tanya-chatbot 0.7.1 → 0.7.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.
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
lg:transform lg:translate-y-0
|
|
14
14
|
|
|
15
15
|
`,style:{background:"linear-gradient(170.1deg, #FFFFFF 60.03%, #E3DEEF 99.59%)"},children:[n.jsxs("div",{className:"flex justify-between p-3 bg-[#FFFFFF] border border-b-1 border-[#E5E5E5] ",children:[n.jsx("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs("div",{className:"flex gap-2 w-28 h-12 text-center items-center p-2 border rounded-l-[20px] rounded-tr-[20px]",style:{background:"linear-gradient(265.62deg, #6851C6 5.24%, #8668FF 98.49%)"},children:[n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 15 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M15 4.48438V0.5C15 0.5 8.94395 1.4375 6.78127 4.25C4.61859 7.0625 5.33095 15.5 5.33095 15.5H9.19857C9.19857 15.5 8.72793 7.76562 10.1654 6.125C11.6029 4.48438 15 4.48438 15 4.48438Z",fill:"white"}),n.jsx("path",{d:"M0 0.5H6.28488V4.25H0V0.5Z",fill:"white"})]}),n.jsx("p",{className:"text-[#FFFFFF] font-nunitoSans font-semibold",children:"TANYA"})]}),n.jsxs("p",{className:"text-[#5B5B5B] font-nunitoSans font-semibold",style:{fontStyle:"italic"},children:[" ","Your AI shopping assistant !"," "]})]})}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:"1.25rem",margin:"0.75rem"},children:n.jsx("button",{onClick:()=>w(!1),children:n.jsxs("svg",{width:"24",height:"25",viewBox:"0 0 24 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsxs("g",{clipPath:"url(#clip0_501_6036)",children:[n.jsx("path",{d:"M18 6.5L6 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M6 6.5L18 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),n.jsx("defs",{children:n.jsx("clipPath",{id:"clip0_501_6036",children:n.jsx("rect",{width:"24",height:"24",fill:"white",transform:"translate(0 0.5)"})})})]})})})]}),n.jsxs("div",{className:"flex h-full md:flex-row lg:flex-row",children:[n.jsxs("div",{className:`flex flex-col h-full ${R?"lg:w-2/3 w-full":"w-full"}`,children:[n.jsxs("div",{ref:D,className:"overflow-y-auto pr-5 pb-2 space-y-4 hide-scrollbar flex-grow mb-24",children:[(E==null?void 0:E.whomRequired)&&n.jsxs("div",{className:"mx-3 p-3 rounded-2xl bg-[#FFFFFF]",children:[n.jsx("div",{className:"flex gap-2 bg-[#FFFFFF]",children:n.jsx("p",{className:"font-bold font-nunitoSans text-[#494949]",children:"Is this for you or someone else?"})}),n.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:o.map(f=>n.jsx("button",{onClick:()=>ye(f),className:"px-2 py-2 font-semibold text-xs text-[#18181B] bg-[#F3F3F3] rounded-2xl",style:{backgroundColor:oe===s[f]?"#FFFFFF":"#F3F3F3",borderColor:oe===s[f]?"#BBB3DD":""},children:f},f))})]}),Te.map((f,O)=>{var A,V;return n.jsxs("div",{children:[n.jsx("div",{className:"flex justify-end",children:n.jsx("p",{className:"text-sm font-nunitoSans font-bold text-[#000000] bg-[#E2DBFF] border border-[#C9C2DE] rounded-l-xl p-2 m-3 mb-4 rounded-br-xl max-w-[75%]",children:f.query})}),f.response&&f.response.includes("Thinking")?n.jsx("div",{children:n.jsx("div",{className:"font-nunitoSans animate-pulse font-bold text-sm text-[#494949] bg-[#FFFFFF] px-7 py-1 rounded-r-xl rounded-bl-2xl w-full",dangerouslySetInnerHTML:{__html:Zt(f.response)}})}):n.jsx("div",{children:n.jsx("div",{className:"font-nunitoSans font-bold text-sm text-[#494949] bg-[#FFFFFF] px-7 py-1 rounded-r-xl rounded-bl-2xl w-full",dangerouslySetInnerHTML:{__html:Zt(f.response)}})}),Ee&&!f.response.includes("Thinking")&&((A=f.products)==null?void 0:A.length)==0&&n.jsx("div",{children:n.jsx("p",{className:"text-sm animate-pulse font-nunitoSans font-bold text-[#000000] bg-[#E2DBFF] border border-[#C9C2DE] rounded-l-xl p-2 m-3 mb-4 rounded-br-xl max-w-[75%]",children:"Finding best products for you"})}),(f==null?void 0:f.products)&&((V=f==null?void 0:f.products)==null?void 0:V.length)>0&&n.jsx(Ho,{chat:f.products,storeDetails:E}),(f==null?void 0:f.potentialQuestions.length)>0&&n.jsxs("div",{className:"my-2 px-4 text-sm text-gray-700",children:[n.jsx("p",{className:"font-nunitoSans font-bold text-sm text-[#494949]",style:{color:E.themeDarkColor},children:"Why not explore these inquiries..."}),f.potentialQuestions.split(",").map((L,T)=>n.jsx("button",{className:`cursor-pointer font-nunitoSans font-semibold text-[#232323] border bg-[#804C9E0D] border-${E.themeDarkColor} m-1 rounded-xl px-2 py-1`,onClick:()=>_e(L),style:{backgroundColor:E.tanyaThemeColorLight},children:L},T))]}),(f==null?void 0:f.secondaryLoading)&&n.jsx("div",{className:"mt-3 mb-4 px-4",children:n.jsxs("div",{className:"tanya-surprise-wrapper bg-indigo-300 text-sm px-7 py-4 rounded-r-xl rounded-bl-2xl w-full relative overflow-hidden",style:{margin:"0.75rem"},children:[n.jsxs("div",{className:"flex gap-1",children:[n.jsx("div",{className:"tanya-sparkle tanya-sparkle-1",children:"✨"}),n.jsx("div",{className:"tanya-sparkle tanya-sparkle-2",children:"✨"}),n.jsx("div",{className:"tanya-sparkle tanya-sparkle-3",children:"✨"})]}),n.jsx("div",{className:"tanya-shimmer"}),n.jsx("p",{className:"font-semibold tanya-pulse",style:{color:E.themeDarkColor},children:"I’ve found a special surprise crafted just for you… hang on a sec!"}),n.jsx("p",{className:"tanya-dots mt-1",style:{color:E.themeDarkColor},children:"• • •"})]})}),(f==null?void 0:f.secondaryResponse)&&n.jsx(n.Fragment,{children:n.jsxs("div",{className:"mt-3 mb-8 px-4 bg-indigo-300 rounded-tr-[5px]",children:[n.jsx("div",{className:"text-sm text-[#232323] bg-[#FFFFFF] px-7 py-4 rounded-br-xl rounded-bl-2xl w-full",style:{backgroundColor:E.tanyaThemeColorLight},dangerouslySetInnerHTML:{__html:Zt(f.secondaryResponse)}}),f.productSnapshot&&n.jsx("div",{className:"mt-4 w-full",children:n.jsxs("div",{className:"flex gap-4 items-stretch rounded-2xl p-4",style:{backgroundColor:E.tanyaThemeColorLight},children:[n.jsx("div",{className:"flex-shrink-0 rounded-xl overflow-hidden border",style:{width:112,height:112,borderColor:"#eee"},children:f.productSnapshot.image?n.jsx("img",{src:f.productSnapshot.image,alt:f.productSnapshot.name,className:"w-full h-full object-cover"}):n.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs text-gray-500",children:"No Image"})}),n.jsxs("div",{className:"flex flex-col flex-1 justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"font-semibold text-[15px] leading-snug",children:f.productSnapshot.name}),n.jsx("p",{className:"mt-1 text-[14px] font-medium",children:f.productSnapshot.price!=null?new Intl.NumberFormat(void 0,{style:"currency",currency:(E==null?void 0:E.currency)||"USD"}).format(f.productSnapshot.price):""}),f.productSnapshot.points>0&&n.jsxs("p",{className:"mt-1 text-xs opacity-80",children:["You will earn"," ",n.jsxs("strong",{children:[f.productSnapshot.points," ","points"]})]})]}),n.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[n.jsxs("div",{className:"flex items-center border rounded-full overflow-hidden",children:[n.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>me(L=>L.map((T,le)=>le===O&&T.productSnapshot?{...T,productSnapshot:{...T.productSnapshot,quantity:Math.max(1,T.productSnapshot.quantity-1)}}:T)),style:{background:"transparent",color:E.themeDarkColor},children:"−"}),n.jsx("div",{className:"px-3 py-1 text-sm select-none",children:f.productSnapshot.quantity}),n.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>me(L=>L.map((T,le)=>le===O&&T.productSnapshot?{...T,productSnapshot:{...T.productSnapshot,quantity:T.productSnapshot.quantity+1}}:T)),style:{background:"transparent",color:E.themeDarkColor},children:"+"})]}),n.jsx("button",{onClick:()=>{Gt(Ce(f.productSnapshot),f.productSnapshot.quantity)},disabled:I,className:"px-4 py-2 rounded-full font-medium",style:{background:E.tanyaThemeColor,color:(E==null?void 0:E.tanyaThemeContrastColor)||"#fff",opacity:I?.8:1},children:I?"Adding...":"Add to cart"})]})]})]})})]})}),n.jsx("div",{className:"mb-20"})]},O)})]}),n.jsx("div",{className:"flex flex-col gap-2 sticky bottom-0 left-0 right-0 bg-[#E3DEEF] z-50 px-4 py-2",children:n.jsx("div",{className:"p-[1px] rounded-xl",style:{background:"linear-gradient(180deg, #B09FFF 0%, #8D79F6 100%)"},children:n.jsxs("div",{className:"flex items-center bg-[#FFFFFF] flex-1 rounded-xl px-2 py-1",children:[n.jsx("input",{className:"flex-1 bg-[#FFFFFF] text-[#232323] outline-none border-none px-2 py-2 text-sm",placeholder:"How can I help you...",value:U,autoFocus:!0,onChange:f=>ge(f.target.value),onKeyDown:f=>{f.key==="Enter"&&!g&&_e()}}),n.jsx("button",{type:"submit",disabled:g,className:"p-3",onClick:()=>_e(),children:g?n.jsx("div",{className:"p-3 animate-spin rounded-full h-3 w-3 border-b-2",style:{borderBottom:"2px solid",color:E.tanyaThemeColor}}):n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.jsx("path",{d:"M16.6357 13.6701L18.3521 8.5208C19.8516 4.02242 20.6013 1.77322 19.414 0.585948C18.2268 -0.601312 15.9776 0.148418 11.4792 1.64788L6.32987 3.36432C2.69923 4.57453 0.883923 5.17964 0.368062 6.06698C-0.122688 6.91112 -0.122688 7.95369 0.368062 8.7978C0.883923 9.6852 2.69923 10.2903 6.32987 11.5005C6.77981 11.6505 7.28601 11.5434 7.62294 11.2096L13.1286 5.75495C13.4383 5.44808 13.9382 5.45041 14.245 5.76015C14.5519 6.06989 14.5496 6.56975 14.2398 6.87662L8.8231 12.2432C8.4518 12.6111 8.3342 13.1742 8.4995 13.6701C9.7097 17.3007 10.3148 19.1161 11.2022 19.6319C12.0463 20.1227 13.0889 20.1227 13.933 19.6319C14.8204 19.1161 15.4255 17.3008 16.6357 13.6701Z",fill:"#6952C7"})})})]})})})]}),n.jsx(Yo,{addToCartPwa:r})]})]})]})]})})};var cr=function(e,t){return cr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(r[s]=o[s])},cr(e,t)};function Ko(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");cr(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var Ye=function(){return Ye=Object.assign||function(t){for(var r,o=1,s=arguments.length;o<s;o++){r=arguments[o];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},Ye.apply(this,arguments)};function Wo(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(e);s<o.length;s++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(e,o[s])&&(r[o[s]]=e[o[s]]);return r}var er="Invariant Violation",Yr=Object.setPrototypeOf,Qo=Yr===void 0?function(e,t){return e.__proto__=t,e}:Yr,Pn=(function(e){Ko(t,e);function t(r){r===void 0&&(r=er);var o=e.call(this,typeof r=="number"?er+": "+r+" (see https://github.com/apollographql/invariant-packages)":r)||this;return o.framesToPop=1,o.name=er,Qo(o,t.prototype),o}return t})(Error);function rt(e,t){if(!e)throw new Pn(t)}var En=["debug","log","warn","error","silent"],Go=En.indexOf("log");function $t(e){return function(){if(En.indexOf(e)>=Go){var t=console[e]||console.log;return t.apply(console,arguments)}}}(function(e){e.debug=$t("debug"),e.log=$t("log"),e.warn=$t("warn"),e.error=$t("error")})(rt||(rt={}));var Tn="3.14.0";function ht(e){try{return e()}catch{}}const dr=ht(function(){return globalThis})||ht(function(){return window})||ht(function(){return self})||ht(function(){return global})||ht(function(){return ht.constructor("return this")()});var Jr=new Map;function Xo(e){var t=Jr.get(e)||1;return Jr.set(e,t+1),"".concat(e,":").concat(t,":").concat(Math.random().toString(36).slice(2))}function Zo(e,t){var r=Xo("stringifyForDisplay");return JSON.stringify(e,function(o,s){return s===void 0?r:s},t).split(JSON.stringify(r)).join("<undefined>")}function Dt(e){return function(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(typeof t=="number"){var s=t;t=wr(s),t||(t=br(s,r),r=[])}e.apply(void 0,[t].concat(r))}}var tr=Object.assign(function(t,r){for(var o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];t||rt(t,wr(r,o)||br(r,o))},{debug:Dt(rt.debug),log:Dt(rt.log),warn:Dt(rt.warn),error:Dt(rt.error)});function On(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return new Pn(wr(e,t)||br(e,t))}var Kr=Symbol.for("ApolloErrorMessageHandler_"+Tn);function An(e){if(typeof e=="string")return e;try{return Zo(e,2).slice(0,1e3)}catch{return"<non-serializable>"}}function wr(e,t){if(t===void 0&&(t=[]),!!e)return dr[Kr]&&dr[Kr](e,t.map(An))}function br(e,t){if(t===void 0&&(t=[]),!!e)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:Tn,message:e,args:t.map(An)})))}function es(e){return e.definitions.filter(function(t){return t.kind==="OperationDefinition"&&!!t.name}).map(function(t){return t.name.value})[0]||null}let ae=null;const Wr={};let ts=1;const rs=()=>class{constructor(){this.id=["slot",ts++,Date.now(),Math.random().toString(36).slice(2)].join(":")}hasValue(){for(let t=ae;t;t=t.parent)if(this.id in t.slots){const r=t.slots[this.id];if(r===Wr)break;return t!==ae&&(ae.slots[this.id]=r),!0}return ae&&(ae.slots[this.id]=Wr),!1}getValue(){if(this.hasValue())return ae.slots[this.id]}withValue(t,r,o,s){const a={__proto__:null,[this.id]:t},i=ae;ae={parent:i,slots:a};try{return r.apply(s,o)}finally{ae=i}}static bind(t){const r=ae;return function(){const o=ae;try{return ae=r,t.apply(this,arguments)}finally{ae=o}}}static noContext(t,r,o){if(ae){const s=ae;try{return ae=null,t.apply(o,r)}finally{ae=s}}else return t.apply(o,r)}};function Qr(e){try{return e()}catch{}}const rr="@wry/context:Slot",ns=Qr(()=>globalThis)||Qr(()=>global)||Object.create(null),Gr=ns,vr=Gr[rr]||Array[rr]||(function(e){try{Object.defineProperty(Gr,rr,{value:e,enumerable:!1,writable:!1,configurable:!0})}finally{return e}})(rs()),{bind:za,noContext:Ma}=vr;new vr;function os(e,t){var r=typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=ss(e))||t){r&&(e=r);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
16
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ss(e,t){if(e){if(typeof e=="string")return Xr(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Xr(e,t)}}function Xr(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function Zr(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function jr(e,t,r){return t&&Zr(e.prototype,t),r&&Zr(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var kr=function(){return typeof Symbol=="function"},Sr=function(e){return kr()&&!!Symbol[e]},Nr=function(e){return Sr(e)?Symbol[e]:"@@"+e};kr()&&!Sr("observable")&&(Symbol.observable=Symbol("observable"));var as=Nr("iterator"),ur=Nr("observable"),$n=Nr("species");function Jt(e,t){var r=e[t];if(r!=null){if(typeof r!="function")throw new TypeError(r+" is not a function");return r}}function kt(e){var t=e.constructor;return t!==void 0&&(t=t[$n],t===null&&(t=void 0)),t!==void 0?t:fe}function is(e){return e instanceof fe}function gt(e){gt.log?gt.log(e):setTimeout(function(){throw e})}function zt(e){Promise.resolve().then(function(){try{e()}catch(t){gt(t)}})}function Dn(e){var t=e._cleanup;if(t!==void 0&&(e._cleanup=void 0,!!t))try{if(typeof t=="function")t();else{var r=Jt(t,"unsubscribe");r&&r.call(t)}}catch(o){gt(o)}}function fr(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function ls(e){var t=e._queue;if(t){e._queue=void 0,e._state="ready";for(var r=0;r<t.length&&(Ln(e,t[r].type,t[r].value),e._state!=="closed");++r);}}function Ln(e,t,r){e._state="running";var o=e._observer;try{var s=Jt(o,t);switch(t){case"next":s&&s.call(o,r);break;case"error":if(fr(e),s)s.call(o,r);else throw r;break;case"complete":fr(e),s&&s.call(o);break}}catch(a){gt(a)}e._state==="closed"?Dn(e):e._state==="running"&&(e._state="ready")}function nr(e,t,r){if(e._state!=="closed"){if(e._state==="buffering"){e._queue.push({type:t,value:r});return}if(e._state!=="ready"){e._state="buffering",e._queue=[{type:t,value:r}],zt(function(){return ls(e)});return}Ln(e,t,r)}}var cs=(function(){function e(r,o){this._cleanup=void 0,this._observer=r,this._queue=void 0,this._state="initializing";var s=new ds(this);try{this._cleanup=o.call(void 0,s)}catch(a){s.error(a)}this._state==="initializing"&&(this._state="ready")}var t=e.prototype;return t.unsubscribe=function(){this._state!=="closed"&&(fr(this),Dn(this))},jr(e,[{key:"closed",get:function(){return this._state==="closed"}}]),e})(),ds=(function(){function e(r){this._subscription=r}var t=e.prototype;return t.next=function(o){nr(this._subscription,"next",o)},t.error=function(o){nr(this._subscription,"error",o)},t.complete=function(){nr(this._subscription,"complete")},jr(e,[{key:"closed",get:function(){return this._subscription._state==="closed"}}]),e})(),fe=(function(){function e(r){if(!(this instanceof e))throw new TypeError("Observable cannot be called as a function");if(typeof r!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=r}var t=e.prototype;return t.subscribe=function(o){return(typeof o!="object"||o===null)&&(o={next:o,error:arguments[1],complete:arguments[2]}),new cs(o,this._subscriber)},t.forEach=function(o){var s=this;return new Promise(function(a,i){if(typeof o!="function"){i(new TypeError(o+" is not a function"));return}function c(){l.unsubscribe(),a()}var l=s.subscribe({next:function(p){try{o(p,c)}catch(h){i(h),l.unsubscribe()}},error:i,complete:a})})},t.map=function(o){var s=this;if(typeof o!="function")throw new TypeError(o+" is not a function");var a=kt(this);return new a(function(i){return s.subscribe({next:function(c){try{c=o(c)}catch(l){return i.error(l)}i.next(c)},error:function(c){i.error(c)},complete:function(){i.complete()}})})},t.filter=function(o){var s=this;if(typeof o!="function")throw new TypeError(o+" is not a function");var a=kt(this);return new a(function(i){return s.subscribe({next:function(c){try{if(!o(c))return}catch(l){return i.error(l)}i.next(c)},error:function(c){i.error(c)},complete:function(){i.complete()}})})},t.reduce=function(o){var s=this;if(typeof o!="function")throw new TypeError(o+" is not a function");var a=kt(this),i=arguments.length>1,c=!1,l=arguments[1],p=l;return new a(function(h){return s.subscribe({next:function(y){var w=!c;if(c=!0,!w||i)try{p=o(p,y)}catch(k){return h.error(k)}else p=y},error:function(y){h.error(y)},complete:function(){if(!c&&!i)return h.error(new TypeError("Cannot reduce an empty sequence"));h.next(p),h.complete()}})})},t.concat=function(){for(var o=this,s=arguments.length,a=new Array(s),i=0;i<s;i++)a[i]=arguments[i];var c=kt(this);return new c(function(l){var p,h=0;function y(w){p=w.subscribe({next:function(k){l.next(k)},error:function(k){l.error(k)},complete:function(){h===a.length?(p=void 0,l.complete()):y(c.from(a[h++]))}})}return y(o),function(){p&&(p.unsubscribe(),p=void 0)}})},t.flatMap=function(o){var s=this;if(typeof o!="function")throw new TypeError(o+" is not a function");var a=kt(this);return new a(function(i){var c=[],l=s.subscribe({next:function(h){if(o)try{h=o(h)}catch(w){return i.error(w)}var y=a.from(h).subscribe({next:function(w){i.next(w)},error:function(w){i.error(w)},complete:function(){var w=c.indexOf(y);w>=0&&c.splice(w,1),p()}});c.push(y)},error:function(h){i.error(h)},complete:function(){p()}});function p(){l.closed&&c.length===0&&i.complete()}return function(){c.forEach(function(h){return h.unsubscribe()}),l.unsubscribe()}})},t[ur]=function(){return this},e.from=function(o){var s=typeof this=="function"?this:e;if(o==null)throw new TypeError(o+" is not an object");var a=Jt(o,ur);if(a){var i=a.call(o);if(Object(i)!==i)throw new TypeError(i+" is not an object");return is(i)&&i.constructor===s?i:new s(function(c){return i.subscribe(c)})}if(Sr("iterator")&&(a=Jt(o,as),a))return new s(function(c){zt(function(){if(!c.closed){for(var l=os(a.call(o)),p;!(p=l()).done;){var h=p.value;if(c.next(h),c.closed)return}c.complete()}})});if(Array.isArray(o))return new s(function(c){zt(function(){if(!c.closed){for(var l=0;l<o.length;++l)if(c.next(o[l]),c.closed)return;c.complete()}})});throw new TypeError(o+" is not observable")},e.of=function(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];var i=typeof this=="function"?this:e;return new i(function(c){zt(function(){if(!c.closed){for(var l=0;l<s.length;++l)if(c.next(s[l]),c.closed)return;c.complete()}})})},jr(e,null,[{key:$n,get:function(){return this}}]),e})();kr()&&Object.defineProperty(fe,Symbol("extensions"),{value:{symbol:ur,hostReportError:gt},configurable:!0});function us(e){var t,r=e.Symbol;if(typeof r=="function")if(r.observable)t=r.observable;else{typeof r.for=="function"?t=r.for("https://github.com/benlesh/symbol-observable"):t=r("https://github.com/benlesh/symbol-observable");try{r.observable=t}catch{}}else t="@@observable";return t}var pt;typeof self<"u"?pt=self:typeof window<"u"?pt=window:typeof global<"u"?pt=global:typeof module<"u"?pt=module:pt=Function("return this")();us(pt);var en=fe.prototype,tn="@@observable";en[tn]||(en[tn]=function(){return this});function fs(e){for(var t=["query","operationName","variables","extensions","context"],r=0,o=Object.keys(e);r<o.length;r++){var s=o[r];if(t.indexOf(s)<0)throw On(58,s)}return e}function ms(e,t){var r=Ye({},e),o=function(a){typeof a=="function"?r=Ye(Ye({},r),a(r)):r=Ye(Ye({},r),a)},s=function(){return Ye({},r)};return Object.defineProperty(t,"setContext",{enumerable:!1,value:o}),Object.defineProperty(t,"getContext",{enumerable:!1,value:s}),t}function hs(e){var t={variables:e.variables||{},extensions:e.extensions||{},operationName:e.operationName,query:e.query};return t.operationName||(t.operationName=typeof t.query!="string"?es(t.query)||void 0:""),t}var ps=Symbol.for("apollo.deprecations"),gs=dr,xs=new vr;function ys(e){return gs[ps]||(xs.getValue()||[]).includes(e)}function ws(e,t){ys(e)||t()}function rn(e,t){return t?t(e):fe.of()}function St(e){return typeof e=="function"?new zn(e):e}function Lt(e){return e.request.length<=1}var zn=(function(){function e(t){t&&(this.request=t)}return e.empty=function(){return new e(function(){return fe.of()})},e.from=function(t){return t.length===0?e.empty():t.map(St).reduce(function(r,o){return r.concat(o)})},e.split=function(t,r,o){var s=St(r),a=St(o||new e(rn)),i;return Lt(s)&&Lt(a)?i=new e(function(c){return t(c)?s.request(c)||fe.of():a.request(c)||fe.of()}):i=new e(function(c,l){return t(c)?s.request(c,l)||fe.of():a.request(c,l)||fe.of()}),Object.assign(i,{left:s,right:a})},e.execute=function(t,r){return t.request(ms(r.context,hs(fs(r))))||fe.of()},e.concat=function(t,r){var o=St(t);if(Lt(o))return globalThis.__DEV__!==!1&&tr.warn(47,o),o;var s=St(r),a;return Lt(s)?a=new e(function(i){return o.request(i,function(c){return s.request(c)||fe.of()})||fe.of()}):a=new e(function(i,c){return o.request(i,function(l){return s.request(l,c)||fe.of()})||fe.of()}),Object.assign(a,{left:o,right:s})},e.prototype.split=function(t,r,o){return this.concat(e.split(t,r,o||new e(rn)))},e.prototype.concat=function(t){return e.concat(this,t)},e.prototype.request=function(t,r){throw On(48)},e.prototype.onError=function(t,r){if(globalThis.__DEV__!==!1&&ws("onError",function(){globalThis.__DEV__!==!1&&tr.warn(49)}),r&&r.error)return r.error(t),!1;throw t},e.prototype.setOnError=function(t){return globalThis.__DEV__!==!1&&globalThis.__DEV__!==!1&&tr.warn(50),this.onError=t,this},e})();function bs(e){return new zn(function(t,r){var o=Wo(t,[]);return new fe(function(s){var a,i=!1;return Promise.resolve(o).then(function(c){return e(c,t.getContext())}).then(t.setContext).then(function(){i||(a=r(t).subscribe({next:s.next.bind(s),error:s.error.bind(s),complete:s.complete.bind(s)}))}).catch(s.error.bind(s)),function(){i=!0,a&&a.unsubscribe()}})})}const vs=async()=>{const e="https://auth.australia-southeast1.gcp.commercetools.com/oauth/token",o="Basic "+btoa(encodeURIComponent("tfegsSBVOYnR7e_yE-AjxVVN")+":"+encodeURIComponent("pyKWgHuTxuMwDygh9JH1ehLEaLvAhBo4"));try{const s=await pe.post(e,new URLSearchParams({grant_type:"client_credentials"}),{headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:o}});return s.status===200&&s.data.access_token?s.data.access_token:(console.error("Failed to fetch token:",s.data),null)}catch(s){return pe.isAxiosError(s)?console.error("Error fetching token:",s.response||s.message):console.error("Unexpected error:",s),null}},js="https://api.australia-southeast1.gcp.commercetools.com/kt-demo/graphql",ks=Ut.createHttpLink({uri:`${js}`}),Ss=bs(async(e,{headers:t})=>{const r=await vs();return{headers:{...t,authorization:`Bearer ${r}`}}}),Ns=new Ut.ApolloClient({link:Ss.concat(ks),cache:new Ut.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"cache-and-network"}}}),Cs=e=>{const{tanyaConfig:t}=e;return n.jsx(Ut.ApolloProvider,{client:Ns,children:n.jsx($o,{children:n.jsx(Jo,{tanyaConfig:t})})})};function _s(e,t){const r=e.icons,o=e.aliases||Object.create(null),s=Object.create(null);function a(i){if(r[i])return s[i]=[];if(!(i in s)){s[i]=null;const c=o[i]&&o[i].parent,l=c&&a(c);l&&(s[i]=[c].concat(l))}return s[i]}return Object.keys(r).concat(Object.keys(o)).forEach(a),s}const Mn=Object.freeze({left:0,top:0,width:16,height:16}),Kt=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Cr=Object.freeze({...Mn,...Kt}),mr=Object.freeze({...Cr,body:"",hidden:!1});function Is(e,t){const r={};!e.hFlip!=!t.hFlip&&(r.hFlip=!0),!e.vFlip!=!t.vFlip&&(r.vFlip=!0);const o=((e.rotate||0)+(t.rotate||0))%4;return o&&(r.rotate=o),r}function nn(e,t){const r=Is(e,t);for(const o in mr)o in Kt?o in e&&!(o in r)&&(r[o]=Kt[o]):o in t?r[o]=t[o]:o in e&&(r[o]=e[o]);return r}function Fs(e,t,r){const o=e.icons,s=e.aliases||Object.create(null);let a={};function i(c){a=nn(o[c]||s[c],a)}return i(t),r.forEach(i),nn(e,a)}function qn(e,t){const r=[];if(typeof e!="object"||typeof e.icons!="object")return r;e.not_found instanceof Array&&e.not_found.forEach(s=>{t(s,null),r.push(s)});const o=_s(e);for(const s in o){const a=o[s];a&&(t(s,Fs(e,s,a)),r.push(s))}return r}const Ps={provider:"",aliases:{},not_found:{},...Mn};function or(e,t){for(const r in t)if(r in e&&typeof e[r]!=typeof t[r])return!1;return!0}function Rn(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!or(e,Ps))return null;const r=t.icons;for(const s in r){const a=r[s];if(!s||typeof a.body!="string"||!or(a,mr))return null}const o=t.aliases||Object.create(null);for(const s in o){const a=o[s],i=a.parent;if(!s||typeof i!="string"||!r[i]&&!o[i]||!or(a,mr))return null}return t}const on=Object.create(null);function Es(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function xt(e,t){const r=on[e]||(on[e]=Object.create(null));return r[t]||(r[t]=Es(e,t))}function Bn(e,t){return Rn(t)?qn(t,(r,o)=>{o?e.icons[r]=o:e.missing.add(r)}):[]}function Ts(e,t,r){try{if(typeof r.body=="string")return e.icons[t]={...r},!0}catch{}return!1}const Un=/^[a-z0-9]+(-[a-z0-9]+)*$/,Wt=(e,t,r,o="")=>{const s=e.split(":");if(e.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;o=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const c=s.pop(),l=s.pop(),p={provider:s.length>0?s[0]:o,prefix:l,name:c};return t&&!Mt(p)?null:p}const a=s[0],i=a.split("-");if(i.length>1){const c={provider:o,prefix:i.shift(),name:i.join("-")};return t&&!Mt(c)?null:c}if(r&&o===""){const c={provider:o,prefix:"",name:a};return t&&!Mt(c,r)?null:c}return null},Mt=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let Ft=!1;function Hn(e){return typeof e=="boolean"&&(Ft=e),Ft}function sn(e){const t=typeof e=="string"?Wt(e,!0,Ft):e;if(t){const r=xt(t.provider,t.prefix),o=t.name;return r.icons[o]||(r.missing.has(o)?null:void 0)}}function Os(e,t){const r=Wt(e,!0,Ft);if(!r)return!1;const o=xt(r.provider,r.prefix);return t?Ts(o,r.name,t):(o.missing.add(r.name),!0)}function As(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),Ft&&!t&&!e.prefix){let s=!1;return Rn(e)&&(e.prefix="",qn(e,(a,i)=>{Os(a,i)&&(s=!0)})),s}const r=e.prefix;if(!Mt({prefix:r,name:"a"}))return!1;const o=xt(t,r);return!!Bn(o,e)}const Vn=Object.freeze({width:null,height:null}),Yn=Object.freeze({...Vn,...Kt}),$s=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Ds=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function an(e,t,r){if(t===1)return e;if(r=r||100,typeof e=="number")return Math.ceil(e*t*r)/r;if(typeof e!="string")return e;const o=e.split($s);if(o===null||!o.length)return e;const s=[];let a=o.shift(),i=Ds.test(a);for(;;){if(i){const c=parseFloat(a);isNaN(c)?s.push(a):s.push(Math.ceil(c*t*r)/r)}else s.push(a);if(a=o.shift(),a===void 0)return s.join("");i=!i}}function Ls(e,t="defs"){let r="";const o=e.indexOf("<"+t);for(;o>=0;){const s=e.indexOf(">",o),a=e.indexOf("</"+t);if(s===-1||a===-1)break;const i=e.indexOf(">",a);if(i===-1)break;r+=e.slice(s+1,a).trim(),e=e.slice(0,o).trim()+e.slice(i+1)}return{defs:r,content:e}}function zs(e,t){return e?"<defs>"+e+"</defs>"+t:t}function Ms(e,t,r){const o=Ls(e);return zs(o.defs,t+o.content+r)}const qs=e=>e==="unset"||e==="undefined"||e==="none";function Rs(e,t){const r={...Cr,...e},o={...Yn,...t},s={left:r.left,top:r.top,width:r.width,height:r.height};let a=r.body;[r,o].forEach(_=>{const S=[],I=_.hFlip,B=_.vFlip;let g=_.rotate;I?B?g+=2:(S.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),S.push("scale(-1 1)"),s.top=s.left=0):B&&(S.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),S.push("scale(1 -1)"),s.top=s.left=0);let H;switch(g<0&&(g-=Math.floor(g/4)*4),g=g%4,g){case 1:H=s.height/2+s.top,S.unshift("rotate(90 "+H.toString()+" "+H.toString()+")");break;case 2:S.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:H=s.width/2+s.left,S.unshift("rotate(-90 "+H.toString()+" "+H.toString()+")");break}g%2===1&&(s.left!==s.top&&(H=s.left,s.left=s.top,s.top=H),s.width!==s.height&&(H=s.width,s.width=s.height,s.height=H)),S.length&&(a=Ms(a,'<g transform="'+S.join(" ")+'">',"</g>"))});const i=o.width,c=o.height,l=s.width,p=s.height;let h,y;i===null?(y=c===null?"1em":c==="auto"?p:c,h=an(y,l/p)):(h=i==="auto"?l:i,y=c===null?an(h,p/l):c==="auto"?p:c);const w={},k=(_,S)=>{qs(S)||(w[_]=S.toString())};k("width",h),k("height",y);const N=[s.left,s.top,l,p];return w.viewBox=N.join(" "),{attributes:w,viewBox:N,body:a}}const Bs=/\sid="(\S+)"/g,Us="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Hs=0;function Vs(e,t=Us){const r=[];let o;for(;o=Bs.exec(e);)r.push(o[1]);if(!r.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return r.forEach(a=>{const i=typeof t=="function"?t(a):t+(Hs++).toString(),c=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+c+')([")]|\\.[a-z])',"g"),"$1"+i+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const hr=Object.create(null);function Ys(e,t){hr[e]=t}function pr(e){return hr[e]||hr[""]}function _r(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const Ir=Object.create(null),Nt=["https://api.simplesvg.com","https://api.unisvg.com"],qt=[];for(;Nt.length>0;)Nt.length===1||Math.random()>.5?qt.push(Nt.shift()):qt.push(Nt.pop());Ir[""]=_r({resources:["https://api.iconify.design"].concat(qt)});function Js(e,t){const r=_r(t);return r===null?!1:(Ir[e]=r,!0)}function Fr(e){return Ir[e]}const Ks=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let ln=Ks();function Ws(e,t){const r=Fr(e);if(!r)return 0;let o;if(!r.maxURL)o=0;else{let s=0;r.resources.forEach(i=>{s=Math.max(s,i.length)});const a=t+".json?icons=";o=r.maxURL-s-r.path.length-a.length}return o}function Qs(e){return e===404}const Gs=(e,t,r)=>{const o=[],s=Ws(e,t),a="icons";let i={type:a,provider:e,prefix:t,icons:[]},c=0;return r.forEach((l,p)=>{c+=l.length+1,c>=s&&p>0&&(o.push(i),i={type:a,provider:e,prefix:t,icons:[]},c=l.length),i.icons.push(l)}),o.push(i),o};function Xs(e){if(typeof e=="string"){const t=Fr(e);if(t)return t.path}return"/"}const Zs=(e,t,r)=>{if(!ln){r("abort",424);return}let o=Xs(t.provider);switch(t.type){case"icons":{const a=t.prefix,c=t.icons.join(","),l=new URLSearchParams({icons:c});o+=a+".json?"+l.toString();break}case"custom":{const a=t.uri;o+=a.slice(0,1)==="/"?a.slice(1):a;break}default:r("abort",400);return}let s=503;ln(e+o).then(a=>{const i=a.status;if(i!==200){setTimeout(()=>{r(Qs(i)?"abort":"next",i)});return}return s=501,a.json()}).then(a=>{if(typeof a!="object"||a===null){setTimeout(()=>{a===404?r("abort",a):r("next",s)});return}setTimeout(()=>{r("success",a)})}).catch(()=>{r("next",s)})},ea={prepare:Gs,send:Zs};function Jn(e,t){e.forEach(r=>{const o=r.loaderCallbacks;o&&(r.loaderCallbacks=o.filter(s=>s.id!==t))})}function ta(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let r=!1;const o=e.provider,s=e.prefix;t.forEach(a=>{const i=a.icons,c=i.pending.length;i.pending=i.pending.filter(l=>{if(l.prefix!==s)return!0;const p=l.name;if(e.icons[p])i.loaded.push({provider:o,prefix:s,name:p});else if(e.missing.has(p))i.missing.push({provider:o,prefix:s,name:p});else return r=!0,!0;return!1}),i.pending.length!==c&&(r||Jn([e],a.id),a.callback(i.loaded.slice(0),i.missing.slice(0),i.pending.slice(0),a.abort))})}))}let ra=0;function na(e,t,r){const o=ra++,s=Jn.bind(null,r,o);if(!t.pending.length)return s;const a={id:o,icons:t,callback:e,abort:s};return r.forEach(i=>{(i.loaderCallbacks||(i.loaderCallbacks=[])).push(a)}),s}function oa(e){const t={loaded:[],missing:[],pending:[]},r=Object.create(null);e.sort((s,a)=>s.provider!==a.provider?s.provider.localeCompare(a.provider):s.prefix!==a.prefix?s.prefix.localeCompare(a.prefix):s.name.localeCompare(a.name));let o={provider:"",prefix:"",name:""};return e.forEach(s=>{if(o.name===s.name&&o.prefix===s.prefix&&o.provider===s.provider)return;o=s;const a=s.provider,i=s.prefix,c=s.name,l=r[a]||(r[a]=Object.create(null)),p=l[i]||(l[i]=xt(a,i));let h;c in p.icons?h=t.loaded:i===""||p.missing.has(c)?h=t.missing:h=t.pending;const y={provider:a,prefix:i,name:c};h.push(y)}),t}function sa(e,t=!0,r=!1){const o=[];return e.forEach(s=>{const a=typeof s=="string"?Wt(s,t,r):s;a&&o.push(a)}),o}const aa={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function ia(e,t,r,o){const s=e.resources.length,a=e.random?Math.floor(Math.random()*s):e.index;let i;if(e.random){let P=e.resources.slice(0);for(i=[];P.length>1;){const U=Math.floor(Math.random()*P.length);i.push(P[U]),P=P.slice(0,U).concat(P.slice(U+1))}i=i.concat(P)}else i=e.resources.slice(a).concat(e.resources.slice(0,a));const c=Date.now();let l="pending",p=0,h,y=null,w=[],k=[];typeof o=="function"&&k.push(o);function N(){y&&(clearTimeout(y),y=null)}function _(){l==="pending"&&(l="aborted"),N(),w.forEach(P=>{P.status==="pending"&&(P.status="aborted")}),w=[]}function S(P,U){U&&(k=[]),typeof P=="function"&&k.push(P)}function I(){return{startTime:c,payload:t,status:l,queriesSent:p,queriesPending:w.length,subscribe:S,abort:_}}function B(){l="failed",k.forEach(P=>{P(void 0,h)})}function g(){w.forEach(P=>{P.status==="pending"&&(P.status="aborted")}),w=[]}function H(P,U,ge){const oe=U!=="success";switch(w=w.filter(Q=>Q!==P),l){case"pending":break;case"failed":if(oe||!e.dataAfterTimeout)return;break;default:return}if(U==="abort"){h=ge,B();return}if(oe){h=ge,w.length||(i.length?Ee():B());return}if(N(),g(),!e.random){const Q=e.resources.indexOf(P.resource);Q!==-1&&Q!==e.index&&(e.index=Q)}l="completed",k.forEach(Q=>{Q(ge)})}function Ee(){if(l!=="pending")return;N();const P=i.shift();if(P===void 0){if(w.length){y=setTimeout(()=>{N(),l==="pending"&&(g(),B())},e.timeout);return}B();return}const U={status:"pending",resource:P,callback:(ge,oe)=>{H(U,ge,oe)}};w.push(U),p++,y=setTimeout(Ee,e.rotate),r(P,t,U.callback)}return setTimeout(Ee),I}function Kn(e){const t={...aa,...e};let r=[];function o(){r=r.filter(c=>c().status==="pending")}function s(c,l,p){const h=ia(t,c,l,(y,w)=>{o(),p&&p(y,w)});return r.push(h),h}function a(c){return r.find(l=>c(l))||null}return{query:s,find:a,setIndex:c=>{t.index=c},getIndex:()=>t.index,cleanup:o}}function cn(){}const sr=Object.create(null);function la(e){if(!sr[e]){const t=Fr(e);if(!t)return;const r=Kn(t),o={config:t,redundancy:r};sr[e]=o}return sr[e]}function ca(e,t,r){let o,s;if(typeof e=="string"){const a=pr(e);if(!a)return r(void 0,424),cn;s=a.send;const i=la(e);i&&(o=i.redundancy)}else{const a=_r(e);if(a){o=Kn(a);const i=e.resources?e.resources[0]:"",c=pr(i);c&&(s=c.send)}}return!o||!s?(r(void 0,424),cn):o.query(t,s,r)().abort}function dn(){}function da(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,ta(e)}))}function ua(e){const t=[],r=[];return e.forEach(o=>{(o.match(Un)?t:r).push(o)}),{valid:t,invalid:r}}function Ct(e,t,r){function o(){const s=e.pendingIcons;t.forEach(a=>{s&&s.delete(a),e.icons[a]||e.missing.add(a)})}if(r&&typeof r=="object")try{if(!Bn(e,r).length){o();return}}catch(s){console.error(s)}o(),da(e)}function un(e,t){e instanceof Promise?e.then(r=>{t(r)}).catch(()=>{t(null)}):t(e)}function fa(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:r,prefix:o}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const a=e.loadIcon;if(e.loadIcons&&(s.length>1||!a)){un(e.loadIcons(s,o,r),h=>{Ct(e,s,h)});return}if(a){s.forEach(h=>{const y=a(h,o,r);un(y,w=>{const k=w?{prefix:o,icons:{[h]:w}}:null;Ct(e,[h],k)})});return}const{valid:i,invalid:c}=ua(s);if(c.length&&Ct(e,c,null),!i.length)return;const l=o.match(Un)?pr(r):null;if(!l){Ct(e,i,null);return}l.prepare(r,o,i).forEach(h=>{ca(r,h,y=>{Ct(e,h.icons,y)})})}))}const ma=(e,t)=>{const r=sa(e,!0,Hn()),o=oa(r);if(!o.pending.length){let l=!0;return t&&setTimeout(()=>{l&&t(o.loaded,o.missing,o.pending,dn)}),()=>{l=!1}}const s=Object.create(null),a=[];let i,c;return o.pending.forEach(l=>{const{provider:p,prefix:h}=l;if(h===c&&p===i)return;i=p,c=h,a.push(xt(p,h));const y=s[p]||(s[p]=Object.create(null));y[h]||(y[h]=[])}),o.pending.forEach(l=>{const{provider:p,prefix:h,name:y}=l,w=xt(p,h),k=w.pendingIcons||(w.pendingIcons=new Set);k.has(y)||(k.add(y),s[p][h].push(y))}),a.forEach(l=>{const p=s[l.provider][l.prefix];p.length&&fa(l,p)}),t?na(t,o,a):dn};function ha(e,t){const r={...e};for(const o in t){const s=t[o],a=typeof s;o in Vn?(s===null||s&&(a==="string"||a==="number"))&&(r[o]=s):a===typeof r[o]&&(r[o]=o==="rotate"?s%4:s)}return r}const pa=/[\s,]+/;function ga(e,t){t.split(pa).forEach(r=>{switch(r.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function xa(e,t=0){const r=e.replace(/^-?[0-9.]*/,"");function o(s){for(;s<0;)s+=4;return s%4}if(r===""){const s=parseInt(e);return isNaN(s)?0:o(s)}else if(r!==e){let s=0;switch(r){case"%":s=25;break;case"deg":s=90}if(s){let a=parseFloat(e.slice(0,e.length-r.length));return isNaN(a)?0:(a=a/s,a%1===0?o(a):0)}}return t}function ya(e,t){let r=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const o in t)r+=" "+o+'="'+t[o]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+r+">"+e+"</svg>"}function wa(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function ba(e){return"data:image/svg+xml,"+wa(e)}function va(e){return'url("'+ba(e)+'")'}let _t;function ja(){try{_t=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{_t=null}}function ka(e){return _t===void 0&&ja(),_t?_t.createHTML(e):e}const Wn={...Yn,inline:!1},Sa={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Na={display:"inline-block"},gr={backgroundColor:"currentColor"},Qn={backgroundColor:"transparent"},fn={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},mn={WebkitMask:gr,mask:gr,background:Qn};for(const e in mn){const t=mn[e];for(const r in fn)t[e+r]=fn[r]}const Ca={...Wn,inline:!0};function hn(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const _a=(e,t,r)=>{const o=t.inline?Ca:Wn,s=ha(o,t),a=t.mode||"svg",i={},c=t.style||{},l={...a==="svg"?Sa:{}};if(r){const S=Wt(r,!1,!0);if(S){const I=["iconify"],B=["provider","prefix"];for(const g of B)S[g]&&I.push("iconify--"+S[g]);l.className=I.join(" ")}}for(let S in t){const I=t[S];if(I!==void 0)switch(S){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":l.ref=I;break;case"className":l[S]=(l[S]?l[S]+" ":"")+I;break;case"inline":case"hFlip":case"vFlip":s[S]=I===!0||I==="true"||I===1;break;case"flip":typeof I=="string"&&ga(s,I);break;case"color":i.color=I;break;case"rotate":typeof I=="string"?s[S]=xa(I):typeof I=="number"&&(s[S]=I);break;case"ariaHidden":case"aria-hidden":I!==!0&&I!=="true"&&delete l["aria-hidden"];break;default:o[S]===void 0&&(l[S]=I)}}const p=Rs(e,s),h=p.attributes;if(s.inline&&(i.verticalAlign="-0.125em"),a==="svg"){l.style={...i,...c},Object.assign(l,h);let S=0,I=t.id;return typeof I=="string"&&(I=I.replace(/-/g,"_")),l.dangerouslySetInnerHTML={__html:ka(Vs(p.body,I?()=>I+"ID"+S++:"iconifyReact"))},x.createElement("svg",l)}const{body:y,width:w,height:k}=e,N=a==="mask"||(a==="bg"?!1:y.indexOf("currentColor")!==-1),_=ya(y,{...h,width:w+"",height:k+""});return l.style={...i,"--svg":va(_),width:hn(h.width),height:hn(h.height),...Na,...N?gr:Qn,...c},x.createElement("span",l)};Hn(!0);Ys("",ea);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,r="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(o=>{try{(typeof o!="object"||o===null||o instanceof Array||typeof o.icons!="object"||typeof o.prefix!="string"||!As(o))&&console.error(r)}catch{console.error(r)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let r in t){const o="IconifyProviders["+r+"] is invalid.";try{const s=t[r];if(typeof s!="object"||!s||s.resources===void 0)continue;Js(r,s)||console.error(o)}catch{console.error(o)}}}}function Gn(e){const[t,r]=x.useState(!!e.ssr),[o,s]=x.useState({});function a(k){if(k){const N=e.icon;if(typeof N=="object")return{name:"",data:N};const _=sn(N);if(_)return{name:N,data:_}}return{name:""}}const[i,c]=x.useState(a(!!e.ssr));function l(){const k=o.callback;k&&(k(),s({}))}function p(k){if(JSON.stringify(i)!==JSON.stringify(k))return l(),c(k),!0}function h(){var k;const N=e.icon;if(typeof N=="object"){p({name:"",data:N});return}const _=sn(N);if(p({name:N,data:_}))if(_===void 0){const S=ma([N],h);s({callback:S})}else _&&((k=e.onLoad)===null||k===void 0||k.call(e,N))}x.useEffect(()=>(r(!0),l),[]),x.useEffect(()=>{t&&h()},[e.icon,t]);const{name:y,data:w}=i;return w?_a({...Cr,...w},e,y):e.children?e.children:e.fallback?e.fallback:x.createElement("span",{})}const te=x.forwardRef((e,t)=>Gn({...e,_ref:t}));x.forwardRef((e,t)=>Gn({inline:!0,...e,_ref:t}));const qe="USD",pn=e=>{var o,s,a;const t=e==null?void 0:e.availability;if(!t)return!1;const r=(a=(s=(o=t.channels)==null?void 0:o.results)==null?void 0:s[0])==null?void 0:a.availability;return r?r.isOnStock===!0&&(r.availableQuantity??0)>0:!1},xr=(e,t=qe)=>{const r=(e==null?void 0:e.prices)??[];if(!r.length)return null;const o=i=>{var p,h;const c=i.find(y=>{var w;return!!((w=y.discounted)!=null&&w.value)});if(c)return{cent:c.discounted.value.centAmount,cur:c.discounted.value.currencyCode,regularCent:(p=c.value)==null?void 0:p.centAmount};const l=(h=i[0])==null?void 0:h.value;return l?{cent:l.centAmount,cur:l.currencyCode}:null},s=r.filter(i=>{var c,l;return((l=((c=i.discounted)==null?void 0:c.value)||i.value)==null?void 0:l.currencyCode)===t}),a=o(s);return a||o(r)||null},Ia=(e,t)=>{if(!Array.isArray(e))return"";const r=e.find(o=>o.name===t)||e.find(o=>{var s;return((s=o.name)==null?void 0:s.toLowerCase())===t.toLowerCase()});return!r||!r.value?"":typeof r.value=="object"?r.value.label||"":r.value},Fa=e=>{let t="";if(Array.isArray(e)){const r=e.find(o=>o.name==="size")||e.find(o=>o.name==="Size");r&&r.value&&(t=typeof r.value=="object"?r.value.label||"":r.value)}return{sizeLabel:t}},Me=e=>Ia((e==null?void 0:e.attributesRaw)??[],"color"),Ve=e=>Fa((e==null?void 0:e.attributesRaw)??[]).sizeLabel,et=(e,t,r)=>{for(const o of e){const s=Me(o.variant),a=Ve(o.variant);if((t?s===t:!0)&&(r?a===r:!0))return o}return null},He=e=>e.charAt(0).toUpperCase()+e.slice(1),tt={standard:{label:"Standard Delivery",fee:0,subtitle:"Arrives in 4–6 days (Free)",icon:"mdi:clock-outline"},express:{label:"Express Delivery",fee:5,subtitle:"Arrives in 1–2 days (+$5)",icon:"mdi:flash"},sameday:{label:"Same-Day Delivery",fee:10,subtitle:"Available in select locations (+$10)",icon:"mdi:truck-fast-outline"}},Pa={standard:"GROUND",express:"2-DAY SHIPPING",sameday:"OVERNIGHT"},Pe=(e,t)=>{try{return e.toLocaleString("en-US",{style:"currency",currency:t||"USD"})}catch{return`${t} ${e.toFixed(2)}`}},Xn=e=>e==null?void 0:e.masterVariant,gn=e=>Array.isArray(e==null?void 0:e.variants)?e.variants:[],Rt=e=>{const t=Xn(e);return t?[t,...gn(e)]:gn(e)},Ea=(e,t=0)=>Rt(e)[t],Ta=e=>{var t,r;return((r=(t=e==null?void 0:e.images)==null?void 0:t[0])==null?void 0:r.url)??""},xn=(e,t)=>{var r,o,s,a;return Ta(t)||(e==null?void 0:e.image)||((o=(r=e==null?void 0:e.images)==null?void 0:r[0])==null?void 0:o.src)||((a=(s=e==null?void 0:e.media)==null?void 0:s[0])==null?void 0:a.url)||""},yn=e=>(e==null?void 0:e.name)||(e==null?void 0:e.title)||(e==null?void 0:e.productName)||"any",Bt=e=>{var a,i,c,l,p,h;const t=e?xr(e,qe):null;if(t!=null&&t.cent&&(t!=null&&t.cur))return{amount:+(t.cent/100),currency:t.cur,regularAmount:t.regularCent?t.regularCent/100:void 0};const r=(c=(i=(a=e==null?void 0:e.prices)==null?void 0:a[0])==null?void 0:i.value)==null?void 0:c.centAmount,o=((h=(p=(l=e==null?void 0:e.prices)==null?void 0:l[0])==null?void 0:p.value)==null?void 0:h.currencyCode)??qe;return{amount:Number.isFinite(r)?+(Number(r)/100):0,currency:o}},wn=(e,t)=>{const{amount:r}=Bt(t);if(r)return r;const o=(e==null?void 0:e.price)??(e==null?void 0:e.sellingPrice)??(e==null?void 0:e.unitPrice)??(e==null?void 0:e.mrp)??0,s=Number(o);return Number.isFinite(s)?s:0},bn=e=>{var t;return(e==null?void 0:e.sku)||((t=e==null?void 0:e.variant)==null?void 0:t.sku)||(e==null?void 0:e.selectedSku)||""},Oa=e=>{var t;return(e==null?void 0:e.color)||(e==null?void 0:e.selectedColor)||((t=e==null?void 0:e.variant)==null?void 0:t.color)||""},Aa=e=>{var t;return(e==null?void 0:e.size)||(e==null?void 0:e.selectedSize)||((t=e==null?void 0:e.variant)==null?void 0:t.size)||""},vn=20,$a=({open:e,onClose:t,product:r,index:o,addressListProp:s,addressLoading:a})=>{const l=Rt(r),p=Math.min(Math.max(0,o||0),Math.max(0,l.length-1)),h=l.length,[y,w]=x.useState(p),[k,N]=x.useState(null),[_,S]=x.useState(null),I=x.useRef(null),B=x.useRef(null),g=Ea(r,y),[H,Ee]=x.useState(""),[P,U]=x.useState(!1),[ge,oe]=x.useState(!1),[Q,Ce]=x.useState(!1),[Te,me]=x.useState(""),[D,E]=x.useState(!1),[R,Ke]=x.useState(null),[Be,ye]=x.useState([]),[ke,ct]=x.useState([]),[We,z]=x.useState([]),[ie,_e]=x.useState(!1),[Se,Qt]=x.useState(),[Gt,f]=x.useState(!0),[O,A]=x.useState(!1),[V,L]=x.useState(!1),[T,le]=x.useState("standard"),[M,$]=x.useState(!1),[G,re]=x.useState(!1),[we,be]=x.useState("card"),[X,J]=x.useState(!1),[ve,Z]=x.useState(!1),[j,Y]=x.useState(!1),[K,ce]=x.useState(null),[je,Qe]=x.useState(null),[dt,Pt]=x.useState(""),[Le,Et]=x.useState(!1),ut=x.useRef(null);x.useEffect(()=>{const d=Rt(r),m=Math.min(Math.max(0,o||0),Math.max(0,d.length-1));w(m);const u=Xn(r),v=Me(u),F=Ve(u);I.current=v||null,B.current=F||null,N(v||null),S(F||null)},[o,r]),x.useEffect(()=>{ut.current&&(ut.current.scrollTop=ut.current.scrollHeight)},[Be,ie,O,V,M,G,X,ve,j,P,ge]);const C="var(--tanya)",Oe="var(--tanya-contrast)",Ge=C,wt="var(--tanya)",Zn=()=>{console.log("AgenticShopping feedback:",{rating:je,comment:dt}),Et(!0)},eo=()=>{Qe(null),Pt(""),Et(!0)},Pr=d=>{const u=((d==null?void 0:d.intentMandateId)||(d==null?void 0:d.intent_mandate_id)||(d==null?void 0:d.id)||null)??K;return console.log(e,"it is open"),e?n.jsxs("div",{className:"mt-3 flex items-start gap-3 rounded-lg border border-green-200 bg-green-50 p-4 text-green-800",children:[n.jsx("div",{className:"success-tick-animation",children:n.jsx(te,{icon:"mdi:check-circle",width:"28",color:"#16a34a"})}),n.jsxs("div",{className:"text-sm w-full",children:[n.jsx("div",{className:"font-semibold",children:"Success!"}),n.jsx("div",{children:"Your smart order has been saved. I’ll watch the price and auto-purchase when the conditions are met."}),u&&n.jsxs("div",{className:"mt-2 text-xs font-medium",children:["Your Smart Order ID: ",n.jsx("span",{className:"font-semibold text-blue-600 cursor-pointer underline",children:u})]}),!Le&&n.jsxs("div",{className:"mt-4 rounded-lg bg-white/70 p-3 text-gray-900",children:[n.jsx("h4",{className:"font-semibold mb-1",children:"Please post your feedback here"}),n.jsx("p",{className:"text-sm text-gray-700 mb-3",children:"Rate us on how much our response was helpful"}),n.jsx("div",{className:"flex items-center gap-1 mb-3",children:[1,2,3,4,5].map(v=>n.jsx("button",{type:"button",onClick:()=>Qe(v),className:"p-0.5",children:n.jsx(te,{icon:je&&je>=v?"mdi:star":"mdi:star-outline",width:"20",className:"text-yellow-500"})},v))}),n.jsx("label",{className:"block text-sm text-gray-700 mb-1",children:"Tell us more about the response"}),n.jsx("textarea",{value:dt,onChange:v=>Pt(v.target.value),rows:3,className:"mt-1 w-full rounded-md border border-gray-300 p-2 text-sm outline-none focus:ring-1 focus:ring-gray-300",placeholder:"Your feedback helps us improve..."}),n.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[n.jsx("button",{type:"button",onClick:eo,className:"px-4 py-2 rounded-full border text-sm font-medium hover:bg-gray-50",children:"Cancel"}),n.jsx("button",{type:"button",onClick:Zn,className:"px-4 py-2 rounded-full text-sm font-semibold text-white shadow",style:{background:C},disabled:!je&&!dt.trim(),children:"Submit"})]})]}),Le&&n.jsx("div",{className:"mt-3 text-xs text-green-900 font-medium",children:"Thanks for your feedback! 💚"})]})]}):null},to=async()=>{try{z(s)}catch(d){console.error("Error fetching addresses:",d)}},bt=(d,m)=>{ye(u=>[...u,{query:"",response:"__SNAPSHOT__",snapshotStage:d,snapshotPayload:m}])},Er=(d,m)=>{ye(u=>u.map(v=>v.response==="__CARD__"?{...v,response:"__SNAPSHOT__",snapshotStage:d??v.snapshotStage,snapshotPayload:m??v.snapshotPayload}:v))},ro=()=>{ye(d=>d.filter(m=>!(m.query===""&&m.response!=="__SNAPSHOT__"&&m.response!=="__TEXT__")))},Tt=()=>{Z(!1),_e(!1),L(!1),re(!1),A(!1),$(!1),J(!1),Y(!1),E(!1),Ke(null),ro(),U(!1),oe(!1)},no=()=>{_e(!1),A(!1),L(!1),le("standard"),$(!1),re(!1),be("card"),J(!1),Z(!1),Y(!1),f(!0),Ke(null),localStorage.removeItem("agentic_order"),localStorage.removeItem("agentic_order_address"),localStorage.removeItem("agentic_order_delivery"),localStorage.removeItem("agentic_order_payment"),localStorage.removeItem("agentic_order_final")},Ne=x.useMemo(()=>Rt(r).map((m,u)=>({index:u,variant:m,images:((m==null?void 0:m.images)||[]).map(v=>(v==null?void 0:v.url)||"").filter(Boolean)})),[r]),vt=x.useMemo(()=>{if(!Ne.length)return!1;const d=k||void 0,m=_||void 0,u=(v,F)=>{var q;const b=et(Ne,v||void 0,F||void 0);return!!(b&&((q=b.variant)!=null&&q.sku))};return d&&m?u(d,m):d&&!m?u(d,null):!d&&m?u(void 0,m):!!(g&&g.sku)},[Ne,k,_,g]),oo=Q||D||!vt,jt=d=>{const m=Number((d==null?void 0:d.quantity)??1);return Number.isFinite(m)&&m>0?m:1},Tr=d=>{const m=jt(d),u=Number((d==null?void 0:d.max_price_minor)??0);return Number.isFinite(u)&&u>0?+(u/100):+(wn(r,g)*m)},Or=d=>{var W;const m=R,u=Bt(g),v=d||(m==null?void 0:m.currency)||u.currency||qe,F=Tr(m),b=+(F*.08).toFixed(2),q=((W=tt[T])==null?void 0:W.fee)||0;return{product_total:F,tax:b,shipping_fee:q,currency:v}},Xt=async(d,m,u)=>{Er(),no(),Ce(!0),E(!0),U(!1),oe(!1);const v=ke.slice(-vn);try{const F=await ir(null,null);if(!F)throw new Error("Failed to fetch token");const b=localStorage.getItem("customerNumber"),q=localStorage.getItem("isLoggedIn"),de=`https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({registered:String(q||!1),userId:String(b||new Date().getTime())}).toString()}`,ee=await fetch(`${de}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${F}`},body:JSON.stringify({flowId:"MTMI0P4LC6",flowAliasId:"BCUA138F2Q",input:{instruction:`Use SKU ${m}. Currency is USD. ${d}`,metadata:{productId:(r==null?void 0:r.id)??null,skuId:m??null,variantIndex:u},context:v}})});if(!ee.body)throw new Error("Readable stream not supported");const xe=ee.body.getReader(),ne=new TextDecoder;let Ie="",Fe="",Ae="";for(;;){const{done:he,value:Ue}=await xe.read();if(he)break;Ie+=ne.decode(Ue,{stream:!0});const ft=Ie.split(`
|
|
16
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ss(e,t){if(e){if(typeof e=="string")return Xr(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Xr(e,t)}}function Xr(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function Zr(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function jr(e,t,r){return t&&Zr(e.prototype,t),r&&Zr(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var kr=function(){return typeof Symbol=="function"},Sr=function(e){return kr()&&!!Symbol[e]},Nr=function(e){return Sr(e)?Symbol[e]:"@@"+e};kr()&&!Sr("observable")&&(Symbol.observable=Symbol("observable"));var as=Nr("iterator"),ur=Nr("observable"),$n=Nr("species");function Jt(e,t){var r=e[t];if(r!=null){if(typeof r!="function")throw new TypeError(r+" is not a function");return r}}function kt(e){var t=e.constructor;return t!==void 0&&(t=t[$n],t===null&&(t=void 0)),t!==void 0?t:fe}function is(e){return e instanceof fe}function gt(e){gt.log?gt.log(e):setTimeout(function(){throw e})}function zt(e){Promise.resolve().then(function(){try{e()}catch(t){gt(t)}})}function Dn(e){var t=e._cleanup;if(t!==void 0&&(e._cleanup=void 0,!!t))try{if(typeof t=="function")t();else{var r=Jt(t,"unsubscribe");r&&r.call(t)}}catch(o){gt(o)}}function fr(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function ls(e){var t=e._queue;if(t){e._queue=void 0,e._state="ready";for(var r=0;r<t.length&&(Ln(e,t[r].type,t[r].value),e._state!=="closed");++r);}}function Ln(e,t,r){e._state="running";var o=e._observer;try{var s=Jt(o,t);switch(t){case"next":s&&s.call(o,r);break;case"error":if(fr(e),s)s.call(o,r);else throw r;break;case"complete":fr(e),s&&s.call(o);break}}catch(a){gt(a)}e._state==="closed"?Dn(e):e._state==="running"&&(e._state="ready")}function nr(e,t,r){if(e._state!=="closed"){if(e._state==="buffering"){e._queue.push({type:t,value:r});return}if(e._state!=="ready"){e._state="buffering",e._queue=[{type:t,value:r}],zt(function(){return ls(e)});return}Ln(e,t,r)}}var cs=(function(){function e(r,o){this._cleanup=void 0,this._observer=r,this._queue=void 0,this._state="initializing";var s=new ds(this);try{this._cleanup=o.call(void 0,s)}catch(a){s.error(a)}this._state==="initializing"&&(this._state="ready")}var t=e.prototype;return t.unsubscribe=function(){this._state!=="closed"&&(fr(this),Dn(this))},jr(e,[{key:"closed",get:function(){return this._state==="closed"}}]),e})(),ds=(function(){function e(r){this._subscription=r}var t=e.prototype;return t.next=function(o){nr(this._subscription,"next",o)},t.error=function(o){nr(this._subscription,"error",o)},t.complete=function(){nr(this._subscription,"complete")},jr(e,[{key:"closed",get:function(){return this._subscription._state==="closed"}}]),e})(),fe=(function(){function e(r){if(!(this instanceof e))throw new TypeError("Observable cannot be called as a function");if(typeof r!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=r}var t=e.prototype;return t.subscribe=function(o){return(typeof o!="object"||o===null)&&(o={next:o,error:arguments[1],complete:arguments[2]}),new cs(o,this._subscriber)},t.forEach=function(o){var s=this;return new Promise(function(a,i){if(typeof o!="function"){i(new TypeError(o+" is not a function"));return}function c(){l.unsubscribe(),a()}var l=s.subscribe({next:function(p){try{o(p,c)}catch(h){i(h),l.unsubscribe()}},error:i,complete:a})})},t.map=function(o){var s=this;if(typeof o!="function")throw new TypeError(o+" is not a function");var a=kt(this);return new a(function(i){return s.subscribe({next:function(c){try{c=o(c)}catch(l){return i.error(l)}i.next(c)},error:function(c){i.error(c)},complete:function(){i.complete()}})})},t.filter=function(o){var s=this;if(typeof o!="function")throw new TypeError(o+" is not a function");var a=kt(this);return new a(function(i){return s.subscribe({next:function(c){try{if(!o(c))return}catch(l){return i.error(l)}i.next(c)},error:function(c){i.error(c)},complete:function(){i.complete()}})})},t.reduce=function(o){var s=this;if(typeof o!="function")throw new TypeError(o+" is not a function");var a=kt(this),i=arguments.length>1,c=!1,l=arguments[1],p=l;return new a(function(h){return s.subscribe({next:function(y){var w=!c;if(c=!0,!w||i)try{p=o(p,y)}catch(k){return h.error(k)}else p=y},error:function(y){h.error(y)},complete:function(){if(!c&&!i)return h.error(new TypeError("Cannot reduce an empty sequence"));h.next(p),h.complete()}})})},t.concat=function(){for(var o=this,s=arguments.length,a=new Array(s),i=0;i<s;i++)a[i]=arguments[i];var c=kt(this);return new c(function(l){var p,h=0;function y(w){p=w.subscribe({next:function(k){l.next(k)},error:function(k){l.error(k)},complete:function(){h===a.length?(p=void 0,l.complete()):y(c.from(a[h++]))}})}return y(o),function(){p&&(p.unsubscribe(),p=void 0)}})},t.flatMap=function(o){var s=this;if(typeof o!="function")throw new TypeError(o+" is not a function");var a=kt(this);return new a(function(i){var c=[],l=s.subscribe({next:function(h){if(o)try{h=o(h)}catch(w){return i.error(w)}var y=a.from(h).subscribe({next:function(w){i.next(w)},error:function(w){i.error(w)},complete:function(){var w=c.indexOf(y);w>=0&&c.splice(w,1),p()}});c.push(y)},error:function(h){i.error(h)},complete:function(){p()}});function p(){l.closed&&c.length===0&&i.complete()}return function(){c.forEach(function(h){return h.unsubscribe()}),l.unsubscribe()}})},t[ur]=function(){return this},e.from=function(o){var s=typeof this=="function"?this:e;if(o==null)throw new TypeError(o+" is not an object");var a=Jt(o,ur);if(a){var i=a.call(o);if(Object(i)!==i)throw new TypeError(i+" is not an object");return is(i)&&i.constructor===s?i:new s(function(c){return i.subscribe(c)})}if(Sr("iterator")&&(a=Jt(o,as),a))return new s(function(c){zt(function(){if(!c.closed){for(var l=os(a.call(o)),p;!(p=l()).done;){var h=p.value;if(c.next(h),c.closed)return}c.complete()}})});if(Array.isArray(o))return new s(function(c){zt(function(){if(!c.closed){for(var l=0;l<o.length;++l)if(c.next(o[l]),c.closed)return;c.complete()}})});throw new TypeError(o+" is not observable")},e.of=function(){for(var o=arguments.length,s=new Array(o),a=0;a<o;a++)s[a]=arguments[a];var i=typeof this=="function"?this:e;return new i(function(c){zt(function(){if(!c.closed){for(var l=0;l<s.length;++l)if(c.next(s[l]),c.closed)return;c.complete()}})})},jr(e,null,[{key:$n,get:function(){return this}}]),e})();kr()&&Object.defineProperty(fe,Symbol("extensions"),{value:{symbol:ur,hostReportError:gt},configurable:!0});function us(e){var t,r=e.Symbol;if(typeof r=="function")if(r.observable)t=r.observable;else{typeof r.for=="function"?t=r.for("https://github.com/benlesh/symbol-observable"):t=r("https://github.com/benlesh/symbol-observable");try{r.observable=t}catch{}}else t="@@observable";return t}var pt;typeof self<"u"?pt=self:typeof window<"u"?pt=window:typeof global<"u"?pt=global:typeof module<"u"?pt=module:pt=Function("return this")();us(pt);var en=fe.prototype,tn="@@observable";en[tn]||(en[tn]=function(){return this});function fs(e){for(var t=["query","operationName","variables","extensions","context"],r=0,o=Object.keys(e);r<o.length;r++){var s=o[r];if(t.indexOf(s)<0)throw On(58,s)}return e}function ms(e,t){var r=Ye({},e),o=function(a){typeof a=="function"?r=Ye(Ye({},r),a(r)):r=Ye(Ye({},r),a)},s=function(){return Ye({},r)};return Object.defineProperty(t,"setContext",{enumerable:!1,value:o}),Object.defineProperty(t,"getContext",{enumerable:!1,value:s}),t}function hs(e){var t={variables:e.variables||{},extensions:e.extensions||{},operationName:e.operationName,query:e.query};return t.operationName||(t.operationName=typeof t.query!="string"?es(t.query)||void 0:""),t}var ps=Symbol.for("apollo.deprecations"),gs=dr,xs=new vr;function ys(e){return gs[ps]||(xs.getValue()||[]).includes(e)}function ws(e,t){ys(e)||t()}function rn(e,t){return t?t(e):fe.of()}function St(e){return typeof e=="function"?new zn(e):e}function Lt(e){return e.request.length<=1}var zn=(function(){function e(t){t&&(this.request=t)}return e.empty=function(){return new e(function(){return fe.of()})},e.from=function(t){return t.length===0?e.empty():t.map(St).reduce(function(r,o){return r.concat(o)})},e.split=function(t,r,o){var s=St(r),a=St(o||new e(rn)),i;return Lt(s)&&Lt(a)?i=new e(function(c){return t(c)?s.request(c)||fe.of():a.request(c)||fe.of()}):i=new e(function(c,l){return t(c)?s.request(c,l)||fe.of():a.request(c,l)||fe.of()}),Object.assign(i,{left:s,right:a})},e.execute=function(t,r){return t.request(ms(r.context,hs(fs(r))))||fe.of()},e.concat=function(t,r){var o=St(t);if(Lt(o))return globalThis.__DEV__!==!1&&tr.warn(47,o),o;var s=St(r),a;return Lt(s)?a=new e(function(i){return o.request(i,function(c){return s.request(c)||fe.of()})||fe.of()}):a=new e(function(i,c){return o.request(i,function(l){return s.request(l,c)||fe.of()})||fe.of()}),Object.assign(a,{left:o,right:s})},e.prototype.split=function(t,r,o){return this.concat(e.split(t,r,o||new e(rn)))},e.prototype.concat=function(t){return e.concat(this,t)},e.prototype.request=function(t,r){throw On(48)},e.prototype.onError=function(t,r){if(globalThis.__DEV__!==!1&&ws("onError",function(){globalThis.__DEV__!==!1&&tr.warn(49)}),r&&r.error)return r.error(t),!1;throw t},e.prototype.setOnError=function(t){return globalThis.__DEV__!==!1&&globalThis.__DEV__!==!1&&tr.warn(50),this.onError=t,this},e})();function bs(e){return new zn(function(t,r){var o=Wo(t,[]);return new fe(function(s){var a,i=!1;return Promise.resolve(o).then(function(c){return e(c,t.getContext())}).then(t.setContext).then(function(){i||(a=r(t).subscribe({next:s.next.bind(s),error:s.error.bind(s),complete:s.complete.bind(s)}))}).catch(s.error.bind(s)),function(){i=!0,a&&a.unsubscribe()}})})}const vs=async()=>{const e="https://auth.australia-southeast1.gcp.commercetools.com/oauth/token",o="Basic "+btoa(encodeURIComponent("tfegsSBVOYnR7e_yE-AjxVVN")+":"+encodeURIComponent("pyKWgHuTxuMwDygh9JH1ehLEaLvAhBo4"));try{const s=await pe.post(e,new URLSearchParams({grant_type:"client_credentials"}),{headers:{"Content-Type":"application/x-www-form-urlencoded",Authorization:o}});return s.status===200&&s.data.access_token?s.data.access_token:(console.error("Failed to fetch token:",s.data),null)}catch(s){return pe.isAxiosError(s)?console.error("Error fetching token:",s.response||s.message):console.error("Unexpected error:",s),null}},js="https://api.australia-southeast1.gcp.commercetools.com/kt-demo/graphql",ks=Ut.createHttpLink({uri:`${js}`}),Ss=bs(async(e,{headers:t})=>{const r=await vs();return{headers:{...t,authorization:`Bearer ${r}`}}}),Ns=new Ut.ApolloClient({link:Ss.concat(ks),cache:new Ut.InMemoryCache,defaultOptions:{watchQuery:{fetchPolicy:"cache-and-network"}}}),Cs=e=>{const{tanyaConfig:t}=e;return n.jsx(Ut.ApolloProvider,{client:Ns,children:n.jsx($o,{children:n.jsx(Jo,{tanyaConfig:t})})})};function _s(e,t){const r=e.icons,o=e.aliases||Object.create(null),s=Object.create(null);function a(i){if(r[i])return s[i]=[];if(!(i in s)){s[i]=null;const c=o[i]&&o[i].parent,l=c&&a(c);l&&(s[i]=[c].concat(l))}return s[i]}return Object.keys(r).concat(Object.keys(o)).forEach(a),s}const Mn=Object.freeze({left:0,top:0,width:16,height:16}),Kt=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Cr=Object.freeze({...Mn,...Kt}),mr=Object.freeze({...Cr,body:"",hidden:!1});function Is(e,t){const r={};!e.hFlip!=!t.hFlip&&(r.hFlip=!0),!e.vFlip!=!t.vFlip&&(r.vFlip=!0);const o=((e.rotate||0)+(t.rotate||0))%4;return o&&(r.rotate=o),r}function nn(e,t){const r=Is(e,t);for(const o in mr)o in Kt?o in e&&!(o in r)&&(r[o]=Kt[o]):o in t?r[o]=t[o]:o in e&&(r[o]=e[o]);return r}function Fs(e,t,r){const o=e.icons,s=e.aliases||Object.create(null);let a={};function i(c){a=nn(o[c]||s[c],a)}return i(t),r.forEach(i),nn(e,a)}function qn(e,t){const r=[];if(typeof e!="object"||typeof e.icons!="object")return r;e.not_found instanceof Array&&e.not_found.forEach(s=>{t(s,null),r.push(s)});const o=_s(e);for(const s in o){const a=o[s];a&&(t(s,Fs(e,s,a)),r.push(s))}return r}const Ps={provider:"",aliases:{},not_found:{},...Mn};function or(e,t){for(const r in t)if(r in e&&typeof e[r]!=typeof t[r])return!1;return!0}function Rn(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!or(e,Ps))return null;const r=t.icons;for(const s in r){const a=r[s];if(!s||typeof a.body!="string"||!or(a,mr))return null}const o=t.aliases||Object.create(null);for(const s in o){const a=o[s],i=a.parent;if(!s||typeof i!="string"||!r[i]&&!o[i]||!or(a,mr))return null}return t}const on=Object.create(null);function Es(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function xt(e,t){const r=on[e]||(on[e]=Object.create(null));return r[t]||(r[t]=Es(e,t))}function Bn(e,t){return Rn(t)?qn(t,(r,o)=>{o?e.icons[r]=o:e.missing.add(r)}):[]}function Ts(e,t,r){try{if(typeof r.body=="string")return e.icons[t]={...r},!0}catch{}return!1}const Un=/^[a-z0-9]+(-[a-z0-9]+)*$/,Wt=(e,t,r,o="")=>{const s=e.split(":");if(e.slice(0,1)==="@"){if(s.length<2||s.length>3)return null;o=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const c=s.pop(),l=s.pop(),p={provider:s.length>0?s[0]:o,prefix:l,name:c};return t&&!Mt(p)?null:p}const a=s[0],i=a.split("-");if(i.length>1){const c={provider:o,prefix:i.shift(),name:i.join("-")};return t&&!Mt(c)?null:c}if(r&&o===""){const c={provider:o,prefix:"",name:a};return t&&!Mt(c,r)?null:c}return null},Mt=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let Ft=!1;function Hn(e){return typeof e=="boolean"&&(Ft=e),Ft}function sn(e){const t=typeof e=="string"?Wt(e,!0,Ft):e;if(t){const r=xt(t.provider,t.prefix),o=t.name;return r.icons[o]||(r.missing.has(o)?null:void 0)}}function Os(e,t){const r=Wt(e,!0,Ft);if(!r)return!1;const o=xt(r.provider,r.prefix);return t?Ts(o,r.name,t):(o.missing.add(r.name),!0)}function As(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),Ft&&!t&&!e.prefix){let s=!1;return Rn(e)&&(e.prefix="",qn(e,(a,i)=>{Os(a,i)&&(s=!0)})),s}const r=e.prefix;if(!Mt({prefix:r,name:"a"}))return!1;const o=xt(t,r);return!!Bn(o,e)}const Vn=Object.freeze({width:null,height:null}),Yn=Object.freeze({...Vn,...Kt}),$s=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Ds=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function an(e,t,r){if(t===1)return e;if(r=r||100,typeof e=="number")return Math.ceil(e*t*r)/r;if(typeof e!="string")return e;const o=e.split($s);if(o===null||!o.length)return e;const s=[];let a=o.shift(),i=Ds.test(a);for(;;){if(i){const c=parseFloat(a);isNaN(c)?s.push(a):s.push(Math.ceil(c*t*r)/r)}else s.push(a);if(a=o.shift(),a===void 0)return s.join("");i=!i}}function Ls(e,t="defs"){let r="";const o=e.indexOf("<"+t);for(;o>=0;){const s=e.indexOf(">",o),a=e.indexOf("</"+t);if(s===-1||a===-1)break;const i=e.indexOf(">",a);if(i===-1)break;r+=e.slice(s+1,a).trim(),e=e.slice(0,o).trim()+e.slice(i+1)}return{defs:r,content:e}}function zs(e,t){return e?"<defs>"+e+"</defs>"+t:t}function Ms(e,t,r){const o=Ls(e);return zs(o.defs,t+o.content+r)}const qs=e=>e==="unset"||e==="undefined"||e==="none";function Rs(e,t){const r={...Cr,...e},o={...Yn,...t},s={left:r.left,top:r.top,width:r.width,height:r.height};let a=r.body;[r,o].forEach(_=>{const S=[],I=_.hFlip,B=_.vFlip;let g=_.rotate;I?B?g+=2:(S.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),S.push("scale(-1 1)"),s.top=s.left=0):B&&(S.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),S.push("scale(1 -1)"),s.top=s.left=0);let H;switch(g<0&&(g-=Math.floor(g/4)*4),g=g%4,g){case 1:H=s.height/2+s.top,S.unshift("rotate(90 "+H.toString()+" "+H.toString()+")");break;case 2:S.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:H=s.width/2+s.left,S.unshift("rotate(-90 "+H.toString()+" "+H.toString()+")");break}g%2===1&&(s.left!==s.top&&(H=s.left,s.left=s.top,s.top=H),s.width!==s.height&&(H=s.width,s.width=s.height,s.height=H)),S.length&&(a=Ms(a,'<g transform="'+S.join(" ")+'">',"</g>"))});const i=o.width,c=o.height,l=s.width,p=s.height;let h,y;i===null?(y=c===null?"1em":c==="auto"?p:c,h=an(y,l/p)):(h=i==="auto"?l:i,y=c===null?an(h,p/l):c==="auto"?p:c);const w={},k=(_,S)=>{qs(S)||(w[_]=S.toString())};k("width",h),k("height",y);const N=[s.left,s.top,l,p];return w.viewBox=N.join(" "),{attributes:w,viewBox:N,body:a}}const Bs=/\sid="(\S+)"/g,Us="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let Hs=0;function Vs(e,t=Us){const r=[];let o;for(;o=Bs.exec(e);)r.push(o[1]);if(!r.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return r.forEach(a=>{const i=typeof t=="function"?t(a):t+(Hs++).toString(),c=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+c+')([")]|\\.[a-z])',"g"),"$1"+i+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const hr=Object.create(null);function Ys(e,t){hr[e]=t}function pr(e){return hr[e]||hr[""]}function _r(e){let t;if(typeof e.resources=="string")t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}const Ir=Object.create(null),Nt=["https://api.simplesvg.com","https://api.unisvg.com"],qt=[];for(;Nt.length>0;)Nt.length===1||Math.random()>.5?qt.push(Nt.shift()):qt.push(Nt.pop());Ir[""]=_r({resources:["https://api.iconify.design"].concat(qt)});function Js(e,t){const r=_r(t);return r===null?!1:(Ir[e]=r,!0)}function Fr(e){return Ir[e]}const Ks=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let ln=Ks();function Ws(e,t){const r=Fr(e);if(!r)return 0;let o;if(!r.maxURL)o=0;else{let s=0;r.resources.forEach(i=>{s=Math.max(s,i.length)});const a=t+".json?icons=";o=r.maxURL-s-r.path.length-a.length}return o}function Qs(e){return e===404}const Gs=(e,t,r)=>{const o=[],s=Ws(e,t),a="icons";let i={type:a,provider:e,prefix:t,icons:[]},c=0;return r.forEach((l,p)=>{c+=l.length+1,c>=s&&p>0&&(o.push(i),i={type:a,provider:e,prefix:t,icons:[]},c=l.length),i.icons.push(l)}),o.push(i),o};function Xs(e){if(typeof e=="string"){const t=Fr(e);if(t)return t.path}return"/"}const Zs=(e,t,r)=>{if(!ln){r("abort",424);return}let o=Xs(t.provider);switch(t.type){case"icons":{const a=t.prefix,c=t.icons.join(","),l=new URLSearchParams({icons:c});o+=a+".json?"+l.toString();break}case"custom":{const a=t.uri;o+=a.slice(0,1)==="/"?a.slice(1):a;break}default:r("abort",400);return}let s=503;ln(e+o).then(a=>{const i=a.status;if(i!==200){setTimeout(()=>{r(Qs(i)?"abort":"next",i)});return}return s=501,a.json()}).then(a=>{if(typeof a!="object"||a===null){setTimeout(()=>{a===404?r("abort",a):r("next",s)});return}setTimeout(()=>{r("success",a)})}).catch(()=>{r("next",s)})},ea={prepare:Gs,send:Zs};function Jn(e,t){e.forEach(r=>{const o=r.loaderCallbacks;o&&(r.loaderCallbacks=o.filter(s=>s.id!==t))})}function ta(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let r=!1;const o=e.provider,s=e.prefix;t.forEach(a=>{const i=a.icons,c=i.pending.length;i.pending=i.pending.filter(l=>{if(l.prefix!==s)return!0;const p=l.name;if(e.icons[p])i.loaded.push({provider:o,prefix:s,name:p});else if(e.missing.has(p))i.missing.push({provider:o,prefix:s,name:p});else return r=!0,!0;return!1}),i.pending.length!==c&&(r||Jn([e],a.id),a.callback(i.loaded.slice(0),i.missing.slice(0),i.pending.slice(0),a.abort))})}))}let ra=0;function na(e,t,r){const o=ra++,s=Jn.bind(null,r,o);if(!t.pending.length)return s;const a={id:o,icons:t,callback:e,abort:s};return r.forEach(i=>{(i.loaderCallbacks||(i.loaderCallbacks=[])).push(a)}),s}function oa(e){const t={loaded:[],missing:[],pending:[]},r=Object.create(null);e.sort((s,a)=>s.provider!==a.provider?s.provider.localeCompare(a.provider):s.prefix!==a.prefix?s.prefix.localeCompare(a.prefix):s.name.localeCompare(a.name));let o={provider:"",prefix:"",name:""};return e.forEach(s=>{if(o.name===s.name&&o.prefix===s.prefix&&o.provider===s.provider)return;o=s;const a=s.provider,i=s.prefix,c=s.name,l=r[a]||(r[a]=Object.create(null)),p=l[i]||(l[i]=xt(a,i));let h;c in p.icons?h=t.loaded:i===""||p.missing.has(c)?h=t.missing:h=t.pending;const y={provider:a,prefix:i,name:c};h.push(y)}),t}function sa(e,t=!0,r=!1){const o=[];return e.forEach(s=>{const a=typeof s=="string"?Wt(s,t,r):s;a&&o.push(a)}),o}const aa={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function ia(e,t,r,o){const s=e.resources.length,a=e.random?Math.floor(Math.random()*s):e.index;let i;if(e.random){let P=e.resources.slice(0);for(i=[];P.length>1;){const U=Math.floor(Math.random()*P.length);i.push(P[U]),P=P.slice(0,U).concat(P.slice(U+1))}i=i.concat(P)}else i=e.resources.slice(a).concat(e.resources.slice(0,a));const c=Date.now();let l="pending",p=0,h,y=null,w=[],k=[];typeof o=="function"&&k.push(o);function N(){y&&(clearTimeout(y),y=null)}function _(){l==="pending"&&(l="aborted"),N(),w.forEach(P=>{P.status==="pending"&&(P.status="aborted")}),w=[]}function S(P,U){U&&(k=[]),typeof P=="function"&&k.push(P)}function I(){return{startTime:c,payload:t,status:l,queriesSent:p,queriesPending:w.length,subscribe:S,abort:_}}function B(){l="failed",k.forEach(P=>{P(void 0,h)})}function g(){w.forEach(P=>{P.status==="pending"&&(P.status="aborted")}),w=[]}function H(P,U,ge){const oe=U!=="success";switch(w=w.filter(Q=>Q!==P),l){case"pending":break;case"failed":if(oe||!e.dataAfterTimeout)return;break;default:return}if(U==="abort"){h=ge,B();return}if(oe){h=ge,w.length||(i.length?Ee():B());return}if(N(),g(),!e.random){const Q=e.resources.indexOf(P.resource);Q!==-1&&Q!==e.index&&(e.index=Q)}l="completed",k.forEach(Q=>{Q(ge)})}function Ee(){if(l!=="pending")return;N();const P=i.shift();if(P===void 0){if(w.length){y=setTimeout(()=>{N(),l==="pending"&&(g(),B())},e.timeout);return}B();return}const U={status:"pending",resource:P,callback:(ge,oe)=>{H(U,ge,oe)}};w.push(U),p++,y=setTimeout(Ee,e.rotate),r(P,t,U.callback)}return setTimeout(Ee),I}function Kn(e){const t={...aa,...e};let r=[];function o(){r=r.filter(c=>c().status==="pending")}function s(c,l,p){const h=ia(t,c,l,(y,w)=>{o(),p&&p(y,w)});return r.push(h),h}function a(c){return r.find(l=>c(l))||null}return{query:s,find:a,setIndex:c=>{t.index=c},getIndex:()=>t.index,cleanup:o}}function cn(){}const sr=Object.create(null);function la(e){if(!sr[e]){const t=Fr(e);if(!t)return;const r=Kn(t),o={config:t,redundancy:r};sr[e]=o}return sr[e]}function ca(e,t,r){let o,s;if(typeof e=="string"){const a=pr(e);if(!a)return r(void 0,424),cn;s=a.send;const i=la(e);i&&(o=i.redundancy)}else{const a=_r(e);if(a){o=Kn(a);const i=e.resources?e.resources[0]:"",c=pr(i);c&&(s=c.send)}}return!o||!s?(r(void 0,424),cn):o.query(t,s,r)().abort}function dn(){}function da(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,ta(e)}))}function ua(e){const t=[],r=[];return e.forEach(o=>{(o.match(Un)?t:r).push(o)}),{valid:t,invalid:r}}function Ct(e,t,r){function o(){const s=e.pendingIcons;t.forEach(a=>{s&&s.delete(a),e.icons[a]||e.missing.add(a)})}if(r&&typeof r=="object")try{if(!Bn(e,r).length){o();return}}catch(s){console.error(s)}o(),da(e)}function un(e,t){e instanceof Promise?e.then(r=>{t(r)}).catch(()=>{t(null)}):t(e)}function fa(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;const{provider:r,prefix:o}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const a=e.loadIcon;if(e.loadIcons&&(s.length>1||!a)){un(e.loadIcons(s,o,r),h=>{Ct(e,s,h)});return}if(a){s.forEach(h=>{const y=a(h,o,r);un(y,w=>{const k=w?{prefix:o,icons:{[h]:w}}:null;Ct(e,[h],k)})});return}const{valid:i,invalid:c}=ua(s);if(c.length&&Ct(e,c,null),!i.length)return;const l=o.match(Un)?pr(r):null;if(!l){Ct(e,i,null);return}l.prepare(r,o,i).forEach(h=>{ca(r,h,y=>{Ct(e,h.icons,y)})})}))}const ma=(e,t)=>{const r=sa(e,!0,Hn()),o=oa(r);if(!o.pending.length){let l=!0;return t&&setTimeout(()=>{l&&t(o.loaded,o.missing,o.pending,dn)}),()=>{l=!1}}const s=Object.create(null),a=[];let i,c;return o.pending.forEach(l=>{const{provider:p,prefix:h}=l;if(h===c&&p===i)return;i=p,c=h,a.push(xt(p,h));const y=s[p]||(s[p]=Object.create(null));y[h]||(y[h]=[])}),o.pending.forEach(l=>{const{provider:p,prefix:h,name:y}=l,w=xt(p,h),k=w.pendingIcons||(w.pendingIcons=new Set);k.has(y)||(k.add(y),s[p][h].push(y))}),a.forEach(l=>{const p=s[l.provider][l.prefix];p.length&&fa(l,p)}),t?na(t,o,a):dn};function ha(e,t){const r={...e};for(const o in t){const s=t[o],a=typeof s;o in Vn?(s===null||s&&(a==="string"||a==="number"))&&(r[o]=s):a===typeof r[o]&&(r[o]=o==="rotate"?s%4:s)}return r}const pa=/[\s,]+/;function ga(e,t){t.split(pa).forEach(r=>{switch(r.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function xa(e,t=0){const r=e.replace(/^-?[0-9.]*/,"");function o(s){for(;s<0;)s+=4;return s%4}if(r===""){const s=parseInt(e);return isNaN(s)?0:o(s)}else if(r!==e){let s=0;switch(r){case"%":s=25;break;case"deg":s=90}if(s){let a=parseFloat(e.slice(0,e.length-r.length));return isNaN(a)?0:(a=a/s,a%1===0?o(a):0)}}return t}function ya(e,t){let r=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const o in t)r+=" "+o+'="'+t[o]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+r+">"+e+"</svg>"}function wa(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function ba(e){return"data:image/svg+xml,"+wa(e)}function va(e){return'url("'+ba(e)+'")'}let _t;function ja(){try{_t=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{_t=null}}function ka(e){return _t===void 0&&ja(),_t?_t.createHTML(e):e}const Wn={...Yn,inline:!1},Sa={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Na={display:"inline-block"},gr={backgroundColor:"currentColor"},Qn={backgroundColor:"transparent"},fn={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},mn={WebkitMask:gr,mask:gr,background:Qn};for(const e in mn){const t=mn[e];for(const r in fn)t[e+r]=fn[r]}const Ca={...Wn,inline:!0};function hn(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const _a=(e,t,r)=>{const o=t.inline?Ca:Wn,s=ha(o,t),a=t.mode||"svg",i={},c=t.style||{},l={...a==="svg"?Sa:{}};if(r){const S=Wt(r,!1,!0);if(S){const I=["iconify"],B=["provider","prefix"];for(const g of B)S[g]&&I.push("iconify--"+S[g]);l.className=I.join(" ")}}for(let S in t){const I=t[S];if(I!==void 0)switch(S){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":l.ref=I;break;case"className":l[S]=(l[S]?l[S]+" ":"")+I;break;case"inline":case"hFlip":case"vFlip":s[S]=I===!0||I==="true"||I===1;break;case"flip":typeof I=="string"&&ga(s,I);break;case"color":i.color=I;break;case"rotate":typeof I=="string"?s[S]=xa(I):typeof I=="number"&&(s[S]=I);break;case"ariaHidden":case"aria-hidden":I!==!0&&I!=="true"&&delete l["aria-hidden"];break;default:o[S]===void 0&&(l[S]=I)}}const p=Rs(e,s),h=p.attributes;if(s.inline&&(i.verticalAlign="-0.125em"),a==="svg"){l.style={...i,...c},Object.assign(l,h);let S=0,I=t.id;return typeof I=="string"&&(I=I.replace(/-/g,"_")),l.dangerouslySetInnerHTML={__html:ka(Vs(p.body,I?()=>I+"ID"+S++:"iconifyReact"))},x.createElement("svg",l)}const{body:y,width:w,height:k}=e,N=a==="mask"||(a==="bg"?!1:y.indexOf("currentColor")!==-1),_=ya(y,{...h,width:w+"",height:k+""});return l.style={...i,"--svg":va(_),width:hn(h.width),height:hn(h.height),...Na,...N?gr:Qn,...c},x.createElement("span",l)};Hn(!0);Ys("",ea);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,r="Invalid IconifyPreload syntax.";typeof t=="object"&&t!==null&&(t instanceof Array?t:[t]).forEach(o=>{try{(typeof o!="object"||o===null||o instanceof Array||typeof o.icons!="object"||typeof o.prefix!="string"||!As(o))&&console.error(r)}catch{console.error(r)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let r in t){const o="IconifyProviders["+r+"] is invalid.";try{const s=t[r];if(typeof s!="object"||!s||s.resources===void 0)continue;Js(r,s)||console.error(o)}catch{console.error(o)}}}}function Gn(e){const[t,r]=x.useState(!!e.ssr),[o,s]=x.useState({});function a(k){if(k){const N=e.icon;if(typeof N=="object")return{name:"",data:N};const _=sn(N);if(_)return{name:N,data:_}}return{name:""}}const[i,c]=x.useState(a(!!e.ssr));function l(){const k=o.callback;k&&(k(),s({}))}function p(k){if(JSON.stringify(i)!==JSON.stringify(k))return l(),c(k),!0}function h(){var k;const N=e.icon;if(typeof N=="object"){p({name:"",data:N});return}const _=sn(N);if(p({name:N,data:_}))if(_===void 0){const S=ma([N],h);s({callback:S})}else _&&((k=e.onLoad)===null||k===void 0||k.call(e,N))}x.useEffect(()=>(r(!0),l),[]),x.useEffect(()=>{t&&h()},[e.icon,t]);const{name:y,data:w}=i;return w?_a({...Cr,...w},e,y):e.children?e.children:e.fallback?e.fallback:x.createElement("span",{})}const te=x.forwardRef((e,t)=>Gn({...e,_ref:t}));x.forwardRef((e,t)=>Gn({inline:!0,...e,_ref:t}));const qe="USD",pn=e=>{var o,s,a;const t=e==null?void 0:e.availability;if(!t)return!1;const r=(a=(s=(o=t.channels)==null?void 0:o.results)==null?void 0:s[0])==null?void 0:a.availability;return r?r.isOnStock===!0&&(r.availableQuantity??0)>0:!1},xr=(e,t=qe)=>{const r=(e==null?void 0:e.prices)??[];if(!r.length)return null;const o=i=>{var p,h;const c=i.find(y=>{var w;return!!((w=y.discounted)!=null&&w.value)});if(c)return{cent:c.discounted.value.centAmount,cur:c.discounted.value.currencyCode,regularCent:(p=c.value)==null?void 0:p.centAmount};const l=(h=i[0])==null?void 0:h.value;return l?{cent:l.centAmount,cur:l.currencyCode}:null},s=r.filter(i=>{var c,l;return((l=((c=i.discounted)==null?void 0:c.value)||i.value)==null?void 0:l.currencyCode)===t}),a=o(s);return a||o(r)||null},Ia=(e,t)=>{if(!Array.isArray(e))return"";const r=e.find(o=>o.name===t)||e.find(o=>{var s;return((s=o.name)==null?void 0:s.toLowerCase())===t.toLowerCase()});return!r||!r.value?"":typeof r.value=="object"?r.value.label||"":r.value},Fa=e=>{let t="";if(Array.isArray(e)){const r=e.find(o=>o.name==="size")||e.find(o=>o.name==="Size");r&&r.value&&(t=typeof r.value=="object"?r.value.label||"":r.value)}return{sizeLabel:t}},Me=e=>Ia((e==null?void 0:e.attributesRaw)??[],"color"),Ve=e=>Fa((e==null?void 0:e.attributesRaw)??[]).sizeLabel,et=(e,t,r)=>{for(const o of e){const s=Me(o.variant),a=Ve(o.variant);if((t?s===t:!0)&&(r?a===r:!0))return o}return null},He=e=>e.charAt(0).toUpperCase()+e.slice(1),tt={standard:{label:"Standard Delivery",fee:0,subtitle:"Arrives in 4–6 days (Free)",icon:"mdi:clock-outline"},express:{label:"Express Delivery",fee:5,subtitle:"Arrives in 1–2 days (+$5)",icon:"mdi:flash"},sameday:{label:"Same-Day Delivery",fee:10,subtitle:"Available in select locations (+$10)",icon:"mdi:truck-fast-outline"}},Pa={standard:"GROUND",express:"2-DAY SHIPPING",sameday:"OVERNIGHT"},Pe=(e,t)=>{try{return e.toLocaleString("en-US",{style:"currency",currency:t||"USD"})}catch{return`${t} ${e.toFixed(2)}`}},Xn=e=>e==null?void 0:e.masterVariant,gn=e=>Array.isArray(e==null?void 0:e.variants)?e.variants:[],Rt=e=>{const t=Xn(e);return t?[t,...gn(e)]:gn(e)},Ea=(e,t=0)=>Rt(e)[t],Ta=e=>{var t,r;return((r=(t=e==null?void 0:e.images)==null?void 0:t[0])==null?void 0:r.url)??""},xn=(e,t)=>{var r,o,s,a;return Ta(t)||(e==null?void 0:e.image)||((o=(r=e==null?void 0:e.images)==null?void 0:r[0])==null?void 0:o.src)||((a=(s=e==null?void 0:e.media)==null?void 0:s[0])==null?void 0:a.url)||""},yn=e=>(e==null?void 0:e.name)||(e==null?void 0:e.title)||(e==null?void 0:e.productName)||"any",Bt=e=>{var a,i,c,l,p,h;const t=e?xr(e,qe):null;if(t!=null&&t.cent&&(t!=null&&t.cur))return{amount:+(t.cent/100),currency:t.cur,regularAmount:t.regularCent?t.regularCent/100:void 0};const r=(c=(i=(a=e==null?void 0:e.prices)==null?void 0:a[0])==null?void 0:i.value)==null?void 0:c.centAmount,o=((h=(p=(l=e==null?void 0:e.prices)==null?void 0:l[0])==null?void 0:p.value)==null?void 0:h.currencyCode)??qe;return{amount:Number.isFinite(r)?+(Number(r)/100):0,currency:o}},wn=(e,t)=>{const{amount:r}=Bt(t);if(r)return r;const o=(e==null?void 0:e.price)??(e==null?void 0:e.sellingPrice)??(e==null?void 0:e.unitPrice)??(e==null?void 0:e.mrp)??0,s=Number(o);return Number.isFinite(s)?s:0},bn=e=>{var t;return(e==null?void 0:e.sku)||((t=e==null?void 0:e.variant)==null?void 0:t.sku)||(e==null?void 0:e.selectedSku)||""},Oa=e=>{var t;return(e==null?void 0:e.color)||(e==null?void 0:e.selectedColor)||((t=e==null?void 0:e.variant)==null?void 0:t.color)||""},Aa=e=>{var t;return(e==null?void 0:e.size)||(e==null?void 0:e.selectedSize)||((t=e==null?void 0:e.variant)==null?void 0:t.size)||""},vn=20,$a=({open:e,onClose:t,product:r,index:o,addressListProp:s,addressLoading:a})=>{console.log(r,"the product for ai shopping");const i=null,c=null,l=Rt(r),p=Math.min(Math.max(0,o||0),Math.max(0,l.length-1)),h=l.length,[y,w]=x.useState(p),[k,N]=x.useState(null),[_,S]=x.useState(null),I=x.useRef(null),B=x.useRef(null),g=Ea(r,y),[H,Ee]=x.useState(""),[P,U]=x.useState(!1),[ge,oe]=x.useState(!1),[Q,Ce]=x.useState(!1),[Te,me]=x.useState(""),[D,E]=x.useState(!1),[R,Ke]=x.useState(null),[Be,ye]=x.useState([]),[ke,ct]=x.useState([]),[We,z]=x.useState([]),[ie,_e]=x.useState(!1),[Se,Qt]=x.useState(),[Gt,f]=x.useState(!0),[O,A]=x.useState(!1),[V,L]=x.useState(!1),[T,le]=x.useState("standard"),[M,$]=x.useState(!1),[G,re]=x.useState(!1),[we,be]=x.useState("card"),[X,J]=x.useState(!1),[ve,Z]=x.useState(!1),[j,Y]=x.useState(!1),[K,ce]=x.useState(null),[je,Qe]=x.useState(null),[dt,Pt]=x.useState(""),[Le,Et]=x.useState(!1),ut=x.useRef(null);x.useEffect(()=>{const d=Rt(r),m=Math.min(Math.max(0,o||0),Math.max(0,d.length-1));w(m);const u=Xn(r),v=Me(u),F=Ve(u);I.current=v||null,B.current=F||null,N(v||null),S(F||null)},[o,r]),x.useEffect(()=>{ut.current&&(ut.current.scrollTop=ut.current.scrollHeight)},[Be,ie,O,V,M,G,X,ve,j,P,ge]);const C="var(--tanya)",Oe="var(--tanya-contrast)",Ge=C,wt="#804c9e",Zn=()=>{console.log("AgenticShopping feedback:",{rating:je,comment:dt}),Et(!0)},eo=()=>{Qe(null),Pt(""),Et(!0)},Pr=d=>{const u=((d==null?void 0:d.intentMandateId)||(d==null?void 0:d.intent_mandate_id)||(d==null?void 0:d.id)||null)??K;return e?n.jsxs("div",{className:"mt-3 flex items-start gap-3 rounded-lg border border-green-200 bg-green-50 p-4 text-green-800",children:[n.jsx("div",{className:"success-tick-animation",children:n.jsx(te,{icon:"mdi:check-circle",width:"28",color:"#16a34a"})}),n.jsxs("div",{className:"text-sm w-full",children:[n.jsx("div",{className:"font-semibold",children:"Success!"}),n.jsx("div",{children:"Your smart order has been saved. I’ll watch the price and auto-purchase when the conditions are met."}),u&&n.jsxs("div",{className:"mt-2 text-xs font-medium",children:["Your Smart Order ID: ",n.jsx("span",{className:"font-semibold text-blue-600 cursor-pointer underline",children:u})]}),!Le&&n.jsxs("div",{className:"mt-4 rounded-lg bg-white/70 p-3 text-gray-900",children:[n.jsx("h4",{className:"font-semibold mb-1",children:"Please post your feedback here"}),n.jsx("p",{className:"text-sm text-gray-700 mb-3",children:"Rate us on how much our response was helpful"}),n.jsx("div",{className:"flex items-center gap-1 mb-3",children:[1,2,3,4,5].map(v=>n.jsx("button",{type:"button",onClick:()=>Qe(v),className:"p-0.5",children:n.jsx(te,{icon:je&&je>=v?"mdi:star":"mdi:star-outline",width:"20",className:"text-yellow-500"})},v))}),n.jsx("label",{className:"block text-sm text-gray-700 mb-1",children:"Tell us more about the response"}),n.jsx("textarea",{value:dt,onChange:v=>Pt(v.target.value),rows:3,className:"mt-1 w-full rounded-md border border-gray-300 p-2 text-sm outline-none focus:ring-1 focus:ring-gray-300",placeholder:"Your feedback helps us improve..."}),n.jsxs("div",{className:"mt-3 flex justify-end gap-2",children:[n.jsx("button",{type:"button",onClick:eo,className:"px-4 py-2 rounded-full border text-sm font-medium hover:bg-gray-50",children:"Cancel"}),n.jsx("button",{type:"button",onClick:Zn,className:"px-4 py-2 rounded-full text-sm font-semibold text-white shadow",style:{background:C},disabled:!je&&!dt.trim(),children:"Submit"})]})]}),Le&&n.jsx("div",{className:"mt-3 text-xs text-green-900 font-medium",children:"Thanks for your feedback! 💚"})]})]}):null},to=async()=>{try{z(s)}catch(d){console.error("Error fetching addresses:",d)}},bt=(d,m)=>{ye(u=>[...u,{query:"",response:"__SNAPSHOT__",snapshotStage:d,snapshotPayload:m}])},Er=(d,m)=>{ye(u=>u.map(v=>v.response==="__CARD__"?{...v,response:"__SNAPSHOT__",snapshotStage:d??v.snapshotStage,snapshotPayload:m??v.snapshotPayload}:v))},ro=()=>{ye(d=>d.filter(m=>!(m.query===""&&m.response!=="__SNAPSHOT__"&&m.response!=="__TEXT__")))},Tt=()=>{Z(!1),_e(!1),L(!1),re(!1),A(!1),$(!1),J(!1),Y(!1),E(!1),Ke(null),ro(),U(!1),oe(!1)},no=()=>{_e(!1),A(!1),L(!1),le("standard"),$(!1),re(!1),be("card"),J(!1),Z(!1),Y(!1),f(!0),Ke(null),localStorage.removeItem("agentic_order"),localStorage.removeItem("agentic_order_address"),localStorage.removeItem("agentic_order_delivery"),localStorage.removeItem("agentic_order_payment"),localStorage.removeItem("agentic_order_final")},Ne=x.useMemo(()=>Rt(r).map((m,u)=>({index:u,variant:m,images:((m==null?void 0:m.images)||[]).map(v=>(v==null?void 0:v.url)||"").filter(Boolean)})),[r]),vt=x.useMemo(()=>{if(!Ne.length)return!1;const d=k||void 0,m=_||void 0,u=(v,F)=>{var q;const b=et(Ne,v||void 0,F||void 0);return!!(b&&((q=b.variant)!=null&&q.sku))};return d&&m?u(d,m):d&&!m?u(d,null):!d&&m?u(void 0,m):!!(g&&g.sku)},[Ne,k,_,g]),oo=Q||D||!vt,jt=d=>{const m=Number((d==null?void 0:d.quantity)??1);return Number.isFinite(m)&&m>0?m:1},Tr=d=>{const m=jt(d),u=Number((d==null?void 0:d.max_price_minor)??0);return Number.isFinite(u)&&u>0?+(u/100):+(wn(r,g)*m)},Or=d=>{var W;const m=R,u=Bt(g),v=d||(m==null?void 0:m.currency)||u.currency||qe,F=Tr(m),b=+(F*.08).toFixed(2),q=((W=tt[T])==null?void 0:W.fee)||0;return{product_total:F,tax:b,shipping_fee:q,currency:v}},Xt=async(d,m,u)=>{Er(),no(),Ce(!0),E(!0),U(!1),oe(!1);const v=ke.slice(-vn);try{const F=await ir(i,c);if(!F)throw new Error("Failed to fetch token");const b=localStorage.getItem("customerNumber"),q=localStorage.getItem("isLoggedIn"),de=`https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({registered:String(q||!1),userId:String(b||new Date().getTime())}).toString()}`,ee=await fetch(`${de}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${F}`},body:JSON.stringify({flowId:"MTMI0P4LC6",flowAliasId:"BCUA138F2Q",input:{instruction:`Use SKU ${m}. Currency is USD. ${d}`,metadata:{productId:(r==null?void 0:r.id)??null,skuId:m??null,variantIndex:u},context:v}})});if(!ee.body)throw new Error("Readable stream not supported");const xe=ee.body.getReader(),ne=new TextDecoder;let Ie="",Fe="",Ae="";for(;;){const{done:he,value:Ue}=await xe.read();if(he)break;Ie+=ne.decode(Ue,{stream:!0});const ft=Ie.split(`
|
|
17
17
|
`);Ie=ft.pop()||"";for(const mt of ft){if(!mt.startsWith("data:"))continue;const Xe=mt.slice(5).trim();try{const ze=JSON.parse(Xe),$e=ze.index,ue=ze.data;$e===0?Fe=String(ue??""):$e===1&&(Ae=String(ue??""))}catch(ze){console.error("Error parsing JSON chunk:",ze)}}}let se=null;if(Fe){const he=String(Fe).replace(/\\n/g,"").trim();if(he.startsWith("{")&&he.endsWith("}"))try{se=JSON.parse(he),se.product_id=m,se.sku_id=m,localStorage.setItem("agentic_order",JSON.stringify(se))}catch(Ue){console.log(Ue)}}Ke(se),se&&ye(he=>[...he,{query:"",response:"__CARD__",snapshotPayload:{extractedDetails:se}}]),ct(he=>[...he,{userQuery:d,mainResponse:Fe||"",keywords:Ae||""}].slice(-vn))}catch(F){console.error("Error sending message to Tanya:",F),E(!1)}finally{Ce(!1)}},Ar=async d=>{if(D||Q||!vt)return;const m=Te.trim();if(!m)return;ye(b=>[...b,{query:m,response:""}]),me(""),Ee(m);const u=g==null?void 0:g.sku,v=bn(r),F=u||v||"";if(h<=1){if(F){Xt(m,F,y);return}oe(!0),E(!0);return}F?(U(!0),E(!0)):(oe(!0),E(!0))},so=()=>{const d=g==null?void 0:g.sku;d&&Xt(H,d,y)},ao=()=>{U(!1),oe(!0),E(!0)},io=()=>{if(!g||!g.sku)return;const d=g.sku;Xt(H,d,y)},lo=async()=>{_e(!0),L(!1),re(!1),Z(!1),A(!1),$(!1),J(!1),Y(!1),await to(),Er("initial",{extractedDetails:R??void 0})},co=()=>{if(!Se)return;const d=We.find(m=>String(m.addressId??m.id)===Se)||null;d&&(localStorage.setItem("agentic_order_address",JSON.stringify(d)),A(!0),L(!0),$(!1),re(!1),J(!1),Z(!1),Y(!1),bt("address",d))},uo=()=>{A(!1),L(!1),$(!1),re(!1),J(!1),Z(!1),Y(!1),localStorage.removeItem("agentic_order_address")},fo=()=>{T&&(localStorage.setItem("agentic_order_delivery",T),$(!0),re(!0),J(!1),Z(!1),Y(!1),bt("delivery",{method:T,...tt[T]}))},$r=()=>{L(!1),$(!1),re(!1),J(!1),Z(!1),Y(!1),E(!1),Tt(),ye(d=>[...d,{query:"",response:"__TEXT__",snapshotPayload:{text:"No worries! I’ve cancelled this request. You can start again anytime — just tell me what you’d like to buy or track"}}])},mo=()=>{$(!1),re(!1),J(!1),Z(!1),Y(!1),localStorage.removeItem("agentic_order_delivery")},ho=()=>{we&&(localStorage.setItem("agentic_order_payment",we),J(!0),Z(!0),Y(!1),bt("payment",{method:we}))},po=()=>{re(!1),J(!1),Z(!1),Y(!1),E(!1),Tt(),ye(d=>[...d,{query:"",response:"__TEXT__",snapshotPayload:{text:"No worries! I’ve cancelled this request. You can start again anytime — just tell me what you’d like to buy or track"}}])},go=()=>{J(!1),Z(!1),Y(!1),localStorage.removeItem("agentic_order_payment")},xo=async()=>{try{Ce(!0);const d=R||{},m=JSON.parse(localStorage.getItem("agentic_order_address")||"null"),u=localStorage.getItem("agentic_order_delivery"),v=localStorage.getItem("agentic_order_payment")||"card",{product_total:F,tax:b,shipping_fee:q,currency:W}=Or(),de=d.shopper_id||localStorage.getItem("customerId")||void 0,ee=(m==null?void 0:m.addressId)||(m==null?void 0:m.id)||void 0,xe=u?Pa[u]:"GROUND",ne="card-visa",Ie=g==null?void 0:g.sku,Fe=(r==null?void 0:r.id)||"",Ae=jt(d),se=typeof d.max_price_minor=="number"?d.max_price_minor:Math.round(F*100),ft={shopper_id:de,shipping_address_id:ee,shipping_method_id:xe,payment_method_id:ne,sku:Ie,platform:"SFCC",storeCode:"Sites-SiteGenesis-Site",product_id:Fe,quantity:Ae,max_price_minor:se,currency:W,instruction_text:H};if(!de||!ee){console.error("Missing shopper_id or shipping_address_id for intent-mandate",{shopperId:de,shippingAddressId:ee}),alert("Missing customer or address information. Please re-select address and try again."),Ce(!1);return}const Xe=(await yt()).access_token;if(!Xe)throw new Error("Failed to fetch auth token for intent-mandate");const{serverUrl:ze}=st(),$e=await fetch(`${ze}/api/intent-mandate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Xe}`},body:JSON.stringify(ft)});if(!$e.ok){const ko=await $e.text().catch(()=>"");console.error("intent-mandate failed",$e.status,ko),alert("Something went wrong while saving your smart order. Please try again."),Ce(!1);return}const ue=await $e.json().catch(()=>null);console.log("intent-mandate success:",ue);const Ze=(ue==null?void 0:ue.intent_mandate_id)||(ue==null?void 0:ue.intent_mandateId)||(ue==null?void 0:ue.key)||null;Ze&&ce(Ze);const Ot={...d,address:m,delivery:u,payment:v,summary:{product_total:F,tax:b,shipping_fee:q,currency:W},intent_mandate_id:Ze};localStorage.setItem("agentic_order_final",JSON.stringify(Ot)),Y(!0),f(!1),bt("final",Ot),bt("success",{intentMandateId:Ze}),Tt()}catch(d){console.error("Error in handleConfirmWatch / intent-mandate:",d),alert("Unable to complete your smart order right now. Please try again in a moment.")}finally{Ce(!1)}},Dr=()=>{Tt(),ye(d=>[...d,{query:"",response:"__TEXT__",snapshotPayload:{text:"No worries! I’ve cancelled this request. You can start again anytime — just tell me what you’d like to buy or track"}}])},yo=()=>{const d=xn(r,g),m=yn(r),u=(g==null?void 0:g.sku)||"",v=Me(g)||"",F=Ve(g)||"",{amount:b}=Bt(g),q=!!(g!=null&&g.sku),W=g&&q?pn(g):!1;return n.jsx("div",{className:"mx-4 mt-2 rounded-xl border border-gray-200 bg-white p-4",children:n.jsxs("div",{className:"flex flex-col sm:flex-row items-center sm:items-center gap-4",children:[n.jsx("div",{className:"flex-shrink-0 flex justify-center sm:justify-start",children:n.jsx("div",{className:"w-[150px] h-[150px] rounded-lg bg-gray-50 border border-gray-200 flex items-center justify-center overflow-hidden",children:d?n.jsx("img",{src:d,alt:m,className:"object-contain w-full h-full"}):n.jsx(te,{icon:"mdi:image-outline",width:"28",className:"opacity-60"})})}),n.jsxs("div",{className:"flex-grow flex flex-col justify-center text-center",children:[n.jsx("div",{className:"text-2xl font-bold text-gray-900 mb-1",children:m}),n.jsx("div",{className:"text-sm text-gray-700 mb-1",children:[u&&`SKU: ${u}`,v&&`Color: ${v}`,F&&`Size: ${F}`].filter(Boolean).join(" • ")||"—"}),n.jsx("div",{className:"mt-1 text-xl font-semibold text-gray-900",children:q?Pe(Number(b)||0,qe):"Currently unavailable"}),q&&!W&&n.jsx("div",{className:"mt-1 text-xs font-medium text-red-600",children:"Currently out of stock"})]})]})})},Lr=({showSubmit:d=!0})=>{const m={},u=Ne.map(b=>Me(b.variant)).filter(b=>!!b&&!m[b]&&(m[b]=!0)),v={},F=Ne.map(b=>Ve(b.variant)).filter(b=>!!b&&!v[b]&&(v[b]=!0));return n.jsxs("div",{className:"mx-4 mt-4 mb-2 rounded-xl border border-gray-200 bg-white p-4 animate-fade-in",children:[n.jsx("h3",{className:"font-semibold text-gray-800",children:"Choose a variant"}),u.length>0&&n.jsxs("div",{className:"mt-4",children:[n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx("div",{className:"text-sm font-bold",children:"Color :"}),k&&n.jsx("div",{className:"text-sm text-gray-600",children:k})]}),n.jsx("div",{className:"flex flex-wrap gap-4 mt-2",children:u.map(b=>{var Ae;const q=k===b,W=_||B.current||null,de=W?et(Ne,b,W):et(Ne,b,null),ee=!!de,xe=ee&&pn(de.variant),ne=ee&&xe?xr(de.variant,qe)||xr(de.variant):null,Ie=Ne.find(se=>Me(se.variant)===b),Fe=(Ae=Ie==null?void 0:Ie.images)==null?void 0:Ae[0];return n.jsxs("div",{className:`flex flex-col items-center w-28 border rounded-md p-2
|
|
18
18
|
${q?"border-2 border-tanya-light":"border-gray-300"}
|
|
19
|
-
${!ee||!xe?"opacity-60":""}`,children:[n.jsx("button",{onClick:()=>{N(b);const se=_||B.current||null,he=se&&et(Ne,b,se)||et(Ne,b,null);he&&w(he.index)},className:"w-full h-20 flex items-center justify-center overflow-hidden",title:b,children:Fe?n.jsx("img",{src:Fe,alt:b,className:"w/full h-full object-contain"}):n.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs px-1",children:b})}),n.jsx("div",{className:"w-full border-t my-2"}),ee&&!xe&&n.jsx("div",{className:"text-[11px] text-red-600 text-center",children:"Out of stock"}),!ee&&n.jsx("div",{className:"text-[11px] text-red-600 text-center",children:"any not offered"}),ee&&xe&&ne&&n.jsxs("div",{className:"text-xs text-gray-800 font-medium text-center",children:[Pe(ne.cent/100,ne.cur),ne.regularCent&&ne.regularCent>ne.cent&&n.jsx("span",{className:"ml-1 line-through text-gray-500",children:Pe(ne.regularCent/100,ne.cur)})]})]},`color-${b}`)})})]}),F.length>0&&n.jsxs("div",{className:"mt-4",children:[n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx("div",{className:"text-sm font-bold",children:"Size :"}),_&&n.jsx("div",{className:"text-sm text-gray-600",children:_})]}),n.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:F.map(b=>{const q=_===b;return n.jsx("button",{onClick:()=>{S(b);const W=k&&et(Ne,k,b)||et(Ne,void 0,b);W&&w(W.index)},className:`px-4 py-2 rounded-md border text-sm ${q?"border-2 border-tanya-light font-semibold":"border-gray-300"}`,title:b,children:b},`size-${b}`)})})]}),d&&n.jsx("div",{className:"mt-4 flex justify-end",children:n.jsx("button",{onClick:io,className:"px-6 py-2.5 rounded-full font-semibold text-white shadow-md",style:{background:C},disabled:!vt,children:"Submit"})})]})},zr=(d,m=!0)=>{!(d!=null&&d.extractedDetails)&&d&&(d={extractedDetails:d});const u=(d==null?void 0:d.extractedDetails)||R;if(!u)return null;const v=jt(u),{currency:F}=Bt(g),b=wn(r,g),q=Number((u==null?void 0:u.max_price_minor)??0),de=Number.isFinite(q)&&q>0?+(q/100):+(b*v),ee=(u==null?void 0:u.currency)||F||qe,xe=g!=null&&g.sku?g.sku:u.product_id;return n.jsxs("div",{className:"px-6 pb-6 flex flex-col items-center space-y-4",style:{backgroundColor:"var(--tanya-light)"},children:[n.jsx("p",{className:"text-base font-semibold text-center mt-2",style:{color:Oe},children:"Here’s what I found from your instruction:"}),n.jsxs("div",{className:"w-full max-w-md bg-white rounded-xl shadow-inner p-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-y-2 text-sm",children:[n.jsx("p",{className:"font-semibold text-gray-600",children:"SKU:"}),n.jsx("p",{className:"text-gray-800",children:xe}),n.jsx("p",{className:"font-semibold text-gray-600",children:"Quantity:"}),n.jsx("p",{className:"text-gray-800",children:jt(u)}),n.jsx("p",{className:"font-semibold text-gray-600",children:"Currency:"}),n.jsx("p",{className:"text-gray-800",children:ee}),n.jsx("p",{className:"font-semibold text-gray-600",children:"Maximum Total Price:"}),n.jsx("p",{className:"text-gray-800",children:Pe(de,ee)})]}),n.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs",children:[Me(g)&&n.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-1",children:["Color: ",Me(g)]}),Ve(g)&&n.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-1",children:["Size: ",Ve(g)]}),(g==null?void 0:g.sku)&&n.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-1",children:["SKU: ",g.sku]})]})]}),!m&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"text-sm font-medium text-gray-700 text-center max-w-[90%] leading-relaxed",style:{color:Oe},children:["Would you like me to ",n.jsx("strong",{children:"lock this in"})," and monitor it for you?"]}),n.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[n.jsxs("button",{onClick:lo,disabled:ie,className:`relative inline-flex items-center justify-center px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${ie?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:`${C}`},children:[n.jsx(te,{icon:"fluent:checkmark-circle-24-filled",className:"mr-2",width:"18",height:"18"}),"Yes, lock it in"]}),n.jsxs("button",{onClick:Dr,disabled:ie,className:`relative inline-flex items-center justify-center px-6 py-2.5 rounded-full font-semibold border transition-all duration-300 ${ie?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{borderColor:C,color:Oe},children:[n.jsx(te,{icon:"fluent:dismiss-circle-24-filled",className:"mr-2",width:"18",height:"18"}),"No"]})]})]})]})},Mr=(d,m=!0)=>{var mt,Xe,ze,$e,ue,Ze;const u=d||{},v=((mt=u==null?void 0:u.summary)==null?void 0:mt.currency)||(R==null?void 0:R.currency)||qe,F=xn(r,g),b=yn(r),q=g!=null&&g.sku?g.sku:(r==null?void 0:r.id)??(R==null?void 0:R.product_id),W=(g==null?void 0:g.sku)??bn(r),de=Me(g)||Oa(r),ee=Ve(g)||Aa(r),xe=jt(u),ne=((Xe=u==null?void 0:u.summary)==null?void 0:Xe.product_total)!=null?+u.summary.product_total:Tr(u),Ie=xe>0?+(ne/xe).toFixed(2):0,Fe=ne,Ae=((ze=u==null?void 0:u.summary)==null?void 0:ze.tax)??+(ne*.08).toFixed(2),se=(($e=u==null?void 0:u.summary)==null?void 0:$e.shipping_fee)??(((ue=tt[T])==null?void 0:ue.fee)||0),he=u!=null&&u.address?[u.address.addressLine1,u.address.addressLine2,u.address.street,[u.address.city,u.address.state,u.address.postalCode].filter(Boolean).join(", "),u.address.country].filter(Boolean).map(Ot=>He(String(Ot))).join(", "):"—",Ue=(u==null?void 0:u.payment)||"card",ft=Ue==="card"?n.jsxs(n.Fragment,{children:["Credit Card — Mastercard",n.jsx("br",{}),"•••• 7820 Exp: 12/26"]}):n.jsx(n.Fragment,{children:He(Ue)});return n.jsxs("div",{className:"mx-auto mt-3 mb-3 rounded-2xl bg-white",children:[n.jsx("div",{className:"px-6 pt-5 pb-3",children:n.jsxs("h3",{className:"font-semibold text-lg mb-2 text-gray-800 flex items-center gap-2",children:[n.jsx(te,{icon:"mdi:receipt-text-check-outline",width:"24",color:C}),"All set! Here’s what your smart order looks like 🧾"]})}),n.jsx("div",{className:"px-6 pb-4",children:n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-12 gap-4 rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"sm:col-span-2 flex",children:n.jsx("div",{className:"w-30 h-26 sm:w-30 sm:h-26 overflow-hidden rounded-lg bg-white border border-gray-200 flex items-center justify-center mx-auto sm:mx-0",children:F?n.jsx("img",{src:F,alt:b,className:"w-full h-full object-contain"}):n.jsx(te,{icon:"mdi:image-outline",width:"24",className:"opacity-50"})})}),n.jsxs("div",{className:"sm:col-span-10",children:[n.jsxs("div",{className:"mb-3",children:[n.jsx("div",{className:"text-lg text-center font-bold text-gray-900",children:b}),n.jsxs("div",{className:"text-xs text-center font-bold text-gray-600",children:[n.jsx("span",{className:"font-medium",children:"SKU:"})," ",q??"—"]}),(W||de||ee)&&n.jsxs("div",{className:"text-xs text-gray-600 mt-0.5 text-center",children:[W&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",children:"SKU:"})," ",W," "]}),de&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",children:"Color:"})," ",de," "]}),ee&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",children:"Size:"})," ",ee]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md-grid-cols-3 md:grid-cols-3 gap-3",children:[n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center",children:[n.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Unit Price"}),n.jsx("div",{className:"mt-0.5 text-base font-bold text-gray-900",children:Pe(Ie,v)})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center",children:[n.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Quantity"}),n.jsx("div",{className:"mt-0.5 text-base font-bold text-gray-900",children:xe})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center",children:[n.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Subtotal"}),n.jsx("div",{className:"mt-0.5 text-base font-bold text-gray-900",children:Pe(Fe,v)})]})]})]})]})}),n.jsxs("div",{className:"px-6 pb-2",children:[n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 mb-3",children:[n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🏠 Address"}),n.jsx("div",{className:"mt-1 text-sm font-semibold text-gray-900 text-center",children:he})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"💳 Payment"}),n.jsx("div",{className:"mt-1 text-sm font-semibold text-gray-900 text-center",children:ft})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🚚 Delivery"}),n.jsx("div",{className:"mt-1 text-sm font-semibold text-gray-900 text-center",children:u!=null&&u.delivery&&((Ze=tt[u.delivery])==null?void 0:Ze.label)||"—"})]})]}),n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[n.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-gray-200 bg-gray-50 p-4 text-center",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"💰 any(s)"}),n.jsx("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:Pe(ne,v)})]}),n.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-gray-200 bg-gray-50 p-4 text-center",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🏛️ Taxes"}),n.jsx("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:Pe(Ae,v)})]}),n.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-gray-200 bg-gray-50 p-4 text-center",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🚚 Shipping"}),n.jsx("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:Pe(se,v)})]})]}),n.jsxs("div",{className:"mt-4 rounded-xl p-4 text-center text-white shadow-sm",style:{background:Ge},children:[n.jsx("div",{className:"text-sm/5 opacity-95",children:"🔹 Total Payable"}),n.jsx("div",{className:"mt-1 text-3xl font-extrabold tracking-tight",children:Pe(ne+Ae+se,v)})]})]}),!m&&n.jsxs("div",{className:"px-6 pb-5",children:[!j&&n.jsx("p",{className:"mt-3 text-center text-sm text-gray-700",children:"Everything looks good! Do you want me to watch this product and buy it automatically when it meets your condition?"}),j&&Pr({intentMandateId:K}),Gt&&!j&&n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-3",children:[n.jsx("button",{onClick:xo,className:"inline-flex items-center justify-center rounded-full px-6 py-2.5 font-semibold text-white shadow-md transition-transform duration-150 hover:-translate-y-0.5 hover:shadow-lg",style:{background:Ge},children:"Confirm"}),n.jsx("button",{onClick:Dr,className:"inline-flex items-center justify-center rounded-full border px-6 py-2.5 font-semibold hover:bg-gray-50",style:{borderColor:Ge,color:Ge},children:"Cancel"})]})]})]})},wo=d=>{if(!d)return null;const m=[d.addressLine1,d.addressLine2,d.street,[d.city,d.state,d.postalCode].filter(Boolean).join(", "),d.country].filter(u=>!!u).map(u=>He(u)).join(", ");return n.jsx("div",{className:"px-6 py-4",style:{backgroundColor:"var(--tanya-light)"},children:n.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx(te,{icon:"mdi:home-map-marker",width:"20",color:C}),n.jsx("div",{className:"font-semibold text-gray-800",children:"Delivery Address"})]}),n.jsx("div",{className:"text-sm text-gray-800",children:m})]})})},bo=d=>{const m=d==null?void 0:d.method,u=m?tt[m]:void 0;return n.jsx("div",{className:"px-6 py-4",style:{backgroundColor:"var(--tanya-light)"},children:n.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx(te,{icon:"mdi:truck-delivery",width:"20",color:C}),n.jsx("div",{className:"font-semibold text-gray-800",children:"Delivery Method"})]}),n.jsx("div",{className:"text-sm text-gray-800",children:u?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(te,{icon:u.icon,width:"18"}),n.jsx("span",{className:"font-medium",children:u.label})]}),n.jsx("div",{className:"text-gray-600",children:u.subtitle})]}):"—"})]})})},vo=d=>{const m=(d==null?void 0:d.method)||"card";return n.jsx("div",{className:"px-6 py-4",style:{backgroundColor:"var(--tanya-light)"},children:n.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx(te,{icon:"mdi:credit-card-outline",width:"20",color:C}),n.jsx("div",{className:"font-semibold text-gray-800",children:"Payment Method"})]}),n.jsx("div",{className:"text-sm text-gray-800",children:m==="card"?n.jsxs(n.Fragment,{children:["Credit Card — Mastercard",n.jsx("br",{}),"•••• 7820 Exp: 12/26"]}):He(m)})]})})},jo=(d,m)=>{const u=d.snapshotStage;if(!u||u==="address"&&ie||u==="delivery"&&V||u==="payment"&&G||u==="final"&&ve)return null;switch(u){case"initial":return zr(d.snapshotPayload,!m);case"address":return wo(d.snapshotPayload);case"delivery":return bo(d.snapshotPayload);case"payment":return vo(d.snapshotPayload);case"final":return Mr(d.snapshotPayload,!m);case"success":return Pr(d.snapshotPayload);default:return null}};return Co.createPortal(n.jsxs("div",{className:"fixed inset-0",style:{zIndex:2147483647},"aria-modal":"true",role:"dialog",children:[n.jsx("div",{className:"absolute inset-0",style:{background:"rgba(0,0,0,0.25)"},onClick:t}),n.jsx("div",{className:"absolute right-0 ",children:n.jsxs("div",{className:"w-[64.7vw] h-screen bg-white rounded-xl overflow-hidden flex flex-col shadow-xl",children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",borderTopLeftRadius:"0.75rem",borderBottomLeftRadius:"0.75rem",padding:"0.25rem",background:wt},children:[n.jsxs("div",{style:{display:"flex",color:"#ffffff",alignItems:"center",gap:"0.5rem"},children:[n.jsx(te,{icon:"ph:sparkle-duotone",width:"25",height:"25"}),n.jsx("div",{children:n.jsx("p",{className:"font-bold",children:"Agentic Shopping with TANYA"})})]}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:"1.25rem",margin:"0.75rem"},children:n.jsx(te,{icon:"fluent:dismiss-24-filled",color:"#ffffff",width:"24",height:"24",className:"cursor-pointer",onClick:t})})]}),n.jsxs("div",{ref:ut,className:"overflow-y-auto pr-5 pb-4 space-y-4 hide-scrollbar flex-grow",children:[n.jsxs("div",{className:"text-sm text-[16px] rounded-r-xl p-3 m-3 rounded-bl-xl w-3/4 text-tanya-contrast",style:{backgroundColor:"var(--tanya-light)"},children:["Welcome to your smart shopping companion!",n.jsx("p",{children:"Simply share your instruction — like “If this product goes below $100, grab it for me.”"}),n.jsx("p",{children:"I’ll monitor it, calculate total prices, and place the order when your conditions are met."})]}),n.jsx(yo,{}),h>1&&n.jsx(Lr,{showSubmit:!1}),Be.map((d,m)=>{var F;const u=m===Be.length-1,v=!!d.snapshotStage;return n.jsxs("div",{children:[d.query&&n.jsx("div",{className:"flex justify-end",children:n.jsx("p",{className:"text-sm rounded-l-xl p-3 m-3 mb-4 rounded-br-xl max-w-[75%]",style:{color:"#ffffff",backgroundColor:"var(--tanya)"},children:d.query})}),d.response==="__TEXT__"&&((F=d.snapshotPayload)==null?void 0:F.text)&&n.jsx("div",{className:"mt-2",children:n.jsx("div",{className:"text-sm text-tanya-contrast px-7 py-4 rounded-r-xl rounded-bl-2xl w-full",style:{backgroundColor:"var(--tanya-light)",margin:"0.75rem"},children:n.jsx("div",{className:"flex items-center gap-2",children:n.jsx("p",{children:d.snapshotPayload.text})})})}),u&&P&&h>1&&n.jsxs("div",{className:"mx-4 mt-2 rounded-xl border border-gray-200 bg-white p-4 animate-fade-in",children:[n.jsxs("div",{className:"text-sm text-gray-800",children:["Proceed with color:"," ",n.jsx("span",{className:"font-semibold",children:Me(g)||"—"}),", size:"," ",n.jsx("span",{className:"font-semibold",children:Ve(g)||"—"}),"?"]}),n.jsxs("div",{className:"mt-3 flex gap-3",children:[n.jsx("button",{onClick:so,className:"px-5 py-2 rounded-full text-white font-semibold",style:{background:C},children:"Yes"}),n.jsx("button",{onClick:ao,className:"px-5 py-2 rounded-full font-semibold border",style:{borderColor:C,color:C},children:"No, change SKU"})]})]}),u&&ge&&n.jsx(Lr,{showSubmit:!0}),u&&Q&&n.jsx("div",{className:"mt-4",children:n.jsx("div",{className:"text-sm text-tanya-contrast px-7 py-4 rounded-r-xl rounded-bl-2xl w-full",style:{backgroundColor:"var(--tanya-light)",margin:"0.75rem"},children:n.jsx("div",{className:"flex items-center gap-2 tanya-pulse-text",children:n.jsx("p",{children:"Reading your instruction and setting things up…"})})})}),(v||d.response==="__CARD__")&&(!Q||!u)&&n.jsx("div",{className:"mt-6 mb-4 mx-4 animate-fade-in",style:{backgroundColor:"#fff",borderRadius:"1rem",boxShadow:"0 2px 8px rgba(0,0,0,0.08)",overflow:"hidden"},children:v?jo(d,u):zr(d.snapshotPayload,!1)})]},m)}),ie&&n.jsxs("div",{className:"mt-6 mb-6 mx-6 rounded-xl p-6 shadow-md border border-gray-200 bg-white animate-fade-in",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("h3",{className:"font-semibold text-lg text-gray-800 flex items-center gap-2",children:[n.jsx(te,{icon:"mdi:home-map-marker",width:"24",color:"var(--tanya-light)"}),"Select a Delivery Address"]}),O&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ml-2 text-xs px-2 py-1 rounded-full bg-green-100 text-green-700 font-semibold",children:"Selected"}),!j&&n.jsx("button",{onClick:uo,className:"ml-2 text-xs px-2 py-1 rounded-full border hover:bg-gray-50",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},title:"Change address",children:"Change"})]})]}),n.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Choose where you’d like us to deliver this item."}),a?n.jsxs("div",{className:"flex items-center py-6",children:[n.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2",style:{borderBottomColor:"var(--tanya-light)"}}),n.jsx("p",{className:"ml-3 text-gray-600",children:"Fetching your addresses..."})]}):We.length>0?n.jsxs("div",{className:`space-y-3 ${O?"opacity-70":""}`,children:[We.map(d=>{const m=[d.addressLine1,d.addressLine2].filter(Boolean).map(W=>He(W||"")).join(" "),u=He(d.city||""),v=`${He(d.state||"")}${d.state&&d.postalCode?", ":""}${d.postalCode||""}`,F=He(d.country||""),b=String(d.addressId??d.id),q=Se===b;return n.jsxs("label",{className:`flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${q?"border-tanya-light":"border-gray-300"} ${O?"pointer-events-none":""}`,title:O?"Address already submitted":"",children:[n.jsx("input",{type:"radio",name:"address",className:"mt-1 accent-tanya-light",checked:q,disabled:O,onChange:()=>Qt(b),value:b}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"font-semibold text-gray-800",children:m||"Address"}),n.jsxs("div",{className:"text-sm text-gray-700",children:[u,n.jsx("br",{}),v,n.jsx("br",{}),F]})]})]},b)}),n.jsxs("div",{className:"flex justify-between pt-2",children:[n.jsx("button",{onClick:$r,className:"px-6 py-2.5 rounded-full font-semibold border transition-all hover:-translate-y-0.5 hover:shadow-sm",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},children:"Cancel"}),n.jsx("button",{onClick:co,disabled:O,className:`px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${O?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:C},children:O?"Address Submitted":"Submit Address"})]})]}):n.jsx("div",{className:"text-center py-8 text-gray-600",children:"No addresses found. Please add a new one in your profile."})]}),V&&n.jsxs("div",{className:"mt-2 mb-6 mx-6 rounded-xl p-6 shadow-md border border-gray-200 bg-white animate-fade-in",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("h3",{className:"font-semibold text-lg text-gray-800 flex items-center gap-2",children:[n.jsx(te,{icon:"mdi:truck-delivery",width:"24",color:"var(--tanya-light)"}),"Great! Now choose how fast you want it delivered 🚚"]}),M&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ml-2 text-xs px-2 py-1 rounded-full bg-green-100 text-green-700 font-semibold",children:"Selected"}),!j&&n.jsx("button",{onClick:mo,className:"ml-2 text-xs px-2 py-1 rounded-full border hover:bg-gray-50",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},title:"Change shipping method",children:"Change"})]})]}),n.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Which one would you like me to use for this order?"}),n.jsx("div",{className:`space-y-3 ${M?"opacity-70":""}`,children:Object.keys(tt).map(d=>{const m=tt[d],u=T===d;return n.jsxs("label",{className:`flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${u?"border-tanya-light":"border-gray-300"} ${M?"pointer-events-none":""}`,title:M?"Delivery already submitted":"",children:[n.jsx("input",{type:"radio",name:"delivery",className:"mt-1 accent-tanya-light",checked:u,disabled:M,onChange:()=>le(d)}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"font-semibold text-gray-800 flex items-center gap-2",children:[n.jsx(te,{icon:m.icon,width:"18"})," ",m.label]}),n.jsx("div",{className:"text-sm text-gray-700",children:m.subtitle})]}),n.jsx("div",{className:"text-sm font-semibold text-gray-800",children:m.fee===0?"Free":Pe(m.fee,(R==null?void 0:R.currency)||qe)})]},d)})}),n.jsxs("div",{className:"flex justify-between pt-4",children:[n.jsx("button",{onClick:$r,className:"px-6 py-2.5 rounded-full font-semibold border transition-all hover:-translate-y-0.5 hover:shadow-sm",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},children:"Cancel"}),n.jsx("button",{onClick:fo,disabled:M,className:`px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${M?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:"var(--tanya)"},children:M?"Delivery Submitted":"Submit Delivery Option"})]})]}),G&&n.jsxs("div",{className:"mt-2 mb-6 mx-6 rounded-xl p-6 shadow-md border border-gray-200 bg-white animate-fade-in",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("h3",{className:"font-semibold text-lg text-gray-800 flex items-center gap-2",children:[n.jsx(te,{icon:"mdi:credit-card-outline",width:"24",color:"var(--tanya-light)"}),"Almost done! 💳"]}),X&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ml-2 text-xs px-2 py-1 rounded-full bg-green-100 text-green-700 font-semibold",children:"Selected"}),!j&&n.jsx("button",{onClick:go,className:"ml-2 text-xs px-2 py-1 rounded-full border hover:bg-gray-50",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},title:"Change payment method",children:"Change"})]})]}),n.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Please choose a payment method for this order:"}),n.jsx("div",{className:`space-y-3 ${X?"opacity-70":""}`,children:n.jsxs("label",{className:`flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${we==="card"?"border-tanya-light":"border-gray-300"} ${X?"pointer-events-none":""}`,title:X?"Payment already submitted":"",children:[n.jsx("input",{type:"radio",name:"payment",className:"mt-1 accent-tanya-light",checked:we==="card",disabled:X,onChange:()=>be("card")}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"font-semibold text-gray-800 flex items-center gap-2",children:[n.jsx(te,{icon:"mdi:credit-card-chip-outline",width:"18"})," ","Credit Card"]}),we==="card"&&n.jsxs("div",{className:"text-sm text-gray-700 mt-1",children:["Mastercard •••• 7820",n.jsx("br",{}),"Expiry: 12/26"]})]})]})}),n.jsxs("div",{className:"flex justify-between pt-4",children:[n.jsx("button",{onClick:po,className:"px-6 py-2.5 rounded-full font-semibold border transition-all hover:-translate-y-0.5 hover:shadow-sm",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},children:"Cancel"}),n.jsx("button",{onClick:ho,disabled:X,className:`px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${X?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:"var(--tanya)"},children:X?"Payment Submitted":"Submit Payment Method"})]})]}),ve&&Mr({...R,address:JSON.parse(localStorage.getItem("agentic_order_address")||"null"),delivery:localStorage.getItem("agentic_order_delivery"),payment:localStorage.getItem("agentic_order_payment"),summary:Or(R==null?void 0:R.currency)},!1)]}),n.jsxs("div",{className:"sticky bottom-0 w-[96%] drop-shadow-xl flex items-center rounded-full bg-white border border-gray-300 m-[15px]",children:[n.jsx("input",{placeholder:D?"Complete the current step…":vt?"What would you like me to do? (e.g., If this product goes below $100, grab it for me.)":"Oops! This combination isn’t available for this product. Try a different option.",disabled:oo,className:`w-full rounded-full p-4 outline-none border-none focus:ring-0 focus:border-transparent disabled:bg-gray-100 disabled:cursor-not-allowed
|
|
19
|
+
${!ee||!xe?"opacity-60":""}`,children:[n.jsx("button",{onClick:()=>{N(b);const se=_||B.current||null,he=se&&et(Ne,b,se)||et(Ne,b,null);he&&w(he.index)},className:"w-full h-20 flex items-center justify-center overflow-hidden",title:b,children:Fe?n.jsx("img",{src:Fe,alt:b,className:"w/full h-full object-contain"}):n.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs px-1",children:b})}),n.jsx("div",{className:"w-full border-t my-2"}),ee&&!xe&&n.jsx("div",{className:"text-[11px] text-red-600 text-center",children:"Out of stock"}),!ee&&n.jsx("div",{className:"text-[11px] text-red-600 text-center",children:"any not offered"}),ee&&xe&&ne&&n.jsxs("div",{className:"text-xs text-gray-800 font-medium text-center",children:[Pe(ne.cent/100,ne.cur),ne.regularCent&&ne.regularCent>ne.cent&&n.jsx("span",{className:"ml-1 line-through text-gray-500",children:Pe(ne.regularCent/100,ne.cur)})]})]},`color-${b}`)})})]}),F.length>0&&n.jsxs("div",{className:"mt-4",children:[n.jsxs("div",{className:"flex items-baseline gap-2",children:[n.jsx("div",{className:"text-sm font-bold",children:"Size :"}),_&&n.jsx("div",{className:"text-sm text-gray-600",children:_})]}),n.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:F.map(b=>{const q=_===b;return n.jsx("button",{onClick:()=>{S(b);const W=k&&et(Ne,k,b)||et(Ne,void 0,b);W&&w(W.index)},className:`px-4 py-2 rounded-md border text-sm ${q?"border-2 border-tanya-light font-semibold":"border-gray-300"}`,title:b,children:b},`size-${b}`)})})]}),d&&n.jsx("div",{className:"mt-4 flex justify-end",children:n.jsx("button",{onClick:io,className:"px-6 py-2.5 rounded-full font-semibold text-white shadow-md",style:{background:C},disabled:!vt,children:"Submit"})})]})},zr=(d,m=!0)=>{!(d!=null&&d.extractedDetails)&&d&&(d={extractedDetails:d});const u=(d==null?void 0:d.extractedDetails)||R;if(!u)return null;const v=jt(u),{currency:F}=Bt(g),b=wn(r,g),q=Number((u==null?void 0:u.max_price_minor)??0),de=Number.isFinite(q)&&q>0?+(q/100):+(b*v),ee=(u==null?void 0:u.currency)||F||qe,xe=g!=null&&g.sku?g.sku:u.product_id;return n.jsxs("div",{className:"px-6 pb-6 flex flex-col items-center space-y-4",style:{backgroundColor:"#14377D"},children:[n.jsx("p",{className:"text-base font-semibold text-center mt-2",style:{color:Oe},children:"Here’s what I found from your instruction:"}),n.jsxs("div",{className:"w-full max-w-md bg-white rounded-xl shadow-inner p-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-y-2 text-sm",children:[n.jsx("p",{className:"font-semibold text-gray-600",children:"SKU:"}),n.jsx("p",{className:"text-gray-800",children:xe}),n.jsx("p",{className:"font-semibold text-gray-600",children:"Quantity:"}),n.jsx("p",{className:"text-gray-800",children:jt(u)}),n.jsx("p",{className:"font-semibold text-gray-600",children:"Currency:"}),n.jsx("p",{className:"text-gray-800",children:ee}),n.jsx("p",{className:"font-semibold text-gray-600",children:"Maximum Total Price:"}),n.jsx("p",{className:"text-gray-800",children:Pe(de,ee)})]}),n.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 text-xs",children:[Me(g)&&n.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-1",children:["Color: ",Me(g)]}),Ve(g)&&n.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-1",children:["Size: ",Ve(g)]}),(g==null?void 0:g.sku)&&n.jsxs("span",{className:"rounded-full bg-gray-100 px-2 py-1",children:["SKU: ",g.sku]})]})]}),!m&&n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"text-sm font-medium text-gray-700 text-center max-w-[90%] leading-relaxed",style:{color:Oe},children:["Would you like me to ",n.jsx("strong",{children:"lock this in"})," and monitor it for you?"]}),n.jsxs("div",{className:"flex flex-wrap justify-center gap-4",children:[n.jsxs("button",{onClick:lo,disabled:ie,className:`relative inline-flex items-center justify-center px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${ie?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:`${C}`},children:[n.jsx(te,{icon:"fluent:checkmark-circle-24-filled",className:"mr-2",width:"18",height:"18"}),"Yes, lock it in"]}),n.jsxs("button",{onClick:Dr,disabled:ie,className:`relative inline-flex items-center justify-center px-6 py-2.5 rounded-full font-semibold border transition-all duration-300 ${ie?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{borderColor:C,color:Oe},children:[n.jsx(te,{icon:"fluent:dismiss-circle-24-filled",className:"mr-2",width:"18",height:"18"}),"No"]})]})]})]})},Mr=(d,m=!0)=>{var mt,Xe,ze,$e,ue,Ze;const u=d||{},v=((mt=u==null?void 0:u.summary)==null?void 0:mt.currency)||(R==null?void 0:R.currency)||qe,F=xn(r,g),b=yn(r),q=g!=null&&g.sku?g.sku:(r==null?void 0:r.id)??(R==null?void 0:R.product_id),W=(g==null?void 0:g.sku)??bn(r),de=Me(g)||Oa(r),ee=Ve(g)||Aa(r),xe=jt(u),ne=((Xe=u==null?void 0:u.summary)==null?void 0:Xe.product_total)!=null?+u.summary.product_total:Tr(u),Ie=xe>0?+(ne/xe).toFixed(2):0,Fe=ne,Ae=((ze=u==null?void 0:u.summary)==null?void 0:ze.tax)??+(ne*.08).toFixed(2),se=(($e=u==null?void 0:u.summary)==null?void 0:$e.shipping_fee)??(((ue=tt[T])==null?void 0:ue.fee)||0),he=u!=null&&u.address?[u.address.addressLine1,u.address.addressLine2,u.address.street,[u.address.city,u.address.state,u.address.postalCode].filter(Boolean).join(", "),u.address.country].filter(Boolean).map(Ot=>He(String(Ot))).join(", "):"—",Ue=(u==null?void 0:u.payment)||"card",ft=Ue==="card"?n.jsxs(n.Fragment,{children:["Credit Card — Mastercard",n.jsx("br",{}),"•••• 7820 Exp: 12/26"]}):n.jsx(n.Fragment,{children:He(Ue)});return n.jsxs("div",{className:"mx-auto mt-3 mb-3 rounded-2xl bg-white",children:[n.jsx("div",{className:"px-6 pt-5 pb-3",children:n.jsxs("h3",{className:"font-semibold text-lg mb-2 text-gray-800 flex items-center gap-2",children:[n.jsx(te,{icon:"mdi:receipt-text-check-outline",width:"24",color:C}),"All set! Here’s what your smart order looks like 🧾"]})}),n.jsx("div",{className:"px-6 pb-4",children:n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-12 gap-4 rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"sm:col-span-2 flex",children:n.jsx("div",{className:"w-30 h-26 sm:w-30 sm:h-26 overflow-hidden rounded-lg bg-white border border-gray-200 flex items-center justify-center mx-auto sm:mx-0",children:F?n.jsx("img",{src:F,alt:b,className:"w-full h-full object-contain"}):n.jsx(te,{icon:"mdi:image-outline",width:"24",className:"opacity-50"})})}),n.jsxs("div",{className:"sm:col-span-10",children:[n.jsxs("div",{className:"mb-3",children:[n.jsx("div",{className:"text-lg text-center font-bold text-gray-900",children:b}),n.jsxs("div",{className:"text-xs text-center font-bold text-gray-600",children:[n.jsx("span",{className:"font-medium",children:"SKU:"})," ",q??"—"]}),(W||de||ee)&&n.jsxs("div",{className:"text-xs text-gray-600 mt-0.5 text-center",children:[W&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",children:"SKU:"})," ",W," "]}),de&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",children:"Color:"})," ",de," "]}),ee&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",children:"Size:"})," ",ee]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md-grid-cols-3 md:grid-cols-3 gap-3",children:[n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center",children:[n.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Unit Price"}),n.jsx("div",{className:"mt-0.5 text-base font-bold text-gray-900",children:Pe(Ie,v)})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center",children:[n.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Quantity"}),n.jsx("div",{className:"mt-0.5 text-base font-bold text-gray-900",children:xe})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-white p-3 text-center",children:[n.jsx("div",{className:"text-[11px] uppercase tracking-wide text-gray-500",children:"Subtotal"}),n.jsx("div",{className:"mt-0.5 text-base font-bold text-gray-900",children:Pe(Fe,v)})]})]})]})]})}),n.jsxs("div",{className:"px-6 pb-2",children:[n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 mb-3",children:[n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🏠 Address"}),n.jsx("div",{className:"mt-1 text-sm font-semibold text-gray-900 text-center",children:he})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"💳 Payment"}),n.jsx("div",{className:"mt-1 text-sm font-semibold text-gray-900 text-center",children:ft})]}),n.jsxs("div",{className:"flex flex-col items-center rounded-xl border border-gray-200 bg-gray-50 p-3",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🚚 Delivery"}),n.jsx("div",{className:"mt-1 text-sm font-semibold text-gray-900 text-center",children:u!=null&&u.delivery&&((Ze=tt[u.delivery])==null?void 0:Ze.label)||"—"})]})]}),n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[n.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-gray-200 bg-gray-50 p-4 text-center",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"💰 any(s)"}),n.jsx("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:Pe(ne,v)})]}),n.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-gray-200 bg-gray-50 p-4 text-center",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🏛️ Taxes"}),n.jsx("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:Pe(Ae,v)})]}),n.jsxs("div",{className:"flex flex-col items-center justify-center rounded-xl border border-gray-200 bg-gray-50 p-4 text-center",children:[n.jsx("div",{className:"text-xs uppercase tracking-wide text-gray-500",children:"🚚 Shipping"}),n.jsx("div",{className:"mt-1 text-2xl font-bold text-gray-900",children:Pe(se,v)})]})]}),n.jsxs("div",{className:"mt-4 rounded-xl p-4 text-center text-white shadow-sm",style:{background:Ge},children:[n.jsx("div",{className:"text-sm/5 opacity-95",children:"🔹 Total Payable"}),n.jsx("div",{className:"mt-1 text-3xl font-extrabold tracking-tight",children:Pe(ne+Ae+se,v)})]})]}),!m&&n.jsxs("div",{className:"px-6 pb-5",children:[!j&&n.jsx("p",{className:"mt-3 text-center text-sm text-gray-700",children:"Everything looks good! Do you want me to watch this product and buy it automatically when it meets your condition?"}),j&&Pr({intentMandateId:K}),Gt&&!j&&n.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-3",children:[n.jsx("button",{onClick:xo,className:"inline-flex items-center justify-center rounded-full px-6 py-2.5 font-semibold text-white shadow-md transition-transform duration-150 hover:-translate-y-0.5 hover:shadow-lg",style:{background:Ge},children:"Confirm"}),n.jsx("button",{onClick:Dr,className:"inline-flex items-center justify-center rounded-full border px-6 py-2.5 font-semibold hover:bg-gray-50",style:{borderColor:Ge,color:Ge},children:"Cancel"})]})]})]})},wo=d=>{if(!d)return null;const m=[d.addressLine1,d.addressLine2,d.street,[d.city,d.state,d.postalCode].filter(Boolean).join(", "),d.country].filter(u=>!!u).map(u=>He(u)).join(", ");return n.jsx("div",{className:"px-6 py-4",style:{backgroundColor:"var(--tanya-light)"},children:n.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx(te,{icon:"mdi:home-map-marker",width:"20",color:C}),n.jsx("div",{className:"font-semibold text-gray-800",children:"Delivery Address"})]}),n.jsx("div",{className:"text-sm text-gray-800",children:m})]})})},bo=d=>{const m=d==null?void 0:d.method,u=m?tt[m]:void 0;return n.jsx("div",{className:"px-6 py-4",style:{backgroundColor:"var(--tanya-light)"},children:n.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx(te,{icon:"mdi:truck-delivery",width:"20",color:C}),n.jsx("div",{className:"font-semibold text-gray-800",children:"Delivery Method"})]}),n.jsx("div",{className:"text-sm text-gray-800",children:u?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(te,{icon:u.icon,width:"18"}),n.jsx("span",{className:"font-medium",children:u.label})]}),n.jsx("div",{className:"text-gray-600",children:u.subtitle})]}):"—"})]})})},vo=d=>{const m=(d==null?void 0:d.method)||"card";return n.jsx("div",{className:"px-6 py-4",style:{backgroundColor:"var(--tanya-light)"},children:n.jsxs("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx(te,{icon:"mdi:credit-card-outline",width:"20",color:C}),n.jsx("div",{className:"font-semibold text-gray-800",children:"Payment Method"})]}),n.jsx("div",{className:"text-sm text-gray-800",children:m==="card"?n.jsxs(n.Fragment,{children:["Credit Card — Mastercard",n.jsx("br",{}),"•••• 7820 Exp: 12/26"]}):He(m)})]})})},jo=(d,m)=>{const u=d.snapshotStage;if(!u||u==="address"&&ie||u==="delivery"&&V||u==="payment"&&G||u==="final"&&ve)return null;switch(u){case"initial":return zr(d.snapshotPayload,!m);case"address":return wo(d.snapshotPayload);case"delivery":return bo(d.snapshotPayload);case"payment":return vo(d.snapshotPayload);case"final":return Mr(d.snapshotPayload,!m);case"success":return Pr(d.snapshotPayload);default:return null}};return Co.createPortal(n.jsxs("div",{className:"fixed inset-0",style:{zIndex:2147483647},"aria-modal":"true",role:"dialog",children:[n.jsx("div",{className:"absolute inset-0",style:{background:"rgba(0,0,0,0.25)"},onClick:t}),n.jsx("div",{className:"absolute right-0 ",children:n.jsxs("div",{className:"w-[64.7vw] h-screen bg-white rounded-xl overflow-hidden flex flex-col shadow-xl",children:[n.jsxs("div",{style:{display:"flex",justifyContent:"space-between",borderTopLeftRadius:"0.75rem",borderBottomLeftRadius:"0.75rem",padding:"0.25rem",background:wt},children:[n.jsxs("div",{style:{display:"flex",color:"#ffffff",alignItems:"center",gap:"0.5rem"},children:[n.jsx(te,{icon:"ph:sparkle-duotone",width:"25",height:"25"}),n.jsx("div",{children:n.jsx("p",{className:"font-bold",children:"Agentic Shopping with TANYA"})})]}),n.jsx("div",{style:{display:"flex",alignItems:"center",gap:"1.25rem",margin:"0.75rem"},children:n.jsx(te,{icon:"fluent:dismiss-24-filled",color:"#ffffff",width:"24",height:"24",className:"cursor-pointer",onClick:t})})]}),n.jsxs("div",{ref:ut,className:"overflow-y-auto pr-5 pb-4 space-y-4 hide-scrollbar flex-grow",children:[n.jsxs("div",{className:"text-sm text-[16px] rounded-r-xl p-3 m-3 rounded-bl-xl w-3/4 text-tanya-contrast",style:{backgroundColor:"#804c9e"},children:["Welcome to your smart shopping companion!",n.jsxs("p",{children:["Simply share your instruction — like “If this product goes below $",parseInt(r.price)-5," grab it for me.”"]}),n.jsx("p",{children:"I’ll monitor it, calculate total prices, and place the order when your conditions are met."})]}),n.jsx(yo,{}),h>1&&n.jsx(Lr,{showSubmit:!1}),Be.map((d,m)=>{var F;const u=m===Be.length-1,v=!!d.snapshotStage;return n.jsxs("div",{children:[d.query&&n.jsx("div",{className:"flex justify-end",children:n.jsx("p",{className:"text-sm rounded-l-xl p-3 m-3 mb-4 rounded-br-xl max-w-[75%]",style:{color:"#ffffff",backgroundColor:"var(--tanya)"},children:d.query})}),d.response==="__TEXT__"&&((F=d.snapshotPayload)==null?void 0:F.text)&&n.jsx("div",{className:"mt-2",children:n.jsx("div",{className:"text-sm text-tanya-contrast px-7 py-4 rounded-r-xl rounded-bl-2xl w-full",style:{backgroundColor:"var(--tanya-light)",margin:"0.75rem"},children:n.jsx("div",{className:"flex items-center gap-2",children:n.jsx("p",{children:d.snapshotPayload.text})})})}),u&&P&&h>1&&n.jsxs("div",{className:"mx-4 mt-2 rounded-xl border border-gray-200 bg-white p-4 animate-fade-in",children:[n.jsxs("div",{className:"text-sm text-gray-800",children:["Proceed with color:"," ",n.jsx("span",{className:"font-semibold",children:Me(g)||"—"}),", size:"," ",n.jsx("span",{className:"font-semibold",children:Ve(g)||"—"}),"?"]}),n.jsxs("div",{className:"mt-3 flex gap-3",children:[n.jsx("button",{onClick:so,className:"px-5 py-2 rounded-full text-white font-semibold",style:{background:C},children:"Yes"}),n.jsx("button",{onClick:ao,className:"px-5 py-2 rounded-full font-semibold border",style:{borderColor:C,color:C},children:"No, change SKU"})]})]}),u&&ge&&n.jsx(Lr,{showSubmit:!0}),u&&Q&&n.jsx("div",{className:"mt-4",children:n.jsx("div",{className:"text-sm text-tanya-contrast px-7 py-4 rounded-r-xl rounded-bl-2xl w-full",style:{backgroundColor:"var(--tanya-light)",margin:"0.75rem"},children:n.jsx("div",{className:"flex items-center gap-2 tanya-pulse-text",children:n.jsx("p",{children:"Reading your instruction and setting things up…"})})})}),(v||d.response==="__CARD__")&&(!Q||!u)&&n.jsx("div",{className:"mt-6 mb-4 mx-4 animate-fade-in",style:{backgroundColor:"#fff",borderRadius:"1rem",boxShadow:"0 2px 8px rgba(0,0,0,0.08)",overflow:"hidden"},children:v?jo(d,u):zr(d.snapshotPayload,!1)})]},m)}),ie&&n.jsxs("div",{className:"mt-6 mb-6 mx-6 rounded-xl p-6 shadow-md border border-gray-200 bg-white animate-fade-in",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("h3",{className:"font-semibold text-lg text-gray-800 flex items-center gap-2",children:[n.jsx(te,{icon:"mdi:home-map-marker",width:"24",color:"var(--tanya-light)"}),"Select a Delivery Address"]}),O&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ml-2 text-xs px-2 py-1 rounded-full bg-green-100 text-green-700 font-semibold",children:"Selected"}),!j&&n.jsx("button",{onClick:uo,className:"ml-2 text-xs px-2 py-1 rounded-full border hover:bg-gray-50",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},title:"Change address",children:"Change"})]})]}),n.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Choose where you’d like us to deliver this item."}),a?n.jsxs("div",{className:"flex items-center py-6",children:[n.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2",style:{borderBottomColor:"var(--tanya-light)"}}),n.jsx("p",{className:"ml-3 text-gray-600",children:"Fetching your addresses..."})]}):We.length>0?n.jsxs("div",{className:`space-y-3 ${O?"opacity-70":""}`,children:[We.map(d=>{const m=[d.addressLine1,d.addressLine2].filter(Boolean).map(W=>He(W||"")).join(" "),u=He(d.city||""),v=`${He(d.state||"")}${d.state&&d.postalCode?", ":""}${d.postalCode||""}`,F=He(d.country||""),b=String(d.addressId??d.id),q=Se===b;return n.jsxs("label",{className:`flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${q?"border-tanya-light":"border-gray-300"} ${O?"pointer-events-none":""}`,title:O?"Address already submitted":"",children:[n.jsx("input",{type:"radio",name:"address",className:"mt-1 accent-tanya-light",checked:q,disabled:O,onChange:()=>Qt(b),value:b}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"font-semibold text-gray-800",children:m||"Address"}),n.jsxs("div",{className:"text-sm text-gray-700",children:[u,n.jsx("br",{}),v,n.jsx("br",{}),F]})]})]},b)}),n.jsxs("div",{className:"flex justify-between pt-2",children:[n.jsx("button",{onClick:$r,className:"px-6 py-2.5 rounded-full font-semibold border transition-all hover:-translate-y-0.5 hover:shadow-sm",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},children:"Cancel"}),n.jsx("button",{onClick:co,disabled:O,className:`px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${O?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:C},children:O?"Address Submitted":"Submit Address"})]})]}):n.jsx("div",{className:"text-center py-8 text-gray-600",children:"No addresses found. Please add a new one in your profile."})]}),V&&n.jsxs("div",{className:"mt-2 mb-6 mx-6 rounded-xl p-6 shadow-md border border-gray-200 bg-white animate-fade-in",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("h3",{className:"font-semibold text-lg text-gray-800 flex items-center gap-2",children:[n.jsx(te,{icon:"mdi:truck-delivery",width:"24",color:"var(--tanya-light)"}),"Great! Now choose how fast you want it delivered 🚚"]}),M&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ml-2 text-xs px-2 py-1 rounded-full bg-green-100 text-green-700 font-semibold",children:"Selected"}),!j&&n.jsx("button",{onClick:mo,className:"ml-2 text-xs px-2 py-1 rounded-full border hover:bg-gray-50",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},title:"Change shipping method",children:"Change"})]})]}),n.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Which one would you like me to use for this order?"}),n.jsx("div",{className:`space-y-3 ${M?"opacity-70":""}`,children:Object.keys(tt).map(d=>{const m=tt[d],u=T===d;return n.jsxs("label",{className:`flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${u?"border-tanya-light":"border-gray-300"} ${M?"pointer-events-none":""}`,title:M?"Delivery already submitted":"",children:[n.jsx("input",{type:"radio",name:"delivery",className:"mt-1 accent-tanya-light",checked:u,disabled:M,onChange:()=>le(d)}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"font-semibold text-gray-800 flex items-center gap-2",children:[n.jsx(te,{icon:m.icon,width:"18"})," ",m.label]}),n.jsx("div",{className:"text-sm text-gray-700",children:m.subtitle})]}),n.jsx("div",{className:"text-sm font-semibold text-gray-800",children:m.fee===0?"Free":Pe(m.fee,(R==null?void 0:R.currency)||qe)})]},d)})}),n.jsxs("div",{className:"flex justify-between pt-4",children:[n.jsx("button",{onClick:$r,className:"px-6 py-2.5 rounded-full font-semibold border transition-all hover:-translate-y-0.5 hover:shadow-sm",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},children:"Cancel"}),n.jsx("button",{onClick:fo,disabled:M,className:`px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${M?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:"var(--tanya)"},children:M?"Delivery Submitted":"Submit Delivery Option"})]})]}),G&&n.jsxs("div",{className:"mt-2 mb-6 mx-6 rounded-xl p-6 shadow-md border border-gray-200 bg-white animate-fade-in",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("h3",{className:"font-semibold text-lg text-gray-800 flex items-center gap-2",children:[n.jsx(te,{icon:"mdi:credit-card-outline",width:"24",color:"var(--tanya-light)"}),"Almost done! 💳"]}),X&&n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"ml-2 text-xs px-2 py-1 rounded-full bg-green-100 text-green-700 font-semibold",children:"Selected"}),!j&&n.jsx("button",{onClick:go,className:"ml-2 text-xs px-2 py-1 rounded-full border hover:bg-gray-50",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},title:"Change payment method",children:"Change"})]})]}),n.jsx("p",{className:"text-sm text-gray-600 mb-4",children:"Please choose a payment method for this order:"}),n.jsx("div",{className:`space-y-3 ${X?"opacity-70":""}`,children:n.jsxs("label",{className:`flex items-start gap-3 p-4 border rounded-lg cursor-pointer transition hover:shadow-sm ${we==="card"?"border-tanya-light":"border-gray-300"} ${X?"pointer-events-none":""}`,title:X?"Payment already submitted":"",children:[n.jsx("input",{type:"radio",name:"payment",className:"mt-1 accent-tanya-light",checked:we==="card",disabled:X,onChange:()=>be("card")}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"font-semibold text-gray-800 flex items-center gap-2",children:[n.jsx(te,{icon:"mdi:credit-card-chip-outline",width:"18"})," ","Credit Card"]}),we==="card"&&n.jsxs("div",{className:"text-sm text-gray-700 mt-1",children:["Mastercard •••• 7820",n.jsx("br",{}),"Expiry: 12/26"]})]})]})}),n.jsxs("div",{className:"flex justify-between pt-4",children:[n.jsx("button",{onClick:po,className:"px-6 py-2.5 rounded-full font-semibold border transition-all hover:-translate-y-0.5 hover:shadow-sm",style:{borderColor:"var(--tanya-light)",color:"var(--tanya-light)"},children:"Cancel"}),n.jsx("button",{onClick:ho,disabled:X,className:`px-6 py-2.5 rounded-full font-semibold text-white shadow-md transition-all duration-300 ${X?"opacity-60 cursor-not-allowed":"hover:-translate-y-0.5 hover:shadow-lg"}`,style:{background:"var(--tanya)"},children:X?"Payment Submitted":"Submit Payment Method"})]})]}),ve&&Mr({...R,address:JSON.parse(localStorage.getItem("agentic_order_address")||"null"),delivery:localStorage.getItem("agentic_order_delivery"),payment:localStorage.getItem("agentic_order_payment"),summary:Or(R==null?void 0:R.currency)},!1)]}),n.jsxs("div",{className:"sticky bottom-0 w-[96%] drop-shadow-xl flex items-center rounded-full bg-white border border-gray-300 m-[15px]",children:[n.jsx("input",{placeholder:D?"Complete the current step…":vt?`What would you like me to do? (e.g., If this product goes below $${parseInt(r.price)-5}, grab it for me.)`:"Oops! This combination isn’t available for this product. Try a different option.",disabled:oo,className:`w-full rounded-full p-4 outline-none border-none focus:ring-0 focus:border-transparent disabled:bg-gray-100 disabled:cursor-not-allowed
|
|
20
20
|
${vt?"":"placeholder:text-red-400 text-red-500"}`,value:Te,onKeyDown:d=>{d.key==="Enter"&&!Q&&!D&&Ar()},onChange:d=>me(d.target.value)}),n.jsx("button",{type:"submit",disabled:Q||D,className:"mr-6 font-medium",style:{color:"var(--tanya-light)"},onClick:()=>Ar(),children:Q?n.jsx("div",{className:"m-3 animate-spin rounded-full h-6 w-6 border-b-2",style:{borderBottom:"2px solid"}}):n.jsx(te,{icon:"fluent:send-48-filled",color:"var(--tanya-light)",width:"24",height:"24"})})]})]})})]}),document.body)};exports.AgenticShoppingButton=$a;exports.TanyaChatbot=Cs;exports.TanyaChatbotProvider=Fo;
|
|
21
21
|
//# sourceMappingURL=tanya-chatbot.cjs.js.map
|