@nosto/search-js 1.7.1 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/preact/preact.cjs.js +1 -1
- package/dist/preact/preact.d.ts +3 -1
- package/dist/preact/preact.es.js +318 -332
- package/dist/preact/src/components/InfiniteScroll/InfiniteScrollWithLink.d.ts +21 -0
- package/dist/utils/utils.cjs.js +1 -0
- package/dist/utils/utils.d.ts +2 -0
- package/dist/utils/utils.es.js +20 -0
- package/package.json +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("preact"),p=require("preact/hooks"),re=require("../search-BVJZK90N.cjs"),E=require("../index.es-DlUp67LT.cjs");var ne=" daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|\\||^<|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\(compatible;?(?:\\s\\w+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|adscanner/|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|cookiehubscan|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|jsjcw_scanner|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|retriever|rexx;|rigor|rss\\b|scanner\\.|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|zgrab",oe=/bot|crawl|http|lighthouse|scan|search|spider/i,z;function se(){if(z instanceof RegExp)return z;try{z=new RegExp(ne,"i")}catch{z=oe}return z}function ae(e){return!!e&&se().test(e)}function Q(){return ae(navigator.userAgent)}var ce=0;function w(e,r,t,n,o,c){r||(r={});var s,a,l=r;if("ref"in l)for(a in l={},r)a=="ref"?s=r[a]:l[a]=r[a];var i={type:e,props:l,key:t,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ce,__i:-1,__u:0,__source:o,__self:c};if(typeof e=="function"&&(s=e.defaultProps))for(a in s)l[a]===void 0&&(l[a]=s[a]);return P.options.vnode&&P.options.vnode(i),i}const L=e=>String(e)==="[object Object]";function F(e){if(!L(e))return!1;const r=e.constructor;if(r===void 0)return!0;const t=r.prototype;return!(!L(t)||!t.hasOwnProperty("isPrototypeOf"))}function T(...e){return e.reduce((r,t)=>O(r,t))}function B(...e){return e.reduce((r,t)=>O(r,t))}function O(e,r){return F(e)&&F(r)?Object.entries(r).reduce((t,[n,o])=>(t[n]=O(t[n],o),t),{...e}):F(e)?e:r}function R(e,r){if(e===r)return!0;if(e instanceof Date&&r instanceof Date)return e.getTime()===r.getTime();if(Array.isArray(e)&&Array.isArray(r))return e.length!==r.length?!1:e.every((t,n)=>R(t,r[n]));if(F(e)&&F(r)){const t=Object.entries(e);return t.length!==Object.keys(r).length?!1:t.every(([n,o])=>R(o,r[n]))}return!1}function K(e,r={}){const t=new Map;let n=B(e,r??{});const o=B(e,r);function c(u){n=u(n);for(const f of t.values())f(n)}function s(u){c(f=>({...f,...u}))}function a(){return n}function l(){return structuredClone(o)}function i(u,f){let m;t.set(f,g=>{const y=u(g);R(y,m)||(m=y,f(y))})}function d(u){t.delete(u)}return{updateState:s,getState:a,getInitialState:l,onChange:i,clearOnChange:d}}const H={loading:!0,query:{},response:{},initialized:!1};function A(e={}){return K(H,e)}const M=P.createContext(A());function v(e=ie){const r=p.useContext(M),[t,n]=p.useState(e(r.getState()));return r.onChange(e,n),p.useEffect(()=>()=>r.clearOnChange(n),[r]),t}const ie=e=>e;function W(e,...r){return r.reduce((t,n)=>(t[n]=e[n],t),{})}const I=P.createContext(null),G=()=>{const e=p.useContext(I);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};function ue(e){return Array.from(new Set(e))}function le(e,r){return{...r,products:{facets:e==="autocomplete"?void 0:["*"],fields:de,...r.products},...r.keywords?{keywords:{...r.keywords,fields:ue([...fe,...r.keywords.fields??[]]),highlight:r.keywords.highlight??{preTag:"<strong>",postTag:"</strong>"}}}:{}}}const de=["productId","url","name","imageUrl","imageHash","thumbUrl","description","brand","variantId","availability","price","priceText","categoryIds","categories","customFields.key","customFields.value","priceCurrencyCode","datePublished","listPrice","unitPricingBaseMeasure","unitPricingUnit","unitPricingMeasure","googleCategory","gtin","ageGroup","gender","condition","alternateImageUrls","ratingValue","reviewCount","inventoryLevel","skus.id","skus.name","skus.price","skus.listPrice","skus.priceText","skus.url","skus.imageUrl","skus.inventoryLevel","skus.customFields.key","skus.customFields.value","skus.availability","pid","onDiscount","extra.key","extra.value","saleable","available","tags1","tags2","tags3"],fe=["keyword","_redirect"];function pe(...e){if(!e.every(r=>r==null))return e.filter(r=>Array.isArray(r)).reduce((r,t)=>r.concat(t),[])}const J="nosto.search.";function ge(e){var t;const r=`${J}${e}`;(t=window.performance)==null||t.mark(`${r}.start`)}function he(e){var t,n;const r=`${J}${e}`;(t=window.performance)==null||t.mark(`${r}.end`),(n=window.performance)==null||n.measure(r,`${r}.start`,`${r}.end`)}function _(e){return ge(e),()=>he(e)}function me(e,r,t){const n=JSON.stringify(r);try{console.info("Setting storage",e,n),t.setItem(e,n)}catch(o){console.warn(o)}}function ye(e,r){try{const t=r.getItem(e);if(t)return JSON.parse(t)}catch(t){console.warn(t)}}function ve(e,r){me(e,r,sessionStorage)}function Se(e){return ye(e,sessionStorage)}const Y="nosto:search:searchResult";function we(e,r,t){if(!e)return;ve(Y,{query:r,result:t})}function be(e,r){if(!e)return null;const t=Se(Y);if(!t||!ke(t))return null;const n=U(t.query);return R(U(r),n)?t.result:null}function U(e){return{accountId:e.accountId,customRules:e.customRules,explain:e.explain,keywords:e.keywords,products:e.products,query:e.query,redirect:e.redirect,rules:e.rules,segments:e.segments,sessionParams:e.sessionParams}}function ke(e){return typeof e=="object"&&e!==null&&"query"in e&&"result"in e}async function X(e,r,t){var i,d,u;const n=_("newSearch"),o=e.config.pageType,c=T(e.store.getInitialState().query,r),s=T(e.config.search,t,{track:o,redirect:o!=="autocomplete",isKeyword:!!(t!=null&&t.isKeyword)});e.store.updateState({query:c,loading:!0,initialized:!0});const a=o!=="autocomplete"&&e.config.persistentSearchCache,l=e.config.queryModifications({...c,products:{...c.products,filter:pe((d=(i=e.store.getInitialState().query)==null?void 0:i.products)==null?void 0:d.filter,(u=r.products)==null?void 0:u.filter)}},o);try{let f;const m=be(a,l);if(m)f=m;else{const g=le(o,l);f=await re.search(g,s),we(a,l,f)}e.store.updateState({response:f,loading:!1})}catch(f){console.error("Search action failed",f)}n()}async function q(e,r,t){const n=_("updateSearch"),o=T(e.store.getState().query,{products:{from:0}},r);await X(e,o,t),n()}async function Ce(e,r,t){var s;const n=_("replaceFilter"),o=(s=e.store.getState().query.products)==null?void 0:s.filter,c=t!==void 0?[{field:r,[typeof t=="object"?"range":"value"]:[t]}]:[];await q(e,{products:{filter:[...(o==null?void 0:o.filter(a=>a.field!==r))??[],...c]}}),n()}async function Pe(e,r,t,n){var l,i;const o=_("toggleProductFilter"),c=(l=e.store.getState().query.products)==null?void 0:l.filter,s=c==null?void 0:c.find(d=>d.value instanceof Array&&d.field===r),a=s!=null&&s.value?{...s,value:[...s.value.filter(d=>!R(d,t)),...n?[t]:[]]}:n?{field:r,value:[t]}:void 0;await q(e,{products:{filter:[...(c==null?void 0:c.filter(d=>d!==s))??[],...(i=a==null?void 0:a.value)!=null&&i.length?[a]:[]]}}),o()}function k(){const e=G(),r=p.useContext(M),t=p.useMemo(()=>({config:e,store:r}),[e,r]),n=p.useCallback((a,l)=>X(t,a,l),[t]),o=p.useCallback((a,l)=>q(t,a,l),[t]),c=p.useCallback((a,l,i)=>Pe(t,a,l,i),[t]),s=p.useCallback((a,l)=>Ce(t,a,l),[t]);return{newSearch:n,updateSearch:o,toggleProductFilter:c,replaceFilter:s}}function Fe({from:e,size:r,pageSize:t}){return Q()?{products:{from:e+t}}:{products:{size:r+t}}}function j(e=24){const{from:r,size:t}=v(c=>{var s,a;return{from:((s=c.query.products)==null?void 0:s.from)??0,size:((a=c.query.products)==null?void 0:a.size)??0}}),{updateSearch:n}=k();return{loadMore:p.useCallback(async()=>{await n(Fe({from:r,size:t,pageSize:e}))},[r,t,e,n])}}function Me({pageSize:e}){const{loadMore:r}=j(e);return w("button",{onClick:r,children:"More results"})}function Z(e,r){var c,s,a;const t=((c=r.products)==null?void 0:c.total)??0,n=((s=e.products)==null?void 0:s.from)??0,o=((a=e.products)==null?void 0:a.size)??0;return t>0&&t>n+o}function ze(){return!!(window.IntersectionObserver&&window.IntersectionObserverEntry&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)}function Re({children:e,loadMoreComponent:r,pageSize:t}){const{loading:n,query:o,response:c}=v(a=>W(a,"loading","query","response")),s=!n&&Z(o,c);return w(P.Fragment,{children:[e,s&&(r?w(r,{pageSize:t}):w(Me,{pageSize:t}))]})}function Ae({children:e,pageSize:r}){const t=p.useRef(null),{query:n,response:o}=v(s=>W(s,"query","response")),{loadMore:c}=j(r);return p.useEffect(()=>{let s,a;return Z(n,o)&&(s=t.current,a=new IntersectionObserver(l=>{const i=l[0];i!=null&&i.isIntersecting&&c()}),s&&a.observe(s)),()=>{s&&a.unobserve(s)}},[o]),w(P.Fragment,{children:[e,w("div",{ref:t,style:{height:"1px"}})]})}const xe=!Q()&&ze()?Ae:Re;function Ie(e){return e.type==="input"}function _e(e){return!!e&&typeof e=="object"&&"type"in e&&"props"in e}function $(e,r={depth:0}){const{children:t}=e;return P.toChildArray(t).map(n=>{if(!_e(n))return n;const o=e.updateElement(n,r);return o===null?null:(o.props={...o.props,children:$({...e,children:o.props.children},{depth:r.depth+1})},o)})}function Ne({children:e,onSearchInput:r}){return $({children:e,updateElement:t=>(!Ie(t)||t.props.type!=="search"||(t.props={...t.props,onInput:n=>{n.target instanceof HTMLInputElement&&r(n.target)}}),t)})}const Te="nosto:search:scrollPos";function Ee(){window.sessionStorage.setItem(Te,window.scrollY.toString())}function Oe({children:e,hit:r,onClick:t}){const{pageType:n}=G(),o=n==="autocomplete"?void 0:n;return $({children:e,updateElement:(c,s)=>(s.depth>0||(c.props={...c.props,onClick:a=>{r&&o&&E.s(l=>l.recordSearchClick(o,r)),Ee(),typeof t=="function"&&t(a)}}),c)})}function V(){p.useEffect(()=>{const e=window.setTimeout(()=>{console.error("Nosto client script has not loaded after 3 seconds.")},3e3);E.s(()=>{window.clearTimeout(e)})},[])}const D={defaultCurrency:"EUR",queryModifications:e=>e},qe={...D};function je(e){return{pageType:"autocomplete",...qe,...e}}function $e({config:e,store:r,children:t}){const n=r??A();return V(),w(I,{value:je(e),children:w(M,{value:n,children:t})})}const Ve={...D,persistentSearchCache:!1,preservePageScroll:!1};function De(e){return{pageType:"category",...Ve,...e}}function Le({config:e,store:r,children:t}){const n=r??A();return V(),w(I,{value:De(e),children:w(M,{value:n,children:t})})}const Be={...D,persistentSearchCache:!1,preservePageScroll:!1};function Ue(e={}){return{pageType:"serp",...Be,...e}}function Qe({config:e,store:r,children:t}){const n=r??A();return V(),w(I,{value:Ue(e),children:w(M,{value:n,children:t})})}function Ke(e){const r=v(t=>t.response);return e&&Array.isArray(e)||e&&F(e)?e:r}function He(e){var s;const r=((s=e.data)==null?void 0:s.filter(a=>a.selected).length)??0,[t,n]=p.useState(r>0),{toggleProductFilter:o}=k();return{active:t,selectedFiltersCount:r,toggleActive:()=>{n(!t)},toggleProductFilter:o}}function We(){const{loading:e,facets:r}=v(t=>{var n,o;return{loading:t.loading,facets:((o=(n=t.response)==null?void 0:n.products)==null?void 0:o.facets)??[]}});return{loading:e,facets:r}}function Ge(e,r){const t=r-e;return!isNaN(t)&&t>0?new Array(r-e).fill(void 0).map((n,o)=>o+e):[]}function Je(e){const{query:r,products:t}=v(n=>({query:n.query,products:n.response.products}));return p.useMemo(()=>{var C;if(!t)return{totalPages:0,resultsFrom:0,resultsTo:0,pages:[]};const n=((C=r.products)==null?void 0:C.from)??0,o=(e==null?void 0:e.width)??1/0,c=Math.max(Math.floor(o-1)/2,1),s=t.size>0?Math.floor(n/t.size)+1:1,a=t.size>0?Math.ceil(t.total/t.size):0,l=b=>b>=s-c&&b<=s+c,i=n+1,d=Math.min(n+t.total,t.total),u={from:n,page:s,current:!0},f=b=>({from:(b-1)*t.size,page:b,current:b===s}),m=s>1?f(s-1):void 0,g=s<a?f(s+1):void 0,y=c===1/0||s-c-1>1?f(1):void 0,h=c===1/0||s+c+1<a?f(a):void 0,S=Ge(1,a+1).filter(l).map(f);return{totalPages:a,resultsFrom:i,resultsTo:d,current:u,prev:m,next:g,first:y,last:h,pages:S}},[r,t,e==null?void 0:e.width])}function Ye(){const[e,r]=p.useState([]),[t,n]=p.useState([]);return p.useEffect(()=>{E.s(async o=>{const{products:c,segments:s}=await o.getSearchSessionParams();r(s??[]),n((c==null?void 0:c.personalizationBoost)??[])})},[]),{segments:e,boost:t}}function Xe(){const{facets:e}=v(i=>{var d;return{facets:((d=i.response.products)==null?void 0:d.facets)??[]}}),{replaceFilter:r,toggleProductFilter:t}=k(),n=p.useCallback(i=>{const d=e==null?void 0:e.find(u=>u.type==="stats"&&u.field===i);if(d&&"min"in d&&"max"in d)return d},[e]),o=p.useCallback(i=>{var d;return((d=e==null?void 0:e.find(u=>u.field===i))==null?void 0:d.name)??i},[e]),c=p.useCallback(i=>"field"in i&&(i.value instanceof Array||i.range instanceof Array),[]),s=p.useCallback(i=>{var d;return{...i,range:(d=i.range)==null?void 0:d.map(u=>({gt:u.gt?Number(u.gt):u.gt,gte:u.gte?Number(u.gte):u.gte,lt:u.lt?Number(u.lt):u.lt,lte:u.lte?Number(u.lte):u.lte}))}},[]),a=p.useCallback(i=>(i.value??[]).map(u=>({value:u,field:i.field,name:o(i.field),filter:s(i),remove:()=>{t(i.field,u,!1)}})),[s,o,t]),l=p.useCallback(i=>(i.range??[]).map(u=>{var g,y;const f=u.gte??u.gt??((g=n(i.field))==null?void 0:g.min),m=u.lte??u.lt??((y=n(i.field))==null?void 0:y.max);if(f!==void 0&&m!==void 0)return{value:`${f} - ${m}`,field:i.field,name:o(i.field),filter:s(i),remove:()=>{r(i.field,void 0)}}}).filter(Boolean),[s,n,o,r]);return{selectFilters:c,toValueFilter:a,toRangeFilter:l}}function ee(){const{filter:e}=v(a=>{var l;return{filter:((l=a.query.products)==null?void 0:l.filter)??[]}}),{updateSearch:r}=k(),{selectFilters:t,toValueFilter:n,toRangeFilter:o}=Xe(),c=p.useMemo(()=>e?e.filter(t).flatMap(a=>"value"in a?n(a):"range"in a?o(a):[]).filter(Boolean):[],[e,t,o,n]),s=p.useCallback(()=>{r({products:{filter:[]}})},[r]);return{filters:c,removeAll:s}}function x(e){if(typeof e=="number")return e;if(typeof e!="string")return;const r=Number(e);return isNaN(r)?void 0:r}function te(e){var u,f,m;const{replaceFilter:r}=k(),{query:t,products:n}=v(g=>({query:g.query,products:g.response.products})),o=(u=n==null?void 0:n.facets)==null?void 0:u.find(g=>g.id===e);if(!o)return{min:0,max:0,range:[0,0],updateRange:()=>{}};const c=(m=(f=t.products)==null?void 0:f.filter)==null?void 0:m.find(g=>g.field===o.field),s=c!=null&&c.range?c.range[0]:void 0,a=typeof s=="object"&&("gte"in s||"lte"in s)?[x(s.gte),x(s.lte)]:[void 0,void 0],l="min"in o?Math.floor(o.min):0,i="max"in o?Math.ceil(o.max):0,d=([g,y])=>{const h=g!==void 0?Math.floor(g):void 0,S=y!==void 0?Math.ceil(y):void 0,C=h!==void 0,b=S!==void 0;(l===h||!C)&&(i===S||!b)?r(o.field,void 0):(l===h||!C)&&b?r(o.field,{lte:S.toString()}):(i===S||!b)&&C?r(o.field,{gte:h.toString()}):C&&b&&r(o.field,{gte:h.toString(),lte:S.toString()})};return{min:l,max:i,range:[a[0]??l,a[1]??i],updateRange:d}}function Ze(e,r){const{min:t,max:n,range:o,updateRange:c}=te(e),{filters:s}=ee(),a=p.useMemo(()=>{var y;const u=s.find(h=>{var S;return(S=h==null?void 0:h.filter)==null?void 0:S.range});let f=null;if(u){const h=(y=u.filter.range)==null?void 0:y[0];f=[x(h==null?void 0:h.gte),x(h==null?void 0:h.lte)]}const m=[];let g=Math.floor(t/r)*r;for(;g<n;){const h=g+r,S=f&&f[0]===g&&f[1]===h;m.push({min:g,max:h,selected:S}),g=h}return m},[s,t,n,r]),l=u=>{c([u,o[1]])},i=u=>{c([o[0],u])},d=t!==o[0]||n!==o[1];return{min:t,max:n,range:o,updateRange:c,ranges:a,handleMinChange:l,handleMaxChange:i,isSelected:d}}function et(){const{products:e,keywords:r}=v(t=>t.response);return{products:e??{hits:[],total:0},keywords:r??{hits:[],total:0}}}function tt(){const e=v(t=>{var n;return(n=t.query.products)==null?void 0:n.filter});return p.useMemo(()=>e?e.reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:1),0):0,[e])}function N(e){return e&&!Number.isNaN(e)?e:0}function rt(e,r){const{from:t,size:n,total:o}=v(i=>{var d,u,f,m,g;return{from:N(((d=i.query.products)==null?void 0:d.from)??0),size:N(((f=(u=i.response)==null?void 0:u.products)==null?void 0:f.size)??0),total:N(((g=(m=i.response)==null?void 0:m.products)==null?void 0:g.total)??0)}}),{updateSearch:c}=k(),s=t+n,a=[...e].reverse().filter(i=>i+r<o);return{from:t,to:s,total:o,size:n,sizeOptions:a,handleSizeChange:i=>{c({products:{size:i}})}}}function nt(e,r){return e.length!==r.length?!1:e.every(t=>r.find(n=>t.field===n.field&&t.order===n.order))}function ot(e){var c,s;const r=v(a=>a.query),{updateSearch:t}=k();return{activeSort:((c=e.find(a=>{var l;return nt(a.value.sort,((l=r.products)==null?void 0:l.sort)||[])}))==null?void 0:c.id)??((s=e[0])==null?void 0:s.id),setSort:a=>{const l=e.find(i=>i.id===a);l&&t({products:{sort:l.value.sort}})}}}exports.AutocompletePageProvider=$e;exports.CategoryPageProvider=Le;exports.InfiniteScroll=xe;exports.SearchInput=Ne;exports.SearchPageProvider=Qe;exports.SerpElement=Oe;exports.StoreContext=M;exports.createExtendableStore=K;exports.createStore=A;exports.defaultState=H;exports.useActions=k;exports.useDecoratedSearchResults=Ke;exports.useFacet=He;exports.useFacets=We;exports.useLoadMore=j;exports.useNostoAppState=v;exports.usePagination=Je;exports.usePersonalization=Ye;exports.useProductFilters=ee;exports.useRange=te;exports.useRangeSelector=Ze;exports.useResponse=et;exports.useSelectedFiltersCount=tt;exports.useSizeOptions=rt;exports.useSort=ot;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("../utils/utils.cjs.js"),b=require("preact"),g=require("preact/hooks"),ne=require("../search-BVJZK90N.cjs"),q=require("../index.es-DlUp67LT.cjs");var oe=0;function C(e,r,t,n,o,i){r||(r={});var s,c,l=r;if("ref"in l)for(c in l={},r)c=="ref"?s=r[c]:l[c]=r[c];var u={type:e,props:l,key:t,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--oe,__i:-1,__u:0,__source:o,__self:i};if(typeof e=="function"&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return b.options.vnode&&b.options.vnode(u),u}const $=e=>String(e)==="[object Object]";function F(e){if(!$(e))return!1;const r=e.constructor;if(r===void 0)return!0;const t=r.prototype;return!(!$(t)||!t.hasOwnProperty("isPrototypeOf"))}function T(...e){return e.reduce((r,t)=>O(r,t))}function D(...e){return e.reduce((r,t)=>O(r,t))}function O(e,r){return F(e)&&F(r)?Object.entries(r).reduce((t,[n,o])=>(t[n]=O(t[n],o),t),{...e}):F(e)?e:r}function A(e,r){if(e===r)return!0;if(e instanceof Date&&r instanceof Date)return e.getTime()===r.getTime();if(Array.isArray(e)&&Array.isArray(r))return e.length!==r.length?!1:e.every((t,n)=>A(t,r[n]));if(F(e)&&F(r)){const t=Object.entries(e);return t.length!==Object.keys(r).length?!1:t.every(([n,o])=>A(o,r[n]))}return!1}function U(e,r={}){const t=new Map;let n=D(e,r??{});const o=D(e,r);function i(a){n=a(n);for(const f of t.values())f(n)}function s(a){i(f=>({...f,...a}))}function c(){return n}function l(){return structuredClone(o)}function u(a,f){let h;t.set(f,p=>{const y=a(p);A(y,h)||(h=y,f(y))})}function d(a){t.delete(a)}return{updateState:s,getState:c,getInitialState:l,onChange:u,clearOnChange:d}}const K={loading:!0,query:{},response:{},initialized:!1};function I(e={}){return U(K,e)}const M=b.createContext(I());function S(e=se){const r=g.useContext(M),[t,n]=g.useState(e(r.getState()));return r.onChange(e,n),g.useEffect(()=>()=>r.clearOnChange(n),[r]),t}const se=e=>e;function H(e,...r){return r.reduce((t,n)=>(t[n]=e[n],t),{})}const N=b.createContext(null),W=()=>{const e=g.useContext(N);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};function ce(e){return Array.from(new Set(e))}function ie(e,r){return{...r,products:{facets:e==="autocomplete"?void 0:["*"],fields:ue,...r.products},...r.keywords?{keywords:{...r.keywords,fields:ce([...ae,...r.keywords.fields??[]]),highlight:r.keywords.highlight??{preTag:"<strong>",postTag:"</strong>"}}}:{}}}const ue=["productId","url","name","imageUrl","imageHash","thumbUrl","description","brand","variantId","availability","price","priceText","categoryIds","categories","customFields.key","customFields.value","priceCurrencyCode","datePublished","listPrice","unitPricingBaseMeasure","unitPricingUnit","unitPricingMeasure","googleCategory","gtin","ageGroup","gender","condition","alternateImageUrls","ratingValue","reviewCount","inventoryLevel","skus.id","skus.name","skus.price","skus.listPrice","skus.priceText","skus.url","skus.imageUrl","skus.inventoryLevel","skus.customFields.key","skus.customFields.value","skus.availability","pid","onDiscount","extra.key","extra.value","saleable","available","tags1","tags2","tags3"],ae=["keyword","_redirect"];function le(...e){if(!e.every(r=>r==null))return e.filter(r=>Array.isArray(r)).reduce((r,t)=>r.concat(t),[])}const G="nosto.search.";function de(e){var t;const r=`${G}${e}`;(t=window.performance)==null||t.mark(`${r}.start`)}function fe(e){var t,n;const r=`${G}${e}`;(t=window.performance)==null||t.mark(`${r}.end`),(n=window.performance)==null||n.measure(r,`${r}.start`,`${r}.end`)}function _(e){return de(e),()=>fe(e)}function ge(e,r,t){const n=JSON.stringify(r);try{console.info("Setting storage",e,n),t.setItem(e,n)}catch(o){console.warn(o)}}function pe(e,r){try{const t=r.getItem(e);if(t)return JSON.parse(t)}catch(t){console.warn(t)}}function me(e,r){ge(e,r,sessionStorage)}function he(e){return pe(e,sessionStorage)}const J="nosto:search:searchResult";function ye(e,r,t){if(!e)return;me(J,{query:r,result:t})}function Se(e,r){if(!e)return null;const t=he(J);if(!t||!ve(t))return null;const n=B(t.query);return A(B(r),n)?t.result:null}function B(e){return{accountId:e.accountId,customRules:e.customRules,explain:e.explain,keywords:e.keywords,products:e.products,query:e.query,redirect:e.redirect,rules:e.rules,segments:e.segments,sessionParams:e.sessionParams}}function ve(e){return typeof e=="object"&&e!==null&&"query"in e&&"result"in e}async function Y(e,r,t){var u,d,a;const n=_("newSearch"),o=e.config.pageType,i=T(e.store.getInitialState().query,r),s=T(e.config.search,t,{track:o,redirect:o!=="autocomplete",isKeyword:!!(t!=null&&t.isKeyword)});e.store.updateState({query:i,loading:!0,initialized:!0});const c=o!=="autocomplete"&&e.config.persistentSearchCache,l=e.config.queryModifications({...i,products:{...i.products,filter:le((d=(u=e.store.getInitialState().query)==null?void 0:u.products)==null?void 0:d.filter,(a=r.products)==null?void 0:a.filter)}},o);try{let f;const h=Se(c,l);if(h)f=h;else{const p=ie(o,l);f=await ne.search(p,s),ye(c,l,f)}e.store.updateState({response:f,loading:!1})}catch(f){console.error("Search action failed",f)}n()}async function z(e,r,t){const n=_("updateSearch"),o=T(e.store.getState().query,{products:{from:0}},r);await Y(e,o,t),n()}async function Ce(e,r,t){var s;const n=_("replaceFilter"),o=(s=e.store.getState().query.products)==null?void 0:s.filter,i=t!==void 0?[{field:r,[typeof t=="object"?"range":"value"]:[t]}]:[];await z(e,{products:{filter:[...(o==null?void 0:o.filter(c=>c.field!==r))??[],...i]}}),n()}async function we(e,r,t,n){var l,u;const o=_("toggleProductFilter"),i=(l=e.store.getState().query.products)==null?void 0:l.filter,s=i==null?void 0:i.find(d=>d.value instanceof Array&&d.field===r),c=s!=null&&s.value?{...s,value:[...s.value.filter(d=>!A(d,t)),...n?[t]:[]]}:n?{field:r,value:[t]}:void 0;await z(e,{products:{filter:[...(i==null?void 0:i.filter(d=>d!==s))??[],...(u=c==null?void 0:c.value)!=null&&u.length?[c]:[]]}}),o()}function k(){const e=W(),r=g.useContext(M),t=g.useMemo(()=>({config:e,store:r}),[e,r]),n=g.useCallback((c,l)=>Y(t,c,l),[t]),o=g.useCallback((c,l)=>z(t,c,l),[t]),i=g.useCallback((c,l,u)=>we(t,c,l,u),[t]),s=g.useCallback((c,l)=>Ce(t,c,l),[t]);return{newSearch:n,updateSearch:o,toggleProductFilter:i,replaceFilter:s}}function X({from:e,size:r,pageSize:t}){return Q.isBot()?{products:{from:e+t}}:{products:{size:r+t}}}function E(e=24){const{from:r,size:t}=S(i=>{var s,c;return{from:((s=i.query.products)==null?void 0:s.from)??0,size:((c=i.query.products)==null?void 0:c.size)??0}}),{updateSearch:n}=k();return{loadMore:g.useCallback(async()=>{await n(X({from:r,size:t,pageSize:e}))},[r,t,e,n])}}function ke({pageSize:e}){const{loadMore:r}=E(e);return C("button",{onClick:r,children:"More results"})}function Z(e,r){var i,s,c;const t=((i=r.products)==null?void 0:i.total)??0,n=((s=e.products)==null?void 0:s.from)??0,o=((c=e.products)==null?void 0:c.size)??0;return t>0&&t>n+o}function Pe(){return!!(window.IntersectionObserver&&window.IntersectionObserverEntry&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)}function ee({children:e,loadMoreComponent:r,pageSize:t}){const{loading:n,query:o,response:i}=S(c=>H(c,"loading","query","response")),s=!n&&Z(o,i);return C(b.Fragment,{children:[e,s&&(r?C(r,{pageSize:t}):C(ke,{pageSize:t}))]})}function be({children:e,pageSize:r}){const t=g.useRef(null),{query:n,response:o}=S(s=>H(s,"query","response")),{loadMore:i}=E(r);return g.useEffect(()=>{let s,c;return Z(n,o)&&(s=t.current,c=new IntersectionObserver(l=>{const u=l[0];u!=null&&u.isIntersecting&&i()}),s&&c.observe(s)),()=>{s&&c.unobserve(s)}},[o]),C(b.Fragment,{children:[e,C("div",{ref:t,style:{height:"1px"}})]})}const Fe=!Q.isBot()&&Pe()?be:ee;function Me(e){return e.type==="input"}function Ae(e){return!!e&&typeof e=="object"&&"type"in e&&"props"in e}function j(e,r={depth:0}){const{children:t}=e;return b.toChildArray(t).map(n=>{if(!Ae(n))return n;const o=e.updateElement(n,r);return o===null?null:(o.props={...o.props,children:j({...e,children:o.props.children},{depth:r.depth+1})},o)})}function Ie({children:e,onSearchInput:r}){return j({children:e,updateElement:t=>(!Me(t)||t.props.type!=="search"||(t.props={...t.props,onInput:n=>{n.target instanceof HTMLInputElement&&r(n.target)}}),t)})}const Re="nosto:search:scrollPos";function Ne(){window.sessionStorage.setItem(Re,window.scrollY.toString())}function _e({children:e,hit:r,onClick:t}){const{pageType:n}=W(),o=n==="autocomplete"?void 0:n;return j({children:e,updateElement:(i,s)=>(s.depth>0||(i.props={...i.props,onClick:c=>{r&&o&&q.s(l=>l.recordSearchClick(o,r)),Ne(),typeof t=="function"&&t(c)}}),i)})}function L(){g.useEffect(()=>{const e=window.setTimeout(()=>{console.error("Nosto client script has not loaded after 3 seconds.")},3e3);q.s(()=>{window.clearTimeout(e)})},[])}const V={defaultCurrency:"EUR",queryModifications:e=>e},xe={...V};function Te(e){return{pageType:"autocomplete",...xe,...e}}function qe({config:e,store:r,children:t}){const n=r??I();return L(),C(N,{value:Te(e),children:C(M,{value:n,children:t})})}const Oe={...V,persistentSearchCache:!1,preservePageScroll:!1};function ze(e){return{pageType:"category",...Oe,...e}}function Ee({config:e,store:r,children:t}){const n=r??I();return L(),C(N,{value:ze(e),children:C(M,{value:n,children:t})})}const je={...V,persistentSearchCache:!1,preservePageScroll:!1};function Le(e={}){return{pageType:"serp",...je,...e}}function Ve({config:e,store:r,children:t}){const n=r??I();return L(),C(N,{value:Le(e),children:C(M,{value:n,children:t})})}function $e(e){const r=S(t=>t.response);return e&&Array.isArray(e)||e&&F(e)?e:r}function De(e){var s;const r=((s=e.data)==null?void 0:s.filter(c=>c.selected).length)??0,[t,n]=g.useState(r>0),{toggleProductFilter:o}=k();return{active:t,selectedFiltersCount:r,toggleActive:()=>{n(!t)},toggleProductFilter:o}}function Be(){const{loading:e,facets:r}=S(t=>{var n,o;return{loading:t.loading,facets:((o=(n=t.response)==null?void 0:n.products)==null?void 0:o.facets)??[]}});return{loading:e,facets:r}}function Qe(e,r){const t=r-e;return!isNaN(t)&&t>0?new Array(r-e).fill(void 0).map((n,o)=>o+e):[]}function Ue(e){const{query:r,products:t}=S(n=>({query:n.query,products:n.response.products}));return g.useMemo(()=>{var P;if(!t)return{totalPages:0,resultsFrom:0,resultsTo:0,pages:[]};const n=((P=r.products)==null?void 0:P.from)??0,o=(e==null?void 0:e.width)??1/0,i=Math.max(Math.floor(o-1)/2,1),s=t.size>0?Math.floor(n/t.size)+1:1,c=t.size>0?Math.ceil(t.total/t.size):0,l=w=>w>=s-i&&w<=s+i,u=n+1,d=Math.min(n+t.total,t.total),a={from:n,page:s,current:!0},f=w=>({from:(w-1)*t.size,page:w,current:w===s}),h=s>1?f(s-1):void 0,p=s<c?f(s+1):void 0,y=i===1/0||s-i-1>1?f(1):void 0,m=i===1/0||s+i+1<c?f(c):void 0,v=Qe(1,c+1).filter(l).map(f);return{totalPages:c,resultsFrom:u,resultsTo:d,current:a,prev:h,next:p,first:y,last:m,pages:v}},[r,t,e==null?void 0:e.width])}function Ke(){const[e,r]=g.useState([]),[t,n]=g.useState([]);return g.useEffect(()=>{q.s(async o=>{const{products:i,segments:s}=await o.getSearchSessionParams();r(s??[]),n((i==null?void 0:i.personalizationBoost)??[])})},[]),{segments:e,boost:t}}function He(){const{facets:e}=S(u=>{var d;return{facets:((d=u.response.products)==null?void 0:d.facets)??[]}}),{replaceFilter:r,toggleProductFilter:t}=k(),n=g.useCallback(u=>{const d=e==null?void 0:e.find(a=>a.type==="stats"&&a.field===u);if(d&&"min"in d&&"max"in d)return d},[e]),o=g.useCallback(u=>{var d;return((d=e==null?void 0:e.find(a=>a.field===u))==null?void 0:d.name)??u},[e]),i=g.useCallback(u=>"field"in u&&(u.value instanceof Array||u.range instanceof Array),[]),s=g.useCallback(u=>{var d;return{...u,range:(d=u.range)==null?void 0:d.map(a=>({gt:a.gt?Number(a.gt):a.gt,gte:a.gte?Number(a.gte):a.gte,lt:a.lt?Number(a.lt):a.lt,lte:a.lte?Number(a.lte):a.lte}))}},[]),c=g.useCallback(u=>(u.value??[]).map(a=>({value:a,field:u.field,name:o(u.field),filter:s(u),remove:()=>{t(u.field,a,!1)}})),[s,o,t]),l=g.useCallback(u=>(u.range??[]).map(a=>{var p,y;const f=a.gte??a.gt??((p=n(u.field))==null?void 0:p.min),h=a.lte??a.lt??((y=n(u.field))==null?void 0:y.max);if(f!==void 0&&h!==void 0)return{value:`${f} - ${h}`,field:u.field,name:o(u.field),filter:s(u),remove:()=>{r(u.field,void 0)}}}).filter(Boolean),[s,n,o,r]);return{selectFilters:i,toValueFilter:c,toRangeFilter:l}}function te(){const{filter:e}=S(c=>{var l;return{filter:((l=c.query.products)==null?void 0:l.filter)??[]}}),{updateSearch:r}=k(),{selectFilters:t,toValueFilter:n,toRangeFilter:o}=He(),i=g.useMemo(()=>e?e.filter(t).flatMap(c=>"value"in c?n(c):"range"in c?o(c):[]).filter(Boolean):[],[e,t,o,n]),s=g.useCallback(()=>{r({products:{filter:[]}})},[r]);return{filters:i,removeAll:s}}function R(e){if(typeof e=="number")return e;if(typeof e!="string")return;const r=Number(e);return isNaN(r)?void 0:r}function re(e){var a,f,h;const{replaceFilter:r}=k(),{query:t,products:n}=S(p=>({query:p.query,products:p.response.products})),o=(a=n==null?void 0:n.facets)==null?void 0:a.find(p=>p.id===e);if(!o)return{min:0,max:0,range:[0,0],updateRange:()=>{}};const i=(h=(f=t.products)==null?void 0:f.filter)==null?void 0:h.find(p=>p.field===o.field),s=i!=null&&i.range?i.range[0]:void 0,c=typeof s=="object"&&("gte"in s||"lte"in s)?[R(s.gte),R(s.lte)]:[void 0,void 0],l="min"in o?Math.floor(o.min):0,u="max"in o?Math.ceil(o.max):0,d=([p,y])=>{const m=p!==void 0?Math.floor(p):void 0,v=y!==void 0?Math.ceil(y):void 0,P=m!==void 0,w=v!==void 0;(l===m||!P)&&(u===v||!w)?r(o.field,void 0):(l===m||!P)&&w?r(o.field,{lte:v.toString()}):(u===v||!w)&&P?r(o.field,{gte:m.toString()}):P&&w&&r(o.field,{gte:m.toString(),lte:v.toString()})};return{min:l,max:u,range:[c[0]??l,c[1]??u],updateRange:d}}function We(e,r){const{min:t,max:n,range:o,updateRange:i}=re(e),{filters:s}=te(),c=g.useMemo(()=>{var y;const a=s.find(m=>{var v;return(v=m==null?void 0:m.filter)==null?void 0:v.range});let f=null;if(a){const m=(y=a.filter.range)==null?void 0:y[0];f=[R(m==null?void 0:m.gte),R(m==null?void 0:m.lte)]}const h=[];let p=Math.floor(t/r)*r;for(;p<n;){const m=p+r,v=f&&f[0]===p&&f[1]===m;h.push({min:p,max:m,selected:v}),p=m}return h},[s,t,n,r]),l=a=>{i([a,o[1]])},u=a=>{i([o[0],a])},d=t!==o[0]||n!==o[1];return{min:t,max:n,range:o,updateRange:i,ranges:c,handleMinChange:l,handleMaxChange:u,isSelected:d}}function Ge(){const{products:e,keywords:r}=S(t=>t.response);return{products:e??{hits:[],total:0},keywords:r??{hits:[],total:0}}}function Je(){const e=S(t=>{var n;return(n=t.query.products)==null?void 0:n.filter});return g.useMemo(()=>e?e.reduce((t,n)=>t+(Array.isArray(n.value)?n.value.length:1),0):0,[e])}function x(e){return e&&!Number.isNaN(e)?e:0}function Ye(e,r){const{from:t,size:n,total:o}=S(u=>{var d,a,f,h,p;return{from:x(((d=u.query.products)==null?void 0:d.from)??0),size:x(((f=(a=u.response)==null?void 0:a.products)==null?void 0:f.size)??0),total:x(((p=(h=u.response)==null?void 0:h.products)==null?void 0:p.total)??0)}}),{updateSearch:i}=k(),s=t+n,c=[...e].reverse().filter(u=>u+r<o);return{from:t,to:s,total:o,size:n,sizeOptions:c,handleSizeChange:u=>{i({products:{size:u}})}}}function Xe(e,r){return e.length!==r.length?!1:e.every(t=>r.find(n=>t.field===n.field&&t.order===n.order))}function Ze(e){var i,s;const r=S(c=>c.query),{updateSearch:t}=k();return{activeSort:((i=e.find(c=>{var l;return Xe(c.value.sort,((l=r.products)==null?void 0:l.sort)||[])}))==null?void 0:i.id)??((s=e[0])==null?void 0:s.id),setSort:c=>{const l=e.find(u=>u.id===c);l&&t({products:{sort:l.value.sort}})}}}exports.AutocompletePageProvider=qe;exports.CategoryPageProvider=Ee;exports.InfiniteScroll=Fe;exports.InfiniteScrollWithLink=ee;exports.SearchInput=Ie;exports.SearchPageProvider=Ve;exports.SerpElement=_e;exports.StoreContext=M;exports.createExtendableStore=U;exports.createStore=I;exports.defaultState=K;exports.getNextPageQuery=X;exports.useActions=k;exports.useDecoratedSearchResults=$e;exports.useFacet=De;exports.useFacets=Be;exports.useLoadMore=E;exports.useNostoAppState=S;exports.usePagination=Ue;exports.usePersonalization=Ke;exports.useProductFilters=te;exports.useRange=re;exports.useRangeSelector=We;exports.useResponse=Ge;exports.useSelectedFiltersCount=Je;exports.useSizeOptions=Ye;exports.useSort=Ze;
|
package/dist/preact/preact.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @module preact */
|
|
2
|
-
export { InfiniteScroll } from './src/components/InfiniteScroll/InfiniteScroll';
|
|
2
|
+
export { InfiniteScroll, type InfiniteScrollProps } from './src/components/InfiniteScroll/InfiniteScroll';
|
|
3
|
+
export { InfiniteScrollWithLink } from './src/components/InfiniteScroll/InfiniteScrollWithLink';
|
|
3
4
|
export { SearchInput } from './src/components/SearchInput';
|
|
4
5
|
export { SerpElement } from './src/components/SerpElement';
|
|
5
6
|
export type { PublicAutocompleteConfig as AutocompleteConfig } from './src/config/pages/autocomplete/config';
|
|
@@ -12,6 +13,7 @@ export { useActions } from './src/hooks/useActions';
|
|
|
12
13
|
export { useDecoratedSearchResults } from './src/hooks/useDecoratedSearchResults';
|
|
13
14
|
export { useFacet } from './src/hooks/useFacet';
|
|
14
15
|
export { useFacets } from './src/hooks/useFacets';
|
|
16
|
+
export { getNextPageQuery } from './src/hooks/useLoadMore/getNextPageQuery';
|
|
15
17
|
export { useLoadMore } from './src/hooks/useLoadMore/useLoadMore';
|
|
16
18
|
export { useNostoAppState } from './src/hooks/useNostoAppState';
|
|
17
19
|
export { type Page, usePagination } from './src/hooks/usePagination';
|
package/dist/preact/preact.es.js
CHANGED
|
@@ -1,79 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { s as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return F;
|
|
9
|
-
try {
|
|
10
|
-
F = new RegExp(ce, "i");
|
|
11
|
-
} catch {
|
|
12
|
-
F = ae;
|
|
13
|
-
}
|
|
14
|
-
return F;
|
|
15
|
-
}
|
|
16
|
-
function le(e) {
|
|
17
|
-
return !!e && ue().test(e);
|
|
18
|
-
}
|
|
19
|
-
function J() {
|
|
20
|
-
return le(navigator.userAgent);
|
|
21
|
-
}
|
|
22
|
-
var de = 0;
|
|
23
|
-
function S(e, r, t, n, o, c) {
|
|
1
|
+
import { isBot as H } from "../utils/utils.es.js";
|
|
2
|
+
import { options as B, createContext as W, Fragment as G, toChildArray as ne } from "preact";
|
|
3
|
+
import { useContext as q, useState as I, useEffect as N, useMemo as M, useCallback as v, useRef as oe } from "preact/hooks";
|
|
4
|
+
import { s as se } from "../search-B0-bVNMy.js";
|
|
5
|
+
import { s as E } from "../index.es-B8mbAxS4.js";
|
|
6
|
+
var ie = 0;
|
|
7
|
+
function w(e, r, t, n, o, c) {
|
|
24
8
|
r || (r = {});
|
|
25
9
|
var s, i, l = r;
|
|
26
10
|
if ("ref" in l) for (i in l = {}, r) i == "ref" ? s = r[i] : l[i] = r[i];
|
|
27
|
-
var
|
|
11
|
+
var u = { type: e, props: l, key: t, ref: s, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --ie, __i: -1, __u: 0, __source: o, __self: c };
|
|
28
12
|
if (typeof e == "function" && (s = e.defaultProps)) for (i in s) l[i] === void 0 && (l[i] = s[i]);
|
|
29
|
-
return
|
|
13
|
+
return B.vnode && B.vnode(u), u;
|
|
30
14
|
}
|
|
31
|
-
const
|
|
32
|
-
function
|
|
33
|
-
if (!
|
|
15
|
+
const U = (e) => String(e) === "[object Object]";
|
|
16
|
+
function F(e) {
|
|
17
|
+
if (!U(e))
|
|
34
18
|
return !1;
|
|
35
19
|
const r = e.constructor;
|
|
36
20
|
if (r === void 0)
|
|
37
21
|
return !0;
|
|
38
22
|
const t = r.prototype;
|
|
39
|
-
return !(!
|
|
23
|
+
return !(!U(t) || !t.hasOwnProperty("isPrototypeOf"));
|
|
40
24
|
}
|
|
41
|
-
function
|
|
42
|
-
return e.reduce((r, t) =>
|
|
25
|
+
function x(...e) {
|
|
26
|
+
return e.reduce((r, t) => V(r, t));
|
|
43
27
|
}
|
|
44
|
-
function
|
|
45
|
-
return e.reduce((r, t) =>
|
|
28
|
+
function Q(...e) {
|
|
29
|
+
return e.reduce((r, t) => V(r, t));
|
|
46
30
|
}
|
|
47
|
-
function
|
|
48
|
-
return
|
|
49
|
-
(t, [n, o]) => (t[n] =
|
|
31
|
+
function V(e, r) {
|
|
32
|
+
return F(e) && F(r) ? Object.entries(r).reduce(
|
|
33
|
+
(t, [n, o]) => (t[n] = V(t[n], o), t),
|
|
50
34
|
{ ...e }
|
|
51
|
-
) :
|
|
35
|
+
) : F(e) ? e : r;
|
|
52
36
|
}
|
|
53
|
-
function
|
|
37
|
+
function b(e, r) {
|
|
54
38
|
if (e === r)
|
|
55
39
|
return !0;
|
|
56
40
|
if (e instanceof Date && r instanceof Date)
|
|
57
41
|
return e.getTime() === r.getTime();
|
|
58
42
|
if (Array.isArray(e) && Array.isArray(r))
|
|
59
|
-
return e.length !== r.length ? !1 : e.every((t, n) =>
|
|
60
|
-
if (
|
|
43
|
+
return e.length !== r.length ? !1 : e.every((t, n) => b(t, r[n]));
|
|
44
|
+
if (F(e) && F(r)) {
|
|
61
45
|
const t = Object.entries(e);
|
|
62
|
-
return t.length !== Object.keys(r).length ? !1 : t.every(([n, o]) =>
|
|
46
|
+
return t.length !== Object.keys(r).length ? !1 : t.every(([n, o]) => b(o, r[n]));
|
|
63
47
|
}
|
|
64
48
|
return !1;
|
|
65
49
|
}
|
|
66
|
-
function
|
|
50
|
+
function ce(e, r = {}) {
|
|
67
51
|
const t = /* @__PURE__ */ new Map();
|
|
68
|
-
let n =
|
|
69
|
-
const o =
|
|
70
|
-
function c(
|
|
71
|
-
n =
|
|
72
|
-
for (const
|
|
73
|
-
|
|
52
|
+
let n = Q(e, r ?? {});
|
|
53
|
+
const o = Q(e, r);
|
|
54
|
+
function c(a) {
|
|
55
|
+
n = a(n);
|
|
56
|
+
for (const d of t.values())
|
|
57
|
+
d(n);
|
|
74
58
|
}
|
|
75
|
-
function s(
|
|
76
|
-
c((
|
|
59
|
+
function s(a) {
|
|
60
|
+
c((d) => ({ ...d, ...a }));
|
|
77
61
|
}
|
|
78
62
|
function i() {
|
|
79
63
|
return n;
|
|
@@ -81,66 +65,66 @@ function fe(e, r = {}) {
|
|
|
81
65
|
function l() {
|
|
82
66
|
return structuredClone(o);
|
|
83
67
|
}
|
|
84
|
-
function a
|
|
68
|
+
function u(a, d) {
|
|
85
69
|
let m;
|
|
86
|
-
t.set(
|
|
87
|
-
const h =
|
|
88
|
-
|
|
70
|
+
t.set(d, (g) => {
|
|
71
|
+
const h = a(g);
|
|
72
|
+
b(h, m) || (m = h, d(h));
|
|
89
73
|
});
|
|
90
74
|
}
|
|
91
|
-
function
|
|
92
|
-
t.delete(
|
|
75
|
+
function f(a) {
|
|
76
|
+
t.delete(a);
|
|
93
77
|
}
|
|
94
78
|
return {
|
|
95
79
|
updateState: s,
|
|
96
80
|
getState: i,
|
|
97
81
|
getInitialState: l,
|
|
98
|
-
onChange:
|
|
99
|
-
clearOnChange:
|
|
82
|
+
onChange: u,
|
|
83
|
+
clearOnChange: f
|
|
100
84
|
};
|
|
101
85
|
}
|
|
102
|
-
const
|
|
86
|
+
const ue = {
|
|
103
87
|
loading: !0,
|
|
104
88
|
query: {},
|
|
105
89
|
response: {},
|
|
106
90
|
initialized: !1
|
|
107
91
|
};
|
|
108
92
|
function _(e = {}) {
|
|
109
|
-
return
|
|
93
|
+
return ce(ue, e);
|
|
110
94
|
}
|
|
111
95
|
const A = W(_());
|
|
112
|
-
function y(e =
|
|
113
|
-
const r =
|
|
114
|
-
return r.onChange(e, n),
|
|
96
|
+
function y(e = ae) {
|
|
97
|
+
const r = q(A), [t, n] = I(e(r.getState()));
|
|
98
|
+
return r.onChange(e, n), N(() => () => r.clearOnChange(n), [r]), t;
|
|
115
99
|
}
|
|
116
|
-
const
|
|
117
|
-
function
|
|
100
|
+
const ae = (e) => e;
|
|
101
|
+
function J(e, ...r) {
|
|
118
102
|
return r.reduce(
|
|
119
103
|
(t, n) => (t[n] = e[n], t),
|
|
120
104
|
{}
|
|
121
105
|
);
|
|
122
106
|
}
|
|
123
|
-
const
|
|
124
|
-
const e =
|
|
107
|
+
const T = W(null), Y = () => {
|
|
108
|
+
const e = q(T);
|
|
125
109
|
if (!e)
|
|
126
110
|
throw new Error("useConfig must be used within a ConfigProvider");
|
|
127
111
|
return e;
|
|
128
112
|
};
|
|
129
|
-
function
|
|
113
|
+
function le(e) {
|
|
130
114
|
return Array.from(new Set(e));
|
|
131
115
|
}
|
|
132
|
-
function
|
|
116
|
+
function fe(e, r) {
|
|
133
117
|
return {
|
|
134
118
|
...r,
|
|
135
119
|
products: {
|
|
136
120
|
facets: e === "autocomplete" ? void 0 : ["*"],
|
|
137
|
-
fields:
|
|
121
|
+
fields: de,
|
|
138
122
|
...r.products
|
|
139
123
|
},
|
|
140
124
|
...r.keywords ? {
|
|
141
125
|
keywords: {
|
|
142
126
|
...r.keywords,
|
|
143
|
-
fields:
|
|
127
|
+
fields: le([...ge, ...r.keywords.fields ?? []]),
|
|
144
128
|
highlight: r.keywords.highlight ?? {
|
|
145
129
|
preTag: "<strong>",
|
|
146
130
|
postTag: "</strong>"
|
|
@@ -149,7 +133,7 @@ function he(e, r) {
|
|
|
149
133
|
} : {}
|
|
150
134
|
};
|
|
151
135
|
}
|
|
152
|
-
const
|
|
136
|
+
const de = [
|
|
153
137
|
"productId",
|
|
154
138
|
"url",
|
|
155
139
|
"name",
|
|
@@ -201,26 +185,26 @@ const ye = [
|
|
|
201
185
|
"tags1",
|
|
202
186
|
"tags2",
|
|
203
187
|
"tags3"
|
|
204
|
-
],
|
|
205
|
-
function
|
|
188
|
+
], ge = ["keyword", "_redirect"];
|
|
189
|
+
function pe(...e) {
|
|
206
190
|
if (!e.every((r) => r == null))
|
|
207
191
|
return e.filter((r) => Array.isArray(r)).reduce((r, t) => r.concat(t), []);
|
|
208
192
|
}
|
|
209
|
-
const
|
|
210
|
-
function
|
|
193
|
+
const X = "nosto.search.";
|
|
194
|
+
function me(e) {
|
|
211
195
|
var t;
|
|
212
|
-
const r = `${
|
|
196
|
+
const r = `${X}${e}`;
|
|
213
197
|
(t = window.performance) == null || t.mark(`${r}.start`);
|
|
214
198
|
}
|
|
215
|
-
function
|
|
199
|
+
function he(e) {
|
|
216
200
|
var t, n;
|
|
217
|
-
const r = `${
|
|
201
|
+
const r = `${X}${e}`;
|
|
218
202
|
(t = window.performance) == null || t.mark(`${r}.end`), (n = window.performance) == null || n.measure(r, `${r}.start`, `${r}.end`);
|
|
219
203
|
}
|
|
220
|
-
function
|
|
221
|
-
return
|
|
204
|
+
function O(e) {
|
|
205
|
+
return me(e), () => he(e);
|
|
222
206
|
}
|
|
223
|
-
function
|
|
207
|
+
function ye(e, r, t) {
|
|
224
208
|
const n = JSON.stringify(r);
|
|
225
209
|
try {
|
|
226
210
|
console.info("Setting storage", e, n), t.setItem(e, n);
|
|
@@ -228,7 +212,7 @@ function ke(e, r, t) {
|
|
|
228
212
|
console.warn(o);
|
|
229
213
|
}
|
|
230
214
|
}
|
|
231
|
-
function
|
|
215
|
+
function Se(e, r) {
|
|
232
216
|
try {
|
|
233
217
|
const t = r.getItem(e);
|
|
234
218
|
if (t)
|
|
@@ -237,28 +221,28 @@ function Ce(e, r) {
|
|
|
237
221
|
console.warn(t);
|
|
238
222
|
}
|
|
239
223
|
}
|
|
240
|
-
function
|
|
241
|
-
|
|
224
|
+
function ve(e, r) {
|
|
225
|
+
ye(e, r, sessionStorage);
|
|
242
226
|
}
|
|
243
|
-
function
|
|
244
|
-
return
|
|
227
|
+
function we(e) {
|
|
228
|
+
return Se(e, sessionStorage);
|
|
245
229
|
}
|
|
246
|
-
const
|
|
247
|
-
function
|
|
230
|
+
const Z = "nosto:search:searchResult";
|
|
231
|
+
function Ce(e, r, t) {
|
|
248
232
|
if (!e)
|
|
249
233
|
return;
|
|
250
|
-
|
|
234
|
+
ve(Z, { query: r, result: t });
|
|
251
235
|
}
|
|
252
|
-
function
|
|
236
|
+
function ke(e, r) {
|
|
253
237
|
if (!e)
|
|
254
238
|
return null;
|
|
255
|
-
const t =
|
|
256
|
-
if (!t || !
|
|
239
|
+
const t = we(Z);
|
|
240
|
+
if (!t || !Pe(t))
|
|
257
241
|
return null;
|
|
258
|
-
const n =
|
|
259
|
-
return
|
|
242
|
+
const n = K(t.query);
|
|
243
|
+
return b(K(r), n) ? t.result : null;
|
|
260
244
|
}
|
|
261
|
-
function
|
|
245
|
+
function K(e) {
|
|
262
246
|
return {
|
|
263
247
|
accountId: e.accountId,
|
|
264
248
|
customRules: e.customRules,
|
|
@@ -272,12 +256,12 @@ function H(e) {
|
|
|
272
256
|
sessionParams: e.sessionParams
|
|
273
257
|
};
|
|
274
258
|
}
|
|
275
|
-
function
|
|
259
|
+
function Pe(e) {
|
|
276
260
|
return typeof e == "object" && e !== null && "query" in e && "result" in e;
|
|
277
261
|
}
|
|
278
|
-
async function
|
|
279
|
-
var
|
|
280
|
-
const n =
|
|
262
|
+
async function ee(e, r, t) {
|
|
263
|
+
var u, f, a;
|
|
264
|
+
const n = O("newSearch"), o = e.config.pageType, c = x(e.store.getInitialState().query, r), s = x(e.config.search, t, {
|
|
281
265
|
track: o,
|
|
282
266
|
redirect: o !== "autocomplete",
|
|
283
267
|
isKeyword: !!(t != null && t.isKeyword)
|
|
@@ -293,75 +277,75 @@ async function te(e, r, t) {
|
|
|
293
277
|
products: {
|
|
294
278
|
...c.products,
|
|
295
279
|
// Apply filter merging to avoid overwriting base filters
|
|
296
|
-
filter:
|
|
280
|
+
filter: pe((f = (u = e.store.getInitialState().query) == null ? void 0 : u.products) == null ? void 0 : f.filter, (a = r.products) == null ? void 0 : a.filter)
|
|
297
281
|
}
|
|
298
282
|
},
|
|
299
283
|
o
|
|
300
284
|
);
|
|
301
285
|
try {
|
|
302
|
-
let
|
|
303
|
-
const m =
|
|
286
|
+
let d;
|
|
287
|
+
const m = ke(i, l);
|
|
304
288
|
if (m)
|
|
305
|
-
|
|
289
|
+
d = m;
|
|
306
290
|
else {
|
|
307
|
-
const
|
|
308
|
-
|
|
291
|
+
const g = fe(o, l);
|
|
292
|
+
d = await se(g, s), Ce(i, l, d);
|
|
309
293
|
}
|
|
310
294
|
e.store.updateState({
|
|
311
|
-
response:
|
|
295
|
+
response: d,
|
|
312
296
|
loading: !1
|
|
313
297
|
});
|
|
314
|
-
} catch (
|
|
315
|
-
console.error("Search action failed",
|
|
298
|
+
} catch (d) {
|
|
299
|
+
console.error("Search action failed", d);
|
|
316
300
|
}
|
|
317
301
|
n();
|
|
318
302
|
}
|
|
319
|
-
async function
|
|
320
|
-
const n =
|
|
321
|
-
await
|
|
303
|
+
async function $(e, r, t) {
|
|
304
|
+
const n = O("updateSearch"), o = x(e.store.getState().query, { products: { from: 0 } }, r);
|
|
305
|
+
await ee(e, o, t), n();
|
|
322
306
|
}
|
|
323
|
-
async function
|
|
307
|
+
async function Fe(e, r, t) {
|
|
324
308
|
var s;
|
|
325
|
-
const n =
|
|
326
|
-
await
|
|
309
|
+
const n = O("replaceFilter"), o = (s = e.store.getState().query.products) == null ? void 0 : s.filter, c = t !== void 0 ? [{ field: r, [typeof t == "object" ? "range" : "value"]: [t] }] : [];
|
|
310
|
+
await $(e, {
|
|
327
311
|
products: {
|
|
328
312
|
filter: [...(o == null ? void 0 : o.filter((i) => i.field !== r)) ?? [], ...c]
|
|
329
313
|
}
|
|
330
314
|
}), n();
|
|
331
315
|
}
|
|
332
|
-
async function
|
|
333
|
-
var l,
|
|
334
|
-
const o =
|
|
316
|
+
async function be(e, r, t, n) {
|
|
317
|
+
var l, u;
|
|
318
|
+
const o = O("toggleProductFilter"), c = (l = e.store.getState().query.products) == null ? void 0 : l.filter, s = c == null ? void 0 : c.find((f) => f.value instanceof Array && f.field === r), i = s != null && s.value ? {
|
|
335
319
|
...s,
|
|
336
|
-
value: [...s.value.filter((
|
|
320
|
+
value: [...s.value.filter((f) => !b(f, t)), ...n ? [t] : []]
|
|
337
321
|
} : n ? {
|
|
338
322
|
field: r,
|
|
339
323
|
value: [t]
|
|
340
324
|
} : void 0;
|
|
341
|
-
await
|
|
325
|
+
await $(e, {
|
|
342
326
|
products: {
|
|
343
|
-
filter: [...(c == null ? void 0 : c.filter((
|
|
327
|
+
filter: [...(c == null ? void 0 : c.filter((f) => f !== s)) ?? [], ...(u = i == null ? void 0 : i.value) != null && u.length ? [i] : []]
|
|
344
328
|
}
|
|
345
329
|
}), o();
|
|
346
330
|
}
|
|
347
|
-
function
|
|
348
|
-
const e =
|
|
331
|
+
function P() {
|
|
332
|
+
const e = Y(), r = q(A), t = M(
|
|
349
333
|
() => ({
|
|
350
334
|
config: e,
|
|
351
335
|
store: r
|
|
352
336
|
}),
|
|
353
337
|
[e, r]
|
|
354
|
-
), n =
|
|
355
|
-
(i, l) =>
|
|
338
|
+
), n = v(
|
|
339
|
+
(i, l) => ee(t, i, l),
|
|
356
340
|
[t]
|
|
357
|
-
), o =
|
|
358
|
-
(i, l) =>
|
|
341
|
+
), o = v(
|
|
342
|
+
(i, l) => $(t, i, l),
|
|
359
343
|
[t]
|
|
360
|
-
), c =
|
|
361
|
-
(i, l,
|
|
344
|
+
), c = v(
|
|
345
|
+
(i, l, u) => be(t, i, l, u),
|
|
362
346
|
[t]
|
|
363
|
-
), s =
|
|
364
|
-
(i, l) =>
|
|
347
|
+
), s = v(
|
|
348
|
+
(i, l) => Fe(t, i, l),
|
|
365
349
|
[t]
|
|
366
350
|
);
|
|
367
351
|
return {
|
|
@@ -371,84 +355,84 @@ function C() {
|
|
|
371
355
|
replaceFilter: s
|
|
372
356
|
};
|
|
373
357
|
}
|
|
374
|
-
function
|
|
375
|
-
return
|
|
358
|
+
function Me({ from: e, size: r, pageSize: t }) {
|
|
359
|
+
return H() ? {
|
|
376
360
|
products: { from: e + t }
|
|
377
361
|
} : {
|
|
378
362
|
products: { size: r + t }
|
|
379
363
|
};
|
|
380
364
|
}
|
|
381
|
-
function
|
|
365
|
+
function te(e = 24) {
|
|
382
366
|
const { from: r, size: t } = y((c) => {
|
|
383
367
|
var s, i;
|
|
384
368
|
return {
|
|
385
369
|
from: ((s = c.query.products) == null ? void 0 : s.from) ?? 0,
|
|
386
370
|
size: ((i = c.query.products) == null ? void 0 : i.size) ?? 0
|
|
387
371
|
};
|
|
388
|
-
}), { updateSearch: n } =
|
|
372
|
+
}), { updateSearch: n } = P();
|
|
389
373
|
return {
|
|
390
|
-
loadMore:
|
|
391
|
-
await n(
|
|
374
|
+
loadMore: v(async () => {
|
|
375
|
+
await n(Me({ from: r, size: t, pageSize: e }));
|
|
392
376
|
}, [r, t, e, n])
|
|
393
377
|
};
|
|
394
378
|
}
|
|
395
|
-
function
|
|
396
|
-
const { loadMore: r } =
|
|
397
|
-
return /* @__PURE__ */
|
|
379
|
+
function Ae({ pageSize: e }) {
|
|
380
|
+
const { loadMore: r } = te(e);
|
|
381
|
+
return /* @__PURE__ */ w("button", { onClick: r, children: "More results" });
|
|
398
382
|
}
|
|
399
|
-
function
|
|
383
|
+
function re(e, r) {
|
|
400
384
|
var c, s, i;
|
|
401
385
|
const t = ((c = r.products) == null ? void 0 : c.total) ?? 0, n = ((s = e.products) == null ? void 0 : s.from) ?? 0, o = ((i = e.products) == null ? void 0 : i.size) ?? 0;
|
|
402
386
|
return t > 0 && t > n + o;
|
|
403
387
|
}
|
|
404
|
-
function
|
|
388
|
+
function Ie() {
|
|
405
389
|
return !!(window.IntersectionObserver && window.IntersectionObserverEntry && "intersectionRatio" in window.IntersectionObserverEntry.prototype);
|
|
406
390
|
}
|
|
407
|
-
function
|
|
408
|
-
const { loading: n, query: o, response: c } = y((i) =>
|
|
409
|
-
return /* @__PURE__ */
|
|
391
|
+
function Re({ children: e, loadMoreComponent: r, pageSize: t }) {
|
|
392
|
+
const { loading: n, query: o, response: c } = y((i) => J(i, "loading", "query", "response")), s = !n && re(o, c);
|
|
393
|
+
return /* @__PURE__ */ w(G, { children: [
|
|
410
394
|
e,
|
|
411
|
-
s && (r ? /* @__PURE__ */
|
|
395
|
+
s && (r ? /* @__PURE__ */ w(r, { pageSize: t }) : /* @__PURE__ */ w(Ae, { pageSize: t }))
|
|
412
396
|
] });
|
|
413
397
|
}
|
|
414
|
-
function
|
|
415
|
-
const t =
|
|
416
|
-
return
|
|
398
|
+
function Ne({ children: e, pageSize: r }) {
|
|
399
|
+
const t = oe(null), { query: n, response: o } = y((s) => J(s, "query", "response")), { loadMore: c } = te(r);
|
|
400
|
+
return N(() => {
|
|
417
401
|
let s, i;
|
|
418
|
-
return
|
|
419
|
-
const
|
|
420
|
-
|
|
402
|
+
return re(n, o) && (s = t.current, i = new IntersectionObserver((l) => {
|
|
403
|
+
const u = l[0];
|
|
404
|
+
u != null && u.isIntersecting && c();
|
|
421
405
|
}), s && i.observe(s)), () => {
|
|
422
406
|
s && i.unobserve(s);
|
|
423
407
|
};
|
|
424
|
-
}, [o]), /* @__PURE__ */
|
|
408
|
+
}, [o]), /* @__PURE__ */ w(G, { children: [
|
|
425
409
|
e,
|
|
426
|
-
/* @__PURE__ */
|
|
410
|
+
/* @__PURE__ */ w("div", { ref: t, style: { height: "1px" } })
|
|
427
411
|
] });
|
|
428
412
|
}
|
|
429
|
-
const
|
|
430
|
-
function
|
|
413
|
+
const Ye = !H() && Ie() ? Ne : Re;
|
|
414
|
+
function _e(e) {
|
|
431
415
|
return e.type === "input";
|
|
432
416
|
}
|
|
433
|
-
function
|
|
417
|
+
function Te(e) {
|
|
434
418
|
return !!e && typeof e == "object" && "type" in e && "props" in e;
|
|
435
419
|
}
|
|
436
|
-
function
|
|
420
|
+
function j(e, r = { depth: 0 }) {
|
|
437
421
|
const { children: t } = e;
|
|
438
|
-
return
|
|
439
|
-
if (!
|
|
422
|
+
return ne(t).map((n) => {
|
|
423
|
+
if (!Te(n))
|
|
440
424
|
return n;
|
|
441
425
|
const o = e.updateElement(n, r);
|
|
442
426
|
return o === null ? null : (o.props = {
|
|
443
427
|
...o.props,
|
|
444
|
-
children:
|
|
428
|
+
children: j({ ...e, children: o.props.children }, { depth: r.depth + 1 })
|
|
445
429
|
}, o);
|
|
446
430
|
});
|
|
447
431
|
}
|
|
448
|
-
function
|
|
449
|
-
return
|
|
432
|
+
function Xe({ children: e, onSearchInput: r }) {
|
|
433
|
+
return j({
|
|
450
434
|
children: e,
|
|
451
|
-
updateElement: (t) => (!
|
|
435
|
+
updateElement: (t) => (!_e(t) || t.props.type !== "search" || (t.props = {
|
|
452
436
|
...t.props,
|
|
453
437
|
onInput: (n) => {
|
|
454
438
|
n.target instanceof HTMLInputElement && r(n.target);
|
|
@@ -456,28 +440,28 @@ function rt({ children: e, onSearchInput: r }) {
|
|
|
456
440
|
}), t)
|
|
457
441
|
});
|
|
458
442
|
}
|
|
459
|
-
const
|
|
460
|
-
function
|
|
461
|
-
window.sessionStorage.setItem(
|
|
443
|
+
const Oe = "nosto:search:scrollPos";
|
|
444
|
+
function ze() {
|
|
445
|
+
window.sessionStorage.setItem(Oe, window.scrollY.toString());
|
|
462
446
|
}
|
|
463
|
-
function
|
|
464
|
-
const { pageType: n } =
|
|
465
|
-
return
|
|
447
|
+
function Ze({ children: e, hit: r, onClick: t }) {
|
|
448
|
+
const { pageType: n } = Y(), o = n === "autocomplete" ? void 0 : n;
|
|
449
|
+
return j({
|
|
466
450
|
children: e,
|
|
467
451
|
updateElement: (c, s) => (s.depth > 0 || (c.props = {
|
|
468
452
|
...c.props,
|
|
469
453
|
onClick: (i) => {
|
|
470
|
-
r && o &&
|
|
454
|
+
r && o && E((l) => l.recordSearchClick(o, r)), ze(), typeof t == "function" && t(i);
|
|
471
455
|
}
|
|
472
456
|
}), c)
|
|
473
457
|
});
|
|
474
458
|
}
|
|
475
459
|
function D() {
|
|
476
|
-
|
|
460
|
+
N(() => {
|
|
477
461
|
const e = window.setTimeout(() => {
|
|
478
462
|
console.error("Nosto client script has not loaded after 3 seconds.");
|
|
479
463
|
}, 3e3);
|
|
480
|
-
|
|
464
|
+
E(() => {
|
|
481
465
|
window.clearTimeout(e);
|
|
482
466
|
});
|
|
483
467
|
}, []);
|
|
@@ -485,59 +469,59 @@ function D() {
|
|
|
485
469
|
const L = {
|
|
486
470
|
defaultCurrency: "EUR",
|
|
487
471
|
queryModifications: (e) => e
|
|
488
|
-
},
|
|
472
|
+
}, xe = {
|
|
489
473
|
...L
|
|
490
474
|
};
|
|
491
|
-
function
|
|
475
|
+
function qe(e) {
|
|
492
476
|
return {
|
|
493
477
|
pageType: "autocomplete",
|
|
494
|
-
...
|
|
478
|
+
...xe,
|
|
495
479
|
...e
|
|
496
480
|
};
|
|
497
481
|
}
|
|
498
|
-
function
|
|
482
|
+
function et({ config: e, store: r, children: t }) {
|
|
499
483
|
const n = r ?? _();
|
|
500
|
-
return D(), /* @__PURE__ */
|
|
484
|
+
return D(), /* @__PURE__ */ w(T, { value: qe(e), children: /* @__PURE__ */ w(A, { value: n, children: t }) });
|
|
501
485
|
}
|
|
502
|
-
const
|
|
486
|
+
const Ee = {
|
|
503
487
|
...L,
|
|
504
488
|
persistentSearchCache: !1,
|
|
505
489
|
preservePageScroll: !1
|
|
506
490
|
};
|
|
507
|
-
function
|
|
491
|
+
function Ve(e) {
|
|
508
492
|
return {
|
|
509
493
|
pageType: "category",
|
|
510
|
-
...
|
|
494
|
+
...Ee,
|
|
511
495
|
...e
|
|
512
496
|
};
|
|
513
497
|
}
|
|
514
|
-
function
|
|
498
|
+
function tt({ config: e, store: r, children: t }) {
|
|
515
499
|
const n = r ?? _();
|
|
516
|
-
return D(), /* @__PURE__ */
|
|
500
|
+
return D(), /* @__PURE__ */ w(T, { value: Ve(e), children: /* @__PURE__ */ w(A, { value: n, children: t }) });
|
|
517
501
|
}
|
|
518
|
-
const
|
|
502
|
+
const $e = {
|
|
519
503
|
...L,
|
|
520
504
|
persistentSearchCache: !1,
|
|
521
505
|
preservePageScroll: !1
|
|
522
506
|
};
|
|
523
|
-
function
|
|
507
|
+
function je(e = {}) {
|
|
524
508
|
return {
|
|
525
509
|
pageType: "serp",
|
|
526
|
-
|
|
510
|
+
...$e,
|
|
527
511
|
...e
|
|
528
512
|
};
|
|
529
513
|
}
|
|
530
|
-
function
|
|
514
|
+
function rt({ config: e, store: r, children: t }) {
|
|
531
515
|
const n = r ?? _();
|
|
532
|
-
return D(), /* @__PURE__ */
|
|
516
|
+
return D(), /* @__PURE__ */ w(T, { value: je(e), children: /* @__PURE__ */ w(A, { value: n, children: t }) });
|
|
533
517
|
}
|
|
534
|
-
function
|
|
518
|
+
function nt(e) {
|
|
535
519
|
const r = y((t) => t.response);
|
|
536
|
-
return e && Array.isArray(e) || e &&
|
|
520
|
+
return e && Array.isArray(e) || e && F(e) ? e : r;
|
|
537
521
|
}
|
|
538
|
-
function
|
|
522
|
+
function ot(e) {
|
|
539
523
|
var s;
|
|
540
|
-
const r = ((s = e.data) == null ? void 0 : s.filter((i) => i.selected).length) ?? 0, [t, n] = I(r > 0), { toggleProductFilter: o } =
|
|
524
|
+
const r = ((s = e.data) == null ? void 0 : s.filter((i) => i.selected).length) ?? 0, [t, n] = I(r > 0), { toggleProductFilter: o } = P();
|
|
541
525
|
return {
|
|
542
526
|
/** Active value */
|
|
543
527
|
active: t,
|
|
@@ -551,7 +535,7 @@ function at(e) {
|
|
|
551
535
|
toggleProductFilter: o
|
|
552
536
|
};
|
|
553
537
|
}
|
|
554
|
-
function
|
|
538
|
+
function st() {
|
|
555
539
|
const { loading: e, facets: r } = y((t) => {
|
|
556
540
|
var n, o;
|
|
557
541
|
return {
|
|
@@ -566,16 +550,16 @@ function ut() {
|
|
|
566
550
|
facets: r
|
|
567
551
|
};
|
|
568
552
|
}
|
|
569
|
-
function
|
|
553
|
+
function De(e, r) {
|
|
570
554
|
const t = r - e;
|
|
571
555
|
return !isNaN(t) && t > 0 ? new Array(r - e).fill(void 0).map((n, o) => o + e) : [];
|
|
572
556
|
}
|
|
573
|
-
function
|
|
557
|
+
function it(e) {
|
|
574
558
|
const { query: r, products: t } = y((n) => ({
|
|
575
559
|
query: n.query,
|
|
576
560
|
products: n.response.products
|
|
577
561
|
}));
|
|
578
|
-
return
|
|
562
|
+
return M(() => {
|
|
579
563
|
var k;
|
|
580
564
|
if (!t)
|
|
581
565
|
return {
|
|
@@ -584,32 +568,32 @@ function lt(e) {
|
|
|
584
568
|
resultsTo: 0,
|
|
585
569
|
pages: []
|
|
586
570
|
};
|
|
587
|
-
const n = ((k = r.products) == null ? void 0 : k.from) ?? 0, o = (e == null ? void 0 : e.width) ?? 1 / 0, c = Math.max(Math.floor(o - 1) / 2, 1), s = t.size > 0 ? Math.floor(n / t.size) + 1 : 1, i = t.size > 0 ? Math.ceil(t.total / t.size) : 0, l = (
|
|
571
|
+
const n = ((k = r.products) == null ? void 0 : k.from) ?? 0, o = (e == null ? void 0 : e.width) ?? 1 / 0, c = Math.max(Math.floor(o - 1) / 2, 1), s = t.size > 0 ? Math.floor(n / t.size) + 1 : 1, i = t.size > 0 ? Math.ceil(t.total / t.size) : 0, l = (C) => C >= s - c && C <= s + c, u = n + 1, f = Math.min(n + t.total, t.total), a = {
|
|
588
572
|
from: n,
|
|
589
573
|
page: s,
|
|
590
574
|
current: !0
|
|
591
|
-
},
|
|
592
|
-
from: (
|
|
593
|
-
page:
|
|
594
|
-
current:
|
|
595
|
-
}), m = s > 1 ?
|
|
575
|
+
}, d = (C) => ({
|
|
576
|
+
from: (C - 1) * t.size,
|
|
577
|
+
page: C,
|
|
578
|
+
current: C === s
|
|
579
|
+
}), m = s > 1 ? d(s - 1) : void 0, g = s < i ? d(s + 1) : void 0, h = c === 1 / 0 || s - c - 1 > 1 ? d(1) : void 0, p = c === 1 / 0 || s + c + 1 < i ? d(i) : void 0, S = De(1, i + 1).filter(l).map(d);
|
|
596
580
|
return {
|
|
597
581
|
totalPages: i,
|
|
598
|
-
resultsFrom:
|
|
599
|
-
resultsTo:
|
|
600
|
-
current:
|
|
582
|
+
resultsFrom: u,
|
|
583
|
+
resultsTo: f,
|
|
584
|
+
current: a,
|
|
601
585
|
prev: m,
|
|
602
|
-
next:
|
|
586
|
+
next: g,
|
|
603
587
|
first: h,
|
|
604
|
-
last:
|
|
605
|
-
pages:
|
|
588
|
+
last: p,
|
|
589
|
+
pages: S
|
|
606
590
|
};
|
|
607
591
|
}, [r, t, e == null ? void 0 : e.width]);
|
|
608
592
|
}
|
|
609
|
-
function
|
|
593
|
+
function ct() {
|
|
610
594
|
const [e, r] = I([]), [t, n] = I([]);
|
|
611
|
-
return
|
|
612
|
-
|
|
595
|
+
return N(() => {
|
|
596
|
+
E(async (o) => {
|
|
613
597
|
const { products: c, segments: s } = await o.getSearchSessionParams();
|
|
614
598
|
r(s ?? []), n((c == null ? void 0 : c.personalizationBoost) ?? []);
|
|
615
599
|
});
|
|
@@ -618,59 +602,59 @@ function dt() {
|
|
|
618
602
|
boost: t
|
|
619
603
|
};
|
|
620
604
|
}
|
|
621
|
-
function
|
|
622
|
-
const { facets: e } = y((
|
|
623
|
-
var
|
|
605
|
+
function Le() {
|
|
606
|
+
const { facets: e } = y((u) => {
|
|
607
|
+
var f;
|
|
624
608
|
return {
|
|
625
|
-
facets: ((
|
|
609
|
+
facets: ((f = u.response.products) == null ? void 0 : f.facets) ?? []
|
|
626
610
|
};
|
|
627
|
-
}), { replaceFilter: r, toggleProductFilter: t } =
|
|
628
|
-
(
|
|
629
|
-
const
|
|
630
|
-
if (
|
|
631
|
-
return
|
|
611
|
+
}), { replaceFilter: r, toggleProductFilter: t } = P(), n = v(
|
|
612
|
+
(u) => {
|
|
613
|
+
const f = e == null ? void 0 : e.find((a) => a.type === "stats" && a.field === u);
|
|
614
|
+
if (f && "min" in f && "max" in f)
|
|
615
|
+
return f;
|
|
632
616
|
},
|
|
633
617
|
[e]
|
|
634
|
-
), o =
|
|
635
|
-
(
|
|
636
|
-
var
|
|
637
|
-
return ((
|
|
618
|
+
), o = v(
|
|
619
|
+
(u) => {
|
|
620
|
+
var f;
|
|
621
|
+
return ((f = e == null ? void 0 : e.find((a) => a.field === u)) == null ? void 0 : f.name) ?? u;
|
|
638
622
|
},
|
|
639
623
|
[e]
|
|
640
|
-
), c =
|
|
641
|
-
var
|
|
624
|
+
), c = v((u) => "field" in u && (u.value instanceof Array || u.range instanceof Array), []), s = v((u) => {
|
|
625
|
+
var f;
|
|
642
626
|
return {
|
|
643
|
-
...
|
|
644
|
-
range: (
|
|
645
|
-
gt:
|
|
646
|
-
gte:
|
|
647
|
-
lt:
|
|
648
|
-
lte:
|
|
627
|
+
...u,
|
|
628
|
+
range: (f = u.range) == null ? void 0 : f.map((a) => ({
|
|
629
|
+
gt: a.gt ? Number(a.gt) : a.gt,
|
|
630
|
+
gte: a.gte ? Number(a.gte) : a.gte,
|
|
631
|
+
lt: a.lt ? Number(a.lt) : a.lt,
|
|
632
|
+
lte: a.lte ? Number(a.lte) : a.lte
|
|
649
633
|
}))
|
|
650
634
|
};
|
|
651
|
-
}, []), i =
|
|
652
|
-
(
|
|
653
|
-
value:
|
|
654
|
-
field:
|
|
655
|
-
name: o(
|
|
656
|
-
filter: s(
|
|
635
|
+
}, []), i = v(
|
|
636
|
+
(u) => (u.value ?? []).map((a) => ({
|
|
637
|
+
value: a,
|
|
638
|
+
field: u.field,
|
|
639
|
+
name: o(u.field),
|
|
640
|
+
filter: s(u),
|
|
657
641
|
remove: () => {
|
|
658
|
-
t(
|
|
642
|
+
t(u.field, a, !1);
|
|
659
643
|
}
|
|
660
644
|
})),
|
|
661
645
|
[s, o, t]
|
|
662
|
-
), l =
|
|
663
|
-
(
|
|
664
|
-
var
|
|
665
|
-
const
|
|
666
|
-
if (
|
|
646
|
+
), l = v(
|
|
647
|
+
(u) => (u.range ?? []).map((a) => {
|
|
648
|
+
var g, h;
|
|
649
|
+
const d = a.gte ?? a.gt ?? ((g = n(u.field)) == null ? void 0 : g.min), m = a.lte ?? a.lt ?? ((h = n(u.field)) == null ? void 0 : h.max);
|
|
650
|
+
if (d !== void 0 && m !== void 0)
|
|
667
651
|
return {
|
|
668
|
-
value: `${
|
|
669
|
-
field:
|
|
670
|
-
name: o(
|
|
671
|
-
filter: s(
|
|
652
|
+
value: `${d} - ${m}`,
|
|
653
|
+
field: u.field,
|
|
654
|
+
name: o(u.field),
|
|
655
|
+
filter: s(u),
|
|
672
656
|
remove: () => {
|
|
673
|
-
r(
|
|
657
|
+
r(u.field, void 0);
|
|
674
658
|
}
|
|
675
659
|
};
|
|
676
660
|
}).filter(Boolean),
|
|
@@ -682,13 +666,13 @@ function He() {
|
|
|
682
666
|
toRangeFilter: l
|
|
683
667
|
};
|
|
684
668
|
}
|
|
685
|
-
function
|
|
669
|
+
function Be() {
|
|
686
670
|
const { filter: e } = y((i) => {
|
|
687
671
|
var l;
|
|
688
672
|
return {
|
|
689
673
|
filter: ((l = i.query.products) == null ? void 0 : l.filter) ?? []
|
|
690
674
|
};
|
|
691
|
-
}), { updateSearch: r } =
|
|
675
|
+
}), { updateSearch: r } = P(), { selectFilters: t, toValueFilter: n, toRangeFilter: o } = Le(), c = M(() => e ? e.filter(t).flatMap((i) => "value" in i ? n(i) : "range" in i ? o(i) : []).filter(Boolean) : [], [e, t, o, n]), s = v(() => {
|
|
692
676
|
r({
|
|
693
677
|
products: {
|
|
694
678
|
filter: []
|
|
@@ -710,12 +694,12 @@ function R(e) {
|
|
|
710
694
|
const r = Number(e);
|
|
711
695
|
return isNaN(r) ? void 0 : r;
|
|
712
696
|
}
|
|
713
|
-
function
|
|
714
|
-
var
|
|
715
|
-
const { replaceFilter: r } =
|
|
716
|
-
query:
|
|
717
|
-
products:
|
|
718
|
-
})), o = (
|
|
697
|
+
function Ue(e) {
|
|
698
|
+
var a, d, m;
|
|
699
|
+
const { replaceFilter: r } = P(), { query: t, products: n } = y((g) => ({
|
|
700
|
+
query: g.query,
|
|
701
|
+
products: g.response.products
|
|
702
|
+
})), o = (a = n == null ? void 0 : n.facets) == null ? void 0 : a.find((g) => g.id === e);
|
|
719
703
|
if (!o)
|
|
720
704
|
return {
|
|
721
705
|
min: 0,
|
|
@@ -724,56 +708,56 @@ function Ge(e) {
|
|
|
724
708
|
updateRange: () => {
|
|
725
709
|
}
|
|
726
710
|
};
|
|
727
|
-
const c = (m = (
|
|
728
|
-
const
|
|
729
|
-
(l ===
|
|
730
|
-
lte:
|
|
731
|
-
}) : (
|
|
732
|
-
gte:
|
|
733
|
-
}) : k &&
|
|
734
|
-
gte:
|
|
735
|
-
lte:
|
|
711
|
+
const c = (m = (d = t.products) == null ? void 0 : d.filter) == null ? void 0 : m.find((g) => g.field === o.field), s = c != null && c.range ? c.range[0] : void 0, i = typeof s == "object" && ("gte" in s || "lte" in s) ? [R(s.gte), R(s.lte)] : [void 0, void 0], l = "min" in o ? Math.floor(o.min) : 0, u = "max" in o ? Math.ceil(o.max) : 0, f = ([g, h]) => {
|
|
712
|
+
const p = g !== void 0 ? Math.floor(g) : void 0, S = h !== void 0 ? Math.ceil(h) : void 0, k = p !== void 0, C = S !== void 0;
|
|
713
|
+
(l === p || !k) && (u === S || !C) ? r(o.field, void 0) : (l === p || !k) && C ? r(o.field, {
|
|
714
|
+
lte: S.toString()
|
|
715
|
+
}) : (u === S || !C) && k ? r(o.field, {
|
|
716
|
+
gte: p.toString()
|
|
717
|
+
}) : k && C && r(o.field, {
|
|
718
|
+
gte: p.toString(),
|
|
719
|
+
lte: S.toString()
|
|
736
720
|
});
|
|
737
721
|
};
|
|
738
722
|
return {
|
|
739
723
|
/** Min value */
|
|
740
724
|
min: l,
|
|
741
725
|
/** Max value */
|
|
742
|
-
max:
|
|
726
|
+
max: u,
|
|
743
727
|
/** Range value */
|
|
744
|
-
range: [i[0] ?? l, i[1] ??
|
|
728
|
+
range: [i[0] ?? l, i[1] ?? u],
|
|
745
729
|
/** Update range function */
|
|
746
|
-
updateRange:
|
|
730
|
+
updateRange: f
|
|
747
731
|
};
|
|
748
732
|
}
|
|
749
|
-
function
|
|
750
|
-
const { min: t, max: n, range: o, updateRange: c } =
|
|
733
|
+
function ut(e, r) {
|
|
734
|
+
const { min: t, max: n, range: o, updateRange: c } = Ue(e), { filters: s } = Be(), i = M(() => {
|
|
751
735
|
var h;
|
|
752
|
-
const
|
|
753
|
-
var
|
|
754
|
-
return (
|
|
736
|
+
const a = s.find((p) => {
|
|
737
|
+
var S;
|
|
738
|
+
return (S = p == null ? void 0 : p.filter) == null ? void 0 : S.range;
|
|
755
739
|
});
|
|
756
|
-
let
|
|
757
|
-
if (
|
|
758
|
-
const
|
|
759
|
-
|
|
740
|
+
let d = null;
|
|
741
|
+
if (a) {
|
|
742
|
+
const p = (h = a.filter.range) == null ? void 0 : h[0];
|
|
743
|
+
d = [R(p == null ? void 0 : p.gte), R(p == null ? void 0 : p.lte)];
|
|
760
744
|
}
|
|
761
745
|
const m = [];
|
|
762
|
-
let
|
|
763
|
-
for (;
|
|
764
|
-
const
|
|
746
|
+
let g = Math.floor(t / r) * r;
|
|
747
|
+
for (; g < n; ) {
|
|
748
|
+
const p = g + r, S = d && d[0] === g && d[1] === p;
|
|
765
749
|
m.push({
|
|
766
|
-
min:
|
|
767
|
-
max:
|
|
768
|
-
selected:
|
|
769
|
-
}),
|
|
750
|
+
min: g,
|
|
751
|
+
max: p,
|
|
752
|
+
selected: S
|
|
753
|
+
}), g = p;
|
|
770
754
|
}
|
|
771
755
|
return m;
|
|
772
|
-
}, [s, t, n, r]), l = (
|
|
773
|
-
c([
|
|
774
|
-
},
|
|
775
|
-
c([o[0],
|
|
776
|
-
},
|
|
756
|
+
}, [s, t, n, r]), l = (a) => {
|
|
757
|
+
c([a, o[1]]);
|
|
758
|
+
}, u = (a) => {
|
|
759
|
+
c([o[0], a]);
|
|
760
|
+
}, f = t !== o[0] || n !== o[1];
|
|
777
761
|
return {
|
|
778
762
|
/** Minimum value */
|
|
779
763
|
min: t,
|
|
@@ -788,12 +772,12 @@ function ft(e, r) {
|
|
|
788
772
|
/** Handle min change */
|
|
789
773
|
handleMinChange: l,
|
|
790
774
|
/** Handle max change */
|
|
791
|
-
handleMaxChange:
|
|
775
|
+
handleMaxChange: u,
|
|
792
776
|
/** Is selected */
|
|
793
|
-
isSelected:
|
|
777
|
+
isSelected: f
|
|
794
778
|
};
|
|
795
779
|
}
|
|
796
|
-
function
|
|
780
|
+
function at() {
|
|
797
781
|
const { products: e, keywords: r } = y((t) => t.response);
|
|
798
782
|
return {
|
|
799
783
|
/** Array of products */
|
|
@@ -802,25 +786,25 @@ function pt() {
|
|
|
802
786
|
keywords: r ?? { hits: [], total: 0 }
|
|
803
787
|
};
|
|
804
788
|
}
|
|
805
|
-
function
|
|
789
|
+
function lt() {
|
|
806
790
|
const e = y((t) => {
|
|
807
791
|
var n;
|
|
808
792
|
return (n = t.query.products) == null ? void 0 : n.filter;
|
|
809
793
|
});
|
|
810
|
-
return
|
|
794
|
+
return M(() => e ? e.reduce((t, n) => t + (Array.isArray(n.value) ? n.value.length : 1), 0) : 0, [e]);
|
|
811
795
|
}
|
|
812
|
-
function
|
|
796
|
+
function z(e) {
|
|
813
797
|
return e && !Number.isNaN(e) ? e : 0;
|
|
814
798
|
}
|
|
815
|
-
function
|
|
816
|
-
const { from: t, size: n, total: o } = y((
|
|
817
|
-
var
|
|
799
|
+
function ft(e, r) {
|
|
800
|
+
const { from: t, size: n, total: o } = y((u) => {
|
|
801
|
+
var f, a, d, m, g;
|
|
818
802
|
return {
|
|
819
|
-
from:
|
|
820
|
-
size:
|
|
821
|
-
total:
|
|
803
|
+
from: z(((f = u.query.products) == null ? void 0 : f.from) ?? 0),
|
|
804
|
+
size: z(((d = (a = u.response) == null ? void 0 : a.products) == null ? void 0 : d.size) ?? 0),
|
|
805
|
+
total: z(((g = (m = u.response) == null ? void 0 : m.products) == null ? void 0 : g.total) ?? 0)
|
|
822
806
|
};
|
|
823
|
-
}), { updateSearch: c } =
|
|
807
|
+
}), { updateSearch: c } = P(), s = t + n, i = [...e].reverse().filter((u) => u + r < o);
|
|
824
808
|
return {
|
|
825
809
|
/** from value */
|
|
826
810
|
from: t,
|
|
@@ -833,30 +817,30 @@ function mt(e, r) {
|
|
|
833
817
|
/** Array of size options */
|
|
834
818
|
sizeOptions: i,
|
|
835
819
|
/** Should be called when size is changed */
|
|
836
|
-
handleSizeChange: (
|
|
820
|
+
handleSizeChange: (u) => {
|
|
837
821
|
c({
|
|
838
822
|
products: {
|
|
839
|
-
size:
|
|
823
|
+
size: u
|
|
840
824
|
}
|
|
841
825
|
});
|
|
842
826
|
}
|
|
843
827
|
};
|
|
844
828
|
}
|
|
845
|
-
function
|
|
829
|
+
function Qe(e, r) {
|
|
846
830
|
return e.length !== r.length ? !1 : e.every((t) => r.find((n) => t.field === n.field && t.order === n.order));
|
|
847
831
|
}
|
|
848
|
-
function
|
|
832
|
+
function dt(e) {
|
|
849
833
|
var c, s;
|
|
850
|
-
const r = y((i) => i.query), { updateSearch: t } =
|
|
834
|
+
const r = y((i) => i.query), { updateSearch: t } = P();
|
|
851
835
|
return {
|
|
852
836
|
/** Active sort */
|
|
853
837
|
activeSort: ((c = e.find((i) => {
|
|
854
838
|
var l;
|
|
855
|
-
return
|
|
839
|
+
return Qe(i.value.sort, ((l = r.products) == null ? void 0 : l.sort) || []);
|
|
856
840
|
})) == null ? void 0 : c.id) ?? ((s = e[0]) == null ? void 0 : s.id),
|
|
857
841
|
/** Set sort function */
|
|
858
842
|
setSort: (i) => {
|
|
859
|
-
const l = e.find((
|
|
843
|
+
const l = e.find((u) => u.id === i);
|
|
860
844
|
l && t({
|
|
861
845
|
products: {
|
|
862
846
|
sort: l.value.sort
|
|
@@ -866,29 +850,31 @@ function ht(e) {
|
|
|
866
850
|
};
|
|
867
851
|
}
|
|
868
852
|
export {
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
853
|
+
et as AutocompletePageProvider,
|
|
854
|
+
tt as CategoryPageProvider,
|
|
855
|
+
Ye as InfiniteScroll,
|
|
856
|
+
Re as InfiniteScrollWithLink,
|
|
857
|
+
Xe as SearchInput,
|
|
858
|
+
rt as SearchPageProvider,
|
|
859
|
+
Ze as SerpElement,
|
|
875
860
|
A as StoreContext,
|
|
876
|
-
|
|
861
|
+
ce as createExtendableStore,
|
|
877
862
|
_ as createStore,
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
863
|
+
ue as defaultState,
|
|
864
|
+
Me as getNextPageQuery,
|
|
865
|
+
P as useActions,
|
|
866
|
+
nt as useDecoratedSearchResults,
|
|
867
|
+
ot as useFacet,
|
|
868
|
+
st as useFacets,
|
|
869
|
+
te as useLoadMore,
|
|
884
870
|
y as useNostoAppState,
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
871
|
+
it as usePagination,
|
|
872
|
+
ct as usePersonalization,
|
|
873
|
+
Be as useProductFilters,
|
|
874
|
+
Ue as useRange,
|
|
875
|
+
ut as useRangeSelector,
|
|
876
|
+
at as useResponse,
|
|
877
|
+
lt as useSelectedFiltersCount,
|
|
878
|
+
ft as useSizeOptions,
|
|
879
|
+
dt as useSort
|
|
894
880
|
};
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { InfiniteScrollProps } from './InfiniteScroll';
|
|
2
2
|
/**
|
|
3
3
|
* Infinite scroll component that loads more results when user clicks a link.
|
|
4
|
+
* * @example
|
|
5
|
+
* ```jsx
|
|
6
|
+
* import { InfiniteScrollWithLink } from "@nosto/search-js/preact"
|
|
7
|
+
*
|
|
8
|
+
* // With custom load more button
|
|
9
|
+
* function LoadMoreButton({ pageSize }) {
|
|
10
|
+
* const { loadMore } = useLoadMore(pageSize)
|
|
11
|
+
*
|
|
12
|
+
* return (
|
|
13
|
+
* <button
|
|
14
|
+
* onClick={loadMore}
|
|
15
|
+
* >
|
|
16
|
+
* More results
|
|
17
|
+
* </button>
|
|
18
|
+
* )
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* <InfiniteScrollWithLink loadMoreComponent={LoadMoreButton} pageSize={defaultConfig.pageSize}>
|
|
22
|
+
* {products?.hits?.map(hit => <Product hit={hit} />)}
|
|
23
|
+
* </InfiniteScrollWithLink>
|
|
24
|
+
* ```
|
|
4
25
|
* @group Components
|
|
5
26
|
*/
|
|
6
27
|
export declare function InfiniteScrollWithLink({ children, loadMoreComponent: LoadMore, pageSize }: InfiniteScrollProps): import("preact").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var r=" daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|\\||^<|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\(compatible;?(?:\\s\\w+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|adscanner/|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|cookiehubscan|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|jsjcw_scanner|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|retriever|rexx;|rigor|rss\\b|scanner\\.|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|zgrab",t=/bot|crawl|http|lighthouse|scan|search|spider/i,e;function o(){if(e instanceof RegExp)return e;try{e=new RegExp(r,"i")}catch{e=t}return e}function s(a){return!!a&&o().test(a)}function c(){return s(navigator.userAgent)}exports.isBot=c;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var r = " daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|\\||^<|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\(compatible;?(?:\\s\\w+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|adscanner/|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|cookiehubscan|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|jsjcw_scanner|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|retriever|rexx;|rigor|rss\\b|scanner\\.|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|zgrab", t = /bot|crawl|http|lighthouse|scan|search|spider/i, e;
|
|
2
|
+
function o() {
|
|
3
|
+
if (e instanceof RegExp)
|
|
4
|
+
return e;
|
|
5
|
+
try {
|
|
6
|
+
e = new RegExp(r, "i");
|
|
7
|
+
} catch {
|
|
8
|
+
e = t;
|
|
9
|
+
}
|
|
10
|
+
return e;
|
|
11
|
+
}
|
|
12
|
+
function s(a) {
|
|
13
|
+
return !!a && o().test(a);
|
|
14
|
+
}
|
|
15
|
+
function c() {
|
|
16
|
+
return s(navigator.userAgent);
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
c as isBot
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosto/search-js",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.3",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"types": "./dist/preact/preact.d.ts",
|
|
37
37
|
"import": "./dist/preact/preact.es.js",
|
|
38
38
|
"require": "./dist/preact/preact.cjs.js"
|
|
39
|
+
},
|
|
40
|
+
"./utils": {
|
|
41
|
+
"types": "./dist/utils/utils.d.ts",
|
|
42
|
+
"import": "./dist/utils/utils.es.js",
|
|
43
|
+
"require": "./dist/utils/utils.cjs.js"
|
|
39
44
|
}
|
|
40
45
|
},
|
|
41
46
|
"keywords": [],
|