"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToolbarContext = exports.LegendContext = exports.AppContextProvider = exports.AppContext = void 0;
var tslib_1 = require("tslib");
/**
 * context.ts
 *
 * This module holds various React component contexts and validation maps
 */
var React = tslib_1.__importStar(require("react"));
var i18n_1 = require("../api/i18n");
var string_1 = require("../utils/string");
var VOID_NOOP = function () { };
exports.AppContext = React.createContext({
    allowHtmlValuesInSelection: function () { return false; },
    getHTMLCleaner: function () { return function (v) { return v; }; },
    getLegendLayerExtraIconsProvider: function () { return []; },
    getLegendGroupExtraIconsProvider: function () { return []; }
});
/**
 * @since 0.14.9
 */
var AppContextProvider = function (_a) {
    var mapguide = _a.mapguide, children = _a.children;
    var providerImpl = React.useMemo(function () { return ({
        allowHtmlValuesInSelection: function () { var _a, _b; return (_b = (_a = mapguide === null || mapguide === void 0 ? void 0 : mapguide.selectionSettings) === null || _a === void 0 ? void 0 : _a.allowHtmlValues) !== null && _b !== void 0 ? _b : false; },
        getHTMLCleaner: function () { var _a, _b; return (_b = (_a = mapguide === null || mapguide === void 0 ? void 0 : mapguide.selectionSettings) === null || _a === void 0 ? void 0 : _a.cleanHtml) !== null && _b !== void 0 ? _b : (function (v) { return v; }); },
        getLegendLayerExtraIconsProvider: function (options) { var _a, _b, _c; return (_c = (_b = (_a = mapguide === null || mapguide === void 0 ? void 0 : mapguide.legendSettings) === null || _a === void 0 ? void 0 : _a.provideExtraLayerIconsHtml) === null || _b === void 0 ? void 0 : _b.call(_a, options)) !== null && _c !== void 0 ? _c : []; },
        getLegendGroupExtraIconsProvider: function (options) { var _a, _b, _c; return (_c = (_b = (_a = mapguide === null || mapguide === void 0 ? void 0 : mapguide.legendSettings) === null || _a === void 0 ? void 0 : _a.provideExtraGroupIconsHtml) === null || _b === void 0 ? void 0 : _b.call(_a, options)) !== null && _c !== void 0 ? _c : []; }
    }); }, [mapguide]);
    return React.createElement(exports.AppContext.Provider, { value: providerImpl }, children);
};
exports.AppContextProvider = AppContextProvider;
exports.LegendContext = React.createContext({
    stateless: false,
    getMapName: function () { return undefined; },
    getSessionId: function () { return undefined; },
    isFiltering: function () { return false; },
    getFilterText: function () { return string_1.STR_EMPTY; },
    getLocale: function () { return i18n_1.DEFAULT_LOCALE; },
    getBaseIconSize: function () { return 0; },
    getIconMimeType: function () { return string_1.STR_EMPTY; },
    getChildren: function () { return []; },
    getCurrentScale: function () { return -1; },
    getTree: VOID_NOOP,
    getLayerVisibility: function () { return false; },
    getGroupVisibility: function () { return false; },
    setGroupVisibility: VOID_NOOP,
    setLayerVisibility: VOID_NOOP,
    getLayerSelectability: function () { return false; },
    setLayerSelectability: function () { return false; },
    getGroupExpanded: function () { return false; },
    setGroupExpanded: VOID_NOOP,
    getLayerExpanded: function () { return false; },
    setLayerExpanded: VOID_NOOP,
    provideExtraGroupIconsHtml: function () { return []; },
    provideExtraLayerIconsHtml: function () { return []; }
});
exports.ToolbarContext = React.createContext({
    openFlyout: VOID_NOOP,
    closeFlyout: VOID_NOOP,
    openComponent: VOID_NOOP,
    closeComponent: VOID_NOOP
});
//# sourceMappingURL=context.js.map