@botuyo/chat-widget-standalone 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +243 -290
- package/dist/{ChatWidget-B6W68bT_.js → ChatWidget-BCHSZnMy.js} +17 -17
- package/dist/{ChatWidget-B6W68bT_.js.map → ChatWidget-BCHSZnMy.js.map} +1 -1
- package/dist/botuyo-chat.css +1 -1
- package/dist/botuyo-chat.js +1 -1
- package/dist/{chunk-audio-CgduwQLl.js → chunk-audio-BT2WWPfS.js} +2 -2
- package/dist/{chunk-audio-CgduwQLl.js.map → chunk-audio-BT2WWPfS.js.map} +1 -1
- package/dist/{chunk-chat-ui-EAAXXtnK.js → chunk-chat-ui-BHfnFN_3.js} +10 -10
- package/dist/{chunk-chat-ui-EAAXXtnK.js.map → chunk-chat-ui-BHfnFN_3.js.map} +1 -1
- package/dist/{chunk-gallery-B9sBFYYc.js → chunk-gallery-CHMxgXlB.js} +2 -2
- package/dist/{chunk-gallery-B9sBFYYc.js.map → chunk-gallery-CHMxgXlB.js.map} +1 -1
- package/dist/src/chat-widget/ChatWidget.d.ts +3 -0
- package/dist/src/chat-widget/ChatWidget.d.ts.map +1 -0
- package/dist/src/chat-widget/ChatWidgetProvider.d.ts +81 -0
- package/dist/src/chat-widget/ChatWidgetProvider.d.ts.map +1 -0
- package/dist/src/chat-widget/components/AudioPlayer.d.ts +8 -0
- package/dist/src/chat-widget/components/AudioPlayer.d.ts.map +1 -0
- package/dist/src/chat-widget/components/AudioPlayer.stories.d.ts +37 -0
- package/dist/src/chat-widget/components/AudioPlayer.stories.d.ts.map +1 -0
- package/dist/src/chat-widget/components/ChatWindow.d.ts +28 -0
- package/dist/src/chat-widget/components/ChatWindow.d.ts.map +1 -0
- package/dist/src/chat-widget/components/ChatWindow.stories.d.ts +71 -0
- package/dist/src/chat-widget/components/ChatWindow.stories.d.ts.map +1 -0
- package/dist/src/chat-widget/components/ErrorBoundary.d.ts +36 -0
- package/dist/src/chat-widget/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/src/chat-widget/components/ErrorBoundary.stories.d.ts +29 -0
- package/dist/src/chat-widget/components/ErrorBoundary.stories.d.ts.map +1 -0
- package/dist/src/chat-widget/components/Gallery.d.ts +14 -0
- package/dist/src/chat-widget/components/Gallery.d.ts.map +1 -0
- package/dist/src/chat-widget/components/Gallery.stories.d.ts +33 -0
- package/dist/src/chat-widget/components/Gallery.stories.d.ts.map +1 -0
- package/dist/src/chat-widget/components/Icons.d.ts +7 -0
- package/dist/src/chat-widget/components/Icons.d.ts.map +1 -0
- package/dist/src/chat-widget/components/InputArea.d.ts +20 -0
- package/dist/src/chat-widget/components/InputArea.d.ts.map +1 -0
- package/dist/src/chat-widget/components/InputArea.stories.d.ts +61 -0
- package/dist/src/chat-widget/components/InputArea.stories.d.ts.map +1 -0
- package/dist/src/chat-widget/components/LanguageSelector.d.ts +25 -0
- package/dist/src/chat-widget/components/LanguageSelector.d.ts.map +1 -0
- package/dist/src/chat-widget/components/Launcher.d.ts +21 -0
- package/dist/src/chat-widget/components/Launcher.d.ts.map +1 -0
- package/dist/src/chat-widget/components/Launcher.stories.d.ts +75 -0
- package/dist/src/chat-widget/components/Launcher.stories.d.ts.map +1 -0
- package/dist/src/chat-widget/components/LiveCallInputArea.d.ts +29 -0
- package/dist/src/chat-widget/components/LiveCallInputArea.d.ts.map +1 -0
- package/dist/src/chat-widget/components/MessageBubble.d.ts +14 -0
- package/dist/src/chat-widget/components/MessageBubble.d.ts.map +1 -0
- package/dist/src/chat-widget/components/MessageBubble.stories.d.ts +70 -0
- package/dist/src/chat-widget/components/MessageBubble.stories.d.ts.map +1 -0
- package/dist/src/chat-widget/components/MessageList.d.ts +15 -0
- package/dist/src/chat-widget/components/MessageList.d.ts.map +1 -0
- package/dist/src/chat-widget/components/MessageList.stories.d.ts +52 -0
- package/dist/src/chat-widget/components/MessageList.stories.d.ts.map +1 -0
- package/dist/src/chat-widget/components/TypingIndicator.d.ts +2 -0
- package/dist/src/chat-widget/components/TypingIndicator.d.ts.map +1 -0
- package/dist/src/chat-widget/components/TypingIndicator.stories.d.ts +39 -0
- package/dist/src/chat-widget/components/TypingIndicator.stories.d.ts.map +1 -0
- package/dist/src/chat-widget/components/VoiceInputArea.d.ts +26 -0
- package/dist/src/chat-widget/components/VoiceInputArea.d.ts.map +1 -0
- package/dist/src/chat-widget/components/index.d.ts +16 -0
- package/dist/src/chat-widget/components/index.d.ts.map +1 -0
- package/dist/src/chat-widget/hooks/useAnalytics.d.ts +19 -0
- package/dist/src/chat-widget/hooks/useAnalytics.d.ts.map +1 -0
- package/dist/src/chat-widget/hooks/useChatSocket.d.ts +30 -0
- package/dist/src/chat-widget/hooks/useChatSocket.d.ts.map +1 -0
- package/dist/src/chat-widget/hooks/useChatState.d.ts +23 -0
- package/dist/src/chat-widget/hooks/useChatState.d.ts.map +1 -0
- package/dist/src/chat-widget/hooks/useChatWidget.d.ts +48 -0
- package/dist/src/chat-widget/hooks/useChatWidget.d.ts.map +1 -0
- package/dist/src/chat-widget/hooks/useDarkMode.d.ts +6 -0
- package/dist/src/chat-widget/hooks/useDarkMode.d.ts.map +1 -0
- package/dist/src/chat-widget/hooks/useDynamicHeight.d.ts +10 -0
- package/dist/src/chat-widget/hooks/useDynamicHeight.d.ts.map +1 -0
- package/dist/src/chat-widget/hooks/useFocusTrap.d.ts +34 -0
- package/dist/src/chat-widget/hooks/useFocusTrap.d.ts.map +1 -0
- package/dist/src/chat-widget/hooks/useHighContrast.d.ts +6 -0
- package/dist/src/chat-widget/hooks/useHighContrast.d.ts.map +1 -0
- package/dist/src/chat-widget/hooks/useIsMobile.d.ts +2 -0
- package/dist/src/chat-widget/hooks/useIsMobile.d.ts.map +1 -0
- package/dist/src/chat-widget/hooks/useNotifications.d.ts +23 -0
- package/dist/src/chat-widget/hooks/useNotifications.d.ts.map +1 -0
- package/dist/src/chat-widget/hooks/useRateLimit.d.ts +15 -0
- package/dist/src/chat-widget/hooks/useRateLimit.d.ts.map +1 -0
- package/dist/src/chat-widget/hooks/useSEOMetadata.d.ts +10 -0
- package/dist/src/chat-widget/hooks/useSEOMetadata.d.ts.map +1 -0
- package/dist/src/chat-widget/hooks/useWidgetTheme.d.ts +12 -0
- package/dist/src/chat-widget/hooks/useWidgetTheme.d.ts.map +1 -0
- package/dist/src/chat-widget/i18n/LanguageContext.d.ts +33 -0
- package/dist/src/chat-widget/i18n/LanguageContext.d.ts.map +1 -0
- package/dist/src/chat-widget/i18n/index.d.ts +8 -0
- package/dist/src/chat-widget/i18n/index.d.ts.map +1 -0
- package/dist/src/chat-widget/i18n/translations.d.ts +177 -0
- package/dist/src/chat-widget/i18n/translations.d.ts.map +1 -0
- package/dist/src/chat-widget/i18n/useTranslations.d.ts +27 -0
- package/dist/src/chat-widget/i18n/useTranslations.d.ts.map +1 -0
- package/dist/src/chat-widget/index.d.ts +11 -0
- package/dist/src/chat-widget/index.d.ts.map +1 -0
- package/dist/src/chat-widget/types/index.d.ts +268 -0
- package/dist/src/chat-widget/types/index.d.ts.map +1 -0
- package/dist/src/chat-widget/types/socket.d.ts +101 -0
- package/dist/src/chat-widget/types/socket.d.ts.map +1 -0
- package/dist/src/chat-widget/utils/dateUtils.d.ts +33 -0
- package/dist/src/chat-widget/utils/dateUtils.d.ts.map +1 -0
- package/dist/src/chat-widget/utils/defaultAssets.d.ts +20 -0
- package/dist/src/chat-widget/utils/defaultAssets.d.ts.map +1 -0
- package/dist/src/chat-widget/utils/deviceId.d.ts +18 -0
- package/dist/src/chat-widget/utils/deviceId.d.ts.map +1 -0
- package/dist/src/chat-widget/utils/fileValidation.d.ts +75 -0
- package/dist/src/chat-widget/utils/fileValidation.d.ts.map +1 -0
- package/dist/src/chat-widget/utils/logger.d.ts +31 -0
- package/dist/src/chat-widget/utils/logger.d.ts.map +1 -0
- package/dist/src/chat-widget/utils/performance.d.ts +50 -0
- package/dist/src/chat-widget/utils/performance.d.ts.map +1 -0
- package/dist/src/chat-widget/utils/storage.d.ts +24 -0
- package/dist/src/chat-widget/utils/storage.d.ts.map +1 -0
- package/dist/src/chat-widget/utils/theme.d.ts +122 -0
- package/dist/src/chat-widget/utils/theme.d.ts.map +1 -0
- package/dist/src/chat-widget/utils/theme.examples.d.ts +47 -0
- package/dist/src/chat-widget/utils/theme.examples.d.ts.map +1 -0
- package/dist/src/chat-widget/utils/themes/index.d.ts +12 -0
- package/dist/src/chat-widget/utils/themes/index.d.ts.map +1 -0
- package/dist/src/chat-widget/voice/components/CallButton.d.ts +12 -0
- package/dist/src/chat-widget/voice/components/CallButton.d.ts.map +1 -0
- package/dist/src/chat-widget/voice/components/LiveCallOverlay.d.ts +12 -0
- package/dist/src/chat-widget/voice/components/LiveCallOverlay.d.ts.map +1 -0
- package/dist/src/chat-widget/voice/components/VoiceButton.d.ts +13 -0
- package/dist/src/chat-widget/voice/components/VoiceButton.d.ts.map +1 -0
- package/dist/src/chat-widget/voice/components/VoiceChatOverlay.d.ts +12 -0
- package/dist/src/chat-widget/voice/components/VoiceChatOverlay.d.ts.map +1 -0
- package/dist/src/chat-widget/voice/components/WaveformVisualizer.d.ts +12 -0
- package/dist/src/chat-widget/voice/components/WaveformVisualizer.d.ts.map +1 -0
- package/dist/src/chat-widget/voice/components/index.d.ts +10 -0
- package/dist/src/chat-widget/voice/components/index.d.ts.map +1 -0
- package/dist/src/chat-widget/voice/index.d.ts +11 -0
- package/dist/src/chat-widget/voice/index.d.ts.map +1 -0
- package/dist/src/chat-widget/voice/types.d.ts +232 -0
- package/dist/src/chat-widget/voice/types.d.ts.map +1 -0
- package/dist/src/chat-widget/voice/useLiveCall.d.ts +13 -0
- package/dist/src/chat-widget/voice/useLiveCall.d.ts.map +1 -0
- package/dist/src/chat-widget/voice/useVoiceChat.d.ts +13 -0
- package/dist/src/chat-widget/voice/useVoiceChat.d.ts.map +1 -0
- package/dist/src/chat-widget/voice/useVoiceState.d.ts +38 -0
- package/dist/src/chat-widget/voice/useVoiceState.d.ts.map +1 -0
- package/dist/src/lib/utils.d.ts +3 -0
- package/dist/src/lib/utils.d.ts.map +1 -0
- package/dist/standalone.d.ts +95 -0
- package/dist/standalone.d.ts.map +1 -0
- package/dist/stats.html +1 -1
- package/package.json +3 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e,j as t}from"./vendor-react-CtfcjTlq.js";import{u as n,g as r,D as o,c as s,X as i,M as a,l as c,m as u,t as d,e as l,f as p,h as f}from"./chunk-chat-ui-
|
|
1
|
+
import{r as e,j as t}from"./vendor-react-CtfcjTlq.js";import{u as n,g as r,D as o,c as s,X as i,M as a,l as c,m as u,t as d,e as l,f as p,h as f}from"./chunk-chat-ui-BHfnFN_3.js";import{l as m}from"./vendor-socket-DMqyM-90.js";function h({isOpen:u,onClick:d,unreadCount:l=0,primaryColor:p,logoUrl:f,starterPrompt:m,position:h="bottom-right",emotion:g="default",avatars:y={},styles:v,promptPersistence:b="session",avatarScale:_=1}){const{t:w}=n("extracted"),k=r({primaryColor:p}),z=v?.launcher?.bg,x=!1!==v?.launcher?.pulse,[S,E]=e.useState(!1),[O,I]=e.useState(!1),[$,N]=e.useState(!1),[C,T]=e.useState(!1),A="bottom-right"===h,j="chat_launcher_prompt_state",Z=e.useMemo(()=>y[g]||y.default||f||o,[g,y,f]);e.useEffect(()=>{T(!1)},[Z]),e.useEffect(()=>{const e=Object.values(y).filter(e=>!!e);f&&e.push(f),e.forEach(e=>{(new Image).src=e})},[y,f]),e.useEffect(()=>{"forever"===b&&"dismissed"===localStorage.getItem(j)&&N(!0)},[b]);const M=e.useCallback(()=>{I(!0),setTimeout(()=>E(!1),500),"always"!==b&&(N(!0),"forever"===b&&localStorage.setItem(j,"dismissed"))},[b]);return e.useEffect(()=>{if("always"!==b&&$||!m||u)return void E(!1);const e=setTimeout(()=>{E(!0),I(!1)},2e3),t=setTimeout(()=>M(),12e3);return()=>{clearTimeout(e),clearTimeout(t)}},[m,u,$,b,M]),/* @__PURE__ */t.jsxs("div",{className:s("flex items-center w-fit transition-all duration-500",A?"flex-row ml-auto":"flex-row-reverse mr-auto"),children:[
|
|
2
2
|
/* @__PURE__ */t.jsx("div",{className:s("transition-all duration-700 ease-in-out flex items-center",S?s("opacity-100 translate-x-0 w-auto max-w-[350px]",A?"mr-4":"ml-4"):"opacity-0 translate-x-8 w-0 max-w-0 overflow-hidden"),children:/* @__PURE__ */t.jsxs("div",{className:s("relative px-5 py-3.5 shadow-soft-xl border flex items-center gap-3",v?.radius?.card||"rounded-[20px]",O&&"opacity-0 scale-95 transition-all duration-300",!S&&"hidden"),style:{width:"max-content",maxWidth:"280px",backgroundColor:"hsl(var(--background))",color:"hsl(var(--foreground))",borderColor:"hsl(var(--border))"},children:[
|
|
3
3
|
/* @__PURE__ */t.jsx("span",{className:"text-sm font-semibold leading-tight tracking-tight whitespace-nowrap",children:m}),
|
|
4
4
|
/* @__PURE__ */t.jsx("button",{onClick:e=>{e.stopPropagation(),M()},className:"text-muted-foreground hover:text-foreground transition-colors p-1 rounded-full hover:bg-muted shrink-0",children:/* @__PURE__ */t.jsx(i,{className:"h-3.5 w-3.5 stroke-[2.5]"})}),
|
|
@@ -7,27 +7,27 @@ import{r as e,j as t}from"./vendor-react-CtfcjTlq.js";import{u as n,g as r,D as
|
|
|
7
7
|
/* @__PURE__ */t.jsxs("div",{className:"relative flex items-center justify-center shrink-0",children:[!u&&x&&/* @__PURE__ */t.jsx("span",{className:"absolute inset-0 flex items-center justify-center",children:/* @__PURE__ */t.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-20",style:{backgroundColor:k}})}),
|
|
8
8
|
/* @__PURE__ */t.jsxs("button",{type:"button",onClick:()=>{c.debug("Launcher handleMainAction called, isOpen:",u),N(!0),"forever"===b&&localStorage.setItem(j,"dismissed"),d()},className:s("relative z-10 h-14 w-14 sm:h-16 sm:w-16","flex items-center justify-center text-white transition-all duration-500","hover:scale-110 active:scale-95 shadow-soft-xl cursor-pointer",!u&&"hover:rotate-6",v?.radius?.button||"rounded-full",z),style:{backgroundColor:k||"hsl(160, 84%, 39%)"},"aria-label":u?"Cerrar chat":"Abrir chat",children:[
|
|
9
9
|
/* @__PURE__ */t.jsxs("div",{className:"relative h-full w-full flex items-center justify-center overflow-hidden rounded-inherit",children:[
|
|
10
|
-
/* @__PURE__ */t.jsx("div",{className:s("absolute inset-0 transition-all duration-500 flex items-center justify-center",u?"opacity-0 scale-50 rotate-90":"opacity-100 scale-100 rotate-0"),children:Z&&!
|
|
10
|
+
/* @__PURE__ */t.jsx("div",{className:s("absolute inset-0 transition-all duration-500 flex items-center justify-center",u?"opacity-0 scale-50 rotate-90":"opacity-100 scale-100 rotate-0"),children:Z&&!C?/* @__PURE__ */t.jsx("img",{src:Z,alt:w("assistant"),className:"w-full h-full object-cover",style:{transform:`scale(${_})`},onError:()=>T(!0)},Z):/* @__PURE__ */t.jsx(a,{className:"h-7 w-7 sm:h-8 sm:w-8 fill-current"})}),
|
|
11
11
|
/* @__PURE__ */t.jsx("div",{className:s("absolute inset-0 transition-all duration-500 flex items-center justify-center bg-black/5 dark:bg-white/10",u?"opacity-100 scale-100 rotate-0":"opacity-0 scale-50 -rotate-90"),children:/* @__PURE__ */t.jsx(i,{className:"h-7 w-7 sm:h-8 sm:w-8 stroke-[2.5]"})})]}),!u&&l>0&&/* @__PURE__ */t.jsx("div",{className:"absolute -top-1 -right-1 z-20 flex h-6 w-6 items-center justify-center bg-destructive text-destructive-foreground rounded-full border-2 border-background text-[10px] font-black shadow-soft-md tabular-nums",children:l>9?"9+":l})]})]})]})}class g extends e.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){c.error("ErrorBoundary caught error:",e,t),this.props.onError?.(e,t)}handleReset=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:/* @__PURE__ */t.jsxs("div",{className:"flex flex-col items-center justify-center p-8 bg-background text-center",children:[
|
|
12
12
|
/* @__PURE__ */t.jsx("div",{className:"text-6xl mb-4",children:"⚠️"}),
|
|
13
13
|
/* @__PURE__ */t.jsx("h2",{className:"text-xl font-bold text-foreground mb-2",children:"Algo salió mal"}),
|
|
14
14
|
/* @__PURE__ */t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-md",children:this.state.error?.message||"Ocurrió un error inesperado"}),
|
|
15
|
-
/* @__PURE__ */t.jsx("button",{onClick:this.handleReset,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg font-medium hover:opacity-90 transition-opacity",children:"Intentar de nuevo"})]}):this.props.children}}const y={bubble:"rounded-2xl",image:"rounded-xl",button:"rounded-xl",card:"rounded-2xl"},v={bg:"bg-muted/50 dark:bg-muted/20",text:"text-foreground",border:"border-border/50"},b={text:"text-primary-foreground"};const _=(e,t)=>t.some(t=>e instanceof t);let w,k;const z=/* @__PURE__ */new WeakMap,x=/* @__PURE__ */new WeakMap,S=/* @__PURE__ */new WeakMap;let E={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return z.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return $(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function O(e){E=e(E)}function I(e){return"function"==typeof e?(t=e,(k||(k=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(N(this),e),$(this.request)}:function(...e){return $(t.apply(N(this),e))}):(e instanceof IDBTransaction&&function(e){if(z.has(e))return;const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",s),e.removeEventListener("abort",s)},o=()=>{t(),r()},s=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",s),e.addEventListener("abort",s)});z.set(e,t)}(e),_(e,w||(w=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,E):e);var t}function $(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("success",o),e.removeEventListener("error",s)},o=()=>{t($(e.result)),r()},s=()=>{n(e.error),r()};e.addEventListener("success",o),e.addEventListener("error",s)});return S.set(t,e),t}(e);if(x.has(e))return x.get(e);const t=I(e);return t!==e&&(x.set(e,t),S.set(t,e)),t}const N=e=>S.get(e),T=["get","getKey","getAll","getAllKeys","count"],C=["put","add","delete","clear"],A=/* @__PURE__ */new Map;function j(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(A.get(t))return A.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,o=C.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!o&&!T.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,o?"readwrite":"readonly");let i=s.store;return r&&(i=i.index(t.shift())),(await Promise.all([i[n](...t),o&&s.done]))[0]};return A.set(t,s),s}O(e=>({...e,get:(t,n,r)=>j(t,n)||e.get(t,n,r),has:(t,n)=>!!j(t,n)||e.has(t,n)}));const Z=["continue","continuePrimaryKey","advance"],M={},P=/* @__PURE__ */new WeakMap,F=/* @__PURE__ */new WeakMap,D={get(e,t){if(!Z.includes(t))return e[t];let n=M[t];return n||(n=M[t]=function(...e){P.set(this,F.get(this)[t](...e))}),n}};async function*R(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const n=new Proxy(t,D);for(F.set(n,t),S.set(n,N(t));t;)yield n,t=await(P.get(n)||t.continue()),P.delete(n)}function U(e,t){return t===Symbol.asyncIterator&&_(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&_(e,[IDBIndex,IDBObjectStore])}O(e=>({...e,get:(t,n,r)=>U(t,n)?R:e.get(t,n,r),has:(t,n)=>U(t,n)||e.has(t,n)}));const L=new class{db=null;DB_NAME="botuyo-chat";DB_VERSION=1;async init(){try{this.db=await function(e,t,{blocked:n,upgrade:r,blocking:o,terminated:s}={}){const i=indexedDB.open(e,t),a=$(i);return r&&i.addEventListener("upgradeneeded",e=>{r($(i.result),e.oldVersion,e.newVersion,$(i.transaction),e)}),n&&i.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),a.then(e=>{s&&e.addEventListener("close",()=>s()),o&&e.addEventListener("versionchange",e=>o(e.oldVersion,e.newVersion,e))}).catch(()=>{}),a}(this.DB_NAME,this.DB_VERSION,{upgrade(e){e.objectStoreNames.contains("messages")||e.createObjectStore("messages",{keyPath:"id"}).createIndex("by-timestamp","timestamp"),e.objectStoreNames.contains("metadata")||e.createObjectStore("metadata")}}),c.info("IndexedDB initialized")}catch(e){throw c.error("Failed to initialize IndexedDB:",e),e}}async saveMessage(e){this.db||await this.init();try{await this.db.put("messages",e)}catch(t){c.error("Failed to save message:",t)}}async saveMessages(e){this.db||await this.init();try{const t=this.db.transaction("messages","readwrite");await Promise.all([...e.map(e=>t.store.put(e)),t.done])}catch(t){c.error("Failed to save messages:",t)}}async getMessages(e=100){this.db||await this.init();try{return(await this.db.getAllFromIndex("messages","by-timestamp")).slice(-e)}catch(t){return c.error("Failed to get messages:",t),[]}}async getMessage(e){this.db||await this.init();try{return await this.db.get("messages",e)}catch(t){return void c.error("Failed to get message:",t)}}async deleteMessage(e){this.db||await this.init();try{await this.db.delete("messages",e)}catch(t){c.error("Failed to delete message:",t)}}async clearMessages(){this.db||await this.init();try{await this.db.clear("messages"),c.info("Messages cleared from IndexedDB")}catch(e){c.error("Failed to clear messages:",e)}}async setMetadata(e){this.db||await this.init();try{await this.db.put("metadata",e,"chat-metadata")}catch(t){c.error("Failed to set metadata:",t)}}async getMetadata(){this.db||await this.init();try{return await this.db.get("metadata","chat-metadata")}catch(e){return c.error("Failed to get metadata:",e),null}}async clearAll(){this.db||await this.init();try{await Promise.all([this.db.clear("messages"),this.db.clear("metadata")]),c.info("All data cleared from IndexedDB")}catch(e){c.error("Failed to clear all data:",e)}}async migrateFromLocalStorage(){try{const e="botuyo_chat_v1",t=localStorage.getItem(e);if(!t)return;const n=JSON.parse(t);if(n.messages&&Array.isArray(n.messages)){const e=n.messages.map(e=>({...e,timestamp:new Date(e.timestamp)}));await this.saveMessages(e),c.info(`Migrated ${e.length} messages from localStorage`)}n.sessionId&&await this.setMetadata({sessionId:n.sessionId}),localStorage.removeItem(e),c.info("Migration from localStorage completed")}catch(e){c.error("Failed to migrate from localStorage:",e)}}},J="botuyo_chat_v1",B={isOpen:!1,isConnected:!1,isTyping:!1,messages:[],error:null,sessionId:null};function W(e,t){switch(t.type){case"TOGGLE_WINDOW":return{...e,isOpen:!e.isOpen};case"OPEN_WINDOW":return{...e,isOpen:!0};case"CLOSE_WINDOW":return{...e,isOpen:!1};case"SET_CONNECTED":return{...e,isConnected:t.payload};case"SET_TYPING":return{...e,isTyping:t.payload};case"ADD_MESSAGE":{if(e.messages.some(e=>e.id===t.payload.id))return e;const n=[...e.messages,t.payload],r="bot"===t.payload.sender;return{...e,messages:n,isTyping:!r&&e.isTyping}}case"SET_MESSAGES":return{...e,messages:[...t.payload]};case"SET_ERROR":return{...e,error:t.payload};case"SET_SESSION_ID":return{...e,sessionId:t.payload};case"CLEAR_CHAT":return{...B,isOpen:e.isOpen};case"RESTORE_SESSION":return{...e,...t.payload,isConnected:!1,isTyping:!1,error:null};default:return e}}function V(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:i,traits:/* @__PURE__ */new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const o=i.prototype,s=Object.keys(o);for(let e=0;e<s.length;e++){const t=s[e];t in n||(n[t]=o[t].bind(n))}}const o=n?.Parent??Object;class s extends o{}function i(e){var t;const o=n?.Parent?new s:this;r(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const n of o._zod.deferred)n();return o}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class q extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class G extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const K={};function H(e){return K}function X(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function Y(e,t){return"bigint"==typeof t?t.toString():t}function Q(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ee(e){return null==e}function te(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const ne=/* @__PURE__ */Symbol("evaluating");function re(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ne)return void 0===r&&(r=ne,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function oe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function se(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ie(e){return JSON.stringify(e)}const ae="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ce(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const ue=Q(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function de(e){if(!1===ce(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==ce(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function le(e){return de(e)?{...e}:Array.isArray(e)?[...e]:e}const pe=/* @__PURE__ */new Set(["string","number","symbol"]);function fe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function me(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function he(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const ge={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ye(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function ve(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function be(e){return"string"==typeof e?e:e?.message}function _e(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=be(e.inst?._zod.def?.error?.(e))??be(t?.error?.(e))??be(n.customError?.(e))??be(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function we(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function ke(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const ze=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Y,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},xe=V("$ZodError",ze),Se=V("$ZodError",ze,{Parent:Error}),Ee=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new q;if(i.issues.length){const t=new(o?.Err??e)(i.issues.map(e=>_e(e,s,H())));throw ae(t,o?.callee),t}return i.value},Oe=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const t=new(o?.Err??e)(i.issues.map(e=>_e(e,s,H())));throw ae(t,o?.callee),t}return i.value},Ie=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new q;return s.issues.length?{success:!1,error:new(e??xe)(s.issues.map(e=>_e(e,o,H())))}:{success:!0,data:s.value}},$e=/* @__PURE__ */Ie(Se),Ne=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(e=>_e(e,o,H())))}:{success:!0,data:s.value}},Te=/* @__PURE__ */Ne(Se),Ce=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ee(e)(t,n,o)},Ae=e=>(t,n,r)=>Ee(e)(t,n,r),je=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oe(e)(t,n,o)},Ze=e=>async(t,n,r)=>Oe(e)(t,n,r),Me=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ie(e)(t,n,o)},Pe=e=>(t,n,r)=>Ie(e)(t,n,r),Fe=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ne(e)(t,n,o)},De=e=>async(t,n,r)=>Ne(e)(t,n,r),Re=/^[cC][^\s-]{8,}$/,Ue=/^[0-9a-z]+$/,Le=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Je=/^[0-9a-vA-V]{20}$/,Be=/^[A-Za-z0-9]{27}$/,We=/^[a-zA-Z0-9_-]{21}$/,Ve=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qe=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ge=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ke=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,He=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Xe=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Ye=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Qe=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,et=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tt=/^[A-Za-z0-9_-]*$/,nt=/^\+[1-9]\d{6,14}$/,rt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",ot=/* @__PURE__ */new RegExp(`^${rt}$`);function st(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const it=/^-?\d+$/,at=/^-?\d+(?:\.\d+)?$/,ct=/^[^A-Z]*$/,ut=/^[^a-z]*$/,dt=/* @__PURE__ */V("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),lt={number:"number",bigint:"bigint",object:"date"},pt=/* @__PURE__ */V("$ZodCheckLessThan",(e,t)=>{dt.init(e,t);const n=lt[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ft=/* @__PURE__ */V("$ZodCheckGreaterThan",(e,t)=>{dt.init(e,t);const n=lt[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mt=/* @__PURE__ */V("$ZodCheckMultipleOf",(e,t)=>{dt.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value===BigInt(0):0===function(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(0===o&&/\d?e-\d?/.test(r)){const e=r.match(/\d?e-(\d?)/);e?.[1]&&(o=Number.parseInt(e[1]))}const s=n>o?n:o;return Number.parseInt(e.toFixed(s).replace(".",""))%Number.parseInt(t.toFixed(s).replace(".",""))/10**s}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ht=/* @__PURE__ */V("$ZodCheckNumberFormat",(e,t)=>{dt.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=ge[t.format];e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,r.minimum=o,r.maximum=s,n&&(r.pattern=it)}),e._zod.check=i=>{const a=i.value;if(n){if(!Number.isInteger(a))return void i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}))}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),gt=/* @__PURE__ */V("$ZodCheckMaxLength",(e,t)=>{var n;dt.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!ee(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const o=we(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),yt=/* @__PURE__ */V("$ZodCheckMinLength",(e,t)=>{var n;dt.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!ee(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const o=we(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),vt=/* @__PURE__ */V("$ZodCheckLengthEquals",(e,t)=>{var n;dt.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!ee(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const r=n.value,o=r.length;if(o===t.length)return;const s=we(r),i=o>t.length;n.issues.push({origin:s,...i?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),bt=/* @__PURE__ */V("$ZodCheckStringFormat",(e,t)=>{var n,r;dt.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=/* @__PURE__ */new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),_t=/* @__PURE__ */V("$ZodCheckRegex",(e,t)=>{bt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),wt=/* @__PURE__ */V("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ct),bt.init(e,t)}),kt=/* @__PURE__ */V("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ut),bt.init(e,t)}),zt=/* @__PURE__ */V("$ZodCheckIncludes",(e,t)=>{dt.init(e,t);const n=fe(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),xt=/* @__PURE__ */V("$ZodCheckStartsWith",(e,t)=>{dt.init(e,t);const n=new RegExp(`^${fe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),St=/* @__PURE__ */V("$ZodCheckEndsWith",(e,t)=>{dt.init(e,t);const n=new RegExp(`.*${fe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Et=/* @__PURE__ */V("$ZodCheckOverwrite",(e,t)=>{dt.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Ot{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const o of r)this.content.push(o)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const It={major:4,minor:3,patch:6},$t=/* @__PURE__ */V("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=It;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const t of o._zod.onattach)t(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,n)=>{let r,o=ye(e);for(const s of t){if(s._zod.def.when){if(!s._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,i=s._zod.check(e);if(i instanceof Promise&&!1===n?.async)throw new q;if(r||i instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await i,e.issues.length!==t&&(o||(o=ye(e,t)))});else{if(e.issues.length===t)continue;o||(o=ye(e,t))}}return r?r.then(()=>e):e},n=(n,o,s)=>{if(ye(n))return n.aborted=!0,n;const i=t(o,r,s);if(i instanceof Promise){if(!1===s.async)throw new q;return i.then(t=>e._zod.parse(t,s))}return e._zod.parse(i,s)};e._zod.run=(o,s)=>{if(s.skipChecks)return e._zod.parse(o,s);if("backward"===s.direction){const t=e._zod.parse({value:o.value,issues:[]},{...s,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,o,s)):n(t,o,s)}const i=e._zod.parse(o,s);if(i instanceof Promise){if(!1===s.async)throw new q;return i.then(e=>t(e,r,s))}return t(i,r,s)}}re(e,"~standard",()=>({validate:t=>{try{const n=$e(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Te(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Nt=/* @__PURE__ */V("$ZodString",(e,t)=>{var n;$t.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(o){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Tt=/* @__PURE__ */V("$ZodStringFormat",(e,t)=>{bt.init(e,t),Nt.init(e,t)}),Ct=/* @__PURE__ */V("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=qe),Tt.init(e,t)}),At=/* @__PURE__ */V("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ge(e))}else t.pattern??(t.pattern=Ge());Tt.init(e,t)}),jt=/* @__PURE__ */V("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ke),Tt.init(e,t)}),Zt=/* @__PURE__ */V("$ZodURL",(e,t)=>{Tt.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=o.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Mt=/* @__PURE__ */V("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Tt.init(e,t)}),Pt=/* @__PURE__ */V("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=We),Tt.init(e,t)}),Ft=/* @__PURE__ */V("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Re),Tt.init(e,t)}),Dt=/* @__PURE__ */V("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ue),Tt.init(e,t)}),Rt=/* @__PURE__ */V("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Le),Tt.init(e,t)}),Ut=/* @__PURE__ */V("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Je),Tt.init(e,t)}),Lt=/* @__PURE__ */V("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Be),Tt.init(e,t)}),Jt=/* @__PURE__ */V("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=st({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${rt}T(?:${r})$`)}(t)),Tt.init(e,t)}),Bt=/* @__PURE__ */V("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ot),Tt.init(e,t)}),Wt=/* @__PURE__ */V("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${st(t)}$`)),Tt.init(e,t)}),Vt=/* @__PURE__ */V("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ve),Tt.init(e,t)}),qt=/* @__PURE__ */V("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=He),Tt.init(e,t),e._zod.bag.format="ipv4"}),Gt=/* @__PURE__ */V("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Xe),Tt.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Kt=/* @__PURE__ */V("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ye),Tt.init(e,t)}),Ht=/* @__PURE__ */V("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Qe),Tt.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(2!==r.length)throw new Error;const[e,t]=r;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Xt(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Yt=/* @__PURE__ */V("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=et),Tt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Xt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Qt=/* @__PURE__ */V("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=tt),Tt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!tt.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Xt(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),en=/* @__PURE__ */V("$ZodE164",(e,t)=>{t.pattern??(t.pattern=nt),Tt.init(e,t)}),tn=/* @__PURE__ */V("$ZodJWT",(e,t)=>{Tt.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),nn=/* @__PURE__ */V("$ZodNumber",(e,t)=>{$t.init(e,t),e._zod.pattern=e._zod.bag.pattern??at,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(i){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),rn=/* @__PURE__ */V("$ZodNumberFormat",(e,t)=>{ht.init(e,t),nn.init(e,t)}),on=/* @__PURE__ */V("$ZodAny",(e,t)=>{$t.init(e,t),e._zod.parse=e=>e}),sn=/* @__PURE__ */V("$ZodUnknown",(e,t)=>{$t.init(e,t),e._zod.parse=e=>e}),an=/* @__PURE__ */V("$ZodNever",(e,t)=>{$t.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function cn(e,t,n){e.issues.length&&t.issues.push(...ve(n,e.issues)),t.value[n]=e.value}const un=/* @__PURE__ */V("$ZodArray",(e,t)=>{$t.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let e=0;e<o.length;e++){const i=o[e],a=t.element._zod.run({value:i,issues:[]},r);a instanceof Promise?s.push(a.then(t=>cn(t,n,e))):cn(a,n,e)}return s.length?Promise.all(s).then(()=>n):n}});function dn(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...ve(n,e.issues))}void 0===e.value?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function ln(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter(e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function pn(e,t,n,r,o,s){const i=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,d="optional"===c.optout;for(const l in t){if(a.has(l))continue;if("never"===u){i.push(l);continue}const o=c.run({value:t[l],issues:[]},r);o instanceof Promise?e.push(o.then(e=>dn(e,n,l,t,d))):dn(o,n,l,t,d)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const fn=/* @__PURE__ */V("$ZodObject",(e,t)=>{$t.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const r=Q(()=>ln(t));re(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=/* @__PURE__ */new Set);for(const e of r.values)n[t].add(e)}}return n});const o=ce,s=t.catchall;let i;e._zod.parse=(t,n)=>{i??(i=r.value);const a=t.value;if(!o(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const c=[],u=i.shape;for(const e of i.keys){const r=u[e],o="optional"===r._zod.optout,s=r._zod.run({value:a[e],issues:[]},n);s instanceof Promise?c.push(s.then(n=>dn(n,t,e,a,o))):dn(s,t,e,a,o)}return s?pn(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}}),mn=/* @__PURE__ */V("$ZodObjectJIT",(e,t)=>{fn.init(e,t);const n=e._zod.parse,r=Q(()=>ln(t));let o;const s=ce,i=!K.jitless,a=i&&ue.value,c=t.catchall;let u;e._zod.parse=(d,l)=>{u??(u=r.value);const p=d.value;return s(p)?i&&a&&!1===l?.async&&!0!==l.jitless?(o||(o=(e=>{const t=new Ot(["shape","payload","ctx"]),n=r.value,o=e=>{const t=ie(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const s=/* @__PURE__ */Object.create(null);let i=0;for(const r of n.keys)s[r]="key_"+i++;t.write("const newResult = {};");for(const r of n.keys){const n=s[r],i=ie(r),a=e[r],c="optional"===a?._zod?.optout;t.write(`const ${n} = ${o(r)};`),c?t.write(`\n if (${n}.issues.length) {\n if (${i} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${i}, ...iss.path] : [${i}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${i} in input) {\n newResult[${i}] = undefined;\n }\n } else {\n newResult[${i}] = ${n}.value;\n }\n \n `):t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${i}, ...iss.path] : [${i}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${i} in input) {\n newResult[${i}] = undefined;\n }\n } else {\n newResult[${i}] = ${n}.value;\n }\n \n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),d=o(d,l),c?pn([],p,d,l,u,e):d):n(d,l):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}});function hn(e,t,n,r){for(const s of e)if(0===s.issues.length)return t.value=s.value,t;const o=e.filter(e=>!ye(e));return 1===o.length?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>_e(e,r,H())))}),t)}const gn=/* @__PURE__ */V("$ZodUnion",(e,t)=>{$t.init(e,t),re(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),re(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),re(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),re(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>te(e.source)).join("|")})$`)}});const n=1===t.options.length,r=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(n)return r(o,s);let i=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:o.value,issues:[]},s);if(t instanceof Promise)a.push(t),i=!0;else{if(0===t.issues.length)return t;a.push(t)}}return i?Promise.all(a).then(t=>hn(t,o,e,s)):hn(a,o,e,s)}}),yn=/* @__PURE__ */V("$ZodIntersection",(e,t)=>{$t.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,o=t.left._zod.run({value:r,issues:[]},n),s=t.right._zod.run({value:r,issues:[]},n);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([t,n])=>bn(e,t,n)):bn(e,o,s)}});function vn(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(de(e)&&de(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),o={...e,...t};for(const s of r){const n=vn(e[s],t[s]);if(!n.valid)return{valid:!1,mergeErrorPath:[s,...n.mergeErrorPath]};o[s]=n.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=vn(e[r],t[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function bn(e,t,n){const r=/* @__PURE__ */new Map;let o;for(const a of t.issues)if("unrecognized_keys"===a.code){o??(o=a);for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(a);for(const a of n.issues)if("unrecognized_keys"===a.code)for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(a);const s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length&&o&&e.issues.push({...o,keys:s}),ye(e))return e;const i=vn(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const _n=/* @__PURE__ */V("$ZodEnum",(e,t)=>{$t.init(e,t);const n=X(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>pe.has(typeof e)).map(e=>"string"==typeof e?fe(e):e.toString()).join("|")})$`),e._zod.parse=(t,o)=>{const s=t.value;return r.has(s)||t.issues.push({code:"invalid_value",values:n,input:s,inst:e}),t}}),wn=/* @__PURE__ */V("$ZodTransform",(e,t)=>{$t.init(e,t),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new G(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(n.value=e,n));if(o instanceof Promise)throw new q;return n.value=o,n}});function kn(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const zn=/* @__PURE__ */V("$ZodOptional",(e,t)=>{$t.init(e,t),e._zod.optin="optional",e._zod.optout="optional",re(e._zod,"values",()=>t.innerType._zod.values?/* @__PURE__ */new Set([...t.innerType._zod.values,void 0]):void 0),re(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${te(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>kn(t,e.value)):kn(r,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),xn=/* @__PURE__ */V("$ZodExactOptional",(e,t)=>{zn.init(e,t),re(e._zod,"values",()=>t.innerType._zod.values),re(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Sn=/* @__PURE__ */V("$ZodNullable",(e,t)=>{$t.init(e,t),re(e._zod,"optin",()=>t.innerType._zod.optin),re(e._zod,"optout",()=>t.innerType._zod.optout),re(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${te(e.source)}|null)$`):void 0}),re(e._zod,"values",()=>t.innerType._zod.values?/* @__PURE__ */new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),En=/* @__PURE__ */V("$ZodDefault",(e,t)=>{$t.init(e,t),e._zod.optin="optional",re(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>On(e,t)):On(r,t)}});function On(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const In=/* @__PURE__ */V("$ZodPrefault",(e,t)=>{$t.init(e,t),e._zod.optin="optional",re(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),$n=/* @__PURE__ */V("$ZodNonOptional",(e,t)=>{$t.init(e,t),re(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(t=>Nn(t,e)):Nn(o,e)}});function Nn(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Tn=/* @__PURE__ */V("$ZodCatch",(e,t)=>{$t.init(e,t),re(e._zod,"optin",()=>t.innerType._zod.optin),re(e._zod,"optout",()=>t.innerType._zod.optout),re(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>_e(e,n,H()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>_e(e,n,H()))},input:e.value}),e.issues=[]),e)}}),Cn=/* @__PURE__ */V("$ZodPipe",(e,t)=>{$t.init(e,t),re(e._zod,"values",()=>t.in._zod.values),re(e._zod,"optin",()=>t.in._zod.optin),re(e._zod,"optout",()=>t.out._zod.optout),re(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>An(e,t.in,n)):An(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>An(e,t.out,n)):An(r,t.out,n)}});function An(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const jn=/* @__PURE__ */V("$ZodReadonly",(e,t)=>{$t.init(e,t),re(e._zod,"propValues",()=>t.innerType._zod.propValues),re(e._zod,"values",()=>t.innerType._zod.values),re(e._zod,"optin",()=>t.innerType?._zod?.optin),re(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Zn):Zn(r)}});function Zn(e){return e.value=Object.freeze(e.value),e}const Mn=/* @__PURE__ */V("$ZodCustom",(e,t)=>{dt.init(e,t),$t.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(t=>Pn(t,n,r,e));Pn(o,n,r,e)}});function Pn(e,t,n,r){if(!e){const e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(ke(e))}}var Fn;(Fn=globalThis).__zod_globalRegistry??(Fn.__zod_globalRegistry=new class{constructor(){this._map=/* @__PURE__ */new WeakMap,this._idmap=/* @__PURE__ */new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */new WeakMap,this._idmap=/* @__PURE__ */new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}});const Dn=globalThis.__zod_globalRegistry;function Rn(e,t){return new e({type:"string",...he(t)})}function Un(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...he(t)})}function Ln(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...he(t)})}function Jn(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...he(t)})}function Bn(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...he(t)})}function Wn(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...he(t)})}function Vn(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...he(t)})}function qn(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...he(t)})}function Gn(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...he(t)})}function Kn(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...he(t)})}function Hn(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...he(t)})}function Xn(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...he(t)})}function Yn(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...he(t)})}function Qn(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...he(t)})}function er(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...he(t)})}function tr(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...he(t)})}function nr(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...he(t)})}function rr(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...he(t)})}function or(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...he(t)})}function sr(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...he(t)})}function ir(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...he(t)})}function ar(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...he(t)})}function cr(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...he(t)})}function ur(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...he(t)})}function dr(e,t){return new e({type:"string",format:"date",check:"string_format",...he(t)})}function lr(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...he(t)})}function pr(e,t){return new e({type:"string",format:"duration",check:"string_format",...he(t)})}function fr(e,t){return new e({type:"number",checks:[],...he(t)})}function mr(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...he(t)})}function hr(e){return new e({type:"any"})}function gr(e){return new e({type:"unknown"})}function yr(e,t){return new e({type:"never",...he(t)})}function vr(e,t){return new pt({check:"less_than",...he(t),value:e,inclusive:!1})}function br(e,t){return new pt({check:"less_than",...he(t),value:e,inclusive:!0})}function _r(e,t){return new ft({check:"greater_than",...he(t),value:e,inclusive:!1})}function wr(e,t){return new ft({check:"greater_than",...he(t),value:e,inclusive:!0})}function kr(e,t){return new mt({check:"multiple_of",...he(t),value:e})}function zr(e,t){return new gt({check:"max_length",...he(t),maximum:e})}function xr(e,t){return new yt({check:"min_length",...he(t),minimum:e})}function Sr(e,t){return new vt({check:"length_equals",...he(t),length:e})}function Er(e,t){return new _t({check:"string_format",format:"regex",...he(t),pattern:e})}function Or(e){return new wt({check:"string_format",format:"lowercase",...he(e)})}function Ir(e){return new kt({check:"string_format",format:"uppercase",...he(e)})}function $r(e,t){return new zt({check:"string_format",format:"includes",...he(t),includes:e})}function Nr(e,t){return new xt({check:"string_format",format:"starts_with",...he(t),prefix:e})}function Tr(e,t){return new St({check:"string_format",format:"ends_with",...he(t),suffix:e})}function Cr(e){return new Et({check:"overwrite",tx:e})}function Ar(e){/* @__PURE__ */
|
|
16
|
-
return
|
|
17
|
-
return
|
|
18
|
-
return
|
|
19
|
-
return
|
|
20
|
-
return
|
|
21
|
-
return
|
|
15
|
+
/* @__PURE__ */t.jsx("button",{onClick:this.handleReset,className:"px-4 py-2 bg-primary text-primary-foreground rounded-lg font-medium hover:opacity-90 transition-opacity",children:"Intentar de nuevo"})]}):this.props.children}}const y={bubble:"rounded-2xl",image:"rounded-xl",button:"rounded-xl",card:"rounded-2xl"},v={bg:"bg-muted/50 dark:bg-muted/20",text:"text-foreground",border:"border-border/50"},b={text:"text-primary-foreground"};const _=(e,t)=>t.some(t=>e instanceof t);let w,k;const z=/* @__PURE__ */new WeakMap,x=/* @__PURE__ */new WeakMap,S=/* @__PURE__ */new WeakMap;let E={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return z.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return $(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function O(e){E=e(E)}function I(e){return"function"==typeof e?(t=e,(k||(k=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(N(this),e),$(this.request)}:function(...e){return $(t.apply(N(this),e))}):(e instanceof IDBTransaction&&function(e){if(z.has(e))return;const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",s),e.removeEventListener("abort",s)},o=()=>{t(),r()},s=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",s),e.addEventListener("abort",s)});z.set(e,t)}(e),_(e,w||(w=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,E):e);var t}function $(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("success",o),e.removeEventListener("error",s)},o=()=>{t($(e.result)),r()},s=()=>{n(e.error),r()};e.addEventListener("success",o),e.addEventListener("error",s)});return S.set(t,e),t}(e);if(x.has(e))return x.get(e);const t=I(e);return t!==e&&(x.set(e,t),S.set(t,e)),t}const N=e=>S.get(e),C=["get","getKey","getAll","getAllKeys","count"],T=["put","add","delete","clear"],A=/* @__PURE__ */new Map;function j(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(A.get(t))return A.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,o=T.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!o&&!C.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,o?"readwrite":"readonly");let i=s.store;return r&&(i=i.index(t.shift())),(await Promise.all([i[n](...t),o&&s.done]))[0]};return A.set(t,s),s}O(e=>({...e,get:(t,n,r)=>j(t,n)||e.get(t,n,r),has:(t,n)=>!!j(t,n)||e.has(t,n)}));const Z=["continue","continuePrimaryKey","advance"],M={},P=/* @__PURE__ */new WeakMap,D=/* @__PURE__ */new WeakMap,F={get(e,t){if(!Z.includes(t))return e[t];let n=M[t];return n||(n=M[t]=function(...e){P.set(this,D.get(this)[t](...e))}),n}};async function*R(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const n=new Proxy(t,F);for(D.set(n,t),S.set(n,N(t));t;)yield n,t=await(P.get(n)||t.continue()),P.delete(n)}function U(e,t){return t===Symbol.asyncIterator&&_(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&_(e,[IDBIndex,IDBObjectStore])}O(e=>({...e,get:(t,n,r)=>U(t,n)?R:e.get(t,n,r),has:(t,n)=>U(t,n)||e.has(t,n)}));const L=new class{db=null;DB_NAME="botuyo-chat";DB_VERSION=1;async init(){try{this.db=await function(e,t,{blocked:n,upgrade:r,blocking:o,terminated:s}={}){const i=indexedDB.open(e,t),a=$(i);return r&&i.addEventListener("upgradeneeded",e=>{r($(i.result),e.oldVersion,e.newVersion,$(i.transaction),e)}),n&&i.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),a.then(e=>{s&&e.addEventListener("close",()=>s()),o&&e.addEventListener("versionchange",e=>o(e.oldVersion,e.newVersion,e))}).catch(()=>{}),a}(this.DB_NAME,this.DB_VERSION,{upgrade(e){e.objectStoreNames.contains("messages")||e.createObjectStore("messages",{keyPath:"id"}).createIndex("by-timestamp","timestamp"),e.objectStoreNames.contains("metadata")||e.createObjectStore("metadata")}}),c.info("IndexedDB initialized")}catch(e){throw c.error("Failed to initialize IndexedDB:",e),e}}async saveMessage(e){this.db||await this.init();try{await this.db.put("messages",e)}catch(t){c.error("Failed to save message:",t)}}async saveMessages(e){this.db||await this.init();try{const t=this.db.transaction("messages","readwrite");await Promise.all([...e.map(e=>t.store.put(e)),t.done])}catch(t){c.error("Failed to save messages:",t)}}async getMessages(e=100){this.db||await this.init();try{return(await this.db.getAllFromIndex("messages","by-timestamp")).slice(-e)}catch(t){return c.error("Failed to get messages:",t),[]}}async getMessage(e){this.db||await this.init();try{return await this.db.get("messages",e)}catch(t){return void c.error("Failed to get message:",t)}}async deleteMessage(e){this.db||await this.init();try{await this.db.delete("messages",e)}catch(t){c.error("Failed to delete message:",t)}}async clearMessages(){this.db||await this.init();try{await this.db.clear("messages"),c.info("Messages cleared from IndexedDB")}catch(e){c.error("Failed to clear messages:",e)}}async setMetadata(e){this.db||await this.init();try{await this.db.put("metadata",e,"chat-metadata")}catch(t){c.error("Failed to set metadata:",t)}}async getMetadata(){this.db||await this.init();try{return await this.db.get("metadata","chat-metadata")}catch(e){return c.error("Failed to get metadata:",e),null}}async clearAll(){this.db||await this.init();try{await Promise.all([this.db.clear("messages"),this.db.clear("metadata")]),c.info("All data cleared from IndexedDB")}catch(e){c.error("Failed to clear all data:",e)}}async migrateFromLocalStorage(){try{const e="botuyo_chat_v1",t=localStorage.getItem(e);if(!t)return;const n=JSON.parse(t);if(n.messages&&Array.isArray(n.messages)){const e=n.messages.map(e=>({...e,timestamp:new Date(e.timestamp)}));await this.saveMessages(e),c.info(`Migrated ${e.length} messages from localStorage`)}n.sessionId&&await this.setMetadata({sessionId:n.sessionId}),localStorage.removeItem(e),c.info("Migration from localStorage completed")}catch(e){c.error("Failed to migrate from localStorage:",e)}}},J="botuyo_chat_v1",B={isOpen:!1,isConnected:!1,isTyping:!1,messages:[],error:null,sessionId:null};function W(e,t){switch(t.type){case"TOGGLE_WINDOW":return{...e,isOpen:!e.isOpen};case"OPEN_WINDOW":return{...e,isOpen:!0};case"CLOSE_WINDOW":return{...e,isOpen:!1};case"SET_CONNECTED":return{...e,isConnected:t.payload};case"SET_TYPING":return{...e,isTyping:t.payload};case"ADD_MESSAGE":{if(e.messages.some(e=>e.id===t.payload.id))return e;const n=[...e.messages,t.payload],r="bot"===t.payload.sender;return{...e,messages:n,isTyping:!r&&e.isTyping}}case"SET_MESSAGES":return{...e,messages:[...t.payload]};case"SET_ERROR":return{...e,error:t.payload};case"SET_SESSION_ID":return{...e,sessionId:t.payload};case"CLEAR_CHAT":return{...B,isOpen:e.isOpen};case"RESTORE_SESSION":return{...e,...t.payload,isConnected:!1,isTyping:!1,error:null};default:return e}}function V(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:i,traits:/* @__PURE__ */new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const o=i.prototype,s=Object.keys(o);for(let e=0;e<s.length;e++){const t=s[e];t in n||(n[t]=o[t].bind(n))}}const o=n?.Parent??Object;class s extends o{}function i(e){var t;const o=n?.Parent?new s:this;r(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const n of o._zod.deferred)n();return o}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class q extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class G extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const K={};function H(e){return K}function Y(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function X(e,t){return"bigint"==typeof t?t.toString():t}function Q(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ee(e){return null==e}function te(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const ne=/* @__PURE__ */Symbol("evaluating");function re(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ne)return void 0===r&&(r=ne,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function oe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function se(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ie(e){return JSON.stringify(e)}const ae="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ce(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const ue=Q(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function de(e){if(!1===ce(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==ce(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function le(e){return de(e)?{...e}:Array.isArray(e)?[...e]:e}const pe=/* @__PURE__ */new Set(["string","number","symbol"]);function fe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function me(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function he(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const ge={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ye(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function ve(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function be(e){return"string"==typeof e?e:e?.message}function _e(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=be(e.inst?._zod.def?.error?.(e))??be(t?.error?.(e))??be(n.customError?.(e))??be(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function we(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function ke(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const ze=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,X,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},xe=V("$ZodError",ze),Se=V("$ZodError",ze,{Parent:Error}),Ee=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new q;if(i.issues.length){const t=new(o?.Err??e)(i.issues.map(e=>_e(e,s,H())));throw ae(t,o?.callee),t}return i.value},Oe=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const t=new(o?.Err??e)(i.issues.map(e=>_e(e,s,H())));throw ae(t,o?.callee),t}return i.value},Ie=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new q;return s.issues.length?{success:!1,error:new(e??xe)(s.issues.map(e=>_e(e,o,H())))}:{success:!0,data:s.value}},$e=/* @__PURE__ */Ie(Se),Ne=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(e=>_e(e,o,H())))}:{success:!0,data:s.value}},Ce=/* @__PURE__ */Ne(Se),Te=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ee(e)(t,n,o)},Ae=e=>(t,n,r)=>Ee(e)(t,n,r),je=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Oe(e)(t,n,o)},Ze=e=>async(t,n,r)=>Oe(e)(t,n,r),Me=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ie(e)(t,n,o)},Pe=e=>(t,n,r)=>Ie(e)(t,n,r),De=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ne(e)(t,n,o)},Fe=e=>async(t,n,r)=>Ne(e)(t,n,r),Re=/^[cC][^\s-]{8,}$/,Ue=/^[0-9a-z]+$/,Le=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Je=/^[0-9a-vA-V]{20}$/,Be=/^[A-Za-z0-9]{27}$/,We=/^[a-zA-Z0-9_-]{21}$/,Ve=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qe=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ge=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ke=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,He=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ye=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Xe=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Qe=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,et=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,tt=/^[A-Za-z0-9_-]*$/,nt=/^\+[1-9]\d{6,14}$/,rt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",ot=/* @__PURE__ */new RegExp(`^${rt}$`);function st(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const it=/^-?\d+$/,at=/^-?\d+(?:\.\d+)?$/,ct=/^[^A-Z]*$/,ut=/^[^a-z]*$/,dt=/* @__PURE__ */V("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),lt={number:"number",bigint:"bigint",object:"date"},pt=/* @__PURE__ */V("$ZodCheckLessThan",(e,t)=>{dt.init(e,t);const n=lt[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ft=/* @__PURE__ */V("$ZodCheckGreaterThan",(e,t)=>{dt.init(e,t);const n=lt[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mt=/* @__PURE__ */V("$ZodCheckMultipleOf",(e,t)=>{dt.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value===BigInt(0):0===function(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(0===o&&/\d?e-\d?/.test(r)){const e=r.match(/\d?e-(\d?)/);e?.[1]&&(o=Number.parseInt(e[1]))}const s=n>o?n:o;return Number.parseInt(e.toFixed(s).replace(".",""))%Number.parseInt(t.toFixed(s).replace(".",""))/10**s}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ht=/* @__PURE__ */V("$ZodCheckNumberFormat",(e,t)=>{dt.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=ge[t.format];e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,r.minimum=o,r.maximum=s,n&&(r.pattern=it)}),e._zod.check=i=>{const a=i.value;if(n){if(!Number.isInteger(a))return void i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}))}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),gt=/* @__PURE__ */V("$ZodCheckMaxLength",(e,t)=>{var n;dt.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!ee(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const o=we(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),yt=/* @__PURE__ */V("$ZodCheckMinLength",(e,t)=>{var n;dt.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!ee(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const o=we(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),vt=/* @__PURE__ */V("$ZodCheckLengthEquals",(e,t)=>{var n;dt.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!ee(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const r=n.value,o=r.length;if(o===t.length)return;const s=we(r),i=o>t.length;n.issues.push({origin:s,...i?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),bt=/* @__PURE__ */V("$ZodCheckStringFormat",(e,t)=>{var n,r;dt.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=/* @__PURE__ */new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),_t=/* @__PURE__ */V("$ZodCheckRegex",(e,t)=>{bt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),wt=/* @__PURE__ */V("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ct),bt.init(e,t)}),kt=/* @__PURE__ */V("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ut),bt.init(e,t)}),zt=/* @__PURE__ */V("$ZodCheckIncludes",(e,t)=>{dt.init(e,t);const n=fe(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),xt=/* @__PURE__ */V("$ZodCheckStartsWith",(e,t)=>{dt.init(e,t);const n=new RegExp(`^${fe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),St=/* @__PURE__ */V("$ZodCheckEndsWith",(e,t)=>{dt.init(e,t);const n=new RegExp(`.*${fe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=/* @__PURE__ */new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Et=/* @__PURE__ */V("$ZodCheckOverwrite",(e,t)=>{dt.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Ot{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const o of r)this.content.push(o)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const It={major:4,minor:3,patch:6},$t=/* @__PURE__ */V("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=It;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const t of o._zod.onattach)t(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,n)=>{let r,o=ye(e);for(const s of t){if(s._zod.def.when){if(!s._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,i=s._zod.check(e);if(i instanceof Promise&&!1===n?.async)throw new q;if(r||i instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await i,e.issues.length!==t&&(o||(o=ye(e,t)))});else{if(e.issues.length===t)continue;o||(o=ye(e,t))}}return r?r.then(()=>e):e},n=(n,o,s)=>{if(ye(n))return n.aborted=!0,n;const i=t(o,r,s);if(i instanceof Promise){if(!1===s.async)throw new q;return i.then(t=>e._zod.parse(t,s))}return e._zod.parse(i,s)};e._zod.run=(o,s)=>{if(s.skipChecks)return e._zod.parse(o,s);if("backward"===s.direction){const t=e._zod.parse({value:o.value,issues:[]},{...s,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,o,s)):n(t,o,s)}const i=e._zod.parse(o,s);if(i instanceof Promise){if(!1===s.async)throw new q;return i.then(e=>t(e,r,s))}return t(i,r,s)}}re(e,"~standard",()=>({validate:t=>{try{const n=$e(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Ce(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Nt=/* @__PURE__ */V("$ZodString",(e,t)=>{var n;$t.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(o){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Ct=/* @__PURE__ */V("$ZodStringFormat",(e,t)=>{bt.init(e,t),Nt.init(e,t)}),Tt=/* @__PURE__ */V("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=qe),Ct.init(e,t)}),At=/* @__PURE__ */V("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Ge(e))}else t.pattern??(t.pattern=Ge());Ct.init(e,t)}),jt=/* @__PURE__ */V("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ke),Ct.init(e,t)}),Zt=/* @__PURE__ */V("$ZodURL",(e,t)=>{Ct.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=o.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Mt=/* @__PURE__ */V("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ct.init(e,t)}),Pt=/* @__PURE__ */V("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=We),Ct.init(e,t)}),Dt=/* @__PURE__ */V("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Re),Ct.init(e,t)}),Ft=/* @__PURE__ */V("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ue),Ct.init(e,t)}),Rt=/* @__PURE__ */V("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Le),Ct.init(e,t)}),Ut=/* @__PURE__ */V("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Je),Ct.init(e,t)}),Lt=/* @__PURE__ */V("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Be),Ct.init(e,t)}),Jt=/* @__PURE__ */V("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=st({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${rt}T(?:${r})$`)}(t)),Ct.init(e,t)}),Bt=/* @__PURE__ */V("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ot),Ct.init(e,t)}),Wt=/* @__PURE__ */V("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${st(t)}$`)),Ct.init(e,t)}),Vt=/* @__PURE__ */V("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ve),Ct.init(e,t)}),qt=/* @__PURE__ */V("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=He),Ct.init(e,t),e._zod.bag.format="ipv4"}),Gt=/* @__PURE__ */V("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ye),Ct.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Kt=/* @__PURE__ */V("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Xe),Ct.init(e,t)}),Ht=/* @__PURE__ */V("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Qe),Ct.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(2!==r.length)throw new Error;const[e,t]=r;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Yt(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Xt=/* @__PURE__ */V("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=et),Ct.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Yt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Qt=/* @__PURE__ */V("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=tt),Ct.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!tt.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Yt(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),en=/* @__PURE__ */V("$ZodE164",(e,t)=>{t.pattern??(t.pattern=nt),Ct.init(e,t)}),tn=/* @__PURE__ */V("$ZodJWT",(e,t)=>{Ct.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),nn=/* @__PURE__ */V("$ZodNumber",(e,t)=>{$t.init(e,t),e._zod.pattern=e._zod.bag.pattern??at,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(i){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),rn=/* @__PURE__ */V("$ZodNumberFormat",(e,t)=>{ht.init(e,t),nn.init(e,t)}),on=/* @__PURE__ */V("$ZodAny",(e,t)=>{$t.init(e,t),e._zod.parse=e=>e}),sn=/* @__PURE__ */V("$ZodUnknown",(e,t)=>{$t.init(e,t),e._zod.parse=e=>e}),an=/* @__PURE__ */V("$ZodNever",(e,t)=>{$t.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function cn(e,t,n){e.issues.length&&t.issues.push(...ve(n,e.issues)),t.value[n]=e.value}const un=/* @__PURE__ */V("$ZodArray",(e,t)=>{$t.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let e=0;e<o.length;e++){const i=o[e],a=t.element._zod.run({value:i,issues:[]},r);a instanceof Promise?s.push(a.then(t=>cn(t,n,e))):cn(a,n,e)}return s.length?Promise.all(s).then(()=>n):n}});function dn(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...ve(n,e.issues))}void 0===e.value?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function ln(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter(e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function pn(e,t,n,r,o,s){const i=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,d="optional"===c.optout;for(const l in t){if(a.has(l))continue;if("never"===u){i.push(l);continue}const o=c.run({value:t[l],issues:[]},r);o instanceof Promise?e.push(o.then(e=>dn(e,n,l,t,d))):dn(o,n,l,t,d)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const fn=/* @__PURE__ */V("$ZodObject",(e,t)=>{$t.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const r=Q(()=>ln(t));re(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=/* @__PURE__ */new Set);for(const e of r.values)n[t].add(e)}}return n});const o=ce,s=t.catchall;let i;e._zod.parse=(t,n)=>{i??(i=r.value);const a=t.value;if(!o(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const c=[],u=i.shape;for(const e of i.keys){const r=u[e],o="optional"===r._zod.optout,s=r._zod.run({value:a[e],issues:[]},n);s instanceof Promise?c.push(s.then(n=>dn(n,t,e,a,o))):dn(s,t,e,a,o)}return s?pn(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}}),mn=/* @__PURE__ */V("$ZodObjectJIT",(e,t)=>{fn.init(e,t);const n=e._zod.parse,r=Q(()=>ln(t));let o;const s=ce,i=!K.jitless,a=i&&ue.value,c=t.catchall;let u;e._zod.parse=(d,l)=>{u??(u=r.value);const p=d.value;return s(p)?i&&a&&!1===l?.async&&!0!==l.jitless?(o||(o=(e=>{const t=new Ot(["shape","payload","ctx"]),n=r.value,o=e=>{const t=ie(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const s=/* @__PURE__ */Object.create(null);let i=0;for(const r of n.keys)s[r]="key_"+i++;t.write("const newResult = {};");for(const r of n.keys){const n=s[r],i=ie(r),a=e[r],c="optional"===a?._zod?.optout;t.write(`const ${n} = ${o(r)};`),c?t.write(`\n if (${n}.issues.length) {\n if (${i} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${i}, ...iss.path] : [${i}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${i} in input) {\n newResult[${i}] = undefined;\n }\n } else {\n newResult[${i}] = ${n}.value;\n }\n \n `):t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${i}, ...iss.path] : [${i}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${i} in input) {\n newResult[${i}] = undefined;\n }\n } else {\n newResult[${i}] = ${n}.value;\n }\n \n `)}t.write("payload.value = newResult;"),t.write("return payload;");const a=t.compile();return(t,n)=>a(e,t,n)})(t.shape)),d=o(d,l),c?pn([],p,d,l,u,e):d):n(d,l):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}});function hn(e,t,n,r){for(const s of e)if(0===s.issues.length)return t.value=s.value,t;const o=e.filter(e=>!ye(e));return 1===o.length?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>_e(e,r,H())))}),t)}const gn=/* @__PURE__ */V("$ZodUnion",(e,t)=>{$t.init(e,t),re(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),re(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),re(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),re(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>te(e.source)).join("|")})$`)}});const n=1===t.options.length,r=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(n)return r(o,s);let i=!1;const a=[];for(const e of t.options){const t=e._zod.run({value:o.value,issues:[]},s);if(t instanceof Promise)a.push(t),i=!0;else{if(0===t.issues.length)return t;a.push(t)}}return i?Promise.all(a).then(t=>hn(t,o,e,s)):hn(a,o,e,s)}}),yn=/* @__PURE__ */V("$ZodIntersection",(e,t)=>{$t.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,o=t.left._zod.run({value:r,issues:[]},n),s=t.right._zod.run({value:r,issues:[]},n);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([t,n])=>bn(e,t,n)):bn(e,o,s)}});function vn(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(de(e)&&de(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),o={...e,...t};for(const s of r){const n=vn(e[s],t[s]);if(!n.valid)return{valid:!1,mergeErrorPath:[s,...n.mergeErrorPath]};o[s]=n.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=vn(e[r],t[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function bn(e,t,n){const r=/* @__PURE__ */new Map;let o;for(const a of t.issues)if("unrecognized_keys"===a.code){o??(o=a);for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(a);for(const a of n.issues)if("unrecognized_keys"===a.code)for(const e of a.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(a);const s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length&&o&&e.issues.push({...o,keys:s}),ye(e))return e;const i=vn(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const _n=/* @__PURE__ */V("$ZodEnum",(e,t)=>{$t.init(e,t);const n=Y(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>pe.has(typeof e)).map(e=>"string"==typeof e?fe(e):e.toString()).join("|")})$`),e._zod.parse=(t,o)=>{const s=t.value;return r.has(s)||t.issues.push({code:"invalid_value",values:n,input:s,inst:e}),t}}),wn=/* @__PURE__ */V("$ZodTransform",(e,t)=>{$t.init(e,t),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new G(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(n.value=e,n));if(o instanceof Promise)throw new q;return n.value=o,n}});function kn(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const zn=/* @__PURE__ */V("$ZodOptional",(e,t)=>{$t.init(e,t),e._zod.optin="optional",e._zod.optout="optional",re(e._zod,"values",()=>t.innerType._zod.values?/* @__PURE__ */new Set([...t.innerType._zod.values,void 0]):void 0),re(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${te(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>kn(t,e.value)):kn(r,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),xn=/* @__PURE__ */V("$ZodExactOptional",(e,t)=>{zn.init(e,t),re(e._zod,"values",()=>t.innerType._zod.values),re(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Sn=/* @__PURE__ */V("$ZodNullable",(e,t)=>{$t.init(e,t),re(e._zod,"optin",()=>t.innerType._zod.optin),re(e._zod,"optout",()=>t.innerType._zod.optout),re(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${te(e.source)}|null)$`):void 0}),re(e._zod,"values",()=>t.innerType._zod.values?/* @__PURE__ */new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),En=/* @__PURE__ */V("$ZodDefault",(e,t)=>{$t.init(e,t),e._zod.optin="optional",re(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>On(e,t)):On(r,t)}});function On(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const In=/* @__PURE__ */V("$ZodPrefault",(e,t)=>{$t.init(e,t),e._zod.optin="optional",re(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),$n=/* @__PURE__ */V("$ZodNonOptional",(e,t)=>{$t.init(e,t),re(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(t=>Nn(t,e)):Nn(o,e)}});function Nn(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Cn=/* @__PURE__ */V("$ZodCatch",(e,t)=>{$t.init(e,t),re(e._zod,"optin",()=>t.innerType._zod.optin),re(e._zod,"optout",()=>t.innerType._zod.optout),re(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>_e(e,n,H()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>_e(e,n,H()))},input:e.value}),e.issues=[]),e)}}),Tn=/* @__PURE__ */V("$ZodPipe",(e,t)=>{$t.init(e,t),re(e._zod,"values",()=>t.in._zod.values),re(e._zod,"optin",()=>t.in._zod.optin),re(e._zod,"optout",()=>t.out._zod.optout),re(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>An(e,t.in,n)):An(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>An(e,t.out,n)):An(r,t.out,n)}});function An(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const jn=/* @__PURE__ */V("$ZodReadonly",(e,t)=>{$t.init(e,t),re(e._zod,"propValues",()=>t.innerType._zod.propValues),re(e._zod,"values",()=>t.innerType._zod.values),re(e._zod,"optin",()=>t.innerType?._zod?.optin),re(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Zn):Zn(r)}});function Zn(e){return e.value=Object.freeze(e.value),e}const Mn=/* @__PURE__ */V("$ZodCustom",(e,t)=>{dt.init(e,t),$t.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(t=>Pn(t,n,r,e));Pn(o,n,r,e)}});function Pn(e,t,n,r){if(!e){const e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(ke(e))}}var Dn;(Dn=globalThis).__zod_globalRegistry??(Dn.__zod_globalRegistry=new class{constructor(){this._map=/* @__PURE__ */new WeakMap,this._idmap=/* @__PURE__ */new Map}add(e,...t){const n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */new WeakMap,this._idmap=/* @__PURE__ */new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}});const Fn=globalThis.__zod_globalRegistry;function Rn(e,t){return new e({type:"string",...he(t)})}function Un(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...he(t)})}function Ln(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...he(t)})}function Jn(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...he(t)})}function Bn(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...he(t)})}function Wn(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...he(t)})}function Vn(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...he(t)})}function qn(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...he(t)})}function Gn(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...he(t)})}function Kn(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...he(t)})}function Hn(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...he(t)})}function Yn(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...he(t)})}function Xn(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...he(t)})}function Qn(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...he(t)})}function er(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...he(t)})}function tr(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...he(t)})}function nr(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...he(t)})}function rr(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...he(t)})}function or(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...he(t)})}function sr(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...he(t)})}function ir(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...he(t)})}function ar(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...he(t)})}function cr(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...he(t)})}function ur(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...he(t)})}function dr(e,t){return new e({type:"string",format:"date",check:"string_format",...he(t)})}function lr(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...he(t)})}function pr(e,t){return new e({type:"string",format:"duration",check:"string_format",...he(t)})}function fr(e,t){return new e({type:"number",checks:[],...he(t)})}function mr(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...he(t)})}function hr(e){return new e({type:"any"})}function gr(e){return new e({type:"unknown"})}function yr(e,t){return new e({type:"never",...he(t)})}function vr(e,t){return new pt({check:"less_than",...he(t),value:e,inclusive:!1})}function br(e,t){return new pt({check:"less_than",...he(t),value:e,inclusive:!0})}function _r(e,t){return new ft({check:"greater_than",...he(t),value:e,inclusive:!1})}function wr(e,t){return new ft({check:"greater_than",...he(t),value:e,inclusive:!0})}function kr(e,t){return new mt({check:"multiple_of",...he(t),value:e})}function zr(e,t){return new gt({check:"max_length",...he(t),maximum:e})}function xr(e,t){return new yt({check:"min_length",...he(t),minimum:e})}function Sr(e,t){return new vt({check:"length_equals",...he(t),length:e})}function Er(e,t){return new _t({check:"string_format",format:"regex",...he(t),pattern:e})}function Or(e){return new wt({check:"string_format",format:"lowercase",...he(e)})}function Ir(e){return new kt({check:"string_format",format:"uppercase",...he(e)})}function $r(e,t){return new zt({check:"string_format",format:"includes",...he(t),includes:e})}function Nr(e,t){return new xt({check:"string_format",format:"starts_with",...he(t),prefix:e})}function Cr(e,t){return new St({check:"string_format",format:"ends_with",...he(t),suffix:e})}function Tr(e){return new Et({check:"overwrite",tx:e})}function Ar(e){/* @__PURE__ */
|
|
16
|
+
return Tr(t=>t.normalize(e))}function jr(){/* @__PURE__ */
|
|
17
|
+
return Tr(e=>e.trim())}function Zr(){/* @__PURE__ */
|
|
18
|
+
return Tr(e=>e.toLowerCase())}function Mr(){/* @__PURE__ */
|
|
19
|
+
return Tr(e=>e.toUpperCase())}function Pr(){/* @__PURE__ */
|
|
20
|
+
return Tr(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e))}function Dr(e,t,n){return new e({type:"array",element:t,...he(n)})}function Fr(e,t,n){return new e({type:"custom",check:"custom",fn:t,...he(n)})}function Rr(e){const t=/* @__PURE__ */Ur(n=>(n.addIssue=e=>{if("string"==typeof e)n.issues.push(ke(e,n.value,t._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(ke(r))}},e(n.value,n)));return t}function Ur(e,t){const n=new dt({check:"custom",...he(t)});return n._zod.check=e,n}function Lr(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Fn,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:/* @__PURE__ */new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Jr(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,r);else{const n=i.schema,s=t.processors[o.type];if(!s)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);s(e,t,n,r)}const s=e._zod.parent;s&&(i.ref||(i.ref=s),Jr(s,t,r),t.seen.get(s).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),"input"===t.io&&Vr(e)&&(delete i.schema.examples,delete i.schema.default),"input"===t.io&&i.schema._prefault&&((r=i.schema).default??(r.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Br(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=/* @__PURE__ */new Map;for(const s of e.seen.entries()){const t=e.metadataRegistry.get(s[0])?.id;if(t){const e=r.get(t);if(e&&e!==s[0])throw new Error(`Duplicate schema id "${t}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(t,s[0])}}const o=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:o,defId:s}=(t=>{const r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const n=e.external.registry.get(t[0])?.id,o=e.external.uri??(e=>e);if(n)return{ref:o(n)};const s=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=s,{defId:s,ref:`${o("__shared")}#/${r}/${s}`}}if(t[1]===n)return{ref:"#"};const o=`#/${r}/`,s=t[1].schema.id??"__schema"+e.counter++;return{defId:s,ref:o+s}})(t);r.def={...r.schema},s&&(r.defId=s);const i=r.schema;for(const e in i)delete i[e];i.$ref=o};if("throw"===e.cycles)for(const s of e.seen.entries()){const e=s[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const n=s[1];if(t===s[0]){o(s);continue}if(e.external){const n=e.external.registry.get(s[0])?.id;if(t!==s[0]&&n){o(s);continue}}const r=e.metadataRegistry.get(s[0])?.id;(r||n.cycle||n.count>1&&"ref"===e.reused)&&o(s)}}function Wr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=t=>{const n=e.seen.get(t);if(null===n.ref)return;const o=n.def??n.schema,s={...o},i=n.ref;if(n.ref=null,i){r(i);const n=e.seen.get(i),a=n.schema;if(!a.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(o,a):(o.allOf=o.allOf??[],o.allOf.push(a)),Object.assign(o,s),t._zod.parent===i)for(const e in o)"$ref"!==e&&"allOf"!==e&&(e in s||delete o[e]);if(a.$ref&&n.def)for(const e in o)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(o[e])===JSON.stringify(n.def[e])&&delete o[e]}const a=t._zod.parent;if(a&&a!==i){r(a);const t=e.seen.get(a);if(t?.schema.$ref&&(o.$ref=t.schema.$ref,t.def))for(const e in o)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(o[e])===JSON.stringify(t.def[e])&&delete o[e]}e.override({zodSchema:t,jsonSchema:o,path:n.path??[]})};for(const a of[...e.seen.entries()].reverse())r(a[0]);const o={};if("draft-2020-12"===e.target?o.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?o.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const n=e.external.registry.get(t)?.id;if(!n)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(n)}Object.assign(o,n.def??n.schema);const s=e.external?.defs??{};for(const a of e.seen.entries()){const e=a[1];e.def&&e.defId&&(s[e.defId]=e.def)}e.external||Object.keys(s).length>0&&("draft-2020-12"===e.target?o.$defs=s:o.definitions=s);try{const n=JSON.parse(JSON.stringify(o));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:qr(t,"input",e.processors),output:qr(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(i){throw new Error("Error converting schema to JSON.")}}function Vr(e,t){const n=t??{seen:/* @__PURE__ */new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if("transform"===r.type)return!0;if("array"===r.type)return Vr(r.element,n);if("set"===r.type)return Vr(r.valueType,n);if("lazy"===r.type)return Vr(r.getter(),n);if("promise"===r.type||"optional"===r.type||"nonoptional"===r.type||"nullable"===r.type||"readonly"===r.type||"default"===r.type||"prefault"===r.type)return Vr(r.innerType,n);if("intersection"===r.type)return Vr(r.left,n)||Vr(r.right,n);if("record"===r.type||"map"===r.type)return Vr(r.keyType,n)||Vr(r.valueType,n);if("pipe"===r.type)return Vr(r.in,n)||Vr(r.out,n);if("object"===r.type){for(const e in r.shape)if(Vr(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(Vr(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(Vr(e,n))return!0;return!(!r.rest||!Vr(r.rest,n))}return!1}const qr=(e,t,n={})=>r=>{const{libraryOptions:o,target:s}=r??{},i=Lr({...o??{},target:s,io:t,processors:n});return Jr(e,i),Br(i,e),Wr(i,e)},Gr={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Kr=(e,t,n,r)=>{const o=e._zod.def;Jr(o.innerType,t,r),t.seen.get(e).ref=o.innerType},Hr=/* @__PURE__ */V("ZodISODateTime",(e,t)=>{Jt.init(e,t),vo.init(e,t)}),Yr=/* @__PURE__ */V("ZodISODate",(e,t)=>{Bt.init(e,t),vo.init(e,t)}),Xr=/* @__PURE__ */V("ZodISOTime",(e,t)=>{Wt.init(e,t),vo.init(e,t)}),Qr=/* @__PURE__ */V("ZodISODuration",(e,t)=>{Vt.init(e,t),vo.init(e,t)}),eo=V("ZodError",(e,t)=>{xe.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=e=>{for(const o of e.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(e=>r({issues:e}));else if("invalid_key"===o.code)r({issues:o.issues});else if("invalid_element"===o.code)r({issues:o.issues});else if(0===o.path.length)n._errors.push(t(o));else{let e=n,r=0;for(;r<o.path.length;){const n=o.path[r];r===o.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(o))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,X,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,X,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),to=/* @__PURE__ */Ee(eo),no=/* @__PURE__ */Oe(eo),ro=/* @__PURE__ */Ie(eo),oo=/* @__PURE__ */Ne(eo),so=/* @__PURE__ */Te(eo),io=/* @__PURE__ */Ae(eo),ao=/* @__PURE__ */je(eo),co=/* @__PURE__ */Ze(eo),uo=/* @__PURE__ */Me(eo),lo=/* @__PURE__ */Pe(eo),po=/* @__PURE__ */De(eo),fo=/* @__PURE__ */Fe(eo),mo=/* @__PURE__ */V("ZodType",(e,t)=>($t.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:qr(e,"input"),output:qr(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=Lr({...n,processors:t});return Jr(e,r),Br(r,e),Wr(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(se(t,{checks:[...t.checks??[],...n.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>me(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>to(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ro(e,t,n),e.parseAsync=async(t,n)=>no(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>oo(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>so(e,t,n),e.decode=(t,n)=>io(e,t,n),e.encodeAsync=async(t,n)=>ao(e,t,n),e.decodeAsync=async(t,n)=>co(e,t,n),e.safeEncode=(t,n)=>uo(e,t,n),e.safeDecode=(t,n)=>lo(e,t,n),e.safeEncodeAsync=async(t,n)=>po(e,t,n),e.safeDecodeAsync=async(t,n)=>fo(e,t,n),e.refine=(t,n)=>e.check(function(e,t={}){/* @__PURE__ */
|
|
21
|
+
return Fr(ls,e,t)}(t,n)),e.superRefine=t=>e.check(/* @__PURE__ */Rr(t)),e.overwrite=t=>e.check(/* @__PURE__ */Tr(t)),e.optional=()=>es(e),e.exactOptional=()=>new ts({type:"optional",innerType:e}),e.nullable=()=>rs(e),e.nullish=()=>es(rs(e)),e.nonoptional=t=>function(e,t){return new is({type:"nonoptional",innerType:e,...he(t)})}(e,t),e.array=()=>/* @__PURE__ */Dr(Vo,e,void 0),e.or=t=>new Go({type:"union",options:[e,t],...he(void 0)}),e.and=t=>new Ko({type:"intersection",left:e,right:t}),e.transform=t=>us(e,new Xo({type:"transform",transform:t})),e.default=t=>{return n=t,new os({type:"default",innerType:e,get defaultValue(){return"function"==typeof n?n():le(n)}});var n},e.prefault=t=>{return n=t,new ss({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof n?n():le(n)}});var n},e.catch=t=>{return new as({type:"catch",innerType:e,catchValue:"function"==typeof(n=t)?n:()=>n});var n},e.pipe=t=>us(e,t),e.readonly=()=>new ds({type:"readonly",innerType:e}),e.describe=t=>{const n=e.clone();return Fn.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>Fn.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Fn.get(e);const n=e.clone();return Fn.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),ho=/* @__PURE__ */V("_ZodString",(e,t)=>{Nt.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:o,maximum:s,format:i,patterns:a,contentEncoding:c}=e._zod.bag;if("number"==typeof o&&(r.minLength=o),"number"==typeof s&&(r.maxLength=s),i&&(r.format=Gr[i]??i,""===r.format&&delete r.format,"time"===i&&delete r.format),c&&(r.contentEncoding=c),a&&a.size>0){const e=[...a];1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(/* @__PURE__ */Er(...t)),e.includes=(...t)=>e.check(/* @__PURE__ */$r(...t)),e.startsWith=(...t)=>e.check(/* @__PURE__ */Nr(...t)),e.endsWith=(...t)=>e.check(/* @__PURE__ */Cr(...t)),e.min=(...t)=>e.check(/* @__PURE__ */xr(...t)),e.max=(...t)=>e.check(/* @__PURE__ */zr(...t)),e.length=(...t)=>e.check(/* @__PURE__ */Sr(...t)),e.nonempty=(...t)=>e.check(/* @__PURE__ */xr(1,...t)),e.lowercase=t=>e.check(/* @__PURE__ */Or(t)),e.uppercase=t=>e.check(/* @__PURE__ */Ir(t)),e.trim=()=>e.check(/* @__PURE__ */jr()),e.normalize=(...t)=>e.check(/* @__PURE__ */Ar(...t)),e.toLowerCase=()=>e.check(/* @__PURE__ */Zr()),e.toUpperCase=()=>e.check(/* @__PURE__ */Mr()),e.slugify=()=>e.check(/* @__PURE__ */Pr())}),go=/* @__PURE__ */V("ZodString",(e,t)=>{Nt.init(e,t),ho.init(e,t),e.email=t=>e.check(/* @__PURE__ */Un(bo,t)),e.url=t=>e.check(/* @__PURE__ */qn(ko,t)),e.jwt=t=>e.check(/* @__PURE__ */cr(Po,t)),e.emoji=t=>e.check(/* @__PURE__ */Gn(zo,t)),e.guid=t=>e.check(/* @__PURE__ */Ln(_o,t)),e.uuid=t=>e.check(/* @__PURE__ */Jn(wo,t)),e.uuidv4=t=>e.check(/* @__PURE__ */Bn(wo,t)),e.uuidv6=t=>e.check(/* @__PURE__ */Wn(wo,t)),e.uuidv7=t=>e.check(/* @__PURE__ */Vn(wo,t)),e.nanoid=t=>e.check(/* @__PURE__ */Kn(xo,t)),e.guid=t=>e.check(/* @__PURE__ */Ln(_o,t)),e.cuid=t=>e.check(/* @__PURE__ */Hn(So,t)),e.cuid2=t=>e.check(/* @__PURE__ */Yn(Eo,t)),e.ulid=t=>e.check(/* @__PURE__ */Xn(Oo,t)),e.base64=t=>e.check(/* @__PURE__ */sr(jo,t)),e.base64url=t=>e.check(/* @__PURE__ */ir(Zo,t)),e.xid=t=>e.check(/* @__PURE__ */Qn(Io,t)),e.ksuid=t=>e.check(/* @__PURE__ */er($o,t)),e.ipv4=t=>e.check(/* @__PURE__ */tr(No,t)),e.ipv6=t=>e.check(/* @__PURE__ */nr(Co,t)),e.cidrv4=t=>e.check(/* @__PURE__ */rr(To,t)),e.cidrv6=t=>e.check(/* @__PURE__ */or(Ao,t)),e.e164=t=>e.check(/* @__PURE__ */ar(Mo,t)),e.datetime=t=>e.check(function(e){/* @__PURE__ */
|
|
22
22
|
return ur(Hr,e)}(t)),e.date=t=>e.check(function(e){/* @__PURE__ */
|
|
23
|
-
return dr(
|
|
24
|
-
return lr(
|
|
23
|
+
return dr(Yr,e)}(t)),e.time=t=>e.check(function(e){/* @__PURE__ */
|
|
24
|
+
return lr(Xr,e)}(t)),e.duration=t=>e.check(function(e){/* @__PURE__ */
|
|
25
25
|
return pr(Qr,e)}(t))});function yo(e){/* @__PURE__ */
|
|
26
|
-
return Rn(go,e)}const vo=/* @__PURE__ */V("ZodStringFormat",(e,t)=>{
|
|
27
|
-
return fr(
|
|
26
|
+
return Rn(go,e)}const vo=/* @__PURE__ */V("ZodStringFormat",(e,t)=>{Ct.init(e,t),ho.init(e,t)}),bo=/* @__PURE__ */V("ZodEmail",(e,t)=>{jt.init(e,t),vo.init(e,t)}),_o=/* @__PURE__ */V("ZodGUID",(e,t)=>{Tt.init(e,t),vo.init(e,t)}),wo=/* @__PURE__ */V("ZodUUID",(e,t)=>{At.init(e,t),vo.init(e,t)}),ko=/* @__PURE__ */V("ZodURL",(e,t)=>{Zt.init(e,t),vo.init(e,t)}),zo=/* @__PURE__ */V("ZodEmoji",(e,t)=>{Mt.init(e,t),vo.init(e,t)}),xo=/* @__PURE__ */V("ZodNanoID",(e,t)=>{Pt.init(e,t),vo.init(e,t)}),So=/* @__PURE__ */V("ZodCUID",(e,t)=>{Dt.init(e,t),vo.init(e,t)}),Eo=/* @__PURE__ */V("ZodCUID2",(e,t)=>{Ft.init(e,t),vo.init(e,t)}),Oo=/* @__PURE__ */V("ZodULID",(e,t)=>{Rt.init(e,t),vo.init(e,t)}),Io=/* @__PURE__ */V("ZodXID",(e,t)=>{Ut.init(e,t),vo.init(e,t)}),$o=/* @__PURE__ */V("ZodKSUID",(e,t)=>{Lt.init(e,t),vo.init(e,t)}),No=/* @__PURE__ */V("ZodIPv4",(e,t)=>{qt.init(e,t),vo.init(e,t)}),Co=/* @__PURE__ */V("ZodIPv6",(e,t)=>{Gt.init(e,t),vo.init(e,t)}),To=/* @__PURE__ */V("ZodCIDRv4",(e,t)=>{Kt.init(e,t),vo.init(e,t)}),Ao=/* @__PURE__ */V("ZodCIDRv6",(e,t)=>{Ht.init(e,t),vo.init(e,t)}),jo=/* @__PURE__ */V("ZodBase64",(e,t)=>{Xt.init(e,t),vo.init(e,t)}),Zo=/* @__PURE__ */V("ZodBase64URL",(e,t)=>{Qt.init(e,t),vo.init(e,t)}),Mo=/* @__PURE__ */V("ZodE164",(e,t)=>{en.init(e,t),vo.init(e,t)}),Po=/* @__PURE__ */V("ZodJWT",(e,t)=>{tn.init(e,t),vo.init(e,t)}),Do=/* @__PURE__ */V("ZodNumber",(e,t)=>{nn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,{minimum:o,maximum:s,format:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u}=e._zod.bag;"string"==typeof i&&i.includes("int")?r.type="integer":r.type="number","number"==typeof u&&("draft-04"===t.target||"openapi-3.0"===t.target?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u),"number"==typeof o&&(r.minimum=o,"number"==typeof u&&"draft-04"!==t.target&&(u>=o?delete r.minimum:delete r.exclusiveMinimum)),"number"==typeof c&&("draft-04"===t.target||"openapi-3.0"===t.target?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c),"number"==typeof s&&(r.maximum=s,"number"==typeof c&&"draft-04"!==t.target&&(c<=s?delete r.maximum:delete r.exclusiveMaximum)),"number"==typeof a&&(r.multipleOf=a)})(e,t,n),e.gt=(t,n)=>e.check(/* @__PURE__ */_r(t,n)),e.gte=(t,n)=>e.check(/* @__PURE__ */wr(t,n)),e.min=(t,n)=>e.check(/* @__PURE__ */wr(t,n)),e.lt=(t,n)=>e.check(/* @__PURE__ */vr(t,n)),e.lte=(t,n)=>e.check(/* @__PURE__ */br(t,n)),e.max=(t,n)=>e.check(/* @__PURE__ */br(t,n)),e.int=t=>e.check(Uo(t)),e.safe=t=>e.check(Uo(t)),e.positive=t=>e.check(/* @__PURE__ */_r(0,t)),e.nonnegative=t=>e.check(/* @__PURE__ */wr(0,t)),e.negative=t=>e.check(/* @__PURE__ */vr(0,t)),e.nonpositive=t=>e.check(/* @__PURE__ */br(0,t)),e.multipleOf=(t,n)=>e.check(/* @__PURE__ */kr(t,n)),e.step=(t,n)=>e.check(/* @__PURE__ */kr(t,n)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Fo(e){/* @__PURE__ */
|
|
27
|
+
return fr(Do,e)}const Ro=/* @__PURE__ */V("ZodNumberFormat",(e,t)=>{rn.init(e,t),Do.init(e,t)});function Uo(e){/* @__PURE__ */
|
|
28
28
|
return mr(Ro,e)}const Lo=/* @__PURE__ */V("ZodAny",(e,t)=>{on.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}}),Jo=/* @__PURE__ */V("ZodUnknown",(e,t)=>{sn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function Bo(){/* @__PURE__ */
|
|
29
|
-
return gr(Jo)}const Wo=/* @__PURE__ */V("ZodNever",(e,t)=>{an.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)}),Vo=/* @__PURE__ */V("ZodArray",(e,t)=>{un.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;"number"==typeof i&&(o.minItems=i),"number"==typeof a&&(o.maxItems=a),o.type="array",o.items=Jr(s.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(/* @__PURE__ */xr(t,n)),e.nonempty=t=>e.check(/* @__PURE__ */xr(1,t)),e.max=(t,n)=>e.check(/* @__PURE__ */zr(t,n)),e.length=(t,n)=>e.check(/* @__PURE__ */Sr(t,n)),e.unwrap=()=>e.element}),qo=/* @__PURE__ */V("ZodObject",(e,t)=>{mn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object",o.properties={};const i=s.shape;for(const u in i)o.properties[u]=Jr(i[u],t,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(e=>{const n=s.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));c.size>0&&(o.required=Array.from(c)),"never"===s.catchall?._zod.def.type?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=Jr(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)})(e,t,n,r),re(e,"shape",()=>t.shape),e.keyof=()=>Xo(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Bo()}),e.loose=()=>e.clone({...e._zod.def,catchall:Bo()}),e.strict=()=>e.clone({...e._zod.def,catchall:/* @__PURE__ */yr(Wo,void 0)}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!de(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=se(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return oe(this,"shape",n),n}});return me(e,r)}(e,t),e.safeExtend=t=>function(e,t){if(!de(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=se(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return oe(this,"shape",n),n}});return me(e,n)}(e,t),e.merge=t=>function(e,t){const n=se(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return oe(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return me(e,n)}(e,t),e.pick=t=>function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return me(e,se(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return oe(this,"shape",e),e},checks:[]}))}(e,t),e.omit=t=>function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=se(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return oe(this,"shape",r),r},checks:[]});return me(e,o)}(e,t),e.partial=(...t)=>function(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=se(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)o[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return oe(this,"shape",o),o},checks:[]});return me(t,o)}(Qo,e,t[0]),e.required=(...t)=>function(e,t,n){const r=se(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=new e({type:"nonoptional",innerType:r[t]}))}else for(const t in r)o[t]=new e({type:"nonoptional",innerType:r[t]});return oe(this,"shape",o),o}});return me(t,r)}(is,e,t[0])}),Go=/* @__PURE__ */V("ZodUnion",(e,t)=>{gn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,s=!1===o.inclusive,i=o.options.map((e,n)=>Jr(e,t,{...r,path:[...r.path,s?"oneOf":"anyOf",n]}));s?n.oneOf=i:n.anyOf=i})(e,t,n,r),e.options=t.options}),Ko=/* @__PURE__ */V("ZodIntersection",(e,t)=>{yn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,s=Jr(o.left,t,{...r,path:[...r.path,"allOf",0]}),i=Jr(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c})(e,t,n,r)}),Ho=/* @__PURE__ */V("ZodEnum",(e,t)=>{_n.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=X(e._zod.def.entries);r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=r})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const o={};for(const s of e){if(!n.has(s))throw new Error(`Key ${s} not found in enum`);o[s]=t.entries[s]}return new Ho({...t,checks:[],...he(r),entries:o})},e.exclude=(e,r)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new Ho({...t,checks:[],...he(r),entries:o})}});function Xo(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ho({type:"enum",entries:n,...he(t)})}const Yo=/* @__PURE__ */V("ZodTransform",(e,t)=>{wn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new G(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(ke(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(ke(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(e=>(n.value=e,n)):(n.value=o,n)}}),Qo=/* @__PURE__ */V("ZodOptional",(e,t)=>{zn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kr(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function es(e){return new Qo({type:"optional",innerType:e})}const ts=/* @__PURE__ */V("ZodExactOptional",(e,t)=>{xn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kr(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}),ns=/* @__PURE__ */V("ZodNullable",(e,t)=>{Sn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,s=Jr(o.innerType,t,r),i=t.seen.get(e);"openapi-3.0"===t.target?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rs(e){return new ns({type:"nullable",innerType:e})}const os=/* @__PURE__ */V("ZodDefault",(e,t)=>{En.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;Jr(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),ss=/* @__PURE__ */V("ZodPrefault",(e,t)=>{In.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;Jr(o.innerType,t,r),t.seen.get(e).ref=o.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),is=/* @__PURE__ */V("ZodNonOptional",(e,t)=>{$n.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;Jr(o.innerType,t,r),t.seen.get(e).ref=o.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}),as=/* @__PURE__ */V("ZodCatch",(e,t)=>{Tn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;let s;Jr(o.innerType,t,r),t.seen.get(e).ref=o.innerType;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),cs=/* @__PURE__ */V("ZodPipe",(e,t)=>{Cn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,s="input"===t.io?"transform"===o.in._zod.def.type?o.out:o.in:o.out;Jr(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function us(e,t){return new cs({type:"pipe",in:e,out:t})}const ds=/* @__PURE__ */V("ZodReadonly",(e,t)=>{jn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;Jr(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),ls=/* @__PURE__ */V("ZodCustom",(e,t)=>{Mn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)}),ps="chat_device_id";function fs(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}class ms{queue=[];endpoint;apiKey;flushInterval=null;MAX_QUEUE_SIZE=100;FLUSH_INTERVAL_MS=3e4;BATCH_SIZE=10;constructor(e,t){this.endpoint=e,this.apiKey=t,this.startAutoFlush()}startAutoFlush(){this.flushInterval=setInterval(()=>{this.queue.length>0&&this.flush()},this.FLUSH_INTERVAL_MS)}trackOpen(){this.track("chat_opened")}trackClose(){this.track("chat_closed")}trackMessageSent(e){this.track("message_sent",{type:e})}trackMessageReceived(e,t){this.track("message_received",{type:e,latency:t})}trackError(e,t){this.track("error",{error:e,context:t})}trackConnectionStatus(e){this.track("connection_status",{isConnected:e})}trackFeatureUsed(e){this.track("feature_used",{feature:e})}trackTypingStarted(){this.track("typing_started")}trackAttachmentSent(e,t){this.track("attachment_sent",{type:e,size:t})}track(e,t){this.queue.push({event:e,properties:{...t,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0},timestamp:Date.now()}),this.queue.length>=this.BATCH_SIZE&&this.flush(),this.queue.length>this.MAX_QUEUE_SIZE&&(this.queue=this.queue.slice(-this.MAX_QUEUE_SIZE),c.warn("Analytics queue overflow, dropping old events"))}async flush(){if(0===this.queue.length)return;const e=[...this.queue];this.queue=[];try{const t=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({events:e}),keepalive:!0});if(t.ok)c.debug(`Analytics: Flushed ${e.length} events`);else{if(!(t.status>=400&&t.status<500))throw new Error(`Server error: ${t.status}`);c.debug(`Analytics endpoint returned ${t.status}, events discarded`)}}catch(t){c.debug("Analytics flush failed:",t),this.queue.length+e.length<=this.MAX_QUEUE_SIZE&&this.queue.unshift(...e)}}destroy(){this.flushInterval&&clearInterval(this.flushInterval),this.flush()}}function hs(t){const{apiKey:r,apiBaseUrl:s,pageContext:i,includeSEOMetadata:a=!1,theme:u,userContext:p,onLogin:f,onNavigate:h,onEvent:g,onStateChange:y,onThemeUpdate:v}=t,[b,_]=e.useState(0),w=e.useRef(0),{t:k}=n(),z=function(t,n,r=!0){const o=e.useRef(null);return e.useEffect(()=>{if(!r||!t||!n)return;const e=`${t}/analytics`;o.current=new ms(e,n);const s=()=>o.current?.flush(),i=()=>{"hidden"===document.visibilityState&&o.current?.flush()};return window.addEventListener("beforeunload",s),window.addEventListener("visibilitychange",i),()=>{window.removeEventListener("beforeunload",s),window.removeEventListener("visibilitychange",i),o.current?.destroy()}},[t,n,r]),{trackOpen:e.useCallback(()=>{o.current?.trackOpen()},[]),trackClose:e.useCallback(()=>{o.current?.trackClose()},[]),trackMessageSent:e.useCallback(e=>{o.current?.trackMessageSent(e)},[]),trackMessageReceived:e.useCallback((e,t)=>{o.current?.trackMessageReceived(e,t)},[]),trackError:e.useCallback((e,t)=>{o.current?.trackError(e,t)},[]),trackConnectionStatus:e.useCallback(e=>{o.current?.trackConnectionStatus(e)},[]),trackFeatureUsed:e.useCallback(e=>{o.current?.trackFeatureUsed(e)},[])}}(s,r,!0),x=function({enabled:t=!0,soundEnabled:n=!0,desktopEnabled:r=!0,botName:s="Asistente",logoUrl:i,notificationSoundUrl:a}={}){const[u,d]=e.useState("default"),p=e.useRef(null),f=i||o,m=a||l;e.useEffect(()=>{n&&"undefined"!=typeof window&&(p.current=new Audio(m),p.current.volume=.3)},[n,m]),e.useEffect(()=>{"undefined"!=typeof window&&"Notification"in window&&d(Notification.permission)},[]);const h=e.useCallback(async()=>{if("undefined"==typeof window||!("Notification"in window))return c.warn("Notifications API not available"),!1;try{const e=await Notification.requestPermission();return d(e),c.info("Notification permission:",e),"granted"===e}catch(e){return c.error("Error requesting notification permission:",e),!1}},[]),g=e.useCallback(e=>{if(t&&r&&"granted"===u&&("undefined"==typeof document||!document.hasFocus()))try{const t=`Nuevo mensaje de ${s}`;let n="Mensaje recibido";"text"===e.type&&"content"in e?n=e.content?.slice(0,100)||"Mensaje recibido":"image"===e.type?n="📷 Imagen":"audio"===e.type?n="🎵 Audio":"location"===e.type&&(n="📍 Ubicación");const r=new Notification(t,{body:n,icon:f,tag:"chat-message",requireInteraction:!1,silent:!1});r.onclick=()=>{window.focus(),r.close()},setTimeout(()=>r.close(),5e3)}catch(n){c.error("Error showing notification:",n)}},[t,r,u,s,f]),y=e.useCallback(()=>{if(t&&n&&("undefined"==typeof document||!document.hasFocus()))try{p.current?.play().catch(e=>{c.debug("Audio playback blocked:",e)})}catch(e){c.error("Error playing sound:",e)}},[t,n]),v=e.useCallback(e=>{g(e),y()},[g,y]);return{permission:u,requestPermission:h,notify:g,playSound:y,notifyWithSound:v}}({enabled:!0,soundEnabled:!0,desktopEnabled:!0,botName:u?.botName||"Asistente",logoUrl:u?.logoUrl}),S=function(t=10,n=6e4){const r=e.useRef([]);return{isAllowed:e.useCallback(()=>{const e=Date.now();return r.current=r.current.filter(t=>e-t<n),!(r.current.length>=t||(r.current.push(e),0))},[t,n]),getRemainingAttempts:e.useCallback(()=>{const e=Date.now();return r.current=r.current.filter(t=>e-t<n),Math.max(0,t-r.current.length)},[t,n]),getTimeUntilReset:e.useCallback(()=>{if(0===r.current.length)return 0;const e=Date.now(),t=r.current[0],o=n-(e-t);return Math.max(0,o)},[n]),reset:e.useCallback(()=>{r.current=[]},[])}}(10,6e4),{state:E,actions:O}=function(){const[t,n]=e.useReducer(W,B),[r,o]=e.useState(!1);e.useEffect(()=>{"undefined"==typeof window||r||(async()=>{try{await L.migrateFromLocalStorage();const e=await L.getMessages(100),t=await L.getMetadata();if(e.length>0||t){const r={messages:e.map(e=>({...e,timestamp:new Date(e.timestamp)})),sessionId:t?.sessionId||null,isOpen:t?.isOpen||!1};n({type:"RESTORE_SESSION",payload:r})}}catch(e){c.warn("Chat: Error rehydrating from IndexedDB",e);try{const e=localStorage.getItem(J);if(e){const t=JSON.parse(e);t.messages&&(t.messages=t.messages.map(e=>({...e,timestamp:new Date(e.timestamp)}))),n({type:"RESTORE_SESSION",payload:t})}}catch(t){c.error("Chat: Fallback rehydration failed",t)}}finally{o(!0)}})()},[r]),e.useEffect(()=>{if(!r)return;const e=setTimeout(async()=>{try{await L.saveMessages(t.messages),await L.setMetadata({isOpen:t.isOpen,sessionId:t.sessionId})}catch(e){c.error("Chat Persistence Error:",e);try{const e={isOpen:t.isOpen,messages:t.messages,sessionId:t.sessionId};localStorage.setItem(J,JSON.stringify(e))}catch(n){c.error("Chat: Fallback persistence failed",n)}}},500);return()=>clearTimeout(e)},[t.isOpen,t.messages,t.sessionId,r]);const s=e.useCallback(e=>{n({type:"ADD_MESSAGE",payload:e})},[]),i=e.useCallback(()=>n({type:"TOGGLE_WINDOW"}),[]),a=e.useCallback(()=>n({type:"OPEN_WINDOW"}),[]),u=e.useCallback(()=>n({type:"CLOSE_WINDOW"}),[]),d=e.useCallback(e=>n({type:"SET_CONNECTED",payload:e}),[]),l=e.useCallback(e=>n({type:"SET_TYPING",payload:e}),[]),p=e.useCallback(e=>n({type:"SET_MESSAGES",payload:e}),[]),f=e.useCallback(e=>n({type:"SET_ERROR",payload:e}),[]),m=e.useCallback(e=>n({type:"SET_SESSION_ID",payload:e}),[]),h=e.useCallback(()=>{localStorage.removeItem(J),n({type:"CLEAR_CHAT"})},[]),g=e.useCallback(()=>{n({type:"SET_MESSAGES",payload:[]})},[]);return{state:t,isHydrated:r,actions:{toggleWindow:i,openWindow:a,closeWindow:u,setConnected:d,setTyping:l,addMessage:s,setMessages:p,setError:f,setSessionId:m,clearChat:h,clearMessages:g}}}(),I=function(t=!1){const n="undefined"!=typeof window?window.location.pathname:"",r=e.useMemo(()=>n,[n]),[o,s]=e.useState({});return e.useEffect(()=>{if(!t)return void s({});const e=setTimeout(()=>{const e=function(){if("undefined"==typeof window)return{};const e={};e.title=document.title,document.querySelectorAll("meta").forEach(t=>{const n=t.getAttribute("name"),r=t.getAttribute("property"),o=t.getAttribute("content");if(o){if(n)switch(n){case"description":e.description=o;break;case"keywords":e.keywords=o.split(",").map(e=>e.trim());break;case"author":e.author=o}if(r){if(r.startsWith("og:")){const t=r.replace("og:","og_");e[t]=o}if(r.startsWith("twitter:")){const t=r.replace("twitter:","twitter_");e[t]=o}}}});try{const t=document.querySelectorAll('script[type="application/ld+json"]');if(t.length>0){const n=[];t.forEach(e=>{try{const t=JSON.parse(e.textContent||"");n.push(t)}catch{}}),n.length>0&&(e.structuredData=n)}}catch{}return e}();s(e)},100);return()=>clearTimeout(e)},[r,t]),t&&Object.keys(o).length>0?o:void 0}(a),$=function(t){const{apiKey:n,apiBaseUrl:r,pageContext:o,userContext:s}=t,i=e.useRef(t);e.useEffect(()=>{i.current=t},[t]);const a=e.useRef(null),[u,l]=e.useState(!1),[p,f]=e.useState(!1),h=e.useRef(function(){try{const e=localStorage.getItem(ps);if(e)return e;const t=fs();return localStorage.setItem(ps,t),t}catch{return c.warn("localStorage not available, using session-only device ID"),fs()}}()),g=e.useRef(o);e.useEffect(()=>{g.current=o},[o]);const y=function(){const e={type:"object",shape:{id:yo().optional(),type:Xo(["text","image","audio","location","system"]).default("text"),content:yo().optional(),imageUrl:yo().url().optional(),audioUrl:yo().url().optional(),latitude:Do().optional(),longitude:Do().optional(),timestamp:yo().optional(),sender:Xo(["bot","user","system"]).optional(),emotion:/* @__PURE__ */hr(Lo).optional()}??{},...he(void 0)};return new qo(e)}(),v=e.useCallback(e=>{const t=y.safeParse(e),n=t.success&&t.data.id?t.data.id:`msg-${Math.random().toString(36).slice(2,11)}`,r=t.success&&t.data.sender?t.data.sender:"bot",o=t.success&&t.data.timestamp?new Date(t.data.timestamp):/* @__PURE__ */new Date,s=t.success?t.data:{type:"text"};switch(s.type){case"image":return{id:n,type:"image",sender:r,timestamp:o,imageUrl:s.imageUrl||s.content||"",altText:"Imagen enviada"};case"audio":return{id:n,type:"audio",sender:r,timestamp:o,content:s.audioUrl||s.content||""};case"location":return{id:n,type:"location",sender:r,timestamp:o,latitude:Number(s.latitude||0),longitude:Number(s.longitude||0),name:s.content||"Ubicación compartida"};case"system":return{id:n,type:"system",sender:"system",timestamp:o,content:String(s.content||"")};default:return{id:n,type:"text",sender:r,timestamp:o,content:String(s.content||"Sin contenido"),emotion:s.emotion}}},[y]),b=e.useCallback(()=>{if(!n||!r)return;if(a.current?.connected)return;l(!0);const e=m(r,{auth:{apiKey:n,deviceId:h.current,token:s?.token,metadata:s?.metadata},transports:["websocket"],reconnection:!0,extraHeaders:{"bypass-tunnel-reminder":"true","X-Tunnel-Skip-Anti-Phishing-Page":"true"}});e.on("connect",()=>{l(!1),f(!0)}),e.on("disconnect",e=>{l(!1),f(!1),i.current.onDisconnected()}),e.on("connect_error",e=>{l(!1),i.current.onError(`Error de conexión: ${e.message}`)}),e.on("connection_ack",e=>{i.current.onConnected(e.sessionId,e.config)}),e.on("bot_message",e=>{try{i.current.onMessage(v(e))}catch(t){c.error("ChatSocket Error processing bot_message:",t)}}),e.on("chat_history",e=>{e.messages&&Array.isArray(e.messages)&&e.messages.forEach(e=>{try{i.current.onMessage(v(e))}catch(t){c.debug("Error processing history message:",t)}}),i.current.onEvent&&i.current.onEvent("history_loaded",e)}),e.on("bot_typing",e=>i.current.onTyping(e)),e.on("auth_success",e=>{i.current.onLogin&&i.current.onLogin(e),e.theme&&i.current.onThemeUpdate&&i.current.onThemeUpdate(e.theme)}),a.current=e},[n,r,s?.token,s?.metadata,v]),_=e.useCallback(()=>{a.current&&(a.current.disconnect(),a.current=null,f(!1))},[]);e.useEffect(()=>(b(),()=>_()),[b,_]);const w=e.useRef([]),k=e.useRef([]),z=e.useCallback(()=>`msg_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,[]),x=e.useCallback(()=>{if(a.current?.connected)for(;w.current.length>0;){const e=w.current.shift();a.current.emit("user_message",e)}},[]);e.useEffect(()=>{p&&x()},[p,x]),e.useEffect(()=>{if(!p)return;const e=setInterval(()=>{const e=Date.now();k.current=k.current.filter(t=>e<t.nextRetryAt||(t.attempts>=t.maxAttempts?(i.current.onEvent?.("message_failed",{id:t.id,payload:t.payload}),c.error("Message failed after max retries:",t.id),!1):!a.current?.connected||(a.current.emit("user_message",t.payload,e=>{e?.success&&i.current.onEvent?.("message_sent",{id:t.id})}),t.attempts++,t.nextRetryAt=e+1e3*Math.pow(2,t.attempts),t.attempts<t.maxAttempts)))},500);return()=>clearInterval(e)},[p]);const S=e.useCallback((e,t="text")=>{const n=z(),r={...g.current,currentUrl:"undefined"!=typeof window?window.location.href:void 0,sentAt:/* @__PURE__ */(new Date).toISOString(),deviceId:h.current},o={id:n,content:e.trim(),type:t,metadata:r};return a.current?.connected?(a.current.emit("user_message",o,e=>{!1!==e?.success&&e?i.current.onEvent?.("message_sent",{id:n}):(k.current.push({id:n,payload:o,attempts:0,maxAttempts:3,nextRetryAt:Date.now()+1e3}),i.current.onEvent?.("message_retry_queued",{id:n}))}),n):(w.current.push(o),i.current.onEvent?.("queued_message",{id:n,payload:o}),n)},[z]),E=e.useMemo(()=>d(e=>{a.current?.emit("typing",e)},250),[]);return{isConnected:p,isConnecting:u,sendMessage:S,sendTyping:E,requestHistory:e.useCallback(()=>{a.current?.emit("request_history")},[]),reconnect:b,disconnect:_}}({apiKey:r,apiBaseUrl:s,pageContext:e.useMemo(()=>I?{...i||{},seo:{...I||{}}}:i,[i,I]),userContext:p,onMessage:e.useCallback(e=>{const t=Date.now(),n=w.current>0?t-w.current:void 0;w.current=t,O.addMessage(e),z.trackMessageReceived(e.type,n),E.isOpen||"bot"!==e.sender||(_(e=>e+1),x.notifyWithSound(e))},[O,E.isOpen,z,x]),onConnected:e.useCallback((e,t)=>{O.setConnected(!0),O.setSessionId(e),z.trackConnectionStatus(!0),t&&g&&g("backend_config",t)},[O,g,z]),onDisconnected:e.useCallback(()=>{O.setConnected(!1),z.trackConnectionStatus(!1)},[O,z]),onTyping:e.useCallback(e=>O.setTyping(e),[O]),onError:e.useCallback(e=>{O.setError(e),z.trackError(e)},[O,z]),onLogin:f,onNavigate:h,onEvent:g,onThemeUpdate:v}),N=e.useCallback(()=>{c.debug("ChatWidget handleToggle called, current isOpen:",E.isOpen),E.isOpen?(O.closeWindow(),z.trackClose(),y?.(!1),c.debug("ChatWidget Closing window")):(O.openWindow(),_(0),z.trackOpen(),y?.(!0),c.debug("ChatWidget Opening window"))},[E.isOpen,O,y,z]),T=e.useCallback(e=>{if(!S.isAllowed()){const e=S.getTimeUntilReset(),t=Math.ceil(e/1e3);return void O.setError(k("rate_limit_exceeded")+` Espera ${t}s.`)}const t={id:`temp-${Date.now()}-${Math.random()}`,type:"text",sender:"user",timestamp:/* @__PURE__ */new Date,content:e};O.addMessage(t),z.trackMessageSent("text"),$.sendMessage(e,"text")},[O,$,S,z,k]),C=e.useCallback(async(e,t)=>{let n;n="audio"===t?{id:`temp-${Date.now()}-${Math.random()}`,type:"audio",sender:"user",timestamp:/* @__PURE__ */new Date,content:URL.createObjectURL(e)}:"image"===t?{id:`temp-${Date.now()}-${Math.random()}`,type:"image",sender:"user",timestamp:/* @__PURE__ */new Date,imageUrl:URL.createObjectURL(e)}:{id:`temp-${Date.now()}-${Math.random()}`,type:"text",sender:"user",timestamp:/* @__PURE__ */new Date,content:`📎 ${e.name}`},O.addMessage(n);const r=await(e=>new Promise((t,n)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result),r.onerror=e=>n(e)}))(e);$.sendMessage(r,t)},[O,$]),A=e.useCallback(e=>{const t={id:`temp-${Date.now()}-${Math.random()}`,type:"location",sender:"user",timestamp:/* @__PURE__ */new Date,latitude:e.latitude,longitude:e.longitude,name:"Mi ubicación"};O.addMessage(t),$.sendMessage(JSON.stringify(e),"location")},[O,$]);e.useEffect(()=>()=>{},[T]);const j=e.useCallback(()=>{O.clearMessages(),c.info("Chat history cleared")},[O]);e.useEffect(()=>()=>{},[j]);const Z=e.useMemo(()=>{if(E.isTyping)return"thinking";const e=[...E.messages].reverse().find(e=>"bot"===e.sender&&"text"===e.type);return"text"===e?.type&&e.emotion?e.emotion:"default"},[E.isTyping,E.messages]);return{state:E,actions:O,unreadCount:b,currentBotEmotion:Z,isConnected:$.isConnected,handleToggle:N,handleSendText:T,handleSendAttachment:C,handleSendLocation:A}}function gs(n){const{apiKey:r,apiBaseUrl:o,pageContext:i,includeSEOMetadata:a=!1,theme:c,mediaConfig:d,userContext:l,onLogin:m,onNavigate:_,onEvent:w,onStateChange:k}=n,z=e.useRef(null),x=p();!function(t){const[n,r]=e.useState(!1);e.useEffect(()=>{let e=null;const n=()=>{if(!t.current)return;const e=!!t.current.parentElement?.closest(".dark"),n=!!document.getElementById("botuyo-chat-widget-root")?.classList.contains("dark"),o=document.getElementById("botuyo-chat-widget-root"),s=!!o?.parentElement?.closest(".dark"),i=document.documentElement.classList.contains("dark"),a=document.body.classList.contains("dark"),c=window.matchMedia("(prefers-color-scheme: dark)").matches,u=e||n||s||i||a||c;t.current&&(u?t.current.classList.add("dark"):t.current.classList.remove("dark")),r(u)};n();const o=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>n();o.addEventListener("change",s);const i=new MutationObserver(()=>{n()}),a=document.getElementById("botuyo-chat-widget-root");a&&(i.observe(a,{attributes:!0,attributeFilter:["class"]}),a.parentElement&&(i.observe(a.parentElement,{attributes:!0,attributeFilter:["class"],childList:!0}),e=a.parentElement)),i.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),i.observe(document.body,{attributes:!0,attributeFilter:["class"]});let c=t.current?.parentElement;for(;c;)i.observe(c,{attributes:!0,attributeFilter:["class"]}),c=c.parentElement;const u=setInterval(()=>{const t=document.getElementById("botuyo-chat-widget-root");t&&t.parentElement!==e&&(e&&t.parentElement&&(i.observe(t.parentElement,{attributes:!0,attributeFilter:["class"],childList:!0}),e=t.parentElement),n())},100);return()=>{i.disconnect(),o.removeEventListener("change",s),clearInterval(u)}},[t])}(z);const[S,E]=e.useState(),{mergedTheme:O,mergedStyles:I,getContainerStyle:$}=function(t,n){const r=function(){const[t,n]=e.useState(()=>"undefined"!=typeof window&&(window.matchMedia("(prefers-contrast: high)").matches||window.matchMedia("(prefers-contrast: more)").matches));return e.useEffect(()=>{const e=window.matchMedia("(prefers-contrast: high)"),t=window.matchMedia("(prefers-contrast: more)"),r=e=>{n(e.matches)};return e.addEventListener("change",r),t.addEventListener("change",r),()=>{e.removeEventListener("change",r),t.removeEventListener("change",r)}},[]),t}(),o=e.useMemo(()=>{const e=u(t,n);return r?{...e,primaryColor:"#000000",cssVariables:{...e.cssVariables,background:"#FFFFFF",foreground:"#000000",card:"#FFFFFF",cardForeground:"#000000",primary:"#000000",primaryForeground:"#FFFFFF",muted:"#F5F5F5",mutedForeground:"#000000",border:"#000000"}}:e},[t,n,r]),s=e.useMemo(()=>({radius:{...y,...t?.bubbleStyles?.radius},bot:{...v,...t?.bubbleStyles?.bot},user:{...b,...t?.bubbleStyles?.user},launcher:{...t?.bubbleStyles?.launcher},mapCard:{...t?.bubbleStyles?.mapCard}}),[t?.bubbleStyles]);return{mergedTheme:o,mergedStyles:s,getContainerStyle:(e,t,n)=>({"--chat-primary":o.primaryColor,zIndex:e?2147483647:9999,position:"fixed",top:t&&e?0:"auto",left:t&&e?0:"bottom-left"===n?"24px":"auto",right:t&&e?0:"bottom-right"!==n&&n?"auto":"24px",bottom:t&&e?0:"100px",width:t&&e?"100%":"auto",height:t&&e?"100%":"auto"})}}(c,S),{state:N,actions:T,unreadCount:C,currentBotEmotion:A,isConnected:j,handleToggle:Z,handleSendText:M,handleSendAttachment:P,handleSendLocation:F}=hs({apiKey:r,apiBaseUrl:o,pageContext:i,includeSEOMetadata:a,theme:c,userContext:l,onLogin:m,onNavigate:_,onEvent:w,onStateChange:k,onThemeUpdate:E}),D=e.useCallback(e=>{e.stopPropagation()},[]),R=$(N.isOpen,x,c?.position),U=e.useMemo(()=>{if(!O.cssVariables)return{};const e={},t=O.cssVariables;return t.background&&(e["--background"]=t.background),t.foreground&&(e["--foreground"]=t.foreground),t.card&&(e["--card"]=t.card),t.cardForeground&&(e["--card-foreground"]=t.cardForeground),t.primary&&(e["--primary"]=t.primary),t.primaryForeground&&(e["--primary-foreground"]=t.primaryForeground),t.muted&&(e["--muted"]=t.muted),t.mutedForeground&&(e["--muted-foreground"]=t.mutedForeground),t.border&&(e["--border"]=t.border),t.destructive&&(e["--destructive"]=t.destructive),t.radius&&(e["--radius"]=t.radius),t.spacing1&&(e["--spacing-1"]=t.spacing1),t.spacing2&&(e["--spacing-2"]=t.spacing2),t.spacing3&&(e["--spacing-3"]=t.spacing3),t.spacing4&&(e["--spacing-4"]=t.spacing4),t.spacing5&&(e["--spacing-5"]=t.spacing5),t.spacing6&&(e["--spacing-6"]=t.spacing6),t.spacing8&&(e["--spacing-8"]=t.spacing8),e},[O.cssVariables]);/* @__PURE__ */
|
|
29
|
+
return gr(Jo)}const Wo=/* @__PURE__ */V("ZodNever",(e,t)=>{an.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)}),Vo=/* @__PURE__ */V("ZodArray",(e,t)=>{un.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;"number"==typeof i&&(o.minItems=i),"number"==typeof a&&(o.maxItems=a),o.type="array",o.items=Jr(s.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(/* @__PURE__ */xr(t,n)),e.nonempty=t=>e.check(/* @__PURE__ */xr(1,t)),e.max=(t,n)=>e.check(/* @__PURE__ */zr(t,n)),e.length=(t,n)=>e.check(/* @__PURE__ */Sr(t,n)),e.unwrap=()=>e.element}),qo=/* @__PURE__ */V("ZodObject",(e,t)=>{mn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object",o.properties={};const i=s.shape;for(const u in i)o.properties[u]=Jr(i[u],t,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(e=>{const n=s.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));c.size>0&&(o.required=Array.from(c)),"never"===s.catchall?._zod.def.type?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=Jr(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)})(e,t,n,r),re(e,"shape",()=>t.shape),e.keyof=()=>Yo(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Bo()}),e.loose=()=>e.clone({...e._zod.def,catchall:Bo()}),e.strict=()=>e.clone({...e._zod.def,catchall:/* @__PURE__ */yr(Wo,void 0)}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!de(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const n=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=se(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return oe(this,"shape",n),n}});return me(e,r)}(e,t),e.safeExtend=t=>function(e,t){if(!de(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=se(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return oe(this,"shape",n),n}});return me(e,n)}(e,t),e.merge=t=>function(e,t){const n=se(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return oe(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return me(e,n)}(e,t),e.pick=t=>function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return me(e,se(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return oe(this,"shape",e),e},checks:[]}))}(e,t),e.omit=t=>function(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=se(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return oe(this,"shape",r),r},checks:[]});return me(e,o)}(e,t),e.partial=(...t)=>function(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const o=se(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)o[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return oe(this,"shape",o),o},checks:[]});return me(t,o)}(Qo,e,t[0]),e.required=(...t)=>function(e,t,n){const r=se(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=new e({type:"nonoptional",innerType:r[t]}))}else for(const t in r)o[t]=new e({type:"nonoptional",innerType:r[t]});return oe(this,"shape",o),o}});return me(t,r)}(is,e,t[0])}),Go=/* @__PURE__ */V("ZodUnion",(e,t)=>{gn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,s=!1===o.inclusive,i=o.options.map((e,n)=>Jr(e,t,{...r,path:[...r.path,s?"oneOf":"anyOf",n]}));s?n.oneOf=i:n.anyOf=i})(e,t,n,r),e.options=t.options}),Ko=/* @__PURE__ */V("ZodIntersection",(e,t)=>{yn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,s=Jr(o.left,t,{...r,path:[...r.path,"allOf",0]}),i=Jr(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c})(e,t,n,r)}),Ho=/* @__PURE__ */V("ZodEnum",(e,t)=>{_n.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=Y(e._zod.def.entries);r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=r})(e,0,n),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const o={};for(const s of e){if(!n.has(s))throw new Error(`Key ${s} not found in enum`);o[s]=t.entries[s]}return new Ho({...t,checks:[],...he(r),entries:o})},e.exclude=(e,r)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new Ho({...t,checks:[],...he(r),entries:o})}});function Yo(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ho({type:"enum",entries:n,...he(t)})}const Xo=/* @__PURE__ */V("ZodTransform",(e,t)=>{wn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")})(0,e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new G(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(ke(r,n.value,t));else{const t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(ke(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(e=>(n.value=e,n)):(n.value=o,n)}}),Qo=/* @__PURE__ */V("ZodOptional",(e,t)=>{zn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kr(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function es(e){return new Qo({type:"optional",innerType:e})}const ts=/* @__PURE__ */V("ZodExactOptional",(e,t)=>{xn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kr(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}),ns=/* @__PURE__ */V("ZodNullable",(e,t)=>{Sn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,s=Jr(o.innerType,t,r),i=t.seen.get(e);"openapi-3.0"===t.target?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rs(e){return new ns({type:"nullable",innerType:e})}const os=/* @__PURE__ */V("ZodDefault",(e,t)=>{En.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;Jr(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),ss=/* @__PURE__ */V("ZodPrefault",(e,t)=>{In.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;Jr(o.innerType,t,r),t.seen.get(e).ref=o.innerType,"input"===t.io&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),is=/* @__PURE__ */V("ZodNonOptional",(e,t)=>{$n.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;Jr(o.innerType,t,r),t.seen.get(e).ref=o.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType}),as=/* @__PURE__ */V("ZodCatch",(e,t)=>{Cn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;let s;Jr(o.innerType,t,r),t.seen.get(e).ref=o.innerType;try{s=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),cs=/* @__PURE__ */V("ZodPipe",(e,t)=>{Tn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,s="input"===t.io?"transform"===o.in._zod.def.type?o.out:o.in:o.out;Jr(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function us(e,t){return new cs({type:"pipe",in:e,out:t})}const ds=/* @__PURE__ */V("ZodReadonly",(e,t)=>{jn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;Jr(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType}),ls=/* @__PURE__ */V("ZodCustom",(e,t)=>{Mn.init(e,t),mo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")})(0,e)}),ps="chat_device_id";function fs(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}class ms{queue=[];endpoint;apiKey;flushInterval=null;isFlushing=!1;isDisabled=!1;MAX_QUEUE_SIZE=100;FLUSH_INTERVAL_MS=3e4;BATCH_SIZE=10;constructor(e,t){this.endpoint=e,this.apiKey=t,this.startAutoFlush()}startAutoFlush(){this.flushInterval=setInterval(()=>{!this.isDisabled&&this.queue.length>0&&this.flush()},this.FLUSH_INTERVAL_MS)}trackOpen(){this.track("chat_opened")}trackClose(){this.track("chat_closed")}trackMessageSent(e){this.track("message_sent",{type:e})}trackMessageReceived(e,t){this.track("message_received",{type:e,latency:t})}trackError(e,t){this.track("error",{error:e,context:t})}trackConnectionStatus(e){this.track("connection_status",{isConnected:e})}trackFeatureUsed(e){this.track("feature_used",{feature:e})}trackTypingStarted(){this.track("typing_started")}trackAttachmentSent(e,t){this.track("attachment_sent",{type:e,size:t})}track(e,t){this.isDisabled||(this.queue.push({event:e,properties:{...t,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0,url:"undefined"!=typeof window?window.location.href:void 0},timestamp:Date.now()}),this.queue.length>=this.BATCH_SIZE&&this.flush(),this.queue.length>this.MAX_QUEUE_SIZE&&(this.queue=this.queue.slice(-this.MAX_QUEUE_SIZE),c.warn("Analytics queue overflow, dropping old events")))}async flush(){if(this.isDisabled||0===this.queue.length||this.isFlushing)return;this.isFlushing=!0;const e=[...this.queue];this.queue=[];try{const t=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({events:e}),keepalive:!0});t.ok?c.debug(`Analytics: Flushed ${e.length} events`):(this.isDisabled=!0,this.queue=[],c.debug(`Analytics disabled: endpoint returned ${t.status}`))}catch(t){this.isDisabled=!0,this.queue=[],c.debug("Analytics disabled due to network error")}finally{this.isFlushing=!1}}destroy(){this.flushInterval&&clearInterval(this.flushInterval),this.flush()}}function hs(t){const{apiKey:r,apiBaseUrl:s,pageContext:i,includeSEOMetadata:a=!1,theme:u,userContext:p,onLogin:f,onNavigate:h,onEvent:g,onStateChange:y,onThemeUpdate:v}=t,[b,_]=e.useState(0),w=e.useRef(0),{t:k}=n(),z=function(t,n,r=!0){const o=e.useRef(null);return e.useEffect(()=>{if(!r||!t||!n)return;const e=`${t}/analytics`;o.current=new ms(e,n);const s=()=>o.current?.flush(),i=()=>{"hidden"===document.visibilityState&&o.current?.flush()};return window.addEventListener("beforeunload",s),window.addEventListener("visibilitychange",i),()=>{window.removeEventListener("beforeunload",s),window.removeEventListener("visibilitychange",i),o.current?.destroy()}},[t,n,r]),{trackOpen:e.useCallback(()=>{o.current?.trackOpen()},[]),trackClose:e.useCallback(()=>{o.current?.trackClose()},[]),trackMessageSent:e.useCallback(e=>{o.current?.trackMessageSent(e)},[]),trackMessageReceived:e.useCallback((e,t)=>{o.current?.trackMessageReceived(e,t)},[]),trackError:e.useCallback((e,t)=>{o.current?.trackError(e,t)},[]),trackConnectionStatus:e.useCallback(e=>{o.current?.trackConnectionStatus(e)},[]),trackFeatureUsed:e.useCallback(e=>{o.current?.trackFeatureUsed(e)},[])}}(s,r,!0),x=function({enabled:t=!0,soundEnabled:n=!0,desktopEnabled:r=!0,botName:s="Asistente",logoUrl:i,notificationSoundUrl:a}={}){const[u,d]=e.useState("default"),p=e.useRef(null),f=i||o,m=a||l;e.useEffect(()=>{n&&"undefined"!=typeof window&&(p.current=new Audio(m),p.current.volume=.3)},[n,m]),e.useEffect(()=>{"undefined"!=typeof window&&"Notification"in window&&d(Notification.permission)},[]);const h=e.useCallback(async()=>{if("undefined"==typeof window||!("Notification"in window))return c.warn("Notifications API not available"),!1;try{const e=await Notification.requestPermission();return d(e),c.info("Notification permission:",e),"granted"===e}catch(e){return c.error("Error requesting notification permission:",e),!1}},[]),g=e.useCallback(e=>{if(t&&r&&"granted"===u&&("undefined"==typeof document||!document.hasFocus()))try{const t=`Nuevo mensaje de ${s}`;let n="Mensaje recibido";"text"===e.type&&"content"in e?n=e.content?.slice(0,100)||"Mensaje recibido":"image"===e.type?n="📷 Imagen":"audio"===e.type?n="🎵 Audio":"location"===e.type&&(n="📍 Ubicación");const r=new Notification(t,{body:n,icon:f,tag:"chat-message",requireInteraction:!1,silent:!1});r.onclick=()=>{window.focus(),r.close()},setTimeout(()=>r.close(),5e3)}catch(n){c.error("Error showing notification:",n)}},[t,r,u,s,f]),y=e.useCallback(()=>{if(t&&n&&("undefined"==typeof document||!document.hasFocus()))try{p.current?.play().catch(e=>{c.debug("Audio playback blocked:",e)})}catch(e){c.error("Error playing sound:",e)}},[t,n]),v=e.useCallback(e=>{g(e),y()},[g,y]);return{permission:u,requestPermission:h,notify:g,playSound:y,notifyWithSound:v}}({enabled:!0,soundEnabled:!0,desktopEnabled:!0,botName:u?.botName||"Asistente",logoUrl:u?.logoUrl}),S=function(t=10,n=6e4){const r=e.useRef([]);return{isAllowed:e.useCallback(()=>{const e=Date.now();return r.current=r.current.filter(t=>e-t<n),!(r.current.length>=t||(r.current.push(e),0))},[t,n]),getRemainingAttempts:e.useCallback(()=>{const e=Date.now();return r.current=r.current.filter(t=>e-t<n),Math.max(0,t-r.current.length)},[t,n]),getTimeUntilReset:e.useCallback(()=>{if(0===r.current.length)return 0;const e=Date.now(),t=r.current[0],o=n-(e-t);return Math.max(0,o)},[n]),reset:e.useCallback(()=>{r.current=[]},[])}}(10,6e4),{state:E,actions:O}=function(){const[t,n]=e.useReducer(W,B),[r,o]=e.useState(!1);e.useEffect(()=>{"undefined"==typeof window||r||(async()=>{try{await L.migrateFromLocalStorage();const e=await L.getMessages(100),t=await L.getMetadata();if(e.length>0||t){const r={messages:e.map(e=>({...e,timestamp:new Date(e.timestamp)})),sessionId:t?.sessionId||null,isOpen:t?.isOpen||!1};n({type:"RESTORE_SESSION",payload:r})}}catch(e){c.warn("Chat: Error rehydrating from IndexedDB",e);try{const e=localStorage.getItem(J);if(e){const t=JSON.parse(e);t.messages&&(t.messages=t.messages.map(e=>({...e,timestamp:new Date(e.timestamp)}))),n({type:"RESTORE_SESSION",payload:t})}}catch(t){c.error("Chat: Fallback rehydration failed",t)}}finally{o(!0)}})()},[r]),e.useEffect(()=>{if(!r)return;const e=setTimeout(async()=>{try{await L.saveMessages(t.messages),await L.setMetadata({isOpen:t.isOpen,sessionId:t.sessionId})}catch(e){c.error("Chat Persistence Error:",e);try{const e={isOpen:t.isOpen,messages:t.messages,sessionId:t.sessionId};localStorage.setItem(J,JSON.stringify(e))}catch(n){c.error("Chat: Fallback persistence failed",n)}}},500);return()=>clearTimeout(e)},[t.isOpen,t.messages,t.sessionId,r]);const s=e.useCallback(e=>{n({type:"ADD_MESSAGE",payload:e})},[]),i=e.useCallback(()=>n({type:"TOGGLE_WINDOW"}),[]),a=e.useCallback(()=>n({type:"OPEN_WINDOW"}),[]),u=e.useCallback(()=>n({type:"CLOSE_WINDOW"}),[]),d=e.useCallback(e=>n({type:"SET_CONNECTED",payload:e}),[]),l=e.useCallback(e=>n({type:"SET_TYPING",payload:e}),[]),p=e.useCallback(e=>n({type:"SET_MESSAGES",payload:e}),[]),f=e.useCallback(e=>n({type:"SET_ERROR",payload:e}),[]),m=e.useCallback(e=>n({type:"SET_SESSION_ID",payload:e}),[]),h=e.useCallback(()=>{localStorage.removeItem(J),n({type:"CLEAR_CHAT"})},[]),g=e.useCallback(()=>{n({type:"SET_MESSAGES",payload:[]})},[]);return{state:t,isHydrated:r,actions:{toggleWindow:i,openWindow:a,closeWindow:u,setConnected:d,setTyping:l,addMessage:s,setMessages:p,setError:f,setSessionId:m,clearChat:h,clearMessages:g}}}(),I=function(t=!1){const n="undefined"!=typeof window?window.location.pathname:"",r=e.useMemo(()=>n,[n]),[o,s]=e.useState({});return e.useEffect(()=>{if(!t)return void s({});const e=setTimeout(()=>{const e=function(){if("undefined"==typeof window)return{};const e={};e.title=document.title,document.querySelectorAll("meta").forEach(t=>{const n=t.getAttribute("name"),r=t.getAttribute("property"),o=t.getAttribute("content");if(o){if(n)switch(n){case"description":e.description=o;break;case"keywords":e.keywords=o.split(",").map(e=>e.trim());break;case"author":e.author=o}if(r){if(r.startsWith("og:")){const t=r.replace("og:","og_");e[t]=o}if(r.startsWith("twitter:")){const t=r.replace("twitter:","twitter_");e[t]=o}}}});try{const t=document.querySelectorAll('script[type="application/ld+json"]');if(t.length>0){const n=[];t.forEach(e=>{try{const t=JSON.parse(e.textContent||"");n.push(t)}catch{}}),n.length>0&&(e.structuredData=n)}}catch{}return e}();s(e)},100);return()=>clearTimeout(e)},[r,t]),t&&Object.keys(o).length>0?o:void 0}(a),$=function(t){const{apiKey:n,apiBaseUrl:r,pageContext:o,userContext:s}=t,i=e.useRef(t);e.useEffect(()=>{i.current=t},[t]);const a=e.useRef(null),[u,l]=e.useState(!1),[p,f]=e.useState(!1),h=e.useRef(function(){try{const e=localStorage.getItem(ps);if(e)return e;const t=fs();return localStorage.setItem(ps,t),t}catch{return c.warn("localStorage not available, using session-only device ID"),fs()}}()),g=e.useRef(o);e.useEffect(()=>{g.current=o},[o]);const y=function(){const e={type:"object",shape:{id:yo().optional(),type:Yo(["text","image","audio","location","system"]).default("text"),content:yo().optional(),imageUrl:yo().url().optional(),audioUrl:yo().url().optional(),latitude:Fo().optional(),longitude:Fo().optional(),timestamp:yo().optional(),sender:Yo(["bot","user","system"]).optional(),emotion:/* @__PURE__ */hr(Lo).optional()}??{},...he(void 0)};return new qo(e)}(),v=e.useCallback(e=>{const t=y.safeParse(e),n=t.success&&t.data.id?t.data.id:`msg-${Math.random().toString(36).slice(2,11)}`,r=t.success&&t.data.sender?t.data.sender:"bot",o=t.success&&t.data.timestamp?new Date(t.data.timestamp):/* @__PURE__ */new Date,s=t.success?t.data:{type:"text"};switch(s.type){case"image":return{id:n,type:"image",sender:r,timestamp:o,imageUrl:s.imageUrl||s.content||"",altText:"Imagen enviada"};case"audio":return{id:n,type:"audio",sender:r,timestamp:o,content:s.audioUrl||s.content||""};case"location":return{id:n,type:"location",sender:r,timestamp:o,latitude:Number(s.latitude||0),longitude:Number(s.longitude||0),name:s.content||"Ubicación compartida"};case"system":return{id:n,type:"system",sender:"system",timestamp:o,content:String(s.content||"")};default:return{id:n,type:"text",sender:r,timestamp:o,content:String(s.content||"Sin contenido"),emotion:s.emotion}}},[y]),b=e.useCallback(()=>{if(!n||!r)return;if(a.current?.connected)return;l(!0);const e=m(r,{path:"/webchat",auth:{apiKey:n,deviceId:h.current,token:s?.token,metadata:s?.metadata},transports:["websocket"],reconnection:!0,reconnectionAttempts:5,reconnectionDelay:1e3,extraHeaders:{"bypass-tunnel-reminder":"true","X-Tunnel-Skip-Anti-Phishing-Page":"true"}});e.on("connect",()=>{l(!1),f(!0),i.current.onConnected(`temp-${Date.now()}`,void 0)}),e.on("disconnect",e=>{l(!1),f(!1),i.current.onDisconnected()}),e.on("connect_error",e=>{l(!1),i.current.onError(`Error de conexión: ${e.message}`)}),e.on("connection_ack",e=>{i.current.onConnected(e.sessionId,e.config)}),e.on("bot_message",e=>{try{i.current.onMessage(v(e))}catch(t){c.error("ChatSocket Error processing bot_message:",t)}}),e.on("chat_history",e=>{e.messages&&Array.isArray(e.messages)&&e.messages.forEach(e=>{try{i.current.onMessage(v(e))}catch(t){c.debug("Error processing history message:",t)}}),i.current.onEvent&&i.current.onEvent("history_loaded",e)}),e.on("bot_typing",e=>i.current.onTyping(e)),e.on("auth_success",e=>{i.current.onLogin&&i.current.onLogin(e),e.theme&&i.current.onThemeUpdate&&i.current.onThemeUpdate(e.theme)}),a.current=e},[n,r,s?.token,s?.metadata,v]),_=e.useCallback(()=>{a.current&&(a.current.disconnect(),a.current=null,f(!1))},[]);e.useEffect(()=>(b(),()=>_()),[b,_]);const w=e.useRef([]),k=e.useRef([]),z=e.useCallback(()=>`msg_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,[]),x=e.useCallback(()=>{if(a.current?.connected)for(;w.current.length>0;){const e=w.current.shift();a.current.emit("user_message",e)}},[]);e.useEffect(()=>{p&&x()},[p,x]),e.useEffect(()=>{if(!p)return;const e=setInterval(()=>{const e=Date.now();k.current=k.current.filter(t=>e<t.nextRetryAt||(t.attempts>=t.maxAttempts?(i.current.onEvent?.("message_failed",{id:t.id,payload:t.payload}),c.error("Message failed after max retries:",t.id),!1):!a.current?.connected||(a.current.emit("user_message",t.payload,e=>{e?.success&&i.current.onEvent?.("message_sent",{id:t.id})}),t.attempts++,t.nextRetryAt=e+1e3*Math.pow(2,t.attempts),t.attempts<t.maxAttempts)))},500);return()=>clearInterval(e)},[p]);const S=e.useCallback((e,t="text")=>{const n=z(),r={...g.current,currentUrl:"undefined"!=typeof window?window.location.href:void 0,sentAt:/* @__PURE__ */(new Date).toISOString(),deviceId:h.current},o={id:n,content:e.trim(),type:t,metadata:r};return a.current?.connected?(a.current.emit("user_message",o,e=>{!1!==e?.success&&e?i.current.onEvent?.("message_sent",{id:n}):(k.current.push({id:n,payload:o,attempts:0,maxAttempts:3,nextRetryAt:Date.now()+1e3}),i.current.onEvent?.("message_retry_queued",{id:n}))}),n):(w.current.push(o),i.current.onEvent?.("queued_message",{id:n,payload:o}),n)},[z]),E=e.useMemo(()=>d(e=>{a.current?.emit("typing",e)},250),[]);return{isConnected:p,isConnecting:u,sendMessage:S,sendTyping:E,requestHistory:e.useCallback(()=>{a.current?.emit("request_history")},[]),reconnect:b,disconnect:_}}({apiKey:r,apiBaseUrl:s,pageContext:e.useMemo(()=>I?{...i||{},seo:{...I||{}}}:i,[i,I]),userContext:p,onMessage:e.useCallback(e=>{const t=Date.now(),n=w.current>0?t-w.current:void 0;w.current=t,O.addMessage(e),z.trackMessageReceived(e.type,n),E.isOpen||"bot"!==e.sender||(_(e=>e+1),x.notifyWithSound(e))},[O,E.isOpen,z,x]),onConnected:e.useCallback((e,t)=>{O.setConnected(!0),O.setSessionId(e),z.trackConnectionStatus(!0),t&&g&&g("backend_config",t)},[O,g,z]),onDisconnected:e.useCallback(()=>{O.setConnected(!1),z.trackConnectionStatus(!1)},[O,z]),onTyping:e.useCallback(e=>O.setTyping(e),[O]),onError:e.useCallback(e=>{O.setError(e),z.trackError(e)},[O,z]),onLogin:f,onNavigate:h,onEvent:g,onThemeUpdate:v}),N=e.useCallback(()=>{c.debug("ChatWidget handleToggle called, current isOpen:",E.isOpen),E.isOpen?(O.closeWindow(),z.trackClose(),y?.(!1),c.debug("ChatWidget Closing window")):(O.openWindow(),_(0),z.trackOpen(),y?.(!0),c.debug("ChatWidget Opening window"))},[E.isOpen,O,y,z]),C=e.useCallback(e=>{if(!S.isAllowed()){const e=S.getTimeUntilReset(),t=Math.ceil(e/1e3);return void O.setError(k("rate_limit_exceeded")+` Espera ${t}s.`)}const t={id:`temp-${Date.now()}-${Math.random()}`,type:"text",sender:"user",timestamp:/* @__PURE__ */new Date,content:e};O.addMessage(t),z.trackMessageSent("text"),$.sendMessage(e,"text")},[O,$,S,z,k]),T=e.useCallback(async(e,t)=>{let n;n="audio"===t?{id:`temp-${Date.now()}-${Math.random()}`,type:"audio",sender:"user",timestamp:/* @__PURE__ */new Date,content:URL.createObjectURL(e)}:"image"===t?{id:`temp-${Date.now()}-${Math.random()}`,type:"image",sender:"user",timestamp:/* @__PURE__ */new Date,imageUrl:URL.createObjectURL(e)}:{id:`temp-${Date.now()}-${Math.random()}`,type:"text",sender:"user",timestamp:/* @__PURE__ */new Date,content:`📎 ${e.name}`},O.addMessage(n);const r=await(e=>new Promise((t,n)=>{const r=new FileReader;r.readAsDataURL(e),r.onload=()=>t(r.result),r.onerror=e=>n(e)}))(e);$.sendMessage(r,t)},[O,$]),A=e.useCallback(e=>{const t={id:`temp-${Date.now()}-${Math.random()}`,type:"location",sender:"user",timestamp:/* @__PURE__ */new Date,latitude:e.latitude,longitude:e.longitude,name:"Mi ubicación"};O.addMessage(t),$.sendMessage(JSON.stringify(e),"location")},[O,$]);e.useEffect(()=>()=>{},[C]);const j=e.useCallback(()=>{O.clearMessages(),c.info("Chat history cleared")},[O]);e.useEffect(()=>()=>{},[j]);const Z=e.useMemo(()=>{if(E.isTyping)return"thinking";const e=[...E.messages].reverse().find(e=>"bot"===e.sender&&"text"===e.type);return"text"===e?.type&&e.emotion?e.emotion:"default"},[E.isTyping,E.messages]);return{state:E,actions:O,unreadCount:b,currentBotEmotion:Z,isConnected:$.isConnected,handleToggle:N,handleSendText:C,handleSendAttachment:T,handleSendLocation:A}}function gs(n){const{apiKey:r,apiBaseUrl:o,pageContext:i,includeSEOMetadata:a=!1,theme:c,mediaConfig:d,userContext:l,onLogin:m,onNavigate:_,onEvent:w,onStateChange:k}=n,z=e.useRef(null),x=p();!function(t){const[n,r]=e.useState(!1);e.useEffect(()=>{let e=null;const n=()=>{if(!t.current)return;const e=!!t.current.parentElement?.closest(".dark"),n=!!document.getElementById("botuyo-chat-widget-root")?.classList.contains("dark"),o=document.getElementById("botuyo-chat-widget-root"),s=!!o?.parentElement?.closest(".dark"),i=document.documentElement.classList.contains("dark"),a=document.body.classList.contains("dark"),c=window.matchMedia("(prefers-color-scheme: dark)").matches,u=e||n||s||i||a||c;t.current&&(u?t.current.classList.add("dark"):t.current.classList.remove("dark")),r(u)};n();const o=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>n();o.addEventListener("change",s);const i=new MutationObserver(()=>{n()}),a=document.getElementById("botuyo-chat-widget-root");a&&(i.observe(a,{attributes:!0,attributeFilter:["class"]}),a.parentElement&&(i.observe(a.parentElement,{attributes:!0,attributeFilter:["class"],childList:!0}),e=a.parentElement)),i.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),i.observe(document.body,{attributes:!0,attributeFilter:["class"]});let c=t.current?.parentElement;for(;c;)i.observe(c,{attributes:!0,attributeFilter:["class"]}),c=c.parentElement;const u=setInterval(()=>{const t=document.getElementById("botuyo-chat-widget-root");t&&t.parentElement!==e&&(e&&t.parentElement&&(i.observe(t.parentElement,{attributes:!0,attributeFilter:["class"],childList:!0}),e=t.parentElement),n())},100);return()=>{i.disconnect(),o.removeEventListener("change",s),clearInterval(u)}},[t])}(z);const[S,E]=e.useState(),{mergedTheme:O,mergedStyles:I,getContainerStyle:$}=function(t,n){const r=function(){const[t,n]=e.useState(()=>"undefined"!=typeof window&&(window.matchMedia("(prefers-contrast: high)").matches||window.matchMedia("(prefers-contrast: more)").matches));return e.useEffect(()=>{const e=window.matchMedia("(prefers-contrast: high)"),t=window.matchMedia("(prefers-contrast: more)"),r=e=>{n(e.matches)};return e.addEventListener("change",r),t.addEventListener("change",r),()=>{e.removeEventListener("change",r),t.removeEventListener("change",r)}},[]),t}(),o=e.useMemo(()=>{const e=u(t,n);return r?{...e,primaryColor:"#000000",cssVariables:{...e.cssVariables,background:"#FFFFFF",foreground:"#000000",card:"#FFFFFF",cardForeground:"#000000",primary:"#000000",primaryForeground:"#FFFFFF",muted:"#F5F5F5",mutedForeground:"#000000",border:"#000000"}}:e},[t,n,r]),s=e.useMemo(()=>({radius:{...y,...t?.bubbleStyles?.radius},bot:{...v,...t?.bubbleStyles?.bot},user:{...b,...t?.bubbleStyles?.user},launcher:{...t?.bubbleStyles?.launcher},mapCard:{...t?.bubbleStyles?.mapCard}}),[t?.bubbleStyles]);return{mergedTheme:o,mergedStyles:s,getContainerStyle:(e,t,n)=>({"--chat-primary":o.primaryColor,zIndex:e?2147483647:9999,position:"fixed",top:t&&e?0:"auto",left:t&&e?0:"bottom-left"===n?"24px":"auto",right:t&&e?0:"bottom-right"!==n&&n?"auto":"24px",bottom:t&&e?0:"100px",width:t&&e?"100%":"auto",height:t&&e?"100%":"auto"})}}(c,S),{state:N,actions:C,unreadCount:T,currentBotEmotion:A,isConnected:j,handleToggle:Z,handleSendText:M,handleSendAttachment:P,handleSendLocation:D}=hs({apiKey:r,apiBaseUrl:o,pageContext:i,includeSEOMetadata:a,theme:c,userContext:l,onLogin:m,onNavigate:_,onEvent:w,onStateChange:k,onThemeUpdate:E}),F=e.useCallback(e=>{e.stopPropagation()},[]),R=$(N.isOpen,x,c?.position),U=e.useMemo(()=>{if(!O.cssVariables)return{};const e={},t=O.cssVariables;return t.background&&(e["--background"]=t.background),t.foreground&&(e["--foreground"]=t.foreground),t.card&&(e["--card"]=t.card),t.cardForeground&&(e["--card-foreground"]=t.cardForeground),t.primary&&(e["--primary"]=t.primary),t.primaryForeground&&(e["--primary-foreground"]=t.primaryForeground),t.muted&&(e["--muted"]=t.muted),t.mutedForeground&&(e["--muted-foreground"]=t.mutedForeground),t.border&&(e["--border"]=t.border),t.destructive&&(e["--destructive"]=t.destructive),t.radius&&(e["--radius"]=t.radius),t.spacing1&&(e["--spacing-1"]=t.spacing1),t.spacing2&&(e["--spacing-2"]=t.spacing2),t.spacing3&&(e["--spacing-3"]=t.spacing3),t.spacing4&&(e["--spacing-4"]=t.spacing4),t.spacing5&&(e["--spacing-5"]=t.spacing5),t.spacing6&&(e["--spacing-6"]=t.spacing6),t.spacing8&&(e["--spacing-8"]=t.spacing8),e},[O.cssVariables]);/* @__PURE__ */
|
|
30
30
|
return t.jsxs("div",{ref:z,id:"botuyo-chat-widget",className:s("botuyo-chat-widget flex flex-col",!x&&("bottom-left"===c?.position?"items-start":"items-end")),style:{...R,...U,pointerEvents:"auto",backgroundColor:"transparent"},children:[
|
|
31
|
-
/* @__PURE__ */t.jsx("div",{className:s("transition-all duration-500 ease-in-out origin-bottom",N.isOpen?"opacity-100 scale-100 h-full w-full translate-y-0 pointer-events-auto":"opacity-0 scale-95 pointer-events-none translate-y-full h-0 w-0"),style:{pointerEvents:N.isOpen?"auto":"none"},onMouseDown:
|
|
32
|
-
/* @__PURE__ */t.jsx("div",{className:s(N.isOpen?"hidden":"block",!x&&"mt-4"),style:{pointerEvents:"auto"},onMouseDown:
|
|
33
|
-
//# sourceMappingURL=ChatWidget-
|
|
31
|
+
/* @__PURE__ */t.jsx("div",{className:s("transition-all duration-500 ease-in-out origin-bottom",N.isOpen?"opacity-100 scale-100 h-full w-full translate-y-0 pointer-events-auto":"opacity-0 scale-95 pointer-events-none translate-y-full h-0 w-0"),style:{pointerEvents:N.isOpen?"auto":"none"},onMouseDown:F,onTouchStart:F,children:/* @__PURE__ */t.jsx(g,{children:/* @__PURE__ */t.jsx(f,{isOpen:N.isOpen,isConnected:j,isTyping:N.isTyping,messages:N.messages,onClose:()=>C.closeWindow(),onSendMessage:M,onSendAttachment:P,onSendLocation:D,botName:c?.botName,logoUrl:c?.logoUrl,welcomeMessage:c?.welcomeMessage,inputPlaceholder:c?.inputPlaceholder,primaryColor:c?.primaryColor,position:c?.position,bubbleStyles:I,avatars:c?.avatars,mediaConfig:d,theme:O})})}),
|
|
32
|
+
/* @__PURE__ */t.jsx("div",{className:s(N.isOpen?"hidden":"block",!x&&"mt-4"),style:{pointerEvents:"auto"},onMouseDown:F,onTouchStart:F,children:/* @__PURE__ */t.jsx(h,{isOpen:N.isOpen,onClick:Z,unreadCount:T,position:c?.position||"bottom-right",primaryColor:c?.primaryColor,logoUrl:c?.logoUrl,starterPrompt:c?.starterPrompt,avatars:c?.avatars,emotion:A,styles:I,promptPersistence:c?.promptPersistence,avatarScale:c?.avatarScale})})]})}e.createContext(null);export{gs as ChatWidget};
|
|
33
|
+
//# sourceMappingURL=ChatWidget-BCHSZnMy.js.map
|