@callimacus/thamyr-shopify 6.0.0 → 6.0.2

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.
@@ -18,5 +18,5 @@
18
18
  * See LICENSE.md for the full terms.
19
19
  *
20
20
  */
21
- const vt="chapter-event",wt="story-created",kt="cart-command",St="error",At="server-response",_t="client-ready",xt="user-interaction",Ct={debug:0,info:1,warn:2,error:3,silent:4},Et=new class{config={enabled:!1,level:"info",prefix:"[Thamyr]"};debug=(...t)=>{this.log("debug",...t)};info=(...t)=>{this.log("info",...t)};warn=(...t)=>{this.log("warn",...t)};error=(...t)=>{this.log("error",...t)};log(t,...e){if(!(this.config.enabled&&Ct[t]>=Ct[this.config.level]))return;const{prefix:n}=this.config,o=void 0===n||""===n?e:[n,...e];console[t](...o)}configure(t){this.config={...this.config,...t}}getConfig(){return{...this.config}}};function Tt(){let t,e="";try{e=globalThis.location.search}catch{}try{t=localStorage}catch{}(function(t,e){if(new URLSearchParams(t).has("callimacus_debug"))return!0;try{return null!==(e?.getItem("callimacus:debug")??null)}catch{return!1}})(e,t)&&Et.configure({enabled:!0,level:"warn"})}function Rt(){const t="undefined"==typeof crypto?void 0:crypto;if("function"==typeof t?.randomUUID)return t.randomUUID();const e=new Uint8Array(16);if("function"==typeof t?.getRandomValues)t.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(256*Math.random());e[6]=15&e[6]|64,e[8]=63&e[8]|128;const n=[...e].map(t=>t.toString(16).padStart(2,"0"));return[n.slice(0,4).join(""),n.slice(4,6).join(""),n.slice(6,8).join(""),n.slice(8,10).join(""),n.slice(10,16).join("")].join("-")}const Ot="Callimacus is AI.",qt="Learn more",$t="https://callimacus.ai",It="draft-2026-11-16",Nt=Symbol.for("callimacus.pageViewRecorders");function Lt(){const t=globalThis,e=t.callimacusPageView;return"object"==typeof e&&null!==e&&"string"==typeof e.id||(t[Nt]??0)>0}var Mt,Bt;!function(t){t.GET_STORY="get-story",t.CREATE_ROUND="create-round",t.RESET_STORY="reset-story",t.BACK_FROM_ROUND="back-from-round",t.SHARE_STORY="share-story",t.GET_SHARED_STORY="get-shared-story",t.SUGGEST="suggest"}(Mt||(Mt={})),function(t){t.ROUND_CREATED="round-created",t.ROUND_EVENT="round-event",t.ROUND_COMPLETED="round-completed",t.ERROR="error"}(Bt||(Bt={}));const jt={productSelector:"[data-product-id]",blockSelector:"[data-block-id]",maxTrackedElements:40,minVisibilityRatio:.5};class Ut{elements=new Map;elementRefs=new Map;elementKeys=new WeakMap;blocks=new Map;blockRefs=new Map;blockKeys=new WeakMap;started=!1;config;constructor(t={}){const e=t.minVisibilityRatio??jt.minVisibilityRatio;this.config={productSelector:t.productSelector??jt.productSelector,blockSelector:t.blockSelector??jt.blockSelector,maxTrackedElements:t.maxTrackedElements??jt.maxTrackedElements,minVisibilityRatio:Math.min(1,Math.max(0,e))}}rescanUi(){if(!this.canUseDom())return;let t,e;try{t=document.querySelectorAll(this.config.productSelector),e=document.querySelectorAll(this.config.blockSelector)}catch(t){return void Et.warn("UI Observer: invalid selector, skipping rescan:",t)}const n=Date.now();for(const e of t){const t=this.normalizeRect(e.getBoundingClientRect()),o=this.calculateVisibilityRatio(t);this.syncTrackedElement(e,{bounds:t,isVisible:o>=this.config.minVisibilityRatio,visibilityRatio:o,observedAt:n})}for(const t of e){const e=this.normalizeRect(t.getBoundingClientRect()),o=this.calculateVisibilityRatio(e);this.syncTrackedBlock(t,{bounds:e,isVisible:o>=this.config.minVisibilityRatio,visibilityRatio:o,observedAt:n})}this.pruneTrackedElements(),this.pruneTrackedBlocks()}pruneTrackedElements(){if(this.elements.size<=this.config.maxTrackedElements)return;const t=[...this.elements].sort(([,t],[,e])=>{const n=t.visibilityRatio-e.visibilityRatio;return 0===n||Number.isNaN(n)?t.observedAt-e.observedAt:n}).slice(0,this.elements.size-this.config.maxTrackedElements);for(const[e]of t)this.elements.delete(e),this.elementRefs.delete(e)}pruneTrackedBlocks(){if(this.blocks.size<=this.config.maxTrackedElements)return;const t=[...this.blocks].sort(([,t],[,e])=>{const n=t.visibilityRatio-e.visibilityRatio;return 0===n||Number.isNaN(n)?t.observedAt-e.observedAt:n}).slice(0,this.blocks.size-this.config.maxTrackedElements);for(const[e]of t)this.blocks.delete(e),this.blockRefs.delete(e)}syncTrackedElement(t,e){const n=this.resolveElementId(t),o=this.resolveBlockId(t),r=this.createTrackingKey(n,o),i=this.elementKeys.get(t);void 0!==i&&""!==i&&i!==r&&(this.elements.delete(i),this.elementRefs.delete(i)),this.elementKeys.set(t,r),this.elementRefs.set(r,t),this.elements.set(r,{id:n,blockId:o,trackingKey:r,...e})}syncTrackedBlock(t,e){const n=this.resolveTrackedBlockId(t),o=this.blockKeys.get(t),r=n;void 0!==o&&""!==o&&o!==r&&(this.blocks.delete(o),this.blockRefs.delete(o)),this.blockKeys.set(t,r),this.blockRefs.set(r,t),this.blocks.set(r,{id:n,...e})}resolveElementId(t){return[t.dataset.productId,t.dataset.productid,t.dataset.sku,t.id].find(t=>void 0!==t&&""!==t)??`${t.tagName}-${t.dataset.productId??this.elements.size}`}resolveBlockId(t){let e;try{e=t.closest(this.config.blockSelector)??void 0}catch{return}return e instanceof HTMLElement?this.resolveTrackedBlockId(e):void 0}resolveTrackedBlockId(t){return[t.dataset.blockId,t.dataset.blockid,t.id].find(t=>void 0!==t&&""!==t)??`${t.tagName}-${t.dataset.blockId??this.blocks.size}`}createTrackingKey(t,e){return void 0===e||""===e?t:`${t}::${e}`}normalizeRect(t){return{x:t.x,y:t.y,width:t.width,height:t.height,top:t.top,left:t.left,right:t.right,bottom:t.bottom}}calculateVisibilityRatio(t){const e=Math.max(0,Math.min(t.right,window.innerWidth)-Math.max(t.left,0))*Math.max(0,Math.min(t.bottom,window.innerHeight)-Math.max(t.top,0)),n=t.width*t.height;if(n<=0)return 0;const o=window.innerWidth*window.innerHeight,r=o>0?Math.min(n,o):n;return Math.min(1,Math.max(0,e/r))}canUseDom(){return void 0!==globalThis.window&&"undefined"!=typeof document}start(){!this.started&&this.canUseDom()&&(this.started=!0)}stop(){this.started&&(this.started=!1,this.elements.clear(),this.elementRefs.clear(),this.blocks.clear(),this.blockRefs.clear())}getSnapshot(){if(!this.canUseDom())return;this.rescanUi();const t=[],e=[],n=Date.now();for(const[e,n]of this.elements){const o=this.elementRefs.get(e);o?.isConnected?n.visibilityRatio<=0||t.push({blockId:n.blockId,element:{id:n.id,bounds:n.bounds,isVisible:n.visibilityRatio>=this.config.minVisibilityRatio,visibilityRatio:n.visibilityRatio}}):(this.elements.delete(e),this.elementRefs.delete(e))}for(const[t,n]of this.blocks){const o=this.blockRefs.get(t);o?.isConnected?n.visibilityRatio<this.config.minVisibilityRatio||e.push(n.id):(this.blocks.delete(t),this.blockRefs.delete(t))}const o=t.slice(0,this.config.maxTrackedElements);return{timestamp:n,viewport:{width:window.innerWidth,height:window.innerHeight},blockIds:[...new Set([...e,...o.flatMap(t=>t.blockId??[])])],elements:o.map(t=>t.element)}}}function Ft(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}const Dt=t=>"string"==typeof t&&t.length>0,Pt=t=>Ft(t)&&Dt(t.size)&&Dt(t.variantId)&&"boolean"==typeof t.orderable;class Wt{socket;serverResponseListeners=new Set;connectionStatusListeners=new Set;errorListeners=new Set;warningListeners=new Set;reportedWarnings=new Set;uiObserver;uiObserverConfig=jt;handshakeRetryAttempts=0;handshakeRetryTimer;setupEventListeners(){this.socket&&(this.socket.on("connect",()=>{Et.debug("Connected to Callimacus"),this.clearHandshakeRetry(),this.handshakeRetryAttempts=0,this.updateConnectionStatus(!0),this.socket?.emit(_t)}),this.socket.on("disconnect",()=>{Et.info("Disconnected from Callimacus"),this.updateConnectionStatus(!1)}),this.socket.on("connect_error",t=>{this.updateConnectionStatus(!1);const e=function(t,e){return e?void 0:function(t){const{data:e}=t;if("object"!=typeof e||null===e)return;const{code:n,reason:o}=e;return"number"==typeof n?{code:n,..."string"==typeof o&&{reason:o}}:void 0}(t)??{code:0}}(t,this.socket?.active??!0);e&&(Et.error("Connection refused by Callimacus:",t.message,e.reason??""),this.notifyRejection(e,t.message),this.scheduleHandshakeRetry(e.code))}),this.socket.on(St,t=>{Et.error("Received error from Callimacus:",t),this.notifyErrorListeners(t)}),this.socket.io.on("reconnect",t=>{Et.info(`Reconnected to Callimacus after ${t} attempts`)}),this.socket.io.on("reconnect_attempt",t=>{Et.info(`Attempting to reconnect: attempt ${t}`)}),this.socket.io.on("reconnect_error",t=>{Et.error("Reconnection error:",t)}),this.socket.io.on("reconnect_failed",()=>{Et.error("Failed to reconnect to Callimacus service!"),this.updateConnectionStatus(!1)}),this.socket.on(At,t=>{"chapter-event"===t.type&&this.notifyWarningListeners(function(t,e){return(t.warnings??[]).filter(n=>{const o=`${t.id}:${n.block}:${n.content}`;return!e.has(o)&&(e.add(o),!0)})}(t.chapter,this.reportedWarnings)),this.notifyServerResponseListeners(t)}))}notifyServerResponseListeners(t){this.serverResponseListeners.forEach(e=>{try{e(t)}catch(t){Et.error("Error in server response listener:",t)}})}updateConnectionStatus(t){this.connectionStatusListeners.forEach(e=>{try{e(t)}catch(t){Et.error("Error in connection status listener:",t)}})}notifyRejection(t,e){this.notifyErrorListeners({code:t.code,message:e,...void 0!==t.reason&&{reason:t.reason}})}scheduleHandshakeRetry(t){if(!this.socket)return;if(this.clearHandshakeRetry(),!function(t,e){return t>=500&&e<3}(t,this.handshakeRetryAttempts))return void(t>=500&&(Et.error("Giving up on the Callimacus connection after 3 retries"),this.notifyRejection({code:t,reason:"retries_exhausted"},"Connection failed after 3 retries; call connect() to try again")));const e=2**(this.handshakeRetryAttempts+1);this.handshakeRetryAttempts+=1,Et.info(`Retrying Callimacus connection in ${e}s (attempt ${this.handshakeRetryAttempts}/3)`),this.handshakeRetryTimer=setTimeout(()=>{this.socket?.connect()},1e3*e)}clearHandshakeRetry(){void 0!==this.handshakeRetryTimer&&(clearTimeout(this.handshakeRetryTimer),this.handshakeRetryTimer=void 0)}notifyErrorListeners(t){this.errorListeners.forEach(e=>{try{e(t)}catch(t){Et.error("Error in error listener:",t)}})}notifyWarningListeners(t){for(const e of t)0===this.warningListeners.size&&Et.warn(`Block "${e.block}" was not shown: its content "${e.content}" failed (${e.cause}). \`callimacus thamyr probe\` shows why.`),this.warningListeners.forEach(t=>{try{t(e)}catch(t){Et.error("Error in warning listener:",t)}})}async getLocation(){if("undefined"!=typeof navigator&&"function"==typeof navigator.geolocation?.getCurrentPosition)return new Promise(t=>{navigator.geolocation.getCurrentPosition(e=>{t(e)},()=>{t(void 0)})})}enrichPayloadWithUiContext(t){try{this.ensureUiObserver();const e=this.uiObserver?.getSnapshot();return e?{...t,context:{...t.context,uiSnapshot:e}}:t}catch(e){return Et.error("Error enriching payload with UI context:",e),t}}ensureUiObserver(){"undefined"!=typeof window&&"undefined"!=typeof document&&this.uiObserverConfig.enabled&&(this.uiObserver??=new Ut(this.uiObserverConfig),this.uiObserver.start())}socketEndpoint(t){const e=new URL(t),n=new URL("thamyr",e).pathname;return{origin:e.origin,path:n}}connect(t="wss://localhost:4000",e,n){this.socket&&(Et.warn("Already connected to Thamyr. Disconnecting first...."),this.disconnect());const o=this.socketEndpoint(t);let r;"undefined"!=typeof window&&void 0!==globalThis.location&&(r=globalThis.location.href);const i="undefined"==typeof document?void 0:function(t){const e=t.split("; ").find(t=>t.startsWith("intent_sid="))?.slice(11);return void 0===e||""===e?void 0:e}(document.cookie),s={...void 0!==r&&""!==r&&{referrer:r},...void 0!==i&&{intentSid:i},...n};Et.info("Connecting to Thamyr at",o),this.socket=bt(o.origin,{path:o.path,transports:["websocket","polling"],tryAllTransports:!0,extraHeaders:e,auth(t){t({...s,...Lt()&&{recordsPageViews:!0}})}}),this.setupEventListeners(),this.ensureUiObserver()}disconnect(){this.clearHandshakeRetry(),this.handshakeRetryAttempts=0,this.socket&&(this.socket.disconnect(),this.socket=void 0,this.uiObserver?.stop(),this.uiObserver=void 0,this.updateConnectionStatus(!1),Et.info("Disconnected from Callimacus"))}configureUiObserver(t){if(!t)return this.uiObserver?.stop(),this.uiObserver=void 0,void(this.uiObserverConfig={...jt,enabled:!1});const e=t.enabled??(void 0!==t.productSelector||void 0!==t.blockSelector||void 0!==t.maxTrackedElements||void 0!==t.minVisibilityRatio||this.uiObserverConfig.enabled);if(this.uiObserverConfig={...this.uiObserverConfig,...t,enabled:e},"undefined"==typeof window||"undefined"==typeof document||!this.uiObserverConfig.enabled)return this.uiObserver?.stop(),void(this.uiObserver=void 0);this.uiObserver&&this.uiObserver.stop(),this.uiObserver=new Ut(this.uiObserverConfig),this.uiObserver.start()}sendUserInteraction(t,e){if(!this.socket)return void Et.error("Socket is not connected. Cannot send interaction.");if(t===Mt.SUGGEST)return void Et.error("SUGGEST is a request/response command. Use suggest() instead.");if(t===Mt.BACK_FROM_ROUND&&void 0===e.chapterId)return void Et.error("BACK_FROM_ROUND requires chapterId.");const n={type:t,payload:this.enrichPayloadWithUiContext(e)},o={id:Rt()};this.socket.emit(xt,{type:n.type,payload:n.payload},o.id)}async suggest(t,e={}){if(!this.socket?.connected)return{suggestions:[]};try{return function(t){const e=t?.suggestions;return{suggestions:Array.isArray(e)?e.filter(t=>"string"==typeof t):[]}}(await this.socket.timeout(e.timeoutMs??4e3).emitWithAck(xt,{type:Mt.SUGGEST,payload:t}))}catch(t){return Et.warn("Suggestions failed or timed out; serving none.",t),{suggestions:[]}}}async gatherClientInfo(){const t="undefined"==typeof navigator?void 0:navigator,e="undefined"==typeof window?void 0:window.screen;return{userAgent:t?.userAgent??"",language:t?.language??"",timezone:(new Intl.DateTimeFormat).resolvedOptions().timeZone,localTime:(new Date).toLocaleString(),screenResolution:void 0===e?"":`${e.width}x${e.height}`,location:await this.getLocation()}}onServerResponse(t){return this.serverResponseListeners.add(t),()=>{this.serverResponseListeners.delete(t)}}onConnectionStatus(t){return this.connectionStatusListeners.add(t),()=>{this.connectionStatusListeners.delete(t)}}onError(t){return this.errorListeners.add(t),()=>{this.errorListeners.delete(t)}}onWarning(t){return this.warningListeners.add(t),()=>{this.warningListeners.delete(t)}}}const zt=10,Vt=/^[A-Za-z]\w{0,39}$/u,Ht=/^[\w\-./:]{1,128}$/u,Kt=new Set(["page_viewed","item_opened","added_to_cart","custom_event","conversation_started","question_asked","answer_delivered"]);const Jt=/^[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/u,Yt=t=>void 0!==t&&Jt.test(t),Gt="function"==typeof TextEncoder?new TextEncoder:void 0,Xt=new WeakMap;function Zt(t){let e=Xt.get(t);if(void 0===e){const n=JSON.stringify(t);e=void 0===Gt?3*n.length:Gt.encode(n).length,Xt.set(t,e)}return e}function Qt(t){const e=[];let n=[],o=0;for(const r of t){const t=Zt(r);(50===n.length||n.length>0&&o+t>57344)&&(e.push(n),n=[],o=0),n.push(r),o+=t}return n.length>0&&e.push(n),e}function te(t){const{transport:e,declares:n}=t,o=t.delayMs??3e3;let r,i,s,a,c=[],d=!1,l=0,u=!1;const h=new Set(n.types),p=(t,e)=>({sentAt:(new Date).toISOString(),events:t,declares:{types:[...h],addsCarryRoundId:n.addsCarryRoundId},...e>0&&{dropped:e}});function f(){clearTimeout(s),clearTimeout(a),s=void 0,a=void 0}function m(){void 0!==s||void 0!==a||u||(s=setTimeout(()=>{s=void 0,g()},o))}async function g(){if(d||u)return;f(),r??=function(){const[t]=Qt(c);if(void 0===t)return;c=c.slice(t.length);const e=l;return l=0,{events:t,dropped:e,attempts:0}}();const t=r;if(void 0===t)return;let n;d=!0;try{n=await e.send(p(t.events,t.dropped))}catch{n="retry"}if(d=!1,r!==t||u)return void(c.length>0&&m());const o="object"==typeof n?n.retryAfterMs:void 0;if(("retry"===n||void 0!==o)&&t.attempts<3)return t.attempts+=1,void(a=setTimeout(()=>{a=void 0,g()},o??2e3*2**(t.attempts-1)));r=void 0,"accepted"!==n&&(l+=t.dropped+t.events.length),c.length>0&&m()}function y(t,e){t.catch(()=>!1).then(t=>{t||(l+=e)})}function b(){if(u)return;f();const t=void 0===r||d?void 0:r,n=[...r?.events??[],...c];let o=l+(t?.dropped??0);c=[],r=void 0,l=0;const i=Qt(n);0===i.length&&o>0&&i.push([]);for(const t of i){const n=t.length+o;let r=!1;try{r=e.sendOnHide(p(t,o))}catch{}!1===r?l+=n:!0!==r&&y(r,n),o=0}}const v=()=>{b()},w=()=>{"undefined"!=typeof document&&"hidden"===document.visibilityState&&b()};return"function"==typeof globalThis.addEventListener&&globalThis.addEventListener("pagehide",v),"undefined"!=typeof document&&"function"==typeof document.addEventListener&&document.addEventListener("visibilitychange",w),{record(e,n,o={}){const s=Date.now(),a=function(t=Date.now()){const e=new Uint8Array(16),n="undefined"==typeof crypto?void 0:crypto;if("function"==typeof n?.getRandomValues)n.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(256*Math.random());let o=t;for(let t=5;t>=0;t--)e[t]=o%256,o=Math.floor(o/256);e[6]=15&e[6]|112,e[8]=63&e[8]|128;const r=[...e].map(t=>t.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}(s),d="page_viewed"===e?void 0:t.conversationId?.(),p={eventId:a,type:e,typeVersion:1,clientCreatedAt:new Date(s).toISOString(),...void 0!==i&&"page_viewed"!==e&&{pageViewId:i},...Yt(o.roundId)&&{roundId:o.roundId},...Yt(d)&&{conversationId:d},payload:n};return"page_viewed"===e&&(i=a),u?a:c.length+(r?.events.length??0)>=100||Zt(p)>57344||"custom_event"===e&&!function(t){if(!Vt.test(t.name)||Kt.has(t.name.toLowerCase()))return!1;const e=Object.entries(t.fields??{});return e.length<=zt&&e.every(([t,e])=>Vt.test(t)&&(t=>"boolean"==typeof t||"number"==typeof t&&Number.isFinite(t)||"string"==typeof t&&Ht.test(t))(e))}(n)?(l+=1,a):(h.add(e),c.push(p),m(),a)},get pageViewId(){return i},adoptPageView(t){i=t},flush:g,stop(){u=!0,f(),"function"==typeof globalThis.removeEventListener&&globalThis.removeEventListener("pagehide",v),"undefined"!=typeof document&&"function"==typeof document.removeEventListener&&document.removeEventListener("visibilitychange",w)}}}const ee=Symbol.for("callimacus.eventMarkupRuntimes"),ne=(t,e)=>{const n=t?.getAttribute(e)?.trim();return void 0===n||""===n?void 0:n};function oe(){const t=globalThis;return t[ee]??={runtimes:[]},t[ee]}const re=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),ie=t=>String(t).split("/").pop()??"";function se(t,e,n=0){if(!(null===t||"object"!=typeof t||n>6)){if(function(t){if(!re(t)||!re(t.fields))return!1;const e=t.fields["shopify-handle"];return"string"==typeof e&&""!==e}(t)){const n=t.fields.variantTree?.variants??[];if(Array.isArray(n)&&n.some(t=>ie(t?.id??"")===e))return"string"==typeof t.id&&""!==t.id?t.id:t.fields["shopify-handle"]}for(const o of Object.values(t)){const t=se(o,e,n+1);if(void 0!==t)return t}}}function ae(t,e,n,o){const r=ie(t),i=n.itemId??se(o,r);return void 0===i||""===i?void 0:{itemId:i,variantId:`gid://shopify/ProductVariant/${r}`,quantity:e,origin:n.origin??"card"}}function ce(t){const e=t?.trim()??"",n=""===e?NaN:Number(e),o=Number.isFinite(n)?1e3*n:Date.parse(e)-Date.now();return Number.isFinite(o)?Math.min(Math.max(o,0),6e5):6e4}async function de(t,e,n){const o=void 0===n||"function"!=typeof AbortController?void 0:new AbortController,r=void 0===o?void 0:setTimeout(()=>{o.abort()},n);try{const n=await fetch(t,{...e,...void 0!==o&&{signal:o.signal}}),r=429===n.status?n.headers.get("retry-after"):void 0;return function(t,e){return t>=200&&t<300?"accepted":429===t?{retryAfterMs:ce(e)}:t>=500?"retry":"refused"}(n.status,r??void 0)}catch{return"retry"}finally{clearTimeout(r)}}function le(t){const e=`${t.endsWith("/")?t.slice(0,-1):t}/events`,n=t=>({method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),credentials:"same-origin"});return{send:async t=>de(e,n(t),1e4),sendOnHide:async t=>async function(t,e){return"accepted"===await de(t,{...e,keepalive:!0})}(e,n(t))}}const ue="callimacus:shopify-cart-commands",he=new Set(["cart_disabled","cart_unavailable"]);function pe(t,e){const{item:n,quantity:o}=t,r=`${o>1?`${o} × `:""}${n.name}${n.options.length>0?` (${n.options.map(t=>t.value).join(", ")})`:""}`;return void 0===e.error?{...t,outcome:"added",message:e.warnings?.[0]?.message??`${r} is in your bag.`}:"refused"===e.error.code?{...t,outcome:"refused",message:e.error.message}:he.has(e.error.code)?{...t,outcome:"unavailable",message:"The bag is not available on this site right now."}:{...t,outcome:"failed",message:e.error.message}}const fe=/^gid:\/\/shopify\/ProductVariant\/\d+$/v,me="[callimacus]",ge={debug(...t){console.debug(me,...t)},info(...t){console.info(me,...t)},warn(...t){console.warn(me,...t)},error(...t){console.error(me,...t)}};function ye(t){try{return globalThis[t]}catch{return}}function be(t,e){try{return ye(t)?.getItem(e)??void 0}catch{return}}function ve(t,e,n){try{const o=ye(t);return!!o&&(o.setItem(e,n),!0)}catch(n){return ge.warn(`could not write ${t} "${e}"`,n),!1}}function we(t,e){try{ye(t)?.removeItem(e)}catch(n){ge.warn(`could not clear ${t} "${e}"`,n)}}function ke(t,e="",n){const o=document.createElement(t);return""!==e&&(o.className=e),void 0!==n&&(o.textContent=n),o}function Se(t,e=""){const n=ke("p",`cal-cart-notice ${e}`.trim(),t.message);return n.setAttribute("role","status"),n.dataset.outcome=t.outcome,n}const Ae="http://www.w3.org/2000/svg";function _e(t,e,n){const o=document.createElementNS(Ae,"svg");o.setAttribute("class",n),o.setAttribute("viewBox",t),o.setAttribute("aria-hidden","true"),o.setAttribute("focusable","false");const r=document.createElementNS(Ae,"path");return r.setAttribute("d",e),r.setAttribute("fill","currentColor"),r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),o.append(r),o}function xe(t,e){for(const n of e.split(/\n{2,}/u)){const e=ke("p");for(const[t,o]of n.split("**").entries())""!==o&&e.append(t%2==1?ke("strong","",o):document.createTextNode(o));e.childNodes.length>0&&t.append(e)}}function Ce(t){for(let e=t;e&&e!==document.body;e=e.parentElement??void 0){const{position:t}=getComputedStyle(e);if("fixed"===t||"sticky"===t)return e}}function Ee(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Te(t){if(!Ee(t)||!Ee(t.fields))return!1;const e=t.fields["shopify-handle"];return"string"==typeof e&&""!==e}function Re(t){return"string"==typeof t.kind&&""!==t.kind?t.kind:"product"}const Oe=/^\s*\{\s*"error"\s*:/u;function qe(t){return"string"==typeof t&&""!==t.trim()&&!Oe.test(t)}function $e(...t){for(const e of t)if(qe(e))return e.trim();return""}function Ie(t){return"string"==typeof t?t.trim():""}function Ne(t){return null!==t.closest("[data-callimacus-ui], .cal-dock, .cal-stage, .cal-toast")}function Le(t){const e=new Set,n=[];for(const o of t){if(!Te(o))continue;const t=Re(o),r=`${t}:${o.fields["shopify-handle"]}`,i=(o.fields.title??"").trim().toLowerCase(),s=`${t}|${i}`;e.has(r)||""!==i&&e.has(s)||(e.add(r),""!==i&&e.add(s),n.push(o))}return n}function Me(t,e){const n=t.trim();if(n.length<=e)return n;const o=n.slice(0,e-1),r=o.lastIndexOf(" ");return`${(r>e/2?o.slice(0,r):o).trimEnd()}…`}function Be(t){return Ee(t)&&Ee(t.meta)&&Array.isArray(t.sections)}function je(t){const e=(t.sections??[]).filter(t=>Ee(t)&&"text"===t.type&&qe(t.content)).flatMap(t=>String(t.content).split(/\n{2,}/u)).map(t=>t.trim()).filter(t=>qe(t)),n=[];let o=600;for(const t of e){if(t.length>o){0===n.length&&n.push(Me(t,o));break}n.push(t),o-=t.length}return n}function Ue(t){const e=t?.data;return Ee(e)?Object.values(e):[]}function Fe(t){return Ue(t).some(t=>function(t){return null!=t&&("string"==typeof t?qe(t):Array.isArray(t)?t.length>0:"object"!=typeof t||Object.keys(t).length>0)}(t))}function De(t){if(Array.isArray(t))return t.map(t=>De(t));if(Be(t)){const e=t.meta??{};return{id:t.id,name:t.name,meta:{url:e.url,title:e.title,shopifyKind:e.shopifyKind},sections:je(t).map(t=>({type:"text",content:t}))}}if(Te(t)&&"product"!==Re(t)){const{fields:e}=t;return{id:t.id,kind:t.kind,fields:{title:e.title,"shopify-handle":e["shopify-handle"],"shopify-blogHandle":e["shopify-blogHandle"],"shopify-publishedAt":e["shopify-publishedAt"],"shopify-author":e["shopify-author"],"shopify-productsCount":e["shopify-productsCount"],descriptionText:qe(e.descriptionText)?Me(e.descriptionText,240):void 0,images:(e.images??[]).slice(0,2).map(t=>({url:t?.url,alt:t?.alt}))}}}if(Te(t)){const{fields:e}=t;return{id:t.id,kind:t.kind,fields:{title:e.title,"shopify-handle":e["shopify-handle"],"shopify-vendor":e["shopify-vendor"],"shopify-productType":e["shopify-productType"],price:e.price,availableSizes:e.availableSizes,images:(e.images??[]).slice(0,2).map(t=>({url:t?.url,alt:t?.alt})),variantTree:{variants:(e.variantTree?.variants??[]).map(t=>({id:t?.id,axes:t?.axes,price:t?.price,orderable:t?.orderable}))}}}}return Ee(t)?Object.fromEntries(Object.entries(t).map(([t,e])=>[t,De(e)])):t}const Pe=["aria-labelledby","aria-describedby","aria-controls","for","form"];function We(t){const e=t.fields.variantTree?.variants;return Array.isArray(e)?e:[]}function ze(t){const e=We(t);return e.length>0&&e.every(t=>!0!==t?.orderable)}function Ve(t){const e=globalThis.Shopify,n=$e(t.settings.rootUrl,e?.routes?.root,"/");return n.endsWith("/")?n:`${n}/`}async function He(t){return new Promise(e=>{setTimeout(e,t)})}function Ke(t){return void 0===t.hit?.id||""===t.hit.id?t.handle:t.hit.id}function Je(t,e,n){const{hit:o}=t,r=ke("span");if(We(o).length>1||Array.isArray(o.fields.availableSizes)&&o.fields.availableSizes.length>1){const t=ke("a",n.className);return t.href=e.url(o),r.textContent=n.labels.choose,t.append(r),t}const i=ke("button",n.className);i.type="button",i.setAttribute("aria-live","polite"),i.append(r),n.busy&&i.append(n.busy);const s=e.variantId(o);if(""===s)return r.textContent=n.labels.soldOut,i.disabled=!0,i;r.textContent=n.labels.add;return i.addEventListener("click",()=>{(async()=>{if("true"!==i.getAttribute("aria-disabled")){i.setAttribute("aria-disabled","true"),i.classList.add("loading"),n.busy?.classList.remove("hidden");try{await e.addToCart(s,1,{productId:Ke(t)}),e.remember?.("added",t.handle),r.textContent=n.labels.added,await He(2e3),r.textContent=n.labels.add}catch(t){r.textContent=t instanceof Error&&""!==t.message?t.message:n.labels.failed}finally{i.classList.remove("loading"),n.busy?.classList.add("hidden"),i.removeAttribute("aria-disabled")}}})()}),i}function Ye(t){if("string"==typeof t){const e=t.trim();return""===e?void 0:{handle:e,hit:void 0,title:""}}return Te(t)?"product"===Re(t)?{handle:t.fields["shopify-handle"],hit:t,title:Ie(t.fields.title)}:void 0:Ee(t)&&""!==Ie(t.handle)?{handle:Ie(t.handle),hit:void 0,title:Ie(t.title)}:void 0}function Ge(t,e){const n=new Map,o=new Map,r=new Map,i=new Map,s=[];let a,c,d=0;function l(){for(;d<6&&s.length>0;)d+=1,s.shift()?.()}async function u(r,i){const{handle:a}=r,c=n.get(a);if(c)return c;const u="string"==typeof t?`${Ve(i)}products/${encodeURIComponent(a)}?section_id=${t}`:t(r,Ve(i)),h=async function(t){return new Promise((e,n)=>{s.push(()=>{t().then(e).catch(n).finally(()=>{d-=1,l()})}),l()})}(async()=>fetch(u,{headers:{Accept:"text/html"}})).then(async t=>t.ok?t.text():void 0).then(t=>void 0===t?void 0:e.extract(t,r)).catch(()=>{}).then(t=>(o.set(a,t),t));return n.set(a,h),h}function h(t,n,o){const i=t.content.firstElementChild;if(!i)throw new Error("empty card template");const s=document.importNode(i,!0);if(void 0!==o.sizes)for(const t of s.querySelectorAll("img[srcset]"))t.sizes=o.sizes;const a=(r.get(n)??0)+1;return r.set(n,a),e.prepare?.(s),a>1&&function(t,e){const n=new Map;for(const o of t.querySelectorAll("[id]"))n.set(o.id,o.id+e),o.id+=e;for(const e of t.querySelectorAll(Pe.map(t=>`[${t}]`).join(",")))for(const t of Pe){const o=e.getAttribute(t);null!==o&&""!==o&&e.setAttribute(t,o.split(/\s+/u).map(t=>n.get(t)??t).join(" "))}}(s,`-${a}`),s}function p(t,n,o){t.classList.remove("cal-card--pending"),t.classList.add("cal-card--offline"),o.hit||e.offline(n,o)}return{card:function(t,n,r={}){const s=Ye(t);if(!s)return;a=n,s.hit&&function(t,e){for(const n of We(t)){const t=String(n?.id??"").split("/").pop()??"";""!==t&&i.set(t,e)}}(s.hit,s.handle);const d=ke("div","cal-card");d.dataset.handle=s.handle;const l={handle:s.handle,ctx:n,productId:Ke(s)};d.addEventListener("click",()=>{c={...l,at:Date.now()}},{capture:!0});const f=o.get(s.handle);if(f)return d.append(h(f,s.handle,r)),d;const m=s.hit?e.placeholder({...s,hit:s.hit},n,r):e.skeleton(s,n,r);return d.append(m),o.has(s.handle)?(p(d,m,s),d):(d.classList.add("cal-card--pending"),u(s,n).then(async t=>{t?await async function({host:t,draft:e},n,o,r){const i=h(n,o,r),s=e.querySelector("img"),a=i.querySelector("img");a&&s?.complete&&s.naturalWidth>0&&(a.loading="eager",await Promise.race([a.decode().catch(()=>{}),He(800)])),e.replaceWith(i),t.classList.remove("cal-card--pending")}({host:d,draft:m},t,s.handle,r):p(d,m,s)}),d)},rememberAdded:function(t,e=1){const n="string"==typeof t||"number"==typeof t?String(t).split("/").pop()??"":"",o=i.get(n);void 0!==o&&(a?.remember?.("added",o),c?.handle!==o||Date.now()-c.at>6e4||(c.ctx.productAdded?.(n,e,{productId:c.productId}),c=void 0))}}}const Xe=globalThis;function Ze(){return"undefined"==typeof PUB_SUB_EVENTS?void 0:PUB_SUB_EVENTS}const Qe={Accept:"application/javascript","X-Requested-With":"XMLHttpRequest"};class tn extends Error{code;constructor(t,e,n){super(e,n),this.name="CartAddError",this.code=t}}async function en(t){try{return await t(),{}}catch(t){const e=t instanceof Error&&""!==t.message?t.message:"Could not add to cart.";return{error:{code:t instanceof tn?t.code:"failed",message:e}}}}async function nn(t,e){let n;try{n=await fetch(`${t.cartAddUrl}.js`,{method:"POST",...e})}catch(t){throw new tn("failed","Could not reach the cart. Check your connection and try again.",{cause:t})}const o=await n.json().catch(()=>{}),r=Ee(o)?o:{},i=$e(r.description,r.message,"Could not add to cart.");return!Boolean(r.status)&&n.ok?{json:r,failure:void 0===o?new tn("cart_unavailable",i):void 0}:{json:r,failure:new tn(on("number"==typeof r.status?r.status:n.status),i)}}function on(t){return 422===t?"refused":404===t?"cart_unavailable":"failed"}const rn="cart:update";function sn(t,e){document.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:e}))}async function an(t,e,n){const o=new FormData;o.append("id",t),o.append("quantity",String(e));const r=[...document.querySelectorAll("cart-items-component[data-section-id]")].map(t=>t.dataset.sectionId??"").filter(t=>""!==t);r.length>0&&o.append("sections",r.join(","));const{json:i,failure:s}=await nn(n,{headers:Qe,body:o});if(s)throw sn("cart:error",{sourceId:"callimacus",data:{message:i.message,errors:i.errors,description:i.description}}),s;const a=await async function(t){try{const e=await fetch(`${Ve({settings:t})}cart.js`,{headers:{accept:"application/json"}}),n=await e.json();return Ee(n)?n:void 0}catch{return}}(n),c="number"==typeof a?.item_count?a.item_count:void 0;return sn(rn,{resource:a,sourceId:"callimacus",data:{source:void 0===c?"product-form-component":"callimacus",itemCount:c??e,variantId:t,sections:Ee(i.sections)?i.sections:void 0}}),i}const cn=/^[*\-•]\s+(?<text>\S.*)$/u,dn=/^\d+[).]\s+(?<text>\S.*)$/u,ln=/^#{1,6}\s+(?<text>\S.*)$/u,un=/^\s*(?:[*\-•]|\d+[).]|#{1,6})\s*$/u;const hn=new WeakMap;function pn(t,e){hn.get(t)!==e&&(hn.set(t,e),t.replaceChildren(),function(t,e){for(const[n,o]of e.split("**").entries())""!==o&&t.append(n%2==1?ke("strong","",o):document.createTextNode(o))}(t,e))}function fn(t,e){for(const[n,o]of e.entries()){let e=t.children.item(n);null===e&&(e=ke("li"),t.append(e)),pn(e,o)}for(;t.children.length>e.length;)t.lastElementChild?.remove()}const mn=new WeakMap;function gn(t,e,n){const o=mn.get(t)??ke("span","cal-caret");mn.set(t,o),o.setAttribute("aria-hidden","true"),o.remove();const r=function(t,e){const n=t.replaceAll(/\r\n?/gu,"\n").split("\n");!e&&un.test(n.at(-1)??"")&&n.pop();const o=[];let r,i;for(const t of n){const e=t.trim();if(""===e){r=void 0,i=void 0;continue}const n=ln.exec(e);if(n){o.push({tag:"h3",text:n.groups?.text??""}),r=void 0,i=void 0;continue}const s=cn.exec(e),a=s??dn.exec(e);if(a){const t=s?"ul":"ol";i?.tag!==t&&(i={tag:t,items:[]},o.push(i)),i.items.push(a.groups?.text??""),r=void 0;continue}i&&/^\s/u.test(t)?i.items[i.items.length-1]+=` ${e}`:(i=void 0,r?r.text+=` ${e}`:(r={tag:"p",text:e},o.push(r)))}return o}(e,n);for(const[e,n]of r.entries()){let o=t.children.item(e);if(o?.tagName.toLowerCase()!==n.tag){const e=ke(n.tag);null===o?t.append(e):o.replaceWith(e),o=e}"items"in n?fn(o,n.items):pn(o,n.text)}for(;t.children.length>r.length;)t.lastElementChild?.remove();const i=t.lastElementChild;!n&&i&&(i.matches("ul, ol")?i.lastElementChild??i:i).append(o)}function yn(t,e,n=!0,o=""){const r=ke("div",`${e} cal-prose ${o}`.trim());return gn(r,t,n),r}function bn(t){return Array.isArray(t)?t:[]}function vn(t){return Ee(t)?t:{}}let wn=0;function kn(t){return wn+=1,`cal-${t}-${wn}`}function Sn(){return _e("0 0 14 10","M8.537.808a.5.5 0 01.817-.162l4 4a.5.5 0 010 .708l-4 4a.5.5 0 11-.708-.708L11.793 5.5H1a.5.5 0 010-1h10.793L8.646 1.354a.5.5 0 01-.109-.546z","cal-icon cal-icon--arrow")}function An(){return _e("0 0 10 6","M9.354.646a.5.5 0 00-.708 0L5 4.293 1.354.646a.5.5 0 00-.708.708l4 4a.5.5 0 00.708 0l4-4a.5.5 0 000-.708z","cal-icon cal-icon--caret")}function _n(t,e,n){return`${t} ${1===t?e:n}`}const xn=["text","message","reply","answer","intro","body"],Cn=["What would you recommend?","Show me what is new","What are your best sellers?","Help me find a gift"];function En(t){return bn(t.fields.images).length>1?1:0}function Tn(t,e,{index:n=0,widths:o,sizes:r,eager:i=!1,className:s=""}){const a=o[Math.floor(o.length/2)]??800,c=t.imageUrl(e,{index:n,width:a});if(""===c)return;const d=ke("img",s);return d.srcset=o.map(o=>`${t.imageUrl(e,{index:n,width:o})} ${o}w`).join(", "),d.sizes=r,d.src=c,d.alt=$e(e.fields.images?.[n]?.alt,e.fields.title),d.decoding="async",d.loading=i?"eager":"lazy",i&&(d.fetchPriority="high"),function(t){t.classList.add("cal-reveal");const e=()=>{t.classList.add("is-ready")};t.complete&&t.naturalWidth>0?e():(t.addEventListener("load",e,{once:!0}),t.addEventListener("error",e,{once:!0}))}(d),d}const Rn=[360,535,750,1070];function On(t,e){const n="string"==typeof t?new Date(t):void 0;return!n||Number.isNaN(n.getTime())?"":function(t){let e=qn.get(t);if(!e){try{e=new Intl.DateTimeFormat(t,{dateStyle:"medium"})}catch{e=new Intl.DateTimeFormat("en",{dateStyle:"medium"})}qn.set(t,e)}return e}(e).format(n)}const qn=new Map;function $n(t,e,n){const o=Re(t),r=Tn(e,t,{widths:Rn,sizes:n}),i=ke("article",`cal-entry cal-entry--${"collection"===o||"article"===o?o:"other"}${r?"":" cal-entry--text"}`);if(r){const t=ke("div","cal-entry__media cal-media");t.append(r),i.append(t)}const s=ke("div","cal-entry__body"),a=function(t,e){const{fields:n}=t;switch(Re(t)){case"collection":{const t=n["shopify-productsCount"];return"number"==typeof t&&t>0?_n(t,"product","products"):""}case"article":return[On(n["shopify-publishedAt"],e.settings.language),$e(n["shopify-author"])].filter(t=>""!==t).join(" · ");default:return""}}(t,e);""!==a&&s.append(ke("p","cal-entry__meta",a));const c=$e(t.fields.title,t.fields["shopify-handle"].replaceAll("-"," ")),d=ke("h3","cal-entry__title"),l=e.url(t);if(""===l)d.textContent=c;else{const t=ke("a","cal-entry__link",c);t.href=l,d.append(t)}s.append(d);const u=$e(t.fields.descriptionText);return""===u||"collection"===o&&r||s.append(ke("p","cal-entry__text",u)),i.append(s),i}function In(t,e,n){const o=ke("ul",`cal-entries cal-entries--${n}`);o.setAttribute("role","list");const r=4===n?"(min-width: 990px) 25vw, (min-width: 750px) 33vw, 50vw":"(min-width: 750px) 33vw, 100vw";for(const n of t){const t=ke("li","cal-entries__item");t.append($n(n,e,r)),o.append(t)}return o}const Nn=new WeakMap;function Ln(t,e){const n=JSON.stringify(vn(t.data),(t,e)=>{const n=Ee(e)&&Ee(e.fields)?e.fields["shopify-handle"]:void 0;return"string"==typeof n?n:e});return`${e.chapter.isFirst?1:0}|${e.chapter.question}|${n}`}function Mn(t,e){return{type:t,render(t,n){const o=e(vn(t.data),n,t);return o&&Nn.set(o,Ln(t,n)),o},update:(t,e,n)=>Nn.get(t)===Ln(e,n)}}function Bn(t){const{classes:e}=t;function n(t,e="section"){return ke(e,`cal-section cal-${t}`)}function o(...t){const n=ke("div",`${e.pageWidth} cal-section__inner`);return n.append(...t.filter(t=>void 0!==t)),n}function r(t){return ke("p","cal-eyebrow",t)}function i(t,e,n){const o=ke("div","cal-head"),r=ke("h2","cal-title",e);return r.id=kn("title"),t.setAttribute("aria-labelledby",r.id),o.append(r),void 0!==n&&o.append(ke("p","cal-head__meta",n)),o}function s(t,n,o=""){const r=ke("button",`${e.buttonSecondary} cal-chip ${o}`.trim());return r.type="button",r.dataset.callimacusAsk=n,n!==t&&(r.title=n),r.append(ke("span","cal-chip__label",t),Sn()),r}function a(t){const e=ke("ul","cal-chips");e.setAttribute("role","list");for(const n of t){const t=ke("li");t.append(s(n.label,n.question)),e.append(t)}return e}function c(t,e,n){const o=ke("a",n);o.href=e.url(t);const r=$e(t.fields.title);return o.append(ke("span","",""===r?"Shop now":`Shop ${r}`),Sn()),o}function d(t,e){const n=$e(e).replace(/^Show me .+? — /u,"");if(""===n)return`Show me ${t}`;return`Show me ${t} — ${/^(?:I\b|I'|[A-Z]{2})/u.test(n)?n:n.charAt(0).toLowerCase()+n.slice(1)}`}function l(r,i,s,a=!0){if(""===r&&0===i.length)return;const c=n("note"),d=o();""!==r&&d.append(yn(r,e.rte,a,"cal-prose--note"));const l=i.filter(t=>"product"!==Re(t)),u=[t.cards(i.filter(t=>"product"===Re(t)),s),l.length>0?In(l,s,3):void 0];return d.append(...u.filter(t=>void 0!==t)),c.append(d),c}function u(t,e,n,o){return xn.map(e=>$e(t[e])).find(t=>""!==t)??(e.length>0?"":n.text(o))}function h(t,e){const n=$e(vn(t.data).text,e.text(t));return 0===e.chapter.blocks.filter(e=>e.id!==t.id).length&&!e.chapter.addedToCart||/solomei\.ai/iu.test(n)?{kind:"redirect",text:n}:{kind:""!==n&&e.final?"note":"wait",text:n}}function p(t){const e=n("redirect"),r=ke("p","cal-redirect__text",`I can help with questions about what ${t.settings.storeName} sells.`),i=(t.settings.starters.length>0?t.settings.starters.slice(0,4):Cn).map(t=>({label:t,question:t}));return e.append(o(r,a(i))),e}const f=[(m="custom:storefrontReply",g=(t,e,n)=>$e(t.text,e.text(n)),y=(t,r)=>{const i=n("answer"),s=ke("div","cal-answer__body");return s.append(yn(t,e.rte,r.final,"cal-prose--answer")),i.append(o(s)),i},{type:m,render(t,e){const n=g(vn(t.data),e,t);return""===n?void 0:y(n,e)},update(t,e,n){const o=t instanceof Element?t.querySelector(".cal-prose"):void 0,r=g(vn(e.data),n,e);return!(!o||""===r||(gn(o,r,n.final),0))}}),Mn("custom:editorialHero",(t,i)=>{const s=vn(t.copy),a={eyebrow:$e(s.eyebrow),headline:$e(s.headline),dek:$e(s.dek)},d=i.hits(t.lead).at(0),{isFirst:l}=i.chapter,u=d?Tn(i,d,{index:En(d),widths:l?[750,1100,1500,1800,2400]:[200,320,480],sizes:l?"100vw":"(min-width: 750px) 160px, 96px",eager:l}):void 0;if(u||""!==a.eyebrow||""!==a.headline||""!==a.dek)return l?function(t,o,i,s){const a=n("hero");a.classList.add("cal-hero--lead");const d=ke("div","cal-hero__banner "+(i?"cal-hero__banner--image":"cal-hero__banner--text"));if(i){const t=ke("div","cal-hero__media cal-media");t.append(i),d.append(t)}if(""!==t.eyebrow||""!==t.headline||""!==t.dek){const n=ke("div",`cal-hero__content ${e.pageWidth}`),i=ke("div","cal-hero__box");if(""!==t.eyebrow&&i.append(r(t.eyebrow)),""!==t.headline&&i.append(ke("h2","cal-display cal-hero__headline",t.headline)),""!==t.dek&&i.append(ke("p","cal-hero__dek",t.dek)),o){const t=ke("div","cal-hero__buttons");t.append(c(o,s,`${e.buttonPrimary} cal-hero__cta`)),i.append(t)}n.append(i),d.append(n)}return a.append(d),a}(a,d,u,i):function(t,i,s,a){const d=n("hero");d.classList.add("cal-hero--compact");const l=ke("div","cal-hero__row");if(s&&i){const t=ke("a","cal-hero__thumb cal-media");t.href=a.url(i),t.tabIndex=-1,t.setAttribute("aria-hidden","true"),t.append(s),l.append(t)}const u=ke("div","cal-hero__text");return""!==t.eyebrow&&u.append(r(t.eyebrow)),""!==t.headline&&u.append(ke("h2","cal-title cal-hero__headline",t.headline)),""!==t.dek&&u.append(ke("p","cal-hero__dek",t.dek)),i&&u.append(c(i,a,`${e.link} cal-link`)),l.append(u),d.append(o(l)),d}(a,d,u,i)}),Mn("custom:storefrontPicks",(e,r,s)=>{const a=r.hits(e.picks);return function(e,r,s){if(0===r.length)return;const a=n("picks"),c=i(a,e,_n(r.length,"product","products"));return a.append(o(c,t.cards(r,s))),a}("Picked for you",a.length>0?a:r.picks(s),r)}),Mn("custom:pageAnswer",(t,i)=>{const s=bn(t.pages).filter(t=>Be(t)).map(t=>({title:$e(t.meta?.title,t.name),kind:t.meta?.shopifyKind,text:je(t),url:i.url(t)})).filter(t=>""!==t.title&&t.text.length>0&&""!==t.url).slice(0,2);if(0===s.length)return;const a=n("pages"),c=ke("div","cal-pages__list");return c.append(...s.map(t=>function(t,n){const o=ke("article","cal-page"),i=ke("h2","cal-subtitle cal-page__title",t.title);i.id=kn("title"),o.setAttribute("aria-labelledby",i.id);const s=ke("a",`${e.link} cal-link cal-page__link`);return s.href=t.url,s.append(ke("span","","Read the full "+("policy"===t.kind?"policy":"page")),ke("span",e.visuallyHidden,`: ${t.title}`),Sn()),o.append(r("policy"===t.kind?"Store policy":`From ${n.settings.storeName}`),i,yn(t.text.join("\n\n"),e.rte,!0,"cal-page__text"),s),o}(t,i))),a.append(o(c)),a}),Mn("custom:collectionGrid",(t,e)=>{const r=e.hits(t.collections).filter(t=>"collection"===Re(t)&&0!==t.fields["shopify-productsCount"]);if(0===r.length)return;const s=n("collections"),a=i(s,"Shop by collection",_n(r.length,"collection","collections"));return s.append(o(a,In(r,e,4))),s}),Mn("custom:storyCards",(t,e)=>{const r=e.hits(t.stories).filter(t=>"article"===Re(t));if(0===r.length)return;const s=n("stories"),a=i(s,"From the journal",_n(r.length,"story","stories"));return s.append(o(a,In(r,e,3))),s}),Mn("custom:problemGuide",(t,r)=>{const a=vn(t.guide),c=bn(a.steps).map(t=>vn(t)).map(t=>({title:$e(t.title),body:$e(t.body),shopFor:$e(t.shopFor)})).filter(t=>""!==t.title||""!==t.body);if(0===c.length)return;const l=n("guide"),u=ke("ol",`cal-steps cal-steps--${Math.min(c.length,4)}`);u.setAttribute("role","list");for(const[t,n]of c.entries()){const o=ke("li","cal-step"),i=ke("div","cal-step__card"),a=ke("span","cal-step__index",String(t+1).padStart(2,"0"));a.setAttribute("aria-hidden","true");const c=ke("div","cal-step__info");""!==n.title&&c.append(ke("h3","cal-step__title",n.title)),""!==n.body&&c.append(yn(n.body,e.rte,!0,"cal-step__body")),""!==n.shopFor&&c.append(s(`Shop ${n.shopFor}`,d(n.shopFor,r.chapter.question),"cal-chip--compact cal-step__shop")),i.append(a,c),o.append(i),u.append(o)}const h=i(l,$e(a.title,"Step by step"),_n(c.length,"step","steps"));return l.append(o(h,u)),l}),Mn("custom:materialStory",(i,s)=>{const a=vn(i.story),c=$e(a.material),d=$e(a.headline),l=$e(a.body),u=bn(a.facts).map(t=>$e(t)).filter(t=>""!==t),h=s.hits(i.products).slice(0,3);if(""===d&&""===l&&0===u.length&&0===h.length)return;const p=n("material"),f=h.at(0),m=f?Tn(s,f,{index:En(f),widths:[535,750,1070,1500],sizes:"(min-width: 1600px) 750px, (min-width: 750px) calc((100vw - 130px) / 2), calc(100vw - 30px)"}):void 0;if(""!==d||""!==l||""!==c||u.length>0){const t=ke("div","cal-material__feature"+(m?"":" cal-material__feature--text"));if(m){const e=ke("div","cal-material__media cal-media");e.append(m),t.append(e)}const n=ke("div","cal-material__content");if(""!==c&&n.append(r(c)),""!==d){const t=ke("h2","cal-title cal-material__heading",d);t.id=kn("title"),p.setAttribute("aria-labelledby",t.id),n.append(t)}if(""!==l&&n.append(yn(l,e.rte,!0,"cal-material__body")),u.length>0){const t=ke("ul","cal-facts");t.setAttribute("role","list");for(const e of u)t.append(ke("li","cal-facts__item",e));n.append(t)}t.append(n),p.append(o(t))}if(h.length>0){const e=ke("div","cal-material__products");e.append(ke("h3","cal-subtitle",""===c?"Shop the story":`Made with ${c}`));const n=t.cards(h,s,{columns:3});n&&e.append(n),p.append(o(e))}return p}),Mn("custom:sizeCare",t=>{const i=bn(t.faq).map(t=>vn(t)).map(t=>({question:$e(t.question),answer:$e(t.answer)})).filter(t=>""!==t.question&&""!==t.answer);if(0===i.length)return;const s=n("faq"),a=ke("div","cal-faq__layout"),c=ke("div","cal-faq__header"),d=ke("h2","cal-title","Good to know");d.id=kn("title"),s.setAttribute("aria-labelledby",d.id),c.append(r("Sizes and care"),d);const l=ke("div","cal-faq__list");for(const[t,n]of i.entries()){const o=kn("faq"),r=ke("div","cal-faq__item"),i=ke("details");i.open=0===t;const s=ke("summary","cal-faq__summary");s.id=`${o}-summary`,s.append(ke("h3","cal-faq__question",n.question),An());const a=ke("div","cal-faq__answer");a.id=`${o}-content`,a.setAttribute("role","region"),a.setAttribute("aria-labelledby",s.id),a.append(yn(n.answer,e.rte)),i.append(s,a),r.append(i),l.append(r)}return a.append(c,l),s.append(o(a)),s}),Mn("custom:compareSet",(i,s)=>{const a=vn(i.pair),c=vn(i.verdict),d=s.hits(i.first).at(0),l=s.hits(i.second).at(0),u=bn(c.rows).map(t=>vn(t)).map(t=>({aspect:$e(t.aspect),first:$e(t.first),second:$e(t.second)})).filter(t=>""!==t.aspect),h=$e(c.summary);if(!d&&!l&&""===h&&0===u.length)return;const p=$e(d?.fields.title,a.first,"The first"),f=$e(l?.fields.title,a.second,"The second"),m=n("compare");d||l||m.classList.add("cal-compare--text");const g=ke("div","cal-compare__layout"),y=ke("div","cal-compare__intro"),b=ke("h2","cal-title",`${p} or ${f}?`);b.id=kn("title"),m.setAttribute("aria-labelledby",b.id),y.append(r("Side by side"),b),""!==h&&y.append(yn(h,e.rte,!0,"cal-compare__summary")),g.append(y);for(const[e,n]of[d,l].entries()){const o=ke("div","cal-compare__card cal-compare__card--"+(0===e?"first":"second")),r=n?t.card(n,s,{position:e}):void 0;r&&o.append(r),g.append(o)}return u.length>0&&g.append(function(t,n,o){const r=ke("div","cal-compare__table");r.setAttribute("role","table"),r.setAttribute("aria-label",`${t} compared with ${n}`);const i=ke("div","cal-compare__row cal-compare__row--head");i.setAttribute("role","row");const s=ke("span","cal-compare__aspect");s.setAttribute("role","columnheader"),s.append(ke("span",e.visuallyHidden,"Aspect")),i.append(s);for(const e of[t,n]){const t=ke("span","cal-compare__value",e);t.setAttribute("role","columnheader"),i.append(t)}r.append(i);for(const t of o){const e=ke("div","cal-compare__row");e.setAttribute("role","row");const n=ke("span","cal-compare__aspect",t.aspect);n.setAttribute("role","rowheader"),e.append(n);for(const n of[t.first,t.second]){const t=ke("span","cal-compare__value",n);t.setAttribute("role","cell"),e.append(t)}r.append(e)}return r}(p,f,u)),m.append(o(g)),m}),Mn("custom:completeSet",(e,r)=>{const s=bn(e.companions).map(t=>vn(t)).map(t=>({why:$e(t.why),hit:r.hits(t.product).at(0)})).filter(t=>void 0!==t.hit).slice(0,3);if(0===s.length)return;const a=n("set"),c=ke("div",`cal-set__collage cal-set__collage--${s.length}`);for(const[e,n]of s.entries()){const o=ke("div","cal-set__item cal-set__item--"+(0===e?"lead":"side")),i=ke("figure","cal-set__piece"),s=t.card(n.hit,r,0===e?{sizes:"(min-width: 1600px) 780px, (min-width: 750px) calc((100vw - 130px) / 2), calc(100vw - 30px)",position:e}:{position:e});s&&i.append(s),""!==n.why&&i.append(ke("figcaption","cal-set__why",n.why)),o.append(i),c.append(o)}return a.append(o(i(a,"Complete the set"),c)),a}),Mn("custom:followUps",t=>{const e=bn(t.next).map(t=>vn(t)).map(t=>({label:$e(t.label,t.question),question:$e(t.question,t.label)})).filter(t=>""!==t.question);if(0===e.length)return;const r=n("next","nav"),i=ke("h2","cal-eyebrow cal-next__title","Keep exploring");return i.id=kn("title"),r.setAttribute("aria-labelledby",i.id),r.append(o(i,a(e))),r}),Mn("custom:addToCartResult",(t,r,i)=>{const s=function(t){if(!Ft(t.data)||!Ft(t.data.addToCart))return;const e=t.data.addToCart;return"error"===e.status?{status:"error"}:"resolved"===e.status&&Dt(e.variantId)&&Dt(e.productName)&&Dt(e.size)?{status:"resolved",variantId:e.variantId,productName:e.productName,size:e.size}:"size_selection_needed"===e.status&&Dt(e.productSku)&&Dt(e.productName)&&Array.isArray(e.availableSizes)&&e.availableSizes.every(Pt)?{status:"size_selection_needed",productSku:e.productSku,productName:e.productName,availableSizes:e.availableSizes}:void 0}(i);if("size_selection_needed"!==s?.status||0===s.availableSizes.length)return;const a=n("choice"),c=ke("h2","cal-eyebrow cal-choice__title",s.productName);c.id=kn("title"),a.setAttribute("aria-labelledby",c.id);const d=ke("div","cal-choice__options");d.setAttribute("role","group"),d.setAttribute("aria-labelledby",c.id);const l=ke("div","cal-choice__status"),u={isOn:!1};for(const t of s.availableSizes){const n=ke("button",`${e.buttonSecondary} cal-choice__option`);n.type="button",n.append(ke("span","cal-choice__label",t.size));const o=async()=>{if(u.isOn)return;u.isOn=!0,n.setAttribute("aria-disabled","true");const e=await en(async()=>r.addToCart(t.variantId,1,{productId:s.productSku,origin:"request"})),o={id:s.productSku,name:s.productName,options:[{name:"option",value:t.size}]},i=pe({id:r.chapter.id??"",item:o,quantity:1},e);n.dataset.outcome=i.outcome,l.replaceChildren(Se(i)),n.removeAttribute("aria-disabled"),u.isOn=!1};t.orderable?n.addEventListener("click",()=>{o()}):(n.disabled=!0,n.append(ke("span","cal-choice__sold-out","Sold out"))),d.append(n)}return a.append(o(c,d,l)),a}),{type:"*",render(t,e){const n=e.picks(t);return l(u(vn(t.data),n,e,t),n,e,e.final)},update(t,e,n){const o=t instanceof Element?t.querySelector(".cal-prose"):void 0,r=n.picks(e),i=u(vn(e.data),r,n,e);return!(!o||""===i||r.length>0)&&(gn(o,i,n.final),!0)}}];var m,g,y;for(const t of["demosthenesResponse","custom:demosthenesResponse"])f.push({type:t,render(t,e){const n=h(t,e);return"redirect"===n.kind?p(e):"wait"===n.kind?void 0:l(n.text,[],e)},update(t,e,n){const o=h(e,n);if("redirect"===o.kind)return t instanceof Element&&t.classList.contains("cal-redirect");const r=t instanceof Element?t.querySelector(".cal-prose"):void 0;return!(!r||"note"!==o.kind)&&(gn(r,o.text,!0),!0)}});return f}const jn="callimacus.cards",Un=["_pos","_sid","_ss","_psq","_fid"],Fn=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","TD","TH"]);function Dn(t){if(null!==t)try{const e=/\/products\/(?<handle>[^#/?]+)/u.exec(new URL(t,globalThis.location.origin).pathname);return void 0===e?.groups?.handle?void 0:decodeURIComponent(e.groups.handle)}catch{return}}function Pn(t,e){return[...t.querySelectorAll('a[href*="/products/"]')].some(t=>{const n=Dn(t.getAttribute("href"));return void 0!==n&&n!==e})}function Wn(){const t=be("sessionStorage",jn),e={searches:0,sectionId:void 0,borrowed:0,missed:[],styles:0,scripts:[],verdict:"fits"===t||"fails"===t?t:"unknown",why:void 0===t?"":"decided on an earlier page of this tab"},n=new Set;return{stats:e,source:function(t,n){const o=""===t.title?t.handle.replaceAll("-"," "):t.title,r=new URLSearchParams({type:"product",q:o,"options[prefix]":"last"});return void 0!==e.sectionId&&r.set("section_id",e.sectionId),e.searches+=1,`${n}search?${r.toString()}`},extract:function(t,o){const r=document.createElement("template");r.innerHTML=t;const i=function(t,e){const n=[...(t.querySelector("main")??t).querySelectorAll('a[href*="/products/"]')].filter(t=>Dn(t.getAttribute("href"))===e&&!t.closest('cart-drawer, cart-drawer-component, cart-notification, cart-items, [id^="CartDrawer"], [id^="cart-notification"], [class*="cart-drawer"], .cart-item'));for(const t of n){let n=t;for(;n.parentElement&&!n.parentElement.matches('main, body, .shopify-section, ul, ol, [role="list"], form, section, slider-component, .grid, [class*="product-grid"]')&&!Pn(n.parentElement,e)&&!n.parentElement.querySelector("h1");)n=n.parentElement;if("LI"===n.tagName&&1===n.childElementCount&&n.firstElementChild&&(n=n.firstElementChild),!Fn.has(n.tagName)&&!n.closest("table")&&n.querySelector("img, picture, svg")&&(n!==t||""!==n.textContent.trim()))return n}}(r.content,o.handle);if(!i)return void e.missed.push({handle:o.handle,why:"not in the search results"});const s=i.closest('[id^="shopify-section-"]');s&&void 0===e.sectionId&&(e.sectionId=s.id.slice(16),ge.info(`borrowing cards from the search section ${e.sectionId}`)),s&&function(t){for(const o of t.querySelectorAll("style")){const t=o.textContent;if(n.has(t))continue;n.add(t);const r=document.createElement("style");r.dataset.callimacusBorrowed="",r.textContent=t,document.head.append(r),e.styles+=1}const o=new Set([...document.querySelectorAll('link[rel="stylesheet"], script[src]')].map(t=>(t.getAttribute("href")??t.getAttribute("src")??"").split("?",1)[0]));for(const r of t.querySelectorAll('link[rel="stylesheet"]')){const t=r.getAttribute("href")??"",i=t.split("?",1)[0]??t;""===t||o.has(i)||n.has(i)||(n.add(i),document.head.append(r.cloneNode(!0)),e.styles+=1)}for(const r of t.querySelectorAll("script[src]")){const t=r.getAttribute("src")??"",i=t.split("?",1)[0]??t;if(""===t||o.has(i)||n.has(i))continue;n.add(i);const s=document.createElement("script");s.src=t,s.defer=!0,document.head.append(s),e.scripts.push(i.split("/").pop()??i)}}(s);const a=document.createElement("template");return a.content.append(i),e.borrowed+=1,a},prepare:function(t){!function(t){for(const e of t.querySelectorAll("a[href]")){const t=e.getAttribute("href")??"";try{const n=new URL(t,globalThis.location.origin);if(Un.some(t=>n.searchParams.has(t))){for(const t of Un)n.searchParams.delete(t);const o=n.origin===globalThis.location.origin&&!/^https?:/iu.test(t);e.setAttribute("href",o?`${n.pathname}${n.search}${n.hash}`:n.href)}}catch{}}}(t);for(const e of t.querySelectorAll('dialog, [role="dialog"], quick-add-modal, [class*="modal"][id]')){const t=""===e.id?void 0:document.querySelector(`#${CSS.escape(e.id)}`);t&&t!==e?e.remove():t||document.body.append(e)}},check:function(t){if("unknown"!==e.verdict)return e.verdict;const n=function(t){const e=t.getBoundingClientRect();if(e.width<40||e.height<40)return;const n=t.querySelector("img, picture, svg"),o=n?.getBoundingClientRect();if(!n||!o||0===o.height)return;const r=[...t.querySelectorAll('a[href*="/products/"], h2, h3, h4, p, [class*="title"], [class*="price"]')].filter(t=>!t.contains(n)&&!n.contains(t)&&""!==t.textContent.trim()).map(t=>t.getBoundingClientRect()).find(t=>t.height>=8&&t.width>=8&&!(t.top<=o.top&&t.bottom>=o.bottom));return r?e.height<e.width?{fits:!1,why:`the card is wider than it is tall (${Math.round(e.width)} by ${Math.round(e.height)} px): a list row`}:o.bottom>r.top+4?{fits:!1,why:"the card's text sits beside its picture, not under it"}:{fits:!0,why:"a picture above its text, taller than wide"}:{fits:!1,why:"the card has no text beside its picture"}}(t);return n&&(e.verdict=n.fits?"fits":"fails",e.why=n.why,ve("sessionStorage",jn,e.verdict),ge.info(`the theme's cards ${n.fits?"fit":"do not fit"}: ${n.why}`)),e.verdict}}}const zn=[240,360,480,640,840,1080],Vn={add:"Add to cart",added:"Added",choose:"Choose options",soldOut:"Sold out",failed:"Could not add. Try again"},Hn=Object.freeze({pageWidth:"cal-page-width",buttonPrimary:"cal-button",buttonSecondary:"cal-button cal-button--secondary",link:"cal-link",rte:"cal-rte",visuallyHidden:"cal-visually-hidden",grid:t=>`cal-egrid cal-egrid--${t}`,gridItem:"cal-egrid__item"});function Kn(){const t=document.querySelector("cart-notification, cart-drawer");return"function"==typeof t?.getSectionsToRender?"dawn":document.querySelector("cart-items-component, cart-drawer-component, cart-icon")?"horizon":"plain"}function Jn(t){return[...t.querySelectorAll('a[href$="/cart"], a[href*="/cart?"], a[href$="/cart/"]')].filter(t=>!Ne(t))}let Yn;async function Gn(t,e,n,o){const{json:r,failure:i}=await nn(n,{headers:{"content-type":"application/json",accept:"application/json","x-requested-with":"XMLHttpRequest"},body:JSON.stringify({items:[{id:Number(t),quantity:e}]})});if(i)throw i;const s=Array.isArray(r.items)&&Ee(r.items[0])?r.items[0]:{};!function(t,e){document.querySelector(".cal-toast")?.remove(),clearTimeout(Yn);const n=ke("div","cal-toast");n.setAttribute("role","status"),n.dataset.callimacusUi="",n.append(ke("p","cal-toast__text",""===t?"Added to your cart":`Added to your cart: ${t}`));const o=ke("a","cal-button cal-toast__action","View cart");o.href=`${Ve({settings:e})}cart`,n.append(o),document.body.append(n),Yn=setTimeout(()=>{n.remove()},5e3)}($e(s.product_title,s.title),n),document.dispatchEvent(new CustomEvent("cart:refresh",{bubbles:!0,detail:r}));const a=await async function(){const t=Jn(document),e=t.at(0);if(void 0===e)return!1;const n=e.closest('[id^="shopify-section-"]')?.id.slice(16)??"";let o="";try{if(""!==n){const t=new URL(globalThis.location.href);t.search=`sections=${encodeURIComponent(n)}`;const e=await fetch(t,{headers:{accept:"application/json"}}),r=await e.json();o=Ee(r)&&"string"==typeof r[n]?r[n]:""}if(""===o){const t=await fetch(globalThis.location.href,{headers:{accept:"text/html"}});o=await t.text()}}catch(t){return ge.warn("could not redraw the cart icon",t),!1}const r=Jn((new DOMParser).parseFromString(o,"text/html"));let i=0;for(const[e,n]of t.entries()){const t=(""===n.id?void 0:r.find(t=>t.id===n.id))??r.at(e);void 0!==t&&t.innerHTML!==n.innerHTML&&(n.innerHTML=t.innerHTML,i+=1)}return i>0}();return o.cart[a?"iconRedrawn":"iconMissed"]+=1,{...s,handle:$e(s.handle)}}function Xn(t,e){const n=ke("div","cal-ecard"),o=ke("div","cal-ecard__media"),r=ke("div","cal-ecard__info"),i=ke("a","cal-ecard__title",t);return i.href=e,r.append(i),n.append(o,r),{root:n,info:r,title:i,media:o}}function Zn(t,e){const n=ke("div","cal-ecard__quick-add cal-card__quick-add");return n.append(Je(t,e,{className:"cal-button cal-button--secondary cal-ecard__add",labels:Vn})),n}function Qn(t,e,n={}){const{hit:o}=t,r=e.url(o),i=Xn(t.title,r),s=Tn(e,o,{widths:zn,sizes:n.sizes??"(min-width: 990px) calc((100vw - 160px) / 4), (min-width: 750px) calc((100vw - 120px) / 3), calc((100vw - 40px) / 2)"});if(s){const t=ke("a","cal-ecard__image");t.href=r,t.tabIndex=-1,t.setAttribute("aria-hidden","true"),t.append(s),i.media.append(t)}return i.info.append(ke("p","cal-ecard__price"+(ze(o)?" cal-ecard__price--sold-out":""),function(t,e){const{fields:n}=t,o=Ee(n.priceRange)?n.priceRange:{},r=Number(o.min),i=Number(o.max);if(Number.isFinite(r)&&Number.isFinite(i)&&r<i){const t=$e(o.currency,"object"==typeof n.price?n.price.currency:"");return`From ${e.money(""===t?r:{amount:r,currency:t})}`}return void 0===n.price?"":e.money(n.price)}(o,e))),!1===n.quickAdd||ze(o)||i.info.append(Zn(t,e)),i.root}function to(t,e){const n=Xn("",`${Ve(e)}products/${encodeURIComponent(t.handle)}`);return n.root.classList.add("cal-card__skeleton"),n.title.append(ke("span","cal-card__line")),n.title.setAttribute("aria-label",""===t.title?"Loading product":t.title),n.root}function eo(t,e){t.classList.remove("cal-card__skeleton");const n=t.querySelector(":scope .cal-ecard__title");n&&(n.removeAttribute("aria-label"),n.textContent=""===e.title?e.handle.replaceAll("-"," "):e.title)}function no(t,e,n,o){t.addEventListener("click",r=>{const i=r.target instanceof Element?r.target.closest("a[href]"):void 0;i&&t.contains(i)&&n.productClicked?.(Ke(e),o)})}function oo(){const t=new Map;async function e(e,n){let o=t.get(e);return o||(o=fetch(`${Ve(n)}products/${encodeURIComponent(e)}.js`,{headers:{accept:"application/json"}}).then(async t=>t.ok?t.json():void 0).then(t=>Ee(t)?function(t){const e=$e(t.handle);if(""===e)return;const n=Array.isArray(t.variants)?t.variants.filter(t=>Ee(t)):[],o=Array.isArray(t.images)?t.images.filter(t=>"string"==typeof t):[],r=t=>Number(t)/100;return{fields:{"shopify-handle":e,title:$e(t.title),price:r(t.price),priceRange:{min:r(t.price_min),max:r(t.price_max)},images:o.map(t=>({url:t.startsWith("//")?`https:${t}`:t})),variantTree:{variants:n.map(t=>({id:t.id,orderable:!0===t.available,online:!0}))}}}}(t):void 0).catch(()=>{}),t.set(e,o)),o}function n({host:t,ref:n,ctx:o,options:r}){if(n.hit){const i=Qn({...n,hit:n.hit},o,r);return t.replaceChildren(i),void(0===(n.hit.fields.images??[]).length&&e(n.handle,o).then(t=>{if(!t||!i.isConnected)return;const e={...t,fields:{...t.fields,...n.hit?.fields,images:t.fields.images}};i.replaceWith(Qn({...n,hit:e},o,r))}))}const i=to(n,o);t.replaceChildren(i),t.classList.add("cal-card--pending"),e(n.handle,o).then(e=>{t.classList.remove("cal-card--pending"),e?i.replaceWith(Qn({handle:n.handle,hit:e,title:$e(n.title,e.fields.title)},o,r)):eo(i,n)})}return{card:function(t,e,o={}){const r=Ye(t);if(!r)return;const i=ke("div","cal-card");return i.dataset.handle=r.handle,n({host:i,ref:r,ctx:e,options:o}),i},draw:n}}function ro(t){const e=oo(),n=Wn(),o={cart:{kind:void 0,adds:0,iconRedrawn:0,iconMissed:0},addedButtons:0,borrow:n.stats},r=new Set,i=Ge(n.source,{extract:n.extract,prepare:n.prepare,placeholder:Qn,skeleton:to,offline:eo});let s=!1;const a=t=>!t.classList.contains("cal-card--pending")&&null!==t.firstElementChild&&!t.firstElementChild.classList.contains("cal-ecard");function c(t){const i=t.host.firstElementChild;if(null===i||!a(t.host))return;if("fails"===n.check(i))return void function(){for(const t of r)t.host.isConnected?a(t.host)&&(e.draw(t),r.delete(t)):r.delete(t)}();if(function({host:t,ref:e,ctx:n,options:r}){const i=t.firstElementChild;null!==i?.querySelector('button[name="add"], form[action*="/cart/add"], modal-opener, [data-quick-add], quick-add-component, .quick-add, product-form-component')||null!==t.querySelector(":scope > .cal-ecard__quick-add")||null===i||!1===r.quickAdd||!e.hit||ze(e.hit)||(t.append(Zn({...e,hit:e.hit},n)),o.addedButtons+=1)}(t),"unknown"!==n.stats.verdict)return;const s=()=>{c(t)};if(i.querySelector("img")?.addEventListener("load",s,{once:!0}),"function"!=typeof IntersectionObserver)return;const d=new IntersectionObserver(t=>{t.every(t=>!t.isIntersecting)||(d.disconnect(),s())});d.observe(t.host)}function d(o,d,l={}){const u=Ye(o);if("auto"!==t||"fails"===n.stats.verdict){const t=e.card(o,d,l);return t&&u&&no(t,u,d,l.position),t}!function(){if(s)return;s=!0;const t=Ze();t&&"function"==typeof Xe.subscribe&&Xe.subscribe(t.cartUpdate,t=>{const e=Ee(t)?t:{};"product-form"===e.source&&i.rememberAdded(e.productVariantId)}),document.addEventListener(rn,t=>{const{detail:e}=t,n=Ee(e)&&Ee(e.data)?e.data:{};if(!Ee(e)||"product-form-component"!==n.source||!0===n.didError)return;const o=Number(n.itemCount);i.rememberAdded(e.sourceId,Number.isSafeInteger(o)&&o>0?o:1)})}();const h=i.card(o,d,l);if(!h||!u)return h;no(h,u,d,l.position);const p={host:h,ref:u,ctx:d,options:l};if(r.add(p),a(h))queueMicrotask(()=>{c(p)});else{const t=new MutationObserver(()=>{h.classList.contains("cal-card--pending")||(t.disconnect(),c(p))});t.observe(h,{childList:!0,attributes:!0,attributeFilter:["class"]})}return h}return Object.freeze({classes:Hn,card:d,cards:(t,e,n={})=>function(t,e){if(0===t.length)return;const n=[2,3,4,5].includes(e.columns??4)?e.columns??4:4,o=ke("ul",`${Hn.grid(n)} cal-grid`);o.setAttribute("role","list");for(const e of t){const t=ke("li",Hn.gridItem);t.append(e),o.append(t)}return o}(function(t,e){return(Array.isArray(t)?t:[]).map((t,n)=>e(t,n)).filter(t=>void 0!==t)}(t,(t,o)=>d(t,e,{...n,position:o})),n),addToCart:async function(t,e,n){const r=Kn();let i;return o.cart.kind=r,i="dawn"===r?await async function(t,e,n){const o=document.querySelector("cart-notification")??document.querySelector("cart-drawer")??void 0,r=new FormData;r.append("id",t),r.append("quantity",String(e)),"function"==typeof o?.getSectionsToRender&&(r.append("sections",o.getSectionsToRender().map(t=>t.id).join(",")),r.append("sections_url",globalThis.location.pathname),o.setActiveElement?.(document.activeElement));const{json:i,failure:s}=await nn(n,{headers:Qe,body:r}),a=Ze();if(s)throw a&&"function"==typeof Xe.publish&&Xe.publish(a.cartError,{source:"callimacus",productVariantId:t,errors:i.description,message:i.message}),s;if(a&&"function"==typeof Xe.publish&&Xe.publish(a.cartUpdate,{source:"callimacus",productVariantId:t}),"function"==typeof o?.renderContents&&void 0!==i.sections)try{return o.renderContents(i),o.classList.remove("is-empty"),i}catch(t){ge.error("the cart could not redraw itself after adding",t)}return document.dispatchEvent(new CustomEvent("cart:refresh",{bubbles:!0,detail:i})),i}(t,e,n):"horizon"===r?await an(t,e,n):await Gn(t,e,n,o),o.cart.adds+=1,i},install(){"dawn"===Kn()&&"function"!=typeof Xe.getCurrentSellingPlanId&&(Xe.getCurrentSellingPlanId=()=>"")},stats:o})}const io=["header details-modal summary",'header [class*="search"] summary','header a[href$="/search"]','header a[href*="/search?"]','header button[aria-label*="earch" i]','header summary[aria-label*="earch" i]','header [class*="search-toggle"]',"header search-button button",'header [class*="search"] button','[class*="header"] a[href$="/search"]','[class*="header"] [class*="search-toggle"]','[class*="header"] button[aria-label*="earch" i]'],so=['header a[href$="/cart"]','[class*="header"] a[href$="/cart"]'],ao=/search|js-|drawer|modal|toggle|open|trigger|active/iu,co="http://www.w3.org/2000/svg";function lo(t){const e=t.getBoundingClientRect();return e.width>0&&e.height>0}function uo(t){for(const e of t){const t=[...document.querySelectorAll(e)].find(t=>lo(t)&&!t.closest("[data-callimacus-ui]"));if(t)return{node:t,selector:e}}}function ho(t){const e=uo(io)??uo(so);if(!e)return{placed:!1,how:"no search or cart control found in the header"};const n=e.node,o=ke("button","cal-header-ask");o.type="button",o.dataset.callimacusOpen="",o.dataset.callimacusUi="",o.setAttribute("aria-label",t);for(const t of n.classList)ao.test(t)||o.classList.add(t);const r=Math.round(n.querySelector("svg")?.getBoundingClientRect().width??0);return o.append(function(t){const e=document.createElementNS(co,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("width",String(t)),e.setAttribute("height",String(t)),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");const n=document.createElementNS(co,"path");return n.setAttribute("d","M12 3.5l1.6 4.4 4.4 1.6-4.4 1.6L12 15.5l-1.6-4.4L6 9.5l4.4-1.6zM18.5 14l.8 2.2 2.2.8-2.2.8-.8 2.2-.8-2.2-2.2-.8 2.2-.8z"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.4"),n.setAttribute("stroke-linejoin","round"),e.append(n),e}(r>0?r:20)),function(t){let e=t.closest("details-modal, details")??t;for(e.parentElement?.matches("details-modal")&&(e=e.parentElement);1===e.parentElement?.childElementCount&&!e.parentElement.matches('header, nav, [class*="icons"], [class*="actions"]');)e=e.parentElement;return e}(n).before(o),{placed:!0,how:`before ${e.selector}`}}function po({template:t,searchTerms:e,assistantLabel:n,entrance:o}){const r=ke("div","cal-stage");r.dataset.callimacusUi="";const i=ke("div");if(i.dataset.callimacusStage="",i.dataset.stageKind="index"===t?"home":"search"===t?"search":"page","search"===t&&""!==e){const t=ke("div","cal-stage__intro cal-page-width");t.append(ke("p","cal-stage__lede",`Answering “${e}”`)),r.append(t),i.dataset.askOnLoad=e}if("index"===t&&o&&r.append(function(t,e){const n=ke("div","cal-stage__intro cal-entrance cal-page-width");""!==t.heading&&n.append(ke("h2","cal-stage__heading",t.heading)),""!==t.subheading&&n.append(ke("p","cal-stage__lede",t.subheading));const o=ke("form","cal-entrance__form");o.dataset.callimacusForm="";const r=ke("input","cal-entrance__input");r.type="text",r.name="q",r.maxLength=200,r.autocomplete="off",r.enterKeyHint="send",r.placeholder=""===t.placeholder?`${e} anything`:t.placeholder,r.setAttribute("aria-label",e);const i=ke("button","cal-button",""===t.buttonLabel?"Ask":t.buttonLabel);i.type="submit",o.append(r,i);const s=ke("p","cal-entrance__ai-notice",Ot);s.id="cal-entrance-ai-notice",s.dataset.version=It;const a=ke("a","",qt);if(a.href=$t,a.target="_blank",a.rel="noopener noreferrer",s.append(" ",a),r.setAttribute("aria-describedby",s.id),n.append(o,s),t.starters.length>0){const e=ke("div","cal-entrance__starters");for(const n of t.starters){const t=ke("button","cal-chip cal-button cal-button--secondary",n);t.type="button",t.dataset.callimacusAsk=n,e.append(t)}n.append(e)}return n}(o,n)),"index"===t){const t=ke("div","cal-welcome cal-page-width");t.dataset.callimacusWelcome="",t.hidden=!0,i.append(t)}const s=ke("div");s.dataset.callimacusThread="",i.append(s),r.append(i);const a=document.querySelector("#MainContent")??document.querySelector("main")??document.querySelector('[role="main"]')??document.body,c="product"===t?function(t){const e=t.querySelector('form[action*="/cart/add"]'),n=e?.closest('[id^="shopify-section-"]')??void 0;return n&&t.contains(n)?n:void 0}(a):"index"===t?function(t){return t.querySelector(':scope > [id^="shopify-section-"]')??void 0}(a):void 0;return c?(c.after(r),{placed:!0,how:`after ${c.id}`}):(a.prepend(r),{placed:!0,how:`top of ${""===a.id?a.tagName.toLowerCase():`#${a.id}`}`})}const fo="callimacus.rejected";function mo(t){const e=Number(t);return Number.isSafeInteger(e)?e:0}function go({status:t,reason:e}){ve("sessionStorage",fo,JSON.stringify({status:t,...void 0!==e&&{reason:e},until:Date.now()+6e5}))}function yo(){const t=be("sessionStorage",fo);if(void 0===t)return;let e;try{e=JSON.parse(t)}catch{e=void 0}return Ee(e)?"number"==typeof e.until&&e.until<=Date.now()?void we("sessionStorage",fo):{status:mo(e.status),..."string"==typeof e.reason&&{reason:e.reason}}:{status:mo(t)}}const bo="callimacus.session";function vo(t){return"string"==typeof t?t:""}function wo(t){return Ee(t)&&Ee(t.tokens)&&"string"==typeof t.css?{tokens:t.tokens,css:t.css,readAt:vo(t.readAt)}:void 0}function ko(t){if(!Ee(t))return;const e=Array.isArray(t.starters)?t.starters.filter(t=>"string"==typeof t&&""!==t.trim()):[];return{heading:vo(t.heading),subheading:vo(t.subheading),placeholder:vo(t.placeholder),buttonLabel:vo(t.buttonLabel),starters:e}}function So(t,e){if(Ee(t)&&""!==vo(t.token)&&""!==vo(t.endpoint)&&!Number.isNaN(Date.parse(vo(t.expiresAt))))return{token:vo(t.token),endpoint:vo(t.endpoint),expiresAt:vo(t.expiresAt),themeId:e,entrance:ko(t.entrance),look:wo(t.look)}}async function Ao(t){try{const e=await t.json();return Ee(e)&&"string"==typeof e.reason?e.reason:void 0}catch{return}}function _o(t,e){const n=t.endsWith("/")?t.slice(0,-1):t;let o,r;function i(t){return o=t,t&&ve("sessionStorage",bo,JSON.stringify(t)),t}async function s(){return r??=(async()=>{try{const t=await fetch(`${n}/session?theme_id=${encodeURIComponent(e)}`,{headers:{accept:"application/json"}});if([401,403,404].includes(t.status))return go({status:t.status,reason:await Ao(t)}),i(void 0);if(!t.ok)throw new Error(`the storefront session answered ${t.status}`);return i(So(await t.json(),e))}finally{r=void 0}})(),r}async function a(){return o??=await async function(){const t=globalThis.callimacusSession;if(Reflect.deleteProperty(globalThis,"callimacusSession"),t)try{return So(await t,e)}catch(t){return void ge.warn("the loader could not get a storefront session",t)}}()??function(){try{const t=JSON.parse(be("sessionStorage",bo)??"null");return Ee(t)&&t.themeId===e?So(t,e):void 0}catch{return}}(),o}return{current:async function(){if(void 0!==yo())return;const t=await a(),e=function(t){return void 0!==t&&Date.parse(t.expiresAt)-Date.now()>3e5}(t)?t:await s();return e?{token:e.token,endpoint:e.endpoint}:void 0},renew:async function(){const t=await s();return t?{token:t.token,endpoint:t.endpoint}:void 0},known:a,keepLook:function(t){o&&i({...o,look:t})}}}const xo={fg:{property:"--cal-fg",kind:"color"},bg:{property:"--cal-bg",kind:"color"},bodyFont:{property:"--cal-font-body",kind:"font"},bodyWeight:{property:"--cal-font-body-weight",kind:"keyword"},bodyStyle:{property:"--cal-font-body-style",kind:"keyword"},bodySize:{property:"--cal-body-size",kind:"length"},headingFont:{property:"--cal-font-heading",kind:"font"},headingWeight:{property:"--cal-font-heading-weight",kind:"keyword"},headingStyle:{property:"--cal-font-heading-style",kind:"keyword"},headingCase:{property:"--cal-heading-transform",kind:"keyword"},buttonBg:{property:"--cal-button-bg",kind:"color"},buttonFg:{property:"--cal-button-fg",kind:"color"},buttonBorderColor:{property:"--cal-button-border-color",kind:"color"},buttonBorderWidth:{property:"--cal-button-border-width",kind:"length"},buttonRadius:{property:"--cal-radius-button",kind:"length"},buttonCase:{property:"--cal-button-transform",kind:"keyword"},buttonSpacing:{property:"--cal-button-letter-spacing",kind:"length"},buttonFont:{property:"--cal-font-button",kind:"font"},buttonWeight:{property:"--cal-font-button-weight",kind:"keyword"},secondaryFg:{property:"--cal-button2-fg",kind:"color"},mediaRadius:{property:"--cal-radius-media",kind:"length"},cardRadius:{property:"--cal-radius-card",kind:"length"},pageWidth:{property:"--cal-page-width",kind:"length"}},Co={color:/^(?:#[\da-f]{3,8}|transparent|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([\s\d%+,\-./a-z]{1,80}\))$/iu,font:/^[\p{Letter}\p{Number} "',\-_]{1,200}$/u,length:/^(?:normal|none|-?(?:\d+(?:\.\d*)?|\.\d+)(?:px|rem|em|%|ch|vw)?)$/iu,keyword:/^(?:normal|bold|bolder|lighter|italic|oblique|none|uppercase|lowercase|capitalize|[1-9]\d{0,2}|1000)$/iu};function Eo(t){return Object.entries(t).filter(t=>{return e=t[0],Object.hasOwn(xo,e)&&"string"==typeof t[1];var e}).map(([t,e])=>`${xo[t].property}:${e}`).join(";")}const To=/^#(?<digits>[\da-f]{3,8})$/u,Ro=/^rgba?\((?<channels>[^)]*)\)$/u;function Oo(t){const e=t.trim().toLowerCase(),n=To.exec(e)?.groups?.digits;if(void 0!==n){const t=n.length<=4?[...n].map(t=>t+t).join(""):n;if(6!==t.length&&8!==t.length)return;const e=e=>Number.parseInt(t.slice(e,e+2),16);return[e(0),e(2),e(4),8===t.length?e(6)/255:1]}const o=Ro.exec(e)?.groups?.channels?.split(/[\s,/]+/u).filter(t=>""!==t);if(void 0===o||o.length<3||o.length>4)return;const[r=NaN,i=NaN,s=NaN,a=1]=o.map((t,e)=>function(t,e){const n=Number(t.endsWith("%")?t.slice(0,-1):t);return t.endsWith("%")?3===e?n/100:2.55*n:n}(t,e));return[r,i,s,a].some(t=>Number.isNaN(t))?void 0:[r,i,s,a]}function qo([t,e,n]){const o=t=>{const e=t/255;return e<=.03928?e/12.92:((e+.055)/1.055)**2.4};return.2126*o(t)+.7152*o(e)+.0722*o(n)}function $o(t,e){return(Math.max(qo(t),qo(e))+.05)/(Math.min(qo(t),qo(e))+.05)}function Io(t){const e=void 0===t.bg?void 0:Oo(t.bg),n=void 0===t.buttonBg?void 0:Oo(t.buttonBg),o=void 0!==n&&n[3]>.5?n:e,r=void 0===t.buttonFg?void 0:Oo(t.buttonFg);if(void 0===o||void 0===r)return t;const i=$o(r,o);if(i>=3)return t;let s;for(const e of[t.fg,t.bg]){const t=void 0===e?void 0:Oo(e),n=void 0===t?0:$o(t,o);void 0!==e&&n>(s?.ratio??i)&&(s={value:e,ratio:n})}return void 0===s?t:{...t,buttonFg:s.value}}const No="callimacus-look";let Lo;function Mo(){return Lo?.isConnected||(Lo=document.createElement("div"),Lo.setAttribute("aria-hidden","true"),Lo.style.cssText="position:absolute;left:-9999px;top:0;width:400px;visibility:hidden;pointer-events:none;",document.body.append(Lo)),Lo}function Bo(t,e){const n=document.createElement("span");if(n.style.display="block",n.style[t]=e,""===n.style[t])return"";Mo().append(n);const o=getComputedStyle(n)[t];return n.remove(),o}function jo(t){const e=t.getBoundingClientRect(),n=getComputedStyle(t);return e.width>4&&e.height>4&&"hidden"!==n.visibility&&"none"!==n.display}function Uo(t){return"transparent"===t||/^rgba\((?:[^),]*,){3}\s*0(?:\.0+)?\)$/u.test(t)||/\/\s*0(?:\.0+)?\)$/u.test(t)}function Fo(t,e=()=>!0){for(const n of t)for(const t of document.querySelectorAll(n))if(!Ne(t)&&jo(t)&&e(t))return{node:t,selector:n}}function Do(t){const e=[...t.classList].slice(0,2).map(t=>`.${t}`).join("");return`${t.tagName.toLowerCase()}${e}`}const Po=/\b(?:add to (?:cart|bag|basket)|buy now|add)\b/iu,Wo=['form[action*="/cart/add"] button[type="submit"]','form[action*="/cart/add"] button[name="add"]','form[action*="/cart/add"] input[type="submit"]','form[action*="/cart/add"] button:not([type="button"])'],zo=["main .button:not(.button--secondary):not(.button--tertiary)","main .btn:not(.btn--secondary)",'main a[class*="button"]','main button[class*="button"]',".shopify-section .button",".shopify-section .btn",'main button[type="submit"]'],Vo=[".shopify-payment-button__button--unbranded"],Ho=/secondary|outline|tertiary/iu,Ko=["main .button--secondary","main .btn--secondary",'main [class*="button-secondary"]'],Jo=["main h1","main h2","h1","h2",".h1",".h2"],Yo=['main a[href*="/products/"] img','a[href*="/products/"] img'],Go=[".card","product-card",".product-card",'[class*="product-card"]',".grid-product",".grid-view-item",".product-item"],Xo=["main .page-width",".page-width","main .container","main .wrapper",".page-container .page-width","main .grid__item"],Zo=/banner|hero|slideshow|slider|carousel|video|image-with-text/iu;function Qo(t,e){const n=[];for(let o=t.parentElement;o&&n.length<e;o=o.parentElement)n.push(o);return n}function tr(t){return t.matches('button, a[href], input[type="submit"], input[type="button"]')}function er(t){const e=[];let n=0,o=0;for(const[r,i]of[...t].entries())n+="("===i?1:")"===i?-1:0,","===i&&0===n&&(e.push(t.slice(o,r)),o=r+1);return e.push(t.slice(o)),e}function nr(t){for(const e of["::after","::before"]){const n=er(getComputedStyle(t,e).boxShadow);for(const t of n){const n=/^(?<color>rgba?\([^)]*\))\s+0px\s+0px\s+0px\s+(?<width>[\d.]+)px$/u.exec(t.trim());if(void 0!==n?.groups?.color&&!Uo(n.groups.color))return{width:`${n.groups.width}px`,color:n.groups.color,how:`${e} outline`}}}}function or(t){return e=t.borderTopWidth,Number(e.replace(/px$/u,""))>0&&"none"!==t.borderTopStyle&&!Uo(t.borderTopColor);var e}function rr(t){const e=t.getBoundingClientRect(),n=getComputedStyle(t);return e.width>=60&&e.height>=28&&!t.closest('header, nav, footer, [role="dialog"], dialog')&&(!Uo(n.backgroundColor)||or(n)||void 0!==nr(t))}function ir(t){let e=t.parentElement;for(let t=0;e&&t<8&&!e.matches("main, body");t+=1){if(Zo.test(e.className)||"none"!==getComputedStyle(e).backgroundImage)return!0;e=e.parentElement}return!1}function sr(t,e){return Ho.test(t.className)||getComputedStyle(t).backgroundColor===e}function ar(t,e){const n=t=>e=>tr(e)&&rr(e)&&ir(e)===t,o="product"===t?Fo(Wo,n(!1))??function(){for(const t of document.querySelectorAll('main button, main a[href], main input[type="submit"]')){const e=t instanceof HTMLInputElement?t.value:t.textContent;if(Po.test(e.trim())&&!Ne(t)&&jo(t)&&rr(t))return{node:t,selector:"a button labelled add to cart"}}}():void 0,r=(o&&sr(o.node,e)?Fo([...Vo,...zo],t=>n(!1)(t)&&!sr(t,e)):void 0)??o??Fo(zo,n(!1))??("other"===t?Fo(zo,n(!0)):void 0);return r?{node:r.node,how:`button ${Do(r.node)}`}:void 0}function cr(t,e,n,o){const r=or(e),i=r||!o?void 0:nr(o),s=r||void 0!==i;Uo(e.backgroundColor)?s&&t("buttonBg","transparent",`${n} (outline)`):t("buttonBg",e.backgroundColor,n),t("buttonFg",e.color,n),i?(t("buttonBorderColor",i.color,`${n} ${i.how}`),t("buttonBorderWidth",i.width,`${n} ${i.how}`)):(t("buttonBorderColor",r?e.borderTopColor:e.backgroundColor,n),t("buttonBorderWidth",r?e.borderTopWidth:"0px",n)),t("buttonRadius",e.borderTopLeftRadius,n),t("buttonCase",e.textTransform,n),t("buttonSpacing","normal"===e.letterSpacing?"0px":e.letterSpacing,n),t("buttonFont",e.fontFamily,n),t("buttonWeight",e.fontWeight,n)}const dr=[{name:"Dawn",marker:"--font-body-family",read:{fg:"rgb(var(--color-foreground, var(--color-base-text)))",bg:"rgb(var(--color-background, var(--color-base-background-1)))",bodyFont:"var(--font-body-family)",headingFont:"var(--font-heading-family)",buttonBg:"rgb(var(--color-button, var(--color-base-accent-1)))",buttonFg:"rgb(var(--color-button-text, var(--color-base-solid-button-labels)))",buttonRadius:"var(--buttons-radius)",mediaRadius:"var(--media-radius)",cardRadius:"var(--product-card-corner-radius)",pageWidth:"var(--page-width)"}},{name:"Horizon",marker:"--font-body--family",read:{fg:"var(--color-foreground)",bg:"var(--color-background)",bodyFont:"var(--font-body--family)",headingFont:"var(--font-heading--family)",buttonRadius:"var(--style-border-radius-buttons-primary)"}}];function lr(t,e){const{kind:n}=xo[t];return Bo("color"===n?"color":"length"===n?"pageWidth"===t?"width":"borderTopLeftRadius":"fontFamily",e)}function ur(t){const e={},n=(t,n,o)=>{const r=n.trim();!(""===r||!("buttonBg"===t&&"transparent"===r)&&"color"===xo[t].kind&&Uo(r))&&void 0===e[t]&&function(t,e){return e.length<=200&&Co[t].test(e.trim())}(xo[t].kind,r)&&(e[t]={value:r,how:o})};return function(t,e){const n=getComputedStyle(document.body);t("fg",n.color,"body text");let o=n.backgroundColor;Uo(o)&&(o=getComputedStyle(document.documentElement).backgroundColor),t("bg",Uo(o)?"rgb(255, 255, 255)":o,Uo(o)?"browser default":"page background"),t("bodyFont",n.fontFamily,"body text"),t("bodyWeight",n.fontWeight,"body text"),t("bodyStyle",n.fontStyle,"body text"),t("bodySize",n.fontSize,"body text");const r=Fo(Jo,t=>""!==t.textContent.trim());if(r){const e=getComputedStyle(r.node),n=`heading ${Do(r.node)}`;t("headingFont",e.fontFamily,n),t("headingWeight",e.fontWeight,n),t("headingStyle",e.fontStyle,n),t("headingCase",e.textTransform,n)}const i=ar(e,Uo(o)?"rgb(255, 255, 255)":o);i&&cr(t,getComputedStyle(i.node),i.how,i.node);const s=Fo(Ko,t=>tr(t)&&!ir(t));s&&t("secondaryFg",getComputedStyle(s.node).color,`button ${Do(s.node)}`);const a=Fo(Yo);if(a){const e=[a.node,...Qo(a.node,4)].find(t=>!["0px","0",""].includes(getComputedStyle(t).borderTopLeftRadius));t("mediaRadius",e?getComputedStyle(e).borderTopLeftRadius:"0px",e?`product image ${Do(e)}`:`product image ${Do(a.node)} (square)`)}const c=Fo(Go);c&&t("cardRadius",getComputedStyle(c.node).borderTopLeftRadius,`card ${Do(c.node)}`);const d=Fo(Xo,t=>"none"!==getComputedStyle(t).maxWidth&&t.getBoundingClientRect().width>300);d&&t("pageWidth",getComputedStyle(d.node).maxWidth,`content width ${Do(d.node)}`)}(n,t),function(t){const e=getComputedStyle(document.documentElement),n=dr.find(t=>""!==e.getPropertyValue(t.marker).trim());for(const[e,o]of Object.entries(n?.read??{}))t(e,lr(e,o),`${n?.name??""} variable ${o}`)}(n),"other"===t&&void 0===e.buttonFg&&function(t){const e=document.createElement("a");e.className="button button--primary btn btn--primary",e.href="#",e.textContent="Probe",Mo().append(e);const n=getComputedStyle(e);Uo(n.backgroundColor)||cr(t,n,"probe .button.btn",void 0)}(n),Mo().remove(),e}function hr(t){return Object.fromEntries(Object.entries(t).map(([t,e])=>[t,e.value]))}function pr(t){let e=document.querySelector(`#${No}`);e||(e=document.createElement("style"),e.id=No,document.head.append(e)),e.textContent=`:root{${Eo(t)}}`}function fr(t){return Object.keys(xo).filter(e=>void 0===t[e])}function mr(){return"function"==typeof globalThis.matchMedia&&globalThis.matchMedia("(prefers-color-scheme: dark), (forced-colors: active), (prefers-contrast: more)").matches||void 0!==document.documentElement.dataset.darkreaderScheme||null!==document.querySelector('meta[name="darkreader"]')}function gr(t,e){const n=performance.now();t.readings=ur("product"),t.measureMs=Math.round(performance.now()-n);const o=function(t,e){const n=Io({...t,...hr(e)});return Object.keys(xo).some(e=>n[e]!==t[e])?n:void 0}(e,t.readings);void 0!==o&&(pr(o),t.look=o,t.unset=fr(o))}async function yr({page:t,stored:e,post:n,keep:o}){if(e){pr(e.tokens);const n={source:"stored",page:t,readings:{},look:e.tokens,unset:fr(e.tokens)};return"product"===t&&mr()&&gr(n,e.tokens),n}const r=performance.now(),i=ur(t),s=function(t){return Io(hr(t))}(i),a={source:"read",page:t,readings:i,look:s,unset:fr(s),measureMs:Math.round(performance.now()-r)};if(pr(s),"product"!==t||0===Object.keys(s).length||mr())return a;const c=await n(s).catch(()=>{});return a.posted=void 0===c?"failed":c.stored?"stored":"kept",c&&o(c.look),c&&!c.stored&&(pr(c.look.tokens),a.look=c.look.tokens,a.unset=fr(c.look.tokens)),a}const br=/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/u;function vr(t){const{config:e}=t,n=te({transport:t.transport,declares:{types:["page_viewed","item_opened","added_to_cart"],addsCarryRoundId:!0},conversationId:t.conversationId}),o=globalThis.callimacusPageView,r=Ee(o)&&"string"==typeof o.id&&br.test(o.id)?o.id:void 0;let i=void 0===r;const s=function(t,e){const n=e.window??globalThis,{history:o}=n,r=new AbortController,{signal:i}=r;let s=n.location.pathname,a=!1;const c=globalThis;c[Nt]=(c[Nt]??0)+1;const d=()=>{t.record("page_viewed",{page:e.page(n.location)})},l=()=>{try{if(a||n.location.pathname===s)return;s=n.location.pathname,d()}catch{}};void 0!==e.current?t.adoptPageView(e.current):!0===n.document.prerendering?n.document.addEventListener("prerenderingchange",d,{once:!0,signal:i}):d();const{pushState:u,replaceState:h}=o,p=function(...t){u.apply(this,t),l()},f=function(...t){h.apply(this,t),l()};return o.pushState=p,o.replaceState=f,n.addEventListener("popstate",l,{signal:i}),()=>{a||(a=!0,c[Nt]=Math.max((c[Nt]??1)-1,0),r.abort(),o.pushState===p&&(o.pushState=u),o.replaceState===f&&(o.replaceState=h))}}(n,{page:t=>{const n=function(t,e){const n=e.endsWith("/")?e.slice(0,-1):e,o=""===n||t!==n&&!t.startsWith(`${n}/`)?t:t.slice(n.length),[r,i,s,a]=o.split("/").filter(Boolean),c=t=>void 0===t?{}:{handle:t.slice(0,255)};switch(r){case void 0:return{kind:"shopify",template:"index"};case"products":return{kind:"shopify",template:"product",...c(i)};case"collections":return"products"===s?{kind:"shopify",template:"product",...c(a)}:void 0===i?{kind:"shopify",template:"list-collections"}:{kind:"shopify",template:"collection",...c(i)};case"blogs":return{kind:"shopify",template:void 0===s?"blog":"article"};case"pages":return{kind:"shopify",template:"page"};case"policies":return{kind:"shopify",template:"policy"};case"account":return{kind:"shopify",template:"customers/account"};case"cart":case"search":return{kind:"shopify",template:r};default:return{kind:"shopify",template:"other"}}}(t.pathname,e.rootUrl),o=i&&""!==e.template?e.template.slice(0,64):n.template;return i=!1,{...n,template:o}},...void 0!==r&&{current:r}}),a=function(t,e={}){const n=e.document??("undefined"==typeof document?void 0:document);if(void 0===n)return()=>{};const o=oe();if(o.runtimes.push(t),void 0===o.stop){const t=t=>{try{const e=t.target??void 0,n=(t=>void 0!==t&&"function"==typeof t.closest)(e)?e.closest("[data-callimacus-event]")??void 0:void 0,o=ne(n,"data-callimacus-event"),{runtimes:r}=oe(),i=void 0===n?void 0:r.find(t=>t.owns(n))??r[0];if(void 0===n||void 0===o||void 0===i)return;const s=ne(n.closest("[data-callimacus-round]")??void 0,"data-callimacus-round")??i.roundOf?.(n),a=function(t){const e={};for(const{name:n,value:o}of t.attributes)""!==o&&n.length>22&&n.startsWith("data-callimacus-event-")&&(e[n.slice(22)]=o);return e}(n);i.collector(n)?.record("custom_event",{name:o,...Object.keys(a).length>0&&{fields:a}},{roundId:s})}catch{}};n.addEventListener("click",t,{capture:!0}),o.stop=()=>{n.removeEventListener("click",t,{capture:!0})}}let r=!1;return()=>{if(r)return;r=!0;const e=oe();e.runtimes=e.runtimes.filter(e=>e!==t),e.runtimes.length>0||(e.stop?.(),e.stop=void 0)}}({owns:t=>null!==t.closest("[data-chapter-id], [data-callimacus-stage]"),collector:()=>n,...void 0!==t.roundOf&&{roundOf:t.roundOf}});return{collector:n,added(t,e,o,r){const i=ae(t,e,{itemId:o.productId,origin:o.origin},r.map(t=>t.data));void 0!==i&&n.record("added_to_cart",i,{roundId:o.roundId})},clicked(t,e,o){n.record("item_opened",{itemId:t,...void 0!==e&&{position:e},surface:"card"},{roundId:o})},stop(){s(),a(),n.stop()}}}const wr=["hero","answer","picks","topic","cross","next","other"],kr=["hero","answer","picks","topic","cross","next"],Sr=new Map([["custom:editorialHero","hero"],["custom:storefrontReply","answer"],["custom:pageAnswer","answer"],["demosthenesResponse","answer"],["custom:demosthenesResponse","answer"],["custom:addToCartResult","answer"],["custom:storefrontPicks","picks"],["custom:collectionGrid","picks"],["custom:problemGuide","topic"],["custom:materialStory","topic"],["custom:sizeCare","topic"],["custom:compareSet","topic"],["custom:storyCards","topic"],["custom:completeSet","cross"],["custom:followUps","next"]]);function Ar(t){return"object"==typeof t&&null!==t&&"string"==typeof t.type&&"function"==typeof t.render}function _r(t){const e=globalThis.callimacusRenderers;if(Array.isArray(e))for(let n=e.length-1;n>=0;n--){const o=e[n];if(Ar(o)&&o.type===t)return o}}function xr(t,e){const n=new Map(t.map(t=>[t.type,t])),o=function(t){return{type:"*",render(e,n){const o=n.text(e);if(""===o)return;const r=ke("div",`cal-fallback-note ${t.pageWidth}`),i=ke("div",`cal-fallback-note__body ${t.rte}`);return xe(i,o),r.append(i),r},update(t,e,n){const o=n.text(e),r=t instanceof Element?t.querySelector(".cal-fallback-note__body"):void 0;return!(""===o||!r||(r.replaceChildren(),xe(r,o),0))}}}(e),r=new Set;return t=>{const e=_r(t)??n.get(t)??_r("*")??n.get("*");return e||(Sr.has(t)?void(r.has(t)||(r.add(t),ge.warn(`no renderer for ${t}, skipped`))):o)}}function Cr(t,e,n){try{const o=t.render(e,n);return o instanceof Node?o:void(null!=o&&ge.error(`renderer for ${e.type} returned something that is not a Node, skipped`))}catch(t){return ge.error(`renderer for ${e.type} threw in render()`,t),!1}}function Er(t,e,n){const o=ke("article","cal-chapter");o.dataset.chapterIndex=String(e.index),void 0!==e.id&&(o.dataset.chapterId=e.id);const r=`CallimacusChapter-${t}`,i=ke("header",`cal-chapter__head ${n.pageWidth}`),s=ke("h2","cal-chapter__heading"),a=ke("button","cal-chapter__toggle");a.type="button",a.setAttribute("aria-expanded","true"),a.setAttribute("aria-controls",r),a.append(ke("span","cal-chapter__question",e.question)),void 0!==e.about&&a.append(ke("span","cal-chapter__about",`About: ${e.about}`));const c=ke("span","cal-chapter__thumbs");c.setAttribute("aria-hidden","true"),a.append(c,function(t,e,n){const o=document.createElementNS(Ae,"svg");o.setAttribute("viewBox",t),o.setAttribute("fill","none"),o.setAttribute("aria-hidden","true"),o.setAttribute("focusable","false"),o.setAttribute("class",n);const r=document.createElementNS(Ae,"path");return r.setAttribute("d",e),r.setAttribute("stroke","currentColor"),r.setAttribute("stroke-width","1.4"),r.setAttribute("stroke-linecap","round"),r.setAttribute("stroke-linejoin","round"),o.append(r),o}("0 0 16 16","M4 6l4 4 4-4","cal-chapter__chevron")),s.append(a),i.append(s);const d=ke("div","cal-chapter__body");d.id=r;const l=new Map;for(const t of wr){const e=ke("div","cal-slot");e.dataset.slot=t,l.set(t,e),d.append(e)}return o.append(i,d),{key:t,id:e.id,question:e.question,about:e.about,sent:e.sent??e.question,index:e.index,status:e.status??0,blocks:e.blocks??[],nodes:new Map,cart:e.cart,slots:l,el:o,body:d,toggle:a,thumbs:c,timing:void 0}}function Tr(t,e){const n=t.slots.get(e);if(!n)throw new Error(`chapter has no ${e} slot`);return n}function Rr(t,e){t.el.dataset.state=e,t.el.setAttribute("aria-busy",String("streaming"===e))}function Or(t){let e;for(const n of t)(!e||n.index>e.index)&&(e=n);return e}function qr(t){return t.blocks.map((t,e)=>({block:t,position:e})).sort((t,e)=>{const n=(t.block.priority??0)-(e.block.priority??0);return 0===n?t.position-e.position:n}).map(({block:t})=>t)}function $r(t,e=""){return"string"==typeof t&&""!==t.trim()?t.trim():e}function Ir(t,e){let n=t.language;try{Intl.NumberFormat.supportedLocalesOf(n)}catch{ge.warn(`invalid language "${n}", formatting prices with "en"`),n="en"}const o=new Map;const r=t.rootUrl.endsWith("/")?t.rootUrl.slice(0,-1):t.rootUrl;return{settings:t,text(t){for(const e of Ue(t)){if(qe(e))return e.trim();if(Ee(e)&&qe(e.text))return e.text.trim()}return""},hits:t=>Le(Array.isArray(t)?t:[t]),picks(t){for(const e of Ue(t)){if(!Array.isArray(e))continue;const t=Le(e);if(t.length>0)return t}return[]},money(e){const r="number"==typeof e?e:e?.amount;if(void 0===r||""===r)return"";const i=Number(r);if(!Number.isFinite(i))return"";const s="object"==typeof e?e.currency:void 0,a=function(t){if(!o.has(t))try{o.set(t,new Intl.NumberFormat(n,{style:"currency",currency:t}))}catch{ge.warn(`invalid currency "${t}", showing bare amounts`),o.set(t,void 0)}return o.get(t)}(void 0===s||""===s?t.currency:s);return a?a.format(i):i.toFixed(2)},url(t){const e=void 0===t?"":function(t){if(!Te(t)){const e=Ee(t.meta)?t.meta.url:void 0;return"string"==typeof e&&/^\/(?!\/)/u.test(e)&&!/[\s\\]/u.test(e)?e:""}const e=encodeURIComponent(t.fields["shopify-handle"]);switch(Re(t)){case"product":return`/products/${e}`;case"collection":return`/collections/${e}`;case"article":{const n=$e(t.fields["shopify-blogHandle"]);return""===n?"":`/blogs/${encodeURIComponent(n)}/${e}`}default:return""}}(t);return""===e?"":`${r}${e}`},imageUrl(t,{width:e=800,index:n=0}={}){const o=t?.fields.images;if(!Array.isArray(o)||0===o.length)return"";const r=o[n]?.url??o[0]?.url;return"string"!=typeof r||""===r?"":`${r.split("?",1)[0]}?width=${e}`},variantId(t){const e=t?.fields.variantTree?.variants;if(!Array.isArray(e)||0===e.length)return"";const n=e.find(t=>!0===t?.orderable)??e[0];return void 0===n?.id?"":String(n.id).split("/").pop()??""},addToCart:e.addToCart,productClicked:e.productClicked,productAdded:e.productAdded,ask:e.ask,remember:e.remember}}function Nr(){return globalThis.Shopify}function Lr(){try{const t=Nr()?.customerPrivacy?.preferencesProcessingAllowed?.();return void 0===t?"unknown":!0===t?"allowed":"refused"}catch{return"unknown"}}function Mr(t){return be("sessionStorage",t)??("allowed"===Lr()?be("localStorage",t):void 0)}function Br(t){const e=Mr(t);if(void 0!==e&&""!==e)try{return JSON.parse(e)}catch{return void ge.warn(`ignoring unreadable "${t}"`)}}function jr(t,e){const n=ve("sessionStorage",t,e);return"allowed"!==Lr()||ve("localStorage",t,e)||we("localStorage",t),n}function Ur(t){we("localStorage",t),we("sessionStorage",t)}function Fr(t){const e=Lr();if("unknown"!==e)for(const n of t){if("allowed"===e){const t=be("sessionStorage",n);void 0!==t&&ve("localStorage",n,t);continue}const t=be("localStorage",n);void 0!==t&&(void 0===be("sessionStorage",n)&&ve("sessionStorage",n,t),we("localStorage",n))}}const Dr="callimacus.memory",Pr=6,Wr=12,zr=12,Vr=new TextEncoder;function Hr(t){return Array.isArray(t)?t.filter(t=>Ee(t)):[]}function Kr(t){return"number"==typeof t&&Number.isFinite(t)?t:0}function Jr(){const t=Br(Dr),e=Ee(t)?t:{};return{questions:Hr(e.questions).filter(t=>"string"==typeof t.q).map(t=>({q:t.q,at:Kr(t.at)})),viewed:Hr(e.viewed).filter(t=>"string"==typeof t.handle).map(t=>({handle:t.handle,title:"string"==typeof t.title?t.title:"",at:Kr(t.at)})),added:Hr(e.added).filter(t=>"string"==typeof t.handle).map(t=>({handle:t.handle,at:Kr(t.at)}))}}function Yr(t){return"string"==typeof t?t:Ee(t)&&"string"==typeof t.handle?t.handle:""}function Gr(t,e){const n=Jr(),o=Date.now();switch(t){case"questions":case"question":{const t="string"==typeof e?e.trim():"";if(""===t)return;n.questions=[{q:t,at:o},...n.questions.filter(e=>e.q!==t)].slice(0,12);break}case"viewed":{const t=Yr(e);if(""===t)return;const r=Ee(e)&&"string"==typeof e.title?e.title:"";n.viewed=[{handle:t,title:r,at:o},...n.viewed.filter(e=>e.handle!==t)].slice(0,12);break}case"added":{const t=Yr(e);if(""===t)return;n.added=[{handle:t,at:o},...n.added.filter(e=>e.handle!==t)].slice(0,12);break}default:return void ge.warn(`remember() does not know "${t}"`)}jr(Dr,JSON.stringify(n))}function Xr(t,e){const n=t=>t.slice(0,200),o=t=>t.length<=200,r={questions:t.questions.map(t=>t.q).filter(t=>t!==e).slice(0,Pr).map(t=>n(t)),viewed:t.viewed.filter(t=>o(t.handle)).slice(0,Wr).map(({handle:t,title:e})=>""===e?{handle:t}:{handle:t,title:n(e)}),added:t.added.map(t=>t.handle).filter(t=>o(t)).slice(0,zr)};for(;Vr.encode(JSON.stringify(r)).length>4096;){let t="viewed";for(const e of["added","questions"])r[e].length>r[t].length&&(t=e);r[t].pop()}return r}function Zr(t){return ke("div",`cal-skeleton__bone cal-skeleton__bone--${t}`)}function Qr(t,e){const n=ke("ul",e.grid(t));for(let o=0;o<t;o++){const t=ke("li",e.gridItem),o=ke("div","cal-skeleton__card");o.append(Zr("media"),Zr("title"),Zr("price")),t.append(o),n.append(t)}return n}function ti(){const t=ke("div","cal-skeleton__lines");return t.append(Zr("line"),Zr("line"),Zr("line")),t}function ei(t,e,n){const o=ke("div","cal-skeleton");o.dataset.skeleton=t,o.setAttribute("aria-hidden","true");const r=ke("div","cal-skeleton__inner"),i="hero"===t&&0===e,s=ke("div",i?"cal-skeleton__content":`cal-skeleton__content${"hero"!==t||i?"":" cal-skeleton__content--row"} ${n.pageWidth}`);return s.append(...function(t,e,n){switch(t){case"hero":return e?[Zr("hero")]:[Zr("lead"),ti()];case"answer":return[ti()];case"picks":return[Qr(4,n)];case"topic":return[Zr("topic")];case"cross":return[Qr(3,n)];case"next":{const t=ke("div","cal-skeleton__chips");return t.append(Zr("chip"),Zr("chip"),Zr("chip")),[t]}case"other":return[]}}(t,i,n)),r.append(s),o.append(r),o}function ni(t,e){if(!Ee(t)||"shopify-add"!==t.command||"string"!=typeof t.chapterId||"string"!=typeof t.variantId||!(t=>fe.test(t))(t.variantId))return;if(void 0!==e&&"string"==typeof t.storyId&&t.storyId!==e)return;const n=Ee(t.item)?t.item:{},o=(Array.isArray(n.options)?n.options:[]).filter(t=>Ee(t)&&"string"==typeof t.value).map(t=>{const{name:e,value:n}=t;return{name:"string"==typeof e?e:"",value:n}});return{storyId:"string"==typeof t.storyId?t.storyId:e??"",chapterId:t.chapterId,command:"shopify-add",variantId:t.variantId,quantity:"number"==typeof t.quantity?t.quantity:NaN,item:{id:"string"==typeof n.id?n.id:"",name:"string"==typeof n.name&&""!==n.name?n.name:"This product",options:o}}}function oi(t,e){const n=String(t?.id??"");if(void 0===e||e!==t?.title||!/^\d+$/u.test(n))return{};const{innerWidth:o,innerHeight:r}=globalThis,i={id:`shopify:product:gid://shopify/Product/${n}`,isVisible:!0,visibilityRatio:1,bounds:{x:0,y:0,width:o,height:r,top:0,left:0,right:o,bottom:r}};return{uiSnapshot:{timestamp:Date.now(),viewport:{width:o,height:r},elements:[i],blockIds:[]}}}const ri="callimacus.thread",ii="callimacus.storyId",si=15e5;function ai(t){return Array.isArray(t)?t.filter(t=>Ee(t)&&"string"==typeof t.id&&""!==t.id):[]}function ci(t){const e=t.inputEvent;return Ee(e)&&Ee(e.data)?Ie(e.data.value):""}function di(t){const e=t.lastIndexOf(" (about the ");if(-1===e||!t.endsWith(")"))return{question:t,about:void 0};const n=t.slice(e+12,-1);return""===n?{question:t,about:void 0}:{question:t.slice(0,e),about:n}}function li(t){const e=Number(t);return Number.isFinite(e)?e:0}function ui(){return Mr(ii)}function hi(t){void 0===t?Ur(ii):jr(ii,t)}const pi=new Set(["added","refused","unavailable","failed"]);function fi(t){const{notice:e}=t;return Ee(e)&&"string"==typeof e.outcome&&pi.has(e.outcome)&&"string"==typeof e.message?{notice:{outcome:e.outcome,message:e.message}}:{}}function mi(){const t=Br(ri);return Array.isArray(t)?t.filter(t=>Ee(t)&&"string"==typeof t.question).map(t=>t).map(t=>{const e=t.question;return{id:""===Ie(t.id)?void 0:Ie(t.id),question:e,about:""===Ie(t.about)?void 0:Ie(t.about),sent:""===Ie(t.sent)?e:Ie(t.sent),index:li(t.index),status:li(t.status),blocks:ai(t.blocks),...Ee(t.cart)&&{cart:fi(t.cart)}}}).sort((t,e)=>t.index-e.index).slice(-12):[]}function gi(t){return Math.round(performance.now()-t.t0)}const yi=4e3,bi=[ri,ii,Dr],vi="data-callimacus-on",wi=new Set([401,403]),ki=new Set(["invalid_token","origin_not_allowed","paused"]);function Si(t){return"function"==typeof globalThis.matchMedia?globalThis.matchMedia(t):{matches:!1}}function Ai(t){const{kit:e}=t,n=t.roundTimeoutMs??45e3,o=t.createTransport??(()=>new Wt),r=function(){let t={};try{const e=JSON.parse(document.querySelector("#callimacus-config")?.textContent??"{}");t=Ee(e)?e:{}}catch(t){ge.error("#callimacus-config is not valid JSON",t)}const e=globalThis.Shopify,n=Ee(t.product)&&""!==$r(t.product.handle)?Object.freeze({handle:$r(t.product.handle),title:$r(t.product.title),id:"number"==typeof t.product.id||"string"==typeof t.product.id?t.product.id:void 0}):void 0,o=$r(t.storeName,"this store");return Object.freeze({language:$r(t.language,"en"),rootUrl:$r(t.rootUrl,"/"),cartAddUrl:$r(t.cartAddUrl,"/cart/add"),currency:$r(t.currency,"USD"),designMode:!0===t.designMode||Boolean(e?.designMode),template:$r(t.template),product:n,storeName:o,assistantLabel:$r(t.assistantLabel,`Ask ${o}`),starters:Object.freeze(Array.isArray(t.starters)?t.starters.map(t=>$r(t)).filter(t=>""!==t):[])})}(),i=function(t){return{connecting:"Connecting…",asking:"Thinking…",streaming:"Composing your answer…",done:"Answer ready.",queued:t=>`Queued: “${t}”. I’ll ask that next.`,queueFull:"Still answering. Ask again in a moment.",dequeued:"Removed from the queue.",timeout:"This is taking longer than usual. Try asking again.",failed:"Something went wrong. Please try again.",reconnecting:"Reconnecting…",unavailable:`${t.assistantLabel} is unavailable right now. Please try again later.`,trimmed:"Earlier answers were trimmed from this conversation.",designMode:`${t.assistantLabel} answers on the live store, not in the theme editor.`,interrupted:"This answer stopped before it was finished.",unanswered:`${t.storeName} could not answer that just now.`}}(r),s=document.documentElement,a=new AbortController,{signal:c}=a,d=[],l=Si("(prefers-reduced-motion: reduce)"),u=Si("(pointer: coarse)"),h={ui:"idle",storyId:void 0,isConnected:!1,isOff:!1,thread:[],round:void 0,queue:[],about:r.product?.title,hydrateMode:void 0,refreshTimer:void 0,lastAsk:void 0,statusTimer:void 0,nextKey:0},p=[],f=xr(t.renderers,e.classes);let m;const g=function(t,e={}){const n=new Set;function o(e){const o=function(){try{const e=JSON.parse(t().getItem(ue)??"[]");return Array.isArray(e)?e.filter(t=>"string"==typeof t):[]}catch{return}}();if(o?.includes(e)||n.has(e))return!1;try{t().setItem(ue,JSON.stringify([...o??[],e].slice(-50)))}catch{n.add(e)}return!0}return async(t,n)=>{if(void 0===n||!o(t.chapterId))return;const r=Math.trunc(t.quantity),i=Math.min(Math.max(Number.isFinite(r)?r:1,1),10),s=await n(i);return void 0===s.error&&e.collector?.()?.record("added_to_cart",{itemId:t.item.id,variantId:t.variantId,quantity:i,origin:"request"},{roundId:t.chapterId}),{notice:pe({id:t.chapterId,item:t.item,quantity:i},s),...s.error&&{code:s.error.code}}}}(()=>sessionStorage,{collector:()=>m?.collector});function y(){a.abort(),m?.stop();for(const t of d)t.disconnect();clearTimeout(h.refreshTimer),clearTimeout(h.statusTimer),clearTimeout(h.round?.timer)}function b(t,e){document.dispatchEvent(new CustomEvent(t,{detail:e}))}function v(t){h.ui!==t&&(h.ui=t,s.dataset.callimacusState=t,b("callimacus:state",{state:t}))}function w(t,{clearAfter:e=0}={}){clearTimeout(h.statusTimer);for(const e of document.querySelectorAll("[data-callimacus-status]"))e.textContent=t;e>0&&(h.statusTimer=setTimeout(()=>{w("")},e))}function k(t){h.storyId=""===t?void 0:t,hi(h.storyId)}function S(t,e,n){const o=String(t).split("/").pop()??"";m?.added(o,e,n,h.thread.find(t=>void 0!==t.id&&t.id===n.roundId)?.blocks??[])}async function A(t,n=1,o){const i=String(t).split("/").pop()??"";if(!/^\d+$/u.test(i))throw new Error("This product cannot be added right now.");const s=await e.addToCart(i,n,r);return"string"==typeof s.handle&&""!==s.handle&&Gr("added",s.handle),o&&S(i,n,o),s}const _=Ir(r,{addToCart:async(t,e,n)=>A(t,e,n??{}),productClicked(t,e){m?.clicked(t,e,void 0)},productAdded(t,e,n){S(t,e,{...n,origin:"card"})},ask:t=>"refused"!==W(t,{type:"relatedQuestion"}),remember:Gr});const x={stage:void 0,thread:void 0,earlier:void 0,trimmed:void 0,dock:document.querySelector("[data-callimacus-dock]")??void 0};function C(){return x.stage?.dataset.stageKind??"page"}function E(){let t=document.querySelector("[data-callimacus-stage]")??void 0;t||(t=ke("div","cal-stage"),t.dataset.callimacusStage="",t.dataset.stageKind="page",t.dataset.callimacusUi="",(document.querySelector("#MainContent")??document.body).prepend(t));let n=t.querySelector("[data-callimacus-thread]")??void 0;n||(n=ke("div","cal-thread"),n.dataset.callimacusThread="",t.append(n)),n.classList.add("cal-thread");const o=ke("button",`cal-thread__earlier ${e.classes.pageWidth}`);o.type="button",o.hidden=!0,o.addEventListener("click",()=>{R(!1)},{signal:c});const r=ke("p",`cal-thread__trimmed ${e.classes.pageWidth}`,i.trimmed);return r.hidden=!0,n.after(o,r),Object.assign(x,{stage:t,thread:n,earlier:o,trimmed:r}),{stage:t,thread:n}}function T(){return x.thread??E().thread}function R(t){x.thread&&(x.thread.toggleAttribute("data-compact",t),O())}function O(){if(!x.earlier||!x.thread||!x.trimmed)return;const t=h.thread.length-1,e=Object.hasOwn(x.thread.dataset,"compact"),n=e&&t>0;x.earlier.hidden=!n,n&&(x.earlier.textContent=`Show ${t} earlier question${1===t?"":"s"}`),x.trimmed.hidden=e||0===h.thread.length||h.thread.some(t=>0===t.index)}function q(){const t=new Set([...h.thread].sort((t,e)=>e.index-t.index).slice(12));for(const e of t)e.el.remove();h.thread=h.thread.filter(e=>!t.has(e))}function $(t){h.nextKey+=1;const n=Er(h.nextKey,t,e.classes);return n.toggle.addEventListener("click",()=>{N(n,Object.hasOwn(n.el.dataset,"collapsed"))},{signal:c}),n}function I(t){for(const n of kr){const o=Tr(t,n);o.querySelector(":scope > .cal-block, :scope > .cal-skeleton")||o.append(ei(n,t.index,e.classes))}}function N(t,e,{shouldAnimate:n=!0}={}){e!==!Object.hasOwn(t.el.dataset,"collapsed")&&(e||t.thumbs.replaceChildren(...function(t){const e=new Set,n=[],o=qr(t).flatMap(t=>_.picks(t));for(const t of o){if(4===n.length)break;const o=t.fields["shopify-handle"],r=_.imageUrl(t,{width:160});if(""===r||e.has(o))continue;e.add(o);const i=ke("img","cal-chapter__thumb");i.src=r,i.alt="",i.loading="lazy",i.decoding="async",i.width=40,i.height=50,n.push(i)}return n}(t)),t.el.toggleAttribute("data-collapsed",!e),t.toggle.setAttribute("aria-expanded",String(e)),t.body.inert=!e,e&&n&&!l.matches&&(t.el.dataset.animating="",setTimeout(()=>{delete t.el.dataset.animating},360)))}function L(t){const e=t.el,n=()=>{t.el.style.setProperty("--cal-header-height",`${function(){if("function"!=typeof document.elementsFromPoint)return 0;const t=document.documentElement.clientWidth;let e=0;for(const n of[.25,.5,.75])for(const o of document.elementsFromPoint(Math.round(t*n),1)){const t=Ce(o)?.getBoundingClientRect();t&&t.top<=1&&t.bottom>e&&t.bottom<globalThis.innerHeight/2&&(e=t.bottom)}return Math.round(e)}()}px`),e.scrollIntoView?.({behavior:l.matches?"auto":"smooth",block:"start"})};"function"==typeof requestAnimationFrame?requestAnimationFrame(n):n()}function M(t,n){const o=t.body.querySelector(":scope > .cal-chapter__note");if(!n)return void o?.remove();if(o)return;const r=ke("div",`cal-chapter__note ${e.classes.pageWidth}`);r.append(ke("p","",t.blocks.length>0?i.interrupted:i.unanswered));const s=ke("button","cal-chapter__retry","Ask again");s.type="button",s.addEventListener("click",()=>{W(t.question,{type:"question",about:t.about})},{signal:c}),r.append(s),t.body.append(r)}function B(t,e,n,o){const r=Tr(t,Sr.get(e.type)??"other"),i=ke("div","cal-block");i.dataset.blockId=e.id,i.dataset.blockType=e.type,i.dataset.order=String(o.order),i.append(n),r.querySelector(":scope > .cal-skeleton")?.remove();const s=[...r.children].find(t=>Number(t.dataset.order)>o.order)??r.querySelector(":scope > .cal-cart-notice");if(s?s.before(i):r.append(i),o.shouldAnimate&&!l.matches){const t=60*o.stagger;i.style.setProperty("--cal-stagger",`${t}ms`),i.dataset.arriving="",setTimeout(()=>{delete i.dataset.arriving,i.style.removeProperty("--cal-stagger")},240+t+60)}var a;return a=t.timing,"pending"===a?.outcome&&void 0===a.firstBlockMs&&(a.firstBlockMs=gi(a),performance.mark(`callimacus:chapter-${a.chapter}:first-block`)),b("callimacus:block",{chapterId:t.id,blockId:e.id,type:e.type,node:n}),i}function j(t,e,n,o){const r=f(e.type);if(!r||!Fe(e))return!1;const i=function(t,e){return`${void 0===t.cart?"":"cart|"}${JSON.stringify(e.data)}`}(t,e);let s=t.nodes.get(e.id);if(s?.wrap&&(s.wrap.dataset.order=String(o.order)),!0===s?.isBroken)return!1;if(void 0===s?.node){if(s?.signature===i&&!o.hasBecomeDone)return!1;const a=Cr(r,e,n);return s={signature:i,node:!1===a?void 0:a,wrap:void 0,isBroken:!1===a},t.nodes.set(e.id,s),s.node?(s.wrap=B(t,e,s.node,o),!0):!1}if(i===s.signature&&!o.hasBecomeDone)return!1;if(s.signature=i,function(t,e,n,o){if("function"!=typeof t.update)return!1;try{return t.update(e,n,o)}catch(t){return ge.error(`renderer for ${n.type} threw in update()`,t),!1}}(r,s.node,e,n))return!1;const a=Cr(r,e,n);return!1===a?s.isBroken=!0:a&&s.wrap&&(s.wrap.replaceChildren(a),s.node=a),!1}function U(t,{hasBecomeDone:e=!1,shouldAnimate:n=!0}={}){const o=function(t){const e=4===t.status,n=Object.freeze({id:t.id,index:t.index,isFirst:0===t.index,question:t.question,done:e,blocks:Object.freeze([...t.blocks]),addedToCart:void 0!==t.cart});return Object.freeze({..._,addToCart:async(e,n,o)=>A(e,n,{...o,roundId:t.id}),productClicked(e,n){m?.clicked(e,n,t.id)},productAdded(e,n,o){S(e,n,{...o,origin:"card",roundId:t.id})},chapter:n,final:e})}(t);let r=0;for(const[i,s]of qr(t).entries())j(t,s,o,{order:i,stagger:r,hasBecomeDone:e,shouldAnimate:n})&&(r+=1)}const F=function(t){let e,n=!1,o=!1,r=0;const i=[];function s(e,o=t.session.current()){n=!1,o.then(o=>{if(!t.isOff()){if(!o)return i.length=0,void t.onRefused();e.connect(o.endpoint,{Authorization:`Bearer ${o.token}`},{token:o.token}),n=!0;for(const t of i.splice(0))t(e)}}).catch(e=>{ge.warn("no storefront session",e),i.length=0,t.onError({code:503,reason:"retries_exhausted",message:"no storefront session"})})}function a(){if(e)return o&&(o=!1,s(e)),e;const n=t.createTransport();return n.onServerResponse(t.onResponse),n.onError(t.onError),n.onConnectionStatus(t.onStatus),e=n,s(n),n}return{connect:a,send:function(t,e){const o=a();n?o.sendUserInteraction(t,e):i.push(n=>{n.sendUserInteraction(t,e)})},markFailed(){o=!0},didRenew:function(){const n=Date.now();return!(!e||n-r<6e4||(r=n,ge.info("the storefront token expired; asking the store for a fresh one"),s(e,t.session.renew()),0))}}}({session:t.session,createTransport:o,onResponse:function(t){const e=t;switch(e.type){case wt:!function(t){if(!Ee(t)||"string"!=typeof t.id||""===t.id)return;t.id!==h.storyId&&k(t.id);const e=(Array.isArray(t.chapters)?t.chapters:[]).filter(t=>Ee(t)&&"string"==typeof t.id&&""!==t.id&&!0!==t.deleted).map(t=>t);e.length>0?function(t){const e="restore"===h.hydrateMode;let n=!1;for(const o of t.slice(-12)){const r=t.indexOf(o),i=h.thread.find(t=>t.id===o.id)??J(o);if(i){e&&nt(i,r),Y(i,o,h.round?.rec===i);continue}const s=ci(o);if(!e||""===s)continue;const{question:a,about:c}=di(s);tt({id:o.id,question:a,about:c,sent:s,index:r,status:"number"==typeof o.status?o.status:0,blocks:ai(o.blocks)}),n=!0}if(n){const e=new Set(t.map(t=>t.id));let n=t.length;for(const t of h.thread)e.has(t.id)||nt(t,n++);pt(),et(),Q()}e&&(h.hydrateMode="refresh")}(e):"restore"===h.hydrateMode&&(h.hydrateMode="refresh")}(e.story);break;case vt:!function(t){if(!Ee(t)||"string"!=typeof t.id||""===t.id||!0===t.deleted)return;const e=h.thread.find(e=>e.id===t.id)??J(t);e?Y(e,t,!0):ge.debug("chapter-event for a chapter this page does not show",t.id)}(e.chapter);break;case kt:!async function(t){const e=ni(t,h.storyId);if(!e)return void ge.debug("cart-command this page does not run");const n=h.thread.find(t=>t.id===e.chapterId)??h.round?.rec,o=await g(e,async t=>(n&&(n.cart={},M(n,!1),U(n,{shouldAnimate:!1}),Q()),en(async()=>A(e.variantId,t))));if(!o)return;const{notice:r}=o;if(w(r.message,{clearAfter:8e3}),b("callimacus:cart",{outcome:r.outcome,variantId:e.variantId,quantity:r.quantity,..."added"!==r.outcome&&{message:r.message}}),!n)return;n.cart={notice:{outcome:r.outcome,message:r.message}},D(n),Q()}(e.data);break;default:ge.debug("ignored server response",e.type)}},onError:function(t){const{code:e}=t;if(ge.warn("server error",e,t.message??"",t.reason??""),"token_expired"===t.reason&&F.didRenew())return;if(function(t){return wi.has(t.code)&&(!h.isConnected||ki.has(t.reason??""))}(t))return void P(t);const{round:o}=h;if(404===e&&(k(void 0),it({shouldFailPending:!0}),o&&!o.isRetried&&void 0===o.rec.id))return o.isRetried=!0,ge.info("story not found, asking again as a new story"),clearTimeout(o.timer),o.timer=setTimeout(()=>{K(o)},n),void H(o);const r=!h.isConnected;if(r&&"retries_exhausted"!==t.reason&&!(e>=400&&e<500))return void(o&&w(i.reconnecting));r&&F.markFailed();o?(w(r?i.unavailable:i.failed),G(o.rec,"error")):r&&(v("error"),w(i.unavailable))},onStatus:function(t){h.isConnected=t;const{round:e}=h;if(!t||!e||void 0!==e.rec.timing?.firstEventMs)return;v("asking"),w(i.asking)},isOff:()=>h.isOff,onRefused(){const{status:t,reason:e}=yo()??{status:401,reason:"invalid_token"};P({code:t,reason:e})}});function D(t){const n=t.cart?.notice;n&&Tr(t,"answer").append(Se(n,e.classes.pageWidth))}function P(t){const e="paused"===t.reason;if(ge.warn(`the store refused this storefront (${String(t.code)} ${t.reason??""}); the theme's own search is back`),h.isOff=!0,go({status:t.code,reason:t.reason}),it(),h.queue=[],dt(),h.round&&G(h.round.rec,"error"),v("error"),e){for(const t of document.querySelectorAll('[data-callimacus-form] input[name="q"], [data-callimacus-form] [type="submit"], [data-callimacus-open], button[data-callimacus-ask]'))t.disabled=!0;w(i.unavailable)}else s.removeAttribute(vi),w("");b("callimacus:off",{code:t.code,reason:t.reason})}function W(t,{type:e="question",about:n}={}){const o=Ie(t),s=function(t){if(""===t||h.isOff)return"";if(r.designMode)return i.designMode;const e=Date.now();return h.lastAsk?.text===t&&e-h.lastAsk.at<600?"":(h.lastAsk={text:t,at:e},h.round&&h.queue.length>=3?i.queueFull:void 0)}(o);if(void 0!==s)return""!==s&&w(s,{clearAfter:s===i.unavailable?0:yi}),"refused";const a={display:o,about:n,type:e,sent:void 0===n?o:`${o} (about the ${n})`,visit:Xr(Jr(),o)};return Gr("questions",o),b("callimacus:ask",{question:o,type:e,queued:Boolean(h.round)}),h.round?(h.queue.push(a),dt(),w(i.queued(o),{clearAfter:yi}),"queued"):(z(a),"sent")}function z(t){const e=$({question:t.display,about:t.about,sent:t.sent,index:V()});for(const t of h.thread)N(t,!1);h.thread.push(e),T().prepend(e.el),q(),Rr(e,"streaming"),I(e),pt(),ct(),O();const o={rec:e,type:t.type,visit:t.visit,timer:void 0,isRetried:!1};var r,s;h.round=o,e.timing=(r=e.index,s=e.question,performance.mark(`callimacus:chapter-${r}:sent`),{chapter:r,question:s,chapterId:void 0,sentAt:(new Date).toISOString(),firstEventMs:void 0,firstBlockMs:void 0,doneMs:void 0,outcome:"pending",t0:performance.now()}),p.push(e.timing),v(h.isConnected?"asking":"connecting"),w(h.isConnected?i.asking:i.connecting),o.timer=setTimeout(()=>{K(o)},n),L(e),Q(),b("callimacus:chapter",X(e)),H(o)}function V(){let t=0;for(const e of h.thread)t=Math.max(t,e.index+1);return t}function H(t){try{F.connect()}catch(e){return ge.error("could not start the Callimacus client",e),void(h.round===t&&(w(i.unavailable),G(t.rec,"error")))}if(h.round===t)try{!function(t){const e=m?.collector.pageViewId,n={visit:t.visit,shopifyCart:!0,...oi(r.product,t.rec.about),...void 0!==e&&{pageViewId:e}},o={...void 0!==h.storyId&&{storyId:h.storyId},language:r.language,inputEvent:{type:t.type,data:{value:t.rec.sent}},context:n};F.send(Mt.CREATE_ROUND,o)}(t)}catch(e){ge.error("could not send the question",e),w(i.failed),G(t.rec,"error")}}function K(t){h.round===t&&(ge.warn(`no complete answer within ${n/1e3} s for “${t.rec.question}”`),w(i.timeout),G(t.rec,"timeout"))}function J(t){const e=ci(t),n=""===e?void 0===h.round?.rec.id?h.round?.rec:void 0:h.thread.findLast(t=>void 0===t.id&&t.sent===e);if(n&&"string"==typeof t.id)return n.id=t.id,n.el.dataset.chapterId=t.id,n}function Y(t,e,n){const o=4===t.status;var r,s;t.blocks=function(t,e){const n=[...t];for(const t of e){const e=n.findIndex(e=>e.id===t.id);-1===e?n.push(t):n[e]=t}return n}(t.blocks,ai(e.blocks)),t.status="number"==typeof e.status?e.status:t.status,h.round?.rec===t&&void 0===t.timing?.firstEventMs&&(r=t.timing,s=t.id,r&&void 0===r.firstEventMs&&(r.firstEventMs=gi(r),r.chapterId=s),v("streaming"),w(i.streaming));const a=!o&&4===t.status;U(t,{hasBecomeDone:a,shouldAnimate:n}),a&&G(t,"done")}function G(t,e){const n="done"!==e;Rr(t,n?"error":"done"),function(t){for(const e of t.body.querySelectorAll(":scope > .cal-slot > .cal-skeleton")){if(Object.hasOwn(e.dataset,"leaving"))continue;e.dataset.leaving="";const t=()=>{e.remove()};e.addEventListener("transitionend",t,{once:!0}),setTimeout(t,400)}}(t),M(t,n&&!h.isOff&&void 0===t.cart),function(t,e,n){if("pending"!==t?.outcome)return;t.outcome=n,t.chapterId=e,t.doneMs=gi(t),performance.mark(`callimacus:chapter-${t.chapter}:${n}`);const{t0:o,...r}=t;ge.debug("timing",r)}(t.timing,t.id,e),Q(),b("callimacus:chapter",X(t));const o=h.round?.rec===t?h.round:void 0;o&&(clearTimeout(o.timer),h.round=void 0,n?v("error"):(v("idle"),w(i.done,{clearAfter:yi})),function(){if(void 0!==h.round||h.isOff)return;const t=h.queue.shift();if(!t)return;dt(),z(t)}())}function X(t){return{id:t.id,index:t.index,question:t.question,state:t.el.dataset.state}}function Z(t){return{id:t.id,question:t.question,about:t.about,sent:t.sent,index:t.index,status:t.status,blocks:t.blocks,...t.cart&&{cart:t.cart}}}function Q(){!function(t){if(0===t.length)return;const e=[...t].sort((t,e)=>t.index-e.index).slice(-12);let n=JSON.stringify(e);if(n.length>si){for(const t of e)t.blocks=De(t.blocks);n=JSON.stringify(e)}for(;e.length>0;){if(n.length<=si&&jr(ri,n))return;e.shift(),n=JSON.stringify(e)}Ur(ri)}(h.thread.map(t=>Z(t))),hi(h.storyId)}function tt(t){const e=$(t);h.thread.push(e);const n=4===e.status,o=!n&&void 0!==e.id&&void 0!==h.storyId;return Rr(e,n?"done":o?"streaming":"error"),o&&I(e),U(e,{shouldAnimate:!1}),D(e),n||o||void 0!==e.cart||M(e,!0),e}function et(){q();const t=Or(h.thread),e="home"===C();for(const n of h.thread)N(n,e&&n===t||h.round?.rec===n,{shouldAnimate:!1});!function(){const t=[...h.thread].sort((t,e)=>e.index-t.index);T().append(...t.map(t=>t.el))}(),R(!e),ct()}function nt(t,e){t.index=e,t.el.dataset.chapterIndex=String(e)}function ot(){return h.thread.filter(t=>void 0!==t.id&&4!==t.status&&h.round?.rec!==t&&"streaming"===t.el.dataset.state)}function rt(t=0){clearTimeout(h.refreshTimer);const{storyId:e}=h;if(!(void 0===e||h.isOff||t>0&&"restore"!==h.hydrateMode&&0===ot().length))if(t>=6)it({shouldFailPending:!0});else{try{F.send(Mt.GET_STORY,{storyId:e})}catch(t){ge.error("could not start the Callimacus client",t)}h.refreshTimer=setTimeout(()=>{rt(t+1)},3e3)}}function it({shouldFailPending:t=!1}={}){if(clearTimeout(h.refreshTimer),h.hydrateMode=void 0,t)for(const t of ot())G(t,"error")}const st=t=>x.dock?.querySelector(t)??void 0,at={input:st('input[name="q"]'),chips:st("[data-callimacus-dock-chips]"),count:st("[data-callimacus-thread-count]"),countLabel:st("[data-callimacus-thread-count-label]"),next:st("[data-callimacus-next]"),nextLabel:st("[data-callimacus-next-label]"),about:st("[data-callimacus-about]"),aboutLabel:st("[data-callimacus-about-label]")};function ct(){if(!at.count)return;const t=h.thread.length;at.count.hidden=0===t;const e=`${t} question${1===t?"":"s"}`;at.countLabel&&(at.countLabel.textContent=String(t)),at.count.title=e,at.count.setAttribute("aria-label",`${e} in this conversation. Show the conversation`)}function dt(){if(!at.next)return;const[t]=h.queue;if(at.next.hidden=void 0===t,void 0!==t){const e=h.queue.length>1?` (+${h.queue.length-1})`:"";at.nextLabel&&(at.nextLabel.textContent=`Next: ${t.display}${e}`),at.next.setAttribute("aria-label",`Next question: ${t.display}. Remove it from the queue`)}at.chips&&(at.chips.hidden=[...at.chips.children].every(t=>t instanceof HTMLElement&&!0===t.hidden))}function lt(){const t=h.about;at.about&&(at.about.hidden=void 0===t),void 0!==t&&at.aboutLabel&&(at.aboutLabel.textContent=`About: ${t}`),at.input&&(at.input.placeholder=void 0===t?at.input.dataset.placeholder??at.input.placeholder:"Ask anything about it")}function ut(){at.input&&(at.input.focus(),mt())}function ht(){R(!1);const t=Or(h.thread);t&&(N(t,!0),L(t))}function pt(){const t=document.querySelector("[data-callimacus-welcome]");t&&(t.hidden=!0)}function ft(t){const e=ke("section","cal-welcome__group");return e.append(ke("h2","cal-welcome__title",t)),e}function mt(){if(!r.designMode&&!h.isOff)try{F.connect()}catch(t){ge.error("could not start the Callimacus client",t)}}function gt(){return!h.isOff&&s.hasAttribute(vi)}function yt(t){const e=t.target instanceof Element?t.target.closest("[data-callimacus-form]"):void 0;if(!e||!gt())return;t.preventDefault();const n=e.querySelector('input[name="q"]'),o=n?.value.trim()??"";n&&""!==o?("refused"!==W(o,{type:"question",about:h.about})&&(n.value=""),u.matches&&n.blur()):n?.focus()}function bt(t){if(!(gt()&&t.target instanceof Element))return;const e=t.target.closest("[data-callimacus-ask]");if(e){const n=e.dataset.callimacusAsk?.trim()??"";return void(""!==n&&(t.preventDefault(),W(n,{type:"relatedQuestion"})))}t.target.closest("[data-callimacus-open]")&&(t.preventDefault(),ut())}function St(t){var e;gt()&&("/"!==t.key||t.metaKey||t.ctrlKey||t.altKey||(e=t.target)instanceof Element&&null!==e.closest('input, textarea, select, [contenteditable=""], [contenteditable="true"]')?"Escape"===t.key&&t.target instanceof HTMLElement&&t.target.matches('[data-callimacus-form] input[name="q"]')&&t.target.blur():(t.preventDefault(),ut()))}const At={ask:t=>"refused"!==W(t,{type:"question"}),get thread(){return[...h.thread].sort((t,e)=>t.index-e.index).map(t=>Z(t))},ctx:_,timings:p,get state(){return h.ui},get storyId(){return h.storyId},reset:function(){it(),clearTimeout(h.round?.timer),h.round=void 0,h.queue=[];for(const t of h.thread)t.el.remove();h.thread=[],k(void 0),Ur(ri),dt(),ct(),R(!1),v("idle"),w("")}};s.dataset.callimacusState=h.ui;const _t=globalThis;if(_t.callimacus=At,_t.callimacusTheme={card:e.card,cards:e.cards},void 0!==yo()||!s.hasAttribute(vi))return s.removeAttribute(vi),h.isOff=!0,v("error"),b("callimacus:ready",{designMode:r.designMode,off:!0}),{page:At,destroy:y};if(e.install?.(),function(t,e){Fr(t),document.addEventListener("visitorConsentCollected",()=>{Fr(t)},{signal:e})}(bi,c),h.storyId=ui(),document.addEventListener("submit",yt,{signal:c}),document.addEventListener("click",bt,{signal:c}),document.addEventListener("keydown",St,{signal:c}),document.addEventListener("focusin",t=>{t.target instanceof Element&&t.target.matches('[data-callimacus-form] input[name="q"]')&&mt()},{signal:c}),at.count?.addEventListener("click",ht,{signal:c}),at.next?.addEventListener("click",()=>{h.queue.shift(),dt(),w(i.dequeued,{clearAfter:yi}),at.input?.focus()},{signal:c}),x.dock?.querySelector("[data-callimacus-about-remove]")?.addEventListener("click",()=>{h.about=void 0,lt(),at.input?.focus()},{signal:c}),function(){const{dock:t}=x;if(!t||"function"!=typeof ResizeObserver)return;const e=new ResizeObserver(()=>{s.style.setProperty("--cal-dock-space",`${Math.ceil(t.offsetHeight)}px`)});e.observe(t),d.push(e)}(),globalThis.addEventListener("pagehide",()=>{(void 0!==h.round||ot().length>0)&&Q()},{signal:c}),globalThis.addEventListener("pageshow",t=>{t.persisted&&function(){const t=t=>t.id??`${t.index}:${t.sent}`,e=new Set(h.thread.map(e=>t(e))),n=mi().filter(n=>!e.has(t(n))),o=ui();if(void 0!==o&&o!==h.storyId&&(h.storyId=o),0!==n.length){for(const t of n)tt(t);pt(),et(),O()}}()},{signal:c}),lt(),ct(),dt(),r.designMode)return b("callimacus:ready",{designMode:!0,off:!1}),{page:At,destroy:y};r.product&&Gr("viewed",{handle:r.product.handle,title:r.product.title}),t.events&&(m=vr({transport:t.events,config:r,conversationId:()=>h.storyId,roundOf:t=>t.closest("[data-chapter-id]")?.dataset.chapterId??Or(h.thread)?.id}));const{stage:xt}=E();!function(){for(const t of mi())tt(t);return 0!==h.thread.length&&(et(),!0)}()?void 0!==h.storyId&&(h.hydrateMode="restore",rt()):ot().length>0&&(h.hydrateMode="refresh",rt()),"home"===C()&&function(){const t=document.querySelector("[data-callimacus-welcome]");if(!t)return;const n=Jr(),o=n.questions.slice(0,4),r=n.viewed.slice(0,4);t.querySelector(":scope > .cal-welcome__body")?.remove();const i=ke("div","cal-welcome__body");if(0===h.thread.length&&o.length>0){const t=ft("Pick up where you left off"),n=ke("div","cal-welcome__chips");for(const[t,{q:r}]of o.entries()){const o=ke("button",`cal-chip ${0===t?e.classes.buttonPrimary:e.classes.buttonSecondary}`,r);o.type="button",o.dataset.callimacusAsk=r,n.append(o)}t.append(n),i.append(t)}const s=0===h.thread.length&&r.length>0?e.cards(r.map(t=>({handle:t.handle,title:t.title})),_):void 0;if(s){const t=ft("Recently viewed"),e=ke("div","cal-welcome__cards");e.append(s),t.append(e),i.append(t)}t.hidden=0===i.childNodes.length,t.hidden||t.append(i)}();const Ct=Ie(xt.dataset.askOnLoad);return""!==Ct&&Or(h.thread)?.question!==Ct&&W(Ct,{type:"question"}),b("callimacus:ready",{designMode:!1,off:!1}),{page:At,destroy:y}}const _i="callimacus.pending";function xi(){return document.querySelector("#callimacus-config")??void 0}async function Ci(){Tt();const t=document.documentElement,e=function(){try{const t=JSON.parse(xi()?.textContent??"{}");return Ee(t)?t:{}}catch{return{}}}(),n=function(t){return{cards:"own"===t.cards?"own":"auto",proxyBase:""===Ie(t.proxyBase)?"/apps/callimacus":Ie(t.proxyBase),searchTerms:Ie(t.searchTerms),template:Ie(t.template),starters:Array.isArray(t.starters)?t.starters.map(t=>Ie(t)).filter(t=>""!==t):[],designMode:!0===t.designMode,assistantLabel:""===Ie(t.assistantLabel)?"Ask":Ie(t.assistantLabel)}}(e),o=globalThis.Shopify?.theme?.id,r="number"==typeof o||"string"==typeof o?String(o):"",i=_o(n.proxyBase,r),s=()=>void 0!==yo()||!t.hasAttribute(vi),a=s()?void 0:async function(){const t=Nr();if(void 0!==t?.customerPrivacy||"function"!=typeof t?.loadFeatures)return;const{loadFeatures:e}=t;await new Promise(t=>{const n=setTimeout(t,1e3),o=()=>{clearTimeout(n),t()};try{e([{name:"consent-tracking-api",version:"0.2"}],o)}catch(t){ge.warn("Shopify's privacy API did not load",t),o()}})}(),c=s()?void 0:await i.known(),d=c?.entrance&&{...c.entrance,starters:n.starters.length>0?n.starters:c.entrance.starters.slice(0,4)};let l;d&&0===n.starters.length&&d.starters.length>0&&function(t,e){const n=xi();n&&(n.textContent=JSON.stringify({...t,...e}))}(e,{starters:d.starters}),t.dataset.callimacusTemplate=n.template,s()||(l=await yr({page:"product"!==n.template||n.designMode?"other":"product",stored:c?.look,post:async t=>async function(t,e,n){const o=await fetch(`${t}/look?theme_id=${encodeURIComponent(e)}`,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify({tokens:n})});if(!o.ok)return void ge.warn(`the store did not keep the look (${o.status})`);const r=await o.json();if(!Ee(r))return;const i=wo(r.look);return i&&{stored:!0===r.stored,look:i}}(n.proxyBase,r,t),keep(t){i.keepLook(t)}}));const u=ho(n.assistantLabel),h=po({template:n.template,searchTerms:n.searchTerms,assistantLabel:n.assistantLabel,entrance:d}),p=ro(n.cards);await a;const{page:f}=Ai({kit:p,renderers:Bn(p),session:i,events:le(n.proxyBase)});Object.assign(f,{style:l,embed:{header:u,stage:h,...p.stats}});const m=be("sessionStorage",_i);we("sessionStorage",_i),void 0!==m&&""!==m.trim()&&f.ask(m)}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{Ci()},{once:!0}):Ci()}();
21
+ const vt="chapter-event",wt="story-created",kt="cart-command",St="error",At="server-response",_t="client-ready",xt="user-interaction",Ct={debug:0,info:1,warn:2,error:3,silent:4},Et=new class{config={enabled:!1,level:"info",prefix:"[Thamyr]"};debug=(...t)=>{this.log("debug",...t)};info=(...t)=>{this.log("info",...t)};warn=(...t)=>{this.log("warn",...t)};error=(...t)=>{this.log("error",...t)};log(t,...e){if(!(this.config.enabled&&Ct[t]>=Ct[this.config.level]))return;const{prefix:n}=this.config,o=void 0===n||""===n?e:[n,...e];console[t](...o)}configure(t){this.config={...this.config,...t}}getConfig(){return{...this.config}}};function Tt(){let t,e="";try{e=globalThis.location.search}catch{}try{t=localStorage}catch{}(function(t,e){if(new URLSearchParams(t).has("callimacus_debug"))return!0;try{return null!==(e?.getItem("callimacus:debug")??null)}catch{return!1}})(e,t)&&Et.configure({enabled:!0,level:"warn"})}function Rt(){const t="undefined"==typeof crypto?void 0:crypto;if("function"==typeof t?.randomUUID)return t.randomUUID();const e=new Uint8Array(16);if("function"==typeof t?.getRandomValues)t.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(256*Math.random());e[6]=15&e[6]|64,e[8]=63&e[8]|128;const n=[...e].map(t=>t.toString(16).padStart(2,"0"));return[n.slice(0,4).join(""),n.slice(4,6).join(""),n.slice(6,8).join(""),n.slice(8,10).join(""),n.slice(10,16).join("")].join("-")}const Ot="Callimacus is AI.",qt="Learn more",$t="https://callimacus.ai",It="draft-2026-11-16",Nt=Symbol.for("callimacus.pageViewRecorders");function Lt(){const t=globalThis,e=t.callimacusPageView;return"object"==typeof e&&null!==e&&"string"==typeof e.id||(t[Nt]??0)>0}var Mt,Bt;!function(t){t.GET_STORY="get-story",t.CREATE_ROUND="create-round",t.RESET_STORY="reset-story",t.BACK_FROM_ROUND="back-from-round",t.SHARE_STORY="share-story",t.GET_SHARED_STORY="get-shared-story",t.SUGGEST="suggest"}(Mt||(Mt={})),function(t){t.ROUND_CREATED="round-created",t.ROUND_EVENT="round-event",t.ROUND_COMPLETED="round-completed",t.ERROR="error"}(Bt||(Bt={}));const jt={productSelector:"[data-product-id]",blockSelector:"[data-block-id]",maxTrackedElements:40,minVisibilityRatio:.5};class Ut{elements=new Map;elementRefs=new Map;elementKeys=new WeakMap;blocks=new Map;blockRefs=new Map;blockKeys=new WeakMap;started=!1;config;constructor(t={}){const e=t.minVisibilityRatio??jt.minVisibilityRatio;this.config={productSelector:t.productSelector??jt.productSelector,blockSelector:t.blockSelector??jt.blockSelector,maxTrackedElements:t.maxTrackedElements??jt.maxTrackedElements,minVisibilityRatio:Math.min(1,Math.max(0,e))}}rescanUi(){if(!this.canUseDom())return;let t,e;try{t=document.querySelectorAll(this.config.productSelector),e=document.querySelectorAll(this.config.blockSelector)}catch(t){return void Et.warn("UI Observer: invalid selector, skipping rescan:",t)}const n=Date.now();for(const e of t){const t=this.normalizeRect(e.getBoundingClientRect()),o=this.calculateVisibilityRatio(t);this.syncTrackedElement(e,{bounds:t,isVisible:o>=this.config.minVisibilityRatio,visibilityRatio:o,observedAt:n})}for(const t of e){const e=this.normalizeRect(t.getBoundingClientRect()),o=this.calculateVisibilityRatio(e);this.syncTrackedBlock(t,{bounds:e,isVisible:o>=this.config.minVisibilityRatio,visibilityRatio:o,observedAt:n})}this.pruneTrackedElements(),this.pruneTrackedBlocks()}pruneTrackedElements(){if(this.elements.size<=this.config.maxTrackedElements)return;const t=[...this.elements].sort(([,t],[,e])=>{const n=t.visibilityRatio-e.visibilityRatio;return 0===n||Number.isNaN(n)?t.observedAt-e.observedAt:n}).slice(0,this.elements.size-this.config.maxTrackedElements);for(const[e]of t)this.elements.delete(e),this.elementRefs.delete(e)}pruneTrackedBlocks(){if(this.blocks.size<=this.config.maxTrackedElements)return;const t=[...this.blocks].sort(([,t],[,e])=>{const n=t.visibilityRatio-e.visibilityRatio;return 0===n||Number.isNaN(n)?t.observedAt-e.observedAt:n}).slice(0,this.blocks.size-this.config.maxTrackedElements);for(const[e]of t)this.blocks.delete(e),this.blockRefs.delete(e)}syncTrackedElement(t,e){const n=this.resolveElementId(t),o=this.resolveBlockId(t),r=this.createTrackingKey(n,o),i=this.elementKeys.get(t);void 0!==i&&""!==i&&i!==r&&(this.elements.delete(i),this.elementRefs.delete(i)),this.elementKeys.set(t,r),this.elementRefs.set(r,t),this.elements.set(r,{id:n,blockId:o,trackingKey:r,...e})}syncTrackedBlock(t,e){const n=this.resolveTrackedBlockId(t),o=this.blockKeys.get(t),r=n;void 0!==o&&""!==o&&o!==r&&(this.blocks.delete(o),this.blockRefs.delete(o)),this.blockKeys.set(t,r),this.blockRefs.set(r,t),this.blocks.set(r,{id:n,...e})}resolveElementId(t){return[t.dataset.productId,t.dataset.productid,t.dataset.sku,t.id].find(t=>void 0!==t&&""!==t)??`${t.tagName}-${t.dataset.productId??this.elements.size}`}resolveBlockId(t){let e;try{e=t.closest(this.config.blockSelector)??void 0}catch{return}return e instanceof HTMLElement?this.resolveTrackedBlockId(e):void 0}resolveTrackedBlockId(t){return[t.dataset.blockId,t.dataset.blockid,t.id].find(t=>void 0!==t&&""!==t)??`${t.tagName}-${t.dataset.blockId??this.blocks.size}`}createTrackingKey(t,e){return void 0===e||""===e?t:`${t}::${e}`}normalizeRect(t){return{x:t.x,y:t.y,width:t.width,height:t.height,top:t.top,left:t.left,right:t.right,bottom:t.bottom}}calculateVisibilityRatio(t){const e=Math.max(0,Math.min(t.right,window.innerWidth)-Math.max(t.left,0))*Math.max(0,Math.min(t.bottom,window.innerHeight)-Math.max(t.top,0)),n=t.width*t.height;if(n<=0)return 0;const o=window.innerWidth*window.innerHeight,r=o>0?Math.min(n,o):n;return Math.min(1,Math.max(0,e/r))}canUseDom(){return void 0!==globalThis.window&&"undefined"!=typeof document}start(){!this.started&&this.canUseDom()&&(this.started=!0)}stop(){this.started&&(this.started=!1,this.elements.clear(),this.elementRefs.clear(),this.blocks.clear(),this.blockRefs.clear())}getSnapshot(){if(!this.canUseDom())return;this.rescanUi();const t=[],e=[],n=Date.now();for(const[e,n]of this.elements){const o=this.elementRefs.get(e);o?.isConnected?n.visibilityRatio<=0||t.push({blockId:n.blockId,element:{id:n.id,bounds:n.bounds,isVisible:n.visibilityRatio>=this.config.minVisibilityRatio,visibilityRatio:n.visibilityRatio}}):(this.elements.delete(e),this.elementRefs.delete(e))}for(const[t,n]of this.blocks){const o=this.blockRefs.get(t);o?.isConnected?n.visibilityRatio<this.config.minVisibilityRatio||e.push(n.id):(this.blocks.delete(t),this.blockRefs.delete(t))}const o=t.slice(0,this.config.maxTrackedElements);return{timestamp:n,viewport:{width:window.innerWidth,height:window.innerHeight},blockIds:[...new Set([...e,...o.flatMap(t=>t.blockId??[])])],elements:o.map(t=>t.element)}}}function Ft(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}const Dt=t=>"string"==typeof t&&t.length>0,Pt=t=>Ft(t)&&Dt(t.size)&&Dt(t.variantId)&&"boolean"==typeof t.orderable;class Wt{socket;serverResponseListeners=new Set;connectionStatusListeners=new Set;errorListeners=new Set;warningListeners=new Set;reportedWarnings=new Set;uiObserver;uiObserverConfig=jt;handshakeRetryAttempts=0;handshakeRetryTimer;setupEventListeners(){this.socket&&(this.socket.on("connect",()=>{Et.debug("Connected to Callimacus"),this.clearHandshakeRetry(),this.handshakeRetryAttempts=0,this.updateConnectionStatus(!0),this.socket?.emit(_t)}),this.socket.on("disconnect",()=>{Et.info("Disconnected from Callimacus"),this.updateConnectionStatus(!1)}),this.socket.on("connect_error",t=>{this.updateConnectionStatus(!1);const e=function(t,e){return e?void 0:function(t){const{data:e}=t;if("object"!=typeof e||null===e)return;const{code:n,reason:o}=e;return"number"==typeof n?{code:n,..."string"==typeof o&&{reason:o}}:void 0}(t)??{code:0}}(t,this.socket?.active??!0);e&&(Et.error("Connection refused by Callimacus:",t.message,e.reason??""),this.notifyRejection(e,t.message),this.scheduleHandshakeRetry(e.code))}),this.socket.on(St,t=>{Et.error("Received error from Callimacus:",t),this.notifyErrorListeners(t)}),this.socket.io.on("reconnect",t=>{Et.info(`Reconnected to Callimacus after ${t} attempts`)}),this.socket.io.on("reconnect_attempt",t=>{Et.info(`Attempting to reconnect: attempt ${t}`)}),this.socket.io.on("reconnect_error",t=>{Et.error("Reconnection error:",t)}),this.socket.io.on("reconnect_failed",()=>{Et.error("Failed to reconnect to Callimacus service!"),this.updateConnectionStatus(!1)}),this.socket.on(At,t=>{"chapter-event"===t.type&&this.notifyWarningListeners(function(t,e){return(t.warnings??[]).filter(n=>{const o=`${t.id}:${n.block}:${n.content}`;return!e.has(o)&&(e.add(o),!0)})}(t.chapter,this.reportedWarnings)),this.notifyServerResponseListeners(t)}))}notifyServerResponseListeners(t){this.serverResponseListeners.forEach(e=>{try{e(t)}catch(t){Et.error("Error in server response listener:",t)}})}updateConnectionStatus(t){this.connectionStatusListeners.forEach(e=>{try{e(t)}catch(t){Et.error("Error in connection status listener:",t)}})}notifyRejection(t,e){this.notifyErrorListeners({code:t.code,message:e,...void 0!==t.reason&&{reason:t.reason}})}scheduleHandshakeRetry(t){if(!this.socket)return;if(this.clearHandshakeRetry(),!function(t,e){return t>=500&&e<3}(t,this.handshakeRetryAttempts))return void(t>=500&&(Et.error("Giving up on the Callimacus connection after 3 retries"),this.notifyRejection({code:t,reason:"retries_exhausted"},"Connection failed after 3 retries; call connect() to try again")));const e=2**(this.handshakeRetryAttempts+1);this.handshakeRetryAttempts+=1,Et.info(`Retrying Callimacus connection in ${e}s (attempt ${this.handshakeRetryAttempts}/3)`),this.handshakeRetryTimer=setTimeout(()=>{this.socket?.connect()},1e3*e)}clearHandshakeRetry(){void 0!==this.handshakeRetryTimer&&(clearTimeout(this.handshakeRetryTimer),this.handshakeRetryTimer=void 0)}notifyErrorListeners(t){this.errorListeners.forEach(e=>{try{e(t)}catch(t){Et.error("Error in error listener:",t)}})}notifyWarningListeners(t){for(const e of t)0===this.warningListeners.size&&Et.warn(`Block "${e.block}" was not shown: its content "${e.content}" failed (${e.cause}). \`callimacus thamyr probe\` shows why.`),this.warningListeners.forEach(t=>{try{t(e)}catch(t){Et.error("Error in warning listener:",t)}})}async getLocation(){if("undefined"!=typeof navigator&&"function"==typeof navigator.geolocation?.getCurrentPosition)return new Promise(t=>{navigator.geolocation.getCurrentPosition(e=>{t(e)},()=>{t(void 0)})})}enrichPayloadWithUiContext(t){try{this.ensureUiObserver();const e=this.uiObserver?.getSnapshot();return e?{...t,context:{...t.context,uiSnapshot:e}}:t}catch(e){return Et.error("Error enriching payload with UI context:",e),t}}ensureUiObserver(){"undefined"!=typeof window&&"undefined"!=typeof document&&this.uiObserverConfig.enabled&&(this.uiObserver??=new Ut(this.uiObserverConfig),this.uiObserver.start())}socketEndpoint(t){const e=new URL(t),n=new URL("thamyr",e).pathname;return{origin:e.origin,path:n}}connect(t="wss://localhost:4000",e,n){this.socket&&(Et.warn("Already connected to Thamyr. Disconnecting first...."),this.disconnect());const o=this.socketEndpoint(t);let r;"undefined"!=typeof window&&void 0!==globalThis.location&&(r=globalThis.location.href);const i="undefined"==typeof document?void 0:function(t){const e=t.split("; ").find(t=>t.startsWith("intent_sid="))?.slice(11);return void 0===e||""===e?void 0:e}(document.cookie),s={...void 0!==r&&""!==r&&{referrer:r},...void 0!==i&&{intentSid:i},...n};Et.info("Connecting to Thamyr at",o),this.socket=bt(o.origin,{path:o.path,transports:["websocket","polling"],tryAllTransports:!0,extraHeaders:e,auth(t){t({...s,...Lt()&&{recordsPageViews:!0}})}}),this.setupEventListeners(),this.ensureUiObserver()}disconnect(){this.clearHandshakeRetry(),this.handshakeRetryAttempts=0,this.socket&&(this.socket.disconnect(),this.socket=void 0,this.uiObserver?.stop(),this.uiObserver=void 0,this.updateConnectionStatus(!1),Et.info("Disconnected from Callimacus"))}configureUiObserver(t){if(!t)return this.uiObserver?.stop(),this.uiObserver=void 0,void(this.uiObserverConfig={...jt,enabled:!1});const e=t.enabled??(void 0!==t.productSelector||void 0!==t.blockSelector||void 0!==t.maxTrackedElements||void 0!==t.minVisibilityRatio||this.uiObserverConfig.enabled);if(this.uiObserverConfig={...this.uiObserverConfig,...t,enabled:e},"undefined"==typeof window||"undefined"==typeof document||!this.uiObserverConfig.enabled)return this.uiObserver?.stop(),void(this.uiObserver=void 0);this.uiObserver&&this.uiObserver.stop(),this.uiObserver=new Ut(this.uiObserverConfig),this.uiObserver.start()}sendUserInteraction(t,e){if(!this.socket)return void Et.error("Socket is not connected. Cannot send interaction.");if(t===Mt.SUGGEST)return void Et.error("SUGGEST is a request/response command. Use suggest() instead.");if(t===Mt.BACK_FROM_ROUND&&void 0===e.chapterId)return void Et.error("BACK_FROM_ROUND requires chapterId.");const n={type:t,payload:this.enrichPayloadWithUiContext(e)},o={id:Rt()};this.socket.emit(xt,{type:n.type,payload:n.payload},o.id)}async suggest(t,e={}){if(!this.socket?.connected)return{suggestions:[]};try{return function(t){const e=t?.suggestions;return{suggestions:Array.isArray(e)?e.filter(t=>"string"==typeof t):[]}}(await this.socket.timeout(e.timeoutMs??4e3).emitWithAck(xt,{type:Mt.SUGGEST,payload:t}))}catch(t){return Et.warn("Suggestions failed or timed out; serving none.",t),{suggestions:[]}}}async gatherClientInfo(){const t="undefined"==typeof navigator?void 0:navigator,e="undefined"==typeof window?void 0:window.screen;return{userAgent:t?.userAgent??"",language:t?.language??"",timezone:(new Intl.DateTimeFormat).resolvedOptions().timeZone,localTime:(new Date).toLocaleString(),screenResolution:void 0===e?"":`${e.width}x${e.height}`,location:await this.getLocation()}}onServerResponse(t){return this.serverResponseListeners.add(t),()=>{this.serverResponseListeners.delete(t)}}onConnectionStatus(t){return this.connectionStatusListeners.add(t),()=>{this.connectionStatusListeners.delete(t)}}onError(t){return this.errorListeners.add(t),()=>{this.errorListeners.delete(t)}}onWarning(t){return this.warningListeners.add(t),()=>{this.warningListeners.delete(t)}}}const zt=10,Vt=/^[A-Za-z]\w{0,39}$/u,Ht=/^[\w\-./:]{1,128}$/u,Kt=new Set(["page_viewed","item_opened","added_to_cart","custom_event","conversation_started","question_asked","answer_delivered"]);const Jt=/^[\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/u,Yt=t=>void 0!==t&&Jt.test(t),Gt="function"==typeof TextEncoder?new TextEncoder:void 0,Xt=new WeakMap;function Zt(t){let e=Xt.get(t);if(void 0===e){const n=JSON.stringify(t);e=void 0===Gt?3*n.length:Gt.encode(n).length,Xt.set(t,e)}return e}function Qt(t){const e=[];let n=[],o=0;for(const r of t){const t=Zt(r);(50===n.length||n.length>0&&o+t>57344)&&(e.push(n),n=[],o=0),n.push(r),o+=t}return n.length>0&&e.push(n),e}function te(t){const{transport:e,declares:n}=t,o=t.delayMs??3e3;let r,i,s,a,c=[],d=!1,l=0,u=!1;const h=new Set(n.types),p=(t,e)=>({sentAt:(new Date).toISOString(),events:t,declares:{types:[...h],addsCarryRoundId:n.addsCarryRoundId},...e>0&&{dropped:e}});function f(){clearTimeout(s),clearTimeout(a),s=void 0,a=void 0}function m(){void 0!==s||void 0!==a||u||(s=setTimeout(()=>{s=void 0,g()},o))}async function g(){if(d||u)return;f(),r??=function(){const[t]=Qt(c);if(void 0===t)return;c=c.slice(t.length);const e=l;return l=0,{events:t,dropped:e,attempts:0}}();const t=r;if(void 0===t)return;let n;d=!0;try{n=await e.send(p(t.events,t.dropped))}catch{n="retry"}if(d=!1,r!==t||u)return void(c.length>0&&m());const o="object"==typeof n?n.retryAfterMs:void 0;if(("retry"===n||void 0!==o)&&t.attempts<3)return t.attempts+=1,void(a=setTimeout(()=>{a=void 0,g()},o??2e3*2**(t.attempts-1)));r=void 0,"accepted"!==n&&(l+=t.dropped+t.events.length),c.length>0&&m()}function y(t,e){t.catch(()=>!1).then(t=>{t||(l+=e)})}function b(){if(u)return;f();const t=void 0===r||d?void 0:r,n=[...r?.events??[],...c];let o=l+(t?.dropped??0);c=[],r=void 0,l=0;const i=Qt(n);0===i.length&&o>0&&i.push([]);for(const t of i){const n=t.length+o;let r=!1;try{r=e.sendOnHide(p(t,o))}catch{}!1===r?l+=n:!0!==r&&y(r,n),o=0}}const v=()=>{b()},w=()=>{"undefined"!=typeof document&&"hidden"===document.visibilityState&&b()};return"function"==typeof globalThis.addEventListener&&globalThis.addEventListener("pagehide",v),"undefined"!=typeof document&&"function"==typeof document.addEventListener&&document.addEventListener("visibilitychange",w),{record(e,n,o={}){const s=Date.now(),a=function(t=Date.now()){const e=new Uint8Array(16),n="undefined"==typeof crypto?void 0:crypto;if("function"==typeof n?.getRandomValues)n.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(256*Math.random());let o=t;for(let t=5;t>=0;t--)e[t]=o%256,o=Math.floor(o/256);e[6]=15&e[6]|112,e[8]=63&e[8]|128;const r=[...e].map(t=>t.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}(s),d="page_viewed"===e?void 0:t.conversationId?.(),p={eventId:a,type:e,typeVersion:1,clientCreatedAt:new Date(s).toISOString(),...void 0!==i&&"page_viewed"!==e&&{pageViewId:i},...Yt(o.roundId)&&{roundId:o.roundId},...Yt(d)&&{conversationId:d},payload:n};return"page_viewed"===e&&(i=a),u?a:c.length+(r?.events.length??0)>=100||Zt(p)>57344||"custom_event"===e&&!function(t){if(!Vt.test(t.name)||Kt.has(t.name.toLowerCase()))return!1;const e=Object.entries(t.fields??{});return e.length<=zt&&e.every(([t,e])=>Vt.test(t)&&(t=>"boolean"==typeof t||"number"==typeof t&&Number.isFinite(t)||"string"==typeof t&&Ht.test(t))(e))}(n)?(l+=1,a):(h.add(e),c.push(p),m(),a)},get pageViewId(){return i},adoptPageView(t){i=t},flush:g,stop(){u=!0,f(),"function"==typeof globalThis.removeEventListener&&globalThis.removeEventListener("pagehide",v),"undefined"!=typeof document&&"function"==typeof document.removeEventListener&&document.removeEventListener("visibilitychange",w)}}}const ee=Symbol.for("callimacus.eventMarkupRuntimes"),ne=(t,e)=>{const n=t?.getAttribute(e)?.trim();return void 0===n||""===n?void 0:n};function oe(){const t=globalThis;return t[ee]??={runtimes:[]},t[ee]}const re=t=>"object"==typeof t&&null!==t&&!Array.isArray(t),ie=t=>String(t).split("/").pop()??"";function se(t,e,n=0){if(!(null===t||"object"!=typeof t||n>6)){if(function(t){if(!re(t)||!re(t.fields))return!1;const e=t.fields["shopify-handle"];return"string"==typeof e&&""!==e}(t)){const n=t.fields.variantTree?.variants??[];if(Array.isArray(n)&&n.some(t=>ie(t?.id??"")===e))return"string"==typeof t.id&&""!==t.id?t.id:t.fields["shopify-handle"]}for(const o of Object.values(t)){const t=se(o,e,n+1);if(void 0!==t)return t}}}function ae(t,e,n,o){const r=ie(t),i=n.itemId??se(o,r);return void 0===i||""===i?void 0:{itemId:i,variantId:`gid://shopify/ProductVariant/${r}`,quantity:e,origin:n.origin??"card"}}function ce(t){const e=t?.trim()??"",n=""===e?NaN:Number(e),o=Number.isFinite(n)?1e3*n:Date.parse(e)-Date.now();return Number.isFinite(o)?Math.min(Math.max(o,0),6e5):6e4}async function de(t,e,n){const o=void 0===n||"function"!=typeof AbortController?void 0:new AbortController,r=void 0===o?void 0:setTimeout(()=>{o.abort()},n);try{const n=await fetch(t,{...e,...void 0!==o&&{signal:o.signal}}),r=429===n.status?n.headers.get("retry-after"):void 0;return function(t,e){return t>=200&&t<300?"accepted":429===t?{retryAfterMs:ce(e)}:t>=500?"retry":"refused"}(n.status,r??void 0)}catch{return"retry"}finally{clearTimeout(r)}}function le(t){const e=`${t.endsWith("/")?t.slice(0,-1):t}/events`,n=t=>({method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t),credentials:"same-origin"});return{send:async t=>de(e,n(t),1e4),sendOnHide:async t=>async function(t,e){return"accepted"===await de(t,{...e,keepalive:!0})}(e,n(t))}}const ue="callimacus:shopify-cart-commands",he=new Set(["cart_disabled","cart_unavailable"]);function pe(t,e){const{item:n,quantity:o}=t,r=`${o>1?`${o} × `:""}${n.name}${n.options.length>0?` (${n.options.map(t=>t.value).join(", ")})`:""}`;return void 0===e.error?{...t,outcome:"added",message:e.warnings?.[0]?.message??`${r} is in your bag.`}:"refused"===e.error.code?{...t,outcome:"refused",message:e.error.message}:he.has(e.error.code)?{...t,outcome:"unavailable",message:"The bag is not available on this site right now."}:{...t,outcome:"failed",message:e.error.message}}const fe=/^gid:\/\/shopify\/ProductVariant\/\d+$/v,me="[callimacus]",ge={debug(...t){console.debug(me,...t)},info(...t){console.info(me,...t)},warn(...t){console.warn(me,...t)},error(...t){console.error(me,...t)}};function ye(t){try{return globalThis[t]}catch{return}}function be(t,e){try{return ye(t)?.getItem(e)??void 0}catch{return}}function ve(t,e,n){try{const o=ye(t);return!!o&&(o.setItem(e,n),!0)}catch(n){return ge.warn(`could not write ${t} "${e}"`,n),!1}}function we(t,e){try{ye(t)?.removeItem(e)}catch(n){ge.warn(`could not clear ${t} "${e}"`,n)}}function ke(t,e="",n){const o=document.createElement(t);return""!==e&&(o.className=e),void 0!==n&&(o.textContent=n),o}function Se(t,e=""){const n=ke("p",`cal-cart-notice ${e}`.trim(),t.message);return n.setAttribute("role","status"),n.dataset.outcome=t.outcome,n}const Ae="http://www.w3.org/2000/svg";function _e(t,e,n){const o=document.createElementNS(Ae,"svg");o.setAttribute("class",n),o.setAttribute("viewBox",t),o.setAttribute("aria-hidden","true"),o.setAttribute("focusable","false");const r=document.createElementNS(Ae,"path");return r.setAttribute("d",e),r.setAttribute("fill","currentColor"),r.setAttribute("fill-rule","evenodd"),r.setAttribute("clip-rule","evenodd"),o.append(r),o}function xe(t,e){for(const n of e.split(/\n{2,}/u)){const e=ke("p");for(const[t,o]of n.split("**").entries())""!==o&&e.append(t%2==1?ke("strong","",o):document.createTextNode(o));e.childNodes.length>0&&t.append(e)}}function Ce(t){for(let e=t;e&&e!==document.body;e=e.parentElement??void 0){const{position:t}=getComputedStyle(e);if("fixed"===t||"sticky"===t)return e}}function Ee(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Te(t){if(!Ee(t)||!Ee(t.fields))return!1;const e=t.fields["shopify-handle"];return"string"==typeof e&&""!==e}function Re(t){return"string"==typeof t.kind&&""!==t.kind?t.kind:"product"}const Oe=/^\s*\{\s*"error"\s*:/u;function qe(t){return"string"==typeof t&&""!==t.trim()&&!Oe.test(t)}function $e(...t){for(const e of t)if(qe(e))return e.trim();return""}function Ie(t){return"string"==typeof t?t.trim():""}function Ne(t){return null!==t.closest("[data-callimacus-ui], .cal-dock, .cal-stage, .cal-toast")}function Le(t){const e=new Set,n=[];for(const o of t){if(!Te(o))continue;const t=Re(o),r=`${t}:${o.fields["shopify-handle"]}`,i=(o.fields.title??"").trim().toLowerCase(),s=`${t}|${i}`;e.has(r)||""!==i&&e.has(s)||(e.add(r),""!==i&&e.add(s),n.push(o))}return n}function Me(t,e){const n=t.trim();if(n.length<=e)return n;const o=n.slice(0,e-1),r=o.lastIndexOf(" ");return`${(r>e/2?o.slice(0,r):o).trimEnd()}…`}function Be(t){return Ee(t)&&Ee(t.meta)&&Array.isArray(t.sections)}function je(t){const e=(t.sections??[]).filter(t=>Ee(t)&&"text"===t.type&&qe(t.content)).flatMap(t=>String(t.content).split(/\n{2,}/u)).map(t=>t.trim()).filter(t=>qe(t)),n=[];let o=600;for(const t of e){if(t.length>o){0===n.length&&n.push(Me(t,o));break}n.push(t),o-=t.length}return n}function Ue(t){const e=t?.data;return Ee(e)?Object.values(e):[]}function Fe(t){return Ue(t).some(t=>function(t){return null!=t&&("string"==typeof t?qe(t):Array.isArray(t)?t.length>0:"object"!=typeof t||Object.keys(t).length>0)}(t))}function De(t){if(Array.isArray(t))return t.map(t=>De(t));if(Be(t)){const e=t.meta??{};return{id:t.id,name:t.name,meta:{url:e.url,title:e.title,shopifyKind:e.shopifyKind},sections:je(t).map(t=>({type:"text",content:t}))}}if(Te(t)&&"product"!==Re(t)){const{fields:e}=t;return{id:t.id,kind:t.kind,fields:{title:e.title,"shopify-handle":e["shopify-handle"],"shopify-blogHandle":e["shopify-blogHandle"],"shopify-publishedAt":e["shopify-publishedAt"],"shopify-author":e["shopify-author"],"shopify-productsCount":e["shopify-productsCount"],descriptionText:qe(e.descriptionText)?Me(e.descriptionText,240):void 0,images:(e.images??[]).slice(0,2).map(t=>({url:t?.url,alt:t?.alt}))}}}if(Te(t)){const{fields:e}=t;return{id:t.id,kind:t.kind,fields:{title:e.title,"shopify-handle":e["shopify-handle"],"shopify-vendor":e["shopify-vendor"],"shopify-productType":e["shopify-productType"],price:e.price,availableSizes:e.availableSizes,images:(e.images??[]).slice(0,2).map(t=>({url:t?.url,alt:t?.alt})),variantTree:{variants:(e.variantTree?.variants??[]).map(t=>({id:t?.id,axes:t?.axes,price:t?.price,orderable:t?.orderable}))}}}}return Ee(t)?Object.fromEntries(Object.entries(t).map(([t,e])=>[t,De(e)])):t}const Pe=["aria-labelledby","aria-describedby","aria-controls","for","form"];function We(t){const e=t.fields.variantTree?.variants;return Array.isArray(e)?e:[]}function ze(t){const e=We(t);return e.length>0&&e.every(t=>!0!==t?.orderable)}function Ve(t){const e=globalThis.Shopify,n=$e(t.settings.rootUrl,e?.routes?.root,"/");return n.endsWith("/")?n:`${n}/`}async function He(t){return new Promise(e=>{setTimeout(e,t)})}function Ke(t){return void 0===t.hit?.id||""===t.hit.id?t.handle:t.hit.id}function Je(t,e,n){const{hit:o}=t,r=ke("span");if(We(o).length>1||Array.isArray(o.fields.availableSizes)&&o.fields.availableSizes.length>1){const t=ke("a",n.className);return t.href=e.url(o),r.textContent=n.labels.choose,t.append(r),t}const i=ke("button",n.className);i.type="button",i.setAttribute("aria-live","polite"),i.append(r),n.busy&&i.append(n.busy);const s=e.variantId(o);if(""===s)return r.textContent=n.labels.soldOut,i.disabled=!0,i;r.textContent=n.labels.add;return i.addEventListener("click",()=>{(async()=>{if("true"!==i.getAttribute("aria-disabled")){i.setAttribute("aria-disabled","true"),i.classList.add("loading"),n.busy?.classList.remove("hidden");try{await e.addToCart(s,1,{productId:Ke(t)}),e.remember?.("added",t.handle),r.textContent=n.labels.added,await He(2e3),r.textContent=n.labels.add}catch(t){r.textContent=t instanceof Error&&""!==t.message?t.message:n.labels.failed}finally{i.classList.remove("loading"),n.busy?.classList.add("hidden"),i.removeAttribute("aria-disabled")}}})()}),i}function Ye(t){if("string"==typeof t){const e=t.trim();return""===e?void 0:{handle:e,hit:void 0,title:""}}return Te(t)?"product"===Re(t)?{handle:t.fields["shopify-handle"],hit:t,title:Ie(t.fields.title)}:void 0:Ee(t)&&""!==Ie(t.handle)?{handle:Ie(t.handle),hit:void 0,title:Ie(t.title)}:void 0}function Ge(t,e){const n=new Map,o=new Map,r=new Map,i=new Map,s=[];let a,c,d=0;function l(){for(;d<6&&s.length>0;)d+=1,s.shift()?.()}async function u(r,i){const{handle:a}=r,c=n.get(a);if(c)return c;const u="string"==typeof t?`${Ve(i)}products/${encodeURIComponent(a)}?section_id=${t}`:t(r,Ve(i)),h=async function(t){return new Promise((e,n)=>{s.push(()=>{t().then(e).catch(n).finally(()=>{d-=1,l()})}),l()})}(async()=>fetch(u,{headers:{Accept:"text/html"}})).then(async t=>t.ok?t.text():void 0).then(t=>void 0===t?void 0:e.extract(t,r)).catch(()=>{}).then(t=>(o.set(a,t),t));return n.set(a,h),h}function h(t,n,o){const i=t.content.firstElementChild;if(!i)throw new Error("empty card template");const s=document.importNode(i,!0);if(void 0!==o.sizes)for(const t of s.querySelectorAll("img[srcset]"))t.sizes=o.sizes;const a=(r.get(n)??0)+1;return r.set(n,a),e.prepare?.(s),a>1&&function(t,e){const n=new Map;for(const o of t.querySelectorAll("[id]"))n.set(o.id,o.id+e),o.id+=e;for(const e of t.querySelectorAll(Pe.map(t=>`[${t}]`).join(",")))for(const t of Pe){const o=e.getAttribute(t);null!==o&&""!==o&&e.setAttribute(t,o.split(/\s+/u).map(t=>n.get(t)??t).join(" "))}}(s,`-${a}`),s}function p(t,n,o){t.classList.remove("cal-card--pending"),t.classList.add("cal-card--offline"),o.hit||e.offline(n,o)}return{card:function(t,n,r={}){const s=Ye(t);if(!s)return;a=n,s.hit&&function(t,e){for(const n of We(t)){const t=String(n?.id??"").split("/").pop()??"";""!==t&&i.set(t,e)}}(s.hit,s.handle);const d=ke("div","cal-card");d.dataset.handle=s.handle;const l={handle:s.handle,ctx:n,productId:Ke(s)};d.addEventListener("click",()=>{c={...l,at:Date.now()}},{capture:!0});const f=o.get(s.handle);if(f)return d.append(h(f,s.handle,r)),d;const m=s.hit?e.placeholder({...s,hit:s.hit},n,r):e.skeleton(s,n,r);return d.append(m),o.has(s.handle)?(p(d,m,s),d):(d.classList.add("cal-card--pending"),u(s,n).then(async t=>{t?await async function({host:t,draft:e},n,o,r){const i=h(n,o,r),s=e.querySelector("img"),a=i.querySelector("img");a&&s?.complete&&s.naturalWidth>0&&(a.loading="eager",await Promise.race([a.decode().catch(()=>{}),He(800)])),e.replaceWith(i),t.classList.remove("cal-card--pending")}({host:d,draft:m},t,s.handle,r):p(d,m,s)}),d)},rememberAdded:function(t,e=1){const n="string"==typeof t||"number"==typeof t?String(t).split("/").pop()??"":"",o=i.get(n);void 0!==o&&(a?.remember?.("added",o),c?.handle!==o||Date.now()-c.at>6e4||(c.ctx.productAdded?.(n,e,{productId:c.productId}),c=void 0))}}}const Xe=globalThis;function Ze(){return"undefined"==typeof PUB_SUB_EVENTS?void 0:PUB_SUB_EVENTS}const Qe={Accept:"application/javascript","X-Requested-With":"XMLHttpRequest"};class tn extends Error{code;constructor(t,e,n){super(e,n),this.name="CartAddError",this.code=t}}async function en(t){try{return await t(),{}}catch(t){const e=t instanceof Error&&""!==t.message?t.message:"Could not add to cart.";return{error:{code:t instanceof tn?t.code:"failed",message:e}}}}async function nn(t,e){let n;try{n=await fetch(`${t.cartAddUrl}.js`,{method:"POST",...e})}catch(t){throw new tn("failed","Could not reach the cart. Check your connection and try again.",{cause:t})}const o=await n.json().catch(()=>{}),r=Ee(o)?o:{},i=$e(r.description,r.message,"Could not add to cart.");return!Boolean(r.status)&&n.ok?{json:r,failure:void 0===o?new tn("cart_unavailable",i):void 0}:{json:r,failure:new tn(on("number"==typeof r.status?r.status:n.status),i)}}function on(t){return 422===t?"refused":404===t?"cart_unavailable":"failed"}const rn="cart:update";function sn(t,e){document.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:e}))}async function an(t,e,n){const o=new FormData;o.append("id",t),o.append("quantity",String(e));const r=[...document.querySelectorAll("cart-items-component[data-section-id]")].map(t=>t.dataset.sectionId??"").filter(t=>""!==t);r.length>0&&o.append("sections",r.join(","));const{json:i,failure:s}=await nn(n,{headers:Qe,body:o});if(s)throw sn("cart:error",{sourceId:"callimacus",data:{message:i.message,errors:i.errors,description:i.description}}),s;const a=await async function(t){try{const e=await fetch(`${Ve({settings:t})}cart.js`,{headers:{accept:"application/json"}}),n=await e.json();return Ee(n)?n:void 0}catch{return}}(n),c="number"==typeof a?.item_count?a.item_count:void 0;return sn(rn,{resource:a,sourceId:"callimacus",data:{source:void 0===c?"product-form-component":"callimacus",itemCount:c??e,variantId:t,sections:Ee(i.sections)?i.sections:void 0}}),i}const cn=/^[*\-•]\s+(?<text>\S.*)$/u,dn=/^\d+[).]\s+(?<text>\S.*)$/u,ln=/^#{1,6}\s+(?<text>\S.*)$/u,un=/^\s*(?:[*\-•]|\d+[).]|#{1,6})\s*$/u;const hn=new WeakMap;function pn(t,e){hn.get(t)!==e&&(hn.set(t,e),t.replaceChildren(),function(t,e){for(const[n,o]of e.split("**").entries())""!==o&&t.append(n%2==1?ke("strong","",o):document.createTextNode(o))}(t,e))}function fn(t,e){for(const[n,o]of e.entries()){let e=t.children.item(n);null===e&&(e=ke("li"),t.append(e)),pn(e,o)}for(;t.children.length>e.length;)t.lastElementChild?.remove()}const mn=new WeakMap;function gn(t,e,n){const o=mn.get(t)??ke("span","cal-caret");mn.set(t,o),o.setAttribute("aria-hidden","true"),o.remove();const r=function(t,e){const n=t.replaceAll(/\r\n?/gu,"\n").split("\n");!e&&un.test(n.at(-1)??"")&&n.pop();const o=[];let r,i;for(const t of n){const e=t.trim();if(""===e){r=void 0,i=void 0;continue}const n=ln.exec(e);if(n){o.push({tag:"h3",text:n.groups?.text??""}),r=void 0,i=void 0;continue}const s=cn.exec(e),a=s??dn.exec(e);if(a){const t=s?"ul":"ol";i?.tag!==t&&(i={tag:t,items:[]},o.push(i)),i.items.push(a.groups?.text??""),r=void 0;continue}i&&/^\s/u.test(t)?i.items[i.items.length-1]+=` ${e}`:(i=void 0,r?r.text+=` ${e}`:(r={tag:"p",text:e},o.push(r)))}return o}(e,n);for(const[e,n]of r.entries()){let o=t.children.item(e);if(o?.tagName.toLowerCase()!==n.tag){const e=ke(n.tag);null===o?t.append(e):o.replaceWith(e),o=e}"items"in n?fn(o,n.items):pn(o,n.text)}for(;t.children.length>r.length;)t.lastElementChild?.remove();const i=t.lastElementChild;!n&&i&&(i.matches("ul, ol")?i.lastElementChild??i:i).append(o)}function yn(t,e,n=!0,o=""){const r=ke("div",`${e} cal-prose ${o}`.trim());return gn(r,t,n),r}function bn(t){return Array.isArray(t)?t:[]}function vn(t){return Ee(t)?t:{}}let wn=0;function kn(t){return wn+=1,`cal-${t}-${wn}`}function Sn(){return _e("0 0 14 10","M8.537.808a.5.5 0 01.817-.162l4 4a.5.5 0 010 .708l-4 4a.5.5 0 11-.708-.708L11.793 5.5H1a.5.5 0 010-1h10.793L8.646 1.354a.5.5 0 01-.109-.546z","cal-icon cal-icon--arrow")}function An(){return _e("0 0 10 6","M9.354.646a.5.5 0 00-.708 0L5 4.293 1.354.646a.5.5 0 00-.708.708l4 4a.5.5 0 00.708 0l4-4a.5.5 0 000-.708z","cal-icon cal-icon--caret")}function _n(t,e,n){return`${t} ${1===t?e:n}`}const xn=["text","message","reply","answer","intro","body"],Cn=["What would you recommend?","Show me what is new","What are your best sellers?","Help me find a gift"];function En(t){return bn(t.fields.images).length>1?1:0}function Tn(t,e,{index:n=0,widths:o,sizes:r,eager:i=!1,className:s=""}){const a=o[Math.floor(o.length/2)]??800,c=t.imageUrl(e,{index:n,width:a});if(""===c)return;const d=ke("img",s);return d.srcset=o.map(o=>`${t.imageUrl(e,{index:n,width:o})} ${o}w`).join(", "),d.sizes=r,d.src=c,d.alt=$e(e.fields.images?.[n]?.alt,e.fields.title),d.decoding="async",d.loading=i?"eager":"lazy",i&&(d.fetchPriority="high"),function(t){t.classList.add("cal-reveal");const e=()=>{t.classList.add("is-ready")};t.complete&&t.naturalWidth>0?e():(t.addEventListener("load",e,{once:!0}),t.addEventListener("error",e,{once:!0}))}(d),d}const Rn=[360,535,750,1070];function On(t,e){const n="string"==typeof t?new Date(t):void 0;return!n||Number.isNaN(n.getTime())?"":function(t){let e=qn.get(t);if(!e){try{e=new Intl.DateTimeFormat(t,{dateStyle:"medium"})}catch{e=new Intl.DateTimeFormat("en",{dateStyle:"medium"})}qn.set(t,e)}return e}(e).format(n)}const qn=new Map;function $n(t,e,n){const o=Re(t),r=Tn(e,t,{widths:Rn,sizes:n}),i=ke("article",`cal-entry cal-entry--${"collection"===o||"article"===o?o:"other"}${r?"":" cal-entry--text"}`);if(r){const t=ke("div","cal-entry__media cal-media");t.append(r),i.append(t)}const s=ke("div","cal-entry__body"),a=function(t,e){const{fields:n}=t;switch(Re(t)){case"collection":{const t=n["shopify-productsCount"];return"number"==typeof t&&t>0?_n(t,"product","products"):""}case"article":return[On(n["shopify-publishedAt"],e.settings.language),$e(n["shopify-author"])].filter(t=>""!==t).join(" · ");default:return""}}(t,e);""!==a&&s.append(ke("p","cal-entry__meta",a));const c=$e(t.fields.title,t.fields["shopify-handle"].replaceAll("-"," ")),d=ke("h3","cal-entry__title"),l=e.url(t);if(""===l)d.textContent=c;else{const t=ke("a","cal-entry__link",c);t.href=l,d.append(t)}s.append(d);const u=$e(t.fields.descriptionText);return""===u||"collection"===o&&r||s.append(ke("p","cal-entry__text",u)),i.append(s),i}function In(t,e,n){const o=ke("ul",`cal-entries cal-entries--${n}`);o.setAttribute("role","list");const r=4===n?"(min-width: 990px) 25vw, (min-width: 750px) 33vw, 50vw":"(min-width: 750px) 33vw, 100vw";for(const n of t){const t=ke("li","cal-entries__item");t.append($n(n,e,r)),o.append(t)}return o}const Nn=new WeakMap;function Ln(t,e){const n=JSON.stringify(vn(t.data),(t,e)=>{const n=Ee(e)&&Ee(e.fields)?e.fields["shopify-handle"]:void 0;return"string"==typeof n?n:e});return`${e.chapter.isFirst?1:0}|${e.chapter.question}|${n}`}function Mn(t,e){return{type:t,render(t,n){const o=e(vn(t.data),n,t);return o&&Nn.set(o,Ln(t,n)),o},update:(t,e,n)=>Nn.get(t)===Ln(e,n)}}function Bn(t){const{classes:e}=t;function n(t,e="section"){return ke(e,`cal-section cal-${t}`)}function o(...t){const n=ke("div",`${e.pageWidth} cal-section__inner`);return n.append(...t.filter(t=>void 0!==t)),n}function r(t){return ke("p","cal-eyebrow",t)}function i(t,e,n){const o=ke("div","cal-head"),r=ke("h2","cal-title",e);return r.id=kn("title"),t.setAttribute("aria-labelledby",r.id),o.append(r),void 0!==n&&o.append(ke("p","cal-head__meta",n)),o}function s(t,n,o=""){const r=ke("button",`${e.buttonSecondary} cal-chip ${o}`.trim());return r.type="button",r.dataset.callimacusAsk=n,n!==t&&(r.title=n),r.append(ke("span","cal-chip__label",t),Sn()),r}function a(t){const e=ke("ul","cal-chips");e.setAttribute("role","list");for(const n of t){const t=ke("li");t.append(s(n.label,n.question)),e.append(t)}return e}function c(t,e,n){const o=Ye(e);return void 0!==o&&t.addEventListener("click",()=>{n.productClicked(Ke(o))}),t}function d(t,e,n){const o=ke("a",n);o.href=e.url(t);const r=$e(t.fields.title);return o.append(ke("span","",""===r?"Shop now":`Shop ${r}`),Sn()),c(o,t,e)}function l(t,e){const n=$e(e).replace(/^Show me .+? — /u,"");if(""===n)return`Show me ${t}`;return`Show me ${t} — ${/^(?:I\b|I'|[A-Z]{2})/u.test(n)?n:n.charAt(0).toLowerCase()+n.slice(1)}`}function u(r,i,s,a=!0){if(""===r&&0===i.length)return;const c=n("note"),d=o();""!==r&&d.append(yn(r,e.rte,a,"cal-prose--note"));const l=i.filter(t=>"product"!==Re(t)),u=[t.cards(i.filter(t=>"product"===Re(t)),s),l.length>0?In(l,s,3):void 0];return d.append(...u.filter(t=>void 0!==t)),c.append(d),c}function h(t,e,n,o){return xn.map(e=>$e(t[e])).find(t=>""!==t)??(e.length>0?"":n.text(o))}function p(t,e){const n=$e(vn(t.data).text,e.text(t));return 0===e.chapter.blocks.filter(e=>e.id!==t.id).length&&!e.chapter.addedToCart||/solomei\.ai/iu.test(n)?{kind:"redirect",text:n}:{kind:""!==n&&e.final?"note":"wait",text:n}}function f(t){const e=n("redirect"),r=ke("p","cal-redirect__text",`I can help with questions about what ${t.settings.storeName} sells.`),i=(t.settings.starters.length>0?t.settings.starters.slice(0,4):Cn).map(t=>({label:t,question:t}));return e.append(o(r,a(i))),e}const m=[(g="custom:storefrontReply",y=(t,e,n)=>$e(t.text,e.text(n)),b=(t,r)=>{const i=n("answer"),s=ke("div","cal-answer__body");return s.append(yn(t,e.rte,r.final,"cal-prose--answer")),i.append(o(s)),i},{type:g,render(t,e){const n=y(vn(t.data),e,t);return""===n?void 0:b(n,e)},update(t,e,n){const o=t instanceof Element?t.querySelector(".cal-prose"):void 0,r=y(vn(e.data),n,e);return!(!o||""===r||(gn(o,r,n.final),0))}}),Mn("custom:editorialHero",(t,i)=>{const s=vn(t.copy),a={eyebrow:$e(s.eyebrow),headline:$e(s.headline),dek:$e(s.dek)},l=i.hits(t.lead).at(0),{isFirst:u}=i.chapter,h=l?Tn(i,l,{index:En(l),widths:u?[750,1100,1500,1800,2400]:[200,320,480],sizes:u?"100vw":"(min-width: 750px) 160px, 96px",eager:u}):void 0;if(h||""!==a.eyebrow||""!==a.headline||""!==a.dek)return u?function(t,o,i,s){const a=n("hero");a.classList.add("cal-hero--lead");const c=ke("div","cal-hero__banner "+(i?"cal-hero__banner--image":"cal-hero__banner--text"));if(i){const t=ke("div","cal-hero__media cal-media");t.append(i),c.append(t)}if(""!==t.eyebrow||""!==t.headline||""!==t.dek){const n=ke("div",`cal-hero__content ${e.pageWidth}`),i=ke("div","cal-hero__box");if(""!==t.eyebrow&&i.append(r(t.eyebrow)),""!==t.headline&&i.append(ke("h2","cal-display cal-hero__headline",t.headline)),""!==t.dek&&i.append(ke("p","cal-hero__dek",t.dek)),o){const t=ke("div","cal-hero__buttons");t.append(d(o,s,`${e.buttonPrimary} cal-hero__cta`)),i.append(t)}n.append(i),c.append(n)}return a.append(c),a}(a,l,h,i):function(t,i,s,a){const l=n("hero");l.classList.add("cal-hero--compact");const u=ke("div","cal-hero__row");if(s&&i){const t=ke("a","cal-hero__thumb cal-media");t.href=a.url(i),t.tabIndex=-1,t.setAttribute("aria-hidden","true"),t.append(s),u.append(c(t,i,a))}const h=ke("div","cal-hero__text");return""!==t.eyebrow&&h.append(r(t.eyebrow)),""!==t.headline&&h.append(ke("h2","cal-title cal-hero__headline",t.headline)),""!==t.dek&&h.append(ke("p","cal-hero__dek",t.dek)),i&&h.append(d(i,a,`${e.link} cal-link`)),u.append(h),l.append(o(u)),l}(a,l,h,i)}),Mn("custom:storefrontPicks",(e,r,s)=>{const a=r.hits(e.picks);return function(e,r,s){if(0===r.length)return;const a=n("picks"),c=i(a,e,_n(r.length,"product","products"));return a.append(o(c,t.cards(r,s))),a}("Picked for you",a.length>0?a:r.picks(s),r)}),Mn("custom:pageAnswer",(t,i)=>{const s=bn(t.pages).filter(t=>Be(t)).map(t=>({title:$e(t.meta?.title,t.name),kind:t.meta?.shopifyKind,text:je(t),url:i.url(t)})).filter(t=>""!==t.title&&t.text.length>0&&""!==t.url).slice(0,2);if(0===s.length)return;const a=n("pages"),c=ke("div","cal-pages__list");return c.append(...s.map(t=>function(t,n){const o=ke("article","cal-page"),i=ke("h2","cal-subtitle cal-page__title",t.title);i.id=kn("title"),o.setAttribute("aria-labelledby",i.id);const s=ke("a",`${e.link} cal-link cal-page__link`);return s.href=t.url,s.append(ke("span","","Read the full "+("policy"===t.kind?"policy":"page")),ke("span",e.visuallyHidden,`: ${t.title}`),Sn()),o.append(r("policy"===t.kind?"Store policy":`From ${n.settings.storeName}`),i,yn(t.text.join("\n\n"),e.rte,!0,"cal-page__text"),s),o}(t,i))),a.append(o(c)),a}),Mn("custom:collectionGrid",(t,e)=>{const r=e.hits(t.collections).filter(t=>"collection"===Re(t)&&0!==t.fields["shopify-productsCount"]);if(0===r.length)return;const s=n("collections"),a=i(s,"Shop by collection",_n(r.length,"collection","collections"));return s.append(o(a,In(r,e,4))),s}),Mn("custom:storyCards",(t,e)=>{const r=e.hits(t.stories).filter(t=>"article"===Re(t));if(0===r.length)return;const s=n("stories"),a=i(s,"From the journal",_n(r.length,"story","stories"));return s.append(o(a,In(r,e,3))),s}),Mn("custom:problemGuide",(t,r)=>{const a=vn(t.guide),c=bn(a.steps).map(t=>vn(t)).map(t=>({title:$e(t.title),body:$e(t.body),shopFor:$e(t.shopFor)})).filter(t=>""!==t.title||""!==t.body);if(0===c.length)return;const d=n("guide"),u=ke("ol",`cal-steps cal-steps--${Math.min(c.length,4)}`);u.setAttribute("role","list");for(const[t,n]of c.entries()){const o=ke("li","cal-step"),i=ke("div","cal-step__card"),a=ke("span","cal-step__index",String(t+1).padStart(2,"0"));a.setAttribute("aria-hidden","true");const c=ke("div","cal-step__info");""!==n.title&&c.append(ke("h3","cal-step__title",n.title)),""!==n.body&&c.append(yn(n.body,e.rte,!0,"cal-step__body")),""!==n.shopFor&&c.append(s(`Shop ${n.shopFor}`,l(n.shopFor,r.chapter.question),"cal-chip--compact cal-step__shop")),i.append(a,c),o.append(i),u.append(o)}const h=i(d,$e(a.title,"Step by step"),_n(c.length,"step","steps"));return d.append(o(h,u)),d}),Mn("custom:materialStory",(i,s)=>{const a=vn(i.story),c=$e(a.material),d=$e(a.headline),l=$e(a.body),u=bn(a.facts).map(t=>$e(t)).filter(t=>""!==t),h=s.hits(i.products).slice(0,3);if(""===d&&""===l&&0===u.length&&0===h.length)return;const p=n("material"),f=h.at(0),m=f?Tn(s,f,{index:En(f),widths:[535,750,1070,1500],sizes:"(min-width: 1600px) 750px, (min-width: 750px) calc((100vw - 130px) / 2), calc(100vw - 30px)"}):void 0;if(""!==d||""!==l||""!==c||u.length>0){const t=ke("div","cal-material__feature"+(m?"":" cal-material__feature--text"));if(m){const e=ke("div","cal-material__media cal-media");e.append(m),t.append(e)}const n=ke("div","cal-material__content");if(""!==c&&n.append(r(c)),""!==d){const t=ke("h2","cal-title cal-material__heading",d);t.id=kn("title"),p.setAttribute("aria-labelledby",t.id),n.append(t)}if(""!==l&&n.append(yn(l,e.rte,!0,"cal-material__body")),u.length>0){const t=ke("ul","cal-facts");t.setAttribute("role","list");for(const e of u)t.append(ke("li","cal-facts__item",e));n.append(t)}t.append(n),p.append(o(t))}if(h.length>0){const e=ke("div","cal-material__products");e.append(ke("h3","cal-subtitle",""===c?"Shop the story":`Made with ${c}`));const n=t.cards(h,s,{columns:3});n&&e.append(n),p.append(o(e))}return p}),Mn("custom:sizeCare",t=>{const i=bn(t.faq).map(t=>vn(t)).map(t=>({question:$e(t.question),answer:$e(t.answer)})).filter(t=>""!==t.question&&""!==t.answer);if(0===i.length)return;const s=n("faq"),a=ke("div","cal-faq__layout"),c=ke("div","cal-faq__header"),d=ke("h2","cal-title","Good to know");d.id=kn("title"),s.setAttribute("aria-labelledby",d.id),c.append(r("Sizes and care"),d);const l=ke("div","cal-faq__list");for(const[t,n]of i.entries()){const o=kn("faq"),r=ke("div","cal-faq__item"),i=ke("details");i.open=0===t;const s=ke("summary","cal-faq__summary");s.id=`${o}-summary`,s.append(ke("h3","cal-faq__question",n.question),An());const a=ke("div","cal-faq__answer");a.id=`${o}-content`,a.setAttribute("role","region"),a.setAttribute("aria-labelledby",s.id),a.append(yn(n.answer,e.rte)),i.append(s,a),r.append(i),l.append(r)}return a.append(c,l),s.append(o(a)),s}),Mn("custom:compareSet",(i,s)=>{const a=vn(i.pair),c=vn(i.verdict),d=s.hits(i.first).at(0),l=s.hits(i.second).at(0),u=bn(c.rows).map(t=>vn(t)).map(t=>({aspect:$e(t.aspect),first:$e(t.first),second:$e(t.second)})).filter(t=>""!==t.aspect),h=$e(c.summary);if(!d&&!l&&""===h&&0===u.length)return;const p=$e(d?.fields.title,a.first,"The first"),f=$e(l?.fields.title,a.second,"The second"),m=n("compare");d||l||m.classList.add("cal-compare--text");const g=ke("div","cal-compare__layout"),y=ke("div","cal-compare__intro"),b=ke("h2","cal-title",`${p} or ${f}?`);b.id=kn("title"),m.setAttribute("aria-labelledby",b.id),y.append(r("Side by side"),b),""!==h&&y.append(yn(h,e.rte,!0,"cal-compare__summary")),g.append(y);for(const[e,n]of[d,l].entries()){const o=ke("div","cal-compare__card cal-compare__card--"+(0===e?"first":"second")),r=n?t.card(n,s,{position:e}):void 0;r&&o.append(r),g.append(o)}return u.length>0&&g.append(function(t,n,o){const r=ke("div","cal-compare__table");r.setAttribute("role","table"),r.setAttribute("aria-label",`${t} compared with ${n}`);const i=ke("div","cal-compare__row cal-compare__row--head");i.setAttribute("role","row");const s=ke("span","cal-compare__aspect");s.setAttribute("role","columnheader"),s.append(ke("span",e.visuallyHidden,"Aspect")),i.append(s);for(const e of[t,n]){const t=ke("span","cal-compare__value",e);t.setAttribute("role","columnheader"),i.append(t)}r.append(i);for(const t of o){const e=ke("div","cal-compare__row");e.setAttribute("role","row");const n=ke("span","cal-compare__aspect",t.aspect);n.setAttribute("role","rowheader"),e.append(n);for(const n of[t.first,t.second]){const t=ke("span","cal-compare__value",n);t.setAttribute("role","cell"),e.append(t)}r.append(e)}return r}(p,f,u)),m.append(o(g)),m}),Mn("custom:completeSet",(e,r)=>{const s=bn(e.companions).map(t=>vn(t)).map(t=>({why:$e(t.why),hit:r.hits(t.product).at(0)})).filter(t=>void 0!==t.hit).slice(0,3);if(0===s.length)return;const a=n("set"),c=ke("div",`cal-set__collage cal-set__collage--${s.length}`);for(const[e,n]of s.entries()){const o=ke("div","cal-set__item cal-set__item--"+(0===e?"lead":"side")),i=ke("figure","cal-set__piece"),s=t.card(n.hit,r,0===e?{sizes:"(min-width: 1600px) 780px, (min-width: 750px) calc((100vw - 130px) / 2), calc(100vw - 30px)",position:e}:{position:e});s&&i.append(s),""!==n.why&&i.append(ke("figcaption","cal-set__why",n.why)),o.append(i),c.append(o)}return a.append(o(i(a,"Complete the set"),c)),a}),Mn("custom:followUps",t=>{const e=bn(t.next).map(t=>vn(t)).map(t=>({label:$e(t.label,t.question),question:$e(t.question,t.label)})).filter(t=>""!==t.question);if(0===e.length)return;const r=n("next","nav"),i=ke("h2","cal-eyebrow cal-next__title","Keep exploring");return i.id=kn("title"),r.setAttribute("aria-labelledby",i.id),r.append(o(i,a(e))),r}),Mn("custom:addToCartResult",(t,r,i)=>{const s=function(t){if(!Ft(t.data)||!Ft(t.data.addToCart))return;const e=t.data.addToCart;return"error"===e.status?{status:"error"}:"resolved"===e.status&&Dt(e.variantId)&&Dt(e.productName)&&Dt(e.size)?{status:"resolved",variantId:e.variantId,productName:e.productName,size:e.size}:"size_selection_needed"===e.status&&Dt(e.productSku)&&Dt(e.productName)&&Array.isArray(e.availableSizes)&&e.availableSizes.every(Pt)?{status:"size_selection_needed",productSku:e.productSku,productName:e.productName,availableSizes:e.availableSizes}:void 0}(i);if("size_selection_needed"!==s?.status||0===s.availableSizes.length)return;const a=n("choice"),c=ke("h2","cal-eyebrow cal-choice__title",s.productName);c.id=kn("title"),a.setAttribute("aria-labelledby",c.id);const d=ke("div","cal-choice__options");d.setAttribute("role","group"),d.setAttribute("aria-labelledby",c.id);const l=ke("div","cal-choice__status"),u={isOn:!1};for(const t of s.availableSizes){const n=ke("button",`${e.buttonSecondary} cal-choice__option`);n.type="button",n.append(ke("span","cal-choice__label",t.size));const o=async()=>{if(u.isOn)return;u.isOn=!0,n.setAttribute("aria-disabled","true");const e=await en(async()=>r.addToCart(t.variantId,1,{productId:s.productSku,origin:"request"})),o={id:s.productSku,name:s.productName,options:[{name:"option",value:t.size}]},i=pe({id:r.chapter.id??"",item:o,quantity:1},e);n.dataset.outcome=i.outcome,l.replaceChildren(Se(i)),n.removeAttribute("aria-disabled"),u.isOn=!1};t.orderable?n.addEventListener("click",()=>{o()}):(n.disabled=!0,n.append(ke("span","cal-choice__sold-out","Sold out"))),d.append(n)}return a.append(o(c,d,l)),a}),{type:"*",render(t,e){const n=e.picks(t);return u(h(vn(t.data),n,e,t),n,e,e.final)},update(t,e,n){const o=t instanceof Element?t.querySelector(".cal-prose"):void 0,r=n.picks(e),i=h(vn(e.data),r,n,e);return!(!o||""===i||r.length>0)&&(gn(o,i,n.final),!0)}}];var g,y,b;for(const t of["demosthenesResponse","custom:demosthenesResponse"])m.push({type:t,render(t,e){const n=p(t,e);return"redirect"===n.kind?f(e):"wait"===n.kind?void 0:u(n.text,[],e)},update(t,e,n){const o=p(e,n);if("redirect"===o.kind)return t instanceof Element&&t.classList.contains("cal-redirect");const r=t instanceof Element?t.querySelector(".cal-prose"):void 0;return!(!r||"note"!==o.kind)&&(gn(r,o.text,!0),!0)}});return m}const jn="callimacus.cards",Un=["_pos","_sid","_ss","_psq","_fid"],Fn=new Set(["TABLE","THEAD","TBODY","TFOOT","TR","TD","TH"]);function Dn(t){if(null!==t)try{const e=/\/products\/(?<handle>[^#/?]+)/u.exec(new URL(t,globalThis.location.origin).pathname);return void 0===e?.groups?.handle?void 0:decodeURIComponent(e.groups.handle)}catch{return}}function Pn(t,e){return[...t.querySelectorAll('a[href*="/products/"]')].some(t=>{const n=Dn(t.getAttribute("href"));return void 0!==n&&n!==e})}function Wn(){const t=be("sessionStorage",jn),e={searches:0,sectionId:void 0,borrowed:0,missed:[],styles:0,scripts:[],verdict:"fits"===t||"fails"===t?t:"unknown",why:void 0===t?"":"decided on an earlier page of this tab"},n=new Set;return{stats:e,source:function(t,n){const o=""===t.title?t.handle.replaceAll("-"," "):t.title,r=new URLSearchParams({type:"product",q:o,"options[prefix]":"last"});return void 0!==e.sectionId&&r.set("section_id",e.sectionId),e.searches+=1,`${n}search?${r.toString()}`},extract:function(t,o){const r=document.createElement("template");r.innerHTML=t;const i=function(t,e){const n=[...(t.querySelector("main")??t).querySelectorAll('a[href*="/products/"]')].filter(t=>Dn(t.getAttribute("href"))===e&&!t.closest('cart-drawer, cart-drawer-component, cart-notification, cart-items, [id^="CartDrawer"], [id^="cart-notification"], [class*="cart-drawer"], .cart-item'));for(const t of n){let n=t;for(;n.parentElement&&!n.parentElement.matches('main, body, .shopify-section, ul, ol, [role="list"], form, section, slider-component, .grid, [class*="product-grid"]')&&!Pn(n.parentElement,e)&&!n.parentElement.querySelector("h1");)n=n.parentElement;if("LI"===n.tagName&&1===n.childElementCount&&n.firstElementChild&&(n=n.firstElementChild),!Fn.has(n.tagName)&&!n.closest("table")&&n.querySelector("img, picture, svg")&&(n!==t||""!==n.textContent.trim()))return n}}(r.content,o.handle);if(!i)return void e.missed.push({handle:o.handle,why:"not in the search results"});const s=i.closest('[id^="shopify-section-"]');s&&void 0===e.sectionId&&(e.sectionId=s.id.slice(16),ge.info(`borrowing cards from the search section ${e.sectionId}`)),s&&function(t){for(const o of t.querySelectorAll("style")){const t=o.textContent;if(n.has(t))continue;n.add(t);const r=document.createElement("style");r.dataset.callimacusBorrowed="",r.textContent=t,document.head.append(r),e.styles+=1}const o=new Set([...document.querySelectorAll('link[rel="stylesheet"], script[src]')].map(t=>(t.getAttribute("href")??t.getAttribute("src")??"").split("?",1)[0]));for(const r of t.querySelectorAll('link[rel="stylesheet"]')){const t=r.getAttribute("href")??"",i=t.split("?",1)[0]??t;""===t||o.has(i)||n.has(i)||(n.add(i),document.head.append(r.cloneNode(!0)),e.styles+=1)}for(const r of t.querySelectorAll("script[src]")){const t=r.getAttribute("src")??"",i=t.split("?",1)[0]??t;if(""===t||o.has(i)||n.has(i))continue;n.add(i);const s=document.createElement("script");s.src=t,s.defer=!0,document.head.append(s),e.scripts.push(i.split("/").pop()??i)}}(s);const a=document.createElement("template");return a.content.append(i),e.borrowed+=1,a},prepare:function(t){!function(t){for(const e of t.querySelectorAll("a[href]")){const t=e.getAttribute("href")??"";try{const n=new URL(t,globalThis.location.origin);if(Un.some(t=>n.searchParams.has(t))){for(const t of Un)n.searchParams.delete(t);const o=n.origin===globalThis.location.origin&&!/^https?:/iu.test(t);e.setAttribute("href",o?`${n.pathname}${n.search}${n.hash}`:n.href)}}catch{}}}(t);for(const e of t.querySelectorAll('dialog, [role="dialog"], quick-add-modal, [class*="modal"][id]')){const t=""===e.id?void 0:document.querySelector(`#${CSS.escape(e.id)}`);t&&t!==e?e.remove():t||document.body.append(e)}},check:function(t){if("unknown"!==e.verdict)return e.verdict;const n=function(t){const e=t.getBoundingClientRect();if(e.width<40||e.height<40)return;const n=t.querySelector("img, picture, svg"),o=n?.getBoundingClientRect();if(!n||!o||0===o.height)return;const r=[...t.querySelectorAll('a[href*="/products/"], h2, h3, h4, p, [class*="title"], [class*="price"]')].filter(t=>!t.contains(n)&&!n.contains(t)&&""!==t.textContent.trim()).map(t=>t.getBoundingClientRect()).find(t=>t.height>=8&&t.width>=8&&!(t.top<=o.top&&t.bottom>=o.bottom));return r?e.height<e.width?{fits:!1,why:`the card is wider than it is tall (${Math.round(e.width)} by ${Math.round(e.height)} px): a list row`}:o.bottom>r.top+4?{fits:!1,why:"the card's text sits beside its picture, not under it"}:{fits:!0,why:"a picture above its text, taller than wide"}:{fits:!1,why:"the card has no text beside its picture"}}(t);return n&&(e.verdict=n.fits?"fits":"fails",e.why=n.why,ve("sessionStorage",jn,e.verdict),ge.info(`the theme's cards ${n.fits?"fit":"do not fit"}: ${n.why}`)),e.verdict}}}const zn=[240,360,480,640,840,1080],Vn={add:"Add to cart",added:"Added",choose:"Choose options",soldOut:"Sold out",failed:"Could not add. Try again"},Hn=Object.freeze({pageWidth:"cal-page-width",buttonPrimary:"cal-button",buttonSecondary:"cal-button cal-button--secondary",link:"cal-link",rte:"cal-rte",visuallyHidden:"cal-visually-hidden",grid:t=>`cal-egrid cal-egrid--${t}`,gridItem:"cal-egrid__item"});function Kn(){const t=document.querySelector("cart-notification, cart-drawer");return"function"==typeof t?.getSectionsToRender?"dawn":document.querySelector("cart-items-component, cart-drawer-component, cart-icon")?"horizon":"plain"}function Jn(t){return[...t.querySelectorAll('a[href$="/cart"], a[href*="/cart?"], a[href$="/cart/"]')].filter(t=>!Ne(t))}let Yn;async function Gn(t,e,n,o){const{json:r,failure:i}=await nn(n,{headers:{"content-type":"application/json",accept:"application/json","x-requested-with":"XMLHttpRequest"},body:JSON.stringify({items:[{id:Number(t),quantity:e}]})});if(i)throw i;const s=Array.isArray(r.items)&&Ee(r.items[0])?r.items[0]:{};!function(t,e){document.querySelector(".cal-toast")?.remove(),clearTimeout(Yn);const n=ke("div","cal-toast");n.setAttribute("role","status"),n.dataset.callimacusUi="",n.append(ke("p","cal-toast__text",""===t?"Added to your cart":`Added to your cart: ${t}`));const o=ke("a","cal-button cal-toast__action","View cart");o.href=`${Ve({settings:e})}cart`,n.append(o),document.body.append(n),Yn=setTimeout(()=>{n.remove()},5e3)}($e(s.product_title,s.title),n),document.dispatchEvent(new CustomEvent("cart:refresh",{bubbles:!0,detail:r}));const a=await async function(){const t=Jn(document),e=t.at(0);if(void 0===e)return!1;const n=e.closest('[id^="shopify-section-"]')?.id.slice(16)??"";let o="";try{if(""!==n){const t=new URL(globalThis.location.href);t.search=`sections=${encodeURIComponent(n)}`;const e=await fetch(t,{headers:{accept:"application/json"}}),r=await e.json();o=Ee(r)&&"string"==typeof r[n]?r[n]:""}if(""===o){const t=await fetch(globalThis.location.href,{headers:{accept:"text/html"}});o=await t.text()}}catch(t){return ge.warn("could not redraw the cart icon",t),!1}const r=Jn((new DOMParser).parseFromString(o,"text/html"));let i=0;for(const[e,n]of t.entries()){const t=(""===n.id?void 0:r.find(t=>t.id===n.id))??r.at(e);void 0!==t&&t.innerHTML!==n.innerHTML&&(n.innerHTML=t.innerHTML,i+=1)}return i>0}();return o.cart[a?"iconRedrawn":"iconMissed"]+=1,{...s,handle:$e(s.handle)}}function Xn(t,e){const n=ke("div","cal-ecard"),o=ke("div","cal-ecard__media"),r=ke("div","cal-ecard__info"),i=ke("a","cal-ecard__title",t);return i.href=e,r.append(i),n.append(o,r),{root:n,info:r,title:i,media:o}}function Zn(t,e){const n=ke("div","cal-ecard__quick-add cal-card__quick-add");return n.append(Je(t,e,{className:"cal-button cal-button--secondary cal-ecard__add",labels:Vn})),n}function Qn(t,e,n={}){const{hit:o}=t,r=e.url(o),i=Xn(t.title,r),s=Tn(e,o,{widths:zn,sizes:n.sizes??"(min-width: 990px) calc((100vw - 160px) / 4), (min-width: 750px) calc((100vw - 120px) / 3), calc((100vw - 40px) / 2)"});if(s){const t=ke("a","cal-ecard__image");t.href=r,t.tabIndex=-1,t.setAttribute("aria-hidden","true"),t.append(s),i.media.append(t)}return i.info.append(ke("p","cal-ecard__price"+(ze(o)?" cal-ecard__price--sold-out":""),function(t,e){const{fields:n}=t,o=Ee(n.priceRange)?n.priceRange:{},r=Number(o.min),i=Number(o.max);if(Number.isFinite(r)&&Number.isFinite(i)&&r<i){const t=$e(o.currency,"object"==typeof n.price?n.price.currency:"");return`From ${e.money(""===t?r:{amount:r,currency:t})}`}return void 0===n.price?"":e.money(n.price)}(o,e))),!1===n.quickAdd||ze(o)||i.info.append(Zn(t,e)),i.root}function to(t,e){const n=Xn("",`${Ve(e)}products/${encodeURIComponent(t.handle)}`);return n.root.classList.add("cal-card__skeleton"),n.title.append(ke("span","cal-card__line")),n.title.setAttribute("aria-label",""===t.title?"Loading product":t.title),n.root}function eo(t,e){t.classList.remove("cal-card__skeleton");const n=t.querySelector(":scope .cal-ecard__title");n&&(n.removeAttribute("aria-label"),n.textContent=""===e.title?e.handle.replaceAll("-"," "):e.title)}function no(t,e,n,o){t.addEventListener("click",r=>{const i=r.target instanceof Element?r.target.closest("a[href]"):void 0;i&&t.contains(i)&&n.productClicked?.(Ke(e),o)})}function oo(){const t=new Map;async function e(e,n){let o=t.get(e);return o||(o=fetch(`${Ve(n)}products/${encodeURIComponent(e)}.js`,{headers:{accept:"application/json"}}).then(async t=>t.ok?t.json():void 0).then(t=>Ee(t)?function(t){const e=$e(t.handle);if(""===e)return;const n=Array.isArray(t.variants)?t.variants.filter(t=>Ee(t)):[],o=Array.isArray(t.images)?t.images.filter(t=>"string"==typeof t):[],r=t=>Number(t)/100;return{fields:{"shopify-handle":e,title:$e(t.title),price:r(t.price),priceRange:{min:r(t.price_min),max:r(t.price_max)},images:o.map(t=>({url:t.startsWith("//")?`https:${t}`:t})),variantTree:{variants:n.map(t=>({id:t.id,orderable:!0===t.available,online:!0}))}}}}(t):void 0).catch(()=>{}),t.set(e,o)),o}function n({host:t,ref:n,ctx:o,options:r}){if(n.hit){const i=Qn({...n,hit:n.hit},o,r);return t.replaceChildren(i),void(0===(n.hit.fields.images??[]).length&&e(n.handle,o).then(t=>{if(!t||!i.isConnected)return;const e={...t,fields:{...t.fields,...n.hit?.fields,images:t.fields.images}};i.replaceWith(Qn({...n,hit:e},o,r))}))}const i=to(n,o);t.replaceChildren(i),t.classList.add("cal-card--pending"),e(n.handle,o).then(e=>{t.classList.remove("cal-card--pending"),e?i.replaceWith(Qn({handle:n.handle,hit:e,title:$e(n.title,e.fields.title)},o,r)):eo(i,n)})}return{card:function(t,e,o={}){const r=Ye(t);if(!r)return;const i=ke("div","cal-card");return i.dataset.handle=r.handle,n({host:i,ref:r,ctx:e,options:o}),i},draw:n}}function ro(t){const e=oo(),n=Wn(),o={cart:{kind:void 0,adds:0,iconRedrawn:0,iconMissed:0},addedButtons:0,borrow:n.stats},r=new Set,i=Ge(n.source,{extract:n.extract,prepare:n.prepare,placeholder:Qn,skeleton:to,offline:eo});let s=!1;const a=t=>!t.classList.contains("cal-card--pending")&&null!==t.firstElementChild&&!t.firstElementChild.classList.contains("cal-ecard");function c(t){const i=t.host.firstElementChild;if(null===i||!a(t.host))return;if("fails"===n.check(i))return void function(){for(const t of r)t.host.isConnected?a(t.host)&&(e.draw(t),r.delete(t)):r.delete(t)}();if(function({host:t,ref:e,ctx:n,options:r}){const i=t.firstElementChild;null!==i?.querySelector('button[name="add"], form[action*="/cart/add"], modal-opener, [data-quick-add], quick-add-component, .quick-add, product-form-component')||null!==t.querySelector(":scope > .cal-ecard__quick-add")||null===i||!1===r.quickAdd||!e.hit||ze(e.hit)||(t.append(Zn({...e,hit:e.hit},n)),o.addedButtons+=1)}(t),"unknown"!==n.stats.verdict)return;const s=()=>{c(t)};if(i.querySelector("img")?.addEventListener("load",s,{once:!0}),"function"!=typeof IntersectionObserver)return;const d=new IntersectionObserver(t=>{t.every(t=>!t.isIntersecting)||(d.disconnect(),s())});d.observe(t.host)}function d(o,d,l={}){const u=Ye(o);if("auto"!==t||"fails"===n.stats.verdict){const t=e.card(o,d,l);return t&&u&&no(t,u,d,l.position),t}!function(){if(s)return;s=!0;const t=Ze();t&&"function"==typeof Xe.subscribe&&Xe.subscribe(t.cartUpdate,t=>{const e=Ee(t)?t:{};"product-form"===e.source&&i.rememberAdded(e.productVariantId)}),document.addEventListener(rn,t=>{const{detail:e}=t,n=Ee(e)&&Ee(e.data)?e.data:{};if(!Ee(e)||"product-form-component"!==n.source||!0===n.didError)return;const o=Number(n.itemCount);i.rememberAdded(e.sourceId,Number.isSafeInteger(o)&&o>0?o:1)})}();const h=i.card(o,d,l);if(!h||!u)return h;no(h,u,d,l.position);const p={host:h,ref:u,ctx:d,options:l};if(r.add(p),a(h))queueMicrotask(()=>{c(p)});else{const t=new MutationObserver(()=>{h.classList.contains("cal-card--pending")||(t.disconnect(),c(p))});t.observe(h,{childList:!0,attributes:!0,attributeFilter:["class"]})}return h}return Object.freeze({classes:Hn,card:d,cards:(t,e,n={})=>function(t,e){if(0===t.length)return;const n=[2,3,4,5].includes(e.columns??4)?e.columns??4:4,o=ke("ul",`${Hn.grid(n)} cal-grid`);o.setAttribute("role","list");for(const e of t){const t=ke("li",Hn.gridItem);t.append(e),o.append(t)}return o}(function(t,e){return(Array.isArray(t)?t:[]).map((t,n)=>e(t,n)).filter(t=>void 0!==t)}(t,(t,o)=>d(t,e,{...n,position:o})),n),addToCart:async function(t,e,n){const r=Kn();let i;return o.cart.kind=r,i="dawn"===r?await async function(t,e,n){const o=document.querySelector("cart-notification")??document.querySelector("cart-drawer")??void 0,r=new FormData;r.append("id",t),r.append("quantity",String(e)),"function"==typeof o?.getSectionsToRender&&(r.append("sections",o.getSectionsToRender().map(t=>t.id).join(",")),r.append("sections_url",globalThis.location.pathname),o.setActiveElement?.(document.activeElement));const{json:i,failure:s}=await nn(n,{headers:Qe,body:r}),a=Ze();if(s)throw a&&"function"==typeof Xe.publish&&Xe.publish(a.cartError,{source:"callimacus",productVariantId:t,errors:i.description,message:i.message}),s;if(a&&"function"==typeof Xe.publish&&Xe.publish(a.cartUpdate,{source:"callimacus",productVariantId:t}),"function"==typeof o?.renderContents&&void 0!==i.sections)try{return o.renderContents(i),o.classList.remove("is-empty"),i}catch(t){ge.error("the cart could not redraw itself after adding",t)}return document.dispatchEvent(new CustomEvent("cart:refresh",{bubbles:!0,detail:i})),i}(t,e,n):"horizon"===r?await an(t,e,n):await Gn(t,e,n,o),o.cart.adds+=1,i},install(){"dawn"===Kn()&&"function"!=typeof Xe.getCurrentSellingPlanId&&(Xe.getCurrentSellingPlanId=()=>"")},stats:o})}const io=["header details-modal summary",'header [class*="search"] summary','header a[href$="/search"]','header a[href*="/search?"]','header button[aria-label*="earch" i]','header summary[aria-label*="earch" i]','header [class*="search-toggle"]',"header search-button button",'header [class*="search"] button','[class*="header"] a[href$="/search"]','[class*="header"] [class*="search-toggle"]','[class*="header"] button[aria-label*="earch" i]'],so=['header a[href$="/cart"]','[class*="header"] a[href$="/cart"]'],ao=/search|js-|drawer|modal|toggle|open|trigger|active/iu,co="http://www.w3.org/2000/svg";function lo(t){const e=t.getBoundingClientRect();return e.width>0&&e.height>0}function uo(t){for(const e of t){const t=[...document.querySelectorAll(e)].find(t=>lo(t)&&!t.closest("[data-callimacus-ui]"));if(t)return{node:t,selector:e}}}function ho(t){const e=uo(io)??uo(so);if(!e)return{placed:!1,how:"no search or cart control found in the header"};const n=e.node,o=ke("button","cal-header-ask");o.type="button",o.dataset.callimacusOpen="",o.dataset.callimacusUi="",o.setAttribute("aria-label",t);for(const t of n.classList)ao.test(t)||o.classList.add(t);const r=Math.round(n.querySelector("svg")?.getBoundingClientRect().width??0);return o.append(function(t){const e=document.createElementNS(co,"svg");e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("width",String(t)),e.setAttribute("height",String(t)),e.setAttribute("aria-hidden","true"),e.setAttribute("focusable","false");const n=document.createElementNS(co,"path");return n.setAttribute("d","M12 3.5l1.6 4.4 4.4 1.6-4.4 1.6L12 15.5l-1.6-4.4L6 9.5l4.4-1.6zM18.5 14l.8 2.2 2.2.8-2.2.8-.8 2.2-.8-2.2-2.2-.8 2.2-.8z"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","1.4"),n.setAttribute("stroke-linejoin","round"),e.append(n),e}(r>0?r:20)),function(t){let e=t.closest("details-modal, details")??t;for(e.parentElement?.matches("details-modal")&&(e=e.parentElement);1===e.parentElement?.childElementCount&&!e.parentElement.matches('header, nav, [class*="icons"], [class*="actions"]');)e=e.parentElement;return e}(n).before(o),{placed:!0,how:`before ${e.selector}`}}function po({template:t,searchTerms:e,assistantLabel:n,entrance:o}){const r=ke("div","cal-stage");r.dataset.callimacusUi="";const i=ke("div");if(i.dataset.callimacusStage="",i.dataset.stageKind="index"===t?"home":"search"===t?"search":"page","search"===t&&""!==e){const t=ke("div","cal-stage__intro cal-page-width");t.append(ke("p","cal-stage__lede",`Answering “${e}”`)),r.append(t),i.dataset.askOnLoad=e}if("index"===t&&o&&r.append(function(t,e){const n=ke("div","cal-stage__intro cal-entrance cal-page-width");""!==t.heading&&n.append(ke("h2","cal-stage__heading",t.heading)),""!==t.subheading&&n.append(ke("p","cal-stage__lede",t.subheading));const o=ke("form","cal-entrance__form");o.dataset.callimacusForm="";const r=ke("input","cal-entrance__input");r.type="text",r.name="q",r.maxLength=200,r.autocomplete="off",r.enterKeyHint="send",r.placeholder=""===t.placeholder?`${e} anything`:t.placeholder,r.setAttribute("aria-label",e);const i=ke("button","cal-button",""===t.buttonLabel?"Ask":t.buttonLabel);i.type="submit",o.append(r,i);const s=ke("p","cal-entrance__ai-notice",Ot);s.id="cal-entrance-ai-notice",s.dataset.version=It;const a=ke("a","",qt);if(a.href=$t,a.target="_blank",a.rel="noopener noreferrer",s.append(" ",a),r.setAttribute("aria-describedby",s.id),n.append(o,s),t.starters.length>0){const e=ke("div","cal-entrance__starters");for(const n of t.starters){const t=ke("button","cal-chip cal-button cal-button--secondary",n);t.type="button",t.dataset.callimacusAsk=n,e.append(t)}n.append(e)}return n}(o,n)),"index"===t){const t=ke("div","cal-welcome cal-page-width");t.dataset.callimacusWelcome="",t.hidden=!0,i.append(t)}const s=ke("div");s.dataset.callimacusThread="",i.append(s),r.append(i);const a=document.querySelector("#MainContent")??document.querySelector("main")??document.querySelector('[role="main"]')??document.body,c="product"===t?function(t){const e=t.querySelector('form[action*="/cart/add"]'),n=e?.closest('[id^="shopify-section-"]')??void 0;return n&&t.contains(n)?n:void 0}(a):"index"===t?function(t){return t.querySelector(':scope > [id^="shopify-section-"]')??void 0}(a):void 0;return c?(c.after(r),{placed:!0,how:`after ${c.id}`}):(a.prepend(r),{placed:!0,how:`top of ${""===a.id?a.tagName.toLowerCase():`#${a.id}`}`})}const fo="callimacus.rejected";function mo(t){const e=Number(t);return Number.isSafeInteger(e)?e:0}function go({status:t,reason:e}){ve("sessionStorage",fo,JSON.stringify({status:t,...void 0!==e&&{reason:e},until:Date.now()+6e5}))}function yo(){const t=be("sessionStorage",fo);if(void 0===t)return;let e;try{e=JSON.parse(t)}catch{e=void 0}return Ee(e)?"number"==typeof e.until&&e.until<=Date.now()?void we("sessionStorage",fo):{status:mo(e.status),..."string"==typeof e.reason&&{reason:e.reason}}:{status:mo(t)}}const bo="callimacus.session";function vo(t){return"string"==typeof t?t:""}function wo(t){return Ee(t)&&Ee(t.tokens)&&"string"==typeof t.css?{tokens:t.tokens,css:t.css,readAt:vo(t.readAt)}:void 0}function ko(t){if(!Ee(t))return;const e=Array.isArray(t.starters)?t.starters.filter(t=>"string"==typeof t&&""!==t.trim()):[];return{heading:vo(t.heading),subheading:vo(t.subheading),placeholder:vo(t.placeholder),buttonLabel:vo(t.buttonLabel),starters:e}}function So(t,e){if(Ee(t)&&""!==vo(t.token)&&""!==vo(t.endpoint)&&!Number.isNaN(Date.parse(vo(t.expiresAt))))return{token:vo(t.token),endpoint:vo(t.endpoint),expiresAt:vo(t.expiresAt),themeId:e,entrance:ko(t.entrance),look:wo(t.look)}}async function Ao(t){try{const e=await t.json();return Ee(e)&&"string"==typeof e.reason?e.reason:void 0}catch{return}}function _o(t,e){const n=t.endsWith("/")?t.slice(0,-1):t;let o,r;function i(t){return o=t,t&&ve("sessionStorage",bo,JSON.stringify(t)),t}async function s(){return r??=(async()=>{try{const t=await fetch(`${n}/session?theme_id=${encodeURIComponent(e)}`,{headers:{accept:"application/json"}});if([401,403,404].includes(t.status))return go({status:t.status,reason:await Ao(t)}),i(void 0);if(!t.ok)throw new Error(`the storefront session answered ${t.status}`);return i(So(await t.json(),e))}finally{r=void 0}})(),r}async function a(){return o??=await async function(){const t=globalThis.callimacusSession;if(Reflect.deleteProperty(globalThis,"callimacusSession"),t)try{return So(await t,e)}catch(t){return void ge.warn("the loader could not get a storefront session",t)}}()??function(){try{const t=JSON.parse(be("sessionStorage",bo)??"null");return Ee(t)&&t.themeId===e?So(t,e):void 0}catch{return}}(),o}return{current:async function(){if(void 0!==yo())return;const t=await a(),e=function(t){return void 0!==t&&Date.parse(t.expiresAt)-Date.now()>3e5}(t)?t:await s();return e?{token:e.token,endpoint:e.endpoint}:void 0},renew:async function(){const t=await s();return t?{token:t.token,endpoint:t.endpoint}:void 0},known:a,keepLook:function(t){o&&i({...o,look:t})}}}const xo={fg:{property:"--cal-fg",kind:"color"},bg:{property:"--cal-bg",kind:"color"},bodyFont:{property:"--cal-font-body",kind:"font"},bodyWeight:{property:"--cal-font-body-weight",kind:"keyword"},bodyStyle:{property:"--cal-font-body-style",kind:"keyword"},bodySize:{property:"--cal-body-size",kind:"length"},headingFont:{property:"--cal-font-heading",kind:"font"},headingWeight:{property:"--cal-font-heading-weight",kind:"keyword"},headingStyle:{property:"--cal-font-heading-style",kind:"keyword"},headingCase:{property:"--cal-heading-transform",kind:"keyword"},buttonBg:{property:"--cal-button-bg",kind:"color"},buttonFg:{property:"--cal-button-fg",kind:"color"},buttonBorderColor:{property:"--cal-button-border-color",kind:"color"},buttonBorderWidth:{property:"--cal-button-border-width",kind:"length"},buttonRadius:{property:"--cal-radius-button",kind:"length"},buttonCase:{property:"--cal-button-transform",kind:"keyword"},buttonSpacing:{property:"--cal-button-letter-spacing",kind:"length"},buttonFont:{property:"--cal-font-button",kind:"font"},buttonWeight:{property:"--cal-font-button-weight",kind:"keyword"},secondaryFg:{property:"--cal-button2-fg",kind:"color"},mediaRadius:{property:"--cal-radius-media",kind:"length"},cardRadius:{property:"--cal-radius-card",kind:"length"},pageWidth:{property:"--cal-page-width",kind:"length"}},Co={color:/^(?:#[\da-f]{3,8}|transparent|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\([\s\d%+,\-./a-z]{1,80}\))$/iu,font:/^[\p{Letter}\p{Number} "',\-_]{1,200}$/u,length:/^(?:normal|none|-?(?:\d+(?:\.\d*)?|\.\d+)(?:px|rem|em|%|ch|vw)?)$/iu,keyword:/^(?:normal|bold|bolder|lighter|italic|oblique|none|uppercase|lowercase|capitalize|[1-9]\d{0,2}|1000)$/iu};function Eo(t){return Object.entries(t).filter(t=>{return e=t[0],Object.hasOwn(xo,e)&&"string"==typeof t[1];var e}).map(([t,e])=>`${xo[t].property}:${e}`).join(";")}const To=/^#(?<digits>[\da-f]{3,8})$/u,Ro=/^rgba?\((?<channels>[^)]*)\)$/u;function Oo(t){const e=t.trim().toLowerCase(),n=To.exec(e)?.groups?.digits;if(void 0!==n){const t=n.length<=4?[...n].map(t=>t+t).join(""):n;if(6!==t.length&&8!==t.length)return;const e=e=>Number.parseInt(t.slice(e,e+2),16);return[e(0),e(2),e(4),8===t.length?e(6)/255:1]}const o=Ro.exec(e)?.groups?.channels?.split(/[\s,/]+/u).filter(t=>""!==t);if(void 0===o||o.length<3||o.length>4)return;const[r=NaN,i=NaN,s=NaN,a=1]=o.map((t,e)=>function(t,e){const n=Number(t.endsWith("%")?t.slice(0,-1):t);return t.endsWith("%")?3===e?n/100:2.55*n:n}(t,e));return[r,i,s,a].some(t=>Number.isNaN(t))?void 0:[r,i,s,a]}function qo([t,e,n]){const o=t=>{const e=t/255;return e<=.03928?e/12.92:((e+.055)/1.055)**2.4};return.2126*o(t)+.7152*o(e)+.0722*o(n)}function $o(t,e){return(Math.max(qo(t),qo(e))+.05)/(Math.min(qo(t),qo(e))+.05)}function Io(t){const e=void 0===t.bg?void 0:Oo(t.bg),n=void 0===t.buttonBg?void 0:Oo(t.buttonBg),o=void 0!==n&&n[3]>.5?n:e,r=void 0===t.buttonFg?void 0:Oo(t.buttonFg);if(void 0===o||void 0===r)return t;const i=$o(r,o);if(i>=3)return t;let s;for(const e of[t.fg,t.bg]){const t=void 0===e?void 0:Oo(e),n=void 0===t?0:$o(t,o);void 0!==e&&n>(s?.ratio??i)&&(s={value:e,ratio:n})}return void 0===s?t:{...t,buttonFg:s.value}}const No="callimacus-look";let Lo;function Mo(){return Lo?.isConnected||(Lo=document.createElement("div"),Lo.setAttribute("aria-hidden","true"),Lo.style.cssText="position:absolute;left:-9999px;top:0;width:400px;visibility:hidden;pointer-events:none;",document.body.append(Lo)),Lo}function Bo(t,e){const n=document.createElement("span");if(n.style.display="block",n.style[t]=e,""===n.style[t])return"";Mo().append(n);const o=getComputedStyle(n)[t];return n.remove(),o}function jo(t){const e=t.getBoundingClientRect(),n=getComputedStyle(t);return e.width>4&&e.height>4&&"hidden"!==n.visibility&&"none"!==n.display}function Uo(t){return"transparent"===t||/^rgba\((?:[^),]*,){3}\s*0(?:\.0+)?\)$/u.test(t)||/\/\s*0(?:\.0+)?\)$/u.test(t)}function Fo(t,e=()=>!0){for(const n of t)for(const t of document.querySelectorAll(n))if(!Ne(t)&&jo(t)&&e(t))return{node:t,selector:n}}function Do(t){const e=[...t.classList].slice(0,2).map(t=>`.${t}`).join("");return`${t.tagName.toLowerCase()}${e}`}const Po=/\b(?:add to (?:cart|bag|basket)|buy now|add)\b/iu,Wo=['form[action*="/cart/add"] button[type="submit"]','form[action*="/cart/add"] button[name="add"]','form[action*="/cart/add"] input[type="submit"]','form[action*="/cart/add"] button:not([type="button"])'],zo=["main .button:not(.button--secondary):not(.button--tertiary)","main .btn:not(.btn--secondary)",'main a[class*="button"]','main button[class*="button"]',".shopify-section .button",".shopify-section .btn",'main button[type="submit"]'],Vo=[".shopify-payment-button__button--unbranded"],Ho=/secondary|outline|tertiary/iu,Ko=["main .button--secondary","main .btn--secondary",'main [class*="button-secondary"]'],Jo=["main h1","main h2","h1","h2",".h1",".h2"],Yo=['main a[href*="/products/"] img','a[href*="/products/"] img'],Go=[".card","product-card",".product-card",'[class*="product-card"]',".grid-product",".grid-view-item",".product-item"],Xo=["main .page-width",".page-width","main .container","main .wrapper",".page-container .page-width","main .grid__item"],Zo=/banner|hero|slideshow|slider|carousel|video|image-with-text/iu;function Qo(t,e){const n=[];for(let o=t.parentElement;o&&n.length<e;o=o.parentElement)n.push(o);return n}function tr(t){return t.matches('button, a[href], input[type="submit"], input[type="button"]')}function er(t){const e=[];let n=0,o=0;for(const[r,i]of[...t].entries())n+="("===i?1:")"===i?-1:0,","===i&&0===n&&(e.push(t.slice(o,r)),o=r+1);return e.push(t.slice(o)),e}function nr(t){for(const e of["::after","::before"]){const n=er(getComputedStyle(t,e).boxShadow);for(const t of n){const n=/^(?<color>rgba?\([^)]*\))\s+0px\s+0px\s+0px\s+(?<width>[\d.]+)px$/u.exec(t.trim());if(void 0!==n?.groups?.color&&!Uo(n.groups.color))return{width:`${n.groups.width}px`,color:n.groups.color,how:`${e} outline`}}}}function or(t){return e=t.borderTopWidth,Number(e.replace(/px$/u,""))>0&&"none"!==t.borderTopStyle&&!Uo(t.borderTopColor);var e}function rr(t){const e=t.getBoundingClientRect(),n=getComputedStyle(t);return e.width>=60&&e.height>=28&&!t.closest('header, nav, footer, [role="dialog"], dialog')&&(!Uo(n.backgroundColor)||or(n)||void 0!==nr(t))}function ir(t){let e=t.parentElement;for(let t=0;e&&t<8&&!e.matches("main, body");t+=1){if(Zo.test(e.className)||"none"!==getComputedStyle(e).backgroundImage)return!0;e=e.parentElement}return!1}function sr(t,e){return Ho.test(t.className)||getComputedStyle(t).backgroundColor===e}function ar(t,e){const n=t=>e=>tr(e)&&rr(e)&&ir(e)===t,o="product"===t?Fo(Wo,n(!1))??function(){for(const t of document.querySelectorAll('main button, main a[href], main input[type="submit"]')){const e=t instanceof HTMLInputElement?t.value:t.textContent;if(Po.test(e.trim())&&!Ne(t)&&jo(t)&&rr(t))return{node:t,selector:"a button labelled add to cart"}}}():void 0,r=(o&&sr(o.node,e)?Fo([...Vo,...zo],t=>n(!1)(t)&&!sr(t,e)):void 0)??o??Fo(zo,n(!1))??("other"===t?Fo(zo,n(!0)):void 0);return r?{node:r.node,how:`button ${Do(r.node)}`}:void 0}function cr(t,e,n,o){const r=or(e),i=r||!o?void 0:nr(o),s=r||void 0!==i;Uo(e.backgroundColor)?s&&t("buttonBg","transparent",`${n} (outline)`):t("buttonBg",e.backgroundColor,n),t("buttonFg",e.color,n),i?(t("buttonBorderColor",i.color,`${n} ${i.how}`),t("buttonBorderWidth",i.width,`${n} ${i.how}`)):(t("buttonBorderColor",r?e.borderTopColor:e.backgroundColor,n),t("buttonBorderWidth",r?e.borderTopWidth:"0px",n)),t("buttonRadius",e.borderTopLeftRadius,n),t("buttonCase",e.textTransform,n),t("buttonSpacing","normal"===e.letterSpacing?"0px":e.letterSpacing,n),t("buttonFont",e.fontFamily,n),t("buttonWeight",e.fontWeight,n)}const dr=[{name:"Dawn",marker:"--font-body-family",read:{fg:"rgb(var(--color-foreground, var(--color-base-text)))",bg:"rgb(var(--color-background, var(--color-base-background-1)))",bodyFont:"var(--font-body-family)",headingFont:"var(--font-heading-family)",buttonBg:"rgb(var(--color-button, var(--color-base-accent-1)))",buttonFg:"rgb(var(--color-button-text, var(--color-base-solid-button-labels)))",buttonRadius:"var(--buttons-radius)",mediaRadius:"var(--media-radius)",cardRadius:"var(--product-card-corner-radius)",pageWidth:"var(--page-width)"}},{name:"Horizon",marker:"--font-body--family",read:{fg:"var(--color-foreground)",bg:"var(--color-background)",bodyFont:"var(--font-body--family)",headingFont:"var(--font-heading--family)",buttonRadius:"var(--style-border-radius-buttons-primary)"}}];function lr(t,e){const{kind:n}=xo[t];return Bo("color"===n?"color":"length"===n?"pageWidth"===t?"width":"borderTopLeftRadius":"fontFamily",e)}function ur(t){const e={},n=(t,n,o)=>{const r=n.trim();!(""===r||!("buttonBg"===t&&"transparent"===r)&&"color"===xo[t].kind&&Uo(r))&&void 0===e[t]&&function(t,e){return e.length<=200&&Co[t].test(e.trim())}(xo[t].kind,r)&&(e[t]={value:r,how:o})};return function(t,e){const n=getComputedStyle(document.body);t("fg",n.color,"body text");let o=n.backgroundColor;Uo(o)&&(o=getComputedStyle(document.documentElement).backgroundColor),t("bg",Uo(o)?"rgb(255, 255, 255)":o,Uo(o)?"browser default":"page background"),t("bodyFont",n.fontFamily,"body text"),t("bodyWeight",n.fontWeight,"body text"),t("bodyStyle",n.fontStyle,"body text"),t("bodySize",n.fontSize,"body text");const r=Fo(Jo,t=>""!==t.textContent.trim());if(r){const e=getComputedStyle(r.node),n=`heading ${Do(r.node)}`;t("headingFont",e.fontFamily,n),t("headingWeight",e.fontWeight,n),t("headingStyle",e.fontStyle,n),t("headingCase",e.textTransform,n)}const i=ar(e,Uo(o)?"rgb(255, 255, 255)":o);i&&cr(t,getComputedStyle(i.node),i.how,i.node);const s=Fo(Ko,t=>tr(t)&&!ir(t));s&&t("secondaryFg",getComputedStyle(s.node).color,`button ${Do(s.node)}`);const a=Fo(Yo);if(a){const e=[a.node,...Qo(a.node,4)].find(t=>!["0px","0",""].includes(getComputedStyle(t).borderTopLeftRadius));t("mediaRadius",e?getComputedStyle(e).borderTopLeftRadius:"0px",e?`product image ${Do(e)}`:`product image ${Do(a.node)} (square)`)}const c=Fo(Go);c&&t("cardRadius",getComputedStyle(c.node).borderTopLeftRadius,`card ${Do(c.node)}`);const d=Fo(Xo,t=>"none"!==getComputedStyle(t).maxWidth&&t.getBoundingClientRect().width>300);d&&t("pageWidth",getComputedStyle(d.node).maxWidth,`content width ${Do(d.node)}`)}(n,t),function(t){const e=getComputedStyle(document.documentElement),n=dr.find(t=>""!==e.getPropertyValue(t.marker).trim());for(const[e,o]of Object.entries(n?.read??{}))t(e,lr(e,o),`${n?.name??""} variable ${o}`)}(n),"other"===t&&void 0===e.buttonFg&&function(t){const e=document.createElement("a");e.className="button button--primary btn btn--primary",e.href="#",e.textContent="Probe",Mo().append(e);const n=getComputedStyle(e);Uo(n.backgroundColor)||cr(t,n,"probe .button.btn",void 0)}(n),Mo().remove(),e}function hr(t){return Object.fromEntries(Object.entries(t).map(([t,e])=>[t,e.value]))}function pr(t){let e=document.querySelector(`#${No}`);e||(e=document.createElement("style"),e.id=No,document.head.append(e)),e.textContent=`:root{${Eo(t)}}`}function fr(t){return Object.keys(xo).filter(e=>void 0===t[e])}function mr(){return"function"==typeof globalThis.matchMedia&&globalThis.matchMedia("(prefers-color-scheme: dark), (forced-colors: active), (prefers-contrast: more)").matches||void 0!==document.documentElement.dataset.darkreaderScheme||null!==document.querySelector('meta[name="darkreader"]')}function gr(t,e){const n=performance.now();t.readings=ur("product"),t.measureMs=Math.round(performance.now()-n);const o=function(t,e){const n=Io({...t,...hr(e)});return Object.keys(xo).some(e=>n[e]!==t[e])?n:void 0}(e,t.readings);void 0!==o&&(pr(o),t.look=o,t.unset=fr(o))}async function yr({page:t,stored:e,post:n,keep:o}){if(e){pr(e.tokens);const n={source:"stored",page:t,readings:{},look:e.tokens,unset:fr(e.tokens)};return"product"===t&&mr()&&gr(n,e.tokens),n}const r=performance.now(),i=ur(t),s=function(t){return Io(hr(t))}(i),a={source:"read",page:t,readings:i,look:s,unset:fr(s),measureMs:Math.round(performance.now()-r)};if(pr(s),"product"!==t||0===Object.keys(s).length||mr())return a;const c=await n(s).catch(()=>{});return a.posted=void 0===c?"failed":c.stored?"stored":"kept",c&&o(c.look),c&&!c.stored&&(pr(c.look.tokens),a.look=c.look.tokens,a.unset=fr(c.look.tokens)),a}const br=/^[\da-f]{8}-[\da-f]{4}-7[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/u;function vr(t){const{config:e}=t,n=te({transport:t.transport,declares:{types:["page_viewed","item_opened","added_to_cart"],addsCarryRoundId:!0},conversationId:t.conversationId}),o=globalThis.callimacusPageView,r=Ee(o)&&"string"==typeof o.id&&br.test(o.id)?o.id:void 0;let i=void 0===r;const s=function(t,e){const n=e.window??globalThis,{history:o}=n,r=new AbortController,{signal:i}=r;let s=n.location.pathname,a=!1;const c=globalThis;c[Nt]=(c[Nt]??0)+1;const d=()=>{t.record("page_viewed",{page:e.page(n.location)})},l=()=>{try{if(a||n.location.pathname===s)return;s=n.location.pathname,d()}catch{}};void 0!==e.current?t.adoptPageView(e.current):!0===n.document.prerendering?n.document.addEventListener("prerenderingchange",d,{once:!0,signal:i}):d();const{pushState:u,replaceState:h}=o,p=function(...t){u.apply(this,t),l()},f=function(...t){h.apply(this,t),l()};return o.pushState=p,o.replaceState=f,n.addEventListener("popstate",l,{signal:i}),()=>{a||(a=!0,c[Nt]=Math.max((c[Nt]??1)-1,0),r.abort(),o.pushState===p&&(o.pushState=u),o.replaceState===f&&(o.replaceState=h))}}(n,{page:t=>{const n=function(t,e){const n=e.endsWith("/")?e.slice(0,-1):e,o=""===n||t!==n&&!t.startsWith(`${n}/`)?t:t.slice(n.length),[r,i,s,a]=o.split("/").filter(Boolean),c=t=>void 0===t?{}:{handle:t.slice(0,255)};switch(r){case void 0:return{kind:"shopify",template:"index"};case"products":return{kind:"shopify",template:"product",...c(i)};case"collections":return"products"===s?{kind:"shopify",template:"product",...c(a)}:void 0===i?{kind:"shopify",template:"list-collections"}:{kind:"shopify",template:"collection",...c(i)};case"blogs":return{kind:"shopify",template:void 0===s?"blog":"article"};case"pages":return{kind:"shopify",template:"page"};case"policies":return{kind:"shopify",template:"policy"};case"account":return{kind:"shopify",template:"customers/account"};case"cart":case"search":return{kind:"shopify",template:r};default:return{kind:"shopify",template:"other"}}}(t.pathname,e.rootUrl),o=i&&""!==e.template?e.template.slice(0,64):n.template;return i=!1,{...n,template:o}},...void 0!==r&&{current:r}}),a=function(t,e={}){const n=e.document??("undefined"==typeof document?void 0:document);if(void 0===n)return()=>{};const o=oe();if(o.runtimes.push(t),void 0===o.stop){const t=t=>{try{const e=t.target??void 0,n=(t=>void 0!==t&&"function"==typeof t.closest)(e)?e.closest("[data-callimacus-event]")??void 0:void 0,o=ne(n,"data-callimacus-event"),{runtimes:r}=oe(),i=void 0===n?void 0:r.find(t=>t.owns(n))??r[0];if(void 0===n||void 0===o||void 0===i)return;const s=ne(n.closest("[data-callimacus-round]")??void 0,"data-callimacus-round")??i.roundOf?.(n),a=function(t){const e={};for(const{name:n,value:o}of t.attributes)""!==o&&n.length>22&&n.startsWith("data-callimacus-event-")&&(e[n.slice(22)]=o);return e}(n);i.collector(n)?.record("custom_event",{name:o,...Object.keys(a).length>0&&{fields:a}},{roundId:s})}catch{}};n.addEventListener("click",t,{capture:!0}),o.stop=()=>{n.removeEventListener("click",t,{capture:!0})}}let r=!1;return()=>{if(r)return;r=!0;const e=oe();e.runtimes=e.runtimes.filter(e=>e!==t),e.runtimes.length>0||(e.stop?.(),e.stop=void 0)}}({owns:t=>null!==t.closest("[data-chapter-id], [data-callimacus-stage]"),collector:()=>n,...void 0!==t.roundOf&&{roundOf:t.roundOf}});return{collector:n,added(t,e,o,r){const i=ae(t,e,{itemId:o.productId,origin:o.origin},r.map(t=>t.data));void 0!==i&&n.record("added_to_cart",i,{roundId:o.roundId})},clicked(t,e,o){n.record("item_opened",{itemId:t,...void 0!==e&&{position:e},surface:"card"},{roundId:o})},stop(){s(),a(),n.stop()}}}const wr=["hero","answer","picks","topic","cross","next","other"],kr=["hero","answer","picks","topic","cross","next"],Sr=new Map([["custom:editorialHero","hero"],["custom:storefrontReply","answer"],["custom:pageAnswer","answer"],["demosthenesResponse","answer"],["custom:demosthenesResponse","answer"],["custom:addToCartResult","answer"],["custom:storefrontPicks","picks"],["custom:collectionGrid","picks"],["custom:problemGuide","topic"],["custom:materialStory","topic"],["custom:sizeCare","topic"],["custom:compareSet","topic"],["custom:storyCards","topic"],["custom:completeSet","cross"],["custom:followUps","next"]]);function Ar(t){return"object"==typeof t&&null!==t&&"string"==typeof t.type&&"function"==typeof t.render}function _r(t){const e=globalThis.callimacusRenderers;if(Array.isArray(e))for(let n=e.length-1;n>=0;n--){const o=e[n];if(Ar(o)&&o.type===t)return o}}function xr(t,e){const n=new Map(t.map(t=>[t.type,t])),o=function(t){return{type:"*",render(e,n){const o=n.text(e);if(""===o)return;const r=ke("div",`cal-fallback-note ${t.pageWidth}`),i=ke("div",`cal-fallback-note__body ${t.rte}`);return xe(i,o),r.append(i),r},update(t,e,n){const o=n.text(e),r=t instanceof Element?t.querySelector(".cal-fallback-note__body"):void 0;return!(""===o||!r||(r.replaceChildren(),xe(r,o),0))}}}(e),r=new Set;return t=>{const e=_r(t)??n.get(t)??_r("*")??n.get("*");return e||(Sr.has(t)?void(r.has(t)||(r.add(t),ge.warn(`no renderer for ${t}, skipped`))):o)}}function Cr(t,e,n){try{const o=t.render(e,n);return o instanceof Node?o:void(null!=o&&ge.error(`renderer for ${e.type} returned something that is not a Node, skipped`))}catch(t){return ge.error(`renderer for ${e.type} threw in render()`,t),!1}}function Er(t,e,n){const o=ke("article","cal-chapter");o.dataset.chapterIndex=String(e.index),void 0!==e.id&&(o.dataset.chapterId=e.id);const r=`CallimacusChapter-${t}`,i=ke("header",`cal-chapter__head ${n.pageWidth}`),s=ke("h2","cal-chapter__heading"),a=ke("button","cal-chapter__toggle");a.type="button",a.setAttribute("aria-expanded","true"),a.setAttribute("aria-controls",r),a.append(ke("span","cal-chapter__question",e.question)),void 0!==e.about&&a.append(ke("span","cal-chapter__about",`About: ${e.about}`));const c=ke("span","cal-chapter__thumbs");c.setAttribute("aria-hidden","true"),a.append(c,function(t,e,n){const o=document.createElementNS(Ae,"svg");o.setAttribute("viewBox",t),o.setAttribute("fill","none"),o.setAttribute("aria-hidden","true"),o.setAttribute("focusable","false"),o.setAttribute("class",n);const r=document.createElementNS(Ae,"path");return r.setAttribute("d",e),r.setAttribute("stroke","currentColor"),r.setAttribute("stroke-width","1.4"),r.setAttribute("stroke-linecap","round"),r.setAttribute("stroke-linejoin","round"),o.append(r),o}("0 0 16 16","M4 6l4 4 4-4","cal-chapter__chevron")),s.append(a),i.append(s);const d=ke("div","cal-chapter__body");d.id=r;const l=new Map;for(const t of wr){const e=ke("div","cal-slot");e.dataset.slot=t,l.set(t,e),d.append(e)}return o.append(i,d),{key:t,id:e.id,question:e.question,about:e.about,sent:e.sent??e.question,index:e.index,status:e.status??0,blocks:e.blocks??[],nodes:new Map,cart:e.cart,slots:l,el:o,body:d,toggle:a,thumbs:c,timing:void 0}}function Tr(t,e){const n=t.slots.get(e);if(!n)throw new Error(`chapter has no ${e} slot`);return n}function Rr(t,e){t.el.dataset.state=e,t.el.setAttribute("aria-busy",String("streaming"===e))}function Or(t){let e;for(const n of t)(!e||n.index>e.index)&&(e=n);return e}function qr(t){return t.blocks.map((t,e)=>({block:t,position:e})).sort((t,e)=>{const n=(t.block.priority??0)-(e.block.priority??0);return 0===n?t.position-e.position:n}).map(({block:t})=>t)}function $r(t,e=""){return"string"==typeof t&&""!==t.trim()?t.trim():e}function Ir(t,e){let n=t.language;try{Intl.NumberFormat.supportedLocalesOf(n)}catch{ge.warn(`invalid language "${n}", formatting prices with "en"`),n="en"}const o=new Map;const r=t.rootUrl.endsWith("/")?t.rootUrl.slice(0,-1):t.rootUrl;return{settings:t,text(t){for(const e of Ue(t)){if(qe(e))return e.trim();if(Ee(e)&&qe(e.text))return e.text.trim()}return""},hits:t=>Le(Array.isArray(t)?t:[t]),picks(t){for(const e of Ue(t)){if(!Array.isArray(e))continue;const t=Le(e);if(t.length>0)return t}return[]},money(e){const r="number"==typeof e?e:e?.amount;if(void 0===r||""===r)return"";const i=Number(r);if(!Number.isFinite(i))return"";const s="object"==typeof e?e.currency:void 0,a=function(t){if(!o.has(t))try{o.set(t,new Intl.NumberFormat(n,{style:"currency",currency:t}))}catch{ge.warn(`invalid currency "${t}", showing bare amounts`),o.set(t,void 0)}return o.get(t)}(void 0===s||""===s?t.currency:s);return a?a.format(i):i.toFixed(2)},url(t){const e=void 0===t?"":function(t){if(!Te(t)){const e=Ee(t.meta)?t.meta.url:void 0;return"string"==typeof e&&/^\/(?!\/)/u.test(e)&&!/[\s\\]/u.test(e)?e:""}const e=encodeURIComponent(t.fields["shopify-handle"]);switch(Re(t)){case"product":return`/products/${e}`;case"collection":return`/collections/${e}`;case"article":{const n=$e(t.fields["shopify-blogHandle"]);return""===n?"":`/blogs/${encodeURIComponent(n)}/${e}`}default:return""}}(t);return""===e?"":`${r}${e}`},imageUrl(t,{width:e=800,index:n=0}={}){const o=t?.fields.images;if(!Array.isArray(o)||0===o.length)return"";const r=o[n]?.url??o[0]?.url;return"string"!=typeof r||""===r?"":`${r.split("?",1)[0]}?width=${e}`},variantId(t){const e=t?.fields.variantTree?.variants;if(!Array.isArray(e)||0===e.length)return"";const n=e.find(t=>!0===t?.orderable)??e[0];return void 0===n?.id?"":String(n.id).split("/").pop()??""},addToCart:e.addToCart,productClicked:e.productClicked,productAdded:e.productAdded,ask:e.ask,remember:e.remember}}function Nr(){return globalThis.Shopify}function Lr(){try{const t=Nr()?.customerPrivacy?.preferencesProcessingAllowed?.();return void 0===t?"unknown":!0===t?"allowed":"refused"}catch{return"unknown"}}function Mr(t){return be("sessionStorage",t)??("allowed"===Lr()?be("localStorage",t):void 0)}function Br(t){const e=Mr(t);if(void 0!==e&&""!==e)try{return JSON.parse(e)}catch{return void ge.warn(`ignoring unreadable "${t}"`)}}function jr(t,e){const n=ve("sessionStorage",t,e);return"allowed"!==Lr()||ve("localStorage",t,e)||we("localStorage",t),n}function Ur(t){we("localStorage",t),we("sessionStorage",t)}function Fr(t){const e=Lr();if("unknown"!==e)for(const n of t){if("allowed"===e){const t=be("sessionStorage",n);void 0!==t&&ve("localStorage",n,t);continue}const t=be("localStorage",n);void 0!==t&&(void 0===be("sessionStorage",n)&&ve("sessionStorage",n,t),we("localStorage",n))}}const Dr="callimacus.memory",Pr=6,Wr=12,zr=12,Vr=new TextEncoder;function Hr(t){return Array.isArray(t)?t.filter(t=>Ee(t)):[]}function Kr(t){return"number"==typeof t&&Number.isFinite(t)?t:0}function Jr(){const t=Br(Dr),e=Ee(t)?t:{};return{questions:Hr(e.questions).filter(t=>"string"==typeof t.q).map(t=>({q:t.q,at:Kr(t.at)})),viewed:Hr(e.viewed).filter(t=>"string"==typeof t.handle).map(t=>({handle:t.handle,title:"string"==typeof t.title?t.title:"",at:Kr(t.at)})),added:Hr(e.added).filter(t=>"string"==typeof t.handle).map(t=>({handle:t.handle,at:Kr(t.at)}))}}function Yr(t){return"string"==typeof t?t:Ee(t)&&"string"==typeof t.handle?t.handle:""}function Gr(t,e){const n=Jr(),o=Date.now();switch(t){case"questions":case"question":{const t="string"==typeof e?e.trim():"";if(""===t)return;n.questions=[{q:t,at:o},...n.questions.filter(e=>e.q!==t)].slice(0,12);break}case"viewed":{const t=Yr(e);if(""===t)return;const r=Ee(e)&&"string"==typeof e.title?e.title:"";n.viewed=[{handle:t,title:r,at:o},...n.viewed.filter(e=>e.handle!==t)].slice(0,12);break}case"added":{const t=Yr(e);if(""===t)return;n.added=[{handle:t,at:o},...n.added.filter(e=>e.handle!==t)].slice(0,12);break}default:return void ge.warn(`remember() does not know "${t}"`)}jr(Dr,JSON.stringify(n))}function Xr(t,e){const n=t=>t.slice(0,200),o=t=>t.length<=200,r={questions:t.questions.map(t=>t.q).filter(t=>t!==e).slice(0,Pr).map(t=>n(t)),viewed:t.viewed.filter(t=>o(t.handle)).slice(0,Wr).map(({handle:t,title:e})=>""===e?{handle:t}:{handle:t,title:n(e)}),added:t.added.map(t=>t.handle).filter(t=>o(t)).slice(0,zr)};for(;Vr.encode(JSON.stringify(r)).length>4096;){let t="viewed";for(const e of["added","questions"])r[e].length>r[t].length&&(t=e);r[t].pop()}return r}function Zr(t){return ke("div",`cal-skeleton__bone cal-skeleton__bone--${t}`)}function Qr(t,e){const n=ke("ul",e.grid(t));for(let o=0;o<t;o++){const t=ke("li",e.gridItem),o=ke("div","cal-skeleton__card");o.append(Zr("media"),Zr("title"),Zr("price")),t.append(o),n.append(t)}return n}function ti(){const t=ke("div","cal-skeleton__lines");return t.append(Zr("line"),Zr("line"),Zr("line")),t}function ei(t,e,n){const o=ke("div","cal-skeleton");o.dataset.skeleton=t,o.setAttribute("aria-hidden","true");const r=ke("div","cal-skeleton__inner"),i="hero"===t&&0===e,s=ke("div",i?"cal-skeleton__content":`cal-skeleton__content${"hero"!==t||i?"":" cal-skeleton__content--row"} ${n.pageWidth}`);return s.append(...function(t,e,n){switch(t){case"hero":return e?[Zr("hero")]:[Zr("lead"),ti()];case"answer":return[ti()];case"picks":return[Qr(4,n)];case"topic":return[Zr("topic")];case"cross":return[Qr(3,n)];case"next":{const t=ke("div","cal-skeleton__chips");return t.append(Zr("chip"),Zr("chip"),Zr("chip")),[t]}case"other":return[]}}(t,i,n)),r.append(s),o.append(r),o}function ni(t,e){if(!Ee(t)||"shopify-add"!==t.command||"string"!=typeof t.chapterId||"string"!=typeof t.variantId||!(t=>fe.test(t))(t.variantId))return;if(void 0!==e&&"string"==typeof t.storyId&&t.storyId!==e)return;const n=Ee(t.item)?t.item:{},o=(Array.isArray(n.options)?n.options:[]).filter(t=>Ee(t)&&"string"==typeof t.value).map(t=>{const{name:e,value:n}=t;return{name:"string"==typeof e?e:"",value:n}});return{storyId:"string"==typeof t.storyId?t.storyId:e??"",chapterId:t.chapterId,command:"shopify-add",variantId:t.variantId,quantity:"number"==typeof t.quantity?t.quantity:NaN,item:{id:"string"==typeof n.id?n.id:"",name:"string"==typeof n.name&&""!==n.name?n.name:"This product",options:o}}}function oi(t,e){const n=String(t?.id??"");if(void 0===e||e!==t?.title||!/^\d+$/u.test(n))return{};const{innerWidth:o,innerHeight:r}=globalThis,i={id:`shopify:product:gid://shopify/Product/${n}`,isVisible:!0,visibilityRatio:1,bounds:{x:0,y:0,width:o,height:r,top:0,left:0,right:o,bottom:r}};return{uiSnapshot:{timestamp:Date.now(),viewport:{width:o,height:r},elements:[i],blockIds:[]}}}const ri="callimacus.thread",ii="callimacus.storyId",si=15e5;function ai(t){return Array.isArray(t)?t.filter(t=>Ee(t)&&"string"==typeof t.id&&""!==t.id):[]}function ci(t){const e=t.inputEvent;return Ee(e)&&Ee(e.data)?Ie(e.data.value):""}function di(t){const e=t.lastIndexOf(" (about the ");if(-1===e||!t.endsWith(")"))return{question:t,about:void 0};const n=t.slice(e+12,-1);return""===n?{question:t,about:void 0}:{question:t.slice(0,e),about:n}}function li(t){const e=Number(t);return Number.isFinite(e)?e:0}function ui(){return Mr(ii)}function hi(t){void 0===t?Ur(ii):jr(ii,t)}const pi=new Set(["added","refused","unavailable","failed"]);function fi(t){const{notice:e}=t;return Ee(e)&&"string"==typeof e.outcome&&pi.has(e.outcome)&&"string"==typeof e.message?{notice:{outcome:e.outcome,message:e.message}}:{}}function mi(){const t=Br(ri);return Array.isArray(t)?t.filter(t=>Ee(t)&&"string"==typeof t.question).map(t=>t).map(t=>{const e=t.question;return{id:""===Ie(t.id)?void 0:Ie(t.id),question:e,about:""===Ie(t.about)?void 0:Ie(t.about),sent:""===Ie(t.sent)?e:Ie(t.sent),index:li(t.index),status:li(t.status),blocks:ai(t.blocks),...Ee(t.cart)&&{cart:fi(t.cart)}}}).sort((t,e)=>t.index-e.index).slice(-12):[]}function gi(t){return Math.round(performance.now()-t.t0)}const yi=4e3,bi=[ri,ii,Dr],vi="data-callimacus-on",wi=new Set([401,403]),ki=new Set(["invalid_token","origin_not_allowed","paused"]);function Si(t){return"function"==typeof globalThis.matchMedia?globalThis.matchMedia(t):{matches:!1}}function Ai(t){const{kit:e}=t,n=t.roundTimeoutMs??45e3,o=t.createTransport??(()=>new Wt),r=function(){let t={};try{const e=JSON.parse(document.querySelector("#callimacus-config")?.textContent??"{}");t=Ee(e)?e:{}}catch(t){ge.error("#callimacus-config is not valid JSON",t)}const e=globalThis.Shopify,n=Ee(t.product)&&""!==$r(t.product.handle)?Object.freeze({handle:$r(t.product.handle),title:$r(t.product.title),id:"number"==typeof t.product.id||"string"==typeof t.product.id?t.product.id:void 0}):void 0,o=$r(t.storeName,"this store");return Object.freeze({language:$r(t.language,"en"),rootUrl:$r(t.rootUrl,"/"),cartAddUrl:$r(t.cartAddUrl,"/cart/add"),currency:$r(t.currency,"USD"),designMode:!0===t.designMode||Boolean(e?.designMode),template:$r(t.template),product:n,storeName:o,assistantLabel:$r(t.assistantLabel,`Ask ${o}`),starters:Object.freeze(Array.isArray(t.starters)?t.starters.map(t=>$r(t)).filter(t=>""!==t):[])})}(),i=function(t){return{connecting:"Connecting…",asking:"Thinking…",streaming:"Composing your answer…",done:"Answer ready.",queued:t=>`Queued: “${t}”. I’ll ask that next.`,queueFull:"Still answering. Ask again in a moment.",dequeued:"Removed from the queue.",timeout:"This is taking longer than usual. Try asking again.",failed:"Something went wrong. Please try again.",reconnecting:"Reconnecting…",unavailable:`${t.assistantLabel} is unavailable right now. Please try again later.`,trimmed:"Earlier answers were trimmed from this conversation.",designMode:`${t.assistantLabel} answers on the live store, not in the theme editor.`,interrupted:"This answer stopped before it was finished.",unanswered:`${t.storeName} could not answer that just now.`}}(r),s=document.documentElement,a=new AbortController,{signal:c}=a,d=[],l=Si("(prefers-reduced-motion: reduce)"),u=Si("(pointer: coarse)"),h={ui:"idle",storyId:void 0,isConnected:!1,isOff:!1,thread:[],round:void 0,queue:[],about:r.product?.title,hydrateMode:void 0,refreshTimer:void 0,lastAsk:void 0,statusTimer:void 0,nextKey:0},p=[],f=xr(t.renderers,e.classes);let m;const g=function(t,e={}){const n=new Set;function o(e){const o=function(){try{const e=JSON.parse(t().getItem(ue)??"[]");return Array.isArray(e)?e.filter(t=>"string"==typeof t):[]}catch{return}}();if(o?.includes(e)||n.has(e))return!1;try{t().setItem(ue,JSON.stringify([...o??[],e].slice(-50)))}catch{n.add(e)}return!0}return async(t,n)=>{if(void 0===n||!o(t.chapterId))return;const r=Math.trunc(t.quantity),i=Math.min(Math.max(Number.isFinite(r)?r:1,1),10),s=await n(i);return void 0===s.error&&e.collector?.()?.record("added_to_cart",{itemId:t.item.id,variantId:t.variantId,quantity:i,origin:"request"},{roundId:t.chapterId}),{notice:pe({id:t.chapterId,item:t.item,quantity:i},s),...s.error&&{code:s.error.code}}}}(()=>sessionStorage,{collector:()=>m?.collector});function y(){a.abort(),m?.stop();for(const t of d)t.disconnect();clearTimeout(h.refreshTimer),clearTimeout(h.statusTimer),clearTimeout(h.round?.timer)}function b(t,e){document.dispatchEvent(new CustomEvent(t,{detail:e}))}function v(t){h.ui!==t&&(h.ui=t,s.dataset.callimacusState=t,b("callimacus:state",{state:t}))}function w(t,{clearAfter:e=0}={}){clearTimeout(h.statusTimer);for(const e of document.querySelectorAll("[data-callimacus-status]"))e.textContent=t;e>0&&(h.statusTimer=setTimeout(()=>{w("")},e))}function k(t){h.storyId=""===t?void 0:t,hi(h.storyId)}function S(t,e,n){const o=String(t).split("/").pop()??"";m?.added(o,e,n,h.thread.find(t=>void 0!==t.id&&t.id===n.roundId)?.blocks??[])}async function A(t,n=1,o){const i=String(t).split("/").pop()??"";if(!/^\d+$/u.test(i))throw new Error("This product cannot be added right now.");const s=await e.addToCart(i,n,r);return"string"==typeof s.handle&&""!==s.handle&&Gr("added",s.handle),o&&S(i,n,o),s}const _=Ir(r,{addToCart:async(t,e,n)=>A(t,e,n??{}),productClicked(t,e){m?.clicked(t,e,void 0)},productAdded(t,e,n){S(t,e,{...n,origin:"card"})},ask:t=>"refused"!==W(t,{type:"relatedQuestion"}),remember:Gr});const x={stage:void 0,thread:void 0,earlier:void 0,trimmed:void 0,dock:document.querySelector("[data-callimacus-dock]")??void 0};function C(){return x.stage?.dataset.stageKind??"page"}function E(){let t=document.querySelector("[data-callimacus-stage]")??void 0;t||(t=ke("div","cal-stage"),t.dataset.callimacusStage="",t.dataset.stageKind="page",t.dataset.callimacusUi="",(document.querySelector("#MainContent")??document.body).prepend(t));let n=t.querySelector("[data-callimacus-thread]")??void 0;n||(n=ke("div","cal-thread"),n.dataset.callimacusThread="",t.append(n)),n.classList.add("cal-thread");const o=ke("button",`cal-thread__earlier ${e.classes.pageWidth}`);o.type="button",o.hidden=!0,o.addEventListener("click",()=>{R(!1)},{signal:c});const r=ke("p",`cal-thread__trimmed ${e.classes.pageWidth}`,i.trimmed);return r.hidden=!0,n.after(o,r),Object.assign(x,{stage:t,thread:n,earlier:o,trimmed:r}),{stage:t,thread:n}}function T(){return x.thread??E().thread}function R(t){x.thread&&(x.thread.toggleAttribute("data-compact",t),O())}function O(){if(!x.earlier||!x.thread||!x.trimmed)return;const t=h.thread.length-1,e=Object.hasOwn(x.thread.dataset,"compact"),n=e&&t>0;x.earlier.hidden=!n,n&&(x.earlier.textContent=`Show ${t} earlier question${1===t?"":"s"}`),x.trimmed.hidden=e||0===h.thread.length||h.thread.some(t=>0===t.index)}function q(){const t=new Set([...h.thread].sort((t,e)=>e.index-t.index).slice(12));for(const e of t)e.el.remove();h.thread=h.thread.filter(e=>!t.has(e))}function $(t){h.nextKey+=1;const n=Er(h.nextKey,t,e.classes);return n.toggle.addEventListener("click",()=>{N(n,Object.hasOwn(n.el.dataset,"collapsed"))},{signal:c}),n}function I(t){for(const n of kr){const o=Tr(t,n);o.querySelector(":scope > .cal-block, :scope > .cal-skeleton")||o.append(ei(n,t.index,e.classes))}}function N(t,e,{shouldAnimate:n=!0}={}){e!==!Object.hasOwn(t.el.dataset,"collapsed")&&(e||t.thumbs.replaceChildren(...function(t){const e=new Set,n=[],o=qr(t).flatMap(t=>_.picks(t));for(const t of o){if(4===n.length)break;const o=t.fields["shopify-handle"],r=_.imageUrl(t,{width:160});if(""===r||e.has(o))continue;e.add(o);const i=ke("img","cal-chapter__thumb");i.src=r,i.alt="",i.loading="lazy",i.decoding="async",i.width=40,i.height=50,n.push(i)}return n}(t)),t.el.toggleAttribute("data-collapsed",!e),t.toggle.setAttribute("aria-expanded",String(e)),t.body.inert=!e,e&&n&&!l.matches&&(t.el.dataset.animating="",setTimeout(()=>{delete t.el.dataset.animating},360)))}function L(t){const e=t.el,n=()=>{t.el.style.setProperty("--cal-header-height",`${function(){if("function"!=typeof document.elementsFromPoint)return 0;const t=document.documentElement.clientWidth;let e=0;for(const n of[.25,.5,.75])for(const o of document.elementsFromPoint(Math.round(t*n),1)){const t=Ce(o)?.getBoundingClientRect();t&&t.top<=1&&t.bottom>e&&t.bottom<globalThis.innerHeight/2&&(e=t.bottom)}return Math.round(e)}()}px`),e.scrollIntoView?.({behavior:l.matches?"auto":"smooth",block:"start"})};"function"==typeof requestAnimationFrame?requestAnimationFrame(n):n()}function M(t,n){const o=t.body.querySelector(":scope > .cal-chapter__note");if(!n)return void o?.remove();if(o)return;const r=ke("div",`cal-chapter__note ${e.classes.pageWidth}`);r.append(ke("p","",t.blocks.length>0?i.interrupted:i.unanswered));const s=ke("button","cal-chapter__retry","Ask again");s.type="button",s.addEventListener("click",()=>{W(t.question,{type:"question",about:t.about})},{signal:c}),r.append(s),t.body.append(r)}function B(t,e,n,o){const r=Tr(t,Sr.get(e.type)??"other"),i=ke("div","cal-block");i.dataset.blockId=e.id,i.dataset.blockType=e.type,i.dataset.order=String(o.order),i.append(n),r.querySelector(":scope > .cal-skeleton")?.remove();const s=[...r.children].find(t=>Number(t.dataset.order)>o.order)??r.querySelector(":scope > .cal-cart-notice");if(s?s.before(i):r.append(i),o.shouldAnimate&&!l.matches){const t=60*o.stagger;i.style.setProperty("--cal-stagger",`${t}ms`),i.dataset.arriving="",setTimeout(()=>{delete i.dataset.arriving,i.style.removeProperty("--cal-stagger")},240+t+60)}var a;return a=t.timing,"pending"===a?.outcome&&void 0===a.firstBlockMs&&(a.firstBlockMs=gi(a),performance.mark(`callimacus:chapter-${a.chapter}:first-block`)),b("callimacus:block",{chapterId:t.id,blockId:e.id,type:e.type,node:n}),i}function j(t,e,n,o){const r=f(e.type);if(!r||!Fe(e))return!1;const i=function(t,e){return`${void 0===t.cart?"":"cart|"}${JSON.stringify(e.data)}`}(t,e);let s=t.nodes.get(e.id);if(s?.wrap&&(s.wrap.dataset.order=String(o.order)),!0===s?.isBroken)return!1;if(void 0===s?.node){if(s?.signature===i&&!o.hasBecomeDone)return!1;const a=Cr(r,e,n);return s={signature:i,node:!1===a?void 0:a,wrap:void 0,isBroken:!1===a},t.nodes.set(e.id,s),s.node?(s.wrap=B(t,e,s.node,o),!0):!1}if(i===s.signature&&!o.hasBecomeDone)return!1;if(s.signature=i,function(t,e,n,o){if("function"!=typeof t.update)return!1;try{return t.update(e,n,o)}catch(t){return ge.error(`renderer for ${n.type} threw in update()`,t),!1}}(r,s.node,e,n))return!1;const a=Cr(r,e,n);return!1===a?s.isBroken=!0:a&&s.wrap&&(s.wrap.replaceChildren(a),s.node=a),!1}function U(t,{hasBecomeDone:e=!1,shouldAnimate:n=!0}={}){const o=function(t){const e=4===t.status,n=Object.freeze({id:t.id,index:t.index,isFirst:0===t.index,question:t.question,done:e,blocks:Object.freeze([...t.blocks]),addedToCart:void 0!==t.cart});return Object.freeze({..._,addToCart:async(e,n,o)=>A(e,n,{...o,roundId:t.id}),productClicked(e,n){m?.clicked(e,n,t.id)},productAdded(e,n,o){S(e,n,{...o,origin:"card",roundId:t.id})},chapter:n,final:e})}(t);let r=0;for(const[i,s]of qr(t).entries())j(t,s,o,{order:i,stagger:r,hasBecomeDone:e,shouldAnimate:n})&&(r+=1)}const F=function(t){let e,n=!1,o=!1,r=0;const i=[];function s(e,o=t.session.current()){n=!1,o.then(o=>{if(!t.isOff()){if(!o)return i.length=0,void t.onRefused();e.connect(o.endpoint,{Authorization:`Bearer ${o.token}`},{token:o.token}),n=!0;for(const t of i.splice(0))t(e)}}).catch(e=>{ge.warn("no storefront session",e),i.length=0,t.onError({code:503,reason:"retries_exhausted",message:"no storefront session"})})}function a(){if(e)return o&&(o=!1,s(e)),e;const n=t.createTransport();return n.onServerResponse(t.onResponse),n.onError(t.onError),n.onConnectionStatus(t.onStatus),e=n,s(n),n}return{connect:a,send:function(t,e){const o=a();n?o.sendUserInteraction(t,e):i.push(n=>{n.sendUserInteraction(t,e)})},markFailed(){o=!0},didRenew:function(){const n=Date.now();return!(!e||n-r<6e4||(r=n,ge.info("the storefront token expired; asking the store for a fresh one"),s(e,t.session.renew()),0))}}}({session:t.session,createTransport:o,onResponse:function(t){const e=t;switch(e.type){case wt:!function(t){if(!Ee(t)||"string"!=typeof t.id||""===t.id)return;t.id!==h.storyId&&k(t.id);const e=(Array.isArray(t.chapters)?t.chapters:[]).filter(t=>Ee(t)&&"string"==typeof t.id&&""!==t.id&&!0!==t.deleted).map(t=>t);e.length>0?function(t){const e="restore"===h.hydrateMode;let n=!1;for(const o of t.slice(-12)){const r=t.indexOf(o),i=h.thread.find(t=>t.id===o.id)??J(o);if(i){e&&nt(i,r),Y(i,o,h.round?.rec===i);continue}const s=ci(o);if(!e||""===s)continue;const{question:a,about:c}=di(s);tt({id:o.id,question:a,about:c,sent:s,index:r,status:"number"==typeof o.status?o.status:0,blocks:ai(o.blocks)}),n=!0}if(n){const e=new Set(t.map(t=>t.id));let n=t.length;for(const t of h.thread)e.has(t.id)||nt(t,n++);pt(),et(),Q()}e&&(h.hydrateMode="refresh")}(e):"restore"===h.hydrateMode&&(h.hydrateMode="refresh")}(e.story);break;case vt:!function(t){if(!Ee(t)||"string"!=typeof t.id||""===t.id||!0===t.deleted)return;const e=h.thread.find(e=>e.id===t.id)??J(t);e?Y(e,t,!0):ge.debug("chapter-event for a chapter this page does not show",t.id)}(e.chapter);break;case kt:!async function(t){const e=ni(t,h.storyId);if(!e)return void ge.debug("cart-command this page does not run");const n=h.thread.find(t=>t.id===e.chapterId)??h.round?.rec,o=await g(e,async t=>(n&&(n.cart={},M(n,!1),U(n,{shouldAnimate:!1}),Q()),en(async()=>A(e.variantId,t))));if(!o)return;const{notice:r}=o;if(w(r.message,{clearAfter:8e3}),b("callimacus:cart",{outcome:r.outcome,variantId:e.variantId,quantity:r.quantity,..."added"!==r.outcome&&{message:r.message}}),!n)return;n.cart={notice:{outcome:r.outcome,message:r.message}},D(n),Q()}(e.data);break;default:ge.debug("ignored server response",e.type)}},onError:function(t){const{code:e}=t;if(ge.warn("server error",e,t.message??"",t.reason??""),"token_expired"===t.reason&&F.didRenew())return;if(function(t){return wi.has(t.code)&&(!h.isConnected||ki.has(t.reason??""))}(t))return void P(t);const{round:o}=h;if(404===e&&(k(void 0),it({shouldFailPending:!0}),o&&!o.isRetried&&void 0===o.rec.id))return o.isRetried=!0,ge.info("story not found, asking again as a new story"),clearTimeout(o.timer),o.timer=setTimeout(()=>{K(o)},n),void H(o);const r=!h.isConnected;if(r&&"retries_exhausted"!==t.reason&&!(e>=400&&e<500))return void(o&&w(i.reconnecting));r&&F.markFailed();o?(w(r?i.unavailable:i.failed),G(o.rec,"error")):r&&(v("error"),w(i.unavailable))},onStatus:function(t){h.isConnected=t;const{round:e}=h;if(!t||!e||void 0!==e.rec.timing?.firstEventMs)return;v("asking"),w(i.asking)},isOff:()=>h.isOff,onRefused(){const{status:t,reason:e}=yo()??{status:401,reason:"invalid_token"};P({code:t,reason:e})}});function D(t){const n=t.cart?.notice;n&&Tr(t,"answer").append(Se(n,e.classes.pageWidth))}function P(t){const e="paused"===t.reason;if(ge.warn(`the store refused this storefront (${String(t.code)} ${t.reason??""}); the theme's own search is back`),h.isOff=!0,go({status:t.code,reason:t.reason}),it(),h.queue=[],dt(),h.round&&G(h.round.rec,"error"),v("error"),e){for(const t of document.querySelectorAll('[data-callimacus-form] input[name="q"], [data-callimacus-form] [type="submit"], [data-callimacus-open], button[data-callimacus-ask]'))t.disabled=!0;w(i.unavailable)}else s.removeAttribute(vi),w("");b("callimacus:off",{code:t.code,reason:t.reason})}function W(t,{type:e="question",about:n}={}){const o=Ie(t),s=function(t){if(""===t||h.isOff)return"";if(r.designMode)return i.designMode;const e=Date.now();return h.lastAsk?.text===t&&e-h.lastAsk.at<600?"":(h.lastAsk={text:t,at:e},h.round&&h.queue.length>=3?i.queueFull:void 0)}(o);if(void 0!==s)return""!==s&&w(s,{clearAfter:s===i.unavailable?0:yi}),"refused";const a={display:o,about:n,type:e,sent:void 0===n?o:`${o} (about the ${n})`,visit:Xr(Jr(),o)};return Gr("questions",o),b("callimacus:ask",{question:o,type:e,queued:Boolean(h.round)}),h.round?(h.queue.push(a),dt(),w(i.queued(o),{clearAfter:yi}),"queued"):(z(a),"sent")}function z(t){const e=$({question:t.display,about:t.about,sent:t.sent,index:V()});for(const t of h.thread)N(t,!1);h.thread.push(e),T().prepend(e.el),q(),Rr(e,"streaming"),I(e),pt(),ct(),O();const o={rec:e,type:t.type,visit:t.visit,timer:void 0,isRetried:!1};var r,s;h.round=o,e.timing=(r=e.index,s=e.question,performance.mark(`callimacus:chapter-${r}:sent`),{chapter:r,question:s,chapterId:void 0,sentAt:(new Date).toISOString(),firstEventMs:void 0,firstBlockMs:void 0,doneMs:void 0,outcome:"pending",t0:performance.now()}),p.push(e.timing),v(h.isConnected?"asking":"connecting"),w(h.isConnected?i.asking:i.connecting),o.timer=setTimeout(()=>{K(o)},n),L(e),Q(),b("callimacus:chapter",X(e)),H(o)}function V(){let t=0;for(const e of h.thread)t=Math.max(t,e.index+1);return t}function H(t){try{F.connect()}catch(e){return ge.error("could not start the Callimacus client",e),void(h.round===t&&(w(i.unavailable),G(t.rec,"error")))}if(h.round===t)try{!function(t){const e=m?.collector.pageViewId,n={visit:t.visit,shopifyCart:!0,...oi(r.product,t.rec.about),...void 0!==e&&{pageViewId:e}},o={...void 0!==h.storyId&&{storyId:h.storyId},language:r.language,inputEvent:{type:t.type,data:{value:t.rec.sent}},context:n};F.send(Mt.CREATE_ROUND,o)}(t)}catch(e){ge.error("could not send the question",e),w(i.failed),G(t.rec,"error")}}function K(t){h.round===t&&(ge.warn(`no complete answer within ${n/1e3} s for “${t.rec.question}”`),w(i.timeout),G(t.rec,"timeout"))}function J(t){const e=ci(t),n=""===e?void 0===h.round?.rec.id?h.round?.rec:void 0:h.thread.findLast(t=>void 0===t.id&&t.sent===e);if(n&&"string"==typeof t.id)return n.id=t.id,n.el.dataset.chapterId=t.id,n}function Y(t,e,n){const o=4===t.status;var r,s;t.blocks=function(t,e){const n=[...t];for(const t of e){const e=n.findIndex(e=>e.id===t.id);-1===e?n.push(t):n[e]=t}return n}(t.blocks,ai(e.blocks)),t.status="number"==typeof e.status?e.status:t.status,h.round?.rec===t&&void 0===t.timing?.firstEventMs&&(r=t.timing,s=t.id,r&&void 0===r.firstEventMs&&(r.firstEventMs=gi(r),r.chapterId=s),v("streaming"),w(i.streaming));const a=!o&&4===t.status;U(t,{hasBecomeDone:a,shouldAnimate:n}),a&&G(t,"done")}function G(t,e){const n="done"!==e;Rr(t,n?"error":"done"),function(t){for(const e of t.body.querySelectorAll(":scope > .cal-slot > .cal-skeleton")){if(Object.hasOwn(e.dataset,"leaving"))continue;e.dataset.leaving="";const t=()=>{e.remove()};e.addEventListener("transitionend",t,{once:!0}),setTimeout(t,400)}}(t),M(t,n&&!h.isOff&&void 0===t.cart),function(t,e,n){if("pending"!==t?.outcome)return;t.outcome=n,t.chapterId=e,t.doneMs=gi(t),performance.mark(`callimacus:chapter-${t.chapter}:${n}`);const{t0:o,...r}=t;ge.debug("timing",r)}(t.timing,t.id,e),Q(),b("callimacus:chapter",X(t));const o=h.round?.rec===t?h.round:void 0;o&&(clearTimeout(o.timer),h.round=void 0,n?v("error"):(v("idle"),w(i.done,{clearAfter:yi})),function(){if(void 0!==h.round||h.isOff)return;const t=h.queue.shift();if(!t)return;dt(),z(t)}())}function X(t){return{id:t.id,index:t.index,question:t.question,state:t.el.dataset.state}}function Z(t){return{id:t.id,question:t.question,about:t.about,sent:t.sent,index:t.index,status:t.status,blocks:t.blocks,...t.cart&&{cart:t.cart}}}function Q(){!function(t){if(0===t.length)return;const e=[...t].sort((t,e)=>t.index-e.index).slice(-12);let n=JSON.stringify(e);if(n.length>si){for(const t of e)t.blocks=De(t.blocks);n=JSON.stringify(e)}for(;e.length>0;){if(n.length<=si&&jr(ri,n))return;e.shift(),n=JSON.stringify(e)}Ur(ri)}(h.thread.map(t=>Z(t))),hi(h.storyId)}function tt(t){const e=$(t);h.thread.push(e);const n=4===e.status,o=!n&&void 0!==e.id&&void 0!==h.storyId;return Rr(e,n?"done":o?"streaming":"error"),o&&I(e),U(e,{shouldAnimate:!1}),D(e),n||o||void 0!==e.cart||M(e,!0),e}function et(){q();const t=Or(h.thread),e="home"===C();for(const n of h.thread)N(n,e&&n===t||h.round?.rec===n,{shouldAnimate:!1});!function(){const t=[...h.thread].sort((t,e)=>e.index-t.index);T().append(...t.map(t=>t.el))}(),R(!e),ct()}function nt(t,e){t.index=e,t.el.dataset.chapterIndex=String(e)}function ot(){return h.thread.filter(t=>void 0!==t.id&&4!==t.status&&h.round?.rec!==t&&"streaming"===t.el.dataset.state)}function rt(t=0){clearTimeout(h.refreshTimer);const{storyId:e}=h;if(!(void 0===e||h.isOff||t>0&&"restore"!==h.hydrateMode&&0===ot().length))if(t>=6)it({shouldFailPending:!0});else{try{F.send(Mt.GET_STORY,{storyId:e})}catch(t){ge.error("could not start the Callimacus client",t)}h.refreshTimer=setTimeout(()=>{rt(t+1)},3e3)}}function it({shouldFailPending:t=!1}={}){if(clearTimeout(h.refreshTimer),h.hydrateMode=void 0,t)for(const t of ot())G(t,"error")}const st=t=>x.dock?.querySelector(t)??void 0,at={input:st('input[name="q"]'),chips:st("[data-callimacus-dock-chips]"),count:st("[data-callimacus-thread-count]"),countLabel:st("[data-callimacus-thread-count-label]"),next:st("[data-callimacus-next]"),nextLabel:st("[data-callimacus-next-label]"),about:st("[data-callimacus-about]"),aboutLabel:st("[data-callimacus-about-label]")};function ct(){if(!at.count)return;const t=h.thread.length;at.count.hidden=0===t;const e=`${t} question${1===t?"":"s"}`;at.countLabel&&(at.countLabel.textContent=String(t)),at.count.title=e,at.count.setAttribute("aria-label",`${e} in this conversation. Show the conversation`)}function dt(){if(!at.next)return;const[t]=h.queue;if(at.next.hidden=void 0===t,void 0!==t){const e=h.queue.length>1?` (+${h.queue.length-1})`:"";at.nextLabel&&(at.nextLabel.textContent=`Next: ${t.display}${e}`),at.next.setAttribute("aria-label",`Next question: ${t.display}. Remove it from the queue`)}at.chips&&(at.chips.hidden=[...at.chips.children].every(t=>t instanceof HTMLElement&&!0===t.hidden))}function lt(){const t=h.about;at.about&&(at.about.hidden=void 0===t),void 0!==t&&at.aboutLabel&&(at.aboutLabel.textContent=`About: ${t}`),at.input&&(at.input.placeholder=void 0===t?at.input.dataset.placeholder??at.input.placeholder:"Ask anything about it")}function ut(){at.input&&(at.input.focus(),mt())}function ht(){R(!1);const t=Or(h.thread);t&&(N(t,!0),L(t))}function pt(){const t=document.querySelector("[data-callimacus-welcome]");t&&(t.hidden=!0)}function ft(t){const e=ke("section","cal-welcome__group");return e.append(ke("h2","cal-welcome__title",t)),e}function mt(){if(!r.designMode&&!h.isOff)try{F.connect()}catch(t){ge.error("could not start the Callimacus client",t)}}function gt(){return!h.isOff&&s.hasAttribute(vi)}function yt(t){const e=t.target instanceof Element?t.target.closest("[data-callimacus-form]"):void 0;if(!e||!gt())return;t.preventDefault();const n=e.querySelector('input[name="q"]'),o=n?.value.trim()??"";n&&""!==o?("refused"!==W(o,{type:"question",about:h.about})&&(n.value=""),u.matches&&n.blur()):n?.focus()}function bt(t){if(!(gt()&&t.target instanceof Element))return;const e=t.target.closest("[data-callimacus-ask]");if(e){const n=e.dataset.callimacusAsk?.trim()??"";return void(""!==n&&(t.preventDefault(),W(n,{type:"relatedQuestion"})))}t.target.closest("[data-callimacus-open]")&&(t.preventDefault(),ut())}function St(t){var e;gt()&&("/"!==t.key||t.metaKey||t.ctrlKey||t.altKey||(e=t.target)instanceof Element&&null!==e.closest('input, textarea, select, [contenteditable=""], [contenteditable="true"]')?"Escape"===t.key&&t.target instanceof HTMLElement&&t.target.matches('[data-callimacus-form] input[name="q"]')&&t.target.blur():(t.preventDefault(),ut()))}const At={ask:t=>"refused"!==W(t,{type:"question"}),get thread(){return[...h.thread].sort((t,e)=>t.index-e.index).map(t=>Z(t))},ctx:_,timings:p,get state(){return h.ui},get storyId(){return h.storyId},reset:function(){it(),clearTimeout(h.round?.timer),h.round=void 0,h.queue=[];for(const t of h.thread)t.el.remove();h.thread=[],k(void 0),Ur(ri),dt(),ct(),R(!1),v("idle"),w("")}};s.dataset.callimacusState=h.ui;const _t=globalThis;if(_t.callimacus=At,_t.callimacusTheme={card:e.card,cards:e.cards},void 0!==yo()||!s.hasAttribute(vi))return s.removeAttribute(vi),h.isOff=!0,v("error"),b("callimacus:ready",{designMode:r.designMode,off:!0}),{page:At,destroy:y};if(e.install?.(),function(t,e){Fr(t),document.addEventListener("visitorConsentCollected",()=>{Fr(t)},{signal:e})}(bi,c),h.storyId=ui(),document.addEventListener("submit",yt,{signal:c}),document.addEventListener("click",bt,{signal:c}),document.addEventListener("keydown",St,{signal:c}),document.addEventListener("focusin",t=>{t.target instanceof Element&&t.target.matches('[data-callimacus-form] input[name="q"]')&&mt()},{signal:c}),at.count?.addEventListener("click",ht,{signal:c}),at.next?.addEventListener("click",()=>{h.queue.shift(),dt(),w(i.dequeued,{clearAfter:yi}),at.input?.focus()},{signal:c}),x.dock?.querySelector("[data-callimacus-about-remove]")?.addEventListener("click",()=>{h.about=void 0,lt(),at.input?.focus()},{signal:c}),function(){const{dock:t}=x;if(!t||"function"!=typeof ResizeObserver)return;const e=new ResizeObserver(()=>{s.style.setProperty("--cal-dock-space",`${Math.ceil(t.offsetHeight)}px`)});e.observe(t),d.push(e)}(),globalThis.addEventListener("pagehide",()=>{(void 0!==h.round||ot().length>0)&&Q()},{signal:c}),globalThis.addEventListener("pageshow",t=>{t.persisted&&function(){const t=t=>t.id??`${t.index}:${t.sent}`,e=new Set(h.thread.map(e=>t(e))),n=mi().filter(n=>!e.has(t(n))),o=ui();if(void 0!==o&&o!==h.storyId&&(h.storyId=o),0!==n.length){for(const t of n)tt(t);pt(),et(),O()}}()},{signal:c}),lt(),ct(),dt(),r.designMode)return b("callimacus:ready",{designMode:!0,off:!1}),{page:At,destroy:y};r.product&&Gr("viewed",{handle:r.product.handle,title:r.product.title}),t.events&&(m=vr({transport:t.events,config:r,conversationId:()=>h.storyId,roundOf:t=>t.closest("[data-chapter-id]")?.dataset.chapterId??Or(h.thread)?.id}));const{stage:xt}=E();!function(){for(const t of mi())tt(t);return 0!==h.thread.length&&(et(),!0)}()?void 0!==h.storyId&&(h.hydrateMode="restore",rt()):ot().length>0&&(h.hydrateMode="refresh",rt()),"home"===C()&&function(){const t=document.querySelector("[data-callimacus-welcome]");if(!t)return;const n=Jr(),o=n.questions.slice(0,4),r=n.viewed.slice(0,4);t.querySelector(":scope > .cal-welcome__body")?.remove();const i=ke("div","cal-welcome__body");if(0===h.thread.length&&o.length>0){const t=ft("Pick up where you left off"),n=ke("div","cal-welcome__chips");for(const[t,{q:r}]of o.entries()){const o=ke("button",`cal-chip ${0===t?e.classes.buttonPrimary:e.classes.buttonSecondary}`,r);o.type="button",o.dataset.callimacusAsk=r,n.append(o)}t.append(n),i.append(t)}const s=0===h.thread.length&&r.length>0?e.cards(r.map(t=>({handle:t.handle,title:t.title})),_):void 0;if(s){const t=ft("Recently viewed"),e=ke("div","cal-welcome__cards");e.append(s),t.append(e),i.append(t)}t.hidden=0===i.childNodes.length,t.hidden||t.append(i)}();const Ct=Ie(xt.dataset.askOnLoad);return""!==Ct&&Or(h.thread)?.question!==Ct&&W(Ct,{type:"question"}),b("callimacus:ready",{designMode:!1,off:!1}),{page:At,destroy:y}}const _i="callimacus.pending";function xi(){return document.querySelector("#callimacus-config")??void 0}async function Ci(){Tt();const t=document.documentElement,e=function(){try{const t=JSON.parse(xi()?.textContent??"{}");return Ee(t)?t:{}}catch{return{}}}(),n=function(t){return{cards:"own"===t.cards?"own":"auto",proxyBase:""===Ie(t.proxyBase)?"/apps/callimacus":Ie(t.proxyBase),searchTerms:Ie(t.searchTerms),template:Ie(t.template),starters:Array.isArray(t.starters)?t.starters.map(t=>Ie(t)).filter(t=>""!==t):[],designMode:!0===t.designMode,assistantLabel:""===Ie(t.assistantLabel)?"Ask":Ie(t.assistantLabel)}}(e),o=globalThis.Shopify?.theme?.id,r="number"==typeof o||"string"==typeof o?String(o):"",i=_o(n.proxyBase,r),s=()=>void 0!==yo()||!t.hasAttribute(vi),a=s()?void 0:async function(){const t=Nr();if(void 0!==t?.customerPrivacy||"function"!=typeof t?.loadFeatures)return;const{loadFeatures:e}=t;await new Promise(t=>{const n=setTimeout(t,1e3),o=()=>{clearTimeout(n),t()};try{e([{name:"consent-tracking-api",version:"0.2"}],o)}catch(t){ge.warn("Shopify's privacy API did not load",t),o()}})}(),c=s()?void 0:await i.known(),d=c?.entrance&&{...c.entrance,starters:n.starters.length>0?n.starters:c.entrance.starters.slice(0,4)};let l;d&&0===n.starters.length&&d.starters.length>0&&function(t,e){const n=xi();n&&(n.textContent=JSON.stringify({...t,...e}))}(e,{starters:d.starters}),t.dataset.callimacusTemplate=n.template,s()||(l=await yr({page:"product"!==n.template||n.designMode?"other":"product",stored:c?.look,post:async t=>async function(t,e,n){const o=await fetch(`${t}/look?theme_id=${encodeURIComponent(e)}`,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify({tokens:n})});if(!o.ok)return void ge.warn(`the store did not keep the look (${o.status})`);const r=await o.json();if(!Ee(r))return;const i=wo(r.look);return i&&{stored:!0===r.stored,look:i}}(n.proxyBase,r,t),keep(t){i.keepLook(t)}}));const u=ho(n.assistantLabel),h=po({template:n.template,searchTerms:n.searchTerms,assistantLabel:n.assistantLabel,entrance:d}),p=ro(n.cards);await a;const{page:f}=Ai({kit:p,renderers:Bn(p),session:i,events:le(n.proxyBase)});Object.assign(f,{style:l,embed:{header:u,stage:h,...p.stats}});const m=be("sessionStorage",_i);we("sessionStorage",_i),void 0!==m&&""!==m.trim()&&f.ask(m)}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{Ci()},{once:!0}):Ci()}();
22
22
  //# sourceMappingURL=callimacus.min.js.map