<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">define(["require", "exports", "esri/geometry/support/jsonUtils"], function (require, exports, jsonUtils_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports._searchSourcesValidate = exports._extentSelectorConfigValidate = exports._extentSelectorConfigConvert = exports.parseConfig = void 0;
    /**
     * "Convert" functions handle backwards compatibility for the App Configs by transforming
     * the inputted Config into a form that is equivalent to what the Config
     * Panel would produce right at this moment.
     *
     * "Validate" functions handle turning potentially invalid app item JSON into a valid
     * form, which will not cause the template app to error.
     *
     * *** NOTE:
     * For all "Convert" additions below, please add a comment with the old
     * interface that is being transformed from, and the new interface that
     * is being transformed to
     * ****
     * @param config - App Config
     */
    function parseConfig(config) {
        var _a, _b;
        if ((config === null || config === void 0 ? void 0 : config.extentSelectorConfig) != null) {
            config.extentSelectorConfig = _extentSelectorConfigConvert(config.extentSelectorConfig);
            config.extentSelectorConfig = _extentSelectorConfigValidate(config.extentSelectorConfig);
        }
        if (((_b = (_a = config === null || config === void 0 ? void 0 : config.searchConfiguration) === null || _a === void 0 ? void 0 : _a.sources) === null || _b === void 0 ? void 0 : _b.length) &gt; 0) {
            config.searchConfiguration.sources = _searchSourcesValidate(config.searchConfiguration.sources);
        }
        return config;
    }
    exports.parseConfig = parseConfig;
    var MIN_SCALE_DEFAULT = 591657528;
    var MAX_SCALE_DEFAULT = 100;
    /**
     * // old (extentSelectorConfig === __esri.MapViewConstraints)
     * // =&gt;
     * // new (extentSelectorConfig === IExtentSelectorOutput)
     * @param config
     */
    function _extentSelectorConfigConvert(extentSelectorConfig) {
        if (extentSelectorConfig &amp;&amp; (extentSelectorConfig.geometry != null ||
            extentSelectorConfig.maxScale != null ||
            extentSelectorConfig.minScale != null)) { // old
            return {
                constraints: extentSelectorConfig,
                mapRotation: 0
            };
        }
        else { // new
            return extentSelectorConfig;
        }
    }
    exports._extentSelectorConfigConvert = _extentSelectorConfigConvert;
    function _extentSelectorConfigValidate(extentSelectorConfig) {
        var _a, _b, _c, _d;
        if (extentSelectorConfig) {
            if (typeof extentSelectorConfig === "object" &amp;&amp; ((_a = Object.keys(extentSelectorConfig)) === null || _a === void 0 ? void 0 : _a.length) === 0) {
                return {
                    constraints: {
                        geometry: null,
                        minScale: MIN_SCALE_DEFAULT,
                        maxScale: MAX_SCALE_DEFAULT,
                        rotationEnabled: true
                    },
                    mapRotation: 0
                };
            }
            if (((_b = extentSelectorConfig === null || extentSelectorConfig === void 0 ? void 0 : extentSelectorConfig.constraints) === null || _b === void 0 ? void 0 : _b.geometry) != null) {
                var geom = (0, jsonUtils_1.fromJSON)(extentSelectorConfig.constraints.geometry);
                if ((geom === null || geom === void 0 ? void 0 : geom.type) === "polygon") {
                    extentSelectorConfig.constraints.geometry =
                        geom.rings.length &gt; 0 ?
                            extentSelectorConfig.constraints.geometry :
                            null;
                }
                else if ((geom === null || geom === void 0 ? void 0 : geom.type) === "extent") {
                    extentSelectorConfig.constraints.geometry =
                        geom.width != null &amp;&amp; geom.height != null ?
                            extentSelectorConfig.constraints.geometry :
                            null;
                }
                else {
                    extentSelectorConfig.constraints.geometry = null;
                }
            }
            if ((extentSelectorConfig === null || extentSelectorConfig === void 0 ? void 0 : extentSelectorConfig.constraints) &amp;&amp; ((_c = extentSelectorConfig.constraints) === null || _c === void 0 ? void 0 : _c.minScale) == null) {
                extentSelectorConfig.constraints.minScale = MIN_SCALE_DEFAULT;
            }
            if ((extentSelectorConfig === null || extentSelectorConfig === void 0 ? void 0 : extentSelectorConfig.constraints) &amp;&amp; ((_d = extentSelectorConfig.constraints) === null || _d === void 0 ? void 0 : _d.maxScale) == null) {
                extentSelectorConfig.constraints.maxScale = MAX_SCALE_DEFAULT;
            }
        }
        return extentSelectorConfig;
    }
    exports._extentSelectorConfigValidate = _extentSelectorConfigValidate;
    function _searchSourcesValidate(sources) {
        sources === null || sources === void 0 ? void 0 : sources.forEach(function (source) {
            var _a;
            if (((_a = source === null || source === void 0 ? void 0 : source.locator) === null || _a === void 0 ? void 0 : _a.url) &amp;&amp; !(source === null || source === void 0 ? void 0 : source.url)) {
                source.url = source.locator.url;
            }
        });
        return sources;
    }
    exports._searchSourcesValidate = _searchSourcesValidate;
});
// todo update locally and test 
</pre></body></html>