"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    useCurrentSearchParams: ()=>useCurrentSearchParams,
    useIsInSettingsPage: ()=>useIsInSettingsPage,
    useLocationNoUpdate: ()=>useLocationNoUpdate,
    CurrentTabUidContext: ()=>CurrentTabUidContext,
    useIsSubPageClosedByPageMenu: ()=>useIsSubPageClosedByPageMenu,
    useMatchAdmin: ()=>useMatchAdmin,
    useMatchAdminName: ()=>useMatchAdminName,
    useNavigateNoUpdate: ()=>useNavigateNoUpdate,
    CurrentPageUidContext: ()=>CurrentPageUidContext,
    useCurrentPageUid: ()=>useCurrentPageUid,
    useLocationSearch: ()=>useLocationSearch,
    useRouterBasename: ()=>useRouterBasename,
    LocationSearchContext: ()=>LocationSearchContext,
    IsSubPageClosedByPageMenuProvider: ()=>IsSubPageClosedByPageMenuProvider,
    useIsAdminPage: ()=>useIsAdminPage,
    useCurrentTabUid: ()=>useCurrentTabUid,
    CustomRouterContextProvider: ()=>CustomRouterContextProvider,
    CurrentPageUidProvider: ()=>CurrentPageUidProvider,
    CurrentTabUidProvider: ()=>CurrentTabUidProvider
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
const external_lodash_namespaceObject = require("lodash");
var external_lodash_default = /*#__PURE__*/ __webpack_require__.n(external_lodash_namespaceObject);
const external_react_router_dom_namespaceObject = require("react-router-dom");
const NavigateNoUpdateContext = /*#__PURE__*/ external_react_default().createContext(null);
NavigateNoUpdateContext.displayName = 'NavigateNoUpdateContext';
const LocationNoUpdateContext = /*#__PURE__*/ external_react_default().createContext(null);
LocationNoUpdateContext.displayName = 'LocationNoUpdateContext';
const LocationSearchContext = /*#__PURE__*/ external_react_default().createContext('');
LocationSearchContext.displayName = 'LocationSearchContext';
const IsAdminPageContext = /*#__PURE__*/ external_react_default().createContext(false);
IsAdminPageContext.displayName = 'IsAdminPageContext';
const CurrentPageUidContext = /*#__PURE__*/ external_react_default().createContext('');
CurrentPageUidContext.displayName = 'CurrentPageUidContext';
const MatchAdminContext = /*#__PURE__*/ external_react_default().createContext(false);
MatchAdminContext.displayName = 'MatchAdminContext';
const MatchAdminNameContext = /*#__PURE__*/ external_react_default().createContext(false);
MatchAdminNameContext.displayName = 'MatchAdminNameContext';
const IsInSettingsPageContext = /*#__PURE__*/ external_react_default().createContext(false);
IsInSettingsPageContext.displayName = 'IsInSettingsPageContext';
const CurrentTabUidContext = /*#__PURE__*/ external_react_default().createContext('');
CurrentTabUidContext.displayName = 'CurrentTabUidContext';
const SearchParamsContext = /*#__PURE__*/ external_react_default().createContext(new URLSearchParams());
SearchParamsContext.displayName = 'SearchParamsContext';
const RouterBasenameContext = /*#__PURE__*/ external_react_default().createContext('');
RouterBasenameContext.displayName = 'RouterBasenameContext';
const IsSubPageClosedByPageMenuContext = /*#__PURE__*/ external_react_default().createContext({
    isSubPageClosedByPageMenu: ()=>false,
    setFieldSchema: ()=>{},
    reset: ()=>{}
});
IsSubPageClosedByPageMenuContext.displayName = 'IsSubPageClosedByPageMenuContext';
const IsSubPageClosedByPageMenuProvider = (param)=>{
    let { children } = param;
    const params = (0, external_react_router_dom_namespaceObject.useParams)();
    const prevParamsRef = (0, external_react_namespaceObject.useRef)({});
    const [fieldSchema, setFieldSchema] = (0, external_react_namespaceObject.useState)(null);
    const isSubPageClosedByPageMenu = (0, external_react_namespaceObject.useCallback)(()=>{
        var _fieldSchema_xcomponentprops, _prevParamsRef_current_;
        const result = external_lodash_default().isEmpty(params['*']) && (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.openMode) === 'page' && !!(null === (_prevParamsRef_current_ = prevParamsRef.current['*']) || void 0 === _prevParamsRef_current_ ? void 0 : _prevParamsRef_current_.includes(fieldSchema['x-uid']));
        prevParamsRef.current = params;
        return result;
    }, [
        fieldSchema,
        params
    ]);
    const reset = (0, external_react_namespaceObject.useCallback)(()=>{
        prevParamsRef.current = {};
    }, []);
    const value = (0, external_react_namespaceObject.useMemo)(()=>({
            isSubPageClosedByPageMenu,
            setFieldSchema,
            reset
        }), [
        isSubPageClosedByPageMenu,
        reset
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(IsSubPageClosedByPageMenuContext.Provider, {
        value: value,
        children: children
    });
};
const RouterBasenameProvider = (param)=>{
    let { children } = param;
    const basenameOfCurrentRouter = (0, external_react_router_dom_namespaceObject.useHref)('/');
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RouterBasenameContext.Provider, {
        value: basenameOfCurrentRouter,
        children: children
    });
};
const SearchParamsProvider = (param)=>{
    let { children } = param;
    const [searchParams] = (0, external_react_router_dom_namespaceObject.useSearchParams)();
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SearchParamsContext.Provider, {
        value: searchParams,
        children: children
    });
};
const IsInSettingsPageProvider = (param)=>{
    let { children } = param;
    const isInSettingsPage = (0, external_react_router_dom_namespaceObject.useLocation)().pathname.includes('/settings');
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(IsInSettingsPageContext.Provider, {
        value: isInSettingsPage,
        children: children
    });
};
const MatchAdminProvider = (param)=>{
    let { children } = param;
    const isMatchAdmin = !!(0, external_react_router_dom_namespaceObject.useMatch)('/admin');
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MatchAdminContext.Provider, {
        value: isMatchAdmin,
        children: children
    });
};
const MatchAdminNameProvider = (param)=>{
    let { children } = param;
    const isMatchAdminName = !!(0, external_react_router_dom_namespaceObject.useMatch)('/admin/:name');
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MatchAdminNameContext.Provider, {
        value: isMatchAdminName,
        children: children
    });
};
const IsAdminPageProvider = (param)=>{
    let { children } = param;
    const location = (0, external_react_router_dom_namespaceObject.useLocation)();
    const isAdminPage = location.pathname.startsWith('/admin');
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(IsAdminPageContext.Provider, {
        value: isAdminPage,
        children: children
    });
};
const CurrentPageUidProvider = (param)=>{
    let { children } = param;
    const params = (0, external_react_router_dom_namespaceObject.useParams)();
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CurrentPageUidContext.Provider, {
        value: params.name,
        children: children
    });
};
const CurrentTabUidProvider = (param)=>{
    let { children } = param;
    const params = (0, external_react_router_dom_namespaceObject.useParams)();
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CurrentTabUidContext.Provider, {
        value: params.tabUid,
        children: children
    });
};
const NavigateNoUpdateProvider = (param)=>{
    let { children } = param;
    const navigate = (0, external_react_router_dom_namespaceObject.useNavigate)();
    const navigateRef = external_react_default().useRef(navigate);
    navigateRef.current = navigate;
    const navigateNoUpdate = external_react_default().useCallback((to, options)=>{
        navigateRef.current(to, options);
    }, []);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(NavigateNoUpdateContext.Provider, {
        value: navigateNoUpdate,
        children: children
    });
};
const LocationNoUpdateProvider = (param)=>{
    let { children } = param;
    const location = (0, external_react_router_dom_namespaceObject.useLocation)();
    const locationRef = external_react_default().useRef({});
    (0, external_react_namespaceObject.useEffect)(()=>{
        Object.assign(locationRef.current, location);
    }, [
        location
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LocationNoUpdateContext.Provider, {
        value: locationRef.current,
        children: children
    });
};
const LocationSearchProvider = (param)=>{
    let { children } = param;
    const location = (0, external_react_router_dom_namespaceObject.useLocation)();
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LocationSearchContext.Provider, {
        value: location.search,
        children: children
    });
};
const useNavigateNoUpdate = ()=>external_react_default().useContext(NavigateNoUpdateContext);
const useLocationNoUpdate = ()=>external_react_default().useContext(LocationNoUpdateContext);
const useLocationSearch = ()=>external_react_default().useContext(LocationSearchContext);
const useIsAdminPage = ()=>external_react_default().useContext(IsAdminPageContext);
const useCurrentPageUid = ()=>external_react_default().useContext(CurrentPageUidContext);
const useMatchAdmin = ()=>external_react_default().useContext(MatchAdminContext);
const useMatchAdminName = ()=>external_react_default().useContext(MatchAdminNameContext);
const useIsInSettingsPage = ()=>external_react_default().useContext(IsInSettingsPageContext);
const useCurrentTabUid = ()=>external_react_default().useContext(CurrentTabUidContext);
const useCurrentSearchParams = ()=>external_react_default().useContext(SearchParamsContext);
const useRouterBasename = ()=>external_react_default().useContext(RouterBasenameContext);
const useIsSubPageClosedByPageMenu = (fieldSchema)=>{
    const { isSubPageClosedByPageMenu, setFieldSchema, reset } = external_react_default().useContext(IsSubPageClosedByPageMenuContext);
    (0, external_react_namespaceObject.useEffect)(()=>{
        setFieldSchema(fieldSchema);
    }, [
        fieldSchema,
        setFieldSchema
    ]);
    return {
        isSubPageClosedByPageMenu,
        reset
    };
};
const CustomRouterContextProvider = (param)=>{
    let { children } = param;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(NavigateNoUpdateProvider, {
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LocationNoUpdateProvider, {
            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(IsAdminPageProvider, {
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LocationSearchProvider, {
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MatchAdminProvider, {
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MatchAdminNameProvider, {
                            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SearchParamsProvider, {
                                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(RouterBasenameProvider, {
                                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(IsInSettingsPageProvider, {
                                        children: children
                                    })
                                })
                            })
                        })
                    })
                })
            })
        })
    });
};
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
