@dori-ai/dori-side-widget 1.13.201 → 1.13.203

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.
@@ -0,0 +1 @@
1
+ import{A as e,c as t,f as n,p as i}from"../widget.js";import{r,S as s,U as o}from"./store-font-B5B6CNk6.js";import{S as a}from"./anchors-B_5p2Z47.js";function l(e,t){t.buffer+=e.replace(/\r\n?/g,"\n");const n=[];let i=t.buffer.indexOf("\n\n");for(;-1!==i;){const e=t.buffer.slice(0,i);t.buffer=t.buffer.slice(i+2);let r="message";const s=[];for(const t of e.split("\n"))t.startsWith("event:")?r=t.slice(6).trim():t.startsWith("data:")&&s.push(t.slice(5).replace(/^ /,""));s.length&&n.push({event:r,data:s.join("\n")}),i=t.buffer.indexOf("\n\n")}return n}const c=(e=window)=>e.Shopify?.routes?.root||"/";class d extends Error{constructor(e){super(`AI search unavailable (${e})`),this.status=e}}const p=t=>`${e}/ai-search/${encodeURIComponent(t)}`;let h=null;const u=e=>{h=e},f=()=>h?{"X-Dori-Preview":h}:{};async function g(e,t,n,i,r){const s=new URLSearchParams({q:t,mode:n});i.currency&&s.set("currency",i.currency),i.country&&s.set("country",i.country);const o=await fetch(`${p(e)}/suggest?${s}`,{signal:r,headers:f()});if(!o.ok)throw new d(o.status);return(await o.json()).products??[]}async function m(e,t,n){try{const i=t.endsWith("/")?t:`${t}/`,r=new URLSearchParams({q:e,"resources[type]":"collection","resources[limit]":"2"}),s=await fetch(`${i}search/suggest.json?${r}`,{signal:n});if(!s.ok)return[];const o=await s.json();return(o.resources?.results?.collections??[]).filter(e=>!!e.title&&!!e.url).map(e=>({title:e.title,url:e.url}))}catch{return[]}}const x="What are you looking for?",v="Cancel",y="AI search",w="Search all products",b="Preview: only you see AI search",k=new Set(["results","answer","not_found","fallback"]),$="dori-ai-search",q='header, [role="banner"], [id*="header" i], [class*="header" i]';function S(e,t){if(null==e)return!1;try{const n=new URL(e||"/",t);return n.origin===t&&/\/search\/?$/.test(n.pathname)}catch{return!1}}const A=e=>String(e??"").replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[e])),M=(e=!1,t=18)=>`<svg class="spark${e?" live":""}" width="${t}" height="${t}" viewBox="0 0 24 24" aria-hidden="true"><path class="s1" d="M10 4Q11.76 10.24 18 12Q11.76 13.76 10 20Q8.24 13.76 2 12Q8.24 10.24 10 4Z" fill="currentColor"/><path class="s2" d="M19 1.5Q19.77 4.23 22.5 5Q19.77 5.77 19 8.5Q18.23 5.77 15.5 5Q18.23 4.23 19 1.5Z" fill="currentColor"/></svg>`;function z(e,t,n){if(null==e||!Number.isFinite(e))return"";const i=(t||n.currency||"").split(" ")[0].toUpperCase(),r=Number.isInteger(e)?0:2;try{if(i)return new Intl.NumberFormat(n.locale||void 0,{style:"currency",currency:i,minimumFractionDigits:r,maximumFractionDigits:2}).format(e)}catch{}return`${e.toFixed(r)}${i?` ${i}`:""}`}function P(e,t){if(!e)return"#";if(/^https?:\/\//.test(e))return e;if(e.startsWith("//"))return"#";const n=e.startsWith("/")?e:`/${e}`,i=t.root.endsWith("/")?t.root:`${t.root}/`;return"/"===i?n:`${i.slice(0,-1)}${n}`}const L=(e,t)=>P(`/search?q=${encodeURIComponent(e)}&options%5Bprefix%5D=last`,t);function E(e,t){return e?/cdn\.shopify\.com|\/cdn\/shop\//.test(e)?`${e}${e.includes("?")?"&":"?"}width=${t}`:e:""}function j(e,t){const n=z(e.price,e.currency,t),i=e.price_unit?` / ${A(e.price_unit)}`:"",r=e.compare_at?` <s>${A(z(e.compare_at,e.currency,t))}</s>`:"";return`${A(n)}${i}${r}`}const C=(e,t)=>`<div class="grid">${e.map(e=>function(e,t){const n=e.image?`<img src="${A(E(e.image,400))}" alt="" loading="lazy">`:"";return`<a class="card" href="${A(P(e.url,t))}" data-id="${A(e.id)}"><div class="ph">${n}</div>`+(e.brand?`<div class="br">${A(e.brand)}</div>`:"")+`<div class="nm">${A(e.name)}</div><div class="pr">${j(e,t)}${e.sold_out?'<span class="so">Sold out</span>':""}</div></a>`}(e,t)).join("")}</div>`;function F(e){return`<a class="colrow" href="${A((t=e.url,t&&(/^https?:\/\//.test(t)||t.startsWith("/")&&!t.startsWith("//"))?t:"#"))}">${A(e.title)}</a>`;var t}const _=(e,t)=>`<div class="stp${t?" done":""}"><span class="ic">${t?'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m5 12.5 4.5 4.5L19 7.5"/></svg>':""}</span><span class="tx">${A(e)}</span></div>`;function R(e,t,n){return null!=e.cursor?`<div class="loader">${t.loadingMore?'<span class="spin"></span>':""}</div>`:`<div class="end"><a class="more" href="${A(L(t.asked,n))}">${w}</a></div>`}function I(e,t,n,i){return`<div class="empty"><h2>${A(e)}</h2><a class="more" href="${A(L(t.asked,n))}">${w}</a></div>`+(i.length?`<div class="popular"><div class="sech">Popular right now</div>${C(i,n)}</div>`:"")}function N(e,t){return"typing"===e.phase?function(e,t){const n=e.q.trim();if(!n)return"";const i=e=>e===n||n.startsWith(e),r=i(e.collectionsFor)?e.collections.slice(0,2):[],s=i(e.suggestedFor)?e.suggestions.slice(0,4):[];return function(e){return`<button class="airow" data-act="enter">${M()}<span class="lab">${y}</span><span class="q">“${A(e)}”</span><span class="key"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 5v7a3 3 0 0 1-3 3H6"/><path d="m10 11-4 4 4 4"/></svg></span></button>`}(n)+(r.length?`<div class="sech">Collections</div><div class="rows">${r.map(F).join("")}</div>`:"")+(s.length?`<div class="sech">Products</div><div class="rows">${s.map((e,n)=>function(e,t,n){const i=e.image?`<img src="${A(E(e.image,120))}" alt="" loading="lazy">`:'<span class="noimg"></span>';return`<a class="row" href="${A(P(e.url,t))}" data-id="${A(e.id)}" data-i="${n}">${i}<span class="meta"><span class="nm">${A(e.name)}</span><span class="pr">${j(e,t)}</span></span></a>`}(e,t,n)).join("")}</div>`:"")}(e,t):"working"!==e.phase&&e.result?function(e,t){const n=e.result;switch(n.type){case"results":{const s=n.chips.length?`<div class="chips">${n.chips.map(e=>`<button class="chip" data-drop="${A(e.key)}" aria-label="Remove">${A(function(e,t){if("price"===e.kind){const n=e.min?z(e.min,e.currency,t):"",i=e.max?z(e.max,e.currency,t):"";return n&&i?`${n} to ${i}`:i?`Under ${i}`:`From ${n}`}return e.value??""}(e,t))}<svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"/></svg></button>`).join("")}</div>`:"",o=n.note?.currency||t.currency;return s+(n.note?`<div class="note">${A((i=z(n.note.under,o,t),r=null!=n.note.from?z(n.note.from,o,t):null,r?`Nothing under ${i}. Closest from ${r}`:`Nothing under ${i}`))}</div>`:"")+C(n.products,t)+R(n,e,t)}case"fallback":return n.products.length?C(n.products,t)+R(n,e,t):I(`Nothing found for “${e.asked}”`,e,t,[]);case"not_found":return I(`No ${n.noun} found`,e,t,n.popular);case"answer":{if("none"===n.kind)return I("No answer in the store's help pages",e,t,[]);const i=n.text&&"entry"!==n.kind?`<div class="ansh">${M(!1,13)}Answer</div><p class="anst">${A(n.text)}</p>`:"";return`<div class="ans">${i}<div class="src${i?"":" alone"}"><div class="sech">${"page"===n.entry.source?"From the store's pages":"From the store's FAQ"}</div><div class="fq">${A(n.entry.question)}</div><div class="fa">${A(n.entry.answer)}</div></div></div>`}}var i,r}(e,t):function(e){const t=`<div class="aih">${M(!0)}<span class="shim">${y}</span></div>`,n=e.plan?[_(e.plan.label,!0),_("faq"===e.plan.kind?"Checking the store's help pages":(s=e.plan.products,s?`Searching ${s.toLocaleString()} products`:"Searching the products"),!1)]:[_((r=e.asked,`Reading “${r}”`),!1)],i="faq"===e.plan?.kind?'<div class="ans"><span class="skl sk" style="width:92%"></span><span class="skl sk" style="width:70%"></span></div>':`<div class="grid">${Array.from({length:4},()=>'<div class="card skel"><div class="ph"></div><span class="skl sk" style="width:80%"></span><span class="skl sk" style="width:40%"></span></div>').join("")}</div>`;var r,s;return`<div class="aib">${t}<div class="stps">${n.join("")}</div></div>${i}`}(e)}const O="dori-ai-search-last";let T=null;class U{constructor(e){this.config=e,this.state=((e="")=>({q:e,phase:"typing",suggestions:[],collections:[],suggestedFor:"",collectionsFor:"",asked:"",rid:null,drop:[],plan:null,result:null,loadingMore:!1}))(),this.shopper=function(e=window){const t=e.Shopify;return{currency:t?.currency?.active||void 0,country:t?.country||void 0,language:t?.locale||document.documentElement.lang||void 0}}(),this.ctx={locale:navigator.language||"en",currency:this.shopper.currency||"",root:c()},this.host=document.createElement("div"),this.host.id=$,this.host.style.setProperty("display","block","important");const t=this.host.attachShadow({mode:"open"}),n=getComputedStyle(document.body).color||"#111",i=r(document.body);i&&this.host.style.setProperty(s,i),this.host.style.fontFamily=o,t.innerHTML=`<style>\n:host{all:initial}\n*{box-sizing:border-box}\n.wrap{position:fixed;inset:0;z-index:2147483647;color:var(--ink,#111);font-size:14px;line-height:1.35;-webkit-font-smoothing:antialiased}\n.scrim{position:absolute;inset:0;background:rgba(0,0,0,.32);animation:fadein .16s ease both}\n.panel{position:absolute;inset:0;background:#fff;display:flex;flex-direction:column;animation:fadein .16s ease both}\na{color:inherit;text-decoration:none}\nbutton{font:inherit;color:inherit}\n.sbar{display:flex;align-items:center;gap:10px;padding:10px 14px;border-bottom:1px solid var(--line)}\n.field{flex:1;display:flex;align-items:center;gap:8px;height:44px;border-radius:8px;background:#f5f5f5;padding:0 12px;border:1px solid #e6e6e6;min-width:0}\n.field svg{flex:none;color:#777}\n.field input{flex:1;min-width:0;border:0;outline:0;background:none;font:inherit;font-size:16px;color:var(--ink);-webkit-appearance:none;appearance:none}\n.field input::-webkit-search-cancel-button{display:none}\n.cancel{border:0;background:none;font-size:15px;cursor:pointer;padding:6px 2px}\n.cancel .x{display:none}\n.pv{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 14px;font-size:13px;line-height:1.3;background:#fff6d6;color:#4d3b00;border-bottom:1px solid #f0e2a8}\n.pv a{flex:none;text-decoration:underline;white-space:nowrap}\n.body{flex:1;overflow-y:auto;overscroll-behavior:contain;min-height:120px}\n.body:empty{min-height:0}\n.spark{flex:none;display:block}\n.spark.live .s1{transform-origin:10px 12px;animation:pulse 1.3s ease-in-out infinite}\n.spark.live .s2{transform-origin:19px 5px;animation:twinkle 1.3s ease-in-out infinite}\n@keyframes pulse{50%{transform:scale(.76)}}\n@keyframes twinkle{0%,100%{opacity:.2;transform:scale(.55)}50%{opacity:1;transform:scale(1)}}\n.airow{display:flex;align-items:center;gap:10px;width:calc(100% - 24px);margin:10px 12px 2px;padding:12px;border:0;border-radius:12px;background:var(--ai);cursor:pointer;text-align:left;transition:transform .12s ease}\n.airow:active{transform:scale(.975)}\n.airow .lab{font-weight:600;white-space:nowrap;font-size:15px}\n.airow .q{min-width:0;flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#5c5c5c;font-size:15px}\n.airow .key{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:24px;border-radius:7px;background:#fff;border:1px solid var(--line);color:#555}\n.sech{font-weight:600;font-size:11px;line-height:1;letter-spacing:.12em;text-transform:uppercase;color:#777;margin:16px 14px 6px}\n.rows{display:flex;flex-direction:column}\n.row{display:flex;align-items:center;gap:12px;padding:7px 14px}\n.row img,.row .noimg{width:46px;height:46px;object-fit:contain;background:#f6f6f6;border-radius:6px;flex:none}\n.row .meta{min-width:0;flex:1;display:flex;flex-direction:column}\n.row .nm{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.row .pr{font-size:13px;color:#555;margin-top:2px}\n.colrow{display:block;padding:8px 14px;font-size:14px}\n.aib{padding:16px 16px 0}\n.aih{display:flex;align-items:center;gap:8px;font-weight:600;font-size:15.5px}\n.shim{background:linear-gradient(90deg,var(--ink) 0%,var(--ink) 38%,#c4c4c4 50%,var(--ink) 62%,var(--ink) 100%);background-size:260% 100%;-webkit-background-clip:text;background-clip:text;color:transparent;animation:shim 1.7s linear infinite}\n@keyframes shim{from{background-position:100% 0}to{background-position:-160% 0}}\n.stps{margin:10px 0 0 1px;display:flex;flex-direction:column;gap:8px}\n.stp{display:flex;align-items:center;gap:9px;font-size:14px;color:#6b6b6b;animation:fadein .24s ease both}\n.stp .ic{width:15px;height:15px;flex:none;border-radius:50%;border:1.7px solid #d2d2d2;border-top-color:var(--ink);animation:spin .8s linear infinite;display:flex;align-items:center;justify-content:center}\n.stp.done{color:var(--ink)}\n.stp.done .ic{border:0;animation:none}\n.stp .tx{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n@keyframes spin{to{transform:rotate(360deg)}}\n.chips{display:flex;flex-wrap:wrap;gap:6px;padding:10px 14px 0}\n.chip{display:inline-flex;align-items:center;gap:7px;font-size:13px;border:1px solid var(--ink);border-radius:999px;padding:5px 11px;cursor:pointer;background:#fff}\n.note{margin:10px 14px 0;font-size:13px;color:#6b6b6b}\n.grid{display:grid;grid-template-columns:1fr 1fr;gap:18px 10px;padding:14px 14px 20px}\n.card{min-width:0;display:block}\n.card .ph{aspect-ratio:1/1;background:#f6f6f6;border-radius:6px;overflow:hidden}\n.card .ph img{width:100%;height:100%;object-fit:contain;display:block}\n.card .br{font-size:10.5px;font-weight:500;line-height:1.2;letter-spacing:.12em;text-transform:uppercase;color:#777;margin-top:8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.card .nm{font-size:13.5px;line-height:1.3;margin-top:3px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}\n.card .pr{font-size:13.5px;margin-top:4px}\n.card .pr s,.row .pr s{color:#8a8a8a;margin-left:4px}\n.card .so{font-size:11px;color:#a33;margin-left:6px}\n.card.skel .ph,.sk{background:linear-gradient(90deg,#f3f3f3,#e9e9e9,#f3f3f3);background-size:200% 100%;animation:sh 1.2s linear infinite}\n.skl{display:block;height:10px;border-radius:5px;margin-top:9px}\n@keyframes sh{to{background-position:-200% 0}}\n.ans{padding:18px 16px 24px}\n.ansh{display:flex;align-items:center;gap:6px;font-weight:600;font-size:11px;line-height:1;letter-spacing:.12em;text-transform:uppercase;color:#777}\n.anst{margin:10px 0 0;font-size:16.5px;line-height:1.5}\n.src{margin-top:20px;border-top:1px solid var(--line);padding-top:16px}\n.src.alone{margin-top:0;border-top:0;padding-top:0}\n.src .sech{margin:0 0 9px}\n.src .fq{font-weight:500;font-size:15px;line-height:1.3}\n.src .fa{margin-top:6px;font-size:13.5px;line-height:1.5;color:#555;white-space:pre-line}\n.empty{padding:36px 20px 20px;text-align:center}\n.empty h2{margin:0;font-weight:500;font-size:21px;line-height:1.25}\n.more{display:inline-block;margin-top:12px;font-size:13.5px;color:#6b6b6b;text-decoration:underline}\n.end{text-align:center;padding:0 14px 28px}\n.loader{display:flex;justify-content:center;padding:4px 0 28px;min-height:40px}\n.spin{width:18px;height:18px;border-radius:50%;border:2px solid #ddd;border-top-color:var(--ink);animation:spin .8s linear infinite}\n.popular{border-top:1px solid var(--line);margin:6px 14px 0;padding-top:14px}\n.popular .sech{margin:0 0 2px}\n.popular .grid{padding:12px 0 28px}\n@keyframes fadein{from{opacity:0}to{opacity:1}}\n@media (min-width:750px){\n .scrim{background:rgba(0,0,0,.18)}\n .panel{inset:auto;top:var(--top,16px);left:var(--left,16px);width:var(--w,min(760px,100vw - 32px));max-height:calc(100vh - var(--top,16px) - 16px);border-radius:12px;overflow:hidden;box-shadow:0 0 0 1px rgba(0,0,0,.06),0 14px 40px rgba(0,0,0,.16);animation:drop .14s ease-out both}\n .sbar{height:56px;padding:0 8px 0 16px;gap:6px;border-bottom:0}\n .field{height:56px;padding:0;gap:10px;border:0;border-radius:0;background:none}\n .body:not(:empty){border-top:1px solid var(--line)}\n .pv{padding:8px 16px}\n .pv + .body:not(:empty){border-top:0}\n .cancel{display:flex;align-items:center;justify-content:center;width:36px;height:36px;padding:0;border-radius:8px;color:#6b6b6b}\n .cancel:hover{background:#f2f2f2;color:var(--ink)}\n .cancel .t{display:none}\n .cancel .x{display:block}\n .grid{grid-template-columns:repeat(4,minmax(0,1fr))}\n .narrow .grid{grid-template-columns:repeat(3,minmax(0,1fr))}\n}\n@keyframes drop{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}\n@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}\n</style><div class="wrap" style="--ink:${n};--ai:color-mix(in srgb, ${n} 6%, #fff);--line:#eaeaea" hidden><div class="scrim"></div><div class="panel" role="dialog" aria-modal="true" aria-label="${y}"><form class="sbar" role="search"><label class="field"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/></svg><input type="search" enterkeyhint="search" autocomplete="off" autocapitalize="off" spellcheck="false" placeholder="${x}"></label><button type="button" class="cancel" aria-label="${v}"><span class="t">${v}</span><svg class="x" width="18" height="18" viewBox="0 0 18 18" aria-hidden="true"><path d="M4.5 4.5l9 9M13.5 4.5l-9 9" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg></button></form>`+(e.preview?`<div class="pv"><span>${b}</span><a class="pvl" target="_blank" rel="noopener">Your usual results</a></div>`:"")+'<div class="body"></div></div></div>',this.input=t.querySelector("input"),this.setPlaceholder(e.placeholder),this.body=t.querySelector(".body"),this.syncPreviewBar(),t.querySelector("form").addEventListener("submit",e=>{e.preventDefault(),this.search()}),this.input.addEventListener("input",()=>this.typed()),t.querySelector(".cancel").addEventListener("click",()=>this.close()),t.querySelector(".scrim").addEventListener("click",()=>this.close()),this.body.addEventListener("click",e=>this.clicked(e)),this.body.addEventListener("scroll",()=>this.scrolled(),{passive:!0}),window.addEventListener("popstate",this.onPop),window.addEventListener("resize",this.onResize,{passive:!0}),document.addEventListener("keydown",this.onKey,!0),document.documentElement.appendChild(this.host)}host;input;body;state;ctx;shopper;timers=[];suggestAbort=null;searchAbort=null;moreAbort=null;pausedFor="";isOpen=!1;pushed=!1;overflow="";started=0;anchor=null;notice=null;setPlaceholder(e){this.input.placeholder=e?.trim()||x}get tag(){return this.config.preview?{preview:!0}:{}}get wrap(){return this.host.shadowRoot.querySelector(".wrap")}place(){const e=this.host.shadowRoot.querySelector(".panel");if(!window.matchMedia("(min-width: 750px)").matches)return e.removeAttribute("style"),void e.classList.remove("narrow");let t=this.anchor&&this.anchor.isConnected?this.anchor:null,n=t?.getBoundingClientRect();(!n||n.width<=0)&&(t=function(){for(const e of document.querySelectorAll(a)){if(e.closest(`#${$}`))continue;const t=e.getBoundingClientRect();if(t.width>0&&t.height>0&&t.top<window.innerHeight/3)return e}return null}(),n=t?.getBoundingClientRect());const i=function(e,t,n){const i=t-32;if(!e||e.width<=0||e.height<=0){const e=Math.min(760,i);return{top:16,left:Math.round((t-e)/2),width:e}}const r=e.width>=240,s=Math.round(Math.min(i,r?Math.max(e.width+16,560):760)),o=r?e.left-8:(t-s)/2,a=e.top+e.height/2-28;return{top:Math.round(Math.min(Math.max(a,8),Math.max(8,n-240))),left:Math.round(Math.min(Math.max(o,16),t-16-s)),width:s}}(n??null,window.innerWidth,window.innerHeight);e.style.setProperty("--top",`${i.top}px`),e.style.setProperty("--left",`${i.left}px`),e.style.setProperty("--w",`${i.width}px`),e.classList.toggle("narrow",i.width<860)}onResize=()=>{this.isOpen&&this.place()};open(e,n,i=null){if(!this.isOpen){this.isOpen=!0,this.anchor=i,this.wrap.hidden=!1,this.overflow=document.documentElement.style.overflow,document.documentElement.style.overflow="hidden",this.place();try{history.pushState({...history.state||{},doriAiSearch:!0},""),this.pushed=!0}catch{this.pushed=!1}t("ai_search_open",{run:n,...this.tag})}e&&e!==this.input.value&&(this.input.value=e,this.typed()),n||this.input.focus(),n&&e.trim()&&this.search()}restore(e){this.isOpen=!0;try{history.replaceState({...history.state||{},doriAiSearch:!1},""),history.pushState({...history.state||{},doriAiSearch:!0},""),this.pushed=!0}catch{this.pushed=!1}this.wrap.hidden=!1,this.overflow=document.documentElement.style.overflow,document.documentElement.style.overflow="hidden",this.anchor=null,this.place(),this.input.value=e.q,this.dispatch({type:"restore",q:e.q,rid:e.rid,result:e.result,drop:e.drop})}close(e=!1){this.isOpen&&(this.isOpen=!1,this.cancelAll(),this.wrap.hidden=!0,document.documentElement.style.overflow=this.overflow,this.pushed&&!e&&history.state?.doriAiSearch&&(this.pushed=!1,history.back()),this.pushed=!1)}destroy(){this.close(),window.removeEventListener("popstate",this.onPop),window.removeEventListener("resize",this.onResize),document.removeEventListener("keydown",this.onKey,!0),this.host.remove()}onKey=e=>{this.isOpen&&"Escape"===e.key&&(e.stopPropagation(),this.close())};onPop=()=>{this.isOpen&&!history.state?.doriAiSearch&&this.close(!0)};syncPreviewBar(){const e=this.host.shadowRoot,t=e.querySelector(".pvl");if(!t)return;const n=this.input.value.trim();t.setAttribute("href",function(e,t,n,i){const r=t.find(e=>S(e.action,n));if(!r)return i;const s=new URL(r.action||"/search",n);for(const[o,a]of r.hidden)"q"!==o&&s.searchParams.set(o,a);return s.searchParams.set("q",e),s.pathname+s.search}(n,[...document.querySelectorAll("form")].map(e=>({action:e.getAttribute("action"),hidden:[...e.querySelectorAll('input[type="hidden"][name]')].map(e=>[e.name,e.value])})),location.origin,L(n,this.ctx)));const i="done"===this.state.phase&&"fallback"===this.state.result?.type&&!this.notice;e.querySelector(".pv span").textContent=i?"Preview: AI didn't run for this search, so these are plain results":b}dispatch(e){this.state=function(e,t){switch(t.type){case"input":return{...e,q:t.q,phase:"typing",rid:null,plan:null,result:null,loadingMore:!1};case"suggested":return t.q!==e.q.trim()||"typing"!==e.phase?e:t.collections?{...e,suggestions:t.products,suggestedFor:t.q,collections:t.collections,collectionsFor:t.q}:{...e,suggestions:t.products,suggestedFor:t.q};case"enter":return{...e,phase:"working",asked:e.q.trim(),rid:t.rid,drop:t.drop??[],plan:null,result:null,loadingMore:!1};case"server":return t.rid!==e.rid||"working"!==e.phase?e:"plan"===t.event.type?{...e,plan:t.event}:k.has(t.event.type)?{...e,phase:"done",result:t.event}:e;case"failed":return t.rid!==e.rid||"working"!==e.phase?e:{...e,phase:"done",result:{type:"fallback",products:[],cursor:null}};case"loading_more":return t.rid!==e.rid?e:{...e,loadingMore:!0};case"more":{const n=e.result;if(t.rid!==e.rid||!n||"results"!==n.type&&"fallback"!==n.type)return e;const i=new Set(n.products.map(e=>e.id)),r=[...n.products,...t.products.filter(e=>!i.has(e.id))];return{...e,loadingMore:!1,result:{...n,products:r,cursor:t.cursor}}}case"restore":return{...e,q:t.q,asked:t.q,rid:t.rid,drop:t.drop,phase:"done",result:t.result,plan:null,loadingMore:!1}}}(this.state,e),this.syncPreviewBar();const t=this.body.scrollTop;this.body.innerHTML=this.notice&&"done"===this.state.phase?`<div class="empty"><h2>${this.notice}</h2></div>`:N(this.state,this.ctx),"done"===this.state.phase&&(this.body.scrollTop=t)}cancelAll(){this.timers.forEach(e=>clearTimeout(e)),this.timers=[];for(const e of[this.suggestAbort,this.searchAbort,this.moreAbort])e?.abort();this.suggestAbort=this.searchAbort=this.moreAbort=null}typed(){this.cancelAll(),this.body.scrollTop=0,this.dispatch({type:"input",q:this.input.value});const e=this.input.value.trim();if(!e)return;this.pausedFor="";const t=new AbortController;this.suggestAbort=t,this.timers.push(window.setTimeout(()=>{g(this.config.sharingId,e,"key",this.shopper,t.signal).then(t=>{this.pausedFor!==e&&this.dispatch({type:"suggested",q:e,products:t})}).catch(()=>{})},80)),this.timers.push(window.setTimeout(()=>{Promise.all([g(this.config.sharingId,e,"pause",this.shopper,t.signal),m(e,this.ctx.root,t.signal)]).then(([t,n])=>{this.pausedFor=e,this.dispatch({type:"suggested",q:e,products:t,collections:n})}).catch(()=>{})},350))}search(e=[]){const i=this.input.value.trim();if(!i)return;this.cancelAll();const r=function(){const e=globalThis.crypto;if(e?.randomUUID)return e.randomUUID();const t=Array.from({length:16},()=>Math.floor(256*Math.random()));t[6]=15&t[6]|64,t[8]=63&t[8]|128;const n=t.map(e=>e.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}();this.notice=null,this.started=performance.now(),this.dispatch({type:"enter",rid:r,drop:e}),this.input.blur(),this.body.scrollTop=0;const s=new AbortController;this.searchAbort=s,async function(e,t,n,i){const r=await fetch(`${p(e)}/search`,{method:"POST",headers:{"Content-Type":"application/json",...f()},body:JSON.stringify(t),signal:i});if(!r.ok||!r.body)throw new d(r.status);const s=r.body.getReader(),o=new TextDecoder,a={buffer:""};for(;;){const{done:e,value:t}=await s.read(),i=e?o.decode()+"\n\n":o.decode(t,{stream:!0});for(const r of l(i,a))try{n(JSON.parse(r.data))}catch{}if(e)return}}(this.config.sharingId,{q:i,rid:r,drop:e,...this.shopper},e=>{this.dispatch({type:"server",rid:r,event:e}),"plan"!==e.type&&t("ai_search_enter",{outcome:e.type,ms:Math.round(performance.now()-this.started),count:"products"in e&&Array.isArray(e.products)?e.products.length:void 0,...this.tag})},s.signal).then(()=>this.dispatch({type:"failed",rid:r})).catch(e=>{if(!s.signal.aborted){if(e instanceof d){const s=(t=e.status,this.config.preview?404===t?{notice:'This preview link no longer works. Open "Try it on your store" in Dori again.',forget:!0}:{notice:"No more preview searches for now. Try again later.",forget:!1}:"leave");return"leave"===s?(this.close(),void location.assign(L(i,this.ctx))):(s.forget&&n(),this.notice=s.notice,void this.dispatch({type:"failed",rid:r}))}var t;this.dispatch({type:"failed",rid:r})}})}loadMore(){const e=this.state.result,t=this.state.rid;if(!t||this.state.loadingMore||!e||"results"!==e.type&&"fallback"!==e.type||null==e.cursor)return;this.dispatch({type:"loading_more",rid:t});const n=new AbortController;this.moreAbort=n,async function(e,t,n,i){const r=await fetch(`${p(e)}/more?${new URLSearchParams({rid:t,cursor:String(n)})}`,{signal:i,headers:f()});if(!r.ok)throw new d(r.status);return await r.json()}(this.config.sharingId,t,e.cursor,n.signal).then(e=>this.dispatch({type:"more",rid:t,products:e.products,cursor:e.cursor})).catch(()=>{n.signal.aborted||this.dispatch({type:"more",rid:t,products:[],cursor:null})})}scrolled(){const e=this.body;e.scrollTop+e.clientHeight>e.scrollHeight-500&&this.loadMore()}clicked(e){const n=e.target;if(n.closest("[data-act='enter']"))return e.preventDefault(),void this.search();const i=n.closest("[data-drop]");if(i)return e.preventDefault(),void this.search([...this.state.drop,i.dataset.drop]);const r=n.closest("a.card, a.row");r&&(t("ai_search_click",{phase:this.state.phase,outcome:this.state.result?.type,id:r.dataset.id,...this.tag}),this.save())}save(){const e=this.state;if("done"!==e.phase||!e.result||!e.rid)return;const t={q:e.asked,rid:e.rid,drop:e.drop,result:e.result,url:location.href,at:Date.now()};try{sessionStorage.setItem(O,JSON.stringify(t))}catch{}}}let D=null,B=null,W=null;function Q(e,t,n=null){return!(!e||!0!==e.feature_flags?.ai_search&&!n||t)}function H(e,t,n,i){return i||(n?t:e?null:t)}function K(e,t,n=null){const r=window,s=H(!0===e?.feature_flags?.ai_search,n,i(),W);if(!Q(e,!0===r.Shopify?.designMode,s))return D?.(),D=null,B=null,W=null,u(null),T?.destroy(),void(T=null);W=s,u(s);const o=e?.feature_flags?.ai_search_placeholder;B={sharingId:t,preview:!!s,placeholder:o},function(e){T?.setPlaceholder(e)}(o),D||(D=function(e,t,n){const i=e=>{const i=e.target;if(!i||"FORM"!==i.tagName||!S(i.getAttribute("action"),n))return;e.preventDefault(),e.stopImmediatePropagation();const r=i.querySelector('input[name="q"]');t(r?.value??"",!0,r??i)},r=e=>{const i=e.target;i&&"INPUT"===i.tagName&&i.matches('input[type="search"], input[name="q"]')&&(i.form?S(i.form.getAttribute("action"),n):i.closest?.(q))&&(i.blur?.(),t(i.value??"",!1,i))},s=e=>{const i=e;if(i.defaultPrevented||0!==(i.button??0)||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey)return;const r=e.target;if(!r?.closest)return;const s=r.closest(a);if(!s||"INPUT"===s.tagName)return;if(s.closest(`#${$}`))return;if("FORM"===s.tagName||r.closest("form"))return;if(!("A"===s.tagName?S(s.getAttribute("href"),n):s.closest(q)))return;e.preventDefault(),e.stopImmediatePropagation();const o="A"===s.tagName?function(e,t){if(!e)return"";try{return new URL(e,t).searchParams.get("q")??""}catch{return""}}(s.getAttribute("href"),n):"";t(o,!!o,s)};return e.addEventListener("submit",i,!0),e.addEventListener("focusin",r,!0),e.addEventListener("click",s,!0),()=>{e.removeEventListener("submit",i,!0),e.removeEventListener("focusin",r,!0),e.removeEventListener("click",s,!0)}}(window,(e,t,n)=>B&&function(e,t,n,i=null){T||(T=new U(B)),T.open(t,n,i)}(0,e,t,n),location.origin),function(e){let t=null;try{t=JSON.parse(sessionStorage.getItem(O)||"null")}catch{t=null}const n=history.state,i=n?.doriAiSearch?function(e,t,n){return!e||e.url!==t||n-e.at>18e5?null:e}(t,location.href,Date.now()):null;i&&(T||(T=new U(e)),T.restore(i))}(B))}export{K as applyAiSearch,H as keyForPage,Q as wantsAiSearch};
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./MarkdownContent-DEZk-48W.js","./provider-PfefeRav.js","../widget.js","./store-font-B5B6CNk6.js","./link-BGyuhQrO.js"])))=>i.map(i=>d[i]);
2
+ import{j as e,a as n,n as t,aB as a,ah as i,ak as r,aj as s,ag as o,ai as l,k as c,bi as p,ab as d,bk as u,ad as m,ae as h,bl as g}from"./provider-PfefeRav.js";import{n as x,_ as f,P as b,Q as v,t as y,R as k,S as w,T as j,A as z,U as N,H as S}from"../widget.js";import"./store-font-B5B6CNk6.js";const C={current:null},A={fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},_=()=>e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",strokeWidth:"2",...A,"aria-hidden":!0,children:e.jsx("path",{d:"M12 5v14M5 12h14"})}),P=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",strokeWidth:"2.4",...A,"aria-hidden":!0,children:e.jsx("path",{d:"m5 12.5 4.5 4.5L19 7.5"})}),q=()=>e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",strokeWidth:"1.8",...A,"aria-hidden":!0,children:e.jsx("path",{d:"M12 20s-7-4.4-7-10a4 4 0 0 1 7-2.6A4 4 0 0 1 19 10c0 5.6-7 10-7 10Z"})}),I=()=>e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",strokeWidth:"1.8",...A,"aria-hidden":!0,children:e.jsx("path",{d:"M5 12h14M13 6l6 6-6 6"})}),R=()=>e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",strokeWidth:"2",...A,"aria-hidden":!0,children:e.jsx("path",{d:"m15 5-7 7 7 7"})}),E=()=>e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",strokeWidth:"2",...A,"aria-hidden":!0,children:e.jsx("path",{d:"m9 5 7 7-7 7"})}),D=()=>e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",strokeWidth:"2",...A,"aria-hidden":!0,children:e.jsx("path",{d:"M6 6l12 12M18 6 6 18"})}),F=()=>e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",strokeWidth:"1.8",...A,"aria-hidden":!0,children:[e.jsx("path",{d:"M5 8h14l-1 13H6L5 8Z"}),e.jsx("path",{d:"M9 8V6a3 3 0 0 1 6 0v2"})]}),$=()=>e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",strokeWidth:"2.2",...A,"aria-hidden":!0,children:e.jsx("path",{d:"M12 19V5M5.5 11.5 12 5l6.5 6.5"})}),M=/\b(colou?rs?|colou?rway|colore|colori|couleurs?|farben?|kleur(en)?|cor(es)?|shade|warna|renk|kolor|barva|f[äa]rg)\b/i,L=/\b(sizes?|taille|gr(ö|oe)(ß|ss)e|talla|maat|tamanho|misura|taglia|storlek|st(ø|o)rrelse|koko|rozmiar|velikost|m(é|e)ret|beden|ukuran)\b/i,U=/\b(siz(e|ing) (down|up)|true to size|(your|their) true size|runs? (small|large|big)|order (one|a) size|fits? (small|large|true))\b/i,O=/detail|feature|highlight|measure|spec|dimension|size ?& ?fit|^fit|fabric|material|content|composition|care/i,B=/size guide|sizing guide|size chart|guideline/i,T=e=>e?e.startsWith("//")?`https:${e}`:e:void 0;function W(e){const n=(e??"").match(/(?:^|\/)products\/([^/?#]+)/);return n?decodeURIComponent(n[1]):null}const Z={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",rsquo:"’",lsquo:"‘",rdquo:"”",ldquo:"“",ndash:"-",mdash:"-",hellip:"…",deg:"°",reg:"®",trade:"™",copy:"©",frac12:"½"};function G(e){const n=function(e){return(n=e.replace(/<(script|style)[\s\S]*?<\/\1>/gi,"").replace(/<li[^>]*>\s*/gi,"\n• ").replace(/<br\s*\/?>/gi,"\n").replace(/<\/?(p|div|h[1-6]|ul|ol|tr|table|section|blockquote)[^>]*>/gi,"␞").replace(/<[^>]+>/g,""),n.replace(/&(#x?[0-9a-f]+|[a-z]+[0-9]*);/gi,(e,n)=>{if("#"===n[0]){const t="x"===n[1].toLowerCase()?parseInt(n.slice(2),16):parseInt(n.slice(1),10);return Number.isFinite(t)&&t>0?String.fromCodePoint(t):e}return Z[n.toLowerCase()]??e})).split("␞").map(e=>e.split("\n").map(e=>e.replace(/\s+/g," ").trim()).filter(e=>e&&"•"!==e).map(e=>e.replace(/^[-*–]\s+/,"• "))).filter(e=>e.length>0);var n}(e??""),t=[];let a=null;for(const o of n.flat()){const e=o.startsWith("• "),n=e?o.slice(2).trim():o;if(!n)continue;const i=e?null:n.match(/^([^:]{2,40}):\s*(.*)$/);i?(a={label:i[1].trim(),items:i[2]?[i[2].trim()]:[]},t.push(a)):a&&(e||0===a.items.length)?a.items.push(n):a=null}const i=function(e){const n=[];for(const t of e){let e=[],a=[];const i=()=>{e.length&&n.push({type:"p",text:e.join(" ")}),a.length&&n.push({type:"ul",items:a}),e=[],a=[]};for(const n of t)n.startsWith("• ")?(e.length&&i(),a.push(n.slice(2).trim())):(a.length&&i(),e.push(n));i()}return n}(n),r=i.find(e=>"p"===e.type&&U.test(e.text))?.text??i.flatMap(e=>"ul"===e.type?e.items:[]).find(e=>U.test(e))??null;return{sections:t.filter(e=>e.items.length>0&&O.test(e.label)&&!B.test(e.label)).slice(0,3).map(e=>({label:e.label,items:e.items.slice(0,6)})),full:i,tip:r?(s=r,s.length>420?`${s.slice(0,419).trimEnd()}…`:s):null};var s}function K(e,n,t){return e.variants.filter(a=>!(null!==n&&null!==e.colourIndex&&a.options[e.colourIndex]!==n||null!==t&&null!==e.sizeIndex&&a.options[e.sizeIndex]!==t))}const X=(e,n,t)=>K(e,n,t).some(e=>e.available);function H(e,n){const t=n?e.variants.find(e=>e.id===String(n)):void 0;if(t)return{price:t.price,compareAt:t.compareAt,from:!1};const a=e.variants.map(e=>e.price);if(0===a.length)return{price:e.price,compareAt:e.compareAt,from:!1};const i=Math.min(...a),r=e.variants.find(e=>e.price===i);return{price:i,compareAt:r?.compareAt??null,from:i<Math.max(...a)}}const V=new Map,Y=new Map;function J(e,{fresh:n=!1}={}){const t=W(e);if(!t)return Promise.resolve(null);let a=n?void 0:V.get(t);return a||(a=fetch(`${x()}products/${encodeURIComponent(t)}.js`,{credentials:"same-origin",...n?{cache:"no-store"}:{}}).then(e=>e.ok?e.json():null).then(e=>e?function(e){const n=(e.options??[]).map(e=>"string"==typeof e?e:e.name),t=(e.options??[]).map(e=>"string"==typeof e?[]:e.values??[]),a=e=>(t[e]?.length??0)>1,i=(e,t)=>{const i=n.findIndex((n,i)=>e.test(n)&&!(t&&t.test(n))&&a(i));return-1===i?null:i},r=i(M),s=i(L,M),o=n.findIndex(e=>L.test(e)&&!M.test(e)),l=-1===o?null:o,c=n.some((e,n)=>a(n)&&n!==r&&n!==s),p=!!e.requires_selling_plan||(e.variants??[]).some(e=>!!e.requires_selling_plan||(e.quantity_rule?.min??1)>1||(e.quantity_rule?.increment??1)>1),d=(e.variants??[]).map(e=>{const n="number"==typeof e.price?e.price/100:0,t="number"==typeof e.compare_at_price?e.compare_at_price/100:null;return{id:String(e.id),options:e.options??[e.option1,e.option2,e.option3].filter(e=>!!e),available:!1!==e.available,price:n,compareAt:null!==t&&t>n?t:null,image:T(e.featured_image?.src)}}),u=null===r?[]:t[r].map(e=>{const n=d.filter(n=>n.options[r]===e);return{name:e,image:n.find(e=>e.image)?.image,available:n.some(e=>e.available)}}),m="number"==typeof e.price?e.price/100:0,h="number"==typeof e.compare_at_price?e.compare_at_price/100:null;return{handle:e.handle??"",url:e.url??"",title:e.title??"",vendor:e.vendor??"",productType:e.type??"",price:m,compareAt:null!==h&&h>m?h:null,images:(e.images??[]).map(T).filter(e=>!!e),colourIndex:r,sizeIndex:s,sizeOption:l,colours:u,sizes:null===s?[]:t[s],variants:d,extraOptions:c,sellingRules:p,...G(e.description)}}(e):null).catch(()=>null),V.set(t,a),n&&a.then(e=>{e&&Y.get(t)?.forEach(n=>n(e))})),a}function Q(e,n){if(!e)return"";if(!/cdn\.shopify\.com|\/cdn\/shop\//.test(e))return e;const t=e.replace(/([?&])width=\d+&?/,"$1").replace(/[?&]$/,"");return`${t}${t.includes("?")?"&":"?"}width=${n}`}function ee(e){const[t,a]=n.useState(void 0);return n.useEffect(()=>{let n=!0;a(void 0),J(e).then(e=>{n&&a(e)});const t=W(e),i=e=>{n&&a(e)};return t&&(Y.has(t)||Y.set(t,new Set),Y.get(t).add(i)),()=>{n=!1,t&&Y.get(t)?.delete(i)}},[e]),t}function ne(e,n){const t=[];for(const a of[e,...n])if(a&&!t.some(e=>{return n=a,e.split("?")[0]===n.split("?")[0];var n})&&t.push(a),5===t.length)break;return t}function te({photos:t,name:a,width:i,labels:r}){const s=n.useRef(null),[o,l]=n.useState(0),c=e=>{const n=s.current;n&&n.scrollBy({left:e*n.clientWidth,behavior:"smooth"})};return e.jsxs("div",{className:"gal",children:[e.jsx("div",{className:"slides",ref:s,tabIndex:0,"aria-label":r.photos.replace("{name}",a),onScroll:e=>{const n=e.currentTarget;l(Math.round(n.scrollLeft/Math.max(1,n.clientWidth)))},children:t.map((n,t)=>e.jsx("span",{className:"frame",children:e.jsx("img",{src:Q(n,i),alt:t?"":a,loading:t?"lazy":void 0})},n))}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dots",children:t.map((n,t)=>e.jsx("i",{className:t===o?"on":void 0},n))}),e.jsx("button",{type:"button",className:"gnav gprev","aria-label":r.prev,onClick:()=>c(-1),children:e.jsx(R,{})}),e.jsx("button",{type:"button",className:"gnav gnext","aria-label":r.next,onClick:()=>c(1),children:e.jsx(E,{})})]})]})}const ae=/\b(colou?rs?|colou?rway|colore|colori|couleurs?|farben?|kleur(en)?|cor(es)?|shade|warna|renk|kolor|barva|f[äa]rg)\b/i,ie=/\b(sizes?|taille|gr(ö|oe)(ß|ss)e|talla|maat|tamanho|misura|taglia|storlek|st(ø|o)rrelse|koko|rozmiar|velikost|m(é|e)ret|beden|ukuran)\b/i,re=e=>(e??"").trim().toLowerCase(),se=e=>Object.entries(e.options).find(([e])=>ae.test(e))?.[1]??null;function oe(e){const n=e.qualifying_variants;if(!n?.length)return null;const t=re(e.selected_color);return t&&n.find(e=>re(se(e))===t)||n[0]}function le(e,n){const t=n?re(se(n)):"";if(t)for(const a of e.variant_summary?.options??[]){if(!ae.test(a.name))continue;const e=a.values.find(e=>re(e.value)===t)?.image;if(e)return e}return e.image}function ce(e,n){const t=oe(e),a=!t&&!!e.is_on_sale&&"number"==typeof e.sale_price&&e.sale_price<e.price,i=n.size,r=i&&t?Object.entries(t.options).find(([e,n])=>re(e)===re(i.option)&&re(n)===re(i.value))?.[1]:void 0,s=e.variant_summary,o=!t&&!a&&"number"==typeof s?.price_min&&"number"==typeof s?.price_max&&s.price_min<s.price_max?s.price_min:null;return{variant:t,image:le(e,t),price:t?t.price:a?e.sale_price:o??e.price,compareAt:a?e.price:null,from:null!==o,currency:t?e.currency:e.sale_currency||e.currency,...r?{size:r}:{}}}function pe(e){let n=null;const t=[],a=new Set,i=new Map;for(const o of e){const e=o.variant_summary?.options.find(e=>ie.test(e.name)&&!ae.test(e.name));if(!e)continue;n=n??e.name,o.product_type&&i.set(o.product_type,(i.get(o.product_type)??0)+1);let r=0;for(const n of e.values){const e=t.indexOf(n.value);-1===e&&t.splice(r,0,n.value),r=(-1===e?r:e)+1,n.available&&a.add(n.value)}}const r=t.filter(e=>a.has(e));if(!n||r.length<2)return null;const s=[...i.entries()].sort((e,n)=>n[1]-e[1])[0]?.[0];return{option:n,values:r,...s?{scope:s}:{}}}const de=(e,n,t)=>({...e,size:{value:t,option:n.option,...n.scope?{scope:n.scope}:{}}});function ue(e){const n={...e};return delete n.size,n}function me(e){const n={...e};return delete n.max_price,n}function he(e,n){const t=e=>e.size?[re(e.size.value),re(e.size.option),re(e.size.scope)].join("|"):"";return t(e)===t(n)&&(e.max_price??null)===(n.max_price??null)}function ge(e,n){const t=e.size;return t?t.scope&&n.product_type&&re(t.scope)!==re(n.product_type)?null:t:null}function xe(e,n){return!!e.price_on_request||0===n?.price||(e.minimum_quantity??1)>1||!!e.add_quantity||!!e.price_unit||!!n?.extraOptions||!!n?.sellingRules}function fe(e,n,t,a){if(!t.available)return!1;if("number"==typeof a.max_price&&t.price>a.max_price)return!1;const i=ge(a,e);return!i||null===n.sizeOption||re(t.options[n.sizeOption])===re(i.value)}function be(e,n,t){if(xe(e,n))return{kind:"open"};if(void 0===n)return function(e,n){const t=(e.variant_summary?.options??[]).filter(e=>e.values.length>1);return 0===t.length||!t.some(e=>!ie.test(e.name)||ae.test(e.name))&&!!ge(n,e)}(e,t)?{kind:"wait"}:{kind:"open"};const a=n?function(e,n,t){if(null!==n.colourIndex)return null;if(null===n.sizeIndex)return 1===n.variants.length?n.variants[0]:null;const a=ge(t,e);if(!a)return null;const i=n.sizeIndex,r=n.variants.filter(e=>re(e.options[i])===re(a.value));return 1===r.length?r[0]:null}(e,n,t):null;return n&&a&&fe(e,n,a,t)?{kind:"add",request:{variant_id:a.id,product_id:String(e.id),product_name:e.name,product_url:e.url,quantity:1}}:{kind:"open"}}function ve(e){const n=oe(e);return n?se(n):e.selected_color??null}async function ye(e,n,t){const a=await J(e.url,{fresh:!0});if(!a)return"unknown";const i=a.variants.find(e=>e.id===String(n));return i&&i.available?t&&!fe(e,a,i,t)?"changed":"ok":"changed"}const ke={"€":"EUR","£":"GBP","₹":"INR","₩":"KRW","₺":"TRY","₽":"RUB","¥":"¥",$:"$"},we={dollar:"$",dollars:"$",bucks:"$",euro:"EUR",euros:"EUR",pound:"GBP",pounds:"GBP"},je=String.raw`(?:[A-Z]{1,3}\$|[$€£¥₹₩₺₽]|\b(?:${"usd|eur|gbp|cad|aud|nzd|chf|sek|nok|dkk|pln|inr|jpy|cny|hkd|sgd|mxn"})\b)`,ze=String.raw`(\d{1,3}(?:[.,\s]\d{3})+|\d+)(?:[.,](\d{1,2}))?`,Ne=String.raw`(${je})?\s?${ze}\s?(${je}|dollars?|euros?|pounds?|bucks)?`,Se=new RegExp(String.raw`(?:under|below|less than|cheaper than|no more than|not more than|at most|up to|max(?:imum)?|within|budget(?: of| is)?|moins de|sous|unter|bis zu|menos de|por debajo de|meno di|sotto|abaixo de|até|onder|tot)\s*`+Ne,"i"),Ce=new RegExp(Ne+String.raw`\s*(?:or less|or under|or below|max(?:imum)?|tops|at most)`,"i"),Ae=new Set(["USD","CAD","AUD","NZD","SGD","HKD","TWD","MXN","CLP","COP","ARS","FJD","JMD","TTD","BSD","BBD","BZD","XCD"]),_e={US:"USD",USD:"USD",C:"CAD",CA:"CAD",CAD:"CAD",A:"AUD",AU:"AUD",AUD:"AUD",NZ:"NZD",NZD:"NZD",S:"SGD",SG:"SGD",SGD:"SGD",HK:"HKD",HKD:"HKD",NT:"TWD",MX:"MXN",MXN:"MXN",R:"BRL"};function Pe(e){const n=e.toLowerCase();if(we[n])return we[n];if(ke[e])return ke[e];const t=e.match(/^([a-z]{1,3})\$$/i);return t?_e[t[1].toUpperCase()]??null:e.toUpperCase()}function qe(e){const n=e.brand?.trim()||null;return n&&e.name.toLowerCase().startsWith(`${n.toLowerCase()} `)?{brand:n,name:e.name.slice(n.length).trim()}:{brand:n,name:e.name}}function Ie(e,n,t){return e.price_on_request?t:0===n?"":null}const Re=/[??؟]/,Ee=/[^.!??؟。!\n]*[??؟]/gu,De=e=>e.normalize("NFC").replace(/[*_`]+/g,"").replace(/[“”]/g,'"').replace(/[‘’]/g,"'").replace(/\s+/g," ").trim().toLowerCase(),Fe=e=>De(e).replace(/[\p{P}\p{S}\s]+$/u,"");function $e({product:n,page:a,actions:i}){const{t:r}=t(),s=ce(n,i.rules),o=a?H(a,s.variant?.variant_id):null,l=o?void 0:s.currency,c=o?o.price:s.price,p=o?o.compareAt:s.compareAt,d=Ie(n,c,r("priceOnRequest"));if(null!==d)return e.jsx(e.Fragment,{children:d});const u=i.money(c,l);return e.jsxs(e.Fragment,{children:[null!==p&&e.jsx("s",{children:i.money(p,l)}),(o?o.from:s.from)?r("aiPageFrom").replace("{price}",u):u]})}function Me(e,t,a,i){const r=n.useRef(!1),[s,o]=n.useState(!1);return{checking:s,onAdd:async()=>{if(!r.current){if("add"!==t?.kind||!t.request.variant_id)return i();r.current=!0,o(!0);try{"ok"===await ye(e,String(t.request.variant_id),a.rules)?await a.onAdd(e,t.request):i()}finally{r.current=!1,o(!1)}}}}}function Le({product:n,step:i,actions:r}){const{t:s}=t(),o=ce(n,r.rules),l=ee(n.url),{brand:c,name:p}=qe(n),d=String(n.id),u=r.inCart.has(d),m=r.saved?.has(d)??!1,h=a(n,r.botData),g=h?null:be(n,l,r.rules),x=function(e){const n=e.variant_summary?.options.find(e=>ae.test(e.name));return n?n.values.length:0}(n),f=()=>r.onOpen(n,r.rules),b=Me(n,g,r,f);return e.jsxs("div",{className:"card fadein",children:[e.jsxs("div",{className:"phw",children:[e.jsx("button",{type:"button",className:"frame",onClick:f,"aria-label":n.name,children:e.jsx("img",{src:Q(o.image,700),alt:"",loading:"lazy"})}),r.saved&&e.jsx("button",{type:"button",className:"save","aria-pressed":m,"aria-label":`${s("saveForLater")}: ${n.name}`,onClick:()=>r.onSave(n),children:e.jsx(q,{})}),!h&&e.jsx("button",{type:"button",className:"qa"+(u?" inbag":""),"aria-label":`${s(u?"aiPageInCart":"addToCartFull")}: ${n.name}`,disabled:(r.busy||"wait"===g?.kind||b.checking)&&!u,onClick:()=>u?r.onCart():void b.onAdd(),children:u?e.jsx(P,{}):e.jsx(_,{})})]}),i?e.jsx("p",{className:"step",children:i}):c&&e.jsx("p",{className:"brand",children:c}),e.jsx("h4",{className:"nm",children:e.jsx("button",{type:"button",onClick:f,children:p})}),e.jsxs("p",{className:"pr",children:[e.jsx($e,{product:n,page:l,actions:r}),x>1&&e.jsx("span",{children:s("aiPageColours").replace("{count}",String(x))})]}),n.description&&e.jsx("p",{className:"wy",children:n.description}),u&&e.jsxs("p",{className:"got",children:[e.jsx(P,{}),s("aiPageInCart")]})]})}function Ue({product:n,tagged:i,nudge:r,actions:s}){const{t:o}=t(),l=ce(n,s.rules),{brand:c,name:p}=qe(n),d=ee(n.url),u=String(n.id),m=s.inCart.has(u),h=a(n,s.botData),g=h?null:be(n,d,s.rules),x=()=>s.onOpen(n,s.rules),f=Me(n,g,s,x);return e.jsxs("div",{className:"pick fadein",children:[e.jsxs("div",{className:"head",children:[i&&e.jsx("p",{className:"tag",children:o("aiPageMyPick")}),c&&e.jsx("p",{className:"brand",children:c}),e.jsx("h3",{className:"name",children:p}),e.jsx("p",{className:"price",children:e.jsx($e,{product:n,page:d,actions:s})})]}),e.jsx(te,{photos:ne(l.image,d?.images??[]),name:n.name,width:900,labels:{photos:o("aiPagePhotos"),prev:o("aiPagePrev"),next:o("aiPageNext")}}),e.jsxs("div",{className:"body",children:[n.description&&e.jsx("p",{className:"why",children:n.description}),l.size&&e.jsxs("p",{className:"opts",children:[e.jsx(P,{}),o("aiPageInStockSize").replace("{size}",l.size)]}),e.jsxs("div",{className:"acts",children:[h?e.jsx("a",{className:"btn primary",href:h.href,children:o(h.labelKey)}):e.jsx("button",{type:"button",className:"btn primary",disabled:(s.busy||"wait"===g?.kind||f.checking)&&!m,onClick:()=>m?s.onCart():void f.onAdd(),children:m?e.jsxs(e.Fragment,{children:[e.jsx(P,{}),o("aiPageInCart")]}):o("open"!==g?.kind?"addToCartFull":"chooseOptions")}),e.jsx("button",{type:"button",className:"btn ghost",onClick:x,children:o("aiPageSeeDetails")})]}),r&&e.jsxs("p",{className:"nudge",children:[o("aiPageNotSure")," ",e.jsx("button",{type:"button",onClick:()=>s.onAsk(r),children:r})]})]})]})}const Oe=n.lazy(()=>f(()=>import("./MarkdownContent-DEZk-48W.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url));function Be({avatar:n}){const{t:a}=t();return e.jsxs("div",{className:"waiting",children:[e.jsxs("div",{className:"think",role:"status",children:[e.jsx("span",{className:"dot",children:n&&e.jsx("img",{src:n,alt:""})}),e.jsx("span",{children:a("aiPageLooking")})]}),e.jsx("div",{className:"grid top ghosts","aria-hidden":"true",children:[0,1,2,3].map(n=>e.jsxs("div",{className:"ghost",children:[e.jsx("span",{className:"frame"}),e.jsx("span",{className:"ln"}),e.jsx("span",{className:"ln short"})]},n))})]})}function Te({question:n,avatar:t}){return e.jsxs("article",{className:"turn",children:[e.jsx("h2",{className:"q",children:n}),e.jsx(Be,{avatar:t})]})}function We(n,t,a="{size}"){const[i,r]=n.split(a);return e.jsxs(e.Fragment,{children:[i,e.jsx("b",{children:t}),r]})}function Ze({row:n,cap:a,busy:i,onSize:r,onAllSizes:s,onAnyPrice:o}){const{t:l}=t();return e.jsxs("div",{className:"fitask",children:[a&&e.jsxs("p",{children:[e.jsx("span",{children:We(l("aiPageShowingUnder"),a,"{price}")}),e.jsx("button",{type:"button",className:"linkbtn",disabled:i,onClick:o,children:l("aiPageAllPrices")})]}),n&&e.jsxs(e.Fragment,{children:[e.jsx("p",{children:n.checking?e.jsx("span",{children:We(l("aiPageCheckingSize"),n.checking)}):n.chosen?e.jsxs(e.Fragment,{children:[e.jsx("span",{children:We(l("aiPageShowingSize"),n.chosen)}),e.jsx("button",{type:"button",className:"linkbtn",disabled:i,onClick:s,children:l("aiPageAllSizes")})]}):e.jsxs("span",{children:[e.jsx("b",{children:l("aiPageSizeQuestion")})," ",l("aiPageSizeHint")]})}),e.jsx("div",{className:"sizes",role:"group","aria-label":l("aiPageYourSize"),children:n.values.map(t=>e.jsx("button",{type:"button",className:"sz","aria-pressed":t===(n.checking??n.chosen),disabled:i,onClick:()=>r(t),children:t},t))})]})]})}function Ge({message:n}){return"handover"===n.type&&n.handover?e.jsx(i,{message:n}):"handover_event"===n.type&&n.handoverEvent?e.jsx(r,{message:n}):"team"===n.type?e.jsx(s,{message:n}):"follow_up"===n.type&&n.followUp?e.jsx(o,{message:n}):"email_signup"===n.type&&n.emailSignup?e.jsx(l,{message:n}):null}function Ke({turn:n,nudge:a,actions:i}){const{t:r}=t(),s=n.products,o=e=>String(e.id??e.url??e.name),l=(t,a)=>e.jsx(Le,{product:t,step:"routine"===n.shape&&t.step_label?`${a+1}. ${t.step_label}`:void 0,actions:i},o(t));if(1===s.length)return e.jsx(Ue,{product:s[0],tagged:!1,nudge:a,actions:i},o(s[0]));if("single_pick"===n.shape){const[n,...t]=s;return e.jsxs(e.Fragment,{children:[e.jsx(Ue,{product:n,tagged:!0,nudge:a,actions:i},o(n)),e.jsx("h3",{className:"more",children:r("aiPageAlso")}),e.jsx("div",{className:"grid",children:t.map((e,n)=>l(e,n+1))})]})}return"shortlist"===n.shape||"routine"===n.shape?e.jsx("div",{className:"row"+(2===s.length?" two":""),children:s.map(l)}):e.jsx("div",{className:"grid top",children:s.map(l)})}function Xe({section:a,latest:i,avatar:r,sizeRow:s,cap:o,onSize:l,onAllSizes:c,onAnyPrice:p,failed:d,chipsDisabled:u,actions:m}){const{t:h}=t(),{head:g,shown:x}=a,f={...m,rules:a.rules,busy:m.busy||!!a.pending,onOpen:(e,n)=>m.onOpen(e,n??a.rules,a.key)},b=x.text.length>0||x.products.length>0||a.cards.length>0,v=i&&!u&&a.complete?x.chips:[],{choices:y,followUps:k}=function(e,n){const t={choices:[],followUps:e},a=De(n);if(e.length>=2&&e.every(e=>Fe(e).length>0&&a.includes(Fe(e))))return{choices:e,followUps:[]};const i=[...a.matchAll(Ee)].pop()?.[0];if(!i)return t;const r=e.filter(e=>{const n=Fe(e);return n.length>0&&!Re.test(e.trim().slice(-1))&&i.includes(n)});return r.length<2?t:{choices:r,followUps:e.filter(e=>!r.includes(e))}}(v,x.text.map(e=>e.content).join(" ")),w=1===x.products.length||"single_pick"===x.shape&&x.products.length>1,j=w?k[0]:void 0,z=w?k.slice(1):k,N=!!a.rules.size||!!a.rules.max_price,S=i&&a.complete&&!a.pending&&b&&0===x.products.length&&N&&a.ruleChange;return e.jsxs("article",{className:"turn",children:[g.question&&e.jsx("h2",{className:"q",children:g.question.content}),!b&&!a.complete&&!d&&e.jsx(Be,{avatar:r}),e.jsxs("div",{className:a.pending?"updating":void 0,children:[x.text.map(t=>e.jsx("div",{className:"say",children:e.jsx(n.Suspense,{fallback:e.jsx("p",{children:t.content}),children:e.jsx(Oe,{variant:"dori",textSize:{base:"17px",md:"18px"},children:t.content})})},t.id)),y.length>0&&e.jsx("div",{className:"choices",children:y.map(n=>e.jsx("button",{type:"button",className:"choice",onClick:()=>m.onAsk(n),children:n},n))}),a.cards.length>0&&e.jsx("div",{className:"cards",children:a.cards.map(n=>e.jsx(Ge,{message:n},n.id))}),d&&e.jsxs("div",{className:"failed",children:[e.jsx("span",{children:d.expired?h("aiPageExpired"):h("aiPageNotLoaded")}),e.jsx("button",{type:"button",className:"btn primary",onClick:d.expired?d.onAskAgain:d.onRetry,children:d.expired?h("aiPageAskAgain"):h("aiPageTryAgain")})]}),i&&(s||o)&&e.jsxs(e.Fragment,{children:[e.jsx(Ze,{row:s,cap:o,busy:u,onSize:l,onAllSizes:c,onAnyPrice:p}),e.jsx("div",{className:"bar"})]}),e.jsxs("div",{className:"set",children:[x.products.length>0&&e.jsx(Ke,{turn:x,nudge:j,actions:f}),S&&e.jsx("div",{className:"none",children:e.jsxs("div",{className:"acts",children:[v[0]&&e.jsx("button",{type:"button",className:"btn primary",onClick:()=>m.onAsk(v[0]),children:v[0]}),a.rules.size&&e.jsx("button",{type:"button",className:"btn ghost",onClick:c,children:h("aiPageAllSizes")}),a.rules.max_price&&e.jsx("button",{type:"button",className:"btn ghost",onClick:p,children:h("aiPageAllPrices")})]})})]}),z.length>0&&!S&&e.jsxs("div",{className:"asknext",children:[e.jsx("h3",{children:h("aiPageAskNext")}),z.map(n=>e.jsxs("button",{type:"button",className:"nx",onClick:()=>m.onAsk(n),children:[n,e.jsx(I,{})]},n))]})]})]})}const He=e=>e===e.toUpperCase()&&/[A-Z]/.test(e)?e.toLowerCase().replace(new RegExp("\\b\\p{L}","gu"),e=>e.toUpperCase()):e;function Ve({product:i,actions:r,storeName:s,onAdd:o,onAskAbout:l,onClose:c}){const{t:p}=t(),[d,u]=n.useState(void 0),[m,h]=n.useState(null),[g,x]=n.useState(null),[f,b]=n.useState(!0),[v,y]=n.useState(!1),k=n.useRef(!1),[w,j]=n.useState(!1),[z,N]=n.useState(null),[S,C]=n.useState(!1),[A,_]=n.useState(!1),q=n.useRef(null),I=n.useRef(c);I.current=c;const R=e=>{if(u(e),!e)return;const n=function(e,n,t){const a=ge(t,e),i=a?n.sizes.find(e=>re(e)===re(a.value))??null:null,r=n.variants.filter(a=>fe(e,n,a,t)).map(e=>({colour:null===n.colourIndex?null:e.options[n.colourIndex],size:null===n.sizeIndex?null:e.options[n.sizeIndex]}));if(0===r.length)return{colour:null,size:null,fits:!1};const s=[(o=ve(e),n.colours.find(e=>re(e.name)===re(o))?.name??null),...n.colours.map(e=>e.name)];var o;const l=(null===n.colourIndex?r[0]:s.map(e=>r.find(n=>n.colour===e)).find(Boolean))??r[0],c=null===n.sizeIndex||null===l.size||l.size!==i&&1!==n.sizes.length?null:l.size;return{colour:l.colour,size:c,fits:!0}}(i,e,r.rules);h(n.colour),x(n.size),b(n.fits),y(!1)};n.useEffect(()=>{let e=!0;return J(i.url,{fresh:!0}).then(n=>{e&&R(n)}),()=>{e=!1}},[i]),n.useEffect(()=>{q.current?.focus({preventScroll:!0});const e=e=>{"Escape"===e.key&&I.current()},n=document.documentElement,t=n.style.overflow;return n.style.overflow="hidden",document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e),n.style.overflow=t}},[]);const E=ce(i,r.rules),{brand:F,name:$}=qe(i),M=a(i,r.botData),L=xe(i,d)||null===d,U=d?function(e,n,t){if(null!==e.colourIndex&&null===n)return null;if(null!==e.sizeIndex&&null===t)return null;const a=K(e,n,t).filter(e=>e.available);return 1===a.length?a[0]:null}(d,m,g):null,O=!!d&&d.variants.every(e=>!e.available),B=M||L||!U?null:{variant_id:U.id,product_id:String(i.id),product_name:i.name,product_url:i.url,quantity:1},T=d?U?{price:U.price,compareAt:U.compareAt,from:!1}:H(d,E.variant?.variant_id):null,W=T?void 0:E.currency,Z=T?T.price:E.price,G=r.money(Z,W),V=T?T.compareAt:E.compareAt,Y=Ie(i,Z,p("priceOnRequest")),ee=d?.colours.find(e=>e.name===m)?.image,ae=ne(ee??E.image,d?.images??[]),ie=`${m??""}|${g??""}`,se=!!d&&d.colours.length>0&&d.colours.every(e=>e.image),oe=d&&null!==d.colourIndex&&null===m?p("aiPageChooseColour"):d&&null!==d.sizeIndex&&null===g?p("aiPageChooseSize"):null,le=[m&&d&&d.colours.length>1?He(m):null,g&&d&&d.sizes.length>1?g:null].filter(Boolean).join(", ");return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scrim",onClick:c,"aria-hidden":!0}),e.jsxs("aside",{className:"sheet",role:"dialog","aria-modal":"true","aria-labelledby":"aip-sheet-name",children:[e.jsx("span",{className:"grab","aria-hidden":!0}),e.jsx("button",{type:"button",className:"x",ref:q,onClick:c,"aria-label":p("close"),children:e.jsx(D,{})}),e.jsx(te,{photos:ae,name:i.name,width:1e3,labels:{photos:p("aiPagePhotos"),prev:p("aiPagePrev"),next:p("aiPageNext")}},m??"all"),e.jsxs("div",{className:"shb",children:[F&&e.jsx("p",{className:"brand",children:F}),e.jsx("h3",{className:"name",id:"aip-sheet-name",children:$}),e.jsx("p",{className:"price",children:Y??e.jsxs(e.Fragment,{children:[null!==V&&e.jsx("s",{children:r.money(V,W)}),T?.from?p("aiPageFrom").replace("{price}",G):G]})}),i.description&&e.jsxs("div",{className:"note",children:[e.jsx("b",{children:p("aiPageWhy")}),e.jsx("p",{children:i.description})]}),d&&d.colours.length>1&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"lbl",children:[p("aiPageColour"),": ",e.jsx("b",{children:m?He(m):p("aiPageChooseOne")})]}),e.jsx("div",{className:se?"swatches":"sizes",role:"group","aria-label":p("aiPageColour"),children:d.colours.map(n=>e.jsx("button",{type:"button",className:se?"sw":"sz","aria-pressed":n.name===m,"aria-label":se?He(n.name):void 0,disabled:!n.available||w,onClick:()=>{h(n.name),y(!0),g&&!X(d,n.name,g)&&x(null)},children:se&&n.image?e.jsx("img",{src:Q(n.image,120),alt:""}):He(n.name)},n.name))})]}),d&&d.sizes.length>1&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"lbl",children:[p("aiPageSize"),": ",e.jsx("b",{children:g??p("aiPageChooseOne")})]}),e.jsx("div",{className:"sizes",role:"group","aria-label":p("aiPageSize"),children:d.sizes.map(n=>e.jsx("button",{type:"button",className:"sz","aria-pressed":n===g,disabled:!X(d,m,n)||w,onClick:()=>{x(n),y(!0)},children:n},n))})]}),d?.tip&&e.jsxs("p",{className:"tip",children:[e.jsx("b",{children:p("aiPageFitTip").replace("{store}",s)})," ",d.tip]}),e.jsx("div",{className:"buy",children:z===ie?e.jsxs("div",{className:"done",children:[e.jsxs("p",{children:[e.jsx(P,{}),e.jsx("span",{children:p("aiPageAddedTo").replace("{item}",le?`${$}, ${le}`:$)})]}),e.jsx("button",{type:"button",className:"btn primary wide",onClick:r.onCart,children:p("cartViewCart")}),e.jsx("button",{type:"button",className:"btn ghost wide",onClick:c,children:p("aiPageKeepBrowsing")})]}):M?e.jsx("a",{className:"btn primary wide",href:M.href,children:p(M.labelKey)}):L&&i.url?e.jsxs(e.Fragment,{children:[e.jsx("a",{className:"btn primary wide",href:i.url,children:p("chooseOptions")}),e.jsx("button",{type:"button",className:"btn ghost wide",onClick:()=>l(i),children:p("askAboutProduct")})]}):e.jsxs(e.Fragment,{children:[S&&e.jsx("p",{className:"err",children:p("aiPageAddFailed")}),O?e.jsx("p",{className:"err",children:p("cartErrorProductOutOfStock")}):d&&!f&&!v&&e.jsx("p",{className:"err",children:p("aiPageNoLongerFits")}),e.jsx("button",{type:"button",className:"btn primary wide",disabled:!B||r.busy||w,onClick:()=>{(async()=>{if(B?.variant_id&&!k.current){k.current=!0,j(!0),C(!1);try{const e=await ye(i,String(B.variant_id),f&&!v?r.rules:null);if("changed"===e)return void R(await J(i.url));if("unknown"===e)return void C(!0);await o(i,B)?N(ie):C(!0)}finally{k.current=!1,j(!1)}}})()},children:oe??p(!d||f||v||O?"addToCartFull":"aiPageAddAnyway")}),e.jsx("button",{type:"button",className:"btn ghost wide",onClick:()=>l(i),children:p("askAboutProduct")})]})}),d&&d.sections.length>0&&e.jsx("div",{className:"facts",children:d.sections.map(n=>e.jsxs("div",{children:[e.jsx("h4",{children:n.label}),e.jsx("ul",{children:n.items.map(n=>e.jsx("li",{children:n},n))})]},n.label))}),d&&d.full.length>0&&(A?e.jsx("div",{className:"about",children:d.full.map((n,t)=>"p"===n.type?e.jsx("p",{children:n.text},t):e.jsx("ul",{children:n.items.map(n=>e.jsx("li",{children:n},n))},t))}):e.jsx("button",{type:"button",className:"linkbtn",onClick:()=>_(!0),children:p("aiPageReadMore")})),i.url&&e.jsx("a",{className:"pdp",href:i.url,children:p("aiPageProductPage")})]})]})]})}const Ye=new Set(["running","done","failed","unknown"]);function Je({items:a,money:i,onOpen:r,onRemove:s,onCompare:o,onClose:l}){const{t:c}=t(),p=n.useRef(null),d=n.useRef(l);return d.current=l,n.useEffect(()=>{p.current?.focus({preventScroll:!0});const e=e=>{"Escape"===e.key&&d.current()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scrim",onClick:l,"aria-hidden":!0}),e.jsxs("aside",{className:"sheet list",role:"dialog","aria-modal":"true","aria-labelledby":"aip-saved-title",children:[e.jsx("span",{className:"grab","aria-hidden":!0}),e.jsx("button",{type:"button",className:"x",ref:p,onClick:l,"aria-label":c("close"),children:e.jsx(D,{})}),e.jsxs("div",{className:"shb",children:[e.jsx("h3",{className:"name",id:"aip-saved-title",children:c("savedProducts")}),0===a.length&&e.jsx("p",{className:"empty",children:c("savedEmpty")}),a.map(n=>e.jsxs("div",{className:"lrow",children:[e.jsx("span",{className:"frame",children:e.jsx("img",{src:Q(n.image,160),alt:""})}),e.jsxs("div",{children:[e.jsx("b",{children:qe(n).name}),e.jsx("span",{children:Ie(n,n.price,c("priceOnRequest"))??i(n.price,n.currency)})]}),e.jsx("button",{type:"button",className:"linkbtn",onClick:()=>r(n),children:c("aiPageView")}),e.jsx("button",{type:"button",className:"linkbtn",onClick:()=>s(n),children:c("aiPageRemove")})]},String(n.id))),a.length>=2&&e.jsx("div",{className:"buy",children:e.jsx("button",{type:"button",className:"btn primary wide",onClick:o,children:c("compareSaved").replace("{count}",String(Math.min(a.length,3)))})})]})]})]})}function Qe(e){e.classList.add("dori-aip--asked")}function en(e){const n=(e??"").match(/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:\s*[,/]\s*([\d.]+%?))?\s*\)/i);if(!n)return null;const t=void 0===n[4]?1:n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4]);return{rgb:[Number(n[1]),Number(n[2]),Number(n[3])],alpha:t}}const nn=e=>`rgb(${e.map(e=>Math.round(e)).join(", ")})`,tn=(e,n,t)=>nn([0,1,2].map(a=>e[a]*t+n[a]*(1-t))),an=/hidden|auto|scroll|overlay/;function rn({draft:n,onDraft:a,onSubmit:i,sending:r,placeholder:s,inputRef:o,about:l,onClearAbout:c,savedCount:p,onSaved:d,cartCount:u,onCart:m}){const{t:h}=t();return e.jsxs("div",{className:"tray",children:[l&&e.jsxs("div",{className:"about-line",children:[e.jsxs("span",{children:[h("askAboutProduct"),": ",e.jsx("b",{children:l.name})]}),e.jsx("button",{type:"button",className:"linkbtn","aria-label":h("close"),onClick:c,children:e.jsx(D,{})})]}),e.jsxs("div",{className:"tray-in",children:[p>0&&e.jsxs("button",{type:"button",className:"tb","aria-label":h("savedProducts"),onClick:d,children:[e.jsx(q,{}),e.jsx("span",{children:p})]}),u>0&&e.jsxs("button",{type:"button",className:"tb","aria-label":h("cartViewCart"),onClick:m,children:[e.jsx(F,{}),e.jsx("span",{children:u})]}),e.jsxs("form",{className:"ask",onSubmit:e=>{e.preventDefault(),!r&&n.trim()&&i()},children:[e.jsx("label",{className:"sr",htmlFor:"aip-dock",children:s}),e.jsx("input",{id:"aip-dock",ref:o,value:n,autoComplete:"off",placeholder:s,onChange:e=>a(e.target.value)}),e.jsx("button",{type:"submit",className:"send","aria-label":s,disabled:r||!n.trim(),children:e.jsx($,{})})]})]})]})}const sn=new Set(["team","handover","handover_event","follow_up","email_signup"]);function on(e,n){return{key:n,question:e,text:[],products:[],chips:[],cards:[],pending:!1}}function ln(e){const n=[];let t=null;const a=new Set;for(const i of e)if("welcome"!==i.type)if("user"!==i.type)if(t||(t=on(null,`before-${i.id}`),n.push(t)),"dori"===i.type&&i.isError)t.failed=!0;else if("dori"!==i.type||i.showCartSummary||i.showCartActions)if("products"===i.type){i.shape&&(t.shape=i.shape);for(const e of i.products??[]){const n=String(e.id??e.url??e.name);a.has(n)||(a.add(n),t.products.push(e))}}else"suggestions"===i.type?t.chips=i.suggestions??[]:sn.has(i.type)?t.cards.push(i):"loading"!==i.type&&"typing"!==i.type||(t.pending=!0);else t.text.push(i),t.failed=!1;else t=on(i,i.id),n.push(t),a.clear();return n}function cn(e,n=Date.now()){return n-e>=864e5}const pn="dori_ai_page_view",dn={asks:[],inFlight:null};function un(e){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const{size:n,max_price:t}=e;if(!(void 0===t||"number"==typeof t&&t>0))return!1;if(void 0===n)return!0;const a=n;return"object"==typeof a&&null!==a&&"string"==typeof a.value&&"string"==typeof a.option}function mn(e){const n=e;return!!n&&"string"==typeof n.turnId&&"string"==typeof n.question&&"boolean"==typeof n.refine&&un(n.rules)}const hn={},gn=e=>(e??"").trim().toLowerCase(),xn=(e,n,t,a)=>{const i=N(e.productType,a?.feature_flags?.sale_units);return{id:e.handle,name:e.title,brand:e.vendor||null,product_type:e.productType,price:e.price,...null!==e.compareAt?{is_on_sale:!0,sale_price:e.price,price:e.compareAt}:{},image:e.images[0]??"",url:n,...t>1?{minimum_quantity:t}:{},...i?{price_unit:i.unit}:{}}};function fn({shell:a}){const{botData:i,messages:r,sendMessage:s,isInputDisabled:o,setPanelOpen:l,chatState:u,addToCartDirect:m,isCartBusy:h,cartItemCount:g,shortlist:f,shortlistEnabled:N,toggleShortlist:S}=c(),{t:A}=t();p({sharingId:b()});const[_,P]=n.useState(()=>function(e=localStorage,n=Date.now()){try{const t=e.getItem(pn);if(!t)return dn;const a=JSON.parse(t),i=Array.isArray(a.asks)?a.asks.filter(mn).slice(-30).map(e=>({...e,askedAt:"number"==typeof e.askedAt?e.askedAt:0})):[],r=function(e){const n=e;return!!n&&"string"==typeof n.turnId&&"string"==typeof n.question&&"number"==typeof n.startedAt&&un(n.rules)}(a.inFlight)&&!cn(a.inFlight.startedAt,n)?a.inFlight:null,s=a.recovered;return{asks:i,inFlight:r,...!s||"string"!=typeof s.question||"string"!=typeof s.turnId||"done"!==s.status&&"failed"!==s.status?{}:{recovered:s}}}catch{return dn}}()),q=n.useRef(_);q.current=_,n.useEffect(()=>{!function(e,n=localStorage){try{n.setItem(pn,JSON.stringify(e))}catch{}}(_)},[_]);const I=n.useRef(u);I.current=u;const R=n.useRef(r);R.current=r;const E=i?.assistant_id??null,D=n.useRef(E);D.current=E;const F=n.useRef(i);F.current=i;const[$,M]=n.useState(null),[L,U]=n.useState(null),[O,B]=n.useState(!1),T=O||!1===i?.is_widget_enabled,W=n.useRef(T);W.current=T;const[Z,G]=n.useState(()=>new Set),[K,X]=n.useState(null),[H,V]=n.useState(null),[Y,Q]=n.useState(!1),[ee,ne]=n.useState(null),te=n.useRef(ee);te.current=ee;const[ae,ie]=n.useState({});n.useEffect(()=>{const e=a??document.body;ie(function(e,n){const t=en(e)?.rgb??[34,34,34],a=en(n)?.rgb??[255,255,255],i=(([e,n,t])=>(.2126*e+.7152*n+.0722*t)/255)(a)<.45;return{"--ink":nn(t),"--text":tn(t,a,.9),"--muted":tn(t,a,.6),"--line":tn(t,a,.1),"--edge":tn(t,a,.2),"--stone":tn(t,a,i?.08:.035),"--paper":nn(a),"--btn":nn(t),"--btn-ink":nn(a),"--blend":i?"normal":"multiply"}}(getComputedStyle(e).color,function(e){for(let n=e;n;n=n.parentElement){const e=getComputedStyle(n).backgroundColor,t=en(e);if(t&&t.alpha>.9)return e}return"rgb(255, 255, 255)"}(e)))},[a]);const re=n.useMemo(()=>{const e=function(e,n){if(!n)return e;let t=-1;e.forEach((e,a)=>{e.question?.content===n.question&&(t=a)});const a=t>=0?e[t]:on({id:`recovered-q-${n.turnId}`,type:"user",content:n.question,timestamp:new Date},`recovered-${n.turnId}`),i="done"===n.status?{...a,text:n.text?[{id:`recovered-a-${n.turnId}`,type:"dori",content:n.text,timestamp:new Date}]:[],products:n.products??[],chips:n.chips??[],pending:!1,failed:!1}:{...a,pending:!1,failed:!0};return t>=0?e.map((e,n)=>n===t?i:e):[...e,i]}(ln(r),_.recovered);return e.map(e=>$&&e.question?.content===$.question?{...e,pending:!0,failed:!1}:L&&e.question?.content===L.question?{...e,pending:!1,failed:!0}:e)},[r,_.recovered,$,L]),[se,oe]=n.useState(!1);n.useEffect(()=>{u.isRequestInProgress||oe(!1)},[u.isRequestInProgress]);const le=se&&!!u.isRequestInProgress,[ce,ge]=n.useState(null),xe=n.useRef(re.length);xe.current=re.length;const fe=n.useMemo(()=>function(e,n,t){const a=[];let i=0;return e.forEach((r,s)=>{const o=(e=>{if(!e)return null;for(let t=i;t<n.length;t++)if(n[t].question===e)return i=t+1,n[t];return null})(r.question?.content),l=r.pending||t&&s===e.length-1,c=a[a.length-1];if(o?.refine&&c)return c.cards.push(...r.cards),void(l?(c.pending=o.rules,c.failed=null):r.failed?(c.pending=null,c.failed=r):(c.shown=r,c.rules=o.rules,c.pending=null,c.failed=null,c.complete=!0,c.ruleChange=!0));const p=o?.rules??{};a.push({key:r.key,head:r,shown:r,rules:p,pending:null,failed:r.failed&&!l?r:null,complete:!l,cards:[...r.cards],ruleChange:!he(p,c?.rules??{})})}),a}(re,_.asks,le),[re,_.asks,le]),be=fe[fe.length-1]?.rules??hn,ve=n.useRef(be);ve.current=be;const[ye,ke]=n.useState(null);n.useEffect(()=>{ye&&(re.length>ye.turns||T)&&ke(null)},[ye,re.length,T]);const[we,je]=n.useState(""),ze=n.useRef(null),Ne=n.useRef(null),_e=n.useRef(null),qe=n.useRef(fe.length),Ie=n.useRef(null),[Re,Ee]=n.useState(!1);n.useEffect(()=>{const e=Ie.current;if(!e)return;const n=e.getRootNode();Ee(function(e){for(const n of e)if(an.test(`${n.overflowX} ${n.overflowY}`))return!0;return!1}(function*(e){for(let n=e;n&&n!==document.body&&n!==document.documentElement;n=n.parentElement)yield getComputedStyle(n)}(n instanceof ShadowRoot?n.host:e.parentElement)))},[]);const De=n.useCallback((e,n,t,a={})=>{oe(!0),s({message:e,page:{turnId:n,rules:t},...a.silent?{silent:!0}:{}},a.about??void 0)},[s]),Fe=n.useCallback((e,n={})=>{if(W.current)return void(window.location.href=a?function(e,n){const t=e.querySelector("[data-dori-ask-form]");return`${t?.action||"/search"}?q=${encodeURIComponent(n)}`}(a,e):`/search?q=${encodeURIComponent(e)}`);const t=n.rules??ve.current,r=n.refine?null:function(e){const n=e.match(Se)??e.match(Ce),t=n?.[1]??n?.[4];if(!n||!t)return null;const a=Number(n[2].replace(/[.,\s]/g,""))+(n[3]?Number(n[3].padEnd(2,"0"))/100:0);return a>0?{amount:a,currency:Pe(t)}:null}(e),s=r&&function(e,n){const t=(n??"").toUpperCase();return!(!t||!e)&&("$"===e?Ae.has(t):"¥"===e?"JPY"===t||"CNY"===t:e===t)}(r.currency,function(){const e=document.querySelector("script#dori-side-widget")?.getAttribute("data-currency"),n=window.Shopify?.currency?.active;return e||n||null}())?r.amount:null,o=s?{...t,max_price:s}:t,l=v(),c=Date.now(),p=te.current;ne(null),U(null),P(t=>({asks:[...t.asks,{turnId:l,question:e,rules:o,refine:!!n.refine,askedAt:c}].slice(-30),inFlight:{turnId:l,question:e,startedAt:c,rules:o},recovered:"done"===t.recovered?.status?t.recovered:null})),n.refine||ke({question:e,turns:xe.current}),a&&Qe(a),y("ai_page_ask",{assistantId:D.current}),i?De(e,l,o,{about:p}):Ne.current={question:e,turnId:l,rules:o,about:p}},[i,De,a]),$e=n.useRef(Fe);$e.current=Fe,n.useEffect(()=>{if(!a)return;const e=function(e,n){const t=e.querySelector("[data-dori-ask-form]"),a=e.querySelector("[data-dori-ask-input]"),i=[];if(t&&a){const e=e=>{e.preventDefault();const t=a.value.trim();t&&(a.value="",n(t))};t.addEventListener("submit",e),i.push(()=>t.removeEventListener("submit",e))}for(const r of Array.from(e.querySelectorAll("[data-dori-ask]"))){const e=e=>{e.preventDefault();const t=r.dataset.doriAsk?.trim();t&&n(t)};r.addEventListener("click",e),i.push(()=>r.removeEventListener("click",e))}return()=>i.forEach(e=>e())}(a,e=>$e.current(e));!function(e,n,t,a){const i=new URLSearchParams(n.search).get("q")?.trim().slice(0,300),r=e.querySelector("[data-dori-ask-input]");if(!i||!r)return null;r.value=i;const s=e.querySelector("[data-dori-ask-send]");s&&(s.textContent=a);try{const e=new URL(n.href);e.searchParams.delete("q"),(e=>{history.replaceState(history.state,"",e)})(e.toString())}catch{}}(a,window.location,0,A("aiPageShowMe")),k(w(window.location.search));const n=function(e,n){n.__doriAiPageReady=!0;const t="string"==typeof n.__doriAiAsk?n.__doriAiAsk.trim():"";n.__doriAiAsk=null;const a=e.querySelector("[data-dori-ask-input]");a&&(a.readOnly=!1);const i=e.querySelector("[data-dori-ask-send]");return i&&(i.disabled=!1,i.removeAttribute?.("aria-busy")),t||null}(a,window);n&&$e.current(n);const t=e=>{const n=e.target?.closest?.("[data-dori-product]");if(!n)return;e.preventDefault();const t=n.getAttribute("href")||"",a=Number(n.getAttribute("data-dori-min"))||1;J(t).then(e=>{e?V({product:xn(e,t,a,F.current),rules:ve.current}):window.location.href=t})};return a.addEventListener("click",t),()=>{e(),a.removeEventListener("click",t)}},[a]),n.useEffect(()=>{a&&re.length>0&&Qe(a)},[a,re.length]),n.useEffect(()=>(l(!0),()=>l(!1)),[l]);const Me=n.useRef(!1);n.useEffect(()=>{!Me.current&&E&&(Me.current=!0,y("ai_page_view",{assistantId:E}))},[E]),n.useEffect(()=>{if(!i||!Ne.current)return;const{question:e,turnId:n,rules:t,about:a}=Ne.current;Ne.current=null,W.current||De(e,n,t,{about:a})},[i,De]),n.useEffect(()=>{const e=()=>B(!0);return window.addEventListener("dori:usage-cap",e),()=>window.removeEventListener("dori:usage-cap",e)},[]),n.useEffect(()=>{T&&a&&function(e,n){const t=e.querySelector("[data-dori-ask-input]");t&&(t.placeholder=n,t.setAttribute("aria-label",n));const a=e.querySelector("[data-dori-ask-send]");a&&(a.textContent=n)}(a,A("aiPageSearch"))},[T,a]);const Le=n.useCallback((e,n)=>{const t=n||I.current.threadId,a=b();return t&&a?async function(e,n,t,a,i=fetch){try{const r=`${e}/v2/turn/${encodeURIComponent(n)}/${encodeURIComponent(t)}?sharing_id=${encodeURIComponent(a)}`,s=await i(r,{cache:"no-store"});if(!s.ok)return{status:"unreachable"};const o=await s.json();return o&&Ye.has(o.status)?o:{status:"unreachable"}}catch{return{status:"unreachable"}}}(z,t,e.turnId,a):Promise.resolve({status:"unreachable"})},[]),Ue=n.useCallback(async(e,n,t)=>{M(e);const a=await async function(e,{pollMs:n=2e3,maxWaitMs:t=6e4,sleep:a=e=>new Promise(n=>setTimeout(n,e))}={}){let i=0;for(;;){const r=await e();if("running"!==r.status&&"unreachable"!==r.status)return r;if(i>=t)return r;await a(n),i+=n}}(()=>Le(e,t),{maxWaitMs:n});M(null);const{turnId:i,question:r}=e;return"running"===a.status||"unreachable"===a.status?(U(e),a.status):(U(null),P(e=>({...e,inFlight:e.inFlight?.turnId===i?null:e.inFlight,recovered:"done"===a.status?{question:r,turnId:i,status:"done",text:a.text,products:a.products,chips:a.chips}:{question:r,turnId:i,status:"failed"}})),a.status)},[Le]),Oe=n.useRef(!1);n.useEffect(()=>{if(Oe.current||!i)return;Oe.current=!0;const e=q.current.inFlight;e&&Ue(e,6e4)},[i,Ue]),n.useEffect(()=>{const e=e=>{const n=q.current.inFlight,t=e.detail?.threadId;n&&Ue(n,6e4,t)};return window.addEventListener("dori:turn-known",e),()=>window.removeEventListener("dori:turn-known",e)},[Ue]);const Be=n.useRef(!1);n.useEffect(()=>{const e=!!u.isRequestInProgress;Be.current&&!e&&q.current.inFlight&&!re[re.length-1]?.failed&&P(e=>({...e,inFlight:null})),Be.current=e},[u.isRequestInProgress,re]);const We=n.useCallback(async e=>{if(W.current)return;if(cn(e.startedAt))return void ge(e.turnId);const n=await Ue(e,2e4);if("failed"!==n&&"unknown"!==n)return;if(cn(e.startedAt))return void ge(e.turnId);const{turnId:t,question:a,rules:i,startedAt:r}=e,s=ln(R.current).some(e=>e.question?.content===a);P(e=>({...e,recovered:null,inFlight:{turnId:t,question:a,startedAt:r,rules:i}})),De(a,t,i,{silent:s})},[Ue,De]);n.useEffect(()=>{fe.length>qe.current&&_e.current?.scrollIntoView({block:"start",behavior:"smooth"}),qe.current=fe.length},[fe.length]);const Ze=re.length>0||!!ye;n.useEffect(()=>(C.current=Ze?()=>ze.current?.focus():null,()=>{C.current=null}),[Ze]),n.useEffect(()=>{const e=Ie.current,n=e?.querySelector(":scope > .tray");if(Re&&e&&n)return function(e,n){let t=0,a=0;const i=()=>{a=0;const i=(r=e.getBoundingClientRect().bottom+t,s=n.getBoundingClientRect().bottom,Math.max(0,Math.round(r-s)));var r,s;i!==t&&(t=i,e.style.transform=i?`translateY(${-i}px)`:"")},r=()=>{a||(a=requestAnimationFrame(i))};document.addEventListener("scroll",r,{capture:!0,passive:!0}),window.addEventListener("resize",r);const s=new ResizeObserver(r);return s.observe(n),i(),()=>{document.removeEventListener("scroll",r,{capture:!0}),window.removeEventListener("resize",r),s.disconnect(),a&&cancelAnimationFrame(a),e.style.transform=""}}(n,e)},[Re,Ze]),n.useEffect(()=>{if(!K)return;const e=setTimeout(()=>X(null),3600);return()=>clearTimeout(e)},[K]);const Ge=n.useCallback(()=>{X(null),V(null),Q(!1),j()||(window.location.href=`${x()}cart`)},[]),Ke=n.useCallback(async(e,n,t=!1)=>"success"!==(await m(n,{quiet:!0})).type?(t||X(A("aiPageAddFailed")),!1):(G(n=>new Set(n).add(String(e.id))),y("ai_page_add",{assistantId:D.current}),t||X(A("aiPageAddedTo").replace("{item}",e.name)),!0),[m,A]),He=n.useCallback(e=>{V(null),ne(e),setTimeout(()=>ze.current?.focus(),0)},[]),sn="undefined"!=typeof document&&document.documentElement.lang||void 0,fn="undefined"!=typeof document&&document.querySelector("script#dori-side-widget")?.getAttribute("data-currency")||i?.currency?.split(" - ")[0]?.trim()||void 0,bn=n.useCallback((e,n)=>d(e,n||fn,sn),[fn,sn]),vn=n.useMemo(()=>new Set(f.map(e=>String(e.id))),[f]),yn={botData:i,rules:be,inCart:Z,saved:N?vn:null,busy:h,money:bn,onAdd:(e,n)=>Ke(e,n),onOpen:(e,n,t)=>V({product:e,rules:n??ve.current,from:t}),onSave:S,onCart:Ge,onAsk:e=>Fe(e)},kn=fe[fe.length-1],wn=kn?pe(kn.shown.products)??pe(kn.head.products):null,jn=e=>{const n=e?.size;return!n||n.scope&&wn?.scope&&gn(n.scope)!==gn(wn.scope)?null:n.value},zn=(()=>{if(!kn||T||!kn.complete&&!kn.pending)return null;const e=jn(kn.rules),n=kn.pending?jn(kn.pending):null,t=wn?[...wn.values]:[];for(const a of[e,n])a&&!t.some(e=>gn(e)===gn(a))&&t.push(a);return t.length<2&&!e&&!n?null:{values:t,chosen:e,checking:n}})(),Nn=kn&&!T?(kn.pending??kn.rules).max_price??null:null,Sn=e=>{const n=kn?.rules??hn;if(n.size&&gn(n.size.value)===gn(e))return void Fe(A("aiPageAnySize"),{rules:ue(n),refine:!0});const t=wn??{option:n.size?.option??"Size",scope:n.size?.scope};Fe(A("aiPageMySize").replace("{size}",e),{rules:de(n,t,e),refine:!0})},Cn=()=>Fe(A("aiPageAnySize"),{rules:ue(kn?.rules??hn),refine:!0}),An=()=>Fe(A("aiPageAnyPrice"),{rules:me(kn?.rules??hn),refine:!0}),_n=ae,Pn=i?.agent_image||i?.bot_image||void 0,qn=i?.agent_name||i?.bot_name||"";return e.jsxs("div",{className:Re?"aip floats":"aip",ref:Ie,style:_n,children:[e.jsx("style",{children:'\n.aip{--ink:#222;--text:#34312e;--muted:#7a746e;--line:#ebe6e0;--stone:#f8f5f2;--paper:#fff;--btn:#222;--btn-ink:#fff;--edge:#dcd6cf;--blend:multiply;\n --ease:cubic-bezier(.2,.75,.2,1);--read:680px;--gut:24px;--tray:84px;\n color:var(--text);font-size:16px;line-height:1.5;-webkit-font-smoothing:antialiased}\n.aip *,.aip *::before,.aip *::after{box-sizing:border-box}\n.aip button{font:inherit;color:inherit;background:none;border:0;padding:0;margin:0;cursor:pointer;text-align:inherit}\n.aip img{display:block;max-width:100%}\n.aip a{color:inherit}\n.aip :focus-visible{outline:2px solid var(--ink);outline-offset:3px;border-radius:6px}\n.aip [hidden]{display:none!important}\n.aip .sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n/* Strips that scroll sideways never widen the page: themes size their main area to its content. */\n.aip .sizes,.aip .slides,.aip .row{contain:inline-size}\n\n.aip .frame{position:relative;display:block;width:100%;aspect-ratio:var(--ar,3/4);background:var(--stone);border-radius:6px;overflow:hidden}\n.aip .frame img{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;mix-blend-mode:var(--blend)}\n\n.aip .thread{padding-bottom:40px}\n.aip.floats .thread{padding-bottom:calc(var(--tray) + 40px)}\n.aip .turn{padding:40px 0 12px;scroll-margin-top:12px}\n.aip .turn + .turn{border-top:1px solid var(--line);margin-top:32px}\n.aip .q{text-wrap:balance;font-weight:300;font-size:clamp(23px,2.4vw,31px);line-height:1.2;letter-spacing:-.018em;color:var(--ink);margin:0 0 14px;max-width:24em}\n.aip .say{font-size:clamp(17px,1.4vw,18.5px);line-height:1.62;color:var(--text);max-width:var(--read);margin:0;transition:opacity .2s}\n.aip .say p{margin:0 0 10px}\n.aip .say p:last-child{margin-bottom:0}\n.aip .say strong,.aip .say b{font-weight:700;color:var(--ink)}\n.aip .say ul,.aip .say ol{margin:6px 0 10px;padding-left:20px}\n.aip .think{display:flex;align-items:center;gap:12px;color:var(--muted);font-size:16px}\n.aip .think .dot{width:30px;height:30px;border-radius:50%;border:1px solid var(--line);background:var(--paper);display:grid;place-items:center;overflow:hidden;animation:aip-breathe 1.6s ease-in-out infinite}\n.aip .think .dot img{width:100%;height:100%;object-fit:contain;padding:4px}\n@keyframes aip-breathe{50%{box-shadow:0 0 0 6px color-mix(in srgb,var(--ink) 6%,transparent)}}\n.aip .think span:last-child{font-size:17px;color:var(--ink);background:linear-gradient(90deg,var(--muted) 0,var(--ink) 50%,var(--muted) 100%) 0 0/200% 100%;-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;animation:aip-sheen 1.8s linear infinite}\n.aip .waiting{animation:aip-fadein .25s ease both}\n.aip .ghost .frame{background:color-mix(in srgb,var(--ink) 7%,transparent);animation:aip-ghost 1.4s ease-in-out infinite}\n.aip .ghost .ln{display:block;height:12px;margin-top:12px;border-radius:6px;background:color-mix(in srgb,var(--ink) 7%,transparent);animation:aip-ghost 1.4s ease-in-out infinite}\n.aip .ghost .ln.short{width:45%;margin-top:8px}\n.aip .ghost:nth-child(2) *{animation-delay:.15s}.aip .ghost:nth-child(3) *{animation-delay:.3s}.aip .ghost:nth-child(4) *{animation-delay:.45s}\n@keyframes aip-ghost{50%{opacity:.45}}\n@keyframes aip-sheen{to{background-position:-200% 0}}\n@media (prefers-reduced-motion:reduce){.aip .think span:last-child,.aip .ghost .frame,.aip .ghost .ln{animation:none}}\n.aip .fadein{animation:aip-fadein .2s ease both}\n@keyframes aip-fadein{from{opacity:0}}\n.aip .failed{margin-top:14px;display:flex;flex-wrap:wrap;align-items:center;gap:12px;padding:14px 16px;border:1px solid var(--line);border-radius:14px;max-width:var(--read)}\n.aip .cards{margin-top:14px;max-width:var(--read);display:grid;gap:10px}\n\n.aip .fitask{margin:24px 0 0}\n.aip .fitask p{margin:0 0 10px;font-size:15px;color:var(--muted);display:flex;flex-wrap:wrap;gap:4px 12px;align-items:baseline}\n.aip .fitask p b{color:var(--ink);font-weight:700}\n.aip .choices{display:flex;flex-wrap:wrap;gap:10px;margin:18px 0 6px;max-width:var(--read)}\n.aip .choice{min-height:46px;padding:0 20px;border:1px solid var(--edge);border-radius:999px;background:var(--paper);color:var(--ink);font-size:15.5px;line-height:1.25;text-align:center;transition:background .2s,color .2s,border-color .2s,transform .12s;animation:aip-choice .32s var(--ease) both}\n.aip .choice:nth-child(2){animation-delay:.05s}.aip .choice:nth-child(3){animation-delay:.1s}.aip .choice:nth-child(n+4){animation-delay:.15s}\n.aip .choice:hover{border-color:var(--ink)}\n.aip .choice:active{transform:scale(.97);background:var(--ink);color:var(--paper)}\n@keyframes aip-choice{from{opacity:0;transform:translateY(6px)}}\n@media (prefers-reduced-motion:reduce){.aip .choice{animation:none}}\n.aip .linkbtn{font-size:14.5px;color:var(--ink);text-decoration:underline;text-underline-offset:3px}\n.aip .sizes{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none;scroll-padding-inline:var(--gut);margin:0 calc(var(--gut) * -1);padding:2px var(--gut) 6px}\n.aip .sizes::-webkit-scrollbar{display:none}\n.aip .sz{flex:none;min-width:56px;height:44px;padding:0 13px;border:1px solid var(--edge);border-radius:10px;font-size:14.5px;color:var(--ink);background:var(--paper);text-align:center;transition:background .2s,color .2s,border-color .2s}\n.aip .sz:hover{border-color:var(--ink)}\n.aip .sz[aria-pressed="true"]{background:var(--ink);color:var(--paper);border-color:var(--ink)}\n.aip .sz:disabled{color:var(--muted);opacity:.55;border-color:var(--line);cursor:default;background:linear-gradient(to top right,transparent calc(50% - .5px),var(--line) calc(50% - .5px),var(--line) calc(50% + .5px),transparent calc(50% + .5px))}\n.aip .bar{height:2px;margin:16px 0 -18px;border-radius:1px;background:linear-gradient(90deg,transparent,var(--ink),transparent) no-repeat;background-size:35% 100%;opacity:0;transition:opacity .2s}\n.aip .updating .bar{opacity:1;animation:aip-bar 1s linear infinite}\n@keyframes aip-bar{from{background-position:-40% 0}to{background-position:140% 0}}\n.aip .set{transition:opacity .2s}\n.aip .updating .set,.aip .updating .say{opacity:.5}\n\n.aip .pick{margin-top:30px;display:grid;grid-template-columns:minmax(0,400px) minmax(0,1fr);grid-template-areas:"gal head" "gal body";grid-template-rows:auto 1fr;column-gap:52px;align-items:start}\n.aip .pick .head{grid-area:head;padding-top:4px}\n.aip .pick .gal{grid-area:gal}\n.aip .pick .body{grid-area:body}\n.aip .gal{position:relative}\n.aip .slides{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:none;overscroll-behavior-x:contain;border-radius:6px}\n.aip .slides::-webkit-scrollbar{display:none}\n.aip .slides .frame{flex:0 0 100%;scroll-snap-align:start;border-radius:0}\n.aip .dots{position:absolute;left:0;right:0;bottom:14px;display:flex;justify-content:center;gap:6px;pointer-events:none}\n.aip .dots i{width:6px;height:6px;border-radius:3px;background:color-mix(in srgb,var(--ink) 22%,transparent);transition:width .25s var(--ease),background .25s}\n.aip .dots i.on{width:18px;background:color-mix(in srgb,var(--ink) 70%,transparent)}\n.aip .gnav{position:absolute;top:50%;margin-top:-20px;width:40px;height:40px;border-radius:50%;background:color-mix(in srgb,var(--paper) 94%,transparent);color:var(--ink);display:grid;place-items:center;opacity:0;transition:opacity .2s;box-shadow:0 2px 10px -4px rgba(0,0,0,.25)}\n.aip .gprev{left:12px}.aip .gnext{right:12px}\n@media (hover:hover){.aip .gal:hover .gnav{opacity:1}}\n.aip .gnav:focus-visible{opacity:1}\n.aip .tag{display:inline-block;font-size:13px;font-weight:700;color:var(--ink);background:var(--stone);border-radius:999px;padding:5px 11px;margin:0 0 14px}\n.aip .brand{font-size:13.5px;color:var(--muted);margin:0 0 3px}\n.aip .name{font-size:clamp(21px,2vw,27px);line-height:1.2;font-weight:700;letter-spacing:-.012em;color:var(--ink);margin:0 0 8px;max-width:17em}\n.aip .price{font-size:17px;color:var(--ink);margin:0}\n.aip .price s,.aip .pr s{color:var(--muted);margin-right:6px}\n.aip .why{font-size:16.5px;line-height:1.6;color:var(--text);margin:18px 0 0;max-width:30em}\n.aip .opts{display:flex;align-items:center;gap:8px;font-size:14.5px;font-weight:700;color:var(--ink);margin:16px 0 0}\n.aip .acts{display:flex;gap:10px;flex-wrap:wrap;margin-top:20px}\n.aip .btn{height:50px;padding:0 26px;border-radius:999px;font-size:15.5px;font-weight:700;display:inline-flex;align-items:center;justify-content:center;gap:8px;text-align:center;text-decoration:none;transition:transform .15s,background .2s,color .2s,border-color .2s}\n.aip .btn:active{transform:scale(.98)}\n.aip .btn:disabled{opacity:.6;cursor:default}\n.aip .btn.primary{background:var(--btn);color:var(--btn-ink)}\n.aip .btn.ghost{border:1px solid var(--edge);color:var(--ink);background:var(--paper)}\n.aip .btn.ghost:hover{border-color:var(--ink)}\n.aip .nudge{margin:18px 0 0;font-size:15px;color:var(--muted)}\n.aip .nudge button{color:var(--ink);font-weight:700;text-decoration:underline;text-underline-offset:3px}\n.aip .none{margin-top:28px;padding:24px;border-radius:14px;background:var(--stone);max-width:var(--read)}\n.aip .none .acts{margin-top:0}\n\n.aip .more{font-size:16px;font-weight:700;color:var(--ink);margin:48px 0 16px}\n.aip .grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:32px 18px}\n.aip .row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:24px;margin-top:30px}\n.aip .row.two{grid-template-columns:repeat(2,minmax(0,1fr));max-width:760px}\n.aip .grid.top{margin-top:30px}\n.aip .card{min-width:0}\n.aip .phw{position:relative}\n.aip .save,.aip .qa{position:absolute;width:38px;height:38px;border-radius:50%;background:color-mix(in srgb,var(--paper) 94%,transparent);color:var(--ink);display:grid;place-items:center;box-shadow:0 3px 12px -5px rgba(34,30,26,.35);transition:transform .15s}\n.aip .save{top:10px;right:10px}\n.aip .qa{right:10px;bottom:10px}\n.aip .save:active,.aip .qa:active{transform:scale(.92)}\n.aip .save[aria-pressed="true"] svg{fill:currentColor}\n.aip .qa.inbag{background:var(--ink);color:var(--paper)}\n.aip .card .brand{font-size:12.5px;margin:12px 0 2px}\n.aip .step{font-size:12.5px;font-weight:700;color:var(--muted);margin:12px 0 2px}\n.aip .nm{font-size:15px;line-height:1.36;font-weight:700;color:var(--ink);margin:0}\n.aip .card .brand + .nm,.aip .step + .nm{margin-top:0}\n.aip .card .phw + .nm{margin-top:12px}\n.aip .nm button{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}\n.aip .pr{font-size:15px;color:var(--ink);margin:4px 0 0}\n.aip .pr span{color:var(--muted);font-size:13.5px;margin-left:8px}\n.aip .wy{font-size:14.5px;line-height:1.5;color:var(--text);margin:8px 0 0}\n.aip .row .wy{font-size:15.5px;line-height:1.55}\n.aip .got{display:flex;align-items:center;gap:6px;font-size:13.5px;font-weight:700;color:var(--ink);margin:8px 0 0}\n\n.aip .asknext{margin-top:48px;max-width:var(--read)}\n.aip .asknext h3{font-size:14.5px;font-weight:700;color:var(--ink);margin:0 0 4px}\n.aip .nx{display:flex;width:100%;align-items:center;justify-content:space-between;gap:14px;padding:14px 2px;border-bottom:1px solid var(--line);font-size:16px;color:var(--ink)}\n.aip .nx svg{flex:none;color:var(--muted);transition:transform .2s var(--ease)}\n.aip .nx:hover svg{transform:translateX(3px)}\n.aip .paused{margin:12px 0 0;font-size:15px;color:var(--muted)}\n\n/* Sticks to the bottom of the screen while the conversation scrolls, then stops at its end, so the footer comes after it. It spans the section with its side margins; a fade, not a line, so the two widths look the same. */\n.aip .tray{position:sticky;bottom:0;z-index:900;margin:0 calc(-1 * var(--gut));background:var(--paper);padding:12px 16px max(12px,env(safe-area-inset-bottom))}\n.aip .tray::before{content:"";position:absolute;left:0;right:0;bottom:100%;height:28px;background:linear-gradient(to top,var(--paper),transparent);pointer-events:none}\n.aip.floats .tray{position:fixed;left:0;right:0;margin:0}\n.aip .tray-in{max-width:760px;margin:0 auto;display:flex;align-items:center;gap:8px}\n.aip .about-line{max-width:760px;margin:0 auto 8px;display:flex;align-items:center;gap:8px;font-size:13.5px;color:var(--muted)}\n.aip .about-line b{color:var(--ink)}\n.aip .ask{position:relative;margin:0;flex:1;min-width:0}\n.aip .ask input{width:100%;height:52px;border-radius:26px;border:1px solid var(--edge);background:var(--paper);padding:0 64px 0 22px;font:inherit;font-size:16.5px;color:var(--ink);transition:border-color .2s,box-shadow .2s}\n.aip .ask input::placeholder{color:var(--muted)}\n.aip .ask input:focus{outline:none;border-color:var(--ink);box-shadow:0 0 0 4px color-mix(in srgb,var(--ink) 7%,transparent)}\n.aip .send{position:absolute;right:5px;top:50%;margin-top:-21px;width:42px;height:42px;border-radius:50%;background:var(--btn);color:var(--btn-ink);display:grid;place-items:center;transition:transform .15s}\n.aip .send:active{transform:scale(.94)}\n.aip .send:disabled{opacity:.45;cursor:default}\n.aip .tb{position:relative;flex:none;height:52px;min-width:52px;padding:0 14px;border-radius:26px;border:1px solid var(--edge);display:inline-flex;align-items:center;justify-content:center;gap:7px;font-size:14.5px;font-weight:700;color:var(--ink);background:var(--paper)}\n.aip .tb.bump{animation:aip-bump .45s var(--ease)}\n@keyframes aip-bump{40%{transform:scale(1.12)}}\n\n.aip .scrim{position:fixed;inset:0;background:rgba(24,20,16,.34);z-index:2147482000;animation:aip-fadein .25s ease both}\n.aip .sheet{position:fixed;z-index:2147482001;background:var(--paper);color:var(--text);overscroll-behavior:contain;top:50%;left:50%;width:min(1000px,92vw);height:min(700px,88vh);border-radius:16px;overflow:hidden;display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);transform:translate(-50%,-50%);animation:aip-sheet-in .35s var(--ease) both}\n@keyframes aip-sheet-in{from{transform:translate(-50%,-47%) scale(.98);opacity:0}}\n.aip .sheet.list{grid-template-columns:1fr;width:min(560px,92vw);height:auto;max-height:80vh}\n.aip .sheet > .gal{height:100%;background:var(--stone)}\n.aip .sheet > .gal .slides{height:100%;border-radius:0}\n.aip .sheet > .gal .slides .frame{aspect-ratio:auto;height:100%}\n.aip .sheet .x{position:absolute;top:14px;right:14px;width:42px;height:42px;border-radius:50%;background:color-mix(in srgb,var(--paper) 94%,transparent);display:grid;place-items:center;z-index:3;color:var(--ink);box-shadow:0 2px 10px -4px rgba(0,0,0,.25)}\n.aip .sheet .grab{display:none}\n.aip .shb{padding:26px 28px 34px;overflow-y:auto}\n.aip .shb .name{font-size:23px;margin-right:40px}\n.aip .note{background:var(--stone);border-radius:14px;padding:14px 16px;margin:18px 0 0}\n.aip .note b{display:block;font-size:13.5px;color:var(--ink);margin:0 0 3px}\n.aip .note p{margin:0;font-size:15.5px;line-height:1.55;color:var(--text)}\n.aip .lbl{font-size:14.5px;color:var(--ink);margin:22px 0 10px}\n.aip .lbl b{font-weight:700}\n.aip .swatches{display:flex;flex-wrap:wrap;gap:10px}\n.aip .sw{width:44px;height:44px;border-radius:50%;padding:2px;border:1px solid transparent;transition:border-color .2s}\n.aip .sw img,.aip .sw span{width:100%;height:100%;border-radius:50%;object-fit:cover;background:var(--stone);display:grid;place-items:center;font-size:12px;color:var(--ink)}\n.aip .sw[aria-pressed="true"]{border-color:var(--ink)}\n.aip .sw:disabled{opacity:.35}\n.aip .shb .sizes{flex-wrap:wrap;overflow:visible;margin:0;padding:0}\n.aip .tip{font-size:14px;line-height:1.5;color:var(--muted);margin:12px 0 0}\n.aip .tip b{color:var(--ink)}\n.aip .buy{margin-top:22px;display:flex;flex-direction:column;gap:10px}\n.aip .wide{width:100%}\n.aip .done{display:flex;flex-direction:column;gap:10px}\n.aip .done p{margin:0 0 4px;display:flex;align-items:flex-start;gap:8px;font-size:15.5px;color:var(--ink);line-height:1.45}\n.aip .done p svg{flex:none;margin-top:3px}\n.aip .err{margin:0;font-size:14.5px;color:var(--ink)}\n.aip .facts{margin-top:28px;padding-top:20px;border-top:1px solid var(--line)}\n.aip .facts h4{font-size:14px;font-weight:700;color:var(--ink);margin:16px 0 6px}\n.aip .facts h4:first-child{margin-top:0}\n.aip .facts ul{margin:0;padding-left:18px;font-size:14.5px;line-height:1.6;color:var(--text)}\n.aip .about{margin-top:16px;font-size:14.5px;line-height:1.65;color:var(--muted)}\n.aip .about p{margin:0 0 10px}\n.aip .about ul{margin:0 0 10px;padding-left:18px}\n.aip .shb > .linkbtn{display:block;margin-top:16px}\n.aip .pdp{display:inline-block;margin-top:16px;font-size:15px;font-weight:700;color:var(--ink);text-underline-offset:3px}\n.aip .lrow{display:flex;align-items:center;gap:14px;padding:12px 0;border-bottom:1px solid var(--line)}\n.aip .lrow .frame{width:56px;flex:none;border-radius:5px}\n.aip .lrow div{flex:1;min-width:0}\n.aip .lrow b{display:block;font-size:15px;color:var(--ink);line-height:1.35;word-break:normal;overflow-wrap:break-word}\n.aip .lrow span{display:block;font-size:14px;color:var(--muted)}\n.aip .lrow .linkbtn{font-size:14px;flex:none;white-space:nowrap}\n.aip .empty{color:var(--muted);font-size:15px;margin:12px 0 0}\n\n.aip .toast{position:fixed;left:50%;bottom:calc(var(--tray) + 12px);transform:translateX(-50%);background:var(--ink);color:var(--paper);border-radius:999px;padding:12px 14px 12px 20px;display:flex;align-items:center;gap:16px;font-size:14.5px;z-index:2147481999;width:max-content;max-width:calc(100% - 32px);animation:aip-toast .35s var(--ease) both}\n@keyframes aip-toast{from{opacity:0;transform:translate(-50%,14px)}}\n.aip .toast button{color:var(--paper);font-weight:700;white-space:nowrap;text-decoration:underline;text-underline-offset:3px;padding:2px 6px}\n\n@media (max-width:900px){\n .aip{--gut:20px;--tray:78px}\n .aip .turn{padding-top:26px}\n .aip .pick{grid-template-columns:1fr;grid-template-areas:"head" "gal" "body";row-gap:16px;margin-top:24px}\n .aip .pick .head{padding-top:0}\n .aip .pick .gal{margin:0 calc(var(--gut) * -1)}\n .aip .pick .gal .slides{gap:8px;padding:0 var(--gut);scroll-padding-inline:var(--gut);border-radius:0}\n .aip .pick .gal .slides .frame{flex:0 0 56%;border-radius:6px}\n /* A lone photo fills the width but never more than about 340px tall: the decision stays in view. */\n .aip .pick .gal .slides .frame:only-child,.aip .sheet > .gal .slides .frame:only-child{flex-basis:min(100%, calc(340px * var(--ar,.75)))}\n .aip .pick .gal .dots,.aip .pick .gal .gnav{display:none}\n .aip .why{margin-top:2px}\n .aip .grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:26px 12px}\n .aip .row{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;scroll-padding-inline:var(--gut);gap:12px;margin:24px calc(var(--gut) * -1) 0;padding:0 var(--gut) 6px;scrollbar-width:none}\n .aip .row::-webkit-scrollbar{display:none}\n .aip .row .card{flex:0 0 62%;scroll-snap-align:start}\n .aip .row.two{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:24px 0 0;padding:0}\n .aip .row.two .wy,.aip .row.two .nm{font-size:14.5px}\n .aip .more{margin-top:40px}\n .aip .asknext{margin-top:40px}\n .aip .tray{padding:10px 12px max(10px,env(safe-area-inset-bottom))}\n .aip .ask input{height:50px}\n .aip .tb{height:50px;min-width:50px;padding:0 12px}\n .aip .sheet,.aip .sheet.list{display:block;top:auto;bottom:0;left:0;width:100%;height:auto;max-height:92vh;overflow-y:auto;border-radius:20px 20px 0 0;transform:none;animation:aip-sheet-up .35s var(--ease) both}\n @keyframes aip-sheet-up{from{transform:translateY(102%)}}\n .aip .sheet .grab{display:block;position:absolute;top:8px;left:50%;margin-left:-20px;width:40px;height:4px;border-radius:2px;background:color-mix(in srgb,var(--ink) 25%,transparent);z-index:3}\n .aip .sheet > .gal,.aip .sheet > .gal .slides{height:auto;background:none}\n .aip .sheet > .gal{padding-top:22px}\n .aip .sheet > .gal .slides{gap:8px;padding:0 var(--gut);scroll-padding-inline:var(--gut)}\n .aip .sheet > .gal .slides .frame{flex:0 0 58%;aspect-ratio:var(--ar,3/4);height:auto;border-radius:6px}\n .aip .sheet > .gal .dots,.aip .sheet > .gal .gnav{display:none}\n .aip .shb{padding:18px var(--gut) 28px;overflow:visible}\n .aip .buy{position:sticky;bottom:0;background:var(--paper);margin:22px calc(var(--gut) * -1) 0;padding:12px var(--gut) max(14px,env(safe-area-inset-bottom));border-top:1px solid var(--line);z-index:2}\n}\n@media (min-width:901px) and (max-width:1100px){.aip .grid{grid-template-columns:repeat(3,minmax(0,1fr))}.aip .pick{grid-template-columns:minmax(0,340px) minmax(0,1fr);column-gap:36px}}\n@media (prefers-reduced-motion:reduce){.aip *,.aip *::before,.aip *::after{animation:none!important;transition:none!important}}\n'}),Ze&&e.jsxs("div",{className:"thread",children:[fe.map((n,t)=>{const a=t===fe.length-1,i=a&&n.failed&&!T?(e=>{const n=e.question?.content;if(!n)return null;const{inFlight:t,asks:a}=q.current;if(t?.question===n)return t;const i=[...a].reverse().find(e=>e.question===n);return i?{turnId:i.turnId,question:n,rules:i.rules,startedAt:i.askedAt}:{turnId:v(),question:n,rules:ve.current,startedAt:Date.now()}})(n.failed):null,r=!!i&&(ce===i.turnId||cn(i.startedAt));return e.jsx("div",{ref:a?_e:void 0,children:e.jsx(Xe,{section:n,latest:a,avatar:Pn,sizeRow:a?zn:null,cap:a&&Nn?bn(Nn):null,onSize:Sn,onAllSizes:Cn,onAnyPrice:An,failed:i?r?{expired:!0,onAskAgain:()=>Fe(i.question)}:{expired:!1,onRetry:()=>{We(i)}}:void 0,chipsDisabled:o||T,actions:yn})},n.key)}),ye&&!T&&e.jsx(Te,{question:ye.question,avatar:Pn}),T&&e.jsx("p",{className:"paused",role:"status",children:A("aiPagePaused").replace("{name}",qn)})]}),Ze&&e.jsx(rn,{draft:we,onDraft:je,onSubmit:()=>{const e=we.trim();je(""),Fe(e)},sending:o&&!T,placeholder:A(T?"aiPageSearch":"aiPageFollowUp"),inputRef:ze,about:ee,onClearAbout:()=>ne(null),savedCount:N?f.length:0,onSaved:()=>Q(!0),cartCount:g,onCart:Ge}),K&&e.jsxs("div",{className:"toast",role:"status",children:[e.jsx("span",{children:K}),K!==A("aiPageAddFailed")&&e.jsx("button",{type:"button",onClick:Ge,children:A("cartViewCart")})]}),H&&e.jsx(Ve,{product:H.product,actions:{...yn,rules:H.rules,busy:yn.busy||!!fe.find(e=>e.key===H.from)?.pending},storeName:i?.bot_name||"",onAdd:(e,n)=>Ke(e,n,!0),onAskAbout:He,onClose:()=>V(null)},String(H.product.id)),Y&&e.jsx(Je,{items:f,money:bn,onOpen:e=>{Q(!1),V({product:e,rules:ve.current})},onRemove:S,onCompare:()=>{const e=f.slice(0,3).map(e=>e.name);Q(!1),Fe(A("compareSavedIntent").replace("{names}",e.join(", ")))},onClose:()=>Q(!1)})]})}function bn(n){if(n.dataset.doriMounted)return;n.dataset.doriMounted="1";const t=n.closest("[data-dori-ai-shell]");n.setAttribute("data-nosnippet",""),u.createRoot(n).render(e.jsx(m.StrictMode,{children:e.jsx(h,{children:e.jsx(g,{forceStoreFont:!0,children:e.jsx(fn,{shell:t})})})}));const a=()=>{if(C.current)return C.current();t?.querySelector("[data-dori-ask-input]")?.focus()},i=window;i.doriWidget={...i.doriWidget??{},open:a},S(a)}export{bn as mountAiPage};
Binary file
Binary file