From 52cb17a97d4eae286f7e9859614eae20d1cbdba0 Mon Sep 17 00:00:00 2001 From: Abhijit Bhatnagar Date: Wed, 10 Jan 2024 12:51:18 +0530 Subject: [PATCH 1/2] making the resource link dynamic --- bootstrap.php | 4 ++ includes/Data/Brands.php | 76 ++++++++++++++++++++++++++++++++++ includes/HelpCenter.php | 10 ++++- src/components/NoResults.js | 11 +---- src/components/ResourceLink.js | 19 +++++++++ 5 files changed, 109 insertions(+), 11 deletions(-) create mode 100644 includes/Data/Brands.php create mode 100644 src/components/ResourceLink.js diff --git a/bootstrap.php b/bootstrap.php index 91297e5..8e7c628 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -2,6 +2,7 @@ use NewfoldLabs\WP\Module\HelpCenter\HelpCenter; use NewfoldLabs\WP\ModuleLoader\Container; +use NewfoldLabs\WP\Module\HelpCenter\Data\Brands; use function NewfoldLabs\WP\ModuleLoader\register; if ( function_exists( 'add_action' ) ) { @@ -31,6 +32,9 @@ function () { } new HelpCenter( $container ); + + // Define the brand + Brands::set_current_brand( $container ); }, 'isActive' => true, 'isHidden' => true, diff --git a/includes/Data/Brands.php b/includes/Data/Brands.php new file mode 100644 index 0000000..4430a4d --- /dev/null +++ b/includes/Data/Brands.php @@ -0,0 +1,76 @@ + array( + 'brand' => 'bluehost', + 'name' => 'Bluehost', + 'url' => 'https://bluehost.com', + 'helpURL' => 'https://www.bluehost.com/help', + ), + 'hostgator-us' => array( + 'brand' => 'hostgator', + 'name' => 'HostGator', + 'url' => 'https://www.hostgator.com', + 'helpUrl' => 'https://www.hostgator.com/help', + ), + 'hostgator-br' => array( + 'brand' => 'hostgator-br', + 'name' => 'HostGator', + 'url' => 'https://www.hostgator.com.br', + 'helpUrl' => 'https://suporte.hostgator.com.br/hc/pt-br', + ), + ); + } + + /** + * Sets the hosting brand. + * + * @param object $container The brand plugin container. + */ + public static function set_current_brand( $container ) { + if ( ! defined('NFD_HELPCENTER_PLUGIN_BRAND') ) { + $brand = $container->plugin()->brand; + if (empty($brand)) { + $brand = 'wordpress'; + } + + if (false !== strpos($brand, 'hostgator')) { + $region = strtolower($container->plugin()->region); + $brand = "hostgator-{$region}"; + } + + $brand = sanitize_title_with_dashes(str_replace('_', '-', $brand)); + + define('NFD_HELPCENTER_PLUGIN_BRAND', $brand); + } + } + + /** + * Returns the resource link. + * + * @param string $brand_name The brand name for which the link is to be fetched. + * @return string + */ + public static function get_resource_link_for_brand( $brand_name ) { + $brands = self::get_brands(); + if ( isset( $brands[ $brand_name ][ 'helpURL' ] ) ) { + return $brands[ $brand_name ][ 'helpURL' ]; + } + return ''; + } +} diff --git a/includes/HelpCenter.php b/includes/HelpCenter.php index 2547738..b9e42b7 100644 --- a/includes/HelpCenter.php +++ b/includes/HelpCenter.php @@ -4,6 +4,7 @@ use NewfoldLabs\WP\Module\HelpCenter\I18nLoader; use NewfoldLabs\WP\ModuleLoader\Container; +use NewfoldLabs\WP\Module\HelpCenter\Data\Brands; /** * The class to initialize and load the module. @@ -115,12 +116,17 @@ public function register_assets() { \wp_enqueue_style( 'stylesheet', NFD_HELPCENTER_PLUGIN_URL . 'vendor/newfold-labs/wp-module-help-center/build/index.css', - null, '1', 'screen' + array(), '1', 'screen' ); \wp_add_inline_script( self::$slug, - 'var nfdHelpCenter =' . wp_json_encode( array( 'restUrl' => \get_home_url() . '/index.php?rest_route=', ) ) . ';', + 'var nfdHelpCenter =' . wp_json_encode( + array( + 'restUrl' => \get_home_url() . '/index.php?rest_route=', + 'resourceLink' => Brands::get_resource_link_for_brand( NFD_HELPCENTER_PLUGIN_BRAND ) + ) + ) . ';', 'before' ); } diff --git a/src/components/NoResults.js b/src/components/NoResults.js index affe3da..6d1de88 100644 --- a/src/components/NoResults.js +++ b/src/components/NoResults.js @@ -1,5 +1,6 @@ import { __ } from '@wordpress/i18n'; import { ReactComponent as NoResultIllustration } from '../icons/no-result.svg'; +import ResourceLink from './ResourceLink'; const NoResults = () => { return ( @@ -24,15 +25,7 @@ const NoResults = () => { 'wp-module-help-center' ) }

-

- { __( - 'In the meantime, try searching our', - 'wp-module-help-center' - ) }{ ' ' } - - { __( 'Resource center.', 'wp-module-help-center' ) } - -

+
); diff --git a/src/components/ResourceLink.js b/src/components/ResourceLink.js new file mode 100644 index 0000000..cffc65b --- /dev/null +++ b/src/components/ResourceLink.js @@ -0,0 +1,19 @@ +import { __ } from '@wordpress/i18n'; + +const ResourceLink = () => { + if ( window?.nfdHelpCenter?.resourceLink ) { + return ( +

+ { __( + 'In the meantime, try searching our', + 'wp-module-help-center' + ) }{ ' ' } + + { __( 'Resource center.', 'wp-module-help-center' ) } + +

+ ); + } +}; + +export default ResourceLink; From 9014b60933186d42f898a3c2816ade77e6dd1715 Mon Sep 17 00:00:00 2001 From: Abhijit Bhatnagar Date: Wed, 10 Jan 2024 19:19:59 +0530 Subject: [PATCH 2/2] creating a new build --- build/index.asset.php | 2 +- build/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/index.asset.php b/build/index.asset.php index 7dd0bf9..ecb2c72 100644 --- a/build/index.asset.php +++ b/build/index.asset.php @@ -1 +1 @@ - array('lodash', 'react', 'wp-api-fetch', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '47871efacaa34562e3f9'); + array('lodash', 'react', 'wp-api-fetch', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '14909b5dc8e12284ee9c'); diff --git a/build/index.js b/build/index.js index c74b2e4..35fd168 100644 --- a/build/index.js +++ b/build/index.js @@ -1 +1 @@ -!function(){var e={7331:function(e){function t(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(e){return"function"==typeof e}function r(e){return"object"==typeof e&&null!==e}function i(e){return void 0===e}e.exports=t,t.prototype._events=void 0,t.prototype._maxListeners=void 0,t.defaultMaxListeners=10,t.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},t.prototype.emit=function(e){var t,a,o,s,c,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||r(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}if(i(a=this._events[e]))return!1;if(n(a))switch(arguments.length){case 1:a.call(this);break;case 2:a.call(this,arguments[1]);break;case 3:a.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),a.apply(this,s)}else if(r(a))for(s=Array.prototype.slice.call(arguments,1),o=(u=a.slice()).length,c=0;c0&&this._events[e].length>o&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},t.prototype.on=t.prototype.addListener,t.prototype.once=function(e,t){if(!n(t))throw TypeError("listener must be a function");var r=!1;function i(){this.removeListener(e,i),r||(r=!0,t.apply(this,arguments))}return i.listener=t,this.on(e,i),this},t.prototype.removeListener=function(e,t){var i,a,o,s;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(o=(i=this._events[e]).length,a=-1,i===t||n(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(r(i)){for(s=o;s-- >0;)if(i[s]===t||i[s].listener&&i[s].listener===t){a=s;break}if(a<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(a,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},t.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},t.prototype.listeners=function(e){return this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},t.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},t.listenerCount=function(e,t){return e.listenerCount(t)}},8131:function(e,t,n){"use strict";var r=n(9374),i=n(7775),a=n(3076);function o(e,t,n){return new r(e,t,n)}o.version=n(4336),o.AlgoliaSearchHelper=r,o.SearchParameters=i,o.SearchResults=a,e.exports=o},8078:function(e,t,n){"use strict";var r=n(7331);function i(e,t){this.main=e,this.fn=t,this.lastResults=null}n(4853)(i,r),i.prototype.detach=function(){this.removeAllListeners(),this.main.detachDerivedHelper(this)},i.prototype.getModifiedState=function(e){return this.fn(e)},e.exports=i},2437:function(e,t,n){"use strict";var r=n(2344),i=n(116),a=n(9803),o={addRefinement:function(e,t,n){if(o.isRefined(e,t,n))return e;var i=""+n,a=e[t]?e[t].concat(i):[i],s={};return s[t]=a,r({},s,e)},removeRefinement:function(e,t,n){if(void 0===n)return o.clearRefinement(e,(function(e,n){return t===n}));var r=""+n;return o.clearRefinement(e,(function(e,n){return t===n&&r===e}))},toggleRefinement:function(e,t,n){if(void 0===n)throw new Error("toggleRefinement should be used with a value");return o.isRefined(e,t,n)?o.removeRefinement(e,t,n):o.addRefinement(e,t,n)},clearRefinement:function(e,t,n){if(void 0===t)return i(e)?{}:e;if("string"==typeof t)return a(e,[t]);if("function"==typeof t){var r=!1,o=Object.keys(e).reduce((function(i,a){var o=e[a]||[],s=o.filter((function(e){return!t(e,a,n)}));return s.length!==o.length&&(r=!0),i[a]=s,i}),{});return r?o:e}},isRefined:function(e,t,n){var r=Boolean(e[t])&&e[t].length>0;if(void 0===n||!r)return r;var i=""+n;return-1!==e[t].indexOf(i)}};e.exports=o},7775:function(e,t,n){"use strict";var r=n(2344),i=n(7888),a=n(2686),o=n(185),s=n(116),c=n(9803),u=n(8023),l=n(6801),f=n(2437);function h(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((function(e,n){return h(t[n],e)})):e===t}function p(e){var t=e?p._parseNumbers(e):{};void 0===t.userToken||l(t.userToken)||console.warn("[algoliasearch-helper] The `userToken` parameter is invalid. This can lead to wrong analytics.\n - Format: [a-zA-Z0-9_-]{1,64}"),this.facets=t.facets||[],this.disjunctiveFacets=t.disjunctiveFacets||[],this.hierarchicalFacets=t.hierarchicalFacets||[],this.facetsRefinements=t.facetsRefinements||{},this.facetsExcludes=t.facetsExcludes||{},this.disjunctiveFacetsRefinements=t.disjunctiveFacetsRefinements||{},this.numericRefinements=t.numericRefinements||{},this.tagRefinements=t.tagRefinements||[],this.hierarchicalFacetsRefinements=t.hierarchicalFacetsRefinements||{};var n=this;Object.keys(t).forEach((function(e){var r=-1!==p.PARAMETERS.indexOf(e),i=void 0!==t[e];!r&&i&&(n[e]=t[e])}))}p.PARAMETERS=Object.keys(new p),p._parseNumbers=function(e){if(e instanceof p)return e;var t={};if(["aroundPrecision","aroundRadius","getRankingInfo","minWordSizefor2Typos","minWordSizefor1Typo","page","maxValuesPerFacet","distinct","minimumAroundRadius","hitsPerPage","minProximity"].forEach((function(n){var r=e[n];if("string"==typeof r){var i=parseFloat(r);t[n]=isNaN(i)?r:i}})),Array.isArray(e.insideBoundingBox)&&(t.insideBoundingBox=e.insideBoundingBox.map((function(e){return Array.isArray(e)?e.map((function(e){return parseFloat(e)})):e}))),e.numericRefinements){var n={};Object.keys(e.numericRefinements).forEach((function(t){var r=e.numericRefinements[t]||{};n[t]={},Object.keys(r).forEach((function(e){var i=r[e].map((function(e){return Array.isArray(e)?e.map((function(e){return"string"==typeof e?parseFloat(e):e})):"string"==typeof e?parseFloat(e):e}));n[t][e]=i}))})),t.numericRefinements=n}return o({},e,t)},p.make=function(e){var t=new p(e);return(e.hierarchicalFacets||[]).forEach((function(e){if(e.rootPath){var n=t.getHierarchicalRefinement(e.name);n.length>0&&0!==n[0].indexOf(e.rootPath)&&(t=t.clearRefinements(e.name)),0===(n=t.getHierarchicalRefinement(e.name)).length&&(t=t.toggleHierarchicalFacetRefinement(e.name,e.rootPath))}})),t},p.validate=function(e,t){var n=t||{};return e.tagFilters&&n.tagRefinements&&n.tagRefinements.length>0?new Error("[Tags] Cannot switch from the managed tag API to the advanced API. It is probably an error, if it is really what you want, you should first clear the tags with clearTags method."):e.tagRefinements.length>0&&n.tagFilters?new Error("[Tags] Cannot switch from the advanced tag API to the managed API. It is probably an error, if it is not, you should first clear the tags with clearTags method."):e.numericFilters&&n.numericRefinements&&s(n.numericRefinements)?new Error("[Numeric filters] Can't switch from the advanced to the managed API. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):s(e.numericRefinements)&&n.numericFilters?new Error("[Numeric filters] Can't switch from the managed API to the advanced. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):null},p.prototype={constructor:p,clearRefinements:function(e){var t={numericRefinements:this._clearNumericRefinements(e),facetsRefinements:f.clearRefinement(this.facetsRefinements,e,"conjunctiveFacet"),facetsExcludes:f.clearRefinement(this.facetsExcludes,e,"exclude"),disjunctiveFacetsRefinements:f.clearRefinement(this.disjunctiveFacetsRefinements,e,"disjunctiveFacet"),hierarchicalFacetsRefinements:f.clearRefinement(this.hierarchicalFacetsRefinements,e,"hierarchicalFacet")};return t.numericRefinements===this.numericRefinements&&t.facetsRefinements===this.facetsRefinements&&t.facetsExcludes===this.facetsExcludes&&t.disjunctiveFacetsRefinements===this.disjunctiveFacetsRefinements&&t.hierarchicalFacetsRefinements===this.hierarchicalFacetsRefinements?this:this.setQueryParameters(t)},clearTags:function(){return void 0===this.tagFilters&&0===this.tagRefinements.length?this:this.setQueryParameters({tagFilters:void 0,tagRefinements:[]})},setIndex:function(e){return e===this.index?this:this.setQueryParameters({index:e})},setQuery:function(e){return e===this.query?this:this.setQueryParameters({query:e})},setPage:function(e){return e===this.page?this:this.setQueryParameters({page:e})},setFacets:function(e){return this.setQueryParameters({facets:e})},setDisjunctiveFacets:function(e){return this.setQueryParameters({disjunctiveFacets:e})},setHitsPerPage:function(e){return this.hitsPerPage===e?this:this.setQueryParameters({hitsPerPage:e})},setTypoTolerance:function(e){return this.typoTolerance===e?this:this.setQueryParameters({typoTolerance:e})},addNumericRefinement:function(e,t,n){var r=u(n);if(this.isNumericRefined(e,t,r))return this;var i=o({},this.numericRefinements);return i[e]=o({},i[e]),i[e][t]?(i[e][t]=i[e][t].slice(),i[e][t].push(r)):i[e][t]=[r],this.setQueryParameters({numericRefinements:i})},getConjunctiveRefinements:function(e){return this.isConjunctiveFacet(e)&&this.facetsRefinements[e]||[]},getDisjunctiveRefinements:function(e){return this.isDisjunctiveFacet(e)&&this.disjunctiveFacetsRefinements[e]||[]},getHierarchicalRefinement:function(e){return this.hierarchicalFacetsRefinements[e]||[]},getExcludeRefinements:function(e){return this.isConjunctiveFacet(e)&&this.facetsExcludes[e]||[]},removeNumericRefinement:function(e,t,n){var r=n;return void 0!==r?this.isNumericRefined(e,t,r)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(n,i){return i===e&&n.op===t&&h(n.val,u(r))}))}):this:void 0!==t?this.isNumericRefined(e,t)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(n,r){return r===e&&n.op===t}))}):this:this.isNumericRefined(e)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(t,n){return n===e}))}):this},getNumericRefinements:function(e){return this.numericRefinements[e]||{}},getNumericRefinement:function(e,t){return this.numericRefinements[e]&&this.numericRefinements[e][t]},_clearNumericRefinements:function(e){if(void 0===e)return s(this.numericRefinements)?{}:this.numericRefinements;if("string"==typeof e)return c(this.numericRefinements,[e]);if("function"==typeof e){var t=!1,n=this.numericRefinements,r=Object.keys(n).reduce((function(r,i){var a=n[i],o={};return a=a||{},Object.keys(a).forEach((function(n){var r=a[n]||[],s=[];r.forEach((function(t){e({val:t,op:n},i,"numeric")||s.push(t)})),s.length!==r.length&&(t=!0),o[n]=s})),r[i]=o,r}),{});return t?r:this.numericRefinements}},addFacet:function(e){return this.isConjunctiveFacet(e)?this:this.setQueryParameters({facets:this.facets.concat([e])})},addDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this:this.setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.concat([e])})},addHierarchicalFacet:function(e){if(this.isHierarchicalFacet(e.name))throw new Error("Cannot declare two hierarchical facets with the same name: `"+e.name+"`");return this.setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.concat([e])})},addFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsRefinements,e,t)?this:this.setQueryParameters({facetsRefinements:f.addRefinement(this.facetsRefinements,e,t)})},addExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsExcludes,e,t)?this:this.setQueryParameters({facetsExcludes:f.addRefinement(this.facetsExcludes,e,t)})},addDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return f.isRefined(this.disjunctiveFacetsRefinements,e,t)?this:this.setQueryParameters({disjunctiveFacetsRefinements:f.addRefinement(this.disjunctiveFacetsRefinements,e,t)})},addTagRefinement:function(e){if(this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.concat(e)};return this.setQueryParameters(t)},removeFacet:function(e){return this.isConjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({facets:this.facets.filter((function(t){return t!==e}))}):this},removeDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.filter((function(t){return t!==e}))}):this},removeHierarchicalFacet:function(e){return this.isHierarchicalFacet(e)?this.clearRefinements(e).setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.filter((function(t){return t.name!==e}))}):this},removeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsRefinements,e,t)?this.setQueryParameters({facetsRefinements:f.removeRefinement(this.facetsRefinements,e,t)}):this},removeExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsExcludes,e,t)?this.setQueryParameters({facetsExcludes:f.removeRefinement(this.facetsExcludes,e,t)}):this},removeDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return f.isRefined(this.disjunctiveFacetsRefinements,e,t)?this.setQueryParameters({disjunctiveFacetsRefinements:f.removeRefinement(this.disjunctiveFacetsRefinements,e,t)}):this},removeTagRefinement:function(e){if(!this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.filter((function(t){return t!==e}))};return this.setQueryParameters(t)},toggleRefinement:function(e,t){return this.toggleFacetRefinement(e,t)},toggleFacetRefinement:function(e,t){if(this.isHierarchicalFacet(e))return this.toggleHierarchicalFacetRefinement(e,t);if(this.isConjunctiveFacet(e))return this.toggleConjunctiveFacetRefinement(e,t);if(this.isDisjunctiveFacet(e))return this.toggleDisjunctiveFacetRefinement(e,t);throw new Error("Cannot refine the undeclared facet "+e+"; it should be added to the helper options facets, disjunctiveFacets or hierarchicalFacets")},toggleConjunctiveFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsRefinements:f.toggleRefinement(this.facetsRefinements,e,t)})},toggleExcludeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsExcludes:f.toggleRefinement(this.facetsExcludes,e,t)})},toggleDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return this.setQueryParameters({disjunctiveFacetsRefinements:f.toggleRefinement(this.disjunctiveFacetsRefinements,e,t)})},toggleHierarchicalFacetRefinement:function(e,t){if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration");var n=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e)),i={};return void 0!==this.hierarchicalFacetsRefinements[e]&&this.hierarchicalFacetsRefinements[e].length>0&&(this.hierarchicalFacetsRefinements[e][0]===t||0===this.hierarchicalFacetsRefinements[e][0].indexOf(t+n))?-1===t.indexOf(n)?i[e]=[]:i[e]=[t.slice(0,t.lastIndexOf(n))]:i[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:r({},i,this.hierarchicalFacetsRefinements)})},addHierarchicalFacetRefinement:function(e,t){if(this.isHierarchicalFacetRefined(e))throw new Error(e+" is already refined.");if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration.");var n={};return n[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:r({},n,this.hierarchicalFacetsRefinements)})},removeHierarchicalFacetRefinement:function(e){if(!this.isHierarchicalFacetRefined(e))return this;var t={};return t[e]=[],this.setQueryParameters({hierarchicalFacetsRefinements:r({},t,this.hierarchicalFacetsRefinements)})},toggleTagRefinement:function(e){return this.isTagRefined(e)?this.removeTagRefinement(e):this.addTagRefinement(e)},isDisjunctiveFacet:function(e){return this.disjunctiveFacets.indexOf(e)>-1},isHierarchicalFacet:function(e){return void 0!==this.getHierarchicalFacetByName(e)},isConjunctiveFacet:function(e){return this.facets.indexOf(e)>-1},isFacetRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&f.isRefined(this.facetsRefinements,e,t)},isExcludeRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&f.isRefined(this.facetsExcludes,e,t)},isDisjunctiveFacetRefined:function(e,t){return!!this.isDisjunctiveFacet(e)&&f.isRefined(this.disjunctiveFacetsRefinements,e,t)},isHierarchicalFacetRefined:function(e,t){if(!this.isHierarchicalFacet(e))return!1;var n=this.getHierarchicalRefinement(e);return t?-1!==n.indexOf(t):n.length>0},isNumericRefined:function(e,t,n){if(void 0===n&&void 0===t)return Boolean(this.numericRefinements[e]);var r=this.numericRefinements[e]&&void 0!==this.numericRefinements[e][t];if(void 0===n||!r)return r;var a,o,s=u(n),c=void 0!==(a=this.numericRefinements[e][t],o=s,i(a,(function(e){return h(e,o)})));return r&&c},isTagRefined:function(e){return-1!==this.tagRefinements.indexOf(e)},getRefinedDisjunctiveFacets:function(){var e=this,t=a(Object.keys(this.numericRefinements).filter((function(t){return Object.keys(e.numericRefinements[t]).length>0})),this.disjunctiveFacets);return Object.keys(this.disjunctiveFacetsRefinements).filter((function(t){return e.disjunctiveFacetsRefinements[t].length>0})).concat(t).concat(this.getRefinedHierarchicalFacets()).sort()},getRefinedHierarchicalFacets:function(){var e=this;return a(this.hierarchicalFacets.map((function(e){return e.name})),Object.keys(this.hierarchicalFacetsRefinements).filter((function(t){return e.hierarchicalFacetsRefinements[t].length>0}))).sort()},getUnrefinedDisjunctiveFacets:function(){var e=this.getRefinedDisjunctiveFacets();return this.disjunctiveFacets.filter((function(t){return-1===e.indexOf(t)}))},managedParameters:["index","facets","disjunctiveFacets","facetsRefinements","hierarchicalFacets","facetsExcludes","disjunctiveFacetsRefinements","numericRefinements","tagRefinements","hierarchicalFacetsRefinements"],getQueryParams:function(){var e=this.managedParameters,t={},n=this;return Object.keys(this).forEach((function(r){var i=n[r];-1===e.indexOf(r)&&void 0!==i&&(t[r]=i)})),t},setQueryParameter:function(e,t){if(this[e]===t)return this;var n={};return n[e]=t,this.setQueryParameters(n)},setQueryParameters:function(e){if(!e)return this;var t=p.validate(this,e);if(t)throw t;var n=this,r=p._parseNumbers(e),i=Object.keys(this).reduce((function(e,t){return e[t]=n[t],e}),{}),a=Object.keys(r).reduce((function(e,t){var n=void 0!==e[t],i=void 0!==r[t];return n&&!i?c(e,[t]):(i&&(e[t]=r[t]),e)}),i);return new this.constructor(a)},resetPage:function(){return void 0===this.page?this:this.setPage(0)},_getHierarchicalFacetSortBy:function(e){return e.sortBy||["isRefined:desc","name:asc"]},_getHierarchicalFacetSeparator:function(e){return e.separator||" > "},_getHierarchicalRootPath:function(e){return e.rootPath||null},_getHierarchicalShowParentLevel:function(e){return"boolean"!=typeof e.showParentLevel||e.showParentLevel},getHierarchicalFacetByName:function(e){return i(this.hierarchicalFacets,(function(t){return t.name===e}))},getHierarchicalFacetBreadcrumb:function(e){if(!this.isHierarchicalFacet(e))return[];var t=this.getHierarchicalRefinement(e)[0];if(!t)return[];var n=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e));return t.split(n).map((function(e){return e.trim()}))},toString:function(){return JSON.stringify(this,null,2)}},e.exports=p},210:function(e,t,n){"use strict";e.exports=function(e){return function(t,n){var r=e.hierarchicalFacets[n],u=e.hierarchicalFacetsRefinements[r.name]&&e.hierarchicalFacetsRefinements[r.name][0]||"",l=e._getHierarchicalFacetSeparator(r),f=e._getHierarchicalRootPath(r),h=e._getHierarchicalShowParentLevel(r),p=a(e._getHierarchicalFacetSortBy(r)),d=t.every((function(e){return e.exhaustive})),m=function(e,t,n,r,a){return function(u,l,f){var h=u;if(f>0){var p=0;for(h=u;p-1})));if(u){var l=u.attributes.indexOf(t),h=s(e.hierarchicalFacets,(function(e){return e.name===u.name}));c.hierarchicalFacets[h][l]={attribute:t,data:i,exhaustive:a.exhaustiveFacetsCount}}else{var p,d=-1!==e.disjunctiveFacets.indexOf(t),v=-1!==e.facets.indexOf(t);d&&(p=y[t],c.disjunctiveFacets[p]={name:t,data:i,exhaustive:a.exhaustiveFacetsCount},m(c.disjunctiveFacets[p],a.facets_stats,t)),v&&(p=f[t],c.facets[p]={name:t,data:i,exhaustive:a.exhaustiveFacetsCount},m(c.facets[p],a.facets_stats,t))}})),this.hierarchicalFacets=r(this.hierarchicalFacets),l.forEach((function(n){var r=t[v],o=r&&r.facets?r.facets:{},l=e.getHierarchicalFacetByName(n);Object.keys(o).forEach((function(t){var n,f=o[t];if(l){n=s(e.hierarchicalFacets,(function(e){return e.name===l.name}));var p=s(c.hierarchicalFacets[n],(function(e){return e.attribute===t}));if(-1===p)return;c.hierarchicalFacets[n][p].data=u({},c.hierarchicalFacets[n][p].data,f)}else{n=y[t];var d=a.facets&&a.facets[t]||{};c.disjunctiveFacets[n]={name:t,data:i({},f,d),exhaustive:r.exhaustiveFacetsCount},m(c.disjunctiveFacets[n],r.facets_stats,t),e.disjunctiveFacetsRefinements[t]&&e.disjunctiveFacetsRefinements[t].forEach((function(r){!c.disjunctiveFacets[n].data[r]&&e.disjunctiveFacetsRefinements[t].indexOf(h(r))>-1&&(c.disjunctiveFacets[n].data[r]=0)}))}})),v++})),e.getRefinedHierarchicalFacets().forEach((function(n){var r=e.getHierarchicalFacetByName(n),a=e._getHierarchicalFacetSeparator(r),o=e.getHierarchicalRefinement(n);0===o.length||o[0].split(a).length<2||t.slice(v).forEach((function(t){var n=t&&t.facets?t.facets:{};Object.keys(n).forEach((function(t){var u=n[t],l=s(e.hierarchicalFacets,(function(e){return e.name===r.name})),f=s(c.hierarchicalFacets[l],(function(e){return e.attribute===t}));if(-1!==f){var h={};if(o.length>0){var p=o[0].split(a)[0];h[p]=c.hierarchicalFacets[l][f].data[p]}c.hierarchicalFacets[l][f].data=i(h,u,c.hierarchicalFacets[l][f].data)}})),v++}))})),Object.keys(e.facetsExcludes).forEach((function(t){var n=e.facetsExcludes[t],r=f[t];c.facets[r]={name:t,data:g[t],exhaustive:a.exhaustiveFacetsCount},n.forEach((function(e){c.facets[r]=c.facets[r]||{name:t},c.facets[r].data=c.facets[r].data||{},c.facets[r].data[e]=0}))})),this.hierarchicalFacets=this.hierarchicalFacets.map(p(e)),this.facets=r(this.facets),this.disjunctiveFacets=r(this.disjunctiveFacets),this._state=e}function v(e,t){function n(e){return e.name===t}if(e._state.isConjunctiveFacet(t)){var r=o(e.facets,n);return r?Object.keys(r.data).map((function(n){var i=f(n);return{name:n,escapedValue:i,count:r.data[n],isRefined:e._state.isFacetRefined(t,i),isExcluded:e._state.isExcludeRefined(t,n)}})):[]}if(e._state.isDisjunctiveFacet(t)){var i=o(e.disjunctiveFacets,n);return i?Object.keys(i.data).map((function(n){var r=f(n);return{name:n,escapedValue:r,count:i.data[n],isRefined:e._state.isDisjunctiveFacetRefined(t,r)}})):[]}if(e._state.isHierarchicalFacet(t)){var a=o(e.hierarchicalFacets,n);if(!a)return a;var s=e._state.getHierarchicalFacetByName(t),c=e._state._getHierarchicalFacetSeparator(s),u=h(e._state.getHierarchicalRefinement(t)[0]||"");0===u.indexOf(s.rootPath)&&(u=u.replace(s.rootPath+c,""));var l=u.split(c);return l.unshift(t),g(a,l,0),a}}function g(e,t,n){e.isRefined=e.name===t[n],e.data&&e.data.forEach((function(e){g(e,t,n+1)}))}function b(e,t,n,r){if(r=r||0,Array.isArray(t))return e(t,n[r]);if(!t.data||0===t.data.length)return t;var a=t.data.map((function(t){return b(e,t,n,r+1)})),o=e(a,n[r]);return i({data:o},t)}function A(e,t){var n=o(e,(function(e){return e.name===t}));return n&&n.stats}function I(e,t,n,r,i){var a=o(i,(function(e){return e.name===n})),s=a&&a.data&&a.data[r]?a.data[r]:0,c=a&&a.exhaustive||!1;return{type:t,attributeName:n,name:r,count:s,exhaustive:c}}y.prototype.getFacetByName=function(e){function t(t){return t.name===e}return o(this.facets,t)||o(this.disjunctiveFacets,t)||o(this.hierarchicalFacets,t)},y.DEFAULT_SORT=["isRefined:desc","count:desc","name:asc"],y.prototype.getFacetValues=function(e,t){var n=v(this,e);if(n){var r=i({},t,{sortBy:y.DEFAULT_SORT,facetOrdering:!(t&&t.sortBy)}),a=this;return b((function(e,t){if(r.facetOrdering){var n=function(e,t){return e.renderingContent&&e.renderingContent.facetOrdering&&e.renderingContent.facetOrdering.values&&e.renderingContent.facetOrdering.values[t]}(a,t);if(n)return function(e,t){var n=[],r=[],i=(t.order||[]).reduce((function(e,t,n){return e[t]=n,e}),{});e.forEach((function(e){var t=e.path||e.name;void 0!==i[t]?n[i[t]]=e:r.push(e)})),n=n.filter((function(e){return e}));var a,o=t.sortRemainingBy;return"hidden"===o?n:(a="alpha"===o?[["path","name"],["asc","asc"]]:[["count"],["desc"]],n.concat(l(r,a[0],a[1])))}(e,n)}if(Array.isArray(r.sortBy)){var i=c(r.sortBy,y.DEFAULT_SORT);return l(e,i[0],i[1])}if("function"==typeof r.sortBy)return function(e,t){return t.sort(e)}(r.sortBy,e);throw new Error("options.sortBy is optional but if defined it must be either an array of string (predicates) or a sorting function")}),n,Array.isArray(n)?[e]:a._state.getHierarchicalFacetByName(n.name).attributes)}},y.prototype.getFacetStats=function(e){return this._state.isConjunctiveFacet(e)?A(this.facets,e):this._state.isDisjunctiveFacet(e)?A(this.disjunctiveFacets,e):void 0},y.prototype.getRefinements=function(){var e=this._state,t=this,n=[];return Object.keys(e.facetsRefinements).forEach((function(r){e.facetsRefinements[r].forEach((function(e){n.push(I(0,"facet",r,e,t.facets))}))})),Object.keys(e.facetsExcludes).forEach((function(r){e.facetsExcludes[r].forEach((function(e){n.push(I(0,"exclude",r,e,t.facets))}))})),Object.keys(e.disjunctiveFacetsRefinements).forEach((function(r){e.disjunctiveFacetsRefinements[r].forEach((function(e){n.push(I(0,"disjunctive",r,e,t.disjunctiveFacets))}))})),Object.keys(e.hierarchicalFacetsRefinements).forEach((function(r){e.hierarchicalFacetsRefinements[r].forEach((function(i){n.push(function(e,t,n,r){var i=e.getHierarchicalFacetByName(t),a=e._getHierarchicalFacetSeparator(i),s=n.split(a),c=o(r,(function(e){return e.name===t})),u=s.reduce((function(e,t){var n=e&&o(e.data,(function(e){return e.name===t}));return void 0!==n?n:e}),c),l=u&&u.count||0,f=u&&u.exhaustive||!1,h=u&&u.path||"";return{type:"hierarchical",attributeName:t,name:h,count:l,exhaustive:f}}(e,r,i,t.hierarchicalFacets))}))})),Object.keys(e.numericRefinements).forEach((function(t){var r=e.numericRefinements[t];Object.keys(r).forEach((function(e){r[e].forEach((function(r){n.push({type:"numeric",attributeName:t,name:r,numericValue:r,operator:e})}))}))})),e.tagRefinements.forEach((function(e){n.push({type:"tag",attributeName:"_tags",name:e})})),n},e.exports=y},9374:function(e,t,n){"use strict";var r=n(7331),i=n(8078),a=n(4039).escapeFacetValue,o=n(4853),s=n(185),c=n(116),u=n(9803),l=n(6394),f=n(7775),h=n(3076),p=n(4336);function d(e,t,n){"function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+p+")"),this.setClient(e);var r=n||{};r.index=t,this.state=f.make(r),this.lastResults=null,this._queryId=0,this._lastQueryIdReceived=-1,this.derivedHelpers=[],this._currentNbQueries=0}function m(e){if(e<0)throw new Error("Page requested below 0.");return this._change({state:this.state.setPage(e),isPageReset:!1}),this}function y(){return this.state.page}o(d,r),d.prototype.search=function(){return this._search({onlyWithDerivedHelpers:!1}),this},d.prototype.searchOnlyWithDerivedHelpers=function(){return this._search({onlyWithDerivedHelpers:!0}),this},d.prototype.getQuery=function(){var e=this.state;return l._getHitsSearchParams(e)},d.prototype.searchOnce=function(e,t){var n=e?this.state.setQueryParameters(e):this.state,r=l._getQueries(n.index,n),i=this;if(this._currentNbQueries++,this.emit("searchOnce",{state:n}),!t)return this.client.search(r).then((function(e){return i._currentNbQueries--,0===i._currentNbQueries&&i.emit("searchQueueEmpty"),{content:new h(n,e.results),state:n,_originalResponse:e}}),(function(e){throw i._currentNbQueries--,0===i._currentNbQueries&&i.emit("searchQueueEmpty"),e}));this.client.search(r).then((function(e){i._currentNbQueries--,0===i._currentNbQueries&&i.emit("searchQueueEmpty"),t(null,new h(n,e.results),n)})).catch((function(e){i._currentNbQueries--,0===i._currentNbQueries&&i.emit("searchQueueEmpty"),t(e,null,n)}))},d.prototype.findAnswers=function(e){console.warn("[algoliasearch-helper] answers is no longer supported");var t=this.state,n=this.derivedHelpers[0];if(!n)return Promise.resolve([]);var r=n.getModifiedState(t),i=s({attributesForPrediction:e.attributesForPrediction,nbHits:e.nbHits},{params:u(l._getHitsSearchParams(r),["attributesToSnippet","hitsPerPage","restrictSearchableAttributes","snippetEllipsisText"])}),a="search for answers was called, but this client does not have a function client.initIndex(index).findAnswers";if("function"!=typeof this.client.initIndex)throw new Error(a);var o=this.client.initIndex(r.index);if("function"!=typeof o.findAnswers)throw new Error(a);return o.findAnswers(r.query,e.queryLanguages,i)},d.prototype.searchForFacetValues=function(e,t,n,r){var i="function"==typeof this.client.searchForFacetValues,o="function"==typeof this.client.initIndex;if(!i&&!o&&"function"!=typeof this.client.search)throw new Error("search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues");var s=this.state.setQueryParameters(r||{}),c=s.isDisjunctiveFacet(e),u=l.getSearchForFacetQuery(e,t,n,s);this._currentNbQueries++;var f,h=this;return i?f=this.client.searchForFacetValues([{indexName:s.index,params:u}]):o?f=this.client.initIndex(s.index).searchForFacetValues(u):(delete u.facetName,f=this.client.search([{type:"facet",facet:e,indexName:s.index,params:u}]).then((function(e){return e.results[0]}))),this.emit("searchForFacetValues",{state:s,facet:e,query:t}),f.then((function(t){return h._currentNbQueries--,0===h._currentNbQueries&&h.emit("searchQueueEmpty"),(t=Array.isArray(t)?t[0]:t).facetHits.forEach((function(t){t.escapedValue=a(t.value),t.isRefined=c?s.isDisjunctiveFacetRefined(e,t.escapedValue):s.isFacetRefined(e,t.escapedValue)})),t}),(function(e){throw h._currentNbQueries--,0===h._currentNbQueries&&h.emit("searchQueueEmpty"),e}))},d.prototype.setQuery=function(e){return this._change({state:this.state.resetPage().setQuery(e),isPageReset:!0}),this},d.prototype.clearRefinements=function(e){return this._change({state:this.state.resetPage().clearRefinements(e),isPageReset:!0}),this},d.prototype.clearTags=function(){return this._change({state:this.state.resetPage().clearTags(),isPageReset:!0}),this},d.prototype.addDisjunctiveFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addDisjunctiveFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.addDisjunctiveRefine=function(){return this.addDisjunctiveFacetRefinement.apply(this,arguments)},d.prototype.addHierarchicalFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addHierarchicalFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.addNumericRefinement=function(e,t,n){return this._change({state:this.state.resetPage().addNumericRefinement(e,t,n),isPageReset:!0}),this},d.prototype.addFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.addRefine=function(){return this.addFacetRefinement.apply(this,arguments)},d.prototype.addFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().addExcludeRefinement(e,t),isPageReset:!0}),this},d.prototype.addExclude=function(){return this.addFacetExclusion.apply(this,arguments)},d.prototype.addTag=function(e){return this._change({state:this.state.resetPage().addTagRefinement(e),isPageReset:!0}),this},d.prototype.removeNumericRefinement=function(e,t,n){return this._change({state:this.state.resetPage().removeNumericRefinement(e,t,n),isPageReset:!0}),this},d.prototype.removeDisjunctiveFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().removeDisjunctiveFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.removeDisjunctiveRefine=function(){return this.removeDisjunctiveFacetRefinement.apply(this,arguments)},d.prototype.removeHierarchicalFacetRefinement=function(e){return this._change({state:this.state.resetPage().removeHierarchicalFacetRefinement(e),isPageReset:!0}),this},d.prototype.removeFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().removeFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.removeRefine=function(){return this.removeFacetRefinement.apply(this,arguments)},d.prototype.removeFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().removeExcludeRefinement(e,t),isPageReset:!0}),this},d.prototype.removeExclude=function(){return this.removeFacetExclusion.apply(this,arguments)},d.prototype.removeTag=function(e){return this._change({state:this.state.resetPage().removeTagRefinement(e),isPageReset:!0}),this},d.prototype.toggleFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().toggleExcludeFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.toggleExclude=function(){return this.toggleFacetExclusion.apply(this,arguments)},d.prototype.toggleRefinement=function(e,t){return this.toggleFacetRefinement(e,t)},d.prototype.toggleFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().toggleFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.toggleRefine=function(){return this.toggleFacetRefinement.apply(this,arguments)},d.prototype.toggleTag=function(e){return this._change({state:this.state.resetPage().toggleTagRefinement(e),isPageReset:!0}),this},d.prototype.nextPage=function(){var e=this.state.page||0;return this.setPage(e+1)},d.prototype.previousPage=function(){var e=this.state.page||0;return this.setPage(e-1)},d.prototype.setCurrentPage=m,d.prototype.setPage=m,d.prototype.setIndex=function(e){return this._change({state:this.state.resetPage().setIndex(e),isPageReset:!0}),this},d.prototype.setQueryParameter=function(e,t){return this._change({state:this.state.resetPage().setQueryParameter(e,t),isPageReset:!0}),this},d.prototype.setState=function(e){return this._change({state:f.make(e),isPageReset:!1}),this},d.prototype.overrideStateWithoutTriggeringChangeEvent=function(e){return this.state=new f(e),this},d.prototype.hasRefinements=function(e){return!!c(this.state.getNumericRefinements(e))||(this.state.isConjunctiveFacet(e)?this.state.isFacetRefined(e):this.state.isDisjunctiveFacet(e)?this.state.isDisjunctiveFacetRefined(e):!!this.state.isHierarchicalFacet(e)&&this.state.isHierarchicalFacetRefined(e))},d.prototype.isExcluded=function(e,t){return this.state.isExcludeRefined(e,t)},d.prototype.isDisjunctiveRefined=function(e,t){return this.state.isDisjunctiveFacetRefined(e,t)},d.prototype.hasTag=function(e){return this.state.isTagRefined(e)},d.prototype.isTagRefined=function(){return this.hasTagRefinements.apply(this,arguments)},d.prototype.getIndex=function(){return this.state.index},d.prototype.getCurrentPage=y,d.prototype.getPage=y,d.prototype.getTags=function(){return this.state.tagRefinements},d.prototype.getRefinements=function(e){var t=[];this.state.isConjunctiveFacet(e)?(this.state.getConjunctiveRefinements(e).forEach((function(e){t.push({value:e,type:"conjunctive"})})),this.state.getExcludeRefinements(e).forEach((function(e){t.push({value:e,type:"exclude"})}))):this.state.isDisjunctiveFacet(e)&&this.state.getDisjunctiveRefinements(e).forEach((function(e){t.push({value:e,type:"disjunctive"})}));var n=this.state.getNumericRefinements(e);return Object.keys(n).forEach((function(e){var r=n[e];t.push({value:r,operator:e,type:"numeric"})})),t},d.prototype.getNumericRefinement=function(e,t){return this.state.getNumericRefinement(e,t)},d.prototype.getHierarchicalFacetBreadcrumb=function(e){return this.state.getHierarchicalFacetBreadcrumb(e)},d.prototype._search=function(e){var t=this.state,n=[],r=[];e.onlyWithDerivedHelpers||(r=l._getQueries(t.index,t),n.push({state:t,queriesCount:r.length,helper:this}),this.emit("search",{state:t,results:this.lastResults}));var i=this.derivedHelpers.map((function(e){var r=e.getModifiedState(t),i=r.index?l._getQueries(r.index,r):[];return n.push({state:r,queriesCount:i.length,helper:e}),e.emit("search",{state:r,results:e.lastResults}),i})),a=Array.prototype.concat.apply(r,i),o=this._queryId++;if(this._currentNbQueries++,!a.length)return Promise.resolve({results:[]}).then(this._dispatchAlgoliaResponse.bind(this,n,o));try{this.client.search(a).then(this._dispatchAlgoliaResponse.bind(this,n,o)).catch(this._dispatchAlgoliaError.bind(this,o))}catch(e){this.emit("error",{error:e})}},d.prototype._dispatchAlgoliaResponse=function(e,t,n){if(!(t0},d.prototype._change=function(e){var t=e.state,n=e.isPageReset;t!==this.state&&(this.state=t,this.emit("change",{state:this.state,results:this.lastResults,isPageReset:n}))},d.prototype.clearCache=function(){return this.client.clearCache&&this.client.clearCache(),this},d.prototype.setClient=function(e){return this.client===e||("function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+p+")"),this.client=e),this},d.prototype.getClient=function(){return this.client},d.prototype.derive=function(e){var t=new i(this,e);return this.derivedHelpers.push(t),t},d.prototype.detachDerivedHelper=function(e){var t=this.derivedHelpers.indexOf(e);if(-1===t)throw new Error("Derived helper already detached");this.derivedHelpers.splice(t,1)},d.prototype.hasPendingRequests=function(){return this._currentNbQueries>0},e.exports=d},4587:function(e){"use strict";e.exports=function(e){return Array.isArray(e)?e.filter(Boolean):[]}},2344:function(e){"use strict";e.exports=function(){return Array.prototype.slice.call(arguments).reduceRight((function(e,t){return Object.keys(Object(t)).forEach((function(n){void 0!==t[n]&&(void 0!==e[n]&&delete e[n],e[n]=t[n])})),e}),{})}},4039:function(e){"use strict";e.exports={escapeFacetValue:function(e){return"string"!=typeof e?e:String(e).replace(/^-/,"\\-")},unescapeFacetValue:function(e){return"string"!=typeof e?e:e.replace(/^\\-/,"-")}}},7888:function(e){"use strict";e.exports=function(e,t){if(Array.isArray(e))for(var n=0;n1||!a?(e[0].push(i[0]),e[1].push(i[1]),e):(e[0].push(a[0]),e[1].push(a[1]),e)}),[[],[]])}},4853:function(e){"use strict";e.exports=function(e,t){e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}},2686:function(e){"use strict";e.exports=function(e,t){return e.filter((function(n,r){return t.indexOf(n)>-1&&e.indexOf(n)===r}))}},185:function(e){"use strict";function t(e){return"function"==typeof e||Array.isArray(e)||"[object Object]"===Object.prototype.toString.call(e)}function n(e,r){if(e===r)return e;for(var i in r)if(Object.prototype.hasOwnProperty.call(r,i)&&"__proto__"!==i&&"constructor"!==i){var a=r[i],o=e[i];void 0!==o&&void 0===a||(t(o)&&t(a)?e[i]=n(o,a):e[i]="object"==typeof(s=a)&&null!==s?n(Array.isArray(s)?[]:{},s):s)}var s;return e}e.exports=function(e){t(e)||(e={});for(var r=1,i=arguments.length;r0}},9803:function(e){"use strict";e.exports=function(e,t){if(null===e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}},2148:function(e){"use strict";function t(e,t){if(e!==t){var n=void 0!==e,r=null===e,i=void 0!==t,a=null===t;if(!a&&e>t||r&&i||!n)return 1;if(!r&&e=r.length?a:"desc"===r[i]?-a:a}return e.index-n.index})),i.map((function(e){return e.value}))}},8023:function(e){"use strict";e.exports=function e(t){if("number"==typeof t)return t;if("string"==typeof t)return parseFloat(t);if(Array.isArray(t))return t.map(e);throw new Error("The value should be a number, a parsable string or an array of those.")}},6394:function(e,t,n){"use strict";var r=n(185);function i(e){return Object.keys(e).sort().reduce((function(t,n){return t[n]=e[n],t}),{})}var a={_getQueries:function(e,t){var n=[];return n.push({indexName:e,params:a._getHitsSearchParams(t)}),t.getRefinedDisjunctiveFacets().forEach((function(r){n.push({indexName:e,params:a._getDisjunctiveFacetSearchParams(t,r)})})),t.getRefinedHierarchicalFacets().forEach((function(r){var i=t.getHierarchicalFacetByName(r),o=t.getHierarchicalRefinement(r),s=t._getHierarchicalFacetSeparator(i);if(o.length>0&&o[0].split(s).length>1){var c=o[0].split(s).slice(0,-1).reduce((function(e,t,n){return e.concat({attribute:i.attributes[n],value:0===n?t:[e[e.length-1].value,t].join(s)})}),[]);c.forEach((function(r,o){var s=a._getDisjunctiveFacetSearchParams(t,r.attribute,0===o);function u(e){return i.attributes.some((function(t){return t===e.split(":")[0]}))}var l=(s.facetFilters||[]).reduce((function(e,t){if(Array.isArray(t)){var n=t.filter((function(e){return!u(e)}));n.length>0&&e.push(n)}return"string"!=typeof t||u(t)||e.push(t),e}),[]),f=c[o-1];s.facetFilters=o>0?l.concat(f.attribute+":"+f.value):l.length>0?l:void 0,n.push({indexName:e,params:s})}))}})),n},_getHitsSearchParams:function(e){var t=e.facets.concat(e.disjunctiveFacets).concat(a._getHitsHierarchicalFacetsAttributes(e)).sort(),n=a._getFacetFilters(e),o=a._getNumericFilters(e),s=a._getTagFilters(e),c={facets:t.indexOf("*")>-1?["*"]:t,tagFilters:s};return n.length>0&&(c.facetFilters=n),o.length>0&&(c.numericFilters=o),i(r({},e.getQueryParams(),c))},_getDisjunctiveFacetSearchParams:function(e,t,n){var o=a._getFacetFilters(e,t,n),s=a._getNumericFilters(e,t),c=a._getTagFilters(e),u={hitsPerPage:0,page:0,analytics:!1,clickAnalytics:!1};c.length>0&&(u.tagFilters=c);var l=e.getHierarchicalFacetByName(t);return u.facets=l?a._getDisjunctiveHierarchicalFacetAttribute(e,l,n):t,s.length>0&&(u.numericFilters=s),o.length>0&&(u.facetFilters=o),i(r({},e.getQueryParams(),u))},_getNumericFilters:function(e,t){if(e.numericFilters)return e.numericFilters;var n=[];return Object.keys(e.numericRefinements).forEach((function(r){var i=e.numericRefinements[r]||{};Object.keys(i).forEach((function(e){var a=i[e]||[];t!==r&&a.forEach((function(t){if(Array.isArray(t)){var i=t.map((function(t){return r+e+t}));n.push(i)}else n.push(r+e+t)}))}))})),n},_getTagFilters:function(e){return e.tagFilters?e.tagFilters:e.tagRefinements.join(",")},_getFacetFilters:function(e,t,n){var r=[],i=e.facetsRefinements||{};Object.keys(i).sort().forEach((function(e){(i[e]||[]).sort().forEach((function(t){r.push(e+":"+t)}))}));var a=e.facetsExcludes||{};Object.keys(a).sort().forEach((function(e){(a[e]||[]).sort().forEach((function(t){r.push(e+":-"+t)}))}));var o=e.disjunctiveFacetsRefinements||{};Object.keys(o).sort().forEach((function(e){var n=o[e]||[];if(e!==t&&n&&0!==n.length){var i=[];n.sort().forEach((function(t){i.push(e+":"+t)})),r.push(i)}}));var s=e.hierarchicalFacetsRefinements||{};return Object.keys(s).sort().forEach((function(i){var a=(s[i]||[])[0];if(void 0!==a){var o,c,u=e.getHierarchicalFacetByName(i),l=e._getHierarchicalFacetSeparator(u),f=e._getHierarchicalRootPath(u);if(t===i){if(-1===a.indexOf(l)||!f&&!0===n||f&&f.split(l).length===a.split(l).length)return;f?(c=f.split(l).length-1,a=f):(c=a.split(l).length-2,a=a.slice(0,a.lastIndexOf(l))),o=u.attributes[c]}else c=a.split(l).length-1,o=u.attributes[c];o&&r.push([o+":"+a])}})),r},_getHitsHierarchicalFacetsAttributes:function(e){return e.hierarchicalFacets.reduce((function(t,n){var r=e.getHierarchicalRefinement(n.name)[0];if(!r)return t.push(n.attributes[0]),t;var i=e._getHierarchicalFacetSeparator(n),a=r.split(i).length,o=n.attributes.slice(0,a+1);return t.concat(o)}),[])},_getDisjunctiveHierarchicalFacetAttribute:function(e,t,n){var r=e._getHierarchicalFacetSeparator(t);if(!0===n){var i=e._getHierarchicalRootPath(t),a=0;return i&&(a=i.split(r).length),[t.attributes[a]]}var o=(e.getHierarchicalRefinement(t.name)[0]||"").split(r).length-1;return t.attributes.slice(0,o+1)},getSearchForFacetQuery:function(e,t,n,o){var s=o.isDisjunctiveFacet(e)?o.clearRefinements(e):o,c={facetQuery:t,facetName:e};return"number"==typeof n&&(c.maxFacetHits=n),i(r({},a._getHitsSearchParams(s),c))}};e.exports=a},6801:function(e){"use strict";e.exports=function(e){return null!==e&&/^[a-zA-Z0-9_-]{1,64}$/.test(e)}},4336:function(e){"use strict";e.exports="3.14.2"},9669:function(e,t,n){e.exports=n(1609)},5448:function(e,t,n){"use strict";var r=n(4867),i=n(6026),a=n(4372),o=n(5327),s=n(4097),c=n(4109),u=n(7985),l=n(5061),f=n(7874),h=n(5263);e.exports=function(e){return new Promise((function(t,n){var p,d=e.data,m=e.headers,y=e.responseType;function v(){e.cancelToken&&e.cancelToken.unsubscribe(p),e.signal&&e.signal.removeEventListener("abort",p)}r.isFormData(d)&&delete m["Content-Type"];var g=new XMLHttpRequest;if(e.auth){var b=e.auth.username||"",A=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";m.Authorization="Basic "+btoa(b+":"+A)}var I=s(e.baseURL,e.url);function w(){if(g){var r="getAllResponseHeaders"in g?c(g.getAllResponseHeaders()):null,a={data:y&&"text"!==y&&"json"!==y?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:r,config:e,request:g};i((function(e){t(e),v()}),(function(e){n(e),v()}),a),g=null}}if(g.open(e.method.toUpperCase(),o(I,e.params,e.paramsSerializer),!0),g.timeout=e.timeout,"onloadend"in g?g.onloadend=w:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(w)},g.onabort=function(){g&&(n(l("Request aborted",e,"ECONNABORTED",g)),g=null)},g.onerror=function(){n(l("Network Error",e,null,g)),g=null},g.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||f;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(l(t,e,r.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",g)),g=null},r.isStandardBrowserEnv()){var S=(e.withCredentials||u(I))&&e.xsrfCookieName?a.read(e.xsrfCookieName):void 0;S&&(m[e.xsrfHeaderName]=S)}"setRequestHeader"in g&&r.forEach(m,(function(e,t){void 0===d&&"content-type"===t.toLowerCase()?delete m[t]:g.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(g.withCredentials=!!e.withCredentials),y&&"json"!==y&&(g.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&g.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&g.upload&&g.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(p=function(e){g&&(n(!e||e&&e.type?new h("canceled"):e),g.abort(),g=null)},e.cancelToken&&e.cancelToken.subscribe(p),e.signal&&(e.signal.aborted?p():e.signal.addEventListener("abort",p))),d||(d=null),g.send(d)}))}},1609:function(e,t,n){"use strict";var r=n(4867),i=n(1849),a=n(321),o=n(7185),s=function e(t){var n=new a(t),s=i(a.prototype.request,n);return r.extend(s,a.prototype,n),r.extend(s,n),s.create=function(n){return e(o(t,n))},s}(n(5546));s.Axios=a,s.Cancel=n(5263),s.CancelToken=n(4972),s.isCancel=n(6502),s.VERSION=n(7288).version,s.all=function(e){return Promise.all(e)},s.spread=n(8713),s.isAxiosError=n(6268),e.exports=s,e.exports.default=s},5263:function(e){"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},4972:function(e,t,n){"use strict";var r=n(5263);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(e){l.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){l.headers[e]=r.merge(s)})),e.exports=l},7874:function(e){"use strict";e.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},7288:function(e){e.exports={version:"0.26.1"}},1849:function(e){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([n]):o[t]?o[t]+", "+n:n}})),o):o}},8713:function(e){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},4875:function(e,t,n){"use strict";var r=n(7288).version,i={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){i[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var a={};i.transitional=function(e,t,n){function i(e,t){return"[Axios v"+r+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,o){if(!1===e)throw new Error(i(r," has been removed"+(t?" in "+t:"")));return t&&!a[r]&&(a[r]=!0,console.warn(i(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,o)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),i=r.length;i-- >0;){var a=r[i],o=t[a];if(o){var s=e[a],c=void 0===s||o(s,a,e);if(!0!==c)throw new TypeError("option "+a+" must be "+c)}else if(!0!==n)throw Error("Unknown option "+a)}},validators:i}},4867:function(e,t,n){"use strict";var r=n(1849),i=Object.prototype.toString;function a(e){return Array.isArray(e)}function o(e){return void 0===e}function s(e){return"[object ArrayBuffer]"===i.call(e)}function c(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==i.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function l(e){return"[object Function]"===i.call(e)}function f(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),a(e))for(var n=0,r=e.length;n=0&&n<=s.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(a=n,!1!==i&&function(e){var n=(r[e]||"silent").toUpperCase();if(typeof window!==t&&u){try{return void(window.localStorage[u]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(u)+"="+n+";"}catch(e){}}}(n),o.call(s,n,e),typeof console===t&&n-1?e.split(","):e},u=function(e,t,n,r){if(e){var a=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(a),u=s?a.slice(0,s.index):a,l=[];if(u){if(!n.plainObjects&&i.call(Object.prototype,u)&&!n.allowPrototypes)return;l.push(u)}for(var f=0;n.depth>0&&null!==(s=o.exec(a))&&f=0;--a){var o,s=e[a];if("[]"===s&&n.parseArrays)o=[].concat(i);else{o=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,l=parseInt(u,10);n.parseArrays||""!==u?!isNaN(l)&&s!==u&&String(l)===u&&l>=0&&n.parseArrays&&l<=n.arrayLimit?(o=[])[l]=i:"__proto__"!==u&&(o[u]=i):o={0:i}}i=o}return i}(l,t,n,r)}};e.exports=function(e,t){var n=function(e){if(!e)return o;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");var t=void 0===e.charset?o.charset:e.charset;return{allowDots:void 0===e.allowDots?o.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:o.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:o.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:o.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:o.comma,decoder:"function"==typeof e.decoder?e.decoder:o.decoder,delimiter:"string"==typeof e.delimiter||r.isRegExp(e.delimiter)?e.delimiter:o.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:o.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:o.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:o.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:o.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:o.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var l="string"==typeof e?function(e,t){var n,u={},l=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,f=t.parameterLimit===1/0?void 0:t.parameterLimit,h=l.split(t.delimiter,f),p=-1,d=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(y=a(y)?[y]:y),i.call(u,m)?u[m]=r.combine(u[m],y):u[m]=y}return u}(e,n):e,f=n.plainObjects?Object.create(null):{},h=Object.keys(l),p=0;p0?I.join(",")||null:void 0}];else if(s(f))j=f;else{var E=Object.keys(I);j=h?E.sort(h):E}for(var T=0;T0?g+v:""}},2769:function(e,t,n){"use strict";var r=n(5798),i=Object.prototype.hasOwnProperty,a=Array.isArray,o=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),s=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(a(n)){for(var r=[],i=0;i=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122||a===r.RFC1738&&(40===l||41===l)?c+=s.charAt(u):l<128?c+=o[l]:l<2048?c+=o[192|l>>6]+o[128|63&l]:l<55296||l>=57344?c+=o[224|l>>12]+o[128|l>>6&63]+o[128|63&l]:(u+=1,l=65536+((1023&l)<<10|1023&s.charCodeAt(u)),c+=o[240|l>>18]+o[128|l>>12&63]+o[128|l>>6&63]+o[128|63&l])}return c},isBuffer:function(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(a(e)){for(var n=[],r=0;r0&&void 0!==arguments[0]?arguments[0]:{};(0,i.default)(this,e),this.server=v.server||{nodes:[{host:"localhost",port:"8108",path:"",protocol:"http"}]},this.server.cacheSearchResultsForSeconds=null!==(t=this.server.cacheSearchResultsForSeconds)&&void 0!==t?t:120,this.additionalSearchParameters=null!==(n=v.additionalSearchParameters)&&void 0!==n?n:{},this.additionalSearchParameters.query_by=null!==(r=null!==(a=this.additionalSearchParameters.queryBy)&&void 0!==a?a:this.additionalSearchParameters.query_by)&&void 0!==r?r:"",this.additionalSearchParameters.preset=null!==(o=null!==(s=this.additionalSearchParameters.preset)&&void 0!==s?s:this.additionalSearchParameters.preset)&&void 0!==o?o:"",this.additionalSearchParameters.sort_by=null!==(c=null!==(u=this.additionalSearchParameters.sortBy)&&void 0!==u?u:this.additionalSearchParameters.sort_by)&&void 0!==c?c:"",this.additionalSearchParameters.highlight_full_fields=null!==(l=null!==(f=this.additionalSearchParameters.highlightFullFields)&&void 0!==f?f:this.additionalSearchParameters.highlight_full_fields)&&void 0!==l?l:this.additionalSearchParameters.query_by,this.geoLocationField=null!==(h=v.geoLocationField)&&void 0!==h?h:"_geoloc",this.facetableFieldsWithSpecialCharacters=null!==(p=v.facetableFieldsWithSpecialCharacters)&&void 0!==p?p:[],this.collectionSpecificSearchParameters=null!==(d=v.collectionSpecificSearchParameters)&&void 0!==d?d:{},Object.keys(this.collectionSpecificSearchParameters).forEach((function(e){var t,n,r,i,a,o,s=y.collectionSpecificSearchParameters[e];s.query_by=null!==(t=s.queryBy)&&void 0!==t?t:s.query_by,s.preset=null!==(n=s.preset)&&void 0!==n?n:s.preset,s.sort_by=null!==(r=s.sortBy)&&void 0!==r?r:s.sort_by,s.highlight_full_fields=null!==(i=null!==(a=null!==(o=s.highlightFullFields)&&void 0!==o?o:s.highlight_full_fields)&&void 0!==a?a:y.additionalSearchParameters.highlight_full_fields)&&void 0!==i?i:s.query_by,Object.keys(s).forEach((function(e){return void 0===s[e]?delete s[e]:{}}))})),this.renderingContent=v.renderingContent,this.flattenGroupedHits=null===(m=v.flattenGroupedHits)||void 0===m||m}return(0,a.default)(e,[{key:"validate",value:function(){if((this.additionalSearchParameters.queryBy||Object.values(this.collectionSpecificSearchParameters).some((function(e){return e.queryBy})))&&console.warn("[typesense-instantsearch-adapter] Please use snake_cased versions of parameters in additionalSearchParameters instead of camelCased parameters. For example: Use query_by instead of queryBy. camelCased parameters will be deprecated in a future version. We're making this change so that parameter names are identical to the ones sent to Typesense (which are all snake_cased), and to also keep the types for these parameters in sync with the types defined in typesense-js."),0===this.additionalSearchParameters.query_by.length&&0===this.additionalSearchParameters.preset.length&&(0===Object.keys(this.collectionSpecificSearchParameters).length||Object.values(this.collectionSpecificSearchParameters).some((function(e){return 0===(e.query_by||"").length&&0===(e.preset||"").length}))))throw new Error("[typesense-instantsearch-adapter] Missing parameter: One of additionalSearchParameters.query_by or additionalSearchParameters.preset needs to be set, or all collectionSpecificSearchParameters need to have either .query_by or .preset set.")}}]),e}();t.Configuration=o},3599:function(e,t,n){"use strict";var r=n(4836);Object.defineProperty(t,"__esModule",{value:!0}),t.FacetSearchResponseAdapter=void 0;var i=r(n(6690)),a=r(n(9728)),o=n(8399),s=function(){function e(t,n){(0,i.default)(this,e),this.typesenseResponse=t,this.instantsearchRequest=n}return(0,a.default)(e,[{key:"_adaptFacetHits",value:function(e){var t=this;return e.find((function(e){return e.field_name===t.instantsearchRequest.params.facetName})).counts.map((function(e){return{value:e.value,highlighted:t._adaptHighlightTag(e.highlighted,t.instantsearchRequest.params.highlightPreTag,t.instantsearchRequest.params.highlightPostTag),count:e.count}}))}},{key:"adapt",value:function(){return{facetHits:this._adaptFacetHits(this.typesenseResponse.facet_counts),exhaustiveFacetsCount:!0,processingTimeMS:this.typesenseResponse.search_time_ms}}}]),e}();t.FacetSearchResponseAdapter=s,Object.assign(s.prototype,o.utils)},4002:function(e,t,n){"use strict";var r=n(4836);Object.defineProperty(t,"__esModule",{value:!0}),t.SearchRequestAdapter=void 0;var i=r(n(1284)),a=r(n(7156)),o=r(n(7424)),s=r(n(6690)),c=r(n(9728)),u=function(){function e(t,n,r){(0,s.default)(this,e),this.instantsearchRequests=t,this.typesenseClient=n,this.configuration=r,this.additionalSearchParameters=r.additionalSearchParameters,this.collectionSpecificSearchParameters=r.collectionSpecificSearchParameters}var t;return(0,c.default)(e,[{key:"_adaptFacetFilters",value:function(e){var t=this,n="";return e?n=e.map((function(e){if(Array.isArray(e)){var n={};e.forEach((function(e){var r=t._parseFacetFilter(e),i=r.fieldName,a=r.fieldValue;n[i]=n[i]||[],n[i].push(a)})),Object.keys(n).length>1&&console.error("[Typesense-Instantsearch-Adapter] Typesense does not support cross-field ORs at the moment. The adapter could not OR values between these fields: ".concat(Object.keys(n).join(",")));var r=Object.keys(n)[0],i=n[r].reduce((function(e,n){return n.startsWith("-")&&!t._isNumber(n)?e[0].push(n.substring(1)):e[1].push(n),e}),[[],[]]),a=(0,o.default)(i,2),s=a[0],c=a[1],u=[];return c.length>0&&u.push("".concat(r,":=[").concat(c.map((function(e){return t._escapeFacetValue(e)})).join(","),"]")),s.length>0&&u.push("".concat(r,":!=[").concat(s.map((function(e){return t._escapeFacetValue(e)})).join(","),"]")),u.filter((function(e){return e})).join(" && ")}var l=t._parseFacetFilter(e),f=l.fieldName,h=l.fieldValue;return h.startsWith("-")&&!t._isNumber(h)?"".concat(f,":!=[").concat(t._escapeFacetValue(h.substring(1)),"]"):"".concat(f,":=[").concat(t._escapeFacetValue(h),"]")})).join(" && "):n}},{key:"_parseFacetFilter",value:function(e){var t,n,r,i,a;if((null===(t=this.configuration.facetableFieldsWithSpecialCharacters)||void 0===t?void 0:t.length)>0){var o=this.configuration.facetableFieldsWithSpecialCharacters.flat().map((function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}));if(n=new RegExp("^(".concat(o.join("|"),"):(.*)$")),null!=(r=e.match(n)))return{fieldName:i="".concat(r[1]),fieldValue:a="".concat(r[2])}}return n=this.constructor.DEFAULT_FACET_FILTER_STRING_MATCHING_REGEX,null==(r=e.match(n))?console.error("[Typesense-Instantsearch-Adapter] Parsing failed for a facet filter `".concat(e,"` with the Regex `").concat(n,"`. If you have field names with special characters, be sure to add them to a parameter called `facetableFieldsWithSpecialCharacters` when instantiating the adapter.")):(i="".concat(r[1]).concat(r[2]),a="".concat(r[3])),{fieldName:i,fieldValue:a}}},{key:"_escapeFacetValue",value:function(e){return"boolean"==typeof e||"true"===e||"false"===e||this._isNumber(e)?e:"`".concat(e,"`")}},{key:"_isNumber",value:function(e){return Number.isInteger(e%1)||!!(e%1)}},{key:"_adaptNumericFilters",value:function(e){var t=this,n="";if(!e)return n;var r={};e.forEach((function(e){var n=t._parseNumericFilter(e),i=n.fieldName,a=n.operator,o=n.fieldValue;r[i]=r[i]||{},r[i][a]=o}));var i=[];return Object.keys(r).forEach((function(e){null!=r[e]["<="]&&null!=r[e][">="]?i.push("".concat(e,":=[").concat(r[e][">="],"..").concat(r[e]["<="],"]")):null!=r[e]["<="]?i.push("".concat(e,":<=").concat(r[e]["<="])):null!=r[e][">="]?i.push("".concat(e,":>=").concat(r[e][">="])):null!=r[e]["="]?i.push("".concat(e,":=").concat(r[e]["="])):console.warn("[Typesense-Instantsearch-Adapter] Unsupported operator found ".concat(JSON.stringify(r[e])))})),i.join(" && ")}},{key:"_parseNumericFilter",value:function(e){var t,n,r,i,a,s;if((null===(t=this.configuration.facetableFieldsWithSpecialCharacters)||void 0===t?void 0:t.length)>0){var c=this.configuration.facetableFieldsWithSpecialCharacters.map((function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}));if(n=new RegExp("^(".concat(c.join("|"),")(<=|>=|>|<|=)(.*)$")),null!=(r=e.match(n))){var u=r,l=(0,o.default)(u,4);return{fieldName:i=l[1],operator:a=l[2],fieldValue:s=l[3]}}}if(n=this.constructor.DEFAULT_NUMERIC_FILTER_STRING_MATCHING_REGEX,null==(r=e.match(n)))console.error("[Typesense-Instantsearch-Adapter] Parsing failed for a numeric filter `".concat(e,"` with the Regex `").concat(n,"`. If you have field names with special characters, be sure to add them to a parameter called `facetableFieldsWithSpecialCharacters` when instantiating the adapter."));else{var f=r,h=(0,o.default)(f,4);i=h[1],a=h[2],s=h[3]}return{fieldName:i,operator:a,fieldValue:s}}},{key:"_adaptGeoFilter",value:function(e){var t=e.insideBoundingBox,n=e.aroundRadius,r=e.aroundLatLng,i=e.insidePolygon;if(t){var a,s,c,u;if(Array.isArray(t)){var l=t.flat(),f=(0,o.default)(l,4);a=f[0],s=f[1],c=f[2],u=f[3]}else{var h=t.split(","),p=(0,o.default)(h,4);a=p[0],s=p[1],c=p[2],u=p[3]}return"".concat(this.configuration.geoLocationField,":(").concat(a,", ").concat(s,", ").concat(a,", ").concat(u,", ").concat(c,", ").concat(u,", ").concat(c,", ").concat(s,")")}if(r||n){if(!n||"all"===n)throw new Error("[Typesense-Instantsearch-Adapter] In Typesense, geo-filtering around a lat/lng also requires a numerical radius. So the `aroundRadius` parameter is required when `aroundLatLng` is used. If you intend to just geo-sort around a lat/long, you want to use the sortBy InstantSearch widget (or a virtual sortBy custom widget).");var d="".concat(parseFloat(n)/1e3," km");return"".concat(this.configuration.geoLocationField,":(").concat(r,", ").concat(d,")")}if(i){var m=i;return Array.isArray(i)&&(m=i.flat().join(",")),"".concat(this.configuration.geoLocationField,":(").concat(m,")")}}},{key:"_adaptFilters",value:function(e){var t=[];return e.filters&&t.push(e.filters),t.push(this._adaptFacetFilters(e.facetFilters)),t.push(this._adaptNumericFilters(e.numericFilters)),t.push(this._adaptGeoFilter(e)),t.filter((function(e){return e&&""!==e})).join(" && ")}},{key:"_adaptIndexName",value:function(e){return e.match(this.constructor.INDEX_NAME_MATCHING_REGEX)[1]}},{key:"_adaptSortBy",value:function(e){return e.match(this.constructor.INDEX_NAME_MATCHING_REGEX)[3]}},{key:"_buildSearchParameters",value:function(e){for(var t=e.params,n=e.indexName,r=this._adaptIndexName(n),i={},a=0,s=Object.entries(this.additionalSearchParameters);a=|>|<|=)(.*)")}}]),e}();t.SearchRequestAdapter=u},2559:function(e,t,n){"use strict";var r=n(4836);Object.defineProperty(t,"__esModule",{value:!0}),t.SearchResponseAdapter=void 0;var i=r(n(8698)),a=r(n(7424)),o=r(n(861)),s=r(n(8416)),c=r(n(6690)),u=r(n(9728)),l=n(8399);function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function h(e){for(var t=1;t3&&void 0!==arguments[3]?arguments[3]:[];(0,c.default)(this,e),this.typesenseResponse=t,this.instantsearchRequest=n,this.configuration=r,this.allTypesenseResponses=i}return(0,u.default)(e,[{key:"_adaptGroupedHits",value:function(e){var t=this,n=[];return n=e.map((function(e){var n=t._adaptHits(e.hits);return n.forEach((function(t){t.group_key=t._group_key=e.group_key,e.found&&(t._group_found=e.found)})),n})),this.configuration.flattenGroupedHits?n.flat():n.map((function(e){return h(h({},e[0]),{},{_grouped_hits:e})}))}},{key:"_adaptHits",value:function(e){var t=this;return e.map((function(e){var n=h({},e.document);n.objectID=e.document.id,n._snippetResult=t._adaptHighlightResult(e,"snippet"),n._highlightResult=t._adaptHighlightResult(e,"value"),n._rawTypesenseHit=e,["text_match","geo_distance_meters","curated","text_match_info","hybrid_search_info","vector_distance"].forEach((function(t){Object.keys(e).includes(t)&&!Object.keys(n).includes(t)&&(n[t]=e[t])}));var r=n[t.configuration.geoLocationField];return r&&(n._geoloc={lat:r[0],lng:r[1]}),n}))}},{key:"_adaptHighlightResult",value:function(e,t){var n={};return null!=e.highlight&&this.isHighlightPost0240RCN32Format(e.highlight)?this.adaptHighlightObject(e,n,t):this.adaptHighlightsArray(e,n,t),n}},{key:"isHighlightPost0240RCN32Format",value:function(e){return null==e.full&&null==e.snippet}},{key:"adaptHighlightsArray",value:function(e,t,n){var r=this;Object.assign.apply(Object,[t].concat((0,o.default)(Object.entries(e.document).map((function(e){var t=(0,a.default)(e,2),n=t[0],r=t[1];return(0,s.default)({},n,{value:r,matchLevel:"none",matchedWords:[]})}))))),e.highlights.forEach((function(e){t[e.field]={value:e[n]||e["".concat(n,"s")],matchLevel:"full",matchedWords:e.matched_tokens},e.indices&&(t[e.field].matchedIndices=e.indices)})),Object.entries(t).forEach((function(o){var s=(0,a.default)(o,2),c=s[0],u=s[1],l=c,f=u.value,h=u.matchLevel,p=u.matchedWords,d=u.matchedIndices;null==f?t[l]=r._adaptHighlightNullValue():Array.isArray(f)?(t[l]=[],e.document[l].forEach((function(e,a){d&&d.includes(a)?t[l].push({value:r._adaptHighlightTag("".concat(f[d.indexOf(a)]),r.instantsearchRequest.params.highlightPreTag,r.instantsearchRequest.params.highlightPostTag),matchLevel:h,matchedWords:p[a]}):"object"===(0,i.default)(e)?t[l].push(r._adaptHighlightInObjectValue(e,{},n)):t[l].push({value:"".concat(e),matchLevel:"none",matchedWords:[]})}))):"object"===(0,i.default)(f)?t[l]=r._adaptHighlightInObjectValue(f,{},n):t[l].value=r._adaptHighlightTag("".concat(f),r.instantsearchRequest.params.highlightPreTag,r.instantsearchRequest.params.highlightPostTag)}))}},{key:"adaptHighlightObject",value:function(e,t,n){Object.assign(t,this._adaptHighlightInObjectValue(e.document,e.highlight,n))}},{key:"_adaptHighlightInObjectValue",value:function(e,t,n){var r=this;return Object.assign.apply(Object,[{}].concat((0,o.default)(Object.entries(e).map((function(e){var o,c=(0,a.default)(e,2),u=c[0],l=c[1];if(null==l)o=r._adaptHighlightNullValue();else if(Array.isArray(l)){var f;o=r._adaptHighlightInArrayValue(l,null!==(f=null==t?void 0:t[u])&&void 0!==f?f:[],n)}else if("object"===(0,i.default)(l)){var h;o=r._adaptHighlightInObjectValue(l,null!==(h=null==t?void 0:t[u])&&void 0!==h?h:{},n)}else o=r._adaptHighlightInPrimitiveValue(l,null==t?void 0:t[u],n);return(0,s.default)({},u,o)})))))}},{key:"_adaptHighlightInArrayValue",value:function(e,t,n){var r=this;return e.map((function(e,a){var o;if(null==e)o=r._adaptHighlightNullValue();else if(Array.isArray(e)){var s;o=r._adaptHighlightInArrayValue(e,null!==(s=null==t?void 0:t[a])&&void 0!==s?s:[],n)}else if("object"===(0,i.default)(e)){var c;o=r._adaptHighlightInObjectValue(e,null!==(c=null==t?void 0:t[a])&&void 0!==c?c:{},n)}else o=r._adaptHighlightInPrimitiveValue(e,null==t?void 0:t[a],n);return o}))}},{key:"_adaptHighlightInPrimitiveValue",value:function(e,t,n){var r,i;return null!=t?{value:this._adaptHighlightTag("".concat(null!==(r=null!==(i=t[n])&&void 0!==i?i:t.highlight)&&void 0!==r?r:t.snippet),this.instantsearchRequest.params.highlightPreTag,this.instantsearchRequest.params.highlightPostTag),matchLevel:(t.matched_tokens||[]).length>0?"full":"none",matchedWords:t.matched_tokens||[]}:{value:this._adaptHighlightTag("".concat(e),this.instantsearchRequest.params.highlightPreTag,this.instantsearchRequest.params.highlightPostTag),matchLevel:"none",matchedWords:[]}}},{key:"_adaptHighlightNullValue",value:function(){return{value:"",matchLevel:"none",matchedWords:[]}}},{key:"_adaptFacets",value:function(e){var t={};return e.forEach((function(e){Object.assign(t,(0,s.default)({},e.field_name,Object.assign.apply(Object,[{}].concat((0,o.default)(e.counts.map((function(e){return(0,s.default)({},e.value,e.count)})))))))})),t}},{key:"_adaptFacetStats",value:function(e){var t={};return e.forEach((function(e){Object.keys(e.stats).length>0&&Object.assign(t,(0,s.default)({},e.field_name,e.stats))})),t}},{key:"_adaptRenderingContent",value:function(e){var t,n=Object.assign({},this.configuration.renderingContent);return null==(null===(t=n.facetOrdering)||void 0===t||null===(t=t.facets)||void 0===t?void 0:t.order)&&(n.facetOrdering=n.facetOrdering||{},n.facetOrdering.facets=n.facetOrdering.facets||{},n.facetOrdering.facets.order=(0,o.default)(new Set(e.map((function(e){return e.field_name})).concat(this.allTypesenseResponses.map((function(e){return e.facet_counts||[]})).flat().map((function(e){return e.field_name})).filter((function(e){return e})))))),n}},{key:"adapt",value:function(){var e=this._adaptRenderingContent(this.typesenseResponse.facet_counts||[]);return h({hits:this.typesenseResponse.grouped_hits?this._adaptGroupedHits(this.typesenseResponse.grouped_hits):this._adaptHits(this.typesenseResponse.hits),nbHits:this.typesenseResponse.found,page:this.typesenseResponse.page-1,nbPages:this._adaptNumberOfPages(),hitsPerPage:this.typesenseResponse.request_params.per_page,facets:this._adaptFacets(this.typesenseResponse.facet_counts||[]),facets_stats:this._adaptFacetStats(this.typesenseResponse.facet_counts||{}),query:this.typesenseResponse.request_params.q,processingTimeMS:this.typesenseResponse.search_time_ms},Object.keys(e).length>0?{renderingContent:e}:null)}}]),e}();t.SearchResponseAdapter=p,Object.assign(p.prototype,l.utils)},8499:function(e,t,n){"use strict";var r=n(4836);t.Z=void 0;var i=r(n(1284)),a=r(n(7156)),o=r(n(6690)),s=r(n(9728)),c=n(7325),u=n(8871),l=n(4002),f=n(2559),h=n(3599),p=function(){function e(t){var n=this;(0,o.default)(this,e),this.updateConfiguration(t),this.searchClient={clearCache:function(){return n.clearCache()},search:function(e){return n.searchTypesenseAndAdapt(e)},searchForFacetValues:function(e){return n.searchTypesenseForFacetValuesAndAdapt(e)}}}var t,n,r;return(0,s.default)(e,[{key:"searchTypesenseAndAdapt",value:(r=(0,a.default)(i.default.mark((function e(t){var n,r,a=this;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._adaptAndPerformTypesenseRequest(t);case 3:return n=e.sent,r=n.results.map((function(e,r){return a._validateTypesenseResult(e),new f.SearchResponseAdapter(e,t[r],a.configuration,n.results).adapt()})),e.abrupt("return",{results:r});case 8:throw e.prev=8,e.t0=e.catch(0),console.error(e.t0),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(_x){return r.apply(this,arguments)})},{key:"searchTypesenseForFacetValuesAndAdapt",value:(n=(0,a.default)(i.default.mark((function e(t){var n,r,a=this;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._adaptAndPerformTypesenseRequest(t);case 3:return n=e.sent,r=n.results.map((function(e,n){return a._validateTypesenseResult(e),new h.FacetSearchResponseAdapter(e,t[n],a.configuration).adapt()})),e.abrupt("return",r);case 8:throw e.prev=8,e.t0=e.catch(0),console.error(e.t0),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return n.apply(this,arguments)})},{key:"_adaptAndPerformTypesenseRequest",value:(t=(0,a.default)(i.default.mark((function e(t){var n,r;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new l.SearchRequestAdapter(t,this.typesenseClient,this.configuration),e.next=3,n.request();case 3:return r=e.sent,e.abrupt("return",r);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"clearCache",value:function(){return this.typesenseClient=new u.SearchClient(this.configuration.server),this.searchClient}},{key:"updateConfiguration",value:function(e){return this.configuration=new c.Configuration(e),this.configuration.validate(),this.typesenseClient=new u.SearchClient(this.configuration.server),!0}},{key:"_validateTypesenseResult",value:function(e){if(e.error)throw new Error("".concat(e.code," - ").concat(e.error));if(!e.hits&&!e.grouped_hits)throw new Error("Did not find any hits. ".concat(e.code," - ").concat(e.error))}}]),e}();t.Z=p},8399:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.utils=void 0;var n={_adaptHighlightTag:function(e,t,n){return e.replace(new RegExp("","g"),t||"").replace(new RegExp("","g"),n||"")},_adaptNumberOfPages:function(){var e=this.typesenseResponse.found/this.typesenseResponse.request_params.per_page;return Number.isFinite(e)?Math.ceil(e):1}};t.utils=n},8871:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Errors=t.SearchClient=t.Client=void 0;var s=o(n(4339));t.Client=s.default;var c=o(n(8834));t.SearchClient=c.default;var u=a(n(6718));t.Errors=u,t.default={Client:s.default,SearchClient:c.default,Errors:u}},8480:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0},transformResponse:[function(e,t){var n=e;return void 0!==t&&"string"==typeof e&&t["content-type"]&&t["content-type"].startsWith("application/json")&&(n=JSON.parse(e)),n}]},!0!==I&&(g.timeout=1e3*h.connectionTimeoutSeconds),f&&0!==Object.keys(f).length&&(g.params=f),h.sendApiKeyAsQueryParam&&(g.params=g.params||{},g.params["x-typesense-api-key"]=h.apiKey),p&&("string"==typeof p&&0!==p.length||"object"==typeof p&&0!==Object.keys(p).length)&&(g.data=p),v&&(A=o.default.CancelToken,w=A.source(),y=function(){return w.cancel()},v.addEventListener("abort",y),g.cancelToken=w.token),[4,(0,o.default)(g)];case 2:if((S=i.sent()).status>=1&&S.status<=499&&h.setNodeHealthcheck(d,u),h.logger.debug("Request #".concat(n,": Request to Node ").concat(d.index," was made. Response Code was ").concat(S.status,".")),S.status>=200&&S.status<300)return[2,{value:Promise.resolve(S.data)}];if(S.status<500)return[2,{value:Promise.reject(h.customErrorForResponse(S,null===(a=S.data)||void 0===a?void 0:a.message))}];throw h.customErrorForResponse(S,null===(s=S.data)||void 0===s?void 0:s.message);case 3:return R=i.sent(),h.setNodeHealthcheck(d,!1),r=R,h.logger.warn("Request #".concat(n,": Request to Node ").concat(d.index,' failed due to "').concat(R.code," ").concat(R.message).concat(null==R.response?"":" - "+JSON.stringify(null===(c=R.response)||void 0===c?void 0:c.data),'"')),h.logger.warn("Request #".concat(n,": Sleeping for ").concat(h.retryIntervalSeconds,"s and then retrying request...")),[4,h.timer(h.retryIntervalSeconds)];case 4:return i.sent(),[3,6];case 5:return v&&y&&v.removeEventListener("abort",y),[7];case 6:return[2]}}))},h=this,d=1,g.label=1;case 1:return d<=this.numRetriesPerRequest+1?[5,l(d)]:[3,4];case 2:if("object"==typeof(y=g.sent()))return[2,y.value];g.label=3;case 3:return d++,[3,1];case 4:return this.logger.debug("Request #".concat(n,": No retries left. Raising last error")),[2,Promise.reject(r)]}}))}))},e.prototype.getNextNode=function(e){if(void 0===e&&(e=0),null!=this.nearestNode){if(this.logger.debug("Request #".concat(e,": Nodes Health: Node ").concat(this.nearestNode.index," is ").concat(!0===this.nearestNode.isHealthy?"Healthy":"Unhealthy")),!0===this.nearestNode.isHealthy||this.nodeDueForHealthcheck(this.nearestNode,e))return this.logger.debug("Request #".concat(e,": Updated current node to Node ").concat(this.nearestNode.index)),this.nearestNode;this.logger.debug("Request #".concat(e,": Falling back to individual nodes"))}this.logger.debug("Request #".concat(e,": Nodes Health: ").concat(this.nodes.map((function(e){return"Node ".concat(e.index," is ").concat(!0===e.isHealthy?"Healthy":"Unhealthy")})).join(" || ")));for(var t=this.nodes[0],n=0;n<=this.nodes.length;n++)if(this.currentNodeIndex=(this.currentNodeIndex+1)%this.nodes.length,!0===(t=this.nodes[this.currentNodeIndex]).isHealthy||this.nodeDueForHealthcheck(t,e))return this.logger.debug("Request #".concat(e,": Updated current node to Node ").concat(t.index)),t;return this.logger.debug("Request #".concat(e,": No healthy nodes were found. Returning the next node, Node ").concat(t.index)),t},e.prototype.nodeDueForHealthcheck=function(e,t){void 0===t&&(t=0);var n=Date.now()-e.lastAccessTimestamp>1e3*this.healthcheckIntervalSeconds;return n&&this.logger.debug("Request #".concat(t,": Node ").concat(e.index," has exceeded healtcheckIntervalSeconds of ").concat(this.healthcheckIntervalSeconds,". Adding it back into rotation.")),n},e.prototype.initializeMetadataForNodes=function(){var e=this;null!=this.nearestNode&&(this.nearestNode.index="nearestNode",this.setNodeHealthcheck(this.nearestNode,u)),this.nodes.forEach((function(t,n){t.index=n,e.setNodeHealthcheck(t,u)}))},e.prototype.setNodeHealthcheck=function(e,t){e.isHealthy=t,e.lastAccessTimestamp=Date.now()},e.prototype.uriFor=function(e,t){return null!=t.url?"".concat(t.url).concat(e):"".concat(t.protocol,"://").concat(t.host,":").concat(t.port).concat(t.path).concat(e)},e.prototype.defaultHeaders=function(){var e={};return this.sendApiKeyAsQueryParam||(e["X-TYPESENSE-API-KEY"]=this.apiKey),e["Content-Type"]="application/json",e},e.prototype.timer=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,1e3*e)}))]}))}))},e.prototype.customErrorForResponse=function(e,t){var n="Request failed with HTTP code ".concat(e.status);"string"==typeof t&&""!==t.trim()&&(n+=" | Server said: ".concat(t));var r=new c.default(n);return(r=400===e.status?new s.RequestMalformed(n):401===e.status?new s.RequestUnauthorized(n):404===e.status?new s.ObjectNotFound(n):409===e.status?new s.ObjectAlreadyExists(n):422===e.status?new s.ObjectUnprocessable(n):e.status>=500&&e.status<=599?new s.ServerError(n):new s.HTTPError(n)).httpStatus=e.status,r},e}();t.default=l},4339:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(2554)),a=r(n(9777)),o=r(n(6581)),s=r(n(8243)),c=r(n(5346)),u=r(n(8480)),l=r(n(2708)),f=r(n(7309)),h=r(n(7634)),p=r(n(6029)),d=r(n(1930)),m=r(n(3095)),y=r(n(9092)),v=r(n(1036)),g=r(n(1040)),b=r(n(6845)),A=function(){function e(e){var t;e.sendApiKeyAsQueryParam=null!==(t=e.sendApiKeyAsQueryParam)&&void 0!==t&&t,this.configuration=new i.default(e),this.apiCall=new a.default(this.configuration),this.debug=new h.default(this.apiCall),this.metrics=new p.default(this.apiCall),this.health=new d.default(this.apiCall),this.operations=new m.default(this.apiCall),this.multiSearch=new y.default(this.apiCall,this.configuration),this._collections=new o.default(this.apiCall),this.individualCollections={},this._aliases=new c.default(this.apiCall),this.individualAliases={},this._keys=new l.default(this.apiCall),this.individualKeys={},this._presets=new v.default(this.apiCall),this.individualPresets={},this.analytics=new b.default(this.apiCall)}return e.prototype.collections=function(e){return void 0===e?this._collections:(void 0===this.individualCollections[e]&&(this.individualCollections[e]=new s.default(e,this.apiCall,this.configuration)),this.individualCollections[e])},e.prototype.aliases=function(e){return void 0===e?this._aliases:(void 0===this.individualAliases[e]&&(this.individualAliases[e]=new u.default(e,this.apiCall)),this.individualAliases[e])},e.prototype.keys=function(e){return void 0===e?this._keys:(void 0===this.individualKeys[e]&&(this.individualKeys[e]=new f.default(e,this.apiCall)),this.individualKeys[e])},e.prototype.presets=function(e){return void 0===e?this._presets:(void 0===this.individualPresets[e]&&(this.individualPresets[e]=new g.default(e,this.apiCall)),this.individualPresets[e])},e}();t.default=A},8243:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0;n--){var r=Math.floor(Math.random()*(n+1));t=[e[r],e[n]],e[n]=t[0],e[r]=t[1]}},e}();t.default=u},7634:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0)throw new s.ImportError("".concat(i.length-a.length," documents imported successfully, ").concat(a.length," documents failed during import. Use `error.importResults` from the raised exception to get a detailed error reason for each document."),i);return[2,i]}return[2,r]}}))}))},t.prototype.export=function(e){return void 0===e&&(e={}),a(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.apiCall.get(this.endpointPath("export"),e)]}))}))},t.prototype.exportStream=function(e){return void 0===e&&(e={}),a(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.apiCall.get(this.endpointPath("export"),e,{responseType:"stream"})]}))}))},t}(n(5586).SearchOnlyDocuments);t.default=c},7117:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},9229:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t,n){var r=e.call(this,t)||this;return r.importResults=n,r}return i(t,e),t}(a(n(4492)).default);t.default=o},1254:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},4105:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},3836:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},220:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},4913:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},9976:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},4959:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},4492:function(e,t){"use strict";var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)});Object.defineProperty(t,"__esModule",{value:!0});var i=function(e){function t(t){var n=this.constructor,r=e.call(this,t)||this;return r.name=n.name,Object.setPrototypeOf(r,n.prototype),r}return r(t,e),t}(Error);t.default=i},6718:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ImportError=t.TypesenseError=t.ServerError=t.RequestUnauthorized=t.RequestMalformed=t.ObjectUnprocessable=t.ObjectNotFound=t.ObjectAlreadyExists=t.MissingConfigurationError=t.HTTPError=void 0;var i=r(n(7117));t.HTTPError=i.default;var a=r(n(1254));t.MissingConfigurationError=a.default;var o=r(n(4105));t.ObjectAlreadyExists=o.default;var s=r(n(3836));t.ObjectNotFound=s.default;var c=r(n(220));t.ObjectUnprocessable=c.default;var u=r(n(4913));t.RequestMalformed=u.default;var l=r(n(9976));t.RequestUnauthorized=l.default;var f=r(n(4959));t.ServerError=f.default;var h=r(n(9229));t.ImportError=h.default;var p=r(n(4492));t.TypesenseError=p.default},1930:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]u&&(y=this.responseCache.keys().next().value,this.responseCache.delete(y)),this.responsePromiseCache.size>u&&(y=this.responsePromiseCache.keys().next().value,this.responsePromiseCache.delete(y)),[2,m]}}))}))},e}();t.default=a},8834:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(2554)),a=r(n(9777)),o=r(n(9092)),s=n(3320),c=function(){function e(e){var t;e.sendApiKeyAsQueryParam=null===(t=e.sendApiKeyAsQueryParam)||void 0===t||t,!0===e.sendApiKeyAsQueryParam&&(e.apiKey||"").length>2e3&&(console.warn("[typesense] API Key is longer than 2000 characters which is over the allowed limit, so disabling sending it as a query parameter."),e.sendApiKeyAsQueryParam=!1),this.configuration=new i.default(e),this.apiCall=new a.default(this.configuration),this.multiSearch=new o.default(this.apiCall,this.configuration,!0),this.individualCollections={}}return e.prototype.clearCache=function(){this.multiSearch.clearCache(),Object.entries(this.individualCollections).forEach((function(e){e[0],e[1].documents().clearCache()}))},e.prototype.collections=function(e){if(e)return void 0===this.individualCollections[e]&&(this.individualCollections[e]=new s.SearchOnlyCollection(e,this.apiCall,this.configuration)),this.individualCollections[e];throw new Error("Typesense.SearchClient only supports search operations, so the collectionName that needs to be searched must be specified. Use Typesense.Client if you need to access the collection object.")},e}();t.default=c},3320:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SearchOnlyCollection=void 0;var r=n(5586),i=function(){function e(e,t,n){this.name=e,this.apiCall=t,this.configuration=n,this._documents=new r.SearchOnlyDocuments(this.name,this.apiCall,this.configuration)}return e.prototype.documents=function(){return this._documents},e}();t.SearchOnlyCollection=i},5586:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]e.length)&&(t=e.length);for(var n=0,r=new Array(t);n{switch(t.type){case"INITIALIZE_NAMESPACE":return{...e,[t.namespace]:l};case"UPDATE_HIIVE_URLS":return{...e,[t.namespace]:{...e[t.namespace],urls:{single:t.urls.single,batch:t.urls.batch}}};case"UPDATE_HIIVE_EVENTS_QUEUE":return{...e,[t.namespace]:{...e[t.namespace],queue:{events:t.events,threshold:e[t.namespace].queue.threshold}}};case"UPDATE_HIIVE_EVENTS_QUEUE_THRESHOLD":return{...e,[t.namespace]:{...e[t.namespace],queue:{events:e[t.namespace].queue.events,threshold:t.threshold}}};case"UPDATE_HIIVE_DEBOUNCE_TIME":return{...e,[t.namespace]:{...e[t.namespace],debounce:{time:t.debounceTime,instance:e[t.namespace].debounce.instance}}};case"UPDATE_HIIVE_DEBOUNCE_INSTANCE":return{...e,[t.namespace]:{...e[t.namespace],debounce:{time:e[t.namespace].debounce.time,instance:t.instance}}}}return e}}),actions:e,selectors:t},S=(0,o.createReduxStore)("newfold/ui-analytics",w);(0,o.register)(S);var R=window.wp.apiFetch,P=n.n(R);const j=e=>!!window?.nfdUIAnalytics?.hiive&&e in window.nfdUIAnalytics.hiive,O=async e=>{if(!(e=>e instanceof u)(e)||!j(e.namespace))return!1;const t=e.namespace;delete e.namespace;const n=(0,o.select)(S).getHiiveSingleUrl(t);if(!n)return!1;try{await P()({url:n,method:"POST",data:e})}catch(e){return console.error(e),!1}};var E,T,x=window.wp.i18n;function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{fallback:function(){}}).fallback;return"undefined"==typeof window?t():e({window:window})}function z(){}function W(e){return W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},W(e)}function Q(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function X(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n=3||2===n&&r>=6||1===n&&r>=10}function $(e,t,n){var r=t.getHelper();return{uiState:n,helper:r,parent:t,instantSearchInstance:e,state:r.state,renderState:e.renderState,templatesConfig:e.templatesConfig,createURL:t.createURL,scopedResults:[],searchMetadata:{isSearchStalled:"stalled"===e.status},status:e.status,error:e.error}}function ee(e,t){var n=t.getResults();return{helper:t.getHelper(),parent:t,instantSearchInstance:e,results:n,scopedResults:t.getScopedResults(),state:n._state,renderState:e.renderState,templatesConfig:e.templatesConfig,createURL:t.createURL,searchMetadata:{isSearchStalled:"stalled"===e.status},status:e.status,error:e.error}}function te(e,t,n){var r=$(t,t.mainIndex,t._initialUiState);e.forEach((function(e){var i={};if(e.getWidgetRenderState){var a=e.getWidgetRenderState(r);a&&a.widgetParams&&(i=a.widgetParams)}var o=Object.keys(i).filter((function(e){return void 0!==i[e]}));n.widgets.push({type:e.$$type,widgetType:e.$$widgetType,params:o}),"ais.index"===e.$$type&&te(e.getWidgets(),t,n)}))}function ne(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).$$internal,t=void 0!==e&&e;return function(e){var n=e.instantSearchInstance,r={widgets:[]},i=document.createElement("meta"),a=document.querySelector("head");return i.name="instantsearch:widgets",{$$type:"ais.metadata",$$internal:t,onStateChange:function(){},subscribe:function(){setTimeout((function(){var e=n.client;r.ua=e.transporter&&e.transporter.userAgent?e.transporter.userAgent.value:e._ua,te(n.mainIndex.getWidgets(),n,r),n.middleware.forEach((function(e){return r.widgets.push({middleware:!0,type:e.instance.$$type,internal:e.instance.$$internal})})),i.content=JSON.stringify(r),a.appendChild(i)}),0)},started:function(){},unsubscribe:function(){i.remove()}}}}var re=n(129);function ie(e){return ie="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ie(e)}function ae(e,t){for(var n=0;n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(e,fe)}function ye(e){return e!==Object(e)}function ve(e,t){if(e===t)return!0;if(ye(e)||ye(t)||"function"==typeof e||"function"==typeof t)return e===t;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n=0,r=Object.keys(e);n0&&void 0!==arguments[0]?arguments[0]:{},t=e.router,n=void 0===t?function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.createURL,n=void 0===t?function(e){var t=e.qsModule,n=e.routeState,r=e.location,i=r.protocol,a=r.hostname,o=r.port,s=void 0===o?"":o,c=r.pathname,u=r.hash,l=t.stringify(n),f=""===s?"":":".concat(s);return l?"".concat(i,"//").concat(a).concat(f).concat(c,"?").concat(l).concat(u):"".concat(i,"//").concat(a).concat(f).concat(c).concat(u)}:t,r=e.parseURL,i=void 0===r?function(e){var t=e.qsModule,n=e.location;return t.parse(n.search.slice(1),{arrayLimit:99})}:r,a=e.writeDelay,o=void 0===a?400:a,s=e.windowTitle,c=e.getLocation,u=void 0===c?function(){return G((function(e){return e.window.location}),{fallback:function(){throw new Error("You need to provide `getLocation` to the `history` router in environments where `window` does not exist.")}})}:c,l=e.start,f=e.dispose,h=e.push;return new ue({createURL:n,parseURL:i,writeDelay:o,windowTitle:s,getLocation:u,start:l,dispose:f,push:h})}():t,r=e.stateMapping,i=void 0===r?{$$type:"ais.simple",stateToRoute:function(e){return Object.keys(e).reduce((function(t,n){return pe(pe({},t),{},de({},n,me(e[n])))}),{})},routeToState:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.keys(e).reduce((function(t,n){return pe(pe({},t),{},de({},n,me(e[n])))}),{})}}:r,a=e.$$internal,o=void 0!==a&&a;return function(e){var t=e.instantSearchInstance;t._createURL=function(e){var r=Object.keys(e).reduce((function(t,n){return Ae(Ae({},t),{},Ie({},n,e[n]))}),t.mainIndex.getWidgetUiState({})),a=i.stateToRoute(r);return n.createURL(a)};var r=void 0,a=t._initialUiState;return{$$type:"ais.router({router:".concat(n.$$type||"__unknown__",", stateMapping:").concat(i.$$type||"__unknown__","})"),$$internal:o,onStateChange:function(e){var t=e.uiState,a=i.stateToRoute(t);void 0!==r&&ve(r,a)||(n.write(a),r=a)},subscribe:function(){t._initialUiState=Ae(Ae({},a),i.routeToState(n.read())),n.onUpdate((function(e){t.setUiState(i.routeToState(e))}))},started:function(){var e;null===(e=n.start)||void 0===e||e.call(n)},unsubscribe:function(){n.dispose()}}}};function Se(){for(var e=arguments.length,t=new Array(e),n=0;n0?e.setQueryParameters({ruleContexts:n}):e}(c,t),l=function(e,t){return t.facets.reduce((function(e,t){return e.addFacet(t)}),e)}(u,t);return function(e,t){t.facets,t.disjunctiveFacets,t.facetsRefinements,t.facetsExcludes,t.disjunctiveFacetsRefinements,t.numericRefinements,t.tagRefinements,t.hierarchicalFacets,t.hierarchicalFacetsRefinements,t.ruleContexts;var n=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,je);return e.setQueryParameters(n)}(l,t)}))};function He(e){return He="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},He(e)}var ke=["initialSearchParameters"];function Me(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ne(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);n2&&void 0!==arguments[2]?arguments[2]:{};return e.reduce((function(e,n){return Re(n)?e:n.getWidgetUiState||n.getWidgetState?n.getWidgetUiState?n.getWidgetUiState(e,t):n.getWidgetState(e,t):e}),n)}function Ge(e,t){var n=t.initialSearchParameters,r=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,ke);return e.filter((function(e){return!Re(e)})).reduce((function(e,t){return t.getWidgetSearchParameters?t.getWidgetSearchParameters(e,r):e}),n)}function ze(e){var t=e.filter(Re);0!==t.length&&t.forEach((function(e){var t=e.getHelper();Be(t,{state:t.state.resetPage(),isPageReset:!0}),ze(e.getWidgets())}))}function We(e){return e.filter(Re).reduce((function(e,t){return e.concat.apply(e,[{indexId:t.getIndexId(),results:t.getResults(),helper:t.getHelper()}].concat(Ue(We(t.getWidgets()))))}),[])}var Qe=function(e){if(void 0===e||void 0===e.indexName)throw new Error(De("The `indexName` option is required."));var t=e.indexName,n=e.indexId,r=void 0===n?t:n,i=[],a={},o=null,s=null,c=null,u=null,l=null;return{$$type:"ais.index",$$widgetType:"ais.index",getIndexName:function(){return t},getIndexId:function(){return r},getHelper:function(){return c},getResults:function(){var e;return null!==(e=u)&&void 0!==e&&e.lastResults?(u.lastResults._state=c.state,u.lastResults):null},getPreviousState:function(){return l},getScopedResults:function(){var e=this.getParent();return We(e?e.getWidgets():[this])},getParent:function(){return s},createURL:function(e){return o._createURL(Ce({},r,Fe(i,{searchParameters:e,helper:c})))},getWidgets:function(){return i},addWidgets:function(e){var t=this;if(!Array.isArray(e))throw new Error(De("The `addWidgets` method expects an array of widgets."));if(e.some((function(e){return"function"!=typeof e.init&&"function"!=typeof e.render})))throw new Error(De("The widget definition expects a `render` and/or an `init` method."));return i=i.concat(e),o&&Boolean(e.length)&&(Be(c,{state:Ge(i,{uiState:a,initialSearchParameters:c.state}),_uiState:a}),e.forEach((function(e){e.getRenderState&&Xe({renderState:e.getRenderState(o.renderState[t.getIndexId()]||{},$(o,t,o._initialUiState)),instantSearchInstance:o,parent:t})})),e.forEach((function(e){e.init&&e.init($(o,t,o._initialUiState))})),o.scheduleSearch()),this},removeWidgets:function(e){var t=this;if(!Array.isArray(e))throw new Error(De("The `removeWidgets` method expects an array of widgets."));if(e.some((function(e){return"function"!=typeof e.dispose})))throw new Error(De("The widget definition expects a `dispose` method."));if(i=i.filter((function(t){return-1===e.indexOf(t)})),o&&Boolean(e.length)){var n=e.reduce((function(e,n){return n.dispose({helper:c,state:e,parent:t})||e}),c.state);a=Fe(i,{searchParameters:n,helper:c}),c.setState(Ge(i,{uiState:a,initialSearchParameters:n})),i.length&&o.scheduleSearch()}return this},init:function(e){var n,f=this,h=e.instantSearchInstance,p=e.parent,d=e.uiState;if(null===c){o=h,s=p,a=d[r]||{};var m=h.mainHelper,y=Ge(i,{uiState:a,initialSearchParameters:new B.SearchParameters({index:t})});(c=B({},y.index,y)).search=function(){return h.onStateChange?(h.onStateChange({uiState:h.mainIndex.getWidgetUiState({}),setUiState:function(e){return h.setUiState(e,!1)}}),m):m.search()},c.searchWithoutTriggeringOnStateChange=function(){return m.search()},c.searchForFacetValues=function(e,t,n,r){var i=c.state.setQueryParameters(r);return m.searchForFacetValues(e,t,n,i)},u=m.derive((function(){return xe.apply(void 0,Ue(function(e){for(var t=e.getParent(),n=[e.getHelper().state];null!==t;)n=[t.getHelper().state].concat(n),t=t.getParent();return n}(f)))}));var v=null===(n=h._initialResults)||void 0===n?void 0:n[this.getIndexId()];if(v){var g=new B.SearchResults(new B.SearchParameters(v.state),v.results);u.lastResults=g,c.lastResults=g}c.on("change",(function(e){e.isPageReset&&ze(i)})),u.on("search",(function(){h.scheduleStalledRender()})),u.on("result",(function(e){var t=e.results;h.scheduleRender(),c.lastResults=t,l=t._state})),i.forEach((function(e){e.getRenderState&&Xe({renderState:e.getRenderState(h.renderState[f.getIndexId()]||{},$(h,f,d)),instantSearchInstance:h,parent:f})})),i.forEach((function(e){e.init&&e.init($(h,f,d))})),c.on("change",(function(e){var t=e.state,n=e._uiState;a=Fe(i,{searchParameters:t,helper:c},n||{}),h.onStateChange||h.onInternalStateChange()})),v&&h.scheduleRender()}},render:function(e){var t=this,n=e.instantSearchInstance;this.getResults()&&("error"!==n.status||n.mainHelper.hasPendingRequests()||c.setState(l),i.forEach((function(e){e.getRenderState&&Xe({renderState:e.getRenderState(n.renderState[t.getIndexId()]||{},ee(n,t)),instantSearchInstance:n,parent:t})})),i.forEach((function(e){e.render&&e.render(ee(n,t))})))},dispose:function(){var e,t,n=this;i.forEach((function(e){e.dispose&&e.dispose({helper:c,state:c.state,parent:n})})),o=null,s=null,null===(e=c)||void 0===e||e.removeAllListeners(),c=null,null===(t=u)||void 0===t||t.detach(),u=null},getWidgetUiState:function(e){return i.filter(Re).reduce((function(e,t){return t.getWidgetUiState(e)}),Ne(Ne({},e),{},Ce({},r,Ne(Ne({},e[r]),a))))},getWidgetState:function(e){return this.getWidgetUiState(e)},getWidgetSearchParameters:function(e,t){var n=t.uiState;return Ge(i,{uiState:n,initialSearchParameters:e})},refreshUiState:function(){a=Fe(i,{searchParameters:this.getHelper().state,helper:this.getHelper()},a)},setIndexUiState:function(e){var t="function"==typeof e?e(a):e;o.setUiState((function(e){return Ne(Ne({},e),{},Ce({},r,t))}))}}};function Xe(e){var t=e.renderState,n=e.instantSearchInstance,r=e.parent,i=r?r.getIndexId():n.mainIndex.getIndexId();n.renderState=Ne(Ne({},n.renderState),{},Ce({},i,Ne(Ne({},n.renderState[i]),t)))}var Je=function(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.descendantName,r=t.modifierName,i=n?"-".concat(n):"",a=r?"--".concat(r):"";return"".concat("ais","-").concat(e).concat(i).concat(a)}};function Ve(e,t){return(Array.isArray(t)?t:t.split(".")).reduce((function(e,t){return e&&e[t]}),e)}var Le={highlightPreTag:"",highlightPostTag:""},Ye=Je("Highlight");function qe(e){var t=Le.highlightPreTag,n=Le.highlightPostTag;return e.map((function(e){return e.isHighlighted?t+e.value+n:e.value})).join("")}RegExp(/[&<>"']/g.source);var Ke={"&":"&","<":"<",">":">",""":'"',"'":"'"},_e=/&(amp|quot|lt|gt|#39);/g,$e=RegExp(_e.source),et=new RegExp(/\w/i);function tt(e,t){var n,r,i,a=e[t],o=(null===(n=e[t+1])||void 0===n?void 0:n.isHighlighted)||!0,s=(null===(r=e[t-1])||void 0===r?void 0:r.isHighlighted)||!0;return et.test((i=a.value)&&$e.test(i)?i.replace(_e,(function(e){return Ke[e]})):i)||s!==o?a.isHighlighted:s}function nt(e){return nt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},nt(e)}function rt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function it(e){for(var t=1;t')).replace(new RegExp(Le.highlightPostTag,"g"),""))}(dt(dt({},JSON.parse(e)),{},{hit:this})))}catch(e){throw new Error('\nThe highlight helper expects a JSON object of the format:\n{ "attribute": "name", "highlightedTagName": "mark" }')}},reverseHighlight:function(e,t){try{return t(function(e){var t=e.attribute,n=e.highlightedTagName,r=void 0===n?"mark":n,i=e.hit,a=e.cssClasses,o=void 0===a?{}:a,s=(Ve(i._highlightResult,t)||{}).value,c=void 0===s?"":s,u=ct({descendantName:"highlighted"})+(o.highlighted?" ".concat(o.highlighted):"");return qe(ot(st(c))).replace(new RegExp(Le.highlightPreTag,"g"),"<".concat(r,' class="').concat(u,'">')).replace(new RegExp(Le.highlightPostTag,"g"),""))}(dt(dt({},JSON.parse(e)),{},{hit:this})))}catch(e){throw new Error('\n The reverseHighlight helper expects a JSON object of the format:\n { "attribute": "name", "highlightedTagName": "mark" }')}},snippet:function(e,t){try{return t(function(e){var t=e.attribute,n=e.highlightedTagName,r=void 0===n?"mark":n,i=e.hit,a=e.cssClasses,o=void 0===a?{}:a,s=(Ve(i._snippetResult,t)||{}).value,c=void 0===s?"":s,u=ut({descendantName:"highlighted"})+(o.highlighted?" ".concat(o.highlighted):"");return c.replace(new RegExp(Le.highlightPreTag,"g"),"<".concat(r,' class="').concat(u,'">')).replace(new RegExp(Le.highlightPostTag,"g"),""))}(dt(dt({},JSON.parse(e)),{},{hit:this})))}catch(e){throw new Error('\nThe snippet helper expects a JSON object of the format:\n{ "attribute": "name", "highlightedTagName": "mark" }')}},reverseSnippet:function(e,t){try{return t(function(e){var t=e.attribute,n=e.highlightedTagName,r=void 0===n?"mark":n,i=e.hit,a=e.cssClasses,o=void 0===a?{}:a,s=(Ve(i._snippetResult,t)||{}).value,c=void 0===s?"":s,u=lt({descendantName:"highlighted"})+(o.highlighted?" ".concat(o.highlighted):"");return qe(ot(st(c))).replace(new RegExp(Le.highlightPreTag,"g"),"<".concat(r,' class="').concat(u,'">')).replace(new RegExp(Le.highlightPostTag,"g"),""))}(dt(dt({},JSON.parse(e)),{},{hit:this})))}catch(e){throw new Error('\n The reverseSnippet helper expects a JSON object of the format:\n { "attribute": "name", "highlightedTagName": "mark" }')}},insights:function(e,t){try{var n=JSON.parse(e),r=n.method,i=n.payload;return t(function(e,t){return function(e){var t,n=e.method,r=e.payload;if("object"!==ft(r))throw new Error("The insights helper expects the payload to be an object.");try{t=function(e){return btoa(encodeURIComponent(JSON.stringify(e)))}(r)}catch(e){throw new Error("Could not JSON serialize the payload object.")}return'data-insights-method="'.concat(n,'" data-insights-payload="').concat(t,'"')}({method:e,payload:t})}(r,dt({objectIDs:[this.objectID]},i)))}catch(e){throw new Error('\nThe insights helper expects a JSON object of the format:\n{ "method": "method-name", "payload": { "eventName": "name of the event" } }')}}}}var vt=Promise.resolve();function gt(e){var t=null,n=!1,r=function(){for(var r=arguments.length,i=new Array(r),a=0;a0&&void 0!==arguments[0])||arguments[0];null!==(e=t.mainHelper)&&void 0!==e&&e.hasPendingRequests()||(clearTimeout(t._searchStalledTimer),t._searchStalledTimer=null,n&&(t.status="idle",t.error=void 0)),t.mainIndex.render({instantSearchInstance:Rt(t)}),t.emit("render")}))),jt(Rt(t),"onInternalStateChange",gt((function(){var e=t.mainIndex.getWidgetUiState({});t.middleware.forEach((function(t){t.instance.onStateChange({uiState:e})}))}))),t.setMaxListeners(100);var n=e.indexName,r=void 0===n?null:n,i=e.numberLocale,s=e.initialUiState,c=void 0===s?{}:s,u=e.routing,l=void 0===u?null:u,f=e.insights,h=void 0!==f&&f,p=e.searchFunction,d=e.stalledSearchDelay,m=void 0===d?200:d,y=e.searchClient,v=void 0===y?null:y,g=e.insightsClient,b=void 0===g?null:g,A=e.onStateChange,I=void 0===A?null:A;if(null===r)throw new Error(Et("The `indexName` option is required."));if(null===v)throw new Error(Et("The `searchClient` option is required."));if("function"!=typeof v.search)throw new Error("The `searchClient` must implement a `search` method.\n\nSee: https://www.algolia.com/doc/guides/building-search-ui/going-further/backend-search/in-depth/backend-instantsearch/js/");if("function"==typeof v.addAlgoliaAgent&&v.addAlgoliaAgent("instantsearch.js (".concat("4.55.0",")")),b&&"function"!=typeof b)throw new Error(Et("The `insightsClient` option should be a function."));if(t.client=v,t.insightsClient=b,t.indexName=r,t.helper=null,t.mainHelper=null,t.mainIndex=Qe({indexName:r}),t.onStateChange=I,t.started=!1,t.templatesConfig={helpers:yt({numberLocale:i}),compileOptions:{}},t._stalledSearchDelay=m,t._searchStalledTimer=null,t._createURL=Tt,t._initialUiState=c,t._initialResults=null,p&&(t._searchFunction=p),t.sendEventToInsights=z,l){var w="boolean"==typeof l?{}:l;w.$$internal=!0,t.use(we(w))}if(h){var S="boolean"==typeof h?{}:h;S.$$internal=!0,t.use(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.insightsClient,n=e.insightsInitParams,r=e.onEvent,i=e.$$internal,a=void 0!==i&&i,o=t;t||null===t||G((function(e){var t=e.window,n=t.AlgoliaAnalyticsObject||"aa";"string"==typeof n&&(o=t[n]),o||(t.AlgoliaAnalyticsObject=n,t[n]||(t[n]=function(){t[n].queue||(t[n].queue=[]);for(var e=arguments.length,r=new Array(e),i=0;i-1}),{fallback:function(){return!1}})&&t.use(ne({$$internal:!0})),t}return t=o,n=[{key:"_isSearchStalled",get:function(){return"stalled"===this.status}},{key:"use",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0&&this.scheduleSearch();this.helper=this.mainIndex.getHelper(),this.started=!0,this.middleware.forEach((function(e){e.instance.started()}))}},{key:"dispose",value:function(){var e;this.scheduleSearch.cancel(),this.scheduleRender.cancel(),clearTimeout(this._searchStalledTimer),this.removeWidgets(this.mainIndex.getWidgets()),this.mainIndex.dispose(),this.started=!1,this.removeAllListeners(),null===(e=this.mainHelper)||void 0===e||e.removeAllListeners(),this.mainHelper=null,this.helper=null,this.middleware.forEach((function(e){e.instance.unsubscribe()}))}},{key:"scheduleStalledRender",value:function(){var e=this;this._searchStalledTimer||(this._searchStalledTimer=setTimeout((function(){e.status="stalled",e.scheduleRender()}),this._stalledSearchDelay))}},{key:"setUiState",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!this.mainHelper)throw new Error(Et("The `start` method needs to be called before `setUiState`."));this.mainIndex.refreshUiState();var r="function"==typeof e?e(this.mainIndex.getWidgetUiState({})):e;this.onStateChange&&n?this.onStateChange({uiState:r,setUiState:function(e){bt("function"==typeof e?e(r):e,t.mainIndex),t.scheduleSearch(),t.onInternalStateChange()}}):(bt(r,this.mainIndex),this.scheduleSearch(),this.onInternalStateChange())}},{key:"getUiState",value:function(){return this.started&&this.mainIndex.refreshUiState(),this.mainIndex.getWidgetUiState({})}},{key:"createURL",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.started)throw new Error(Et("The `start` method needs to be called before `createURL`."));return this._createURL(e)}},{key:"refresh",value:function(){if(!this.mainHelper)throw new Error(Et("The `start` method needs to be called before `refresh`."));this.mainHelper.clearCache().search()}}],n&&wt(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),o}(D),Ht=xt,kt=n(1688),Mt=(0,i.createContext)(null);function Nt(){return(0,i.useContext)(Mt)}var Ct=(0,i.createContext)(null),Ut="6.38.1";function Zt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(e,zt));return n.started?i.createElement(Z.Provider,{value:n},i.createElement(U.Provider,{value:n.mainIndex},t)):null}var Qt=n(8499),Xt=window.lodash;function Jt(e){return Jt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Jt(e)}function Vt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Lt(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:z;return function(e,t){if(void 0===e||"function"!=typeof e)throw new Error("The render function is not valid (received type ".concat((n=e,Object.prototype.toString.call(n).slice(8,-1)),").\n\n").concat(t));var n}(e,qt()),function(n){var r,i,a=(n||{}).queryHook,o=void 0===a?Kt:a;return{$$type:"ais.searchBox",init:function(t){var n=t.instantSearchInstance;e(Lt(Lt({},this.getWidgetRenderState(t)),{},{instantSearchInstance:n}),!0)},render:function(t){var n=t.instantSearchInstance;e(Lt(Lt({},this.getWidgetRenderState(t)),{},{instantSearchInstance:n}),!1)},dispose:function(e){var n=e.state;return t(),n.setQueryParameter("query",void 0)},getRenderState:function(e,t){return Lt(Lt({},e),{},{searchBox:this.getWidgetRenderState(t)})},getWidgetRenderState:function(e){var t=e.helper,a=e.searchMetadata,s=e.state;return r||(r=function(e){o(e,(function(e){return t.setQuery(e).search()}))},i=function(){t.setQuery("").search()}),{query:s.query||"",refine:r,clear:i,widgetParams:n,isSearchStalled:a.isSearchStalled}},getWidgetUiState:function(e,t){var n=t.searchParameters.query||"";return""===n||e&&e.query===n?e:Lt(Lt({},e),{},{query:n})},getWidgetSearchParameters:function(e,t){var n=t.uiState;return e.setQueryParameter("query",n.query||"")}}}};function $t(e){return $t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$t(e)}var en=Object.prototype.hasOwnProperty;function tn(e,t,n){if(null!=n&&n(e,t))return!0;var r,i;if(e===t)return!0;if(e&&t&&(r=e.constructor)===t.constructor){if(r===Date)return e.getTime()===t.getTime();if(r===RegExp)return e.toString()===t.toString();if(r===Array){if((i=e.length)===t.length)for(;i--&&tn(e[i],t[i],n););return-1===i}if(!r||"object"===$t(e)){for(r in i=0,e){if(en.call(e,r)&&++i&&!en.call(t,r))return!1;if(!(r in t)||!tn(e[r],t[r],n))return!1}return Object.keys(t).length===i}}return e!=e&&t!=t}function nn(e){var t,n,r;return new B.SearchResults(e,[{query:null!==(t=e.query)&&void 0!==t?t:"",page:null!==(n=e.page)&&void 0!==n?n:0,hitsPerPage:null!==(r=e.hitsPerPage)&&void 0!==r?r:20,hits:[],nbHits:0,nbPages:0,params:"",exhaustiveNbHits:!0,exhaustiveFacetsCount:!0,processingTimeMS:0,index:e.index}],{__isArtificial:!0})}function rn(e){return rn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rn(e)}function an(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function on(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Sn(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=Nt(),s=fn(),c=ln(),u=pn(r),l=pn(a),f=(0,i.useRef)(!0),h=(0,i.useRef)(null),p=(0,i.useMemo)((function(){return An(An({},e((function(e,t){if(t)f.current=!0;else if(f.current){e.instantSearchInstance,e.widgetParams;var n=wn(e,yn);tn(n,h.current,(function(e,t){return(null==e?void 0:e.constructor)===Function&&(null==t?void 0:t.constructor)===Function}))||(y(n),h.current=n)}}),(function(){f.current=!1}))(u)),l)}),[e,u,l]),d=(t=(0,i.useState)((function(){if(p.getWidgetRenderState){var e,t=c.getHelper(),n=c.getWidgetUiState({})[c.getIndexId()];t.state=(null===(e=p.getWidgetSearchParameters)||void 0===e?void 0:e.call(p,t.state,{uiState:n}))||t.state;var r=cn(c),i=r.results,a=r.scopedResults,o=p.getWidgetRenderState({helper:t,parent:c,instantSearchInstance:s,results:i,scopedResults:a,state:t.state,renderState:s.renderState,templatesConfig:s.templatesConfig,createURL:c.createURL,searchMetadata:{isSearchStalled:"stalled"===s.status},status:s.status,error:s.error});return o.widgetParams,wn(o,vn)}return{}})),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,_x,a,o=[],_n=!0,s=!1;try{if(_x=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;_n=!1}else for(;!(_n=(r=_x.call(n)).done)&&(o.push(r.value),o.length!==t);_n=!0);}catch(e){s=!0,i=e}finally{try{if(!_n&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw i}}return o}}(t,n)||function(e,t){if(e){if("string"==typeof e)return gn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?gn(e,t):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=d[0],y=d[1];return function(e){var t=e.widget,n=e.parentIndex,r=e.props,a=e.shouldSsr,o=(0,i.useRef)(r);(0,i.useEffect)((function(){o.current=r}),[r]);var s=(0,i.useRef)(t);(0,i.useEffect)((function(){s.current=t}),[t]);var c=(0,i.useRef)(null),u=a&&!n.getWidgets().includes(t),l=fn();dn((function(){var e=s.current;return c.current?(clearTimeout(c.current),tn(r,o.current)||(n.removeWidgets([e]),n.addWidgets([t]))):u||n.addWidgets([t]),function(){c.current=setTimeout((function(){l._schedule((function(){l._preventWidgetCleanup||n.removeWidgets([e])}))}))}}),[n,t,u,l,r]),u&&n.addWidgets([t])}({widget:p,parentIndex:c,props:u,shouldSsr:Boolean(o)}),m}function Rn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0&&void 0!==arguments[0]?arguments[0]:{}).catchError,t=fn(),n=function(){var e,t,n=fn(),r=ln(),a=r.getIndexId(),o=(e=(0,i.useState)((function(){return n.getUiState()})),t=2,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,_x,a,o=[],_n=!0,s=!1;try{if(_x=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;_n=!1}else for(;!(_n=(r=_x.call(n)).done)&&(o.push(r.value),o.length!==t);_n=!0);}catch(e){s=!0,i=e}finally{try{if(!_n&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Pn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Pn(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),s=o[0],c=o[1],u=s[a],l=(0,i.useCallback)((function(e){n.setUiState(e)}),[n]),f=(0,i.useCallback)((function(e){r.setIndexUiState(e)}),[r]);return(0,i.useEffect)((function(){function e(){c(n.getUiState())}return n.addListener("render",e),function(){n.removeListener("render",e)}}),[n]),{uiState:s,setUiState:l,indexUiState:u,setIndexUiState:f}}(),r=n.uiState,a=n.setUiState,o=n.indexUiState,s=n.setIndexUiState,c=function(){var e,t,n=fn(),r=ln(),a=(e=(0,i.useState)((function(){return cn(r)})),t=2,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,_x,a,o=[],_n=!0,s=!1;try{if(_x=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;_n=!1}else for(;!(_n=(r=_x.call(n)).done)&&(o.push(r.value),o.length!==t);_n=!0);}catch(e){s=!0,i=e}finally{try{if(!_n&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Rn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Rn(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=a[0],s=a[1];return(0,i.useEffect)((function(){function e(){var e=r.getResults();null!==e&&s({results:e,scopedResults:r.getScopedResults()})}return n.addListener("render",e),function(){n.removeListener("render",e)}}),[n,r]),o}(),u=c.results,l=c.scopedResults,f=(0,i.useCallback)((function(){for(var e=arguments.length,n=new Array(e),r=0;rP()({path:On+"/search",method:"POST",data:{user_prompt:e,identifier:t,extra:n}}),getDefaultSearchResult:()=>P()({path:On+"/search/default",method:"POST"})};function Hn(){return Hn=Object.assign?Object.assign.bind():function(e){for(var t=1;t(0,i.createElement)(i.Fragment,null,(0,i.createElement)("div",{className:"algoliaResult",onClick:t},(0,i.createElement)("p",null,e),(0,i.createElement)("div",{className:"svg"},(0,i.createElement)(Nn,null)))),Un="nfd-help-center/v1",Zn={updateHelpVisible:e=>{localStorage.setItem("helpVisible",e?"true":"false")},getHelpVisible:()=>"true"===localStorage.getItem("helpVisible"),persistResult:(e,t)=>{localStorage.setItem("helpResultContent",e),localStorage.setItem("helpPostId",t)},persistSearchInput:e=>{localStorage.setItem("searchInput",e)},clear:()=>{localStorage.removeItem("helpResultContent"),localStorage.removeItem("helpPostId"),localStorage.removeItem("searchInput")},getResultInfo:()=>({content:localStorage.getItem("helpResultContent"),postId:localStorage.getItem("helpPostId")}),getSearchInput:()=>localStorage.getItem("searchInput"),getFeatureFlag(e){return localStorage.getItem(e)},setFeatureFlag(e,t){localStorage.setItem(e,t)}},Dn=(e,t)=>{const n=new u("wonder_help",e,t,"wonder_help");O(n)};var Bn,Fn,Gn=({postId:e,source:t})=>{const[n,r]=(0,a.useState)(""),o=(0,a.useRef)(null),s=(0,a.useRef)(null);return(0,a.useEffect)((()=>{r(""),s.current.className="feedback-button no",o.current.className="feedback-button yes"}),[e]),(0,a.useEffect)((()=>{(async()=>{"helpful"!==n&&"notHelpful"!==n||(((e,t)=>{P()({path:Un+"/feedback",method:"POST",data:{post_id:e,status:t}})})(e,n),Dn("help_feedback_submitted",{label_key:"type",type:"helpful"===n?"positive":"negative",source:t,post_id:e,page:window.location.href.toString()}))})(),"helpful"===n&&(o.current.className="feedback-button yes selected-yes",s.current.className="feedback-button no"),"notHelpful"===n&&(s.current.className="feedback-button no selected-no",o.current.className="feedback-button yes")}),[n]),(0,i.createElement)("div",{className:"feedback-container"},(0,i.createElement)("div",{className:"feedback-question"},(0,i.createElement)("p",null,(0,i.createElement)("b",null,(0,x.__)("Did this result help you?","wp-module-help-center")))),(0,i.createElement)("div",{className:"icon"},(0,i.createElement)("button",{ref:o,onClick:()=>{r("helpful")},className:"feedback-button yes"},"helpful"===n&&(0,i.createElement)(i.Fragment,null,"🥳")," ",(0,x.__)("Yes","wp-module-help-center")),(0,i.createElement)("button",{onClick:()=>{r("notHelpful")},ref:s,className:"feedback-button no"},"notHelpful"===n&&(0,i.createElement)(i.Fragment,null,"😭")," ",(0,x.__)("No","wp-module-help-center"))))};function zn(){return zn=Object.assign?Object.assign.bind():function(e){for(var t=1;t(0,i.createElement)("div",null,(0,i.createElement)("p",null,(0,x.__)("Result based on your search:","wp-module-help-center")),(0,i.createElement)("h4",null,(0,x.__)("Sorry, we don't have any content for that yet.","wp-module-help-center")),(0,i.createElement)("hr",null),(0,i.createElement)(Wn,null),(0,i.createElement)("p",null,(0,x.__)("This tool is being built and doesn't always have a match.","wp-module-help-center")),(0,i.createElement)("p",null,(0,x.__)("In the meantime, try searching our","wp-module-help-center")," ",(0,i.createElement)("a",{href:"https://www.bluehost.com/help"},(0,x.__)("Resource center.","wp-module-help-center"))),(0,i.createElement)("hr",null));const Xn=({content:e,noResult:t,postId:n,source:r,showFeedbackSection:a})=>t?(0,i.createElement)(Qn,null):e&&e.length>0?(0,i.createElement)(i.Fragment,null,(0,i.createElement)("h4",null,(0,x.__)("Follow these steps:","wp-module-help-center")),(0,i.createElement)("p",{dangerouslySetInnerHTML:{__html:e}}),a&&e&&e.length>0&&(0,i.createElement)(Gn,{postId:n,source:r})):(0,i.createElement)(i.Fragment,null);var Jn,Vn,Ln,Yn,qn,Kn;function $n(){return $n=Object.assign?Object.assign.bind():function(e){for(var t=1;t(0,i.createElement)(i.Fragment,null,(0,i.createElement)(tr,null)," ",(0,i.createElement)(tr,null)," ",(0,i.createElement)(tr,null)),rr=e=>{const[t,n]=(0,a.useState)(!1),[r,o]=(0,a.useState)(!1),[s,c]=(0,a.useState)(""),[u,l]=(0,a.useState)(""),[f,h]=(0,a.useState)(),[p,d]=(0,a.useState)("kb"),{refine:m,clear:y}=Sn(_t,void 0,void 0),{results:v}=jn(),g=(e,t,n)=>{const r=e.replace(/\n/g,"
");l(r),h(t),Zn.persistResult(r,t),Zn.persistSearchInput(n),t&&Dn("help_search",{label_key:"term",term:n,page:window.location.href.toString()})};(0,a.useEffect)((()=>{c(""),l(""),m("")}),[e.refresh]),(0,a.useEffect)((()=>{const{content:e,postId:t}=Zn.getResultInfo();e&&l(e),t&&h(t);const n=Zn.getSearchInput();n&&(c(n),m(n))}),[]);const b=(0,a.useMemo)((()=>(0,Xt.debounce)((function(e){e&&0===e.length&&y(),m(e)}),300)),[]);return(0,a.useEffect)((()=>{b.cancel()}),[]),t?(0,i.createElement)(i.Fragment,null,(0,i.createElement)(nr,null)):(0,i.createElement)(i.Fragment,null,(0,i.createElement)("div",{className:"search-container"},(0,i.createElement)("button",{onClick:()=>{document.getElementById("search-input-box").focus()}},(0,i.createElement)(kn,null)),(0,i.createElement)("input",{type:"text",id:"search-input-box",style:{flexGrow:2},value:s,maxLength:"144",placeholder:(0,x.__)("Ask me anything…","wp-module-help-center"),onChange:e=>{c(e.target.value),g("",void 0,e.target.value),o(!1),b(e.target.value)},onKeyDown:async e=>{"Enter"===e.key&&await(async()=>{n(!0);try{const e=v.hits;if(e.length>0&&((e,t,n)=>{const r=t/e.split(/\s+/).length;return n>=1&&r>=.99})(s,e[0].text_match_info.tokens_matched,e[0].text_match_info.fields_matched))return void g(e[0].post_content,e[0].post_id,s);d("ai");const t=await xn.getSearchResult(s,"helpcenter");g(t.result[0].text,t.post_id,s)}catch(e){o(!0)}finally{n(!1)}})()}})),(0,i.createElement)("div",{className:"attribute"},(0,i.createElement)("p",null,(0,i.createElement)("span",null,s?s.length:0,"/144"))),(0,i.createElement)(Xn,{content:u,noResult:r,postId:f,source:p,showFeedbackSection:!u.includes("do not possess the answer")}),v.hits.length>0&&(0,i.createElement)("p",null,(0,i.createElement)("b",null,u.length>0?(0,x.__)("Other Resources","wp-module-help-center"):(0,x.__)("Search Suggestions","wp-module-help-center"))),v.hits.map(((e,t)=>{const n=document.createElement("span");n.setAttribute("display","none"),n.innerHTML=e.post_title;const r=n.textContent||n.innerText;return(0,i.createElement)(i.Fragment,null,(0,i.createElement)(Cn,{key:t,searchTitle:r,onGo:()=>{c(r),g(e.post_content,e.post_id,r)}}))})))},ir=e=>{const t=new Qt.Z({server:{apiKey:"B9wvYIokTPPgXEM3isTqsxbDOva21igT",nodes:[{host:"search.hiive.cloud",port:443,protocol:"https"}]},additionalSearchParameters:{query_by:"post_title,post_content",sort_by:"post_likes:desc",filter_by:`post_category:=${e.brand}`,limit_hits:3,per_page:3}}).searchClient,[n,r]=(0,a.useState)(!1),[o,s]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{(async()=>{try{const e=await P()({path:Un+"/capability",method:"GET"});s(e)}catch(e){s(!1)}})()}),[]),(0,a.useEffect)((()=>{const e=()=>{r(Zn.getHelpVisible())};return window.addEventListener("storage",e),()=>{window.removeEventListener("storage",e)}}),[]),o&&n?(0,i.createElement)("div",{className:"nfd-help-center"},(0,i.createElement)(Wt,{searchClient:t,indexName:"nfd_help_articles"},(0,i.createElement)(rr,{refresh:e.refresh}))):(0,i.createElement)(i.Fragment,null)},ar=({onClose:e})=>{const[t,n]=(0,a.useState)("");(0,a.useEffect)((()=>{const e=Zn.getHelpVisible();ur(e),(async()=>{const e=await P()({path:Un+"/capability/brand",method:"GET"});n(e.toLowerCase())})()}),[]);const[r,o]=(0,a.useState)(!1);return(0,i.createElement)("div",{className:"modal"},(0,i.createElement)("div",{className:"modal-header"},(0,i.createElement)("h3",{className:"heading"},(0,i.createElement)("span",{className:"icon"},(0,i.createElement)(C,null)),(0,x.__)("Help Center","wp-module-help-center")),(0,i.createElement)("button",{className:"close-button",onClick:()=>{e(),o(!r)}},(0,i.createElement)("div",{className:"icon-button"},(0,i.createElement)(M,null)))),(0,i.createElement)(ir,{closeHelp:()=>{e(),o(!r)},refresh:r,brand:t}))};function or(){return or=Object.assign?Object.assign.bind():function(e){for(var t=1;t{window?.nfdHelpCenter?.restUrl&&(async({namespace:e,urls:{single:t,batch:n}={},settings:{debounce:{time:r}={},queue:{threshold:i=100}={}}={}})=>{!e||!j(e)&&(!t&&!n||((0,o.dispatch)(S).initializeNamespace(e),(0,o.dispatch)(S).updateHiiveUrls({single:t,batch:n},e),(0,o.dispatch)(S).updateHiiveDebounceTime(r,e),(0,o.dispatch)(S).updateHiiveEventsQueueThreshold(i,e),window.nfdUIAnalytics?.hiive?window.nfdUIAnalytics.hiive[e]=!0:window.nfdUIAnalytics={hiive:{[e]:!0}}))})({namespace:"wonder_help",urls:{single:window.nfdHelpCenter.restUrl+"/newfold-data/v1/events"}}),(async()=>{const e=new URL(document.location).searchParams.get("referrer");e&&"nfd-onboarding"===e.toString()&&"1"===(await P()({path:"newfold-onboarding/v1/flow",method:"GET"})).data.wpComfortLevel&&ur(!0)})()}));const cr=document.getElementById("wpcontent"),ur=e=>{cr.classList.toggle("wpcontent-container",e),document.getElementById("nfd-help-center").classList.toggle("help-container",e),Zn.updateHelpVisible(e),window.dispatchEvent(new Event("storage"))};window.newfoldEmbeddedHelp={toggleNFDLaunchedEmbeddedHelp:()=>{(()=>{const e=Zn.getHelpVisible();if(Object.is(e,void 0))return ur(!0),void Dn("help_sidebar_opened",{page:window.location.href.toString()});e||Dn("help_sidebar_opened",{page:window.location.href.toString()}),ur(!e)})()},renderEmbeddedHelp:()=>{const e=document.createElement("div");e.id="nfd-help-center",e.style.display="none",cr.appendChild(e);const t=document.getElementById("nfd-help-center");null!==t&&("undefined"!==a.createRoot?(0,a.createRoot)(t).render((0,i.createElement)(ar,{onClose:()=>{ur(!1),Zn.clear()}})):"undefined"!==a.render&&(0,a.render)((0,i.createElement)(ar,{onClose:()=>{ur(!1),Zn.clear()}}),t))}};const lr=(0,o.subscribe)((()=>{document.getElementById("nfd-help-menu-button-wrapper")?lr():c()((()=>{const e=document.querySelector(".edit-post-header__settings");if(!e)return;const t=document.createElement("div");t.id="nfd-help-menu-button-wrapper",t.classList.add("nfd-help-menu-button-wrapper");const n=e.querySelector(".components-dropdown-menu.interface-more-menu-dropdown");n?e.insertBefore(t,n):e.appendChild(t);const r=(0,i.createElement)("button",{className:"components-button has-icon",onClick:()=>{window.newfoldEmbeddedHelp.toggleNFDLaunchedEmbeddedHelp()}},(0,i.createElement)(sr,null));(0,a.render)(r,document.getElementById("nfd-help-menu-button-wrapper"))}))}));if(window.newfoldEmbeddedHelp.renderEmbeddedHelp(),"enabled"===Zn.getFeatureFlag("featureFlag_newfoldLaunchHelpCenter")){function fr(e){if(e.innerText.trim())return e.innerText;for(const t of e.childNodes)if(t.nodeType===Node.ELEMENT_NODE){const e=fr(t);if(e)return e}return null}window.newfoldEmbeddedHelp.launchNFDEmbeddedHelpQuery=function(e,t){"true"!==Zn.getHelpVisible()&&t&&ur(!0);const n=document.getElementById("nfd-help-center");let r=0;const i=setInterval((()=>{if(r++,n&&(e=>{const t=window.getComputedStyle(e);return"none"!==t.display&&"hidden"!==t.visibility})(n)){const t=document.getElementById("search-input-box");setTimeout((()=>{t.value=e,t.focus()}),500),clearInterval(i)}else r>=5&&clearInterval(i)}),300)},document.addEventListener("click",(e=>{const t=e.target.closest("[data-openNfdHelpCenter]");if(t){const e=fr(t);e&&window.newfoldEmbeddedHelp.launchNFDEmbeddedHelpQuery(e,!0)}}))}}()}(); \ No newline at end of file +!function(){var e={7331:function(e){function t(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(e){return"function"==typeof e}function r(e){return"object"==typeof e&&null!==e}function i(e){return void 0===e}e.exports=t,t.prototype._events=void 0,t.prototype._maxListeners=void 0,t.defaultMaxListeners=10,t.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},t.prototype.emit=function(e){var t,a,o,s,c,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||r(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}if(i(a=this._events[e]))return!1;if(n(a))switch(arguments.length){case 1:a.call(this);break;case 2:a.call(this,arguments[1]);break;case 3:a.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),a.apply(this,s)}else if(r(a))for(s=Array.prototype.slice.call(arguments,1),o=(u=a.slice()).length,c=0;c0&&this._events[e].length>o&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},t.prototype.on=t.prototype.addListener,t.prototype.once=function(e,t){if(!n(t))throw TypeError("listener must be a function");var r=!1;function i(){this.removeListener(e,i),r||(r=!0,t.apply(this,arguments))}return i.listener=t,this.on(e,i),this},t.prototype.removeListener=function(e,t){var i,a,o,s;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(o=(i=this._events[e]).length,a=-1,i===t||n(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(r(i)){for(s=o;s-- >0;)if(i[s]===t||i[s].listener&&i[s].listener===t){a=s;break}if(a<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(a,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},t.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},t.prototype.listeners=function(e){return this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},t.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},t.listenerCount=function(e,t){return e.listenerCount(t)}},4766:function(e,t,n){"use strict";var r=n(9374),i=n(7775),a=n(3076);function o(e,t,n){return new r(e,t,n)}o.version=n(4336),o.AlgoliaSearchHelper=r,o.SearchParameters=i,o.SearchResults=a,e.exports=o},8078:function(e,t,n){"use strict";var r=n(7331);function i(e,t){this.main=e,this.fn=t,this.lastResults=null}n(4853)(i,r),i.prototype.detach=function(){this.removeAllListeners(),this.main.detachDerivedHelper(this)},i.prototype.getModifiedState=function(e){return this.fn(e)},e.exports=i},2437:function(e,t,n){"use strict";var r=n(2344),i=n(9803),a=n(116),o={addRefinement:function(e,t,n){if(o.isRefined(e,t,n))return e;var i=""+n,a=e[t]?e[t].concat(i):[i],s={};return s[t]=a,r({},s,e)},removeRefinement:function(e,t,n){if(void 0===n)return o.clearRefinement(e,(function(e,n){return t===n}));var r=""+n;return o.clearRefinement(e,(function(e,n){return t===n&&r===e}))},toggleRefinement:function(e,t,n){if(void 0===n)throw new Error("toggleRefinement should be used with a value");return o.isRefined(e,t,n)?o.removeRefinement(e,t,n):o.addRefinement(e,t,n)},clearRefinement:function(e,t,n){if(void 0===t)return a(e)?{}:e;if("string"==typeof t)return i(e,[t]);if("function"==typeof t){var r=!1,o=Object.keys(e).reduce((function(i,a){var o=e[a]||[],s=o.filter((function(e){return!t(e,a,n)}));return s.length!==o.length&&(r=!0),i[a]=s,i}),{});return r?o:e}},isRefined:function(e,t,n){var r=!!e[t]&&e[t].length>0;if(void 0===n||!r)return r;var i=""+n;return-1!==e[t].indexOf(i)}};e.exports=o},7775:function(e,t,n){"use strict";var r=n(185),i=n(2344),a=n(2686),o=n(7888),s=n(8023),c=n(9803),u=n(116),l=n(6801),f=n(2437);function h(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((function(e,n){return h(t[n],e)})):e===t}function p(e){var t=e?p._parseNumbers(e):{};void 0===t.userToken||l(t.userToken)||console.warn("[algoliasearch-helper] The `userToken` parameter is invalid. This can lead to wrong analytics.\n - Format: [a-zA-Z0-9_-]{1,64}"),this.facets=t.facets||[],this.disjunctiveFacets=t.disjunctiveFacets||[],this.hierarchicalFacets=t.hierarchicalFacets||[],this.facetsRefinements=t.facetsRefinements||{},this.facetsExcludes=t.facetsExcludes||{},this.disjunctiveFacetsRefinements=t.disjunctiveFacetsRefinements||{},this.numericRefinements=t.numericRefinements||{},this.tagRefinements=t.tagRefinements||[],this.hierarchicalFacetsRefinements=t.hierarchicalFacetsRefinements||{};var n=this;Object.keys(t).forEach((function(e){var r=-1!==p.PARAMETERS.indexOf(e),i=void 0!==t[e];!r&&i&&(n[e]=t[e])}))}p.PARAMETERS=Object.keys(new p),p._parseNumbers=function(e){if(e instanceof p)return e;var t={};if(["aroundPrecision","aroundRadius","getRankingInfo","minWordSizefor2Typos","minWordSizefor1Typo","page","maxValuesPerFacet","distinct","minimumAroundRadius","hitsPerPage","minProximity"].forEach((function(n){var r=e[n];if("string"==typeof r){var i=parseFloat(r);t[n]=isNaN(i)?r:i}})),Array.isArray(e.insideBoundingBox)&&(t.insideBoundingBox=e.insideBoundingBox.map((function(e){return Array.isArray(e)?e.map((function(e){return parseFloat(e)})):e}))),e.numericRefinements){var n={};Object.keys(e.numericRefinements).forEach((function(t){var r=e.numericRefinements[t]||{};n[t]={},Object.keys(r).forEach((function(e){var i=r[e].map((function(e){return Array.isArray(e)?e.map((function(e){return"string"==typeof e?parseFloat(e):e})):"string"==typeof e?parseFloat(e):e}));n[t][e]=i}))})),t.numericRefinements=n}return r({},e,t)},p.make=function(e){var t=new p(e);return(e.hierarchicalFacets||[]).forEach((function(e){if(e.rootPath){var n=t.getHierarchicalRefinement(e.name);n.length>0&&0!==n[0].indexOf(e.rootPath)&&(t=t.clearRefinements(e.name)),0===(n=t.getHierarchicalRefinement(e.name)).length&&(t=t.toggleHierarchicalFacetRefinement(e.name,e.rootPath))}})),t},p.validate=function(e,t){var n=t||{};return e.tagFilters&&n.tagRefinements&&n.tagRefinements.length>0?new Error("[Tags] Cannot switch from the managed tag API to the advanced API. It is probably an error, if it is really what you want, you should first clear the tags with clearTags method."):e.tagRefinements.length>0&&n.tagFilters?new Error("[Tags] Cannot switch from the advanced tag API to the managed API. It is probably an error, if it is not, you should first clear the tags with clearTags method."):e.numericFilters&&n.numericRefinements&&u(n.numericRefinements)?new Error("[Numeric filters] Can't switch from the advanced to the managed API. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):u(e.numericRefinements)&&n.numericFilters?new Error("[Numeric filters] Can't switch from the managed API to the advanced. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):null},p.prototype={constructor:p,clearRefinements:function(e){var t={numericRefinements:this._clearNumericRefinements(e),facetsRefinements:f.clearRefinement(this.facetsRefinements,e,"conjunctiveFacet"),facetsExcludes:f.clearRefinement(this.facetsExcludes,e,"exclude"),disjunctiveFacetsRefinements:f.clearRefinement(this.disjunctiveFacetsRefinements,e,"disjunctiveFacet"),hierarchicalFacetsRefinements:f.clearRefinement(this.hierarchicalFacetsRefinements,e,"hierarchicalFacet")};return t.numericRefinements===this.numericRefinements&&t.facetsRefinements===this.facetsRefinements&&t.facetsExcludes===this.facetsExcludes&&t.disjunctiveFacetsRefinements===this.disjunctiveFacetsRefinements&&t.hierarchicalFacetsRefinements===this.hierarchicalFacetsRefinements?this:this.setQueryParameters(t)},clearTags:function(){return void 0===this.tagFilters&&0===this.tagRefinements.length?this:this.setQueryParameters({tagFilters:void 0,tagRefinements:[]})},setIndex:function(e){return e===this.index?this:this.setQueryParameters({index:e})},setQuery:function(e){return e===this.query?this:this.setQueryParameters({query:e})},setPage:function(e){return e===this.page?this:this.setQueryParameters({page:e})},setFacets:function(e){return this.setQueryParameters({facets:e})},setDisjunctiveFacets:function(e){return this.setQueryParameters({disjunctiveFacets:e})},setHitsPerPage:function(e){return this.hitsPerPage===e?this:this.setQueryParameters({hitsPerPage:e})},setTypoTolerance:function(e){return this.typoTolerance===e?this:this.setQueryParameters({typoTolerance:e})},addNumericRefinement:function(e,t,n){var i=s(n);if(this.isNumericRefined(e,t,i))return this;var a=r({},this.numericRefinements);return a[e]=r({},a[e]),a[e][t]?(a[e][t]=a[e][t].slice(),a[e][t].push(i)):a[e][t]=[i],this.setQueryParameters({numericRefinements:a})},getConjunctiveRefinements:function(e){return this.isConjunctiveFacet(e)&&this.facetsRefinements[e]||[]},getDisjunctiveRefinements:function(e){return this.isDisjunctiveFacet(e)&&this.disjunctiveFacetsRefinements[e]||[]},getHierarchicalRefinement:function(e){return this.hierarchicalFacetsRefinements[e]||[]},getExcludeRefinements:function(e){return this.isConjunctiveFacet(e)&&this.facetsExcludes[e]||[]},removeNumericRefinement:function(e,t,n){return void 0!==n?this.isNumericRefined(e,t,n)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(r,i){return i===e&&r.op===t&&h(r.val,s(n))}))}):this:void 0!==t?this.isNumericRefined(e,t)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(n,r){return r===e&&n.op===t}))}):this:this.isNumericRefined(e)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements((function(t,n){return n===e}))}):this},getNumericRefinements:function(e){return this.numericRefinements[e]||{}},getNumericRefinement:function(e,t){return this.numericRefinements[e]&&this.numericRefinements[e][t]},_clearNumericRefinements:function(e){if(void 0===e)return u(this.numericRefinements)?{}:this.numericRefinements;if("string"==typeof e)return c(this.numericRefinements,[e]);if("function"==typeof e){var t=!1,n=this.numericRefinements,r=Object.keys(n).reduce((function(r,i){var a=n[i],o={};return a=a||{},Object.keys(a).forEach((function(n){var r=a[n]||[],s=[];r.forEach((function(t){e({val:t,op:n},i,"numeric")||s.push(t)})),s.length!==r.length&&(t=!0),o[n]=s})),r[i]=o,r}),{});return t?r:this.numericRefinements}},addFacet:function(e){return this.isConjunctiveFacet(e)?this:this.setQueryParameters({facets:this.facets.concat([e])})},addDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this:this.setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.concat([e])})},addHierarchicalFacet:function(e){if(this.isHierarchicalFacet(e.name))throw new Error("Cannot declare two hierarchical facets with the same name: `"+e.name+"`");return this.setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.concat([e])})},addFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsRefinements,e,t)?this:this.setQueryParameters({facetsRefinements:f.addRefinement(this.facetsRefinements,e,t)})},addExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsExcludes,e,t)?this:this.setQueryParameters({facetsExcludes:f.addRefinement(this.facetsExcludes,e,t)})},addDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return f.isRefined(this.disjunctiveFacetsRefinements,e,t)?this:this.setQueryParameters({disjunctiveFacetsRefinements:f.addRefinement(this.disjunctiveFacetsRefinements,e,t)})},addTagRefinement:function(e){if(this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.concat(e)};return this.setQueryParameters(t)},removeFacet:function(e){return this.isConjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({facets:this.facets.filter((function(t){return t!==e}))}):this},removeDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.filter((function(t){return t!==e}))}):this},removeHierarchicalFacet:function(e){return this.isHierarchicalFacet(e)?this.clearRefinements(e).setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.filter((function(t){return t.name!==e}))}):this},removeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsRefinements,e,t)?this.setQueryParameters({facetsRefinements:f.removeRefinement(this.facetsRefinements,e,t)}):this},removeExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return f.isRefined(this.facetsExcludes,e,t)?this.setQueryParameters({facetsExcludes:f.removeRefinement(this.facetsExcludes,e,t)}):this},removeDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return f.isRefined(this.disjunctiveFacetsRefinements,e,t)?this.setQueryParameters({disjunctiveFacetsRefinements:f.removeRefinement(this.disjunctiveFacetsRefinements,e,t)}):this},removeTagRefinement:function(e){if(!this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.filter((function(t){return t!==e}))};return this.setQueryParameters(t)},toggleRefinement:function(e,t){return this.toggleFacetRefinement(e,t)},toggleFacetRefinement:function(e,t){if(this.isHierarchicalFacet(e))return this.toggleHierarchicalFacetRefinement(e,t);if(this.isConjunctiveFacet(e))return this.toggleConjunctiveFacetRefinement(e,t);if(this.isDisjunctiveFacet(e))return this.toggleDisjunctiveFacetRefinement(e,t);throw new Error("Cannot refine the undeclared facet "+e+"; it should be added to the helper options facets, disjunctiveFacets or hierarchicalFacets")},toggleConjunctiveFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsRefinements:f.toggleRefinement(this.facetsRefinements,e,t)})},toggleExcludeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsExcludes:f.toggleRefinement(this.facetsExcludes,e,t)})},toggleDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return this.setQueryParameters({disjunctiveFacetsRefinements:f.toggleRefinement(this.disjunctiveFacetsRefinements,e,t)})},toggleHierarchicalFacetRefinement:function(e,t){if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration");var n=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e)),r={};return void 0!==this.hierarchicalFacetsRefinements[e]&&this.hierarchicalFacetsRefinements[e].length>0&&(this.hierarchicalFacetsRefinements[e][0]===t||0===this.hierarchicalFacetsRefinements[e][0].indexOf(t+n))?-1===t.indexOf(n)?r[e]=[]:r[e]=[t.slice(0,t.lastIndexOf(n))]:r[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:i({},r,this.hierarchicalFacetsRefinements)})},addHierarchicalFacetRefinement:function(e,t){if(this.isHierarchicalFacetRefined(e))throw new Error(e+" is already refined.");if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration.");var n={};return n[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:i({},n,this.hierarchicalFacetsRefinements)})},removeHierarchicalFacetRefinement:function(e){if(!this.isHierarchicalFacetRefined(e))return this;var t={};return t[e]=[],this.setQueryParameters({hierarchicalFacetsRefinements:i({},t,this.hierarchicalFacetsRefinements)})},toggleTagRefinement:function(e){return this.isTagRefined(e)?this.removeTagRefinement(e):this.addTagRefinement(e)},isDisjunctiveFacet:function(e){return this.disjunctiveFacets.indexOf(e)>-1},isHierarchicalFacet:function(e){return void 0!==this.getHierarchicalFacetByName(e)},isConjunctiveFacet:function(e){return this.facets.indexOf(e)>-1},isFacetRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&f.isRefined(this.facetsRefinements,e,t)},isExcludeRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&f.isRefined(this.facetsExcludes,e,t)},isDisjunctiveFacetRefined:function(e,t){return!!this.isDisjunctiveFacet(e)&&f.isRefined(this.disjunctiveFacetsRefinements,e,t)},isHierarchicalFacetRefined:function(e,t){if(!this.isHierarchicalFacet(e))return!1;var n=this.getHierarchicalRefinement(e);return t?-1!==n.indexOf(t):n.length>0},isNumericRefined:function(e,t,n){if(void 0===n&&void 0===t)return!!this.numericRefinements[e];var r=this.numericRefinements[e]&&void 0!==this.numericRefinements[e][t];if(void 0===n||!r)return r;var i,a,c=s(n),u=void 0!==(i=this.numericRefinements[e][t],a=c,o(i,(function(e){return h(e,a)})));return r&&u},isTagRefined:function(e){return-1!==this.tagRefinements.indexOf(e)},getRefinedDisjunctiveFacets:function(){var e=this,t=a(Object.keys(this.numericRefinements).filter((function(t){return Object.keys(e.numericRefinements[t]).length>0})),this.disjunctiveFacets);return Object.keys(this.disjunctiveFacetsRefinements).filter((function(t){return e.disjunctiveFacetsRefinements[t].length>0})).concat(t).concat(this.getRefinedHierarchicalFacets())},getRefinedHierarchicalFacets:function(){var e=this;return a(this.hierarchicalFacets.map((function(e){return e.name})),Object.keys(this.hierarchicalFacetsRefinements).filter((function(t){return e.hierarchicalFacetsRefinements[t].length>0})))},getUnrefinedDisjunctiveFacets:function(){var e=this.getRefinedDisjunctiveFacets();return this.disjunctiveFacets.filter((function(t){return-1===e.indexOf(t)}))},managedParameters:["index","facets","disjunctiveFacets","facetsRefinements","hierarchicalFacets","facetsExcludes","disjunctiveFacetsRefinements","numericRefinements","tagRefinements","hierarchicalFacetsRefinements"],getQueryParams:function(){var e=this.managedParameters,t={},n=this;return Object.keys(this).forEach((function(r){var i=n[r];-1===e.indexOf(r)&&void 0!==i&&(t[r]=i)})),t},setQueryParameter:function(e,t){if(this[e]===t)return this;var n={};return n[e]=t,this.setQueryParameters(n)},setQueryParameters:function(e){if(!e)return this;var t=p.validate(this,e);if(t)throw t;var n=this,r=p._parseNumbers(e),i=Object.keys(this).reduce((function(e,t){return e[t]=n[t],e}),{}),a=Object.keys(r).reduce((function(e,t){var n=void 0!==e[t],i=void 0!==r[t];return n&&!i?c(e,[t]):(i&&(e[t]=r[t]),e)}),i);return new this.constructor(a)},resetPage:function(){return void 0===this.page?this:this.setPage(0)},_getHierarchicalFacetSortBy:function(e){return e.sortBy||["isRefined:desc","name:asc"]},_getHierarchicalFacetSeparator:function(e){return e.separator||" > "},_getHierarchicalRootPath:function(e){return e.rootPath||null},_getHierarchicalShowParentLevel:function(e){return"boolean"!=typeof e.showParentLevel||e.showParentLevel},getHierarchicalFacetByName:function(e){return o(this.hierarchicalFacets,(function(t){return t.name===e}))},getHierarchicalFacetBreadcrumb:function(e){if(!this.isHierarchicalFacet(e))return[];var t=this.getHierarchicalRefinement(e)[0];if(!t)return[];var n=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e));return t.split(n).map((function(e){return e.trim()}))},toString:function(){return JSON.stringify(this,null,2)}},e.exports=p},210:function(e,t,n){"use strict";e.exports=function(e){return function(t,n){var o=e.hierarchicalFacets[n],u=e.hierarchicalFacetsRefinements[o.name]&&e.hierarchicalFacetsRefinements[o.name][0]||"",l=e._getHierarchicalFacetSeparator(o),f=e._getHierarchicalRootPath(o),h=e._getHierarchicalShowParentLevel(o),p=a(e._getHierarchicalFacetSortBy(o)),d=t.every((function(e){return e.exhaustive})),m=function(e,t,n,a,o){return function(u,l,f){var h=u;if(f>0){var p=0;for(h=u;p-1})));if(o){var l=o.attributes.indexOf(t),h=c(e.hierarchicalFacets,(function(e){return e.name===o.name}));u.hierarchicalFacets[h][l]={attribute:t,data:i,exhaustive:a.exhaustiveFacetsCount}}else{var p,d=-1!==e.disjunctiveFacets.indexOf(t),v=-1!==e.facets.indexOf(t);d&&(p=y[t],u.disjunctiveFacets[p]={name:t,data:i,exhaustive:a.exhaustiveFacetsCount},m(u.disjunctiveFacets[p],a.facets_stats,t)),v&&(p=f[t],u.facets[p]={name:t,data:i,exhaustive:a.exhaustiveFacetsCount},m(u.facets[p],a.facets_stats,t))}})),this.hierarchicalFacets=o(this.hierarchicalFacets),l.forEach((function(n){var o=t[v],s=o&&o.facets?o.facets:{},l=e.getHierarchicalFacetByName(n);Object.keys(s).forEach((function(t){var n,f=s[t];if(l){n=c(e.hierarchicalFacets,(function(e){return e.name===l.name}));var p=c(u.hierarchicalFacets[n],(function(e){return e.attribute===t}));if(-1===p)return;u.hierarchicalFacets[n][p].data=r({},u.hierarchicalFacets[n][p].data,f)}else{n=y[t];var d=a.facets&&a.facets[t]||{};u.disjunctiveFacets[n]={name:t,data:i({},f,d),exhaustive:o.exhaustiveFacetsCount},m(u.disjunctiveFacets[n],o.facets_stats,t),e.disjunctiveFacetsRefinements[t]&&e.disjunctiveFacetsRefinements[t].forEach((function(r){!u.disjunctiveFacets[n].data[r]&&e.disjunctiveFacetsRefinements[t].indexOf(h(r))>-1&&(u.disjunctiveFacets[n].data[r]=0)}))}})),v++})),e.getRefinedHierarchicalFacets().forEach((function(n){var r=e.getHierarchicalFacetByName(n),a=e._getHierarchicalFacetSeparator(r),o=e.getHierarchicalRefinement(n);0===o.length||o[0].split(a).length<2||t.slice(v).forEach((function(t){var n=t&&t.facets?t.facets:{};Object.keys(n).forEach((function(t){var s=n[t],l=c(e.hierarchicalFacets,(function(e){return e.name===r.name})),f=c(u.hierarchicalFacets[l],(function(e){return e.attribute===t}));if(-1!==f){var h={};if(o.length>0){var p=o[0].split(a)[0];h[p]=u.hierarchicalFacets[l][f].data[p]}u.hierarchicalFacets[l][f].data=i(h,s,u.hierarchicalFacets[l][f].data)}})),v++}))})),Object.keys(e.facetsExcludes).forEach((function(t){var n=e.facetsExcludes[t],r=f[t];u.facets[r]={name:t,data:a.facets[t],exhaustive:a.exhaustiveFacetsCount},n.forEach((function(e){u.facets[r]=u.facets[r]||{name:t},u.facets[r].data=u.facets[r].data||{},u.facets[r].data[e]=0}))})),this.hierarchicalFacets=this.hierarchicalFacets.map(p(e)),this.facets=o(this.facets),this.disjunctiveFacets=o(this.disjunctiveFacets),this._state=e}function v(e,t){function n(e){return e.name===t}if(e._state.isConjunctiveFacet(t)){var r=s(e.facets,n);return r?Object.keys(r.data).map((function(n){var i=f(n);return{name:n,escapedValue:i,count:r.data[n],isRefined:e._state.isFacetRefined(t,i),isExcluded:e._state.isExcludeRefined(t,n)}})):[]}if(e._state.isDisjunctiveFacet(t)){var i=s(e.disjunctiveFacets,n);return i?Object.keys(i.data).map((function(n){var r=f(n);return{name:n,escapedValue:r,count:i.data[n],isRefined:e._state.isDisjunctiveFacetRefined(t,r)}})):[]}if(e._state.isHierarchicalFacet(t)){var a=s(e.hierarchicalFacets,n);if(!a)return a;var o=e._state.getHierarchicalFacetByName(t),c=h(e._state.getHierarchicalRefinement(t)[0]||"").split(e._state._getHierarchicalFacetSeparator(o));return c.unshift(t),g(a,c,0),a}}function g(e,t,n){e.isRefined=e.name===t[n],e.data&&e.data.forEach((function(e){g(e,t,n+1)}))}function b(e,t,n,r){if(r=r||0,Array.isArray(t))return e(t,n[r]);if(!t.data||0===t.data.length)return t;var a=t.data.map((function(t){return b(e,t,n,r+1)})),o=e(a,n[r]);return i({data:o},t)}function A(e,t){var n=s(e,(function(e){return e.name===t}));return n&&n.stats}function I(e,t,n,r,i){var a=s(i,(function(e){return e.name===n})),o=a&&a.data&&a.data[r]?a.data[r]:0,c=a&&a.exhaustive||!1;return{type:t,attributeName:n,name:r,count:o,exhaustive:c}}y.prototype.getFacetByName=function(e){function t(t){return t.name===e}return s(this.facets,t)||s(this.disjunctiveFacets,t)||s(this.hierarchicalFacets,t)},y.DEFAULT_SORT=["isRefined:desc","count:desc","name:asc"],y.prototype.getFacetValues=function(e,t){var n=v(this,e);if(n){var r=i({},t,{sortBy:y.DEFAULT_SORT,facetOrdering:!(t&&t.sortBy)}),o=this;return b((function(e,t){if(r.facetOrdering){var n=function(e,t){return e.renderingContent&&e.renderingContent.facetOrdering&&e.renderingContent.facetOrdering.values&&e.renderingContent.facetOrdering.values[t]}(o,t);if(Boolean(n))return function(e,t){var n=[],r=[],i=(t.order||[]).reduce((function(e,t,n){return e[t]=n,e}),{});e.forEach((function(e){var t=e.path||e.name;void 0!==i[t]?n[i[t]]=e:r.push(e)})),n=n.filter((function(e){return e}));var o,s=t.sortRemainingBy;return"hidden"===s?n:(o="alpha"===s?[["path","name"],["asc","asc"]]:[["count"],["desc"]],n.concat(a(r,o[0],o[1])))}(e,n)}if(Array.isArray(r.sortBy)){var i=u(r.sortBy,y.DEFAULT_SORT);return a(e,i[0],i[1])}if("function"==typeof r.sortBy)return function(e,t){return t.sort(e)}(r.sortBy,e);throw new Error("options.sortBy is optional but if defined it must be either an array of string (predicates) or a sorting function")}),n,Array.isArray(n)?[e]:o._state.getHierarchicalFacetByName(n.name).attributes)}},y.prototype.getFacetStats=function(e){return this._state.isConjunctiveFacet(e)?A(this.facets,e):this._state.isDisjunctiveFacet(e)?A(this.disjunctiveFacets,e):void 0},y.prototype.getRefinements=function(){var e=this._state,t=this,n=[];return Object.keys(e.facetsRefinements).forEach((function(r){e.facetsRefinements[r].forEach((function(e){n.push(I(0,"facet",r,e,t.facets))}))})),Object.keys(e.facetsExcludes).forEach((function(r){e.facetsExcludes[r].forEach((function(e){n.push(I(0,"exclude",r,e,t.facets))}))})),Object.keys(e.disjunctiveFacetsRefinements).forEach((function(r){e.disjunctiveFacetsRefinements[r].forEach((function(e){n.push(I(0,"disjunctive",r,e,t.disjunctiveFacets))}))})),Object.keys(e.hierarchicalFacetsRefinements).forEach((function(r){e.hierarchicalFacetsRefinements[r].forEach((function(i){n.push(function(e,t,n,r){var i=e.getHierarchicalFacetByName(t),a=e._getHierarchicalFacetSeparator(i),o=n.split(a),c=s(r,(function(e){return e.name===t})),u=o.reduce((function(e,t){var n=e&&s(e.data,(function(e){return e.name===t}));return void 0!==n?n:e}),c),l=u&&u.count||0,f=u&&u.exhaustive||!1,h=u&&u.path||"";return{type:"hierarchical",attributeName:t,name:h,count:l,exhaustive:f}}(e,r,i,t.hierarchicalFacets))}))})),Object.keys(e.numericRefinements).forEach((function(t){var r=e.numericRefinements[t];Object.keys(r).forEach((function(e){r[e].forEach((function(r){n.push({type:"numeric",attributeName:t,name:r,numericValue:r,operator:e})}))}))})),e.tagRefinements.forEach((function(e){n.push({type:"tag",attributeName:"_tags",name:e})})),n},e.exports=y},9374:function(e,t,n){"use strict";var r=n(7775),i=n(3076),a=n(8078),o=n(6394),s=n(7331),c=n(4853),u=n(116),l=n(9803),f=n(185),h=n(4336),p=n(4039).escapeFacetValue;function d(e,t,n){"function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+h+")"),this.setClient(e);var i=n||{};i.index=t,this.state=r.make(i),this.lastResults=null,this._queryId=0,this._lastQueryIdReceived=-1,this.derivedHelpers=[],this._currentNbQueries=0}function m(e){if(e<0)throw new Error("Page requested below 0.");return this._change({state:this.state.setPage(e),isPageReset:!1}),this}function y(){return this.state.page}c(d,s),d.prototype.search=function(){return this._search({onlyWithDerivedHelpers:!1}),this},d.prototype.searchOnlyWithDerivedHelpers=function(){return this._search({onlyWithDerivedHelpers:!0}),this},d.prototype.getQuery=function(){var e=this.state;return o._getHitsSearchParams(e)},d.prototype.searchOnce=function(e,t){var n=e?this.state.setQueryParameters(e):this.state,r=o._getQueries(n.index,n),a=this;if(this._currentNbQueries++,this.emit("searchOnce",{state:n}),!t)return this.client.search(r).then((function(e){return a._currentNbQueries--,0===a._currentNbQueries&&a.emit("searchQueueEmpty"),{content:new i(n,e.results),state:n,_originalResponse:e}}),(function(e){throw a._currentNbQueries--,0===a._currentNbQueries&&a.emit("searchQueueEmpty"),e}));this.client.search(r).then((function(e){a._currentNbQueries--,0===a._currentNbQueries&&a.emit("searchQueueEmpty"),t(null,new i(n,e.results),n)})).catch((function(e){a._currentNbQueries--,0===a._currentNbQueries&&a.emit("searchQueueEmpty"),t(e,null,n)}))},d.prototype.findAnswers=function(e){console.warn("[algoliasearch-helper] answers is no longer supported");var t=this.state,n=this.derivedHelpers[0];if(!n)return Promise.resolve([]);var r=n.getModifiedState(t),i=f({attributesForPrediction:e.attributesForPrediction,nbHits:e.nbHits},{params:l(o._getHitsSearchParams(r),["attributesToSnippet","hitsPerPage","restrictSearchableAttributes","snippetEllipsisText"])}),a="search for answers was called, but this client does not have a function client.initIndex(index).findAnswers";if("function"!=typeof this.client.initIndex)throw new Error(a);var s=this.client.initIndex(r.index);if("function"!=typeof s.findAnswers)throw new Error(a);return s.findAnswers(r.query,e.queryLanguages,i)},d.prototype.searchForFacetValues=function(e,t,n,r){var i="function"==typeof this.client.searchForFacetValues,a="function"==typeof this.client.initIndex;if(!i&&!a&&"function"!=typeof this.client.search)throw new Error("search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues");var s=this.state.setQueryParameters(r||{}),c=s.isDisjunctiveFacet(e),u=o.getSearchForFacetQuery(e,t,n,s);this._currentNbQueries++;var l,f=this;return i?l=this.client.searchForFacetValues([{indexName:s.index,params:u}]):a?l=this.client.initIndex(s.index).searchForFacetValues(u):(delete u.facetName,l=this.client.search([{type:"facet",facet:e,indexName:s.index,params:u}]).then((function(e){return e.results[0]}))),this.emit("searchForFacetValues",{state:s,facet:e,query:t}),l.then((function(t){return f._currentNbQueries--,0===f._currentNbQueries&&f.emit("searchQueueEmpty"),(t=Array.isArray(t)?t[0]:t).facetHits.forEach((function(t){t.escapedValue=p(t.value),t.isRefined=c?s.isDisjunctiveFacetRefined(e,t.escapedValue):s.isFacetRefined(e,t.escapedValue)})),t}),(function(e){throw f._currentNbQueries--,0===f._currentNbQueries&&f.emit("searchQueueEmpty"),e}))},d.prototype.setQuery=function(e){return this._change({state:this.state.resetPage().setQuery(e),isPageReset:!0}),this},d.prototype.clearRefinements=function(e){return this._change({state:this.state.resetPage().clearRefinements(e),isPageReset:!0}),this},d.prototype.clearTags=function(){return this._change({state:this.state.resetPage().clearTags(),isPageReset:!0}),this},d.prototype.addDisjunctiveFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addDisjunctiveFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.addDisjunctiveRefine=function(){return this.addDisjunctiveFacetRefinement.apply(this,arguments)},d.prototype.addHierarchicalFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addHierarchicalFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.addNumericRefinement=function(e,t,n){return this._change({state:this.state.resetPage().addNumericRefinement(e,t,n),isPageReset:!0}),this},d.prototype.addFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.addRefine=function(){return this.addFacetRefinement.apply(this,arguments)},d.prototype.addFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().addExcludeRefinement(e,t),isPageReset:!0}),this},d.prototype.addExclude=function(){return this.addFacetExclusion.apply(this,arguments)},d.prototype.addTag=function(e){return this._change({state:this.state.resetPage().addTagRefinement(e),isPageReset:!0}),this},d.prototype.removeNumericRefinement=function(e,t,n){return this._change({state:this.state.resetPage().removeNumericRefinement(e,t,n),isPageReset:!0}),this},d.prototype.removeDisjunctiveFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().removeDisjunctiveFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.removeDisjunctiveRefine=function(){return this.removeDisjunctiveFacetRefinement.apply(this,arguments)},d.prototype.removeHierarchicalFacetRefinement=function(e){return this._change({state:this.state.resetPage().removeHierarchicalFacetRefinement(e),isPageReset:!0}),this},d.prototype.removeFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().removeFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.removeRefine=function(){return this.removeFacetRefinement.apply(this,arguments)},d.prototype.removeFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().removeExcludeRefinement(e,t),isPageReset:!0}),this},d.prototype.removeExclude=function(){return this.removeFacetExclusion.apply(this,arguments)},d.prototype.removeTag=function(e){return this._change({state:this.state.resetPage().removeTagRefinement(e),isPageReset:!0}),this},d.prototype.toggleFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().toggleExcludeFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.toggleExclude=function(){return this.toggleFacetExclusion.apply(this,arguments)},d.prototype.toggleRefinement=function(e,t){return this.toggleFacetRefinement(e,t)},d.prototype.toggleFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().toggleFacetRefinement(e,t),isPageReset:!0}),this},d.prototype.toggleRefine=function(){return this.toggleFacetRefinement.apply(this,arguments)},d.prototype.toggleTag=function(e){return this._change({state:this.state.resetPage().toggleTagRefinement(e),isPageReset:!0}),this},d.prototype.nextPage=function(){var e=this.state.page||0;return this.setPage(e+1)},d.prototype.previousPage=function(){var e=this.state.page||0;return this.setPage(e-1)},d.prototype.setCurrentPage=m,d.prototype.setPage=m,d.prototype.setIndex=function(e){return this._change({state:this.state.resetPage().setIndex(e),isPageReset:!0}),this},d.prototype.setQueryParameter=function(e,t){return this._change({state:this.state.resetPage().setQueryParameter(e,t),isPageReset:!0}),this},d.prototype.setState=function(e){return this._change({state:r.make(e),isPageReset:!1}),this},d.prototype.overrideStateWithoutTriggeringChangeEvent=function(e){return this.state=new r(e),this},d.prototype.hasRefinements=function(e){return!!u(this.state.getNumericRefinements(e))||(this.state.isConjunctiveFacet(e)?this.state.isFacetRefined(e):this.state.isDisjunctiveFacet(e)?this.state.isDisjunctiveFacetRefined(e):!!this.state.isHierarchicalFacet(e)&&this.state.isHierarchicalFacetRefined(e))},d.prototype.isExcluded=function(e,t){return this.state.isExcludeRefined(e,t)},d.prototype.isDisjunctiveRefined=function(e,t){return this.state.isDisjunctiveFacetRefined(e,t)},d.prototype.hasTag=function(e){return this.state.isTagRefined(e)},d.prototype.isTagRefined=function(){return this.hasTagRefinements.apply(this,arguments)},d.prototype.getIndex=function(){return this.state.index},d.prototype.getCurrentPage=y,d.prototype.getPage=y,d.prototype.getTags=function(){return this.state.tagRefinements},d.prototype.getRefinements=function(e){var t=[];this.state.isConjunctiveFacet(e)?(this.state.getConjunctiveRefinements(e).forEach((function(e){t.push({value:e,type:"conjunctive"})})),this.state.getExcludeRefinements(e).forEach((function(e){t.push({value:e,type:"exclude"})}))):this.state.isDisjunctiveFacet(e)&&this.state.getDisjunctiveRefinements(e).forEach((function(e){t.push({value:e,type:"disjunctive"})}));var n=this.state.getNumericRefinements(e);return Object.keys(n).forEach((function(e){var r=n[e];t.push({value:r,operator:e,type:"numeric"})})),t},d.prototype.getNumericRefinement=function(e,t){return this.state.getNumericRefinement(e,t)},d.prototype.getHierarchicalFacetBreadcrumb=function(e){return this.state.getHierarchicalFacetBreadcrumb(e)},d.prototype._search=function(e){var t=this.state,n=[],r=[];e.onlyWithDerivedHelpers||(r=o._getQueries(t.index,t),n.push({state:t,queriesCount:r.length,helper:this}),this.emit("search",{state:t,results:this.lastResults}));var i=this.derivedHelpers.map((function(e){var r=e.getModifiedState(t),i=o._getQueries(r.index,r);return n.push({state:r,queriesCount:i.length,helper:e}),e.emit("search",{state:r,results:e.lastResults}),i})),a=Array.prototype.concat.apply(r,i),s=this._queryId++;this._currentNbQueries++;try{this.client.search(a).then(this._dispatchAlgoliaResponse.bind(this,n,s)).catch(this._dispatchAlgoliaError.bind(this,s))}catch(e){this.emit("error",{error:e})}},d.prototype._dispatchAlgoliaResponse=function(e,t,n){if(!(t0},d.prototype._change=function(e){var t=e.state,n=e.isPageReset;t!==this.state&&(this.state=t,this.emit("change",{state:this.state,results:this.lastResults,isPageReset:n}))},d.prototype.clearCache=function(){return this.client.clearCache&&this.client.clearCache(),this},d.prototype.setClient=function(e){return this.client===e||("function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+h+")"),this.client=e),this},d.prototype.getClient=function(){return this.client},d.prototype.derive=function(e){var t=new a(this,e);return this.derivedHelpers.push(t),t},d.prototype.detachDerivedHelper=function(e){var t=this.derivedHelpers.indexOf(e);if(-1===t)throw new Error("Derived helper already detached");this.derivedHelpers.splice(t,1)},d.prototype.hasPendingRequests=function(){return this._currentNbQueries>0},e.exports=d},4587:function(e){"use strict";e.exports=function(e){return Array.isArray(e)?e.filter(Boolean):[]}},2344:function(e){"use strict";e.exports=function(){var e=Array.prototype.slice.call(arguments);return e.reduceRight((function(e,t){return Object.keys(Object(t)).forEach((function(n){void 0!==t[n]&&(void 0!==e[n]&&delete e[n],e[n]=t[n])})),e}),{})}},4039:function(e){"use strict";e.exports={escapeFacetValue:function(e){return"string"!=typeof e?e:String(e).replace(/^-/,"\\-")},unescapeFacetValue:function(e){return"string"!=typeof e?e:e.replace(/^\\-/,"-")}}},7888:function(e){"use strict";e.exports=function(e,t){if(Array.isArray(e))for(var n=0;n1||!a?(e[0].push(i[0]),e[1].push(i[1]),e):(e[0].push(a[0]),e[1].push(a[1]),e)}),[[],[]])}},4853:function(e){"use strict";e.exports=function(e,t){e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}},2686:function(e){"use strict";e.exports=function(e,t){return e.filter((function(n,r){return t.indexOf(n)>-1&&e.indexOf(n)===r}))}},185:function(e){"use strict";function t(e){return"function"==typeof e||Array.isArray(e)||"[object Object]"===Object.prototype.toString.call(e)}function n(e,r){if(e===r)return e;for(var i in r)if(Object.prototype.hasOwnProperty.call(r,i)&&"__proto__"!==i&&"constructor"!==i){var a=r[i],o=e[i];void 0!==o&&void 0===a||(t(o)&&t(a)?e[i]=n(o,a):e[i]="object"==typeof(s=a)&&null!==s?n(Array.isArray(s)?[]:{},s):s)}var s;return e}e.exports=function(e){t(e)||(e={});for(var r=1,i=arguments.length;r0}},9803:function(e){"use strict";e.exports=function(e,t){if(null===e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}},2148:function(e){"use strict";function t(e,t){if(e!==t){var n=void 0!==e,r=null===e,i=void 0!==t,a=null===t;if(!a&&e>t||r&&i||!n)return 1;if(!r&&e=r.length?a:"desc"===r[i]?-a:a}return e.index-n.index})),i.map((function(e){return e.value}))}},8023:function(e){"use strict";e.exports=function e(t){if("number"==typeof t)return t;if("string"==typeof t)return parseFloat(t);if(Array.isArray(t))return t.map(e);throw new Error("The value should be a number, a parsable string or an array of those.")}},6394:function(e,t,n){"use strict";var r=n(185);function i(e){return Object.keys(e).sort((function(e,t){return e.localeCompare(t)})).reduce((function(t,n){return t[n]=e[n],t}),{})}var a={_getQueries:function(e,t){var n=[];return n.push({indexName:e,params:a._getHitsSearchParams(t)}),t.getRefinedDisjunctiveFacets().forEach((function(r){n.push({indexName:e,params:a._getDisjunctiveFacetSearchParams(t,r)})})),t.getRefinedHierarchicalFacets().forEach((function(r){var i=t.getHierarchicalFacetByName(r),o=t.getHierarchicalRefinement(r),s=t._getHierarchicalFacetSeparator(i);if(o.length>0&&o[0].split(s).length>1){var c=o[0].split(s).slice(0,-1).reduce((function(e,t,n){return e.concat({attribute:i.attributes[n],value:0===n?t:[e[e.length-1].value,t].join(s)})}),[]);c.forEach((function(r,o){var s=a._getDisjunctiveFacetSearchParams(t,r.attribute,0===o);function u(e){return i.attributes.some((function(t){return t===e.split(":")[0]}))}var l=(s.facetFilters||[]).reduce((function(e,t){if(Array.isArray(t)){var n=t.filter((function(e){return!u(e)}));n.length>0&&e.push(n)}return"string"!=typeof t||u(t)||e.push(t),e}),[]),f=c[o-1];s.facetFilters=o>0?l.concat(f.attribute+":"+f.value):l.length>0?l:void 0,n.push({indexName:e,params:s})}))}})),n},_getHitsSearchParams:function(e){var t=e.facets.concat(e.disjunctiveFacets).concat(a._getHitsHierarchicalFacetsAttributes(e)),n=a._getFacetFilters(e),o=a._getNumericFilters(e),s=a._getTagFilters(e),c={facets:t.indexOf("*")>-1?["*"]:t,tagFilters:s};return n.length>0&&(c.facetFilters=n),o.length>0&&(c.numericFilters=o),i(r({},e.getQueryParams(),c))},_getDisjunctiveFacetSearchParams:function(e,t,n){var o=a._getFacetFilters(e,t,n),s=a._getNumericFilters(e,t),c=a._getTagFilters(e),u={hitsPerPage:0,page:0,analytics:!1,clickAnalytics:!1};c.length>0&&(u.tagFilters=c);var l=e.getHierarchicalFacetByName(t);return u.facets=l?a._getDisjunctiveHierarchicalFacetAttribute(e,l,n):t,s.length>0&&(u.numericFilters=s),o.length>0&&(u.facetFilters=o),i(r({},e.getQueryParams(),u))},_getNumericFilters:function(e,t){if(e.numericFilters)return e.numericFilters;var n=[];return Object.keys(e.numericRefinements).forEach((function(r){var i=e.numericRefinements[r]||{};Object.keys(i).forEach((function(e){var a=i[e]||[];t!==r&&a.forEach((function(t){if(Array.isArray(t)){var i=t.map((function(t){return r+e+t}));n.push(i)}else n.push(r+e+t)}))}))})),n},_getTagFilters:function(e){return e.tagFilters?e.tagFilters:e.tagRefinements.join(",")},_getFacetFilters:function(e,t,n){var r=[],i=e.facetsRefinements||{};Object.keys(i).forEach((function(e){(i[e]||[]).forEach((function(t){r.push(e+":"+t)}))}));var a=e.facetsExcludes||{};Object.keys(a).forEach((function(e){(a[e]||[]).forEach((function(t){r.push(e+":-"+t)}))}));var o=e.disjunctiveFacetsRefinements||{};Object.keys(o).forEach((function(e){var n=o[e]||[];if(e!==t&&n&&0!==n.length){var i=[];n.forEach((function(t){i.push(e+":"+t)})),r.push(i)}}));var s=e.hierarchicalFacetsRefinements||{};return Object.keys(s).forEach((function(i){var a=(s[i]||[])[0];if(void 0!==a){var o,c,u=e.getHierarchicalFacetByName(i),l=e._getHierarchicalFacetSeparator(u),f=e._getHierarchicalRootPath(u);if(t===i){if(-1===a.indexOf(l)||!f&&!0===n||f&&f.split(l).length===a.split(l).length)return;f?(c=f.split(l).length-1,a=f):(c=a.split(l).length-2,a=a.slice(0,a.lastIndexOf(l))),o=u.attributes[c]}else c=a.split(l).length-1,o=u.attributes[c];o&&r.push([o+":"+a])}})),r},_getHitsHierarchicalFacetsAttributes:function(e){return e.hierarchicalFacets.reduce((function(t,n){var r=e.getHierarchicalRefinement(n.name)[0];if(!r)return t.push(n.attributes[0]),t;var i=e._getHierarchicalFacetSeparator(n),a=r.split(i).length,o=n.attributes.slice(0,a+1);return t.concat(o)}),[])},_getDisjunctiveHierarchicalFacetAttribute:function(e,t,n){var r=e._getHierarchicalFacetSeparator(t);if(!0===n){var i=e._getHierarchicalRootPath(t),a=0;return i&&(a=i.split(r).length),[t.attributes[a]]}var o=(e.getHierarchicalRefinement(t.name)[0]||"").split(r).length-1;return t.attributes.slice(0,o+1)},getSearchForFacetQuery:function(e,t,n,o){var s=o.isDisjunctiveFacet(e)?o.clearRefinements(e):o,c={facetQuery:t,facetName:e};return"number"==typeof n&&(c.maxFacetHits=n),i(r({},a._getHitsSearchParams(s),c))}};e.exports=a},6801:function(e){"use strict";e.exports=function(e){return null!==e&&/^[a-zA-Z0-9_-]{1,64}$/.test(e)}},4336:function(e){"use strict";e.exports="3.12.0"},9819:function(e){"use strict";var t=String.prototype.replace,n=/%20/g,r="RFC3986";e.exports={default:r,formatters:{RFC1738:function(e){return t.call(e,n,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:r}},7368:function(e,t,n){"use strict";var r=n(3307),i=n(6316),a=n(9819);e.exports={formats:a,parse:i,stringify:r}},6316:function(e,t,n){"use strict";var r=n(9084),i=Object.prototype.hasOwnProperty,a=Array.isArray,o={allowDots:!1,allowPrototypes:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:r.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},s=function(e){return e.replace(/&#(\d+);/g,(function(e,t){return String.fromCharCode(parseInt(t,10))}))},c=function(e,t){return e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1?e.split(","):e},u=function(e,t,n,r){if(e){var a=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/g,s=n.depth>0&&/(\[[^[\]]*])/.exec(a),u=s?a.slice(0,s.index):a,l=[];if(u){if(!n.plainObjects&&i.call(Object.prototype,u)&&!n.allowPrototypes)return;l.push(u)}for(var f=0;n.depth>0&&null!==(s=o.exec(a))&&f=0;--a){var o,s=e[a];if("[]"===s&&n.parseArrays)o=[].concat(i);else{o=n.plainObjects?Object.create(null):{};var u="["===s.charAt(0)&&"]"===s.charAt(s.length-1)?s.slice(1,-1):s,l=parseInt(u,10);n.parseArrays||""!==u?!isNaN(l)&&s!==u&&String(l)===u&&l>=0&&n.parseArrays&&l<=n.arrayLimit?(o=[])[l]=i:"__proto__"!==u&&(o[u]=i):o={0:i}}i=o}return i}(l,t,n,r)}};e.exports=function(e,t){var n=function(e){if(!e)return o;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");var t=void 0===e.charset?o.charset:e.charset;return{allowDots:void 0===e.allowDots?o.allowDots:!!e.allowDots,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:o.allowPrototypes,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:o.arrayLimit,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:o.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:o.comma,decoder:"function"==typeof e.decoder?e.decoder:o.decoder,delimiter:"string"==typeof e.delimiter||r.isRegExp(e.delimiter)?e.delimiter:o.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:o.depth,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:o.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:o.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:o.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:o.strictNullHandling}}(t);if(""===e||null==e)return n.plainObjects?Object.create(null):{};for(var l="string"==typeof e?function(e,t){var n,u={},l=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,f=t.parameterLimit===1/0?void 0:t.parameterLimit,h=l.split(t.delimiter,f),p=-1,d=t.charset;if(t.charsetSentinel)for(n=0;n-1&&(y=a(y)?[y]:y),i.call(u,m)?u[m]=r.combine(u[m],y):u[m]=y}return u}(e,n):e,f=n.plainObjects?Object.create(null):{},h=Object.keys(l),p=0;p0?I.join(",")||null:void 0}];else if(s(f))j=f;else{var O=Object.keys(I);j=h?O.sort(h):O}for(var T=0;T0?g+v:""}},9084:function(e,t,n){"use strict";var r=n(9819),i=Object.prototype.hasOwnProperty,a=Array.isArray,o=function(){for(var e=[],t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e}(),s=function(e,t){for(var n=t&&t.plainObjects?Object.create(null):{},r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(a(n)){for(var r=[],i=0;i=48&&l<=57||l>=65&&l<=90||l>=97&&l<=122||a===r.RFC1738&&(40===l||41===l)?c+=s.charAt(u):l<128?c+=o[l]:l<2048?c+=o[192|l>>6]+o[128|63&l]:l<55296||l>=57344?c+=o[224|l>>12]+o[128|l>>6&63]+o[128|63&l]:(u+=1,l=65536+((1023&l)<<10|1023&s.charCodeAt(u)),c+=o[240|l>>18]+o[128|l>>12&63]+o[128|l>>6&63]+o[128|63&l])}return c},isBuffer:function(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))},isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},maybeMap:function(e,t){if(a(e)){for(var n=[],r=0;r=0&&n<=o.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(a=n,!1!==i&&function(e){var n=(r[e]||"silent").toUpperCase();if(typeof window!==t&&c){try{return void(window.localStorage[c]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(c)+"="+n+";"}catch(e){}}}(n),s.call(o,n,e),typeof console===t&&n0&&void 0!==arguments[0]?arguments[0]:{};(0,i.default)(this,e),this.server=v.server||{nodes:[{host:"localhost",port:"8108",path:"",protocol:"http"}]},this.server.cacheSearchResultsForSeconds=null!==(t=this.server.cacheSearchResultsForSeconds)&&void 0!==t?t:120,this.additionalSearchParameters=null!==(n=v.additionalSearchParameters)&&void 0!==n?n:{},this.additionalSearchParameters.query_by=null!==(r=null!==(a=this.additionalSearchParameters.queryBy)&&void 0!==a?a:this.additionalSearchParameters.query_by)&&void 0!==r?r:"",this.additionalSearchParameters.preset=null!==(o=null!==(s=this.additionalSearchParameters.preset)&&void 0!==s?s:this.additionalSearchParameters.preset)&&void 0!==o?o:"",this.additionalSearchParameters.sort_by=null!==(c=null!==(u=this.additionalSearchParameters.sortBy)&&void 0!==u?u:this.additionalSearchParameters.sort_by)&&void 0!==c?c:"",this.additionalSearchParameters.highlight_full_fields=null!==(l=null!==(f=this.additionalSearchParameters.highlightFullFields)&&void 0!==f?f:this.additionalSearchParameters.highlight_full_fields)&&void 0!==l?l:this.additionalSearchParameters.query_by,this.geoLocationField=null!==(h=v.geoLocationField)&&void 0!==h?h:"_geoloc",this.facetableFieldsWithSpecialCharacters=null!==(p=v.facetableFieldsWithSpecialCharacters)&&void 0!==p?p:[],this.collectionSpecificSearchParameters=null!==(d=v.collectionSpecificSearchParameters)&&void 0!==d?d:{},Object.keys(this.collectionSpecificSearchParameters).forEach((function(e){var t,n,r,i,a,o,s=y.collectionSpecificSearchParameters[e];s.query_by=null!==(t=s.queryBy)&&void 0!==t?t:s.query_by,s.preset=null!==(n=s.preset)&&void 0!==n?n:s.preset,s.sort_by=null!==(r=s.sortBy)&&void 0!==r?r:s.sort_by,s.highlight_full_fields=null!==(i=null!==(a=null!==(o=s.highlightFullFields)&&void 0!==o?o:s.highlight_full_fields)&&void 0!==a?a:y.additionalSearchParameters.highlight_full_fields)&&void 0!==i?i:s.query_by,Object.keys(s).forEach((function(e){return void 0===s[e]?delete s[e]:{}}))})),this.renderingContent=v.renderingContent,this.flattenGroupedHits=null===(m=v.flattenGroupedHits)||void 0===m||m}return(0,a.default)(e,[{key:"validate",value:function(){if((this.additionalSearchParameters.queryBy||Object.values(this.collectionSpecificSearchParameters).some((function(e){return e.queryBy})))&&console.warn("[typesense-instantsearch-adapter] Please use snake_cased versions of parameters in additionalSearchParameters instead of camelCased parameters. For example: Use query_by instead of queryBy. camelCased parameters will be deprecated in a future version. We're making this change so that parameter names are identical to the ones sent to Typesense (which are all snake_cased), and to also keep the types for these parameters in sync with the types defined in typesense-js."),0===this.additionalSearchParameters.query_by.length&&0===this.additionalSearchParameters.preset.length&&(0===Object.keys(this.collectionSpecificSearchParameters).length||Object.values(this.collectionSpecificSearchParameters).some((function(e){return 0===(e.query_by||"").length&&0===(e.preset||"").length}))))throw new Error("[typesense-instantsearch-adapter] Missing parameter: One of additionalSearchParameters.query_by or additionalSearchParameters.preset needs to be set, or all collectionSpecificSearchParameters need to have either .query_by or .preset set.")}}]),e}();t.Configuration=o},3599:function(e,t,n){"use strict";var r=n(4836);Object.defineProperty(t,"__esModule",{value:!0}),t.FacetSearchResponseAdapter=void 0;var i=r(n(6690)),a=r(n(9728)),o=n(8399),s=function(){function e(t,n){(0,i.default)(this,e),this.typesenseResponse=t,this.instantsearchRequest=n}return(0,a.default)(e,[{key:"_adaptFacetHits",value:function(e){var t=this;return e.find((function(e){return e.field_name===t.instantsearchRequest.params.facetName})).counts.map((function(e){return{value:e.value,highlighted:t._adaptHighlightTag(e.highlighted,t.instantsearchRequest.params.highlightPreTag,t.instantsearchRequest.params.highlightPostTag),count:e.count}}))}},{key:"adapt",value:function(){return{facetHits:this._adaptFacetHits(this.typesenseResponse.facet_counts),exhaustiveFacetsCount:!0,processingTimeMS:this.typesenseResponse.search_time_ms}}}]),e}();t.FacetSearchResponseAdapter=s,Object.assign(s.prototype,o.utils)},4002:function(e,t,n){"use strict";var r=n(4836);Object.defineProperty(t,"__esModule",{value:!0}),t.SearchRequestAdapter=void 0;var i=r(n(1284)),a=r(n(7156)),o=r(n(7424)),s=r(n(6690)),c=r(n(9728)),u=function(){function e(t,n,r){(0,s.default)(this,e),this.instantsearchRequests=t,this.typesenseClient=n,this.configuration=r,this.additionalSearchParameters=r.additionalSearchParameters,this.collectionSpecificSearchParameters=r.collectionSpecificSearchParameters}var t;return(0,c.default)(e,[{key:"_adaptFacetFilters",value:function(e){var t=this,n="";return e?n=e.map((function(e){if(Array.isArray(e)){var n={};e.forEach((function(e){var r=t._parseFacetFilter(e),i=r.fieldName,a=r.fieldValue;n[i]=n[i]||[],n[i].push(a)})),Object.keys(n).length>1&&console.error("[Typesense-Instantsearch-Adapter] Typesense does not support cross-field ORs at the moment. The adapter could not OR values between these fields: ".concat(Object.keys(n).join(",")));var r=Object.keys(n)[0],i=n[r].reduce((function(e,n){return n.startsWith("-")&&!t._isNumber(n)?e[0].push(n.substring(1)):e[1].push(n),e}),[[],[]]),a=(0,o.default)(i,2),s=a[0],c=a[1],u=[];return c.length>0&&u.push("".concat(r,":=[").concat(c.map((function(e){return t._escapeFacetValue(e)})).join(","),"]")),s.length>0&&u.push("".concat(r,":!=[").concat(s.map((function(e){return t._escapeFacetValue(e)})).join(","),"]")),u.filter((function(e){return e})).join(" && ")}var l=t._parseFacetFilter(e),f=l.fieldName,h=l.fieldValue;return h.startsWith("-")&&!t._isNumber(h)?"".concat(f,":!=[").concat(t._escapeFacetValue(h.substring(1)),"]"):"".concat(f,":=[").concat(t._escapeFacetValue(h),"]")})).join(" && "):n}},{key:"_parseFacetFilter",value:function(e){var t,n,r,i,a;if((null===(t=this.configuration.facetableFieldsWithSpecialCharacters)||void 0===t?void 0:t.length)>0){var o=this.configuration.facetableFieldsWithSpecialCharacters.flat().map((function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}));if(n=new RegExp("^(".concat(o.join("|"),"):(.*)$")),null!=(r=e.match(n)))return{fieldName:i="".concat(r[1]),fieldValue:a="".concat(r[2])}}return n=this.constructor.DEFAULT_FACET_FILTER_STRING_MATCHING_REGEX,null==(r=e.match(n))?console.error("[Typesense-Instantsearch-Adapter] Parsing failed for a facet filter `".concat(e,"` with the Regex `").concat(n,"`. If you have field names with special characters, be sure to add them to a parameter called `facetableFieldsWithSpecialCharacters` when instantiating the adapter.")):(i="".concat(r[1]).concat(r[2]),a="".concat(r[3])),{fieldName:i,fieldValue:a}}},{key:"_escapeFacetValue",value:function(e){return"boolean"==typeof e||"true"===e||"false"===e||this._isNumber(e)?e:"`".concat(e,"`")}},{key:"_isNumber",value:function(e){return Number.isInteger(e%1)||!!(e%1)}},{key:"_adaptNumericFilters",value:function(e){var t=this,n="";if(!e)return n;var r={};e.forEach((function(e){var n=t._parseNumericFilter(e),i=n.fieldName,a=n.operator,o=n.fieldValue;r[i]=r[i]||{},r[i][a]=o}));var i=[];return Object.keys(r).forEach((function(e){null!=r[e]["<="]&&null!=r[e][">="]?i.push("".concat(e,":=[").concat(r[e][">="],"..").concat(r[e]["<="],"]")):null!=r[e]["<="]?i.push("".concat(e,":<=").concat(r[e]["<="])):null!=r[e][">="]?i.push("".concat(e,":>=").concat(r[e][">="])):null!=r[e]["="]?i.push("".concat(e,":=").concat(r[e]["="])):console.warn("[Typesense-Instantsearch-Adapter] Unsupported operator found ".concat(JSON.stringify(r[e])))})),i.join(" && ")}},{key:"_parseNumericFilter",value:function(e){var t,n,r,i,a,s;if((null===(t=this.configuration.facetableFieldsWithSpecialCharacters)||void 0===t?void 0:t.length)>0){var c=this.configuration.facetableFieldsWithSpecialCharacters.map((function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}));if(n=new RegExp("^(".concat(c.join("|"),")(<=|>=|>|<|=)(.*)$")),null!=(r=e.match(n))){var u=r,l=(0,o.default)(u,4);return{fieldName:i=l[1],operator:a=l[2],fieldValue:s=l[3]}}}if(n=this.constructor.DEFAULT_NUMERIC_FILTER_STRING_MATCHING_REGEX,null==(r=e.match(n)))console.error("[Typesense-Instantsearch-Adapter] Parsing failed for a numeric filter `".concat(e,"` with the Regex `").concat(n,"`. If you have field names with special characters, be sure to add them to a parameter called `facetableFieldsWithSpecialCharacters` when instantiating the adapter."));else{var f=r,h=(0,o.default)(f,4);i=h[1],a=h[2],s=h[3]}return{fieldName:i,operator:a,fieldValue:s}}},{key:"_adaptGeoFilter",value:function(e){var t=e.insideBoundingBox,n=e.aroundRadius,r=e.aroundLatLng,i=e.insidePolygon;if(t){var a,s,c,u;if(Array.isArray(t)){var l=t.flat(),f=(0,o.default)(l,4);a=f[0],s=f[1],c=f[2],u=f[3]}else{var h=t.split(","),p=(0,o.default)(h,4);a=p[0],s=p[1],c=p[2],u=p[3]}return"".concat(this.configuration.geoLocationField,":(").concat(a,", ").concat(s,", ").concat(a,", ").concat(u,", ").concat(c,", ").concat(u,", ").concat(c,", ").concat(s,")")}if(r||n){if(!n||"all"===n)throw new Error("[Typesense-Instantsearch-Adapter] In Typesense, geo-filtering around a lat/lng also requires a numerical radius. So the `aroundRadius` parameter is required when `aroundLatLng` is used. If you intend to just geo-sort around a lat/long, you want to use the sortBy InstantSearch widget (or a virtual sortBy custom widget).");var d="".concat(parseFloat(n)/1e3," km");return"".concat(this.configuration.geoLocationField,":(").concat(r,", ").concat(d,")")}if(i){var m=i;return Array.isArray(i)&&(m=i.flat().join(",")),"".concat(this.configuration.geoLocationField,":(").concat(m,")")}}},{key:"_adaptFilters",value:function(e){var t=[];return e.filters&&t.push(e.filters),t.push(this._adaptFacetFilters(e.facetFilters)),t.push(this._adaptNumericFilters(e.numericFilters)),t.push(this._adaptGeoFilter(e)),t.filter((function(e){return e&&""!==e})).join(" && ")}},{key:"_adaptIndexName",value:function(e){return e.match(this.constructor.INDEX_NAME_MATCHING_REGEX)[1]}},{key:"_adaptSortBy",value:function(e){return e.match(this.constructor.INDEX_NAME_MATCHING_REGEX)[3]}},{key:"_buildSearchParameters",value:function(e){for(var t=e.params,n=e.indexName,r=this._adaptIndexName(n),i={},a=0,s=Object.entries(this.additionalSearchParameters);a=|>|<|=)(.*)")}}]),e}();t.SearchRequestAdapter=u},2559:function(e,t,n){"use strict";var r=n(4836);Object.defineProperty(t,"__esModule",{value:!0}),t.SearchResponseAdapter=void 0;var i=r(n(8698)),a=r(n(7424)),o=r(n(861)),s=r(n(8416)),c=r(n(6690)),u=r(n(9728)),l=n(8399);function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function h(e){for(var t=1;t3&&void 0!==arguments[3]?arguments[3]:[];(0,c.default)(this,e),this.typesenseResponse=t,this.instantsearchRequest=n,this.configuration=r,this.allTypesenseResponses=i}return(0,u.default)(e,[{key:"_adaptGroupedHits",value:function(e){var t=this,n=[];return n=e.map((function(e){var n=t._adaptHits(e.hits);return n.forEach((function(t){t.group_key=t._group_key=e.group_key,e.found&&(t._group_found=e.found)})),n})),this.configuration.flattenGroupedHits?n.flat():n.map((function(e){return h(h({},e[0]),{},{_grouped_hits:e})}))}},{key:"_adaptHits",value:function(e){var t=this;return e.map((function(e){var n=h({},e.document);n.objectID=e.document.id,n._snippetResult=t._adaptHighlightResult(e,"snippet"),n._highlightResult=t._adaptHighlightResult(e,"value"),n._rawTypesenseHit=e,["text_match","geo_distance_meters","curated","text_match_info","hybrid_search_info","vector_distance"].forEach((function(t){Object.keys(e).includes(t)&&!Object.keys(n).includes(t)&&(n[t]=e[t])}));var r=n[t.configuration.geoLocationField];return r&&(n._geoloc={lat:r[0],lng:r[1]}),n}))}},{key:"_adaptHighlightResult",value:function(e,t){var n={};return null!=e.highlight&&this.isHighlightPost0240RCN32Format(e.highlight)?this.adaptHighlightObject(e,n,t):this.adaptHighlightsArray(e,n,t),n}},{key:"isHighlightPost0240RCN32Format",value:function(e){return null==e.full&&null==e.snippet}},{key:"adaptHighlightsArray",value:function(e,t,n){var r=this;Object.assign.apply(Object,[t].concat((0,o.default)(Object.entries(e.document).map((function(e){var t=(0,a.default)(e,2),n=t[0],r=t[1];return(0,s.default)({},n,{value:r,matchLevel:"none",matchedWords:[]})}))))),e.highlights.forEach((function(e){t[e.field]={value:e[n]||e["".concat(n,"s")],matchLevel:"full",matchedWords:e.matched_tokens},e.indices&&(t[e.field].matchedIndices=e.indices)})),Object.entries(t).forEach((function(o){var s=(0,a.default)(o,2),c=s[0],u=s[1],l=c,f=u.value,h=u.matchLevel,p=u.matchedWords,d=u.matchedIndices;null==f?t[l]=r._adaptHighlightNullValue():Array.isArray(f)?(t[l]=[],e.document[l].forEach((function(e,a){d&&d.includes(a)?t[l].push({value:r._adaptHighlightTag("".concat(f[d.indexOf(a)]),r.instantsearchRequest.params.highlightPreTag,r.instantsearchRequest.params.highlightPostTag),matchLevel:h,matchedWords:p[a]}):"object"===(0,i.default)(e)?t[l].push(r._adaptHighlightInObjectValue(e,{},n)):t[l].push({value:"".concat(e),matchLevel:"none",matchedWords:[]})}))):"object"===(0,i.default)(f)?t[l]=r._adaptHighlightInObjectValue(f,{},n):t[l].value=r._adaptHighlightTag("".concat(f),r.instantsearchRequest.params.highlightPreTag,r.instantsearchRequest.params.highlightPostTag)}))}},{key:"adaptHighlightObject",value:function(e,t,n){Object.assign(t,this._adaptHighlightInObjectValue(e.document,e.highlight,n))}},{key:"_adaptHighlightInObjectValue",value:function(e,t,n){var r=this;return Object.assign.apply(Object,[{}].concat((0,o.default)(Object.entries(e).map((function(e){var o,c=(0,a.default)(e,2),u=c[0],l=c[1];if(null==l)o=r._adaptHighlightNullValue();else if(Array.isArray(l)){var f;o=r._adaptHighlightInArrayValue(l,null!==(f=null==t?void 0:t[u])&&void 0!==f?f:[],n)}else if("object"===(0,i.default)(l)){var h;o=r._adaptHighlightInObjectValue(l,null!==(h=null==t?void 0:t[u])&&void 0!==h?h:{},n)}else o=r._adaptHighlightInPrimitiveValue(l,null==t?void 0:t[u],n);return(0,s.default)({},u,o)})))))}},{key:"_adaptHighlightInArrayValue",value:function(e,t,n){var r=this;return e.map((function(e,a){var o;if(null==e)o=r._adaptHighlightNullValue();else if(Array.isArray(e)){var s;o=r._adaptHighlightInArrayValue(e,null!==(s=null==t?void 0:t[a])&&void 0!==s?s:[],n)}else if("object"===(0,i.default)(e)){var c;o=r._adaptHighlightInObjectValue(e,null!==(c=null==t?void 0:t[a])&&void 0!==c?c:{},n)}else o=r._adaptHighlightInPrimitiveValue(e,null==t?void 0:t[a],n);return o}))}},{key:"_adaptHighlightInPrimitiveValue",value:function(e,t,n){var r,i;return null!=t?{value:this._adaptHighlightTag("".concat(null!==(r=null!==(i=t[n])&&void 0!==i?i:t.highlight)&&void 0!==r?r:t.snippet),this.instantsearchRequest.params.highlightPreTag,this.instantsearchRequest.params.highlightPostTag),matchLevel:(t.matched_tokens||[]).length>0?"full":"none",matchedWords:t.matched_tokens||[]}:{value:this._adaptHighlightTag("".concat(e),this.instantsearchRequest.params.highlightPreTag,this.instantsearchRequest.params.highlightPostTag),matchLevel:"none",matchedWords:[]}}},{key:"_adaptHighlightNullValue",value:function(){return{value:"",matchLevel:"none",matchedWords:[]}}},{key:"_adaptFacets",value:function(e){var t={};return e.forEach((function(e){Object.assign(t,(0,s.default)({},e.field_name,Object.assign.apply(Object,[{}].concat((0,o.default)(e.counts.map((function(e){return(0,s.default)({},e.value,e.count)})))))))})),t}},{key:"_adaptFacetStats",value:function(e){var t={};return e.forEach((function(e){Object.keys(e.stats).length>0&&Object.assign(t,(0,s.default)({},e.field_name,e.stats))})),t}},{key:"_adaptRenderingContent",value:function(e){var t,n=Object.assign({},this.configuration.renderingContent);return null==(null===(t=n.facetOrdering)||void 0===t||null===(t=t.facets)||void 0===t?void 0:t.order)&&(n.facetOrdering=n.facetOrdering||{},n.facetOrdering.facets=n.facetOrdering.facets||{},n.facetOrdering.facets.order=(0,o.default)(new Set(e.map((function(e){return e.field_name})).concat(this.allTypesenseResponses.map((function(e){return e.facet_counts||[]})).flat().map((function(e){return e.field_name})).filter((function(e){return e})))))),n}},{key:"adapt",value:function(){var e=this._adaptRenderingContent(this.typesenseResponse.facet_counts||[]);return h({hits:this.typesenseResponse.grouped_hits?this._adaptGroupedHits(this.typesenseResponse.grouped_hits):this._adaptHits(this.typesenseResponse.hits),nbHits:this.typesenseResponse.found,page:this.typesenseResponse.page-1,nbPages:this._adaptNumberOfPages(),hitsPerPage:this.typesenseResponse.request_params.per_page,facets:this._adaptFacets(this.typesenseResponse.facet_counts||[]),facets_stats:this._adaptFacetStats(this.typesenseResponse.facet_counts||{}),query:this.typesenseResponse.request_params.q,processingTimeMS:this.typesenseResponse.search_time_ms},Object.keys(e).length>0?{renderingContent:e}:null)}}]),e}();t.SearchResponseAdapter=p,Object.assign(p.prototype,l.utils)},8499:function(e,t,n){"use strict";var r=n(4836);t.Z=void 0;var i=r(n(1284)),a=r(n(7156)),o=r(n(6690)),s=r(n(9728)),c=n(7325),u=n(8871),l=n(4002),f=n(2559),h=n(3599),p=function(){function e(t){var n=this;(0,o.default)(this,e),this.updateConfiguration(t),this.searchClient={clearCache:function(){return n.clearCache()},search:function(e){return n.searchTypesenseAndAdapt(e)},searchForFacetValues:function(e){return n.searchTypesenseForFacetValuesAndAdapt(e)}}}var t,n,r;return(0,s.default)(e,[{key:"searchTypesenseAndAdapt",value:(r=(0,a.default)(i.default.mark((function e(t){var n,r,a=this;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._adaptAndPerformTypesenseRequest(t);case 3:return n=e.sent,r=n.results.map((function(e,r){return a._validateTypesenseResult(e),new f.SearchResponseAdapter(e,t[r],a.configuration,n.results).adapt()})),e.abrupt("return",{results:r});case 8:throw e.prev=8,e.t0=e.catch(0),console.error(e.t0),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(_x){return r.apply(this,arguments)})},{key:"searchTypesenseForFacetValuesAndAdapt",value:(n=(0,a.default)(i.default.mark((function e(t){var n,r,a=this;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this._adaptAndPerformTypesenseRequest(t);case 3:return n=e.sent,r=n.results.map((function(e,n){return a._validateTypesenseResult(e),new h.FacetSearchResponseAdapter(e,t[n],a.configuration).adapt()})),e.abrupt("return",r);case 8:throw e.prev=8,e.t0=e.catch(0),console.error(e.t0),e.t0;case 12:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(e){return n.apply(this,arguments)})},{key:"_adaptAndPerformTypesenseRequest",value:(t=(0,a.default)(i.default.mark((function e(t){var n,r;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new l.SearchRequestAdapter(t,this.typesenseClient,this.configuration),e.next=3,n.request();case 3:return r=e.sent,e.abrupt("return",r);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"clearCache",value:function(){return this.typesenseClient=new u.SearchClient(this.configuration.server),this.searchClient}},{key:"updateConfiguration",value:function(e){return this.configuration=new c.Configuration(e),this.configuration.validate(),this.typesenseClient=new u.SearchClient(this.configuration.server),!0}},{key:"_validateTypesenseResult",value:function(e){if(e.error)throw new Error("".concat(e.code," - ").concat(e.error));if(!e.hits&&!e.grouped_hits)throw new Error("Did not find any hits. ".concat(e.code," - ").concat(e.error))}}]),e}();t.Z=p},8399:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.utils=void 0;var n={_adaptHighlightTag:function(e,t,n){return e.replace(new RegExp("","g"),t||"").replace(new RegExp("","g"),n||"")},_adaptNumberOfPages:function(){var e=this.typesenseResponse.found/this.typesenseResponse.request_params.per_page;return Number.isFinite(e)?Math.ceil(e):1}};t.utils=n},8871:function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Errors=t.SearchClient=t.Client=void 0;var s=o(n(4339));t.Client=s.default;var c=o(n(8834));t.SearchClient=c.default;var u=a(n(6718));t.Errors=u,t.default={Client:s.default,SearchClient:c.default,Errors:u}},8480:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0},transformResponse:[function(e,t){var n=e;return void 0!==t&&"string"==typeof e&&t["content-type"]&&t["content-type"].startsWith("application/json")&&(n=JSON.parse(e)),n}]},!0!==I&&(g.timeout=1e3*h.connectionTimeoutSeconds),f&&0!==Object.keys(f).length&&(g.params=f),h.sendApiKeyAsQueryParam&&(g.params=g.params||{},g.params["x-typesense-api-key"]=h.apiKey),p&&("string"==typeof p&&0!==p.length||"object"==typeof p&&0!==Object.keys(p).length)&&(g.data=p),v&&(A=o.default.CancelToken,w=A.source(),y=function(){return w.cancel()},v.addEventListener("abort",y),g.cancelToken=w.token),[4,(0,o.default)(g)];case 2:if((S=i.sent()).status>=1&&S.status<=499&&h.setNodeHealthcheck(d,u),h.logger.debug("Request #".concat(n,": Request to Node ").concat(d.index," was made. Response Code was ").concat(S.status,".")),S.status>=200&&S.status<300)return[2,{value:Promise.resolve(S.data)}];if(S.status<500)return[2,{value:Promise.reject(h.customErrorForResponse(S,null===(a=S.data)||void 0===a?void 0:a.message))}];throw h.customErrorForResponse(S,null===(s=S.data)||void 0===s?void 0:s.message);case 3:return R=i.sent(),h.setNodeHealthcheck(d,!1),r=R,h.logger.warn("Request #".concat(n,": Request to Node ").concat(d.index,' failed due to "').concat(R.code," ").concat(R.message).concat(null==R.response?"":" - "+JSON.stringify(null===(c=R.response)||void 0===c?void 0:c.data),'"')),h.logger.warn("Request #".concat(n,": Sleeping for ").concat(h.retryIntervalSeconds,"s and then retrying request...")),[4,h.timer(h.retryIntervalSeconds)];case 4:return i.sent(),[3,6];case 5:return v&&y&&v.removeEventListener("abort",y),[7];case 6:return[2]}}))},h=this,d=1,g.label=1;case 1:return d<=this.numRetriesPerRequest+1?[5,l(d)]:[3,4];case 2:if("object"==typeof(y=g.sent()))return[2,y.value];g.label=3;case 3:return d++,[3,1];case 4:return this.logger.debug("Request #".concat(n,": No retries left. Raising last error")),[2,Promise.reject(r)]}}))}))},e.prototype.getNextNode=function(e){if(void 0===e&&(e=0),null!=this.nearestNode){if(this.logger.debug("Request #".concat(e,": Nodes Health: Node ").concat(this.nearestNode.index," is ").concat(!0===this.nearestNode.isHealthy?"Healthy":"Unhealthy")),!0===this.nearestNode.isHealthy||this.nodeDueForHealthcheck(this.nearestNode,e))return this.logger.debug("Request #".concat(e,": Updated current node to Node ").concat(this.nearestNode.index)),this.nearestNode;this.logger.debug("Request #".concat(e,": Falling back to individual nodes"))}this.logger.debug("Request #".concat(e,": Nodes Health: ").concat(this.nodes.map((function(e){return"Node ".concat(e.index," is ").concat(!0===e.isHealthy?"Healthy":"Unhealthy")})).join(" || ")));for(var t=this.nodes[0],n=0;n<=this.nodes.length;n++)if(this.currentNodeIndex=(this.currentNodeIndex+1)%this.nodes.length,!0===(t=this.nodes[this.currentNodeIndex]).isHealthy||this.nodeDueForHealthcheck(t,e))return this.logger.debug("Request #".concat(e,": Updated current node to Node ").concat(t.index)),t;return this.logger.debug("Request #".concat(e,": No healthy nodes were found. Returning the next node, Node ").concat(t.index)),t},e.prototype.nodeDueForHealthcheck=function(e,t){void 0===t&&(t=0);var n=Date.now()-e.lastAccessTimestamp>1e3*this.healthcheckIntervalSeconds;return n&&this.logger.debug("Request #".concat(t,": Node ").concat(e.index," has exceeded healtcheckIntervalSeconds of ").concat(this.healthcheckIntervalSeconds,". Adding it back into rotation.")),n},e.prototype.initializeMetadataForNodes=function(){var e=this;null!=this.nearestNode&&(this.nearestNode.index="nearestNode",this.setNodeHealthcheck(this.nearestNode,u)),this.nodes.forEach((function(t,n){t.index=n,e.setNodeHealthcheck(t,u)}))},e.prototype.setNodeHealthcheck=function(e,t){e.isHealthy=t,e.lastAccessTimestamp=Date.now()},e.prototype.uriFor=function(e,t){return null!=t.url?"".concat(t.url).concat(e):"".concat(t.protocol,"://").concat(t.host,":").concat(t.port).concat(t.path).concat(e)},e.prototype.defaultHeaders=function(){var e={};return this.sendApiKeyAsQueryParam||(e["X-TYPESENSE-API-KEY"]=this.apiKey),e["Content-Type"]="application/json",e},e.prototype.timer=function(e){return r(this,void 0,void 0,(function(){return i(this,(function(t){return[2,new Promise((function(t){return setTimeout(t,1e3*e)}))]}))}))},e.prototype.customErrorForResponse=function(e,t){var n="Request failed with HTTP code ".concat(e.status);"string"==typeof t&&""!==t.trim()&&(n+=" | Server said: ".concat(t));var r=new c.default(n);return(r=400===e.status?new s.RequestMalformed(n):401===e.status?new s.RequestUnauthorized(n):404===e.status?new s.ObjectNotFound(n):409===e.status?new s.ObjectAlreadyExists(n):422===e.status?new s.ObjectUnprocessable(n):e.status>=500&&e.status<=599?new s.ServerError(n):new s.HTTPError(n)).httpStatus=e.status,r},e}();t.default=l},4339:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(2554)),a=r(n(9777)),o=r(n(6581)),s=r(n(8243)),c=r(n(5346)),u=r(n(8480)),l=r(n(2708)),f=r(n(7309)),h=r(n(7634)),p=r(n(6029)),d=r(n(1930)),m=r(n(3095)),y=r(n(9092)),v=r(n(1036)),g=r(n(1040)),b=r(n(6845)),A=function(){function e(e){var t;e.sendApiKeyAsQueryParam=null!==(t=e.sendApiKeyAsQueryParam)&&void 0!==t&&t,this.configuration=new i.default(e),this.apiCall=new a.default(this.configuration),this.debug=new h.default(this.apiCall),this.metrics=new p.default(this.apiCall),this.health=new d.default(this.apiCall),this.operations=new m.default(this.apiCall),this.multiSearch=new y.default(this.apiCall,this.configuration),this._collections=new o.default(this.apiCall),this.individualCollections={},this._aliases=new c.default(this.apiCall),this.individualAliases={},this._keys=new l.default(this.apiCall),this.individualKeys={},this._presets=new v.default(this.apiCall),this.individualPresets={},this.analytics=new b.default(this.apiCall)}return e.prototype.collections=function(e){return void 0===e?this._collections:(void 0===this.individualCollections[e]&&(this.individualCollections[e]=new s.default(e,this.apiCall,this.configuration)),this.individualCollections[e])},e.prototype.aliases=function(e){return void 0===e?this._aliases:(void 0===this.individualAliases[e]&&(this.individualAliases[e]=new u.default(e,this.apiCall)),this.individualAliases[e])},e.prototype.keys=function(e){return void 0===e?this._keys:(void 0===this.individualKeys[e]&&(this.individualKeys[e]=new f.default(e,this.apiCall)),this.individualKeys[e])},e.prototype.presets=function(e){return void 0===e?this._presets:(void 0===this.individualPresets[e]&&(this.individualPresets[e]=new g.default(e,this.apiCall)),this.individualPresets[e])},e}();t.default=A},8243:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0;n--){var r=Math.floor(Math.random()*(n+1));t=[e[r],e[n]],e[n]=t[0],e[r]=t[1]}},e}();t.default=u},7634:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0)throw new s.ImportError("".concat(i.length-a.length," documents imported successfully, ").concat(a.length," documents failed during import. Use `error.importResults` from the raised exception to get a detailed error reason for each document."),i);return[2,i]}return[2,r]}}))}))},t.prototype.export=function(e){return void 0===e&&(e={}),a(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.apiCall.get(this.endpointPath("export"),e)]}))}))},t.prototype.exportStream=function(e){return void 0===e&&(e={}),a(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.apiCall.get(this.endpointPath("export"),e,{responseType:"stream"})]}))}))},t}(n(5586).SearchOnlyDocuments);t.default=c},7117:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},9229:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(t,n){var r=e.call(this,t)||this;return r.importResults=n,r}return i(t,e),t}(a(n(4492)).default);t.default=o},1254:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},4105:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},3836:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},220:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},4913:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},9976:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},4959:function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(a(n(4492)).default);t.default=o},4492:function(e,t){"use strict";var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)});Object.defineProperty(t,"__esModule",{value:!0});var i=function(e){function t(t){var n=this.constructor,r=e.call(this,t)||this;return r.name=n.name,Object.setPrototypeOf(r,n.prototype),r}return r(t,e),t}(Error);t.default=i},6718:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ImportError=t.TypesenseError=t.ServerError=t.RequestUnauthorized=t.RequestMalformed=t.ObjectUnprocessable=t.ObjectNotFound=t.ObjectAlreadyExists=t.MissingConfigurationError=t.HTTPError=void 0;var i=r(n(7117));t.HTTPError=i.default;var a=r(n(1254));t.MissingConfigurationError=a.default;var o=r(n(4105));t.ObjectAlreadyExists=o.default;var s=r(n(3836));t.ObjectNotFound=s.default;var c=r(n(220));t.ObjectUnprocessable=c.default;var u=r(n(4913));t.RequestMalformed=u.default;var l=r(n(9976));t.RequestUnauthorized=l.default;var f=r(n(4959));t.ServerError=f.default;var h=r(n(9229));t.ImportError=h.default;var p=r(n(4492));t.TypesenseError=p.default},1930:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]u&&(y=this.responseCache.keys().next().value,this.responseCache.delete(y)),this.responsePromiseCache.size>u&&(y=this.responsePromiseCache.keys().next().value,this.responsePromiseCache.delete(y)),[2,m]}}))}))},e}();t.default=a},8834:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=r(n(2554)),a=r(n(9777)),o=r(n(9092)),s=n(3320),c=function(){function e(e){var t;e.sendApiKeyAsQueryParam=null===(t=e.sendApiKeyAsQueryParam)||void 0===t||t,!0===e.sendApiKeyAsQueryParam&&(e.apiKey||"").length>2e3&&(console.warn("[typesense] API Key is longer than 2000 characters which is over the allowed limit, so disabling sending it as a query parameter."),e.sendApiKeyAsQueryParam=!1),this.configuration=new i.default(e),this.apiCall=new a.default(this.configuration),this.multiSearch=new o.default(this.apiCall,this.configuration,!0),this.individualCollections={}}return e.prototype.clearCache=function(){this.multiSearch.clearCache(),Object.entries(this.individualCollections).forEach((function(e){e[0],e[1].documents().clearCache()}))},e.prototype.collections=function(e){if(e)return void 0===this.individualCollections[e]&&(this.individualCollections[e]=new s.SearchOnlyCollection(e,this.apiCall,this.configuration)),this.individualCollections[e];throw new Error("Typesense.SearchClient only supports search operations, so the collectionName that needs to be searched must be specified. Use Typesense.Client if you need to access the collection object.")},e}();t.default=c},3320:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SearchOnlyCollection=void 0;var r=n(5586),i=function(){function e(e,t,n){this.name=e,this.apiCall=t,this.configuration=n,this._documents=new r.SearchOnlyDocuments(this.name,this.apiCall,this.configuration)}return e.prototype.documents=function(){return this._documents},e}();t.SearchOnlyCollection=i},5586:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(e){l.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){l.headers[e]=r.merge(s)})),e.exports=l},1932:function(e){"use strict";e.exports={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1}},4477:function(e){e.exports={version:"0.26.1"}},5904:function(e){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([n]):o[t]?o[t]+", "+n:n}})),o):o}},3789:function(e){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},5994:function(e,t,n){"use strict";var r=n(4477).version,i={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){i[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var a={};i.transitional=function(e,t,n){function i(e,t){return"[Axios v"+r+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,o){if(!1===e)throw new Error(i(r," has been removed"+(t?" in "+t:"")));return t&&!a[r]&&(a[r]=!0,console.warn(i(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,o)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),i=r.length;i-- >0;){var a=r[i],o=t[a];if(o){var s=e[a],c=void 0===s||o(s,a,e);if(!0!==c)throw new TypeError("option "+a+" must be "+c)}else if(!0!==n)throw Error("Unknown option "+a)}},validators:i}},486:function(e,t,n){"use strict";var r=n(5904),i=Object.prototype.toString;function a(e){return Array.isArray(e)}function o(e){return void 0===e}function s(e){return"[object ArrayBuffer]"===i.call(e)}function c(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==i.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function l(e){return"[object Function]"===i.call(e)}function f(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),a(e))for(var n=0,r=e.length;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n{switch(t.type){case"INITIALIZE_NAMESPACE":return{...e,[t.namespace]:u};case"UPDATE_HIIVE_URLS":return{...e,[t.namespace]:{...e[t.namespace],urls:{single:t.urls.single,batch:t.urls.batch}}};case"UPDATE_HIIVE_EVENTS_QUEUE":return{...e,[t.namespace]:{...e[t.namespace],queue:{events:t.events,threshold:e[t.namespace].queue.threshold}}};case"UPDATE_HIIVE_EVENTS_QUEUE_THRESHOLD":return{...e,[t.namespace]:{...e[t.namespace],queue:{events:e[t.namespace].queue.events,threshold:t.threshold}}};case"UPDATE_HIIVE_DEBOUNCE_TIME":return{...e,[t.namespace]:{...e[t.namespace],debounce:{time:t.debounceTime,instance:e[t.namespace].debounce.instance}}};case"UPDATE_HIIVE_DEBOUNCE_INSTANCE":return{...e,[t.namespace]:{...e[t.namespace],debounce:{time:e[t.namespace].debounce.time,instance:t.instance}}}}return e}}),actions:e,selectors:t},w=(0,a.createReduxStore)("newfold/ui-analytics",I);(0,a.register)(w);var S=window.wp.apiFetch,R=n.n(S);const P=e=>!!window?.nfdUIAnalytics?.hiive&&e in window.nfdUIAnalytics.hiive,j=async e=>{if(!(e=>e instanceof c)(e)||!P(e.namespace))return!1;const t=e.namespace;delete e.namespace;const n=(0,a.select)(w).getHiiveSingleUrl(t);if(!n)return!1;try{await R()({url:n,method:"POST",data:e})}catch(e){return console.error(e),!1}};var E,O,T=window.wp.i18n,x=n(9196);function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{fallback:function(){}},n=t.fallback;return"undefined"==typeof window?n():e({window:window})}function W(){}function Q(e){if(e.transporter){var t=e.transporter,n=t.headers,r=t.queryParameters,i="x-algolia-application-id",a="x-algolia-api-key";return[n[i]||r[i],n[a]||r[a]]}return[e.applicationID,e.apiKey]}function X(e,t){for(var n,r=0;re.length)&&(t=e.length);for(var n=0,r=new Array(t);n=3||2===n&&r>=6||1===n&&r>=10}function re(e,t,n){var r=t.getHelper();return{uiState:n,helper:r,parent:t,instantSearchInstance:e,state:r.state,renderState:e.renderState,templatesConfig:e.templatesConfig,createURL:t.createURL,scopedResults:[],searchMetadata:{isSearchStalled:"stalled"===e.status},status:e.status,error:e.error}}function ie(e,t){var n=t.getResults();return{helper:t.getHelper(),parent:t,instantSearchInstance:e,results:n,scopedResults:t.getScopedResults(),state:n._state,renderState:e.renderState,templatesConfig:e.templatesConfig,createURL:t.createURL,searchMetadata:{isSearchStalled:"stalled"===e.status},status:e.status,error:e.error}}function ae(e,t,n){var r=re(t,t.mainIndex,t._initialUiState);e.forEach((function(e){var i={};if(e.getWidgetRenderState){var a=e.getWidgetRenderState(r);a&&a.widgetParams&&(i=a.widgetParams)}var o=Object.keys(i).filter((function(e){return void 0!==i[e]}));n.widgets.push({type:e.$$type,widgetType:e.$$widgetType,params:o}),"ais.index"===e.$$type&&ae(e.getWidgets(),t,n)}))}var oe=n(7368);function se(e){return se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},se(e)}function ce(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{},t=e.createURL,n=void 0===t?function(e){var t=e.qsModule,n=e.routeState,r=e.location,i=r.protocol,a=r.hostname,o=r.port,s=void 0===o?"":o,c=r.pathname,u=r.hash,l=t.stringify(n),f=""===s?"":":".concat(s);return l?"".concat(i,"//").concat(a).concat(f).concat(c,"?").concat(l).concat(u):"".concat(i,"//").concat(a).concat(f).concat(c).concat(u)}:t,r=e.parseURL,i=void 0===r?function(e){var t=e.qsModule,n=e.location;return t.parse(n.search.slice(1),{arrayLimit:99})}:r,a=e.writeDelay,o=void 0===a?400:a,s=e.windowTitle,c=e.getLocation,u=void 0===c?function(){return z((function(e){return e.window.location}),{fallback:function(){throw new Error("You need to provide `getLocation` to the `history` router in environments where `window` does not exist.")}})}:c,l=e.start,f=e.dispose,h=e.push;return new he({createURL:n,parseURL:i,writeDelay:o,windowTitle:s,getLocation:u,start:l,dispose:f,push:h})}function de(e){return de="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},de(e)}var me=["configure"];function ye(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ve(e){for(var t=1;t=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(e,me)}function Ae(){return{$$type:"ais.simple",stateToRoute:function(e){return Object.keys(e).reduce((function(t,n){return ve(ve({},t),{},ge({},n,be(e[n])))}),{})},routeToState:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.keys(e).reduce((function(t,n){return ve(ve({},t),{},ge({},n,be(e[n])))}),{})}}}function Ie(e){return e!==Object(e)}function we(e,t){if(e===t)return!0;if(Ie(e)||Ie(t)||"function"==typeof e||"function"==typeof t)return e===t;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var n=0,r=Object.keys(e);n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,He);return e.setQueryParameters(n)},Ue=function(e,t){return t.facets.reduce((function(e,t){return e.addFacet(t)}),e)},Ze=function(e,t){return t.disjunctiveFacets.reduce((function(e,t){return e.addDisjunctiveFacet(t)}),e)},De=function(e,t){return e.setQueryParameters({hierarchicalFacets:t.hierarchicalFacets.reduce((function(e,t){var n=function(e,n){if(!Array.isArray(e))return-1;for(var r=0;r0?e.setQueryParameters({ruleContexts:n}):e},Je=function(){for(var e=arguments.length,t=new Array(e),n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n2&&void 0!==arguments[2]?arguments[2]:{};return e.reduce((function(e,n){return Te(n)?e:n.getWidgetUiState||n.getWidgetState?n.getWidgetUiState?n.getWidgetUiState(e,t):n.getWidgetState(e,t):e}),n)}function rt(e,t){var n=t.initialSearchParameters,r=function(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(t,Le);return e.filter((function(e){return!Te(e)})).reduce((function(e,t){return t.getWidgetSearchParameters?t.getWidgetSearchParameters(e,r):e}),n)}function it(e){var t=e.filter(Te);0!==t.length&&t.forEach((function(e){var t=e.getHelper();tt(t,{state:t.state.resetPage(),isPageReset:!0}),it(e.getWidgets())}))}function at(e){return e.filter(Te).reduce((function(e,t){return e.concat.apply(e,[{indexId:t.getIndexId(),results:t.getResults(),helper:t.getHelper()}].concat(_e(at(t.getWidgets()))))}),[])}var ot=function(e){if(void 0===e||void 0===e.indexName)throw new Error(et("The `indexName` option is required."));var t=e.indexName,n=e.indexId,r=void 0===n?t:n,i=[],a={},o=null,s=null,c=null,u=null,l=null;return{$$type:"ais.index",$$widgetType:"ais.index",getIndexName:function(){return t},getIndexId:function(){return r},getHelper:function(){return c},getResults:function(){var e;return null!==(e=u)&&void 0!==e&&e.lastResults?(u.lastResults._state=c.state,u.lastResults):null},getPreviousState:function(){return l},getScopedResults:function(){var e=this.getParent();return at(e?e.getWidgets():[this])},getParent:function(){return s},createURL:function(e){return o._createURL(Ke({},r,nt(i,{searchParameters:e,helper:c})))},getWidgets:function(){return i},addWidgets:function(e){var t=this;if(!Array.isArray(e))throw new Error(et("The `addWidgets` method expects an array of widgets."));if(e.some((function(e){return"function"!=typeof e.init&&"function"!=typeof e.render})))throw new Error(et("The widget definition expects a `render` and/or an `init` method."));return i=i.concat(e),o&&Boolean(e.length)&&(tt(c,{state:rt(i,{uiState:a,initialSearchParameters:c.state}),_uiState:a}),e.forEach((function(e){e.getRenderState&&st({renderState:e.getRenderState(o.renderState[t.getIndexId()]||{},re(o,t,o._initialUiState)),instantSearchInstance:o,parent:t})})),e.forEach((function(e){e.init&&e.init(re(o,t,o._initialUiState))})),o.scheduleSearch()),this},removeWidgets:function(e){var t=this;if(!Array.isArray(e))throw new Error(et("The `removeWidgets` method expects an array of widgets."));if(e.some((function(e){return"function"!=typeof e.dispose})))throw new Error(et("The widget definition expects a `dispose` method."));if(i=i.filter((function(t){return-1===e.indexOf(t)})),o&&Boolean(e.length)){var n=e.reduce((function(e,n){return n.dispose({helper:c,state:e,parent:t})||e}),c.state);a=nt(i,{searchParameters:n,helper:c}),c.setState(rt(i,{uiState:a,initialSearchParameters:n})),i.length&&o.scheduleSearch()}return this},init:function(e){var n,f=this,h=e.instantSearchInstance,p=e.parent,d=e.uiState;if(null===c){o=h,s=p,a=d[r]||{};var m=h.mainHelper,y=rt(i,{uiState:a,initialSearchParameters:new F.SearchParameters({index:t})});(c=F({},y.index,y)).search=function(){return h.onStateChange?(h.onStateChange({uiState:h.mainIndex.getWidgetUiState({}),setUiState:function(e){return h.setUiState(e,!1)}}),m):m.search()},c.searchWithoutTriggeringOnStateChange=function(){return m.search()},c.searchForFacetValues=function(e,t,n,r){var i=c.state.setQueryParameters(r);return m.searchForFacetValues(e,t,n,i)},u=m.derive((function(){return Je.apply(void 0,_e(function(e){for(var t=e.getParent(),n=[e.getHelper().state];null!==t;)n=[t.getHelper().state].concat(n),t=t.getParent();return n}(f)))}));var v=null===(n=h._initialResults)||void 0===n?void 0:n[this.getIndexId()];if(v){var g=new F.SearchResults(new F.SearchParameters(v.state),v.results);u.lastResults=g,c.lastResults=g}c.on("change",(function(e){e.isPageReset&&it(i)})),u.on("search",(function(){h.scheduleStalledRender()})),u.on("result",(function(e){var t=e.results;h.scheduleRender(),c.lastResults=t,l=t._state})),i.forEach((function(e){e.getRenderState&&st({renderState:e.getRenderState(h.renderState[f.getIndexId()]||{},re(h,f,d)),instantSearchInstance:h,parent:f})})),i.forEach((function(e){e.init&&e.init(re(h,f,d))})),c.on("change",(function(e){var t=e.state,n=e._uiState;a=nt(i,{searchParameters:t,helper:c},n||{}),h.onStateChange||h.onInternalStateChange()})),v&&h.scheduleRender()}},render:function(e){var t=this,n=e.instantSearchInstance;this.getResults()&&("error"!==n.status||n.mainHelper.hasPendingRequests()||c.setState(l),i.forEach((function(e){e.getRenderState&&st({renderState:e.getRenderState(n.renderState[t.getIndexId()]||{},ie(n,t)),instantSearchInstance:n,parent:t})})),i.forEach((function(e){e.render&&e.render(ie(n,t))})))},dispose:function(){var e,t,n=this;i.forEach((function(e){e.dispose&&e.dispose({helper:c,state:c.state,parent:n})})),o=null,s=null,null===(e=c)||void 0===e||e.removeAllListeners(),c=null,null===(t=u)||void 0===t||t.detach(),u=null},getWidgetUiState:function(e){return i.filter(Te).reduce((function(e,t){return t.getWidgetUiState(e)}),qe(qe({},e),{},Ke({},r,qe(qe({},e[r]),a))))},getWidgetState:function(e){return this.getWidgetUiState(e)},getWidgetSearchParameters:function(e,t){var n=t.uiState;return rt(i,{uiState:n,initialSearchParameters:e})},refreshUiState:function(){a=nt(i,{searchParameters:this.getHelper().state,helper:this.getHelper()},a)},setIndexUiState:function(e){var t="function"==typeof e?e(a):e;o.setUiState((function(e){return qe(qe({},e),{},Ke({},r,t))}))}}};function st(e){var t=e.renderState,n=e.instantSearchInstance,r=e.parent,i=r?r.getIndexId():n.mainIndex.getIndexId();n.renderState=qe(qe({},n.renderState),{},Ke({},i,qe(qe({},n.renderState[i]),t)))}var ct=function(e){return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.descendantName,r=t.modifierName,i=n?"-".concat(n):"",a=r?"--".concat(r):"";return"".concat("ais","-").concat(e).concat(i).concat(a)}};function ut(e,t){return(Array.isArray(t)?t:t.split(".")).reduce((function(e,t){return e&&e[t]}),e)}var lt="",ft="",ht=ct("Highlight");function pt(e){var t=lt,n=ft;return e.map((function(e){return e.isHighlighted?t+e.value+n:e.value})).join("")}RegExp(/[&<>"']/g.source);var dt={"&":"&","<":"<",">":">",""":'"',"'":"'"},mt=/&(amp|quot|lt|gt|#39);/g,yt=RegExp(mt.source),vt=new RegExp(/\w/i);function gt(e,t){var n,r,i,a=e[t],o=(null===(n=e[t+1])||void 0===n?void 0:n.isHighlighted)||!0,s=(null===(r=e[t-1])||void 0===r?void 0:r.isHighlighted)||!0;return vt.test((i=a.value)&&yt.test(i)?i.replace(mt,(function(e){return dt[e]})):i)||s!==o?a.isHighlighted:s}function bt(e){return bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},bt(e)}function At(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function It(e){for(var t=1;t')).replace(new RegExp(ft,"g"),""))}(Ht(Ht({},JSON.parse(e)),{},{hit:this})))}catch(e){throw new Error('\nThe highlight helper expects a JSON object of the format:\n{ "attribute": "name", "highlightedTagName": "mark" }')}},reverseHighlight:function(e,t){try{return t(function(e){var t=e.attribute,n=e.highlightedTagName,r=void 0===n?"mark":n,i=e.hit,a=e.cssClasses,o=void 0===a?{}:a,s=(ut(i._highlightResult,t)||{}).value,c=void 0===s?"":s,u=Pt({descendantName:"highlighted"})+(o.highlighted?" ".concat(o.highlighted):"");return pt(St(Rt(c))).replace(new RegExp(lt,"g"),"<".concat(r,' class="').concat(u,'">')).replace(new RegExp(ft,"g"),""))}(Ht(Ht({},JSON.parse(e)),{},{hit:this})))}catch(e){throw new Error('\n The reverseHighlight helper expects a JSON object of the format:\n { "attribute": "name", "highlightedTagName": "mark" }')}},snippet:function(e,t){try{return t(function(e){var t=e.attribute,n=e.highlightedTagName,r=void 0===n?"mark":n,i=e.hit,a=e.cssClasses,o=void 0===a?{}:a,s=(ut(i._snippetResult,t)||{}).value,c=void 0===s?"":s,u=jt({descendantName:"highlighted"})+(o.highlighted?" ".concat(o.highlighted):"");return c.replace(new RegExp(lt,"g"),"<".concat(r,' class="').concat(u,'">')).replace(new RegExp(ft,"g"),""))}(Ht(Ht({},JSON.parse(e)),{},{hit:this})))}catch(e){throw new Error('\nThe snippet helper expects a JSON object of the format:\n{ "attribute": "name", "highlightedTagName": "mark" }')}},reverseSnippet:function(e,t){try{return t(function(e){var t=e.attribute,n=e.highlightedTagName,r=void 0===n?"mark":n,i=e.hit,a=e.cssClasses,o=void 0===a?{}:a,s=(ut(i._snippetResult,t)||{}).value,c=void 0===s?"":s,u=Et({descendantName:"highlighted"})+(o.highlighted?" ".concat(o.highlighted):"");return pt(St(Rt(c))).replace(new RegExp(lt,"g"),"<".concat(r,' class="').concat(u,'">')).replace(new RegExp(ft,"g"),""))}(Ht(Ht({},JSON.parse(e)),{},{hit:this})))}catch(e){throw new Error('\n The reverseSnippet helper expects a JSON object of the format:\n { "attribute": "name", "highlightedTagName": "mark" }')}},insights:function(e,t){try{var n=JSON.parse(e),r=n.method,i=n.payload;return t(function(e,t){return function(e){var t,n=e.method,r=e.payload;if("object"!==Ot(r))throw new Error("The insights helper expects the payload to be an object.");try{t=function(e){return btoa(encodeURIComponent(JSON.stringify(e)))}(r)}catch(e){throw new Error("Could not JSON serialize the payload object.")}return'data-insights-method="'.concat(n,'" data-insights-payload="').concat(t,'"')}({method:e,payload:t})}(r,Ht({objectIDs:[this.objectID]},i)))}catch(e){throw new Error('\nThe insights helper expects a JSON object of the format:\n{ "method": "method-name", "payload": { "eventName": "name of the event" } }')}}}}var Nt=Promise.resolve();function Ct(e){var t=null,n=!1,r=function(){for(var r=arguments.length,i=new Array(r),a=0;a0&&void 0!==arguments[0])||arguments[0];null!==(e=t.mainHelper)&&void 0!==e&&e.hasPendingRequests()||(clearTimeout(t._searchStalledTimer),t._searchStalledTimer=null,n&&(t.status="idle",t.error=void 0)),t.mainIndex.render({instantSearchInstance:Wt(t)}),t.emit("render")}))),Xt(Wt(t),"onInternalStateChange",Ct((function(){var e=t.mainIndex.getWidgetUiState({});t.middleware.forEach((function(t){t.instance.onStateChange({uiState:e})}))}))),t.setMaxListeners(100);var n=e.indexName,r=void 0===n?null:n,i=e.numberLocale,s=e.initialUiState,c=void 0===s?{}:s,u=e.routing,l=void 0===u?null:u,f=e.insights,h=void 0!==f&&f,p=e.searchFunction,d=e.stalledSearchDelay,m=void 0===d?200:d,y=e.searchClient,v=void 0===y?null:y,g=e.insightsClient,b=void 0===g?null:g,A=e.onStateChange,I=void 0===A?null:A;if(null===r)throw new Error(Vt("The `indexName` option is required."));if(null===v)throw new Error(Vt("The `searchClient` option is required."));if("function"!=typeof v.search)throw new Error("The `searchClient` must implement a `search` method.\n\nSee: https://www.algolia.com/doc/guides/building-search-ui/going-further/backend-search/in-depth/backend-instantsearch/js/");if("function"==typeof v.addAlgoliaAgent&&v.addAlgoliaAgent("instantsearch.js (".concat("4.55.0",")")),b&&"function"!=typeof b)throw new Error(Vt("The `insightsClient` option should be a function."));if(t.client=v,t.insightsClient=b,t.indexName=r,t.helper=null,t.mainHelper=null,t.mainIndex=ot({indexName:r}),t.onStateChange=I,t.started=!1,t.templatesConfig={helpers:Mt({numberLocale:i}),compileOptions:{}},t._stalledSearchDelay=m,t._searchStalledTimer=null,t._createURL=Lt,t._initialUiState=c,t._initialResults=null,p&&(t._searchFunction=p),t.sendEventToInsights=W,l){var w="boolean"==typeof l?{}:l;w.$$internal=!0,t.use(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.router,n=void 0===t?pe():t,r=e.stateMapping,i=void 0===r?Ae():r,a=e.$$internal,o=void 0!==a&&a;return function(e){var t=e.instantSearchInstance;t._createURL=function(e){var r=Object.keys(e).reduce((function(t,n){return Pe(Pe({},t),{},je({},n,e[n]))}),t.mainIndex.getWidgetUiState({})),a=i.stateToRoute(r);return n.createURL(a)};var r=void 0,a=t._initialUiState;return{$$type:"ais.router({router:".concat(n.$$type||"__unknown__",", stateMapping:").concat(i.$$type||"__unknown__","})"),$$internal:o,onStateChange:function(e){var t=e.uiState,a=i.stateToRoute(t);void 0!==r&&we(r,a)||(n.write(a),r=a)},subscribe:function(){t._initialUiState=Pe(Pe({},a),i.routeToState(n.read())),n.onUpdate((function(e){t.setUiState(i.routeToState(e))}))},started:function(){var e;null===(e=n.start)||void 0===e||e.call(n)},unsubscribe:function(){n.dispose()}}}}(w))}if(h){var S="boolean"==typeof h?{}:h;S.$$internal=!0,t.use(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.insightsClient,n=e.insightsInitParams,r=e.onEvent,i=e.$$internal,a=void 0!==i&&i,o=t;t||null===t||z((function(e){var t=e.window,n=t.AlgoliaAnalyticsObject||"aa";"string"==typeof n&&(o=t[n]),o||(t.AlgoliaAnalyticsObject=n,t[n]||(t[n]=function(){t[n].queue||(t[n].queue=[]);for(var e=arguments.length,r=new Array(e),i=0;i-1}),{fallback:function(){return!1}})&&t.use(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.$$internal,n=void 0!==t&&t;return function(e){var t=e.instantSearchInstance,r={widgets:[]},i=document.createElement("meta"),a=document.querySelector("head");return i.name="instantsearch:widgets",{$$type:"ais.metadata",$$internal:n,onStateChange:function(){},subscribe:function(){setTimeout((function(){var e=t.client;r.ua=e.transporter&&e.transporter.userAgent?e.transporter.userAgent.value:e._ua,ae(t.mainIndex.getWidgets(),t,r),t.middleware.forEach((function(e){return r.widgets.push({middleware:!0,type:e.instance.$$type,internal:e.instance.$$internal})})),i.content=JSON.stringify(r),a.appendChild(i)}),0)},started:function(){},unsubscribe:function(){i.remove()}}}}({$$internal:!0})),t}return t=o,n=[{key:"_isSearchStalled",get:function(){return"stalled"===this.status}},{key:"use",value:function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r0&&this.scheduleSearch();this.helper=this.mainIndex.getHelper(),this.started=!0,this.middleware.forEach((function(e){e.instance.started()}))}},{key:"dispose",value:function(){var e;this.scheduleSearch.cancel(),this.scheduleRender.cancel(),clearTimeout(this._searchStalledTimer),this.removeWidgets(this.mainIndex.getWidgets()),this.mainIndex.dispose(),this.started=!1,this.removeAllListeners(),null===(e=this.mainHelper)||void 0===e||e.removeAllListeners(),this.mainHelper=null,this.helper=null,this.middleware.forEach((function(e){e.instance.unsubscribe()}))}},{key:"scheduleStalledRender",value:function(){var e=this;this._searchStalledTimer||(this._searchStalledTimer=setTimeout((function(){e.status="stalled",e.scheduleRender()}),this._stalledSearchDelay))}},{key:"setUiState",value:function(e){var t=this,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!this.mainHelper)throw new Error(Vt("The `start` method needs to be called before `setUiState`."));this.mainIndex.refreshUiState();var r="function"==typeof e?e(this.mainIndex.getWidgetUiState({})):e;this.onStateChange&&n?this.onStateChange({uiState:r,setUiState:function(e){Ut("function"==typeof e?e(r):e,t.mainIndex),t.scheduleSearch(),t.onInternalStateChange()}}):(Ut(r,this.mainIndex),this.scheduleSearch(),this.onInternalStateChange())}},{key:"getUiState",value:function(){return this.started&&this.mainIndex.refreshUiState(),this.mainIndex.getWidgetUiState({})}},{key:"createURL",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.started)throw new Error(Vt("The `start` method needs to be called before `createURL`."));return this._createURL(e)}},{key:"refresh",value:function(){if(!this.mainHelper)throw new Error(Vt("The `start` method needs to be called before `refresh`."));this.mainHelper.clearCache().search()}}],n&&Bt(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),o}(D),qt=Yt,Kt=n(1688),_t=(0,x.createContext)(null);function $t(){return(0,x.useContext)(_t)}var en=(0,x.createContext)(null),tn="6.38.1";function nn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}(e,cn));return n.started?x.createElement(Z.Provider,{value:n},x.createElement(U.Provider,{value:n.mainIndex},t)):null}var ln=n(8499),fn=window.lodash;function hn(e,t){if(void 0===e||"function"!=typeof e)throw new Error("The render function is not valid (received type ".concat((n=e,Object.prototype.toString.call(n).slice(8,-1)),").\n\n").concat(t));var n}function pn(e){return pn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},pn(e)}function dn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function mn(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:W;return hn(e,vn()),function(n){var r,i,a=(n||{}).queryHook,o=void 0===a?gn:a;return{$$type:"ais.searchBox",init:function(t){var n=t.instantSearchInstance;e(mn(mn({},this.getWidgetRenderState(t)),{},{instantSearchInstance:n}),!0)},render:function(t){var n=t.instantSearchInstance;e(mn(mn({},this.getWidgetRenderState(t)),{},{instantSearchInstance:n}),!1)},dispose:function(e){var n=e.state;return t(),n.setQueryParameter("query",void 0)},getRenderState:function(e,t){return mn(mn({},e),{},{searchBox:this.getWidgetRenderState(t)})},getWidgetRenderState:function(e){var t=e.helper,a=e.searchMetadata,s=e.state;return r||(r=function(e){o(e,(function(e){return t.setQuery(e).search()}))},i=function(){t.setQuery("").search()}),{query:s.query||"",refine:r,clear:i,widgetParams:n,isSearchStalled:a.isSearchStalled}},getWidgetUiState:function(e,t){var n=t.searchParameters.query||"";return""===n||e&&e.query===n?e:mn(mn({},e),{},{query:n})},getWidgetSearchParameters:function(e,t){var n=t.uiState;return e.setQueryParameter("query",n.query||"")}}}};function An(e){return An="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},An(e)}var In=Object.prototype.hasOwnProperty;function wn(e,t,n){if(null!=n&&n(e,t))return!0;var r,i;if(e===t)return!0;if(e&&t&&(r=e.constructor)===t.constructor){if(r===Date)return e.getTime()===t.getTime();if(r===RegExp)return e.toString()===t.toString();if(r===Array){if((i=e.length)===t.length)for(;i--&&wn(e[i],t[i],n););return-1===i}if(!r||"object"===An(e)){for(r in i=0,e){if(In.call(e,r)&&++i&&!In.call(t,r))return!1;if(!(r in t)||!wn(e[r],t[r],n))return!1}return Object.keys(t).length===i}}return e!=e&&t!=t}function Sn(e){var t,n,r;return new F.SearchResults(e,[{query:null!==(t=e.query)&&void 0!==t?t:"",page:null!==(n=e.page)&&void 0!==n?n:0,hitsPerPage:null!==(r=e.hitsPerPage)&&void 0!==r?r:20,hits:[],nbHits:0,nbPages:0,params:"",exhaustiveNbHits:!0,exhaustiveFacetsCount:!0,processingTimeMS:0,index:e.index}],{__isArtificial:!0})}function Rn(e){return Rn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Rn(e)}function Pn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function jn(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Xn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne.length)&&(t=e.length);for(var n=0,r=new Array(t);nR()({path:Yn+"/search",method:"POST",data:{user_prompt:e,identifier:t,extra:n}}),getDefaultSearchResult:()=>R()({path:Yn+"/search/default",method:"POST"})};function er(){return er=Object.assign?Object.assign.bind():function(e){for(var t=1;t(0,i.createElement)(i.Fragment,null,(0,i.createElement)("div",{className:"algoliaResult",onClick:t},(0,i.createElement)("p",null,e),(0,i.createElement)("div",{className:"svg"},(0,i.createElement)(rr,null)))),ar="nfd-help-center/v1",or={updateHelpVisible:e=>{localStorage.setItem("helpVisible",e?"true":"false")},getHelpVisible:()=>"true"===localStorage.getItem("helpVisible"),persistResult:(e,t)=>{localStorage.setItem("helpResultContent",e),localStorage.setItem("helpPostId",t)},persistSearchInput:e=>{localStorage.setItem("searchInput",e)},clear:()=>{localStorage.removeItem("helpResultContent"),localStorage.removeItem("helpPostId"),localStorage.removeItem("searchInput")},getResultInfo:()=>({content:localStorage.getItem("helpResultContent"),postId:localStorage.getItem("helpPostId")}),getSearchInput:()=>localStorage.getItem("searchInput"),getFeatureFlag(e){return localStorage.getItem(e)},setFeatureFlag(e,t){localStorage.setItem(e,t)}},sr=(e,t)=>{const n=new c("wonder_help",e,t,"wonder_help");j(n)};var cr,ur,lr=({postId:e,source:t})=>{const[n,r]=(0,i.useState)(""),a=(0,i.useRef)(null),o=(0,i.useRef)(null);return(0,i.useEffect)((()=>{r(""),o.current.className="feedback-button no",a.current.className="feedback-button yes"}),[e]),(0,i.useEffect)((()=>{(async()=>{"helpful"!==n&&"notHelpful"!==n||(((e,t)=>{R()({path:ar+"/feedback",method:"POST",data:{post_id:e,status:t}})})(e,n),sr("help_feedback_submitted",{label_key:"type",type:"helpful"===n?"positive":"negative",source:t,post_id:e,page:window.location.href.toString()}))})(),"helpful"===n&&(a.current.className="feedback-button yes selected-yes",o.current.className="feedback-button no"),"notHelpful"===n&&(o.current.className="feedback-button no selected-no",a.current.className="feedback-button yes")}),[n]),(0,i.createElement)("div",{className:"feedback-container"},(0,i.createElement)("div",{className:"feedback-question"},(0,i.createElement)("p",null,(0,i.createElement)("b",null,(0,T.__)("Did this result help you?","wp-module-help-center")))),(0,i.createElement)("div",{className:"icon"},(0,i.createElement)("button",{ref:a,onClick:()=>{r("helpful")},className:"feedback-button yes"},"helpful"===n&&(0,i.createElement)(i.Fragment,null,"🥳")," ",(0,T.__)("Yes","wp-module-help-center")),(0,i.createElement)("button",{onClick:()=>{r("notHelpful")},ref:o,className:"feedback-button no"},"notHelpful"===n&&(0,i.createElement)(i.Fragment,null,"😭")," ",(0,T.__)("No","wp-module-help-center"))))};function fr(){return fr=Object.assign?Object.assign.bind():function(e){for(var t=1;t{if(window?.nfdHelpCenter?.resourceLink)return(0,i.createElement)("p",null,(0,T.__)("In the meantime, try searching our","wp-module-help-center")," ",(0,i.createElement)("a",{href:window?.nfdHelpCenter?.resourceLink},(0,T.__)("Resource center.","wp-module-help-center")))},dr=()=>(0,i.createElement)("div",null,(0,i.createElement)("p",null,(0,T.__)("Result based on your search:","wp-module-help-center")),(0,i.createElement)("h4",null,(0,T.__)("Sorry, we don't have any content for that yet.","wp-module-help-center")),(0,i.createElement)("hr",null),(0,i.createElement)(hr,null),(0,i.createElement)("p",null,(0,T.__)("This tool is being built and doesn't always have a match.","wp-module-help-center")),(0,i.createElement)(pr,null),(0,i.createElement)("hr",null));const mr=({content:e,noResult:t,postId:n,source:r,showFeedbackSection:a})=>t?(0,i.createElement)(dr,null):e&&e.length>0?(0,i.createElement)(i.Fragment,null,(0,i.createElement)("h4",null,(0,T.__)("Follow these steps:","wp-module-help-center")),(0,i.createElement)("p",{dangerouslySetInnerHTML:{__html:e}}),a&&e&&e.length>0&&(0,i.createElement)(lr,{postId:n,source:r})):(0,i.createElement)(i.Fragment,null);var yr,vr,gr,br,Ar,Ir;function wr(){return wr=Object.assign?Object.assign.bind():function(e){for(var t=1;t(0,i.createElement)(i.Fragment,null,(0,i.createElement)(Rr,null)," ",(0,i.createElement)(Rr,null)," ",(0,i.createElement)(Rr,null)),jr=e=>{const[t,n]=(0,i.useState)(!1),[r,a]=(0,i.useState)(!1),[o,s]=(0,i.useState)(""),[c,u]=(0,i.useState)(""),[l,f]=(0,i.useState)(),[h,p]=(0,i.useState)("kb"),{refine:d,clear:m}=function(e,t){return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=$t(),i=Hn(),a=xn(),o=Mn(t),s=Mn(n),c=(0,x.useRef)(!0),u=(0,x.useRef)(null),l=(0,x.useMemo)((function(){return zn(zn({},e((function(e,t){if(t)c.current=!0;else if(c.current){e.instantSearchInstance,e.widgetParams;var n=Qn(e,Zn);wn(n,u.current,(function(e,t){return(null==e?void 0:e.constructor)===Function&&(null==t?void 0:t.constructor)===Function}))||(d(n),u.current=n)}}),(function(){c.current=!1}))(o)),s)}),[e,o,s]),f=(0,x.useState)((function(){if(l.getWidgetRenderState){var e,t=a.getHelper(),n=a.getWidgetUiState({})[a.getIndexId()];t.state=(null===(e=l.getWidgetSearchParameters)||void 0===e?void 0:e.call(l,t.state,{uiState:n}))||t.state;var r=On(a),o=r.results,s=r.scopedResults,c=l.getWidgetRenderState({helper:t,parent:a,instantSearchInstance:i,results:o,scopedResults:s,state:t.state,renderState:i.renderState,templatesConfig:i.templatesConfig,createURL:a.createURL,searchMetadata:{isSearchStalled:"stalled"===i.status},status:i.status,error:i.error});return c.widgetParams,Qn(c,Dn)}return{}})),h=Fn(f,2),p=h[0],d=h[1];return Cn({widget:l,parentIndex:a,props:o,shouldSsr:Boolean(r)}),p}(bn,e,t)}(),{results:y}=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.catchError,n=Hn(),r=Ln(),i=r.uiState,a=r.setUiState,o=r.indexUiState,s=r.setIndexUiState,c=Jn(),u=c.results,l=c.scopedResults,f=(0,x.useCallback)((function(){for(var e=arguments.length,t=new Array(e),r=0;r{const r=e.replace(/\n/g,"
");u(r),f(t),or.persistResult(r,t),or.persistSearchInput(n),t&&sr("help_search",{label_key:"term",term:n,page:window.location.href.toString()})};(0,i.useEffect)((()=>{s(""),u(""),d("")}),[e.refresh]),(0,i.useEffect)((()=>{const{content:e,postId:t}=or.getResultInfo();e&&u(e),t&&f(t);const n=or.getSearchInput();n&&(s(n),d(n))}),[]);const g=(0,i.useMemo)((()=>(0,fn.debounce)((function(e){e&&0===e.length&&m(),d(e)}),300)),[]);return(0,i.useEffect)((()=>{g.cancel()}),[]),t?(0,i.createElement)(i.Fragment,null,(0,i.createElement)(Pr,null)):(0,i.createElement)(i.Fragment,null,(0,i.createElement)("div",{className:"search-container"},(0,i.createElement)("button",{onClick:()=>{document.getElementById("search-input-box").focus()}},(0,i.createElement)(tr,null)),(0,i.createElement)("input",{type:"text",id:"search-input-box",style:{flexGrow:2},value:o,maxLength:"144",placeholder:(0,T.__)("Ask me anything…","wp-module-help-center"),onChange:e=>{s(e.target.value),v("",void 0,e.target.value),a(!1),g(e.target.value)},onKeyDown:async e=>{"Enter"===e.key&&await(async()=>{n(!0);try{const e=y.hits;if(e.length>0&&((e,t,n)=>{const r=t/e.split(/\s+/).length;return n>=1&&r>=.99})(o,e[0].text_match_info.tokens_matched,e[0].text_match_info.fields_matched))return void v(e[0].post_content,e[0].post_id,o);p("ai");const t=await $n.getSearchResult(o,"helpcenter");v(t.result[0].text,t.post_id,o)}catch(e){a(!0)}finally{n(!1)}})()}})),(0,i.createElement)("div",{className:"attribute"},(0,i.createElement)("p",null,(0,i.createElement)("span",null,o?o.length:0,"/144"))),(0,i.createElement)(mr,{content:c,noResult:r,postId:l,source:h,showFeedbackSection:!c.includes("do not possess the answer")}),y.hits.length>0&&(0,i.createElement)("p",null,(0,i.createElement)("b",null,c.length>0?(0,T.__)("Other Resources","wp-module-help-center"):(0,T.__)("Search Suggestions","wp-module-help-center"))),y.hits.map(((e,t)=>{const n=document.createElement("span");n.setAttribute("display","none"),n.innerHTML=e.post_title;const r=n.textContent||n.innerText;return(0,i.createElement)(i.Fragment,null,(0,i.createElement)(ir,{key:t,searchTitle:r,onGo:()=>{s(r),v(e.post_content,e.post_id,r)}}))})))},Er=e=>{const t=new ln.Z({server:{apiKey:"B9wvYIokTPPgXEM3isTqsxbDOva21igT",nodes:[{host:"search.hiive.cloud",port:443,protocol:"https"}]},additionalSearchParameters:{query_by:"post_title,post_content",sort_by:"post_likes:desc",filter_by:`post_category:=${e.brand}`,limit_hits:3,per_page:3}}).searchClient,[n,r]=(0,i.useState)(!1),[a,o]=(0,i.useState)(!1);return(0,i.useEffect)((()=>{(async()=>{try{const e=await R()({path:ar+"/capability",method:"GET"});o(e)}catch(e){o(!1)}})()}),[]),(0,i.useEffect)((()=>{const e=()=>{r(or.getHelpVisible())};return window.addEventListener("storage",e),()=>{window.removeEventListener("storage",e)}}),[]),a&&n?(0,i.createElement)("div",{className:"nfd-help-center"},(0,i.createElement)(un,{searchClient:t,indexName:"nfd_help_articles"},(0,i.createElement)(jr,{refresh:e.refresh}))):(0,i.createElement)(i.Fragment,null)},Or=({onClose:e})=>{const[t,n]=(0,i.useState)("");(0,i.useEffect)((()=>{const e=or.getHelpVisible();kr(e),(async()=>{const e=await R()({path:ar+"/capability/brand",method:"GET"});n(e.toLowerCase())})()}),[]);const[r,a]=(0,i.useState)(!1);return(0,i.createElement)("div",{className:"modal"},(0,i.createElement)("div",{className:"modal-header"},(0,i.createElement)("h3",{className:"heading"},(0,i.createElement)("span",{className:"icon"},(0,i.createElement)(C,null)),(0,T.__)("Help Center","wp-module-help-center")),(0,i.createElement)("button",{className:"close-button",onClick:()=>{e(),a(!r)}},(0,i.createElement)("div",{className:"icon-button"},(0,i.createElement)(M,null)))),(0,i.createElement)(Er,{closeHelp:()=>{e(),a(!r)},refresh:r,brand:t}))};function Tr(){return Tr=Object.assign?Object.assign.bind():function(e){for(var t=1;t{window?.nfdHelpCenter?.restUrl&&(async({namespace:e,urls:{single:t,batch:n}={},settings:{debounce:{time:r}={},queue:{threshold:i=100}={}}={}})=>{!e||!P(e)&&(!t&&!n||((0,a.dispatch)(w).initializeNamespace(e),(0,a.dispatch)(w).updateHiiveUrls({single:t,batch:n},e),(0,a.dispatch)(w).updateHiiveDebounceTime(r,e),(0,a.dispatch)(w).updateHiiveEventsQueueThreshold(i,e),window.nfdUIAnalytics?.hiive?window.nfdUIAnalytics.hiive[e]=!0:window.nfdUIAnalytics={hiive:{[e]:!0}}))})({namespace:"wonder_help",urls:{single:window.nfdHelpCenter.restUrl+"/newfold-data/v1/events"}}),(async()=>{const e=new URL(document.location).searchParams.get("referrer");e&&"nfd-onboarding"===e.toString()&&"1"===(await R()({path:"newfold-onboarding/v1/flow",method:"GET"})).data.wpComfortLevel&&kr(!0)})()}));const Hr=document.getElementById("wpcontent"),kr=e=>{Hr.classList.toggle("wpcontent-container",e),document.getElementById("nfd-help-center").classList.toggle("help-container",e),or.updateHelpVisible(e),window.dispatchEvent(new Event("storage"))};window.newfoldEmbeddedHelp={toggleNFDLaunchedEmbeddedHelp:()=>{(()=>{const e=or.getHelpVisible();if(Object.is(e,void 0))return kr(!0),void sr("help_sidebar_opened",{page:window.location.href.toString()});e||sr("help_sidebar_opened",{page:window.location.href.toString()}),kr(!e)})()},renderEmbeddedHelp:()=>{const e=document.createElement("div");e.id="nfd-help-center",e.style.display="none",Hr.appendChild(e);const t=document.getElementById("nfd-help-center");null!==t&&("undefined"!==i.createRoot?(0,i.createRoot)(t).render((0,i.createElement)(Or,{onClose:()=>{kr(!1),or.clear()}})):"undefined"!==i.render&&(0,i.render)((0,i.createElement)(Or,{onClose:()=>{kr(!1),or.clear()}}),t))}};const Mr=(0,a.subscribe)((()=>{document.getElementById("nfd-help-menu-button-wrapper")?Mr():s()((()=>{const e=document.querySelector(".edit-post-header__settings");if(!e)return;const t=document.createElement("div");t.id="nfd-help-menu-button-wrapper",t.classList.add("nfd-help-menu-button-wrapper");const n=e.querySelector(".components-dropdown-menu.interface-more-menu-dropdown");n?e.insertBefore(t,n):e.appendChild(t);const r=(0,i.createElement)("button",{className:"components-button has-icon",onClick:()=>{window.newfoldEmbeddedHelp.toggleNFDLaunchedEmbeddedHelp()}},(0,i.createElement)(xr,null));(0,i.render)(r,document.getElementById("nfd-help-menu-button-wrapper"))}))}));if(window.newfoldEmbeddedHelp.renderEmbeddedHelp(),"enabled"===or.getFeatureFlag("featureFlag_newfoldLaunchHelpCenter")){function Nr(e){if(e.innerText.trim())return e.innerText;for(const t of e.childNodes)if(t.nodeType===Node.ELEMENT_NODE){const e=Nr(t);if(e)return e}return null}window.newfoldEmbeddedHelp.launchNFDEmbeddedHelpQuery=function(e,t){"true"!==or.getHelpVisible()&&t&&kr(!0);const n=document.getElementById("nfd-help-center");let r=0;const i=setInterval((()=>{if(r++,n&&(e=>{const t=window.getComputedStyle(e);return"none"!==t.display&&"hidden"!==t.visibility})(n)){const t=document.getElementById("search-input-box");setTimeout((()=>{t.value=e,t.focus()}),500),clearInterval(i)}else r>=5&&clearInterval(i)}),300)},document.addEventListener("click",(e=>{const t=e.target.closest("[data-openNfdHelpCenter]");if(t){const e=Nr(t);e&&window.newfoldEmbeddedHelp.launchNFDEmbeddedHelpQuery(e,!0)}}))}}()}(); \ No newline at end of file