@sunrise-upc/sales-static-components 4.1.3 → 4.2.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/FalconMainNavigation/CartOverlay/CartItems/CartItems.js +1 -1
- package/dist/cjs/components/FalconMainNavigation/CartOverlay/CartItems/CartItems.js.map +1 -1
- package/dist/cjs/components/FalconMainNavigation/CartOverlay/CartOverlay.js.map +1 -1
- package/dist/cjs/components/FalconMainNavigation/ProfileLinkOut/ProfileLinkOut.js +1 -1
- package/dist/cjs/components/FalconMainNavigation/ProfileLinkOut/ProfileLinkOut.js.map +1 -1
- package/dist/cjs/node_modules/@algolia/client-common/dist/common.js +1 -1
- package/dist/cjs/node_modules/@algolia/client-common/dist/common.js.map +1 -1
- package/dist/cjs/node_modules/@algolia/requester-browser-xhr/dist/requester.xhr.js +1 -1
- package/dist/cjs/node_modules/@algolia/requester-browser-xhr/dist/requester.xhr.js.map +1 -1
- package/dist/cjs/node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.js +1 -1
- package/dist/cjs/node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.js.map +1 -1
- package/dist/cjs/node_modules/algoliasearch/dist/lite/builds/browser.js +1 -1
- package/dist/cjs/node_modules/algoliasearch/dist/lite/builds/browser.js.map +1 -1
- package/dist/cjs/node_modules/algoliasearch-helper/src/SearchParameters/RefinementList.js.map +1 -1
- package/dist/cjs/node_modules/algoliasearch-helper/src/SearchParameters/index.js.map +1 -1
- package/dist/cjs/node_modules/algoliasearch-helper/src/SearchResults/index.js.map +1 -1
- package/dist/cjs/node_modules/algoliasearch-helper/src/algoliasearch.helper.js +1 -1
- package/dist/cjs/node_modules/algoliasearch-helper/src/algoliasearch.helper.js.map +1 -1
- package/dist/cjs/node_modules/algoliasearch-helper/src/utils/sortAndMergeRecommendations.js.map +1 -1
- package/dist/cjs/node_modules/algoliasearch-helper/src/version.js +1 -1
- package/dist/cjs/node_modules/algoliasearch-helper/src/version.js.map +1 -1
- package/dist/cjs/node_modules/immer/dist/immer.js +1 -1
- package/dist/cjs/node_modules/immer/dist/immer.js.map +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/helpers/insights.js +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/helpers/insights.js.map +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/lib/InstantSearch.js +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/lib/InstantSearch.js.map +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/lib/chat/openChat.js +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/lib/chat/openChat.js.map +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/addInsightsToRecommendParameters.js +2 -0
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/addInsightsToRecommendParameters.js.map +1 -0
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/buildWidgetTree.js +2 -0
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/buildWidgetTree.js.map +1 -0
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/defer.js +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/defer.js.map +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/extractWidgetPayload.js +2 -0
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/extractWidgetPayload.js.map +1 -0
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/getHighlightFromSiblings.js +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/getHighlightFromSiblings.js.map +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/now.js +2 -0
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/now.js.map +1 -0
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/omit.js +2 -0
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/omit.js.map +1 -0
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/render-args.js +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/lib/utils/render-args.js.map +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/lib/version.js +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/lib/version.js.map +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/middlewares/createInsightsMiddleware.js +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/middlewares/createInsightsMiddleware.js.map +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/middlewares/createMetadataMiddleware.js +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/middlewares/createMetadataMiddleware.js.map +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/widgets/index/index.js +1 -1
- package/dist/cjs/node_modules/instantsearch.js/es/widgets/index/index.js.map +1 -1
- package/dist/cjs/node_modules/qs/lib/parse.js +1 -1
- package/dist/cjs/node_modules/qs/lib/parse.js.map +1 -1
- package/dist/cjs/node_modules/qs/lib/stringify.js +1 -1
- package/dist/cjs/node_modules/qs/lib/stringify.js.map +1 -1
- package/dist/cjs/node_modules/qs/lib/utils.js +1 -1
- package/dist/cjs/node_modules/qs/lib/utils.js.map +1 -1
- package/dist/cjs/node_modules/react-instantsearch/dist/es/ui/SearchBox.js +1 -1
- package/dist/cjs/node_modules/react-instantsearch/dist/es/ui/SearchBox.js.map +1 -1
- package/dist/cjs/node_modules/react-instantsearch-core/dist/es/hooks/useConnector.js +1 -1
- package/dist/cjs/node_modules/react-instantsearch-core/dist/es/hooks/useConnector.js.map +1 -1
- package/dist/cjs/node_modules/react-instantsearch-core/dist/es/lib/InstantSearchRSCContext.js +1 -1
- package/dist/cjs/node_modules/react-instantsearch-core/dist/es/lib/InstantSearchRSCContext.js.map +1 -1
- package/dist/cjs/node_modules/react-instantsearch-core/dist/es/lib/useWidget.js +1 -1
- package/dist/cjs/node_modules/react-instantsearch-core/dist/es/lib/useWidget.js.map +1 -1
- package/dist/cjs/node_modules/react-instantsearch-core/dist/es/version.js +1 -1
- package/dist/cjs/node_modules/react-instantsearch-core/dist/es/version.js.map +1 -1
- package/dist/esm/components/FalconMainNavigation/CartOverlay/CartItems/CartItems.js +1 -1
- package/dist/esm/components/FalconMainNavigation/CartOverlay/CartItems/CartItems.js.map +1 -1
- package/dist/esm/components/FalconMainNavigation/CartOverlay/CartOverlay.js.map +1 -1
- package/dist/esm/components/FalconMainNavigation/ProfileLinkOut/ProfileLinkOut.js +1 -1
- package/dist/esm/components/FalconMainNavigation/ProfileLinkOut/ProfileLinkOut.js.map +1 -1
- package/dist/esm/node_modules/@algolia/client-common/dist/common.js +1 -1
- package/dist/esm/node_modules/@algolia/client-common/dist/common.js.map +1 -1
- package/dist/esm/node_modules/@algolia/requester-browser-xhr/dist/requester.xhr.js +1 -1
- package/dist/esm/node_modules/@algolia/requester-browser-xhr/dist/requester.xhr.js.map +1 -1
- package/dist/esm/node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.js +1 -1
- package/dist/esm/node_modules/@reduxjs/toolkit/dist/redux-toolkit.modern.js.map +1 -1
- package/dist/esm/node_modules/algoliasearch/dist/lite/builds/browser.js +1 -1
- package/dist/esm/node_modules/algoliasearch/dist/lite/builds/browser.js.map +1 -1
- package/dist/esm/node_modules/algoliasearch-helper/src/SearchParameters/RefinementList.js.map +1 -1
- package/dist/esm/node_modules/algoliasearch-helper/src/SearchParameters/index.js.map +1 -1
- package/dist/esm/node_modules/algoliasearch-helper/src/SearchResults/index.js.map +1 -1
- package/dist/esm/node_modules/algoliasearch-helper/src/algoliasearch.helper.js +1 -1
- package/dist/esm/node_modules/algoliasearch-helper/src/algoliasearch.helper.js.map +1 -1
- package/dist/esm/node_modules/algoliasearch-helper/src/utils/sortAndMergeRecommendations.js.map +1 -1
- package/dist/esm/node_modules/algoliasearch-helper/src/version.js +1 -1
- package/dist/esm/node_modules/algoliasearch-helper/src/version.js.map +1 -1
- package/dist/esm/node_modules/immer/dist/immer.js +1 -1
- package/dist/esm/node_modules/immer/dist/immer.js.map +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/helpers/insights.js +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/helpers/insights.js.map +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/lib/InstantSearch.js +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/lib/InstantSearch.js.map +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/lib/chat/openChat.js +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/lib/chat/openChat.js.map +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/addInsightsToRecommendParameters.js +2 -0
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/addInsightsToRecommendParameters.js.map +1 -0
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/buildWidgetTree.js +2 -0
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/buildWidgetTree.js.map +1 -0
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/defer.js +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/defer.js.map +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/extractWidgetPayload.js +2 -0
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/extractWidgetPayload.js.map +1 -0
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/getHighlightFromSiblings.js +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/getHighlightFromSiblings.js.map +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/now.js +2 -0
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/now.js.map +1 -0
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/omit.js +2 -0
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/omit.js.map +1 -0
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/render-args.js +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/lib/utils/render-args.js.map +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/lib/version.js +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/lib/version.js.map +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/middlewares/createInsightsMiddleware.js +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/middlewares/createInsightsMiddleware.js.map +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/middlewares/createMetadataMiddleware.js +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/middlewares/createMetadataMiddleware.js.map +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/widgets/index/index.js +1 -1
- package/dist/esm/node_modules/instantsearch.js/es/widgets/index/index.js.map +1 -1
- package/dist/esm/node_modules/qs/lib/parse.js +1 -1
- package/dist/esm/node_modules/qs/lib/parse.js.map +1 -1
- package/dist/esm/node_modules/qs/lib/stringify.js +1 -1
- package/dist/esm/node_modules/qs/lib/stringify.js.map +1 -1
- package/dist/esm/node_modules/qs/lib/utils.js +1 -1
- package/dist/esm/node_modules/qs/lib/utils.js.map +1 -1
- package/dist/esm/node_modules/react-instantsearch/dist/es/ui/SearchBox.js +1 -1
- package/dist/esm/node_modules/react-instantsearch/dist/es/ui/SearchBox.js.map +1 -1
- package/dist/esm/node_modules/react-instantsearch-core/dist/es/hooks/useConnector.js +1 -1
- package/dist/esm/node_modules/react-instantsearch-core/dist/es/hooks/useConnector.js.map +1 -1
- package/dist/esm/node_modules/react-instantsearch-core/dist/es/lib/InstantSearchRSCContext.js +1 -1
- package/dist/esm/node_modules/react-instantsearch-core/dist/es/lib/InstantSearchRSCContext.js.map +1 -1
- package/dist/esm/node_modules/react-instantsearch-core/dist/es/lib/useWidget.js +1 -1
- package/dist/esm/node_modules/react-instantsearch-core/dist/es/lib/useWidget.js.map +1 -1
- package/dist/esm/node_modules/react-instantsearch-core/dist/es/version.js +1 -1
- package/dist/esm/node_modules/react-instantsearch-core/dist/es/version.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/navigation.css +20 -20
- package/package.json +1 -1
package/dist/esm/node_modules/instantsearch.js/es/middlewares/createInsightsMiddleware.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInsightsMiddleware.js","sources":["../../../../../../node_modules/instantsearch.js/es/middlewares/createInsightsMiddleware.js"],"sourcesContent":["import { _ as _$2 } from '@swc/helpers/esm/_object_spread.js';\nimport { _ as _$3 } from '@swc/helpers/esm/_object_spread_props.js';\nimport { _ as _$1 } from '@swc/helpers/esm/_sliced_to_array.js';\nimport { _ } from '@swc/helpers/esm/_to_consumable_array.js';\nimport { createUUID } from '../lib/utils/uuid.js';\nimport { getInsightsAnonymousUserTokenInternal } from '../helpers/get-insights-anonymous-user-token.js';\nimport { safelyRunOnBrowser } from '../lib/utils/safelyRunOnBrowser.js';\nimport { getAppIdAndApiKey } from '../lib/utils/getAppIdAndApiKey.js';\nimport { find } from '../lib/utils/find.js';\nimport { noop } from '../lib/utils/noop.js';\n\nvar ALGOLIA_INSIGHTS_VERSION = '2.17.2';\nvar ALGOLIA_INSIGHTS_SRC = \"https://cdn.jsdelivr.net/npm/search-insights@\".concat(ALGOLIA_INSIGHTS_VERSION, \"/dist/search-insights.min.js\");\nfunction createInsightsMiddleware() {\n var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};\n var _insightsClient = props.insightsClient, insightsInitParams = props.insightsInitParams, onEvent = props.onEvent, _props_$$internal = props.$$internal, $$internal = _props_$$internal === void 0 ? false : _props_$$internal, _props_$$automatic = props.$$automatic, $$automatic = _props_$$automatic === void 0 ? false : _props_$$automatic;\n var potentialInsightsClient = _insightsClient;\n if (!_insightsClient && _insightsClient !== null) {\n safelyRunOnBrowser(function(param) {\n var window = param.window;\n var pointer = window.AlgoliaAnalyticsObject || 'aa';\n if (typeof pointer === 'string') {\n potentialInsightsClient = window[pointer];\n }\n if (!potentialInsightsClient) {\n window.AlgoliaAnalyticsObject = pointer;\n if (!window[pointer]) {\n window[pointer] = function() {\n for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){\n args[_key] = arguments[_key];\n }\n if (!window[pointer].queue) {\n window[pointer].queue = [];\n }\n window[pointer].queue.push(args);\n };\n window[pointer].version = ALGOLIA_INSIGHTS_VERSION;\n window[pointer].shouldAddScript = true;\n }\n potentialInsightsClient = window[pointer];\n }\n });\n }\n // if still no insightsClient was found, we use a noop\n var insightsClient = potentialInsightsClient || noop;\n return function(param) {\n var instantSearchInstance = param.instantSearchInstance;\n var _instantSearchInstance;\n // remove existing default insights middleware\n // user-provided insights middleware takes precedence\n var existingInsightsMiddlewares = instantSearchInstance.middleware.filter(function(m) {\n return m.instance.$$type === 'ais.insights' && m.instance.$$internal;\n }).map(function(m) {\n return m.creator;\n });\n (_instantSearchInstance = instantSearchInstance).unuse.apply(_instantSearchInstance, _(existingInsightsMiddlewares));\n var _getAppIdAndApiKey = _$1(getAppIdAndApiKey(instantSearchInstance.client), 2), appId = _getAppIdAndApiKey[0], apiKey = _getAppIdAndApiKey[1];\n var queuedInitParams = undefined;\n var queuedUserToken = undefined;\n var userTokenBeforeInit = undefined;\n var queue = insightsClient.queue;\n if (Array.isArray(queue)) {\n var ref;\n // Context: The umd build of search-insights is asynchronously loaded by the snippet.\n //\n // When user calls `aa('setUserToken', 'my-user-token')` before `search-insights` is loaded,\n // ['setUserToken', 'my-user-token'] gets stored in `aa.queue`.\n // Whenever `search-insights` is finally loaded, it will process the queue.\n //\n // But here's the reason why we handle it here:\n // At this point, even though `search-insights` is not loaded yet,\n // we still want to read the token from the queue.\n // Otherwise, the first search call will be fired without the token.\n ref = _$1([\n 'setUserToken',\n 'init'\n ].map(function(key) {\n var _ref = _$1(find(queue.slice().reverse(), function(param) {\n var _param = _$1(param, 1), method = _param[0];\n return method === key;\n }) || [], 2), value = _ref[1];\n return value;\n }), 2), queuedUserToken = ref[0], queuedInitParams = ref[1];\n }\n // If user called `aa('setUserToken')` before creating the Insights middleware,\n // we temporarily store the token and set it later on.\n //\n // Otherwise, the `init` call might override them with anonymous user token.\n insightsClient('getUserToken', null, function(_error, userToken) {\n userTokenBeforeInit = normalizeUserToken(userToken);\n });\n // Only `init` if the `insightsInitParams` option is passed or\n // if the `insightsClient` version doesn't supports optional `init` calling.\n if (insightsInitParams || !isModernInsightsClient(insightsClient)) {\n insightsClient('init', _$2({\n appId: appId,\n apiKey: apiKey,\n partial: true\n }, insightsInitParams));\n }\n var initialParameters;\n var helper;\n return {\n $$type: 'ais.insights',\n $$internal: $$internal,\n $$automatic: $$automatic,\n onStateChange: function onStateChange() {},\n subscribe: function subscribe() {\n if (!insightsClient.shouldAddScript) return;\n var errorMessage = '[insights middleware]: could not load search-insights.js. Please load it manually following https://alg.li/insights-init';\n try {\n var script = document.createElement('script');\n script.async = true;\n script.src = ALGOLIA_INSIGHTS_SRC;\n script.onerror = function() {\n instantSearchInstance.emit('error', new Error(errorMessage));\n };\n document.body.appendChild(script);\n insightsClient.shouldAddScript = false;\n } catch (cause) {\n insightsClient.shouldAddScript = false;\n instantSearchInstance.emit('error', new Error(errorMessage));\n }\n },\n started: function started() {\n insightsClient('addAlgoliaAgent', 'insights-middleware');\n helper = instantSearchInstance.mainHelper;\n var queueAtStart = insightsClient.queue;\n if (Array.isArray(queueAtStart)) {\n var ref;\n ref = _$1([\n 'setUserToken',\n 'init'\n ].map(function(key) {\n var _ref = _$1(find(queueAtStart.slice().reverse(), function(param) {\n var _param = _$1(param, 1), method = _param[0];\n return method === key;\n }) || [], 2), value = _ref[1];\n return value;\n }), 2), queuedUserToken = ref[0], queuedInitParams = ref[1];\n }\n initialParameters = getInitialParameters(instantSearchInstance);\n // We don't want to force clickAnalytics when the insights is enabled from the search response.\n // This means we don't enable insights for indices that don't opt in\n if (!$$automatic) {\n helper.overrideStateWithoutTriggeringChangeEvent(_$3(_$2({}, helper.state), {\n clickAnalytics: true\n }));\n }\n if (!$$internal) {\n instantSearchInstance.scheduleSearch();\n }\n var setUserTokenToSearch = function setUserTokenToSearch(userToken) {\n var immediate = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;\n var normalizedUserToken = normalizeUserToken(userToken);\n if (!normalizedUserToken) {\n return;\n }\n var existingToken = helper.state.userToken;\n function applyToken() {\n helper.overrideStateWithoutTriggeringChangeEvent(_$3(_$2({}, helper.state), {\n userToken: normalizedUserToken\n }));\n if (existingToken && existingToken !== userToken) {\n instantSearchInstance.scheduleSearch();\n }\n }\n // Delay the token application to the next render cycle\n if (!immediate) {\n setTimeout(applyToken, 0);\n } else {\n applyToken();\n }\n };\n function setUserToken(token) {\n setUserTokenToSearch(token, true);\n insightsClient('setUserToken', token);\n }\n var anonymousUserToken = undefined;\n var anonymousTokenFromInsights = getInsightsAnonymousUserTokenInternal();\n if (anonymousTokenFromInsights) {\n // When `aa('init', { ... })` is called, it creates an anonymous user token in cookie.\n // We can set it as userToken on instantsearch and insights. If it's not set as an insights\n // userToken before a sendEvent, insights automatically generates a new anonymous token,\n // causing a state change and an unnecessary query on instantsearch.\n anonymousUserToken = anonymousTokenFromInsights;\n } else {\n var token = \"anonymous-\".concat(createUUID());\n anonymousUserToken = token;\n }\n var userTokenFromInit;\n // With SSR, the token could be be set on the state. We make sure\n // that insights is in sync with that token since, there is no\n // insights lib on the server.\n var tokenFromSearchParameters = initialParameters.userToken;\n // When the first query is sent, the token is possibly not yet set by\n // the insights onChange callbacks (if insights isn't yet loaded).\n // It is explicitly being set here so that the first query has the\n // initial tokens set and ensure a second query isn't automatically\n // made when the onChange callback actually changes the state.\n if (insightsInitParams === null || insightsInitParams === void 0 ? void 0 : insightsInitParams.userToken) {\n userTokenFromInit = insightsInitParams.userToken;\n }\n if (userTokenFromInit) {\n setUserToken(userTokenFromInit);\n } else if (tokenFromSearchParameters) {\n setUserToken(tokenFromSearchParameters);\n } else if (userTokenBeforeInit) {\n setUserToken(userTokenBeforeInit);\n } else if (queuedUserToken) {\n setUserToken(queuedUserToken);\n } else if (anonymousUserToken) {\n setUserToken(anonymousUserToken);\n if ((insightsInitParams === null || insightsInitParams === void 0 ? void 0 : insightsInitParams.useCookie) || (queuedInitParams === null || queuedInitParams === void 0 ? void 0 : queuedInitParams.useCookie)) {\n saveTokenAsCookie(anonymousUserToken, (insightsInitParams === null || insightsInitParams === void 0 ? void 0 : insightsInitParams.cookieDuration) || (queuedInitParams === null || queuedInitParams === void 0 ? void 0 : queuedInitParams.cookieDuration));\n }\n }\n // This updates userToken which is set explicitly by `aa('setUserToken', userToken)`\n insightsClient('onUserTokenChange', function(token) {\n return setUserTokenToSearch(token, true);\n }, {\n immediate: true\n });\n var insightsClientWithLocalCredentials = insightsClient;\n if (isModernInsightsClient(insightsClient)) {\n insightsClientWithLocalCredentials = function insightsClientWithLocalCredentials(method, payload) {\n var _getAppIdAndApiKey = _$1(getAppIdAndApiKey(instantSearchInstance.client), 2), latestAppId = _getAppIdAndApiKey[0], latestApiKey = _getAppIdAndApiKey[1];\n var extraParams = {\n headers: {\n 'X-Algolia-Application-Id': latestAppId,\n 'X-Algolia-API-Key': latestApiKey\n }\n };\n // @ts-ignore we are calling this only when we know that the client actually is correct\n return insightsClient(method, payload, extraParams);\n };\n }\n var viewedObjectIDs = new Set();\n var lastQueryId;\n instantSearchInstance.mainHelper.derivedHelpers[0].on('result', function(param) {\n var results = param.results;\n if (results && (!results.queryID || results.queryID !== lastQueryId)) {\n lastQueryId = results.queryID;\n viewedObjectIDs.clear();\n }\n });\n instantSearchInstance.sendEventToInsights = function(event) {\n if (onEvent) {\n onEvent(event, insightsClientWithLocalCredentials);\n } else if (event.insightsMethod) {\n if (event.insightsMethod === 'viewedObjectIDs') {\n var payload = event.payload;\n var difference = payload.objectIDs.filter(function(objectID) {\n return !viewedObjectIDs.has(objectID);\n });\n if (difference.length === 0) {\n return;\n }\n difference.forEach(function(objectID) {\n return viewedObjectIDs.add(objectID);\n });\n payload.objectIDs = difference;\n }\n // Source is used to differentiate events sent by instantsearch from those sent manually.\n event.payload.algoliaSource = [\n 'instantsearch'\n ];\n if ($$automatic) {\n event.payload.algoliaSource.push('instantsearch-automatic');\n }\n if (event.eventModifier === 'internal') {\n event.payload.algoliaSource.push('instantsearch-internal');\n }\n insightsClientWithLocalCredentials(event.insightsMethod, event.payload);\n } else ;\n };\n },\n unsubscribe: function unsubscribe() {\n insightsClient('onUserTokenChange', undefined);\n instantSearchInstance.sendEventToInsights = noop;\n if (helper && initialParameters) {\n helper.overrideStateWithoutTriggeringChangeEvent(_$2({}, helper.state, initialParameters));\n instantSearchInstance.scheduleSearch();\n }\n }\n };\n };\n}\nfunction getInitialParameters(instantSearchInstance) {\n var _instantSearchInstance__initialResults_instantSearchInstance_indexName, _instantSearchInstance__initialResults;\n // in SSR, the initial state we use in this domain is set on the main index\n var stateFromInitialResults = ((_instantSearchInstance__initialResults = instantSearchInstance._initialResults) === null || _instantSearchInstance__initialResults === void 0 ? void 0 : (_instantSearchInstance__initialResults_instantSearchInstance_indexName = _instantSearchInstance__initialResults[instantSearchInstance.indexName]) === null || _instantSearchInstance__initialResults_instantSearchInstance_indexName === void 0 ? void 0 : _instantSearchInstance__initialResults_instantSearchInstance_indexName.state) || {};\n var stateFromHelper = instantSearchInstance.mainHelper.state;\n return {\n userToken: stateFromInitialResults.userToken || stateFromHelper.userToken,\n clickAnalytics: stateFromInitialResults.clickAnalytics || stateFromHelper.clickAnalytics\n };\n}\nfunction saveTokenAsCookie(token, cookieDuration) {\n var MONTH = 30 * 24 * 60 * 60 * 1000;\n var d = new Date();\n d.setTime(d.getTime() + (cookieDuration || MONTH * 6));\n var expires = \"expires=\".concat(d.toUTCString());\n document.cookie = \"_ALGOLIA=\".concat(token, \";\").concat(expires, \";path=/\");\n}\n/**\n * Determines if a given insights `client` supports the optional call to `init`\n * and the ability to set credentials via extra parameters when sending events.\n */ function isModernInsightsClient(client) {\n var _split_map = _$1((client.version || '').split('.').map(Number), 2), major = _split_map[0], minor = _split_map[1];\n /* eslint-disable instantsearch/naming-convention */ var v3 = major >= 3;\n var v2_6 = major === 2 && minor >= 6;\n var v1_10 = major === 1 && minor >= 10;\n /* eslint-enable instantsearch/naming-convention */ return v3 || v2_6 || v1_10;\n}\n/**\n * While `search-insights` supports both string and number user tokens,\n * the Search API only accepts strings. This function normalizes the user token.\n */ function normalizeUserToken(userToken) {\n if (!userToken) {\n return undefined;\n }\n return typeof userToken === 'number' ? userToken.toString() : userToken;\n}\n\nexport { createInsightsMiddleware };\n"],"names":["ALGOLIA_INSIGHTS_VERSION","ALGOLIA_INSIGHTS_SRC","concat","createInsightsMiddleware","props","arguments","length","_insightsClient","insightsClient","insightsInitParams","onEvent","_props_$$internal","$$internal","_props_$$automatic","$$automatic","potentialInsightsClient","safelyRunOnBrowser","param","window","pointer","AlgoliaAnalyticsObject","_len","args","Array","_key","queue","push","version","shouldAddScript","noop","_instantSearchInstance","instantSearchInstance","existingInsightsMiddlewares","middleware","filter","m","instance","$$type","map","creator","unuse","apply","_","ref","initialParameters","helper","_getAppIdAndApiKey","_$1","getAppIdAndApiKey","client","appId","apiKey","queuedInitParams","undefined","queuedUserToken","userTokenBeforeInit","isArray","key","_ref","find","slice","reverse","_error","userToken","normalizeUserToken","isModernInsightsClient","_$2","partial","onStateChange","subscribe","errorMessage","script","document","createElement","async","src","onerror","emit","Error","body","appendChild","cause","started","mainHelper","queueAtStart","_instantSearchInstance__initialResults_instantSearchInstance_indexName","_instantSearchInstance__initialResults","stateFromInitialResults","_initialResults","indexName","state","stateFromHelper","clickAnalytics","getInitialParameters","overrideStateWithoutTriggeringChangeEvent","_$3","scheduleSearch","setUserTokenToSearch","immediate","normalizedUserToken","existingToken","applyToken","setTimeout","setUserToken","token","userTokenFromInit","anonymousUserToken","anonymousTokenFromInsights","getInsightsAnonymousUserTokenInternal","createUUID","tokenFromSearchParameters","useCookie","cookieDuration","MONTH","d","Date","setTime","getTime","expires","toUTCString","cookie","saveTokenAsCookie","insightsClientWithLocalCredentials","method","payload","latestAppId","latestApiKey","headers","lastQueryId","viewedObjectIDs","Set","derivedHelpers","on","results","queryID","clear","sendEventToInsights","event","insightsMethod","difference","objectIDs","objectID","has","forEach","add","algoliaSource","eventModifier","unsubscribe","_split_map","split","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,GAAIe,EAAMC,eAAgB,CAC7B,GAA6B,oBAAzBD,EAAMC,eAAsC,CAC5C,IAAId,EAAUa,EAAMb,QAChBe,EAAaf,EAAQgB,UAAU1G,OAAO,SAAS2G,GAC/C,OAAQZ,EAAgBa,IAAID,EAChC,GACA,GAA0B,IAAtBF,EAAWrI,OACX,OAEJqI,EAAWI,QAAQ,SAASF,GACxB,OAAOZ,EAAgBe,IAAIH,EAC/B,GACAjB,EAAQgB,UAAYD,CACxB,CAEAF,EAAMb,QAAQqB,cAAgB,CAC1B,iBAEAnI,GACA2H,EAAMb,QAAQqB,cAAcvH,KAAK,2BAET,aAAxB+G,EAAMS,eACNT,EAAMb,QAAQqB,cAAcvH,KAAK,0BAErCgG,EAAmCe,EAAMC,eAAgBD,EAAMb,QACnE,CACJ,CACJ,EACAuB,YAAa,WACT3I,EAAe,yBAAqB6C,GACpCtB,EAAsByG,oBAAsB3G,EACxCgB,GAAUD,IACVC,EAAOiD,0CAA0C5B,EAAI,CAAA,EAAIrB,EAAO6C,MAAO9C,IACvEb,EAAsBiE,iBAE9B,EAER,CACJ,CAqBI,SAAS/B,EAAuBhB,GAChC,IAAImG,EAAarG,GAAKE,EAAOtB,SAAW,IAAI0H,MAAM,KAAK/G,IAAIgH,QAAS,GAAIC,EAAQH,EAAW,GAAII,EAAQJ,EAAW,GAI9D,OAHUG,GAAS,GAClD,IAAVA,GAAeC,GAAS,GACb,IAAVD,GAAeC,GAAS,EAExC,CAII,SAASxF,EAAmBD,GAC5B,GAAKA,EAGL,MAA4B,iBAAdA,EAAyBA,EAAU0F,WAAa1F,CAClE","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"createInsightsMiddleware.js","sources":["../../../../../../node_modules/instantsearch.js/es/middlewares/createInsightsMiddleware.js"],"sourcesContent":["import { _ as _$2 } from '@swc/helpers/esm/_object_spread.js';\nimport { _ as _$3 } from '@swc/helpers/esm/_object_spread_props.js';\nimport { _ as _$1 } from '@swc/helpers/esm/_sliced_to_array.js';\nimport { _ } from '@swc/helpers/esm/_to_consumable_array.js';\nimport { createUUID } from '../lib/utils/uuid.js';\nimport version from '../lib/version.js';\nimport { getInsightsAnonymousUserTokenInternal } from '../helpers/get-insights-anonymous-user-token.js';\nimport { getUsageSessionId } from '../helpers/insights.js';\nimport { now } from '../lib/utils/now.js';\nimport { serializeWidgetParams, buildWidgetTree } from '../lib/utils/buildWidgetTree.js';\nimport { omit } from '../lib/utils/omit.js';\nimport { safelyRunOnBrowser } from '../lib/utils/safelyRunOnBrowser.js';\nimport { getAppIdAndApiKey } from '../lib/utils/getAppIdAndApiKey.js';\nimport { find } from '../lib/utils/find.js';\nimport { noop } from '../lib/utils/noop.js';\nimport { getAlgoliaAgent } from '../lib/utils/getAlgoliaAgent.js';\n\nvar ALGOLIA_INSIGHTS_VERSION = '2.17.2';\nvar ALGOLIA_INSIGHTS_SRC = \"https://cdn.jsdelivr.net/npm/search-insights@\".concat(ALGOLIA_INSIGHTS_VERSION, \"/dist/search-insights.min.js\");\n// InstantSearch options that must never be sent in usage events because\n// they carry credentials or end-user data. Everything else is reported as-is.\nvar SENSITIVE_OPTIONS = [\n 'searchClient',\n 'insightsClient',\n 'initialUiState'\n];\nfunction createInsightsMiddleware() {\n var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};\n var _insightsClient = props.insightsClient, insightsInitParams = props.insightsInitParams, onEvent = props.onEvent, _props_$$internal = props.$$internal, $$internal = _props_$$internal === void 0 ? false : _props_$$internal, _props_$$automatic = props.$$automatic, $$automatic = _props_$$automatic === void 0 ? false : _props_$$automatic;\n var potentialInsightsClient = _insightsClient;\n if (!_insightsClient && _insightsClient !== null) {\n safelyRunOnBrowser(function(param) {\n var window = param.window;\n var pointer = window.AlgoliaAnalyticsObject || 'aa';\n if (typeof pointer === 'string') {\n potentialInsightsClient = window[pointer];\n }\n if (!potentialInsightsClient) {\n window.AlgoliaAnalyticsObject = pointer;\n if (!window[pointer]) {\n window[pointer] = function() {\n for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){\n args[_key] = arguments[_key];\n }\n if (!window[pointer].queue) {\n window[pointer].queue = [];\n }\n window[pointer].queue.push(args);\n };\n window[pointer].version = ALGOLIA_INSIGHTS_VERSION;\n window[pointer].shouldAddScript = true;\n }\n potentialInsightsClient = window[pointer];\n }\n });\n }\n // if still no insightsClient was found, we use a noop\n var insightsClient = potentialInsightsClient || noop;\n return function(param) {\n var instantSearchInstance = param.instantSearchInstance;\n var _instantSearchInstance;\n // remove existing default insights middleware\n // user-provided insights middleware takes precedence\n var existingInsightsMiddlewares = instantSearchInstance.middleware.filter(function(m) {\n return m.instance.$$type === 'ais.insights' && m.instance.$$internal;\n }).map(function(m) {\n return m.creator;\n });\n (_instantSearchInstance = instantSearchInstance).unuse.apply(_instantSearchInstance, _(existingInsightsMiddlewares));\n var _getAppIdAndApiKey = _$1(getAppIdAndApiKey(instantSearchInstance.client), 2), appId = _getAppIdAndApiKey[0], apiKey = _getAppIdAndApiKey[1];\n var queuedInitParams = undefined;\n var queuedUserToken = undefined;\n var userTokenBeforeInit = undefined;\n var queue = insightsClient.queue;\n if (Array.isArray(queue)) {\n var ref;\n // Context: The umd build of search-insights is asynchronously loaded by the snippet.\n //\n // When user calls `aa('setUserToken', 'my-user-token')` before `search-insights` is loaded,\n // ['setUserToken', 'my-user-token'] gets stored in `aa.queue`.\n // Whenever `search-insights` is finally loaded, it will process the queue.\n //\n // But here's the reason why we handle it here:\n // At this point, even though `search-insights` is not loaded yet,\n // we still want to read the token from the queue.\n // Otherwise, the first search call will be fired without the token.\n ref = _$1([\n 'setUserToken',\n 'init'\n ].map(function(key) {\n var _ref = _$1(find(queue.slice().reverse(), function(param) {\n var _param = _$1(param, 1), method = _param[0];\n return method === key;\n }) || [], 2), value = _ref[1];\n return value;\n }), 2), queuedUserToken = ref[0], queuedInitParams = ref[1];\n }\n // If user called `aa('setUserToken')` before creating the Insights middleware,\n // we temporarily store the token and set it later on.\n //\n // Otherwise, the `init` call might override them with anonymous user token.\n insightsClient('getUserToken', null, function(_error, userToken) {\n userTokenBeforeInit = normalizeUserToken(userToken);\n });\n // Only `init` if the `insightsInitParams` option is passed or\n // if the `insightsClient` version doesn't supports optional `init` calling.\n if (insightsInitParams || !isModernInsightsClient(insightsClient)) {\n insightsClient('init', _$2({\n appId: appId,\n apiKey: apiKey,\n partial: true\n }, insightsInitParams));\n }\n var initialParameters;\n var helper;\n var removeStartEventListener = null;\n return {\n $$type: 'ais.insights',\n $$internal: $$internal,\n $$automatic: $$automatic,\n onStateChange: function onStateChange() {},\n subscribe: function subscribe() {\n if (!insightsClient.shouldAddScript) return;\n var errorMessage = '[insights middleware]: could not load search-insights.js. Please load it manually following https://alg.li/insights-init';\n try {\n var script = document.createElement('script');\n script.async = true;\n script.src = ALGOLIA_INSIGHTS_SRC;\n script.onerror = function() {\n instantSearchInstance.emit('error', new Error(errorMessage));\n };\n document.body.appendChild(script);\n insightsClient.shouldAddScript = false;\n } catch (cause) {\n insightsClient.shouldAddScript = false;\n instantSearchInstance.emit('error', new Error(errorMessage));\n }\n },\n started: function started() {\n insightsClient('addAlgoliaAgent', 'insights-middleware');\n helper = instantSearchInstance.mainHelper;\n var queueAtStart = insightsClient.queue;\n if (Array.isArray(queueAtStart)) {\n var ref;\n ref = _$1([\n 'setUserToken',\n 'init'\n ].map(function(key) {\n var _ref = _$1(find(queueAtStart.slice().reverse(), function(param) {\n var _param = _$1(param, 1), method = _param[0];\n return method === key;\n }) || [], 2), value = _ref[1];\n return value;\n }), 2), queuedUserToken = ref[0], queuedInitParams = ref[1];\n }\n initialParameters = getInitialParameters(instantSearchInstance);\n // We don't want to force clickAnalytics when the insights is enabled from the search response.\n // This means we don't enable insights for indices that don't opt in\n if (!$$automatic) {\n helper.overrideStateWithoutTriggeringChangeEvent(_$3(_$2({}, helper.state), {\n clickAnalytics: true\n }));\n }\n if (!$$internal) {\n instantSearchInstance.scheduleSearch();\n }\n var setUserTokenToSearch = function setUserTokenToSearch(userToken) {\n var immediate = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;\n var normalizedUserToken = normalizeUserToken(userToken);\n if (!normalizedUserToken) {\n return;\n }\n var existingToken = helper.state.userToken;\n function applyToken() {\n helper.overrideStateWithoutTriggeringChangeEvent(_$3(_$2({}, helper.state), {\n userToken: normalizedUserToken\n }));\n if (existingToken && existingToken !== normalizedUserToken) {\n helper._recommendCache = {};\n instantSearchInstance.scheduleSearch();\n }\n }\n // Delay the token application to the next render cycle\n if (!immediate) {\n setTimeout(applyToken, 0);\n } else {\n applyToken();\n }\n };\n function setUserToken(token) {\n setUserTokenToSearch(token, true);\n insightsClient('setUserToken', token);\n }\n var anonymousUserToken = undefined;\n var anonymousTokenFromInsights = getInsightsAnonymousUserTokenInternal();\n if (anonymousTokenFromInsights) {\n // When `aa('init', { ... })` is called, it creates an anonymous user token in cookie.\n // We can set it as userToken on instantsearch and insights. If it's not set as an insights\n // userToken before a sendEvent, insights automatically generates a new anonymous token,\n // causing a state change and an unnecessary query on instantsearch.\n anonymousUserToken = anonymousTokenFromInsights;\n } else {\n var token = \"anonymous-\".concat(createUUID());\n anonymousUserToken = token;\n }\n var userTokenFromInit;\n // With SSR, the token could be be set on the state. We make sure\n // that insights is in sync with that token since, there is no\n // insights lib on the server.\n var tokenFromSearchParameters = initialParameters.userToken;\n // When the first query is sent, the token is possibly not yet set by\n // the insights onChange callbacks (if insights isn't yet loaded).\n // It is explicitly being set here so that the first query has the\n // initial tokens set and ensure a second query isn't automatically\n // made when the onChange callback actually changes the state.\n if (insightsInitParams === null || insightsInitParams === void 0 ? void 0 : insightsInitParams.userToken) {\n userTokenFromInit = insightsInitParams.userToken;\n }\n if (userTokenFromInit) {\n setUserToken(userTokenFromInit);\n } else if (tokenFromSearchParameters) {\n setUserToken(tokenFromSearchParameters);\n } else if (userTokenBeforeInit) {\n setUserToken(userTokenBeforeInit);\n } else if (queuedUserToken) {\n setUserToken(queuedUserToken);\n } else if (anonymousUserToken) {\n setUserToken(anonymousUserToken);\n if ((insightsInitParams === null || insightsInitParams === void 0 ? void 0 : insightsInitParams.useCookie) || (queuedInitParams === null || queuedInitParams === void 0 ? void 0 : queuedInitParams.useCookie)) {\n saveTokenAsCookie(anonymousUserToken, (insightsInitParams === null || insightsInitParams === void 0 ? void 0 : insightsInitParams.cookieDuration) || (queuedInitParams === null || queuedInitParams === void 0 ? void 0 : queuedInitParams.cookieDuration));\n }\n }\n // This updates userToken which is set explicitly by `aa('setUserToken', userToken)`\n insightsClient('onUserTokenChange', function(token) {\n return setUserTokenToSearch(token, true);\n }, {\n immediate: true\n });\n var insightsClientWithLocalCredentials = insightsClient;\n if (isModernInsightsClient(insightsClient)) {\n insightsClientWithLocalCredentials = function insightsClientWithLocalCredentials(method, payload) {\n var _getAppIdAndApiKey = _$1(getAppIdAndApiKey(instantSearchInstance.client), 2), latestAppId = _getAppIdAndApiKey[0], latestApiKey = _getAppIdAndApiKey[1];\n var extraParams = {\n headers: {\n 'X-Algolia-Application-Id': latestAppId,\n 'X-Algolia-API-Key': latestApiKey\n }\n };\n // @ts-ignore we are calling this only when we know that the client actually is correct\n return insightsClient(method, payload, extraParams);\n };\n }\n var viewedObjectIDs = new Set();\n var lastQueryId;\n instantSearchInstance.mainHelper.derivedHelpers[0].on('result', function(param) {\n var results = param.results;\n if (results && (!results.queryID || results.queryID !== lastQueryId)) {\n lastQueryId = results.queryID;\n viewedObjectIDs.clear();\n }\n });\n instantSearchInstance.sendEventToInsights = function(event) {\n if (onEvent) {\n onEvent(event, insightsClientWithLocalCredentials);\n } else if (event.insightsMethod) {\n if (event.insightsMethod === 'viewedObjectIDs') {\n var payload = event.payload;\n var getViewEventKey = function getViewEventKey(objectID) {\n return payload.queryID ? \"\".concat(payload.queryID, \":\").concat(objectID) : objectID;\n };\n var difference = payload.objectIDs.filter(function(objectID) {\n return !viewedObjectIDs.has(getViewEventKey(objectID));\n });\n if (difference.length === 0) {\n return;\n }\n difference.forEach(function(objectID) {\n return viewedObjectIDs.add(getViewEventKey(objectID));\n });\n payload.objectIDs = difference;\n }\n // Source is used to differentiate events sent by instantsearch from those sent manually.\n event.payload.algoliaSource = [\n 'instantsearch'\n ];\n if ($$automatic) {\n event.payload.algoliaSource.push('instantsearch-automatic');\n }\n if (event.eventModifier === 'internal') {\n event.payload.algoliaSource.push('instantsearch-internal');\n }\n insightsClientWithLocalCredentials(event.insightsMethod, event.payload);\n } else ;\n };\n // usage tracking (browser-only)\n safelyRunOnBrowser(function() {\n var usageSessionId = getUsageSessionId();\n function sendUsageEvent(event) {\n var _helper_state;\n var userToken = (_helper_state = helper.state) === null || _helper_state === void 0 ? void 0 : _helper_state.userToken;\n insightsClientWithLocalCredentials('sendEvents', [\n _$2({\n eventType: 'instantsearch',\n timestamp: Date.now(),\n sessionID: usageSessionId,\n userToken: userToken ? String(userToken) : undefined\n }, event)\n ]);\n }\n // Send the start event on the first `render`, by which point every\n // flavor has registered its widgets. `bootstrapMs` then measures the\n // time between the constructor running and that point, so for flavors\n // that register widgets right at start (e.g. React) it captures the\n // cost of adding them.\n var sendStartEvent = function sendStartEvent() {\n try {\n var bootstrapMs = Math.round(now() - instantSearchInstance._createdAt);\n sendUsageEvent({\n eventName: '__start__',\n algoliaAgent: getAlgoliaAgent(instantSearchInstance.client),\n version: version,\n applicationId: appId,\n performance: {\n bootstrapMs: bootstrapMs\n },\n widgets: [\n {\n type: 'ais.instantSearch',\n // The options the instance was created with, serialized the\n // same way every widget's params are. Derived dynamically from\n // `_initialOptions` so new options are reported automatically,\n // minus the keys that carry credentials or user data. Functions\n // (`onStateChange`, `searchFunction`) report their `fn.name`\n // when present, tagged `type: 'function'`.\n params: instantSearchInstance._initialOptions ? serializeWidgetParams(omit(instantSearchInstance._initialOptions, _(SENSITIVE_OPTIONS))) : [],\n children: buildWidgetTree(instantSearchInstance.mainIndex.getWidgets(), instantSearchInstance)\n }\n ]\n });\n } catch (unused) {\n // usage tracking must never crash the host app\n }\n };\n instantSearchInstance.once('render', sendStartEvent);\n removeStartEventListener = function removeStartEventListener() {\n return instantSearchInstance.removeListener('render', sendStartEvent);\n };\n });\n },\n unsubscribe: function unsubscribe() {\n if (removeStartEventListener) {\n removeStartEventListener();\n }\n insightsClient('onUserTokenChange', undefined);\n instantSearchInstance.sendEventToInsights = noop;\n if (helper && initialParameters) {\n helper.overrideStateWithoutTriggeringChangeEvent(_$2({}, helper.state, initialParameters));\n instantSearchInstance.scheduleSearch();\n }\n }\n };\n };\n}\nfunction getInitialParameters(instantSearchInstance) {\n var _instantSearchInstance__initialResults_instantSearchInstance_indexName, _instantSearchInstance__initialResults;\n // in SSR, the initial state we use in this domain is set on the main index\n var stateFromInitialResults = ((_instantSearchInstance__initialResults = instantSearchInstance._initialResults) === null || _instantSearchInstance__initialResults === void 0 ? void 0 : (_instantSearchInstance__initialResults_instantSearchInstance_indexName = _instantSearchInstance__initialResults[instantSearchInstance.indexName]) === null || _instantSearchInstance__initialResults_instantSearchInstance_indexName === void 0 ? void 0 : _instantSearchInstance__initialResults_instantSearchInstance_indexName.state) || {};\n var stateFromHelper = instantSearchInstance.mainHelper.state;\n return {\n userToken: stateFromInitialResults.userToken || stateFromHelper.userToken,\n clickAnalytics: stateFromInitialResults.clickAnalytics || stateFromHelper.clickAnalytics\n };\n}\nfunction saveTokenAsCookie(token, cookieDuration) {\n var MONTH = 30 * 24 * 60 * 60 * 1000;\n var d = new Date();\n d.setTime(d.getTime() + (cookieDuration || MONTH * 6));\n var expires = \"expires=\".concat(d.toUTCString());\n document.cookie = \"_ALGOLIA=\".concat(token, \";\").concat(expires, \";path=/\");\n}\n/**\n * Determines if a given insights `client` supports the optional call to `init`\n * and the ability to set credentials via extra parameters when sending events.\n */ function isModernInsightsClient(client) {\n var _split_map = _$1((client.version || '').split('.').map(Number), 2), major = _split_map[0], minor = _split_map[1];\n /* oxlint-disable instantsearch/naming-convention */ var v3 = major >= 3;\n var v2_6 = major === 2 && minor >= 6;\n var v1_10 = major === 1 && minor >= 10;\n /* oxlint-enable instantsearch/naming-convention */ return v3 || v2_6 || v1_10;\n}\n/**\n * While `search-insights` supports both string and number user tokens,\n * the Search API only accepts strings. This function normalizes the user token.\n */ function normalizeUserToken(userToken) {\n if (!userToken) {\n return undefined;\n }\n return typeof userToken === 'number' ? userToken.toString() : userToken;\n}\n\nexport { createInsightsMiddleware };\n"],"names":["ALGOLIA_INSIGHTS_VERSION","ALGOLIA_INSIGHTS_SRC","concat","SENSITIVE_OPTIONS","createInsightsMiddleware","props","arguments","length","_insightsClient","insightsClient","insightsInitParams","onEvent","_props_$$internal","$$internal","_props_$$automatic","$$automatic","potentialInsightsClient","safelyRunOnBrowser","param","window","pointer","AlgoliaAnalyticsObject","_len","args","Array","_key","queue","push","version","shouldAddScript","noop","_instantSearchInstance","instantSearchInstance","existingInsightsMiddlewares","middleware","filter","m","instance","$$type","map","creator","unuse","apply","_","ref","initialParameters","helper","_getAppIdAndApiKey","_$1","getAppIdAndApiKey","client","appId","apiKey","queuedInitParams","undefined","queuedUserToken","userTokenBeforeInit","isArray","key","_ref","find","slice","reverse","_error","userToken","normalizeUserToken","isModernInsightsClient","_$2","partial","removeStartEventListener","onStateChange","subscribe","errorMessage","script","document","createElement","async","src","onerror","emit","Error","body","appendChild","cause","started","mainHelper","queueAtStart","_instantSearchInstance__initialResults_instantSearchInstance_indexName","_instantSearchInstance__initialResults","stateFromInitialResults","_initialResults","indexName","state","stateFromHelper","clickAnalytics","getInitialParameters","overrideStateWithoutTriggeringChangeEvent","_$3","scheduleSearch","setUserTokenToSearch","immediate","normalizedUserToken","existingToken","applyToken","setTimeout","_recommendCache","setUserToken","token","userTokenFromInit","anonymousUserToken","anonymousTokenFromInsights","getInsightsAnonymousUserTokenInternal","createUUID","tokenFromSearchParameters","useCookie","cookieDuration","MONTH","d","Date","setTime","getTime","expires","toUTCString","cookie","saveTokenAsCookie","insightsClientWithLocalCredentials","method","payload","latestAppId","latestApiKey","headers","lastQueryId","viewedObjectIDs","Set","derivedHelpers","on","results","queryID","clear","sendEventToInsights","event","insightsMethod","getViewEventKey","objectID","difference","objectIDs","has","forEach","add","algoliaSource","eventModifier","usageSessionId","getUsageSessionId","sendStartEvent","bootstrapMs","Math","round","now","_createdAt","eventName","algoliaAgent","getAlgoliaAgent","applicationId","performance","widgets","type","params","_initialOptions","serializeWidgetParams","omit","children","buildWidgetTree","mainIndex","getWidgets","_helper_state","eventType","timestamp","sessionID","String","unused","once","removeListener","unsubscribe","_split_map","split","Number","major","minor","toString"],"mappings":"+9BAiBA,IAAIA,EAA2B,SAC3BC,EAAuB,gDAAgDC,OAAOF,EAA0B,gCAGxGG,EAAoB,CACpB,eACA,iBACA,kBAEJ,SAASC,IACL,IAAIC,EAAQC,UAAUC,OAAS,QAAsB,IAAjBD,UAAU,GAAgBA,UAAU,GAAK,CAAA,EACzEE,EAAkBH,EAAMI,eAAgBC,EAAqBL,EAAMK,mBAAoBC,EAAUN,EAAMM,QAASC,EAAoBP,EAAMQ,WAAYA,OAAmC,IAAtBD,GAAuCA,EAAmBE,EAAqBT,EAAMU,YAAaA,OAAqC,IAAvBD,GAAwCA,EAC3TE,EAA0BR,EACzBA,GAAuC,OAApBA,GACpBS,EAAmB,SAASC,GACxB,IAAIC,EAASD,EAAMC,OACfC,EAAUD,EAAOE,wBAA0B,KACxB,iBAAZD,IACPJ,EAA0BG,EAAOC,IAEhCJ,IACDG,EAAOE,uBAAyBD,EAC3BD,EAAOC,KACRD,EAAOC,GAAW,WACd,IAAI,IAAIE,EAAOhB,UAAUC,OAAQgB,EAAO,IAAIC,MAAMF,GAAOG,EAAO,EAAGA,EAAOH,EAAMG,IAC5EF,EAAKE,GAAQnB,UAAUmB,GAEtBN,EAAOC,GAASM,QACjBP,EAAOC,GAASM,MAAQ,IAE5BP,EAAOC,GAASM,MAAMC,KAAKJ,EAC/B,EACAJ,EAAOC,GAASQ,QAAU5B,EAC1BmB,EAAOC,GAASS,iBAAkB,GAEtCb,EAA0BG,EAAOC,GAEzC,GAGJ,IAA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from"../lib/utils/safelyRunOnBrowser.js";import{getAlgoliaAgent as e}from"../lib/utils/getAlgoliaAgent.js";function i(){return t(function(n){var t,e;return(null===(e=n.window.navigator)||void 0===e||null===(t=e.userAgent)||void 0===t?void 0:t.indexOf("Algolia Crawler"))>-1},{fallback:function(){return!1}})}function r(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).$$internal,i=void 0!==t&&t;return function(t){var r=t.instantSearchInstance,a={widgets:[]},o=document.createElement("meta"),u=document.querySelector("head");return o.name="instantsearch:widgets",{$$type:"ais.metadata",$$internal:i,onStateChange:function(){},subscribe:function(){setTimeout(function(){a.ua=e(r.client),n(r.mainIndex.getWidgets(),r,a),r.middleware.forEach(function(n){return a.widgets.push({middleware:!0,type:n.instance.$$type,internal:n.instance.$$internal})}),o.content=JSON.stringify(a),u.appendChild(o)},0)},started:function(){},unsubscribe:function(){o.remove()}}}}export{r as createMetadataMiddleware,i as isMetadataEnabled};
|
|
2
2
|
//# sourceMappingURL=createMetadataMiddleware.js.map
|
package/dist/esm/node_modules/instantsearch.js/es/middlewares/createMetadataMiddleware.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMetadataMiddleware.js","sources":["../../../../../../node_modules/instantsearch.js/es/middlewares/createMetadataMiddleware.js"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"createMetadataMiddleware.js","sources":["../../../../../../node_modules/instantsearch.js/es/middlewares/createMetadataMiddleware.js"],"sourcesContent":["import { extractWidgetPayload } from '../lib/utils/extractWidgetPayload.js';\nimport { safelyRunOnBrowser } from '../lib/utils/safelyRunOnBrowser.js';\nimport { getAlgoliaAgent } from '../lib/utils/getAlgoliaAgent.js';\n\nfunction isMetadataEnabled() {\n return safelyRunOnBrowser(function(param) {\n var window = param.window;\n var _window_navigator_userAgent, _window_navigator;\n return ((_window_navigator = window.navigator) === null || _window_navigator === void 0 ? void 0 : (_window_navigator_userAgent = _window_navigator.userAgent) === null || _window_navigator_userAgent === void 0 ? void 0 : _window_navigator_userAgent.indexOf('Algolia Crawler')) > -1;\n }, {\n fallback: function fallback() {\n return false;\n }\n });\n}\n/**\n * Exposes the metadata of mounted widgets in a custom\n * `<meta name=\"instantsearch:widgets\" />` tag. The metadata per widget is:\n * - applied parameters\n * - widget name\n * - connector name\n */ function createMetadataMiddleware() {\n var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref_$$internal = _ref.$$internal, $$internal = _ref_$$internal === void 0 ? false : _ref_$$internal;\n return function(param) {\n var instantSearchInstance = param.instantSearchInstance;\n var payload = {\n widgets: []\n };\n var payloadContainer = document.createElement('meta');\n var refNode = document.querySelector('head');\n payloadContainer.name = 'instantsearch:widgets';\n return {\n $$type: 'ais.metadata',\n $$internal: $$internal,\n onStateChange: function onStateChange() {},\n subscribe: function subscribe() {\n // using setTimeout here to delay extraction until widgets have been added in a tick (e.g. Vue)\n setTimeout(function() {\n payload.ua = getAlgoliaAgent(instantSearchInstance.client);\n extractWidgetPayload(instantSearchInstance.mainIndex.getWidgets(), instantSearchInstance, payload);\n instantSearchInstance.middleware.forEach(function(middleware) {\n return payload.widgets.push({\n middleware: true,\n type: middleware.instance.$$type,\n internal: middleware.instance.$$internal\n });\n });\n payloadContainer.content = JSON.stringify(payload);\n refNode.appendChild(payloadContainer);\n }, 0);\n },\n started: function started() {},\n unsubscribe: function unsubscribe() {\n payloadContainer.remove();\n }\n };\n };\n}\n\nexport { createMetadataMiddleware, isMetadataEnabled };\n"],"names":["isMetadataEnabled","safelyRunOnBrowser","param","_window_navigator_userAgent","_window_navigator","window","navigator","userAgent","indexOf","fallback","createMetadataMiddleware","_ref_$$internal","arguments","length","$$internal","instantSearchInstance","payload","widgets","payloadContainer","document","createElement","refNode","querySelector","name","$$type","onStateChange","subscribe","setTimeout","ua","getAlgoliaAgent","client","extractWidgetPayload","mainIndex","getWidgets","middleware","forEach","push","type","instance","internal","content","JSON","stringify","appendChild","started","unsubscribe","remove"],"mappings":"sNAIA,SAASA,IACL,OAAOC,EAAmB,SAASC,GAC/B,IACIC,EAA6BC,EACjC,OAAmD,QAA1CA,EAFIF,EAAMG,OAEiBC,iBAA6C,IAAtBF,GAAwG,QAA/DD,EAA8BC,EAAkBG,iBAAuD,IAAhCJ,OAAjF,EAAmIA,EAA4BK,QAAQ,qBAAsB,CAC3R,EAAG,CACCC,SAAU,WACN,OAAO,CACX,GAER,CAOI,SAASC,IACT,IAAgFC,GAArEC,UAAUC,OAAS,QAAsB,IAAjBD,UAAU,GAAgBA,UAAU,GAAK,CAAA,GAA2BE,WAAYA,OAAiC,IAApBH,GAAqCA,EACrK,OAAO,SAAST,GACZ,IAAIa,EAAwBb,EAAMa,sBAC9BC,EAAU,CACVC,QAAS,IAETC,EAAmBC,SAASC,cAAc,QAC1CC,EAAUF,SAASG,cAAc,QAErC,OADAJ,EAAiBK,KAAO,wBACjB,CACHC,OAAQ,eACRV,WAAYA,EACZW,cAAe,WAA0B,EACzCC,UAAW,WAEPC,WAAW,WACPX,EAAQY,GAAKC,EAAgBd,EAAsBe,QACnDC,EAAqBhB,EAAsBiB,UAAUC,aAAclB,EAAuBC,GAC1FD,EAAsBmB,WAAWC,QAAQ,SAASD,GAC9C,OAAOlB,EAAQC,QAAQmB,KAAK,CACxBF,YAAY,EACZG,KAAMH,EAAWI,SAASd,OAC1Be,SAAUL,EAAWI,SAASxB,YAEtC,GACAI,EAAiBsB,QAAUC,KAAKC,UAAU1B,GAC1CK,EAAQsB,YAAYzB,EACxB,EAAG,EACP,EACA0B,QAAS,WAAoB,EAC7BC,YAAa,WACT3B,EAAiB4B,QACrB,EAER,CACJ","x_google_ignoreList":[0]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e}from"../../../../@swc/helpers/esm/_define_property.js";import{_ as t}from"../../../../@swc/helpers/esm/_instanceof.js";import{_ as r}from"../../../../@swc/helpers/esm/_object_spread.js";import{_ as n}from"../../../../@swc/helpers/esm/_object_spread_props.js";import{_ as a}from"../../../../@swc/helpers/esm/_object_without_properties.js";import{_ as i}from"../../../../@swc/helpers/esm/_to_consumable_array.js";import s from"../../../../../_virtual/index2.js";import{addWidgetId as o}from"../../lib/utils/addWidgetId.js";import{defer as c}from"../../lib/utils/defer.js";import{resolveSearchParameters as d}from"../../lib/utils/resolveSearchParameters.js";import{createDocumentationMessageGenerator as u}from"../../lib/utils/documentation.js";import{isIndexWidget as l}from"../../lib/utils/isIndexWidget.js";import{mergeSearchParameters as m}from"../../lib/utils/mergeSearchParameters.js";import{createRenderArgs as h,storeRenderState as f,createInitArgs as g}from"../../lib/utils/render-args.js";var S=u({name:"index-widget"});function p(e,t){var r=t.state,n=t.recommendState,a=t.isPageReset,i=t._uiState;r!==e.state&&(e.state=r,e.emit("change",{state:e.state,results:e.lastResults,isPageReset:a,_uiState:i})),n!==e.recommendState&&(e.recommendState=n)}function R(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e.reduce(function(e,r){return l(r)?e:r.getWidgetUiState||r.getWidgetState?r.getWidgetUiState?r.getWidgetUiState(e,t):r.getWidgetState(e,t):e},r)}function v(e,t){var r=t.initialSearchParameters,n=a(t,["initialSearchParameters"]);return e.reduce(function(e,t){return!t.getWidgetSearchParameters||l(t)?e:"search"===t.dependsOn&&t.getWidgetParameters?t.getWidgetParameters(e,n):t.getWidgetSearchParameters(e,n)},r)}function _(e,t){var r=t.initialRecommendParameters,n=a(t,["initialRecommendParameters"]);return e.reduce(function(e,t){return!l(t)&&"recommend"===t.dependsOn&&t.getWidgetParameters?t.getWidgetParameters(e,n):e},r)}function P(e){var t=e.filter(l);0!==t.length&&t.forEach(function(e){var t=e.getHelper();p(t,{state:t.state.resetPage(),recommendState:t.recommendState,isPageReset:!0}),P(e.getWidgets())})}function W(e){return e.filter(l).reduce(function(e,t){var r;return(r=e).concat.apply(r,[{indexId:t.getIndexId(),results:t.getResults(),helper:t.getHelper()}].concat(i(W(t.getWidgets()))))},[])}var I=function(a){if(void 0===a||void 0===a.indexName&&!a.EXPERIMENTAL_isolated)throw new Error(S("The `indexName` option is required."));var u=a.indexName,I=void 0===u?"":u,w=a.indexId,x=void 0===w?I:w,y=a.EXPERIMENTAL_isolated,E=void 0!==y&&y,U=[],j={},b=null,A=null,O=null,H=null,L=null,T=!1,$=!1;return{$$type:"ais.index",$$widgetType:"ais.index",_isolated:E,getIndexName:function(){return I},getIndexId:function(){return x},getHelper:function(){return O},getResults:function(){return(null==H?void 0:H.lastResults)?(H.lastResults._state=O.state,H.lastResults):null},getResultsForWidget:function(e){return"recommend"!==e.dependsOn||l(e)||void 0===e.$$id?this.getResults():(null==O?void 0:O.lastRecommendResults)?O.lastRecommendResults[e.$$id]:null},getPreviousState:function(){return L},getScopedResults:function(){var e=this.getParent();return W(e?e.getWidgets():0===I.length?this.getWidgets():[this])},getParent:function(){return E?null:A},createURL:function(t){return"function"==typeof t?b._createURL(e({},x,t(j))):b._createURL(e({},x,R(U,{searchParameters:t,helper:O})))},scheduleLocalSearch:c(function(){E&&(null==O||O.search())}),getWidgets:function(){return U},addWidgets:function(e){var t=this;if(!Array.isArray(e))throw new Error(S("The `addWidgets` method expects an array of widgets."));var r=e.reduce(function(e,t){return e.concat(Array.isArray(t)?t:[t])},[]);if(r.some(function(e){return"function"!=typeof e.init&&"function"!=typeof e.render}))throw new Error(S("The widget definition expects a `render` and/or an `init` method."));return r.forEach(function(e){e.parent=t,l(e)||(b&&"recommend"===e.dependsOn?b._hasRecommendWidget=!0:b?b._hasSearchWidget=!0:"recommend"===e.dependsOn?T=!0:$=!0,o(e))}),U=U.concat(r),b&&Boolean(r.length)&&(p(O,{state:v(U,{uiState:j,initialSearchParameters:O.state}),recommendState:_(U,{uiState:j,initialRecommendParameters:O.recommendState}),_uiState:j}),r.forEach(function(e){if(e.getRenderState){var r=e.getRenderState(b.renderState[t.getIndexId()]||{},g(b,t,b._initialUiState));f({renderState:r,instantSearchInstance:b,parent:t})}}),r.forEach(function(e){e.init&&e.init(g(b,t,b._initialUiState))}),E?this.scheduleLocalSearch():b.scheduleSearch()),this},removeWidgets:function(e){var r=this;if(!Array.isArray(e))throw new Error(S("The `removeWidgets` method expects an array of widgets."));var n=e.reduce(function(e,t){return e.concat(Array.isArray(t)?t:[t])},[]);if(n.some(function(e){return"function"!=typeof e.dispose}))throw new Error(S("The widget definition expects a `dispose` method."));if((U=U.filter(function(e){return-1===n.indexOf(e)})).forEach(function(e){e.parent=void 0,l(e)||(b&&"recommend"===e.dependsOn?b._hasRecommendWidget=!0:b?b._hasSearchWidget=!0:"recommend"===e.dependsOn?T=!0:$=!0)}),b&&Boolean(n.length)){var a=n.reduce(function(e,n){var a=n.dispose({helper:O,state:e.cleanedSearchState,recommendState:e.cleanedRecommendState,parent:r});return t(a,s.RecommendParameters)?e.cleanedRecommendState=a:a&&(e.cleanedSearchState=a),e},{cleanedSearchState:O.state,cleanedRecommendState:O.recommendState}),i=a.cleanedSearchState,o=a.cleanedRecommendState,c=b.future.preserveSharedStateOnUnmount?v(U,{uiState:j,initialSearchParameters:new s.SearchParameters({index:this.getIndexName()})}):v(U,{uiState:R(U,{searchParameters:i,helper:O}),initialSearchParameters:i});j=R(U,{searchParameters:c,helper:O}),O.setState(c),O.recommendState=o,U.length&&(E?this.scheduleLocalSearch():b.scheduleSearch())}return this},init:function(e){var t,r=this,n=e.instantSearchInstance,a=e.parent,o=e.uiState;if(null===O){b=n,A=a,j=o[x]||{};var c=n.mainHelper,u=v(U,{uiState:j,initialSearchParameters:new s.SearchParameters({index:I})}),l=_(U,{uiState:j,initialRecommendParameters:new s.RecommendParameters});(O=s(c.getClient(),u.index,u)).recommendState=l,O.search=function(){return E?(n.status="loading",r.render({instantSearchInstance:n}),n.compositionID?O.searchWithComposition():O.searchOnlyWithDerivedHelpers()):n.onStateChange?(n.onStateChange({uiState:n.mainIndex.getWidgetUiState({}),setUiState:function(e){return n.setUiState(e,!1)}}),c):c.search()},O.searchWithoutTriggeringOnStateChange=function(){return c.search()},O.searchForFacetValues=function(e,t,n,a){var s=m.apply(void 0,[c.state].concat(i(d(r)))).setQueryParameters(a);return c.searchForFacetValues(e,t,n,s)};var h=I?O:s({},"__empty_index__",{}),S=E?h:function(e,t){for(;e;){if(e._isolated)return e.getHelper();e=e.getParent()}return t}(a,c);H=S.derive(function(){return m.apply(void 0,[c.state].concat(i(d(r))))},function(){return r.getHelper().recommendState});var p=null===(t=n._initialResults)||void 0===t?void 0:t[this.getIndexId()];if(null==p?void 0:p.results){var W=new s.SearchResults(new s.SearchParameters(p.state),p.results);H.lastResults=W,O.lastResults=W}if(null==p?void 0:p.recommendResults){var w=new s.RecommendResults(new s.RecommendParameters({params:p.recommendResults.params}),p.recommendResults.results);H.lastRecommendResults=w,O.lastRecommendResults=w}O.on("change",function(e){e.isPageReset&&P(U)}),H.on("search",function(){n.scheduleStalledRender()}),H.on("result",function(e){var t=e.results;n.scheduleRender(),O.lastResults=t,L=null==t?void 0:t._state}),H.on("recommend:result",function(e){var t=e.recommend;n.scheduleRender(),O.lastRecommendResults=t.results}),U.forEach(function(e){if(e.getRenderState){var t=e.getRenderState(n.renderState[r.getIndexId()]||{},g(n,r,o));f({renderState:t,instantSearchInstance:n,parent:r})}}),U.forEach(function(e){e.init&&e.init(g(n,r,o))}),O.on("change",function(e){var t=e.state,r=e._uiState;j=R(U,{searchParameters:t,helper:O},r||{}),n.onStateChange||n.onInternalStateChange()}),p&&n.scheduleRender(),T&&(n._hasRecommendWidget=!0),$&&(n._hasSearchWidget=!0)}},render:function(e){var t=this,r=e.instantSearchInstance;"error"===r.status&&!r.mainHelper.hasPendingRequests()&&L&&O.setState(L);var n=this.getResults()||(null==H?void 0:H.lastRecommendResults)||E&&!I?U:U.filter(function(e){return e.shouldRender});(n=n.filter(function(e){return!e.shouldRender||e.shouldRender({instantSearchInstance:r})})).forEach(function(e){if(e.getRenderState){var n=e.getRenderState(r.renderState[t.getIndexId()]||{},h(r,t,e));f({renderState:n,instantSearchInstance:r,parent:t})}}),n.forEach(function(e){e.render&&e.render(h(r,t,e))})},dispose:function(){var e=this;U.forEach(function(t){t.dispose&&O&&t.dispose({helper:O,state:O.state,recommendState:O.recommendState,parent:e})}),b=null,A=null,null==O||O.removeAllListeners(),O=null,null==H||H.detach(),H=null},getWidgetUiState:function(t){return U.filter(l).filter(function(e){return!e._isolated}).reduce(function(e,t){return t.getWidgetUiState(e)},n(r({},t),e({},x,r({},t[x],j))))},getWidgetState:function(e){return this.getWidgetUiState(e)},getWidgetSearchParameters:function(e,t){var r=t.uiState;return v(U,{uiState:r,initialSearchParameters:e})},shouldRender:function(){return!0},refreshUiState:function(){j=R(U,{searchParameters:this.getHelper().state,helper:this.getHelper()},j)},setIndexUiState:function(t){var a="function"==typeof t?t(j):t;b.setUiState(function(t){return n(r({},t),e({},x,a))})}}};export{I as default};
|
|
1
|
+
import{_ as e}from"../../../../@swc/helpers/esm/_define_property.js";import{_ as t}from"../../../../@swc/helpers/esm/_instanceof.js";import{_ as r}from"../../../../@swc/helpers/esm/_object_spread.js";import{_ as n}from"../../../../@swc/helpers/esm/_object_spread_props.js";import{_ as a}from"../../../../@swc/helpers/esm/_object_without_properties.js";import{_ as i}from"../../../../@swc/helpers/esm/_to_consumable_array.js";import s from"../../../../../_virtual/index2.js";import{addWidgetId as o}from"../../lib/utils/addWidgetId.js";import{isIndexWidget as d}from"../../lib/utils/isIndexWidget.js";import{resolveSearchParameters as c}from"../../lib/utils/resolveSearchParameters.js";import{addInsightsToRecommendParameters as u}from"../../lib/utils/addInsightsToRecommendParameters.js";import{createDocumentationMessageGenerator as l}from"../../lib/utils/documentation.js";import{defer as m}from"../../lib/utils/defer.js";import{mergeSearchParameters as h}from"../../lib/utils/mergeSearchParameters.js";import{createRenderArgs as f,storeRenderState as g,createInitArgs as S}from"../../lib/utils/render-args.js";var p=l({name:"index-widget"});function R(e,t){var r=t.state,n=t.recommendState,a=t.isPageReset,i=t._uiState;r!==e.state&&(e.state=r,e.emit("change",{state:e.state,results:e.lastResults,isPageReset:a,_uiState:i})),n!==e.recommendState&&(e.recommendState=n)}function v(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e.reduce(function(e,r){return d(r)?e:r.getWidgetUiState||r.getWidgetState?r.getWidgetUiState?r.getWidgetUiState(e,t):r.getWidgetState(e,t):e},r)}function P(e,t){var r=t.initialSearchParameters,n=a(t,["initialSearchParameters"]);return e.reduce(function(e,t){return!t.getWidgetSearchParameters||d(t)?e:"search"===t.dependsOn&&t.getWidgetParameters?t.getWidgetParameters(e,n):t.getWidgetSearchParameters(e,n)},r)}function W(e,t){var r=t.initialRecommendParameters,n=a(t,["initialRecommendParameters"]);return e.reduce(function(e,t){return!d(t)&&"recommend"===t.dependsOn&&t.getWidgetParameters?t.getWidgetParameters(e,n):e},r)}function _(e){var t=e.filter(d);0!==t.length&&t.forEach(function(e){var t=e.getHelper();R(t,{state:t.state.resetPage(),recommendState:t.recommendState,isPageReset:!0}),_(e.getWidgets())})}function w(e){return e.filter(d).reduce(function(e,t){var r;return(r=e).concat.apply(r,[{indexId:t.getIndexId(),results:t.getResults(),helper:t.getHelper()}].concat(i(w(t.getWidgets()))))},[])}function x(e){return e.reduce(function(e,t){if(d(t)){if(t._isolated)return e;var a=x(t.getWidgets());return{hasSearchWidget:e.hasSearchWidget||a.hasSearchWidget,hasRecommendWidget:e.hasRecommendWidget||a.hasRecommendWidget}}return"recommend"===t.dependsOn?n(r({},e),{hasRecommendWidget:!0}):"none"===t.dependsOn?e:n(r({},e),{hasSearchWidget:!0})},{hasSearchWidget:!1,hasRecommendWidget:!1})}function I(e){var t=x(e.mainIndex.getWidgets()),r=t.hasSearchWidget,n=t.hasRecommendWidget;e._hasSearchWidget=r,e._hasRecommendWidget=n}var y=function(a){var l;if(void 0===a||void 0===a.indexName&&!a.isolated&&!a.EXPERIMENTAL_isolated)throw new Error(p("The `indexName` option is required."));var x,y=a.indexName,E=void 0===y?"":y,U=a.indexId,j=void 0===U?E:U,b=a.isolated,T=void 0===b?null!==(l=a.EXPERIMENTAL_isolated)&&void 0!==l&&l:b,A=[],O={},H=null,L=null,N=null,$=null,C=null,F=function(){H&&I(H)};return{$$type:"ais.index",$$widgetType:"ais.index",_isolated:T,getIndexName:function(){return E},getIndexId:function(){return j},getHelper:function(){return N},getResults:function(){return(null==$?void 0:$.lastResults)?($.lastResults._state=N.state,$.lastResults):null},getResultsForWidget:function(e){return"recommend"!==e.dependsOn||d(e)||void 0===e.$$id?this.getResults():(null==N?void 0:N.lastRecommendResults)?N.lastRecommendResults[e.$$id]:null},getPreviousState:function(){return C},getScopedResults:function(){var e=this.getParent();return w(e?e.getWidgets():0===E.length?this.getWidgets():[this])},getParent:function(){return T?null:L},createURL:function(t){return"function"==typeof t?H._createURL(e({},j,t(O))):H._createURL(e({},j,v(A,{searchParameters:t,helper:N})))},scheduleLocalSearch:m(function(){T&&(null==N||N.search())}),getWidgets:function(){return A},addWidgets:function(e){var t=this;if(!Array.isArray(e))throw new Error(p("The `addWidgets` method expects an array of widgets."));var r=e.reduce(function(e,t){return e.concat(Array.isArray(t)?t:[t])},[]);if(r.some(function(e){return"function"!=typeof e.init&&"function"!=typeof e.render}))throw new Error(p("The widget definition expects a `render` and/or an `init` method."));return r.forEach(function(e){e.parent=t,d(e)||o(e)}),A=A.concat(r),F(),H&&Boolean(r.length)&&(R(N,{state:P(A,{uiState:O,initialSearchParameters:N.state}),recommendState:W(A,{uiState:O,initialRecommendParameters:N.recommendState}),_uiState:O}),r.forEach(function(e){if(e.getRenderState){var r=e.getRenderState(H.renderState[t.getIndexId()]||{},S(H,t,H._initialUiState));g({renderState:r,instantSearchInstance:H,parent:t})}}),r.forEach(function(e){e.init&&e.init(S(H,t,H._initialUiState))}),T?this.scheduleLocalSearch():H.scheduleSearch()),this},updateWidget:function(e,r){if("function"!=typeof e.dispose)throw new Error(p("The widget definition expects a `dispose` method."));if("function"!=typeof r.init&&"function"!=typeof r.render)throw new Error(p("The widget definition expects a `render` and/or an `init` method."));var n=O;e.parent=void 0,r.parent=this,d(r)||o(r);var a=A.slice(),i=a.indexOf(e);if(-1===i?a.push(r):a[i]=r,A=a,F(),!H)return this;var c=e.dispose({helper:N,state:N.state,recommendState:N.recommendState,parent:this}),u=t(c,s.RecommendParameters)?c:N.recommendState,l=c&&!t(c,s.RecommendParameters)?c:N.state,m=H.future.preserveSharedStateOnUnmount?new s.SearchParameters({index:this.getIndexName()}):l;O=v(A,{searchParameters:P(A,{uiState:n,initialSearchParameters:m}),helper:N});var h=P(A,{uiState:O,initialSearchParameters:m});if(R(N,{state:h,recommendState:W(A,{uiState:O,initialRecommendParameters:u}),_uiState:O}),r.getRenderState){var f=r.getRenderState(H.renderState[this.getIndexId()]||{},S(H,this,H._initialUiState));g({renderState:f,instantSearchInstance:H,parent:this})}return r.init&&r.init(S(H,this,H._initialUiState)),T?this.scheduleLocalSearch():H.scheduleSearch(),this},removeWidgets:function(e){var r=this;if(!Array.isArray(e))throw new Error(p("The `removeWidgets` method expects an array of widgets."));var n=e.reduce(function(e,t){return e.concat(Array.isArray(t)?t:[t])},[]);if(n.some(function(e){return"function"!=typeof e.dispose}))throw new Error(p("The widget definition expects a `dispose` method."));if(A=A.filter(function(e){return-1===n.indexOf(e)}),n.forEach(function(e){e.parent=void 0}),F(),H&&Boolean(n.length)){var a=n.reduce(function(e,n){var a=n.dispose({helper:N,state:e.cleanedSearchState,recommendState:e.cleanedRecommendState,parent:r});return t(a,s.RecommendParameters)?e.cleanedRecommendState=a:a&&(e.cleanedSearchState=a),e},{cleanedSearchState:N.state,cleanedRecommendState:N.recommendState}),i=a.cleanedSearchState,o=a.cleanedRecommendState,d=H.future.preserveSharedStateOnUnmount?P(A,{uiState:O,initialSearchParameters:new s.SearchParameters({index:this.getIndexName()})}):P(A,{uiState:v(A,{searchParameters:i,helper:N}),initialSearchParameters:i});O=v(A,{searchParameters:d,helper:N}),N.setState(d),N.recommendState=o,A.length&&(T?this.scheduleLocalSearch():H.scheduleSearch())}return this},init:function(e){var t,r=this,n=e.instantSearchInstance,a=e.parent,o=e.uiState;if(null===N){H=n,L=a,O=o[j]||{};var d=n.mainHelper,l=P(A,{uiState:O,initialSearchParameters:new s.SearchParameters({index:E})}),m=W(A,{uiState:O,initialRecommendParameters:new s.RecommendParameters});(N=s(d.getClient(),l.index,l)).recommendState=m,N.search=function(){return T?(n.status="loading",r.render({instantSearchInstance:n}),n.compositionID?N.searchWithComposition():N.searchOnlyWithDerivedHelpers()):n.onStateChange?(n.onStateChange({uiState:n.mainIndex.getWidgetUiState({}),setUiState:function(e){return n.setUiState(e,!1)}}),d):d.search()},N.searchWithoutTriggeringOnStateChange=function(){return d.search()},N.searchForFacetValues=function(e,t,n,a){var s=h.apply(void 0,[d.state].concat(i(c(r)))).setQueryParameters(a);return d.searchForFacetValues(e,t,n,s)};var f=E?N:s({},"__empty_index__",{}),p=T?f:function(e,t){for(;e;){if(e._isolated)return e.getHelper();e=e.getParent()}return t}(a,d);$=p.derive(function(){return h.apply(void 0,[d.state].concat(i(c(r))))},function(){return u(r.getHelper().recommendState,d.state)});var R=null===(t=n._initialResults)||void 0===t?void 0:t[this.getIndexId()];if(null==R?void 0:R.results){var w=new s.SearchResults(new s.SearchParameters(R.state),R.results);$.lastResults=w,N.lastResults=w}if(null==R?void 0:R.recommendResults){var x=new s.RecommendResults(new s.RecommendParameters({params:R.recommendResults.params}),R.recommendResults.results);$.lastRecommendResults=x,N.lastRecommendResults=x}N.on("change",function(e){e.isPageReset&&_(A)}),$.on("search",function(){n.scheduleStalledRender()}),$.on("result",function(e){var t=e.results;n.scheduleRender(),N.lastResults=t,C=null==t?void 0:t._state}),$.on("recommend:result",function(e){var t=e.recommend;n.scheduleRender(),N.lastRecommendResults=t.results}),A.forEach(function(e){if(e.getRenderState){var t=e.getRenderState(n.renderState[r.getIndexId()]||{},S(n,r,o));g({renderState:t,instantSearchInstance:n,parent:r})}}),A.forEach(function(e){e.init&&e.init(S(n,r,o))}),N.on("change",function(e){var t=e.state,r=e._uiState;O=v(A,{searchParameters:t,helper:N},r||{}),n.onStateChange||n.onInternalStateChange()}),R&&n.scheduleRender(),F()}},render:function(e){var t=this,r=e.instantSearchInstance;"error"!==r.status?x=void 0:r.error!==x&&!r.mainHelper.hasPendingRequests()&&C&&(x=r.error,N.setState(C));var n=this.getResults()||(null==$?void 0:$.lastRecommendResults)||T&&!E?A:A.filter(function(e){return e.shouldRender});(n=n.filter(function(e){return!e.shouldRender||e.shouldRender({instantSearchInstance:r})})).forEach(function(e){if(e.getRenderState){var n=e.getRenderState(r.renderState[t.getIndexId()]||{},f(r,t,e));g({renderState:n,instantSearchInstance:r,parent:t})}}),n.forEach(function(e){e.render&&e.render(f(r,t,e))})},dispose:function(){var e=this;A.forEach(function(t){t.dispose&&N&&t.dispose({helper:N,state:N.state,recommendState:N.recommendState,parent:e})}),H=null,L=null,null==N||N.removeAllListeners(),N=null,null==$||$.detach(),$=null},getWidgetUiState:function(t){return A.filter(d).filter(function(e){return!e._isolated}).reduce(function(e,t){return t.getWidgetUiState(e)},n(r({},t),e({},j,r({},t[j],O))))},getWidgetState:function(e){return this.getWidgetUiState(e)},getWidgetSearchParameters:function(e,t){var r=t.uiState;return P(A,{uiState:r,initialSearchParameters:e})},shouldRender:function(){return!0},refreshUiState:function(){O=v(A,{searchParameters:this.getHelper().state,helper:this.getHelper()},O)},setIndexUiState:function(t){var a="function"==typeof t?t(O):t;H.setUiState(function(t){return n(r({},t),e({},j,a))})}}};export{y as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../../../../node_modules/instantsearch.js/es/widgets/index/index.js"],"sourcesContent":["import { _ } from '@swc/helpers/esm/_define_property.js';\nimport { _ as _$5 } from '@swc/helpers/esm/_instanceof.js';\nimport { _ as _$3 } from '@swc/helpers/esm/_object_spread.js';\nimport { _ as _$2 } from '@swc/helpers/esm/_object_spread_props.js';\nimport { _ as _$4 } from '@swc/helpers/esm/_object_without_properties.js';\nimport { _ as _$1 } from '@swc/helpers/esm/_to_consumable_array.js';\nimport algoliasearchHelper from 'algoliasearch-helper';\nimport { addWidgetId } from '../../lib/utils/addWidgetId.js';\nimport { defer } from '../../lib/utils/defer.js';\nimport { resolveSearchParameters } from '../../lib/utils/resolveSearchParameters.js';\nimport { createDocumentationMessageGenerator } from '../../lib/utils/documentation.js';\nimport { isIndexWidget } from '../../lib/utils/isIndexWidget.js';\nimport { mergeSearchParameters } from '../../lib/utils/mergeSearchParameters.js';\nimport { createInitArgs, storeRenderState, createRenderArgs } from '../../lib/utils/render-args.js';\n\nvar withUsage = createDocumentationMessageGenerator({\n name: 'index-widget'\n});\n/**\n * This is the same content as helper._change / setState, but allowing for extra\n * UiState to be synchronized.\n * see: https://github.com/algolia/algoliasearch-helper-js/blob/6b835ffd07742f2d6b314022cce6848f5cfecd4a/src/algoliasearch.helper.js#L1311-L1324\n */ function privateHelperSetState(helper, param) {\n var state = param.state, recommendState = param.recommendState, isPageReset = param.isPageReset, _uiState = param._uiState;\n if (state !== helper.state) {\n helper.state = state;\n helper.emit('change', {\n state: helper.state,\n results: helper.lastResults,\n isPageReset: isPageReset,\n _uiState: _uiState\n });\n }\n if (recommendState !== helper.recommendState) {\n helper.recommendState = recommendState;\n // eslint-disable-next-line no-warning-comments\n // TODO: emit \"change\" event when events for Recommend are implemented\n }\n}\nfunction getLocalWidgetsUiState(widgets, widgetStateOptions) {\n var initialUiState = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};\n return widgets.reduce(function(uiState, widget) {\n if (isIndexWidget(widget)) {\n return uiState;\n }\n if (!widget.getWidgetUiState && !widget.getWidgetState) {\n return uiState;\n }\n if (widget.getWidgetUiState) {\n return widget.getWidgetUiState(uiState, widgetStateOptions);\n }\n return widget.getWidgetState(uiState, widgetStateOptions);\n }, initialUiState);\n}\nfunction getLocalWidgetsSearchParameters(widgets, widgetSearchParametersOptions) {\n var initialSearchParameters = widgetSearchParametersOptions.initialSearchParameters, rest = _$4(widgetSearchParametersOptions, [\n \"initialSearchParameters\"\n ]);\n return widgets.reduce(function(state, widget) {\n if (!widget.getWidgetSearchParameters || isIndexWidget(widget)) {\n return state;\n }\n if (widget.dependsOn === 'search' && widget.getWidgetParameters) {\n return widget.getWidgetParameters(state, rest);\n }\n return widget.getWidgetSearchParameters(state, rest);\n }, initialSearchParameters);\n}\nfunction getLocalWidgetsRecommendParameters(widgets, widgetRecommendParametersOptions) {\n var initialRecommendParameters = widgetRecommendParametersOptions.initialRecommendParameters, rest = _$4(widgetRecommendParametersOptions, [\n \"initialRecommendParameters\"\n ]);\n return widgets.reduce(function(state, widget) {\n if (!isIndexWidget(widget) && widget.dependsOn === 'recommend' && widget.getWidgetParameters) {\n return widget.getWidgetParameters(state, rest);\n }\n return state;\n }, initialRecommendParameters);\n}\nfunction resetPageFromWidgets(widgets) {\n var indexWidgets = widgets.filter(isIndexWidget);\n if (indexWidgets.length === 0) {\n return;\n }\n indexWidgets.forEach(function(widget) {\n var widgetHelper = widget.getHelper();\n privateHelperSetState(widgetHelper, {\n state: widgetHelper.state.resetPage(),\n recommendState: widgetHelper.recommendState,\n isPageReset: true\n });\n resetPageFromWidgets(widget.getWidgets());\n });\n}\nfunction resolveScopedResultsFromWidgets(widgets) {\n var indexWidgets = widgets.filter(isIndexWidget);\n return indexWidgets.reduce(function(scopedResults, current) {\n var _scopedResults;\n return (_scopedResults = scopedResults).concat.apply(_scopedResults, [\n {\n indexId: current.getIndexId(),\n results: current.getResults(),\n helper: current.getHelper()\n }\n ].concat(_$1(resolveScopedResultsFromWidgets(current.getWidgets()))));\n }, []);\n}\nvar index = function index(widgetParams) {\n if (widgetParams === undefined || widgetParams.indexName === undefined && !widgetParams.EXPERIMENTAL_isolated) {\n throw new Error(withUsage('The `indexName` option is required.'));\n }\n // When isolated=true, we use an empty string as the default indexName.\n // This is intentional: isolated indices do not require a real index name.\n var _widgetParams_indexName = widgetParams.indexName, indexName = _widgetParams_indexName === void 0 ? '' : _widgetParams_indexName, _widgetParams_indexId = widgetParams.indexId, indexId = _widgetParams_indexId === void 0 ? indexName : _widgetParams_indexId, tmp = widgetParams.EXPERIMENTAL_isolated, isolated = tmp === void 0 ? false : tmp;\n var localWidgets = [];\n var localUiState = {};\n var localInstantSearchInstance = null;\n var localParent = null;\n var helper = null;\n var derivedHelper = null;\n var lastValidSearchParameters = null;\n var hasRecommendWidget = false;\n var hasSearchWidget = false;\n return {\n $$type: 'ais.index',\n $$widgetType: 'ais.index',\n _isolated: isolated,\n getIndexName: function getIndexName() {\n return indexName;\n },\n getIndexId: function getIndexId() {\n return indexId;\n },\n getHelper: function getHelper() {\n return helper;\n },\n getResults: function getResults() {\n if (!(derivedHelper === null || derivedHelper === void 0 ? void 0 : derivedHelper.lastResults)) return null;\n // To make the UI optimistic, we patch the state to display to the current\n // one instead of the one associated with the latest results.\n // This means user-driven UI changes (e.g., checked checkbox) are reflected\n // immediately instead of waiting for Algolia to respond, regardless of\n // the status of the network request.\n derivedHelper.lastResults._state = helper.state;\n return derivedHelper.lastResults;\n },\n getResultsForWidget: function getResultsForWidget(widget) {\n if (widget.dependsOn !== 'recommend' || isIndexWidget(widget) || widget.$$id === undefined) {\n return this.getResults();\n }\n if (!(helper === null || helper === void 0 ? void 0 : helper.lastRecommendResults)) {\n return null;\n }\n return helper.lastRecommendResults[widget.$$id];\n },\n getPreviousState: function getPreviousState() {\n return lastValidSearchParameters;\n },\n getScopedResults: function getScopedResults() {\n var widgetParent = this.getParent();\n var widgetSiblings;\n if (widgetParent) {\n widgetSiblings = widgetParent.getWidgets();\n } else if (indexName.length === 0) {\n // The widget is the root but has no index name:\n // we resolve results from its children index widgets\n widgetSiblings = this.getWidgets();\n } else {\n // The widget is the root and has an index name:\n // we consider itself as the only sibling\n widgetSiblings = [\n this\n ];\n }\n return resolveScopedResultsFromWidgets(widgetSiblings);\n },\n getParent: function getParent() {\n return isolated ? null : localParent;\n },\n createURL: function createURL(nextState) {\n if (typeof nextState === 'function') {\n return localInstantSearchInstance._createURL(_({}, indexId, nextState(localUiState)));\n }\n return localInstantSearchInstance._createURL(_({}, indexId, getLocalWidgetsUiState(localWidgets, {\n searchParameters: nextState,\n helper: helper\n })));\n },\n scheduleLocalSearch: defer(function() {\n if (isolated) {\n helper === null || helper === void 0 ? void 0 : helper.search();\n }\n }),\n getWidgets: function getWidgets() {\n return localWidgets;\n },\n addWidgets: function addWidgets(widgets) {\n var _this = this;\n if (!Array.isArray(widgets)) {\n throw new Error(withUsage('The `addWidgets` method expects an array of widgets.'));\n }\n var flatWidgets = widgets.reduce(function(acc, w) {\n return acc.concat(Array.isArray(w) ? w : [\n w\n ]);\n }, []);\n if (flatWidgets.some(function(widget) {\n return typeof widget.init !== 'function' && typeof widget.render !== 'function';\n })) {\n throw new Error(withUsage('The widget definition expects a `render` and/or an `init` method.'));\n }\n flatWidgets.forEach(function(widget) {\n widget.parent = _this;\n if (isIndexWidget(widget)) {\n return;\n }\n if (localInstantSearchInstance && widget.dependsOn === 'recommend') {\n localInstantSearchInstance._hasRecommendWidget = true;\n } else if (localInstantSearchInstance) {\n localInstantSearchInstance._hasSearchWidget = true;\n } else if (widget.dependsOn === 'recommend') {\n hasRecommendWidget = true;\n } else {\n hasSearchWidget = true;\n }\n addWidgetId(widget);\n });\n localWidgets = localWidgets.concat(flatWidgets);\n if (localInstantSearchInstance && Boolean(flatWidgets.length)) {\n privateHelperSetState(helper, {\n state: getLocalWidgetsSearchParameters(localWidgets, {\n uiState: localUiState,\n initialSearchParameters: helper.state\n }),\n recommendState: getLocalWidgetsRecommendParameters(localWidgets, {\n uiState: localUiState,\n initialRecommendParameters: helper.recommendState\n }),\n _uiState: localUiState\n });\n // We compute the render state before calling `init` in a separate loop\n // to construct the whole render state object that is then passed to\n // `init`.\n flatWidgets.forEach(function(widget) {\n if (widget.getRenderState) {\n var renderState = widget.getRenderState(localInstantSearchInstance.renderState[_this.getIndexId()] || {}, createInitArgs(localInstantSearchInstance, _this, localInstantSearchInstance._initialUiState));\n storeRenderState({\n renderState: renderState,\n instantSearchInstance: localInstantSearchInstance,\n parent: _this\n });\n }\n });\n flatWidgets.forEach(function(widget) {\n if (widget.init) {\n widget.init(createInitArgs(localInstantSearchInstance, _this, localInstantSearchInstance._initialUiState));\n }\n });\n if (isolated) {\n this.scheduleLocalSearch();\n } else {\n localInstantSearchInstance.scheduleSearch();\n }\n }\n return this;\n },\n removeWidgets: function removeWidgets(widgets) {\n var _this = this;\n if (!Array.isArray(widgets)) {\n throw new Error(withUsage('The `removeWidgets` method expects an array of widgets.'));\n }\n var flatWidgets = widgets.reduce(function(acc, w) {\n return acc.concat(Array.isArray(w) ? w : [\n w\n ]);\n }, []);\n if (flatWidgets.some(function(widget) {\n return typeof widget.dispose !== 'function';\n })) {\n throw new Error(withUsage('The widget definition expects a `dispose` method.'));\n }\n localWidgets = localWidgets.filter(function(widget) {\n return flatWidgets.indexOf(widget) === -1;\n });\n localWidgets.forEach(function(widget) {\n widget.parent = undefined;\n if (isIndexWidget(widget)) {\n return;\n }\n if (localInstantSearchInstance && widget.dependsOn === 'recommend') {\n localInstantSearchInstance._hasRecommendWidget = true;\n } else if (localInstantSearchInstance) {\n localInstantSearchInstance._hasSearchWidget = true;\n } else if (widget.dependsOn === 'recommend') {\n hasRecommendWidget = true;\n } else {\n hasSearchWidget = true;\n }\n });\n if (localInstantSearchInstance && Boolean(flatWidgets.length)) {\n var _flatWidgets_reduce = flatWidgets.reduce(function(states, widget) {\n // the `dispose` method exists at this point we already assert it\n var next = widget.dispose({\n helper: helper,\n state: states.cleanedSearchState,\n recommendState: states.cleanedRecommendState,\n parent: _this\n });\n if (_$5(next, algoliasearchHelper.RecommendParameters)) {\n states.cleanedRecommendState = next;\n } else if (next) {\n states.cleanedSearchState = next;\n }\n return states;\n }, {\n cleanedSearchState: helper.state,\n cleanedRecommendState: helper.recommendState\n }), cleanedSearchState = _flatWidgets_reduce.cleanedSearchState, cleanedRecommendState = _flatWidgets_reduce.cleanedRecommendState;\n var newState = localInstantSearchInstance.future.preserveSharedStateOnUnmount ? getLocalWidgetsSearchParameters(localWidgets, {\n uiState: localUiState,\n initialSearchParameters: new algoliasearchHelper.SearchParameters({\n index: this.getIndexName()\n })\n }) : getLocalWidgetsSearchParameters(localWidgets, {\n uiState: getLocalWidgetsUiState(localWidgets, {\n searchParameters: cleanedSearchState,\n helper: helper\n }),\n initialSearchParameters: cleanedSearchState\n });\n localUiState = getLocalWidgetsUiState(localWidgets, {\n searchParameters: newState,\n helper: helper\n });\n helper.setState(newState);\n helper.recommendState = cleanedRecommendState;\n if (localWidgets.length) {\n if (isolated) {\n this.scheduleLocalSearch();\n } else {\n localInstantSearchInstance.scheduleSearch();\n }\n }\n }\n return this;\n },\n init: function init(param) {\n var _this = this;\n var instantSearchInstance = param.instantSearchInstance, parent = param.parent, uiState = param.uiState;\n var _instantSearchInstance__initialResults;\n if (helper !== null) {\n // helper is already initialized, therefore we do not need to set up\n // any listeners\n return;\n }\n localInstantSearchInstance = instantSearchInstance;\n localParent = parent;\n localUiState = uiState[indexId] || {};\n // The `mainHelper` is already defined at this point. The instance is created\n // inside InstantSearch at the `start` method, which occurs before the `init`\n // step.\n var mainHelper = instantSearchInstance.mainHelper;\n var parameters = getLocalWidgetsSearchParameters(localWidgets, {\n uiState: localUiState,\n initialSearchParameters: new algoliasearchHelper.SearchParameters({\n index: indexName\n })\n });\n var recommendParameters = getLocalWidgetsRecommendParameters(localWidgets, {\n uiState: localUiState,\n initialRecommendParameters: new algoliasearchHelper.RecommendParameters()\n });\n // This Helper is only used for state management we do not care about the\n // `searchClient`. Only the \"main\" Helper created at the `InstantSearch`\n // level is aware of the client.\n helper = algoliasearchHelper(mainHelper.getClient(), parameters.index, parameters);\n helper.recommendState = recommendParameters;\n // We forward the call to `search` to the \"main\" instance of the Helper\n // which is responsible for managing the queries (it's the only one that is\n // aware of the `searchClient`).\n helper.search = function() {\n if (isolated) {\n instantSearchInstance.status = 'loading';\n _this.render({\n instantSearchInstance: instantSearchInstance\n });\n return instantSearchInstance.compositionID ? helper.searchWithComposition() : helper.searchOnlyWithDerivedHelpers();\n }\n if (instantSearchInstance.onStateChange) {\n instantSearchInstance.onStateChange({\n uiState: instantSearchInstance.mainIndex.getWidgetUiState({}),\n setUiState: function setUiState(nextState) {\n return instantSearchInstance.setUiState(nextState, false);\n }\n });\n // We don't trigger a search when controlled because it becomes the\n // responsibility of `setUiState`.\n return mainHelper;\n }\n return mainHelper.search();\n };\n helper.searchWithoutTriggeringOnStateChange = function() {\n return mainHelper.search();\n };\n // We use the same pattern for the `searchForFacetValues`.\n helper.searchForFacetValues = function(facetName, facetValue, maxFacetHits, userState) {\n var state = mergeSearchParameters.apply(void 0, [\n mainHelper.state\n ].concat(_$1(resolveSearchParameters(_this)))).setQueryParameters(userState);\n return mainHelper.searchForFacetValues(facetName, facetValue, maxFacetHits, state);\n };\n var isolatedHelper = indexName ? helper : algoliasearchHelper({}, '__empty_index__', {});\n var derivingHelper = isolated ? isolatedHelper : nearestIsolatedHelper(parent, mainHelper);\n derivedHelper = derivingHelper.derive(function() {\n return mergeSearchParameters.apply(void 0, [\n mainHelper.state\n ].concat(_$1(resolveSearchParameters(_this))));\n }, function() {\n return _this.getHelper().recommendState;\n });\n var indexInitialResults = (_instantSearchInstance__initialResults = instantSearchInstance._initialResults) === null || _instantSearchInstance__initialResults === void 0 ? void 0 : _instantSearchInstance__initialResults[this.getIndexId()];\n if (indexInitialResults === null || indexInitialResults === void 0 ? void 0 : indexInitialResults.results) {\n // We restore the shape of the results provided to the instance to respect\n // the helper's structure.\n var results = new algoliasearchHelper.SearchResults(new algoliasearchHelper.SearchParameters(indexInitialResults.state), indexInitialResults.results);\n derivedHelper.lastResults = results;\n helper.lastResults = results;\n }\n if (indexInitialResults === null || indexInitialResults === void 0 ? void 0 : indexInitialResults.recommendResults) {\n var recommendResults = new algoliasearchHelper.RecommendResults(new algoliasearchHelper.RecommendParameters({\n params: indexInitialResults.recommendResults.params\n }), indexInitialResults.recommendResults.results);\n derivedHelper.lastRecommendResults = recommendResults;\n helper.lastRecommendResults = recommendResults;\n }\n // Subscribe to the Helper state changes for the page before widgets\n // are initialized. This behavior mimics the original one of the Helper.\n // It makes sense to replicate it at the `init` step. We have another\n // listener on `change` below, once `init` is done.\n helper.on('change', function(param) {\n var isPageReset = param.isPageReset;\n if (isPageReset) {\n resetPageFromWidgets(localWidgets);\n }\n });\n derivedHelper.on('search', function() {\n // The index does not manage the \"staleness\" of the search. This is the\n // responsibility of the main instance. It does not make sense to manage\n // it at the index level because it's either: all of them or none of them\n // that are stalled. The queries are performed into a single network request.\n instantSearchInstance.scheduleStalledRender();\n });\n derivedHelper.on('result', function(param) {\n var results = param.results;\n // The index does not render the results it schedules a new render\n // to let all the other indices emit their own results. It allows us to\n // run the render process in one pass.\n instantSearchInstance.scheduleRender();\n // the derived helper is the one which actually searches, but the helper\n // which is exposed e.g. via instance.helper, doesn't search, and thus\n // does not have access to lastResults, which it used to in pre-federated\n // search behavior.\n helper.lastResults = results;\n lastValidSearchParameters = results === null || results === void 0 ? void 0 : results._state;\n });\n // eslint-disable-next-line no-warning-comments\n // TODO: listen to \"result\" event when events for Recommend are implemented\n derivedHelper.on('recommend:result', function(param) {\n var recommend = param.recommend;\n // The index does not render the results it schedules a new render\n // to let all the other indices emit their own results. It allows us to\n // run the render process in one pass.\n instantSearchInstance.scheduleRender();\n // the derived helper is the one which actually searches, but the helper\n // which is exposed e.g. via instance.helper, doesn't search, and thus\n // does not have access to lastRecommendResults.\n helper.lastRecommendResults = recommend.results;\n });\n // We compute the render state before calling `init` in a separate loop\n // to construct the whole render state object that is then passed to\n // `init`.\n localWidgets.forEach(function(widget) {\n if (widget.getRenderState) {\n var renderState = widget.getRenderState(instantSearchInstance.renderState[_this.getIndexId()] || {}, createInitArgs(instantSearchInstance, _this, uiState));\n storeRenderState({\n renderState: renderState,\n instantSearchInstance: instantSearchInstance,\n parent: _this\n });\n }\n });\n localWidgets.forEach(function(widget) {\n if (widget.init) {\n widget.init(createInitArgs(instantSearchInstance, _this, uiState));\n }\n });\n // Subscribe to the Helper state changes for the `uiState` once widgets\n // are initialized. Until the first render, state changes are part of the\n // configuration step. This is mainly for backward compatibility with custom\n // widgets. When the subscription happens before the `init` step, the (static)\n // configuration of the widget is pushed in the URL. That's what we want to avoid.\n // https://github.com/algolia/instantsearch/pull/994/commits/4a672ae3fd78809e213de0368549ef12e9dc9454\n helper.on('change', function(event) {\n var state = event.state;\n var _uiState = event._uiState;\n localUiState = getLocalWidgetsUiState(localWidgets, {\n searchParameters: state,\n helper: helper\n }, _uiState || {});\n // We don't trigger an internal change when controlled because it\n // becomes the responsibility of `setUiState`.\n if (!instantSearchInstance.onStateChange) {\n instantSearchInstance.onInternalStateChange();\n }\n });\n if (indexInitialResults) {\n // If there are initial results, we're not notified of the next results\n // because we don't trigger an initial search. We therefore need to directly\n // schedule a render that will render the results injected on the helper.\n instantSearchInstance.scheduleRender();\n }\n if (hasRecommendWidget) {\n instantSearchInstance._hasRecommendWidget = true;\n }\n if (hasSearchWidget) {\n instantSearchInstance._hasSearchWidget = true;\n }\n },\n render: function render(param) {\n var _this = this;\n var instantSearchInstance = param.instantSearchInstance;\n // we can't attach a listener to the error event of search, as the error\n // then would no longer be thrown for global handlers.\n if (instantSearchInstance.status === 'error' && !instantSearchInstance.mainHelper.hasPendingRequests() && lastValidSearchParameters) {\n helper.setState(lastValidSearchParameters);\n }\n // We only render index widgets if there are no results.\n // This makes sure `render` is never called with `results` being `null`.\n // If it's an isolated index without an index name, we render all widgets,\n // as there are no results to display for the isolated index itself.\n var widgetsToRender = this.getResults() || (derivedHelper === null || derivedHelper === void 0 ? void 0 : derivedHelper.lastRecommendResults) || isolated && !indexName ? localWidgets : localWidgets.filter(function(widget) {\n return widget.shouldRender;\n });\n widgetsToRender = widgetsToRender.filter(function(widget) {\n if (!widget.shouldRender) {\n return true;\n }\n return widget.shouldRender({\n instantSearchInstance: instantSearchInstance\n });\n });\n widgetsToRender.forEach(function(widget) {\n if (widget.getRenderState) {\n var renderState = widget.getRenderState(instantSearchInstance.renderState[_this.getIndexId()] || {}, createRenderArgs(instantSearchInstance, _this, widget));\n storeRenderState({\n renderState: renderState,\n instantSearchInstance: instantSearchInstance,\n parent: _this\n });\n }\n });\n widgetsToRender.forEach(function(widget) {\n // At this point, all the variables used below are set. Both `helper`\n // and `derivedHelper` have been created at the `init` step. The attribute\n // `lastResults` might be `null` though. It's possible that a stalled render\n // happens before the result e.g with a dynamically added index the request might\n // be delayed. The render is triggered for the complete tree but some parts do\n // not have results yet.\n if (widget.render) {\n widget.render(createRenderArgs(instantSearchInstance, _this, widget));\n }\n });\n },\n dispose: function dispose() {\n var _this = this;\n localWidgets.forEach(function(widget) {\n if (widget.dispose && helper) {\n // The dispose function is always called once the instance is started\n // (it's an effect of `removeWidgets`). The index is initialized and\n // the Helper is available. We don't care about the return value of\n // `dispose` because the index is removed. We can't call `removeWidgets`\n // because we want to keep the widgets on the instance, to allow idempotent\n // operations on `add` & `remove`.\n widget.dispose({\n helper: helper,\n state: helper.state,\n recommendState: helper.recommendState,\n parent: _this\n });\n }\n });\n localInstantSearchInstance = null;\n localParent = null;\n helper === null || helper === void 0 ? void 0 : helper.removeAllListeners();\n helper = null;\n derivedHelper === null || derivedHelper === void 0 ? void 0 : derivedHelper.detach();\n derivedHelper = null;\n },\n getWidgetUiState: function getWidgetUiState(uiState) {\n return localWidgets.filter(isIndexWidget).filter(function(w) {\n return !w._isolated;\n }).reduce(function(previousUiState, innerIndex) {\n return innerIndex.getWidgetUiState(previousUiState);\n }, _$2(_$3({}, uiState), _({}, indexId, _$3({}, uiState[indexId], localUiState))));\n },\n getWidgetState: function getWidgetState(uiState) {\n return this.getWidgetUiState(uiState);\n },\n getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, param) {\n var uiState = param.uiState;\n return getLocalWidgetsSearchParameters(localWidgets, {\n uiState: uiState,\n initialSearchParameters: searchParameters\n });\n },\n shouldRender: function shouldRender() {\n return true;\n },\n refreshUiState: function refreshUiState() {\n localUiState = getLocalWidgetsUiState(localWidgets, {\n searchParameters: this.getHelper().state,\n helper: this.getHelper()\n }, localUiState);\n },\n setIndexUiState: function setIndexUiState(indexUiState) {\n var nextIndexUiState = typeof indexUiState === 'function' ? indexUiState(localUiState) : indexUiState;\n localInstantSearchInstance.setUiState(function(state) {\n return _$2(_$3({}, state), _({}, indexId, nextIndexUiState));\n });\n }\n };\n};\n/**\n * Walk up the parent chain to find the closest isolated index, or fall back to mainHelper\n */ function nearestIsolatedHelper(current, mainHelper) {\n while(current){\n if (current._isolated) {\n return current.getHelper();\n }\n current = current.getParent();\n }\n return mainHelper;\n}\n\nexport { index as default };\n"],"names":["withUsage","createDocumentationMessageGenerator","name","privateHelperSetState","helper","param","state","recommendState","isPageReset","_uiState","emit","results","lastResults","getLocalWidgetsUiState","widgets","widgetStateOptions","initialUiState","arguments","length","reduce","uiState","widget","isIndexWidget","getWidgetUiState","getWidgetState","getLocalWidgetsSearchParameters","widgetSearchParametersOptions","initialSearchParameters","rest","_$4","getWidgetSearchParameters","dependsOn","getWidgetParameters","getLocalWidgetsRecommendParameters","widgetRecommendParametersOptions","initialRecommendParameters","resetPageFromWidgets","indexWidgets","filter","forEach","widgetHelper","getHelper","resetPage","getWidgets","resolveScopedResultsFromWidgets","scopedResults","current","_scopedResults","concat","apply","indexId","getIndexId","getResults","_$1","index","widgetParams","undefined","indexName","EXPERIMENTAL_isolated","Error","_widgetParams_indexName","_widgetParams_indexId","tmp","isolated","localWidgets","localUiState","localInstantSearchInstance","localParent","derivedHelper","lastValidSearchParameters","hasRecommendWidget","hasSearchWidget","$$type","$$widgetType","_isolated","getIndexName","_state","getResultsForWidget","$$id","this","lastRecommendResults","getPreviousState","getScopedResults","widgetParent","getParent","createURL","nextState","_createURL","_","searchParameters","scheduleLocalSearch","defer","search","addWidgets","_this","Array","isArray","flatWidgets","acc","w","some","init","render","parent","_hasRecommendWidget","_hasSearchWidget","addWidgetId","Boolean","getRenderState","renderState","createInitArgs","_initialUiState","storeRenderState","instantSearchInstance","scheduleSearch","removeWidgets","dispose","indexOf","_flatWidgets_reduce","states","next","cleanedSearchState","cleanedRecommendState","_$5","algoliasearchHelper","RecommendParameters","newState","future","preserveSharedStateOnUnmount","SearchParameters","setState","_instantSearchInstance__initialResults","mainHelper","parameters","recommendParameters","getClient","status","compositionID","searchWithComposition","searchOnlyWithDerivedHelpers","onStateChange","mainIndex","setUiState","searchWithoutTriggeringOnStateChange","searchForFacetValues","facetName","facetValue","maxFacetHits","userState","mergeSearchParameters","resolveSearchParameters","setQueryParameters","isolatedHelper","derivingHelper","nearestIsolatedHelper","derive","indexInitialResults","_initialResults","SearchResults","recommendResults","RecommendResults","params","on","scheduleStalledRender","scheduleRender","recommend","event","onInternalStateChange","hasPendingRequests","widgetsToRender","shouldRender","createRenderArgs","removeAllListeners","detach","previousUiState","innerIndex","_$2","_$3","refreshUiState","setIndexUiState","indexUiState","nextIndexUiState"],"mappings":"k/BAeA,IAAIA,EAAYC,EAAoC,CAChDC,KAAM,iBAMN,SAASC,EAAsBC,EAAQC,GACvC,IAAIC,EAAQD,EAAMC,MAAOC,EAAiBF,EAAME,eAAgBC,EAAcH,EAAMG,YAAaC,EAAWJ,EAAMI,SAC9GH,IAAUF,EAAOE,QACjBF,EAAOE,MAAQA,EACfF,EAAOM,KAAK,SAAU,CAClBJ,MAAOF,EAAOE,MACdK,QAASP,EAAOQ,YAChBJ,YAAaA,EACbC,SAAUA,KAGdF,IAAmBH,EAAOG,iBAC1BH,EAAOG,eAAiBA,EAIhC,CACA,SAASM,EAAuBC,EAASC,GACrC,IAAIC,EAAiBC,UAAUC,OAAS,QAAsB,IAAjBD,UAAU,GAAgBA,UAAU,GAAK,CAAA,EACtF,OAAOH,EAAQK,OAAO,SAASC,EAASC,GACpC,OAAIC,EAAcD,GACPD,EAENC,EAAOE,kBAAqBF,EAAOG,eAGpCH,EAAOE,iBACAF,EAAOE,iBAAiBH,EAASL,GAErCM,EAAOG,eAAeJ,EA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ACvC,EAAGE,EAAIC,EAAI,CAAA,EAAI7J,GAAUoE,EAAE,CAAA,EAAItC,EAAS+H,EAAI,CAAA,EAAI7J,EAAQ8B,GAAUe,KACtE,EACAzC,eAAgB,SAAwBJ,GACpC,OAAO2D,KAAKxD,iBAAiBH,EACjC,EACAU,0BAA2B,SAAmC2D,EAAkBpF,GAC5E,IAAIe,EAAUf,EAAMe,QACpB,OAAOK,EAAgCuC,EAAc,CACjD5C,QAASA,EACTO,wBAAyB8D,GAEjC,EACAiF,aAAc,WACV,OAAO,CACX,EACAQ,eAAgB,WACZjH,EAAepD,EAAuBmD,EAAc,CAChDyB,iBAAkBV,KAAKtC,YAAYnC,MACnCF,OAAQ2E,KAAKtC,aACdwB,EACP,EACAkH,gBAAiB,SAAyBC,GACtC,IAAIC,EAA2C,mBAAjBD,EAA8BA,EAAanH,GAAgBmH,EACzFlH,EAA2B4E,WAAW,SAASxI,GAC3C,OAAO0K,EAAIC,EAAI,CAAA,EAAI3K,GAAQkF,EAAE,CAAA,EAAItC,EAASmI,GAC9C,EACJ,EAER","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../../node_modules/instantsearch.js/es/widgets/index/index.js"],"sourcesContent":["import { _ } from '@swc/helpers/esm/_define_property.js';\nimport { _ as _$5 } from '@swc/helpers/esm/_instanceof.js';\nimport { _ as _$3 } from '@swc/helpers/esm/_object_spread.js';\nimport { _ as _$2 } from '@swc/helpers/esm/_object_spread_props.js';\nimport { _ as _$4 } from '@swc/helpers/esm/_object_without_properties.js';\nimport { _ as _$1 } from '@swc/helpers/esm/_to_consumable_array.js';\nimport algoliasearchHelper from 'algoliasearch-helper';\nimport { addWidgetId } from '../../lib/utils/addWidgetId.js';\nimport { isIndexWidget } from '../../lib/utils/isIndexWidget.js';\nimport { resolveSearchParameters } from '../../lib/utils/resolveSearchParameters.js';\nimport { addInsightsToRecommendParameters } from '../../lib/utils/addInsightsToRecommendParameters.js';\nimport { createDocumentationMessageGenerator } from '../../lib/utils/documentation.js';\nimport { defer } from '../../lib/utils/defer.js';\nimport { mergeSearchParameters } from '../../lib/utils/mergeSearchParameters.js';\nimport { createInitArgs, storeRenderState, createRenderArgs } from '../../lib/utils/render-args.js';\n\nvar withUsage = createDocumentationMessageGenerator({\n name: 'index-widget'\n});\n/**\n * This is the same content as helper._change / setState, but allowing for extra\n * UiState to be synchronized.\n * see: https://github.com/algolia/algoliasearch-helper-js/blob/6b835ffd07742f2d6b314022cce6848f5cfecd4a/src/algoliasearch.helper.js#L1311-L1324\n */ function privateHelperSetState(helper, param) {\n var state = param.state, recommendState = param.recommendState, isPageReset = param.isPageReset, _uiState = param._uiState;\n if (state !== helper.state) {\n helper.state = state;\n helper.emit('change', {\n state: helper.state,\n results: helper.lastResults,\n isPageReset: isPageReset,\n _uiState: _uiState\n });\n }\n if (recommendState !== helper.recommendState) {\n helper.recommendState = recommendState;\n // eslint-disable-next-line no-warning-comments\n // TODO: emit \"change\" event when events for Recommend are implemented\n }\n}\nfunction getLocalWidgetsUiState(widgets, widgetStateOptions) {\n var initialUiState = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};\n return widgets.reduce(function(uiState, widget) {\n if (isIndexWidget(widget)) {\n return uiState;\n }\n if (!widget.getWidgetUiState && !widget.getWidgetState) {\n return uiState;\n }\n if (widget.getWidgetUiState) {\n return widget.getWidgetUiState(uiState, widgetStateOptions);\n }\n return widget.getWidgetState(uiState, widgetStateOptions);\n }, initialUiState);\n}\nfunction getLocalWidgetsSearchParameters(widgets, widgetSearchParametersOptions) {\n var initialSearchParameters = widgetSearchParametersOptions.initialSearchParameters, rest = _$4(widgetSearchParametersOptions, [\n \"initialSearchParameters\"\n ]);\n return widgets.reduce(function(state, widget) {\n if (!widget.getWidgetSearchParameters || isIndexWidget(widget)) {\n return state;\n }\n if (widget.dependsOn === 'search' && widget.getWidgetParameters) {\n return widget.getWidgetParameters(state, rest);\n }\n return widget.getWidgetSearchParameters(state, rest);\n }, initialSearchParameters);\n}\nfunction getLocalWidgetsRecommendParameters(widgets, widgetRecommendParametersOptions) {\n var initialRecommendParameters = widgetRecommendParametersOptions.initialRecommendParameters, rest = _$4(widgetRecommendParametersOptions, [\n \"initialRecommendParameters\"\n ]);\n return widgets.reduce(function(state, widget) {\n if (!isIndexWidget(widget) && widget.dependsOn === 'recommend' && widget.getWidgetParameters) {\n return widget.getWidgetParameters(state, rest);\n }\n return state;\n }, initialRecommendParameters);\n}\nfunction resetPageFromWidgets(widgets) {\n var indexWidgets = widgets.filter(isIndexWidget);\n if (indexWidgets.length === 0) {\n return;\n }\n indexWidgets.forEach(function(widget) {\n var widgetHelper = widget.getHelper();\n privateHelperSetState(widgetHelper, {\n state: widgetHelper.state.resetPage(),\n recommendState: widgetHelper.recommendState,\n isPageReset: true\n });\n resetPageFromWidgets(widget.getWidgets());\n });\n}\nfunction resolveScopedResultsFromWidgets(widgets) {\n var indexWidgets = widgets.filter(isIndexWidget);\n return indexWidgets.reduce(function(scopedResults, current) {\n var _scopedResults;\n return (_scopedResults = scopedResults).concat.apply(_scopedResults, [\n {\n indexId: current.getIndexId(),\n results: current.getResults(),\n helper: current.getHelper()\n }\n ].concat(_$1(resolveScopedResultsFromWidgets(current.getWidgets()))));\n }, []);\n}\nfunction getWidgetsRequestDependencies(widgets) {\n return widgets.reduce(function(dependencies, widget) {\n if (isIndexWidget(widget)) {\n if (widget._isolated) {\n return dependencies;\n }\n var childDependencies = getWidgetsRequestDependencies(widget.getWidgets());\n return {\n hasSearchWidget: dependencies.hasSearchWidget || childDependencies.hasSearchWidget,\n hasRecommendWidget: dependencies.hasRecommendWidget || childDependencies.hasRecommendWidget\n };\n }\n if (widget.dependsOn === 'recommend') {\n return _$2(_$3({}, dependencies), {\n hasRecommendWidget: true\n });\n }\n if (widget.dependsOn === 'none') {\n return dependencies;\n }\n return _$2(_$3({}, dependencies), {\n hasSearchWidget: true\n });\n }, {\n hasSearchWidget: false,\n hasRecommendWidget: false\n });\n}\nfunction recomputeInstantSearchRequestDependencies(instantSearchInstance) {\n var _getWidgetsRequestDependencies = getWidgetsRequestDependencies(instantSearchInstance.mainIndex.getWidgets()), hasSearchWidget = _getWidgetsRequestDependencies.hasSearchWidget, hasRecommendWidget = _getWidgetsRequestDependencies.hasRecommendWidget;\n instantSearchInstance._hasSearchWidget = hasSearchWidget;\n instantSearchInstance._hasRecommendWidget = hasRecommendWidget;\n}\nvar index = function index(widgetParams) {\n var _widgetParams_EXPERIMENTAL_isolated;\n if (widgetParams === undefined || widgetParams.indexName === undefined && !widgetParams.isolated && !widgetParams.EXPERIMENTAL_isolated) {\n throw new Error(withUsage('The `indexName` option is required.'));\n }\n // When isolated=true, we use an empty string as the default indexName.\n // This is intentional: isolated indices do not require a real index name.\n var _widgetParams_indexName = widgetParams.indexName, indexName = _widgetParams_indexName === void 0 ? '' : _widgetParams_indexName, _widgetParams_indexId = widgetParams.indexId, indexId = _widgetParams_indexId === void 0 ? indexName : _widgetParams_indexId, _widgetParams_isolated = widgetParams.isolated, isolated = _widgetParams_isolated === void 0 ? (_widgetParams_EXPERIMENTAL_isolated = widgetParams.EXPERIMENTAL_isolated) !== null && _widgetParams_EXPERIMENTAL_isolated !== void 0 ? _widgetParams_EXPERIMENTAL_isolated : false : _widgetParams_isolated;\n var localWidgets = [];\n var localUiState = {};\n var localInstantSearchInstance = null;\n var localParent = null;\n var helper = null;\n var derivedHelper = null;\n var lastValidSearchParameters = null;\n // The error this index has already rolled back for. Renders also happen for\n // reasons unrelated to a search (a chat panel opening, a recommend result,\n // the stalled timer), and rolling back on every one of them would discard\n // state written after the failed search.\n var restoredForError;\n var recomputeLocalRequestDependencies = function recomputeLocalRequestDependencies() {\n if (localInstantSearchInstance) {\n recomputeInstantSearchRequestDependencies(localInstantSearchInstance);\n }\n };\n return {\n $$type: 'ais.index',\n $$widgetType: 'ais.index',\n _isolated: isolated,\n getIndexName: function getIndexName() {\n return indexName;\n },\n getIndexId: function getIndexId() {\n return indexId;\n },\n getHelper: function getHelper() {\n return helper;\n },\n getResults: function getResults() {\n if (!(derivedHelper === null || derivedHelper === void 0 ? void 0 : derivedHelper.lastResults)) return null;\n // To make the UI optimistic, we patch the state to display to the current\n // one instead of the one associated with the latest results.\n // This means user-driven UI changes (e.g., checked checkbox) are reflected\n // immediately instead of waiting for Algolia to respond, regardless of\n // the status of the network request.\n derivedHelper.lastResults._state = helper.state;\n return derivedHelper.lastResults;\n },\n getResultsForWidget: function getResultsForWidget(widget) {\n if (widget.dependsOn !== 'recommend' || isIndexWidget(widget) || widget.$$id === undefined) {\n return this.getResults();\n }\n if (!(helper === null || helper === void 0 ? void 0 : helper.lastRecommendResults)) {\n return null;\n }\n return helper.lastRecommendResults[widget.$$id];\n },\n getPreviousState: function getPreviousState() {\n return lastValidSearchParameters;\n },\n getScopedResults: function getScopedResults() {\n var widgetParent = this.getParent();\n var widgetSiblings;\n if (widgetParent) {\n widgetSiblings = widgetParent.getWidgets();\n } else if (indexName.length === 0) {\n // The widget is the root but has no index name:\n // we resolve results from its children index widgets\n widgetSiblings = this.getWidgets();\n } else {\n // The widget is the root and has an index name:\n // we consider itself as the only sibling\n widgetSiblings = [\n this\n ];\n }\n return resolveScopedResultsFromWidgets(widgetSiblings);\n },\n getParent: function getParent() {\n return isolated ? null : localParent;\n },\n createURL: function createURL(nextState) {\n if (typeof nextState === 'function') {\n return localInstantSearchInstance._createURL(_({}, indexId, nextState(localUiState)));\n }\n return localInstantSearchInstance._createURL(_({}, indexId, getLocalWidgetsUiState(localWidgets, {\n searchParameters: nextState,\n helper: helper\n })));\n },\n scheduleLocalSearch: defer(function() {\n if (isolated) {\n helper === null || helper === void 0 ? void 0 : helper.search();\n }\n }),\n getWidgets: function getWidgets() {\n return localWidgets;\n },\n addWidgets: function addWidgets(widgets) {\n var _this = this;\n if (!Array.isArray(widgets)) {\n throw new Error(withUsage('The `addWidgets` method expects an array of widgets.'));\n }\n var flatWidgets = widgets.reduce(function(acc, w) {\n return acc.concat(Array.isArray(w) ? w : [\n w\n ]);\n }, []);\n if (flatWidgets.some(function(widget) {\n return typeof widget.init !== 'function' && typeof widget.render !== 'function';\n })) {\n throw new Error(withUsage('The widget definition expects a `render` and/or an `init` method.'));\n }\n flatWidgets.forEach(function(widget) {\n widget.parent = _this;\n if (!isIndexWidget(widget)) {\n addWidgetId(widget);\n }\n });\n localWidgets = localWidgets.concat(flatWidgets);\n recomputeLocalRequestDependencies();\n if (localInstantSearchInstance && Boolean(flatWidgets.length)) {\n privateHelperSetState(helper, {\n state: getLocalWidgetsSearchParameters(localWidgets, {\n uiState: localUiState,\n initialSearchParameters: helper.state\n }),\n recommendState: getLocalWidgetsRecommendParameters(localWidgets, {\n uiState: localUiState,\n initialRecommendParameters: helper.recommendState\n }),\n _uiState: localUiState\n });\n // We compute the render state before calling `init` in a separate loop\n // to construct the whole render state object that is then passed to\n // `init`.\n flatWidgets.forEach(function(widget) {\n if (widget.getRenderState) {\n var renderState = widget.getRenderState(localInstantSearchInstance.renderState[_this.getIndexId()] || {}, createInitArgs(localInstantSearchInstance, _this, localInstantSearchInstance._initialUiState));\n storeRenderState({\n renderState: renderState,\n instantSearchInstance: localInstantSearchInstance,\n parent: _this\n });\n }\n });\n flatWidgets.forEach(function(widget) {\n if (widget.init) {\n widget.init(createInitArgs(localInstantSearchInstance, _this, localInstantSearchInstance._initialUiState));\n }\n });\n if (isolated) {\n this.scheduleLocalSearch();\n } else {\n localInstantSearchInstance.scheduleSearch();\n }\n }\n return this;\n },\n updateWidget: function updateWidget(previousWidget, nextWidget) {\n if (typeof previousWidget.dispose !== 'function') {\n throw new Error(withUsage('The widget definition expects a `dispose` method.'));\n }\n if (typeof nextWidget.init !== 'function' && typeof nextWidget.render !== 'function') {\n throw new Error(withUsage('The widget definition expects a `render` and/or an `init` method.'));\n }\n // The `uiState` as it is before the previous widget is detached, so that\n // the state it owns can be handed over to the next widget.\n var previousUiState = localUiState;\n previousWidget.parent = undefined;\n nextWidget.parent = this;\n if (!isIndexWidget(nextWidget)) {\n addWidgetId(nextWidget);\n }\n // The next widget takes the place of the previous one, so that the order\n // in which widgets contribute to the search parameters is unchanged.\n var nextWidgets = localWidgets.slice();\n var position = nextWidgets.indexOf(previousWidget);\n if (position === -1) {\n nextWidgets.push(nextWidget);\n } else {\n nextWidgets[position] = nextWidget;\n }\n localWidgets = nextWidgets;\n recomputeLocalRequestDependencies();\n if (!localInstantSearchInstance) {\n return this;\n }\n // We still dispose the previous widget, for its side effects. The search\n // state it returns is only used as a base when shared state isn't preserved\n // on unmount, like in `removeWidgets`.\n var disposedState = previousWidget.dispose({\n helper: helper,\n state: helper.state,\n recommendState: helper.recommendState,\n parent: this\n });\n var cleanedRecommendState = _$5(disposedState, algoliasearchHelper.RecommendParameters) ? disposedState : helper.recommendState;\n var cleanedSearchState = disposedState && !_$5(disposedState, algoliasearchHelper.RecommendParameters) ? disposedState : helper.state;\n var initialSearchParameters = localInstantSearchInstance.future.preserveSharedStateOnUnmount ? new algoliasearchHelper.SearchParameters({\n index: this.getIndexName()\n }) : cleanedSearchState;\n // We hand the previous `uiState` over to the next widgets, then read the\n // `uiState` back from them. Widgets only pick up the state they claim, so\n // this drops state that no mounted widget owns anymore (an attribute that\n // changed, for instance) instead of seeding it with `previousUiState`.\n localUiState = getLocalWidgetsUiState(localWidgets, {\n searchParameters: getLocalWidgetsSearchParameters(localWidgets, {\n uiState: previousUiState,\n initialSearchParameters: initialSearchParameters\n }),\n helper: helper\n });\n // The search parameters are then computed again from that narrowed\n // `uiState`, so that they can't hold state the `uiState` doesn't describe.\n var newState = getLocalWidgetsSearchParameters(localWidgets, {\n uiState: localUiState,\n initialSearchParameters: initialSearchParameters\n });\n privateHelperSetState(helper, {\n state: newState,\n recommendState: getLocalWidgetsRecommendParameters(localWidgets, {\n uiState: localUiState,\n initialRecommendParameters: cleanedRecommendState\n }),\n _uiState: localUiState\n });\n if (nextWidget.getRenderState) {\n var renderState = nextWidget.getRenderState(localInstantSearchInstance.renderState[this.getIndexId()] || {}, createInitArgs(localInstantSearchInstance, this, localInstantSearchInstance._initialUiState));\n storeRenderState({\n renderState: renderState,\n instantSearchInstance: localInstantSearchInstance,\n parent: this\n });\n }\n if (nextWidget.init) {\n nextWidget.init(createInitArgs(localInstantSearchInstance, this, localInstantSearchInstance._initialUiState));\n }\n if (isolated) {\n this.scheduleLocalSearch();\n } else {\n localInstantSearchInstance.scheduleSearch();\n }\n return this;\n },\n removeWidgets: function removeWidgets(widgets) {\n var _this = this;\n if (!Array.isArray(widgets)) {\n throw new Error(withUsage('The `removeWidgets` method expects an array of widgets.'));\n }\n var flatWidgets = widgets.reduce(function(acc, w) {\n return acc.concat(Array.isArray(w) ? w : [\n w\n ]);\n }, []);\n if (flatWidgets.some(function(widget) {\n return typeof widget.dispose !== 'function';\n })) {\n throw new Error(withUsage('The widget definition expects a `dispose` method.'));\n }\n localWidgets = localWidgets.filter(function(widget) {\n return flatWidgets.indexOf(widget) === -1;\n });\n flatWidgets.forEach(function(widget) {\n widget.parent = undefined;\n });\n recomputeLocalRequestDependencies();\n if (localInstantSearchInstance && Boolean(flatWidgets.length)) {\n var _flatWidgets_reduce = flatWidgets.reduce(function(states, widget) {\n // the `dispose` method exists at this point we already assert it\n var next = widget.dispose({\n helper: helper,\n state: states.cleanedSearchState,\n recommendState: states.cleanedRecommendState,\n parent: _this\n });\n if (_$5(next, algoliasearchHelper.RecommendParameters)) {\n states.cleanedRecommendState = next;\n } else if (next) {\n states.cleanedSearchState = next;\n }\n return states;\n }, {\n cleanedSearchState: helper.state,\n cleanedRecommendState: helper.recommendState\n }), cleanedSearchState = _flatWidgets_reduce.cleanedSearchState, cleanedRecommendState = _flatWidgets_reduce.cleanedRecommendState;\n var newState = localInstantSearchInstance.future.preserveSharedStateOnUnmount ? getLocalWidgetsSearchParameters(localWidgets, {\n uiState: localUiState,\n initialSearchParameters: new algoliasearchHelper.SearchParameters({\n index: this.getIndexName()\n })\n }) : getLocalWidgetsSearchParameters(localWidgets, {\n uiState: getLocalWidgetsUiState(localWidgets, {\n searchParameters: cleanedSearchState,\n helper: helper\n }),\n initialSearchParameters: cleanedSearchState\n });\n localUiState = getLocalWidgetsUiState(localWidgets, {\n searchParameters: newState,\n helper: helper\n });\n helper.setState(newState);\n helper.recommendState = cleanedRecommendState;\n if (localWidgets.length) {\n if (isolated) {\n this.scheduleLocalSearch();\n } else {\n localInstantSearchInstance.scheduleSearch();\n }\n }\n }\n return this;\n },\n init: function init(param) {\n var _this = this;\n var instantSearchInstance = param.instantSearchInstance, parent = param.parent, uiState = param.uiState;\n var _instantSearchInstance__initialResults;\n if (helper !== null) {\n // helper is already initialized, therefore we do not need to set up\n // any listeners\n return;\n }\n localInstantSearchInstance = instantSearchInstance;\n localParent = parent;\n localUiState = uiState[indexId] || {};\n // The `mainHelper` is already defined at this point. The instance is created\n // inside InstantSearch at the `start` method, which occurs before the `init`\n // step.\n var mainHelper = instantSearchInstance.mainHelper;\n var parameters = getLocalWidgetsSearchParameters(localWidgets, {\n uiState: localUiState,\n initialSearchParameters: new algoliasearchHelper.SearchParameters({\n index: indexName\n })\n });\n var recommendParameters = getLocalWidgetsRecommendParameters(localWidgets, {\n uiState: localUiState,\n initialRecommendParameters: new algoliasearchHelper.RecommendParameters()\n });\n // This Helper is only used for state management we do not care about the\n // `searchClient`. Only the \"main\" Helper created at the `InstantSearch`\n // level is aware of the client.\n helper = algoliasearchHelper(mainHelper.getClient(), parameters.index, parameters);\n helper.recommendState = recommendParameters;\n // We forward the call to `search` to the \"main\" instance of the Helper\n // which is responsible for managing the queries (it's the only one that is\n // aware of the `searchClient`).\n helper.search = function() {\n if (isolated) {\n instantSearchInstance.status = 'loading';\n _this.render({\n instantSearchInstance: instantSearchInstance\n });\n return instantSearchInstance.compositionID ? helper.searchWithComposition() : helper.searchOnlyWithDerivedHelpers();\n }\n if (instantSearchInstance.onStateChange) {\n instantSearchInstance.onStateChange({\n uiState: instantSearchInstance.mainIndex.getWidgetUiState({}),\n setUiState: function setUiState(nextState) {\n return instantSearchInstance.setUiState(nextState, false);\n }\n });\n // We don't trigger a search when controlled because it becomes the\n // responsibility of `setUiState`.\n return mainHelper;\n }\n return mainHelper.search();\n };\n helper.searchWithoutTriggeringOnStateChange = function() {\n return mainHelper.search();\n };\n // We use the same pattern for the `searchForFacetValues`.\n helper.searchForFacetValues = function(facetName, facetValue, maxFacetHits, userState) {\n var state = mergeSearchParameters.apply(void 0, [\n mainHelper.state\n ].concat(_$1(resolveSearchParameters(_this)))).setQueryParameters(userState);\n return mainHelper.searchForFacetValues(facetName, facetValue, maxFacetHits, state);\n };\n var isolatedHelper = indexName ? helper : algoliasearchHelper({}, '__empty_index__', {});\n var derivingHelper = isolated ? isolatedHelper : nearestIsolatedHelper(parent, mainHelper);\n derivedHelper = derivingHelper.derive(function() {\n return mergeSearchParameters.apply(void 0, [\n mainHelper.state\n ].concat(_$1(resolveSearchParameters(_this))));\n }, function() {\n return addInsightsToRecommendParameters(_this.getHelper().recommendState, mainHelper.state);\n });\n var indexInitialResults = (_instantSearchInstance__initialResults = instantSearchInstance._initialResults) === null || _instantSearchInstance__initialResults === void 0 ? void 0 : _instantSearchInstance__initialResults[this.getIndexId()];\n if (indexInitialResults === null || indexInitialResults === void 0 ? void 0 : indexInitialResults.results) {\n // We restore the shape of the results provided to the instance to respect\n // the helper's structure.\n var results = new algoliasearchHelper.SearchResults(new algoliasearchHelper.SearchParameters(indexInitialResults.state), indexInitialResults.results);\n derivedHelper.lastResults = results;\n helper.lastResults = results;\n }\n if (indexInitialResults === null || indexInitialResults === void 0 ? void 0 : indexInitialResults.recommendResults) {\n var recommendResults = new algoliasearchHelper.RecommendResults(new algoliasearchHelper.RecommendParameters({\n params: indexInitialResults.recommendResults.params\n }), indexInitialResults.recommendResults.results);\n derivedHelper.lastRecommendResults = recommendResults;\n helper.lastRecommendResults = recommendResults;\n }\n // Subscribe to the Helper state changes for the page before widgets\n // are initialized. This behavior mimics the original one of the Helper.\n // It makes sense to replicate it at the `init` step. We have another\n // listener on `change` below, once `init` is done.\n helper.on('change', function(param) {\n var isPageReset = param.isPageReset;\n if (isPageReset) {\n resetPageFromWidgets(localWidgets);\n }\n });\n derivedHelper.on('search', function() {\n // The index does not manage the \"staleness\" of the search. This is the\n // responsibility of the main instance. It does not make sense to manage\n // it at the index level because it's either: all of them or none of them\n // that are stalled. The queries are performed into a single network request.\n instantSearchInstance.scheduleStalledRender();\n });\n derivedHelper.on('result', function(param) {\n var results = param.results;\n // The index does not render the results it schedules a new render\n // to let all the other indices emit their own results. It allows us to\n // run the render process in one pass.\n instantSearchInstance.scheduleRender();\n // the derived helper is the one which actually searches, but the helper\n // which is exposed e.g. via instance.helper, doesn't search, and thus\n // does not have access to lastResults, which it used to in pre-federated\n // search behavior.\n helper.lastResults = results;\n lastValidSearchParameters = results === null || results === void 0 ? void 0 : results._state;\n });\n // eslint-disable-next-line no-warning-comments\n // TODO: listen to \"result\" event when events for Recommend are implemented\n derivedHelper.on('recommend:result', function(param) {\n var recommend = param.recommend;\n // The index does not render the results it schedules a new render\n // to let all the other indices emit their own results. It allows us to\n // run the render process in one pass.\n instantSearchInstance.scheduleRender();\n // the derived helper is the one which actually searches, but the helper\n // which is exposed e.g. via instance.helper, doesn't search, and thus\n // does not have access to lastRecommendResults.\n helper.lastRecommendResults = recommend.results;\n });\n // We compute the render state before calling `init` in a separate loop\n // to construct the whole render state object that is then passed to\n // `init`.\n localWidgets.forEach(function(widget) {\n if (widget.getRenderState) {\n var renderState = widget.getRenderState(instantSearchInstance.renderState[_this.getIndexId()] || {}, createInitArgs(instantSearchInstance, _this, uiState));\n storeRenderState({\n renderState: renderState,\n instantSearchInstance: instantSearchInstance,\n parent: _this\n });\n }\n });\n localWidgets.forEach(function(widget) {\n if (widget.init) {\n widget.init(createInitArgs(instantSearchInstance, _this, uiState));\n }\n });\n // Subscribe to the Helper state changes for the `uiState` once widgets\n // are initialized. Until the first render, state changes are part of the\n // configuration step. This is mainly for backward compatibility with custom\n // widgets. When the subscription happens before the `init` step, the (static)\n // configuration of the widget is pushed in the URL. That's what we want to avoid.\n // https://github.com/algolia/instantsearch/pull/994/commits/4a672ae3fd78809e213de0368549ef12e9dc9454\n helper.on('change', function(event) {\n var state = event.state;\n var _uiState = event._uiState;\n localUiState = getLocalWidgetsUiState(localWidgets, {\n searchParameters: state,\n helper: helper\n }, _uiState || {});\n // We don't trigger an internal change when controlled because it\n // becomes the responsibility of `setUiState`.\n if (!instantSearchInstance.onStateChange) {\n instantSearchInstance.onInternalStateChange();\n }\n });\n if (indexInitialResults) {\n // If there are initial results, we're not notified of the next results\n // because we don't trigger an initial search. We therefore need to directly\n // schedule a render that will render the results injected on the helper.\n instantSearchInstance.scheduleRender();\n }\n recomputeLocalRequestDependencies();\n },\n render: function render(param) {\n var _this = this;\n var instantSearchInstance = param.instantSearchInstance;\n // we can't attach a listener to the error event of search, as the error\n // then would no longer be thrown for global handlers.\n if (instantSearchInstance.status !== 'error') {\n restoredForError = undefined;\n } else if (instantSearchInstance.error !== restoredForError && !instantSearchInstance.mainHelper.hasPendingRequests() && lastValidSearchParameters) {\n restoredForError = instantSearchInstance.error;\n helper.setState(lastValidSearchParameters);\n }\n // We only render index widgets if there are no results.\n // This makes sure `render` is never called with `results` being `null`.\n // If it's an isolated index without an index name, we render all widgets,\n // as there are no results to display for the isolated index itself.\n var widgetsToRender = this.getResults() || (derivedHelper === null || derivedHelper === void 0 ? void 0 : derivedHelper.lastRecommendResults) || isolated && !indexName ? localWidgets : localWidgets.filter(function(widget) {\n return widget.shouldRender;\n });\n widgetsToRender = widgetsToRender.filter(function(widget) {\n if (!widget.shouldRender) {\n return true;\n }\n return widget.shouldRender({\n instantSearchInstance: instantSearchInstance\n });\n });\n widgetsToRender.forEach(function(widget) {\n if (widget.getRenderState) {\n var renderState = widget.getRenderState(instantSearchInstance.renderState[_this.getIndexId()] || {}, createRenderArgs(instantSearchInstance, _this, widget));\n storeRenderState({\n renderState: renderState,\n instantSearchInstance: instantSearchInstance,\n parent: _this\n });\n }\n });\n widgetsToRender.forEach(function(widget) {\n // At this point, all the variables used below are set. Both `helper`\n // and `derivedHelper` have been created at the `init` step. The attribute\n // `lastResults` might be `null` though. It's possible that a stalled render\n // happens before the result e.g with a dynamically added index the request might\n // be delayed. The render is triggered for the complete tree but some parts do\n // not have results yet.\n if (widget.render) {\n widget.render(createRenderArgs(instantSearchInstance, _this, widget));\n }\n });\n },\n dispose: function dispose() {\n var _this = this;\n localWidgets.forEach(function(widget) {\n if (widget.dispose && helper) {\n // The dispose function is always called once the instance is started\n // (it's an effect of `removeWidgets`). The index is initialized and\n // the Helper is available. We don't care about the return value of\n // `dispose` because the index is removed. We can't call `removeWidgets`\n // because we want to keep the widgets on the instance, to allow idempotent\n // operations on `add` & `remove`.\n widget.dispose({\n helper: helper,\n state: helper.state,\n recommendState: helper.recommendState,\n parent: _this\n });\n }\n });\n localInstantSearchInstance = null;\n localParent = null;\n helper === null || helper === void 0 ? void 0 : helper.removeAllListeners();\n helper = null;\n derivedHelper === null || derivedHelper === void 0 ? void 0 : derivedHelper.detach();\n derivedHelper = null;\n },\n getWidgetUiState: function getWidgetUiState(uiState) {\n return localWidgets.filter(isIndexWidget).filter(function(w) {\n return !w._isolated;\n }).reduce(function(previousUiState, innerIndex) {\n return innerIndex.getWidgetUiState(previousUiState);\n }, _$2(_$3({}, uiState), _({}, indexId, _$3({}, uiState[indexId], localUiState))));\n },\n getWidgetState: function getWidgetState(uiState) {\n return this.getWidgetUiState(uiState);\n },\n getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, param) {\n var uiState = param.uiState;\n return getLocalWidgetsSearchParameters(localWidgets, {\n uiState: uiState,\n initialSearchParameters: searchParameters\n });\n },\n shouldRender: function shouldRender() {\n return true;\n },\n refreshUiState: function refreshUiState() {\n localUiState = getLocalWidgetsUiState(localWidgets, {\n searchParameters: this.getHelper().state,\n helper: this.getHelper()\n }, localUiState);\n },\n setIndexUiState: function setIndexUiState(indexUiState) {\n var nextIndexUiState = typeof indexUiState === 'function' ? indexUiState(localUiState) : indexUiState;\n localInstantSearchInstance.setUiState(function(state) {\n return _$2(_$3({}, state), _({}, indexId, nextIndexUiState));\n });\n }\n };\n};\n/**\n * Walk up the parent chain to find the closest isolated index, or fall back to mainHelper\n */ function nearestIsolatedHelper(current, mainHelper) {\n while(current){\n if (current._isolated) {\n return current.getHelper();\n }\n current = current.getParent();\n }\n return mainHelper;\n}\n\nexport { index as default };\n"],"names":["withUsage","createDocumentationMessageGenerator","name","privateHelperSetState","helper","param","state","recommendState","isPageReset","_uiState","emit","results","lastResults","getLocalWidgetsUiState","widgets","widgetStateOptions","initialUiState","arguments","length","reduce","uiState","widget","isIndexWidget","getWidgetUiState","getWidgetState","getLocalWidgetsSearchParameters","widgetSearchParametersOptions","initialSearchParameters","rest","_$4","getWidgetSearchParameters","dependsOn","getWidgetParameters","getLocalWidgetsRecommendParameters","widgetRecommendParametersOptions","initialRecommendParameters","resetPageFromWidgets","indexWidgets","filter","forEach","widgetHelper","getHelper","resetPage","getWidgets","resolveScopedResultsFromWidgets","scopedResults","current","_scopedResults","concat","apply","indexId","getIndexId","getResults","_$1","getWidgetsRequestDependencies","dependencies","_isolated","childDependencies","hasSearchWidget","hasRecommendWidget","_$2","_$3","recomputeInstantSearchRequestDependencies","instantSearchInstance","_getWidgetsRequestDependencies","mainIndex","_hasSearchWidget","_hasRecommendWidget","index","widgetParams","_widgetParams_EXPERIMENTAL_isolated","undefined","indexName","isolated","EXPERIMENTAL_isolated","Error","restoredForError","_widgetParams_indexName","_widgetParams_indexId","_widgetParams_isolated","localWidgets","localUiState","localInstantSearchInstance","localParent","derivedHelper","lastValidSearchParameters","recomputeLocalRequestDependencies","$$type","$$widgetType","getIndexName","_state","getResultsForWidget","$$id","this","lastRecommendResults","getPreviousState","getScopedResults","widgetParent","getParent","createURL","nextState","_createURL","_","searchParameters","scheduleLocalSearch","defer","search","addWidgets","_this","Array","isArray","flatWidgets","acc","w","some","init","render","parent","addWidgetId","Boolean","getRenderState","renderState","createInitArgs","_initialUiState","storeRenderState","scheduleSearch","updateWidget","previousWidget","nextWidget","dispose","previousUiState","nextWidgets","slice","position","indexOf","push","disposedState","cleanedRecommendState","_$5","algoliasearchHelper","RecommendParameters","cleanedSearchState","future","preserveSharedStateOnUnmount","SearchParameters","newState","removeWidgets","_flatWidgets_reduce","states","next","setState","_instantSearchInstance__initialResults","mainHelper","parameters","recommendParameters","getClient","status","compositionID","searchWithComposition","searchOnlyWithDerivedHelpers","onStateChange","setUiState","searchWithoutTriggeringOnStateChange","searchForFacetValues","facetName","facetValue","maxFacetHits","userState","mergeSearchParameters","resolveSearchParameters","setQueryParameters","isolatedHelper","derivingHelper","nearestIsolatedHelper","derive","addInsightsToRecommendParameters","indexInitialResults","_initialResults","SearchResults","recommendResults","RecommendResults","params","on","scheduleStalledRender","scheduleRender","recommend","event","onInternalStateChange","error","hasPendingRequests","widgetsToRender","shouldRender","createRenderArgs","removeAllListeners","detach","innerIndex","refreshUiState","setIndexUiState","indexUiState","nextIndexUiState"],"mappings":"ylCAgBA,IAAIA,EAAYC,EAAoC,CAChDC,KAAM,iBAMN,SAASC,EAAsBC,EAAQC,GACvC,IAAIC,EAAQD,EAAMC,MAAOC,EAAiBF,EAAME,eAAgBC,EAAcH,EAAMG,YAAaC,EAAWJ,EAAMI,SAC9GH,IAAUF,EAAOE,QACjBF,EAAOE,MAAQA,EACfF,EAAOM,KAAK,SAAU,CAClBJ,MAAOF,EAAOE,MACdK,QAASP,EAAOQ,YAChBJ,YAAaA,EACbC,SAAUA,KAGdF,IAAmBH,EAAOG,iBAC1BH,EAAOG,eAAiBA,EAIhC,CACA,SAASM,EAAuBC,EAASC,GACrC,IAAIC,EAAiBC,UAAUC,OAAS,QAAsB,IAAjBD,UAAU,GAAgBA,UAAU,GAAK,CAAA,EACtF,OAAOH,EAAQK,OAAO,SAASC,EAASC,GACpC,OAAIC,EAAcD,GACPD,EAENC,EAAOE,kBAAqBF,EAAOG,eAGpCH,EAAOE,iBACAF,EAAOE,i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ACnCF,OAAQyF,KAAKpD,aACdwC,EACP,EACAoH,gBAAiB,SAAyBC,GACtC,IAAIC,EAA2C,mBAAjBD,EAA8BA,EAAarH,GAAgBqH,EACzFpH,EAA2B+E,WAAW,SAAS3J,GAC3C,OAAOsD,EAAIC,EAAI,CAAA,EAAIvD,GAAQgG,EAAE,CAAA,EAAIpD,EAASqJ,GAC9C,EACJ,EAER","x_google_ignoreList":[0]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__require as e}from"./utils.js";var r,t;function i(){if(t)return r;t=1;var i=e(),o=Object.prototype.hasOwnProperty,a=Array.isArray,n={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:i.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictMerge:!0,strictNullHandling:!1,throwOnLimitExceeded:!1},l=function(e){return e.replace(/&#(\d+);/g,function(e,r){return String.fromCharCode(parseInt(r,10))})},c=function(e,r,t){if(e&&"string"==typeof e&&r.comma&&e.indexOf(",")>-1)return e.split(",")
|
|
1
|
+
import{__require as e}from"./utils.js";var r,t;function i(){if(t)return r;t=1;var i=e(),o=Object.prototype.hasOwnProperty,a=Array.isArray,n={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:i.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictMerge:!0,strictNullHandling:!1,throwOnLimitExceeded:!1},l=function(e){return e.replace(/&#(\d+);/g,function(e,r){return String.fromCharCode(parseInt(r,10))})},c=function(e,r,t){if(e&&"string"==typeof e&&r.comma&&e.indexOf(",")>-1){if(r.throwOnLimitExceeded)for(var i=0,o=e.indexOf(",");o>-1;){if((i+=1)>=r.arrayLimit)throw new RangeError("Array limit exceeded. Only "+r.arrayLimit+" element"+(1===r.arrayLimit?"":"s")+" allowed in an array.");o=e.indexOf(",",o+1)}return e.split(",")}if(r.throwOnLimitExceeded&&t>=r.arrayLimit)throw new RangeError("Array limit exceeded. Only "+r.arrayLimit+" element"+(1===r.arrayLimit?"":"s")+" allowed in an array.");return e},s=function(e,r,t,a){if(e){var n=function(e,r){var t=r.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e;if(r.depth<=0){if(!r.plainObjects&&o.call(Object.prototype,t)&&!r.allowPrototypes)return;return[t]}var i=[],a=t.indexOf("["),n=a>=0?t.slice(0,a):t;if(n){if(!r.plainObjects&&o.call(Object.prototype,n)&&!r.allowPrototypes)return;i[i.length]=n}for(var l=t.length,c=a,s=0;c>=0&&s<r.depth;){for(var d=1,p=c+1,y=-1;p<l&&y<0;){var m=t.charCodeAt(p);91===m?d+=1:93===m&&0==(d-=1)&&(y=p),p+=1}if(y<0)return i[i.length]="["+t.slice(c)+"]",i;var f=t.slice(c,y+1),u=f.slice(1,-1);if(!r.plainObjects&&o.call(Object.prototype,u)&&!r.allowPrototypes)return;i[i.length]=f,s+=1,c=t.indexOf("[",y+1)}if(c>=0){if(!0===r.strictDepth)throw new RangeError("Input depth exceeded depth option of "+r.depth+" and strictDepth is true");i[i.length]="["+t.slice(c)+"]"}return i}(e,t);if(n)return function(e,r,t,o){var a=0;if(e.length>0&&"[]"===e[e.length-1]){var n=e.slice(0,-1).join("");a=Array.isArray(r)&&r[n]?r[n].length:0}for(var l=o?r:c(r,t,a),s=e.length-1;s>=0;--s){var d,p=e[s];if("[]"===p&&t.parseArrays)d=i.isOverflow(l)?l:t.allowEmptyArrays&&(""===l||t.strictNullHandling&&null===l)?[]:i.combine([],l,t.arrayLimit,t.plainObjects,t.throwOnLimitExceeded);else{d=t.plainObjects?{__proto__:null}:{};var y="["===p.charAt(0)&&"]"===p.charAt(p.length-1)?p.slice(1,-1):p,m=t.decodeDotInKeys?y.replace(/%2E/g,"."):y,f=parseInt(m,10),u=!isNaN(f)&&p!==m&&String(f)===m&&f>=0&&t.parseArrays;if(t.parseArrays||""!==m)if(u&&f<t.arrayLimit)(d=[])[f]=l;else{if(u&&t.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(1===t.arrayLimit?"":"s")+" allowed in an array.");u?(d[f]=l,i.markOverflow(d,f)):"__proto__"!==m&&(d[m]=l)}else d={0:l}}l=d}return l}(n,r,t,a)}};return r=function(e,r){var t=function(e){if(!e)return n;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.decodeDotInKeys&&"boolean"!=typeof e.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");if(void 0!==e.throwOnLimitExceeded&&"boolean"!=typeof e.throwOnLimitExceeded)throw new TypeError("`throwOnLimitExceeded` option must be a boolean");var r=void 0===e.charset?n.charset:e.charset,t=void 0===e.duplicates?n.duplicates:e.duplicates;if("combine"!==t&&"first"!==t&&"last"!==t)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===e.allowDots?!0===e.decodeDotInKeys||n.allowDots:!!e.allowDots,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:n.allowEmptyArrays,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:n.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:n.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:n.arrayLimit,charset:r,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:n.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:n.comma,decodeDotInKeys:"boolean"==typeof e.decodeDotInKeys?e.decodeDotInKeys:n.decodeDotInKeys,decoder:"function"==typeof e.decoder?e.decoder:n.decoder,delimiter:"string"==typeof e.delimiter||i.isRegExp(e.delimiter)?e.delimiter:n.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:n.depth,duplicates:t,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:n.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:n.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:n.plainObjects,strictDepth:"boolean"==typeof e.strictDepth?!!e.strictDepth:n.strictDepth,strictMerge:"boolean"==typeof e.strictMerge?!!e.strictMerge:n.strictMerge,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:n.strictNullHandling,throwOnLimitExceeded:"boolean"==typeof e.throwOnLimitExceeded&&e.throwOnLimitExceeded}}(r);if(""===e||null==e)return t.plainObjects?{__proto__:null}:{};for(var d="string"==typeof e?function(e,r){var t={__proto__:null},s=r.ignoreQueryPrefix?e.replace(/^\?/,""):e;s=s.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var d=r.parameterLimit===1/0?void 0:r.parameterLimit,p=s.split(r.delimiter,r.throwOnLimitExceeded&&void 0!==d?d+1:d);if(r.throwOnLimitExceeded&&void 0!==d&&p.length>d)throw new RangeError("Parameter limit exceeded. Only "+d+" parameter"+(1===d?"":"s")+" allowed.");var y,m=-1,f=r.charset;if(r.charsetSentinel)for(y=0;y<p.length;++y)0===p[y].indexOf("utf8=")&&("utf8=%E2%9C%93"===p[y]?f="utf-8":"utf8=%26%2310003%3B"===p[y]&&(f="iso-8859-1"),m=y,y=p.length);for(y=0;y<p.length;++y)if(y!==m){var u,h,w=p[y],b=w.indexOf("]="),g=-1===b?w.indexOf("="):b+1;if(-1===g?(u=r.decoder(w,n.decoder,f,"key"),h=r.strictNullHandling?null:""):null!==(u=r.decoder(w.slice(0,g),n.decoder,f,"key"))&&(h=i.maybeMap(c(w.slice(g+1),r,a(t[u])?t[u].length:0),function(e){return r.decoder(e,n.decoder,f,"value")})),h&&r.interpretNumericEntities&&"iso-8859-1"===f&&(h=l(String(h))),w.indexOf("[]=")>-1&&(h=a(h)?[h]:h),r.comma&&a(h)&&h.length>r.arrayLimit&&(h=i.combine([],h,r.arrayLimit,r.plainObjects,r.throwOnLimitExceeded)),null!==u){var O=o.call(t,u);O&&("combine"===r.duplicates||w.indexOf("[]=")>-1)?t[u]=i.combine(t[u],h,r.arrayLimit,r.plainObjects,r.throwOnLimitExceeded):O&&"last"!==r.duplicates||(t[u]=h)}}return t}(e,t):e,p=t.plainObjects?{__proto__:null}:{},y=Object.keys(d),m=0;m<y.length;++m){var f=y[m],u=s(f,d[f],t,"string"==typeof e);p=i.merge(p,u,t)}return!0===t.allowSparse?p:i.compact(p)}}export{i as __require};
|
|
2
2
|
//# sourceMappingURL=parse.js.map
|