tanya-chatbot 0.0.5 → 0.0.7

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.
@@ -1,20 +1,20 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),S=require("react"),Gt=require("@radix-ui/react-popover");require("clsx");require("tailwind-merge");const L=require("axios");require("crypto-js");const Wt=require("react-router-dom"),ye=require("react-redux"),Qt=require("@reduxjs/toolkit"),nt=require("@iconify/react"),K=require("react-toastify");function Yt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const St=Yt(Gt),we=e=>{const t=new CustomEvent("reactCartUpdated",{detail:{cartUpdated:!0,basketId:e}});window.dispatchEvent(t)};function Zt({...e}){return r.jsx(St.Root,{"data-slot":"popover",...e})}function Xt({...e}){return r.jsx(St.Trigger,{"data-slot":"popover-trigger",...e})}const de=()=>({aiConversationUrl:"https://mdv3qwfi2j.execute-api.us-east-1.amazonaws.com/dev/api/bedrock/invoke/stream",xAPIKey:"BJBtjpPkqGatuoa3qJqdR8aHXSsHkgvGaootbubi",serverUrl:"https://tanya-sfcc-server.vercel.app/",basePath:"sc-api"}),kt=async()=>{const e="https://tanya-sfcc-server.vercel.app/";try{const t=await L.post(`${e}api/auth/token-bm-grant?baseUrl=${re()}&siteId=${Z()}`);return t.status===200&&t.data.access_token?t.data.access_token:(console.error("Failed to fetch token:",t.data),null)}catch(t){return L.isAxiosError(t)?console.error("Error fetching token:",t.response||t.message):console.error("Unexpected error:",t),null}},It=async e=>{const t="https://tanya-sfcc-server.vercel.app/";try{const n=JSON.parse(sessionStorage.getItem("customerData")||"{}").dwsid,o=await L.post(`${t}api/auth/token-existing-guest-customer?dwsid=${n}&baseUrl=${re()}&siteId=${Z()}&pubCfg=${ie()}&envRef=${ae()}&orgRef=${ce()}`,{},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}});return o.status===200&&o.data?o.data:null}catch(n){return L.isAxiosError(n)?console.error("Error creating basket:",n.response||n.message):console.error("Unexpected error:",n),null}};async function De(){const e=localStorage.getItem("expires_in"),t=localStorage.getItem("access_token"),n=JSON.parse(sessionStorage.getItem("customerData")||"{}").isGuest;if(e&&t&&new Date().getTime()<parseInt(e)&&n===JSON.parse(localStorage.getItem("isGuest")||"false"))return console.log("access token found in local storage"),{access_token:t,expires_in:e};const{serverUrl:o}=de(),s=JSON.parse(sessionStorage.getItem("customerData")||"{}").dwsid,i=JSON.parse(sessionStorage.getItem("customerData")||"{}").usrRef;try{const a=n?"unregister-auth":"register-auth",l=await L.get(`${o}sc-api/${a}?dwsid=${s}&email=${i}&pubCfg=${ie()}&envRef=${ae()}&orgRef=${ce()}&siteId=${Z()}`);return localStorage.setItem("access_token",l.data.access_token),localStorage.setItem("expires_in",String(new Date().getTime()+l.data.expires_in*1e3)),localStorage.setItem("isGuest",n.toString()),console.log(l.data),l.data}catch(a){console.log(a)}}const re=()=>sessionStorage.getItem("Host"),Z=()=>sessionStorage.getItem("SiteId"),ie=()=>sessionStorage.getItem("pubCfg"),ae=()=>sessionStorage.getItem("envRef"),ce=()=>sessionStorage.getItem("orgRef"),st=async(e,t)=>{const{serverUrl:n,basePath:o}=de();try{const s=re();return(await L.get(`${n}${o}/search-sfcc?baseUrl=${s}&query=${e}&siteId=${Z()}&pubCfg=${ie()}&envRef=${ae()}&orgRef=${ce()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}})).data.hits}catch(s){throw console.error("Error fetching search results:",s),s}},Ct=async e=>{if(!e)throw new Error("Product ID is required");const{serverUrl:t,basePath:n}=de(),o=re();console.log("calling access");const{access_token:s}=await De();return console.log(s),(await L.get(`${t}${n}/product-sfcc/${e}?baseUrl=${o}&siteId=${Z()}&pubCfg=${ie()}&envRef=${ae()}&orgRef=${ce()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})).data},en=async e=>{if(!e)throw new Error("customerId is required");const t=await kt(),{customer_token:n}=await It(t),{serverUrl:o,basePath:s}=de(),a=(await De()).access_token;return(await L.get(`${o}${s}/get-interest?baseUrl=${re()}&customerId=${e}&siteId=${Z()}&pubCfg=${ie()}&envRef=${ae()}&orgRef=${ce()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})).data},ot=e=>String(typeof e=="string"?e:e["en-US"]||e),rt=e=>e!=null&&e.image?[e.image]:"variants"in e?e.variants[0].images:e.masterVariant.images.map(t=>t.url),tn=(e,t)=>e.toLocaleString("en-US",{style:"currency",currency:t||"USD"}),it=e=>{var t,n,o;return"variants"in e?{centAmount:(t=e.variants[0])==null?void 0:t.prices.EUR.max,currencyCode:"DOL"}:{centAmount:(n=e.masterVariant)==null?void 0:n.prices[0].value.centAmount,currencyCode:(o=e.masterVariant)==null?void 0:o.prices[0].value.currencyCode}},nn=e=>e.charAt(0).toUpperCase()+e.slice(1),at=(e,t)=>e.length<t?e:e.slice(0,t)+"...",Re=e=>e.split("\\n").map((t,n)=>{const o=t.match(/^(\d+)\.\s(.+)/);return o?`<p key=${n} class="mb-2"><strong>${o[1]}.</strong> ${o[2]}</p>`:t.trim()?`<p key=${n} class="mb-2">${t}</p>`:"<br/>"}).join("");function sn(e,t){const n=e.icons,o=e.aliases||Object.create(null),s=Object.create(null);function i(a){if(n[a])return s[a]=[];if(!(a in s)){s[a]=null;const l=o[a]&&o[a].parent,c=l&&i(l);c&&(s[a]=[l].concat(c))}return s[a]}return Object.keys(n).concat(Object.keys(o)).forEach(i),s}const Ft=Object.freeze({left:0,top:0,width:16,height:16}),Ae=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Qe=Object.freeze({...Ft,...Ae}),Ve=Object.freeze({...Qe,body:"",hidden:!1});function on(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const o=((e.rotate||0)+(t.rotate||0))%4;return o&&(n.rotate=o),n}function ct(e,t){const n=on(e,t);for(const o in Ve)o in Ae?o in e&&!(o in n)&&(n[o]=Ae[o]):o in t?n[o]=t[o]:o in e&&(n[o]=e[o]);return n}function rn(e,t,n){const o=e.icons,s=e.aliases||Object.create(null);let i={};function a(l){i=ct(o[l]||s[l],i)}return a(t),n.forEach(a),ct(e,i)}function Nt(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(s=>{t(s,null),n.push(s)});const o=sn(e);for(const s in o){const i=o[s];i&&(t(s,rn(e,s,i)),n.push(s))}return n}const an={provider:"",aliases:{},not_found:{},...Ft};function He(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function Tt(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!He(e,an))return null;const n=t.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!He(i,Ve))return null}const o=t.aliases||Object.create(null);for(const s in o){const i=o[s],a=i.parent;if(!s||typeof a!="string"||!n[a]&&!o[a]||!He(i,Ve))return null}return t}const lt=Object.create(null);function cn(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function ve(e,t){const n=lt[e]||(lt[e]=Object.create(null));return n[t]||(n[t]=cn(e,t))}function _t(e,t){return Tt(t)?Nt(t,(n,o)=>{o?e.icons[n]=o:e.missing.add(n)}):[]}function ln(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const Pt=/^[a-z0-9]+(-[a-z0-9]+)*$/,Me=(e,t,n,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 l=s.pop(),c=s.pop(),d={provider:s.length>0?s[0]:o,prefix:c,name:l};return t&&!Ee(d)?null:d}const i=s[0],a=i.split("-");if(a.length>1){const l={provider:o,prefix:a.shift(),name:a.join("-")};return t&&!Ee(l)?null:l}if(n&&o===""){const l={provider:o,prefix:"",name:i};return t&&!Ee(l,n)?null:l}return null},Ee=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let Fe=!1;function Et(e){return typeof e=="boolean"&&(Fe=e),Fe}function ut(e){const t=typeof e=="string"?Me(e,!0,Fe):e;if(t){const n=ve(t.provider,t.prefix),o=t.name;return n.icons[o]||(n.missing.has(o)?null:void 0)}}function un(e,t){const n=Me(e,!0,Fe);if(!n)return!1;const o=ve(n.provider,n.prefix);return t?ln(o,n.name,t):(o.missing.add(n.name),!0)}function dn(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),Fe&&!t&&!e.prefix){let s=!1;return Tt(e)&&(e.prefix="",Nt(e,(i,a)=>{un(i,a)&&(s=!0)})),s}const n=e.prefix;if(!Ee({prefix:n,name:"a"}))return!1;const o=ve(t,n);return!!_t(o,e)}const $t=Object.freeze({width:null,height:null}),At=Object.freeze({...$t,...Ae}),fn=/(-?[0-9.]*[0-9]+[0-9.]*)/g,pn=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function dt(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const o=e.split(fn);if(o===null||!o.length)return e;const s=[];let i=o.shift(),a=pn.test(i);for(;;){if(a){const l=parseFloat(i);isNaN(l)?s.push(i):s.push(Math.ceil(l*t*n)/n)}else s.push(i);if(i=o.shift(),i===void 0)return s.join("");a=!a}}function hn(e,t="defs"){let n="";const o=e.indexOf("<"+t);for(;o>=0;){const s=e.indexOf(">",o),i=e.indexOf("</"+t);if(s===-1||i===-1)break;const a=e.indexOf(">",i);if(a===-1)break;n+=e.slice(s+1,i).trim(),e=e.slice(0,o).trim()+e.slice(a+1)}return{defs:n,content:e}}function mn(e,t){return e?"<defs>"+e+"</defs>"+t:t}function gn(e,t,n){const o=hn(e);return mn(o.defs,t+o.content+n)}const xn=e=>e==="unset"||e==="undefined"||e==="none";function yn(e,t){const n={...Qe,...e},o={...At,...t},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,o].forEach(T=>{const p=[],b=T.hFlip,O=T.vFlip;let E=T.rotate;b?O?E+=2:(p.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),p.push("scale(-1 1)"),s.top=s.left=0):O&&(p.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),p.push("scale(1 -1)"),s.top=s.left=0);let P;switch(E<0&&(E-=Math.floor(E/4)*4),E=E%4,E){case 1:P=s.height/2+s.top,p.unshift("rotate(90 "+P.toString()+" "+P.toString()+")");break;case 2:p.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:P=s.width/2+s.left,p.unshift("rotate(-90 "+P.toString()+" "+P.toString()+")");break}E%2===1&&(s.left!==s.top&&(P=s.left,s.left=s.top,s.top=P),s.width!==s.height&&(P=s.width,s.width=s.height,s.height=P)),p.length&&(i=gn(i,'<g transform="'+p.join(" ")+'">',"</g>"))});const a=o.width,l=o.height,c=s.width,d=s.height;let f,g;a===null?(g=l===null?"1em":l==="auto"?d:l,f=dt(g,c/d)):(f=a==="auto"?c:a,g=l===null?dt(f,d/c):l==="auto"?d:l);const w={},h=(T,p)=>{xn(p)||(w[T]=p.toString())};h("width",f),h("height",g);const j=[s.left,s.top,c,d];return w.viewBox=j.join(" "),{attributes:w,viewBox:j,body:i}}const wn=/\sid="(\S+)"/g,bn="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let vn=0;function jn(e,t=bn){const n=[];let o;for(;o=wn.exec(e);)n.push(o[1]);if(!n.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const a=typeof t=="function"?t(i):t+(vn++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+a+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const Je=Object.create(null);function Sn(e,t){Je[e]=t}function Ke(e){return Je[e]||Je[""]}function Ye(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 Ze=Object.create(null),Se=["https://api.simplesvg.com","https://api.unisvg.com"],$e=[];for(;Se.length>0;)Se.length===1||Math.random()>.5?$e.push(Se.shift()):$e.push(Se.pop());Ze[""]=Ye({resources:["https://api.iconify.design"].concat($e)});function kn(e,t){const n=Ye(t);return n===null?!1:(Ze[e]=n,!0)}function Xe(e){return Ze[e]}const In=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let ft=In();function Cn(e,t){const n=Xe(e);if(!n)return 0;let o;if(!n.maxURL)o=0;else{let s=0;n.resources.forEach(a=>{s=Math.max(s,a.length)});const i=t+".json?icons=";o=n.maxURL-s-n.path.length-i.length}return o}function Fn(e){return e===404}const Nn=(e,t,n)=>{const o=[],s=Cn(e,t),i="icons";let a={type:i,provider:e,prefix:t,icons:[]},l=0;return n.forEach((c,d)=>{l+=c.length+1,l>=s&&d>0&&(o.push(a),a={type:i,provider:e,prefix:t,icons:[]},l=c.length),a.icons.push(c)}),o.push(a),o};function Tn(e){if(typeof e=="string"){const t=Xe(e);if(t)return t.path}return"/"}const _n=(e,t,n)=>{if(!ft){n("abort",424);return}let o=Tn(t.provider);switch(t.type){case"icons":{const i=t.prefix,l=t.icons.join(","),c=new URLSearchParams({icons:l});o+=i+".json?"+c.toString();break}case"custom":{const i=t.uri;o+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;ft(e+o).then(i=>{const a=i.status;if(a!==200){setTimeout(()=>{n(Fn(a)?"abort":"next",a)});return}return s=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",s)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",s)})},Pn={prepare:Nn,send:_n};function Ot(e,t){e.forEach(n=>{const o=n.loaderCallbacks;o&&(n.loaderCallbacks=o.filter(s=>s.id!==t))})}function En(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const o=e.provider,s=e.prefix;t.forEach(i=>{const a=i.icons,l=a.pending.length;a.pending=a.pending.filter(c=>{if(c.prefix!==s)return!0;const d=c.name;if(e.icons[d])a.loaded.push({provider:o,prefix:s,name:d});else if(e.missing.has(d))a.missing.push({provider:o,prefix:s,name:d});else return n=!0,!0;return!1}),a.pending.length!==l&&(n||Ot([e],i.id),i.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),i.abort))})}))}let $n=0;function An(e,t,n){const o=$n++,s=Ot.bind(null,n,o);if(!t.pending.length)return s;const i={id:o,icons:t,callback:e,abort:s};return n.forEach(a=>{(a.loaderCallbacks||(a.loaderCallbacks=[])).push(i)}),s}function On(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((s,i)=>s.provider!==i.provider?s.provider.localeCompare(i.provider):s.prefix!==i.prefix?s.prefix.localeCompare(i.prefix):s.name.localeCompare(i.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 i=s.provider,a=s.prefix,l=s.name,c=n[i]||(n[i]=Object.create(null)),d=c[a]||(c[a]=ve(i,a));let f;l in d.icons?f=t.loaded:a===""||d.missing.has(l)?f=t.missing:f=t.pending;const g={provider:i,prefix:a,name:l};f.push(g)}),t}function Ln(e,t=!0,n=!1){const o=[];return e.forEach(s=>{const i=typeof s=="string"?Me(s,t,n):s;i&&o.push(i)}),o}const Dn={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Mn(e,t,n,o){const s=e.resources.length,i=e.random?Math.floor(Math.random()*s):e.index;let a;if(e.random){let I=e.resources.slice(0);for(a=[];I.length>1;){const $=Math.floor(Math.random()*I.length);a.push(I[$]),I=I.slice(0,$).concat(I.slice($+1))}a=a.concat(I)}else a=e.resources.slice(i).concat(e.resources.slice(0,i));const l=Date.now();let c="pending",d=0,f,g=null,w=[],h=[];typeof o=="function"&&h.push(o);function j(){g&&(clearTimeout(g),g=null)}function T(){c==="pending"&&(c="aborted"),j(),w.forEach(I=>{I.status==="pending"&&(I.status="aborted")}),w=[]}function p(I,$){$&&(h=[]),typeof I=="function"&&h.push(I)}function b(){return{startTime:l,payload:t,status:c,queriesSent:d,queriesPending:w.length,subscribe:p,abort:T}}function O(){c="failed",h.forEach(I=>{I(void 0,f)})}function E(){w.forEach(I=>{I.status==="pending"&&(I.status="aborted")}),w=[]}function P(I,$,R){const W=$!=="success";switch(w=w.filter(D=>D!==I),c){case"pending":break;case"failed":if(W||!e.dataAfterTimeout)return;break;default:return}if($==="abort"){f=R,O();return}if(W){f=R,w.length||(a.length?G():O());return}if(j(),E(),!e.random){const D=e.resources.indexOf(I.resource);D!==-1&&D!==e.index&&(e.index=D)}c="completed",h.forEach(D=>{D(R)})}function G(){if(c!=="pending")return;j();const I=a.shift();if(I===void 0){if(w.length){g=setTimeout(()=>{j(),c==="pending"&&(E(),O())},e.timeout);return}O();return}const $={status:"pending",resource:I,callback:(R,W)=>{P($,R,W)}};w.push($),d++,g=setTimeout(G,e.rotate),n(I,t,$.callback)}return setTimeout(G),b}function Lt(e){const t={...Dn,...e};let n=[];function o(){n=n.filter(l=>l().status==="pending")}function s(l,c,d){const f=Mn(t,l,c,(g,w)=>{o(),d&&d(g,w)});return n.push(f),f}function i(l){return n.find(c=>l(c))||null}return{query:s,find:i,setIndex:l=>{t.index=l},getIndex:()=>t.index,cleanup:o}}function pt(){}const ze=Object.create(null);function Un(e){if(!ze[e]){const t=Xe(e);if(!t)return;const n=Lt(t),o={config:t,redundancy:n};ze[e]=o}return ze[e]}function Bn(e,t,n){let o,s;if(typeof e=="string"){const i=Ke(e);if(!i)return n(void 0,424),pt;s=i.send;const a=Un(e);a&&(o=a.redundancy)}else{const i=Ye(e);if(i){o=Lt(i);const a=e.resources?e.resources[0]:"",l=Ke(a);l&&(s=l.send)}}return!o||!s?(n(void 0,424),pt):o.query(t,s,n)().abort}function ht(){}function qn(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,En(e)}))}function Rn(e){const t=[],n=[];return e.forEach(o=>{(o.match(Pt)?t:n).push(o)}),{valid:t,invalid:n}}function ke(e,t,n){function o(){const s=e.pendingIcons;t.forEach(i=>{s&&s.delete(i),e.icons[i]||e.missing.add(i)})}if(n&&typeof n=="object")try{if(!_t(e,n).length){o();return}}catch(s){console.error(s)}o(),qn(e)}function mt(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function Hn(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:n,prefix:o}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const i=e.loadIcon;if(e.loadIcons&&(s.length>1||!i)){mt(e.loadIcons(s,o,n),f=>{ke(e,s,f)});return}if(i){s.forEach(f=>{const g=i(f,o,n);mt(g,w=>{const h=w?{prefix:o,icons:{[f]:w}}:null;ke(e,[f],h)})});return}const{valid:a,invalid:l}=Rn(s);if(l.length&&ke(e,l,null),!a.length)return;const c=o.match(Pt)?Ke(n):null;if(!c){ke(e,a,null);return}c.prepare(n,o,a).forEach(f=>{Bn(n,f,g=>{ke(e,f.icons,g)})})}))}const zn=(e,t)=>{const n=Ln(e,!0,Et()),o=On(n);if(!o.pending.length){let c=!0;return t&&setTimeout(()=>{c&&t(o.loaded,o.missing,o.pending,ht)}),()=>{c=!1}}const s=Object.create(null),i=[];let a,l;return o.pending.forEach(c=>{const{provider:d,prefix:f}=c;if(f===l&&d===a)return;a=d,l=f,i.push(ve(d,f));const g=s[d]||(s[d]=Object.create(null));g[f]||(g[f]=[])}),o.pending.forEach(c=>{const{provider:d,prefix:f,name:g}=c,w=ve(d,f),h=w.pendingIcons||(w.pendingIcons=new Set);h.has(g)||(h.add(g),s[d][f].push(g))}),i.forEach(c=>{const d=s[c.provider][c.prefix];d.length&&Hn(c,d)}),t?An(t,o,i):ht};function Vn(e,t){const n={...e};for(const o in t){const s=t[o],i=typeof s;o in $t?(s===null||s&&(i==="string"||i==="number"))&&(n[o]=s):i===typeof n[o]&&(n[o]=o==="rotate"?s%4:s)}return n}const Jn=/[\s,]+/;function Kn(e,t){t.split(Jn).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function Gn(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function o(s){for(;s<0;)s+=4;return s%4}if(n===""){const s=parseInt(e);return isNaN(s)?0:o(s)}else if(n!==e){let s=0;switch(n){case"%":s=25;break;case"deg":s=90}if(s){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i=i/s,i%1===0?o(i):0)}}return t}function Wn(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const o in t)n+=" "+o+'="'+t[o]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function Qn(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Yn(e){return"data:image/svg+xml,"+Qn(e)}function Zn(e){return'url("'+Yn(e)+'")'}let Ce;function Xn(){try{Ce=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{Ce=null}}function es(e){return Ce===void 0&&Xn(),Ce?Ce.createHTML(e):e}const Dt={...At,inline:!1},ts={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},ns={display:"inline-block"},Ge={backgroundColor:"currentColor"},Mt={backgroundColor:"transparent"},gt={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},xt={WebkitMask:Ge,mask:Ge,background:Mt};for(const e in xt){const t=xt[e];for(const n in gt)t[e+n]=gt[n]}const ss={...Dt,inline:!0};function yt(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const os=(e,t,n)=>{const o=t.inline?ss:Dt,s=Vn(o,t),i=t.mode||"svg",a={},l=t.style||{},c={...i==="svg"?ts:{}};if(n){const p=Me(n,!1,!0);if(p){const b=["iconify"],O=["provider","prefix"];for(const E of O)p[E]&&b.push("iconify--"+p[E]);c.className=b.join(" ")}}for(let p in t){const b=t[p];if(b!==void 0)switch(p){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":c.ref=b;break;case"className":c[p]=(c[p]?c[p]+" ":"")+b;break;case"inline":case"hFlip":case"vFlip":s[p]=b===!0||b==="true"||b===1;break;case"flip":typeof b=="string"&&Kn(s,b);break;case"color":a.color=b;break;case"rotate":typeof b=="string"?s[p]=Gn(b):typeof b=="number"&&(s[p]=b);break;case"ariaHidden":case"aria-hidden":b!==!0&&b!=="true"&&delete c["aria-hidden"];break;default:o[p]===void 0&&(c[p]=b)}}const d=yn(e,s),f=d.attributes;if(s.inline&&(a.verticalAlign="-0.125em"),i==="svg"){c.style={...a,...l},Object.assign(c,f);let p=0,b=t.id;return typeof b=="string"&&(b=b.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:es(jn(d.body,b?()=>b+"ID"+p++:"iconifyReact"))},S.createElement("svg",c)}const{body:g,width:w,height:h}=e,j=i==="mask"||(i==="bg"?!1:g.indexOf("currentColor")!==-1),T=Wn(g,{...f,width:w+"",height:h+""});return c.style={...a,"--svg":Zn(T),width:yt(f.width),height:yt(f.height),...ns,...j?Ge:Mt,...l},S.createElement("span",c)};Et(!0);Sn("",Pn);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="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"||!dn(o))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const o="IconifyProviders["+n+"] is invalid.";try{const s=t[n];if(typeof s!="object"||!s||s.resources===void 0)continue;kn(n,s)||console.error(o)}catch{console.error(o)}}}}function Ut(e){const[t,n]=S.useState(!!e.ssr),[o,s]=S.useState({});function i(h){if(h){const j=e.icon;if(typeof j=="object")return{name:"",data:j};const T=ut(j);if(T)return{name:j,data:T}}return{name:""}}const[a,l]=S.useState(i(!!e.ssr));function c(){const h=o.callback;h&&(h(),s({}))}function d(h){if(JSON.stringify(a)!==JSON.stringify(h))return c(),l(h),!0}function f(){var h;const j=e.icon;if(typeof j=="object"){d({name:"",data:j});return}const T=ut(j);if(d({name:j,data:T}))if(T===void 0){const p=zn([j],f);s({callback:p})}else T&&((h=e.onLoad)===null||h===void 0||h.call(e,j))}S.useEffect(()=>(n(!0),c),[]),S.useEffect(()=>{t&&f()},[e.icon,t]);const{name:g,data:w}=a;return w?os({...Qe,...w},e,g):e.children?e.children:e.fallback?e.fallback:S.createElement("span",{})}const wt=S.forwardRef((e,t)=>Ut({...e,_ref:t}));S.forwardRef((e,t)=>Ut({inline:!0,...e,_ref:t}));const rs={product:null},Bt=Qt.createSlice({name:"product",initialState:rs,reducers:{setProduct:(e,t)=>{e.product=t.payload}}}),{setProduct:We}=Bt.actions;Bt.reducer;function is(){const e=()=>window.innerWidth<425?1:window.innerWidth<768?2:4,[t,n]=S.useState(e);return S.useEffect(()=>{const o=()=>n(e());return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),t}const as=({product:e})=>{const t=ye.useDispatch(),n=is(),[o,s]=S.useState(0),i=()=>{s(c=>c+n>=e.length?0:c+n)},a=()=>{s(c=>c-n<0?e.length-(e.length%n||n):c-n)},l=async c=>{const d=await Ct(c);t(We(d))};return r.jsx("div",{className:"mt-2 overflow-x-hidden",children:r.jsxs("div",{className:"flex items-center justify-center gap-4 relative",children:[(e==null?void 0:e.length)>n&&r.jsx("button",{onClick:a,className:"absolute z-50 left-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit",children:r.jsx(wt,{icon:"mdi:chevron-left",width:"25"})}),r.jsx("div",{className:"flex gap-5 justify-center flex-1 overflow-hidden",children:e.slice(o,o+n).map(c=>{var d,f,g,w;return r.jsxs("div",{className:"flex-shrink-0 flex flex-col w-[150px] h-[200px] p-2 items-center justify-between cursor-pointer bg-[#FFFFFF] rounded-[10px] shadow-[0px_2px_2px_0px_#9292BC40]",onClick:()=>{l(c.product_id??c.productId)},children:[r.jsx("div",{className:"w-full p-2 flex items-center justify-center bg-white",children:r.jsx("img",{src:((d=rt(c)[0])==null?void 0:d.link)||rt(c)[0]||"https://via.placeholder.com/120",alt:c!=null&&c.productName?c.productName:"Product",className:"w-28 h-28 rounded-[10px] transition-transform duration-300 hover:scale-125 object-cover"})}),r.jsxs("div",{className:"text-white w-full p-2 text-[12px] text-center h-[60px]",children:[r.jsxs("div",{className:"relative inline-block group",children:[r.jsx("div",{className:"w-full line-clamp-1 overflow-hidden text-ellipsis text-[#000000] font-medium font-nunitoSans",children:c!=null&&c.productName?c.productName:c!=null&&c.product_name?c.product_name:at(ot((f=c==null?void 0:c.name)==null?void 0:f["en-US"]),60)||"Product"}),r.jsx("div",{className:"absolute left-0 top-full mt-1 w-max max-w-[200px] p-2 bg-white shadow-lg text-black text-xs rounded opacity-0 transition-opacity duration-300 group-hover:opacity-100 z-50 pointer-events-auto",style:{position:"absolute",top:"-100%",left:"0",marginBottom:"5px",zIndex:50},children:c!=null&&c.productName?c.productName:c!=null&&c.product_name?c.product_name:at(ot((g=c==null?void 0:c.name)==null?void 0:g["en-US"]),60)||"Product"})]}),r.jsxs("div",{className:" flex text-center items-center gap-2 text-[14px] text-[#14121F] font-bold font-nunitoSans text-base mb-1",children:[r.jsx("p",{children:tn(c!=null&&c.price?Number(c==null?void 0:c.price):it(c).centAmount||0,(w=it(c))==null?void 0:w.currencyCode)}),r.jsxs("p",{className:"text-[#14121F] font-normal line-through text-sm font-nunitoSans truncate",children:["$",Number(c==null?void 0:c.price).toFixed(2)??5]})]})]})]},c.productId)})}),(e==null?void 0:e.length)>n&&r.jsx("button",{onClick:i,className:"absolute z-50 right-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit",children:r.jsx(wt,{icon:"mdi:chevron-right",width:"25"})})]})})},cs=({chat:e,storeDetails:t})=>r.jsx("div",{className:"bg-[#FFFFFF] px-7 py-4 rounded-r-xl rounded-bl-2xl w-full",children:e.map((n,o)=>r.jsxs("div",{className:"mb-4 p-3 rounded-xl",style:{background:"linear-gradient(109.52deg, #F0EEF5 36.91%, #F4F3EE 100.34%"},children:[r.jsx("div",{className:"font-nunitoSans font-bold text-sm text-[#494949] p-2 w-fit rounded-[20px]",children:nn(n.keyword)||"No keyword"}),r.jsx(as,{product:n.items,storeDetails:t})]},o))}),qt=async(e,t)=>{const{serverUrl:n,basePath:o}=de(),s=`${n}`;console.log(`customer_token
2
- `,e);try{return(await L.post(`${s}${o}/basket/create?baseUrl=${re()}&siteId=${Z()}&pubCfg=${ie()}&envRef=${ae()}&orgRef=${ce()}`,t,{headers:{"Content-Type":"application/json",Authorization:e}})).data}catch(i){return L.isAxiosError(i)?console.error("Error creating basket:",i.response||i.message):console.error("Unexpected error:",i),null}},Oe=async(e,t,n)=>{const{serverUrl:o,basePath:s}=de(),i=`${o}`;try{const a=await L.post(`${i}${s}/basket/add-product/${e}?baseUrl=${re()}&siteId=${Z()}&pubCfg=${ie()}&envRef=${ae()}&orgRef=${ce()}`,t,{headers:{"Content-Type":"application/json",Authorization:n}});return a.status===200&&a.data?a.data:null}catch(a){return L.isAxiosError(a)?console.error("Error adding products to basket:",a.response||a.message):console.error("Unexpected error:",a),null}},Rt=async({basketId:e,customer_token:t})=>{var i;const{serverUrl:n,basePath:o}=de(),s=`${n}`;try{const a=await L.get(`${s}${o}/basket/${e}?baseUrl=${re()}&siteId=${Z()}&pubCfg=${ie()}&envRef=${ae()}&orgRef=${ce()}`,{headers:{"Content-Type":"application/json",Authorization:t}});return{status:a.status,data:a.data}}catch(a){return L.isAxiosError(a)?{status:(i=a.response)==null?void 0:i.status,data:null}:{status:null,data:null}}},bt="sfcc_basket_id",vt="sfcc_customer_token",Ne="sfcc_token_expiry",ls=300*1e3,Ie="1.0.0";const be=e=>{try{e?localStorage.setItem(bt,e):localStorage.removeItem(bt)}catch(t){console.error("Error saving basket ID to storage:",t)}},Le=e=>{try{if(e){localStorage.setItem(vt,e);const t=Date.now()+ls;localStorage.setItem(Ne,t.toString())}else localStorage.removeItem(vt)}catch(t){console.error("Error storing token:",t)}},jt=300,us=()=>{var l,c,d,f,g,w;const e=ye.useDispatch(),t=ye.useSelector(h=>h.product.product),n=ye.useSelector(h=>h.store.store),[o,s]=S.useState(!!t);if(S.useEffect(()=>{s(!!t)},[t]),!t)return null;const i=async()=>{var h,j,T,p,b,O,E,P,G,I,$,R,W,D,M,fe;console.log(t,"the prod");try{if(!((j=(h=t==null?void 0:t.variants)==null?void 0:h[0])!=null&&j.product_id)&&!(t.type.item||t.type.bundle)&&!((p=(T=t==null?void 0:t.variants)==null?void 0:T[0])!=null&&p.productId)){K.toast.error("Variants not available",{position:"bottom-right",autoClose:1e3}),console.error("No product variant found");return}const m=[{product_id:((b=t.variants)==null?void 0:b[0].product_id)||((O=t.variants)==null?void 0:O[0].productId)||(t==null?void 0:t.id),quantity:1}];console.log(m,"the product data");const je=JSON.parse(sessionStorage.getItem("customerData")||"{}"),le=je==null?void 0:je.basketId,Ue=!1,Te=localStorage.getItem(Ne),X=Date.now();if(!Ue||!Te||X>=parseInt(Te)){let B="";{const te=await De();console.log("token from auth data"),B="Bearer "+te.access_token}if(!B){console.error("Failed to get customer_token");return}const _e=X+300*1e3;if(Le(B),localStorage.setItem(Ne,_e.toString()),le){const te=await Rt({basketId:le,customer_token:B});if(console.log(le,"basket id from customer"),te.status===200&&te){const ne=await Oe(le,m,B);(((E=ne==null?void 0:ne.product_items)==null?void 0:E.length)>0||((P=ne==null?void 0:ne.productItems)==null?void 0:P.length)>0)&&(K.toast.success("Added to cart",{position:"bottom-right",autoClose:3e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0}),we(le));return}}const Be={productItems:[{productId:((G=t.variants)==null?void 0:G[0].product_id)||((I=t.variants)==null?void 0:I[0].productId)||(t==null?void 0:t.id),quantity:1}]};console.log("before create basket");const y=await qt(B,Be);if(console.log(y,y==null?void 0:y.basket_id,y==null?void 0:y.basketId,"the basket response"),!(y!=null&&y.basket_id)&&!(y!=null&&y.basketId)){console.error("Failed to create basket");return}console.log("setting stored id",(y==null?void 0:y.basket_id)||(y==null?void 0:y.basketId)),be((y==null?void 0:y.basket_id)||(y==null?void 0:y.basketId)),console.log("adding product to basket");const ee=await Oe((y==null?void 0:y.basket_id)||(y==null?void 0:y.basketId),m,B);console.log("object added to basket"),((($=ee==null?void 0:ee.product_items)==null?void 0:$.length)>0||((R=ee==null?void 0:ee.productItems)==null?void 0:R.length)>0)&&K.toast.success("Added to cart",{position:"bottom-right",autoClose:3e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0}),we(y.basket_id||(y==null?void 0:y.basketId))}}catch(m){console.error("Error adding to cart:",m),K.toast.error("Failed to add product to cart",{position:"bottom-right",autoClose:3e3}),((W=m==null?void 0:m.response)==null?void 0:W.status)===404||((D=m==null?void 0:m.response)==null?void 0:D.status)===401?(((M=m==null?void 0:m.response)==null?void 0:M.status)===404&&be(null),((fe=m==null?void 0:m.response)==null?void 0:fe.status)===401&&(be(null),Le(null))):(console.error("Failed to add product to basket:",m.message),K.toast.error("Failed to add product to cart",{position:"bottom-right",autoClose:3e3}))}finally{we()}},a=()=>{t&&(window.location.href=t.c_pdpUrl)};return console.log(t,"the prod"),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-40 bg-black/30",onClick:()=>{s(!1),setTimeout(()=>e(We(null)),jt)}}),r.jsxs("div",{className:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),j=require("react"),Kt=require("@radix-ui/react-popover");require("clsx");require("tailwind-merge");const M=require("axios");require("crypto-js");const we=require("react-redux"),Gt=require("@reduxjs/toolkit"),nt=require("@iconify/react"),W=require("react-toastify");function Wt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const St=Wt(Kt),be=e=>{const t=new CustomEvent("reactCartUpdated",{detail:{cartUpdated:!0,basketId:e}});window.dispatchEvent(t)};function Qt({...e}){return r.jsx(St.Root,{"data-slot":"popover",...e})}function Yt({...e}){return r.jsx(St.Trigger,{"data-slot":"popover-trigger",...e})}const de=()=>({aiConversationUrl:"https://mdv3qwfi2j.execute-api.us-east-1.amazonaws.com/dev/api/bedrock/invoke/stream",xAPIKey:"BJBtjpPkqGatuoa3qJqdR8aHXSsHkgvGaootbubi",serverUrl:"https://tanya-sfcc-server.vercel.app/",basePath:"sc-api"}),kt=async()=>{const e="https://tanya-sfcc-server.vercel.app/";try{const t=await M.post(`${e}api/auth/token-bm-grant?baseUrl=${oe()}&siteId=${X()}`);return t.status===200&&t.data.access_token?t.data.access_token:(console.error("Failed to fetch token:",t.data),null)}catch(t){return M.isAxiosError(t)?console.error("Error fetching token:",t.response||t.message):console.error("Unexpected error:",t),null}},It=async e=>{const t="https://tanya-sfcc-server.vercel.app/";try{const n=JSON.parse(sessionStorage.getItem("customerData")||"{}").dwsid,o=await M.post(`${t}api/auth/token-existing-guest-customer?dwsid=${n}&baseUrl=${oe()}&siteId=${X()}&pubCfg=${re()}&envRef=${ie()}&orgRef=${ae()}`,{},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`}});return o.status===200&&o.data?o.data:null}catch(n){return M.isAxiosError(n)?console.error("Error creating basket:",n.response||n.message):console.error("Unexpected error:",n),null}};async function Le(){const e=localStorage.getItem("expires_in"),t=localStorage.getItem("access_token"),n=JSON.parse(sessionStorage.getItem("customerData")||"{}").isGuest;if(e&&t&&new Date().getTime()<parseInt(e)&&n===JSON.parse(localStorage.getItem("isGuest")||"false"))return console.log("access token found in local storage"),{access_token:t,expires_in:e};const{serverUrl:o}=de(),s=JSON.parse(sessionStorage.getItem("customerData")||"{}").dwsid,i=JSON.parse(sessionStorage.getItem("customerData")||"{}").usrRef;try{const a=n?"unregister-auth":"register-auth",l=await M.get(`${o}sc-api/${a}?dwsid=${s}&email=${i}&pubCfg=${re()}&envRef=${ie()}&orgRef=${ae()}&siteId=${X()}`);return localStorage.setItem("access_token",l.data.access_token),localStorage.setItem("expires_in",String(new Date().getTime()+l.data.expires_in*1e3)),localStorage.setItem("isGuest",n.toString()),console.log(l.data),l.data}catch(a){console.log(a)}}const oe=()=>sessionStorage.getItem("Host"),X=()=>sessionStorage.getItem("SiteId"),re=()=>sessionStorage.getItem("pubCfg"),ie=()=>sessionStorage.getItem("envRef"),ae=()=>sessionStorage.getItem("orgRef"),st=async(e,t)=>{const{serverUrl:n,basePath:o}=de();try{const s=oe();return(await M.get(`${n}${o}/search-sfcc?baseUrl=${s}&query=${e}&siteId=${X()}&pubCfg=${re()}&envRef=${ie()}&orgRef=${ae()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`}})).data.hits}catch(s){throw console.error("Error fetching search results:",s),s}},Ct=async e=>{if(!e)throw new Error("Product ID is required");const{serverUrl:t,basePath:n}=de(),o=oe();console.log("calling access");const{access_token:s}=await Le();return console.log(s),(await M.get(`${t}${n}/product-sfcc/${e}?baseUrl=${o}&siteId=${X()}&pubCfg=${re()}&envRef=${ie()}&orgRef=${ae()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`}})).data},Zt=async e=>{if(!e)throw new Error("customerId is required");const t=await kt(),{customer_token:n}=await It(t),{serverUrl:o,basePath:s}=de(),a=(await Le()).access_token;return(await M.get(`${o}${s}/get-interest?baseUrl=${oe()}&customerId=${e}&siteId=${X()}&pubCfg=${re()}&envRef=${ie()}&orgRef=${ae()}`,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`}})).data},ot=e=>String(typeof e=="string"?e:e["en-US"]||e),rt=e=>e!=null&&e.image?[e.image]:"variants"in e?e.variants[0].images:e.masterVariant.images.map(t=>t.url),Xt=(e,t)=>e.toLocaleString("en-US",{style:"currency",currency:t||"USD"}),it=e=>{var t,n,o;return"variants"in e?{centAmount:(t=e.variants[0])==null?void 0:t.prices.EUR.max,currencyCode:"DOL"}:{centAmount:(n=e.masterVariant)==null?void 0:n.prices[0].value.centAmount,currencyCode:(o=e.masterVariant)==null?void 0:o.prices[0].value.currencyCode}},en=e=>e.charAt(0).toUpperCase()+e.slice(1),at=(e,t)=>e.length<t?e:e.slice(0,t)+"...",Re=e=>e.split("\\n").map((t,n)=>{const o=t.match(/^(\d+)\.\s(.+)/);return o?`<p key=${n} class="mb-2"><strong>${o[1]}.</strong> ${o[2]}</p>`:t.trim()?`<p key=${n} class="mb-2">${t}</p>`:"<br/>"}).join("");function tn(e,t){const n=e.icons,o=e.aliases||Object.create(null),s=Object.create(null);function i(a){if(n[a])return s[a]=[];if(!(a in s)){s[a]=null;const l=o[a]&&o[a].parent,c=l&&i(l);c&&(s[a]=[l].concat(c))}return s[a]}return Object.keys(n).concat(Object.keys(o)).forEach(i),s}const Ft=Object.freeze({left:0,top:0,width:16,height:16}),$e=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Qe=Object.freeze({...Ft,...$e}),Ve=Object.freeze({...Qe,body:"",hidden:!1});function nn(e,t){const n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);const o=((e.rotate||0)+(t.rotate||0))%4;return o&&(n.rotate=o),n}function ct(e,t){const n=nn(e,t);for(const o in Ve)o in $e?o in e&&!(o in n)&&(n[o]=$e[o]):o in t?n[o]=t[o]:o in e&&(n[o]=e[o]);return n}function sn(e,t,n){const o=e.icons,s=e.aliases||Object.create(null);let i={};function a(l){i=ct(o[l]||s[l],i)}return a(t),n.forEach(a),ct(e,i)}function Nt(e,t){const n=[];if(typeof e!="object"||typeof e.icons!="object")return n;e.not_found instanceof Array&&e.not_found.forEach(s=>{t(s,null),n.push(s)});const o=tn(e);for(const s in o){const i=o[s];i&&(t(s,sn(e,s,i)),n.push(s))}return n}const on={provider:"",aliases:{},not_found:{},...Ft};function He(e,t){for(const n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function Tt(e){if(typeof e!="object"||e===null)return null;const t=e;if(typeof t.prefix!="string"||!e.icons||typeof e.icons!="object"||!He(e,on))return null;const n=t.icons;for(const s in n){const i=n[s];if(!s||typeof i.body!="string"||!He(i,Ve))return null}const o=t.aliases||Object.create(null);for(const s in o){const i=o[s],a=i.parent;if(!s||typeof a!="string"||!n[a]&&!o[a]||!He(i,Ve))return null}return t}const lt=Object.create(null);function rn(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function je(e,t){const n=lt[e]||(lt[e]=Object.create(null));return n[t]||(n[t]=rn(e,t))}function _t(e,t){return Tt(t)?Nt(t,(n,o)=>{o?e.icons[n]=o:e.missing.add(n)}):[]}function an(e,t,n){try{if(typeof n.body=="string")return e.icons[t]={...n},!0}catch{}return!1}const Pt=/^[a-z0-9]+(-[a-z0-9]+)*$/,De=(e,t,n,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 l=s.pop(),c=s.pop(),d={provider:s.length>0?s[0]:o,prefix:c,name:l};return t&&!Pe(d)?null:d}const i=s[0],a=i.split("-");if(a.length>1){const l={provider:o,prefix:a.shift(),name:a.join("-")};return t&&!Pe(l)?null:l}if(n&&o===""){const l={provider:o,prefix:"",name:i};return t&&!Pe(l,n)?null:l}return null},Pe=(e,t)=>e?!!((t&&e.prefix===""||e.prefix)&&e.name):!1;let Ne=!1;function Et(e){return typeof e=="boolean"&&(Ne=e),Ne}function ut(e){const t=typeof e=="string"?De(e,!0,Ne):e;if(t){const n=je(t.provider,t.prefix),o=t.name;return n.icons[o]||(n.missing.has(o)?null:void 0)}}function cn(e,t){const n=De(e,!0,Ne);if(!n)return!1;const o=je(n.provider,n.prefix);return t?an(o,n.name,t):(o.missing.add(n.name),!0)}function ln(e,t){if(typeof e!="object")return!1;if(typeof t!="string"&&(t=e.provider||""),Ne&&!t&&!e.prefix){let s=!1;return Tt(e)&&(e.prefix="",Nt(e,(i,a)=>{cn(i,a)&&(s=!0)})),s}const n=e.prefix;if(!Pe({prefix:n,name:"a"}))return!1;const o=je(t,n);return!!_t(o,e)}const $t=Object.freeze({width:null,height:null}),At=Object.freeze({...$t,...$e}),un=/(-?[0-9.]*[0-9]+[0-9.]*)/g,dn=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function dt(e,t,n){if(t===1)return e;if(n=n||100,typeof e=="number")return Math.ceil(e*t*n)/n;if(typeof e!="string")return e;const o=e.split(un);if(o===null||!o.length)return e;const s=[];let i=o.shift(),a=dn.test(i);for(;;){if(a){const l=parseFloat(i);isNaN(l)?s.push(i):s.push(Math.ceil(l*t*n)/n)}else s.push(i);if(i=o.shift(),i===void 0)return s.join("");a=!a}}function fn(e,t="defs"){let n="";const o=e.indexOf("<"+t);for(;o>=0;){const s=e.indexOf(">",o),i=e.indexOf("</"+t);if(s===-1||i===-1)break;const a=e.indexOf(">",i);if(a===-1)break;n+=e.slice(s+1,i).trim(),e=e.slice(0,o).trim()+e.slice(a+1)}return{defs:n,content:e}}function pn(e,t){return e?"<defs>"+e+"</defs>"+t:t}function hn(e,t,n){const o=fn(e);return pn(o.defs,t+o.content+n)}const mn=e=>e==="unset"||e==="undefined"||e==="none";function gn(e,t){const n={...Qe,...e},o={...At,...t},s={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,o].forEach(C=>{const h=[],b=C.hFlip,D=C.vFlip;let P=C.rotate;b?D?P+=2:(h.push("translate("+(s.width+s.left).toString()+" "+(0-s.top).toString()+")"),h.push("scale(-1 1)"),s.top=s.left=0):D&&(h.push("translate("+(0-s.left).toString()+" "+(s.height+s.top).toString()+")"),h.push("scale(1 -1)"),s.top=s.left=0);let A;switch(P<0&&(P-=Math.floor(P/4)*4),P=P%4,P){case 1:A=s.height/2+s.top,h.unshift("rotate(90 "+A.toString()+" "+A.toString()+")");break;case 2:h.unshift("rotate(180 "+(s.width/2+s.left).toString()+" "+(s.height/2+s.top).toString()+")");break;case 3:A=s.width/2+s.left,h.unshift("rotate(-90 "+A.toString()+" "+A.toString()+")");break}P%2===1&&(s.left!==s.top&&(A=s.left,s.left=s.top,s.top=A),s.width!==s.height&&(A=s.width,s.width=s.height,s.height=A)),h.length&&(i=hn(i,'<g transform="'+h.join(" ")+'">',"</g>"))});const a=o.width,l=o.height,c=s.width,d=s.height;let f,m;a===null?(m=l===null?"1em":l==="auto"?d:l,f=dt(m,c/d)):(f=a==="auto"?c:a,m=l===null?dt(f,d/c):l==="auto"?d:l);const w={},p=(C,h)=>{mn(h)||(w[C]=h.toString())};p("width",f),p("height",m);const v=[s.left,s.top,c,d];return w.viewBox=v.join(" "),{attributes:w,viewBox:v,body:i}}const xn=/\sid="(\S+)"/g,yn="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16);let wn=0;function bn(e,t=yn){const n=[];let o;for(;o=xn.exec(e);)n.push(o[1]);if(!n.length)return e;const s="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(i=>{const a=typeof t=="function"?t(i):t+(wn++).toString(),l=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+l+')([")]|\\.[a-z])',"g"),"$1"+a+s+"$3")}),e=e.replace(new RegExp(s,"g"),""),e}const Je=Object.create(null);function vn(e,t){Je[e]=t}function Ke(e){return Je[e]||Je[""]}function Ye(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 Ze=Object.create(null),ke=["https://api.simplesvg.com","https://api.unisvg.com"],Ee=[];for(;ke.length>0;)ke.length===1||Math.random()>.5?Ee.push(ke.shift()):Ee.push(ke.pop());Ze[""]=Ye({resources:["https://api.iconify.design"].concat(Ee)});function jn(e,t){const n=Ye(t);return n===null?!1:(Ze[e]=n,!0)}function Xe(e){return Ze[e]}const Sn=()=>{let e;try{if(e=fetch,typeof e=="function")return e}catch{}};let ft=Sn();function kn(e,t){const n=Xe(e);if(!n)return 0;let o;if(!n.maxURL)o=0;else{let s=0;n.resources.forEach(a=>{s=Math.max(s,a.length)});const i=t+".json?icons=";o=n.maxURL-s-n.path.length-i.length}return o}function In(e){return e===404}const Cn=(e,t,n)=>{const o=[],s=kn(e,t),i="icons";let a={type:i,provider:e,prefix:t,icons:[]},l=0;return n.forEach((c,d)=>{l+=c.length+1,l>=s&&d>0&&(o.push(a),a={type:i,provider:e,prefix:t,icons:[]},l=c.length),a.icons.push(c)}),o.push(a),o};function Fn(e){if(typeof e=="string"){const t=Xe(e);if(t)return t.path}return"/"}const Nn=(e,t,n)=>{if(!ft){n("abort",424);return}let o=Fn(t.provider);switch(t.type){case"icons":{const i=t.prefix,l=t.icons.join(","),c=new URLSearchParams({icons:l});o+=i+".json?"+c.toString();break}case"custom":{const i=t.uri;o+=i.slice(0,1)==="/"?i.slice(1):i;break}default:n("abort",400);return}let s=503;ft(e+o).then(i=>{const a=i.status;if(a!==200){setTimeout(()=>{n(In(a)?"abort":"next",a)});return}return s=501,i.json()}).then(i=>{if(typeof i!="object"||i===null){setTimeout(()=>{i===404?n("abort",i):n("next",s)});return}setTimeout(()=>{n("success",i)})}).catch(()=>{n("next",s)})},Tn={prepare:Cn,send:Nn};function Ot(e,t){e.forEach(n=>{const o=n.loaderCallbacks;o&&(n.loaderCallbacks=o.filter(s=>s.id!==t))})}function _n(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1;const o=e.provider,s=e.prefix;t.forEach(i=>{const a=i.icons,l=a.pending.length;a.pending=a.pending.filter(c=>{if(c.prefix!==s)return!0;const d=c.name;if(e.icons[d])a.loaded.push({provider:o,prefix:s,name:d});else if(e.missing.has(d))a.missing.push({provider:o,prefix:s,name:d});else return n=!0,!0;return!1}),a.pending.length!==l&&(n||Ot([e],i.id),i.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),i.abort))})}))}let Pn=0;function En(e,t,n){const o=Pn++,s=Ot.bind(null,n,o);if(!t.pending.length)return s;const i={id:o,icons:t,callback:e,abort:s};return n.forEach(a=>{(a.loaderCallbacks||(a.loaderCallbacks=[])).push(i)}),s}function $n(e){const t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((s,i)=>s.provider!==i.provider?s.provider.localeCompare(i.provider):s.prefix!==i.prefix?s.prefix.localeCompare(i.prefix):s.name.localeCompare(i.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 i=s.provider,a=s.prefix,l=s.name,c=n[i]||(n[i]=Object.create(null)),d=c[a]||(c[a]=je(i,a));let f;l in d.icons?f=t.loaded:a===""||d.missing.has(l)?f=t.missing:f=t.pending;const m={provider:i,prefix:a,name:l};f.push(m)}),t}function An(e,t=!0,n=!1){const o=[];return e.forEach(s=>{const i=typeof s=="string"?De(s,t,n):s;i&&o.push(i)}),o}const On={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Ln(e,t,n,o){const s=e.resources.length,i=e.random?Math.floor(Math.random()*s):e.index;let a;if(e.random){let S=e.resources.slice(0);for(a=[];S.length>1;){const L=Math.floor(Math.random()*S.length);a.push(S[L]),S=S.slice(0,L).concat(S.slice(L+1))}a=a.concat(S)}else a=e.resources.slice(i).concat(e.resources.slice(0,i));const l=Date.now();let c="pending",d=0,f,m=null,w=[],p=[];typeof o=="function"&&p.push(o);function v(){m&&(clearTimeout(m),m=null)}function C(){c==="pending"&&(c="aborted"),v(),w.forEach(S=>{S.status==="pending"&&(S.status="aborted")}),w=[]}function h(S,L){L&&(p=[]),typeof S=="function"&&p.push(S)}function b(){return{startTime:l,payload:t,status:c,queriesSent:d,queriesPending:w.length,subscribe:h,abort:C}}function D(){c="failed",p.forEach(S=>{S(void 0,f)})}function P(){w.forEach(S=>{S.status==="pending"&&(S.status="aborted")}),w=[]}function A(S,L,q){const R=L!=="success";switch(w=w.filter(E=>E!==S),c){case"pending":break;case"failed":if(R||!e.dataAfterTimeout)return;break;default:return}if(L==="abort"){f=q,D();return}if(R){f=q,w.length||(a.length?Q():D());return}if(v(),P(),!e.random){const E=e.resources.indexOf(S.resource);E!==-1&&E!==e.index&&(e.index=E)}c="completed",p.forEach(E=>{E(q)})}function Q(){if(c!=="pending")return;v();const S=a.shift();if(S===void 0){if(w.length){m=setTimeout(()=>{v(),c==="pending"&&(P(),D())},e.timeout);return}D();return}const L={status:"pending",resource:S,callback:(q,R)=>{A(L,q,R)}};w.push(L),d++,m=setTimeout(Q,e.rotate),n(S,t,L.callback)}return setTimeout(Q),b}function Lt(e){const t={...On,...e};let n=[];function o(){n=n.filter(l=>l().status==="pending")}function s(l,c,d){const f=Ln(t,l,c,(m,w)=>{o(),d&&d(m,w)});return n.push(f),f}function i(l){return n.find(c=>l(c))||null}return{query:s,find:i,setIndex:l=>{t.index=l},getIndex:()=>t.index,cleanup:o}}function pt(){}const ze=Object.create(null);function Dn(e){if(!ze[e]){const t=Xe(e);if(!t)return;const n=Lt(t),o={config:t,redundancy:n};ze[e]=o}return ze[e]}function Mn(e,t,n){let o,s;if(typeof e=="string"){const i=Ke(e);if(!i)return n(void 0,424),pt;s=i.send;const a=Dn(e);a&&(o=a.redundancy)}else{const i=Ye(e);if(i){o=Lt(i);const a=e.resources?e.resources[0]:"",l=Ke(a);l&&(s=l.send)}}return!o||!s?(n(void 0,424),pt):o.query(t,s,n)().abort}function ht(){}function Un(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,_n(e)}))}function Bn(e){const t=[],n=[];return e.forEach(o=>{(o.match(Pt)?t:n).push(o)}),{valid:t,invalid:n}}function Ie(e,t,n){function o(){const s=e.pendingIcons;t.forEach(i=>{s&&s.delete(i),e.icons[i]||e.missing.add(i)})}if(n&&typeof n=="object")try{if(!_t(e,n).length){o();return}}catch(s){console.error(s)}o(),Un(e)}function mt(e,t){e instanceof Promise?e.then(n=>{t(n)}).catch(()=>{t(null)}):t(e)}function qn(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:n,prefix:o}=e,s=e.iconsToLoad;if(delete e.iconsToLoad,!s||!s.length)return;const i=e.loadIcon;if(e.loadIcons&&(s.length>1||!i)){mt(e.loadIcons(s,o,n),f=>{Ie(e,s,f)});return}if(i){s.forEach(f=>{const m=i(f,o,n);mt(m,w=>{const p=w?{prefix:o,icons:{[f]:w}}:null;Ie(e,[f],p)})});return}const{valid:a,invalid:l}=Bn(s);if(l.length&&Ie(e,l,null),!a.length)return;const c=o.match(Pt)?Ke(n):null;if(!c){Ie(e,a,null);return}c.prepare(n,o,a).forEach(f=>{Mn(n,f,m=>{Ie(e,f.icons,m)})})}))}const Rn=(e,t)=>{const n=An(e,!0,Et()),o=$n(n);if(!o.pending.length){let c=!0;return t&&setTimeout(()=>{c&&t(o.loaded,o.missing,o.pending,ht)}),()=>{c=!1}}const s=Object.create(null),i=[];let a,l;return o.pending.forEach(c=>{const{provider:d,prefix:f}=c;if(f===l&&d===a)return;a=d,l=f,i.push(je(d,f));const m=s[d]||(s[d]=Object.create(null));m[f]||(m[f]=[])}),o.pending.forEach(c=>{const{provider:d,prefix:f,name:m}=c,w=je(d,f),p=w.pendingIcons||(w.pendingIcons=new Set);p.has(m)||(p.add(m),s[d][f].push(m))}),i.forEach(c=>{const d=s[c.provider][c.prefix];d.length&&qn(c,d)}),t?En(t,o,i):ht};function Hn(e,t){const n={...e};for(const o in t){const s=t[o],i=typeof s;o in $t?(s===null||s&&(i==="string"||i==="number"))&&(n[o]=s):i===typeof n[o]&&(n[o]=o==="rotate"?s%4:s)}return n}const zn=/[\s,]+/;function Vn(e,t){t.split(zn).forEach(n=>{switch(n.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0;break}})}function Jn(e,t=0){const n=e.replace(/^-?[0-9.]*/,"");function o(s){for(;s<0;)s+=4;return s%4}if(n===""){const s=parseInt(e);return isNaN(s)?0:o(s)}else if(n!==e){let s=0;switch(n){case"%":s=25;break;case"deg":s=90}if(s){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i=i/s,i%1===0?o(i):0)}}return t}function Kn(e,t){let n=e.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const o in t)n+=" "+o+'="'+t[o]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+e+"</svg>"}function Gn(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}function Wn(e){return"data:image/svg+xml,"+Gn(e)}function Qn(e){return'url("'+Wn(e)+'")'}let Fe;function Yn(){try{Fe=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch{Fe=null}}function Zn(e){return Fe===void 0&&Yn(),Fe?Fe.createHTML(e):e}const Dt={...At,inline:!1},Xn={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},es={display:"inline-block"},Ge={backgroundColor:"currentColor"},Mt={backgroundColor:"transparent"},gt={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},xt={WebkitMask:Ge,mask:Ge,background:Mt};for(const e in xt){const t=xt[e];for(const n in gt)t[e+n]=gt[n]}const ts={...Dt,inline:!0};function yt(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}const ns=(e,t,n)=>{const o=t.inline?ts:Dt,s=Hn(o,t),i=t.mode||"svg",a={},l=t.style||{},c={...i==="svg"?Xn:{}};if(n){const h=De(n,!1,!0);if(h){const b=["iconify"],D=["provider","prefix"];for(const P of D)h[P]&&b.push("iconify--"+h[P]);c.className=b.join(" ")}}for(let h in t){const b=t[h];if(b!==void 0)switch(h){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":case"fallback":break;case"_ref":c.ref=b;break;case"className":c[h]=(c[h]?c[h]+" ":"")+b;break;case"inline":case"hFlip":case"vFlip":s[h]=b===!0||b==="true"||b===1;break;case"flip":typeof b=="string"&&Vn(s,b);break;case"color":a.color=b;break;case"rotate":typeof b=="string"?s[h]=Jn(b):typeof b=="number"&&(s[h]=b);break;case"ariaHidden":case"aria-hidden":b!==!0&&b!=="true"&&delete c["aria-hidden"];break;default:o[h]===void 0&&(c[h]=b)}}const d=gn(e,s),f=d.attributes;if(s.inline&&(a.verticalAlign="-0.125em"),i==="svg"){c.style={...a,...l},Object.assign(c,f);let h=0,b=t.id;return typeof b=="string"&&(b=b.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:Zn(bn(d.body,b?()=>b+"ID"+h++:"iconifyReact"))},j.createElement("svg",c)}const{body:m,width:w,height:p}=e,v=i==="mask"||(i==="bg"?!1:m.indexOf("currentColor")!==-1),C=Kn(m,{...f,width:w+"",height:p+""});return c.style={...a,"--svg":Qn(C),width:yt(f.width),height:yt(f.height),...es,...v?Ge:Mt,...l},j.createElement("span",c)};Et(!0);vn("",Tn);if(typeof document<"u"&&typeof window<"u"){const e=window;if(e.IconifyPreload!==void 0){const t=e.IconifyPreload,n="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"||!ln(o))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){const t=e.IconifyProviders;if(typeof t=="object"&&t!==null)for(let n in t){const o="IconifyProviders["+n+"] is invalid.";try{const s=t[n];if(typeof s!="object"||!s||s.resources===void 0)continue;jn(n,s)||console.error(o)}catch{console.error(o)}}}}function Ut(e){const[t,n]=j.useState(!!e.ssr),[o,s]=j.useState({});function i(p){if(p){const v=e.icon;if(typeof v=="object")return{name:"",data:v};const C=ut(v);if(C)return{name:v,data:C}}return{name:""}}const[a,l]=j.useState(i(!!e.ssr));function c(){const p=o.callback;p&&(p(),s({}))}function d(p){if(JSON.stringify(a)!==JSON.stringify(p))return c(),l(p),!0}function f(){var p;const v=e.icon;if(typeof v=="object"){d({name:"",data:v});return}const C=ut(v);if(d({name:v,data:C}))if(C===void 0){const h=Rn([v],f);s({callback:h})}else C&&((p=e.onLoad)===null||p===void 0||p.call(e,v))}j.useEffect(()=>(n(!0),c),[]),j.useEffect(()=>{t&&f()},[e.icon,t]);const{name:m,data:w}=a;return w?ns({...Qe,...w},e,m):e.children?e.children:e.fallback?e.fallback:j.createElement("span",{})}const wt=j.forwardRef((e,t)=>Ut({...e,_ref:t}));j.forwardRef((e,t)=>Ut({inline:!0,...e,_ref:t}));const ss={product:null},Bt=Gt.createSlice({name:"product",initialState:ss,reducers:{setProduct:(e,t)=>{e.product=t.payload}}}),{setProduct:We}=Bt.actions;Bt.reducer;function os(){const e=()=>window.innerWidth<425?1:window.innerWidth<768?2:4,[t,n]=j.useState(e);return j.useEffect(()=>{const o=()=>n(e());return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),t}const rs=({product:e})=>{const t=we.useDispatch(),n=os(),[o,s]=j.useState(0),i=()=>{s(c=>c+n>=e.length?0:c+n)},a=()=>{s(c=>c-n<0?e.length-(e.length%n||n):c-n)},l=async c=>{const d=await Ct(c);t(We(d))};return r.jsx("div",{className:"mt-2 overflow-x-hidden",children:r.jsxs("div",{className:"flex items-center justify-center gap-4 relative",children:[(e==null?void 0:e.length)>n&&r.jsx("button",{onClick:a,className:"absolute z-50 left-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit",children:r.jsx(wt,{icon:"mdi:chevron-left",width:"25"})}),r.jsx("div",{className:"flex gap-5 justify-center flex-1 overflow-hidden",children:e.slice(o,o+n).map(c=>{var d,f,m,w;return r.jsxs("div",{className:"flex-shrink-0 flex flex-col w-[150px] h-[200px] p-2 items-center justify-between cursor-pointer bg-[#FFFFFF] rounded-[10px] shadow-[0px_2px_2px_0px_#9292BC40]",onClick:()=>{l(c.product_id??c.productId)},children:[r.jsx("div",{className:"w-full p-2 flex items-center justify-center bg-white",children:r.jsx("img",{src:((d=rt(c)[0])==null?void 0:d.link)||rt(c)[0]||"https://via.placeholder.com/120",alt:c!=null&&c.productName?c.productName:"Product",className:"w-28 h-28 rounded-[10px] transition-transform duration-300 hover:scale-125 object-cover"})}),r.jsxs("div",{className:"text-white w-full p-2 text-[12px] text-center h-[60px]",children:[r.jsxs("div",{className:"relative inline-block group",children:[r.jsx("div",{className:"w-full line-clamp-1 overflow-hidden text-ellipsis text-[#000000] font-medium font-nunitoSans",children:c!=null&&c.productName?c.productName:c!=null&&c.product_name?c.product_name:at(ot((f=c==null?void 0:c.name)==null?void 0:f["en-US"]),60)||"Product"}),r.jsx("div",{className:"absolute left-0 top-full mt-1 w-max max-w-[200px] p-2 bg-white shadow-lg text-black text-xs rounded opacity-0 transition-opacity duration-300 group-hover:opacity-100 z-50 pointer-events-auto",style:{position:"absolute",top:"-100%",left:"0",marginBottom:"5px",zIndex:50},children:c!=null&&c.productName?c.productName:c!=null&&c.product_name?c.product_name:at(ot((m=c==null?void 0:c.name)==null?void 0:m["en-US"]),60)||"Product"})]}),r.jsxs("div",{className:" flex text-center items-center gap-2 text-[14px] text-[#14121F] font-bold font-nunitoSans text-base mb-1",children:[r.jsx("p",{children:Xt(c!=null&&c.price?Number(c==null?void 0:c.price):it(c).centAmount||0,(w=it(c))==null?void 0:w.currencyCode)}),r.jsxs("p",{className:"text-[#14121F] font-normal line-through text-sm font-nunitoSans truncate",children:["$",Number(c==null?void 0:c.price).toFixed(2)??5]})]})]})]},c.productId)})}),(e==null?void 0:e.length)>n&&r.jsx("button",{onClick:i,className:"absolute z-50 right-0 text-[#000000] bg-[#ffffff] rounded-full p-2 flex items-center h-fit",children:r.jsx(wt,{icon:"mdi:chevron-right",width:"25"})})]})})},is=({chat:e,storeDetails:t})=>r.jsx("div",{className:"bg-[#FFFFFF] px-7 py-4 rounded-r-xl rounded-bl-2xl w-full",children:e.map((n,o)=>r.jsxs("div",{className:"mb-4 p-3 rounded-xl",style:{background:"linear-gradient(109.52deg, #F0EEF5 36.91%, #F4F3EE 100.34%"},children:[r.jsx("div",{className:"font-nunitoSans font-bold text-sm text-[#494949] p-2 w-fit rounded-[20px]",children:en(n.keyword)||"No keyword"}),r.jsx(rs,{product:n.items,storeDetails:t})]},o))}),qt=async(e,t)=>{const{serverUrl:n,basePath:o}=de(),s=`${n}`;console.log(`customer_token
2
+ `,e);try{return(await M.post(`${s}${o}/basket/create?baseUrl=${oe()}&siteId=${X()}&pubCfg=${re()}&envRef=${ie()}&orgRef=${ae()}`,t,{headers:{"Content-Type":"application/json",Authorization:e}})).data}catch(i){return M.isAxiosError(i)?console.error("Error creating basket:",i.response||i.message):console.error("Unexpected error:",i),null}},Ae=async(e,t,n)=>{const{serverUrl:o,basePath:s}=de(),i=`${o}`;try{const a=await M.post(`${i}${s}/basket/add-product/${e}?baseUrl=${oe()}&siteId=${X()}&pubCfg=${re()}&envRef=${ie()}&orgRef=${ae()}`,t,{headers:{"Content-Type":"application/json",Authorization:n}});return a.status===200&&a.data?a.data:null}catch(a){return M.isAxiosError(a)?console.error("Error adding products to basket:",a.response||a.message):console.error("Unexpected error:",a),null}},Rt=async({basketId:e,customer_token:t})=>{var i;const{serverUrl:n,basePath:o}=de(),s=`${n}`;try{const a=await M.get(`${s}${o}/basket/${e}?baseUrl=${oe()}&siteId=${X()}&pubCfg=${re()}&envRef=${ie()}&orgRef=${ae()}`,{headers:{"Content-Type":"application/json",Authorization:t}});return{status:a.status,data:a.data}}catch(a){return M.isAxiosError(a)?{status:(i=a.response)==null?void 0:i.status,data:null}:{status:null,data:null}}},bt="sfcc_basket_id",vt="sfcc_customer_token",Te="sfcc_token_expiry",as=300*1e3,Ce="1.0.0";const ve=e=>{try{e?localStorage.setItem(bt,e):localStorage.removeItem(bt)}catch(t){console.error("Error saving basket ID to storage:",t)}},Oe=e=>{try{if(e){localStorage.setItem(vt,e);const t=Date.now()+as;localStorage.setItem(Te,t.toString())}else localStorage.removeItem(vt)}catch(t){console.error("Error storing token:",t)}},jt=300,cs=()=>{var l,c,d,f,m,w;const e=we.useDispatch(),t=we.useSelector(p=>p.product.product),n=we.useSelector(p=>p.store.store),[o,s]=j.useState(!!t);if(j.useEffect(()=>{s(!!t)},[t]),!t)return null;const i=async()=>{var p,v,C,h,b,D,P,A,Q,S,L,q,R,E,fe,_;console.log(t,"the prod");try{if(!((v=(p=t==null?void 0:t.variants)==null?void 0:p[0])!=null&&v.product_id)&&!(t.type.item||t.type.bundle)&&!((h=(C=t==null?void 0:t.variants)==null?void 0:C[0])!=null&&h.productId)){W.toast.error("Variants not available",{position:"bottom-right",autoClose:1e3}),console.error("No product variant found");return}const $=[{product_id:((b=t.variants)==null?void 0:b[0].product_id)||((D=t.variants)==null?void 0:D[0].productId)||(t==null?void 0:t.id),quantity:1}];console.log($,"the product data");const Se=JSON.parse(sessionStorage.getItem("customerData")||"{}"),ce=Se==null?void 0:Se.basketId,Me=!1,ee=localStorage.getItem(Te),le=Date.now();if(!Me||!ee||le>=parseInt(ee)){let H="";{const pe=await Le();console.log("token from auth data"),H="Bearer "+pe.access_token}if(!H){console.error("Failed to get customer_token");return}const Ue=le+300*1e3;if(Oe(H),localStorage.setItem(Te,Ue.toString()),ce){const pe=await Rt({basketId:ce,customer_token:H});if(console.log(ce,"basket id from customer"),pe.status===200&&pe){const te=await Ae(ce,$,H);(((P=te==null?void 0:te.product_items)==null?void 0:P.length)>0||((A=te==null?void 0:te.productItems)==null?void 0:A.length)>0)&&(W.toast.success("Added to cart",{position:"bottom-right",autoClose:3e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0}),be(ce));return}}const Be={productItems:[{productId:((Q=t.variants)==null?void 0:Q[0].product_id)||((S=t.variants)==null?void 0:S[0].productId)||(t==null?void 0:t.id),quantity:1}]};console.log("before create basket");const x=await qt(H,Be);if(console.log(x,x==null?void 0:x.basket_id,x==null?void 0:x.basketId,"the basket response"),!(x!=null&&x.basket_id)&&!(x!=null&&x.basketId)){console.error("Failed to create basket");return}console.log("setting stored id",(x==null?void 0:x.basket_id)||(x==null?void 0:x.basketId)),ve((x==null?void 0:x.basket_id)||(x==null?void 0:x.basketId)),console.log("adding product to basket");const z=await Ae((x==null?void 0:x.basket_id)||(x==null?void 0:x.basketId),$,H);console.log("object added to basket"),(((L=z==null?void 0:z.product_items)==null?void 0:L.length)>0||((q=z==null?void 0:z.productItems)==null?void 0:q.length)>0)&&W.toast.success("Added to cart",{position:"bottom-right",autoClose:3e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0}),be(x.basket_id||(x==null?void 0:x.basketId))}}catch($){console.error("Error adding to cart:",$),W.toast.error("Failed to add product to cart",{position:"bottom-right",autoClose:3e3}),((R=$==null?void 0:$.response)==null?void 0:R.status)===404||((E=$==null?void 0:$.response)==null?void 0:E.status)===401?(((fe=$==null?void 0:$.response)==null?void 0:fe.status)===404&&ve(null),((_=$==null?void 0:$.response)==null?void 0:_.status)===401&&(ve(null),Oe(null))):(console.error("Failed to add product to basket:",$.message),W.toast.error("Failed to add product to cart",{position:"bottom-right",autoClose:3e3}))}finally{be()}},a=()=>{t&&(window.location.href=t.c_pdpUrl)};return console.log(t,"the prod"),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-40 bg-black/30",onClick:()=>{s(!1),setTimeout(()=>e(We(null)),jt)}}),r.jsxs("div",{className:`
3
3
  flex flex-col gap-2 items-center h-[90vh] absolute right-0 bottom-0 z-50 w-full md:w-1/2 md:h-[100vh] lg:w-1/2 lg:h-[100vh] shadow-xl p-2 border-l-2 bg-white border-gray-200 overflow-y-scroll
4
4
  transition-all duration-300
5
5
  ${o?"translate-y-0 md:translate-y-0 md:translate-x-0 opacity-100":"translate-y-full md:translate-y-0 md:translate-x-full opacity-0 pointer-events-none"}
6
- `,style:{willChange:"transform, opacity"},onClick:h=>h.stopPropagation(),children:[r.jsxs("div",{className:"mt-3 flex flex-row justify-between w-full ",children:[r.jsx("div",{children:r.jsx("p",{className:"text-[#000000] font-bold font-nunitoSans",children:t.name})}),r.jsx("div",{children:r.jsx(nt.Icon,{icon:"mdi:close",className:"text-[#555555] w-6 h-6 cursor-pointer",onClick:()=>{s(!1),setTimeout(()=>e(We(null)),jt)}})})]}),r.jsxs("div",{className:"flex flex-row gap-2 items-center flex-wrap",children:[r.jsx("div",{className:"flex flex-row items-center justify-center w-[120px] h-[120px] my-5",children:r.jsx("img",{src:(f=(d=(c=(l=t.imageGroups)==null?void 0:l[0])==null?void 0:c.images)==null?void 0:d[0])==null?void 0:f.link,alt:t.name,className:"rounded-[10px]"})}),r.jsx("div",{className:"flex flex-col items-center gap-2",children:t.imageGroups.slice(1,2).map(h=>h.images.slice(1,2).map(j=>r.jsx("img",{src:j.link,alt:t.name,className:"rounded-[10px] w-[60px] h-[60px]"},j.link)))})]}),r.jsxs("div",{className:"flex flex-row items-center justify-between w-full",children:[r.jsxs("div",{className:"flex flex-row items-center gap-2",children:[r.jsxs("p",{className:"text-[#14121F] font-bold font-nunitoSans",children:[" ","$",t.price.toFixed(2)]})," ",r.jsxs("p",{className:"text-[#14121F] font-normal line-through text-sm font-nunitoSans",children:[" ","$",(t.price+5).toFixed(2)]})]}),r.jsx("div",{children:r.jsx("p",{className:"text-[#EC5050] font-bold font-nunitoSans",children:t.discount})})]}),r.jsx("div",{className:"mt-2 w-full border-t-2 border-gray-200"}),r.jsxs("div",{className:"w-full text-left",children:[r.jsx("div",{className:"text-[#323135] font-bold font-nunitoSans mt-3 text-[14px]",children:"Product Details"}),r.jsx("div",{className:"text-[#68656E] font-normal font-nunitoSans text-xs pl-2 mt-3",dangerouslySetInnerHTML:{__html:t.short_description||t.longDescription}})]}),r.jsxs("div",{className:"mt-4 flex flex-col gap-2 w-full p-2",children:[r.jsx("div",{className:"flex flex-row items-center gap-2",children:r.jsxs("div",{className:"flex items-center gap-2 text-left font-nunitoSans",children:[r.jsxs("div",{className:"text-[#323135] font-bold",children:[((g=t==null?void 0:t.rating)==null?void 0:g.rate)||0," /"," ",r.jsx("span",{className:"text-[#68656E]",children:"5"})]}),r.jsx("div",{className:"text-[#323135] font-semibold text-sm",children:"Overall Rating"}),r.jsxs("div",{className:"text-[#68656E] font-semibold text-sm",children:[((w=t==null?void 0:t.rating)==null?void 0:w.count)||0," ratings"]})]})}),r.jsx("div",{className:"mt-2 flex flex-row items-center gap-2",children:Array.from({length:5}).map((h,j)=>{var T;return r.jsx(nt.Icon,{icon:"mdi:star",width:"20",height:"20",className:`text-yellow-500
7
- ${((T=t==null?void 0:t.rating)==null?void 0:T.rate)>j?"text-yellow-500":"text-gray-300"}
8
- `},j)})})]}),r.jsxs("div",{className:"flex flex-col items-center justify-between font-nunitoSans font-semibold w-5/6 text-black gap-2",style:{marginTop:"150px"},children:[r.jsx("button",{className:"rounded-[5px] shadow-sm text-[#FBFBFC] bg-[#6851C6] p-2 w-full text-center cursor-pointer",style:{backgroundColor:n.tanyaThemeColor},onClick:i,children:"Add to Cart"}),r.jsx("button",{className:"rounded-[5px] shadow-sm text-[#FBFBFC] bg-[#6851C6] p-2 w-full text-center cursor-pointer mb-16",style:{backgroundColor:n.tanyaThemeColor},onClick:a,children:"View more"})]})]})]})},ds=()=>{const e=["Myself","My Child","My Grandchild","Niece/Nephew","My Friends","Others"],t={Myself:"himself/herself","My Child":"his/her child","My Grandchild":"his/her grandchild","Niece/Nephew":"his/her niece/nephew","My Friends":"his/her friends",Others:"others"},n=S.useRef(null),o=S.useRef(null),s=S.useRef(null),i=S.useRef(null),[a,l]=S.useState(null),[c]=Wt.useSearchParams(),[d,f]=S.useState(c.get("shoppingassist")==="true"),[g,w]=S.useState(!1),[h,j]=S.useState(!1),[T,p]=S.useState(!1),[b,O]=S.useState(!1),[E,P]=S.useState(!1),[G,I]=S.useState(""),[$,R]=S.useState(""),W=u=>({id:u.id,title:u.name,image:u.image??"",price:u.price??0}),[D,M]=S.useState([]),fe=S.useRef(null),m=ye.useSelector(u=>u.store.store),je=ye.useSelector(u=>u.product.product),le=()=>{j(!0),setTimeout(()=>w(!0),10)},Ue=()=>{w(!1),setTimeout(()=>j(!1),300)};S.useEffect(()=>{d?le():Ue()},[d]);const Te=u=>{R(t[u])};S.useEffect(()=>{fe.current&&(fe.current.scrollTop+=150)},[D]);let X=null,B=null;const _e=async()=>{if(X&&B&&Date.now()<B)return X;try{const u="https://us-east-1lsr29ln3u.auth.us-east-1.amazoncognito.com/oauth2/token",_=new URLSearchParams({grant_type:"client_credentials",client_id:"4i8rd70sgt961tc4dhskgf08c",client_secret:"bnsfq1220loh2cn2cm2ttn8fdhdpt0u8m1fgj8vfk2rn61aurjg",scope:"default-m2m-resource-server-8xzfzo/read"}),C=await fetch(u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:_});if(!C.ok)throw new Error(`Token request failed! status: ${C.status}`);const N=await C.json();X=N.access_token;const v=N.expires_in||3600;return B=Date.now()+(v-60)*1e3,X}catch(u){return console.error("Error obtaining JWT token:",u),X=null,B=null,null}},Be=async()=>{const u=await De();u!=null&&l(u)};S.useEffect(()=>{Be(),console.log("scapi environment v1")},[]);const y=async()=>{const u=JSON.parse(sessionStorage.getItem("customerData")||"{}").customerId;return(await en(u||"")).c_interests},ee=async(u,_)=>{console.log("in secondary flow",Ie);const C=await y();if(console.log(C,"interests of customer",Ie),!!C)try{M(V=>V.map((Q,Y)=>Y===V.length-1?{...Q,secondaryLoading:!0}:Q));const N=await _e();if(!N)throw new Error("Failed to fetch token");const v=localStorage.getItem("customerNumber"),k=localStorage.getItem("isLoggedIn"),pe=`https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({registered:String(k||!1),userId:String(v||new Date().getTime())}).toString()}`,he=JSON.stringify({flowId:"Q166PR519W",flowAliasId:"HKFUVLWVH2",input:{loyaltyPoints:"",productName:u,productPoints:String(_||0),interests:C}}),H=await fetch(pe,{signal:AbortSignal.timeout(3e4),method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:he});if(!H.body)throw new Error("Readable stream not supported");const me=H.body.getReader(),ge=new TextDecoder;let z="";for(;;){const{done:V,value:Q}=await me.read();if(V)break;z+=ge.decode(Q,{stream:!0});const Y=z.split(`
9
- `);z=Y.pop()||"";for(const se of Y)if(se.startsWith("data:")){const x=se.slice(5).trim();try{const J=JSON.parse(x);J.index===0&&M(A=>A.map((U,oe)=>oe===A.length-1?{...U,secondaryResponse:J.data,secondaryLoading:!1}:U))}catch(J){M(A=>A.map((U,oe)=>oe===A.length-1?{...U,secondaryLoading:!1}:U)),console.error("Secondary flow JSON parse error:",J)}}}}catch(N){console.error("Secondary flow error:",N)}},te=async u=>{const _=u||G.trim();if(_){O(!0),I(""),n.current=null,o.current=null,s.current=null,i.current=null,M(C=>[...C,{query:_,response:"Thinking for what suits you best...",potentialQuestions:"",products:[],keywords:"Thinking for best products..."}]);try{const C=$,N=localStorage.getItem("customerNumber"),v=localStorage.getItem("isLoggedIn"),k=await _e();if(!k)throw new Error("Failed to obtain access token");const pe=`https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({registered:String(v||!1),userId:String(N||new Date().getTime())}).toString()}`,he=JSON.stringify({flowId:"MMHQKYI1NE",flowAliasId:"SZF9ZK1ATE",input:{userPrompt:_,whom:C}}),H=await fetch(pe,{signal:AbortSignal.timeout(3e4),method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${k}`},body:he});if(!H.ok)throw new Error(`HTTP error! status: ${H.status}`);if(!H.body)throw new Error("Readable stream not supported");const me=H.body.getReader(),ge=new TextDecoder;let z="",V="";for(;;){P(!0);const{done:Q,value:Y}=await me.read();if(Q)break;z+=ge.decode(Y,{stream:!0});const se=z.split(`
10
- `);z=se.pop()||"";for(const x of se)if(x.startsWith("data:")){const J=x.slice(5).trim();try{const A=JSON.parse(J);A.index==1&&(V=A.data),M(U=>U.map((oe,Pe)=>Pe===U.length-1?{...oe,[A.index==0?"response":A.index==1?"keywords":A.index==2?"potentialQuestions":"end"]:A.data}:oe))}catch(A){console.error("Error parsing JSON:",A)}}}Ht(ne(V))}catch(C){console.error("Error sending message to Tanya:",C)}finally{O(!1)}}},ne=u=>{const _=u.match(/top five relevant product or category names are: (.*)/i),v=(_?_[1]:u).split(", ").map(q=>q.replace(/\s*(Toys|Bags|Miniature|etc\.*)\s*/gi,"").trim());return[...new Set(v)].filter(Boolean).join(",")},Ht=async u=>{if(console.log(a==null?void 0:a.access_token,"access_token"),typeof u=="string"){console.log(u,"keywords");const _=u.split(",");for(const C of _){const N=await st(C,a==null?void 0:a.access_token);if(P(!1),(N==null?void 0:N.length)>0&&(M(v=>v.map((k,q)=>q===v.length-1?{...k,products:[...k.products||[],{keyword:C,items:N,loading:!1}]}:k)),!n.current||o.current==null)){const v=N[0];n.current=String((v==null?void 0:v.product_name)??""),s.current=v.image.link,o.current=v.product_id;const k=typeof(v==null?void 0:v.price)=="number"?v.price:void 0;i.current=typeof k=="number"&&Number.isFinite(k)?k:null}}}else for(const _ of u){const C=await st(_,a==null?void 0:a.access_token);P(!1),(C==null?void 0:C.length)>0&&M(N=>N.map((v,k)=>k===N.length-1?{...v,products:[...v.products||[],{keyword:_,items:C,loading:!1}]}:v))}if(n.current){M(C=>C.map((N,v)=>v===C.length-1?{...N,productSnapshot:{id:o.current,name:n.current,image:s.current,price:i.current??null,points:0,quantity:1}}:N));const _=JSON.parse(sessionStorage.getItem("customerData")||"{}");(_==null?void 0:_.isGuest)==!1?(console.log("running secondary flow",Ie),ee(n.current,0)):console.log("not running secondary flow",Ie)}P(!1)},zt=async(u,_)=>{var C,N,v,k,q,pe,he,H,me,ge,z,V,Q,Y,se;p(!0);try{const x=await Ct(u.id);if(!((N=(C=x==null?void 0:x.variants)==null?void 0:C[0])!=null&&N.product_id||(k=(v=x==null?void 0:x.variants)==null?void 0:v[0])!=null&&k.productId)&&!(x.type.item||x.type.bundle)){p(!1),K.toast.error("Variants not found",{position:"bottom-right",autoClose:1e3}),console.error("No product variant found");return}const J=[{product_id:((q=x.variants)==null?void 0:q[0].product_id)||((pe=x.variants)==null?void 0:pe[0].productId)||(x==null?void 0:x.id),quantity:_}];console.log(J,"product data","app version",Ie);const A=JSON.parse(sessionStorage.getItem("customerData")||"{}"),U=A==null?void 0:A.basketId,oe=!1,Pe=localStorage.getItem(Ne),et=Date.now();if(!oe||!Pe||et>=parseInt(Pe)){const Vt=await kt();let{customer_token:ue}=await It(Vt);if(ue="Bearer "+a.access_token,!ue){console.error("Failed to get customer_token");return}const Jt=et+300*1e3;if(Le(ue),localStorage.setItem(Ne,Jt.toString()),U){const tt=await Rt({basketId:U,customer_token:ue});if(tt.status===200&&tt){const qe=await Oe(U,J,ue);((he=qe==null?void 0:qe.product_items)==null?void 0:he.length)>0&&(K.toast.success("Added to cart",{position:"bottom-right",autoClose:3e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0}),we(U),p(!1));return}}const Kt={productItems:[{productId:((H=x.variants)==null?void 0:H[0].product_id)||((me=x.variants)==null?void 0:me[0].productId)||(x==null?void 0:x.id),quantity:1}]},F=await qt(ue,Kt);if(console.log(F,F==null?void 0:F.basket_id,F==null?void 0:F.basketId,"the basket response"),!(F!=null&&F.basket_id||!(F!=null&&F.basketId))){p(!1),console.error("Failed to create basket");return}be((F==null?void 0:F.basket_id)||(F==null?void 0:F.basketId));const xe=await Oe((F==null?void 0:F.basket_id)||(F==null?void 0:F.basketId),J,ue);(((ge=xe==null?void 0:xe.product_items)==null?void 0:ge.length)>0||((z=xe==null?void 0:xe.productItems)==null?void 0:z.length)>0)&&K.toast.success("Added to cart",{position:"bottom-right",autoClose:3e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0}),we(F.basket_id||(F==null?void 0:F.basketId))}}catch(x){p(!1),console.error("Error adding to cart:",x),K.toast.error("Failed to add product to cart",{position:"bottom-right",autoClose:3e3}),((V=x==null?void 0:x.response)==null?void 0:V.status)===404||((Q=x==null?void 0:x.response)==null?void 0:Q.status)===401?(((Y=x==null?void 0:x.response)==null?void 0:Y.status)===404&&be(null),((se=x==null?void 0:x.response)==null?void 0:se.status)===401&&(be(null),Le(null))):(console.error("Failed to add product to basket:",x.message),K.toast.error("Failed to add product to cart",{position:"bottom-right",autoClose:3e3}))}finally{we()}p(!1)};return r.jsx("div",{className:"relative flex justify-center",children:r.jsxs(Zt,{open:d,onOpenChange:f,children:[r.jsx(Xt,{onClick:()=>f(!0),style:{},className:"flex items-center rounded-lg cursor-pointer hover:opacity-90 transition-opacity",children:r.jsx("div",{className:"flex flex-col p-[5px]",children:r.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsxs("g",{clipPath:"url(#clip0_958_585)",children:[r.jsx("path",{d:"M30.0002 5C31.7683 5 33.464 5.70238 34.7142 6.95262C35.9644 8.20286 36.6668 9.89856 36.6668 11.6667V25C36.6668 26.7681 35.9644 28.4638 34.7142 29.714C33.464 30.9643 31.7683 31.6667 30.0002 31.6667H25.6902L21.1785 36.1783C20.8915 36.4653 20.5097 36.6377 20.1046 36.6631C19.6996 36.6886 19.2992 36.5654 18.9785 36.3167L18.8218 36.1783L14.3085 31.6667H10.0002C8.28976 31.6667 6.64478 31.0093 5.40548 29.8305C4.16617 28.6516 3.42735 27.0416 3.34183 25.3333L3.3335 25V11.6667C3.3335 9.89856 4.03588 8.20286 5.28612 6.95262C6.53636 5.70238 8.23205 5 10.0002 5H30.0002Z",fill:"url(#paint0_linear_958_585)"}),r.jsx("path",{d:"M28.3335 15.6511V11.6667C28.3335 11.6667 22.2774 12.6042 20.1148 15.4167C17.9521 18.2292 18.6644 26.6667 18.6644 26.6667H22.5321C22.5321 26.6667 22.0614 18.9323 23.4989 17.2917C24.9364 15.6511 28.3335 15.6511 28.3335 15.6511Z",fill:"white"}),r.jsx("path",{d:"M13.3335 11.6667H19.6184V15.4167H13.3335V11.6667Z",fill:"white"})]}),r.jsxs("defs",{children:[r.jsxs("linearGradient",{id:"paint0_linear_958_585",x1:"20.0002",y1:"5",x2:"35.0002",y2:"30",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#452697"}),r.jsx("stop",{offset:"1",stopColor:"#7C5BFF"})]}),r.jsx("clipPath",{id:"clip0_958_585",children:r.jsx("rect",{width:"40",height:"40",fill:"white"})})]})]})})}),h&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-40 bg-black/30",onClick:()=>f(!1)}),r.jsxs("div",{className:`
6
+ `,style:{willChange:"transform, opacity"},onClick:p=>p.stopPropagation(),children:[r.jsxs("div",{className:"mt-3 flex flex-row justify-between w-full ",children:[r.jsx("div",{children:r.jsx("p",{className:"text-[#000000] font-bold font-nunitoSans",children:t.name})}),r.jsx("div",{children:r.jsx(nt.Icon,{icon:"mdi:close",className:"text-[#555555] w-6 h-6 cursor-pointer",onClick:()=>{s(!1),setTimeout(()=>e(We(null)),jt)}})})]}),r.jsxs("div",{className:"flex flex-row gap-2 items-center flex-wrap",children:[r.jsx("div",{className:"flex flex-row items-center justify-center w-[120px] h-[120px] my-5",children:r.jsx("img",{src:(f=(d=(c=(l=t.imageGroups)==null?void 0:l[0])==null?void 0:c.images)==null?void 0:d[0])==null?void 0:f.link,alt:t.name,className:"rounded-[10px]"})}),r.jsx("div",{className:"flex flex-col items-center gap-2",children:t.imageGroups.slice(1,2).map(p=>p.images.slice(1,2).map(v=>r.jsx("img",{src:v.link,alt:t.name,className:"rounded-[10px] w-[60px] h-[60px]"},v.link)))})]}),r.jsxs("div",{className:"flex flex-row items-center justify-between w-full",children:[r.jsxs("div",{className:"flex flex-row items-center gap-2",children:[r.jsxs("p",{className:"text-[#14121F] font-bold font-nunitoSans",children:[" ","$",t.price.toFixed(2)]})," ",r.jsxs("p",{className:"text-[#14121F] font-normal line-through text-sm font-nunitoSans",children:[" ","$",(t.price+5).toFixed(2)]})]}),r.jsx("div",{children:r.jsx("p",{className:"text-[#EC5050] font-bold font-nunitoSans",children:t.discount})})]}),r.jsx("div",{className:"mt-2 w-full border-t-2 border-gray-200"}),r.jsxs("div",{className:"w-full text-left",children:[r.jsx("div",{className:"text-[#323135] font-bold font-nunitoSans mt-3 text-[14px]",children:"Product Details"}),r.jsx("div",{className:"text-[#68656E] font-normal font-nunitoSans text-xs pl-2 mt-3",dangerouslySetInnerHTML:{__html:t.short_description||t.longDescription}})]}),r.jsxs("div",{className:"mt-4 flex flex-col gap-2 w-full p-2",children:[r.jsx("div",{className:"flex flex-row items-center gap-2",children:r.jsxs("div",{className:"flex items-center gap-2 text-left font-nunitoSans",children:[r.jsxs("div",{className:"text-[#323135] font-bold",children:[((m=t==null?void 0:t.rating)==null?void 0:m.rate)||0," /"," ",r.jsx("span",{className:"text-[#68656E]",children:"5"})]}),r.jsx("div",{className:"text-[#323135] font-semibold text-sm",children:"Overall Rating"}),r.jsxs("div",{className:"text-[#68656E] font-semibold text-sm",children:[((w=t==null?void 0:t.rating)==null?void 0:w.count)||0," ratings"]})]})}),r.jsx("div",{className:"mt-2 flex flex-row items-center gap-2",children:Array.from({length:5}).map((p,v)=>{var C;return r.jsx(nt.Icon,{icon:"mdi:star",width:"20",height:"20",className:`text-yellow-500
7
+ ${((C=t==null?void 0:t.rating)==null?void 0:C.rate)>v?"text-yellow-500":"text-gray-300"}
8
+ `},v)})})]}),r.jsxs("div",{className:"flex flex-col items-center justify-between font-nunitoSans font-semibold w-5/6 text-black gap-2",style:{marginTop:"150px"},children:[r.jsx("button",{className:"rounded-[5px] shadow-sm text-[#FBFBFC] bg-[#6851C6] p-2 w-full text-center cursor-pointer",style:{backgroundColor:n.tanyaThemeColor},onClick:i,children:"Add to Cart"}),r.jsx("button",{className:"rounded-[5px] shadow-sm text-[#FBFBFC] bg-[#6851C6] p-2 w-full text-center cursor-pointer mb-16",style:{backgroundColor:n.tanyaThemeColor},onClick:a,children:"View more"})]})]})]})},ls=()=>{const e=["Myself","My Child","My Grandchild","Niece/Nephew","My Friends","Others"],t={Myself:"himself/herself","My Child":"his/her child","My Grandchild":"his/her grandchild","Niece/Nephew":"his/her niece/nephew","My Friends":"his/her friends",Others:"others"},n=j.useRef(null),o=j.useRef(null),s=j.useRef(null),i=j.useRef(null),[a,l]=j.useState(null),[c,d]=j.useState(!1),[f,m]=j.useState(!1),[w,p]=j.useState(!1),[v,C]=j.useState(!1),[h,b]=j.useState(!1),[D,P]=j.useState(!1),[A,Q]=j.useState(""),[S,L]=j.useState(""),q=u=>({id:u.id,title:u.name,image:u.image??"",price:u.price??0}),[R,E]=j.useState([]),fe=j.useRef(null),_=we.useSelector(u=>u.store.store),$=we.useSelector(u=>u.product.product),Se=()=>{p(!0),setTimeout(()=>m(!0),10)},ce=()=>{m(!1),setTimeout(()=>p(!1),300)};j.useEffect(()=>{c?Se():ce()},[c]);const Me=u=>{L(t[u])};j.useEffect(()=>{fe.current&&(fe.current.scrollTop+=150)},[R]);let ee=null,le=null;const H=async()=>{if(ee&&le&&Date.now()<le)return ee;try{const u="https://us-east-1lsr29ln3u.auth.us-east-1.amazoncognito.com/oauth2/token",T=new URLSearchParams({grant_type:"client_credentials",client_id:"4i8rd70sgt961tc4dhskgf08c",client_secret:"bnsfq1220loh2cn2cm2ttn8fdhdpt0u8m1fgj8vfk2rn61aurjg",scope:"default-m2m-resource-server-8xzfzo/read"}),I=await fetch(u,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:T});if(!I.ok)throw new Error(`Token request failed! status: ${I.status}`);const N=await I.json();ee=N.access_token;const y=N.expires_in||3600;return le=Date.now()+(y-60)*1e3,ee}catch(u){return console.error("Error obtaining JWT token:",u),ee=null,le=null,null}},Ue=async()=>{const u=await Le();u!=null&&l(u)};j.useEffect(()=>{Ue(),console.log("scapi environment v1")},[]);const Be=async()=>{const u=JSON.parse(sessionStorage.getItem("customerData")||"{}").customerId;return(await Zt(u||"")).c_interests},x=async(u,T)=>{console.log("in secondary flow",Ce);const I=await Be();if(console.log(I,"interests of customer",Ce),!!I)try{E(K=>K.map((Y,Z)=>Z===K.length-1?{...Y,secondaryLoading:!0}:Y));const N=await H();if(!N)throw new Error("Failed to fetch token");const y=localStorage.getItem("customerNumber"),k=localStorage.getItem("isLoggedIn"),he=`https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({registered:String(k||!1),userId:String(y||new Date().getTime())}).toString()}`,me=JSON.stringify({flowId:"Q166PR519W",flowAliasId:"HKFUVLWVH2",input:{loyaltyPoints:"",productName:u,productPoints:String(T||0),interests:I}}),V=await fetch(he,{signal:AbortSignal.timeout(3e4),method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:me});if(!V.body)throw new Error("Readable stream not supported");const ge=V.body.getReader(),xe=new TextDecoder;let J="";for(;;){const{done:K,value:Y}=await ge.read();if(K)break;J+=xe.decode(Y,{stream:!0});const Z=J.split(`
9
+ `);J=Z.pop()||"";for(const ne of Z)if(ne.startsWith("data:")){const g=ne.slice(5).trim();try{const G=JSON.parse(g);G.index===0&&E(O=>O.map((U,se)=>se===O.length-1?{...U,secondaryResponse:G.data,secondaryLoading:!1}:U))}catch(G){E(O=>O.map((U,se)=>se===O.length-1?{...U,secondaryLoading:!1}:U)),console.error("Secondary flow JSON parse error:",G)}}}}catch(N){console.error("Secondary flow error:",N)}},z=async u=>{const T=u||A.trim();if(T){b(!0),Q(""),n.current=null,o.current=null,s.current=null,i.current=null,E(I=>[...I,{query:T,response:"Thinking for what suits you best...",potentialQuestions:"",products:[],keywords:"Thinking for best products..."}]);try{const I=S,N=localStorage.getItem("customerNumber"),y=localStorage.getItem("isLoggedIn"),k=await H();if(!k)throw new Error("Failed to obtain access token");const he=`https://tanya.aspiresystems.com/api/bedrock/invoke/stream?${new URLSearchParams({registered:String(y||!1),userId:String(N||new Date().getTime())}).toString()}`,me=JSON.stringify({flowId:"MMHQKYI1NE",flowAliasId:"SZF9ZK1ATE",input:{userPrompt:T,whom:I}}),V=await fetch(he,{signal:AbortSignal.timeout(3e4),method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${k}`},body:me});if(!V.ok)throw new Error(`HTTP error! status: ${V.status}`);if(!V.body)throw new Error("Readable stream not supported");const ge=V.body.getReader(),xe=new TextDecoder;let J="",K="";for(;;){P(!0);const{done:Y,value:Z}=await ge.read();if(Y)break;J+=xe.decode(Z,{stream:!0});const ne=J.split(`
10
+ `);J=ne.pop()||"";for(const g of ne)if(g.startsWith("data:")){const G=g.slice(5).trim();try{const O=JSON.parse(G);O.index==1&&(K=O.data),E(U=>U.map((se,_e)=>_e===U.length-1?{...se,[O.index==0?"response":O.index==1?"keywords":O.index==2?"potentialQuestions":"end"]:O.data}:se))}catch(O){console.error("Error parsing JSON:",O)}}}te(pe(K))}catch(I){console.error("Error sending message to Tanya:",I)}finally{b(!1)}}},pe=u=>{const T=u.match(/top five relevant product or category names are: (.*)/i),y=(T?T[1]:u).split(", ").map(B=>B.replace(/\s*(Toys|Bags|Miniature|etc\.*)\s*/gi,"").trim());return[...new Set(y)].filter(Boolean).join(",")},te=async u=>{if(console.log(a==null?void 0:a.access_token,"access_token"),typeof u=="string"){console.log(u,"keywords");const T=u.split(",");for(const I of T){const N=await st(I,a==null?void 0:a.access_token);if(P(!1),(N==null?void 0:N.length)>0&&(E(y=>y.map((k,B)=>B===y.length-1?{...k,products:[...k.products||[],{keyword:I,items:N,loading:!1}]}:k)),!n.current||o.current==null)){const y=N[0];n.current=String((y==null?void 0:y.product_name)??""),s.current=y.image.link,o.current=y.product_id;const k=typeof(y==null?void 0:y.price)=="number"?y.price:void 0;i.current=typeof k=="number"&&Number.isFinite(k)?k:null}}}else for(const T of u){const I=await st(T,a==null?void 0:a.access_token);P(!1),(I==null?void 0:I.length)>0&&E(N=>N.map((y,k)=>k===N.length-1?{...y,products:[...y.products||[],{keyword:T,items:I,loading:!1}]}:y))}if(n.current){E(I=>I.map((N,y)=>y===I.length-1?{...N,productSnapshot:{id:o.current,name:n.current,image:s.current,price:i.current??null,points:0,quantity:1}}:N));const T=JSON.parse(sessionStorage.getItem("customerData")||"{}");(T==null?void 0:T.isGuest)==!1?(console.log("running secondary flow",Ce),x(n.current,0)):console.log("not running secondary flow",Ce)}P(!1)},Ht=async(u,T)=>{var I,N,y,k,B,he,me,V,ge,xe,J,K,Y,Z,ne;C(!0);try{const g=await Ct(u.id);if(!((N=(I=g==null?void 0:g.variants)==null?void 0:I[0])!=null&&N.product_id||(k=(y=g==null?void 0:g.variants)==null?void 0:y[0])!=null&&k.productId)&&!(g.type.item||g.type.bundle)){C(!1),W.toast.error("Variants not found",{position:"bottom-right",autoClose:1e3}),console.error("No product variant found");return}const G=[{product_id:((B=g.variants)==null?void 0:B[0].product_id)||((he=g.variants)==null?void 0:he[0].productId)||(g==null?void 0:g.id),quantity:T}];console.log(G,"product data","app version",Ce);const O=JSON.parse(sessionStorage.getItem("customerData")||"{}"),U=O==null?void 0:O.basketId,se=!1,_e=localStorage.getItem(Te),et=Date.now();if(!se||!_e||et>=parseInt(_e)){const zt=await kt();let{customer_token:ue}=await It(zt);if(ue="Bearer "+a.access_token,!ue){console.error("Failed to get customer_token");return}const Vt=et+300*1e3;if(Oe(ue),localStorage.setItem(Te,Vt.toString()),U){const tt=await Rt({basketId:U,customer_token:ue});if(tt.status===200&&tt){const qe=await Ae(U,G,ue);((me=qe==null?void 0:qe.product_items)==null?void 0:me.length)>0&&(W.toast.success("Added to cart",{position:"bottom-right",autoClose:3e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0}),be(U),C(!1));return}}const Jt={productItems:[{productId:((V=g.variants)==null?void 0:V[0].product_id)||((ge=g.variants)==null?void 0:ge[0].productId)||(g==null?void 0:g.id),quantity:1}]},F=await qt(ue,Jt);if(console.log(F,F==null?void 0:F.basket_id,F==null?void 0:F.basketId,"the basket response"),!(F!=null&&F.basket_id||!(F!=null&&F.basketId))){C(!1),console.error("Failed to create basket");return}ve((F==null?void 0:F.basket_id)||(F==null?void 0:F.basketId));const ye=await Ae((F==null?void 0:F.basket_id)||(F==null?void 0:F.basketId),G,ue);(((xe=ye==null?void 0:ye.product_items)==null?void 0:xe.length)>0||((J=ye==null?void 0:ye.productItems)==null?void 0:J.length)>0)&&W.toast.success("Added to cart",{position:"bottom-right",autoClose:3e3,hideProgressBar:!1,closeOnClick:!0,pauseOnHover:!0,draggable:!0}),be(F.basket_id||(F==null?void 0:F.basketId))}}catch(g){C(!1),console.error("Error adding to cart:",g),W.toast.error("Failed to add product to cart",{position:"bottom-right",autoClose:3e3}),((K=g==null?void 0:g.response)==null?void 0:K.status)===404||((Y=g==null?void 0:g.response)==null?void 0:Y.status)===401?(((Z=g==null?void 0:g.response)==null?void 0:Z.status)===404&&ve(null),((ne=g==null?void 0:g.response)==null?void 0:ne.status)===401&&(ve(null),Oe(null))):(console.error("Failed to add product to basket:",g.message),W.toast.error("Failed to add product to cart",{position:"bottom-right",autoClose:3e3}))}finally{be()}C(!1)};return r.jsx("div",{className:"relative flex justify-center",children:r.jsxs(Qt,{open:c,onOpenChange:d,children:[r.jsx(Yt,{onClick:()=>d(!0),style:{},className:"flex items-center rounded-lg cursor-pointer hover:opacity-90 transition-opacity",children:r.jsx("div",{className:"flex flex-col p-[5px]",children:r.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsxs("g",{clipPath:"url(#clip0_958_585)",children:[r.jsx("path",{d:"M30.0002 5C31.7683 5 33.464 5.70238 34.7142 6.95262C35.9644 8.20286 36.6668 9.89856 36.6668 11.6667V25C36.6668 26.7681 35.9644 28.4638 34.7142 29.714C33.464 30.9643 31.7683 31.6667 30.0002 31.6667H25.6902L21.1785 36.1783C20.8915 36.4653 20.5097 36.6377 20.1046 36.6631C19.6996 36.6886 19.2992 36.5654 18.9785 36.3167L18.8218 36.1783L14.3085 31.6667H10.0002C8.28976 31.6667 6.64478 31.0093 5.40548 29.8305C4.16617 28.6516 3.42735 27.0416 3.34183 25.3333L3.3335 25V11.6667C3.3335 9.89856 4.03588 8.20286 5.28612 6.95262C6.53636 5.70238 8.23205 5 10.0002 5H30.0002Z",fill:"url(#paint0_linear_958_585)"}),r.jsx("path",{d:"M28.3335 15.6511V11.6667C28.3335 11.6667 22.2774 12.6042 20.1148 15.4167C17.9521 18.2292 18.6644 26.6667 18.6644 26.6667H22.5321C22.5321 26.6667 22.0614 18.9323 23.4989 17.2917C24.9364 15.6511 28.3335 15.6511 28.3335 15.6511Z",fill:"white"}),r.jsx("path",{d:"M13.3335 11.6667H19.6184V15.4167H13.3335V11.6667Z",fill:"white"})]}),r.jsxs("defs",{children:[r.jsxs("linearGradient",{id:"paint0_linear_958_585",x1:"20.0002",y1:"5",x2:"35.0002",y2:"30",gradientUnits:"userSpaceOnUse",children:[r.jsx("stop",{stopColor:"#452697"}),r.jsx("stop",{offset:"1",stopColor:"#7C5BFF"})]}),r.jsx("clipPath",{id:"clip0_958_585",children:r.jsx("rect",{width:"40",height:"40",fill:"white"})})]})]})})}),w&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-40 bg-black/30",onClick:()=>d(!1)}),r.jsxs("div",{className:`
11
11
  fixed z-50 h-screen w-[100vw] sm:w-[80vw] md:w-[770px] border-0 bg-white lg:rounded-l-xl overflow-hidden flex flex-col shadow-[0px_4px_10px_0px_#5F499840]
12
12
  top-0 right-0
13
13
  transition-transform duration-300 ease-in-out
14
14
  lg:transform
15
- ${g?"lg:translate-x-0":"lg:translate-x-full"}
15
+ ${f?"lg:translate-x-0":"lg:translate-x-full"}
16
16
  // For mobile: animate from bottom
17
- ${g?"translate-y-0":"translate-y-full"}
17
+ ${f?"translate-y-0":"translate-y-full"}
18
18
  lg:translate-y-0
19
- `,style:{background:"linear-gradient(170.1deg, #FFFFFF 60.03%, #E3DEEF 99.59%)"},children:[r.jsxs("div",{className:"flex justify-between p-3 bg-[#FFFFFF] border border-b-1 border-[#E5E5E5] ",children:[r.jsx("div",{style:{display:"flex",color:m.tanyaThemeContrastColor,alignItems:"center",gap:"0.5rem"},children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.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:[r.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 15 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.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"}),r.jsx("path",{d:"M0 0.5H6.28488V4.25H0V0.5Z",fill:"white"})]}),r.jsx("p",{className:"text-[#FFFFFF] font-nunitoSans font-semibold",children:"TANYA"})]}),r.jsxs("p",{className:"text-[#5B5B5B] font-nunitoSans font-semibold",style:{fontStyle:"italic"},children:[" ","Your AI shopping assistant !"," "]})]})}),r.jsx("div",{style:{display:"flex",alignItems:"center",gap:"1.25rem",margin:"0.75rem"},children:r.jsx("button",{onClick:()=>f(!1),children:r.jsxs("svg",{width:"24",height:"25",viewBox:"0 0 24 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsxs("g",{clipPath:"url(#clip0_501_6036)",children:[r.jsx("path",{d:"M18 6.5L6 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M6 6.5L18 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),r.jsx("defs",{children:r.jsx("clipPath",{id:"clip0_501_6036",children:r.jsx("rect",{width:"24",height:"24",fill:"white",transform:"translate(0 0.5)"})})})]})})})]}),r.jsxs("div",{className:"flex h-full md:flex-row lg:flex-row",children:[r.jsxs("div",{className:`flex flex-col h-full ${je?"lg:w-2/3 w-full":"w-full"}`,children:[r.jsxs("div",{ref:fe,className:"overflow-y-auto pr-5 pb-2 space-y-4 hide-scrollbar flex-grow mb-24",children:[(m==null?void 0:m.whomRequired)&&r.jsxs("div",{className:"mx-3 p-3 rounded-2xl bg-[#FFFFFF]",children:[r.jsx("div",{className:"flex gap-2 bg-[#FFFFFF]",children:r.jsx("p",{className:"font-bold font-nunitoSans text-[#494949]",children:"Is this for you or someone else?"})}),r.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(u=>r.jsx("button",{onClick:()=>Te(u),className:"px-2 py-2 font-semibold text-xs text-[#18181B] bg-[#F3F3F3] rounded-2xl",style:{backgroundColor:$===t[u]?"#FFFFFF":"#F3F3F3",borderColor:$===t[u]?"#BBB3DD":""},children:u},u))})]}),D.map((u,_)=>{var C,N;return r.jsxs("div",{children:[r.jsx("div",{className:"flex justify-end",children:r.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:u.query})}),u.response&&u.response.includes("Thinking")?r.jsx("div",{children:r.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:Re(u.response)}})}):r.jsx("div",{children:r.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:Re(u.response)}})}),E&&!u.response.includes("Thinking")&&((C=u.products)==null?void 0:C.length)==0&&r.jsx("div",{children:r.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"})}),(u==null?void 0:u.products)&&((N=u==null?void 0:u.products)==null?void 0:N.length)>0&&r.jsx(cs,{chat:u.products,storeDetails:m}),u.potentialQuestions.length>0&&r.jsxs("div",{className:"my-2 px-4 text-sm text-gray-700",children:[r.jsx("p",{className:"font-nunitoSans font-bold text-sm text-[#494949]",style:{color:m.themeDarkColor},children:"Why not explore these inquiries..."}),u.potentialQuestions.split(",").map((v,k)=>r.jsx("button",{className:`cursor-pointer font-nunitoSans font-semibold text-[#232323] border bg-[#804C9E0D] border-${m.themeDarkColor} m-1 rounded-xl px-2 py-1`,onClick:()=>te(v),style:{backgroundColor:m.tanyaThemeColorLight},children:v},k))]}),u.secondaryLoading&&r.jsx("div",{className:"mt-3 mb-4 px-4",children:r.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:[r.jsxs("div",{className:"flex gap-1",children:[r.jsx("div",{className:"tanya-sparkle tanya-sparkle-1",children:"✨"}),r.jsx("div",{className:"tanya-sparkle tanya-sparkle-2",children:"✨"}),r.jsx("div",{className:"tanya-sparkle tanya-sparkle-3",children:"✨"})]}),r.jsx("div",{className:"tanya-shimmer"}),r.jsx("p",{className:"font-semibold tanya-pulse",style:{color:m.themeDarkColor},children:"I’ve found a special surprise crafted just for you… hang on a sec!"}),r.jsx("p",{className:"tanya-dots mt-1",style:{color:m.themeDarkColor},children:"• • •"})]})}),u.secondaryResponse&&r.jsx(r.Fragment,{children:r.jsxs("div",{className:"mt-3 mb-8 px-4 bg-indigo-300 rounded-tr-[5px]",children:[r.jsx("div",{className:"text-sm text-[#232323] bg-[#FFFFFF] px-7 py-4 rounded-br-xl rounded-bl-2xl w-full",style:{backgroundColor:m.tanyaThemeColorLight},dangerouslySetInnerHTML:{__html:Re(u.secondaryResponse)}}),u.productSnapshot&&r.jsx("div",{className:"mt-4 w-full",children:r.jsxs("div",{className:"flex gap-4 items-stretch rounded-2xl p-4",style:{backgroundColor:m.tanyaThemeColorLight},children:[r.jsx("div",{className:"flex-shrink-0 rounded-xl overflow-hidden border",style:{width:112,height:112,borderColor:"#eee"},children:u.productSnapshot.image?r.jsx("img",{src:u.productSnapshot.image,alt:u.productSnapshot.name,className:"w-full h-full object-cover"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs text-gray-500",children:"No Image"})}),r.jsxs("div",{className:"flex flex-col flex-1 justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-[15px] leading-snug",children:u.productSnapshot.name}),r.jsx("p",{className:"mt-1 text-[14px] font-medium",children:u.productSnapshot.price!=null?new Intl.NumberFormat(void 0,{style:"currency",currency:(m==null?void 0:m.currency)||"USD"}).format(u.productSnapshot.price):""}),u.productSnapshot.points>0&&r.jsxs("p",{className:"mt-1 text-xs opacity-80",children:["You will earn"," ",r.jsxs("strong",{children:[u.productSnapshot.points," ","points"]})]})]}),r.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[r.jsxs("div",{className:"flex items-center border rounded-full overflow-hidden",children:[r.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>M(v=>v.map((k,q)=>q===_&&k.productSnapshot?{...k,productSnapshot:{...k.productSnapshot,quantity:Math.max(1,k.productSnapshot.quantity-1)}}:k)),style:{background:"transparent",color:m.themeDarkColor},children:"−"}),r.jsx("div",{className:"px-3 py-1 text-sm select-none",children:u.productSnapshot.quantity}),r.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>M(v=>v.map((k,q)=>q===_&&k.productSnapshot?{...k,productSnapshot:{...k.productSnapshot,quantity:k.productSnapshot.quantity+1}}:k)),style:{background:"transparent",color:m.themeDarkColor},children:"+"})]}),r.jsx("button",{onClick:()=>{zt(W(u.productSnapshot),u.productSnapshot.quantity)},disabled:T,className:"px-4 py-2 rounded-full font-medium",style:{background:m.tanyaThemeColor,color:(m==null?void 0:m.tanyaThemeContrastColor)||"#fff",opacity:T?.8:1},children:T?"Adding...":"Add to cart"})]})]})]})})]})}),r.jsx("div",{className:"mb-20"})]},_)})]}),r.jsx("div",{className:"flex flex-col gap-2 sticky bottom-0 left-0 right-0 bg-[#E3DEEF] z-50 px-4 py-2",children:r.jsx("div",{className:"p-[1px] rounded-xl",style:{background:"linear-gradient(180deg, #B09FFF 0%, #8D79F6 100%)"},children:r.jsxs("div",{className:"flex items-center bg-[#FFFFFF] flex-1 rounded-xl px-2 py-1",children:[r.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:G,autoFocus:!0,onChange:u=>I(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!b&&te()}}),r.jsx("button",{type:"submit",disabled:b,className:"p-3",onClick:()=>te(),children:b?r.jsx("div",{className:"p-3 animate-spin rounded-full h-3 w-3 border-b-2",style:{borderBottom:"2px solid",color:m.tanyaThemeColor}}):r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:r.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"})})})]})})})]}),r.jsx(us,{})]})]})]})]})})};exports.TanyaChatbot=ds;
19
+ `,style:{background:"linear-gradient(170.1deg, #FFFFFF 60.03%, #E3DEEF 99.59%)"},children:[r.jsxs("div",{className:"flex justify-between p-3 bg-[#FFFFFF] border border-b-1 border-[#E5E5E5] ",children:[r.jsx("div",{style:{display:"flex",color:_.tanyaThemeContrastColor,alignItems:"center",gap:"0.5rem"},children:r.jsxs("div",{className:"flex flex-col gap-1",children:[r.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:[r.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 15 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.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"}),r.jsx("path",{d:"M0 0.5H6.28488V4.25H0V0.5Z",fill:"white"})]}),r.jsx("p",{className:"text-[#FFFFFF] font-nunitoSans font-semibold",children:"TANYA"})]}),r.jsxs("p",{className:"text-[#5B5B5B] font-nunitoSans font-semibold",style:{fontStyle:"italic"},children:[" ","Your AI shopping assistant !"," "]})]})}),r.jsx("div",{style:{display:"flex",alignItems:"center",gap:"1.25rem",margin:"0.75rem"},children:r.jsx("button",{onClick:()=>d(!1),children:r.jsxs("svg",{width:"24",height:"25",viewBox:"0 0 24 25",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[r.jsxs("g",{clipPath:"url(#clip0_501_6036)",children:[r.jsx("path",{d:"M18 6.5L6 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("path",{d:"M6 6.5L18 18.5",stroke:"#555555",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),r.jsx("defs",{children:r.jsx("clipPath",{id:"clip0_501_6036",children:r.jsx("rect",{width:"24",height:"24",fill:"white",transform:"translate(0 0.5)"})})})]})})})]}),r.jsxs("div",{className:"flex h-full md:flex-row lg:flex-row",children:[r.jsxs("div",{className:`flex flex-col h-full ${$?"lg:w-2/3 w-full":"w-full"}`,children:[r.jsxs("div",{ref:fe,className:"overflow-y-auto pr-5 pb-2 space-y-4 hide-scrollbar flex-grow mb-24",children:[(_==null?void 0:_.whomRequired)&&r.jsxs("div",{className:"mx-3 p-3 rounded-2xl bg-[#FFFFFF]",children:[r.jsx("div",{className:"flex gap-2 bg-[#FFFFFF]",children:r.jsx("p",{className:"font-bold font-nunitoSans text-[#494949]",children:"Is this for you or someone else?"})}),r.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:e.map(u=>r.jsx("button",{onClick:()=>Me(u),className:"px-2 py-2 font-semibold text-xs text-[#18181B] bg-[#F3F3F3] rounded-2xl",style:{backgroundColor:S===t[u]?"#FFFFFF":"#F3F3F3",borderColor:S===t[u]?"#BBB3DD":""},children:u},u))})]}),R.map((u,T)=>{var I,N;return r.jsxs("div",{children:[r.jsx("div",{className:"flex justify-end",children:r.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:u.query})}),u.response&&u.response.includes("Thinking")?r.jsx("div",{children:r.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:Re(u.response)}})}):r.jsx("div",{children:r.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:Re(u.response)}})}),D&&!u.response.includes("Thinking")&&((I=u.products)==null?void 0:I.length)==0&&r.jsx("div",{children:r.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"})}),(u==null?void 0:u.products)&&((N=u==null?void 0:u.products)==null?void 0:N.length)>0&&r.jsx(is,{chat:u.products,storeDetails:_}),u.potentialQuestions.length>0&&r.jsxs("div",{className:"my-2 px-4 text-sm text-gray-700",children:[r.jsx("p",{className:"font-nunitoSans font-bold text-sm text-[#494949]",style:{color:_.themeDarkColor},children:"Why not explore these inquiries..."}),u.potentialQuestions.split(",").map((y,k)=>r.jsx("button",{className:`cursor-pointer font-nunitoSans font-semibold text-[#232323] border bg-[#804C9E0D] border-${_.themeDarkColor} m-1 rounded-xl px-2 py-1`,onClick:()=>z(y),style:{backgroundColor:_.tanyaThemeColorLight},children:y},k))]}),u.secondaryLoading&&r.jsx("div",{className:"mt-3 mb-4 px-4",children:r.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:[r.jsxs("div",{className:"flex gap-1",children:[r.jsx("div",{className:"tanya-sparkle tanya-sparkle-1",children:"✨"}),r.jsx("div",{className:"tanya-sparkle tanya-sparkle-2",children:"✨"}),r.jsx("div",{className:"tanya-sparkle tanya-sparkle-3",children:"✨"})]}),r.jsx("div",{className:"tanya-shimmer"}),r.jsx("p",{className:"font-semibold tanya-pulse",style:{color:_.themeDarkColor},children:"I’ve found a special surprise crafted just for you… hang on a sec!"}),r.jsx("p",{className:"tanya-dots mt-1",style:{color:_.themeDarkColor},children:"• • •"})]})}),u.secondaryResponse&&r.jsx(r.Fragment,{children:r.jsxs("div",{className:"mt-3 mb-8 px-4 bg-indigo-300 rounded-tr-[5px]",children:[r.jsx("div",{className:"text-sm text-[#232323] bg-[#FFFFFF] px-7 py-4 rounded-br-xl rounded-bl-2xl w-full",style:{backgroundColor:_.tanyaThemeColorLight},dangerouslySetInnerHTML:{__html:Re(u.secondaryResponse)}}),u.productSnapshot&&r.jsx("div",{className:"mt-4 w-full",children:r.jsxs("div",{className:"flex gap-4 items-stretch rounded-2xl p-4",style:{backgroundColor:_.tanyaThemeColorLight},children:[r.jsx("div",{className:"flex-shrink-0 rounded-xl overflow-hidden border",style:{width:112,height:112,borderColor:"#eee"},children:u.productSnapshot.image?r.jsx("img",{src:u.productSnapshot.image,alt:u.productSnapshot.name,className:"w-full h-full object-cover"}):r.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs text-gray-500",children:"No Image"})}),r.jsxs("div",{className:"flex flex-col flex-1 justify-between",children:[r.jsxs("div",{children:[r.jsx("p",{className:"font-semibold text-[15px] leading-snug",children:u.productSnapshot.name}),r.jsx("p",{className:"mt-1 text-[14px] font-medium",children:u.productSnapshot.price!=null?new Intl.NumberFormat(void 0,{style:"currency",currency:(_==null?void 0:_.currency)||"USD"}).format(u.productSnapshot.price):""}),u.productSnapshot.points>0&&r.jsxs("p",{className:"mt-1 text-xs opacity-80",children:["You will earn"," ",r.jsxs("strong",{children:[u.productSnapshot.points," ","points"]})]})]}),r.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[r.jsxs("div",{className:"flex items-center border rounded-full overflow-hidden",children:[r.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>E(y=>y.map((k,B)=>B===T&&k.productSnapshot?{...k,productSnapshot:{...k.productSnapshot,quantity:Math.max(1,k.productSnapshot.quantity-1)}}:k)),style:{background:"transparent",color:_.themeDarkColor},children:"−"}),r.jsx("div",{className:"px-3 py-1 text-sm select-none",children:u.productSnapshot.quantity}),r.jsx("button",{className:"px-3 py-1 text-sm",onClick:()=>E(y=>y.map((k,B)=>B===T&&k.productSnapshot?{...k,productSnapshot:{...k.productSnapshot,quantity:k.productSnapshot.quantity+1}}:k)),style:{background:"transparent",color:_.themeDarkColor},children:"+"})]}),r.jsx("button",{onClick:()=>{Ht(q(u.productSnapshot),u.productSnapshot.quantity)},disabled:v,className:"px-4 py-2 rounded-full font-medium",style:{background:_.tanyaThemeColor,color:(_==null?void 0:_.tanyaThemeContrastColor)||"#fff",opacity:v?.8:1},children:v?"Adding...":"Add to cart"})]})]})]})})]})}),r.jsx("div",{className:"mb-20"})]},T)})]}),r.jsx("div",{className:"flex flex-col gap-2 sticky bottom-0 left-0 right-0 bg-[#E3DEEF] z-50 px-4 py-2",children:r.jsx("div",{className:"p-[1px] rounded-xl",style:{background:"linear-gradient(180deg, #B09FFF 0%, #8D79F6 100%)"},children:r.jsxs("div",{className:"flex items-center bg-[#FFFFFF] flex-1 rounded-xl px-2 py-1",children:[r.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:A,autoFocus:!0,onChange:u=>Q(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!h&&z()}}),r.jsx("button",{type:"submit",disabled:h,className:"p-3",onClick:()=>z(),children:h?r.jsx("div",{className:"p-3 animate-spin rounded-full h-3 w-3 border-b-2",style:{borderBottom:"2px solid",color:_.tanyaThemeColor}}):r.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:r.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"})})})]})})})]}),r.jsx(cs,{})]})]})]})]})})};exports.TanyaChatbot=ls;
20
20
  //# sourceMappingURL=tanya-chatbot.cjs.js.map