shopify-chatbot-widget 0.4.7 → 0.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,199 @@
1
+ import React, { useState, useMemo, type FC } from 'react';
2
+ import './ProductCard.css';
3
+ import ProductCarousel from './Carousel/CardSwiper';
4
+ import { ArrowLeftOutlined, ArrowRightOutlined } from '@ant-design/icons';
5
+ import { Button } from 'antd';
6
+ import { useKeenSlider } from 'keen-slider/react';
7
+ import 'keen-slider/keen-slider.min.css';
8
+
9
+ interface ProductVariant {
10
+ name: string;
11
+ price: string;
12
+ link: string;
13
+ image: string;
14
+ variant_id: string;
15
+ variant_tag_name: string;
16
+ color?: string;
17
+ size?: string;
18
+ }
19
+
20
+ interface AssistantMessageProps {
21
+ message: string;
22
+ colorCode: string;
23
+ isBusiness?: boolean;
24
+ handleAddToCart: (variantId: string, name: string, qty?: number) => Promise<void>;
25
+ handleRemoveFromCart: (variantId: string, qty?: number) => Promise<void>;
26
+ }
27
+
28
+ const AssistantMessage: FC<AssistantMessageProps> = ({
29
+ message,
30
+ colorCode,
31
+ handleAddToCart,
32
+ handleRemoveFromCart,
33
+ }) => {
34
+ const [counts, setCounts] = useState<Record<string, number>>({});
35
+ const [selectedVariants, setSelectedVariants] = useState<Record<string, string>>({});
36
+
37
+ const formatTextWithLinks = (text: string): React.ReactNode[] => {
38
+ const urlRegex = /(https?:\/\/[^\s]+)/g;
39
+ return text.split(urlRegex).map((part, i) =>
40
+ urlRegex.test(part) ? (
41
+ <a
42
+ key={i}
43
+ href={part.trim()}
44
+ style={{ color: '#00b3bc' }}
45
+ target="_blank"
46
+ rel="noopener noreferrer"
47
+ className="underline break-words"
48
+ >
49
+ {part}
50
+ </a>
51
+ ) : (
52
+ <span key={i}>{part}</span>
53
+ )
54
+ );
55
+ };
56
+
57
+ const extractProductDetails = (text: string): ProductVariant | null => {
58
+ const normalized = text.trim();
59
+ if (!normalized.includes('Name:') || !normalized.includes('VariantId')) return null;
60
+ const nameMatch = normalized.match(/Name\s*[:\-]\s*(.+)/i);
61
+ const priceMatch = normalized.match(/Price\s*[:\-]\s*(.+)/i);
62
+ const linkMatch = normalized.match(/Link\s*[:\-]\s*(https?:\/\/[^\s]+)/i);
63
+ const variantMatch = normalized.match(/VariantId\s*[:\-]\s*(.+)/i);
64
+ const tagNameMatch = normalized.match(/variant_tag_name\s*[:\-]\s*(.+)/i);
65
+ const colorMatch = normalized.match(/color\s*[:\-]\s*([^|\r\n]+)/i);
66
+ const sizeMatch = normalized.match(/size\s*[:\-]\s*([^|\r\n]+)/i);
67
+ if (!nameMatch || !priceMatch || !linkMatch || !variantMatch || !tagNameMatch) return null;
68
+ return {
69
+ name: nameMatch[1].trim(),
70
+ price: priceMatch[1].trim(),
71
+ link: linkMatch[1].trim(),
72
+ image: '',
73
+ variant_id: variantMatch[1].trim(),
74
+ variant_tag_name: tagNameMatch[1].trim(),
75
+ color: colorMatch?.[1]?.trim(),
76
+ size: sizeMatch?.[1]?.trim(),
77
+ };
78
+ };
79
+
80
+ const parsedSegments = useMemo(() => {
81
+ const parts = message.split('|||').map(p => p.trim()).filter(Boolean);
82
+ const segments: { type: 'text' | 'product'; data: any }[] = [];
83
+ let lastProduct: ProductVariant | null = null;
84
+
85
+ parts.forEach(part => {
86
+ if (part.startsWith('img - ')) {
87
+ const url = part.replace(/^img\s*[-:]\s*/, '').trim();
88
+ if (lastProduct) lastProduct.image = url;
89
+ else {
90
+ const lastSeg = [...segments].reverse().find(s => s.type === 'product');
91
+ if (lastSeg) (lastSeg.data as ProductVariant).image = url;
92
+ }
93
+ } else if (part.includes('Name:') && part.includes('VariantId')) {
94
+ const product = extractProductDetails(part);
95
+ if (product) {
96
+ segments.push({ type: 'product', data: product });
97
+ lastProduct = product;
98
+ }
99
+ } else {
100
+ segments.push({ type: 'text', data: part });
101
+ lastProduct = null;
102
+ }
103
+ });
104
+
105
+ return segments;
106
+ }, [message]);
107
+
108
+ const groupedProducts = useMemo(() => {
109
+ const groups: Record<string, ProductVariant[]> = {};
110
+ parsedSegments.forEach(seg => {
111
+ if (seg.type === 'product') {
112
+ const p = seg.data as ProductVariant;
113
+ groups[p.variant_tag_name] = groups[p.variant_tag_name] || [];
114
+ groups[p.variant_tag_name].push(p);
115
+ }
116
+ });
117
+ return groups;
118
+ }, [parsedSegments]);
119
+
120
+ const shortenName = (name: string, maxLength = 22) =>
121
+ name.length > maxLength ? name.slice(0, maxLength) + '...' : name;
122
+
123
+
124
+
125
+ const [currentSlide, setCurrentSlide] = useState(0);
126
+ const totalSlides =Object.keys(groupedProducts).length ;
127
+ const [sliderRef, slider] = useKeenSlider<HTMLDivElement>({
128
+ loop: false,
129
+ mode: 'free',
130
+ slides: { perView: 1, spacing: 16 },
131
+ slideChanged(s) {
132
+ setCurrentSlide(s.track.details.rel);
133
+ },
134
+ });
135
+
136
+
137
+ return (
138
+ <div className="space-y-6 mt-4 h-fit">
139
+ {parsedSegments
140
+ .filter(seg => seg.type === 'text')
141
+ .map((seg, i) => (
142
+ <p key={i} className="whitespace-pre-wrap break-words">
143
+ {formatTextWithLinks(seg.data)}
144
+ </p>
145
+ ))}
146
+
147
+
148
+
149
+ {Object.keys(groupedProducts).length > 0 && (
150
+ <>
151
+ {Object.keys(groupedProducts).length > 1 && (
152
+ <div
153
+ style={{
154
+ display: 'flex',
155
+ margin: 0,
156
+ marginBottom: '6px',
157
+ justifyContent: 'space-between',
158
+ paddingInline: '4px',
159
+ }}
160
+ >
161
+ <Button
162
+ shape="circle"
163
+ icon={<ArrowLeftOutlined />}
164
+ onClick={() => slider.current?.prev()}
165
+ disabled={currentSlide === 0}
166
+ />
167
+ <Button
168
+ shape="circle"
169
+ icon={<ArrowRightOutlined />}
170
+ onClick={() => slider.current?.next()}
171
+ disabled={currentSlide === totalSlides - 1}
172
+ />
173
+ </div>
174
+ )}
175
+ <div ref={sliderRef} className="keen-slider">
176
+ <ProductCarousel
177
+ groupedProducts={groupedProducts}
178
+ selectedVariants={selectedVariants}
179
+ setSelectedVariants={setSelectedVariants}
180
+ counts={counts}
181
+ setCounts={setCounts}
182
+ handleAddToCart={handleAddToCart}
183
+ handleRemoveFromCart={handleRemoveFromCart}
184
+ colorCode={colorCode}
185
+ shortenName={shortenName}
186
+ sliderInstance={slider} // pass it down if needed
187
+ currentSlide={currentSlide}
188
+ totalSlides={totalSlides}
189
+ sliderRef={sliderRef}
190
+
191
+ />
192
+ </div>
193
+ </>
194
+ )}
195
+ </div>
196
+ );
197
+ };
198
+
199
+ export default AssistantMessage;
@@ -569,7 +569,7 @@ html body {
569
569
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...a){const r=new this(t);return a.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[J4]=this[J4]={accessors:{}}).accessors,o=this.prototype;function c(f){const m=m0(f);r[m]||($W(o,f),r[m]=!0)}return Xe.isArray(t)?t.forEach(c):c(t),this}};vo.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Xe.reduceDescriptors(vo.prototype,({value:e},t)=>{let a=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[a]=r}}}),Xe.freezeMethods(vo);function fO(e,t){const a=this||h0,r=t||a,o=vo.from(r.headers);let c=r.data;return Xe.forEach(e,function(m){c=m.call(a,c,o.normalize(),t?t.status:void 0)}),o.normalize(),c}function e6(e){return!!(e&&e.__CANCEL__)}function Gm(e,t,a){Cn.call(this,e??"canceled",Cn.ERR_CANCELED,t,a),this.name="CanceledError"}Xe.inherits(Gm,Cn,{__CANCEL__:!0});function t6(e,t,a){const r=a.config.validateStatus;!a.status||!r||r(a.status)?e(a):t(new Cn("Request failed with status code "+a.status,[Cn.ERR_BAD_REQUEST,Cn.ERR_BAD_RESPONSE][Math.floor(a.status/100)-4],a.config,a.request,a))}function zW(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function jW(e,t){e=e||10;const a=new Array(e),r=new Array(e);let o=0,c=0,f;return t=t!==void 0?t:1e3,function(g){const p=Date.now(),y=r[c];f||(f=p),a[o]=g,r[o]=p;let S=c,E=0;for(;S!==o;)E+=a[S++],S=S%e;if(o=(o+1)%e,o===c&&(c=(c+1)%e),p-f<t)return;const T=y&&p-y;return T?Math.round(E*1e3/T):void 0}}function LW(e,t){let a=0,r=1e3/t,o,c;const f=(p,y=Date.now())=>{a=y,o=null,c&&(clearTimeout(c),c=null),e.apply(null,p)};return[(...p)=>{const y=Date.now(),S=y-a;S>=r?f(p,y):(o=p,c||(c=setTimeout(()=>{c=null,f(o)},r-S)))},()=>o&&f(o)]}const q1=(e,t,a=3)=>{let r=0;const o=jW(50,250);return LW(c=>{const f=c.loaded,m=c.lengthComputable?c.total:void 0,g=f-r,p=o(g),y=f<=m;r=f;const S={loaded:f,total:m,progress:m?f/m:void 0,bytes:g,rate:p||void 0,estimated:p&&m&&y?(m-f)/p:void 0,event:c,lengthComputable:m!=null,[t?"download":"upload"]:!0};e(S)},a)},n6=(e,t)=>{const a=e!=null;return[r=>t[0]({lengthComputable:a,total:e,loaded:r}),t[1]]},a6=e=>(...t)=>Xe.asap(()=>e(...t)),VW=Ei.hasStandardBrowserEnv?((e,t)=>a=>(a=new URL(a,Ei.origin),e.protocol===a.protocol&&e.host===a.host&&(t||e.port===a.port)))(new URL(Ei.origin),Ei.navigator&&/(msie|trident)/i.test(Ei.navigator.userAgent)):()=>!0,HW=Ei.hasStandardBrowserEnv?{write(e,t,a,r,o,c){const f=[e+"="+encodeURIComponent(t)];Xe.isNumber(a)&&f.push("expires="+new Date(a).toGMTString()),Xe.isString(r)&&f.push("path="+r),Xe.isString(o)&&f.push("domain="+o),c===!0&&f.push("secure"),document.cookie=f.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function BW(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function PW(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function r6(e,t,a){let r=!BW(t);return e&&(r||a==!1)?PW(e,t):t}const i6=e=>e instanceof vo?{...e}:e;function jd(e,t){t=t||{};const a={};function r(p,y,S,E){return Xe.isPlainObject(p)&&Xe.isPlainObject(y)?Xe.merge.call({caseless:E},p,y):Xe.isPlainObject(y)?Xe.merge({},y):Xe.isArray(y)?y.slice():y}function o(p,y,S,E){if(Xe.isUndefined(y)){if(!Xe.isUndefined(p))return r(void 0,p,S,E)}else return r(p,y,S,E)}function c(p,y){if(!Xe.isUndefined(y))return r(void 0,y)}function f(p,y){if(Xe.isUndefined(y)){if(!Xe.isUndefined(p))return r(void 0,p)}else return r(void 0,y)}function m(p,y,S){if(S in t)return r(p,y);if(S in e)return r(void 0,p)}const g={url:c,method:c,data:c,baseURL:f,transformRequest:f,transformResponse:f,paramsSerializer:f,timeout:f,timeoutMessage:f,withCredentials:f,withXSRFToken:f,adapter:f,responseType:f,xsrfCookieName:f,xsrfHeaderName:f,onUploadProgress:f,onDownloadProgress:f,decompress:f,maxContentLength:f,maxBodyLength:f,beforeRedirect:f,transport:f,httpAgent:f,httpsAgent:f,cancelToken:f,socketPath:f,responseEncoding:f,validateStatus:m,headers:(p,y,S)=>o(i6(p),i6(y),S,!0)};return Xe.forEach(Object.keys(Object.assign({},e,t)),function(y){const S=g[y]||o,E=S(e[y],t[y],y);Xe.isUndefined(E)&&S!==m||(a[y]=E)}),a}const o6=e=>{const t=jd({},e);let{data:a,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:c,headers:f,auth:m}=t;t.headers=f=vo.from(f),t.url=W4(r6(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),m&&f.set("Authorization","Basic "+btoa((m.username||"")+":"+(m.password?unescape(encodeURIComponent(m.password)):"")));let g;if(Xe.isFormData(a)){if(Ei.hasStandardBrowserEnv||Ei.hasStandardBrowserWebWorkerEnv)f.setContentType(void 0);else if((g=f.getContentType())!==!1){const[p,...y]=g?g.split(";").map(S=>S.trim()).filter(Boolean):[];f.setContentType([p||"multipart/form-data",...y].join("; "))}}if(Ei.hasStandardBrowserEnv&&(r&&Xe.isFunction(r)&&(r=r(t)),r||r!==!1&&VW(t.url))){const p=o&&c&&HW.read(c);p&&f.set(o,p)}return t},UW=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(a,r){const o=o6(e);let c=o.data;const f=vo.from(o.headers).normalize();let{responseType:m,onUploadProgress:g,onDownloadProgress:p}=o,y,S,E,T,O;function M(){T&&T(),O&&O(),o.cancelToken&&o.cancelToken.unsubscribe(y),o.signal&&o.signal.removeEventListener("abort",y)}let A=new XMLHttpRequest;A.open(o.method.toUpperCase(),o.url,!0),A.timeout=o.timeout;function D(){if(!A)return;const j=vo.from("getAllResponseHeaders"in A&&A.getAllResponseHeaders()),$={data:!m||m==="text"||m==="json"?A.responseText:A.response,status:A.status,statusText:A.statusText,headers:j,config:e,request:A};t6(function(H){a(H),M()},function(H){r(H),M()},$),A=null}"onloadend"in A?A.onloadend=D:A.onreadystatechange=function(){!A||A.readyState!==4||A.status===0&&!(A.responseURL&&A.responseURL.indexOf("file:")===0)||setTimeout(D)},A.onabort=function(){A&&(r(new Cn("Request aborted",Cn.ECONNABORTED,e,A)),A=null)},A.onerror=function(){r(new Cn("Network Error",Cn.ERR_NETWORK,e,A)),A=null},A.ontimeout=function(){let V=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const $=o.transitional||K4;o.timeoutErrorMessage&&(V=o.timeoutErrorMessage),r(new Cn(V,$.clarifyTimeoutError?Cn.ETIMEDOUT:Cn.ECONNABORTED,e,A)),A=null},c===void 0&&f.setContentType(null),"setRequestHeader"in A&&Xe.forEach(f.toJSON(),function(V,$){A.setRequestHeader($,V)}),Xe.isUndefined(o.withCredentials)||(A.withCredentials=!!o.withCredentials),m&&m!=="json"&&(A.responseType=o.responseType),p&&([E,O]=q1(p,!0),A.addEventListener("progress",E)),g&&A.upload&&([S,T]=q1(g),A.upload.addEventListener("progress",S),A.upload.addEventListener("loadend",T)),(o.cancelToken||o.signal)&&(y=j=>{A&&(r(!j||j.type?new Gm(null,e,A):j),A.abort(),A=null)},o.cancelToken&&o.cancelToken.subscribe(y),o.signal&&(o.signal.aborted?y():o.signal.addEventListener("abort",y)));const _=zW(o.url);if(_&&Ei.protocols.indexOf(_)===-1){r(new Cn("Unsupported protocol "+_+":",Cn.ERR_BAD_REQUEST,e));return}A.send(c||null)})},IW=(e,t)=>{const{length:a}=e=e?e.filter(Boolean):[];if(t||a){let r=new AbortController,o;const c=function(p){if(!o){o=!0,m();const y=p instanceof Error?p:this.reason;r.abort(y instanceof Cn?y:new Gm(y instanceof Error?y.message:y))}};let f=t&&setTimeout(()=>{f=null,c(new Cn(`timeout ${t} of ms exceeded`,Cn.ETIMEDOUT))},t);const m=()=>{e&&(f&&clearTimeout(f),f=null,e.forEach(p=>{p.unsubscribe?p.unsubscribe(c):p.removeEventListener("abort",c)}),e=null)};e.forEach(p=>p.addEventListener("abort",c));const{signal:g}=r;return g.unsubscribe=()=>Xe.asap(m),g}},kW=function*(e,t){let a=e.byteLength;if(a<t){yield e;return}let r=0,o;for(;r<a;)o=r+t,yield e.slice(r,o),r=o},FW=async function*(e,t){for await(const a of qW(e))yield*kW(a,t)},qW=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:a,value:r}=await t.read();if(a)break;yield r}}finally{await t.cancel()}},l6=(e,t,a,r)=>{const o=FW(e,t);let c=0,f,m=g=>{f||(f=!0,r&&r(g))};return new ReadableStream({async pull(g){try{const{done:p,value:y}=await o.next();if(p){m(),g.close();return}let S=y.byteLength;if(a){let E=c+=S;a(E)}g.enqueue(new Uint8Array(y))}catch(p){throw m(p),p}},cancel(g){return m(g),o.return()}},{highWaterMark:2})},G1=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",s6=G1&&typeof ReadableStream=="function",GW=G1&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),u6=(e,...t)=>{try{return!!e(...t)}catch{return!1}},XW=s6&&u6(()=>{let e=!1;const t=new Request(Ei.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),c6=64*1024,dO=s6&&u6(()=>Xe.isReadableStream(new Response("").body)),X1={stream:dO&&(e=>e.body)};G1&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!X1[t]&&(X1[t]=Xe.isFunction(e[t])?a=>a[t]():(a,r)=>{throw new Cn(`Response type '${t}' is not supported`,Cn.ERR_NOT_SUPPORT,r)})})})(new Response);const YW=async e=>{if(e==null)return 0;if(Xe.isBlob(e))return e.size;if(Xe.isSpecCompliantForm(e))return(await new Request(Ei.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(Xe.isArrayBufferView(e)||Xe.isArrayBuffer(e))return e.byteLength;if(Xe.isURLSearchParams(e)&&(e=e+""),Xe.isString(e))return(await GW(e)).byteLength},WW=async(e,t)=>{const a=Xe.toFiniteNumber(e.getContentLength());return a??YW(t)},hO={http:gW,xhr:UW,fetch:G1&&(async e=>{let{url:t,method:a,data:r,signal:o,cancelToken:c,timeout:f,onDownloadProgress:m,onUploadProgress:g,responseType:p,headers:y,withCredentials:S="same-origin",fetchOptions:E}=o6(e);p=p?(p+"").toLowerCase():"text";let T=IW([o,c&&c.toAbortSignal()],f),O;const M=T&&T.unsubscribe&&(()=>{T.unsubscribe()});let A;try{if(g&&XW&&a!=="get"&&a!=="head"&&(A=await WW(y,r))!==0){let $=new Request(t,{method:"POST",body:r,duplex:"half"}),L;if(Xe.isFormData(r)&&(L=$.headers.get("content-type"))&&y.setContentType(L),$.body){const[H,z]=n6(A,q1(a6(g)));r=l6($.body,c6,H,z)}}Xe.isString(S)||(S=S?"include":"omit");const D="credentials"in Request.prototype;O=new Request(t,{...E,signal:T,method:a.toUpperCase(),headers:y.normalize().toJSON(),body:r,duplex:"half",credentials:D?S:void 0});let _=await fetch(O,E);const j=dO&&(p==="stream"||p==="response");if(dO&&(m||j&&M)){const $={};["status","statusText","headers"].forEach(U=>{$[U]=_[U]});const L=Xe.toFiniteNumber(_.headers.get("content-length")),[H,z]=m&&n6(L,q1(a6(m),!0))||[];_=new Response(l6(_.body,c6,H,()=>{z&&z(),M&&M()}),$)}p=p||"text";let V=await X1[Xe.findKey(X1,p)||"text"](_,e);return!j&&M&&M(),await new Promise(($,L)=>{t6($,L,{data:V,headers:vo.from(_.headers),status:_.status,statusText:_.statusText,config:e,request:O})})}catch(D){throw M&&M(),D&&D.name==="TypeError"&&/Load failed|fetch/i.test(D.message)?Object.assign(new Cn("Network Error",Cn.ERR_NETWORK,e,O),{cause:D.cause||D}):Cn.from(D,D&&D.code,e,O)}})};Xe.forEach(hO,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const f6=e=>`- ${e}`,ZW=e=>Xe.isFunction(e)||e===null||e===!1,d6={getAdapter:e=>{e=Xe.isArray(e)?e:[e];const{length:t}=e;let a,r;const o={};for(let c=0;c<t;c++){a=e[c];let f;if(r=a,!ZW(a)&&(r=hO[(f=String(a)).toLowerCase()],r===void 0))throw new Cn(`Unknown adapter '${f}'`);if(r)break;o[f||"#"+c]=r}if(!r){const c=Object.entries(o).map(([m,g])=>`adapter ${m} `+(g===!1?"is not supported by the environment":"is not available in the build"));let f=t?c.length>1?`since :
570
570
  `+c.map(f6).join(`
571
571
  `):" "+f6(c[0]):"as no adapter specified";throw new Cn("There is no suitable adapter to dispatch the request "+f,"ERR_NOT_SUPPORT")}return r},adapters:hO};function mO(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Gm(null,e)}function h6(e){return mO(e),e.headers=vo.from(e.headers),e.data=fO.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),d6.getAdapter(e.adapter||h0.adapter)(e).then(function(r){return mO(e),r.data=fO.call(e,e.transformResponse,r),r.headers=vo.from(r.headers),r},function(r){return e6(r)||(mO(e),r&&r.response&&(r.response.data=fO.call(e,e.transformResponse,r.response),r.response.headers=vo.from(r.response.headers))),Promise.reject(r)})}const m6="1.10.0",Y1={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Y1[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const p6={};Y1.transitional=function(t,a,r){function o(c,f){return"[Axios v"+m6+"] Transitional option '"+c+"'"+f+(r?". "+r:"")}return(c,f,m)=>{if(t===!1)throw new Cn(o(f," has been removed"+(a?" in "+a:"")),Cn.ERR_DEPRECATED);return a&&!p6[f]&&(p6[f]=!0,console.warn(o(f," has been deprecated since v"+a+" and will be removed in the near future"))),t?t(c,f,m):!0}},Y1.spelling=function(t){return(a,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function KW(e,t,a){if(typeof e!="object")throw new Cn("options must be an object",Cn.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const c=r[o],f=t[c];if(f){const m=e[c],g=m===void 0||f(m,c,e);if(g!==!0)throw new Cn("option "+c+" must be "+g,Cn.ERR_BAD_OPTION_VALUE);continue}if(a!==!0)throw new Cn("Unknown option "+c,Cn.ERR_BAD_OPTION)}}const W1={assertOptions:KW,validators:Y1},Zs=W1.validators;let Ld=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Z4,response:new Z4}}async request(t,a){try{return await this._request(t,a)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const c=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?c&&!String(r.stack).endsWith(c.replace(/^.+\n.+\n/,""))&&(r.stack+=`
572
- `+c):r.stack=c}catch{}}throw r}}_request(t,a){typeof t=="string"?(a=a||{},a.url=t):a=t||{},a=jd(this.defaults,a);const{transitional:r,paramsSerializer:o,headers:c}=a;r!==void 0&&W1.assertOptions(r,{silentJSONParsing:Zs.transitional(Zs.boolean),forcedJSONParsing:Zs.transitional(Zs.boolean),clarifyTimeoutError:Zs.transitional(Zs.boolean)},!1),o!=null&&(Xe.isFunction(o)?a.paramsSerializer={serialize:o}:W1.assertOptions(o,{encode:Zs.function,serialize:Zs.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),W1.assertOptions(a,{baseUrl:Zs.spelling("baseURL"),withXsrfToken:Zs.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let f=c&&Xe.merge(c.common,c[a.method]);c&&Xe.forEach(["delete","get","head","post","put","patch","common"],O=>{delete c[O]}),a.headers=vo.concat(f,c);const m=[];let g=!0;this.interceptors.request.forEach(function(M){typeof M.runWhen=="function"&&M.runWhen(a)===!1||(g=g&&M.synchronous,m.unshift(M.fulfilled,M.rejected))});const p=[];this.interceptors.response.forEach(function(M){p.push(M.fulfilled,M.rejected)});let y,S=0,E;if(!g){const O=[h6.bind(this),void 0];for(O.unshift.apply(O,m),O.push.apply(O,p),E=O.length,y=Promise.resolve(a);S<E;)y=y.then(O[S++],O[S++]);return y}E=m.length;let T=a;for(S=0;S<E;){const O=m[S++],M=m[S++];try{T=O(T)}catch(A){M.call(this,A);break}}try{y=h6.call(this,T)}catch(O){return Promise.reject(O)}for(S=0,E=p.length;S<E;)y=y.then(p[S++],p[S++]);return y}getUri(t){t=jd(this.defaults,t);const a=r6(t.baseURL,t.url,t.allowAbsoluteUrls);return W4(a,t.params,t.paramsSerializer)}};Xe.forEach(["delete","get","head","options"],function(t){Ld.prototype[t]=function(a,r){return this.request(jd(r||{},{method:t,url:a,data:(r||{}).data}))}}),Xe.forEach(["post","put","patch"],function(t){function a(r){return function(c,f,m){return this.request(jd(m||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:c,data:f}))}}Ld.prototype[t]=a(),Ld.prototype[t+"Form"]=a(!0)});let QW=class u8{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let a;this.promise=new Promise(function(c){a=c});const r=this;this.promise.then(o=>{if(!r._listeners)return;let c=r._listeners.length;for(;c-- >0;)r._listeners[c](o);r._listeners=null}),this.promise.then=o=>{let c;const f=new Promise(m=>{r.subscribe(m),c=m}).then(o);return f.cancel=function(){r.unsubscribe(c)},f},t(function(c,f,m){r.reason||(r.reason=new Gm(c,f,m),a(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const a=this._listeners.indexOf(t);a!==-1&&this._listeners.splice(a,1)}toAbortSignal(){const t=new AbortController,a=r=>{t.abort(r)};return this.subscribe(a),t.signal.unsubscribe=()=>this.unsubscribe(a),t.signal}static source(){let t;return{token:new u8(function(o){t=o}),cancel:t}}};function JW(e){return function(a){return e.apply(null,a)}}function eZ(e){return Xe.isObject(e)&&e.isAxiosError===!0}const pO={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(pO).forEach(([e,t])=>{pO[t]=e});function g6(e){const t=new Ld(e),a=z4(Ld.prototype.request,t);return Xe.extend(a,Ld.prototype,t,{allOwnKeys:!0}),Xe.extend(a,t,null,{allOwnKeys:!0}),a.create=function(o){return g6(jd(e,o))},a}const $a=g6(h0);$a.Axios=Ld,$a.CanceledError=Gm,$a.CancelToken=QW,$a.isCancel=e6,$a.VERSION=m6,$a.toFormData=k1,$a.AxiosError=Cn,$a.Cancel=$a.CanceledError,$a.all=function(t){return Promise.all(t)},$a.spread=JW,$a.isAxiosError=eZ,$a.mergeConfig=jd,$a.AxiosHeaders=vo,$a.formToJSON=e=>Q4(Xe.isHTMLForm(e)?new FormData(e):e),$a.getAdapter=d6.getAdapter,$a.HttpStatusCode=pO,$a.default=$a;const{Axios:eoe,AxiosError:toe,CanceledError:noe,isCancel:aoe,CancelToken:roe,VERSION:ioe,all:ooe,Cancel:loe,isAxiosError:soe,spread:uoe,toFormData:coe,AxiosHeaders:foe,HttpStatusCode:doe,formToJSON:hoe,getAdapter:moe,mergeConfig:poe}=$a,wi={apiUrl:"https://jawebcrm.onrender.com/api/",websocketUrl:"wss://jawebcrm.onrender.com/ws"},sn=e=>typeof e=="string",p0=()=>{let e,t;const a=new Promise((r,o)=>{e=r,t=o});return a.resolve=e,a.reject=t,a},v6=e=>e==null?"":""+e,tZ=(e,t,a)=>{e.forEach(r=>{t[r]&&(a[r]=t[r])})},nZ=/###/g,y6=e=>e&&e.indexOf("###")>-1?e.replace(nZ,"."):e,b6=e=>!e||sn(e),g0=(e,t,a)=>{const r=sn(t)?t.split("."):t;let o=0;for(;o<r.length-1;){if(b6(e))return{};const c=y6(r[o]);!e[c]&&a&&(e[c]=new a),Object.prototype.hasOwnProperty.call(e,c)?e=e[c]:e={},++o}return b6(e)?{}:{obj:e,k:y6(r[o])}},S6=(e,t,a)=>{const{obj:r,k:o}=g0(e,t,Object);if(r!==void 0||t.length===1){r[o]=a;return}let c=t[t.length-1],f=t.slice(0,t.length-1),m=g0(e,f,Object);for(;m.obj===void 0&&f.length;)c=`${f[f.length-1]}.${c}`,f=f.slice(0,f.length-1),m=g0(e,f,Object),m?.obj&&typeof m.obj[`${m.k}.${c}`]<"u"&&(m.obj=void 0);m.obj[`${m.k}.${c}`]=a},aZ=(e,t,a,r)=>{const{obj:o,k:c}=g0(e,t,Object);o[c]=o[c]||[],o[c].push(a)},Z1=(e,t)=>{const{obj:a,k:r}=g0(e,t);if(a&&Object.prototype.hasOwnProperty.call(a,r))return a[r]},rZ=(e,t,a)=>{const r=Z1(e,a);return r!==void 0?r:Z1(t,a)},x6=(e,t,a)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?sn(e[r])||e[r]instanceof String||sn(t[r])||t[r]instanceof String?a&&(e[r]=t[r]):x6(e[r],t[r],a):e[r]=t[r]);return e},Xm=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var iZ={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const oZ=e=>sn(e)?e.replace(/[&<>"'\/]/g,t=>iZ[t]):e;class lZ{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const a=this.regExpMap.get(t);if(a!==void 0)return a;const r=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,r),this.regExpQueue.push(t),r}}const sZ=[" ",",","?","!",";"],uZ=new lZ(20),cZ=(e,t,a)=>{t=t||"",a=a||"";const r=sZ.filter(f=>t.indexOf(f)<0&&a.indexOf(f)<0);if(r.length===0)return!0;const o=uZ.getRegExp(`(${r.map(f=>f==="?"?"\\?":f).join("|")})`);let c=!o.test(e);if(!c){const f=e.indexOf(a);f>0&&!o.test(e.substring(0,f))&&(c=!0)}return c},gO=(e,t,a=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;const r=t.split(a);let o=e;for(let c=0;c<r.length;){if(!o||typeof o!="object")return;let f,m="";for(let g=c;g<r.length;++g)if(g!==c&&(m+=a),m+=r[g],f=o[m],f!==void 0){if(["string","number","boolean"].indexOf(typeof f)>-1&&g<r.length-1)continue;c+=g-c+1;break}o=f}return o},v0=e=>e?.replace("_","-"),fZ={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class K1{constructor(t,a={}){this.init(t,a)}init(t,a={}){this.prefix=a.prefix||"i18next:",this.logger=t||fZ,this.options=a,this.debug=a.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,a,r,o){return o&&!this.debug?null:(sn(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[a](t))}create(t){return new K1(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new K1(this.logger,t)}}var Ks=new K1;class Q1{constructor(){this.observers={}}on(t,a){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const o=this.observers[r].get(a)||0;this.observers[r].set(a,o+1)}),this}off(t,a){if(this.observers[t]){if(!a){delete this.observers[t];return}this.observers[t].delete(a)}}emit(t,...a){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([o,c])=>{for(let f=0;f<c;f++)o(...a)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([o,c])=>{for(let f=0;f<c;f++)o.apply(o,[t,...a])})}}class C6 extends Q1{constructor(t,a={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=a,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const a=this.options.ns.indexOf(t);a>-1&&this.options.ns.splice(a,1)}getResource(t,a,r,o={}){const c=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator,f=o.ignoreJSONStructure!==void 0?o.ignoreJSONStructure:this.options.ignoreJSONStructure;let m;t.indexOf(".")>-1?m=t.split("."):(m=[t,a],r&&(Array.isArray(r)?m.push(...r):sn(r)&&c?m.push(...r.split(c)):m.push(r)));const g=Z1(this.data,m);return!g&&!a&&!r&&t.indexOf(".")>-1&&(t=m[0],a=m[1],r=m.slice(2).join(".")),g||!f||!sn(r)?g:gO(this.data?.[t]?.[a],r,c)}addResource(t,a,r,o,c={silent:!1}){const f=c.keySeparator!==void 0?c.keySeparator:this.options.keySeparator;let m=[t,a];r&&(m=m.concat(f?r.split(f):r)),t.indexOf(".")>-1&&(m=t.split("."),o=a,a=m[1]),this.addNamespaces(a),S6(this.data,m,o),c.silent||this.emit("added",t,a,r,o)}addResources(t,a,r,o={silent:!1}){for(const c in r)(sn(r[c])||Array.isArray(r[c]))&&this.addResource(t,a,c,r[c],{silent:!0});o.silent||this.emit("added",t,a,r)}addResourceBundle(t,a,r,o,c,f={silent:!1,skipCopy:!1}){let m=[t,a];t.indexOf(".")>-1&&(m=t.split("."),o=r,r=a,a=m[1]),this.addNamespaces(a);let g=Z1(this.data,m)||{};f.skipCopy||(r=JSON.parse(JSON.stringify(r))),o?x6(g,r,c):g={...g,...r},S6(this.data,m,g),f.silent||this.emit("added",t,a,r)}removeResourceBundle(t,a){this.hasResourceBundle(t,a)&&delete this.data[t][a],this.removeNamespaces(a),this.emit("removed",t,a)}hasResourceBundle(t,a){return this.getResource(t,a)!==void 0}getResourceBundle(t,a){return a||(a=this.options.defaultNS),this.getResource(t,a)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const a=this.getDataByLanguage(t);return!!(a&&Object.keys(a)||[]).find(o=>a[o]&&Object.keys(a[o]).length>0)}toJSON(){return this.data}}var E6={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,a,r,o){return e.forEach(c=>{t=this.processors[c]?.process(t,a,r,o)??t}),t}};const w6={},T6=e=>!sn(e)&&typeof e!="boolean"&&typeof e!="number";class J1 extends Q1{constructor(t,a={}){super(),tZ(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=a,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Ks.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,a={interpolation:{}}){const r={...a};return t==null?!1:this.resolve(t,r)?.res!==void 0}extractFromKey(t,a){let r=a.nsSeparator!==void 0?a.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const o=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let c=a.ns||this.options.defaultNS||[];const f=r&&t.indexOf(r)>-1,m=!this.options.userDefinedKeySeparator&&!a.keySeparator&&!this.options.userDefinedNsSeparator&&!a.nsSeparator&&!cZ(t,r,o);if(f&&!m){const g=t.match(this.interpolator.nestingRegexp);if(g&&g.length>0)return{key:t,namespaces:sn(c)?[c]:c};const p=t.split(r);(r!==o||r===o&&this.options.ns.indexOf(p[0])>-1)&&(c=p.shift()),t=p.join(o)}return{key:t,namespaces:sn(c)?[c]:c}}translate(t,a,r){let o=typeof a=="object"?{...a}:a;if(typeof o!="object"&&this.options.overloadTranslationOptionHandler&&(o=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(o={...o}),o||(o={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const c=o.returnDetails!==void 0?o.returnDetails:this.options.returnDetails,f=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator,{key:m,namespaces:g}=this.extractFromKey(t[t.length-1],o),p=g[g.length-1];let y=o.nsSeparator!==void 0?o.nsSeparator:this.options.nsSeparator;y===void 0&&(y=":");const S=o.lng||this.language,E=o.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(S?.toLowerCase()==="cimode")return E?c?{res:`${p}${y}${m}`,usedKey:m,exactUsedKey:m,usedLng:S,usedNS:p,usedParams:this.getUsedParamsDetails(o)}:`${p}${y}${m}`:c?{res:m,usedKey:m,exactUsedKey:m,usedLng:S,usedNS:p,usedParams:this.getUsedParamsDetails(o)}:m;const T=this.resolve(t,o);let O=T?.res;const M=T?.usedKey||m,A=T?.exactUsedKey||m,D=["[object Number]","[object Function]","[object RegExp]"],_=o.joinArrays!==void 0?o.joinArrays:this.options.joinArrays,j=!this.i18nFormat||this.i18nFormat.handleAsObject,V=o.count!==void 0&&!sn(o.count),$=J1.hasDefaultValue(o),L=V?this.pluralResolver.getSuffix(S,o.count,o):"",H=o.ordinal&&V?this.pluralResolver.getSuffix(S,o.count,{ordinal:!1}):"",z=V&&!o.ordinal&&o.count===0,U=z&&o[`defaultValue${this.options.pluralSeparator}zero`]||o[`defaultValue${L}`]||o[`defaultValue${H}`]||o.defaultValue;let B=O;j&&!O&&$&&(B=U);const J=T6(B),X=Object.prototype.toString.apply(B);if(j&&B&&J&&D.indexOf(X)<0&&!(sn(_)&&Array.isArray(B))){if(!o.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const W=this.options.returnedObjectHandler?this.options.returnedObjectHandler(M,B,{...o,ns:g}):`key '${m} (${this.language})' returned an object instead of string.`;return c?(T.res=W,T.usedParams=this.getUsedParamsDetails(o),T):W}if(f){const W=Array.isArray(B),K=W?[]:{},re=W?A:M;for(const F in B)if(Object.prototype.hasOwnProperty.call(B,F)){const G=`${re}${f}${F}`;$&&!O?K[F]=this.translate(G,{...o,defaultValue:T6(U)?U[F]:void 0,joinArrays:!1,ns:g}):K[F]=this.translate(G,{...o,joinArrays:!1,ns:g}),K[F]===G&&(K[F]=B[F])}O=K}}else if(j&&sn(_)&&Array.isArray(O))O=O.join(_),O&&(O=this.extendTranslation(O,t,o,r));else{let W=!1,K=!1;!this.isValidLookup(O)&&$&&(W=!0,O=U),this.isValidLookup(O)||(K=!0,O=m);const F=(o.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&K?void 0:O,G=$&&U!==O&&this.options.updateMissing;if(K||W||G){if(this.logger.log(G?"updateKey":"missingKey",S,p,m,G?U:O),f){const q=this.resolve(m,{...o,keySeparator:!1});q&&q.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Z=[];const se=this.languageUtils.getFallbackCodes(this.options.fallbackLng,o.lng||this.language);if(this.options.saveMissingTo==="fallback"&&se&&se[0])for(let q=0;q<se.length;q++)Z.push(se[q]);else this.options.saveMissingTo==="all"?Z=this.languageUtils.toResolveHierarchy(o.lng||this.language):Z.push(o.lng||this.language);const k=(q,ee,ne)=>{const oe=$&&ne!==O?ne:F;this.options.missingKeyHandler?this.options.missingKeyHandler(q,p,ee,oe,G,o):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(q,p,ee,oe,G,o),this.emit("missingKey",q,p,ee,O)};this.options.saveMissing&&(this.options.saveMissingPlurals&&V?Z.forEach(q=>{const ee=this.pluralResolver.getSuffixes(q,o);z&&o[`defaultValue${this.options.pluralSeparator}zero`]&&ee.indexOf(`${this.options.pluralSeparator}zero`)<0&&ee.push(`${this.options.pluralSeparator}zero`),ee.forEach(ne=>{k([q],m+ne,o[`defaultValue${ne}`]||U)})}):k(Z,m,U))}O=this.extendTranslation(O,t,o,T,r),K&&O===m&&this.options.appendNamespaceToMissingKey&&(O=`${p}${y}${m}`),(K||W)&&this.options.parseMissingKeyHandler&&(O=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${p}${y}${m}`:m,W?O:void 0,o))}return c?(T.res=O,T.usedParams=this.getUsedParamsDetails(o),T):O}extendTranslation(t,a,r,o,c){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||o.usedLng,o.usedNS,o.usedKey,{resolved:o});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const g=sn(t)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let p;if(g){const S=t.match(this.interpolator.nestingRegexp);p=S&&S.length}let y=r.replace&&!sn(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(y={...this.options.interpolation.defaultVariables,...y}),t=this.interpolator.interpolate(t,y,r.lng||this.language||o.usedLng,r),g){const S=t.match(this.interpolator.nestingRegexp),E=S&&S.length;p<E&&(r.nest=!1)}!r.lng&&o&&o.res&&(r.lng=this.language||o.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,(...S)=>c?.[0]===S[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${S[0]} in key: ${a[0]}`),null):this.translate(...S,a),r)),r.interpolation&&this.interpolator.reset()}const f=r.postProcess||this.options.postProcess,m=sn(f)?[f]:f;return t!=null&&m?.length&&r.applyPostProcessor!==!1&&(t=E6.handle(m,t,a,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...o,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t,a={}){let r,o,c,f,m;return sn(t)&&(t=[t]),t.forEach(g=>{if(this.isValidLookup(r))return;const p=this.extractFromKey(g,a),y=p.key;o=y;let S=p.namespaces;this.options.fallbackNS&&(S=S.concat(this.options.fallbackNS));const E=a.count!==void 0&&!sn(a.count),T=E&&!a.ordinal&&a.count===0,O=a.context!==void 0&&(sn(a.context)||typeof a.context=="number")&&a.context!=="",M=a.lngs?a.lngs:this.languageUtils.toResolveHierarchy(a.lng||this.language,a.fallbackLng);S.forEach(A=>{this.isValidLookup(r)||(m=A,!w6[`${M[0]}-${A}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(m)&&(w6[`${M[0]}-${A}`]=!0,this.logger.warn(`key "${o}" for languages "${M.join(", ")}" won't get resolved as namespace "${m}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),M.forEach(D=>{if(this.isValidLookup(r))return;f=D;const _=[y];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(_,y,D,A,a);else{let V;E&&(V=this.pluralResolver.getSuffix(D,a.count,a));const $=`${this.options.pluralSeparator}zero`,L=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(E&&(_.push(y+V),a.ordinal&&V.indexOf(L)===0&&_.push(y+V.replace(L,this.options.pluralSeparator)),T&&_.push(y+$)),O){const H=`${y}${this.options.contextSeparator}${a.context}`;_.push(H),E&&(_.push(H+V),a.ordinal&&V.indexOf(L)===0&&_.push(H+V.replace(L,this.options.pluralSeparator)),T&&_.push(H+$))}}let j;for(;j=_.pop();)this.isValidLookup(r)||(c=j,r=this.getResource(D,A,j,a))}))})}),{res:r,usedKey:o,exactUsedKey:c,usedLng:f,usedNS:m}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,a,r,o={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,a,r,o):this.resourceStore.getResource(t,a,r,o)}getUsedParamsDetails(t={}){const a=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!sn(t.replace);let o=r?t.replace:t;if(r&&typeof t.count<"u"&&(o.count=t.count),this.options.interpolation.defaultVariables&&(o={...this.options.interpolation.defaultVariables,...o}),!r){o={...o};for(const c of a)delete o[c]}return o}static hasDefaultValue(t){const a="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&a===r.substring(0,a.length)&&t[r]!==void 0)return!0;return!1}}class O6{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ks.create("languageUtils")}getScriptPartFromCode(t){if(t=v0(t),!t||t.indexOf("-")<0)return null;const a=t.split("-");return a.length===2||(a.pop(),a[a.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(a.join("-"))}getLanguagePartFromCode(t){if(t=v0(t),!t||t.indexOf("-")<0)return t;const a=t.split("-");return this.formatLanguageCode(a[0])}formatLanguageCode(t){if(sn(t)&&t.indexOf("-")>-1){let a;try{a=Intl.getCanonicalLocales(t)[0]}catch{}return a&&this.options.lowerCaseLng&&(a=a.toLowerCase()),a||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let a;return t.forEach(r=>{if(a)return;const o=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(o))&&(a=o)}),!a&&this.options.supportedLngs&&t.forEach(r=>{if(a)return;const o=this.getScriptPartFromCode(r);if(this.isSupportedCode(o))return a=o;const c=this.getLanguagePartFromCode(r);if(this.isSupportedCode(c))return a=c;a=this.options.supportedLngs.find(f=>{if(f===c)return f;if(!(f.indexOf("-")<0&&c.indexOf("-")<0)&&(f.indexOf("-")>0&&c.indexOf("-")<0&&f.substring(0,f.indexOf("-"))===c||f.indexOf(c)===0&&c.length>1))return f})}),a||(a=this.getFallbackCodes(this.options.fallbackLng)[0]),a}getFallbackCodes(t,a){if(!t)return[];if(typeof t=="function"&&(t=t(a)),sn(t)&&(t=[t]),Array.isArray(t))return t;if(!a)return t.default||[];let r=t[a];return r||(r=t[this.getScriptPartFromCode(a)]),r||(r=t[this.formatLanguageCode(a)]),r||(r=t[this.getLanguagePartFromCode(a)]),r||(r=t.default),r||[]}toResolveHierarchy(t,a){const r=this.getFallbackCodes((a===!1?[]:a)||this.options.fallbackLng||[],t),o=[],c=f=>{f&&(this.isSupportedCode(f)?o.push(f):this.logger.warn(`rejecting language code not found in supportedLngs: ${f}`))};return sn(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&c(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&c(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&c(this.getLanguagePartFromCode(t))):sn(t)&&c(this.formatLanguageCode(t)),r.forEach(f=>{o.indexOf(f)<0&&c(this.formatLanguageCode(f))}),o}}const R6={zero:0,one:1,two:2,few:3,many:4,other:5},A6={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class dZ{constructor(t,a={}){this.languageUtils=t,this.options=a,this.logger=Ks.create("pluralResolver"),this.pluralRulesCache={}}addRule(t,a){this.rules[t]=a}clearCache(){this.pluralRulesCache={}}getRule(t,a={}){const r=v0(t==="dev"?"en":t),o=a.ordinal?"ordinal":"cardinal",c=JSON.stringify({cleanedCode:r,type:o});if(c in this.pluralRulesCache)return this.pluralRulesCache[c];let f;try{f=new Intl.PluralRules(r,{type:o})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),A6;if(!t.match(/-|_/))return A6;const g=this.languageUtils.getLanguagePartFromCode(t);f=this.getRule(g,a)}return this.pluralRulesCache[c]=f,f}needsPlural(t,a={}){let r=this.getRule(t,a);return r||(r=this.getRule("dev",a)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,a,r={}){return this.getSuffixes(t,r).map(o=>`${a}${o}`)}getSuffixes(t,a={}){let r=this.getRule(t,a);return r||(r=this.getRule("dev",a)),r?r.resolvedOptions().pluralCategories.sort((o,c)=>R6[o]-R6[c]).map(o=>`${this.options.prepend}${a.ordinal?`ordinal${this.options.prepend}`:""}${o}`):[]}getSuffix(t,a,r={}){const o=this.getRule(t,r);return o?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${o.select(a)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",a,r))}}const M6=(e,t,a,r=".",o=!0)=>{let c=rZ(e,t,a);return!c&&o&&sn(a)&&(c=gO(e,a,r),c===void 0&&(c=gO(t,a,r))),c},vO=e=>e.replace(/\$/g,"$$$$");class hZ{constructor(t={}){this.logger=Ks.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(a=>a),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:a,escapeValue:r,useRawValueToEscape:o,prefix:c,prefixEscaped:f,suffix:m,suffixEscaped:g,formatSeparator:p,unescapeSuffix:y,unescapePrefix:S,nestingPrefix:E,nestingPrefixEscaped:T,nestingSuffix:O,nestingSuffixEscaped:M,nestingOptionsSeparator:A,maxReplaces:D,alwaysFormat:_}=t.interpolation;this.escape=a!==void 0?a:oZ,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=o!==void 0?o:!1,this.prefix=c?Xm(c):f||"{{",this.suffix=m?Xm(m):g||"}}",this.formatSeparator=p||",",this.unescapePrefix=y?"":S||"-",this.unescapeSuffix=this.unescapePrefix?"":y||"",this.nestingPrefix=E?Xm(E):T||Xm("$t("),this.nestingSuffix=O?Xm(O):M||Xm(")"),this.nestingOptionsSeparator=A||",",this.maxReplaces=D||1e3,this.alwaysFormat=_!==void 0?_:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(a,r)=>a?.source===r?(a.lastIndex=0,a):new RegExp(r,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,a,r,o){let c,f,m;const g=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},p=T=>{if(T.indexOf(this.formatSeparator)<0){const D=M6(a,g,T,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(D,void 0,r,{...o,...a,interpolationkey:T}):D}const O=T.split(this.formatSeparator),M=O.shift().trim(),A=O.join(this.formatSeparator).trim();return this.format(M6(a,g,M,this.options.keySeparator,this.options.ignoreJSONStructure),A,r,{...o,...a,interpolationkey:M})};this.resetRegExp();const y=o?.missingInterpolationHandler||this.options.missingInterpolationHandler,S=o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:T=>vO(T)},{regex:this.regexp,safeValue:T=>this.escapeValue?vO(this.escape(T)):vO(T)}].forEach(T=>{for(m=0;c=T.regex.exec(t);){const O=c[1].trim();if(f=p(O),f===void 0)if(typeof y=="function"){const A=y(t,c,o);f=sn(A)?A:""}else if(o&&Object.prototype.hasOwnProperty.call(o,O))f="";else if(S){f=c[0];continue}else this.logger.warn(`missed to pass in variable ${O} for interpolating ${t}`),f="";else!sn(f)&&!this.useRawValueToEscape&&(f=v6(f));const M=T.safeValue(f);if(t=t.replace(c[0],M),S?(T.regex.lastIndex+=f.length,T.regex.lastIndex-=c[0].length):T.regex.lastIndex=0,m++,m>=this.maxReplaces)break}}),t}nest(t,a,r={}){let o,c,f;const m=(g,p)=>{const y=this.nestingOptionsSeparator;if(g.indexOf(y)<0)return g;const S=g.split(new RegExp(`${y}[ ]*{`));let E=`{${S[1]}`;g=S[0],E=this.interpolate(E,f);const T=E.match(/'/g),O=E.match(/"/g);((T?.length??0)%2===0&&!O||O.length%2!==0)&&(E=E.replace(/'/g,'"'));try{f=JSON.parse(E),p&&(f={...p,...f})}catch(M){return this.logger.warn(`failed parsing options string in nesting for key ${g}`,M),`${g}${y}${E}`}return f.defaultValue&&f.defaultValue.indexOf(this.prefix)>-1&&delete f.defaultValue,g};for(;o=this.nestingRegexp.exec(t);){let g=[];f={...r},f=f.replace&&!sn(f.replace)?f.replace:f,f.applyPostProcessor=!1,delete f.defaultValue;const p=/{.*}/.test(o[1])?o[1].lastIndexOf("}")+1:o[1].indexOf(this.formatSeparator);if(p!==-1&&(g=o[1].slice(p).split(this.formatSeparator).map(y=>y.trim()).filter(Boolean),o[1]=o[1].slice(0,p)),c=a(m.call(this,o[1].trim(),f),f),c&&o[0]===t&&!sn(c))return c;sn(c)||(c=v6(c)),c||(this.logger.warn(`missed to resolve ${o[1]} for nesting ${t}`),c=""),g.length&&(c=g.reduce((y,S)=>this.format(y,S,r.lng,{...r,interpolationkey:o[1].trim()}),c.trim())),t=t.replace(o[0],c),this.regexp.lastIndex=0}return t}}const mZ=e=>{let t=e.toLowerCase().trim();const a={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const o=r[1].substring(0,r[1].length-1);t==="currency"&&o.indexOf(":")<0?a.currency||(a.currency=o.trim()):t==="relativetime"&&o.indexOf(":")<0?a.range||(a.range=o.trim()):o.split(";").forEach(f=>{if(f){const[m,...g]=f.split(":"),p=g.join(":").trim().replace(/^'+|'+$/g,""),y=m.trim();a[y]||(a[y]=p),p==="false"&&(a[y]=!1),p==="true"&&(a[y]=!0),isNaN(p)||(a[y]=parseInt(p,10))}})}return{formatName:t,formatOptions:a}},_6=e=>{const t={};return(a,r,o)=>{let c=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(c={...c,[o.interpolationkey]:void 0});const f=r+JSON.stringify(c);let m=t[f];return m||(m=e(v0(r),o),t[f]=m),m(a)}},pZ=e=>(t,a,r)=>e(v0(a),r)(t);class gZ{constructor(t={}){this.logger=Ks.create("formatter"),this.options=t,this.init(t)}init(t,a={interpolation:{}}){this.formatSeparator=a.interpolation.formatSeparator||",";const r=a.cacheInBuiltFormats?_6:pZ;this.formats={number:r((o,c)=>{const f=new Intl.NumberFormat(o,{...c});return m=>f.format(m)}),currency:r((o,c)=>{const f=new Intl.NumberFormat(o,{...c,style:"currency"});return m=>f.format(m)}),datetime:r((o,c)=>{const f=new Intl.DateTimeFormat(o,{...c});return m=>f.format(m)}),relativetime:r((o,c)=>{const f=new Intl.RelativeTimeFormat(o,{...c});return m=>f.format(m,c.range||"day")}),list:r((o,c)=>{const f=new Intl.ListFormat(o,{...c});return m=>f.format(m)})}}add(t,a){this.formats[t.toLowerCase().trim()]=a}addCached(t,a){this.formats[t.toLowerCase().trim()]=_6(a)}format(t,a,r,o={}){const c=a.split(this.formatSeparator);if(c.length>1&&c[0].indexOf("(")>1&&c[0].indexOf(")")<0&&c.find(m=>m.indexOf(")")>-1)){const m=c.findIndex(g=>g.indexOf(")")>-1);c[0]=[c[0],...c.splice(1,m)].join(this.formatSeparator)}return c.reduce((m,g)=>{const{formatName:p,formatOptions:y}=mZ(g);if(this.formats[p]){let S=m;try{const E=o?.formatParams?.[o.interpolationkey]||{},T=E.locale||E.lng||o.locale||o.lng||r;S=this.formats[p](m,T,{...y,...o,...E})}catch(E){this.logger.warn(E)}return S}else this.logger.warn(`there was no format function for ${p}`);return m},t)}}const vZ=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class yZ extends Q1{constructor(t,a,r,o={}){super(),this.backend=t,this.store=a,this.services=r,this.languageUtils=r.languageUtils,this.options=o,this.logger=Ks.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=o.maxParallelReads||10,this.readingCalls=0,this.maxRetries=o.maxRetries>=0?o.maxRetries:5,this.retryTimeout=o.retryTimeout>=1?o.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,o.backend,o)}queueLoad(t,a,r,o){const c={},f={},m={},g={};return t.forEach(p=>{let y=!0;a.forEach(S=>{const E=`${p}|${S}`;!r.reload&&this.store.hasResourceBundle(p,S)?this.state[E]=2:this.state[E]<0||(this.state[E]===1?f[E]===void 0&&(f[E]=!0):(this.state[E]=1,y=!1,f[E]===void 0&&(f[E]=!0),c[E]===void 0&&(c[E]=!0),g[S]===void 0&&(g[S]=!0)))}),y||(m[p]=!0)}),(Object.keys(c).length||Object.keys(f).length)&&this.queue.push({pending:f,pendingCount:Object.keys(f).length,loaded:{},errors:[],callback:o}),{toLoad:Object.keys(c),pending:Object.keys(f),toLoadLanguages:Object.keys(m),toLoadNamespaces:Object.keys(g)}}loaded(t,a,r){const o=t.split("|"),c=o[0],f=o[1];a&&this.emit("failedLoading",c,f,a),!a&&r&&this.store.addResourceBundle(c,f,r,void 0,void 0,{skipCopy:!0}),this.state[t]=a?-1:2,a&&r&&(this.state[t]=0);const m={};this.queue.forEach(g=>{aZ(g.loaded,[c],f),vZ(g,t),a&&g.errors.push(a),g.pendingCount===0&&!g.done&&(Object.keys(g.loaded).forEach(p=>{m[p]||(m[p]={});const y=g.loaded[p];y.length&&y.forEach(S=>{m[p][S]===void 0&&(m[p][S]=!0)})}),g.done=!0,g.errors.length?g.callback(g.errors):g.callback())}),this.emit("loaded",m),this.queue=this.queue.filter(g=>!g.done)}read(t,a,r,o=0,c=this.retryTimeout,f){if(!t.length)return f(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:a,fcName:r,tried:o,wait:c,callback:f});return}this.readingCalls++;const m=(p,y)=>{if(this.readingCalls--,this.waitingReads.length>0){const S=this.waitingReads.shift();this.read(S.lng,S.ns,S.fcName,S.tried,S.wait,S.callback)}if(p&&y&&o<this.maxRetries){setTimeout(()=>{this.read.call(this,t,a,r,o+1,c*2,f)},c);return}f(p,y)},g=this.backend[r].bind(this.backend);if(g.length===2){try{const p=g(t,a);p&&typeof p.then=="function"?p.then(y=>m(null,y)).catch(m):m(null,p)}catch(p){m(p)}return}return g(t,a,m)}prepareLoading(t,a,r={},o){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();sn(t)&&(t=this.languageUtils.toResolveHierarchy(t)),sn(a)&&(a=[a]);const c=this.queueLoad(t,a,r,o);if(!c.toLoad.length)return c.pending.length||o(),null;c.toLoad.forEach(f=>{this.loadOne(f)})}load(t,a,r){this.prepareLoading(t,a,{},r)}reload(t,a,r){this.prepareLoading(t,a,{reload:!0},r)}loadOne(t,a=""){const r=t.split("|"),o=r[0],c=r[1];this.read(o,c,"read",void 0,void 0,(f,m)=>{f&&this.logger.warn(`${a}loading namespace ${c} for language ${o} failed`,f),!f&&m&&this.logger.log(`${a}loaded namespace ${c} for language ${o}`,m),this.loaded(t,f,m)})}saveMissing(t,a,r,o,c,f={},m=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(a)){this.logger.warn(`did not save key "${r}" as the namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const g={...f,isUpdate:c},p=this.backend.create.bind(this.backend);if(p.length<6)try{let y;p.length===5?y=p(t,a,r,o,g):y=p(t,a,r,o),y&&typeof y.then=="function"?y.then(S=>m(null,S)).catch(m):m(null,y)}catch(y){m(y)}else p(t,a,r,o,m,g)}!t||!t[0]||this.store.addResource(t[0],a,r,o)}}}const D6=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),sn(e[1])&&(t.defaultValue=e[1]),sn(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const a=e[3]||e[2];Object.keys(a).forEach(r=>{t[r]=a[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),N6=e=>(sn(e.ns)&&(e.ns=[e.ns]),sn(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),sn(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),typeof e.initImmediate=="boolean"&&(e.initAsync=e.initImmediate),e),ex=()=>{},bZ=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(a=>{typeof e[a]=="function"&&(e[a]=e[a].bind(e))})};class y0 extends Q1{constructor(t={},a){if(super(),this.options=N6(t),this.services={},this.logger=Ks,this.modules={external:[]},bZ(this),a&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,a),this;setTimeout(()=>{this.init(t,a)},0)}}init(t={},a){this.isInitializing=!0,typeof t=="function"&&(a=t,t={}),t.defaultNS==null&&t.ns&&(sn(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const r=D6();this.options={...r,...this.options,...N6(t)},this.options.interpolation={...r.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator);const o=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?Ks.init(o(this.modules.logger),this.options):Ks.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=gZ;const y=new O6(this.options);this.store=new C6(this.options.resources,this.options);const S=this.services;S.logger=Ks,S.resourceStore=this.store,S.languageUtils=y,S.pluralResolver=new dZ(y,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),p&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(S.formatter=o(p),S.formatter.init&&S.formatter.init(S,this.options),this.options.interpolation.format=S.formatter.format.bind(S.formatter)),S.interpolator=new hZ(this.options),S.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},S.backendConnector=new yZ(o(this.modules.backend),S.resourceStore,S,this.options),S.backendConnector.on("*",(T,...O)=>{this.emit(T,...O)}),this.modules.languageDetector&&(S.languageDetector=o(this.modules.languageDetector),S.languageDetector.init&&S.languageDetector.init(S,this.options.detection,this.options)),this.modules.i18nFormat&&(S.i18nFormat=o(this.modules.i18nFormat),S.i18nFormat.init&&S.i18nFormat.init(this)),this.translator=new J1(this.services,this.options),this.translator.on("*",(T,...O)=>{this.emit(T,...O)}),this.modules.external.forEach(T=>{T.init&&T.init(this)})}if(this.format=this.options.interpolation.format,a||(a=ex),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const p=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);p.length>0&&p[0]!=="dev"&&(this.options.lng=p[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(p=>{this[p]=(...y)=>this.store[p](...y)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(p=>{this[p]=(...y)=>(this.store[p](...y),this)});const m=p0(),g=()=>{const p=(y,S)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),m.resolve(S),a(y,S)};if(this.languages&&!this.isInitialized)return p(null,this.t.bind(this));this.changeLanguage(this.options.lng,p)};return this.options.resources||!this.options.initAsync?g():setTimeout(g,0),m}loadResources(t,a=ex){let r=a;const o=sn(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(o?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const c=[],f=m=>{if(!m||m==="cimode")return;this.services.languageUtils.toResolveHierarchy(m).forEach(p=>{p!=="cimode"&&c.indexOf(p)<0&&c.push(p)})};o?f(o):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(g=>f(g)),this.options.preload?.forEach?.(m=>f(m)),this.services.backendConnector.load(c,this.options.ns,m=>{!m&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(m)})}else r(null)}reloadResources(t,a,r){const o=p0();return typeof t=="function"&&(r=t,t=void 0),typeof a=="function"&&(r=a,a=void 0),t||(t=this.languages),a||(a=this.options.ns),r||(r=ex),this.services.backendConnector.reload(t,a,c=>{o.resolve(),r(c)}),o}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&E6.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1)){for(let a=0;a<this.languages.length;a++){const r=this.languages[a];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&this.languages.indexOf(t)<0&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,a){this.isLanguageChangingTo=t;const r=p0();this.emit("languageChanging",t);const o=m=>{this.language=m,this.languages=this.services.languageUtils.toResolveHierarchy(m),this.resolvedLanguage=void 0,this.setResolvedLanguage(m)},c=(m,g)=>{g?this.isLanguageChangingTo===t&&(o(g),this.translator.changeLanguage(g),this.isLanguageChangingTo=void 0,this.emit("languageChanged",g),this.logger.log("languageChanged",g)):this.isLanguageChangingTo=void 0,r.resolve((...p)=>this.t(...p)),a&&a(m,(...p)=>this.t(...p))},f=m=>{!t&&!m&&this.services.languageDetector&&(m=[]);const g=sn(m)?m:m&&m[0],p=this.store.hasLanguageSomeTranslations(g)?g:this.services.languageUtils.getBestMatchFromCodes(sn(m)?[m]:m);p&&(this.language||o(p),this.translator.language||this.translator.changeLanguage(p),this.services.languageDetector?.cacheUserLanguage?.(p)),this.loadResources(p,y=>{c(y,p)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?f(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(f):this.services.languageDetector.detect(f):f(t),r}getFixedT(t,a,r){const o=(c,f,...m)=>{let g;typeof f!="object"?g=this.options.overloadTranslationOptionHandler([c,f].concat(m)):g={...f},g.lng=g.lng||o.lng,g.lngs=g.lngs||o.lngs,g.ns=g.ns||o.ns,g.keyPrefix!==""&&(g.keyPrefix=g.keyPrefix||r||o.keyPrefix);const p=this.options.keySeparator||".";let y;return g.keyPrefix&&Array.isArray(c)?y=c.map(S=>`${g.keyPrefix}${p}${S}`):y=g.keyPrefix?`${g.keyPrefix}${p}${c}`:c,this.t(y,g)};return sn(t)?o.lng=t:o.lngs=t,o.ns=a,o.keyPrefix=r,o}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,a={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=a.lng||this.resolvedLanguage||this.languages[0],o=this.options?this.options.fallbackLng:!1,c=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const f=(m,g)=>{const p=this.services.backendConnector.state[`${m}|${g}`];return p===-1||p===0||p===2};if(a.precheck){const m=a.precheck(this,f);if(m!==void 0)return m}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||f(r,t)&&(!o||f(c,t)))}loadNamespaces(t,a){const r=p0();return this.options.ns?(sn(t)&&(t=[t]),t.forEach(o=>{this.options.ns.indexOf(o)<0&&this.options.ns.push(o)}),this.loadResources(o=>{r.resolve(),a&&a(o)}),r):(a&&a(),Promise.resolve())}loadLanguages(t,a){const r=p0();sn(t)&&(t=[t]);const o=this.options.preload||[],c=t.filter(f=>o.indexOf(f)<0&&this.services.languageUtils.isSupportedCode(f));return c.length?(this.options.preload=o.concat(c),this.loadResources(f=>{r.resolve(),a&&a(f)}),r):(a&&a(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{const o=new Intl.Locale(t);if(o&&o.getTextInfo){const c=o.getTextInfo();if(c&&c.direction)return c.direction}}catch{}const a=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new O6(D6());return t.toLowerCase().indexOf("-latn")>1?"ltr":a.indexOf(r.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},a){return new y0(t,a)}cloneInstance(t={},a=ex){const r=t.forkResourceStore;r&&delete t.forkResourceStore;const o={...this.options,...t,isClone:!0},c=new y0(o);if((t.debug!==void 0||t.prefix!==void 0)&&(c.logger=c.logger.clone(t)),["store","services","language"].forEach(m=>{c[m]=this[m]}),c.services={...this.services},c.services.utils={hasLoadedNamespace:c.hasLoadedNamespace.bind(c)},r){const m=Object.keys(this.store.data).reduce((g,p)=>(g[p]={...this.store.data[p]},g[p]=Object.keys(g[p]).reduce((y,S)=>(y[S]={...g[p][S]},y),g[p]),g),{});c.store=new C6(m,o),c.services.resourceStore=c.store}return c.translator=new J1(c.services,o),c.translator.on("*",(m,...g)=>{c.emit(m,...g)}),c.init(o,a),c.translator.options=o,c.translator.backendConnector.services.utils={hasLoadedNamespace:c.hasLoadedNamespace.bind(c)},c}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Zr=y0.createInstance();Zr.createInstance=y0.createInstance,Zr.createInstance,Zr.dir,Zr.init,Zr.loadResources,Zr.reloadResources,Zr.use,Zr.changeLanguage,Zr.getFixedT,Zr.t,Zr.exists,Zr.setDefaultNamespace,Zr.hasLoadedNamespace,Zr.loadNamespaces,Zr.loadLanguages;const SZ=(e,t,a,r)=>{const o=[a,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(o,"warn","react-i18next::",!0);Vd(o[0])&&(o[0]=`react-i18next:: ${o[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...o):console?.warn&&console.warn(...o)},$6={},yO=(e,t,a,r)=>{Vd(a)&&$6[a]||(Vd(a)&&($6[a]=new Date),SZ(e,t,a,r))},z6=(e,t)=>()=>{if(e.isInitialized)t();else{const a=()=>{setTimeout(()=>{e.off("initialized",a)},0),t()};e.on("initialized",a)}},bO=(e,t,a)=>{e.loadNamespaces(t,z6(e,a))},j6=(e,t,a,r)=>{if(Vd(a)&&(a=[a]),e.options.preload&&e.options.preload.indexOf(t)>-1)return bO(e,a,r);a.forEach(o=>{e.options.ns.indexOf(o)<0&&e.options.ns.push(o)}),e.loadLanguages(t,z6(e,r))},xZ=(e,t,a={})=>!t.languages||!t.languages.length?(yO(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:a.lng,precheck:(r,o)=>{if(a.bindI18n?.indexOf("languageChanging")>-1&&r.services.backendConnector.backend&&r.isLanguageChangingTo&&!o(r.isLanguageChangingTo,e))return!1}}),Vd=e=>typeof e=="string",CZ=e=>typeof e=="object"&&e!==null,EZ=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,wZ={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},TZ=e=>wZ[e];let SO={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(EZ,TZ)};const OZ=(e={})=>{SO={...SO,...e}},RZ=()=>SO;let L6;const AZ=e=>{L6=e},MZ=()=>L6,_Z={type:"3rdParty",init(e){OZ(e.options.react),AZ(e)}},DZ=x.createContext();class NZ{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(a=>{this.usedNamespaces[a]||(this.usedNamespaces[a]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const $Z=(e,t)=>{const a=x.useRef();return x.useEffect(()=>{a.current=e},[e,t]),a.current},V6=(e,t,a,r)=>e.getFixedT(t,a,r),zZ=(e,t,a,r)=>x.useCallback(V6(e,t,a,r),[e,t,a,r]),jZ=(e,t={})=>{const{i18n:a}=t,{i18n:r,defaultNS:o}=x.useContext(DZ)||{},c=a||r||MZ();if(c&&!c.reportNamespaces&&(c.reportNamespaces=new NZ),!c){yO(c,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const V=(L,H)=>Vd(H)?H:CZ(H)&&Vd(H.defaultValue)?H.defaultValue:Array.isArray(L)?L[L.length-1]:L,$=[V,{},!1];return $.t=V,$.i18n={},$.ready=!1,$}c.options.react?.wait&&yO(c,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const f={...RZ(),...c.options.react,...t},{useSuspense:m,keyPrefix:g}=f;let p=o||c.options?.defaultNS;p=Vd(p)?[p]:p||["translation"],c.reportNamespaces.addUsedNamespaces?.(p);const y=(c.isInitialized||c.initializedStoreOnce)&&p.every(V=>xZ(V,c,f)),S=zZ(c,t.lng||null,f.nsMode==="fallback"?p:p[0],g),E=()=>S,T=()=>V6(c,t.lng||null,f.nsMode==="fallback"?p:p[0],g),[O,M]=x.useState(E);let A=p.join();t.lng&&(A=`${t.lng}${A}`);const D=$Z(A),_=x.useRef(!0);x.useEffect(()=>{const{bindI18n:V,bindI18nStore:$}=f;_.current=!0,!y&&!m&&(t.lng?j6(c,t.lng,p,()=>{_.current&&M(T)}):bO(c,p,()=>{_.current&&M(T)})),y&&D&&D!==A&&_.current&&M(T);const L=()=>{_.current&&M(T)};return V&&c?.on(V,L),$&&c?.store.on($,L),()=>{_.current=!1,c&&V?.split(" ").forEach(H=>c.off(H,L)),$&&c&&$.split(" ").forEach(H=>c.store.off(H,L))}},[c,A]),x.useEffect(()=>{_.current&&y&&M(E)},[c,g,y]);const j=[O,c,y];if(j.t=O,j.i18n=c,j.ready=y,y||!y&&!m)return j;throw new Promise(V=>{t.lng?j6(c,t.lng,p,()=>V()):bO(c,p,()=>V())})},LZ={en:{translation:{welcome:"Hi there, you’re speaking with Jaweb AI Assistant."}},ar:{translation:{welcome:"مرحبًا، أنت تتحدث إلى مساعد Jaweb AI."}}};Zr.use(_Z).init({resources:LZ,lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const VZ=3,HZ=3e3,BZ=()=>{const[e,t]=x.useState(!0),[a,r]=x.useState(!1),[o,c]=x.useState(""),[f,m]=x.useState(""),[g,p]=x.useState(!1),[y,S]=x.useState(!1),[E,T]=x.useState(""),[O,M]=x.useState(""),[A,D]=x.useState(""),[_,j]=x.useState(""),[V,$]=x.useState([]),[L,H]=x.useState([]),[z,U]=x.useState(""),B=async(J=0)=>{const X=localStorage.getItem("company_username");console.log(X),t(!0);const W={headers:{"Content-Type":"application/json",Accept:"application/json"},params:{username:X}};try{const re=(await $a.get(`${wi.apiUrl}chatbot-details/`,W)).data.data;re.language==="Arabic"?Zr.changeLanguage("ar"):Zr.changeLanguage("en"),r(re.chatbot_form),c(re.chatbot_color),m(re.chatbot_logo),p(re.disable_chatbot_globally),S(re.remove_powered_by_jaweb),T(re.chatbot_initial_msg),M(re.status),U(re.mode),console.log(re),re.calendly_link&&D(re.calendly_link),re.phone_number_id&&j(`+${re.phone_number_id}`);const F=await $a.get(`${wi.apiUrl}chatbot-plugin-suggestions/`,W);let G=[];Array.isArray(F.data.data)?G=F.data.data:Array.isArray(F.data.user_questions)&&(G=F.data.user_questions),G.length>0?($(G.slice(0,3)),H(G.slice(3))):($([]),H([])),t(!1)}catch(K){console.error("Error fetching data:",K),J<VZ?setTimeout(()=>B(J+1),HZ):console.error("Max retries reached. Could not fetch data.")}};return x.useEffect(()=>{B()},[]),{isFetchingDetails:e,disableForm:a,colorCode:o,chatbotLogo:f,disableChatbotGlobally:g,removePoweredByJaweb:y,initialMessageText:E,subscription:O,calendly:A,merchantPhone:_,messagesSuggestions:V,restSuggestions:L,userType:z}},{Text:PZ,Title:UZ}=Fm,IZ=({chatbotLogo:e,colorCode:t,onNewSession:a,visitorId:r,onSessionSelect:o,setOpen:c,Opened:f,Phone:m})=>{const[g,p]=x.useState([]),[y,S]=x.useState(!0),E=async()=>{try{S(!0);const A=(await(await fetch(`${wi.apiUrl}get-chatlogs-by-ip/?visitor_id=${r}&company_username=${localStorage.getItem("company_username")}`)).json()).map(D=>({id:D.user_session_id,agentName:D.assignee||"AI Agent",createdAt:D.date,isBlurred:D.closed,agentImage:D.assignee_picture}));p(A)}catch(O){console.error("Failed to load sessions:",O)}finally{S(!1)}};x.useEffect(()=>{r&&E()},[r]);const T=ae.jsx(Fu,{style:{fontSize:24},spin:!0});return ae.jsxs("div",{style:{maxWidth:"100%",height:"100%",border:"1px solid #f0f0f0",borderRadius:8,overflow:"hidden",display:"flex",flexDirection:"column",paddingTop:20},children:[ae.jsxs("div",{style:{padding:"0 16px 10px",display:"flex"},children:[ae.jsx(UZ,{level:4,style:{margin:0},children:"Conversations"}),ae.jsx(Gv,{onClick:()=>c(!f),className:"chatbot-close",style:{marginLeft:"auto"}})]}),ae.jsx("div",{style:{flex:1,overflowY:"auto"},children:y?ae.jsx("div",{style:{textAlign:"center",padding:"2rem"},children:ae.jsx(tf,{indicator:T})}):g.length>0?ae.jsx($1,{itemLayout:"horizontal",dataSource:g,split:!0,renderItem:O=>ae.jsx($1.Item,{onClick:()=>!O.isBlurred&&o(O.id,O.agentName||"Ai Agent",O.agentImage||e),style:{padding:"12px",opacity:O.isBlurred?.5:1,cursor:O.isBlurred?"not-allowed":"pointer",borderBottom:"1px solid #f0f0f0"},children:ae.jsx($1.Item.Meta,{avatar:ae.jsx(MT,{size:"large",src:O.agentImage||e,icon:!O.agentImage&&!e?ae.jsx(b4,{}):void 0}),title:ae.jsx("span",{style:{fontWeight:600},children:O.agentName||"AI Agent"}),description:ae.jsxs(ae.Fragment,{children:[ae.jsxs(PZ,{type:"secondary",children:["Created: ",new Date(O.createdAt).toLocaleDateString()]}),O.isBlurred&&ae.jsx("div",{style:{color:"red",fontSize:"12px",marginTop:4},children:"This session is closed and cannot be reopened."})]})})},O.id)}):ae.jsx("div",{style:{padding:"1rem",textAlign:"center",color:"#888"},children:"No conversations yet."})}),ae.jsxs("div",{style:{padding:"12px",borderTop:"1px solid #f0f0f0",display:"flex",gap:4},children:[ae.jsx(ri,{type:"primary",size:"large",block:!0,style:{backgroundColor:t,color:"#fff"},onClick:a,children:"Ask a question"}),m?ae.jsx(ri,{type:"default",style:{backgroundColor:"#25D366",color:"white"},className:"hover:border-black",size:"large",icon:ae.jsx(S4,{style:{color:"white"}}),onClick:()=>{const O=`https://wa.me/${m}`;window.open(O,"_blank")},children:"Chat on WhatsApp"}):ae.jsx(ae.Fragment,{})]})]})},{Title:kZ,Text:xO}=Fm,FZ=({onBack:e,onCreate:t,colorCode:a,visitorId:r,country:o})=>{const[c,f]=x.useState(""),[m,g]=x.useState(""),[p,y]=x.useState(""),[S,E]=x.useState(!1),T=async()=>{const O={visitor_id:r,country:o,name:c,email:m,phone:p,company_username:localStorage.getItem("company_username")};try{E(!0);const M=await fetch(`${wi.apiUrl}chatlog-create/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)}),A=await M.json();M.ok?t({name:c,email:m,phone:p,session_id:A?.user_session_id,messages:A.messages,hasInfo:!0}):console.error("Failed to register:",A)}catch(M){console.error("Error submitting session data:",M)}finally{E(!1)}};return ae.jsxs("div",{style:{padding:"1.5rem"},children:[ae.jsx(ri,{type:"text",icon:ae.jsx(km,{}),onClick:e,style:{marginBottom:"1rem"},children:"Back"}),ae.jsx(kZ,{level:4,style:{marginBottom:"2rem"},children:"Let's create a session"}),ae.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:[ae.jsxs("div",{children:[ae.jsx(xO,{strong:!0,children:"👋 Please, can I have your name?"}),ae.jsx(Yu,{size:"large",placeholder:"John Doe",value:c,onChange:O=>f(O.target.value),style:{marginTop:"0.5rem"}})]}),ae.jsxs("div",{children:[ae.jsx(xO,{strong:!0,children:"📧 What’s your email address?"}),ae.jsx(Yu,{size:"large",type:"email",placeholder:"you@example.com",value:m,onChange:O=>g(O.target.value),style:{marginTop:"0.5rem"}})]}),ae.jsxs("div",{children:[ae.jsx(xO,{strong:!0,children:"📱 May I have your phone number?"}),ae.jsx(Yu,{size:"large",placeholder:"+1 234 567 8900",value:p,onChange:O=>y(O.target.value),style:{marginTop:"0.5rem"}})]}),ae.jsx(ri,{type:"primary",size:"large",style:{backgroundColor:a,color:"white"},onClick:T,disabled:!c||!m||!p,children:S?ae.jsx(tf,{indicator:ae.jsx(Fu,{style:{fontSize:20,color:"white"},spin:!0})}):"Create Session"})]})]})},qZ=e=>{const[t,a]=x.useState([]),[r,o]=x.useState(!1),c=async()=>{const f=e;if(f){o(!0);try{const m=await $a.get(`${wi.apiUrl}chat-message-history/`,{withCredentials:!0,params:{session_id:f,username:localStorage.getItem("company_username")}});m.data?.messages?.length>0&&(a(m.data.messages),o(!1))}catch(m){console.error("Couldn't load history",m)}}};return x.useEffect(()=>{c()},[e]),{messages:t,setMessages:a,isFetchingMessages:r}};function ii(e,t,a,r){return new(a||(a=Promise))(function(o,c){function f(p){try{g(r.next(p))}catch(y){c(y)}}function m(p){try{g(r.throw(p))}catch(y){c(y)}}function g(p){var y;p.done?o(p.value):(y=p.value,y instanceof a?y:new a(function(S){S(y)})).then(f,m)}g((r=r.apply(e,t||[])).next())})}typeof SuppressedError=="function"&&SuppressedError;class b0{constructor(){this.listeners={}}on(t,a,r){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(a),r?.once){const o=()=>{this.un(t,o),this.un(t,a)};return this.on(t,o),o}return()=>this.un(t,a)}un(t,a){var r;(r=this.listeners[t])===null||r===void 0||r.delete(a)}once(t,a){return this.on(t,a,{once:!0})}unAll(){this.listeners={}}emit(t,...a){this.listeners[t]&&this.listeners[t].forEach(r=>r(...a))}}const tx={decode:function(e,t){return ii(this,void 0,void 0,function*(){const a=new AudioContext({sampleRate:t});return a.decodeAudioData(e).finally(()=>a.close())})},createBuffer:function(e,t){return typeof e[0]=="number"&&(e=[e]),function(a){const r=a[0];if(r.some(o=>o>1||o<-1)){const o=r.length;let c=0;for(let f=0;f<o;f++){const m=Math.abs(r[f]);m>c&&(c=m)}for(const f of a)for(let m=0;m<o;m++)f[m]/=c}}(e),{duration:t,length:e[0].length,sampleRate:e[0].length/t,numberOfChannels:e.length,getChannelData:a=>e?.[a],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function H6(e,t){const a=t.xmlns?document.createElementNS(t.xmlns,e):document.createElement(e);for(const[r,o]of Object.entries(t))if(r==="children"&&o)for(const[c,f]of Object.entries(o))f instanceof Node?a.appendChild(f):typeof f=="string"?a.appendChild(document.createTextNode(f)):a.appendChild(H6(c,f));else r==="style"?Object.assign(a.style,o):r==="textContent"?a.textContent=o:a.setAttribute(r,o.toString());return a}function B6(e,t,a){const r=H6(e,t||{});return a?.appendChild(r),r}var GZ=Object.freeze({__proto__:null,createElement:B6,default:B6});const XZ={fetchBlob:function(e,t,a){return ii(this,void 0,void 0,function*(){const r=yield fetch(e,a);if(r.status>=400)throw new Error(`Failed to fetch ${e}: ${r.status} (${r.statusText})`);return function(o,c){ii(this,void 0,void 0,function*(){if(!o.body||!o.headers)return;const f=o.body.getReader(),m=Number(o.headers.get("Content-Length"))||0;let g=0;const p=S=>ii(this,void 0,void 0,function*(){g+=S?.length||0;const E=Math.round(g/m*100);c(E)}),y=()=>ii(this,void 0,void 0,function*(){let S;try{S=yield f.read()}catch{return}S.done||(p(S.value),yield y())});y()})}(r.clone(),t),r.blob()})}};class YZ extends b0{constructor(t){super(),this.isExternalMedia=!1,t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),t.playbackRate!=null&&this.onMediaEvent("canplay",()=>{t.playbackRate!=null&&(this.media.playbackRate=t.playbackRate)},{once:!0})}onMediaEvent(t,a,r){return this.media.addEventListener(t,a,r),()=>this.media.removeEventListener(t,a,r)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,a){const r=this.getSrc();if(t&&r===t)return;this.revokeSrc();const o=a instanceof Blob&&(this.canPlayType(a.type)||!t)?URL.createObjectURL(a):t;if(r&&this.media.removeAttribute("src"),o||t)try{this.media.src=o}catch{this.media.src=t}}destroy(){this.isExternalMedia||(this.media.pause(),this.media.remove(),this.revokeSrc(),this.media.removeAttribute("src"),this.media.load())}setMediaElement(t){this.media=t}play(){return ii(this,void 0,void 0,function*(){return this.media.play()})}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=Math.max(0,Math.min(t,this.getDuration()))}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(t){this.media.volume=t}getMuted(){return this.media.muted}setMuted(t){this.media.muted=t}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(t,a){a!=null&&(this.media.preservesPitch=a),this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){return this.media.setSinkId(t)}}class Ym extends b0{constructor(t,a){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.unsubscribeOnScroll=[],this.subscriptions=[],this.options=t;const r=this.parentFromOptionsContainer(t.container);this.parent=r;const[o,c]=this.initHtml();r.appendChild(o),this.container=o,this.scrollContainer=c.querySelector(".scroll"),this.wrapper=c.querySelector(".wrapper"),this.canvasWrapper=c.querySelector(".canvases"),this.progressWrapper=c.querySelector(".progress"),this.cursor=c.querySelector(".cursor"),a&&c.appendChild(a),this.initEvents()}parentFromOptionsContainer(t){let a;if(typeof t=="string"?a=document.querySelector(t):t instanceof HTMLElement&&(a=t),!a)throw new Error("Container not found");return a}initEvents(){const t=a=>{const r=this.wrapper.getBoundingClientRect(),o=a.clientX-r.left,c=a.clientY-r.top;return[o/r.width,c/r.height]};if(this.wrapper.addEventListener("click",a=>{const[r,o]=t(a);this.emit("click",r,o)}),this.wrapper.addEventListener("dblclick",a=>{const[r,o]=t(a);this.emit("dblclick",r,o)}),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:a,scrollWidth:r,clientWidth:o}=this.scrollContainer,c=a/r,f=(a+o)/r;this.emit("scroll",c,f,a,a+o)}),typeof ResizeObserver=="function"){const a=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{a().then(()=>this.onContainerResize()).catch(()=>{})}),this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;t===this.lastContainerWidth&&this.options.height!=="auto"||(this.lastContainerWidth=t,this.reRender())}initDrag(){this.subscriptions.push(function(t,a,r,o,c=3,f=0,m=100){if(!t)return()=>{};const g=matchMedia("(pointer: coarse)").matches;let p=()=>{};const y=S=>{if(S.button!==f)return;S.preventDefault(),S.stopPropagation();let E=S.clientX,T=S.clientY,O=!1;const M=Date.now(),A=$=>{if($.preventDefault(),$.stopPropagation(),g&&Date.now()-M<m)return;const L=$.clientX,H=$.clientY,z=L-E,U=H-T;if(O||Math.abs(z)>c||Math.abs(U)>c){const B=t.getBoundingClientRect(),{left:J,top:X}=B;O||(r?.(E-J,T-X),O=!0),a(z,U,L-J,H-X),E=L,T=H}},D=$=>{if(O){const L=$.clientX,H=$.clientY,z=t.getBoundingClientRect(),{left:U,top:B}=z;o?.(L-U,H-B)}p()},_=$=>{$.relatedTarget&&$.relatedTarget!==document.documentElement||D($)},j=$=>{O&&($.stopPropagation(),$.preventDefault())},V=$=>{O&&$.preventDefault()};document.addEventListener("pointermove",A),document.addEventListener("pointerup",D),document.addEventListener("pointerout",_),document.addEventListener("pointercancel",_),document.addEventListener("touchmove",V,{passive:!1}),document.addEventListener("click",j,{capture:!0}),p=()=>{document.removeEventListener("pointermove",A),document.removeEventListener("pointerup",D),document.removeEventListener("pointerout",_),document.removeEventListener("pointercancel",_),document.removeEventListener("touchmove",V),setTimeout(()=>{document.removeEventListener("click",j,{capture:!0})},10)}};return t.addEventListener("pointerdown",y),()=>{p(),t.removeEventListener("pointerdown",y)}}(this.wrapper,(t,a,r)=>{this.emit("drag",Math.max(0,Math.min(1,r/this.wrapper.getBoundingClientRect().width)))},t=>{this.isDragging=!0,this.emit("dragstart",Math.max(0,Math.min(1,t/this.wrapper.getBoundingClientRect().width)))},t=>{this.isDragging=!1,this.emit("dragend",Math.max(0,Math.min(1,t/this.wrapper.getBoundingClientRect().width)))}))}getHeight(t,a){var r;const o=((r=this.audioData)===null||r===void 0?void 0:r.numberOfChannels)||1;if(t==null)return 128;if(!isNaN(Number(t)))return Number(t);if(t==="auto"){const c=this.parent.clientHeight||128;return a?.every(f=>!f.overlay)?c/o:c}return 128}initHtml(){const t=document.createElement("div"),a=t.attachShadow({mode:"open"}),r=this.options.cspNonce&&typeof this.options.cspNonce=="string"?this.options.cspNonce.replace(/"/g,""):"";return a.innerHTML=`
572
+ `+c):r.stack=c}catch{}}throw r}}_request(t,a){typeof t=="string"?(a=a||{},a.url=t):a=t||{},a=jd(this.defaults,a);const{transitional:r,paramsSerializer:o,headers:c}=a;r!==void 0&&W1.assertOptions(r,{silentJSONParsing:Zs.transitional(Zs.boolean),forcedJSONParsing:Zs.transitional(Zs.boolean),clarifyTimeoutError:Zs.transitional(Zs.boolean)},!1),o!=null&&(Xe.isFunction(o)?a.paramsSerializer={serialize:o}:W1.assertOptions(o,{encode:Zs.function,serialize:Zs.function},!0)),a.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?a.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:a.allowAbsoluteUrls=!0),W1.assertOptions(a,{baseUrl:Zs.spelling("baseURL"),withXsrfToken:Zs.spelling("withXSRFToken")},!0),a.method=(a.method||this.defaults.method||"get").toLowerCase();let f=c&&Xe.merge(c.common,c[a.method]);c&&Xe.forEach(["delete","get","head","post","put","patch","common"],O=>{delete c[O]}),a.headers=vo.concat(f,c);const m=[];let g=!0;this.interceptors.request.forEach(function(M){typeof M.runWhen=="function"&&M.runWhen(a)===!1||(g=g&&M.synchronous,m.unshift(M.fulfilled,M.rejected))});const p=[];this.interceptors.response.forEach(function(M){p.push(M.fulfilled,M.rejected)});let y,S=0,E;if(!g){const O=[h6.bind(this),void 0];for(O.unshift.apply(O,m),O.push.apply(O,p),E=O.length,y=Promise.resolve(a);S<E;)y=y.then(O[S++],O[S++]);return y}E=m.length;let T=a;for(S=0;S<E;){const O=m[S++],M=m[S++];try{T=O(T)}catch(A){M.call(this,A);break}}try{y=h6.call(this,T)}catch(O){return Promise.reject(O)}for(S=0,E=p.length;S<E;)y=y.then(p[S++],p[S++]);return y}getUri(t){t=jd(this.defaults,t);const a=r6(t.baseURL,t.url,t.allowAbsoluteUrls);return W4(a,t.params,t.paramsSerializer)}};Xe.forEach(["delete","get","head","options"],function(t){Ld.prototype[t]=function(a,r){return this.request(jd(r||{},{method:t,url:a,data:(r||{}).data}))}}),Xe.forEach(["post","put","patch"],function(t){function a(r){return function(c,f,m){return this.request(jd(m||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:c,data:f}))}}Ld.prototype[t]=a(),Ld.prototype[t+"Form"]=a(!0)});let QW=class u8{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let a;this.promise=new Promise(function(c){a=c});const r=this;this.promise.then(o=>{if(!r._listeners)return;let c=r._listeners.length;for(;c-- >0;)r._listeners[c](o);r._listeners=null}),this.promise.then=o=>{let c;const f=new Promise(m=>{r.subscribe(m),c=m}).then(o);return f.cancel=function(){r.unsubscribe(c)},f},t(function(c,f,m){r.reason||(r.reason=new Gm(c,f,m),a(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const a=this._listeners.indexOf(t);a!==-1&&this._listeners.splice(a,1)}toAbortSignal(){const t=new AbortController,a=r=>{t.abort(r)};return this.subscribe(a),t.signal.unsubscribe=()=>this.unsubscribe(a),t.signal}static source(){let t;return{token:new u8(function(o){t=o}),cancel:t}}};function JW(e){return function(a){return e.apply(null,a)}}function eZ(e){return Xe.isObject(e)&&e.isAxiosError===!0}const pO={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(pO).forEach(([e,t])=>{pO[t]=e});function g6(e){const t=new Ld(e),a=z4(Ld.prototype.request,t);return Xe.extend(a,Ld.prototype,t,{allOwnKeys:!0}),Xe.extend(a,t,null,{allOwnKeys:!0}),a.create=function(o){return g6(jd(e,o))},a}const $a=g6(h0);$a.Axios=Ld,$a.CanceledError=Gm,$a.CancelToken=QW,$a.isCancel=e6,$a.VERSION=m6,$a.toFormData=k1,$a.AxiosError=Cn,$a.Cancel=$a.CanceledError,$a.all=function(t){return Promise.all(t)},$a.spread=JW,$a.isAxiosError=eZ,$a.mergeConfig=jd,$a.AxiosHeaders=vo,$a.formToJSON=e=>Q4(Xe.isHTMLForm(e)?new FormData(e):e),$a.getAdapter=d6.getAdapter,$a.HttpStatusCode=pO,$a.default=$a;const{Axios:eoe,AxiosError:toe,CanceledError:noe,isCancel:aoe,CancelToken:roe,VERSION:ioe,all:ooe,Cancel:loe,isAxiosError:soe,spread:uoe,toFormData:coe,AxiosHeaders:foe,HttpStatusCode:doe,formToJSON:hoe,getAdapter:moe,mergeConfig:poe}=$a,wi={apiUrl:"http://localhost:8000/api/",websocketUrl:"ws://localhost:8000/ws"},sn=e=>typeof e=="string",p0=()=>{let e,t;const a=new Promise((r,o)=>{e=r,t=o});return a.resolve=e,a.reject=t,a},v6=e=>e==null?"":""+e,tZ=(e,t,a)=>{e.forEach(r=>{t[r]&&(a[r]=t[r])})},nZ=/###/g,y6=e=>e&&e.indexOf("###")>-1?e.replace(nZ,"."):e,b6=e=>!e||sn(e),g0=(e,t,a)=>{const r=sn(t)?t.split("."):t;let o=0;for(;o<r.length-1;){if(b6(e))return{};const c=y6(r[o]);!e[c]&&a&&(e[c]=new a),Object.prototype.hasOwnProperty.call(e,c)?e=e[c]:e={},++o}return b6(e)?{}:{obj:e,k:y6(r[o])}},S6=(e,t,a)=>{const{obj:r,k:o}=g0(e,t,Object);if(r!==void 0||t.length===1){r[o]=a;return}let c=t[t.length-1],f=t.slice(0,t.length-1),m=g0(e,f,Object);for(;m.obj===void 0&&f.length;)c=`${f[f.length-1]}.${c}`,f=f.slice(0,f.length-1),m=g0(e,f,Object),m?.obj&&typeof m.obj[`${m.k}.${c}`]<"u"&&(m.obj=void 0);m.obj[`${m.k}.${c}`]=a},aZ=(e,t,a,r)=>{const{obj:o,k:c}=g0(e,t,Object);o[c]=o[c]||[],o[c].push(a)},Z1=(e,t)=>{const{obj:a,k:r}=g0(e,t);if(a&&Object.prototype.hasOwnProperty.call(a,r))return a[r]},rZ=(e,t,a)=>{const r=Z1(e,a);return r!==void 0?r:Z1(t,a)},x6=(e,t,a)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?sn(e[r])||e[r]instanceof String||sn(t[r])||t[r]instanceof String?a&&(e[r]=t[r]):x6(e[r],t[r],a):e[r]=t[r]);return e},Xm=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var iZ={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const oZ=e=>sn(e)?e.replace(/[&<>"'\/]/g,t=>iZ[t]):e;class lZ{constructor(t){this.capacity=t,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(t){const a=this.regExpMap.get(t);if(a!==void 0)return a;const r=new RegExp(t);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(t,r),this.regExpQueue.push(t),r}}const sZ=[" ",",","?","!",";"],uZ=new lZ(20),cZ=(e,t,a)=>{t=t||"",a=a||"";const r=sZ.filter(f=>t.indexOf(f)<0&&a.indexOf(f)<0);if(r.length===0)return!0;const o=uZ.getRegExp(`(${r.map(f=>f==="?"?"\\?":f).join("|")})`);let c=!o.test(e);if(!c){const f=e.indexOf(a);f>0&&!o.test(e.substring(0,f))&&(c=!0)}return c},gO=(e,t,a=".")=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;const r=t.split(a);let o=e;for(let c=0;c<r.length;){if(!o||typeof o!="object")return;let f,m="";for(let g=c;g<r.length;++g)if(g!==c&&(m+=a),m+=r[g],f=o[m],f!==void 0){if(["string","number","boolean"].indexOf(typeof f)>-1&&g<r.length-1)continue;c+=g-c+1;break}o=f}return o},v0=e=>e?.replace("_","-"),fZ={type:"logger",log(e){this.output("log",e)},warn(e){this.output("warn",e)},error(e){this.output("error",e)},output(e,t){console?.[e]?.apply?.(console,t)}};class K1{constructor(t,a={}){this.init(t,a)}init(t,a={}){this.prefix=a.prefix||"i18next:",this.logger=t||fZ,this.options=a,this.debug=a.debug}log(...t){return this.forward(t,"log","",!0)}warn(...t){return this.forward(t,"warn","",!0)}error(...t){return this.forward(t,"error","")}deprecate(...t){return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}forward(t,a,r,o){return o&&!this.debug?null:(sn(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[a](t))}create(t){return new K1(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new K1(this.logger,t)}}var Ks=new K1;class Q1{constructor(){this.observers={}}on(t,a){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const o=this.observers[r].get(a)||0;this.observers[r].set(a,o+1)}),this}off(t,a){if(this.observers[t]){if(!a){delete this.observers[t];return}this.observers[t].delete(a)}}emit(t,...a){this.observers[t]&&Array.from(this.observers[t].entries()).forEach(([o,c])=>{for(let f=0;f<c;f++)o(...a)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([o,c])=>{for(let f=0;f<c;f++)o.apply(o,[t,...a])})}}class C6 extends Q1{constructor(t,a={ns:["translation"],defaultNS:"translation"}){super(),this.data=t||{},this.options=a,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const a=this.options.ns.indexOf(t);a>-1&&this.options.ns.splice(a,1)}getResource(t,a,r,o={}){const c=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator,f=o.ignoreJSONStructure!==void 0?o.ignoreJSONStructure:this.options.ignoreJSONStructure;let m;t.indexOf(".")>-1?m=t.split("."):(m=[t,a],r&&(Array.isArray(r)?m.push(...r):sn(r)&&c?m.push(...r.split(c)):m.push(r)));const g=Z1(this.data,m);return!g&&!a&&!r&&t.indexOf(".")>-1&&(t=m[0],a=m[1],r=m.slice(2).join(".")),g||!f||!sn(r)?g:gO(this.data?.[t]?.[a],r,c)}addResource(t,a,r,o,c={silent:!1}){const f=c.keySeparator!==void 0?c.keySeparator:this.options.keySeparator;let m=[t,a];r&&(m=m.concat(f?r.split(f):r)),t.indexOf(".")>-1&&(m=t.split("."),o=a,a=m[1]),this.addNamespaces(a),S6(this.data,m,o),c.silent||this.emit("added",t,a,r,o)}addResources(t,a,r,o={silent:!1}){for(const c in r)(sn(r[c])||Array.isArray(r[c]))&&this.addResource(t,a,c,r[c],{silent:!0});o.silent||this.emit("added",t,a,r)}addResourceBundle(t,a,r,o,c,f={silent:!1,skipCopy:!1}){let m=[t,a];t.indexOf(".")>-1&&(m=t.split("."),o=r,r=a,a=m[1]),this.addNamespaces(a);let g=Z1(this.data,m)||{};f.skipCopy||(r=JSON.parse(JSON.stringify(r))),o?x6(g,r,c):g={...g,...r},S6(this.data,m,g),f.silent||this.emit("added",t,a,r)}removeResourceBundle(t,a){this.hasResourceBundle(t,a)&&delete this.data[t][a],this.removeNamespaces(a),this.emit("removed",t,a)}hasResourceBundle(t,a){return this.getResource(t,a)!==void 0}getResourceBundle(t,a){return a||(a=this.options.defaultNS),this.getResource(t,a)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const a=this.getDataByLanguage(t);return!!(a&&Object.keys(a)||[]).find(o=>a[o]&&Object.keys(a[o]).length>0)}toJSON(){return this.data}}var E6={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,a,r,o){return e.forEach(c=>{t=this.processors[c]?.process(t,a,r,o)??t}),t}};const w6={},T6=e=>!sn(e)&&typeof e!="boolean"&&typeof e!="number";class J1 extends Q1{constructor(t,a={}){super(),tZ(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=a,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Ks.create("translator")}changeLanguage(t){t&&(this.language=t)}exists(t,a={interpolation:{}}){const r={...a};return t==null?!1:this.resolve(t,r)?.res!==void 0}extractFromKey(t,a){let r=a.nsSeparator!==void 0?a.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const o=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator;let c=a.ns||this.options.defaultNS||[];const f=r&&t.indexOf(r)>-1,m=!this.options.userDefinedKeySeparator&&!a.keySeparator&&!this.options.userDefinedNsSeparator&&!a.nsSeparator&&!cZ(t,r,o);if(f&&!m){const g=t.match(this.interpolator.nestingRegexp);if(g&&g.length>0)return{key:t,namespaces:sn(c)?[c]:c};const p=t.split(r);(r!==o||r===o&&this.options.ns.indexOf(p[0])>-1)&&(c=p.shift()),t=p.join(o)}return{key:t,namespaces:sn(c)?[c]:c}}translate(t,a,r){let o=typeof a=="object"?{...a}:a;if(typeof o!="object"&&this.options.overloadTranslationOptionHandler&&(o=this.options.overloadTranslationOptionHandler(arguments)),typeof options=="object"&&(o={...o}),o||(o={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const c=o.returnDetails!==void 0?o.returnDetails:this.options.returnDetails,f=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator,{key:m,namespaces:g}=this.extractFromKey(t[t.length-1],o),p=g[g.length-1];let y=o.nsSeparator!==void 0?o.nsSeparator:this.options.nsSeparator;y===void 0&&(y=":");const S=o.lng||this.language,E=o.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(S?.toLowerCase()==="cimode")return E?c?{res:`${p}${y}${m}`,usedKey:m,exactUsedKey:m,usedLng:S,usedNS:p,usedParams:this.getUsedParamsDetails(o)}:`${p}${y}${m}`:c?{res:m,usedKey:m,exactUsedKey:m,usedLng:S,usedNS:p,usedParams:this.getUsedParamsDetails(o)}:m;const T=this.resolve(t,o);let O=T?.res;const M=T?.usedKey||m,A=T?.exactUsedKey||m,D=["[object Number]","[object Function]","[object RegExp]"],_=o.joinArrays!==void 0?o.joinArrays:this.options.joinArrays,j=!this.i18nFormat||this.i18nFormat.handleAsObject,V=o.count!==void 0&&!sn(o.count),$=J1.hasDefaultValue(o),L=V?this.pluralResolver.getSuffix(S,o.count,o):"",H=o.ordinal&&V?this.pluralResolver.getSuffix(S,o.count,{ordinal:!1}):"",z=V&&!o.ordinal&&o.count===0,U=z&&o[`defaultValue${this.options.pluralSeparator}zero`]||o[`defaultValue${L}`]||o[`defaultValue${H}`]||o.defaultValue;let B=O;j&&!O&&$&&(B=U);const J=T6(B),X=Object.prototype.toString.apply(B);if(j&&B&&J&&D.indexOf(X)<0&&!(sn(_)&&Array.isArray(B))){if(!o.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const W=this.options.returnedObjectHandler?this.options.returnedObjectHandler(M,B,{...o,ns:g}):`key '${m} (${this.language})' returned an object instead of string.`;return c?(T.res=W,T.usedParams=this.getUsedParamsDetails(o),T):W}if(f){const W=Array.isArray(B),K=W?[]:{},re=W?A:M;for(const F in B)if(Object.prototype.hasOwnProperty.call(B,F)){const G=`${re}${f}${F}`;$&&!O?K[F]=this.translate(G,{...o,defaultValue:T6(U)?U[F]:void 0,joinArrays:!1,ns:g}):K[F]=this.translate(G,{...o,joinArrays:!1,ns:g}),K[F]===G&&(K[F]=B[F])}O=K}}else if(j&&sn(_)&&Array.isArray(O))O=O.join(_),O&&(O=this.extendTranslation(O,t,o,r));else{let W=!1,K=!1;!this.isValidLookup(O)&&$&&(W=!0,O=U),this.isValidLookup(O)||(K=!0,O=m);const F=(o.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&K?void 0:O,G=$&&U!==O&&this.options.updateMissing;if(K||W||G){if(this.logger.log(G?"updateKey":"missingKey",S,p,m,G?U:O),f){const q=this.resolve(m,{...o,keySeparator:!1});q&&q.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Z=[];const se=this.languageUtils.getFallbackCodes(this.options.fallbackLng,o.lng||this.language);if(this.options.saveMissingTo==="fallback"&&se&&se[0])for(let q=0;q<se.length;q++)Z.push(se[q]);else this.options.saveMissingTo==="all"?Z=this.languageUtils.toResolveHierarchy(o.lng||this.language):Z.push(o.lng||this.language);const k=(q,ee,ne)=>{const oe=$&&ne!==O?ne:F;this.options.missingKeyHandler?this.options.missingKeyHandler(q,p,ee,oe,G,o):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(q,p,ee,oe,G,o),this.emit("missingKey",q,p,ee,O)};this.options.saveMissing&&(this.options.saveMissingPlurals&&V?Z.forEach(q=>{const ee=this.pluralResolver.getSuffixes(q,o);z&&o[`defaultValue${this.options.pluralSeparator}zero`]&&ee.indexOf(`${this.options.pluralSeparator}zero`)<0&&ee.push(`${this.options.pluralSeparator}zero`),ee.forEach(ne=>{k([q],m+ne,o[`defaultValue${ne}`]||U)})}):k(Z,m,U))}O=this.extendTranslation(O,t,o,T,r),K&&O===m&&this.options.appendNamespaceToMissingKey&&(O=`${p}${y}${m}`),(K||W)&&this.options.parseMissingKeyHandler&&(O=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${p}${y}${m}`:m,W?O:void 0,o))}return c?(T.res=O,T.usedParams=this.getUsedParamsDetails(o),T):O}extendTranslation(t,a,r,o,c){if(this.i18nFormat?.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||o.usedLng,o.usedNS,o.usedKey,{resolved:o});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const g=sn(t)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let p;if(g){const S=t.match(this.interpolator.nestingRegexp);p=S&&S.length}let y=r.replace&&!sn(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(y={...this.options.interpolation.defaultVariables,...y}),t=this.interpolator.interpolate(t,y,r.lng||this.language||o.usedLng,r),g){const S=t.match(this.interpolator.nestingRegexp),E=S&&S.length;p<E&&(r.nest=!1)}!r.lng&&o&&o.res&&(r.lng=this.language||o.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,(...S)=>c?.[0]===S[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${S[0]} in key: ${a[0]}`),null):this.translate(...S,a),r)),r.interpolation&&this.interpolator.reset()}const f=r.postProcess||this.options.postProcess,m=sn(f)?[f]:f;return t!=null&&m?.length&&r.applyPostProcessor!==!1&&(t=E6.handle(m,t,a,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...o,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t,a={}){let r,o,c,f,m;return sn(t)&&(t=[t]),t.forEach(g=>{if(this.isValidLookup(r))return;const p=this.extractFromKey(g,a),y=p.key;o=y;let S=p.namespaces;this.options.fallbackNS&&(S=S.concat(this.options.fallbackNS));const E=a.count!==void 0&&!sn(a.count),T=E&&!a.ordinal&&a.count===0,O=a.context!==void 0&&(sn(a.context)||typeof a.context=="number")&&a.context!=="",M=a.lngs?a.lngs:this.languageUtils.toResolveHierarchy(a.lng||this.language,a.fallbackLng);S.forEach(A=>{this.isValidLookup(r)||(m=A,!w6[`${M[0]}-${A}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(m)&&(w6[`${M[0]}-${A}`]=!0,this.logger.warn(`key "${o}" for languages "${M.join(", ")}" won't get resolved as namespace "${m}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),M.forEach(D=>{if(this.isValidLookup(r))return;f=D;const _=[y];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(_,y,D,A,a);else{let V;E&&(V=this.pluralResolver.getSuffix(D,a.count,a));const $=`${this.options.pluralSeparator}zero`,L=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(E&&(_.push(y+V),a.ordinal&&V.indexOf(L)===0&&_.push(y+V.replace(L,this.options.pluralSeparator)),T&&_.push(y+$)),O){const H=`${y}${this.options.contextSeparator}${a.context}`;_.push(H),E&&(_.push(H+V),a.ordinal&&V.indexOf(L)===0&&_.push(H+V.replace(L,this.options.pluralSeparator)),T&&_.push(H+$))}}let j;for(;j=_.pop();)this.isValidLookup(r)||(c=j,r=this.getResource(D,A,j,a))}))})}),{res:r,usedKey:o,exactUsedKey:c,usedLng:f,usedNS:m}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,a,r,o={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(t,a,r,o):this.resourceStore.getResource(t,a,r,o)}getUsedParamsDetails(t={}){const a=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!sn(t.replace);let o=r?t.replace:t;if(r&&typeof t.count<"u"&&(o.count=t.count),this.options.interpolation.defaultVariables&&(o={...this.options.interpolation.defaultVariables,...o}),!r){o={...o};for(const c of a)delete o[c]}return o}static hasDefaultValue(t){const a="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&a===r.substring(0,a.length)&&t[r]!==void 0)return!0;return!1}}class O6{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ks.create("languageUtils")}getScriptPartFromCode(t){if(t=v0(t),!t||t.indexOf("-")<0)return null;const a=t.split("-");return a.length===2||(a.pop(),a[a.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(a.join("-"))}getLanguagePartFromCode(t){if(t=v0(t),!t||t.indexOf("-")<0)return t;const a=t.split("-");return this.formatLanguageCode(a[0])}formatLanguageCode(t){if(sn(t)&&t.indexOf("-")>-1){let a;try{a=Intl.getCanonicalLocales(t)[0]}catch{}return a&&this.options.lowerCaseLng&&(a=a.toLowerCase()),a||(this.options.lowerCaseLng?t.toLowerCase():t)}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let a;return t.forEach(r=>{if(a)return;const o=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(o))&&(a=o)}),!a&&this.options.supportedLngs&&t.forEach(r=>{if(a)return;const o=this.getScriptPartFromCode(r);if(this.isSupportedCode(o))return a=o;const c=this.getLanguagePartFromCode(r);if(this.isSupportedCode(c))return a=c;a=this.options.supportedLngs.find(f=>{if(f===c)return f;if(!(f.indexOf("-")<0&&c.indexOf("-")<0)&&(f.indexOf("-")>0&&c.indexOf("-")<0&&f.substring(0,f.indexOf("-"))===c||f.indexOf(c)===0&&c.length>1))return f})}),a||(a=this.getFallbackCodes(this.options.fallbackLng)[0]),a}getFallbackCodes(t,a){if(!t)return[];if(typeof t=="function"&&(t=t(a)),sn(t)&&(t=[t]),Array.isArray(t))return t;if(!a)return t.default||[];let r=t[a];return r||(r=t[this.getScriptPartFromCode(a)]),r||(r=t[this.formatLanguageCode(a)]),r||(r=t[this.getLanguagePartFromCode(a)]),r||(r=t.default),r||[]}toResolveHierarchy(t,a){const r=this.getFallbackCodes((a===!1?[]:a)||this.options.fallbackLng||[],t),o=[],c=f=>{f&&(this.isSupportedCode(f)?o.push(f):this.logger.warn(`rejecting language code not found in supportedLngs: ${f}`))};return sn(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&c(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&c(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&c(this.getLanguagePartFromCode(t))):sn(t)&&c(this.formatLanguageCode(t)),r.forEach(f=>{o.indexOf(f)<0&&c(this.formatLanguageCode(f))}),o}}const R6={zero:0,one:1,two:2,few:3,many:4,other:5},A6={select:e=>e===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class dZ{constructor(t,a={}){this.languageUtils=t,this.options=a,this.logger=Ks.create("pluralResolver"),this.pluralRulesCache={}}addRule(t,a){this.rules[t]=a}clearCache(){this.pluralRulesCache={}}getRule(t,a={}){const r=v0(t==="dev"?"en":t),o=a.ordinal?"ordinal":"cardinal",c=JSON.stringify({cleanedCode:r,type:o});if(c in this.pluralRulesCache)return this.pluralRulesCache[c];let f;try{f=new Intl.PluralRules(r,{type:o})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),A6;if(!t.match(/-|_/))return A6;const g=this.languageUtils.getLanguagePartFromCode(t);f=this.getRule(g,a)}return this.pluralRulesCache[c]=f,f}needsPlural(t,a={}){let r=this.getRule(t,a);return r||(r=this.getRule("dev",a)),r?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(t,a,r={}){return this.getSuffixes(t,r).map(o=>`${a}${o}`)}getSuffixes(t,a={}){let r=this.getRule(t,a);return r||(r=this.getRule("dev",a)),r?r.resolvedOptions().pluralCategories.sort((o,c)=>R6[o]-R6[c]).map(o=>`${this.options.prepend}${a.ordinal?`ordinal${this.options.prepend}`:""}${o}`):[]}getSuffix(t,a,r={}){const o=this.getRule(t,r);return o?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${o.select(a)}`:(this.logger.warn(`no plural rule found for: ${t}`),this.getSuffix("dev",a,r))}}const M6=(e,t,a,r=".",o=!0)=>{let c=rZ(e,t,a);return!c&&o&&sn(a)&&(c=gO(e,a,r),c===void 0&&(c=gO(t,a,r))),c},vO=e=>e.replace(/\$/g,"$$$$");class hZ{constructor(t={}){this.logger=Ks.create("interpolator"),this.options=t,this.format=t?.interpolation?.format||(a=>a),this.init(t)}init(t={}){t.interpolation||(t.interpolation={escapeValue:!0});const{escape:a,escapeValue:r,useRawValueToEscape:o,prefix:c,prefixEscaped:f,suffix:m,suffixEscaped:g,formatSeparator:p,unescapeSuffix:y,unescapePrefix:S,nestingPrefix:E,nestingPrefixEscaped:T,nestingSuffix:O,nestingSuffixEscaped:M,nestingOptionsSeparator:A,maxReplaces:D,alwaysFormat:_}=t.interpolation;this.escape=a!==void 0?a:oZ,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=o!==void 0?o:!1,this.prefix=c?Xm(c):f||"{{",this.suffix=m?Xm(m):g||"}}",this.formatSeparator=p||",",this.unescapePrefix=y?"":S||"-",this.unescapeSuffix=this.unescapePrefix?"":y||"",this.nestingPrefix=E?Xm(E):T||Xm("$t("),this.nestingSuffix=O?Xm(O):M||Xm(")"),this.nestingOptionsSeparator=A||",",this.maxReplaces=D||1e3,this.alwaysFormat=_!==void 0?_:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(a,r)=>a?.source===r?(a.lastIndex=0,a):new RegExp(r,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,a,r,o){let c,f,m;const g=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},p=T=>{if(T.indexOf(this.formatSeparator)<0){const D=M6(a,g,T,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(D,void 0,r,{...o,...a,interpolationkey:T}):D}const O=T.split(this.formatSeparator),M=O.shift().trim(),A=O.join(this.formatSeparator).trim();return this.format(M6(a,g,M,this.options.keySeparator,this.options.ignoreJSONStructure),A,r,{...o,...a,interpolationkey:M})};this.resetRegExp();const y=o?.missingInterpolationHandler||this.options.missingInterpolationHandler,S=o?.interpolation?.skipOnVariables!==void 0?o.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:T=>vO(T)},{regex:this.regexp,safeValue:T=>this.escapeValue?vO(this.escape(T)):vO(T)}].forEach(T=>{for(m=0;c=T.regex.exec(t);){const O=c[1].trim();if(f=p(O),f===void 0)if(typeof y=="function"){const A=y(t,c,o);f=sn(A)?A:""}else if(o&&Object.prototype.hasOwnProperty.call(o,O))f="";else if(S){f=c[0];continue}else this.logger.warn(`missed to pass in variable ${O} for interpolating ${t}`),f="";else!sn(f)&&!this.useRawValueToEscape&&(f=v6(f));const M=T.safeValue(f);if(t=t.replace(c[0],M),S?(T.regex.lastIndex+=f.length,T.regex.lastIndex-=c[0].length):T.regex.lastIndex=0,m++,m>=this.maxReplaces)break}}),t}nest(t,a,r={}){let o,c,f;const m=(g,p)=>{const y=this.nestingOptionsSeparator;if(g.indexOf(y)<0)return g;const S=g.split(new RegExp(`${y}[ ]*{`));let E=`{${S[1]}`;g=S[0],E=this.interpolate(E,f);const T=E.match(/'/g),O=E.match(/"/g);((T?.length??0)%2===0&&!O||O.length%2!==0)&&(E=E.replace(/'/g,'"'));try{f=JSON.parse(E),p&&(f={...p,...f})}catch(M){return this.logger.warn(`failed parsing options string in nesting for key ${g}`,M),`${g}${y}${E}`}return f.defaultValue&&f.defaultValue.indexOf(this.prefix)>-1&&delete f.defaultValue,g};for(;o=this.nestingRegexp.exec(t);){let g=[];f={...r},f=f.replace&&!sn(f.replace)?f.replace:f,f.applyPostProcessor=!1,delete f.defaultValue;const p=/{.*}/.test(o[1])?o[1].lastIndexOf("}")+1:o[1].indexOf(this.formatSeparator);if(p!==-1&&(g=o[1].slice(p).split(this.formatSeparator).map(y=>y.trim()).filter(Boolean),o[1]=o[1].slice(0,p)),c=a(m.call(this,o[1].trim(),f),f),c&&o[0]===t&&!sn(c))return c;sn(c)||(c=v6(c)),c||(this.logger.warn(`missed to resolve ${o[1]} for nesting ${t}`),c=""),g.length&&(c=g.reduce((y,S)=>this.format(y,S,r.lng,{...r,interpolationkey:o[1].trim()}),c.trim())),t=t.replace(o[0],c),this.regexp.lastIndex=0}return t}}const mZ=e=>{let t=e.toLowerCase().trim();const a={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const o=r[1].substring(0,r[1].length-1);t==="currency"&&o.indexOf(":")<0?a.currency||(a.currency=o.trim()):t==="relativetime"&&o.indexOf(":")<0?a.range||(a.range=o.trim()):o.split(";").forEach(f=>{if(f){const[m,...g]=f.split(":"),p=g.join(":").trim().replace(/^'+|'+$/g,""),y=m.trim();a[y]||(a[y]=p),p==="false"&&(a[y]=!1),p==="true"&&(a[y]=!0),isNaN(p)||(a[y]=parseInt(p,10))}})}return{formatName:t,formatOptions:a}},_6=e=>{const t={};return(a,r,o)=>{let c=o;o&&o.interpolationkey&&o.formatParams&&o.formatParams[o.interpolationkey]&&o[o.interpolationkey]&&(c={...c,[o.interpolationkey]:void 0});const f=r+JSON.stringify(c);let m=t[f];return m||(m=e(v0(r),o),t[f]=m),m(a)}},pZ=e=>(t,a,r)=>e(v0(a),r)(t);class gZ{constructor(t={}){this.logger=Ks.create("formatter"),this.options=t,this.init(t)}init(t,a={interpolation:{}}){this.formatSeparator=a.interpolation.formatSeparator||",";const r=a.cacheInBuiltFormats?_6:pZ;this.formats={number:r((o,c)=>{const f=new Intl.NumberFormat(o,{...c});return m=>f.format(m)}),currency:r((o,c)=>{const f=new Intl.NumberFormat(o,{...c,style:"currency"});return m=>f.format(m)}),datetime:r((o,c)=>{const f=new Intl.DateTimeFormat(o,{...c});return m=>f.format(m)}),relativetime:r((o,c)=>{const f=new Intl.RelativeTimeFormat(o,{...c});return m=>f.format(m,c.range||"day")}),list:r((o,c)=>{const f=new Intl.ListFormat(o,{...c});return m=>f.format(m)})}}add(t,a){this.formats[t.toLowerCase().trim()]=a}addCached(t,a){this.formats[t.toLowerCase().trim()]=_6(a)}format(t,a,r,o={}){const c=a.split(this.formatSeparator);if(c.length>1&&c[0].indexOf("(")>1&&c[0].indexOf(")")<0&&c.find(m=>m.indexOf(")")>-1)){const m=c.findIndex(g=>g.indexOf(")")>-1);c[0]=[c[0],...c.splice(1,m)].join(this.formatSeparator)}return c.reduce((m,g)=>{const{formatName:p,formatOptions:y}=mZ(g);if(this.formats[p]){let S=m;try{const E=o?.formatParams?.[o.interpolationkey]||{},T=E.locale||E.lng||o.locale||o.lng||r;S=this.formats[p](m,T,{...y,...o,...E})}catch(E){this.logger.warn(E)}return S}else this.logger.warn(`there was no format function for ${p}`);return m},t)}}const vZ=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class yZ extends Q1{constructor(t,a,r,o={}){super(),this.backend=t,this.store=a,this.services=r,this.languageUtils=r.languageUtils,this.options=o,this.logger=Ks.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=o.maxParallelReads||10,this.readingCalls=0,this.maxRetries=o.maxRetries>=0?o.maxRetries:5,this.retryTimeout=o.retryTimeout>=1?o.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,o.backend,o)}queueLoad(t,a,r,o){const c={},f={},m={},g={};return t.forEach(p=>{let y=!0;a.forEach(S=>{const E=`${p}|${S}`;!r.reload&&this.store.hasResourceBundle(p,S)?this.state[E]=2:this.state[E]<0||(this.state[E]===1?f[E]===void 0&&(f[E]=!0):(this.state[E]=1,y=!1,f[E]===void 0&&(f[E]=!0),c[E]===void 0&&(c[E]=!0),g[S]===void 0&&(g[S]=!0)))}),y||(m[p]=!0)}),(Object.keys(c).length||Object.keys(f).length)&&this.queue.push({pending:f,pendingCount:Object.keys(f).length,loaded:{},errors:[],callback:o}),{toLoad:Object.keys(c),pending:Object.keys(f),toLoadLanguages:Object.keys(m),toLoadNamespaces:Object.keys(g)}}loaded(t,a,r){const o=t.split("|"),c=o[0],f=o[1];a&&this.emit("failedLoading",c,f,a),!a&&r&&this.store.addResourceBundle(c,f,r,void 0,void 0,{skipCopy:!0}),this.state[t]=a?-1:2,a&&r&&(this.state[t]=0);const m={};this.queue.forEach(g=>{aZ(g.loaded,[c],f),vZ(g,t),a&&g.errors.push(a),g.pendingCount===0&&!g.done&&(Object.keys(g.loaded).forEach(p=>{m[p]||(m[p]={});const y=g.loaded[p];y.length&&y.forEach(S=>{m[p][S]===void 0&&(m[p][S]=!0)})}),g.done=!0,g.errors.length?g.callback(g.errors):g.callback())}),this.emit("loaded",m),this.queue=this.queue.filter(g=>!g.done)}read(t,a,r,o=0,c=this.retryTimeout,f){if(!t.length)return f(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:a,fcName:r,tried:o,wait:c,callback:f});return}this.readingCalls++;const m=(p,y)=>{if(this.readingCalls--,this.waitingReads.length>0){const S=this.waitingReads.shift();this.read(S.lng,S.ns,S.fcName,S.tried,S.wait,S.callback)}if(p&&y&&o<this.maxRetries){setTimeout(()=>{this.read.call(this,t,a,r,o+1,c*2,f)},c);return}f(p,y)},g=this.backend[r].bind(this.backend);if(g.length===2){try{const p=g(t,a);p&&typeof p.then=="function"?p.then(y=>m(null,y)).catch(m):m(null,p)}catch(p){m(p)}return}return g(t,a,m)}prepareLoading(t,a,r={},o){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),o&&o();sn(t)&&(t=this.languageUtils.toResolveHierarchy(t)),sn(a)&&(a=[a]);const c=this.queueLoad(t,a,r,o);if(!c.toLoad.length)return c.pending.length||o(),null;c.toLoad.forEach(f=>{this.loadOne(f)})}load(t,a,r){this.prepareLoading(t,a,{},r)}reload(t,a,r){this.prepareLoading(t,a,{reload:!0},r)}loadOne(t,a=""){const r=t.split("|"),o=r[0],c=r[1];this.read(o,c,"read",void 0,void 0,(f,m)=>{f&&this.logger.warn(`${a}loading namespace ${c} for language ${o} failed`,f),!f&&m&&this.logger.log(`${a}loaded namespace ${c} for language ${o}`,m),this.loaded(t,f,m)})}saveMissing(t,a,r,o,c,f={},m=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(a)){this.logger.warn(`did not save key "${r}" as the namespace "${a}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend?.create){const g={...f,isUpdate:c},p=this.backend.create.bind(this.backend);if(p.length<6)try{let y;p.length===5?y=p(t,a,r,o,g):y=p(t,a,r,o),y&&typeof y.then=="function"?y.then(S=>m(null,S)).catch(m):m(null,y)}catch(y){m(y)}else p(t,a,r,o,m,g)}!t||!t[0]||this.store.addResource(t[0],a,r,o)}}}const D6=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),sn(e[1])&&(t.defaultValue=e[1]),sn(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const a=e[3]||e[2];Object.keys(a).forEach(r=>{t[r]=a[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),N6=e=>(sn(e.ns)&&(e.ns=[e.ns]),sn(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),sn(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),typeof e.initImmediate=="boolean"&&(e.initAsync=e.initImmediate),e),ex=()=>{},bZ=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(a=>{typeof e[a]=="function"&&(e[a]=e[a].bind(e))})};class y0 extends Q1{constructor(t={},a){if(super(),this.options=N6(t),this.services={},this.logger=Ks,this.modules={external:[]},bZ(this),a&&!this.isInitialized&&!t.isClone){if(!this.options.initAsync)return this.init(t,a),this;setTimeout(()=>{this.init(t,a)},0)}}init(t={},a){this.isInitializing=!0,typeof t=="function"&&(a=t,t={}),t.defaultNS==null&&t.ns&&(sn(t.ns)?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));const r=D6();this.options={...r,...this.options,...N6(t)},this.options.interpolation={...r.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator);const o=p=>p?typeof p=="function"?new p:p:null;if(!this.options.isClone){this.modules.logger?Ks.init(o(this.modules.logger),this.options):Ks.init(null,this.options);let p;this.modules.formatter?p=this.modules.formatter:p=gZ;const y=new O6(this.options);this.store=new C6(this.options.resources,this.options);const S=this.services;S.logger=Ks,S.resourceStore=this.store,S.languageUtils=y,S.pluralResolver=new dZ(y,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.warn("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),p&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(S.formatter=o(p),S.formatter.init&&S.formatter.init(S,this.options),this.options.interpolation.format=S.formatter.format.bind(S.formatter)),S.interpolator=new hZ(this.options),S.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},S.backendConnector=new yZ(o(this.modules.backend),S.resourceStore,S,this.options),S.backendConnector.on("*",(T,...O)=>{this.emit(T,...O)}),this.modules.languageDetector&&(S.languageDetector=o(this.modules.languageDetector),S.languageDetector.init&&S.languageDetector.init(S,this.options.detection,this.options)),this.modules.i18nFormat&&(S.i18nFormat=o(this.modules.i18nFormat),S.i18nFormat.init&&S.i18nFormat.init(this)),this.translator=new J1(this.services,this.options),this.translator.on("*",(T,...O)=>{this.emit(T,...O)}),this.modules.external.forEach(T=>{T.init&&T.init(this)})}if(this.format=this.options.interpolation.format,a||(a=ex),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const p=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);p.length>0&&p[0]!=="dev"&&(this.options.lng=p[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(p=>{this[p]=(...y)=>this.store[p](...y)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(p=>{this[p]=(...y)=>(this.store[p](...y),this)});const m=p0(),g=()=>{const p=(y,S)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),m.resolve(S),a(y,S)};if(this.languages&&!this.isInitialized)return p(null,this.t.bind(this));this.changeLanguage(this.options.lng,p)};return this.options.resources||!this.options.initAsync?g():setTimeout(g,0),m}loadResources(t,a=ex){let r=a;const o=sn(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(o?.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const c=[],f=m=>{if(!m||m==="cimode")return;this.services.languageUtils.toResolveHierarchy(m).forEach(p=>{p!=="cimode"&&c.indexOf(p)<0&&c.push(p)})};o?f(o):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(g=>f(g)),this.options.preload?.forEach?.(m=>f(m)),this.services.backendConnector.load(c,this.options.ns,m=>{!m&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(m)})}else r(null)}reloadResources(t,a,r){const o=p0();return typeof t=="function"&&(r=t,t=void 0),typeof a=="function"&&(r=a,a=void 0),t||(t=this.languages),a||(a=this.options.ns),r||(r=ex),this.services.backendConnector.reload(t,a,c=>{o.resolve(),r(c)}),o}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&E6.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1)){for(let a=0;a<this.languages.length;a++){const r=this.languages[a];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}!this.resolvedLanguage&&this.languages.indexOf(t)<0&&this.store.hasLanguageSomeTranslations(t)&&(this.resolvedLanguage=t,this.languages.unshift(t))}}changeLanguage(t,a){this.isLanguageChangingTo=t;const r=p0();this.emit("languageChanging",t);const o=m=>{this.language=m,this.languages=this.services.languageUtils.toResolveHierarchy(m),this.resolvedLanguage=void 0,this.setResolvedLanguage(m)},c=(m,g)=>{g?this.isLanguageChangingTo===t&&(o(g),this.translator.changeLanguage(g),this.isLanguageChangingTo=void 0,this.emit("languageChanged",g),this.logger.log("languageChanged",g)):this.isLanguageChangingTo=void 0,r.resolve((...p)=>this.t(...p)),a&&a(m,(...p)=>this.t(...p))},f=m=>{!t&&!m&&this.services.languageDetector&&(m=[]);const g=sn(m)?m:m&&m[0],p=this.store.hasLanguageSomeTranslations(g)?g:this.services.languageUtils.getBestMatchFromCodes(sn(m)?[m]:m);p&&(this.language||o(p),this.translator.language||this.translator.changeLanguage(p),this.services.languageDetector?.cacheUserLanguage?.(p)),this.loadResources(p,y=>{c(y,p)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?f(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(f):this.services.languageDetector.detect(f):f(t),r}getFixedT(t,a,r){const o=(c,f,...m)=>{let g;typeof f!="object"?g=this.options.overloadTranslationOptionHandler([c,f].concat(m)):g={...f},g.lng=g.lng||o.lng,g.lngs=g.lngs||o.lngs,g.ns=g.ns||o.ns,g.keyPrefix!==""&&(g.keyPrefix=g.keyPrefix||r||o.keyPrefix);const p=this.options.keySeparator||".";let y;return g.keyPrefix&&Array.isArray(c)?y=c.map(S=>`${g.keyPrefix}${p}${S}`):y=g.keyPrefix?`${g.keyPrefix}${p}${c}`:c,this.t(y,g)};return sn(t)?o.lng=t:o.lngs=t,o.ns=a,o.keyPrefix=r,o}t(...t){return this.translator?.translate(...t)}exists(...t){return this.translator?.exists(...t)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t,a={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=a.lng||this.resolvedLanguage||this.languages[0],o=this.options?this.options.fallbackLng:!1,c=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const f=(m,g)=>{const p=this.services.backendConnector.state[`${m}|${g}`];return p===-1||p===0||p===2};if(a.precheck){const m=a.precheck(this,f);if(m!==void 0)return m}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||f(r,t)&&(!o||f(c,t)))}loadNamespaces(t,a){const r=p0();return this.options.ns?(sn(t)&&(t=[t]),t.forEach(o=>{this.options.ns.indexOf(o)<0&&this.options.ns.push(o)}),this.loadResources(o=>{r.resolve(),a&&a(o)}),r):(a&&a(),Promise.resolve())}loadLanguages(t,a){const r=p0();sn(t)&&(t=[t]);const o=this.options.preload||[],c=t.filter(f=>o.indexOf(f)<0&&this.services.languageUtils.isSupportedCode(f));return c.length?(this.options.preload=o.concat(c),this.loadResources(f=>{r.resolve(),a&&a(f)}),r):(a&&a(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!t)return"rtl";try{const o=new Intl.Locale(t);if(o&&o.getTextInfo){const c=o.getTextInfo();if(c&&c.direction)return c.direction}}catch{}const a=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new O6(D6());return t.toLowerCase().indexOf("-latn")>1?"ltr":a.indexOf(r.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(t={},a){return new y0(t,a)}cloneInstance(t={},a=ex){const r=t.forkResourceStore;r&&delete t.forkResourceStore;const o={...this.options,...t,isClone:!0},c=new y0(o);if((t.debug!==void 0||t.prefix!==void 0)&&(c.logger=c.logger.clone(t)),["store","services","language"].forEach(m=>{c[m]=this[m]}),c.services={...this.services},c.services.utils={hasLoadedNamespace:c.hasLoadedNamespace.bind(c)},r){const m=Object.keys(this.store.data).reduce((g,p)=>(g[p]={...this.store.data[p]},g[p]=Object.keys(g[p]).reduce((y,S)=>(y[S]={...g[p][S]},y),g[p]),g),{});c.store=new C6(m,o),c.services.resourceStore=c.store}return c.translator=new J1(c.services,o),c.translator.on("*",(m,...g)=>{c.emit(m,...g)}),c.init(o,a),c.translator.options=o,c.translator.backendConnector.services.utils={hasLoadedNamespace:c.hasLoadedNamespace.bind(c)},c}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Zr=y0.createInstance();Zr.createInstance=y0.createInstance,Zr.createInstance,Zr.dir,Zr.init,Zr.loadResources,Zr.reloadResources,Zr.use,Zr.changeLanguage,Zr.getFixedT,Zr.t,Zr.exists,Zr.setDefaultNamespace,Zr.hasLoadedNamespace,Zr.loadNamespaces,Zr.loadLanguages;const SZ=(e,t,a,r)=>{const o=[a,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(o,"warn","react-i18next::",!0);Vd(o[0])&&(o[0]=`react-i18next:: ${o[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...o):console?.warn&&console.warn(...o)},$6={},yO=(e,t,a,r)=>{Vd(a)&&$6[a]||(Vd(a)&&($6[a]=new Date),SZ(e,t,a,r))},z6=(e,t)=>()=>{if(e.isInitialized)t();else{const a=()=>{setTimeout(()=>{e.off("initialized",a)},0),t()};e.on("initialized",a)}},bO=(e,t,a)=>{e.loadNamespaces(t,z6(e,a))},j6=(e,t,a,r)=>{if(Vd(a)&&(a=[a]),e.options.preload&&e.options.preload.indexOf(t)>-1)return bO(e,a,r);a.forEach(o=>{e.options.ns.indexOf(o)<0&&e.options.ns.push(o)}),e.loadLanguages(t,z6(e,r))},xZ=(e,t,a={})=>!t.languages||!t.languages.length?(yO(t,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:a.lng,precheck:(r,o)=>{if(a.bindI18n?.indexOf("languageChanging")>-1&&r.services.backendConnector.backend&&r.isLanguageChangingTo&&!o(r.isLanguageChangingTo,e))return!1}}),Vd=e=>typeof e=="string",CZ=e=>typeof e=="object"&&e!==null,EZ=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,wZ={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},TZ=e=>wZ[e];let SO={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:e=>e.replace(EZ,TZ)};const OZ=(e={})=>{SO={...SO,...e}},RZ=()=>SO;let L6;const AZ=e=>{L6=e},MZ=()=>L6,_Z={type:"3rdParty",init(e){OZ(e.options.react),AZ(e)}},DZ=x.createContext();class NZ{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(a=>{this.usedNamespaces[a]||(this.usedNamespaces[a]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const $Z=(e,t)=>{const a=x.useRef();return x.useEffect(()=>{a.current=e},[e,t]),a.current},V6=(e,t,a,r)=>e.getFixedT(t,a,r),zZ=(e,t,a,r)=>x.useCallback(V6(e,t,a,r),[e,t,a,r]),jZ=(e,t={})=>{const{i18n:a}=t,{i18n:r,defaultNS:o}=x.useContext(DZ)||{},c=a||r||MZ();if(c&&!c.reportNamespaces&&(c.reportNamespaces=new NZ),!c){yO(c,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const V=(L,H)=>Vd(H)?H:CZ(H)&&Vd(H.defaultValue)?H.defaultValue:Array.isArray(L)?L[L.length-1]:L,$=[V,{},!1];return $.t=V,$.i18n={},$.ready=!1,$}c.options.react?.wait&&yO(c,"DEPRECATED_OPTION","useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const f={...RZ(),...c.options.react,...t},{useSuspense:m,keyPrefix:g}=f;let p=o||c.options?.defaultNS;p=Vd(p)?[p]:p||["translation"],c.reportNamespaces.addUsedNamespaces?.(p);const y=(c.isInitialized||c.initializedStoreOnce)&&p.every(V=>xZ(V,c,f)),S=zZ(c,t.lng||null,f.nsMode==="fallback"?p:p[0],g),E=()=>S,T=()=>V6(c,t.lng||null,f.nsMode==="fallback"?p:p[0],g),[O,M]=x.useState(E);let A=p.join();t.lng&&(A=`${t.lng}${A}`);const D=$Z(A),_=x.useRef(!0);x.useEffect(()=>{const{bindI18n:V,bindI18nStore:$}=f;_.current=!0,!y&&!m&&(t.lng?j6(c,t.lng,p,()=>{_.current&&M(T)}):bO(c,p,()=>{_.current&&M(T)})),y&&D&&D!==A&&_.current&&M(T);const L=()=>{_.current&&M(T)};return V&&c?.on(V,L),$&&c?.store.on($,L),()=>{_.current=!1,c&&V?.split(" ").forEach(H=>c.off(H,L)),$&&c&&$.split(" ").forEach(H=>c.store.off(H,L))}},[c,A]),x.useEffect(()=>{_.current&&y&&M(E)},[c,g,y]);const j=[O,c,y];if(j.t=O,j.i18n=c,j.ready=y,y||!y&&!m)return j;throw new Promise(V=>{t.lng?j6(c,t.lng,p,()=>V()):bO(c,p,()=>V())})},LZ={en:{translation:{welcome:"Hi there, you’re speaking with Jaweb AI Assistant."}},ar:{translation:{welcome:"مرحبًا، أنت تتحدث إلى مساعد Jaweb AI."}}};Zr.use(_Z).init({resources:LZ,lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1}});const VZ=3,HZ=3e3,BZ=()=>{const[e,t]=x.useState(!0),[a,r]=x.useState(!1),[o,c]=x.useState(""),[f,m]=x.useState(""),[g,p]=x.useState(!1),[y,S]=x.useState(!1),[E,T]=x.useState(""),[O,M]=x.useState(""),[A,D]=x.useState(""),[_,j]=x.useState(""),[V,$]=x.useState([]),[L,H]=x.useState([]),[z,U]=x.useState(""),B=async(J=0)=>{const X=localStorage.getItem("company_username");console.log(X),t(!0);const W={headers:{"Content-Type":"application/json",Accept:"application/json"},params:{username:X}};try{const re=(await $a.get(`${wi.apiUrl}chatbot-details/`,W)).data.data;re.language==="Arabic"?Zr.changeLanguage("ar"):Zr.changeLanguage("en"),r(re.chatbot_form),c(re.chatbot_color),m(re.chatbot_logo),p(re.disable_chatbot_globally),S(re.remove_powered_by_jaweb),T(re.chatbot_initial_msg),M(re.status),U(re.mode),console.log(re),re.calendly_link&&D(re.calendly_link),re.phone_number_id&&j(`+${re.phone_number_id}`);const F=await $a.get(`${wi.apiUrl}chatbot-plugin-suggestions/`,W);let G=[];Array.isArray(F.data.data)?G=F.data.data:Array.isArray(F.data.user_questions)&&(G=F.data.user_questions),G.length>0?($(G.slice(0,3)),H(G.slice(3))):($([]),H([])),t(!1)}catch(K){console.error("Error fetching data:",K),J<VZ?setTimeout(()=>B(J+1),HZ):console.error("Max retries reached. Could not fetch data.")}};return x.useEffect(()=>{B()},[]),{isFetchingDetails:e,disableForm:a,colorCode:o,chatbotLogo:f,disableChatbotGlobally:g,removePoweredByJaweb:y,initialMessageText:E,subscription:O,calendly:A,merchantPhone:_,messagesSuggestions:V,restSuggestions:L,userType:z}},{Text:PZ,Title:UZ}=Fm,IZ=({chatbotLogo:e,colorCode:t,onNewSession:a,visitorId:r,onSessionSelect:o,setOpen:c,Opened:f,Phone:m})=>{const[g,p]=x.useState([]),[y,S]=x.useState(!0),E=async()=>{try{S(!0);const A=(await(await fetch(`${wi.apiUrl}get-chatlogs-by-ip/?visitor_id=${r}&company_username=${localStorage.getItem("company_username")}`)).json()).map(D=>({id:D.user_session_id,agentName:D.assignee||"AI Agent",createdAt:D.date,isBlurred:D.closed,agentImage:D.assignee_picture}));p(A)}catch(O){console.error("Failed to load sessions:",O)}finally{S(!1)}};x.useEffect(()=>{r&&E()},[r]);const T=ae.jsx(Fu,{style:{fontSize:24},spin:!0});return ae.jsxs("div",{style:{maxWidth:"100%",height:"100%",border:"1px solid #f0f0f0",borderRadius:8,overflow:"hidden",display:"flex",flexDirection:"column",paddingTop:20},children:[ae.jsxs("div",{style:{padding:"0 16px 10px",display:"flex"},children:[ae.jsx(UZ,{level:4,style:{margin:0},children:"Conversations"}),ae.jsx(Gv,{onClick:()=>c(!f),className:"chatbot-close",style:{marginLeft:"auto"}})]}),ae.jsx("div",{style:{flex:1,overflowY:"auto"},children:y?ae.jsx("div",{style:{textAlign:"center",padding:"2rem"},children:ae.jsx(tf,{indicator:T})}):g.length>0?ae.jsx($1,{itemLayout:"horizontal",dataSource:g,split:!0,renderItem:O=>ae.jsx($1.Item,{onClick:()=>!O.isBlurred&&o(O.id,O.agentName||"Ai Agent",O.agentImage||e),style:{padding:"12px",opacity:O.isBlurred?.5:1,cursor:O.isBlurred?"not-allowed":"pointer",borderBottom:"1px solid #f0f0f0"},children:ae.jsx($1.Item.Meta,{avatar:ae.jsx(MT,{size:"large",src:O.agentImage||e,icon:!O.agentImage&&!e?ae.jsx(b4,{}):void 0}),title:ae.jsx("span",{style:{fontWeight:600},children:O.agentName||"AI Agent"}),description:ae.jsxs(ae.Fragment,{children:[ae.jsxs(PZ,{type:"secondary",children:["Created: ",new Date(O.createdAt).toLocaleDateString()]}),O.isBlurred&&ae.jsx("div",{style:{color:"red",fontSize:"12px",marginTop:4},children:"This session is closed and cannot be reopened."})]})})},O.id)}):ae.jsx("div",{style:{padding:"1rem",textAlign:"center",color:"#888"},children:"No conversations yet."})}),ae.jsxs("div",{style:{padding:"12px",borderTop:"1px solid #f0f0f0",display:"flex",gap:4},children:[ae.jsx(ri,{type:"primary",size:"large",block:!0,style:{backgroundColor:t,color:"#fff"},onClick:a,children:"Ask a question"}),m?ae.jsx(ri,{type:"default",style:{backgroundColor:"#25D366",color:"white"},className:"hover:border-black",size:"large",icon:ae.jsx(S4,{style:{color:"white"}}),onClick:()=>{const O=`https://wa.me/${m}`;window.open(O,"_blank")},children:"Chat on WhatsApp"}):ae.jsx(ae.Fragment,{})]})]})},{Title:kZ,Text:xO}=Fm,FZ=({onBack:e,onCreate:t,colorCode:a,visitorId:r,country:o})=>{const[c,f]=x.useState(""),[m,g]=x.useState(""),[p,y]=x.useState(""),[S,E]=x.useState(!1),T=async()=>{const O={visitor_id:r,country:o,name:c,email:m,phone:p,company_username:localStorage.getItem("company_username")};try{E(!0);const M=await fetch(`${wi.apiUrl}chatlog-create/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)}),A=await M.json();M.ok?t({name:c,email:m,phone:p,session_id:A?.user_session_id,messages:A.messages,hasInfo:!0}):console.error("Failed to register:",A)}catch(M){console.error("Error submitting session data:",M)}finally{E(!1)}};return ae.jsxs("div",{style:{padding:"1.5rem"},children:[ae.jsx(ri,{type:"text",icon:ae.jsx(km,{}),onClick:e,style:{marginBottom:"1rem"},children:"Back"}),ae.jsx(kZ,{level:4,style:{marginBottom:"2rem"},children:"Let's create a session"}),ae.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:[ae.jsxs("div",{children:[ae.jsx(xO,{strong:!0,children:"👋 Please, can I have your name?"}),ae.jsx(Yu,{size:"large",placeholder:"John Doe",value:c,onChange:O=>f(O.target.value),style:{marginTop:"0.5rem"}})]}),ae.jsxs("div",{children:[ae.jsx(xO,{strong:!0,children:"📧 What’s your email address?"}),ae.jsx(Yu,{size:"large",type:"email",placeholder:"you@example.com",value:m,onChange:O=>g(O.target.value),style:{marginTop:"0.5rem"}})]}),ae.jsxs("div",{children:[ae.jsx(xO,{strong:!0,children:"📱 May I have your phone number?"}),ae.jsx(Yu,{size:"large",placeholder:"+1 234 567 8900",value:p,onChange:O=>y(O.target.value),style:{marginTop:"0.5rem"}})]}),ae.jsx(ri,{type:"primary",size:"large",style:{backgroundColor:a,color:"white"},onClick:T,disabled:!c||!m||!p,children:S?ae.jsx(tf,{indicator:ae.jsx(Fu,{style:{fontSize:20,color:"white"},spin:!0})}):"Create Session"})]})]})},qZ=e=>{const[t,a]=x.useState([]),[r,o]=x.useState(!1),c=async()=>{const f=e;if(f){o(!0);try{const m=await $a.get(`${wi.apiUrl}chat-message-history/`,{withCredentials:!0,params:{session_id:f,username:localStorage.getItem("company_username")}});m.data?.messages?.length>0&&(a(m.data.messages),o(!1))}catch(m){console.error("Couldn't load history",m)}}};return x.useEffect(()=>{c()},[e]),{messages:t,setMessages:a,isFetchingMessages:r}};function ii(e,t,a,r){return new(a||(a=Promise))(function(o,c){function f(p){try{g(r.next(p))}catch(y){c(y)}}function m(p){try{g(r.throw(p))}catch(y){c(y)}}function g(p){var y;p.done?o(p.value):(y=p.value,y instanceof a?y:new a(function(S){S(y)})).then(f,m)}g((r=r.apply(e,t||[])).next())})}typeof SuppressedError=="function"&&SuppressedError;class b0{constructor(){this.listeners={}}on(t,a,r){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(a),r?.once){const o=()=>{this.un(t,o),this.un(t,a)};return this.on(t,o),o}return()=>this.un(t,a)}un(t,a){var r;(r=this.listeners[t])===null||r===void 0||r.delete(a)}once(t,a){return this.on(t,a,{once:!0})}unAll(){this.listeners={}}emit(t,...a){this.listeners[t]&&this.listeners[t].forEach(r=>r(...a))}}const tx={decode:function(e,t){return ii(this,void 0,void 0,function*(){const a=new AudioContext({sampleRate:t});return a.decodeAudioData(e).finally(()=>a.close())})},createBuffer:function(e,t){return typeof e[0]=="number"&&(e=[e]),function(a){const r=a[0];if(r.some(o=>o>1||o<-1)){const o=r.length;let c=0;for(let f=0;f<o;f++){const m=Math.abs(r[f]);m>c&&(c=m)}for(const f of a)for(let m=0;m<o;m++)f[m]/=c}}(e),{duration:t,length:e[0].length,sampleRate:e[0].length/t,numberOfChannels:e.length,getChannelData:a=>e?.[a],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function H6(e,t){const a=t.xmlns?document.createElementNS(t.xmlns,e):document.createElement(e);for(const[r,o]of Object.entries(t))if(r==="children"&&o)for(const[c,f]of Object.entries(o))f instanceof Node?a.appendChild(f):typeof f=="string"?a.appendChild(document.createTextNode(f)):a.appendChild(H6(c,f));else r==="style"?Object.assign(a.style,o):r==="textContent"?a.textContent=o:a.setAttribute(r,o.toString());return a}function B6(e,t,a){const r=H6(e,t||{});return a?.appendChild(r),r}var GZ=Object.freeze({__proto__:null,createElement:B6,default:B6});const XZ={fetchBlob:function(e,t,a){return ii(this,void 0,void 0,function*(){const r=yield fetch(e,a);if(r.status>=400)throw new Error(`Failed to fetch ${e}: ${r.status} (${r.statusText})`);return function(o,c){ii(this,void 0,void 0,function*(){if(!o.body||!o.headers)return;const f=o.body.getReader(),m=Number(o.headers.get("Content-Length"))||0;let g=0;const p=S=>ii(this,void 0,void 0,function*(){g+=S?.length||0;const E=Math.round(g/m*100);c(E)}),y=()=>ii(this,void 0,void 0,function*(){let S;try{S=yield f.read()}catch{return}S.done||(p(S.value),yield y())});y()})}(r.clone(),t),r.blob()})}};class YZ extends b0{constructor(t){super(),this.isExternalMedia=!1,t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),t.playbackRate!=null&&this.onMediaEvent("canplay",()=>{t.playbackRate!=null&&(this.media.playbackRate=t.playbackRate)},{once:!0})}onMediaEvent(t,a,r){return this.media.addEventListener(t,a,r),()=>this.media.removeEventListener(t,a,r)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,a){const r=this.getSrc();if(t&&r===t)return;this.revokeSrc();const o=a instanceof Blob&&(this.canPlayType(a.type)||!t)?URL.createObjectURL(a):t;if(r&&this.media.removeAttribute("src"),o||t)try{this.media.src=o}catch{this.media.src=t}}destroy(){this.isExternalMedia||(this.media.pause(),this.media.remove(),this.revokeSrc(),this.media.removeAttribute("src"),this.media.load())}setMediaElement(t){this.media=t}play(){return ii(this,void 0,void 0,function*(){return this.media.play()})}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=Math.max(0,Math.min(t,this.getDuration()))}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(t){this.media.volume=t}getMuted(){return this.media.muted}setMuted(t){this.media.muted=t}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(t,a){a!=null&&(this.media.preservesPitch=a),this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){return this.media.setSinkId(t)}}class Ym extends b0{constructor(t,a){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.unsubscribeOnScroll=[],this.subscriptions=[],this.options=t;const r=this.parentFromOptionsContainer(t.container);this.parent=r;const[o,c]=this.initHtml();r.appendChild(o),this.container=o,this.scrollContainer=c.querySelector(".scroll"),this.wrapper=c.querySelector(".wrapper"),this.canvasWrapper=c.querySelector(".canvases"),this.progressWrapper=c.querySelector(".progress"),this.cursor=c.querySelector(".cursor"),a&&c.appendChild(a),this.initEvents()}parentFromOptionsContainer(t){let a;if(typeof t=="string"?a=document.querySelector(t):t instanceof HTMLElement&&(a=t),!a)throw new Error("Container not found");return a}initEvents(){const t=a=>{const r=this.wrapper.getBoundingClientRect(),o=a.clientX-r.left,c=a.clientY-r.top;return[o/r.width,c/r.height]};if(this.wrapper.addEventListener("click",a=>{const[r,o]=t(a);this.emit("click",r,o)}),this.wrapper.addEventListener("dblclick",a=>{const[r,o]=t(a);this.emit("dblclick",r,o)}),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:a,scrollWidth:r,clientWidth:o}=this.scrollContainer,c=a/r,f=(a+o)/r;this.emit("scroll",c,f,a,a+o)}),typeof ResizeObserver=="function"){const a=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{a().then(()=>this.onContainerResize()).catch(()=>{})}),this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;t===this.lastContainerWidth&&this.options.height!=="auto"||(this.lastContainerWidth=t,this.reRender())}initDrag(){this.subscriptions.push(function(t,a,r,o,c=3,f=0,m=100){if(!t)return()=>{};const g=matchMedia("(pointer: coarse)").matches;let p=()=>{};const y=S=>{if(S.button!==f)return;S.preventDefault(),S.stopPropagation();let E=S.clientX,T=S.clientY,O=!1;const M=Date.now(),A=$=>{if($.preventDefault(),$.stopPropagation(),g&&Date.now()-M<m)return;const L=$.clientX,H=$.clientY,z=L-E,U=H-T;if(O||Math.abs(z)>c||Math.abs(U)>c){const B=t.getBoundingClientRect(),{left:J,top:X}=B;O||(r?.(E-J,T-X),O=!0),a(z,U,L-J,H-X),E=L,T=H}},D=$=>{if(O){const L=$.clientX,H=$.clientY,z=t.getBoundingClientRect(),{left:U,top:B}=z;o?.(L-U,H-B)}p()},_=$=>{$.relatedTarget&&$.relatedTarget!==document.documentElement||D($)},j=$=>{O&&($.stopPropagation(),$.preventDefault())},V=$=>{O&&$.preventDefault()};document.addEventListener("pointermove",A),document.addEventListener("pointerup",D),document.addEventListener("pointerout",_),document.addEventListener("pointercancel",_),document.addEventListener("touchmove",V,{passive:!1}),document.addEventListener("click",j,{capture:!0}),p=()=>{document.removeEventListener("pointermove",A),document.removeEventListener("pointerup",D),document.removeEventListener("pointerout",_),document.removeEventListener("pointercancel",_),document.removeEventListener("touchmove",V),setTimeout(()=>{document.removeEventListener("click",j,{capture:!0})},10)}};return t.addEventListener("pointerdown",y),()=>{p(),t.removeEventListener("pointerdown",y)}}(this.wrapper,(t,a,r)=>{this.emit("drag",Math.max(0,Math.min(1,r/this.wrapper.getBoundingClientRect().width)))},t=>{this.isDragging=!0,this.emit("dragstart",Math.max(0,Math.min(1,t/this.wrapper.getBoundingClientRect().width)))},t=>{this.isDragging=!1,this.emit("dragend",Math.max(0,Math.min(1,t/this.wrapper.getBoundingClientRect().width)))}))}getHeight(t,a){var r;const o=((r=this.audioData)===null||r===void 0?void 0:r.numberOfChannels)||1;if(t==null)return 128;if(!isNaN(Number(t)))return Number(t);if(t==="auto"){const c=this.parent.clientHeight||128;return a?.every(f=>!f.overlay)?c/o:c}return 128}initHtml(){const t=document.createElement("div"),a=t.attachShadow({mode:"open"}),r=this.options.cspNonce&&typeof this.options.cspNonce=="string"?this.options.cspNonce.replace(/"/g,""):"";return a.innerHTML=`
573
573
  <style${r?` nonce="${r}"`:""}>
574
574
  :host {
575
575
  user-select: none;
@@ -641,7 +641,7 @@ html body {
641
641
  <div class="cursor" part="cursor"></div>
642
642
  </div>
643
643
  </div>
644
- `,[t,a]}setOptions(t){if(this.options.container!==t.container){const a=this.parentFromOptionsContainer(t.container);a.appendChild(this.container),this.parent=a}t.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:a}=this.scrollContainer,r=a*t;this.setScroll(r)}destroy(){var t,a;this.subscriptions.forEach(r=>r()),this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(a=this.unsubscribeOnScroll)===null||a===void 0||a.forEach(r=>r()),this.unsubscribeOnScroll=[]}createDelay(t=10){let a,r;const o=()=>{a&&clearTimeout(a),r&&r()};return this.timeouts.push(o),()=>new Promise((c,f)=>{o(),r=f,a=setTimeout(()=>{a=void 0,r=void 0,c()},t)})}convertColorValues(t){if(!Array.isArray(t))return t||"";if(t.length<2)return t[0]||"";const a=document.createElement("canvas"),r=a.getContext("2d"),o=a.height*(window.devicePixelRatio||1),c=r.createLinearGradient(0,0,0,o),f=1/(t.length-1);return t.forEach((m,g)=>{const p=g*f;c.addColorStop(p,m)}),c}getPixelRatio(){return Math.max(1,window.devicePixelRatio||1)}renderBarWaveform(t,a,r,o){const c=t[0],f=t[1]||t[0],m=c.length,{width:g,height:p}=r.canvas,y=p/2,S=this.getPixelRatio(),E=a.barWidth?a.barWidth*S:1,T=a.barGap?a.barGap*S:a.barWidth?E/2:0,O=a.barRadius||0,M=g/(E+T)/m,A=O&&"roundRect"in r?"roundRect":"rect";r.beginPath();let D=0,_=0,j=0;for(let V=0;V<=m;V++){const $=Math.round(V*M);if($>D){const z=Math.round(_*y*o),U=z+Math.round(j*y*o)||1;let B=y-z;a.barAlign==="top"?B=0:a.barAlign==="bottom"&&(B=p-U),r[A](D*(E+T),B,E,U,O),D=$,_=0,j=0}const L=Math.abs(c[V]||0),H=Math.abs(f[V]||0);L>_&&(_=L),H>j&&(j=H)}r.fill(),r.closePath()}renderLineWaveform(t,a,r,o){const c=f=>{const m=t[f]||t[0],g=m.length,{height:p}=r.canvas,y=p/2,S=r.canvas.width/g;r.moveTo(0,y);let E=0,T=0;for(let O=0;O<=g;O++){const M=Math.round(O*S);if(M>E){const D=y+(Math.round(T*y*o)||1)*(f===0?-1:1);r.lineTo(E,D),E=M,T=0}const A=Math.abs(m[O]||0);A>T&&(T=A)}r.lineTo(E,y)};r.beginPath(),c(0),c(1),r.fill(),r.closePath()}renderWaveform(t,a,r){if(r.fillStyle=this.convertColorValues(a.waveColor),a.renderFunction)return void a.renderFunction(t,r);let o=a.barHeight||1;if(a.normalize){const c=Array.from(t[0]).reduce((f,m)=>Math.max(f,Math.abs(m)),0);o=c?1/c:1}a.barWidth||a.barGap||a.barAlign?this.renderBarWaveform(t,a,r,o):this.renderLineWaveform(t,a,r,o)}renderSingleCanvas(t,a,r,o,c,f,m){const g=this.getPixelRatio(),p=document.createElement("canvas");p.width=Math.round(r*g),p.height=Math.round(o*g),p.style.width=`${r}px`,p.style.height=`${o}px`,p.style.left=`${Math.round(c)}px`,f.appendChild(p);const y=p.getContext("2d");if(this.renderWaveform(t,a,y),p.width>0&&p.height>0){const S=p.cloneNode(),E=S.getContext("2d");E.drawImage(p,0,0),E.globalCompositeOperation="source-in",E.fillStyle=this.convertColorValues(a.progressColor),E.fillRect(0,0,p.width,p.height),m.appendChild(S)}}renderMultiCanvas(t,a,r,o,c,f){const m=this.getPixelRatio(),{clientWidth:g}=this.scrollContainer,p=r/m;let y=Math.min(Ym.MAX_CANVAS_WIDTH,g,p),S={};if(a.barWidth||a.barGap){const A=a.barWidth||.5,D=A+(a.barGap||A/2);y%D!=0&&(y=Math.floor(y/D)*D)}if(y===0)return;const E=A=>{if(A<0||A>=T||S[A])return;S[A]=!0;const D=A*y;let _=Math.min(p-D,y);if(a.barWidth||a.barGap){const V=a.barWidth||.5,$=V+(a.barGap||V/2);_=Math.floor(_/$)*$}if(_<=0)return;const j=t.map(V=>{const $=Math.floor(D/p*V.length),L=Math.floor((D+_)/p*V.length);return V.slice($,L)});this.renderSingleCanvas(j,a,_,o,D,c,f)},T=Math.ceil(p/y);if(!this.isScrollable){for(let A=0;A<T;A++)E(A);return}const O=this.scrollContainer.scrollLeft/p,M=Math.floor(O*T);if(E(M-1),E(M),E(M+1),T>1){const A=this.on("scroll",()=>{const{scrollLeft:D}=this.scrollContainer,_=Math.floor(D/p*T);Object.keys(S).length>Ym.MAX_NODES&&(c.innerHTML="",f.innerHTML="",S={}),E(_-1),E(_),E(_+1)});this.unsubscribeOnScroll.push(A)}}renderChannel(t,a,r,o){var{overlay:c}=a,f=function(y,S){var E={};for(var T in y)Object.prototype.hasOwnProperty.call(y,T)&&S.indexOf(T)<0&&(E[T]=y[T]);if(y!=null&&typeof Object.getOwnPropertySymbols=="function"){var O=0;for(T=Object.getOwnPropertySymbols(y);O<T.length;O++)S.indexOf(T[O])<0&&Object.prototype.propertyIsEnumerable.call(y,T[O])&&(E[T[O]]=y[T[O]])}return E}(a,["overlay"]);const m=document.createElement("div"),g=this.getHeight(f.height,f.splitChannels);m.style.height=`${g}px`,c&&o>0&&(m.style.marginTop=`-${g}px`),this.canvasWrapper.style.minHeight=`${g}px`,this.canvasWrapper.appendChild(m);const p=m.cloneNode();this.progressWrapper.appendChild(p),this.renderMultiCanvas(t,f,r,g,m,p)}render(t){return ii(this,void 0,void 0,function*(){var a;this.timeouts.forEach(g=>g()),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",this.options.width!=null&&(this.scrollContainer.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width);const r=this.getPixelRatio(),o=this.scrollContainer.clientWidth,c=Math.ceil(t.duration*(this.options.minPxPerSec||0));this.isScrollable=c>o;const f=this.options.fillParent&&!this.isScrollable,m=(f?o:c)*r;if(this.wrapper.style.width=f?"100%":`${c}px`,this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden",this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar),this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`,this.cursor.style.width=`${this.options.cursorWidth}px`,this.audioData=t,this.emit("render"),this.options.splitChannels)for(let g=0;g<t.numberOfChannels;g++){const p=Object.assign(Object.assign({},this.options),(a=this.options.splitChannels)===null||a===void 0?void 0:a[g]);this.renderChannel([t.getChannelData(g)],p,m,g)}else{const g=[t.getChannelData(0)];t.numberOfChannels>1&&g.push(t.getChannelData(1)),this.renderChannel(g,this.options,m,0)}Promise.resolve().then(()=>this.emit("rendered"))})}reRender(){if(this.unsubscribeOnScroll.forEach(r=>r()),this.unsubscribeOnScroll=[],!this.audioData)return;const{scrollWidth:t}=this.scrollContainer,{right:a}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:r}=this.progressWrapper.getBoundingClientRect();let o=r-a;o*=2,o=o<0?Math.floor(o):Math.ceil(o),o/=2,this.scrollContainer.scrollLeft+=o}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,a=!1){const{scrollLeft:r,scrollWidth:o,clientWidth:c}=this.scrollContainer,f=t*o,m=r,g=r+c,p=c/2;if(this.isDragging)f+30>g?this.scrollContainer.scrollLeft+=30:f-30<m&&(this.scrollContainer.scrollLeft-=30);else{(f<m||f>g)&&(this.scrollContainer.scrollLeft=f-(this.options.autoCenter?p:0));const y=f-r-p;a&&this.options.autoCenter&&y>0&&(this.scrollContainer.scrollLeft+=Math.min(y,10))}{const y=this.scrollContainer.scrollLeft,S=y/o,E=(y+c)/o;this.emit("scroll",S,E,y,y+c)}}renderProgress(t,a){if(isNaN(t))return;const r=100*t;this.canvasWrapper.style.clipPath=`polygon(${r}% 0%, 100% 0%, 100% 100%, ${r}% 100%)`,this.progressWrapper.style.width=`${r}%`,this.cursor.style.left=`${r}%`,this.cursor.style.transform=`translateX(-${Math.round(r)===100?this.options.cursorWidth:0}px)`,this.isScrollable&&this.options.autoScroll&&this.scrollIntoView(t,a)}exportImage(t,a,r){return ii(this,void 0,void 0,function*(){const o=this.canvasWrapper.querySelectorAll("canvas");if(!o.length)throw new Error("No waveform data");if(r==="dataURL"){const c=Array.from(o).map(f=>f.toDataURL(t,a));return Promise.resolve(c)}return Promise.all(Array.from(o).map(c=>new Promise((f,m)=>{c.toBlob(g=>{g?f(g):m(new Error("Could not export image"))},t,a)})))})}}Ym.MAX_CANVAS_WIDTH=8e3,Ym.MAX_NODES=10;class WZ extends b0{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}class CO extends b0{constructor(t=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this._playbackRate=1,this._duration=void 0,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.autoplay=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=t,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return ii(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(a=>{if(a.status>=400)throw new Error(`Failed to fetch ${t}: ${a.status} (${a.statusText})`);return a.arrayBuffer()}).then(a=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(a)).then(a=>{this.currentSrc===t&&(this.buffer=a,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())})}_play(){var t;if(!this.paused)return;this.paused=!1,(t=this.bufferNode)===null||t===void 0||t.disconnect(),this.bufferNode=this.audioContext.createBufferSource(),this.buffer&&(this.bufferNode.buffer=this.buffer),this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let a=this.playedDuration*this._playbackRate;(a>=this.duration||a<0)&&(a=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,a),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,(t=this.bufferNode)===null||t===void 0||t.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime}play(){return ii(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){const a=t-this.currentTime,r=this.bufferNode;r?.stop(this.audioContext.currentTime+a),r?.addEventListener("ended",()=>{r===this.bufferNode&&(this.bufferNode=null,this.pause())},{once:!0})}setSinkId(t){return ii(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return(this.paused?this.playedDuration:this.playedDuration+(this.audioContext.currentTime-this.playStartTime))*this._playbackRate}set currentTime(t){const a=!this.paused;a&&this._pause(),this.playedDuration=t/this._playbackRate,a&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,a;return(t=this._duration)!==null&&t!==void 0?t:((a=this.buffer)===null||a===void 0?void 0:a.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const a=this.buffer.numberOfChannels;for(let r=0;r<a;r++)t.push(this.buffer.getChannelData(r));return t}}const ZZ={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class Wm extends YZ{static create(t){return new Wm(t)}constructor(t){const a=t.media||(t.backend==="WebAudio"?new CO:void 0);super({media:a,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate}),this.plugins=[],this.decodedData=null,this.stopAtPosition=null,this.subscriptions=[],this.mediaSubscriptions=[],this.abortController=null,this.options=Object.assign({},ZZ,t),this.timer=new WZ;const r=a?void 0:this.getMediaElement();this.renderer=new Ym(this.options,r),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initPlugins();const o=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");const{peaks:c,duration:f}=this.options;(o||c&&f)&&this.load(o,c,f).catch(()=>null)})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t),this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition&&this.pause()}}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{const t=this.updateProgress();this.emit("timeupdate",t)}),this.onMediaEvent("play",()=>{this.emit("play"),this.timer.start()}),this.onMediaEvent("pause",()=>{this.emit("pause"),this.timer.stop(),this.stopAtPosition=null}),this.onMediaEvent("emptied",()=>{this.timer.stop(),this.stopAtPosition=null}),this.onMediaEvent("ended",()=>{this.emit("timeupdate",this.getDuration()),this.emit("finish"),this.stopAtPosition=null}),this.onMediaEvent("seeking",()=>{this.emit("seeking",this.getCurrentTime())}),this.onMediaEvent("error",()=>{var t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error")),this.stopAtPosition=null}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(t,a)=>{this.options.interact&&(this.seekTo(t),this.emit("interaction",t*this.getDuration()),this.emit("click",t,a))}),this.renderer.on("dblclick",(t,a)=>{this.emit("dblclick",t,a)}),this.renderer.on("scroll",(t,a,r,o)=>{const c=this.getDuration();this.emit("scroll",t*c,a*c,r,o)}),this.renderer.on("render",()=>{this.emit("redraw")}),this.renderer.on("rendered",()=>{this.emit("redrawcomplete")}),this.renderer.on("dragstart",t=>{this.emit("dragstart",t)}),this.renderer.on("dragend",t=>{this.emit("dragend",t)}));{let t;this.subscriptions.push(this.renderer.on("drag",a=>{if(!this.options.interact)return;let r;this.renderer.renderProgress(a),clearTimeout(t),this.isPlaying()?r=0:this.options.dragToSeek===!0?r=200:typeof this.options.dragToSeek=="object"&&this.options.dragToSeek!==void 0&&(r=this.options.dragToSeek.debounceTime),t=setTimeout(()=>{this.seekTo(a)},r),this.emit("interaction",a*this.getDuration()),this.emit("drag",a)}))}}initPlugins(){var t;!((t=this.options.plugins)===null||t===void 0)&&t.length&&this.options.plugins.forEach(a=>{this.registerPlugin(a)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(t=>t()),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),t.duration&&!t.peaks&&(this.decodedData=tx.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=tx.createBuffer(t.peaks,t.duration)),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),t.mediaControls!=null&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){t._init(this),this.plugins.push(t);const a=t.once("destroy",()=>{this.plugins=this.plugins.filter(r=>r!==t),this.subscriptions=this.subscriptions.filter(r=>r!==a)});return this.subscriptions.push(a),t}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const a=t/this.getDuration();this.renderer.setScrollPercentage(a)}getActivePlugins(){return this.plugins}loadAudio(t,a,r,o){return ii(this,void 0,void 0,function*(){var c;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,this.stopAtPosition=null,!a&&!r){const m=this.options.fetchParams||{};window.AbortController&&!m.signal&&(this.abortController=new AbortController,m.signal=(c=this.abortController)===null||c===void 0?void 0:c.signal);const g=y=>this.emit("loading",y);a=yield XZ.fetchBlob(t,g,m);const p=this.options.blobMimeType;p&&(a=new Blob([a],{type:p}))}this.setSrc(t,a);const f=yield new Promise(m=>{const g=o||this.getDuration();g?m(g):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>m(this.getDuration()),{once:!0}))});if(!t&&!a){const m=this.getMediaElement();m instanceof CO&&(m.duration=f)}if(r)this.decodedData=tx.createBuffer(r,f||0);else if(a){const m=yield a.arrayBuffer();this.decodedData=yield tx.decode(m,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,a,r){return ii(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,a,r)}catch(o){throw this.emit("error",o),o}})}loadBlob(t,a,r){return ii(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,a,r)}catch(o){throw this.emit("error",o),o}})}zoom(t){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(t),this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:a=8e3,precision:r=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const o=Math.min(t,this.decodedData.numberOfChannels),c=[];for(let f=0;f<o;f++){const m=this.decodedData.getChannelData(f),g=[],p=m.length/a;for(let y=0;y<a;y++){const S=m.slice(Math.floor(y*p),Math.ceil((y+1)*p));let E=0;for(let T=0;T<S.length;T++){const O=S[T];Math.abs(O)>Math.abs(E)&&(E=O)}g.push(Math.round(E*r)/r)}c.push(g)}return c}getDuration(){let t=super.getDuration()||0;return t!==0&&t!==1/0||!this.decodedData||(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null,super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const a=this.getDuration()*t;this.setTime(a)}play(t,a){const r=Object.create(null,{play:{get:()=>super.play}});return ii(this,void 0,void 0,function*(){t!=null&&this.setTime(t);const o=yield r.play.call(this);return a!=null&&(this.media instanceof CO?this.media.stopAt(a):this.stopAtPosition=a),o})}playPause(){return ii(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return ii(this,arguments,void 0,function*(t="image/png",a=1,r="dataURL"){return this.renderer.exportImage(t,a,r)})}destroy(){var t;this.emit("destroy"),(t=this.abortController)===null||t===void 0||t.abort(),this.plugins.forEach(a=>a.destroy()),this.subscriptions.forEach(a=>a()),this.unsubscribePlayerEvents(),this.timer.destroy(),this.renderer.destroy(),super.destroy()}}Wm.BasePlugin=class extends b0{constructor(e){super(),this.subscriptions=[],this.options=e}onInit(){}_init(e){this.wavesurfer=e,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(e=>e())}},Wm.dom=GZ;const KZ=({userMessage:e,setUserMessage:t,handleSendMessage:a,handleSendImage:r,handleSendVoice:o,selectedImage:c,setSelectedImage:f,audioBlob:m,setAudioBlob:g,isSending:p})=>{const{t:y}=jZ(),[S,E]=x.useState(!1),[T,O]=x.useState(!1),M=x.useRef(null),A=x.useRef(null),D=x.useRef([]),_=x.useRef(null),j=x.useRef(null),V=U=>{const B=U.target.files?.[0];B&&f(B)},$=()=>{f(null)},L=async()=>{if(!navigator.mediaDevices?.getUserMedia){alert(y("chatInput.voice.notSupported"));return}if(S)M.current?.stop();else try{const U=await navigator.mediaDevices.getUserMedia({audio:!0}),B=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",J=new MediaRecorder(U,{mimeType:B});M.current=J,D.current=[],J.ondataavailable=X=>{X.data.size>0&&D.current.push(X.data)},J.onstop=()=>{const X=new Blob(D.current,{type:B});g(X),E(!1),U.getTracks().forEach(W=>W.stop())},J.start(),E(!0)}catch(U){console.error(U),alert(y("chatInput.voice.permissionError"))}};x.useEffect(()=>{if(m&&_.current){j.current?.destroy();const U=URL.createObjectURL(m);j.current=Wm.create({container:_.current,waveColor:"#ccc",progressColor:"#7F28F8",cursorWidth:0,barWidth:3,barHeight:1.5,barGap:2,height:40,interact:!0}),j.current.load(U),j.current.on("finish",()=>O(!1))}},[m]);const H=()=>{j.current&&(j.current.playPause(),O(U=>!U))},z=()=>{E(!1),g(null),j.current?.destroy()};return ae.jsxs("div",{style:{display:"flex",alignItems:"center",backgroundColor:"white",border:"1px solid #d1d5db",borderRadius:"9999px",padding:"0.5rem 0.75rem",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",width:"95%",height:"56px"},children:[ae.jsx("button",{style:{color:"#6b7280",background:"none",border:"none",margin:"0 0.5rem",cursor:"pointer",padding:"0"},onClick:()=>A.current?.click(),children:c?ae.jsxs("div",{style:{position:"relative"},children:[ae.jsx("img",{src:URL.createObjectURL(c),alt:y("chatInput.image.selectedAlt"),style:{width:"2rem",height:"2rem",borderRadius:"9999px",objectFit:"cover",padding:"0"}}),ae.jsx(c0,{style:{position:"absolute",top:"-0.5rem",right:"-0.5rem",fontSize:"14px",color:"#ef4444",background:"white",borderRadius:"9999px",cursor:"pointer"},onClick:U=>{U.stopPropagation(),$()}})]}):ae.jsx(p4,{style:{fontSize:"20px"}})}),ae.jsx("input",{disabled:p,type:"file",accept:"image/*",ref:A,onChange:V,style:{display:"none",padding:"0"}}),ae.jsx(Nd,{title:S?"Stop Recording":"Send Audio",children:ae.jsx("button",{onClick:L,style:{color:S?"#ef4444":"#6b7280",background:"none",border:"none",margin:"0 0.5rem",cursor:"pointer",padding:"0"},children:S?ae.jsx(y4,{style:{fontSize:"20px"}}):ae.jsx(f4,{style:{fontSize:"20px"}})})}),ae.jsx("div",{style:{flex:1,margin:"0 0.5rem",minWidth:0,maxWidth:"100%",display:"flex",alignItems:"center"},children:m?ae.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",backgroundColor:"#f3f4f6",padding:"0.5rem 1rem",borderRadius:"0.5rem"},children:[ae.jsx("button",{style:{background:"none",border:"none",marginRight:"0.75rem",color:"#7f28f8",cursor:"pointer",padding:"0"},onClick:H,children:T?ae.jsx(GT,{style:{fontSize:"24px"}}):ae.jsx(XT,{style:{fontSize:"24px"}})}),ae.jsx("div",{ref:_,style:{width:"100%",height:"2rem"}}),ae.jsx(c0,{style:{fontSize:"18px",color:"#ef4444",marginLeft:"0.75rem",cursor:"pointer"},onClick:z})]}):S?ae.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f3f4f6",padding:"0.5rem 1rem",borderRadius:"0.5rem",animation:"pulse 2s infinite"},children:ae.jsx("span",{children:"Recording"})}):ae.jsx(Yu,{type:"text",value:e,onChange:U=>t(U.target.value),placeholder:"Message...",style:{width:"100%",border:"none",fontSize:"16px",margin:0,lineHeight:1.5,color:"#374151",padding:"0"},onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),c?(r(c,e),$(),t("")):e.trim()&&(a(),t("")))}})}),ae.jsx("button",{disabled:p,onClick:()=>{const U=!!c,B=!!e.trim();U?(r(c,e),$(),t("")):!!m?(o(m),z()):B&&a()},"aria-label":y("chatInput.send"),style:{color:"#6b7280",background:"none",border:"none",margin:"0 0.5rem",cursor:"pointer",padding:"0"},children:ae.jsx(g4,{style:{fontSize:"20px"}})})]})};function QZ({suggestions:e,colorCode:t,sendMessageSuggestion:a}){return ae.jsx("div",{style:{overflowX:"auto",overflowY:"hidden",whiteSpace:"nowrap",paddingTop:"4px",paddingBottom:"8px",width:"100%",boxSizing:"border-box",marginLeft:"4%",marginTop:"4px",marginBottom:"4px"},children:ae.jsx("div",{style:{display:"inline-flex",gap:"0.5rem"},children:e?.map((r,o)=>ae.jsx("button",{onClick:()=>a(r),style:{whiteSpace:"nowrap",padding:"0.5rem 1rem",border:`1px solid ${t}`,borderRadius:"9999px",backgroundColor:"white",cursor:"pointer",fontSize:"14px",color:t,flexShrink:0},onMouseEnter:c=>{c.currentTarget.style.backgroundColor="#f3f3f3"},onMouseLeave:c=>{c.currentTarget.style.backgroundColor="white"},children:r},o))})})}function JZ(){return ae.jsxs("div",{className:"jawebcss-powered-container",children:[ae.jsx("span",{className:"jawebcss-powered-label",children:"Powered by"}),ae.jsx("a",{href:"https://jaweb.me/",target:"_blank",className:"jawebcss-powered-link",rel:"noopener noreferrer",children:"Jaweb"})]})}const eK=()=>ae.jsxs("div",{className:"typing-animation",children:[ae.jsx("span",{children:"."}),ae.jsx("span",{children:"."}),ae.jsx("span",{children:"."})]}),tK=({groupedProducts:e,selectedVariants:t,setSelectedVariants:a,counts:r,setCounts:o,handleAddToCart:c,handleRemoveFromCart:f,colorCode:m="#7F28F8",shortenName:g,sliderRef:p,totalSlides:y})=>y===0?null:ae.jsx("div",{className:"relative w-full",children:ae.jsx("div",{ref:p,className:"keen-slider w-full relative ",children:Object.entries(e).map(([S,E])=>{const T=t[S]||E[0].variant_id,O=E.find(L=>L.variant_id===T)||E[0],M=r[O.variant_id]||0,A=Array.from(new Set(E.map(L=>L.color?.trim()||"").filter(L=>L&&L.toLowerCase()!=="none"))),D=Array.from(new Set(E.map(L=>L.size?.trim()||"").filter(L=>L&&L.toLowerCase()!=="none"))),_=(L,H)=>E.some(z=>z.color===L&&z.size===H),j=(L,H)=>{const z=E.find(U=>(!L||U.color===L)&&(!H||U.size===H));z&&a(U=>({...U,[S]:z.variant_id}))},V=async()=>{o(L=>({...L,[O.variant_id]:(L[O.variant_id]||0)+1})),await c(O.variant_id,O.name,1)},$=async()=>{M!==0&&(o(L=>({...L,[O.variant_id]:L[O.variant_id]-1})),await f(O.variant_id,1))};return ae.jsx("div",{className:"keen-slider__slide",children:ae.jsxs("div",{className:"product-card",children:[ae.jsx("div",{className:"product-image-container",children:ae.jsx("img",{src:O.image,alt:O.name,className:"product-image",onClick:()=>window.open(O.link,"_blank")})}),ae.jsxs("div",{className:"product-details",children:[ae.jsx("a",{href:O.link,target:"_blank",rel:"noopener noreferrer",className:"product-name",children:g(O.name)}),ae.jsx("p",{className:"product-price",children:O.price}),A.length>0&&ae.jsxs("div",{children:[ae.jsx("p",{className:"label",children:"Color:"}),ae.jsx("div",{className:"color-options",children:A.map(L=>{const H=!_(L,O.size),z=L===O.color;return ae.jsx("button",{disabled:H,onClick:()=>j(L,O.size),className:`color-button ${z?"active":""} ${H?"disabled":""}`,style:z?{backgroundColor:m,color:"#fff"}:{},children:L==="None"?"One Color":L},L)})})]}),D.length>0&&ae.jsxs("div",{children:[ae.jsx("p",{className:"label",children:"Size:"}),ae.jsx("div",{className:"size-options",children:D.map(L=>{const H=!_(O.color,L),z=L===O.size;return ae.jsx("button",{disabled:H,onClick:()=>j(O.color,L),className:`size-button ${z?"active":""} ${H?"disabled":""}`,style:z?{backgroundColor:m,color:"#fff"}:{},children:L==="None"?"One size":L},L)})})]}),ae.jsxs("div",{className:"cart-controls",children:[ae.jsx("button",{onClick:$,className:"cart-button",children:"–"}),ae.jsx("span",{className:"cart-count",children:M}),ae.jsx("button",{onClick:V,className:"cart-button increment",style:{backgroundColor:m,color:"#fff"},children:"+"})]})]})]})},S)})})});var nx={},P6;function nK(){if(P6)return nx;P6=1,Object.defineProperty(nx,"__esModule",{value:!0});var e=Ed();function t(z){return Array.prototype.slice.call(z)}function a(z,U){var B=Math.floor(z);return B===U||B+1===U?z:U}function r(){return Date.now()}function o(z,U,B){if(U="data-keen-slider-"+U,B===null)return z.removeAttribute(U);z.setAttribute(U,B||"")}function c(z,U){return U=U||document,typeof z=="function"&&(z=z(U)),Array.isArray(z)?z:typeof z=="string"?t(U.querySelectorAll(z)):z instanceof HTMLElement?[z]:z instanceof NodeList?t(z):[]}function f(z){z.raw&&(z=z.raw),z.cancelable&&!z.defaultPrevented&&z.preventDefault()}function m(z){z.raw&&(z=z.raw),z.stopPropagation&&z.stopPropagation()}function g(){var z=[];return{add:function(U,B,J,X){U.addListener?U.addListener(J):U.addEventListener(B,J,X),z.push([U,B,J,X])},input:function(U,B,J,X){this.add(U,B,function(W){return function(K){K.nativeEvent&&(K=K.nativeEvent);var re=K.changedTouches||[],F=K.targetTouches||[],G=K.detail&&K.detail.x?K.detail:null;return W({id:G?G.identifier?G.identifier:"i":F[0]?F[0]?F[0].identifier:"e":"d",idChanged:G?G.identifier?G.identifier:"i":re[0]?re[0]?re[0].identifier:"e":"d",raw:K,x:G&&G.x?G.x:F[0]?F[0].screenX:G?G.x:K.pageX,y:G&&G.y?G.y:F[0]?F[0].screenY:G?G.y:K.pageY})}}(J),X)},purge:function(){z.forEach(function(U){U[0].removeListener?U[0].removeListener(U[2]):U[0].removeEventListener(U[1],U[2],U[3])}),z=[]}}}function p(z,U,B){return Math.min(Math.max(z,U),B)}function y(z){return(z>0?1:0)-(z<0?1:0)||+z}function S(z){var U=z.getBoundingClientRect();return{height:a(U.height,z.offsetHeight),width:a(U.width,z.offsetWidth)}}function E(z,U,B,J){var X=z&&z[U];return X==null?B:J&&typeof X=="function"?X():X}function T(z){return Math.round(1e6*z)/1e6}function O(z,U){if(z===U)return!0;var B=typeof z;if(B!==typeof U)return!1;if(B!=="object"||z===null||U===null)return B==="function"&&z.toString()===U.toString();if(z.length!==U.length||Object.getOwnPropertyNames(z).length!==Object.getOwnPropertyNames(U).length)return!1;for(var J in z)if(!O(z[J],U[J]))return!1;return!0}var M=function(){return M=Object.assign||function(z){for(var U,B=1,J=arguments.length;B<J;B++)for(var X in U=arguments[B])Object.prototype.hasOwnProperty.call(U,X)&&(z[X]=U[X]);return z},M.apply(this,arguments)};function A(z,U,B){for(var J,X=0,W=U.length;X<W;X++)!J&&X in U||(J||(J=Array.prototype.slice.call(U,0,X)),J[X]=U[X]);return z.concat(J||Array.prototype.slice.call(U))}function D(z){var U,B,J,X,W,K;function re(k){K||(K=k),F(!0);var q=k-K;q>J&&(q=J);var ee=X[B];if(ee[3]<q)return B++,re(k);var ne=ee[2],oe=ee[4],le=ee[0],ce=ee[1]*(0,ee[5])(oe===0?1:(q-ne)/oe);if(ce&&z.track.to(le+ce),q<J)return Z();K=null,F(!1),G(null),z.emit("animationEnded")}function F(k){U.active=k}function G(k){U.targetIdx=k}function Z(){var k;k=re,W=window.requestAnimationFrame(k)}function se(){var k;k=W,window.cancelAnimationFrame(k),F(!1),G(null),K&&z.emit("animationStopped"),K=null}return U={active:!1,start:function(k){if(se(),z.track.details){var q=0,ee=z.track.details.position;B=0,J=0,X=k.map(function(ne){var oe,le=Number(ee),ce=(oe=ne.earlyExit)!==null&&oe!==void 0?oe:ne.duration,Ce=ne.easing,ze=ne.distance*Ce(ce/ne.duration)||0;ee+=ze;var $e=J;return J+=ce,q+=ze,[le,ne.distance,$e,J,ne.duration,Ce]}),G(z.track.distToIdx(q)),Z(),z.emit("animationStarted")}},stop:se,targetIdx:null}}function _(z){var U,B,J,X,W,K,re,F,G,Z,se,k,q,ee,ne=1/0,oe=[],le=null,ce=0;function Ce(Ee){we(ce+Ee)}function ze(Ee){var Te=$e(ce+Ee).abs;return ue(Te)?Te:null}function $e(Ee){var Te=Math.floor(Math.abs(T(Ee/B))),Ae=T((Ee%B+B)%B);Ae===B&&(Ae=0);var De=y(Ee),Ue=re.indexOf(A([],re).reduce(function(Le,it){return Math.abs(it-Ae)<Math.abs(Le-Ae)?it:Le})),Fe=Ue;return De<0&&Te++,Ue===K&&(Fe=0,Te+=De>0?1:-1),{abs:Fe+Te*K*De,origin:Ue,rel:Fe}}function ke(Ee,Te,Ae){var De;if(Te||!Ie())return ge(Ee,Ae);if(!ue(Ee))return null;var Ue=$e(Ae??ce),Fe=Ue.abs,Le=Ee-Ue.rel,it=Fe+Le;De=ge(it);var ut=ge(it-K*y(Le));return(ut!==null&&Math.abs(ut)<Math.abs(De)||De===null)&&(De=ut),T(De)}function ge(Ee,Te){if(Te==null&&(Te=T(ce)),!ue(Ee)||Ee===null)return null;Ee=Math.round(Ee);var Ae=$e(Te),De=Ae.abs,Ue=Ae.rel,Fe=Ae.origin,Le=ve(Ee),it=(Te%B+B)%B,ut=re[Fe],vt=Math.floor((Ee-(De-Ue))/K)*B;return T(ut-it-ut+re[Le]+vt+(Fe===K?B:0))}function ue(Ee){return Re(Ee)===Ee}function Re(Ee){return p(Ee,G,Z)}function Ie(){return X.loop}function ve(Ee){return(Ee%K+K)%K}function we(Ee){var Te;Te=Ee-ce,oe.push({distance:Te,timestamp:r()}),oe.length>6&&(oe=oe.slice(-6)),ce=T(Ee);var Ae=be().abs;if(Ae!==le){var De=le!==null;le=Ae,De&&z.emit("slideChanged")}}function be(Ee){var Te=Ee?null:function(){if(K){var Ae=Ie(),De=Ae?(ce%B+B)%B:ce,Ue=(Ae?ce%B:ce)-W[0][2],Fe=0-(Ue<0&&Ae?B-Math.abs(Ue):Ue),Le=0,it=$e(ce),ut=it.abs,vt=it.rel,At=W[vt][2],ht=W.map(function(jt,Vt){var _t=Fe+Le;(_t<0-jt[0]||_t>1)&&(_t+=(Math.abs(_t)>B-1&&Ae?B:0)*y(-_t));var Tt=Vt-vt,ct=y(Tt),gt=Tt+ut;Ae&&(ct===-1&&_t>At&&(gt+=K),ct===1&&_t<At&&(gt-=K),se!==null&&gt<se&&(_t+=B),k!==null&&gt>k&&(_t-=B));var at=_t+jt[0]+jt[1],lt=Math.max(_t>=0&&at<=1?1:at<0||_t>1?0:_t<0?Math.min(1,(jt[0]+_t)/jt[0]):(1-_t)/jt[0],0);return Le+=jt[0]+jt[1],{abs:gt,distance:X.rtl?-1*_t+1-jt[0]:_t,portion:lt,size:jt[0]}});return ut=Re(ut),vt=ve(ut),{abs:Re(ut),length:J,max:ee,maxIdx:Z,min:q,minIdx:G,position:ce,progress:Ae?De/B:ce/J,rel:vt,slides:ht,slidesLength:B}}}();return U.details=Te,z.emit("detailsChanged"),Te}return U={absToRel:ve,add:Ce,details:null,distToIdx:ze,idxToDist:ke,init:function(Ee){if(function(){if(X=z.options,W=(X.trackConfig||[]).map(function(Ue){return[E(Ue,"size",1),E(Ue,"spacing",0),E(Ue,"origin",0)]}),K=W.length){B=T(W.reduce(function(Ue,Fe){return Ue+Fe[0]+Fe[1]},0));var Ae,De=K-1;J=T(B+W[0][2]-W[De][0]-W[De][2]-W[De][1]),re=W.reduce(function(Ue,Fe){if(!Ue)return[0];var Le=W[Ue.length-1],it=Ue[Ue.length-1]+(Le[0]+Le[2])+Le[1];return it-=Fe[2],Ue[Ue.length-1]>it&&(it=Ue[Ue.length-1]),it=T(it),Ue.push(it),(!Ae||Ae<it)&&(F=Ue.length-1),Ae=it,Ue},null),J===0&&(F=0),re.push(T(B))}}(),!K)return be(!0);var Te;(function(){var Ae=z.options.range,De=z.options.loop;se=G=De?E(De,"min",-1/0):0,k=Z=De?E(De,"max",ne):F;var Ue=E(Ae,"min",null),Fe=E(Ae,"max",null);Ue!==null&&(G=Ue),Fe!==null&&(Z=Fe),q=G===-1/0?G:z.track.idxToDist(G||0,!0,0),ee=Z===ne?Z:ke(Z,!0,0),Fe===null&&(k=Z),E(Ae,"align",!1)&&Z!==ne&&W[ve(Z)][2]===0&&(ee-=1-W[ve(Z)][0],Z=ze(ee-ce)),q=T(q),ee=T(ee)})(),Te=Ee,Number(Te)===Te?Ce(ge(Re(Ee))):be()},to:we,velocity:function(){var Ee=r(),Te=oe.reduce(function(Ae,De){var Ue=De.distance,Fe=De.timestamp;return Ee-Fe>200||(y(Ue)!==y(Ae.distance)&&Ae.distance&&(Ae={distance:0,lastTimestamp:0,time:0}),Ae.time&&(Ae.distance+=Ue),Ae.lastTimestamp&&(Ae.time+=Fe-Ae.lastTimestamp),Ae.lastTimestamp=Fe),Ae},{distance:0,lastTimestamp:0,time:0});return Te.distance/Te.time||0}}}function j(z){var U,B,J,X,W,K,re,F;function G(le){return 2*le}function Z(le){return p(le,re,F)}function se(le){return 1-Math.pow(1-le,3)}function k(){return J?z.track.velocity():0}function q(){oe();var le=z.options.mode==="free-snap",ce=z.track,Ce=k();X=y(Ce);var ze=z.track.details,$e=[];if(Ce||!le){var ke=ee(Ce),ge=ke.dist,ue=ke.dur;if(ue=G(ue),ge*=X,le){var Re=ce.idxToDist(ce.distToIdx(ge),!0);Re&&(ge=Re)}$e.push({distance:ge,duration:ue,easing:se});var Ie=ze.position,ve=Ie+ge;if(ve<W||ve>K){var we=ve<W?W-Ie:K-Ie,be=0,Ee=Ce;if(y(we)===X){var Te=Math.min(Math.abs(we)/Math.abs(ge),1),Ae=function(Fe){return 1-Math.pow(1-Fe,1/3)}(Te)*ue;$e[0].earlyExit=Ae,Ee=Ce*(1-Te)}else $e[0].earlyExit=0,be+=we;var De=ee(Ee,100),Ue=De.dist*X;z.options.rubberband&&($e.push({distance:Ue,duration:G(De.dur),easing:se}),$e.push({distance:-Ue+be,duration:500,easing:se}))}z.animator.start($e)}else z.moveToIdx(Z(ze.abs),!0,{duration:500,easing:function(Fe){return 1+--Fe*Fe*Fe*Fe*Fe}})}function ee(le,ce){ce===void 0&&(ce=1e3);var Ce=147e-9+(le=Math.abs(le))/ce;return{dist:Math.pow(le,2)/Ce,dur:le/Ce}}function ne(){var le=z.track.details;le&&(W=le.min,K=le.max,re=le.minIdx,F=le.maxIdx)}function oe(){z.animator.stop()}z.on("updated",ne),z.on("optionsChanged",ne),z.on("created",ne),z.on("dragStarted",function(){J=!1,oe(),U=B=z.track.details.abs}),z.on("dragChecked",function(){J=!0}),z.on("dragEnded",function(){var le=z.options.mode;le==="snap"&&function(){var ce=z.track,Ce=z.track.details,ze=Ce.position,$e=y(k());(ze>K||ze<W)&&($e=0);var ke=U+$e;Ce.slides[ce.absToRel(ke)].portion===0&&(ke-=$e),U!==B&&(ke=B),y(ce.idxToDist(ke,!0))!==$e&&(ke+=$e),ke=Z(ke);var ge=ce.idxToDist(ke,!0);z.animator.start([{distance:ge,duration:500,easing:function(ue){return 1+--ue*ue*ue*ue*ue}}])}(),le!=="free"&&le!=="free-snap"||q()}),z.on("dragged",function(){B=z.track.details.abs})}function V(z){var U,B,J,X,W,K,re,F,G,Z,se,k,q,ee,ne,oe,le,ce,Ce=g();function ze(be){if(K&&F===be.id){var Ee=ue(be);if(G){if(!ge(be))return ke(be);Z=Ee,G=!1,z.emit("dragChecked")}if(oe)return Z=Ee;f(be);var Te=function(De){if(le===-1/0&&ce===1/0)return De;var Ue=z.track.details,Fe=Ue.length,Le=Ue.position,it=p(De,le-Le,ce-Le);if(Fe===0)return 0;if(!z.options.rubberband)return it;if(Le<=ce&&Le>=le||Le<le&&B>0||Le>ce&&B<0)return De;var ut=(Le<le?Le-le:Le-ce)/Fe,vt=X*Fe,At=Math.abs(ut*vt),ht=Math.max(0,1-At/W*2);return ht*ht*De}(re(Z-Ee)/X*J);B=y(Te);var Ae=z.track.details.position;(Ae>le&&Ae<ce||Ae===le&&B>0||Ae===ce&&B<0)&&m(be),se+=Te,!k&&Math.abs(se*X)>5&&(k=!0),z.track.add(Te),Z=Ee,z.emit("dragged")}}function $e(be){!K&&z.track.details&&z.track.details.length&&(se=0,K=!0,k=!1,G=!0,F=be.id,ge(be),Z=ue(be),z.emit("dragStarted"))}function ke(be){K&&F===be.idChanged&&(K=!1,z.emit("dragEnded"))}function ge(be){var Ee=Re(),Te=Ee?be.y:be.x,Ae=Ee?be.x:be.y,De=q!==void 0&&ee!==void 0&&Math.abs(ee-Ae)<=Math.abs(q-Te);return q=Te,ee=Ae,De}function ue(be){return Re()?be.y:be.x}function Re(){return z.options.vertical}function Ie(){X=z.size,W=Re()?window.innerHeight:window.innerWidth;var be=z.track.details;be&&(le=be.min,ce=be.max)}function ve(be){k&&(m(be),f(be))}function we(){if(Ce.purge(),z.options.drag&&!z.options.disabled){var be;be=z.options.dragSpeed||1,re=typeof be=="function"?be:function(Te){return Te*be},J=z.options.rtl?-1:1,Ie(),U=z.container,function(){var Te="data-keen-slider-clickable";c("[".concat(Te,"]:not([").concat(Te,"=false])"),U).map(function(Ae){Ce.add(Ae,"dragstart",m),Ce.add(Ae,"mousedown",m),Ce.add(Ae,"touchstart",m)})}(),Ce.add(U,"dragstart",function(Te){f(Te)}),Ce.add(U,"click",ve,{capture:!0}),Ce.input(U,"ksDragStart",$e),Ce.input(U,"ksDrag",ze),Ce.input(U,"ksDragEnd",ke),Ce.input(U,"mousedown",$e),Ce.input(U,"mousemove",ze),Ce.input(U,"mouseleave",ke),Ce.input(U,"mouseup",ke),Ce.input(U,"touchstart",$e,{passive:!0}),Ce.input(U,"touchmove",ze,{passive:!1}),Ce.input(U,"touchend",ke),Ce.input(U,"touchcancel",ke),Ce.add(window,"wheel",function(Te){K&&f(Te)});var Ee="data-keen-slider-scrollable";c("[".concat(Ee,"]:not([").concat(Ee,"=false])"),z.container).map(function(Te){return function(Ae){var De;Ce.input(Ae,"touchstart",function(Ue){De=ue(Ue),oe=!0,ne=!0},{passive:!0}),Ce.input(Ae,"touchmove",function(Ue){var Fe=Re(),Le=Fe?Ae.scrollHeight-Ae.clientHeight:Ae.scrollWidth-Ae.clientWidth,it=De-ue(Ue),ut=Fe?Ae.scrollTop:Ae.scrollLeft,vt=Fe&&Ae.style.overflowY==="scroll"||!Fe&&Ae.style.overflowX==="scroll";if(De=ue(Ue),(it<0&&ut>0||it>0&&ut<Le)&&ne&&vt)return oe=!0;ne=!1,f(Ue),oe=!1}),Ce.input(Ae,"touchend",function(){oe=!1})}(Te)})}}z.on("updated",Ie),z.on("optionsChanged",we),z.on("created",we),z.on("destroyed",Ce.purge)}function $(z){var U,B,J=null;function X(q,ee,ne){z.animator.active?K(q,ee,ne):requestAnimationFrame(function(){return K(q,ee,ne)})}function W(){X(!1,!1,B)}function K(q,ee,ne){var oe=0,le=z.size,ce=z.track.details;if(ce&&U){var Ce=ce.slides;U.forEach(function(ze,$e){if(q)!J&&ee&&F(ze,null,ne),G(ze,null,ne);else{if(!Ce[$e])return;var ke=Ce[$e].size*le;!J&&ee&&F(ze,ke,ne),G(ze,Ce[$e].distance*le-oe,ne),oe+=ke}})}}function re(q){return z.options.renderMode==="performance"?Math.round(q):q}function F(q,ee,ne){var oe=ne?"height":"width";ee!==null&&(ee=re(ee)+"px"),q.style["min-"+oe]=ee,q.style["max-"+oe]=ee}function G(q,ee,ne){if(ee!==null){ee=re(ee);var oe=ne?ee:0;ee="translate3d(".concat(ne?0:ee,"px, ").concat(oe,"px, 0)")}q.style.transform=ee,q.style["-webkit-transform"]=ee}function Z(){U&&(K(!0,!0,B),U=null),z.on("detailsChanged",W,!0)}function se(){X(!1,!0,B)}function k(){Z(),B=z.options.vertical,z.options.disabled||z.options.renderMode==="custom"||(J=E(z.options.slides,"perView",null)==="auto",z.on("detailsChanged",W),(U=z.slides).length&&se())}z.on("created",k),z.on("optionsChanged",k),z.on("beforeOptionsChanged",function(){Z()}),z.on("updated",se),z.on("destroyed",Z)}function L(z,U){return function(B){var J,X,W,K,re,F=g();function G(ge){var ue;o(B.container,"reverse",(ue=B.container,window.getComputedStyle(ue,null).getPropertyValue("direction")!=="rtl"||ge?null:"")),o(B.container,"v",B.options.vertical&&!ge?"":null),o(B.container,"disabled",B.options.disabled&&!ge?"":null)}function Z(){se()&&oe()}function se(){var ge=null;if(K.forEach(function(Re){Re.matches&&(ge=Re.__media)}),ge===J)return!1;J||B.emit("beforeOptionsChanged"),J=ge;var ue=ge?W.breakpoints[ge]:W;return B.options=M(M({},W),ue),G(),$e(),ke(),ce(),!0}function k(ge){var ue=S(ge);return(B.options.vertical?ue.height:ue.width)/B.size||1}function q(){return B.options.trackConfig.length}function ee(ge){for(var ue in J=!1,W=M(M({},U),ge),F.purge(),X=B.size,K=[],W.breakpoints||[]){var Re=window.matchMedia(ue);Re.__media=ue,K.push(Re),F.add(Re,"change",Z)}F.add(window,"orientationchange",ze),F.add(window,"resize",Ce),se()}function ne(ge){B.animator.stop();var ue=B.track.details;B.track.init(ge??(ue?ue.abs:0))}function oe(ge){ne(ge),B.emit("optionsChanged")}function le(ge,ue){if(ge)return ee(ge),void oe(ue);$e(),ke();var Re=q();ce(),q()!==Re?oe(ue):ne(ue),B.emit("updated")}function ce(){var ge=B.options.slides;if(typeof ge=="function")return B.options.trackConfig=ge(B.size,B.slides);for(var ue=B.slides,Re=ue.length,Ie=typeof ge=="number"?ge:E(ge,"number",Re,!0),ve=[],we=E(ge,"perView",1,!0),be=E(ge,"spacing",0,!0)/B.size||0,Ee=we==="auto"?be:be/we,Te=E(ge,"origin","auto"),Ae=0,De=0;De<Ie;De++){var Ue=we==="auto"?k(ue[De]):1/we-be+Ee,Fe=Te==="center"?.5-Ue/2:Te==="auto"?0:Te;ve.push({origin:Fe,size:Ue,spacing:be}),Ae+=Ue}if(Ae+=be*(Ie-1),Te==="auto"&&!B.options.loop&&we!==1){var Le=0;ve.map(function(it){var ut=Ae-Le;return Le+=it.size+be,ut>=1||(it.origin=1-ut-(Ae>1?0:1-Ae)),it})}B.options.trackConfig=ve}function Ce(){$e();var ge=B.size;B.options.disabled||ge===X||(X=ge,le())}function ze(){Ce(),setTimeout(Ce,500),setTimeout(Ce,2e3)}function $e(){var ge=S(B.container);B.size=(B.options.vertical?ge.height:ge.width)||1}function ke(){B.slides=c(B.options.selector,B.container)}B.container=(re=c(z,document)).length?re[0]:null,B.destroy=function(){F.purge(),B.emit("destroyed"),G(!0)},B.prev=function(){B.moveToIdx(B.track.details.abs-1,!0)},B.next=function(){B.moveToIdx(B.track.details.abs+1,!0)},B.update=le,ee(B.options)}}var H=function(z,U,B){try{return function(J,X){var W,K={};return W={emit:function(re){K[re]&&K[re].forEach(function(G){G(W)});var F=W.options&&W.options[re];F&&F(W)},moveToIdx:function(re,F,G){var Z=W.track.idxToDist(re,F);if(Z){var se=W.options.defaultAnimation;W.animator.start([{distance:Z,duration:E(G||se,"duration",500),easing:E(G||se,"easing",function(k){return 1+--k*k*k*k*k})}])}},on:function(re,F,G){G===void 0&&(G=!1),K[re]||(K[re]=[]);var Z=K[re].indexOf(F);Z>-1?G&&delete K[re][Z]:G||K[re].push(F)},options:J},function(){if(W.track=_(W),W.animator=D(W),X)for(var re=0,F=X;re<F.length;re++)(0,F[re])(W);W.track.init(W.options.initial||0),W.emit("created")}(),W}(U,A([L(z,{drag:!0,mode:"snap",renderMode:"precision",rubberband:!0,selector:".keen-slider__slide"}),$,V,j],B||[],!0))}catch(J){console.error(J)}};return nx.useKeenSlider=function(z,U){var B=e.useRef(null),J=e.useRef(!1),X=e.useRef(z),W=e.useCallback(function(K){K?(X.current=z,B.current=new H(K,z,U),J.current=!1):(B.current&&B.current.destroy&&B.current.destroy(),B.current=null)},[]);return e.useEffect(function(){O(X.current,z)||(X.current=z,B.current&&B.current.update(X.current))},[z]),[W,B]},nx}var EO=nK();const aK=({message:e,colorCode:t,handleAddToCart:a,handleRemoveFromCart:r})=>{const[o,c]=x.useState({}),[f,m]=x.useState({}),g=_=>{const j=/(https?:\/\/[^\s]+)/g;return _.split(j).map((V,$)=>j.test(V)?ae.jsx("a",{href:V.trim(),style:{color:"#00b3bc"},target:"_blank",rel:"noopener noreferrer",className:"underline break-words",children:V},$):ae.jsx("span",{children:V},$))},p=_=>{const j=_.trim();if(!j.includes("Name:")||!j.includes("VariantId"))return null;const V=j.match(/Name\s*[:\-]\s*(.+)/i),$=j.match(/Price\s*[:\-]\s*(.+)/i),L=j.match(/Link\s*[:\-]\s*(https?:\/\/[^\s]+)/i),H=j.match(/VariantId\s*[:\-]\s*(.+)/i),z=j.match(/variant_tag_name\s*[:\-]\s*(.+)/i),U=j.match(/color\s*[:\-]\s*([^|\r\n]+)/i),B=j.match(/size\s*[:\-]\s*([^|\r\n]+)/i);return!V||!$||!L||!H||!z?null:{name:V[1].trim(),price:$[1].trim(),link:L[1].trim(),image:"",variant_id:H[1].trim(),variant_tag_name:z[1].trim(),color:U?.[1]?.trim(),size:B?.[1]?.trim()}},y=x.useMemo(()=>{const _=e.split("|||").map($=>$.trim()).filter(Boolean),j=[];let V=null;return _.forEach($=>{if($.startsWith("img - ")){const L=$.replace(/^img\s*[-:]\s*/,"").trim();if(V)V.image=L;else{const H=[...j].reverse().find(z=>z.type==="product");H&&(H.data.image=L)}}else if($.includes("Name:")&&$.includes("VariantId")){const L=p($);L&&(j.push({type:"product",data:L}),V=L)}else j.push({type:"text",data:$}),V=null}),j},[e]),S=x.useMemo(()=>{const _={};return y.forEach(j=>{if(j.type==="product"){const V=j.data;_[V.variant_tag_name]=_[V.variant_tag_name]||[],_[V.variant_tag_name].push(V)}}),_},[y]),E=(_,j=22)=>_.length>j?_.slice(0,j)+"...":_,[T,O]=x.useState(0),M=Object.keys(S).length,[A,D]=EO.useKeenSlider({loop:!1,mode:"free",slides:{perView:1,spacing:16},slideChanged(_){O(_.track.details.rel)}});return ae.jsxs("div",{className:"space-y-6 mt-4 h-fit",children:[y.filter(_=>_.type==="text").map((_,j)=>ae.jsx("p",{className:"whitespace-pre-wrap break-words",children:g(_.data)},j)),Object.keys(S).length>0&&ae.jsxs(ae.Fragment,{children:[Object.keys(S).length>1&&ae.jsxs("div",{style:{display:"flex",margin:0,marginBottom:"6px",justifyContent:"space-between",paddingInline:"4px"},children:[ae.jsx(ri,{shape:"circle",icon:ae.jsx(km,{}),onClick:()=>D.current?.prev(),disabled:T===0}),ae.jsx(ri,{shape:"circle",icon:ae.jsx(z1,{}),onClick:()=>D.current?.next(),disabled:T===M-1})]}),ae.jsx("div",{ref:A,className:"keen-slider",children:ae.jsx(tK,{groupedProducts:S,selectedVariants:f,setSelectedVariants:m,counts:o,setCounts:c,handleAddToCart:a,handleRemoveFromCart:r,colorCode:t,shortenName:E,sliderInstance:D,currentSlide:T,totalSlides:M,sliderRef:A})})]})]})},U6=({message:e})=>{const t=e.find(r=>r.type==="image_url")?.image_url?.url,a=e?.isBusiness;return ae.jsx("div",{children:ae.jsx("div",{children:t&&ae.jsx("div",{className:"mb-2 bg-transparent text-white ",children:ae.jsx("img",{src:t,alt:"Chat image",style:{width:200},className:`rounded-md bg-transparent mt-2 max-w-xs ${a?"border border-gray-300 shadow-sm":""}`})})})})},rK=({message:e,colorCode:t})=>{const a=e.find(o=>o.type==="text")?.text,r=o=>{const c=/(https?:\/\/[^\s]+)/g;return o.split(c).map((f,m)=>c.test(f)?ae.jsx("a",{href:f.trim(),style:{color:t},target:"_blank",rel:"noopener noreferrer",className:"underline break-words",children:f},m):ae.jsx("span",{children:f},m))};return ae.jsx(ae.Fragment,{children:a&&ae.jsx("div",{style:{color:"white",border:1,backgroundColor:t,paddingTop:10,paddingBottom:10,paddingInline:14,maxWidth:"85%",lineHeight:1.4,borderRadius:"16px",wordBreak:"break-word"},children:ae.jsx("p",{children:r(a)})})})},iK=({link:e,colorCode:t,transcription:a})=>{const r=x.useRef(null),o=x.useRef(null),[c,f]=x.useState(!1),[m,g]=x.useState(!1);x.useEffect(()=>{if(r.current)return o.current?.destroy(),o.current=Wm.create({container:r.current,waveColor:"white",progressColor:"white",cursorWidth:0,barWidth:3,barHeight:1.5,barGap:2,height:40,interact:!0}),o.current.load(e),o.current.on("finish",()=>f(!1)),()=>{o.current?.destroy()}},[e,t]);const p=()=>{o.current&&(o.current.playPause(),f(y=>!y))};return ae.jsxs("div",{style:{backgroundColor:t,padding:"12px",borderRadius:"20px",color:"white",maxWidth:"350px",marginBottom:"16px"},children:[ae.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[ae.jsx("button",{onClick:p,style:{background:"transparent",border:"none",color:"white",marginRight:"12px",cursor:"pointer"},children:c?ae.jsx(GT,{style:{fontSize:"24px"}}):ae.jsx(XT,{style:{fontSize:"24px"}})}),ae.jsx("div",{ref:r,style:{width:"130px",height:"40px",overflow:"hidden",color:"white"}})]}),a&&ae.jsxs("div",{style:{marginTop:"12px",fontSize:"14px",color:"rgba(255,255,255,0.85)"},children:[ae.jsx("button",{onClick:()=>g(!m),style:{background:"none",border:"none",color:"white",textDecoration:"underline",fontSize:"13px",cursor:"pointer",padding:0},children:m?"Hide transcript":"Show transcript"}),m&&ae.jsx("p",{style:{marginTop:"6px",lineHeight:"1.4"},children:a})]})]})},oK=({status:e,user:t})=>{if(!e||!t)return null;let a=`${t} is ${e}`;return e==="typing"?a=`${t} is typing...`:a="",ae.jsx(ae.Fragment,{children:a&&ae.jsx("div",{className:"flex justify-center mb-2",children:ae.jsx("span",{className:"px-3 py-1 bg-gray-100 text-gray-500 text-sm rounded-full",children:a})})})},lK=({message:e})=>{const t=r=>{const o=/(https?:\/\/[^\s]+)/g;return r?.split(o).map((c,f)=>o.test(c)?ae.jsx("a",{href:c.trim(),style:{color:"#00b3bc"},target:"_blank",rel:"noopener noreferrer",className:"underline break-words",children:c},f):ae.jsx("span",{children:c},f))};if(e?.startsWith("Add this to cart for me")&&e?.includes("name:")){const o=e?.match(/name:([^,]+)/i)?.[1]?.trim()||"Product";return ae.jsxs("div",{style:{backgroundColor:"#E8F5E9",border:"1px solid #C8E6C9",borderRadius:"12px",padding:"12px 16px",color:"#2E7D32",fontWeight:500,fontSize:"15px",maxWidth:"360px",margin:"0 auto",textAlign:"center"},children:["✅ ",ae.jsx("strong",{children:o})," has been added to your cart."]})}return ae.jsx("p",{style:{color:"white"},children:t(e)})},wO=x.createContext({});function TO(e){const t=x.useRef(null);return t.current===null&&(t.current=e()),t.current}const OO=typeof window<"u",I6=OO?x.useLayoutEffect:x.useEffect,ax=x.createContext(null);function RO(e,t){e.indexOf(t)===-1&&e.push(t)}function AO(e,t){const a=e.indexOf(t);a>-1&&e.splice(a,1)}const Wu=(e,t,a)=>a>t?t:a<e?e:a;function MO(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}var sK={};let Zm=()=>{},Zu=()=>{};sK.NODE_ENV!=="production"&&(Zm=(e,t,a)=>{!e&&typeof console<"u"&&console.warn(MO(t,a))},Zu=(e,t,a)=>{if(!e)throw new Error(MO(t,a))});const Ku={},k6=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function F6(e){return typeof e=="object"&&e!==null}const q6=e=>/^0[^.\s]+$/u.test(e);function _O(e){let t;return()=>(t===void 0&&(t=e()),t)}const Sl=e=>e,uK=(e,t)=>a=>t(e(a)),S0=(...e)=>e.reduce(uK),x0=(e,t,a)=>{const r=t-e;return r===0?1:(a-e)/r};class DO{constructor(){this.subscriptions=[]}add(t){return RO(this.subscriptions,t),()=>AO(this.subscriptions,t)}notify(t,a,r){const o=this.subscriptions.length;if(o)if(o===1)this.subscriptions[0](t,a,r);else for(let c=0;c<o;c++){const f=this.subscriptions[c];f&&f(t,a,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const is=e=>e*1e3,Qs=e=>e/1e3;function G6(e,t){return t?e*(1e3/t):0}const X6=new Set;function NO(e,t,a){e||X6.has(t)||(console.warn(MO(t,a)),X6.add(t))}const Y6=(e,t,a)=>(((1-3*a+3*t)*e+(3*a-6*t))*e+3*t)*e,cK=1e-7,fK=12;function dK(e,t,a,r,o){let c,f,m=0;do f=t+(a-t)/2,c=Y6(f,r,o)-e,c>0?a=f:t=f;while(Math.abs(c)>cK&&++m<fK);return f}function C0(e,t,a,r){if(e===t&&a===r)return Sl;const o=c=>dK(c,0,1,e,a);return c=>c===0||c===1?c:Y6(o(c),t,r)}const W6=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Z6=e=>t=>1-e(1-t),K6=C0(.33,1.53,.69,.99),$O=Z6(K6),Q6=W6($O),J6=e=>(e*=2)<1?.5*$O(e):.5*(2-Math.pow(2,-10*(e-1))),zO=e=>1-Math.sin(Math.acos(e)),ez=Z6(zO),tz=W6(zO),hK=C0(.42,0,1,1),mK=C0(0,0,.58,1),nz=C0(.42,0,.58,1),pK=e=>Array.isArray(e)&&typeof e[0]!="number",az=e=>Array.isArray(e)&&typeof e[0]=="number",rz={linear:Sl,easeIn:hK,easeInOut:nz,easeOut:mK,circIn:zO,circInOut:tz,circOut:ez,backIn:$O,backInOut:Q6,backOut:K6,anticipate:J6},gK=e=>typeof e=="string",iz=e=>{if(az(e)){Zu(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,a,r,o]=e;return C0(t,a,r,o)}else if(gK(e))return Zu(rz[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),rz[e];return e},rx=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function vK(e,t){let a=new Set,r=new Set,o=!1,c=!1;const f=new WeakSet;let m={delta:0,timestamp:0,isProcessing:!1};function g(y){f.has(y)&&(p.schedule(y),e()),y(m)}const p={schedule:(y,S=!1,E=!1)=>{const O=E&&o?a:r;return S&&f.add(y),O.has(y)||O.add(y),y},cancel:y=>{r.delete(y),f.delete(y)},process:y=>{if(m=y,o){c=!0;return}o=!0,[a,r]=[r,a],a.forEach(g),a.clear(),o=!1,c&&(c=!1,p.process(y))}};return p}const yK=40;function oz(e,t){let a=!1,r=!0;const o={delta:0,timestamp:0,isProcessing:!1},c=()=>a=!0,f=rx.reduce((j,V)=>(j[V]=vK(c),j),{}),{setup:m,read:g,resolveKeyframes:p,preUpdate:y,update:S,preRender:E,render:T,postRender:O}=f,M=()=>{const j=Ku.useManualTiming?o.timestamp:performance.now();a=!1,Ku.useManualTiming||(o.delta=r?1e3/60:Math.max(Math.min(j-o.timestamp,yK),1)),o.timestamp=j,o.isProcessing=!0,m.process(o),g.process(o),p.process(o),y.process(o),S.process(o),E.process(o),T.process(o),O.process(o),o.isProcessing=!1,a&&t&&(r=!1,e(M))},A=()=>{a=!0,r=!0,o.isProcessing||e(M)};return{schedule:rx.reduce((j,V)=>{const $=f[V];return j[V]=(L,H=!1,z=!1)=>(a||A(),$.schedule(L,H,z)),j},{}),cancel:j=>{for(let V=0;V<rx.length;V++)f[rx[V]].cancel(j)},state:o,steps:f}}const{schedule:Pa,cancel:nf,state:oi,steps:jO}=oz(typeof requestAnimationFrame<"u"?requestAnimationFrame:Sl,!0);let ix;function bK(){ix=void 0}const yo={now:()=>(ix===void 0&&yo.set(oi.isProcessing||Ku.useManualTiming?oi.timestamp:performance.now()),ix),set:e=>{ix=e,queueMicrotask(bK)}},lz=e=>t=>typeof t=="string"&&t.startsWith(e),LO=lz("--"),SK=lz("var(--"),VO=e=>SK(e)?xK.test(e.split("/*")[0].trim()):!1,xK=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Km={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},E0={...Km,transform:e=>Wu(0,1,e)},ox={...Km,default:1},w0=e=>Math.round(e*1e5)/1e5,HO=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function CK(e){return e==null}const EK=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,BO=(e,t)=>a=>!!(typeof a=="string"&&EK.test(a)&&a.startsWith(e)||t&&!CK(a)&&Object.prototype.hasOwnProperty.call(a,t)),sz=(e,t,a)=>r=>{if(typeof r!="string")return r;const[o,c,f,m]=r.match(HO);return{[e]:parseFloat(o),[t]:parseFloat(c),[a]:parseFloat(f),alpha:m!==void 0?parseFloat(m):1}},wK=e=>Wu(0,255,e),PO={...Km,transform:e=>Math.round(wK(e))},Hd={test:BO("rgb","red"),parse:sz("red","green","blue"),transform:({red:e,green:t,blue:a,alpha:r=1})=>"rgba("+PO.transform(e)+", "+PO.transform(t)+", "+PO.transform(a)+", "+w0(E0.transform(r))+")"};function TK(e){let t="",a="",r="",o="";return e.length>5?(t=e.substring(1,3),a=e.substring(3,5),r=e.substring(5,7),o=e.substring(7,9)):(t=e.substring(1,2),a=e.substring(2,3),r=e.substring(3,4),o=e.substring(4,5),t+=t,a+=a,r+=r,o+=o),{red:parseInt(t,16),green:parseInt(a,16),blue:parseInt(r,16),alpha:o?parseInt(o,16)/255:1}}const UO={test:BO("#"),parse:TK,transform:Hd.transform},T0=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),af=T0("deg"),Js=T0("%"),on=T0("px"),OK=T0("vh"),RK=T0("vw"),uz={...Js,parse:e=>Js.parse(e)/100,transform:e=>Js.transform(e*100)},Qm={test:BO("hsl","hue"),parse:sz("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:a,alpha:r=1})=>"hsla("+Math.round(e)+", "+Js.transform(w0(t))+", "+Js.transform(w0(a))+", "+w0(E0.transform(r))+")"},xr={test:e=>Hd.test(e)||UO.test(e)||Qm.test(e),parse:e=>Hd.test(e)?Hd.parse(e):Qm.test(e)?Qm.parse(e):UO.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Hd.transform(e):Qm.transform(e),getAnimatableNone:e=>{const t=xr.parse(e);return t.alpha=0,xr.transform(t)}},AK=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function MK(e){return isNaN(e)&&typeof e=="string"&&(e.match(HO)?.length||0)+(e.match(AK)?.length||0)>0}const cz="number",fz="color",_K="var",DK="var(",dz="${}",NK=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function O0(e){const t=e.toString(),a=[],r={color:[],number:[],var:[]},o=[];let c=0;const m=t.replace(NK,g=>(xr.test(g)?(r.color.push(c),o.push(fz),a.push(xr.parse(g))):g.startsWith(DK)?(r.var.push(c),o.push(_K),a.push(g)):(r.number.push(c),o.push(cz),a.push(parseFloat(g))),++c,dz)).split(dz);return{values:a,split:m,indexes:r,types:o}}function hz(e){return O0(e).values}function mz(e){const{split:t,types:a}=O0(e),r=t.length;return o=>{let c="";for(let f=0;f<r;f++)if(c+=t[f],o[f]!==void 0){const m=a[f];m===cz?c+=w0(o[f]):m===fz?c+=xr.transform(o[f]):c+=o[f]}return c}}const $K=e=>typeof e=="number"?0:xr.test(e)?xr.getAnimatableNone(e):e;function zK(e){const t=hz(e);return mz(e)(t.map($K))}const rf={test:MK,parse:hz,createTransformer:mz,getAnimatableNone:zK};function IO(e,t,a){return a<0&&(a+=1),a>1&&(a-=1),a<1/6?e+(t-e)*6*a:a<1/2?t:a<2/3?e+(t-e)*(2/3-a)*6:e}function jK({hue:e,saturation:t,lightness:a,alpha:r}){e/=360,t/=100,a/=100;let o=0,c=0,f=0;if(!t)o=c=f=a;else{const m=a<.5?a*(1+t):a+t-a*t,g=2*a-m;o=IO(g,m,e+1/3),c=IO(g,m,e),f=IO(g,m,e-1/3)}return{red:Math.round(o*255),green:Math.round(c*255),blue:Math.round(f*255),alpha:r}}function lx(e,t){return a=>a>0?t:e}const Za=(e,t,a)=>e+(t-e)*a,kO=(e,t,a)=>{const r=e*e,o=a*(t*t-r)+r;return o<0?0:Math.sqrt(o)},LK=[UO,Hd,Qm],VK=e=>LK.find(t=>t.test(e));function pz(e){const t=VK(e);if(Zm(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!t)return!1;let a=t.parse(e);return t===Qm&&(a=jK(a)),a}const gz=(e,t)=>{const a=pz(e),r=pz(t);if(!a||!r)return lx(e,t);const o={...a};return c=>(o.red=kO(a.red,r.red,c),o.green=kO(a.green,r.green,c),o.blue=kO(a.blue,r.blue,c),o.alpha=Za(a.alpha,r.alpha,c),Hd.transform(o))},FO=new Set(["none","hidden"]);function HK(e,t){return FO.has(e)?a=>a<=0?e:t:a=>a>=1?t:e}function BK(e,t){return a=>Za(e,t,a)}function qO(e){return typeof e=="number"?BK:typeof e=="string"?VO(e)?lx:xr.test(e)?gz:IK:Array.isArray(e)?vz:typeof e=="object"?xr.test(e)?gz:PK:lx}function vz(e,t){const a=[...e],r=a.length,o=e.map((c,f)=>qO(c)(c,t[f]));return c=>{for(let f=0;f<r;f++)a[f]=o[f](c);return a}}function PK(e,t){const a={...e,...t},r={};for(const o in a)e[o]!==void 0&&t[o]!==void 0&&(r[o]=qO(e[o])(e[o],t[o]));return o=>{for(const c in r)a[c]=r[c](o);return a}}function UK(e,t){const a=[],r={color:0,var:0,number:0};for(let o=0;o<t.values.length;o++){const c=t.types[o],f=e.indexes[c][r[c]],m=e.values[f]??0;a[o]=m,r[c]++}return a}const IK=(e,t)=>{const a=rf.createTransformer(t),r=O0(e),o=O0(t);return r.indexes.var.length===o.indexes.var.length&&r.indexes.color.length===o.indexes.color.length&&r.indexes.number.length>=o.indexes.number.length?FO.has(e)&&!o.values.length||FO.has(t)&&!r.values.length?HK(e,t):S0(vz(UK(r,o),o.values),a):(Zm(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),lx(e,t))};function yz(e,t,a){return typeof e=="number"&&typeof t=="number"&&typeof a=="number"?Za(e,t,a):qO(e)(e,t)}const kK=e=>{const t=({timestamp:a})=>e(a);return{start:(a=!0)=>Pa.update(t,a),stop:()=>nf(t),now:()=>oi.isProcessing?oi.timestamp:yo.now()}},bz=(e,t,a=10)=>{let r="";const o=Math.max(Math.round(t/a),2);for(let c=0;c<o;c++)r+=Math.round(e(c/(o-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},sx=2e4;function GO(e){let t=0;const a=50;let r=e.next(t);for(;!r.done&&t<sx;)t+=a,r=e.next(t);return t>=sx?1/0:t}function FK(e,t=100,a){const r=a({...e,keyframes:[0,t]}),o=Math.min(GO(r),sx);return{type:"keyframes",ease:c=>r.next(o*c).value/t,duration:Qs(o)}}const qK=5;function Sz(e,t,a){const r=Math.max(t-qK,0);return G6(a-e(r),t-r)}const Ka={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},XO=.001;function GK({duration:e=Ka.duration,bounce:t=Ka.bounce,velocity:a=Ka.velocity,mass:r=Ka.mass}){let o,c;Zm(e<=is(Ka.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let f=1-t;f=Wu(Ka.minDamping,Ka.maxDamping,f),e=Wu(Ka.minDuration,Ka.maxDuration,Qs(e)),f<1?(o=p=>{const y=p*f,S=y*e,E=y-a,T=YO(p,f),O=Math.exp(-S);return XO-E/T*O},c=p=>{const S=p*f*e,E=S*a+a,T=Math.pow(f,2)*Math.pow(p,2)*e,O=Math.exp(-S),M=YO(Math.pow(p,2),f);return(-o(p)+XO>0?-1:1)*((E-T)*O)/M}):(o=p=>{const y=Math.exp(-p*e),S=(p-a)*e+1;return-XO+y*S},c=p=>{const y=Math.exp(-p*e),S=(a-p)*(e*e);return y*S});const m=5/e,g=YK(o,c,m);if(e=is(e),isNaN(g))return{stiffness:Ka.stiffness,damping:Ka.damping,duration:e};{const p=Math.pow(g,2)*r;return{stiffness:p,damping:f*2*Math.sqrt(r*p),duration:e}}}const XK=12;function YK(e,t,a){let r=a;for(let o=1;o<XK;o++)r=r-e(r)/t(r);return r}function YO(e,t){return e*Math.sqrt(1-t*t)}const WK=["duration","bounce"],ZK=["stiffness","damping","mass"];function xz(e,t){return t.some(a=>e[a]!==void 0)}function KK(e){let t={velocity:Ka.velocity,stiffness:Ka.stiffness,damping:Ka.damping,mass:Ka.mass,isResolvedFromDuration:!1,...e};if(!xz(e,ZK)&&xz(e,WK))if(e.visualDuration){const a=e.visualDuration,r=2*Math.PI/(a*1.2),o=r*r,c=2*Wu(.05,1,1-(e.bounce||0))*Math.sqrt(o);t={...t,mass:Ka.mass,stiffness:o,damping:c}}else{const a=GK(e);t={...t,...a,mass:Ka.mass},t.isResolvedFromDuration=!0}return t}function ux(e=Ka.visualDuration,t=Ka.bounce){const a=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:o}=a;const c=a.keyframes[0],f=a.keyframes[a.keyframes.length-1],m={done:!1,value:c},{stiffness:g,damping:p,mass:y,duration:S,velocity:E,isResolvedFromDuration:T}=KK({...a,velocity:-Qs(a.velocity||0)}),O=E||0,M=p/(2*Math.sqrt(g*y)),A=f-c,D=Qs(Math.sqrt(g/y)),_=Math.abs(A)<5;r||(r=_?Ka.restSpeed.granular:Ka.restSpeed.default),o||(o=_?Ka.restDelta.granular:Ka.restDelta.default);let j;if(M<1){const $=YO(D,M);j=L=>{const H=Math.exp(-M*D*L);return f-H*((O+M*D*A)/$*Math.sin($*L)+A*Math.cos($*L))}}else if(M===1)j=$=>f-Math.exp(-D*$)*(A+(O+D*A)*$);else{const $=D*Math.sqrt(M*M-1);j=L=>{const H=Math.exp(-M*D*L),z=Math.min($*L,300);return f-H*((O+M*D*A)*Math.sinh(z)+$*A*Math.cosh(z))/$}}const V={calculatedDuration:T&&S||null,next:$=>{const L=j($);if(T)m.done=$>=S;else{let H=$===0?O:0;M<1&&(H=$===0?is(O):Sz(j,$,L));const z=Math.abs(H)<=r,U=Math.abs(f-L)<=o;m.done=z&&U}return m.value=m.done?f:L,m},toString:()=>{const $=Math.min(GO(V),sx),L=bz(H=>V.next($*H).value,$,30);return $+"ms "+L},toTransition:()=>{}};return V}ux.applyToOptions=e=>{const t=FK(e,100,ux);return e.ease=t.ease,e.duration=is(t.duration),e.type="keyframes",e};function WO({keyframes:e,velocity:t=0,power:a=.8,timeConstant:r=325,bounceDamping:o=10,bounceStiffness:c=500,modifyTarget:f,min:m,max:g,restDelta:p=.5,restSpeed:y}){const S=e[0],E={done:!1,value:S},T=z=>m!==void 0&&z<m||g!==void 0&&z>g,O=z=>m===void 0?g:g===void 0||Math.abs(m-z)<Math.abs(g-z)?m:g;let M=a*t;const A=S+M,D=f===void 0?A:f(A);D!==A&&(M=D-S);const _=z=>-M*Math.exp(-z/r),j=z=>D+_(z),V=z=>{const U=_(z),B=j(z);E.done=Math.abs(U)<=p,E.value=E.done?D:B};let $,L;const H=z=>{T(E.value)&&($=z,L=ux({keyframes:[E.value,O(E.value)],velocity:Sz(j,z,E.value),damping:o,stiffness:c,restDelta:p,restSpeed:y}))};return H(0),{calculatedDuration:null,next:z=>{let U=!1;return!L&&$===void 0&&(U=!0,V(z),H(z)),$!==void 0&&z>=$?L.next(z-$):(!U&&V(z),E)}}}function QK(e,t,a){const r=[],o=a||Ku.mix||yz,c=e.length-1;for(let f=0;f<c;f++){let m=o(e[f],e[f+1]);if(t){const g=Array.isArray(t)?t[f]||Sl:t;m=S0(g,m)}r.push(m)}return r}function JK(e,t,{clamp:a=!0,ease:r,mixer:o}={}){const c=e.length;if(Zu(c===t.length,"Both input and output ranges must be the same length","range-length"),c===1)return()=>t[0];if(c===2&&t[0]===t[1])return()=>t[1];const f=e[0]===e[1];e[0]>e[c-1]&&(e=[...e].reverse(),t=[...t].reverse());const m=QK(t,r,o),g=m.length,p=y=>{if(f&&y<e[0])return t[0];let S=0;if(g>1)for(;S<e.length-2&&!(y<e[S+1]);S++);const E=x0(e[S],e[S+1],y);return m[S](E)};return a?y=>p(Wu(e[0],e[c-1],y)):p}function eQ(e,t){const a=e[e.length-1];for(let r=1;r<=t;r++){const o=x0(0,t,r);e.push(Za(a,1,o))}}function tQ(e){const t=[0];return eQ(t,e.length-1),t}function nQ(e,t){return e.map(a=>a*t)}function aQ(e,t){return e.map(()=>t||nz).splice(0,e.length-1)}function Jm({duration:e=300,keyframes:t,times:a,ease:r="easeInOut"}){const o=pK(r)?r.map(iz):iz(r),c={done:!1,value:t[0]},f=nQ(a&&a.length===t.length?a:tQ(t),e),m=JK(f,t,{ease:Array.isArray(o)?o:aQ(t,o)});return{calculatedDuration:e,next:g=>(c.value=m(g),c.done=g>=e,c)}}const rQ=e=>e!==null;function ZO(e,{repeat:t,repeatType:a="loop"},r,o=1){const c=e.filter(rQ),m=o<0||t&&a!=="loop"&&t%2===1?0:c.length-1;return!m||r===void 0?c[m]:r}const iQ={decay:WO,inertia:WO,tween:Jm,keyframes:Jm,spring:ux};function Cz(e){typeof e.type=="string"&&(e.type=iQ[e.type])}class KO{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,a){return this.finished.then(t,a)}}var oQ={};const lQ=e=>e/100;class QO extends KO{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:a}=this.options;a&&a.updatedAt!==yo.now()&&this.tick(yo.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;Cz(t);const{type:a=Jm,repeat:r=0,repeatDelay:o=0,repeatType:c,velocity:f=0}=t;let{keyframes:m}=t;const g=a||Jm;oQ.NODE_ENV!=="production"&&g!==Jm&&Zu(m.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${m}`,"spring-two-frames"),g!==Jm&&typeof m[0]!="number"&&(this.mixKeyframes=S0(lQ,yz(m[0],m[1])),m=[0,100]);const p=g({...t,keyframes:m});c==="mirror"&&(this.mirroredGenerator=g({...t,keyframes:[...m].reverse(),velocity:-f})),p.calculatedDuration===null&&(p.calculatedDuration=GO(p));const{calculatedDuration:y}=p;this.calculatedDuration=y,this.resolvedDuration=y+o,this.totalDuration=this.resolvedDuration*(r+1)-o,this.generator=p}updateTime(t){const a=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=a}tick(t,a=!1){const{generator:r,totalDuration:o,mixKeyframes:c,mirroredGenerator:f,resolvedDuration:m,calculatedDuration:g}=this;if(this.startTime===null)return r.next(0);const{delay:p=0,keyframes:y,repeat:S,repeatType:E,repeatDelay:T,type:O,onUpdate:M,finalKeyframe:A}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-o/this.speed,this.startTime)),a?this.currentTime=t:this.updateTime(t);const D=this.currentTime-p*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?D<0:D>o;this.currentTime=Math.max(D,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=o);let j=this.currentTime,V=r;if(S){const z=Math.min(this.currentTime,o)/m;let U=Math.floor(z),B=z%1;!B&&z>=1&&(B=1),B===1&&U--,U=Math.min(U,S+1),!!(U%2)&&(E==="reverse"?(B=1-B,T&&(B-=T/m)):E==="mirror"&&(V=f)),j=Wu(0,1,B)*m}const $=_?{done:!1,value:y[0]}:V.next(j);c&&($.value=c($.value));let{done:L}=$;!_&&g!==null&&(L=this.playbackSpeed>=0?this.currentTime>=o:this.currentTime<=0);const H=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&L);return H&&O!==WO&&($.value=ZO(y,this.options,A,this.speed)),M&&M($.value),H&&this.finish(),$}then(t,a){return this.finished.then(t,a)}get duration(){return Qs(this.calculatedDuration)}get time(){return Qs(this.currentTime)}set time(t){t=is(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(yo.now());const a=this.playbackSpeed!==t;this.playbackSpeed=t,a&&(this.time=Qs(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=kK,startTime:a}=this.options;this.driver||(this.driver=t(o=>this.tick(o))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=a??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(yo.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}function sQ(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Bd=e=>e*180/Math.PI,JO=e=>{const t=Bd(Math.atan2(e[1],e[0]));return eR(t)},uQ={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:JO,rotateZ:JO,skewX:e=>Bd(Math.atan(e[1])),skewY:e=>Bd(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},eR=e=>(e=e%360,e<0&&(e+=360),e),Ez=JO,wz=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Tz=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),cQ={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:wz,scaleY:Tz,scale:e=>(wz(e)+Tz(e))/2,rotateX:e=>eR(Bd(Math.atan2(e[6],e[5]))),rotateY:e=>eR(Bd(Math.atan2(-e[2],e[0]))),rotateZ:Ez,rotate:Ez,skewX:e=>Bd(Math.atan(e[4])),skewY:e=>Bd(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function tR(e){return e.includes("scale")?1:0}function nR(e,t){if(!e||e==="none")return tR(t);const a=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,o;if(a)r=cQ,o=a;else{const m=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=uQ,o=m}if(!o)return tR(t);const c=r[t],f=o[1].split(",").map(dQ);return typeof c=="function"?c(f):f[c]}const fQ=(e,t)=>{const{transform:a="none"}=getComputedStyle(e);return nR(a,t)};function dQ(e){return parseFloat(e.trim())}const ep=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],tp=new Set(ep),Oz=e=>e===Km||e===on,hQ=new Set(["x","y","z"]),mQ=ep.filter(e=>!hQ.has(e));function pQ(e){const t=[];return mQ.forEach(a=>{const r=e.getValue(a);r!==void 0&&(t.push([a,r.get()]),r.set(a.startsWith("scale")?1:0))}),t}const Pd={width:({x:e},{paddingLeft:t="0",paddingRight:a="0"})=>e.max-e.min-parseFloat(t)-parseFloat(a),height:({y:e},{paddingTop:t="0",paddingBottom:a="0"})=>e.max-e.min-parseFloat(t)-parseFloat(a),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>nR(t,"x"),y:(e,{transform:t})=>nR(t,"y")};Pd.translateX=Pd.x,Pd.translateY=Pd.y;const Ud=new Set;let aR=!1,rR=!1,iR=!1;function Rz(){if(rR){const e=Array.from(Ud).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),a=new Map;t.forEach(r=>{const o=pQ(r);o.length&&(a.set(r,o),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const o=a.get(r);o&&o.forEach(([c,f])=>{r.getValue(c)?.set(f)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}rR=!1,aR=!1,Ud.forEach(e=>e.complete(iR)),Ud.clear()}function Az(){Ud.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(rR=!0)})}function gQ(){iR=!0,Az(),Rz(),iR=!1}class oR{constructor(t,a,r,o,c,f=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=a,this.name=r,this.motionValue=o,this.element=c,this.isAsync=f}scheduleResolve(){this.state="scheduled",this.isAsync?(Ud.add(this),aR||(aR=!0,Pa.read(Az),Pa.resolveKeyframes(Rz))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:a,element:r,motionValue:o}=this;if(t[0]===null){const c=o?.get(),f=t[t.length-1];if(c!==void 0)t[0]=c;else if(r&&a){const m=r.readValue(a,f);m!=null&&(t[0]=m)}t[0]===void 0&&(t[0]=f),o&&c===void 0&&o.set(t[0])}sQ(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Ud.delete(this)}cancel(){this.state==="scheduled"&&(Ud.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const vQ=e=>e.startsWith("--");function yQ(e,t,a){vQ(t)?e.style.setProperty(t,a):e.style[t]=a}const bQ=_O(()=>window.ScrollTimeline!==void 0),SQ={};function xQ(e,t){const a=_O(e);return()=>SQ[t]??a()}const Mz=xQ(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),R0=([e,t,a,r])=>`cubic-bezier(${e}, ${t}, ${a}, ${r})`,_z={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:R0([0,.65,.55,1]),circOut:R0([.55,0,1,.45]),backIn:R0([.31,.01,.66,-.59]),backOut:R0([.33,1.53,.69,.99])};function Dz(e,t){if(e)return typeof e=="function"?Mz()?bz(e,t):"ease-out":az(e)?R0(e):Array.isArray(e)?e.map(a=>Dz(a,t)||_z.easeOut):_z[e]}function CQ(e,t,a,{delay:r=0,duration:o=300,repeat:c=0,repeatType:f="loop",ease:m="easeOut",times:g}={},p=void 0){const y={[t]:a};g&&(y.offset=g);const S=Dz(m,o);Array.isArray(S)&&(y.easing=S);const E={delay:r,duration:o,easing:Array.isArray(S)?"linear":S,fill:"both",iterations:c+1,direction:f==="reverse"?"alternate":"normal"};return p&&(E.pseudoElement=p),e.animate(y,E)}function Nz(e){return typeof e=="function"&&"applyToOptions"in e}function EQ({type:e,...t}){return Nz(e)&&Mz()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class wQ extends KO{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:a,name:r,keyframes:o,pseudoElement:c,allowFlatten:f=!1,finalKeyframe:m,onComplete:g}=t;this.isPseudoElement=!!c,this.allowFlatten=f,this.options=t,Zu(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const p=EQ(t);this.animation=CQ(a,r,o,p,c),p.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!c){const y=ZO(o,this.options,m,this.speed);this.updateMotionValue?this.updateMotionValue(y):yQ(a,r,y),this.animation.cancel()}g?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return Qs(Number(t))}get time(){return Qs(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=is(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(t){this.animation.startTime=t}attachTimeline({timeline:t,observe:a}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&bQ()?(this.animation.timeline=t,Sl):a(this)}}const $z={anticipate:J6,backInOut:Q6,circInOut:tz};function TQ(e){return e in $z}function OQ(e){typeof e.ease=="string"&&TQ(e.ease)&&(e.ease=$z[e.ease])}const zz=10;class RQ extends wQ{constructor(t){OQ(t),Cz(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:a,onUpdate:r,onComplete:o,element:c,...f}=this.options;if(!a)return;if(t!==void 0){a.set(t);return}const m=new QO({...f,autoplay:!1}),g=is(this.finishedTime??this.time);a.setWithVelocity(m.sample(g-zz).value,m.sample(g).value,zz),m.stop()}}const jz=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(rf.test(e)||e==="0")&&!e.startsWith("url("));function AQ(e){const t=e[0];if(e.length===1)return!0;for(let a=0;a<e.length;a++)if(e[a]!==t)return!0}function MQ(e,t,a,r){const o=e[0];if(o===null)return!1;if(t==="display"||t==="visibility")return!0;const c=e[e.length-1],f=jz(o,t),m=jz(c,t);return Zm(f===m,`You are trying to animate ${t} from "${o}" to "${c}". "${f?c:o}" is not an animatable value.`,"value-not-animatable"),!f||!m?!1:AQ(e)||(a==="spring"||Nz(a))&&r}const _Q=new Set(["opacity","clipPath","filter","transform"]),DQ=_O(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function NQ(e){const{motionValue:t,name:a,repeatDelay:r,repeatType:o,damping:c,type:f}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:g,transformTemplate:p}=t.owner.getProps();return DQ()&&a&&_Q.has(a)&&(a!=="transform"||!p)&&!g&&!r&&o!=="mirror"&&c!==0&&f!=="inertia"}const $Q=40;class zQ extends KO{constructor({autoplay:t=!0,delay:a=0,type:r="keyframes",repeat:o=0,repeatDelay:c=0,repeatType:f="loop",keyframes:m,name:g,motionValue:p,element:y,...S}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=yo.now();const E={autoplay:t,delay:a,type:r,repeat:o,repeatDelay:c,repeatType:f,name:g,motionValue:p,element:y,...S},T=y?.KeyframeResolver||oR;this.keyframeResolver=new T(m,(O,M,A)=>this.onKeyframesResolved(O,M,E,!A),g,p,y),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,a,r,o){this.keyframeResolver=void 0;const{name:c,type:f,velocity:m,delay:g,isHandoff:p,onUpdate:y}=r;this.resolvedAt=yo.now(),MQ(t,c,f,m)||((Ku.instantAnimations||!g)&&y?.(ZO(t,r,a)),t[0]=t[t.length-1],r.duration=0,r.repeat=0);const E={startTime:o?this.resolvedAt?this.resolvedAt-this.createdAt>$Q?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:a,...r,keyframes:t},T=!p&&NQ(E)?new RQ({...E,element:E.motionValue.owner.current}):new QO(E);T.finished.then(()=>this.notifyFinished()).catch(Sl),this.pendingTimeline&&(this.stopTimeline=T.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=T}get finished(){return this._animation?this.animation.finished:this._finished}then(t,a){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),gQ()),this._animation}get duration(){return this.animation.duration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const jQ=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function LQ(e){const t=jQ.exec(e);if(!t)return[,];const[,a,r,o]=t;return[`--${a??r}`,o]}const VQ=4;function Lz(e,t,a=1){Zu(a<=VQ,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,o]=LQ(e);if(!r)return;const c=window.getComputedStyle(t).getPropertyValue(r);if(c){const f=c.trim();return k6(f)?parseFloat(f):f}return VO(o)?Lz(o,t,a+1):o}function lR(e,t){return e?.[t]??e?.default??e}const Vz=new Set(["width","height","top","left","right","bottom",...ep]),HQ={test:e=>e==="auto",parse:e=>e},Hz=e=>t=>t.test(e),Bz=[Km,on,Js,af,RK,OK,HQ],Pz=e=>Bz.find(Hz(e));function BQ(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||q6(e):!0}const PQ=new Set(["brightness","contrast","saturate","opacity"]);function UQ(e){const[t,a]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=a.match(HO)||[];if(!r)return e;const o=a.replace(r,"");let c=PQ.has(t)?1:0;return r!==a&&(c*=100),t+"("+c+o+")"}const IQ=/\b([a-z-]*)\(.*?\)/gu,sR={...rf,getAnimatableNone:e=>{const t=e.match(IQ);return t?t.map(UQ).join(" "):e}},Uz={...Km,transform:Math.round},uR={borderWidth:on,borderTopWidth:on,borderRightWidth:on,borderBottomWidth:on,borderLeftWidth:on,borderRadius:on,radius:on,borderTopLeftRadius:on,borderTopRightRadius:on,borderBottomRightRadius:on,borderBottomLeftRadius:on,width:on,maxWidth:on,height:on,maxHeight:on,top:on,right:on,bottom:on,left:on,padding:on,paddingTop:on,paddingRight:on,paddingBottom:on,paddingLeft:on,margin:on,marginTop:on,marginRight:on,marginBottom:on,marginLeft:on,backgroundPositionX:on,backgroundPositionY:on,...{rotate:af,rotateX:af,rotateY:af,rotateZ:af,scale:ox,scaleX:ox,scaleY:ox,scaleZ:ox,skew:af,skewX:af,skewY:af,distance:on,translateX:on,translateY:on,translateZ:on,x:on,y:on,z:on,perspective:on,transformPerspective:on,opacity:E0,originX:uz,originY:uz,originZ:on},zIndex:Uz,fillOpacity:E0,strokeOpacity:E0,numOctaves:Uz},kQ={...uR,color:xr,backgroundColor:xr,outlineColor:xr,fill:xr,stroke:xr,borderColor:xr,borderTopColor:xr,borderRightColor:xr,borderBottomColor:xr,borderLeftColor:xr,filter:sR,WebkitFilter:sR},Iz=e=>kQ[e];function kz(e,t){let a=Iz(e);return a!==sR&&(a=rf),a.getAnimatableNone?a.getAnimatableNone(t):void 0}const FQ=new Set(["auto","none","0"]);function qQ(e,t,a){let r=0,o;for(;r<e.length&&!o;){const c=e[r];typeof c=="string"&&!FQ.has(c)&&O0(c).values.length&&(o=e[r]),r++}if(o&&a)for(const c of t)e[c]=kz(a,o)}class GQ extends oR{constructor(t,a,r,o,c){super(t,a,r,o,c,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:a,name:r}=this;if(!a||!a.current)return;super.readKeyframes();for(let g=0;g<t.length;g++){let p=t[g];if(typeof p=="string"&&(p=p.trim(),VO(p))){const y=Lz(p,a.current);y!==void 0&&(t[g]=y),g===t.length-1&&(this.finalKeyframe=p)}}if(this.resolveNoneKeyframes(),!Vz.has(r)||t.length!==2)return;const[o,c]=t,f=Pz(o),m=Pz(c);if(f!==m)if(Oz(f)&&Oz(m))for(let g=0;g<t.length;g++){const p=t[g];typeof p=="string"&&(t[g]=parseFloat(p))}else Pd[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:a}=this,r=[];for(let o=0;o<t.length;o++)(t[o]===null||BQ(t[o]))&&r.push(o);r.length&&qQ(t,r,a)}measureInitialState(){const{element:t,unresolvedKeyframes:a,name:r}=this;if(!t||!t.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Pd[r](t.measureViewportBox(),window.getComputedStyle(t.current)),a[0]=this.measuredOrigin;const o=a[a.length-1];o!==void 0&&t.getValue(r,o).jump(o,!1)}measureEndState(){const{element:t,name:a,unresolvedKeyframes:r}=this;if(!t||!t.current)return;const o=t.getValue(a);o&&o.jump(this.measuredOrigin,!1);const c=r.length-1,f=r[c];r[c]=Pd[a](t.measureViewportBox(),window.getComputedStyle(t.current)),f!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=f),this.removedTransforms?.length&&this.removedTransforms.forEach(([m,g])=>{t.getValue(m).set(g)}),this.resolveNoneKeyframes()}}function XQ(e,t,a){if(e instanceof EventTarget)return[e];if(typeof e=="string"){let r=document;const o=a?.[e]??r.querySelectorAll(e);return o?Array.from(o):[]}return Array.from(e)}const Fz=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function qz(e){return F6(e)&&"offsetHeight"in e}var YQ={};const Gz=30,WQ=e=>!isNaN(parseFloat(e));class ZQ{constructor(t,a={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=(r,o=!0)=>{const c=yo.now();if(this.updatedAt!==c&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const f of this.dependents)f.dirty();o&&this.events.renderRequest?.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=a.owner}setCurrent(t){this.current=t,this.updatedAt=yo.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=WQ(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return YQ.NODE_ENV!=="production"&&NO(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",t)}on(t,a){this.events[t]||(this.events[t]=new DO);const r=this.events[t].add(a);return t==="change"?()=>{r(),Pa.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,a){this.passiveEffect=t,this.stopPassiveEffect=a}set(t,a=!0){!a||!this.passiveEffect?this.updateAndNotify(t,a):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,a,r){this.set(a),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,a=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,a&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=yo.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>Gz)return 0;const a=Math.min(this.updatedAt-this.prevUpdatedAt,Gz);return G6(parseFloat(this.current)-parseFloat(this.prevFrameValue),a)}start(t){return this.stop(),new Promise(a=>{this.hasAnimated=!0,this.animation=t(a),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function np(e,t){return new ZQ(e,t)}const{schedule:cR}=oz(queueMicrotask,!1),os={x:!1,y:!1};function Xz(){return os.x||os.y}function KQ(e){return e==="x"||e==="y"?os[e]?null:(os[e]=!0,()=>{os[e]=!1}):os.x||os.y?null:(os.x=os.y=!0,()=>{os.x=os.y=!1})}function Yz(e,t){const a=XQ(e),r=new AbortController,o={passive:!0,...t,signal:r.signal};return[a,o,()=>r.abort()]}function Wz(e){return!(e.pointerType==="touch"||Xz())}function QQ(e,t,a={}){const[r,o,c]=Yz(e,a),f=m=>{if(!Wz(m))return;const{target:g}=m,p=t(g,m);if(typeof p!="function"||!g)return;const y=S=>{Wz(S)&&(p(S),g.removeEventListener("pointerleave",y))};g.addEventListener("pointerleave",y,o)};return r.forEach(m=>{m.addEventListener("pointerenter",f,o)}),c}const Zz=(e,t)=>t?e===t?!0:Zz(e,t.parentElement):!1,fR=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,JQ=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function eJ(e){return JQ.has(e.tagName)||e.tabIndex!==-1}const cx=new WeakSet;function Kz(e){return t=>{t.key==="Enter"&&e(t)}}function dR(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const tJ=(e,t)=>{const a=e.currentTarget;if(!a)return;const r=Kz(()=>{if(cx.has(a))return;dR(a,"down");const o=Kz(()=>{dR(a,"up")}),c=()=>dR(a,"cancel");a.addEventListener("keyup",o,t),a.addEventListener("blur",c,t)});a.addEventListener("keydown",r,t),a.addEventListener("blur",()=>a.removeEventListener("keydown",r),t)};function Qz(e){return fR(e)&&!Xz()}function nJ(e,t,a={}){const[r,o,c]=Yz(e,a),f=m=>{const g=m.currentTarget;if(!Qz(m))return;cx.add(g);const p=t(g,m),y=(T,O)=>{window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",E),cx.has(g)&&cx.delete(g),Qz(T)&&typeof p=="function"&&p(T,{success:O})},S=T=>{y(T,g===window||g===document||a.useGlobalTarget||Zz(g,T.target))},E=T=>{y(T,!1)};window.addEventListener("pointerup",S,o),window.addEventListener("pointercancel",E,o)};return r.forEach(m=>{(a.useGlobalTarget?window:m).addEventListener("pointerdown",f,o),qz(m)&&(m.addEventListener("focus",p=>tJ(p,o)),!eJ(m)&&!m.hasAttribute("tabindex")&&(m.tabIndex=0))}),c}function Jz(e){return F6(e)&&"ownerSVGElement"in e}function aJ(e){return Jz(e)&&e.tagName==="svg"}const Ti=e=>!!(e&&e.getVelocity),rJ=[...Bz,xr,rf],iJ=e=>rJ.find(Hz(e)),hR=x.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class oJ extends x.Component{getSnapshotBeforeUpdate(t){const a=this.props.childRef.current;if(a&&t.isPresent&&!this.props.isPresent){const r=a.offsetParent,o=qz(r)&&r.offsetWidth||0,c=this.props.sizeRef.current;c.height=a.offsetHeight||0,c.width=a.offsetWidth||0,c.top=a.offsetTop,c.left=a.offsetLeft,c.right=o-c.width-c.left}return null}componentDidUpdate(){}render(){return this.props.children}}function lJ({children:e,isPresent:t,anchorX:a,root:r}){const o=x.useId(),c=x.useRef(null),f=x.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:m}=x.useContext(hR);return x.useInsertionEffect(()=>{const{width:g,height:p,top:y,left:S,right:E}=f.current;if(t||!c.current||!g||!p)return;const T=a==="left"?`left: ${S}`:`right: ${E}`;c.current.dataset.motionPopId=o;const O=document.createElement("style");m&&(O.nonce=m);const M=r??document.head;return M.appendChild(O),O.sheet&&O.sheet.insertRule(`
644
+ `,[t,a]}setOptions(t){if(this.options.container!==t.container){const a=this.parentFromOptionsContainer(t.container);a.appendChild(this.container),this.parent=a}t.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:a}=this.scrollContainer,r=a*t;this.setScroll(r)}destroy(){var t,a;this.subscriptions.forEach(r=>r()),this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(a=this.unsubscribeOnScroll)===null||a===void 0||a.forEach(r=>r()),this.unsubscribeOnScroll=[]}createDelay(t=10){let a,r;const o=()=>{a&&clearTimeout(a),r&&r()};return this.timeouts.push(o),()=>new Promise((c,f)=>{o(),r=f,a=setTimeout(()=>{a=void 0,r=void 0,c()},t)})}convertColorValues(t){if(!Array.isArray(t))return t||"";if(t.length<2)return t[0]||"";const a=document.createElement("canvas"),r=a.getContext("2d"),o=a.height*(window.devicePixelRatio||1),c=r.createLinearGradient(0,0,0,o),f=1/(t.length-1);return t.forEach((m,g)=>{const p=g*f;c.addColorStop(p,m)}),c}getPixelRatio(){return Math.max(1,window.devicePixelRatio||1)}renderBarWaveform(t,a,r,o){const c=t[0],f=t[1]||t[0],m=c.length,{width:g,height:p}=r.canvas,y=p/2,S=this.getPixelRatio(),E=a.barWidth?a.barWidth*S:1,T=a.barGap?a.barGap*S:a.barWidth?E/2:0,O=a.barRadius||0,M=g/(E+T)/m,A=O&&"roundRect"in r?"roundRect":"rect";r.beginPath();let D=0,_=0,j=0;for(let V=0;V<=m;V++){const $=Math.round(V*M);if($>D){const z=Math.round(_*y*o),U=z+Math.round(j*y*o)||1;let B=y-z;a.barAlign==="top"?B=0:a.barAlign==="bottom"&&(B=p-U),r[A](D*(E+T),B,E,U,O),D=$,_=0,j=0}const L=Math.abs(c[V]||0),H=Math.abs(f[V]||0);L>_&&(_=L),H>j&&(j=H)}r.fill(),r.closePath()}renderLineWaveform(t,a,r,o){const c=f=>{const m=t[f]||t[0],g=m.length,{height:p}=r.canvas,y=p/2,S=r.canvas.width/g;r.moveTo(0,y);let E=0,T=0;for(let O=0;O<=g;O++){const M=Math.round(O*S);if(M>E){const D=y+(Math.round(T*y*o)||1)*(f===0?-1:1);r.lineTo(E,D),E=M,T=0}const A=Math.abs(m[O]||0);A>T&&(T=A)}r.lineTo(E,y)};r.beginPath(),c(0),c(1),r.fill(),r.closePath()}renderWaveform(t,a,r){if(r.fillStyle=this.convertColorValues(a.waveColor),a.renderFunction)return void a.renderFunction(t,r);let o=a.barHeight||1;if(a.normalize){const c=Array.from(t[0]).reduce((f,m)=>Math.max(f,Math.abs(m)),0);o=c?1/c:1}a.barWidth||a.barGap||a.barAlign?this.renderBarWaveform(t,a,r,o):this.renderLineWaveform(t,a,r,o)}renderSingleCanvas(t,a,r,o,c,f,m){const g=this.getPixelRatio(),p=document.createElement("canvas");p.width=Math.round(r*g),p.height=Math.round(o*g),p.style.width=`${r}px`,p.style.height=`${o}px`,p.style.left=`${Math.round(c)}px`,f.appendChild(p);const y=p.getContext("2d");if(this.renderWaveform(t,a,y),p.width>0&&p.height>0){const S=p.cloneNode(),E=S.getContext("2d");E.drawImage(p,0,0),E.globalCompositeOperation="source-in",E.fillStyle=this.convertColorValues(a.progressColor),E.fillRect(0,0,p.width,p.height),m.appendChild(S)}}renderMultiCanvas(t,a,r,o,c,f){const m=this.getPixelRatio(),{clientWidth:g}=this.scrollContainer,p=r/m;let y=Math.min(Ym.MAX_CANVAS_WIDTH,g,p),S={};if(a.barWidth||a.barGap){const A=a.barWidth||.5,D=A+(a.barGap||A/2);y%D!=0&&(y=Math.floor(y/D)*D)}if(y===0)return;const E=A=>{if(A<0||A>=T||S[A])return;S[A]=!0;const D=A*y;let _=Math.min(p-D,y);if(a.barWidth||a.barGap){const V=a.barWidth||.5,$=V+(a.barGap||V/2);_=Math.floor(_/$)*$}if(_<=0)return;const j=t.map(V=>{const $=Math.floor(D/p*V.length),L=Math.floor((D+_)/p*V.length);return V.slice($,L)});this.renderSingleCanvas(j,a,_,o,D,c,f)},T=Math.ceil(p/y);if(!this.isScrollable){for(let A=0;A<T;A++)E(A);return}const O=this.scrollContainer.scrollLeft/p,M=Math.floor(O*T);if(E(M-1),E(M),E(M+1),T>1){const A=this.on("scroll",()=>{const{scrollLeft:D}=this.scrollContainer,_=Math.floor(D/p*T);Object.keys(S).length>Ym.MAX_NODES&&(c.innerHTML="",f.innerHTML="",S={}),E(_-1),E(_),E(_+1)});this.unsubscribeOnScroll.push(A)}}renderChannel(t,a,r,o){var{overlay:c}=a,f=function(y,S){var E={};for(var T in y)Object.prototype.hasOwnProperty.call(y,T)&&S.indexOf(T)<0&&(E[T]=y[T]);if(y!=null&&typeof Object.getOwnPropertySymbols=="function"){var O=0;for(T=Object.getOwnPropertySymbols(y);O<T.length;O++)S.indexOf(T[O])<0&&Object.prototype.propertyIsEnumerable.call(y,T[O])&&(E[T[O]]=y[T[O]])}return E}(a,["overlay"]);const m=document.createElement("div"),g=this.getHeight(f.height,f.splitChannels);m.style.height=`${g}px`,c&&o>0&&(m.style.marginTop=`-${g}px`),this.canvasWrapper.style.minHeight=`${g}px`,this.canvasWrapper.appendChild(m);const p=m.cloneNode();this.progressWrapper.appendChild(p),this.renderMultiCanvas(t,f,r,g,m,p)}render(t){return ii(this,void 0,void 0,function*(){var a;this.timeouts.forEach(g=>g()),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",this.options.width!=null&&(this.scrollContainer.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width);const r=this.getPixelRatio(),o=this.scrollContainer.clientWidth,c=Math.ceil(t.duration*(this.options.minPxPerSec||0));this.isScrollable=c>o;const f=this.options.fillParent&&!this.isScrollable,m=(f?o:c)*r;if(this.wrapper.style.width=f?"100%":`${c}px`,this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden",this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar),this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`,this.cursor.style.width=`${this.options.cursorWidth}px`,this.audioData=t,this.emit("render"),this.options.splitChannels)for(let g=0;g<t.numberOfChannels;g++){const p=Object.assign(Object.assign({},this.options),(a=this.options.splitChannels)===null||a===void 0?void 0:a[g]);this.renderChannel([t.getChannelData(g)],p,m,g)}else{const g=[t.getChannelData(0)];t.numberOfChannels>1&&g.push(t.getChannelData(1)),this.renderChannel(g,this.options,m,0)}Promise.resolve().then(()=>this.emit("rendered"))})}reRender(){if(this.unsubscribeOnScroll.forEach(r=>r()),this.unsubscribeOnScroll=[],!this.audioData)return;const{scrollWidth:t}=this.scrollContainer,{right:a}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:r}=this.progressWrapper.getBoundingClientRect();let o=r-a;o*=2,o=o<0?Math.floor(o):Math.ceil(o),o/=2,this.scrollContainer.scrollLeft+=o}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,a=!1){const{scrollLeft:r,scrollWidth:o,clientWidth:c}=this.scrollContainer,f=t*o,m=r,g=r+c,p=c/2;if(this.isDragging)f+30>g?this.scrollContainer.scrollLeft+=30:f-30<m&&(this.scrollContainer.scrollLeft-=30);else{(f<m||f>g)&&(this.scrollContainer.scrollLeft=f-(this.options.autoCenter?p:0));const y=f-r-p;a&&this.options.autoCenter&&y>0&&(this.scrollContainer.scrollLeft+=Math.min(y,10))}{const y=this.scrollContainer.scrollLeft,S=y/o,E=(y+c)/o;this.emit("scroll",S,E,y,y+c)}}renderProgress(t,a){if(isNaN(t))return;const r=100*t;this.canvasWrapper.style.clipPath=`polygon(${r}% 0%, 100% 0%, 100% 100%, ${r}% 100%)`,this.progressWrapper.style.width=`${r}%`,this.cursor.style.left=`${r}%`,this.cursor.style.transform=`translateX(-${Math.round(r)===100?this.options.cursorWidth:0}px)`,this.isScrollable&&this.options.autoScroll&&this.scrollIntoView(t,a)}exportImage(t,a,r){return ii(this,void 0,void 0,function*(){const o=this.canvasWrapper.querySelectorAll("canvas");if(!o.length)throw new Error("No waveform data");if(r==="dataURL"){const c=Array.from(o).map(f=>f.toDataURL(t,a));return Promise.resolve(c)}return Promise.all(Array.from(o).map(c=>new Promise((f,m)=>{c.toBlob(g=>{g?f(g):m(new Error("Could not export image"))},t,a)})))})}}Ym.MAX_CANVAS_WIDTH=8e3,Ym.MAX_NODES=10;class WZ extends b0{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}class CO extends b0{constructor(t=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this._playbackRate=1,this._duration=void 0,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.autoplay=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=t,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return ii(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(a=>{if(a.status>=400)throw new Error(`Failed to fetch ${t}: ${a.status} (${a.statusText})`);return a.arrayBuffer()}).then(a=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(a)).then(a=>{this.currentSrc===t&&(this.buffer=a,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())})}_play(){var t;if(!this.paused)return;this.paused=!1,(t=this.bufferNode)===null||t===void 0||t.disconnect(),this.bufferNode=this.audioContext.createBufferSource(),this.buffer&&(this.bufferNode.buffer=this.buffer),this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let a=this.playedDuration*this._playbackRate;(a>=this.duration||a<0)&&(a=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,a),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,(t=this.bufferNode)===null||t===void 0||t.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime}play(){return ii(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){const a=t-this.currentTime,r=this.bufferNode;r?.stop(this.audioContext.currentTime+a),r?.addEventListener("ended",()=>{r===this.bufferNode&&(this.bufferNode=null,this.pause())},{once:!0})}setSinkId(t){return ii(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return(this.paused?this.playedDuration:this.playedDuration+(this.audioContext.currentTime-this.playStartTime))*this._playbackRate}set currentTime(t){const a=!this.paused;a&&this._pause(),this.playedDuration=t/this._playbackRate,a&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,a;return(t=this._duration)!==null&&t!==void 0?t:((a=this.buffer)===null||a===void 0?void 0:a.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const a=this.buffer.numberOfChannels;for(let r=0;r<a;r++)t.push(this.buffer.getChannelData(r));return t}}const ZZ={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class Wm extends YZ{static create(t){return new Wm(t)}constructor(t){const a=t.media||(t.backend==="WebAudio"?new CO:void 0);super({media:a,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate}),this.plugins=[],this.decodedData=null,this.stopAtPosition=null,this.subscriptions=[],this.mediaSubscriptions=[],this.abortController=null,this.options=Object.assign({},ZZ,t),this.timer=new WZ;const r=a?void 0:this.getMediaElement();this.renderer=new Ym(this.options,r),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initPlugins();const o=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");const{peaks:c,duration:f}=this.options;(o||c&&f)&&this.load(o,c,f).catch(()=>null)})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t),this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition&&this.pause()}}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{const t=this.updateProgress();this.emit("timeupdate",t)}),this.onMediaEvent("play",()=>{this.emit("play"),this.timer.start()}),this.onMediaEvent("pause",()=>{this.emit("pause"),this.timer.stop(),this.stopAtPosition=null}),this.onMediaEvent("emptied",()=>{this.timer.stop(),this.stopAtPosition=null}),this.onMediaEvent("ended",()=>{this.emit("timeupdate",this.getDuration()),this.emit("finish"),this.stopAtPosition=null}),this.onMediaEvent("seeking",()=>{this.emit("seeking",this.getCurrentTime())}),this.onMediaEvent("error",()=>{var t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error")),this.stopAtPosition=null}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(t,a)=>{this.options.interact&&(this.seekTo(t),this.emit("interaction",t*this.getDuration()),this.emit("click",t,a))}),this.renderer.on("dblclick",(t,a)=>{this.emit("dblclick",t,a)}),this.renderer.on("scroll",(t,a,r,o)=>{const c=this.getDuration();this.emit("scroll",t*c,a*c,r,o)}),this.renderer.on("render",()=>{this.emit("redraw")}),this.renderer.on("rendered",()=>{this.emit("redrawcomplete")}),this.renderer.on("dragstart",t=>{this.emit("dragstart",t)}),this.renderer.on("dragend",t=>{this.emit("dragend",t)}));{let t;this.subscriptions.push(this.renderer.on("drag",a=>{if(!this.options.interact)return;let r;this.renderer.renderProgress(a),clearTimeout(t),this.isPlaying()?r=0:this.options.dragToSeek===!0?r=200:typeof this.options.dragToSeek=="object"&&this.options.dragToSeek!==void 0&&(r=this.options.dragToSeek.debounceTime),t=setTimeout(()=>{this.seekTo(a)},r),this.emit("interaction",a*this.getDuration()),this.emit("drag",a)}))}}initPlugins(){var t;!((t=this.options.plugins)===null||t===void 0)&&t.length&&this.options.plugins.forEach(a=>{this.registerPlugin(a)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(t=>t()),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),t.duration&&!t.peaks&&(this.decodedData=tx.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=tx.createBuffer(t.peaks,t.duration)),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),t.mediaControls!=null&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){t._init(this),this.plugins.push(t);const a=t.once("destroy",()=>{this.plugins=this.plugins.filter(r=>r!==t),this.subscriptions=this.subscriptions.filter(r=>r!==a)});return this.subscriptions.push(a),t}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const a=t/this.getDuration();this.renderer.setScrollPercentage(a)}getActivePlugins(){return this.plugins}loadAudio(t,a,r,o){return ii(this,void 0,void 0,function*(){var c;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,this.stopAtPosition=null,!a&&!r){const m=this.options.fetchParams||{};window.AbortController&&!m.signal&&(this.abortController=new AbortController,m.signal=(c=this.abortController)===null||c===void 0?void 0:c.signal);const g=y=>this.emit("loading",y);a=yield XZ.fetchBlob(t,g,m);const p=this.options.blobMimeType;p&&(a=new Blob([a],{type:p}))}this.setSrc(t,a);const f=yield new Promise(m=>{const g=o||this.getDuration();g?m(g):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>m(this.getDuration()),{once:!0}))});if(!t&&!a){const m=this.getMediaElement();m instanceof CO&&(m.duration=f)}if(r)this.decodedData=tx.createBuffer(r,f||0);else if(a){const m=yield a.arrayBuffer();this.decodedData=yield tx.decode(m,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,a,r){return ii(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,a,r)}catch(o){throw this.emit("error",o),o}})}loadBlob(t,a,r){return ii(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,a,r)}catch(o){throw this.emit("error",o),o}})}zoom(t){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(t),this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:a=8e3,precision:r=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const o=Math.min(t,this.decodedData.numberOfChannels),c=[];for(let f=0;f<o;f++){const m=this.decodedData.getChannelData(f),g=[],p=m.length/a;for(let y=0;y<a;y++){const S=m.slice(Math.floor(y*p),Math.ceil((y+1)*p));let E=0;for(let T=0;T<S.length;T++){const O=S[T];Math.abs(O)>Math.abs(E)&&(E=O)}g.push(Math.round(E*r)/r)}c.push(g)}return c}getDuration(){let t=super.getDuration()||0;return t!==0&&t!==1/0||!this.decodedData||(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null,super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const a=this.getDuration()*t;this.setTime(a)}play(t,a){const r=Object.create(null,{play:{get:()=>super.play}});return ii(this,void 0,void 0,function*(){t!=null&&this.setTime(t);const o=yield r.play.call(this);return a!=null&&(this.media instanceof CO?this.media.stopAt(a):this.stopAtPosition=a),o})}playPause(){return ii(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return ii(this,arguments,void 0,function*(t="image/png",a=1,r="dataURL"){return this.renderer.exportImage(t,a,r)})}destroy(){var t;this.emit("destroy"),(t=this.abortController)===null||t===void 0||t.abort(),this.plugins.forEach(a=>a.destroy()),this.subscriptions.forEach(a=>a()),this.unsubscribePlayerEvents(),this.timer.destroy(),this.renderer.destroy(),super.destroy()}}Wm.BasePlugin=class extends b0{constructor(e){super(),this.subscriptions=[],this.options=e}onInit(){}_init(e){this.wavesurfer=e,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(e=>e())}},Wm.dom=GZ;const KZ=({userMessage:e,setUserMessage:t,handleSendMessage:a,handleSendImage:r,handleSendVoice:o,selectedImage:c,setSelectedImage:f,audioBlob:m,setAudioBlob:g,isSending:p})=>{const{t:y}=jZ(),[S,E]=x.useState(!1),[T,O]=x.useState(!1),M=x.useRef(null),A=x.useRef(null),D=x.useRef([]),_=x.useRef(null),j=x.useRef(null),V=U=>{const B=U.target.files?.[0];B&&f(B)},$=()=>{f(null)},L=async()=>{if(!navigator.mediaDevices?.getUserMedia){alert(y("chatInput.voice.notSupported"));return}if(S)M.current?.stop();else try{const U=await navigator.mediaDevices.getUserMedia({audio:!0}),B=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",J=new MediaRecorder(U,{mimeType:B});M.current=J,D.current=[],J.ondataavailable=X=>{X.data.size>0&&D.current.push(X.data)},J.onstop=()=>{const X=new Blob(D.current,{type:B});g(X),E(!1),U.getTracks().forEach(W=>W.stop())},J.start(),E(!0)}catch(U){console.error(U),alert(y("chatInput.voice.permissionError"))}};x.useEffect(()=>{if(m&&_.current){j.current?.destroy();const U=URL.createObjectURL(m);j.current=Wm.create({container:_.current,waveColor:"#ccc",progressColor:"#7F28F8",cursorWidth:0,barWidth:3,barHeight:1.5,barGap:2,height:40,interact:!0}),j.current.load(U),j.current.on("finish",()=>O(!1))}},[m]);const H=()=>{j.current&&(j.current.playPause(),O(U=>!U))},z=()=>{E(!1),g(null),j.current?.destroy()};return ae.jsxs("div",{style:{display:"flex",alignItems:"center",backgroundColor:"white",border:"1px solid #d1d5db",borderRadius:"9999px",padding:"0.5rem 0.75rem",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",width:"95%",height:"56px"},children:[ae.jsx("button",{style:{color:"#6b7280",background:"none",border:"none",margin:"0 0.5rem",cursor:"pointer",padding:"0"},onClick:()=>A.current?.click(),children:c?ae.jsxs("div",{style:{position:"relative"},children:[ae.jsx("img",{src:URL.createObjectURL(c),alt:y("chatInput.image.selectedAlt"),style:{width:"2rem",height:"2rem",borderRadius:"9999px",objectFit:"cover",padding:"0"}}),ae.jsx(c0,{style:{position:"absolute",top:"-0.5rem",right:"-0.5rem",fontSize:"14px",color:"#ef4444",background:"white",borderRadius:"9999px",cursor:"pointer"},onClick:U=>{U.stopPropagation(),$()}})]}):ae.jsx(p4,{style:{fontSize:"20px"}})}),ae.jsx("input",{disabled:p,type:"file",accept:"image/*",ref:A,onChange:V,style:{display:"none",padding:"0"}}),ae.jsx(Nd,{title:S?"Stop Recording":"Send Audio",children:ae.jsx("button",{onClick:L,style:{color:S?"#ef4444":"#6b7280",background:"none",border:"none",margin:"0 0.5rem",cursor:"pointer",padding:"0"},children:S?ae.jsx(y4,{style:{fontSize:"20px"}}):ae.jsx(f4,{style:{fontSize:"20px"}})})}),ae.jsx("div",{style:{flex:1,margin:"0 0.5rem",minWidth:0,maxWidth:"100%",display:"flex",alignItems:"center"},children:m?ae.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",backgroundColor:"#f3f4f6",padding:"0.5rem 1rem",borderRadius:"0.5rem"},children:[ae.jsx("button",{style:{background:"none",border:"none",marginRight:"0.75rem",color:"#7f28f8",cursor:"pointer",padding:"0"},onClick:H,children:T?ae.jsx(GT,{style:{fontSize:"24px"}}):ae.jsx(XT,{style:{fontSize:"24px"}})}),ae.jsx("div",{ref:_,style:{width:"100%",height:"2rem"}}),ae.jsx(c0,{style:{fontSize:"18px",color:"#ef4444",marginLeft:"0.75rem",cursor:"pointer"},onClick:z})]}):S?ae.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f3f4f6",padding:"0.5rem 1rem",borderRadius:"0.5rem",animation:"pulse 2s infinite"},children:ae.jsx("span",{children:"Recording"})}):ae.jsx(Yu,{type:"text",value:e,onChange:U=>t(U.target.value),placeholder:"Message...",style:{width:"100%",border:"none",fontSize:"16px",margin:0,lineHeight:1.5,color:"#374151",padding:"0"},onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),c?(r(c,e),$(),t("")):e.trim()&&(a(),t("")))}})}),ae.jsx("button",{disabled:p,onClick:()=>{const U=!!c,B=!!e.trim();U?(r(c,e),$(),t("")):!!m?(o(m),z()):B&&a()},"aria-label":y("chatInput.send"),style:{color:"#6b7280",background:"none",border:"none",margin:"0 0.5rem",cursor:"pointer",padding:"0"},children:ae.jsx(g4,{style:{fontSize:"20px"}})})]})};function QZ({suggestions:e,colorCode:t,sendMessageSuggestion:a}){return ae.jsx("div",{style:{overflowX:"auto",overflowY:"hidden",whiteSpace:"nowrap",paddingTop:"4px",paddingBottom:"8px",width:"100%",boxSizing:"border-box",marginLeft:"4%",marginTop:"4px",marginBottom:"4px"},children:ae.jsx("div",{style:{display:"inline-flex",gap:"0.5rem"},children:e?.map((r,o)=>ae.jsx("button",{onClick:()=>a(r),style:{whiteSpace:"nowrap",padding:"0.5rem 1rem",border:`1px solid ${t}`,borderRadius:"9999px",backgroundColor:"white",cursor:"pointer",fontSize:"14px",color:t,flexShrink:0},onMouseEnter:c=>{c.currentTarget.style.backgroundColor="#f3f3f3"},onMouseLeave:c=>{c.currentTarget.style.backgroundColor="white"},children:r},o))})})}function JZ(){return ae.jsxs("div",{className:"jawebcss-powered-container",children:[ae.jsx("span",{className:"jawebcss-powered-label",children:"Powered by"}),ae.jsx("a",{href:"https://jaweb.me/",target:"_blank",className:"jawebcss-powered-link",rel:"noopener noreferrer",children:"Jaweb"})]})}const eK=()=>ae.jsxs("div",{className:"typing-animation",children:[ae.jsx("span",{children:"."}),ae.jsx("span",{children:"."}),ae.jsx("span",{children:"."})]}),tK=({groupedProducts:e,selectedVariants:t,setSelectedVariants:a,counts:r,setCounts:o,handleAddToCart:c,handleRemoveFromCart:f,colorCode:m="#7F28F8",shortenName:g,sliderRef:p,totalSlides:y})=>y===0?null:ae.jsx("div",{className:"relative w-full",children:ae.jsx("div",{ref:p,className:"keen-slider w-full relative ",children:Object.entries(e).map(([S,E])=>{const T=t[S]||E[0].variant_id,O=E.find(L=>L.variant_id===T)||E[0],M=r[O.variant_id]||0,A=Array.from(new Set(E.map(L=>L.color?.trim()||"").filter(L=>L&&L.toLowerCase()!=="none"))),D=Array.from(new Set(E.map(L=>L.size?.trim()||"").filter(L=>L&&L.toLowerCase()!=="none"))),_=(L,H)=>E.some(z=>z.color===L&&z.size===H),j=(L,H)=>{const z=E.find(U=>(!L||U.color===L)&&(!H||U.size===H));z&&a(U=>({...U,[S]:z.variant_id}))},V=async()=>{o(L=>({...L,[O.variant_id]:(L[O.variant_id]||0)+1})),await c(O.variant_id,O.name,1)},$=async()=>{M!==0&&(o(L=>({...L,[O.variant_id]:L[O.variant_id]-1})),await f(O.variant_id,1))};return ae.jsx("div",{className:"keen-slider__slide",children:ae.jsxs("div",{className:"product-card",children:[ae.jsx("div",{className:"product-image-container",children:ae.jsx("img",{src:O.image,alt:O.name,className:"product-image",onClick:()=>window.open(O.link,"_blank")})}),ae.jsxs("div",{className:"product-details",children:[ae.jsx("a",{href:O.link,target:"_blank",rel:"noopener noreferrer",className:"product-name",children:g(O.name)}),ae.jsx("p",{className:"product-price",children:O.price}),A.length>0&&ae.jsxs("div",{children:[ae.jsx("p",{className:"label",children:"Color:"}),ae.jsx("div",{className:"color-options",children:A.map(L=>{const H=!_(L,O.size),z=L===O.color;return ae.jsx("button",{disabled:H,onClick:()=>j(L,O.size),className:`color-button ${z?"active":""} ${H?"disabled":""}`,style:z?{backgroundColor:m,color:"#fff"}:{},children:L==="None"?"One Color":L},L)})})]}),D.length>0&&ae.jsxs("div",{children:[ae.jsx("p",{className:"label",children:"Size:"}),ae.jsx("div",{className:"size-options",children:D.map(L=>{const H=!_(O.color,L),z=L===O.size;return ae.jsx("button",{disabled:H,onClick:()=>j(O.color,L),className:`size-button ${z?"active":""} ${H?"disabled":""}`,style:z?{backgroundColor:m,color:"#fff"}:{},children:L==="None"?"One size":L},L)})})]}),ae.jsxs("div",{className:"cart-controls",children:[ae.jsx("button",{onClick:$,className:"cart-button",children:"–"}),ae.jsx("span",{className:"cart-count",children:M}),ae.jsx("button",{onClick:V,className:"cart-button increment",style:{backgroundColor:m,color:"#fff"},children:"+"})]})]})]})},S)})})});var nx={},P6;function nK(){if(P6)return nx;P6=1,Object.defineProperty(nx,"__esModule",{value:!0});var e=Ed();function t(z){return Array.prototype.slice.call(z)}function a(z,U){var B=Math.floor(z);return B===U||B+1===U?z:U}function r(){return Date.now()}function o(z,U,B){if(U="data-keen-slider-"+U,B===null)return z.removeAttribute(U);z.setAttribute(U,B||"")}function c(z,U){return U=U||document,typeof z=="function"&&(z=z(U)),Array.isArray(z)?z:typeof z=="string"?t(U.querySelectorAll(z)):z instanceof HTMLElement?[z]:z instanceof NodeList?t(z):[]}function f(z){z.raw&&(z=z.raw),z.cancelable&&!z.defaultPrevented&&z.preventDefault()}function m(z){z.raw&&(z=z.raw),z.stopPropagation&&z.stopPropagation()}function g(){var z=[];return{add:function(U,B,J,X){U.addListener?U.addListener(J):U.addEventListener(B,J,X),z.push([U,B,J,X])},input:function(U,B,J,X){this.add(U,B,function(W){return function(K){K.nativeEvent&&(K=K.nativeEvent);var re=K.changedTouches||[],F=K.targetTouches||[],G=K.detail&&K.detail.x?K.detail:null;return W({id:G?G.identifier?G.identifier:"i":F[0]?F[0]?F[0].identifier:"e":"d",idChanged:G?G.identifier?G.identifier:"i":re[0]?re[0]?re[0].identifier:"e":"d",raw:K,x:G&&G.x?G.x:F[0]?F[0].screenX:G?G.x:K.pageX,y:G&&G.y?G.y:F[0]?F[0].screenY:G?G.y:K.pageY})}}(J),X)},purge:function(){z.forEach(function(U){U[0].removeListener?U[0].removeListener(U[2]):U[0].removeEventListener(U[1],U[2],U[3])}),z=[]}}}function p(z,U,B){return Math.min(Math.max(z,U),B)}function y(z){return(z>0?1:0)-(z<0?1:0)||+z}function S(z){var U=z.getBoundingClientRect();return{height:a(U.height,z.offsetHeight),width:a(U.width,z.offsetWidth)}}function E(z,U,B,J){var X=z&&z[U];return X==null?B:J&&typeof X=="function"?X():X}function T(z){return Math.round(1e6*z)/1e6}function O(z,U){if(z===U)return!0;var B=typeof z;if(B!==typeof U)return!1;if(B!=="object"||z===null||U===null)return B==="function"&&z.toString()===U.toString();if(z.length!==U.length||Object.getOwnPropertyNames(z).length!==Object.getOwnPropertyNames(U).length)return!1;for(var J in z)if(!O(z[J],U[J]))return!1;return!0}var M=function(){return M=Object.assign||function(z){for(var U,B=1,J=arguments.length;B<J;B++)for(var X in U=arguments[B])Object.prototype.hasOwnProperty.call(U,X)&&(z[X]=U[X]);return z},M.apply(this,arguments)};function A(z,U,B){for(var J,X=0,W=U.length;X<W;X++)!J&&X in U||(J||(J=Array.prototype.slice.call(U,0,X)),J[X]=U[X]);return z.concat(J||Array.prototype.slice.call(U))}function D(z){var U,B,J,X,W,K;function re(k){K||(K=k),F(!0);var q=k-K;q>J&&(q=J);var ee=X[B];if(ee[3]<q)return B++,re(k);var ne=ee[2],oe=ee[4],le=ee[0],ce=ee[1]*(0,ee[5])(oe===0?1:(q-ne)/oe);if(ce&&z.track.to(le+ce),q<J)return Z();K=null,F(!1),G(null),z.emit("animationEnded")}function F(k){U.active=k}function G(k){U.targetIdx=k}function Z(){var k;k=re,W=window.requestAnimationFrame(k)}function se(){var k;k=W,window.cancelAnimationFrame(k),F(!1),G(null),K&&z.emit("animationStopped"),K=null}return U={active:!1,start:function(k){if(se(),z.track.details){var q=0,ee=z.track.details.position;B=0,J=0,X=k.map(function(ne){var oe,le=Number(ee),ce=(oe=ne.earlyExit)!==null&&oe!==void 0?oe:ne.duration,Ce=ne.easing,ze=ne.distance*Ce(ce/ne.duration)||0;ee+=ze;var $e=J;return J+=ce,q+=ze,[le,ne.distance,$e,J,ne.duration,Ce]}),G(z.track.distToIdx(q)),Z(),z.emit("animationStarted")}},stop:se,targetIdx:null}}function _(z){var U,B,J,X,W,K,re,F,G,Z,se,k,q,ee,ne=1/0,oe=[],le=null,ce=0;function Ce(Ee){we(ce+Ee)}function ze(Ee){var Te=$e(ce+Ee).abs;return ue(Te)?Te:null}function $e(Ee){var Te=Math.floor(Math.abs(T(Ee/B))),Ae=T((Ee%B+B)%B);Ae===B&&(Ae=0);var De=y(Ee),Ue=re.indexOf(A([],re).reduce(function(Le,it){return Math.abs(it-Ae)<Math.abs(Le-Ae)?it:Le})),Fe=Ue;return De<0&&Te++,Ue===K&&(Fe=0,Te+=De>0?1:-1),{abs:Fe+Te*K*De,origin:Ue,rel:Fe}}function ke(Ee,Te,Ae){var De;if(Te||!Ie())return ge(Ee,Ae);if(!ue(Ee))return null;var Ue=$e(Ae??ce),Fe=Ue.abs,Le=Ee-Ue.rel,it=Fe+Le;De=ge(it);var ut=ge(it-K*y(Le));return(ut!==null&&Math.abs(ut)<Math.abs(De)||De===null)&&(De=ut),T(De)}function ge(Ee,Te){if(Te==null&&(Te=T(ce)),!ue(Ee)||Ee===null)return null;Ee=Math.round(Ee);var Ae=$e(Te),De=Ae.abs,Ue=Ae.rel,Fe=Ae.origin,Le=ve(Ee),it=(Te%B+B)%B,ut=re[Fe],vt=Math.floor((Ee-(De-Ue))/K)*B;return T(ut-it-ut+re[Le]+vt+(Fe===K?B:0))}function ue(Ee){return Re(Ee)===Ee}function Re(Ee){return p(Ee,G,Z)}function Ie(){return X.loop}function ve(Ee){return(Ee%K+K)%K}function we(Ee){var Te;Te=Ee-ce,oe.push({distance:Te,timestamp:r()}),oe.length>6&&(oe=oe.slice(-6)),ce=T(Ee);var Ae=be().abs;if(Ae!==le){var De=le!==null;le=Ae,De&&z.emit("slideChanged")}}function be(Ee){var Te=Ee?null:function(){if(K){var Ae=Ie(),De=Ae?(ce%B+B)%B:ce,Ue=(Ae?ce%B:ce)-W[0][2],Fe=0-(Ue<0&&Ae?B-Math.abs(Ue):Ue),Le=0,it=$e(ce),ut=it.abs,vt=it.rel,At=W[vt][2],ht=W.map(function(jt,Vt){var _t=Fe+Le;(_t<0-jt[0]||_t>1)&&(_t+=(Math.abs(_t)>B-1&&Ae?B:0)*y(-_t));var Tt=Vt-vt,ct=y(Tt),gt=Tt+ut;Ae&&(ct===-1&&_t>At&&(gt+=K),ct===1&&_t<At&&(gt-=K),se!==null&&gt<se&&(_t+=B),k!==null&&gt>k&&(_t-=B));var at=_t+jt[0]+jt[1],lt=Math.max(_t>=0&&at<=1?1:at<0||_t>1?0:_t<0?Math.min(1,(jt[0]+_t)/jt[0]):(1-_t)/jt[0],0);return Le+=jt[0]+jt[1],{abs:gt,distance:X.rtl?-1*_t+1-jt[0]:_t,portion:lt,size:jt[0]}});return ut=Re(ut),vt=ve(ut),{abs:Re(ut),length:J,max:ee,maxIdx:Z,min:q,minIdx:G,position:ce,progress:Ae?De/B:ce/J,rel:vt,slides:ht,slidesLength:B}}}();return U.details=Te,z.emit("detailsChanged"),Te}return U={absToRel:ve,add:Ce,details:null,distToIdx:ze,idxToDist:ke,init:function(Ee){if(function(){if(X=z.options,W=(X.trackConfig||[]).map(function(Ue){return[E(Ue,"size",1),E(Ue,"spacing",0),E(Ue,"origin",0)]}),K=W.length){B=T(W.reduce(function(Ue,Fe){return Ue+Fe[0]+Fe[1]},0));var Ae,De=K-1;J=T(B+W[0][2]-W[De][0]-W[De][2]-W[De][1]),re=W.reduce(function(Ue,Fe){if(!Ue)return[0];var Le=W[Ue.length-1],it=Ue[Ue.length-1]+(Le[0]+Le[2])+Le[1];return it-=Fe[2],Ue[Ue.length-1]>it&&(it=Ue[Ue.length-1]),it=T(it),Ue.push(it),(!Ae||Ae<it)&&(F=Ue.length-1),Ae=it,Ue},null),J===0&&(F=0),re.push(T(B))}}(),!K)return be(!0);var Te;(function(){var Ae=z.options.range,De=z.options.loop;se=G=De?E(De,"min",-1/0):0,k=Z=De?E(De,"max",ne):F;var Ue=E(Ae,"min",null),Fe=E(Ae,"max",null);Ue!==null&&(G=Ue),Fe!==null&&(Z=Fe),q=G===-1/0?G:z.track.idxToDist(G||0,!0,0),ee=Z===ne?Z:ke(Z,!0,0),Fe===null&&(k=Z),E(Ae,"align",!1)&&Z!==ne&&W[ve(Z)][2]===0&&(ee-=1-W[ve(Z)][0],Z=ze(ee-ce)),q=T(q),ee=T(ee)})(),Te=Ee,Number(Te)===Te?Ce(ge(Re(Ee))):be()},to:we,velocity:function(){var Ee=r(),Te=oe.reduce(function(Ae,De){var Ue=De.distance,Fe=De.timestamp;return Ee-Fe>200||(y(Ue)!==y(Ae.distance)&&Ae.distance&&(Ae={distance:0,lastTimestamp:0,time:0}),Ae.time&&(Ae.distance+=Ue),Ae.lastTimestamp&&(Ae.time+=Fe-Ae.lastTimestamp),Ae.lastTimestamp=Fe),Ae},{distance:0,lastTimestamp:0,time:0});return Te.distance/Te.time||0}}}function j(z){var U,B,J,X,W,K,re,F;function G(le){return 2*le}function Z(le){return p(le,re,F)}function se(le){return 1-Math.pow(1-le,3)}function k(){return J?z.track.velocity():0}function q(){oe();var le=z.options.mode==="free-snap",ce=z.track,Ce=k();X=y(Ce);var ze=z.track.details,$e=[];if(Ce||!le){var ke=ee(Ce),ge=ke.dist,ue=ke.dur;if(ue=G(ue),ge*=X,le){var Re=ce.idxToDist(ce.distToIdx(ge),!0);Re&&(ge=Re)}$e.push({distance:ge,duration:ue,easing:se});var Ie=ze.position,ve=Ie+ge;if(ve<W||ve>K){var we=ve<W?W-Ie:K-Ie,be=0,Ee=Ce;if(y(we)===X){var Te=Math.min(Math.abs(we)/Math.abs(ge),1),Ae=function(Fe){return 1-Math.pow(1-Fe,1/3)}(Te)*ue;$e[0].earlyExit=Ae,Ee=Ce*(1-Te)}else $e[0].earlyExit=0,be+=we;var De=ee(Ee,100),Ue=De.dist*X;z.options.rubberband&&($e.push({distance:Ue,duration:G(De.dur),easing:se}),$e.push({distance:-Ue+be,duration:500,easing:se}))}z.animator.start($e)}else z.moveToIdx(Z(ze.abs),!0,{duration:500,easing:function(Fe){return 1+--Fe*Fe*Fe*Fe*Fe}})}function ee(le,ce){ce===void 0&&(ce=1e3);var Ce=147e-9+(le=Math.abs(le))/ce;return{dist:Math.pow(le,2)/Ce,dur:le/Ce}}function ne(){var le=z.track.details;le&&(W=le.min,K=le.max,re=le.minIdx,F=le.maxIdx)}function oe(){z.animator.stop()}z.on("updated",ne),z.on("optionsChanged",ne),z.on("created",ne),z.on("dragStarted",function(){J=!1,oe(),U=B=z.track.details.abs}),z.on("dragChecked",function(){J=!0}),z.on("dragEnded",function(){var le=z.options.mode;le==="snap"&&function(){var ce=z.track,Ce=z.track.details,ze=Ce.position,$e=y(k());(ze>K||ze<W)&&($e=0);var ke=U+$e;Ce.slides[ce.absToRel(ke)].portion===0&&(ke-=$e),U!==B&&(ke=B),y(ce.idxToDist(ke,!0))!==$e&&(ke+=$e),ke=Z(ke);var ge=ce.idxToDist(ke,!0);z.animator.start([{distance:ge,duration:500,easing:function(ue){return 1+--ue*ue*ue*ue*ue}}])}(),le!=="free"&&le!=="free-snap"||q()}),z.on("dragged",function(){B=z.track.details.abs})}function V(z){var U,B,J,X,W,K,re,F,G,Z,se,k,q,ee,ne,oe,le,ce,Ce=g();function ze(be){if(K&&F===be.id){var Ee=ue(be);if(G){if(!ge(be))return ke(be);Z=Ee,G=!1,z.emit("dragChecked")}if(oe)return Z=Ee;f(be);var Te=function(De){if(le===-1/0&&ce===1/0)return De;var Ue=z.track.details,Fe=Ue.length,Le=Ue.position,it=p(De,le-Le,ce-Le);if(Fe===0)return 0;if(!z.options.rubberband)return it;if(Le<=ce&&Le>=le||Le<le&&B>0||Le>ce&&B<0)return De;var ut=(Le<le?Le-le:Le-ce)/Fe,vt=X*Fe,At=Math.abs(ut*vt),ht=Math.max(0,1-At/W*2);return ht*ht*De}(re(Z-Ee)/X*J);B=y(Te);var Ae=z.track.details.position;(Ae>le&&Ae<ce||Ae===le&&B>0||Ae===ce&&B<0)&&m(be),se+=Te,!k&&Math.abs(se*X)>5&&(k=!0),z.track.add(Te),Z=Ee,z.emit("dragged")}}function $e(be){!K&&z.track.details&&z.track.details.length&&(se=0,K=!0,k=!1,G=!0,F=be.id,ge(be),Z=ue(be),z.emit("dragStarted"))}function ke(be){K&&F===be.idChanged&&(K=!1,z.emit("dragEnded"))}function ge(be){var Ee=Re(),Te=Ee?be.y:be.x,Ae=Ee?be.x:be.y,De=q!==void 0&&ee!==void 0&&Math.abs(ee-Ae)<=Math.abs(q-Te);return q=Te,ee=Ae,De}function ue(be){return Re()?be.y:be.x}function Re(){return z.options.vertical}function Ie(){X=z.size,W=Re()?window.innerHeight:window.innerWidth;var be=z.track.details;be&&(le=be.min,ce=be.max)}function ve(be){k&&(m(be),f(be))}function we(){if(Ce.purge(),z.options.drag&&!z.options.disabled){var be;be=z.options.dragSpeed||1,re=typeof be=="function"?be:function(Te){return Te*be},J=z.options.rtl?-1:1,Ie(),U=z.container,function(){var Te="data-keen-slider-clickable";c("[".concat(Te,"]:not([").concat(Te,"=false])"),U).map(function(Ae){Ce.add(Ae,"dragstart",m),Ce.add(Ae,"mousedown",m),Ce.add(Ae,"touchstart",m)})}(),Ce.add(U,"dragstart",function(Te){f(Te)}),Ce.add(U,"click",ve,{capture:!0}),Ce.input(U,"ksDragStart",$e),Ce.input(U,"ksDrag",ze),Ce.input(U,"ksDragEnd",ke),Ce.input(U,"mousedown",$e),Ce.input(U,"mousemove",ze),Ce.input(U,"mouseleave",ke),Ce.input(U,"mouseup",ke),Ce.input(U,"touchstart",$e,{passive:!0}),Ce.input(U,"touchmove",ze,{passive:!1}),Ce.input(U,"touchend",ke),Ce.input(U,"touchcancel",ke),Ce.add(window,"wheel",function(Te){K&&f(Te)});var Ee="data-keen-slider-scrollable";c("[".concat(Ee,"]:not([").concat(Ee,"=false])"),z.container).map(function(Te){return function(Ae){var De;Ce.input(Ae,"touchstart",function(Ue){De=ue(Ue),oe=!0,ne=!0},{passive:!0}),Ce.input(Ae,"touchmove",function(Ue){var Fe=Re(),Le=Fe?Ae.scrollHeight-Ae.clientHeight:Ae.scrollWidth-Ae.clientWidth,it=De-ue(Ue),ut=Fe?Ae.scrollTop:Ae.scrollLeft,vt=Fe&&Ae.style.overflowY==="scroll"||!Fe&&Ae.style.overflowX==="scroll";if(De=ue(Ue),(it<0&&ut>0||it>0&&ut<Le)&&ne&&vt)return oe=!0;ne=!1,f(Ue),oe=!1}),Ce.input(Ae,"touchend",function(){oe=!1})}(Te)})}}z.on("updated",Ie),z.on("optionsChanged",we),z.on("created",we),z.on("destroyed",Ce.purge)}function $(z){var U,B,J=null;function X(q,ee,ne){z.animator.active?K(q,ee,ne):requestAnimationFrame(function(){return K(q,ee,ne)})}function W(){X(!1,!1,B)}function K(q,ee,ne){var oe=0,le=z.size,ce=z.track.details;if(ce&&U){var Ce=ce.slides;U.forEach(function(ze,$e){if(q)!J&&ee&&F(ze,null,ne),G(ze,null,ne);else{if(!Ce[$e])return;var ke=Ce[$e].size*le;!J&&ee&&F(ze,ke,ne),G(ze,Ce[$e].distance*le-oe,ne),oe+=ke}})}}function re(q){return z.options.renderMode==="performance"?Math.round(q):q}function F(q,ee,ne){var oe=ne?"height":"width";ee!==null&&(ee=re(ee)+"px"),q.style["min-"+oe]=ee,q.style["max-"+oe]=ee}function G(q,ee,ne){if(ee!==null){ee=re(ee);var oe=ne?ee:0;ee="translate3d(".concat(ne?0:ee,"px, ").concat(oe,"px, 0)")}q.style.transform=ee,q.style["-webkit-transform"]=ee}function Z(){U&&(K(!0,!0,B),U=null),z.on("detailsChanged",W,!0)}function se(){X(!1,!0,B)}function k(){Z(),B=z.options.vertical,z.options.disabled||z.options.renderMode==="custom"||(J=E(z.options.slides,"perView",null)==="auto",z.on("detailsChanged",W),(U=z.slides).length&&se())}z.on("created",k),z.on("optionsChanged",k),z.on("beforeOptionsChanged",function(){Z()}),z.on("updated",se),z.on("destroyed",Z)}function L(z,U){return function(B){var J,X,W,K,re,F=g();function G(ge){var ue;o(B.container,"reverse",(ue=B.container,window.getComputedStyle(ue,null).getPropertyValue("direction")!=="rtl"||ge?null:"")),o(B.container,"v",B.options.vertical&&!ge?"":null),o(B.container,"disabled",B.options.disabled&&!ge?"":null)}function Z(){se()&&oe()}function se(){var ge=null;if(K.forEach(function(Re){Re.matches&&(ge=Re.__media)}),ge===J)return!1;J||B.emit("beforeOptionsChanged"),J=ge;var ue=ge?W.breakpoints[ge]:W;return B.options=M(M({},W),ue),G(),$e(),ke(),ce(),!0}function k(ge){var ue=S(ge);return(B.options.vertical?ue.height:ue.width)/B.size||1}function q(){return B.options.trackConfig.length}function ee(ge){for(var ue in J=!1,W=M(M({},U),ge),F.purge(),X=B.size,K=[],W.breakpoints||[]){var Re=window.matchMedia(ue);Re.__media=ue,K.push(Re),F.add(Re,"change",Z)}F.add(window,"orientationchange",ze),F.add(window,"resize",Ce),se()}function ne(ge){B.animator.stop();var ue=B.track.details;B.track.init(ge??(ue?ue.abs:0))}function oe(ge){ne(ge),B.emit("optionsChanged")}function le(ge,ue){if(ge)return ee(ge),void oe(ue);$e(),ke();var Re=q();ce(),q()!==Re?oe(ue):ne(ue),B.emit("updated")}function ce(){var ge=B.options.slides;if(typeof ge=="function")return B.options.trackConfig=ge(B.size,B.slides);for(var ue=B.slides,Re=ue.length,Ie=typeof ge=="number"?ge:E(ge,"number",Re,!0),ve=[],we=E(ge,"perView",1,!0),be=E(ge,"spacing",0,!0)/B.size||0,Ee=we==="auto"?be:be/we,Te=E(ge,"origin","auto"),Ae=0,De=0;De<Ie;De++){var Ue=we==="auto"?k(ue[De]):1/we-be+Ee,Fe=Te==="center"?.5-Ue/2:Te==="auto"?0:Te;ve.push({origin:Fe,size:Ue,spacing:be}),Ae+=Ue}if(Ae+=be*(Ie-1),Te==="auto"&&!B.options.loop&&we!==1){var Le=0;ve.map(function(it){var ut=Ae-Le;return Le+=it.size+be,ut>=1||(it.origin=1-ut-(Ae>1?0:1-Ae)),it})}B.options.trackConfig=ve}function Ce(){$e();var ge=B.size;B.options.disabled||ge===X||(X=ge,le())}function ze(){Ce(),setTimeout(Ce,500),setTimeout(Ce,2e3)}function $e(){var ge=S(B.container);B.size=(B.options.vertical?ge.height:ge.width)||1}function ke(){B.slides=c(B.options.selector,B.container)}B.container=(re=c(z,document)).length?re[0]:null,B.destroy=function(){F.purge(),B.emit("destroyed"),G(!0)},B.prev=function(){B.moveToIdx(B.track.details.abs-1,!0)},B.next=function(){B.moveToIdx(B.track.details.abs+1,!0)},B.update=le,ee(B.options)}}var H=function(z,U,B){try{return function(J,X){var W,K={};return W={emit:function(re){K[re]&&K[re].forEach(function(G){G(W)});var F=W.options&&W.options[re];F&&F(W)},moveToIdx:function(re,F,G){var Z=W.track.idxToDist(re,F);if(Z){var se=W.options.defaultAnimation;W.animator.start([{distance:Z,duration:E(G||se,"duration",500),easing:E(G||se,"easing",function(k){return 1+--k*k*k*k*k})}])}},on:function(re,F,G){G===void 0&&(G=!1),K[re]||(K[re]=[]);var Z=K[re].indexOf(F);Z>-1?G&&delete K[re][Z]:G||K[re].push(F)},options:J},function(){if(W.track=_(W),W.animator=D(W),X)for(var re=0,F=X;re<F.length;re++)(0,F[re])(W);W.track.init(W.options.initial||0),W.emit("created")}(),W}(U,A([L(z,{drag:!0,mode:"snap",renderMode:"precision",rubberband:!0,selector:".keen-slider__slide"}),$,V,j],B||[],!0))}catch(J){console.error(J)}};return nx.useKeenSlider=function(z,U){var B=e.useRef(null),J=e.useRef(!1),X=e.useRef(z),W=e.useCallback(function(K){K?(X.current=z,B.current=new H(K,z,U),J.current=!1):(B.current&&B.current.destroy&&B.current.destroy(),B.current=null)},[]);return e.useEffect(function(){O(X.current,z)||(X.current=z,B.current&&B.current.update(X.current))},[z]),[W,B]},nx}var EO=nK();const aK=({message:e,colorCode:t,handleAddToCart:a,handleRemoveFromCart:r})=>{const[o,c]=x.useState({}),[f,m]=x.useState({}),g=_=>{const j=/(https?:\/\/[^\s]+)/g;return _.split(j).map((V,$)=>j.test(V)?ae.jsx("a",{href:V.trim(),style:{color:"#00b3bc"},target:"_blank",rel:"noopener noreferrer",className:"underline break-words",children:V},$):ae.jsx("span",{children:V},$))},p=_=>{const j=_.trim();if(!j.includes("Name:")||!j.includes("VariantId"))return null;const V=j.match(/Name\s*[:\-]\s*(.+)/i),$=j.match(/Price\s*[:\-]\s*(.+)/i),L=j.match(/Link\s*[:\-]\s*(https?:\/\/[^\s]+)/i),H=j.match(/VariantId\s*[:\-]\s*(.+)/i),z=j.match(/variant_tag_name\s*[:\-]\s*(.+)/i),U=j.match(/options\s*[:\-]\s*([^|\r\n]+)/i);return!V||!$||!L||!H||!z?null:{name:V[1].trim(),price:$[1].trim(),link:L[1].trim(),image:"",variant_id:H[1].trim(),variant_tag_name:z[1].trim(),option:U?.[1]?.trim()}},y=x.useMemo(()=>{const _=e.split("|||").map($=>$.trim()).filter(Boolean),j=[];let V=null;return _.forEach($=>{if($.startsWith("img - ")){const L=$.replace(/^img\s*[-:]\s*/,"").trim();if(V)V.image=L;else{const H=[...j].reverse().find(z=>z.type==="product");H&&(H.data.image=L)}}else if($.includes("Name:")&&$.includes("VariantId")){const L=p($);L&&(j.push({type:"product",data:L}),V=L)}else j.push({type:"text",data:$}),V=null}),j},[e]),S=x.useMemo(()=>{const _={};return y.forEach(j=>{if(j.type==="product"){const V=j.data;_[V.variant_tag_name]=_[V.variant_tag_name]||[],_[V.variant_tag_name].push(V)}}),_},[y]),E=(_,j=22)=>_.length>j?_.slice(0,j)+"...":_,[T,O]=x.useState(0),M=Object.keys(S).length,[A,D]=EO.useKeenSlider({loop:!1,mode:"free",slides:{perView:1,spacing:16},slideChanged(_){O(_.track.details.rel)}});return ae.jsxs("div",{className:"space-y-6 mt-4 h-fit",children:[y.filter(_=>_.type==="text").map((_,j)=>ae.jsx("p",{className:"whitespace-pre-wrap break-words",children:g(_.data)},j)),Object.keys(S).length>0&&ae.jsxs(ae.Fragment,{children:[Object.keys(S).length>1&&ae.jsxs("div",{style:{display:"flex",margin:0,marginBottom:"6px",justifyContent:"space-between",paddingInline:"4px"},children:[ae.jsx(ri,{shape:"circle",icon:ae.jsx(km,{}),onClick:()=>D.current?.prev(),disabled:T===0}),ae.jsx(ri,{shape:"circle",icon:ae.jsx(z1,{}),onClick:()=>D.current?.next(),disabled:T===M-1})]}),ae.jsx("div",{ref:A,className:"keen-slider",children:ae.jsx(tK,{groupedProducts:S,selectedVariants:f,setSelectedVariants:m,counts:o,setCounts:c,handleAddToCart:a,handleRemoveFromCart:r,colorCode:t,shortenName:E,sliderInstance:D,currentSlide:T,totalSlides:M,sliderRef:A})})]})]})},U6=({message:e})=>{const t=e.find(r=>r.type==="image_url")?.image_url?.url,a=e?.isBusiness;return ae.jsx("div",{children:ae.jsx("div",{children:t&&ae.jsx("div",{className:"mb-2 bg-transparent text-white ",children:ae.jsx("img",{src:t,alt:"Chat image",style:{width:200},className:`rounded-md bg-transparent mt-2 max-w-xs ${a?"border border-gray-300 shadow-sm":""}`})})})})},rK=({message:e,colorCode:t})=>{const a=e.find(o=>o.type==="text")?.text,r=o=>{const c=/(https?:\/\/[^\s]+)/g;return o.split(c).map((f,m)=>c.test(f)?ae.jsx("a",{href:f.trim(),style:{color:t},target:"_blank",rel:"noopener noreferrer",className:"underline break-words",children:f},m):ae.jsx("span",{children:f},m))};return ae.jsx(ae.Fragment,{children:a&&ae.jsx("div",{style:{color:"white",border:1,backgroundColor:t,paddingTop:10,paddingBottom:10,paddingInline:14,maxWidth:"85%",lineHeight:1.4,borderRadius:"16px",wordBreak:"break-word"},children:ae.jsx("p",{children:r(a)})})})},iK=({link:e,colorCode:t,transcription:a})=>{const r=x.useRef(null),o=x.useRef(null),[c,f]=x.useState(!1),[m,g]=x.useState(!1);x.useEffect(()=>{if(r.current)return o.current?.destroy(),o.current=Wm.create({container:r.current,waveColor:"white",progressColor:"white",cursorWidth:0,barWidth:3,barHeight:1.5,barGap:2,height:40,interact:!0}),o.current.load(e),o.current.on("finish",()=>f(!1)),()=>{o.current?.destroy()}},[e,t]);const p=()=>{o.current&&(o.current.playPause(),f(y=>!y))};return ae.jsxs("div",{style:{backgroundColor:t,padding:"12px",borderRadius:"20px",color:"white",maxWidth:"350px",marginBottom:"16px"},children:[ae.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[ae.jsx("button",{onClick:p,style:{background:"transparent",border:"none",color:"white",marginRight:"12px",cursor:"pointer"},children:c?ae.jsx(GT,{style:{fontSize:"24px"}}):ae.jsx(XT,{style:{fontSize:"24px"}})}),ae.jsx("div",{ref:r,style:{width:"130px",height:"40px",overflow:"hidden",color:"white"}})]}),a&&ae.jsxs("div",{style:{marginTop:"12px",fontSize:"14px",color:"rgba(255,255,255,0.85)"},children:[ae.jsx("button",{onClick:()=>g(!m),style:{background:"none",border:"none",color:"white",textDecoration:"underline",fontSize:"13px",cursor:"pointer",padding:0},children:m?"Hide transcript":"Show transcript"}),m&&ae.jsx("p",{style:{marginTop:"6px",lineHeight:"1.4"},children:a})]})]})},oK=({status:e,user:t})=>{if(!e||!t)return null;let a=`${t} is ${e}`;return e==="typing"?a=`${t} is typing...`:a="",ae.jsx(ae.Fragment,{children:a&&ae.jsx("div",{className:"flex justify-center mb-2",children:ae.jsx("span",{className:"px-3 py-1 bg-gray-100 text-gray-500 text-sm rounded-full",children:a})})})},lK=({message:e})=>{const t=r=>{const o=/(https?:\/\/[^\s]+)/g;return r?.split(o).map((c,f)=>o.test(c)?ae.jsx("a",{href:c.trim(),style:{color:"#00b3bc"},target:"_blank",rel:"noopener noreferrer",className:"underline break-words",children:c},f):ae.jsx("span",{children:c},f))};if(e?.startsWith("Add this to cart for me")&&e?.includes("name:")){const o=e?.match(/name:([^,]+)/i)?.[1]?.trim()||"Product";return ae.jsxs("div",{style:{backgroundColor:"#E8F5E9",border:"1px solid #C8E6C9",borderRadius:"12px",padding:"12px 16px",color:"#2E7D32",fontWeight:500,fontSize:"15px",maxWidth:"360px",margin:"0 auto",textAlign:"center"},children:["✅ ",ae.jsx("strong",{children:o})," has been added to your cart."]})}return ae.jsx("p",{style:{color:"white"},children:t(e)})},wO=x.createContext({});function TO(e){const t=x.useRef(null);return t.current===null&&(t.current=e()),t.current}const OO=typeof window<"u",I6=OO?x.useLayoutEffect:x.useEffect,ax=x.createContext(null);function RO(e,t){e.indexOf(t)===-1&&e.push(t)}function AO(e,t){const a=e.indexOf(t);a>-1&&e.splice(a,1)}const Wu=(e,t,a)=>a>t?t:a<e?e:a;function MO(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}var sK={};let Zm=()=>{},Zu=()=>{};sK.NODE_ENV!=="production"&&(Zm=(e,t,a)=>{!e&&typeof console<"u"&&console.warn(MO(t,a))},Zu=(e,t,a)=>{if(!e)throw new Error(MO(t,a))});const Ku={},k6=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function F6(e){return typeof e=="object"&&e!==null}const q6=e=>/^0[^.\s]+$/u.test(e);function _O(e){let t;return()=>(t===void 0&&(t=e()),t)}const Sl=e=>e,uK=(e,t)=>a=>t(e(a)),S0=(...e)=>e.reduce(uK),x0=(e,t,a)=>{const r=t-e;return r===0?1:(a-e)/r};class DO{constructor(){this.subscriptions=[]}add(t){return RO(this.subscriptions,t),()=>AO(this.subscriptions,t)}notify(t,a,r){const o=this.subscriptions.length;if(o)if(o===1)this.subscriptions[0](t,a,r);else for(let c=0;c<o;c++){const f=this.subscriptions[c];f&&f(t,a,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const is=e=>e*1e3,Qs=e=>e/1e3;function G6(e,t){return t?e*(1e3/t):0}const X6=new Set;function NO(e,t,a){e||X6.has(t)||(console.warn(MO(t,a)),X6.add(t))}const Y6=(e,t,a)=>(((1-3*a+3*t)*e+(3*a-6*t))*e+3*t)*e,cK=1e-7,fK=12;function dK(e,t,a,r,o){let c,f,m=0;do f=t+(a-t)/2,c=Y6(f,r,o)-e,c>0?a=f:t=f;while(Math.abs(c)>cK&&++m<fK);return f}function C0(e,t,a,r){if(e===t&&a===r)return Sl;const o=c=>dK(c,0,1,e,a);return c=>c===0||c===1?c:Y6(o(c),t,r)}const W6=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Z6=e=>t=>1-e(1-t),K6=C0(.33,1.53,.69,.99),$O=Z6(K6),Q6=W6($O),J6=e=>(e*=2)<1?.5*$O(e):.5*(2-Math.pow(2,-10*(e-1))),zO=e=>1-Math.sin(Math.acos(e)),ez=Z6(zO),tz=W6(zO),hK=C0(.42,0,1,1),mK=C0(0,0,.58,1),nz=C0(.42,0,.58,1),pK=e=>Array.isArray(e)&&typeof e[0]!="number",az=e=>Array.isArray(e)&&typeof e[0]=="number",rz={linear:Sl,easeIn:hK,easeInOut:nz,easeOut:mK,circIn:zO,circInOut:tz,circOut:ez,backIn:$O,backInOut:Q6,backOut:K6,anticipate:J6},gK=e=>typeof e=="string",iz=e=>{if(az(e)){Zu(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,a,r,o]=e;return C0(t,a,r,o)}else if(gK(e))return Zu(rz[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),rz[e];return e},rx=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function vK(e,t){let a=new Set,r=new Set,o=!1,c=!1;const f=new WeakSet;let m={delta:0,timestamp:0,isProcessing:!1};function g(y){f.has(y)&&(p.schedule(y),e()),y(m)}const p={schedule:(y,S=!1,E=!1)=>{const O=E&&o?a:r;return S&&f.add(y),O.has(y)||O.add(y),y},cancel:y=>{r.delete(y),f.delete(y)},process:y=>{if(m=y,o){c=!0;return}o=!0,[a,r]=[r,a],a.forEach(g),a.clear(),o=!1,c&&(c=!1,p.process(y))}};return p}const yK=40;function oz(e,t){let a=!1,r=!0;const o={delta:0,timestamp:0,isProcessing:!1},c=()=>a=!0,f=rx.reduce((j,V)=>(j[V]=vK(c),j),{}),{setup:m,read:g,resolveKeyframes:p,preUpdate:y,update:S,preRender:E,render:T,postRender:O}=f,M=()=>{const j=Ku.useManualTiming?o.timestamp:performance.now();a=!1,Ku.useManualTiming||(o.delta=r?1e3/60:Math.max(Math.min(j-o.timestamp,yK),1)),o.timestamp=j,o.isProcessing=!0,m.process(o),g.process(o),p.process(o),y.process(o),S.process(o),E.process(o),T.process(o),O.process(o),o.isProcessing=!1,a&&t&&(r=!1,e(M))},A=()=>{a=!0,r=!0,o.isProcessing||e(M)};return{schedule:rx.reduce((j,V)=>{const $=f[V];return j[V]=(L,H=!1,z=!1)=>(a||A(),$.schedule(L,H,z)),j},{}),cancel:j=>{for(let V=0;V<rx.length;V++)f[rx[V]].cancel(j)},state:o,steps:f}}const{schedule:Pa,cancel:nf,state:oi,steps:jO}=oz(typeof requestAnimationFrame<"u"?requestAnimationFrame:Sl,!0);let ix;function bK(){ix=void 0}const yo={now:()=>(ix===void 0&&yo.set(oi.isProcessing||Ku.useManualTiming?oi.timestamp:performance.now()),ix),set:e=>{ix=e,queueMicrotask(bK)}},lz=e=>t=>typeof t=="string"&&t.startsWith(e),LO=lz("--"),SK=lz("var(--"),VO=e=>SK(e)?xK.test(e.split("/*")[0].trim()):!1,xK=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Km={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},E0={...Km,transform:e=>Wu(0,1,e)},ox={...Km,default:1},w0=e=>Math.round(e*1e5)/1e5,HO=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function CK(e){return e==null}const EK=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,BO=(e,t)=>a=>!!(typeof a=="string"&&EK.test(a)&&a.startsWith(e)||t&&!CK(a)&&Object.prototype.hasOwnProperty.call(a,t)),sz=(e,t,a)=>r=>{if(typeof r!="string")return r;const[o,c,f,m]=r.match(HO);return{[e]:parseFloat(o),[t]:parseFloat(c),[a]:parseFloat(f),alpha:m!==void 0?parseFloat(m):1}},wK=e=>Wu(0,255,e),PO={...Km,transform:e=>Math.round(wK(e))},Hd={test:BO("rgb","red"),parse:sz("red","green","blue"),transform:({red:e,green:t,blue:a,alpha:r=1})=>"rgba("+PO.transform(e)+", "+PO.transform(t)+", "+PO.transform(a)+", "+w0(E0.transform(r))+")"};function TK(e){let t="",a="",r="",o="";return e.length>5?(t=e.substring(1,3),a=e.substring(3,5),r=e.substring(5,7),o=e.substring(7,9)):(t=e.substring(1,2),a=e.substring(2,3),r=e.substring(3,4),o=e.substring(4,5),t+=t,a+=a,r+=r,o+=o),{red:parseInt(t,16),green:parseInt(a,16),blue:parseInt(r,16),alpha:o?parseInt(o,16)/255:1}}const UO={test:BO("#"),parse:TK,transform:Hd.transform},T0=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),af=T0("deg"),Js=T0("%"),on=T0("px"),OK=T0("vh"),RK=T0("vw"),uz={...Js,parse:e=>Js.parse(e)/100,transform:e=>Js.transform(e*100)},Qm={test:BO("hsl","hue"),parse:sz("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:a,alpha:r=1})=>"hsla("+Math.round(e)+", "+Js.transform(w0(t))+", "+Js.transform(w0(a))+", "+w0(E0.transform(r))+")"},xr={test:e=>Hd.test(e)||UO.test(e)||Qm.test(e),parse:e=>Hd.test(e)?Hd.parse(e):Qm.test(e)?Qm.parse(e):UO.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Hd.transform(e):Qm.transform(e),getAnimatableNone:e=>{const t=xr.parse(e);return t.alpha=0,xr.transform(t)}},AK=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function MK(e){return isNaN(e)&&typeof e=="string"&&(e.match(HO)?.length||0)+(e.match(AK)?.length||0)>0}const cz="number",fz="color",_K="var",DK="var(",dz="${}",NK=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function O0(e){const t=e.toString(),a=[],r={color:[],number:[],var:[]},o=[];let c=0;const m=t.replace(NK,g=>(xr.test(g)?(r.color.push(c),o.push(fz),a.push(xr.parse(g))):g.startsWith(DK)?(r.var.push(c),o.push(_K),a.push(g)):(r.number.push(c),o.push(cz),a.push(parseFloat(g))),++c,dz)).split(dz);return{values:a,split:m,indexes:r,types:o}}function hz(e){return O0(e).values}function mz(e){const{split:t,types:a}=O0(e),r=t.length;return o=>{let c="";for(let f=0;f<r;f++)if(c+=t[f],o[f]!==void 0){const m=a[f];m===cz?c+=w0(o[f]):m===fz?c+=xr.transform(o[f]):c+=o[f]}return c}}const $K=e=>typeof e=="number"?0:xr.test(e)?xr.getAnimatableNone(e):e;function zK(e){const t=hz(e);return mz(e)(t.map($K))}const rf={test:MK,parse:hz,createTransformer:mz,getAnimatableNone:zK};function IO(e,t,a){return a<0&&(a+=1),a>1&&(a-=1),a<1/6?e+(t-e)*6*a:a<1/2?t:a<2/3?e+(t-e)*(2/3-a)*6:e}function jK({hue:e,saturation:t,lightness:a,alpha:r}){e/=360,t/=100,a/=100;let o=0,c=0,f=0;if(!t)o=c=f=a;else{const m=a<.5?a*(1+t):a+t-a*t,g=2*a-m;o=IO(g,m,e+1/3),c=IO(g,m,e),f=IO(g,m,e-1/3)}return{red:Math.round(o*255),green:Math.round(c*255),blue:Math.round(f*255),alpha:r}}function lx(e,t){return a=>a>0?t:e}const Za=(e,t,a)=>e+(t-e)*a,kO=(e,t,a)=>{const r=e*e,o=a*(t*t-r)+r;return o<0?0:Math.sqrt(o)},LK=[UO,Hd,Qm],VK=e=>LK.find(t=>t.test(e));function pz(e){const t=VK(e);if(Zm(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!t)return!1;let a=t.parse(e);return t===Qm&&(a=jK(a)),a}const gz=(e,t)=>{const a=pz(e),r=pz(t);if(!a||!r)return lx(e,t);const o={...a};return c=>(o.red=kO(a.red,r.red,c),o.green=kO(a.green,r.green,c),o.blue=kO(a.blue,r.blue,c),o.alpha=Za(a.alpha,r.alpha,c),Hd.transform(o))},FO=new Set(["none","hidden"]);function HK(e,t){return FO.has(e)?a=>a<=0?e:t:a=>a>=1?t:e}function BK(e,t){return a=>Za(e,t,a)}function qO(e){return typeof e=="number"?BK:typeof e=="string"?VO(e)?lx:xr.test(e)?gz:IK:Array.isArray(e)?vz:typeof e=="object"?xr.test(e)?gz:PK:lx}function vz(e,t){const a=[...e],r=a.length,o=e.map((c,f)=>qO(c)(c,t[f]));return c=>{for(let f=0;f<r;f++)a[f]=o[f](c);return a}}function PK(e,t){const a={...e,...t},r={};for(const o in a)e[o]!==void 0&&t[o]!==void 0&&(r[o]=qO(e[o])(e[o],t[o]));return o=>{for(const c in r)a[c]=r[c](o);return a}}function UK(e,t){const a=[],r={color:0,var:0,number:0};for(let o=0;o<t.values.length;o++){const c=t.types[o],f=e.indexes[c][r[c]],m=e.values[f]??0;a[o]=m,r[c]++}return a}const IK=(e,t)=>{const a=rf.createTransformer(t),r=O0(e),o=O0(t);return r.indexes.var.length===o.indexes.var.length&&r.indexes.color.length===o.indexes.color.length&&r.indexes.number.length>=o.indexes.number.length?FO.has(e)&&!o.values.length||FO.has(t)&&!r.values.length?HK(e,t):S0(vz(UK(r,o),o.values),a):(Zm(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),lx(e,t))};function yz(e,t,a){return typeof e=="number"&&typeof t=="number"&&typeof a=="number"?Za(e,t,a):qO(e)(e,t)}const kK=e=>{const t=({timestamp:a})=>e(a);return{start:(a=!0)=>Pa.update(t,a),stop:()=>nf(t),now:()=>oi.isProcessing?oi.timestamp:yo.now()}},bz=(e,t,a=10)=>{let r="";const o=Math.max(Math.round(t/a),2);for(let c=0;c<o;c++)r+=Math.round(e(c/(o-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},sx=2e4;function GO(e){let t=0;const a=50;let r=e.next(t);for(;!r.done&&t<sx;)t+=a,r=e.next(t);return t>=sx?1/0:t}function FK(e,t=100,a){const r=a({...e,keyframes:[0,t]}),o=Math.min(GO(r),sx);return{type:"keyframes",ease:c=>r.next(o*c).value/t,duration:Qs(o)}}const qK=5;function Sz(e,t,a){const r=Math.max(t-qK,0);return G6(a-e(r),t-r)}const Ka={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},XO=.001;function GK({duration:e=Ka.duration,bounce:t=Ka.bounce,velocity:a=Ka.velocity,mass:r=Ka.mass}){let o,c;Zm(e<=is(Ka.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let f=1-t;f=Wu(Ka.minDamping,Ka.maxDamping,f),e=Wu(Ka.minDuration,Ka.maxDuration,Qs(e)),f<1?(o=p=>{const y=p*f,S=y*e,E=y-a,T=YO(p,f),O=Math.exp(-S);return XO-E/T*O},c=p=>{const S=p*f*e,E=S*a+a,T=Math.pow(f,2)*Math.pow(p,2)*e,O=Math.exp(-S),M=YO(Math.pow(p,2),f);return(-o(p)+XO>0?-1:1)*((E-T)*O)/M}):(o=p=>{const y=Math.exp(-p*e),S=(p-a)*e+1;return-XO+y*S},c=p=>{const y=Math.exp(-p*e),S=(a-p)*(e*e);return y*S});const m=5/e,g=YK(o,c,m);if(e=is(e),isNaN(g))return{stiffness:Ka.stiffness,damping:Ka.damping,duration:e};{const p=Math.pow(g,2)*r;return{stiffness:p,damping:f*2*Math.sqrt(r*p),duration:e}}}const XK=12;function YK(e,t,a){let r=a;for(let o=1;o<XK;o++)r=r-e(r)/t(r);return r}function YO(e,t){return e*Math.sqrt(1-t*t)}const WK=["duration","bounce"],ZK=["stiffness","damping","mass"];function xz(e,t){return t.some(a=>e[a]!==void 0)}function KK(e){let t={velocity:Ka.velocity,stiffness:Ka.stiffness,damping:Ka.damping,mass:Ka.mass,isResolvedFromDuration:!1,...e};if(!xz(e,ZK)&&xz(e,WK))if(e.visualDuration){const a=e.visualDuration,r=2*Math.PI/(a*1.2),o=r*r,c=2*Wu(.05,1,1-(e.bounce||0))*Math.sqrt(o);t={...t,mass:Ka.mass,stiffness:o,damping:c}}else{const a=GK(e);t={...t,...a,mass:Ka.mass},t.isResolvedFromDuration=!0}return t}function ux(e=Ka.visualDuration,t=Ka.bounce){const a=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:o}=a;const c=a.keyframes[0],f=a.keyframes[a.keyframes.length-1],m={done:!1,value:c},{stiffness:g,damping:p,mass:y,duration:S,velocity:E,isResolvedFromDuration:T}=KK({...a,velocity:-Qs(a.velocity||0)}),O=E||0,M=p/(2*Math.sqrt(g*y)),A=f-c,D=Qs(Math.sqrt(g/y)),_=Math.abs(A)<5;r||(r=_?Ka.restSpeed.granular:Ka.restSpeed.default),o||(o=_?Ka.restDelta.granular:Ka.restDelta.default);let j;if(M<1){const $=YO(D,M);j=L=>{const H=Math.exp(-M*D*L);return f-H*((O+M*D*A)/$*Math.sin($*L)+A*Math.cos($*L))}}else if(M===1)j=$=>f-Math.exp(-D*$)*(A+(O+D*A)*$);else{const $=D*Math.sqrt(M*M-1);j=L=>{const H=Math.exp(-M*D*L),z=Math.min($*L,300);return f-H*((O+M*D*A)*Math.sinh(z)+$*A*Math.cosh(z))/$}}const V={calculatedDuration:T&&S||null,next:$=>{const L=j($);if(T)m.done=$>=S;else{let H=$===0?O:0;M<1&&(H=$===0?is(O):Sz(j,$,L));const z=Math.abs(H)<=r,U=Math.abs(f-L)<=o;m.done=z&&U}return m.value=m.done?f:L,m},toString:()=>{const $=Math.min(GO(V),sx),L=bz(H=>V.next($*H).value,$,30);return $+"ms "+L},toTransition:()=>{}};return V}ux.applyToOptions=e=>{const t=FK(e,100,ux);return e.ease=t.ease,e.duration=is(t.duration),e.type="keyframes",e};function WO({keyframes:e,velocity:t=0,power:a=.8,timeConstant:r=325,bounceDamping:o=10,bounceStiffness:c=500,modifyTarget:f,min:m,max:g,restDelta:p=.5,restSpeed:y}){const S=e[0],E={done:!1,value:S},T=z=>m!==void 0&&z<m||g!==void 0&&z>g,O=z=>m===void 0?g:g===void 0||Math.abs(m-z)<Math.abs(g-z)?m:g;let M=a*t;const A=S+M,D=f===void 0?A:f(A);D!==A&&(M=D-S);const _=z=>-M*Math.exp(-z/r),j=z=>D+_(z),V=z=>{const U=_(z),B=j(z);E.done=Math.abs(U)<=p,E.value=E.done?D:B};let $,L;const H=z=>{T(E.value)&&($=z,L=ux({keyframes:[E.value,O(E.value)],velocity:Sz(j,z,E.value),damping:o,stiffness:c,restDelta:p,restSpeed:y}))};return H(0),{calculatedDuration:null,next:z=>{let U=!1;return!L&&$===void 0&&(U=!0,V(z),H(z)),$!==void 0&&z>=$?L.next(z-$):(!U&&V(z),E)}}}function QK(e,t,a){const r=[],o=a||Ku.mix||yz,c=e.length-1;for(let f=0;f<c;f++){let m=o(e[f],e[f+1]);if(t){const g=Array.isArray(t)?t[f]||Sl:t;m=S0(g,m)}r.push(m)}return r}function JK(e,t,{clamp:a=!0,ease:r,mixer:o}={}){const c=e.length;if(Zu(c===t.length,"Both input and output ranges must be the same length","range-length"),c===1)return()=>t[0];if(c===2&&t[0]===t[1])return()=>t[1];const f=e[0]===e[1];e[0]>e[c-1]&&(e=[...e].reverse(),t=[...t].reverse());const m=QK(t,r,o),g=m.length,p=y=>{if(f&&y<e[0])return t[0];let S=0;if(g>1)for(;S<e.length-2&&!(y<e[S+1]);S++);const E=x0(e[S],e[S+1],y);return m[S](E)};return a?y=>p(Wu(e[0],e[c-1],y)):p}function eQ(e,t){const a=e[e.length-1];for(let r=1;r<=t;r++){const o=x0(0,t,r);e.push(Za(a,1,o))}}function tQ(e){const t=[0];return eQ(t,e.length-1),t}function nQ(e,t){return e.map(a=>a*t)}function aQ(e,t){return e.map(()=>t||nz).splice(0,e.length-1)}function Jm({duration:e=300,keyframes:t,times:a,ease:r="easeInOut"}){const o=pK(r)?r.map(iz):iz(r),c={done:!1,value:t[0]},f=nQ(a&&a.length===t.length?a:tQ(t),e),m=JK(f,t,{ease:Array.isArray(o)?o:aQ(t,o)});return{calculatedDuration:e,next:g=>(c.value=m(g),c.done=g>=e,c)}}const rQ=e=>e!==null;function ZO(e,{repeat:t,repeatType:a="loop"},r,o=1){const c=e.filter(rQ),m=o<0||t&&a!=="loop"&&t%2===1?0:c.length-1;return!m||r===void 0?c[m]:r}const iQ={decay:WO,inertia:WO,tween:Jm,keyframes:Jm,spring:ux};function Cz(e){typeof e.type=="string"&&(e.type=iQ[e.type])}class KO{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,a){return this.finished.then(t,a)}}var oQ={};const lQ=e=>e/100;class QO extends KO{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{const{motionValue:a}=this.options;a&&a.updatedAt!==yo.now()&&this.tick(yo.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;Cz(t);const{type:a=Jm,repeat:r=0,repeatDelay:o=0,repeatType:c,velocity:f=0}=t;let{keyframes:m}=t;const g=a||Jm;oQ.NODE_ENV!=="production"&&g!==Jm&&Zu(m.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${m}`,"spring-two-frames"),g!==Jm&&typeof m[0]!="number"&&(this.mixKeyframes=S0(lQ,yz(m[0],m[1])),m=[0,100]);const p=g({...t,keyframes:m});c==="mirror"&&(this.mirroredGenerator=g({...t,keyframes:[...m].reverse(),velocity:-f})),p.calculatedDuration===null&&(p.calculatedDuration=GO(p));const{calculatedDuration:y}=p;this.calculatedDuration=y,this.resolvedDuration=y+o,this.totalDuration=this.resolvedDuration*(r+1)-o,this.generator=p}updateTime(t){const a=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=a}tick(t,a=!1){const{generator:r,totalDuration:o,mixKeyframes:c,mirroredGenerator:f,resolvedDuration:m,calculatedDuration:g}=this;if(this.startTime===null)return r.next(0);const{delay:p=0,keyframes:y,repeat:S,repeatType:E,repeatDelay:T,type:O,onUpdate:M,finalKeyframe:A}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-o/this.speed,this.startTime)),a?this.currentTime=t:this.updateTime(t);const D=this.currentTime-p*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?D<0:D>o;this.currentTime=Math.max(D,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=o);let j=this.currentTime,V=r;if(S){const z=Math.min(this.currentTime,o)/m;let U=Math.floor(z),B=z%1;!B&&z>=1&&(B=1),B===1&&U--,U=Math.min(U,S+1),!!(U%2)&&(E==="reverse"?(B=1-B,T&&(B-=T/m)):E==="mirror"&&(V=f)),j=Wu(0,1,B)*m}const $=_?{done:!1,value:y[0]}:V.next(j);c&&($.value=c($.value));let{done:L}=$;!_&&g!==null&&(L=this.playbackSpeed>=0?this.currentTime>=o:this.currentTime<=0);const H=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&L);return H&&O!==WO&&($.value=ZO(y,this.options,A,this.speed)),M&&M($.value),H&&this.finish(),$}then(t,a){return this.finished.then(t,a)}get duration(){return Qs(this.calculatedDuration)}get time(){return Qs(this.currentTime)}set time(t){t=is(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(yo.now());const a=this.playbackSpeed!==t;this.playbackSpeed=t,a&&(this.time=Qs(this.currentTime))}play(){if(this.isStopped)return;const{driver:t=kK,startTime:a}=this.options;this.driver||(this.driver=t(o=>this.tick(o))),this.options.onPlay?.();const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=a??r),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(yo.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),t.observe(this)}}function sQ(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Bd=e=>e*180/Math.PI,JO=e=>{const t=Bd(Math.atan2(e[1],e[0]));return eR(t)},uQ={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:JO,rotateZ:JO,skewX:e=>Bd(Math.atan(e[1])),skewY:e=>Bd(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},eR=e=>(e=e%360,e<0&&(e+=360),e),Ez=JO,wz=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Tz=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),cQ={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:wz,scaleY:Tz,scale:e=>(wz(e)+Tz(e))/2,rotateX:e=>eR(Bd(Math.atan2(e[6],e[5]))),rotateY:e=>eR(Bd(Math.atan2(-e[2],e[0]))),rotateZ:Ez,rotate:Ez,skewX:e=>Bd(Math.atan(e[4])),skewY:e=>Bd(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function tR(e){return e.includes("scale")?1:0}function nR(e,t){if(!e||e==="none")return tR(t);const a=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,o;if(a)r=cQ,o=a;else{const m=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=uQ,o=m}if(!o)return tR(t);const c=r[t],f=o[1].split(",").map(dQ);return typeof c=="function"?c(f):f[c]}const fQ=(e,t)=>{const{transform:a="none"}=getComputedStyle(e);return nR(a,t)};function dQ(e){return parseFloat(e.trim())}const ep=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],tp=new Set(ep),Oz=e=>e===Km||e===on,hQ=new Set(["x","y","z"]),mQ=ep.filter(e=>!hQ.has(e));function pQ(e){const t=[];return mQ.forEach(a=>{const r=e.getValue(a);r!==void 0&&(t.push([a,r.get()]),r.set(a.startsWith("scale")?1:0))}),t}const Pd={width:({x:e},{paddingLeft:t="0",paddingRight:a="0"})=>e.max-e.min-parseFloat(t)-parseFloat(a),height:({y:e},{paddingTop:t="0",paddingBottom:a="0"})=>e.max-e.min-parseFloat(t)-parseFloat(a),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>nR(t,"x"),y:(e,{transform:t})=>nR(t,"y")};Pd.translateX=Pd.x,Pd.translateY=Pd.y;const Ud=new Set;let aR=!1,rR=!1,iR=!1;function Rz(){if(rR){const e=Array.from(Ud).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),a=new Map;t.forEach(r=>{const o=pQ(r);o.length&&(a.set(r,o),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const o=a.get(r);o&&o.forEach(([c,f])=>{r.getValue(c)?.set(f)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}rR=!1,aR=!1,Ud.forEach(e=>e.complete(iR)),Ud.clear()}function Az(){Ud.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(rR=!0)})}function gQ(){iR=!0,Az(),Rz(),iR=!1}class oR{constructor(t,a,r,o,c,f=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=a,this.name=r,this.motionValue=o,this.element=c,this.isAsync=f}scheduleResolve(){this.state="scheduled",this.isAsync?(Ud.add(this),aR||(aR=!0,Pa.read(Az),Pa.resolveKeyframes(Rz))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:a,element:r,motionValue:o}=this;if(t[0]===null){const c=o?.get(),f=t[t.length-1];if(c!==void 0)t[0]=c;else if(r&&a){const m=r.readValue(a,f);m!=null&&(t[0]=m)}t[0]===void 0&&(t[0]=f),o&&c===void 0&&o.set(t[0])}sQ(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Ud.delete(this)}cancel(){this.state==="scheduled"&&(Ud.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const vQ=e=>e.startsWith("--");function yQ(e,t,a){vQ(t)?e.style.setProperty(t,a):e.style[t]=a}const bQ=_O(()=>window.ScrollTimeline!==void 0),SQ={};function xQ(e,t){const a=_O(e);return()=>SQ[t]??a()}const Mz=xQ(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),R0=([e,t,a,r])=>`cubic-bezier(${e}, ${t}, ${a}, ${r})`,_z={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:R0([0,.65,.55,1]),circOut:R0([.55,0,1,.45]),backIn:R0([.31,.01,.66,-.59]),backOut:R0([.33,1.53,.69,.99])};function Dz(e,t){if(e)return typeof e=="function"?Mz()?bz(e,t):"ease-out":az(e)?R0(e):Array.isArray(e)?e.map(a=>Dz(a,t)||_z.easeOut):_z[e]}function CQ(e,t,a,{delay:r=0,duration:o=300,repeat:c=0,repeatType:f="loop",ease:m="easeOut",times:g}={},p=void 0){const y={[t]:a};g&&(y.offset=g);const S=Dz(m,o);Array.isArray(S)&&(y.easing=S);const E={delay:r,duration:o,easing:Array.isArray(S)?"linear":S,fill:"both",iterations:c+1,direction:f==="reverse"?"alternate":"normal"};return p&&(E.pseudoElement=p),e.animate(y,E)}function Nz(e){return typeof e=="function"&&"applyToOptions"in e}function EQ({type:e,...t}){return Nz(e)&&Mz()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class wQ extends KO{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:a,name:r,keyframes:o,pseudoElement:c,allowFlatten:f=!1,finalKeyframe:m,onComplete:g}=t;this.isPseudoElement=!!c,this.allowFlatten=f,this.options=t,Zu(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const p=EQ(t);this.animation=CQ(a,r,o,p,c),p.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!c){const y=ZO(o,this.options,m,this.speed);this.updateMotionValue?this.updateMotionValue(y):yQ(a,r,y),this.animation.cancel()}g?.(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){this.isPseudoElement||this.animation.commitStyles?.()}get duration(){const t=this.animation.effect?.getComputedTiming?.().duration||0;return Qs(Number(t))}get time(){return Qs(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=is(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(t){this.animation.startTime=t}attachTimeline({timeline:t,observe:a}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,t&&bQ()?(this.animation.timeline=t,Sl):a(this)}}const $z={anticipate:J6,backInOut:Q6,circInOut:tz};function TQ(e){return e in $z}function OQ(e){typeof e.ease=="string"&&TQ(e.ease)&&(e.ease=$z[e.ease])}const zz=10;class RQ extends wQ{constructor(t){OQ(t),Cz(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:a,onUpdate:r,onComplete:o,element:c,...f}=this.options;if(!a)return;if(t!==void 0){a.set(t);return}const m=new QO({...f,autoplay:!1}),g=is(this.finishedTime??this.time);a.setWithVelocity(m.sample(g-zz).value,m.sample(g).value,zz),m.stop()}}const jz=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(rf.test(e)||e==="0")&&!e.startsWith("url("));function AQ(e){const t=e[0];if(e.length===1)return!0;for(let a=0;a<e.length;a++)if(e[a]!==t)return!0}function MQ(e,t,a,r){const o=e[0];if(o===null)return!1;if(t==="display"||t==="visibility")return!0;const c=e[e.length-1],f=jz(o,t),m=jz(c,t);return Zm(f===m,`You are trying to animate ${t} from "${o}" to "${c}". "${f?c:o}" is not an animatable value.`,"value-not-animatable"),!f||!m?!1:AQ(e)||(a==="spring"||Nz(a))&&r}const _Q=new Set(["opacity","clipPath","filter","transform"]),DQ=_O(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function NQ(e){const{motionValue:t,name:a,repeatDelay:r,repeatType:o,damping:c,type:f}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;const{onUpdate:g,transformTemplate:p}=t.owner.getProps();return DQ()&&a&&_Q.has(a)&&(a!=="transform"||!p)&&!g&&!r&&o!=="mirror"&&c!==0&&f!=="inertia"}const $Q=40;class zQ extends KO{constructor({autoplay:t=!0,delay:a=0,type:r="keyframes",repeat:o=0,repeatDelay:c=0,repeatType:f="loop",keyframes:m,name:g,motionValue:p,element:y,...S}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=yo.now();const E={autoplay:t,delay:a,type:r,repeat:o,repeatDelay:c,repeatType:f,name:g,motionValue:p,element:y,...S},T=y?.KeyframeResolver||oR;this.keyframeResolver=new T(m,(O,M,A)=>this.onKeyframesResolved(O,M,E,!A),g,p,y),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(t,a,r,o){this.keyframeResolver=void 0;const{name:c,type:f,velocity:m,delay:g,isHandoff:p,onUpdate:y}=r;this.resolvedAt=yo.now(),MQ(t,c,f,m)||((Ku.instantAnimations||!g)&&y?.(ZO(t,r,a)),t[0]=t[t.length-1],r.duration=0,r.repeat=0);const E={startTime:o?this.resolvedAt?this.resolvedAt-this.createdAt>$Q?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:a,...r,keyframes:t},T=!p&&NQ(E)?new RQ({...E,element:E.motionValue.owner.current}):new QO(E);T.finished.then(()=>this.notifyFinished()).catch(Sl),this.pendingTimeline&&(this.stopTimeline=T.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=T}get finished(){return this._animation?this.animation.finished:this._finished}then(t,a){return this.finished.finally(t).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),gQ()),this._animation}get duration(){return this.animation.duration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}}const jQ=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function LQ(e){const t=jQ.exec(e);if(!t)return[,];const[,a,r,o]=t;return[`--${a??r}`,o]}const VQ=4;function Lz(e,t,a=1){Zu(a<=VQ,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,o]=LQ(e);if(!r)return;const c=window.getComputedStyle(t).getPropertyValue(r);if(c){const f=c.trim();return k6(f)?parseFloat(f):f}return VO(o)?Lz(o,t,a+1):o}function lR(e,t){return e?.[t]??e?.default??e}const Vz=new Set(["width","height","top","left","right","bottom",...ep]),HQ={test:e=>e==="auto",parse:e=>e},Hz=e=>t=>t.test(e),Bz=[Km,on,Js,af,RK,OK,HQ],Pz=e=>Bz.find(Hz(e));function BQ(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||q6(e):!0}const PQ=new Set(["brightness","contrast","saturate","opacity"]);function UQ(e){const[t,a]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=a.match(HO)||[];if(!r)return e;const o=a.replace(r,"");let c=PQ.has(t)?1:0;return r!==a&&(c*=100),t+"("+c+o+")"}const IQ=/\b([a-z-]*)\(.*?\)/gu,sR={...rf,getAnimatableNone:e=>{const t=e.match(IQ);return t?t.map(UQ).join(" "):e}},Uz={...Km,transform:Math.round},uR={borderWidth:on,borderTopWidth:on,borderRightWidth:on,borderBottomWidth:on,borderLeftWidth:on,borderRadius:on,radius:on,borderTopLeftRadius:on,borderTopRightRadius:on,borderBottomRightRadius:on,borderBottomLeftRadius:on,width:on,maxWidth:on,height:on,maxHeight:on,top:on,right:on,bottom:on,left:on,padding:on,paddingTop:on,paddingRight:on,paddingBottom:on,paddingLeft:on,margin:on,marginTop:on,marginRight:on,marginBottom:on,marginLeft:on,backgroundPositionX:on,backgroundPositionY:on,...{rotate:af,rotateX:af,rotateY:af,rotateZ:af,scale:ox,scaleX:ox,scaleY:ox,scaleZ:ox,skew:af,skewX:af,skewY:af,distance:on,translateX:on,translateY:on,translateZ:on,x:on,y:on,z:on,perspective:on,transformPerspective:on,opacity:E0,originX:uz,originY:uz,originZ:on},zIndex:Uz,fillOpacity:E0,strokeOpacity:E0,numOctaves:Uz},kQ={...uR,color:xr,backgroundColor:xr,outlineColor:xr,fill:xr,stroke:xr,borderColor:xr,borderTopColor:xr,borderRightColor:xr,borderBottomColor:xr,borderLeftColor:xr,filter:sR,WebkitFilter:sR},Iz=e=>kQ[e];function kz(e,t){let a=Iz(e);return a!==sR&&(a=rf),a.getAnimatableNone?a.getAnimatableNone(t):void 0}const FQ=new Set(["auto","none","0"]);function qQ(e,t,a){let r=0,o;for(;r<e.length&&!o;){const c=e[r];typeof c=="string"&&!FQ.has(c)&&O0(c).values.length&&(o=e[r]),r++}if(o&&a)for(const c of t)e[c]=kz(a,o)}class GQ extends oR{constructor(t,a,r,o,c){super(t,a,r,o,c,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:a,name:r}=this;if(!a||!a.current)return;super.readKeyframes();for(let g=0;g<t.length;g++){let p=t[g];if(typeof p=="string"&&(p=p.trim(),VO(p))){const y=Lz(p,a.current);y!==void 0&&(t[g]=y),g===t.length-1&&(this.finalKeyframe=p)}}if(this.resolveNoneKeyframes(),!Vz.has(r)||t.length!==2)return;const[o,c]=t,f=Pz(o),m=Pz(c);if(f!==m)if(Oz(f)&&Oz(m))for(let g=0;g<t.length;g++){const p=t[g];typeof p=="string"&&(t[g]=parseFloat(p))}else Pd[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:a}=this,r=[];for(let o=0;o<t.length;o++)(t[o]===null||BQ(t[o]))&&r.push(o);r.length&&qQ(t,r,a)}measureInitialState(){const{element:t,unresolvedKeyframes:a,name:r}=this;if(!t||!t.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Pd[r](t.measureViewportBox(),window.getComputedStyle(t.current)),a[0]=this.measuredOrigin;const o=a[a.length-1];o!==void 0&&t.getValue(r,o).jump(o,!1)}measureEndState(){const{element:t,name:a,unresolvedKeyframes:r}=this;if(!t||!t.current)return;const o=t.getValue(a);o&&o.jump(this.measuredOrigin,!1);const c=r.length-1,f=r[c];r[c]=Pd[a](t.measureViewportBox(),window.getComputedStyle(t.current)),f!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=f),this.removedTransforms?.length&&this.removedTransforms.forEach(([m,g])=>{t.getValue(m).set(g)}),this.resolveNoneKeyframes()}}function XQ(e,t,a){if(e instanceof EventTarget)return[e];if(typeof e=="string"){let r=document;const o=a?.[e]??r.querySelectorAll(e);return o?Array.from(o):[]}return Array.from(e)}const Fz=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function qz(e){return F6(e)&&"offsetHeight"in e}var YQ={};const Gz=30,WQ=e=>!isNaN(parseFloat(e));class ZQ{constructor(t,a={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=(r,o=!0)=>{const c=yo.now();if(this.updatedAt!==c&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(const f of this.dependents)f.dirty();o&&this.events.renderRequest?.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=a.owner}setCurrent(t){this.current=t,this.updatedAt=yo.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=WQ(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return YQ.NODE_ENV!=="production"&&NO(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",t)}on(t,a){this.events[t]||(this.events[t]=new DO);const r=this.events[t].add(a);return t==="change"?()=>{r(),Pa.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,a){this.passiveEffect=t,this.stopPassiveEffect=a}set(t,a=!0){!a||!this.passiveEffect?this.updateAndNotify(t,a):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,a,r){this.set(a),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,a=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,a&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=yo.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>Gz)return 0;const a=Math.min(this.updatedAt-this.prevUpdatedAt,Gz);return G6(parseFloat(this.current)-parseFloat(this.prevFrameValue),a)}start(t){return this.stop(),new Promise(a=>{this.hasAnimated=!0,this.animation=t(a),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function np(e,t){return new ZQ(e,t)}const{schedule:cR}=oz(queueMicrotask,!1),os={x:!1,y:!1};function Xz(){return os.x||os.y}function KQ(e){return e==="x"||e==="y"?os[e]?null:(os[e]=!0,()=>{os[e]=!1}):os.x||os.y?null:(os.x=os.y=!0,()=>{os.x=os.y=!1})}function Yz(e,t){const a=XQ(e),r=new AbortController,o={passive:!0,...t,signal:r.signal};return[a,o,()=>r.abort()]}function Wz(e){return!(e.pointerType==="touch"||Xz())}function QQ(e,t,a={}){const[r,o,c]=Yz(e,a),f=m=>{if(!Wz(m))return;const{target:g}=m,p=t(g,m);if(typeof p!="function"||!g)return;const y=S=>{Wz(S)&&(p(S),g.removeEventListener("pointerleave",y))};g.addEventListener("pointerleave",y,o)};return r.forEach(m=>{m.addEventListener("pointerenter",f,o)}),c}const Zz=(e,t)=>t?e===t?!0:Zz(e,t.parentElement):!1,fR=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,JQ=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function eJ(e){return JQ.has(e.tagName)||e.tabIndex!==-1}const cx=new WeakSet;function Kz(e){return t=>{t.key==="Enter"&&e(t)}}function dR(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const tJ=(e,t)=>{const a=e.currentTarget;if(!a)return;const r=Kz(()=>{if(cx.has(a))return;dR(a,"down");const o=Kz(()=>{dR(a,"up")}),c=()=>dR(a,"cancel");a.addEventListener("keyup",o,t),a.addEventListener("blur",c,t)});a.addEventListener("keydown",r,t),a.addEventListener("blur",()=>a.removeEventListener("keydown",r),t)};function Qz(e){return fR(e)&&!Xz()}function nJ(e,t,a={}){const[r,o,c]=Yz(e,a),f=m=>{const g=m.currentTarget;if(!Qz(m))return;cx.add(g);const p=t(g,m),y=(T,O)=>{window.removeEventListener("pointerup",S),window.removeEventListener("pointercancel",E),cx.has(g)&&cx.delete(g),Qz(T)&&typeof p=="function"&&p(T,{success:O})},S=T=>{y(T,g===window||g===document||a.useGlobalTarget||Zz(g,T.target))},E=T=>{y(T,!1)};window.addEventListener("pointerup",S,o),window.addEventListener("pointercancel",E,o)};return r.forEach(m=>{(a.useGlobalTarget?window:m).addEventListener("pointerdown",f,o),qz(m)&&(m.addEventListener("focus",p=>tJ(p,o)),!eJ(m)&&!m.hasAttribute("tabindex")&&(m.tabIndex=0))}),c}function Jz(e){return F6(e)&&"ownerSVGElement"in e}function aJ(e){return Jz(e)&&e.tagName==="svg"}const Ti=e=>!!(e&&e.getVelocity),rJ=[...Bz,xr,rf],iJ=e=>rJ.find(Hz(e)),hR=x.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class oJ extends x.Component{getSnapshotBeforeUpdate(t){const a=this.props.childRef.current;if(a&&t.isPresent&&!this.props.isPresent){const r=a.offsetParent,o=qz(r)&&r.offsetWidth||0,c=this.props.sizeRef.current;c.height=a.offsetHeight||0,c.width=a.offsetWidth||0,c.top=a.offsetTop,c.left=a.offsetLeft,c.right=o-c.width-c.left}return null}componentDidUpdate(){}render(){return this.props.children}}function lJ({children:e,isPresent:t,anchorX:a,root:r}){const o=x.useId(),c=x.useRef(null),f=x.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:m}=x.useContext(hR);return x.useInsertionEffect(()=>{const{width:g,height:p,top:y,left:S,right:E}=f.current;if(t||!c.current||!g||!p)return;const T=a==="left"?`left: ${S}`:`right: ${E}`;c.current.dataset.motionPopId=o;const O=document.createElement("style");m&&(O.nonce=m);const M=r??document.head;return M.appendChild(O),O.sheet&&O.sheet.insertRule(`
645
645
  [data-motion-pop-id="${o}"] {
646
646
  position: absolute !important;
647
647
  width: ${g}px !important;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shopify-chatbot-widget",
3
3
  "private": false,
4
- "version": "0.4.7",
4
+ "version": "0.4.9",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",