@marketrix.ai/widget 3.8.347 → 3.8.359

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/dist/widget.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import*as e from"react";import t,{createContext as n,createElement as r,forwardRef as o,useCallback as i,useContext as s,useEffect as a,useLayoutEffect as c,useMemo as l,useRef as d,useState as u,useSyncExternalStore as p}from"react";import{createRoot as h}from"react-dom/client";import{Fragment as f,jsx as m,jsxs as g}from"react/jsx-runtime";import*as y from"react-dom";var b=2147483002,w=2147483001,v=2147483005;function x(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function k(e){return function(e){const t=x(e);if(!t)return.5;const[n,r,o]=[t.r/255,t.g/255,t.b/255].map(e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4));return.2126*n+.7152*r+.0722*o}(e)>.5?"#000000":"#ffffff"}function S(e,t){if(e.startsWith("rgba")||e.startsWith("rgb")){const n=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(n)return`rgba(${n[1]}, ${n[2]}, ${n[3]}, ${t})`}const n=x(e);return n?`rgba(${n.r}, ${n.g}, ${n.b}, ${t})`:(e.includes("gradient")||e.includes("linear-gradient"),e)}function _(e,t){const n=x(e);if(!n)return e;const r=1-t;return o=Math.round(n.r*r),i=Math.round(n.g*r),s=Math.round(n.b*r),`#${[o,i,s].map(e=>e.toString(16).padStart(2,"0")).join("")}`;var o,i,s}var C=e=>e?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):/* @__PURE__ */(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),I=e=>{switch(e){case"show":return"Show";case"tell":return"Tell";case"do":return"Do";default:return e}},E={widget_background_color:"#ffffff",widget_text_color:"#1f2937",widget_border_color:"#e5e7eb",widget_accent_color:"#3b82f6",widget_secondary_color:"#6b7280",widget_border_radius:"20px",widget_font_size:"14px",widget_width:"400px",widget_height:"600px",widget_shadow:"0 5px 40px 0 rgba(0, 0, 0, 0.3)",widget_animation_duration:"300ms",widget_fade_duration:"200ms"};function T(e={}){return function(e){return{color:{background:e.widget_background_color,foreground:e.widget_text_color,foregroundMuted:S(e.widget_text_color,.6),foregroundFaint:S(e.widget_text_color,.4),border:e.widget_border_color,borderMuted:S(e.widget_border_color,.3),primary:e.widget_accent_color,primaryForeground:k(e.widget_accent_color),primaryHover:S(e.widget_accent_color,.85),primaryMuted:S(e.widget_accent_color,.3),secondary:e.widget_secondary_color,secondaryForeground:"#ffffff",secondaryBg:S(e.widget_secondary_color,.2),secondaryHover:S(e.widget_secondary_color,.3)},radius:e.widget_border_radius,shadow:e.widget_shadow,typography:{fontSizeBase:e.widget_font_size},motion:{durationAnimation:e.widget_animation_duration,durationFade:e.widget_fade_duration},size:{widgetWidth:e.widget_width,widgetHeight:e.widget_height}}}({...E,widget_background_color:e.widget_background_color??E.widget_background_color,widget_text_color:e.widget_text_color??E.widget_text_color,widget_border_color:e.widget_border_color??E.widget_border_color,widget_accent_color:e.widget_accent_color??E.widget_accent_color,widget_secondary_color:e.widget_secondary_color??E.widget_secondary_color,widget_border_radius:e.widget_border_radius??E.widget_border_radius,widget_font_size:e.widget_font_size??E.widget_font_size,widget_width:e.widget_width??E.widget_width,widget_height:e.widget_height??E.widget_height,widget_shadow:e.widget_shadow??E.widget_shadow,widget_animation_duration:e.widget_animation_duration??E.widget_animation_duration,widget_fade_duration:e.widget_fade_duration??E.widget_fade_duration})}function M(e){return Array.isArray(e)?e:null==e?[]:[e]}var z="orpc",O=class extends Error{constructor(...e){super(...e),this.name="AbortError"}};function R(e){let t;return()=>{if(t)return t.result;const n=e();return t={result:n},n}}function A(){return globalThis["__@orpc/shared@1.14.8/otel/config__"]}function N(e,t={},n){return(A()?.tracer)?.startSpan(e,t,n)}function P(e,t,n={}){if(!e)return;const r=function(e){if(e instanceof Error){const t={message:e.message,name:e.name,stack:e.stack};return!("code"in e)||"string"!=typeof e.code&&"number"!=typeof e.code||(t.code=e.code),t}return{message:String(e)}}(t);e.recordException(r),n.signal?.aborted&&n.signal.reason===t||e.setStatus({code:2,message:r.message})}async function L({name:e,context:t,...n},r){const o=A()?.tracer;if(!o)return r();const i=async e=>{try{return await r(e)}catch(t){throw P(e,t,n),t}finally{e.end()}};return t?o.startActiveSpan(e,n,t,i):o.startActiveSpan(e,n,i)}async function $(e,t){const n=A();if(!e||!n)return t();const r=n.trace.setSpan(n.context.active(),e);return n.context.with(r,t)}function D(e){return!(!e||"object"!=typeof e)&&("next"in e&&"function"==typeof e.next&&Symbol.asyncIterator in e&&"function"==typeof e[Symbol.asyncIterator])}var F=Symbol.asyncDispose??Symbol.for("asyncDispose"),j=class{#e=!1;#t=!1;#n;#r;constructor(e,t){this.#n=t,this.#r=function(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}(async()=>{if(this.#e)return{done:!0,value:void 0};try{const t=await e();return t.done&&(this.#e=!0),t}catch(t){throw this.#e=!0,t}finally{this.#e&&!this.#t&&(this.#t=!0,await this.#n("next"))}})}next(){return this.#r()}async return(e){return this.#e=!0,this.#t||(this.#t=!0,await this.#n("return")),{done:!0,value:e}}async throw(e){throw this.#e=!0,this.#t||(this.#t=!0,await this.#n("throw")),e}async[F](){this.#e=!0,this.#t||(this.#t=!0,await this.#n("dispose"))}[Symbol.asyncIterator](){return this}};function U({name:e,...t},n){let r;return new j(async()=>{r??=N(e);try{const e=await $(r,()=>n.next());return r?.addEvent(e.done?"completed":"yielded"),e}catch(o){throw P(r,o,t),o}},async e=>{try{"next"!==e&&await $(r,()=>n.return?.())}catch(o){throw P(r,o,t),o}finally{r?.end()}})}function W(e,t,n){const r=(t,o)=>{const i=e[o];return i?i({...t,next:(e=t)=>r(e,o+1)}):n(t)};return r(t,0)}function B(e){if(e)return JSON.parse(e)}function H(e){return JSON.stringify(e)}function q(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function V(e){return!!e&&("object"==typeof e||"function"==typeof e)}function Z(e,...t){return"function"==typeof e?e(...t):e}function G(e){return new Proxy(e,{get(e,t,n){const r=Reflect.get(e,t,n);return"then"!==t||"function"!=typeof r?r:new Proxy(r,{apply(t,n,r){if(2!==r.length||r.some(e=>{return!("function"==typeof(t=e)&&Y.test(t.toString()));var t}))return Reflect.apply(t,n,r);let o=!0;r[0].call(n,G(new Proxy(e,{get:(e,t,n)=>{if(!o||"then"!==t)return Reflect.get(e,t,n);o=!1}})))}})}})}var Y=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;var J,K={BAD_REQUEST:{status:400,message:"Bad Request"},UNAUTHORIZED:{status:401,message:"Unauthorized"},FORBIDDEN:{status:403,message:"Forbidden"},NOT_FOUND:{status:404,message:"Not Found"},METHOD_NOT_SUPPORTED:{status:405,message:"Method Not Supported"},NOT_ACCEPTABLE:{status:406,message:"Not Acceptable"},TIMEOUT:{status:408,message:"Request Timeout"},CONFLICT:{status:409,message:"Conflict"},PRECONDITION_FAILED:{status:412,message:"Precondition Failed"},PAYLOAD_TOO_LARGE:{status:413,message:"Payload Too Large"},UNSUPPORTED_MEDIA_TYPE:{status:415,message:"Unsupported Media Type"},UNPROCESSABLE_CONTENT:{status:422,message:"Unprocessable Content"},TOO_MANY_REQUESTS:{status:429,message:"Too Many Requests"},CLIENT_CLOSED_REQUEST:{status:499,message:"Client Closed Request"},INTERNAL_SERVER_ERROR:{status:500,message:"Internal Server Error"},NOT_IMPLEMENTED:{status:501,message:"Not Implemented"},BAD_GATEWAY:{status:502,message:"Bad Gateway"},SERVICE_UNAVAILABLE:{status:503,message:"Service Unavailable"},GATEWAY_TIMEOUT:{status:504,message:"Gateway Timeout"}};var X=class e extends Error{defined;code;status;data;static{const t=Symbol.for("__@orpc/client@1.14.8/error/ORPC_ERROR_CONSTRUCTORS__");globalThis[t]??=/* @__PURE__ */new WeakSet,(J=globalThis[t]).add(e)}constructor(e,...t){const n=function(e){return e[0]??{}}(t);if(void 0!==n.status&&!Q(n.status))throw new Error("[ORPCError] Invalid error status code.");const r=function(e,t){return t||K[e]?.message||e}(e,n.message);super(r,n),this.code=e,this.status=function(e,t){return t??K[e]?.status??500}(e,n.status),this.defined=n.defined??!1,this.data=n.data}toJSON(){return{defined:this.defined,code:this.code,status:this.status,message:this.message,data:this.data}}static[Symbol.hasInstance](e){if(J.has(this)){const t=function(e){return V(e)?Object.getPrototypeOf(e)?.constructor:null}(e);if(t&&J.has(t))return!0}return super[Symbol.hasInstance](e)}};function Q(e){return e<200||e>=400}function ee(e){if(!q(e))return!1;const t=["defined","code","status","message","data"];return!Object.keys(e).some(e=>!t.includes(e))&&("defined"in e&&"boolean"==typeof e.defined&&"code"in e&&"string"==typeof e.code&&"status"in e&&"number"==typeof e.status&&Q(e.status)&&"message"in e&&"string"==typeof e.message)}function te(e,t={}){return new X(e.code,{...t,...e})}var ne=class extends TypeError{},re=class extends TypeError{},oe=class extends Error{data;constructor(e){super(e?.message??"An error event was received",e),this.data=e?.data}};function ie(e){const t=e.replace(/\n+$/,"").split(/\n/),n={data:void 0,event:void 0,id:void 0,retry:void 0,comments:[]};for(const r of t){const e=r.indexOf(":"),t=-1===e?r:r.slice(0,e),o=-1===e?"":r.slice(e+1).replace(/^\s/,"");if(0===e)n.comments.push(o);else if("data"===t)n.data??="",n.data+=`${o}\n`;else if("event"===t)n.event=o;else if("id"===t)n.id=o;else if("retry"===t){const e=Number.parseInt(o);Number.isInteger(e)&&e>=0&&e.toString()===o&&(n.retry=e)}}return n.data=n.data?.replace(/\n$/,""),n}var se=class{constructor(e={}){this.options=e}incomplete="";feed(e){this.incomplete+=e;const t=this.incomplete.lastIndexOf("\n\n");if(-1===t)return;const n=this.incomplete.slice(0,t).split(/\n\n/);this.incomplete=this.incomplete.slice(t+2);for(const r of n){const e=ie(`${r}\n\n`);this.options.onEvent&&this.options.onEvent(e)}}end(){if(this.incomplete)throw new re("Event Iterator ended before complete")}},ae=class extends TransformStream{constructor(){let e;super({start(t){e=new se({onEvent:e=>{t.enqueue(e)}})},transform(t){e.feed(t)},flush(){e.end()}})}};function ce(e){if(e.includes("\n"))throw new ne("Event's id must not contain a newline character")}function le(e){if(!Number.isInteger(e)||e<0)throw new ne("Event's retry must be a integer and >= 0")}function de(e){if(e.includes("\n"))throw new ne("Event's comment must not contain a newline character")}function ue(e){let t="";return t+=function(e){let t="";for(const n of e??[])de(n),t+=`: ${n}\n`;return t}(e.comments),void 0!==e.event&&(!function(e){if(e.includes("\n"))throw new ne("Event's event must not contain a newline character")}(e.event),t+=`event: ${e.event}\n`),void 0!==e.retry&&(le(e.retry),t+=`retry: ${e.retry}\n`),void 0!==e.id&&(ce(e.id),t+=`id: ${e.id}\n`),t+=function(e){const t=e?.split(/\n/)??[];let n="";for(const r of t)n+=`data: ${r}\n`;return n}(e.data),t+="\n",t}var pe=Symbol("ORPC_EVENT_SOURCE_META");function he(e,t){if(void 0===t.id&&void 0===t.retry&&!t.comments?.length)return e;if(void 0!==t.id&&ce(t.id),void 0!==t.retry&&le(t.retry),void 0!==t.comments)for(const n of t.comments)de(n);return new Proxy(e,{get:(e,n,r)=>n===pe?t:Reflect.get(e,n,r)})}function fe(e){return V(e)?Reflect.get(e,pe):void 0}function me(e){const t=e.match(/filename\*=(UTF-8'')?([^;]*)/i);if(t&&"string"==typeof t[2])return function(e){try{return decodeURIComponent(e)}catch{return e}}(t[2]);const n=e.match(/filename="((?:\\"|[^"])*)"/i);return n&&"string"==typeof n[1]?n[1].replace(/\\"/g,'"'):void 0}function ge(e,t){const n=async e=>{let n=await t.error(e);if(n!==e){const t=fe(e);t&&V(n)&&(n=he(n,t))}return n};return new j(async()=>{const{done:r,value:o}=await(async()=>{try{return await e.next()}catch(t){throw await n(t)}})();let i=await t.value(o,r);if(i!==o){const e=fe(o);e&&V(i)&&(i=he(i,e))}return{done:r,value:i}},async()=>{try{await(e.return?.())}catch(t){throw await n(t)}})}function ye(e,t={}){const n=t.path??[];return G(new Proxy(async(...[t,r={}])=>await e.call(n,t,function(e){return{...e,context:e.context??{}}}(r)),{get:(r,o)=>"string"!=typeof o?Reflect.get(r,o):ye(e,{...t,path:[...n,o]})}))}function be(e,t={}){return L({name:"parse_standard_body",signal:t.signal},async()=>{const n=e.headers.get("content-disposition");if("string"==typeof n){const t=me(n)??"blob",r=await e.blob();return new File([r],t,{type:r.type})}const r=e.headers.get("content-type");if(!r||r.startsWith("application/json"))return B(await e.text());if(r.startsWith("multipart/form-data"))return await e.formData();if(r.startsWith("application/x-www-form-urlencoded")){const t=await e.text();return new URLSearchParams(t)}if(r.startsWith("text/event-stream"))return function(e,t={}){const n=(e?.pipeThrough(new TextDecoderStream).pipeThrough(new ae))?.getReader();let r,o=!1;return new j(async()=>{r??=N("consume_event_iterator_stream");try{for(;;){if(void 0===n)return{done:!0,value:void 0};const{done:e,value:t}=await $(r,()=>n.read());if(e){if(o)throw new O("Stream was cancelled");return{done:!0,value:void 0}}switch(t.event){case"message":{let e=B(t.data);return V(e)&&(e=he(e,t)),r?.addEvent("message"),{done:!1,value:e}}case"error":{let e=new oe({data:B(t.data)});throw e=he(e,t),r?.addEvent("error"),e}case"done":{let e=B(t.data);return V(e)&&(e=he(e,t)),r?.addEvent("done"),{done:!0,value:e}}default:r?.addEvent("maybe_keepalive")}}}catch(e){throw e instanceof oe||P(r,e,t),e}},async e=>{try{"next"!==e&&(o=!0,r?.addEvent("cancelled")),await $(r,()=>n?.cancel())}catch(i){throw P(r,i,t),i}finally{r?.end()}})}(e.body,t);if(r.startsWith("text/plain"))return await e.text();const o=await e.blob();return new File([o],"blob",{type:o.type})})}function we(e,t,n={}){if(e instanceof ReadableStream)return e;const r=t.get("content-disposition");return t.delete("content-type"),t.delete("content-disposition"),void 0!==e?e instanceof Blob?(t.set("content-type",e.type),t.set("content-length",e.size.toString()),t.set("content-disposition",r??function(e,t="inline"){return`${t}; filename="${e.replace(/[^\x20-\x7E]/g,"_").replace(/"/g,'\\"')}"; filename*=utf-8''${encodeURIComponent(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}(e instanceof File?e.name:"blob")),e):e instanceof FormData||e instanceof URLSearchParams?e:D(e)?(t.set("content-type","text/event-stream"),function(e,t={}){const n=t.eventIteratorKeepAliveEnabled??!0,r=t.eventIteratorKeepAliveInterval??5e3,o=t.eventIteratorKeepAliveComment??"",i=t.eventIteratorInitialCommentEnabled??!0,s=t.eventIteratorInitialComment??"";let a,c,l=!1;return new ReadableStream({start(e){c=N("stream_event_iterator"),i&&e.enqueue(ue({comments:[s]}))},async pull(t){try{n&&(a=setInterval(()=>{t.enqueue(ue({comments:[o]})),c?.addEvent("keepalive")},r));const i=await $(c,()=>e.next());if(clearInterval(a),l)return;const s=fe(i.value);if(!i.done||void 0!==i.value||void 0!==s){const e=i.done?"done":"message";t.enqueue(ue({...s,event:e,data:H(i.value)})),c?.addEvent(e)}i.done&&(t.close(),c?.end())}catch(i){if(clearInterval(a),l)return;i instanceof oe?(t.enqueue(ue({...fe(i),event:"error",data:H(i.data)})),c?.addEvent("error"),t.close()):(P(c,i),t.error(i)),c?.end()}},async cancel(){try{l=!0,clearInterval(a),c?.addEvent("cancelled"),await $(c,()=>e.return?.())}catch(t){throw P(c,t),t}finally{c?.end()}}}).pipeThrough(new TextEncoderStream)}(e,n)):(t.set("content-type","application/json"),H(e)):void 0}function ve(e,t={}){return e.forEach((e,n)=>{Array.isArray(t[n])?t[n].push(e):void 0!==t[n]?t[n]=[t[n],e]:t[n]=e}),t}function xe(e,t={}){const n=function(e,t=new Headers){for(const[n,r]of Object.entries(e))if(Array.isArray(r))for(const e of r)t.append(n,e);else void 0!==r&&t.append(n,r);return t}(e.headers),r=we(e.body,n,t);return new Request(e.url,{signal:e.signal,method:e.method,headers:n,body:r})}var ke=class{plugins;constructor(e=[]){this.plugins=[...e].sort((e,t)=>(e.order??0)-(t.order??0))}init(e){for(const t of this.plugins)t.init?.(e)}},Se=class{constructor(e,t,n={}){this.codec=e,this.sender=t,new ke(n.plugins).init(n),this.interceptors=M(n.interceptors),this.clientInterceptors=M(n.clientInterceptors)}interceptors;clientInterceptors;call(e,t,n){return L({name:`${z}.${e.join("/")}`,signal:n.signal},r=>(r?.setAttribute("rpc.system",z),r?.setAttribute("rpc.method",e.join(".")),D(t)&&(t=U({name:"consume_event_iterator_input",signal:n.signal},t)),W(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{const o=A();let i;const s=o?.trace.getActiveSpan()??r;s&&o&&(i=o?.trace.setSpan(o.context.active(),s));const a=await L({name:"encode_request",context:i},()=>this.codec.encode(e,t,n)),c=await W(this.clientInterceptors,{...n,input:t,path:e,request:a},({input:e,path:t,request:n,...r})=>L({name:"send_request",signal:r.signal,context:i},()=>this.sender.call(n,r,t,e))),l=await L({name:"decode_response",context:i},()=>this.codec.decode(c,n,e,t));return D(l)?U({name:"consume_event_iterator_output",signal:n.signal},l):l})))}},_e=0,Ce=1,Ie=2,Ee=3,Te=4,Me=5,ze=6,Oe=7,Re=class{customSerializers;constructor(e={}){if(this.customSerializers=e.customJsonSerializers??[],this.customSerializers.length!==new Set(this.customSerializers.map(e=>e.type)).size)throw new Error("Custom serializer type must be unique.")}serialize(e,t=[],n=[],r=[],o=[]){for(const i of this.customSerializers)if(i.condition(e)){const s=this.serialize(i.serialize(e),t,n,r,o);return n.push([i.type,...t]),s}if(e instanceof Blob)return r.push(t),o.push(e),[e,n,r,o];if("bigint"==typeof e)return n.push([_e,...t]),[e.toString(),n,r,o];if(e instanceof Date)return n.push([Ce,...t]),Number.isNaN(e.getTime())?[null,n,r,o]:[e.toISOString(),n,r,o];if(Number.isNaN(e))return n.push([Ie,...t]),[null,n,r,o];if(e instanceof URL)return n.push([Te,...t]),[e.toString(),n,r,o];if(e instanceof RegExp)return n.push([Me,...t]),[e.toString(),n,r,o];if(e instanceof Set){const i=this.serialize(Array.from(e),t,n,r,o);return n.push([ze,...t]),i}if(e instanceof Map){const i=this.serialize(Array.from(e.entries()),t,n,r,o);return n.push([Oe,...t]),i}if(Array.isArray(e))return[e.map((e,i)=>void 0===e?(n.push([Ee,...t,i]),null):this.serialize(e,[...t,i],n,r,o)[0]),n,r,o];if(q(e)){const i={};for(const s in e)"toJSON"===s&&"function"==typeof e[s]||(i[s]=this.serialize(e[s],[...t,s],n,r,o)[0]);return[i,n,r,o]}return[e,n,r,o]}deserialize(e,t,n,r){const o={data:e};n&&r&&n.forEach((e,t)=>{let n=o,i="data";e.forEach(e=>{if(n=n[i],i=e,!Object.hasOwn(n,i))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${i}`)}),n[i]=r(t)});for(const i of t){const e=i[0];let t=o,n="data";for(let r=1;r<i.length;r++)if(t=t[n],n=i[r],!Object.hasOwn(t,n))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${n}`);for(const r of this.customSerializers)if(r.type===e){t[n]=r.deserialize(t[n]);break}switch(e){case _e:t[n]=BigInt(t[n]);break;case Ce:t[n]=new Date(t[n]??"Invalid Date");break;case Ie:t[n]=NaN;break;case Ee:t[n]=void 0;break;case Te:t[n]=new URL(t[n]);break;case Me:{const[,e,r]=t[n].match(/^\/(.*)\/([a-z]*)$/);t[n]=new RegExp(e,r);break}case ze:t[n]=new Set(t[n]);break;case Oe:t[n]=new Map(t[n])}}return o.data}};var Ae,Ne=class{constructor(e,t){this.serializer=e,this.baseUrl=t.url,this.maxUrlLength=t.maxUrlLength??2083,this.fallbackMethod=t.fallbackMethod??"POST",this.expectedMethod=t.method??this.fallbackMethod,this.headers=t.headers??{}}baseUrl;maxUrlLength;fallbackMethod;expectedMethod;headers;async encode(e,t,n){let r=function(e){return"function"==typeof e.forEach?ve(e):e}(await Z(this.headers,n,e,t));void 0!==n.lastEventId&&(r=function(e,t){const n={...e};for(const r in t)Array.isArray(t[r])?n[r]=[...M(n[r]),...t[r]]:void 0!==t[r]&&(Array.isArray(n[r])?n[r]=[...n[r],t[r]]:void 0!==n[r]?n[r]=[n[r],t[r]]:n[r]=t[r]);return n}(r,{"last-event-id":n.lastEventId}));const o=await Z(this.expectedMethod,n,e,t),i=await Z(this.baseUrl,n,e,t),s=new URL(i);s.pathname=`${s.pathname.replace(/\/$/,"")}${function(e){return`/${e.map(encodeURIComponent).join("/")}`}(e)}`;const a=this.serializer.serialize(t);if(!("GET"!==o||a instanceof FormData||D(a))){const i=await Z(this.maxUrlLength,n,e,t),c=new URL(s);if(c.searchParams.append("data",H(a)),c.toString().length<=i)return{body:void 0,method:o,headers:r,url:c,signal:n.signal}}return{url:s,method:"GET"===o?this.fallbackMethod:o,headers:r,body:a,signal:n.signal}}async decode(e){const t=!Q(e.status),n=await(async()=>{let t=!1;try{const n=await e.body();return t=!0,this.serializer.deserialize(n)}catch(n){if(!t)throw new Error("Cannot parse response body, please check the response body and content-type.",{cause:n});throw new Error("Invalid RPC response format.",{cause:n})}})();if(!t){if(ee(n))throw te(n);throw new X((r=e.status,Object.entries(K).find(([,e])=>e.status===r)?.[0]??"MALFORMED_ORPC_ERROR_RESPONSE"),{status:e.status,data:{...e,body:n}})}var r;return n}},Pe=class{constructor(e){this.jsonSerializer=e}serialize(e){return D(e)?ge(e,{value:async e=>this.#o(e,!1),error:async e=>{return new oe({data:this.#o((t=e,t instanceof X?t:new X("INTERNAL_SERVER_ERROR",{message:"Internal server error",cause:t})).toJSON(),!1),cause:e});var t}}):this.#o(e,!0)}#o(e,t){const[n,r,o,i]=this.jsonSerializer.serialize(e),s=0===r.length?void 0:r;if(!t||0===i.length)return{json:n,meta:s};const a=new FormData;return a.set("data",H({json:n,meta:s,maps:o})),i.forEach((e,t)=>{a.set(t.toString(),e)}),a}deserialize(e){return D(e)?ge(e,{value:async e=>this.#i(e),error:async e=>{if(!(e instanceof oe))return e;const t=this.#i(e.data);return ee(t)?te(t,{cause:e}):new oe({data:t,cause:e})}}):this.#i(e)}#i(e){if(void 0===e)return;if(!(e instanceof FormData))return this.jsonSerializer.deserialize(e.json,e.meta??[]);const t=JSON.parse(e.get("data"));return this.jsonSerializer.deserialize(t.json,t.meta??[],t.maps,t=>e.get(t.toString()))}},Le=class extends Se{constructor(e,t){const n=new Re(t),r=new Pe(n);super(new Ne(r,t),e,t)}},$e=class extends ke{initRuntimeAdapter(e){for(const t of this.plugins)t.initRuntimeAdapter?.(e)}},De=class{fetch;toFetchRequestOptions;adapterInterceptors;constructor(e){new $e(e.plugins).initRuntimeAdapter(e),this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.toFetchRequestOptions=e,this.adapterInterceptors=M(e.adapterInterceptors)}async call(e,t,n,r){const o=xe(e,this.toFetchRequestOptions);return function(e,t={}){return{body:R(()=>be(e,t)),status:e.status,get headers(){const t=ve(e.headers);return Object.defineProperty(this,"headers",{value:t,writable:!0}),t},set headers(e){Object.defineProperty(this,"headers",{value:e,writable:!0})}}}(await W(this.adapterInterceptors,{...t,request:o,path:n,input:r,init:{redirect:"manual"}},({request:e,path:t,input:n,init:r,...o})=>this.fetch(e,r,o,t,n)),{signal:o.signal})}},Fe=class extends Le{constructor(e){super(new De(e),e)}};function je(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:s,traits:/* @__PURE__ */new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const o=s.prototype,i=Object.keys(o);for(let e=0;e<i.length;e++){const t=i[e];t in n||(n[t]=o[t].bind(n))}}const o=n?.Parent??Object;class i extends o{}function s(e){var t;const o=n?.Parent?new i:this;r(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const n of o._zod.deferred)n();return o}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var Ue=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},We=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Ae=globalThis).__zod_globalConfig??(Ae.__zod_globalConfig={});var Be=globalThis.__zod_globalConfig;function He(e){return e&&Object.assign(Be,e),Be}function qe(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 Ve(e,t){return"bigint"==typeof t?t.toString():t}function Ze(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ge(e){return null==e}function Ye(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var Je=/* @__PURE__*/Symbol("evaluating");function Ke(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Je)return void 0===r&&(r=Je,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Xe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Qe(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function et(e){return JSON.stringify(e)}var tt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function nt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var rt=/* @__PURE__*/Ze(()=>{if(Be.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function ot(e){if(!1===nt(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!==nt(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function it(e){return ot(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var st=/* @__PURE__*/new Set(["string","number","symbol"]);function at(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ct(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function lt(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}var dt={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 ut(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 pt(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function ht(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ft(e){return"string"==typeof e?e:e?.message}function mt(e,t,n){const r=e.message?e.message:ft(e.inst?._zod.def?.error?.(e))??ft(t?.error?.(e))??ft(n.customError?.(e))??ft(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=s),a}function gt(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function yt(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}var bt=(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,Ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},wt=je("$ZodError",bt),vt=je("$ZodError",bt,{Parent:Error});var xt=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Ue;if(s.issues.length){const t=new(o?.Err??e)(s.issues.map(e=>mt(e,i,He())));throw tt(t,o?.callee),t}return s.value},kt=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(o?.Err??e)(s.issues.map(e=>mt(e,i,He())));throw tt(t,o?.callee),t}return s.value},St=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Ue;return i.issues.length?{success:!1,error:new(e??wt)(i.issues.map(e=>mt(e,o,He())))}:{success:!0,data:i.value}},_t=/* @__PURE__*/St(vt),Ct=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(e=>mt(e,o,He())))}:{success:!0,data:i.value}},It=/* @__PURE__*/Ct(vt),Et=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return xt(e)(t,n,o)},Tt=e=>(t,n,r)=>xt(e)(t,n,r),Mt=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return kt(e)(t,n,o)},zt=e=>async(t,n,r)=>kt(e)(t,n,r),Ot=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return St(e)(t,n,o)},Rt=e=>(t,n,r)=>St(e)(t,n,r),At=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ct(e)(t,n,o)},Nt=e=>async(t,n,r)=>Ct(e)(t,n,r),Pt=/^[cC][0-9a-z]{6,}$/,Lt=/^[0-9a-z]+$/,$t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Dt=/^[0-9a-vA-V]{20}$/,Ft=/^[A-Za-z0-9]{27}$/,jt=/^[a-zA-Z0-9_-]{21}$/,Ut=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Wt=/^([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})$/,Bt=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)$/,Ht=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var qt=/^(?:(?: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])$/,Vt=/^(([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}|:))$/,Zt=/^((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])$/,Gt=/^(([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])$/,Yt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Jt=/^[A-Za-z0-9_-]*$/,Kt=/^https?$/,Xt=/^\+[1-9]\d{6,14}$/,Qt="(?:(?:\\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])))",en=/*@__PURE__*/new RegExp(`^${Qt}$`);function tn(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+)?)?`}var nn=/^-?\d+$/,rn=/^-?\d+(?:\.\d+)?$/,on=/^(?:true|false)$/i,sn=/^[^A-Z]*$/,an=/^[^a-z]*$/,cn=/*@__PURE__*/je("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ln={number:"number",bigint:"bigint",object:"date"},dn=/*@__PURE__*/je("$ZodCheckLessThan",(e,t)=>{cn.init(e,t);const n=ln[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})}}),un=/*@__PURE__*/je("$ZodCheckGreaterThan",(e,t)=>{cn.init(e,t);const n=ln[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})}}),pn=/*@__PURE__*/je("$ZodCheckMultipleOf",(e,t)=>{cn.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/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}(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})}}),hn=/*@__PURE__*/je("$ZodCheckNumberFormat",(e,t)=>{cn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=dt[t.format];e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,r.minimum=o,r.maximum=i,n&&(r.pattern=nn)}),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.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}):s.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&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),fn=/*@__PURE__*/je("$ZodCheckMaxLength",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ge(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=gt(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),mn=/*@__PURE__*/je("$ZodCheckMinLength",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ge(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=gt(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gn=/*@__PURE__*/je("$ZodCheckLengthEquals",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ge(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 i=gt(r),s=o>t.length;n.issues.push({origin:i,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),yn=/*@__PURE__*/je("$ZodCheckStringFormat",(e,t)=>{var n,r;cn.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=()=>{})}),bn=/*@__PURE__*/je("$ZodCheckRegex",(e,t)=>{yn.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})}}),wn=/*@__PURE__*/je("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=sn),yn.init(e,t)}),vn=/*@__PURE__*/je("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=an),yn.init(e,t)}),xn=/*@__PURE__*/je("$ZodCheckIncludes",(e,t)=>{cn.init(e,t);const n=at(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})}}),kn=/*@__PURE__*/je("$ZodCheckStartsWith",(e,t)=>{cn.init(e,t);const n=new RegExp(`^${at(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})}}),Sn=/*@__PURE__*/je("$ZodCheckEndsWith",(e,t)=>{cn.init(e,t);const n=new RegExp(`.*${at(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})}}),_n=/*@__PURE__*/je("$ZodCheckOverwrite",(e,t)=>{cn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Cn=class{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"))}},In={major:4,minor:4,patch:3},En=/*@__PURE__*/je("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=In;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=ut(e);for(const i of t){if(i._zod.def.when){if(pt(e))continue;if(!i._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,s=i._zod.check(e);if(s instanceof Promise&&!1===n?.async)throw new Ue;if(r||s instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await s,e.issues.length!==t&&(o||(o=ut(e,t)))});else{if(e.issues.length===t)continue;o||(o=ut(e,t))}}return r?r.then(()=>e):e},n=(n,o,i)=>{if(ut(n))return n.aborted=!0,n;const s=t(o,r,i);if(s instanceof Promise){if(!1===i.async)throw new Ue;return s.then(t=>e._zod.parse(t,i))}return e._zod.parse(s,i)};e._zod.run=(o,i)=>{if(i.skipChecks)return e._zod.parse(o,i);if("backward"===i.direction){const t=e._zod.parse({value:o.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,o,i)):n(t,o,i)}const s=e._zod.parse(o,i);if(s instanceof Promise){if(!1===i.async)throw new Ue;return s.then(e=>t(e,r,i))}return t(s,r,i)}}Ke(e,"~standard",()=>({validate:t=>{try{const n=_t(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return It(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Tn=/*@__PURE__*/je("$ZodString",(e,t)=>{var n;En.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(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Mn=/*@__PURE__*/je("$ZodStringFormat",(e,t)=>{yn.init(e,t),Tn.init(e,t)}),zn=/*@__PURE__*/je("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Wt),Mn.init(e,t)}),On=/*@__PURE__*/je("$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=Bt(e))}else t.pattern??(t.pattern=Bt());Mn.init(e,t)}),Rn=/*@__PURE__*/je("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ht),Mn.init(e,t)}),An=/*@__PURE__*/je("$ZodURL",(e,t)=>{Mn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Kt.source&&!/^https?:\/\//i.test(r))return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});const 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})}}}),Nn=/*@__PURE__*/je("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Mn.init(e,t)}),Pn=/*@__PURE__*/je("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=jt),Mn.init(e,t)}),Ln=/*@__PURE__*/je("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Pt),Mn.init(e,t)}),$n=/*@__PURE__*/je("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Lt),Mn.init(e,t)}),Dn=/*@__PURE__*/je("$ZodULID",(e,t)=>{t.pattern??(t.pattern=$t),Mn.init(e,t)}),Fn=/*@__PURE__*/je("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Dt),Mn.init(e,t)}),jn=/*@__PURE__*/je("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ft),Mn.init(e,t)}),Un=/*@__PURE__*/je("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=tn({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(`^${Qt}T(?:${r})$`)}(t)),Mn.init(e,t)}),Wn=/*@__PURE__*/je("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=en),Mn.init(e,t)}),Bn=/*@__PURE__*/je("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${tn(t)}$`)),Mn.init(e,t)}),Hn=/*@__PURE__*/je("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ut),Mn.init(e,t)}),qn=/*@__PURE__*/je("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=qt),Mn.init(e,t),e._zod.bag.format="ipv4"}),Vn=/*@__PURE__*/je("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Vt),Mn.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})}}}),Zn=/*@__PURE__*/je("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Zt),Mn.init(e,t)}),Gn=/*@__PURE__*/je("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Gt),Mn.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 Yn(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Jn=/*@__PURE__*/je("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Yt),Mn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Yn(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});var Kn=/*@__PURE__*/je("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Jt),Mn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Jt.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Yn(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})}}),Xn=/*@__PURE__*/je("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Xt),Mn.init(e,t)});var Qn=/*@__PURE__*/je("$ZodJWT",(e,t)=>{Mn.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})}}),er=/*@__PURE__*/je("$ZodNumber",(e,t)=>{En.init(e,t),e._zod.pattern=e._zod.bag.pattern??rn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(s){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i="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,...i?{received:i}:{}}),n}}),tr=/*@__PURE__*/je("$ZodNumberFormat",(e,t)=>{hn.init(e,t),er.init(e,t)}),nr=/*@__PURE__*/je("$ZodBoolean",(e,t)=>{En.init(e,t),e._zod.pattern=on,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(i){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),rr=/*@__PURE__*/je("$ZodUnknown",(e,t)=>{En.init(e,t),e._zod.parse=e=>e}),or=/*@__PURE__*/je("$ZodNever",(e,t)=>{En.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),ir=/*@__PURE__*/je("$ZodDate",(e,t)=>{En.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch(s){}const o=n.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),n}});function sr(e,t,n){e.issues.length&&t.issues.push(...ht(n,e.issues)),t.value[n]=e.value}var ar=/*@__PURE__*/je("$ZodArray",(e,t)=>{En.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 i=[];for(let e=0;e<o.length;e++){const s=o[e],a=t.element._zod.run({value:s,issues:[]},r);a instanceof Promise?i.push(a.then(t=>sr(t,n,e))):sr(a,n,e)}return i.length?Promise.all(i).then(()=>n):n}});function cr(e,t,n,r,o,i){const s=n in r;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...ht(n,e.issues))}s||o?void 0===e.value?s&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}function lr(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 dr(e,t,n,r,o,i){const s=[],a=o.keySet,c=o.catchall._zod,l=c.def.type,d="optional"===c.optin,u="optional"===c.optout;for(const p in t){if("__proto__"===p)continue;if(a.has(p))continue;if("never"===l){s.push(p);continue}const o=c.run({value:t[p],issues:[]},r);o instanceof Promise?e.push(o.then(e=>cr(e,n,p,t,d,u))):cr(o,n,p,t,d,u)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}var ur=/*@__PURE__*/je("$ZodObject",(e,t)=>{if(En.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const n=Ze(()=>lr(t));Ke(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 r=nt,o=t.catchall;let i;e._zod.parse=(t,s)=>{i??(i=n.value);const a=t.value;if(!r(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const c=[],l=i.shape;for(const e of i.keys){const n=l[e],r="optional"===n._zod.optin,o="optional"===n._zod.optout,i=n._zod.run({value:a[e],issues:[]},s);i instanceof Promise?c.push(i.then(n=>cr(n,t,e,a,r,o))):cr(i,t,e,a,r,o)}return o?dr(c,a,t,s,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),pr=/*@__PURE__*/je("$ZodObjectJIT",(e,t)=>{ur.init(e,t);const n=e._zod.parse,r=Ze(()=>lr(t));let o;const i=nt,s=!Be.jitless,a=s&&rt.value,c=t.catchall;let l;e._zod.parse=(d,u)=>{l??(l=r.value);const p=d.value;return i(p)?s&&a&&!1===u?.async&&!0!==u.jitless?(o||(o=(e=>{const t=new Cn(["shape","payload","ctx"]),n=r.value,o=e=>{const t=et(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let s=0;for(const r of n.keys)i[r]="key_"+s++;t.write("const newResult = {};");for(const r of n.keys){const n=i[r],s=et(r),a=e[r],c="optional"===a?._zod?.optin,l="optional"===a?._zod?.optout;t.write(`const ${n} = ${o(r)};`),c&&l?t.write(`\n if (${n}.issues.length) {\n if (${s} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):c?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${s} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${s}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${s}] = undefined;\n } else {\n newResult[${s}] = ${n}.value;\n }\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,u),c?dr([],p,d,u,l,e):d):n(d,u):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}});function hr(e,t,n,r){for(const i of e)if(0===i.issues.length)return t.value=i.value,t;const o=e.filter(e=>!ut(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=>mt(e,r,He())))}),t)}var fr=/*@__PURE__*/je("$ZodUnion",(e,t)=>{En.init(e,t),Ke(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),Ke(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),Ke(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Ke(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=>Ye(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},o);if(t instanceof Promise)s.push(t),i=!0;else{if(0===t.issues.length)return t;s.push(t)}}return i?Promise.all(s).then(t=>hr(t,r,e,o)):hr(s,r,e,o)}}),mr=/*@__PURE__*/je("$ZodIntersection",(e,t)=>{En.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,o=t.left._zod.run({value:r,issues:[]},n),i=t.right._zod.run({value:r,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([t,n])=>yr(e,t,n)):yr(e,o,i)}});function gr(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(ot(e)&&ot(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),o={...e,...t};for(const i of r){const n=gr(e[i],t[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};o[i]=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=gr(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 yr(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 i=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(i.length&&o&&e.issues.push({...o,keys:i}),ut(e))return e;const s=gr(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var br=/*@__PURE__*/je("$ZodRecord",(e,t)=>{En.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!ot(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],s=t.keyType._zod.values;if(s){n.value={};const a=/* @__PURE__ */new Set;for(const l of s)if("string"==typeof l||"number"==typeof l||"symbol"==typeof l){a.add("number"==typeof l?l.toString():l);const s=t.keyType._zod.run({value:l,issues:[]},r);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(s.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>mt(e,r,He())),input:l,path:[l],inst:e});continue}const c=s.value,d=t.valueType._zod.run({value:o[l],issues:[]},r);d instanceof Promise?i.push(d.then(e=>{e.issues.length&&n.issues.push(...ht(l,e.issues)),n.value[c]=e.value})):(d.issues.length&&n.issues.push(...ht(l,d.issues)),n.value[c]=d.value)}let c;for(const e in o)a.has(e)||(c=c??[],c.push(e));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const s of Reflect.ownKeys(o)){if("__proto__"===s)continue;if(!Object.prototype.propertyIsEnumerable.call(o,s))continue;let a=t.keyType._zod.run({value:s,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof s&&rn.test(s)&&a.issues.length){const e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(a=e)}if(a.issues.length){"loose"===t.mode?n.value[s]=o[s]:n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>mt(e,r,He())),input:s,path:[s],inst:e});continue}const c=t.valueType._zod.run({value:o[s],issues:[]},r);c instanceof Promise?i.push(c.then(e=>{e.issues.length&&n.issues.push(...ht(s,e.issues)),n.value[a.value]=e.value})):(c.issues.length&&n.issues.push(...ht(s,c.issues)),n.value[a.value]=c.value)}}return i.length?Promise.all(i).then(()=>n):n}}),wr=/*@__PURE__*/je("$ZodEnum",(e,t)=>{En.init(e,t);const n=qe(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>st.has(typeof e)).map(e=>"string"==typeof e?at(e):e.toString()).join("|")})$`),e._zod.parse=(t,o)=>{const i=t.value;return r.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}}),vr=/*@__PURE__*/je("$ZodLiteral",(e,t)=>{if(En.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?at(e):e?at(e.toString()):String(e)).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),xr=/*@__PURE__*/je("$ZodTransform",(e,t)=>{En.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new We(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.fallback=!0,n));if(o instanceof Promise)throw new Ue;return n.value=o,n.fallback=!0,n}});function kr(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Sr=/*@__PURE__*/je("$ZodOptional",(e,t)=>{En.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ke(e._zod,"values",()=>t.innerType._zod.values?/* @__PURE__ */new Set([...t.innerType._zod.values,void 0]):void 0),Ke(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ye(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=e.value,o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(e=>kr(e,r)):kr(o,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),_r=/*@__PURE__*/je("$ZodExactOptional",(e,t)=>{Sr.init(e,t),Ke(e._zod,"values",()=>t.innerType._zod.values),Ke(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Cr=/*@__PURE__*/je("$ZodNullable",(e,t)=>{En.init(e,t),Ke(e._zod,"optin",()=>t.innerType._zod.optin),Ke(e._zod,"optout",()=>t.innerType._zod.optout),Ke(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ye(e.source)}|null)$`):void 0}),Ke(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)}),Ir=/*@__PURE__*/je("$ZodDefault",(e,t)=>{En.init(e,t),e._zod.optin="optional",Ke(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=>Er(e,t)):Er(r,t)}});function Er(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var Tr=/*@__PURE__*/je("$ZodPrefault",(e,t)=>{En.init(e,t),e._zod.optin="optional",Ke(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))}),Mr=/*@__PURE__*/je("$ZodNonOptional",(e,t)=>{En.init(e,t),Ke(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=>zr(t,e)):zr(o,e)}});function zr(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Or=/*@__PURE__*/je("$ZodCatch",(e,t)=>{En.init(e,t),e._zod.optin="optional",Ke(e._zod,"optout",()=>t.innerType._zod.optout),Ke(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=>mt(e,n,He()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>mt(e,n,He()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Rr=/*@__PURE__*/je("$ZodPipe",(e,t)=>{En.init(e,t),Ke(e._zod,"values",()=>t.in._zod.values),Ke(e._zod,"optin",()=>t.in._zod.optin),Ke(e._zod,"optout",()=>t.out._zod.optout),Ke(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=>Ar(e,t.in,n)):Ar(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ar(e,t.out,n)):Ar(r,t.out,n)}});function Ar(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Nr=/*@__PURE__*/je("$ZodReadonly",(e,t)=>{En.init(e,t),Ke(e._zod,"propValues",()=>t.innerType._zod.propValues),Ke(e._zod,"values",()=>t.innerType._zod.values),Ke(e._zod,"optin",()=>t.innerType?._zod?.optin),Ke(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(Pr):Pr(r)}});function Pr(e){return e.value=Object.freeze(e.value),e}var Lr,$r=/*@__PURE__*/je("$ZodCustom",(e,t)=>{cn.init(e,t),En.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=>Dr(t,n,r,e));Dr(o,n,r,e)}});function Dr(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(yt(e))}}var Fr=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)}};(Lr=globalThis).__zod_globalRegistry??(Lr.__zod_globalRegistry=new Fr);var jr=globalThis.__zod_globalRegistry;function Ur(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...lt(t)})}function Wr(e,t){return new dn({check:"less_than",...lt(t),value:e,inclusive:!1})}function Br(e,t){return new dn({check:"less_than",...lt(t),value:e,inclusive:!0})}function Hr(e,t){return new un({check:"greater_than",...lt(t),value:e,inclusive:!1})}function qr(e,t){return new un({check:"greater_than",...lt(t),value:e,inclusive:!0})}function Vr(e,t){return new pn({check:"multiple_of",...lt(t),value:e})}function Zr(e,t){return new fn({check:"max_length",...lt(t),maximum:e})}function Gr(e,t){return new mn({check:"min_length",...lt(t),minimum:e})}function Yr(e,t){return new gn({check:"length_equals",...lt(t),length:e})}function Jr(e){return new _n({check:"overwrite",tx:e})}function Kr(e,t){const n=new cn({check:"custom",...lt(t)});return n._zod.check=e,n}function Xr(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??jr,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 Qr(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,r);else{const n=s.schema,i=t.processors[o.type];if(!i)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);i(e,t,n,r)}const i=e._zod.parent;i&&(s.ref||(s.ref=i),Qr(i,t,r),t.seen.get(i).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),"input"===t.io&&no(e)&&(delete s.schema.examples,delete s.schema.default),"input"===t.io&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function eo(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 i of e.seen.entries()){const t=e.metadataRegistry.get(i[0])?.id;if(t){const e=r.get(t);if(e&&e!==i[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,i[0])}}const o=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:o,defId:i}=(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 i=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=i,{defId:i,ref:`${o("__shared")}#/${r}/${i}`}}if(t[1]===n)return{ref:"#"};const o=`#/${r}/`,i=t[1].schema.id??"__schema"+e.counter++;return{defId:i,ref:o+i}})(t);r.def={...r.schema},i&&(r.defId=i);const s=r.schema;for(const e in s)delete s[e];s.$ref=o};if("throw"===e.cycles)for(const i of e.seen.entries()){const e=i[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 i of e.seen.entries()){const n=i[1];if(t!==i[0]){if(e.external){const n=e.external.registry.get(i[0])?.id;if(t!==i[0]&&n){o(i);continue}}(e.metadataRegistry.get(i[0])?.id||n.cycle||n.count>1&&"ref"===e.reused)&&o(i)}else o(i)}}function to(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,i={...o},s=n.ref;if(n.ref=null,s){r(s);const n=e.seen.get(s),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,i),t._zod.parent===s)for(const e in o)"$ref"!==e&&"allOf"!==e&&(e in i||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!==s){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 c of[...e.seen.entries()].reverse())r(c[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 i=e.metadataRegistry.get(t)?.id;void 0!==i&&o.id===i&&delete o.id;const s=e.external?.defs??{};for(const c of e.seen.entries()){const e=c[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,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:ro(t,"input",e.processors),output:ro(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function no(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 no(r.element,n);if("set"===r.type)return no(r.valueType,n);if("lazy"===r.type)return no(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 no(r.innerType,n);if("intersection"===r.type)return no(r.left,n)||no(r.right,n);if("record"===r.type||"map"===r.type)return no(r.keyType,n)||no(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(no(r.in,n)||no(r.out,n));if("object"===r.type){for(const e in r.shape)if(no(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(no(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(no(e,n))return!0;return!(!r.rest||!no(r.rest,n))}return!1}var ro=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Xr({...o??{},target:i,io:t,processors:n});return Qr(e,s),eo(s,e),to(s,e)},oo={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},io=(e,t,n,r)=>{const o=e._zod.def;Qr(o.innerType,t,r);t.seen.get(e).ref=o.innerType},so=/*@__PURE__*/je("ZodISODateTime",(e,t)=>{Un.init(e,t),Po.init(e,t)});function ao(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...lt(t)})}(so,e)}var co=/*@__PURE__*/je("ZodISODate",(e,t)=>{Wn.init(e,t),Po.init(e,t)});function lo(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...lt(t)})}(co,e)}var uo=/*@__PURE__*/je("ZodISOTime",(e,t)=>{Bn.init(e,t),Po.init(e,t)});function po(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...lt(t)})}(uo,e)}var ho=/*@__PURE__*/je("ZodISODuration",(e,t)=>{Hn.init(e,t),Po.init(e,t)});function fo(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...lt(t)})}(ho,e)}var mo=(e,t)=>{wt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,o=[])=>{for(const i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map(e=>r({issues:e},[...o,...i.path]));else if("invalid_key"===i.code)r({issues:i.issues},[...o,...i.path]);else if("invalid_element"===i.code)r({issues:i.issues},[...o,...i.path]);else{const e=[...o,...i.path];if(0===e.length)n._errors.push(t(i));else{let r=n,o=0;for(;o<e.length;){const n=e[o];o!==e.length-1?r[n]=r[n]||{_errors:[]}:(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(i))),r=r[n],o++}}}};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,Ve,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ve,2)}},isEmpty:{get:()=>0===e.issues.length}})},go=/*@__PURE__*/je("ZodError",mo,{Parent:Error}),yo=/* @__PURE__ */xt(go),bo=/* @__PURE__ */kt(go),wo=/* @__PURE__ */St(go),vo=/* @__PURE__ */Ct(go),xo=/* @__PURE__ */Et(go),ko=/* @__PURE__ */Tt(go),So=/* @__PURE__ */Mt(go),_o=/* @__PURE__ */zt(go),Co=/* @__PURE__ */Ot(go),Io=/* @__PURE__ */Rt(go),Eo=/* @__PURE__ */At(go),To=/* @__PURE__ */Nt(go),Mo=/* @__PURE__ */new WeakMap;function zo(e,t,n){const r=Object.getPrototypeOf(e);let o=Mo.get(r);if(o||(o=/* @__PURE__ */new Set,Mo.set(r,o)),!o.has(t)){o.add(t);for(const e in n){const t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){const n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Oo=/*@__PURE__*/je("ZodType",(e,t)=>(En.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ro(e,"input"),output:ro(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=Xr({...n,processors:t});return Qr(e,r),eo(r,e),to(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>yo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>wo(e,t,n),e.parseAsync=async(t,n)=>bo(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>vo(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>xo(e,t,n),e.decode=(t,n)=>ko(e,t,n),e.encodeAsync=async(t,n)=>So(e,t,n),e.decodeAsync=async(t,n)=>_o(e,t,n),e.safeEncode=(t,n)=>Co(e,t,n),e.safeDecode=(t,n)=>Io(e,t,n),e.safeEncodeAsync=async(t,n)=>Eo(e,t,n),e.safeDecodeAsync=async(t,n)=>To(e,t,n),zo(e,"ZodType",{check(...e){const t=this.def;return this.clone(Qe(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ct(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...lt(n)})}($i,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=/* @__PURE__ */Kr(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(yt(e,t.value,n._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(yt(r))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check(Jr(e))},optional(){return Ii(this)},exactOptional(){return new Ei({type:"optional",innerType:this})},nullable(){return Mi(this)},nullish(){return Ii(Mi(this))},nonoptional(e){return function(e,t){return new Ri({type:"nonoptional",innerType:e,...lt(t)})}(this,e)},array(){return hi(this)},or(e){return yi([this,e])},and(e){return new bi({type:"intersection",left:this,right:e})},transform(e){return Pi(this,new _i({type:"transform",transform:e}))},default(e){return t=e,new zi({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():it(t)}});var t},prefault(e){return t=e,new Oi({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():it(t)}});var t},catch(e){return new Ai({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Pi(this,e)},readonly(){return new Li({type:"readonly",innerType:this})},describe(e){const t=this.clone();return jr.add(t,{description:e}),t},meta(...e){if(0===e.length)return jr.get(this);const t=this.clone();return jr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>jr.get(e)?.description,configurable:!0}),e)),Ro=/*@__PURE__*/je("_ZodString",(e,t)=>{Tn.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:o,maximum:i,format:s,patterns:a,contentEncoding:c}=e._zod.bag;if("number"==typeof o&&(r.minLength=o),"number"==typeof i&&(r.maxLength=i),s&&(r.format=oo[s]??s,""===r.format&&delete r.format,"time"===s&&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,zo(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new bn({check:"string_format",format:"regex",...lt(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new xn({check:"string_format",format:"includes",...lt(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new kn({check:"string_format",format:"starts_with",...lt(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Sn({check:"string_format",format:"ends_with",...lt(t),suffix:e})}(...e))},min(...e){return this.check(Gr(...e))},max(...e){return this.check(Zr(...e))},length(...e){return this.check(Yr(...e))},nonempty(...e){return this.check(Gr(1,...e))},lowercase(e){return this.check(function(e){return new wn({check:"string_format",format:"lowercase",...lt(e)})}(e))},uppercase(e){return this.check(function(e){return new vn({check:"string_format",format:"uppercase",...lt(e)})}(e))},trim(){return this.check(/* @__PURE__ */Jr(e=>e.trim()))},normalize(...e){return this.check(function(e){/* @__PURE__ */
1
+ import*as e from"react";import t,{createContext as n,createElement as r,forwardRef as o,useCallback as i,useContext as s,useEffect as a,useLayoutEffect as c,useMemo as l,useRef as d,useState as u,useSyncExternalStore as p}from"react";import{createRoot as h}from"react-dom/client";import{Fragment as f,jsx as m,jsxs as g}from"react/jsx-runtime";import*as y from"react-dom";var b=2147483002,w=2147483001,v=2147483005;function x(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function k(e){return function(e){const t=x(e);if(!t)return.5;const[n,r,o]=[t.r/255,t.g/255,t.b/255].map(e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4));return.2126*n+.7152*r+.0722*o}(e)>.5?"#000000":"#ffffff"}function S(e,t){if(e.startsWith("rgba")||e.startsWith("rgb")){const n=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(n)return`rgba(${n[1]}, ${n[2]}, ${n[3]}, ${t})`}const n=x(e);return n?`rgba(${n.r}, ${n.g}, ${n.b}, ${t})`:(e.includes("gradient")||e.includes("linear-gradient"),e)}function _(e,t){const n=x(e);if(!n)return e;const r=1-t;return o=Math.round(n.r*r),i=Math.round(n.g*r),s=Math.round(n.b*r),`#${[o,i,s].map(e=>e.toString(16).padStart(2,"0")).join("")}`;var o,i,s}var C=e=>e?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):/* @__PURE__ */(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),I=e=>{switch(e){case"show":return"Show";case"tell":return"Tell";case"do":return"Do";default:return e}},E={widget_background_color:"#ffffff",widget_text_color:"#1f2937",widget_border_color:"#e5e7eb",widget_accent_color:"#3b82f6",widget_secondary_color:"#6b7280",widget_border_radius:"20px",widget_font_size:"14px",widget_width:"400px",widget_height:"600px",widget_shadow:"0 5px 40px 0 rgba(0, 0, 0, 0.3)",widget_animation_duration:"300ms",widget_fade_duration:"200ms"};function T(e={}){return function(e){return{color:{background:e.widget_background_color,foreground:e.widget_text_color,foregroundMuted:S(e.widget_text_color,.6),foregroundFaint:S(e.widget_text_color,.4),border:e.widget_border_color,borderMuted:S(e.widget_border_color,.3),primary:e.widget_accent_color,primaryForeground:k(e.widget_accent_color),primaryHover:S(e.widget_accent_color,.85),primaryMuted:S(e.widget_accent_color,.3),secondary:e.widget_secondary_color,secondaryForeground:"#ffffff",secondaryBg:S(e.widget_secondary_color,.2),secondaryHover:S(e.widget_secondary_color,.3)},radius:e.widget_border_radius,shadow:e.widget_shadow,typography:{fontSizeBase:e.widget_font_size},motion:{durationAnimation:e.widget_animation_duration,durationFade:e.widget_fade_duration},size:{widgetWidth:e.widget_width,widgetHeight:e.widget_height}}}({...E,widget_background_color:e.widget_background_color??E.widget_background_color,widget_text_color:e.widget_text_color??E.widget_text_color,widget_border_color:e.widget_border_color??E.widget_border_color,widget_accent_color:e.widget_accent_color??E.widget_accent_color,widget_secondary_color:e.widget_secondary_color??E.widget_secondary_color,widget_border_radius:e.widget_border_radius??E.widget_border_radius,widget_font_size:e.widget_font_size??E.widget_font_size,widget_width:e.widget_width??E.widget_width,widget_height:e.widget_height??E.widget_height,widget_shadow:e.widget_shadow??E.widget_shadow,widget_animation_duration:e.widget_animation_duration??E.widget_animation_duration,widget_fade_duration:e.widget_fade_duration??E.widget_fade_duration})}function M(e){return Array.isArray(e)?e:null==e?[]:[e]}var z="orpc",O=class extends Error{constructor(...e){super(...e),this.name="AbortError"}};function R(e){let t;return()=>{if(t)return t.result;const n=e();return t={result:n},n}}function A(){return globalThis["__@orpc/shared@1.14.10/otel/config__"]}function N(e,t={},n){return(A()?.tracer)?.startSpan(e,t,n)}function P(e,t,n={}){if(!e)return;const r=function(e){if(e instanceof Error){const t={message:e.message,name:e.name,stack:e.stack};return!("code"in e)||"string"!=typeof e.code&&"number"!=typeof e.code||(t.code=e.code),t}return{message:String(e)}}(t);e.recordException(r),n.signal?.aborted&&n.signal.reason===t||e.setStatus({code:2,message:r.message})}async function L({name:e,context:t,...n},r){const o=A()?.tracer;if(!o)return r();const i=async e=>{try{return await r(e)}catch(t){throw P(e,t,n),t}finally{e.end()}};return t?o.startActiveSpan(e,n,t,i):o.startActiveSpan(e,n,i)}async function $(e,t){const n=A();if(!e||!n)return t();const r=n.trace.setSpan(n.context.active(),e);return n.context.with(r,t)}function D(e){return!(!e||"object"!=typeof e)&&("next"in e&&"function"==typeof e.next&&Symbol.asyncIterator in e&&"function"==typeof e[Symbol.asyncIterator])}var F=Symbol.asyncDispose??Symbol.for("asyncDispose"),j=class{#e=!1;#t=!1;#n;#r;constructor(e,t){this.#n=t,this.#r=function(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}(async()=>{if(this.#e)return{done:!0,value:void 0};try{const t=await e();return t.done&&(this.#e=!0),t}catch(t){throw this.#e=!0,t}finally{this.#e&&!this.#t&&(this.#t=!0,await this.#n("next"))}})}next(){return this.#r()}async return(e){return this.#e=!0,this.#t||(this.#t=!0,await this.#n("return")),{done:!0,value:e}}async throw(e){throw this.#e=!0,this.#t||(this.#t=!0,await this.#n("throw")),e}async[F](){this.#e=!0,this.#t||(this.#t=!0,await this.#n("dispose"))}[Symbol.asyncIterator](){return this}};function U({name:e,...t},n){let r;return new j(async()=>{r??=N(e);try{const e=await $(r,()=>n.next());return r?.addEvent(e.done?"completed":"yielded"),e}catch(o){throw P(r,o,t),o}},async e=>{try{"next"!==e&&await $(r,()=>n.return?.())}catch(o){throw P(r,o,t),o}finally{r?.end()}})}function W(e,t,n){const r=(t,o)=>{const i=e[o];return i?i({...t,next:(e=t)=>r(e,o+1)}):n(t)};return r(t,0)}function B(e){if(e)return JSON.parse(e)}function H(e){return JSON.stringify(e)}function q(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function V(e){return!!e&&("object"==typeof e||"function"==typeof e)}function Z(e,...t){return"function"==typeof e?e(...t):e}function G(e){return new Proxy(e,{get(e,t,n){const r=Reflect.get(e,t,n);return"then"!==t||"function"!=typeof r?r:new Proxy(r,{apply(t,n,r){if(2!==r.length||r.some(e=>{return!("function"==typeof(t=e)&&Y.test(t.toString()));var t}))return Reflect.apply(t,n,r);let o=!0;r[0].call(n,G(new Proxy(e,{get:(e,t,n)=>{if(!o||"then"!==t)return Reflect.get(e,t,n);o=!1}})))}})}})}var Y=/^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;var J,K={BAD_REQUEST:{status:400,message:"Bad Request"},UNAUTHORIZED:{status:401,message:"Unauthorized"},FORBIDDEN:{status:403,message:"Forbidden"},NOT_FOUND:{status:404,message:"Not Found"},METHOD_NOT_SUPPORTED:{status:405,message:"Method Not Supported"},NOT_ACCEPTABLE:{status:406,message:"Not Acceptable"},TIMEOUT:{status:408,message:"Request Timeout"},CONFLICT:{status:409,message:"Conflict"},PRECONDITION_FAILED:{status:412,message:"Precondition Failed"},PAYLOAD_TOO_LARGE:{status:413,message:"Payload Too Large"},UNSUPPORTED_MEDIA_TYPE:{status:415,message:"Unsupported Media Type"},UNPROCESSABLE_CONTENT:{status:422,message:"Unprocessable Content"},TOO_MANY_REQUESTS:{status:429,message:"Too Many Requests"},CLIENT_CLOSED_REQUEST:{status:499,message:"Client Closed Request"},INTERNAL_SERVER_ERROR:{status:500,message:"Internal Server Error"},NOT_IMPLEMENTED:{status:501,message:"Not Implemented"},BAD_GATEWAY:{status:502,message:"Bad Gateway"},SERVICE_UNAVAILABLE:{status:503,message:"Service Unavailable"},GATEWAY_TIMEOUT:{status:504,message:"Gateway Timeout"}};var X=class e extends Error{defined;code;status;data;static{const t=Symbol.for("__@orpc/client@1.14.10/error/ORPC_ERROR_CONSTRUCTORS__");globalThis[t]??=/* @__PURE__ */new WeakSet,(J=globalThis[t]).add(e)}constructor(e,...t){const n=function(e){return e[0]??{}}(t);if(void 0!==n.status&&!Q(n.status))throw new Error("[ORPCError] Invalid error status code.");const r=function(e,t){return t||K[e]?.message||e}(e,n.message);super(r,n),this.code=e,this.status=function(e,t){return t??K[e]?.status??500}(e,n.status),this.defined=n.defined??!1,this.data=n.data}toJSON(){return{defined:this.defined,code:this.code,status:this.status,message:this.message,data:this.data}}static[Symbol.hasInstance](e){if(J.has(this)){const t=function(e){return V(e)?Object.getPrototypeOf(e)?.constructor:null}(e);if(t&&J.has(t))return!0}return super[Symbol.hasInstance](e)}};function Q(e){return e<200||e>=400}function ee(e){if(!q(e))return!1;const t=["defined","code","status","message","data"];return!Object.keys(e).some(e=>!t.includes(e))&&("defined"in e&&"boolean"==typeof e.defined&&"code"in e&&"string"==typeof e.code&&"status"in e&&"number"==typeof e.status&&Q(e.status)&&"message"in e&&"string"==typeof e.message)}function te(e,t={}){return new X(e.code,{...t,...e})}var ne=class extends TypeError{},re=class extends TypeError{},oe=class extends Error{data;constructor(e){super(e?.message??"An error event was received",e),this.data=e?.data}};function ie(e){const t=e.replace(/\n+$/,"").split(/\n/),n={data:void 0,event:void 0,id:void 0,retry:void 0,comments:[]};for(const r of t){const e=r.indexOf(":"),t=-1===e?r:r.slice(0,e),o=-1===e?"":r.slice(e+1).replace(/^\s/,"");if(0===e)n.comments.push(o);else if("data"===t)n.data??="",n.data+=`${o}\n`;else if("event"===t)n.event=o;else if("id"===t)n.id=o;else if("retry"===t){const e=Number.parseInt(o);Number.isInteger(e)&&e>=0&&e.toString()===o&&(n.retry=e)}}return n.data=n.data?.replace(/\n$/,""),n}var se=class{constructor(e={}){this.options=e}incomplete="";feed(e){this.incomplete+=e;const t=this.incomplete.lastIndexOf("\n\n");if(-1===t)return;const n=this.incomplete.slice(0,t).split(/\n\n/);this.incomplete=this.incomplete.slice(t+2);for(const r of n){const e=ie(`${r}\n\n`);this.options.onEvent&&this.options.onEvent(e)}}end(){if(this.incomplete)throw new re("Event Iterator ended before complete")}},ae=class extends TransformStream{constructor(){let e;super({start(t){e=new se({onEvent:e=>{t.enqueue(e)}})},transform(t){e.feed(t)},flush(){e.end()}})}};function ce(e){if(e.includes("\n"))throw new ne("Event's id must not contain a newline character")}function le(e){if(!Number.isInteger(e)||e<0)throw new ne("Event's retry must be a integer and >= 0")}function de(e){if(e.includes("\n"))throw new ne("Event's comment must not contain a newline character")}function ue(e){let t="";return t+=function(e){let t="";for(const n of e??[])de(n),t+=`: ${n}\n`;return t}(e.comments),void 0!==e.event&&(!function(e){if(e.includes("\n"))throw new ne("Event's event must not contain a newline character")}(e.event),t+=`event: ${e.event}\n`),void 0!==e.retry&&(le(e.retry),t+=`retry: ${e.retry}\n`),void 0!==e.id&&(ce(e.id),t+=`id: ${e.id}\n`),t+=function(e){const t=e?.split(/\n/)??[];let n="";for(const r of t)n+=`data: ${r}\n`;return n}(e.data),t+="\n",t}var pe=Symbol("ORPC_EVENT_SOURCE_META");function he(e,t){if(void 0===t.id&&void 0===t.retry&&!t.comments?.length)return e;if(void 0!==t.id&&ce(t.id),void 0!==t.retry&&le(t.retry),void 0!==t.comments)for(const n of t.comments)de(n);return new Proxy(e,{get:(e,n,r)=>n===pe?t:Reflect.get(e,n,r)})}function fe(e){return V(e)?Reflect.get(e,pe):void 0}function me(e){const t=e.match(/filename\*=(UTF-8'')?([^;]*)/i);if(t&&"string"==typeof t[2])return function(e){try{return decodeURIComponent(e)}catch{return e}}(t[2]);const n=e.match(/filename="((?:\\"|[^"])*)"/i);return n&&"string"==typeof n[1]?n[1].replace(/\\"/g,'"'):void 0}function ge(e,t){const n=async e=>{let n=await t.error(e);if(n!==e){const t=fe(e);t&&V(n)&&(n=he(n,t))}return n};return new j(async()=>{const{done:r,value:o}=await(async()=>{try{return await e.next()}catch(t){throw await n(t)}})();let i=await t.value(o,r);if(i!==o){const e=fe(o);e&&V(i)&&(i=he(i,e))}return{done:r,value:i}},async()=>{try{await(e.return?.())}catch(t){throw await n(t)}})}function ye(e,t={}){const n=t.path??[];return G(new Proxy(async(...[t,r={}])=>await e.call(n,t,function(e){return{...e,context:e.context??{}}}(r)),{get:(r,o)=>"string"!=typeof o?Reflect.get(r,o):ye(e,{...t,path:[...n,o]})}))}function be(e,t={}){return L({name:"parse_standard_body",signal:t.signal},async()=>{const n=e.headers.get("content-disposition");if("string"==typeof n){const t=me(n)??"blob",r=await e.blob();return new File([r],t,{type:r.type})}const r=e.headers.get("content-type");if(!r||r.startsWith("application/json"))return B(await e.text());if(r.startsWith("multipart/form-data"))return await e.formData();if(r.startsWith("application/x-www-form-urlencoded")){const t=await e.text();return new URLSearchParams(t)}if(r.startsWith("text/event-stream"))return function(e,t={}){const n=(e?.pipeThrough(new TextDecoderStream).pipeThrough(new ae))?.getReader();let r,o=!1;return new j(async()=>{r??=N("consume_event_iterator_stream");try{for(;;){if(void 0===n)return{done:!0,value:void 0};const{done:e,value:t}=await $(r,()=>n.read());if(e){if(o)throw new O("Stream was cancelled");return{done:!0,value:void 0}}switch(t.event){case"message":{let e=B(t.data);return V(e)&&(e=he(e,t)),r?.addEvent("message"),{done:!1,value:e}}case"error":{let e=new oe({data:B(t.data)});throw e=he(e,t),r?.addEvent("error"),e}case"done":{let e=B(t.data);return V(e)&&(e=he(e,t)),r?.addEvent("done"),{done:!0,value:e}}default:r?.addEvent("maybe_keepalive")}}}catch(e){throw e instanceof oe||P(r,e,t),e}},async e=>{try{"next"!==e&&(o=!0,r?.addEvent("cancelled")),await $(r,()=>n?.cancel())}catch(i){throw P(r,i,t),i}finally{r?.end()}})}(e.body,t);if(r.startsWith("text/plain"))return await e.text();const o=await e.blob();return new File([o],"blob",{type:o.type})})}function we(e,t,n={}){if(e instanceof ReadableStream)return e;const r=t.get("content-disposition");return t.delete("content-type"),t.delete("content-disposition"),void 0!==e?e instanceof Blob?(t.set("content-type",e.type),t.set("content-length",e.size.toString()),t.set("content-disposition",r??function(e,t="inline"){return`${t}; filename="${e.replace(/[^\x20-\x7E]/g,"_").replace(/"/g,'\\"')}"; filename*=utf-8''${encodeURIComponent(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}(e instanceof File?e.name:"blob")),e):e instanceof FormData||e instanceof URLSearchParams?e:D(e)?(t.set("content-type","text/event-stream"),function(e,t={}){const n=t.eventIteratorKeepAliveEnabled??!0,r=t.eventIteratorKeepAliveInterval??5e3,o=t.eventIteratorKeepAliveComment??"",i=t.eventIteratorInitialCommentEnabled??!0,s=t.eventIteratorInitialComment??"";let a,c,l=!1;return new ReadableStream({start(e){c=N("stream_event_iterator"),i&&e.enqueue(ue({comments:[s]}))},async pull(t){try{n&&(a=setInterval(()=>{t.enqueue(ue({comments:[o]})),c?.addEvent("keepalive")},r));const i=await $(c,()=>e.next());if(clearInterval(a),l)return;const s=fe(i.value);if(!i.done||void 0!==i.value||void 0!==s){const e=i.done?"done":"message";t.enqueue(ue({...s,event:e,data:H(i.value)})),c?.addEvent(e)}i.done&&(t.close(),c?.end())}catch(i){if(clearInterval(a),l)return;i instanceof oe?(t.enqueue(ue({...fe(i),event:"error",data:H(i.data)})),c?.addEvent("error"),t.close()):(P(c,i),t.error(i)),c?.end()}},async cancel(){try{l=!0,clearInterval(a),c?.addEvent("cancelled"),await $(c,()=>e.return?.())}catch(t){throw P(c,t),t}finally{c?.end()}}}).pipeThrough(new TextEncoderStream)}(e,n)):(t.set("content-type","application/json"),H(e)):void 0}function ve(e,t={}){return e.forEach((e,n)=>{Array.isArray(t[n])?t[n].push(e):void 0!==t[n]?t[n]=[t[n],e]:t[n]=e}),t}function xe(e,t={}){const n=function(e,t=new Headers){for(const[n,r]of Object.entries(e))if(Array.isArray(r))for(const e of r)t.append(n,e);else void 0!==r&&t.append(n,r);return t}(e.headers),r=we(e.body,n,t);return new Request(e.url,{signal:e.signal,method:e.method,headers:n,body:r})}var ke=class{plugins;constructor(e=[]){this.plugins=[...e].sort((e,t)=>(e.order??0)-(t.order??0))}init(e){for(const t of this.plugins)t.init?.(e)}},Se=class{constructor(e,t,n={}){this.codec=e,this.sender=t,new ke(n.plugins).init(n),this.interceptors=M(n.interceptors),this.clientInterceptors=M(n.clientInterceptors)}interceptors;clientInterceptors;call(e,t,n){return L({name:`${z}.${e.join("/")}`,signal:n.signal},r=>(r?.setAttribute("rpc.system",z),r?.setAttribute("rpc.method",e.join(".")),D(t)&&(t=U({name:"consume_event_iterator_input",signal:n.signal},t)),W(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{const o=A();let i;const s=o?.trace.getActiveSpan()??r;s&&o&&(i=o?.trace.setSpan(o.context.active(),s));const a=await L({name:"encode_request",context:i},()=>this.codec.encode(e,t,n)),c=await W(this.clientInterceptors,{...n,input:t,path:e,request:a},({input:e,path:t,request:n,...r})=>L({name:"send_request",signal:r.signal,context:i},()=>this.sender.call(n,r,t,e))),l=await L({name:"decode_response",context:i},()=>this.codec.decode(c,n,e,t));return D(l)?U({name:"consume_event_iterator_output",signal:n.signal},l):l})))}},_e=0,Ce=1,Ie=2,Ee=3,Te=4,Me=5,ze=6,Oe=7,Re=class{customSerializers;constructor(e={}){if(this.customSerializers=e.customJsonSerializers??[],this.customSerializers.length!==new Set(this.customSerializers.map(e=>e.type)).size)throw new Error("Custom serializer type must be unique.")}serialize(e,t=[],n=[],r=[],o=[]){for(const i of this.customSerializers)if(i.condition(e)){const s=this.serialize(i.serialize(e),t,n,r,o);return n.push([i.type,...t]),s}if(e instanceof Blob)return r.push(t),o.push(e),[e,n,r,o];if("bigint"==typeof e)return n.push([_e,...t]),[e.toString(),n,r,o];if(e instanceof Date)return n.push([Ce,...t]),Number.isNaN(e.getTime())?[null,n,r,o]:[e.toISOString(),n,r,o];if(Number.isNaN(e))return n.push([Ie,...t]),[null,n,r,o];if(e instanceof URL)return n.push([Te,...t]),[e.toString(),n,r,o];if(e instanceof RegExp)return n.push([Me,...t]),[e.toString(),n,r,o];if(e instanceof Set){const i=this.serialize(Array.from(e),t,n,r,o);return n.push([ze,...t]),i}if(e instanceof Map){const i=this.serialize(Array.from(e.entries()),t,n,r,o);return n.push([Oe,...t]),i}if(Array.isArray(e))return[e.map((e,i)=>void 0===e?(n.push([Ee,...t,i]),null):this.serialize(e,[...t,i],n,r,o)[0]),n,r,o];if(q(e)){const i={};for(const s in e)"toJSON"===s&&"function"==typeof e[s]||(i[s]=this.serialize(e[s],[...t,s],n,r,o)[0]);return[i,n,r,o]}return[e,n,r,o]}deserialize(e,t,n,r){const o={data:e};n&&r&&n.forEach((e,t)=>{let n=o,i="data";e.forEach(e=>{if(n=n[i],i=e,!Object.hasOwn(n,i))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${i}`)}),n[i]=r(t)});for(const i of t){const e=i[0];let t=o,n="data";for(let r=1;r<i.length;r++)if(t=t[n],n=i[r],!Object.hasOwn(t,n))throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${n}`);for(const r of this.customSerializers)if(r.type===e){t[n]=r.deserialize(t[n]);break}switch(e){case _e:t[n]=BigInt(t[n]);break;case Ce:t[n]=new Date(t[n]??"Invalid Date");break;case Ie:t[n]=NaN;break;case Ee:t[n]=void 0;break;case Te:t[n]=new URL(t[n]);break;case Me:{const[,e,r]=t[n].match(/^\/(.*)\/([a-z]*)$/);t[n]=new RegExp(e,r);break}case ze:t[n]=new Set(t[n]);break;case Oe:t[n]=new Map(t[n])}}return o.data}};var Ae,Ne=class{constructor(e,t){this.serializer=e,this.baseUrl=t.url,this.maxUrlLength=t.maxUrlLength??2083,this.fallbackMethod=t.fallbackMethod??"POST",this.expectedMethod=t.method??this.fallbackMethod,this.headers=t.headers??{}}baseUrl;maxUrlLength;fallbackMethod;expectedMethod;headers;async encode(e,t,n){let r=function(e){return"function"==typeof e.forEach?ve(e):e}(await Z(this.headers,n,e,t));void 0!==n.lastEventId&&(r=function(e,t){const n={...e};for(const r in t)Array.isArray(t[r])?n[r]=[...M(n[r]),...t[r]]:void 0!==t[r]&&(Array.isArray(n[r])?n[r]=[...n[r],t[r]]:void 0!==n[r]?n[r]=[n[r],t[r]]:n[r]=t[r]);return n}(r,{"last-event-id":n.lastEventId}));const o=await Z(this.expectedMethod,n,e,t),i=await Z(this.baseUrl,n,e,t),s=new URL(i);s.pathname=`${s.pathname.replace(/\/$/,"")}${function(e){return`/${e.map(encodeURIComponent).join("/")}`}(e)}`;const a=this.serializer.serialize(t);if(!("GET"!==o||a instanceof FormData||D(a))){const i=await Z(this.maxUrlLength,n,e,t),c=new URL(s);if(c.searchParams.append("data",H(a)),c.toString().length<=i)return{body:void 0,method:o,headers:r,url:c,signal:n.signal}}return{url:s,method:"GET"===o?this.fallbackMethod:o,headers:r,body:a,signal:n.signal}}async decode(e){const t=!Q(e.status),n=await(async()=>{let t=!1;try{const n=await e.body();return t=!0,this.serializer.deserialize(n)}catch(n){if(!t)throw new Error("Cannot parse response body, please check the response body and content-type.",{cause:n});throw new Error("Invalid RPC response format.",{cause:n})}})();if(!t){if(ee(n))throw te(n);throw new X((r=e.status,Object.entries(K).find(([,e])=>e.status===r)?.[0]??"MALFORMED_ORPC_ERROR_RESPONSE"),{status:e.status,data:{...e,body:n}})}var r;return n}},Pe=class{constructor(e){this.jsonSerializer=e}serialize(e){return D(e)?ge(e,{value:async e=>this.#o(e,!1),error:async e=>{return new oe({data:this.#o((t=e,t instanceof X?t:new X("INTERNAL_SERVER_ERROR",{message:"Internal server error",cause:t})).toJSON(),!1),cause:e});var t}}):this.#o(e,!0)}#o(e,t){const[n,r,o,i]=this.jsonSerializer.serialize(e),s=0===r.length?void 0:r;if(!t||0===i.length)return{json:n,meta:s};const a=new FormData;return a.set("data",H({json:n,meta:s,maps:o})),i.forEach((e,t)=>{a.set(t.toString(),e)}),a}deserialize(e){return D(e)?ge(e,{value:async e=>this.#i(e),error:async e=>{if(!(e instanceof oe))return e;const t=this.#i(e.data);return ee(t)?te(t,{cause:e}):new oe({data:t,cause:e})}}):this.#i(e)}#i(e){if(void 0===e)return;if(!(e instanceof FormData))return this.jsonSerializer.deserialize(e.json,e.meta??[]);const t=JSON.parse(e.get("data"));return this.jsonSerializer.deserialize(t.json,t.meta??[],t.maps,t=>e.get(t.toString()))}},Le=class extends Se{constructor(e,t){const n=new Re(t),r=new Pe(n);super(new Ne(r,t),e,t)}},$e=class extends ke{initRuntimeAdapter(e){for(const t of this.plugins)t.initRuntimeAdapter?.(e)}},De=class{fetch;toFetchRequestOptions;adapterInterceptors;constructor(e){new $e(e.plugins).initRuntimeAdapter(e),this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.toFetchRequestOptions=e,this.adapterInterceptors=M(e.adapterInterceptors)}async call(e,t,n,r){const o=xe(e,this.toFetchRequestOptions);return function(e,t={}){return{body:R(()=>be(e,t)),status:e.status,get headers(){const t=ve(e.headers);return Object.defineProperty(this,"headers",{value:t,writable:!0}),t},set headers(e){Object.defineProperty(this,"headers",{value:e,writable:!0})}}}(await W(this.adapterInterceptors,{...t,request:o,path:n,input:r,init:{redirect:"manual"}},({request:e,path:t,input:n,init:r,...o})=>this.fetch(e,r,o,t,n)),{signal:o.signal})}},Fe=class extends Le{constructor(e){super(new De(e),e)}};function je(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:s,traits:/* @__PURE__ */new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const o=s.prototype,i=Object.keys(o);for(let e=0;e<i.length;e++){const t=i[e];t in n||(n[t]=o[t].bind(n))}}const o=n?.Parent??Object;class i extends o{}function s(e){var t;const o=n?.Parent?new i:this;r(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const n of o._zod.deferred)n();return o}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(s,"init",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}var Ue=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},We=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Ae=globalThis).__zod_globalConfig??(Ae.__zod_globalConfig={});var Be=globalThis.__zod_globalConfig;function He(e){return e&&Object.assign(Be,e),Be}function qe(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 Ve(e,t){return"bigint"==typeof t?t.toString():t}function Ze(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ge(e){return null==e}function Ye(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var Je=/* @__PURE__*/Symbol("evaluating");function Ke(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Je)return void 0===r&&(r=Je,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Xe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Qe(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function et(e){return JSON.stringify(e)}var tt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function nt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var rt=/* @__PURE__*/Ze(()=>{if(Be.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function ot(e){if(!1===nt(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!==nt(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function it(e){return ot(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var st=/* @__PURE__*/new Set(["string","number","symbol"]);function at(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ct(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function lt(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}var dt={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 ut(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 pt(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function ht(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ft(e){return"string"==typeof e?e:e?.message}function mt(e,t,n){const r=e.message?e.message:ft(e.inst?._zod.def?.error?.(e))??ft(t?.error?.(e))??ft(n.customError?.(e))??ft(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=s),a}function gt(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function yt(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}var bt=(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,Ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},wt=je("$ZodError",bt),vt=je("$ZodError",bt,{Parent:Error});var xt=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new Ue;if(s.issues.length){const t=new(o?.Err??e)(s.issues.map(e=>mt(e,i,He())));throw tt(t,o?.callee),t}return s.value},kt=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(o?.Err??e)(s.issues.map(e=>mt(e,i,He())));throw tt(t,o?.callee),t}return s.value},St=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new Ue;return i.issues.length?{success:!1,error:new(e??wt)(i.issues.map(e=>mt(e,o,He())))}:{success:!0,data:i.value}},_t=/* @__PURE__*/St(vt),Ct=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(e=>mt(e,o,He())))}:{success:!0,data:i.value}},It=/* @__PURE__*/Ct(vt),Et=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return xt(e)(t,n,o)},Tt=e=>(t,n,r)=>xt(e)(t,n,r),Mt=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return kt(e)(t,n,o)},zt=e=>async(t,n,r)=>kt(e)(t,n,r),Ot=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return St(e)(t,n,o)},Rt=e=>(t,n,r)=>St(e)(t,n,r),At=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ct(e)(t,n,o)},Nt=e=>async(t,n,r)=>Ct(e)(t,n,r),Pt=/^[cC][0-9a-z]{6,}$/,Lt=/^[0-9a-z]+$/,$t=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Dt=/^[0-9a-vA-V]{20}$/,Ft=/^[A-Za-z0-9]{27}$/,jt=/^[a-zA-Z0-9_-]{21}$/,Ut=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Wt=/^([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})$/,Bt=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)$/,Ht=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var qt=/^(?:(?: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])$/,Vt=/^(([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}|:))$/,Zt=/^((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])$/,Gt=/^(([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])$/,Yt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Jt=/^[A-Za-z0-9_-]*$/,Kt=/^https?$/,Xt=/^\+[1-9]\d{6,14}$/,Qt="(?:(?:\\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])))",en=/*@__PURE__*/new RegExp(`^${Qt}$`);function tn(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+)?)?`}var nn=/^-?\d+$/,rn=/^-?\d+(?:\.\d+)?$/,on=/^(?:true|false)$/i,sn=/^[^A-Z]*$/,an=/^[^a-z]*$/,cn=/*@__PURE__*/je("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ln={number:"number",bigint:"bigint",object:"date"},dn=/*@__PURE__*/je("$ZodCheckLessThan",(e,t)=>{cn.init(e,t);const n=ln[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})}}),un=/*@__PURE__*/je("$ZodCheckGreaterThan",(e,t)=>{cn.init(e,t);const n=ln[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})}}),pn=/*@__PURE__*/je("$ZodCheckMultipleOf",(e,t)=>{cn.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/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}(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})}}),hn=/*@__PURE__*/je("$ZodCheckNumberFormat",(e,t)=>{cn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=dt[t.format];e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,r.minimum=o,r.maximum=i,n&&(r.pattern=nn)}),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a))return void s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});if(!Number.isSafeInteger(a))return void(a>0?s.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}):s.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&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),fn=/*@__PURE__*/je("$ZodCheckMaxLength",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ge(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=gt(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),mn=/*@__PURE__*/je("$ZodCheckMinLength",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ge(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=gt(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gn=/*@__PURE__*/je("$ZodCheckLengthEquals",(e,t)=>{var n;cn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!Ge(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 i=gt(r),s=o>t.length;n.issues.push({origin:i,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),yn=/*@__PURE__*/je("$ZodCheckStringFormat",(e,t)=>{var n,r;cn.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=()=>{})}),bn=/*@__PURE__*/je("$ZodCheckRegex",(e,t)=>{yn.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})}}),wn=/*@__PURE__*/je("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=sn),yn.init(e,t)}),vn=/*@__PURE__*/je("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=an),yn.init(e,t)}),xn=/*@__PURE__*/je("$ZodCheckIncludes",(e,t)=>{cn.init(e,t);const n=at(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})}}),kn=/*@__PURE__*/je("$ZodCheckStartsWith",(e,t)=>{cn.init(e,t);const n=new RegExp(`^${at(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})}}),Sn=/*@__PURE__*/je("$ZodCheckEndsWith",(e,t)=>{cn.init(e,t);const n=new RegExp(`.*${at(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})}}),_n=/*@__PURE__*/je("$ZodCheckOverwrite",(e,t)=>{cn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Cn=class{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"))}},In={major:4,minor:4,patch:3},En=/*@__PURE__*/je("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=In;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=ut(e);for(const i of t){if(i._zod.def.when){if(pt(e))continue;if(!i._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,s=i._zod.check(e);if(s instanceof Promise&&!1===n?.async)throw new Ue;if(r||s instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await s,e.issues.length!==t&&(o||(o=ut(e,t)))});else{if(e.issues.length===t)continue;o||(o=ut(e,t))}}return r?r.then(()=>e):e},n=(n,o,i)=>{if(ut(n))return n.aborted=!0,n;const s=t(o,r,i);if(s instanceof Promise){if(!1===i.async)throw new Ue;return s.then(t=>e._zod.parse(t,i))}return e._zod.parse(s,i)};e._zod.run=(o,i)=>{if(i.skipChecks)return e._zod.parse(o,i);if("backward"===i.direction){const t=e._zod.parse({value:o.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,o,i)):n(t,o,i)}const s=e._zod.parse(o,i);if(s instanceof Promise){if(!1===i.async)throw new Ue;return s.then(e=>t(e,r,i))}return t(s,r,i)}}Ke(e,"~standard",()=>({validate:t=>{try{const n=_t(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return It(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Tn=/*@__PURE__*/je("$ZodString",(e,t)=>{var n;En.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(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Mn=/*@__PURE__*/je("$ZodStringFormat",(e,t)=>{yn.init(e,t),Tn.init(e,t)}),zn=/*@__PURE__*/je("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Wt),Mn.init(e,t)}),On=/*@__PURE__*/je("$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=Bt(e))}else t.pattern??(t.pattern=Bt());Mn.init(e,t)}),Rn=/*@__PURE__*/je("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ht),Mn.init(e,t)}),An=/*@__PURE__*/je("$ZodURL",(e,t)=>{Mn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Kt.source&&!/^https?:\/\//i.test(r))return void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});const 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})}}}),Nn=/*@__PURE__*/je("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Mn.init(e,t)}),Pn=/*@__PURE__*/je("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=jt),Mn.init(e,t)}),Ln=/*@__PURE__*/je("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Pt),Mn.init(e,t)}),$n=/*@__PURE__*/je("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Lt),Mn.init(e,t)}),Dn=/*@__PURE__*/je("$ZodULID",(e,t)=>{t.pattern??(t.pattern=$t),Mn.init(e,t)}),Fn=/*@__PURE__*/je("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Dt),Mn.init(e,t)}),jn=/*@__PURE__*/je("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ft),Mn.init(e,t)}),Un=/*@__PURE__*/je("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=tn({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(`^${Qt}T(?:${r})$`)}(t)),Mn.init(e,t)}),Wn=/*@__PURE__*/je("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=en),Mn.init(e,t)}),Bn=/*@__PURE__*/je("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${tn(t)}$`)),Mn.init(e,t)}),Hn=/*@__PURE__*/je("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ut),Mn.init(e,t)}),qn=/*@__PURE__*/je("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=qt),Mn.init(e,t),e._zod.bag.format="ipv4"}),Vn=/*@__PURE__*/je("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Vt),Mn.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})}}}),Zn=/*@__PURE__*/je("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Zt),Mn.init(e,t)}),Gn=/*@__PURE__*/je("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Gt),Mn.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 Yn(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Jn=/*@__PURE__*/je("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Yt),Mn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Yn(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});var Kn=/*@__PURE__*/je("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Jt),Mn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!Jt.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Yn(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})}}),Xn=/*@__PURE__*/je("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Xt),Mn.init(e,t)});var Qn=/*@__PURE__*/je("$ZodJWT",(e,t)=>{Mn.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})}}),er=/*@__PURE__*/je("$ZodNumber",(e,t)=>{En.init(e,t),e._zod.pattern=e._zod.bag.pattern??rn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(s){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i="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,...i?{received:i}:{}}),n}}),tr=/*@__PURE__*/je("$ZodNumberFormat",(e,t)=>{hn.init(e,t),er.init(e,t)}),nr=/*@__PURE__*/je("$ZodBoolean",(e,t)=>{En.init(e,t),e._zod.pattern=on,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(i){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),rr=/*@__PURE__*/je("$ZodUnknown",(e,t)=>{En.init(e,t),e._zod.parse=e=>e}),or=/*@__PURE__*/je("$ZodNever",(e,t)=>{En.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),ir=/*@__PURE__*/je("$ZodDate",(e,t)=>{En.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch(s){}const o=n.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),n}});function sr(e,t,n){e.issues.length&&t.issues.push(...ht(n,e.issues)),t.value[n]=e.value}var ar=/*@__PURE__*/je("$ZodArray",(e,t)=>{En.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 i=[];for(let e=0;e<o.length;e++){const s=o[e],a=t.element._zod.run({value:s,issues:[]},r);a instanceof Promise?i.push(a.then(t=>sr(t,n,e))):sr(a,n,e)}return i.length?Promise.all(i).then(()=>n):n}});function cr(e,t,n,r,o,i){const s=n in r;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...ht(n,e.issues))}s||o?void 0===e.value?s&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}function lr(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 dr(e,t,n,r,o,i){const s=[],a=o.keySet,c=o.catchall._zod,l=c.def.type,d="optional"===c.optin,u="optional"===c.optout;for(const p in t){if("__proto__"===p)continue;if(a.has(p))continue;if("never"===l){s.push(p);continue}const o=c.run({value:t[p],issues:[]},r);o instanceof Promise?e.push(o.then(e=>cr(e,n,p,t,d,u))):cr(o,n,p,t,d,u)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}var ur=/*@__PURE__*/je("$ZodObject",(e,t)=>{if(En.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const n=Ze(()=>lr(t));Ke(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 r=nt,o=t.catchall;let i;e._zod.parse=(t,s)=>{i??(i=n.value);const a=t.value;if(!r(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const c=[],l=i.shape;for(const e of i.keys){const n=l[e],r="optional"===n._zod.optin,o="optional"===n._zod.optout,i=n._zod.run({value:a[e],issues:[]},s);i instanceof Promise?c.push(i.then(n=>cr(n,t,e,a,r,o))):cr(i,t,e,a,r,o)}return o?dr(c,a,t,s,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),pr=/*@__PURE__*/je("$ZodObjectJIT",(e,t)=>{ur.init(e,t);const n=e._zod.parse,r=Ze(()=>lr(t));let o;const i=nt,s=!Be.jitless,a=s&&rt.value,c=t.catchall;let l;e._zod.parse=(d,u)=>{l??(l=r.value);const p=d.value;return i(p)?s&&a&&!1===u?.async&&!0!==u.jitless?(o||(o=(e=>{const t=new Cn(["shape","payload","ctx"]),n=r.value,o=e=>{const t=et(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let s=0;for(const r of n.keys)i[r]="key_"+s++;t.write("const newResult = {};");for(const r of n.keys){const n=i[r],s=et(r),a=e[r],c="optional"===a?._zod?.optin,l="optional"===a?._zod?.optout;t.write(`const ${n} = ${o(r)};`),c&&l?t.write(`\n if (${n}.issues.length) {\n if (${s} in input) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):c?t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n \n if (${n}.value === undefined) {\n if (${s} in input) {\n newResult[${s}] = undefined;\n }\n } else {\n newResult[${s}] = ${n}.value;\n }\n \n `):t.write(`\n const ${n}_present = ${s} in input;\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${s}, ...iss.path] : [${s}]\n })));\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${s}]\n });\n }\n\n if (${n}_present) {\n if (${n}.value === undefined) {\n newResult[${s}] = undefined;\n } else {\n newResult[${s}] = ${n}.value;\n }\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,u),c?dr([],p,d,u,l,e):d):n(d,u):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}});function hr(e,t,n,r){for(const i of e)if(0===i.issues.length)return t.value=i.value,t;const o=e.filter(e=>!ut(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=>mt(e,r,He())))}),t)}var fr=/*@__PURE__*/je("$ZodUnion",(e,t)=>{En.init(e,t),Ke(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),Ke(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),Ke(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),Ke(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=>Ye(e.source)).join("|")})$`)}});const n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},o);if(t instanceof Promise)s.push(t),i=!0;else{if(0===t.issues.length)return t;s.push(t)}}return i?Promise.all(s).then(t=>hr(t,r,e,o)):hr(s,r,e,o)}}),mr=/*@__PURE__*/je("$ZodIntersection",(e,t)=>{En.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,o=t.left._zod.run({value:r,issues:[]},n),i=t.right._zod.run({value:r,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([t,n])=>yr(e,t,n)):yr(e,o,i)}});function gr(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(ot(e)&&ot(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),o={...e,...t};for(const i of r){const n=gr(e[i],t[i]);if(!n.valid)return{valid:!1,mergeErrorPath:[i,...n.mergeErrorPath]};o[i]=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=gr(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 yr(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 i=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(i.length&&o&&e.issues.push({...o,keys:i}),ut(e))return e;const s=gr(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var br=/*@__PURE__*/je("$ZodRecord",(e,t)=>{En.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!ot(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],s=t.keyType._zod.values;if(s){n.value={};const a=/* @__PURE__ */new Set;for(const l of s)if("string"==typeof l||"number"==typeof l||"symbol"==typeof l){a.add("number"==typeof l?l.toString():l);const s=t.keyType._zod.run({value:l,issues:[]},r);if(s instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(s.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>mt(e,r,He())),input:l,path:[l],inst:e});continue}const c=s.value,d=t.valueType._zod.run({value:o[l],issues:[]},r);d instanceof Promise?i.push(d.then(e=>{e.issues.length&&n.issues.push(...ht(l,e.issues)),n.value[c]=e.value})):(d.issues.length&&n.issues.push(...ht(l,d.issues)),n.value[c]=d.value)}let c;for(const e in o)a.has(e)||(c=c??[],c.push(e));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const s of Reflect.ownKeys(o)){if("__proto__"===s)continue;if(!Object.prototype.propertyIsEnumerable.call(o,s))continue;let a=t.keyType._zod.run({value:s,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof s&&rn.test(s)&&a.issues.length){const e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(a=e)}if(a.issues.length){"loose"===t.mode?n.value[s]=o[s]:n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(e=>mt(e,r,He())),input:s,path:[s],inst:e});continue}const c=t.valueType._zod.run({value:o[s],issues:[]},r);c instanceof Promise?i.push(c.then(e=>{e.issues.length&&n.issues.push(...ht(s,e.issues)),n.value[a.value]=e.value})):(c.issues.length&&n.issues.push(...ht(s,c.issues)),n.value[a.value]=c.value)}}return i.length?Promise.all(i).then(()=>n):n}}),wr=/*@__PURE__*/je("$ZodEnum",(e,t)=>{En.init(e,t);const n=qe(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>st.has(typeof e)).map(e=>"string"==typeof e?at(e):e.toString()).join("|")})$`),e._zod.parse=(t,o)=>{const i=t.value;return r.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}}),vr=/*@__PURE__*/je("$ZodLiteral",(e,t)=>{if(En.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?at(e):e?at(e.toString()):String(e)).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),xr=/*@__PURE__*/je("$ZodTransform",(e,t)=>{En.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new We(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.fallback=!0,n));if(o instanceof Promise)throw new Ue;return n.value=o,n.fallback=!0,n}});function kr(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Sr=/*@__PURE__*/je("$ZodOptional",(e,t)=>{En.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ke(e._zod,"values",()=>t.innerType._zod.values?/* @__PURE__ */new Set([...t.innerType._zod.values,void 0]):void 0),Ke(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ye(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=e.value,o=t.innerType._zod.run(e,n);return o instanceof Promise?o.then(e=>kr(e,r)):kr(o,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),_r=/*@__PURE__*/je("$ZodExactOptional",(e,t)=>{Sr.init(e,t),Ke(e._zod,"values",()=>t.innerType._zod.values),Ke(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Cr=/*@__PURE__*/je("$ZodNullable",(e,t)=>{En.init(e,t),Ke(e._zod,"optin",()=>t.innerType._zod.optin),Ke(e._zod,"optout",()=>t.innerType._zod.optout),Ke(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ye(e.source)}|null)$`):void 0}),Ke(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)}),Ir=/*@__PURE__*/je("$ZodDefault",(e,t)=>{En.init(e,t),e._zod.optin="optional",Ke(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=>Er(e,t)):Er(r,t)}});function Er(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var Tr=/*@__PURE__*/je("$ZodPrefault",(e,t)=>{En.init(e,t),e._zod.optin="optional",Ke(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))}),Mr=/*@__PURE__*/je("$ZodNonOptional",(e,t)=>{En.init(e,t),Ke(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=>zr(t,e)):zr(o,e)}});function zr(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var Or=/*@__PURE__*/je("$ZodCatch",(e,t)=>{En.init(e,t),e._zod.optin="optional",Ke(e._zod,"optout",()=>t.innerType._zod.optout),Ke(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=>mt(e,n,He()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>mt(e,n,He()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Rr=/*@__PURE__*/je("$ZodPipe",(e,t)=>{En.init(e,t),Ke(e._zod,"values",()=>t.in._zod.values),Ke(e._zod,"optin",()=>t.in._zod.optin),Ke(e._zod,"optout",()=>t.out._zod.optout),Ke(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=>Ar(e,t.in,n)):Ar(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Ar(e,t.out,n)):Ar(r,t.out,n)}});function Ar(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Nr=/*@__PURE__*/je("$ZodReadonly",(e,t)=>{En.init(e,t),Ke(e._zod,"propValues",()=>t.innerType._zod.propValues),Ke(e._zod,"values",()=>t.innerType._zod.values),Ke(e._zod,"optin",()=>t.innerType?._zod?.optin),Ke(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(Pr):Pr(r)}});function Pr(e){return e.value=Object.freeze(e.value),e}var Lr,$r=/*@__PURE__*/je("$ZodCustom",(e,t)=>{cn.init(e,t),En.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=>Dr(t,n,r,e));Dr(o,n,r,e)}});function Dr(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(yt(e))}}var Fr=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)}};(Lr=globalThis).__zod_globalRegistry??(Lr.__zod_globalRegistry=new Fr);var jr=globalThis.__zod_globalRegistry;function Ur(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...lt(t)})}function Wr(e,t){return new dn({check:"less_than",...lt(t),value:e,inclusive:!1})}function Br(e,t){return new dn({check:"less_than",...lt(t),value:e,inclusive:!0})}function Hr(e,t){return new un({check:"greater_than",...lt(t),value:e,inclusive:!1})}function qr(e,t){return new un({check:"greater_than",...lt(t),value:e,inclusive:!0})}function Vr(e,t){return new pn({check:"multiple_of",...lt(t),value:e})}function Zr(e,t){return new fn({check:"max_length",...lt(t),maximum:e})}function Gr(e,t){return new mn({check:"min_length",...lt(t),minimum:e})}function Yr(e,t){return new gn({check:"length_equals",...lt(t),length:e})}function Jr(e){return new _n({check:"overwrite",tx:e})}function Kr(e,t){const n=new cn({check:"custom",...lt(t)});return n._zod.check=e,n}function Xr(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??jr,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 Qr(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,r);else{const n=s.schema,i=t.processors[o.type];if(!i)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);i(e,t,n,r)}const i=e._zod.parent;i&&(s.ref||(s.ref=i),Qr(i,t,r),t.seen.get(i).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),"input"===t.io&&no(e)&&(delete s.schema.examples,delete s.schema.default),"input"===t.io&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function eo(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 i of e.seen.entries()){const t=e.metadataRegistry.get(i[0])?.id;if(t){const e=r.get(t);if(e&&e!==i[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,i[0])}}const o=t=>{if(t[1].schema.$ref)return;const r=t[1],{ref:o,defId:i}=(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 i=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=i,{defId:i,ref:`${o("__shared")}#/${r}/${i}`}}if(t[1]===n)return{ref:"#"};const o=`#/${r}/`,i=t[1].schema.id??"__schema"+e.counter++;return{defId:i,ref:o+i}})(t);r.def={...r.schema},i&&(r.defId=i);const s=r.schema;for(const e in s)delete s[e];s.$ref=o};if("throw"===e.cycles)for(const i of e.seen.entries()){const e=i[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 i of e.seen.entries()){const n=i[1];if(t!==i[0]){if(e.external){const n=e.external.registry.get(i[0])?.id;if(t!==i[0]&&n){o(i);continue}}(e.metadataRegistry.get(i[0])?.id||n.cycle||n.count>1&&"ref"===e.reused)&&o(i)}else o(i)}}function to(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,i={...o},s=n.ref;if(n.ref=null,s){r(s);const n=e.seen.get(s),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,i),t._zod.parent===s)for(const e in o)"$ref"!==e&&"allOf"!==e&&(e in i||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!==s){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 c of[...e.seen.entries()].reverse())r(c[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 i=e.metadataRegistry.get(t)?.id;void 0!==i&&o.id===i&&delete o.id;const s=e.external?.defs??{};for(const c of e.seen.entries()){const e=c[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,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:ro(t,"input",e.processors),output:ro(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function no(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 no(r.element,n);if("set"===r.type)return no(r.valueType,n);if("lazy"===r.type)return no(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 no(r.innerType,n);if("intersection"===r.type)return no(r.left,n)||no(r.right,n);if("record"===r.type||"map"===r.type)return no(r.keyType,n)||no(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(no(r.in,n)||no(r.out,n));if("object"===r.type){for(const e in r.shape)if(no(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(no(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(no(e,n))return!0;return!(!r.rest||!no(r.rest,n))}return!1}var ro=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Xr({...o??{},target:i,io:t,processors:n});return Qr(e,s),eo(s,e),to(s,e)},oo={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},io=(e,t,n,r)=>{const o=e._zod.def;Qr(o.innerType,t,r);t.seen.get(e).ref=o.innerType},so=/*@__PURE__*/je("ZodISODateTime",(e,t)=>{Un.init(e,t),Po.init(e,t)});function ao(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...lt(t)})}(so,e)}var co=/*@__PURE__*/je("ZodISODate",(e,t)=>{Wn.init(e,t),Po.init(e,t)});function lo(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...lt(t)})}(co,e)}var uo=/*@__PURE__*/je("ZodISOTime",(e,t)=>{Bn.init(e,t),Po.init(e,t)});function po(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...lt(t)})}(uo,e)}var ho=/*@__PURE__*/je("ZodISODuration",(e,t)=>{Hn.init(e,t),Po.init(e,t)});function fo(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...lt(t)})}(ho,e)}var mo=(e,t)=>{wt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=(e,o=[])=>{for(const i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map(e=>r({issues:e},[...o,...i.path]));else if("invalid_key"===i.code)r({issues:i.issues},[...o,...i.path]);else if("invalid_element"===i.code)r({issues:i.issues},[...o,...i.path]);else{const e=[...o,...i.path];if(0===e.length)n._errors.push(t(i));else{let r=n,o=0;for(;o<e.length;){const n=e[o];o!==e.length-1?r[n]=r[n]||{_errors:[]}:(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(i))),r=r[n],o++}}}};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,Ve,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ve,2)}},isEmpty:{get:()=>0===e.issues.length}})},go=/*@__PURE__*/je("ZodError",mo,{Parent:Error}),yo=/* @__PURE__ */xt(go),bo=/* @__PURE__ */kt(go),wo=/* @__PURE__ */St(go),vo=/* @__PURE__ */Ct(go),xo=/* @__PURE__ */Et(go),ko=/* @__PURE__ */Tt(go),So=/* @__PURE__ */Mt(go),_o=/* @__PURE__ */zt(go),Co=/* @__PURE__ */Ot(go),Io=/* @__PURE__ */Rt(go),Eo=/* @__PURE__ */At(go),To=/* @__PURE__ */Nt(go),Mo=/* @__PURE__ */new WeakMap;function zo(e,t,n){const r=Object.getPrototypeOf(e);let o=Mo.get(r);if(o||(o=/* @__PURE__ */new Set,Mo.set(r,o)),!o.has(t)){o.add(t);for(const e in n){const t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){const n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var Oo=/*@__PURE__*/je("ZodType",(e,t)=>(En.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ro(e,"input"),output:ro(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=Xr({...n,processors:t});return Qr(e,r),eo(r,e),to(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>yo(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>wo(e,t,n),e.parseAsync=async(t,n)=>bo(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>vo(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>xo(e,t,n),e.decode=(t,n)=>ko(e,t,n),e.encodeAsync=async(t,n)=>So(e,t,n),e.decodeAsync=async(t,n)=>_o(e,t,n),e.safeEncode=(t,n)=>Co(e,t,n),e.safeDecode=(t,n)=>Io(e,t,n),e.safeEncodeAsync=async(t,n)=>Eo(e,t,n),e.safeDecodeAsync=async(t,n)=>To(e,t,n),zo(e,"ZodType",{check(...e){const t=this.def;return this.clone(Qe(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ct(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...lt(n)})}($i,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=/* @__PURE__ */Kr(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(yt(e,t.value,n._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(yt(r))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check(Jr(e))},optional(){return Ii(this)},exactOptional(){return new Ei({type:"optional",innerType:this})},nullable(){return Mi(this)},nullish(){return Ii(Mi(this))},nonoptional(e){return function(e,t){return new Ri({type:"nonoptional",innerType:e,...lt(t)})}(this,e)},array(){return hi(this)},or(e){return yi([this,e])},and(e){return new bi({type:"intersection",left:this,right:e})},transform(e){return Pi(this,new _i({type:"transform",transform:e}))},default(e){return t=e,new zi({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():it(t)}});var t},prefault(e){return t=e,new Oi({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():it(t)}});var t},catch(e){return new Ai({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Pi(this,e)},readonly(){return new Li({type:"readonly",innerType:this})},describe(e){const t=this.clone();return jr.add(t,{description:e}),t},meta(...e){if(0===e.length)return jr.get(this);const t=this.clone();return jr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>jr.get(e)?.description,configurable:!0}),e)),Ro=/*@__PURE__*/je("_ZodString",(e,t)=>{Tn.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n;r.type="string";const{minimum:o,maximum:i,format:s,patterns:a,contentEncoding:c}=e._zod.bag;if("number"==typeof o&&(r.minLength=o),"number"==typeof i&&(r.maxLength=i),s&&(r.format=oo[s]??s,""===r.format&&delete r.format,"time"===s&&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,zo(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new bn({check:"string_format",format:"regex",...lt(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new xn({check:"string_format",format:"includes",...lt(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new kn({check:"string_format",format:"starts_with",...lt(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Sn({check:"string_format",format:"ends_with",...lt(t),suffix:e})}(...e))},min(...e){return this.check(Gr(...e))},max(...e){return this.check(Zr(...e))},length(...e){return this.check(Yr(...e))},nonempty(...e){return this.check(Gr(1,...e))},lowercase(e){return this.check(function(e){return new wn({check:"string_format",format:"lowercase",...lt(e)})}(e))},uppercase(e){return this.check(function(e){return new vn({check:"string_format",format:"uppercase",...lt(e)})}(e))},trim(){return this.check(/* @__PURE__ */Jr(e=>e.trim()))},normalize(...e){return this.check(function(e){/* @__PURE__ */
2
2
  return Jr(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(/* @__PURE__ */Jr(e=>e.toLowerCase()))},toUpperCase(){return this.check(/* @__PURE__ */Jr(e=>e.toUpperCase()))},slugify(){return this.check(/* @__PURE__ */Jr(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Ao=/*@__PURE__*/je("ZodString",(e,t)=>{Tn.init(e,t),Ro.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...lt(t)})}(Lo,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...lt(t)})}(Fo,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...lt(t)})}(ei,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...lt(t)})}(jo,t)),e.guid=t=>e.check(Ur($o,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...lt(t)})}(Do,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...lt(t)})}(Do,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...lt(t)})}(Do,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...lt(t)})}(Do,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...lt(t)})}(Uo,t)),e.guid=t=>e.check(Ur($o,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...lt(t)})}(Wo,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...lt(t)})}(Bo,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...lt(t)})}(Ho,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...lt(t)})}(Ko,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...lt(t)})}(Xo,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...lt(t)})}(qo,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...lt(t)})}(Vo,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...lt(t)})}(Zo,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...lt(t)})}(Go,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...lt(t)})}(Yo,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...lt(t)})}(Jo,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...lt(t)})}(Qo,t)),e.datetime=t=>e.check(ao(t)),e.date=t=>e.check(lo(t)),e.time=t=>e.check(po(t)),e.duration=t=>e.check(fo(t))});function No(e){return function(e,t){return new e({type:"string",...lt(t)})}(Ao,e)}var Po=/*@__PURE__*/je("ZodStringFormat",(e,t)=>{Mn.init(e,t),Ro.init(e,t)}),Lo=/*@__PURE__*/je("ZodEmail",(e,t)=>{Rn.init(e,t),Po.init(e,t)}),$o=/*@__PURE__*/je("ZodGUID",(e,t)=>{zn.init(e,t),Po.init(e,t)}),Do=/*@__PURE__*/je("ZodUUID",(e,t)=>{On.init(e,t),Po.init(e,t)}),Fo=/*@__PURE__*/je("ZodURL",(e,t)=>{An.init(e,t),Po.init(e,t)}),jo=/*@__PURE__*/je("ZodEmoji",(e,t)=>{Nn.init(e,t),Po.init(e,t)}),Uo=/*@__PURE__*/je("ZodNanoID",(e,t)=>{Pn.init(e,t),Po.init(e,t)}),Wo=/*@__PURE__*/je("ZodCUID",(e,t)=>{Ln.init(e,t),Po.init(e,t)}),Bo=/*@__PURE__*/je("ZodCUID2",(e,t)=>{$n.init(e,t),Po.init(e,t)}),Ho=/*@__PURE__*/je("ZodULID",(e,t)=>{Dn.init(e,t),Po.init(e,t)}),qo=/*@__PURE__*/je("ZodXID",(e,t)=>{Fn.init(e,t),Po.init(e,t)}),Vo=/*@__PURE__*/je("ZodKSUID",(e,t)=>{jn.init(e,t),Po.init(e,t)}),Zo=/*@__PURE__*/je("ZodIPv4",(e,t)=>{qn.init(e,t),Po.init(e,t)}),Go=/*@__PURE__*/je("ZodIPv6",(e,t)=>{Vn.init(e,t),Po.init(e,t)}),Yo=/*@__PURE__*/je("ZodCIDRv4",(e,t)=>{Zn.init(e,t),Po.init(e,t)}),Jo=/*@__PURE__*/je("ZodCIDRv6",(e,t)=>{Gn.init(e,t),Po.init(e,t)}),Ko=/*@__PURE__*/je("ZodBase64",(e,t)=>{Jn.init(e,t),Po.init(e,t)}),Xo=/*@__PURE__*/je("ZodBase64URL",(e,t)=>{Kn.init(e,t),Po.init(e,t)}),Qo=/*@__PURE__*/je("ZodE164",(e,t)=>{Xn.init(e,t),Po.init(e,t)}),ei=/*@__PURE__*/je("ZodJWT",(e,t)=>{Qn.init(e,t),Po.init(e,t)}),ti=/*@__PURE__*/je("ZodNumber",(e,t)=>{er.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=n,{minimum:o,maximum:i,format:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l}=e._zod.bag;"string"==typeof s&&s.includes("int")?r.type="integer":r.type="number";const d="number"==typeof l&&l>=(o??Number.NEGATIVE_INFINITY),u="number"==typeof c&&c<=(i??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;d?p?(r.minimum=l,r.exclusiveMinimum=!0):r.exclusiveMinimum=l:"number"==typeof o&&(r.minimum=o),u?p?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:"number"==typeof i&&(r.maximum=i),"number"==typeof a&&(r.multipleOf=a)})(e,t,n),zo(e,"ZodNumber",{gt(e,t){return this.check(Hr(e,t))},gte(e,t){return this.check(qr(e,t))},min(e,t){return this.check(qr(e,t))},lt(e,t){return this.check(Wr(e,t))},lte(e,t){return this.check(Br(e,t))},max(e,t){return this.check(Br(e,t))},int(e){return this.check(oi(e))},safe(e){return this.check(oi(e))},positive(e){return this.check(Hr(0,e))},nonnegative(e){return this.check(qr(0,e))},negative(e){return this.check(Wr(0,e))},nonpositive(e){return this.check(Br(0,e))},multipleOf(e,t){return this.check(Vr(e,t))},step(e,t){return this.check(Vr(e,t))},finite(){return this}});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 ni(e){return function(e,t){return new e({type:"number",checks:[],...lt(t)})}(ti,e)}var ri=/*@__PURE__*/je("ZodNumberFormat",(e,t)=>{tr.init(e,t),ti.init(e,t)});function oi(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...lt(t)})}(ri,e)}var ii=/*@__PURE__*/je("ZodBoolean",(e,t)=>{nr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function si(e){return function(e,t){return new e({type:"boolean",...lt(t)})}(ii,e)}var ai=/*@__PURE__*/je("ZodUnknown",(e,t)=>{rr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function ci(){return new ai({type:"unknown"})}var li=/*@__PURE__*/je("ZodNever",(e,t)=>{or.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function di(e){return function(e,t){return new e({type:"never",...lt(t)})}(li,e)}var ui=/*@__PURE__*/je("ZodDate",(e,t)=>{ir.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Date cannot be represented in JSON Schema")})(0,e),e.min=(t,n)=>e.check(qr(t,n)),e.max=(t,n)=>e.check(Br(t,n));const n=e._zod.bag;e.minDate=n.minimum?new Date(n.minimum):null,e.maxDate=n.maximum?new Date(n.maximum):null}),pi=/*@__PURE__*/je("ZodArray",(e,t)=>{ar.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;"number"==typeof s&&(o.minItems=s),"number"==typeof a&&(o.maxItems=a),o.type="array",o.items=Qr(i.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,zo(e,"ZodArray",{min(e,t){return this.check(Gr(e,t))},nonempty(e){return this.check(Gr(1,e))},max(e,t){return this.check(Zr(e,t))},length(e,t){return this.check(Yr(e,t))},unwrap(){return this.element}})});function hi(e,t){return function(e,t,n){return new e({type:"array",element:t,...lt(n)})}(pi,e,t)}var fi=/*@__PURE__*/je("ZodObject",(e,t)=>{pr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const s=i.shape;for(const l in s)o.properties[l]=Qr(s[l],t,{...r,path:[...r.path,"properties",l]});const a=new Set(Object.keys(s)),c=new Set([...a].filter(e=>{const n=i.shape[e]._zod;return"input"===t.io?void 0===n.optin:void 0===n.optout}));c.size>0&&(o.required=Array.from(c)),"never"===i.catchall?._zod.def.type?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=Qr(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)})(e,t,n,r),Ke(e,"shape",()=>t.shape),zo(e,"ZodObject",{keyof(){return ki(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:ci()})},loose(){return this.clone({...this._zod.def,catchall:ci()})},strict(){return this.clone({...this._zod.def,catchall:di()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!ot(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.")}return ct(e,Qe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Xe(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!ot(t))throw new Error("Invalid input to safeExtend: expected a plain object");return ct(e,Qe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return Xe(this,"shape",n),n}}))}(this,e)},merge(e){return function(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return ct(e,Qe(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return Xe(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}(this,e)},pick(e){return 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 ct(e,Qe(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 Xe(this,"shape",e),e},checks:[]}))}(this,e)},omit(e){return 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");return ct(e,Qe(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 Xe(this,"shape",r),r},checks:[]}))}(this,e)},partial(...e){return 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");return ct(t,Qe(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 Xe(this,"shape",o),o},checks:[]}))}(Ci,this,e[0])},required(...e){return t=Ri,n=this,r=e[0],ct(n,Qe(n._zod.def,{get shape(){const e=n._zod.def.shape,o={...e};if(r)for(const n in r){if(!(n in o))throw new Error(`Unrecognized key: "${n}"`);r[n]&&(o[n]=new t({type:"nonoptional",innerType:e[n]}))}else for(const n in e)o[n]=new t({type:"nonoptional",innerType:e[n]});return Xe(this,"shape",o),o}}));var t,n,r}})});function mi(e,t){const n={type:"object",shape:e??{},...lt(t)};return new fi(n)}var gi=/*@__PURE__*/je("ZodUnion",(e,t)=>{fr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=!1===o.inclusive,s=o.options.map((e,n)=>Qr(e,t,{...r,path:[...r.path,i?"oneOf":"anyOf",n]}));i?n.oneOf=s:n.anyOf=s})(e,t,n,r),e.options=t.options});function yi(e,t){return new gi({type:"union",options:e,...lt(t)})}var bi=/*@__PURE__*/je("ZodIntersection",(e,t)=>{mr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=Qr(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=Qr(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=e=>"allOf"in e&&1===Object.keys(e).length;n.allOf=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]]})(e,t,n,r)});var wi=/*@__PURE__*/je("ZodRecord",(e,t)=>{br.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const s=i.keyType,a=s._zod.bag?.patterns;if("loose"===i.mode&&a&&a.size>0){const e=Qr(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const t of a)o.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(o.propertyNames=Qr(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=Qr(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const c=s._zod.values;if(c){const e=[...c].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(o.required=e)}})(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function vi(e,t,n){return t&&t._zod?new wi({type:"record",keyType:e,valueType:t,...lt(n)}):new wi({type:"record",keyType:No(),valueType:e,...lt(t)})}var xi=/*@__PURE__*/je("ZodEnum",(e,t)=>{wr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=qe(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 i of e){if(!n.has(i))throw new Error(`Key ${i} not found in enum`);o[i]=t.entries[i]}return new xi({...t,checks:[],...lt(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 xi({...t,checks:[],...lt(r),entries:o})}});function ki(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new xi({type:"enum",entries:n,...lt(t)})}var Si=/*@__PURE__*/je("ZodLiteral",(e,t)=>{vr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=e._zod.def,o=[];for(const i of r.values)if(void 0===i){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof i){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(i))}else o.push(i);if(0===o.length);else if(1===o.length){const e=o[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),o.every(e=>"boolean"==typeof e)&&(n.type="boolean"),o.every(e=>null===e)&&(n.type="null"),n.enum=o})(e,t,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});var _i=/*@__PURE__*/je("ZodTransform",(e,t)=>{xr.init(e,t),Oo.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 We(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(yt(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(yt(t))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});var Ci=/*@__PURE__*/je("ZodOptional",(e,t)=>{Sr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>io(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Ii(e){return new Ci({type:"optional",innerType:e})}var Ei=/*@__PURE__*/je("ZodExactOptional",(e,t)=>{_r.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>io(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Ti=/*@__PURE__*/je("ZodNullable",(e,t)=>{Cr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=Qr(o.innerType,t,r),s=t.seen.get(e);"openapi-3.0"===t.target?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Mi(e){return new Ti({type:"nullable",innerType:e})}var zi=/*@__PURE__*/je("ZodDefault",(e,t)=>{Ir.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;Qr(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});var Oi=/*@__PURE__*/je("ZodPrefault",(e,t)=>{Tr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;Qr(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});var Ri=/*@__PURE__*/je("ZodNonOptional",(e,t)=>{Mr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;Qr(o.innerType,t,r),t.seen.get(e).ref=o.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Ai=/*@__PURE__*/je("ZodCatch",(e,t)=>{Or.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;let i;Qr(o.innerType,t,r),t.seen.get(e).ref=o.innerType;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var Ni=/*@__PURE__*/je("ZodPipe",(e,t)=>{Rr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s="input"===t.io?i?o.out:o.in:o.out;Qr(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function Pi(e,t){return new Ni({type:"pipe",in:e,out:t})}var Li=/*@__PURE__*/je("ZodReadonly",(e,t)=>{Nr.init(e,t),Oo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;Qr(o.innerType,t,r),t.seen.get(e).ref=o.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var $i=/*@__PURE__*/je("ZodCustom",(e,t)=>{$r.init(e,t),Oo.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)});function Di(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...lt(t)})}(ti,e)}function Fi(e){return function(e,t){return new e({type:"date",coerce:!0,...lt(t)})}(ui,e)}var ji,Ui=ki(["created","active","suspended","pending_approval"]),Wi=mi({id:ni().optional(),created_at:Fi().optional(),updated_at:Fi().optional()}),Bi=(mi({id:Di()}),mi({slug:No()}),mi({widget_id:Di()}),mi({simulation_id:Di()}),mi({application_id:Di()}),mi({user_id:Di()}),mi({limit:Di().optional().default(50),offset:Di().optional().default(0)}),yi([si(),No()]).transform(e=>"boolean"==typeof e?e:"true"===e||"false"!==e&&void 0).optional(),mi({success:function(e,t){return new Si({type:"literal",values:Array.isArray(e)?e:[e],...lt(t)})}(!0)})),Hi=(Bi.extend({message:No()}),mi({name:No().min(1),params:vi(No(),ci()).default({}),result:vi(No(),ci()).default({})}),No().url().refine(e=>/^https:\/\/hooks\.slack\.com\//.test(e),{message:"Slack webhook URL must start with https://hooks.slack.com/"}),mi({start:No(),end:No(),action:No()}).passthrough()),qi=mi({id:No(),label:No(),purpose:No(),elements:hi(vi(No(),ci())).default([]),bbox:vi(No(),ci()).default({}),screenshot:No().default(""),embedding:hi(ni()).nullish()}).passthrough(),Vi=mi({id:No(),title:No(),url:No(),summary:No().default(""),screenshot:No().default(""),sections:hi(qi).default([]),sequence_ids:hi(ni()).default([]),embedding:hi(ni()).nullish()}).passthrough(),Zi=(mi({nodes:hi(Vi),edges:hi(Hi)}),ki(["free","startup","growth","enterprise"])),Gi=ki(["document","video"]),Yi=ki(["user","research"]),Ji=ki(["queued","running","creating_knowledge","has_question","completed","failed","stopped"]),Ki=ki(["pending","generating","completed","failed"]),Xi=ki(["app","website"]),Qi=ki(["widget"]),es=(ki(["tell","show","do"]),ki(["password","oauth"])),ts=(Wi.extend({is_super:si(),status:Ui,email:No().email(),external_id:No().nullish(),first_name:No().nullish(),last_name:No().nullish(),password:No().nullish(),image_url:No().nullish(),last_login_at:Fi().nullish(),auth_method:es.nullish()}),Wi.extend({name:No(),slug:No(),status:Ui,package:Zi,ending_date:Fi().nullish(),external_workspace_id:No().nullish(),slack_webhook_configured:si().optional(),notify_all_members_on_question:si().optional()}),Wi.extend({workspace_id:ni(),application_id:ni().optional(),file_name:No().min(1),file_size:Di(),file_type:Gi,file_url:No(),source_url:No().nullish(),source:Yi.default("user").optional()}),Wi.extend({workspace_id:ni(),application_id:ni(),persona_id:ni(),file_name:No().min(1),file_size:Di(),file_type:No(),file_url:No()}),ki(["desktop","tablet","mobile"])),ns=ki(["positive","neutral","negative"]),rs=mi({step_index:ni(),screenshot_ref:No().nullable(),reaction:No(),sentiment:ns}),os=mi({id:ni(),run_id:ni().nullable(),persona_id:ni().nullable(),user_index:ni().nullable(),simulation_id:ni().nullable(),study_variant_id:ni().nullable(),study_task_id:ni().nullable(),journey_reaction:No().nullable(),journey_sentiment:ns.nullable(),status:ki(["pending","completed","failed"]),step_reactions:hi(rs).default([]),question_answers:hi(mi({study_question_id:ni(),answer:No()})).default([])}),is=(Wi.extend({application_id:ni(),job_id:No(),browser_session_id:No().nullish(),status:Ji,status_message:No(),path:No().nullish(),instructions:No(),name:No().nullish(),type:ki(["direct","uxr","survey","abtest","qa"]),pinned:si().optional(),source:ki(["direct","qa"]).optional(),graph_id:No().nullish(),source_metadata:vi(No(),ci()).nullish(),step_count:ni().int().nonnegative().nullish(),started_at:Fi().nullish(),completed_at:Fi().nullish(),output_persisted_at:Fi().nullish(),graph_status:Ki.optional(),graph_steps_processed:ni().int().nonnegative().optional(),graph_steps_total:ni().int().nonnegative().optional(),graph_error:No().nullish(),created_by_user_id:ni().nullish(),has_question:si().optional(),riders:hi(mi({persona_id:ni(),user_count:ni().int().positive()})).default([]),reactions:hi(os).default([]),driver_persona_id:ni().nullable().default(null),viewport:ts.default("desktop")}),Wi.extend({workspace_id:ni(),name:No(),slug:No(),type:Xi,url:No(),username:No().nullish(),password:No().nullish(),allowed_domains:hi(No()).default([])}).omit({password:!0}),mi({chip_mode:ki(["show","tell","do"]),chip_text:No()})),ss=mi({widget_enabled:si(),widget_appearance:ki(["default","compact","full","hidden"]),widget_position:ki(["bottom_left","bottom_right","top_left","top_right"]),widget_device:ki(["desktop","mobile","desktop_mobile"]),widget_header:No(),widget_body:No(),widget_greeting:No(),widget_greeting_toast:si(),widget_recording:si(),widget_feature_tell:si(),widget_feature_show:si(),widget_feature_do:si(),widget_feature_human:si(),widget_background_color:No(),widget_text_color:No(),widget_border_color:No(),widget_accent_color:No(),widget_secondary_color:No(),widget_border_radius:No(),widget_font_size:No(),widget_width:No(),widget_height:No(),widget_shadow:No(),widget_animation_duration:No(),widget_fade_duration:No(),widget_bounce_effect:si(),widget_chips:hi(is)}),as=(Wi.extend({application_id:ni(),type:Qi,settings:ss,status:Ui,marketrix_id:No(),marketrix_key:No(),snippet:No().nullish()}),Wi.extend({widget_id:ni(),url_pattern:No(),message:hi(No()),description:No().optional()}),ki(["created","running","finalizing","completed","failed","stopped"]),ki(["passed","failed","indecisive"]),ki(["passed","failed"]),ki(["user_login","url_visit","update_workspace","create_user","update_user","delete_user","create_application","update_application","delete_application","create_widget","update_widget","delete_widget","create_knowledge","update_knowledge","delete_knowledge","approve_user","deny_user","request_workspace","widget_question","qa_run_started","start_simulation","create_workflow","update_workflow","delete_workflow","toggle_workflow","slack_command"])),cs=mi({details:No().optional(),id:ni().optional(),type:No().optional(),name:No().optional(),target_user_id:ni().optional(),target_user_email:No().optional(),reason:No().optional(),assigned_role:No().optional(),new_role:No().optional(),previous_role:No().optional(),workspace_name:No().optional(),workspace_slug:No().optional(),ip_address:No().optional(),user_agent:No().optional(),widget_type:No().optional(),created_by:ni().optional()}).passthrough(),ls=(Wi.extend({workspace_id:ni(),user_id:ni().nullable(),type:as,metadata:cs.optional()}).partial().extend({type:as}),null),ds="";function us(e){return ye(new Fe({url:e,headers:()=>{const e={};return ls&&(e.Authorization=`Bearer ${ls}`),e}}))}ji=us("");var ps=e=>{if(!e?.trim())throw new Error("API URL is required for SDK configuration");e!==ds&&(ds=e,ji=us(e))},hs={setAuthToken:e=>{ls=e},clearAuthToken:()=>{ls=null},getAuthToken:()=>ls,configure:ps},fs=new Proxy({},{get:(e,t)=>t in hs?hs[t]:ji[t]}),ms="undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&!window.location.hostname.includes("localhost")?"error":"debug",gs={debug:0,info:1,warn:2,error:3};function ys(e){return gs[e]>=gs[ms]}var bs=[{id:"navigate",name:"Navigate",description:"Navigate to a URL",displayAction:"Navigating",category:"navigation",actionType:"navigate"},{id:"search",name:"Search",description:"Search the web using a search engine",displayAction:"Searching",category:"navigation",actionType:"search"},{id:"click_element",name:"Click Element",description:"Click on an element by index or coordinates",displayAction:"Clicking element",category:"interaction",actionType:"click_element"},{id:"type_text",name:"Type Text",description:"Type text into an input field",displayAction:"Typing text",category:"interaction",actionType:"type_text"},{id:"scroll",name:"Scroll",description:"Scroll the page up or down",displayAction:"Scrolling",category:"interaction",actionType:"scroll"},{id:"scroll_to_text",name:"Scroll to Text",description:"Scroll until text is visible",displayAction:"Scrolling to text",category:"interaction",actionType:"scroll_to_text"},{id:"send_keys",name:"Send Keys",description:"Send keyboard keys or shortcuts",displayAction:"Pressing key",category:"interaction",actionType:"send_keys"},{id:"extract",name:"Extract",description:"Extract content from the page",displayAction:"Extracting content",category:"extraction",actionType:"extract"},{id:"get_dropdown_options",name:"Get Dropdown Options",description:"Get available options from a dropdown",displayAction:"Reading dropdown options",category:"extraction",actionType:"get_dropdown_options"},{id:"select_dropdown_option",name:"Select Dropdown Option",description:"Select an option from a dropdown",displayAction:"Selecting option",category:"interaction",actionType:"select_dropdown_option"},{id:"upload_file",name:"Upload File",description:"Upload a file to an input field",displayAction:"Uploading file",category:"interaction",actionType:"upload_file"},{id:"go_back",name:"Go Back",description:"Browser back button",displayAction:"Going back",category:"navigation",actionType:"go_back"},{id:"wait",name:"Wait",description:"Wait for a specified duration",displayAction:"Waiting",category:"utility",actionType:"wait"},{id:"switch_tab",name:"Switch Tab",description:"Switch to a different browser tab",displayAction:"Switching tab",category:"utility",actionType:"switch_tab"},{id:"close_tab",name:"Close Tab",description:"Close the current browser tab",displayAction:"Closing tab",category:"utility",actionType:"close_tab"},{id:"done",name:"Done",description:"Mark task as complete",displayAction:"Done",category:"utility",actionType:"done"},{id:"get_html",name:"Get HTML",description:"Get full page HTML with data-id attributes",displayAction:"Viewed your screen",category:"extraction",actionType:"get_html"},{id:"get_interactable_elements",name:"Get Interactable Elements",description:"Get list of interactable elements",displayAction:"Scanning elements",category:"extraction",actionType:"get_interactable_elements"},{id:"get_screenshot",name:"Get Screenshot",description:"Capture a screenshot of the page",displayAction:"Taking screenshot",category:"extraction",actionType:"get_screenshot"}];function ws(e){return e.includes("__THINKING__")}function vs(e){return ws(e)?e:`${e}\n\n__THINKING__`}function xs(e,t,n,r,o){if("agent"!==e.sender||e.isSystemMessage||e.isScreenAccessRequest)return!1;if(o&&t&&("show"===n||"do"===n))if(e.isPlaceholder){if(void 0!==e.mode&&e.mode!==n)return!1}else if(e.mode!==n)return!1;if(r){const t=e.content.trim().length>0,n=e.parts&&e.parts.length>0;if(!t&&!n)return!1}return!0}function ks(e){const{messages:t,isTaskRunning:n,currentMode:r,requireContent:o}=e;let i=-1;if(n&&("show"===r||"do"===r)){const e=!0;for(let s=t.length-1;s>=0;s--){const a=t[s],c=xs(a,n,r,o,e),l=a.isPlaceholder,d=!o||a.content.trim().length>0||a.parts&&a.parts.length>0;if(c&&l&&d){i=s;break}}if(i<0&&!o)for(let s=t.length-1;s>=0;s--){const a=t[s],c=xs(a,n,r,o,e),l=a.isPlaceholder;if(c&&l){i=s;break}}if(i<0)for(let s=t.length-1;s>=0;s--){const a=t[s],c=xs(a,n,r,o,e),l=a.isPlaceholder;if(c&&!l){i=s;break}}}if(i<0){for(let e=t.length-1;e>=0;e--){const n=t[e],r="agent"===n.sender,s=n.isPlaceholder,a=!n.isSystemMessage,c=!n.isScreenAccessRequest,l=!o||n.content.trim().length>0||n.parts&&n.parts.length>0;if(r&&s&&a&&c&&l){i=e;break}}if(i<0&&!o)for(let e=t.length-1;e>=0;e--){const n=t[e];if("agent"===n.sender&&n.isPlaceholder&&!n.isSystemMessage&&!n.isScreenAccessRequest){i=e;break}}if(i<0&&(i=function(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if("agent"===n.sender&&!n.isSystemMessage&&!n.isScreenAccessRequest&&!n.isPlaceholder)return t}return-1}(t)),i<0)for(let e=t.length-1;e>=0;e--){const n=t[e];if("agent"===n.sender&&!n.isSystemMessage&&!n.isScreenAccessRequest){i=e;break}}}return i>=0?{index:i,message:t[i]}:null}function Ss(e){const t={...e};if(!t.parts){t.parts=[];const e=t.content.replace(/\n\n__THINKING__$/,"").trim();e&&t.parts.push({type:"text",content:e})}return t}var _s=/* @__PURE__ */new Set(["click_element","type_text","send_keys","select_dropdown_option","upload_file","scroll"]),Cs=/* @__PURE__ */new Set(["click_element","type_text","select_dropdown_option","send_keys","upload_file"]);function Is(e){return e?e.replace(/\(Cancelled by cleanup\)/gi,"").replace(/\(cancelled by cleanup\)/gi,"").replace(/Cancelled by cleanup/gi,"").replace(/\s+/g," ").trim():e}function Es(e,t,n,r=!1){const o=Ss(e);if(!t||"show"!==n&&"do"!==n)return ws(o.content)?{...o,content:o.content.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,""),placeholderState:void 0}:o;const i=r?"waiting-for-user":"thinking";return ws(o.content)?o.placeholderState!==i?{...o,placeholderState:i}:o:{...o,content:vs(o.content),placeholderState:i}}var Ts=Object.fromEntries(bs.map(e=>[e.id,e.displayAction]));var Ms="marketrix_chat_context",zs={chat_id:null,messages:[],isTaskRunning:!1,activeTaskId:null,currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1,config:null,timestamp:Date.now()},Os=class e{static instance;context=null;constructor(){this.loadContext()}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadContext(){if("undefined"==typeof window)return this.context={...zs},this.context;try{const e=localStorage.getItem(Ms);if(e){const t=JSON.parse(e);return Date.now()-t.timestamp>6048e5?(this.context={...zs},this.saveContext(),this.context):(this.context=t,this.context)}}catch(e){}return this.context={...zs},this.context}saveContext(){if("undefined"!=typeof window&&this.context)try{this.context.timestamp=Date.now(),localStorage.setItem(Ms,JSON.stringify(this.context))}catch(e){}}getContext(){return this.context?this.context:this.loadContext()}updateContext(e){this.context||this.loadContext();const t=this.context;this.context={...t,...e},this.saveContext()}isValidChatId(e){return"string"==typeof e&&""!==e.trim()}getChatId(){if("undefined"!=typeof window&&this.isValidChatId(window.name)){const e=window.name;return e!==this.getContext().chat_id&&this.updateContext({chat_id:e}),e}return this.getContext().chat_id}setChatId(e){this.updateContext({chat_id:e}),"undefined"!=typeof window&&e&&(window.name=e)}getMessages(){return this.getContext().messages}setMessages(e){this.updateContext({messages:e})}getChatState(){const e=this.getContext();return{isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading}}setChatState(e){this.updateContext(e)}getConfig(){return this.getContext().config}setConfig(e){this.updateContext({config:e})}clear(){this.context={...zs},"undefined"!=typeof window&&localStorage.removeItem(Ms)}hasValidContext(){const e=this.getContext();return null!==e.chat_id&&e.chat_id.length>0}}.getInstance(),Rs=class e{static instance;chatId=null;initError=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}initialize(e){this.chatId=e}createInitialContext(e){try{if(Os.hasValidContext())return;Os.updateContext({chat_id:e,messages:[],isTaskRunning:!1,activeTaskId:null,currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1})}catch(t){this.initError=t instanceof Error?t:new Error(String(t))}}getInitError(){return this.initError}restore(){const e=Os.getContext();return{messages:e.chat_id?e.messages.map(e=>{if(e.id.startsWith("screenshare-"))return{...e,content:"Screenshare ended",videoStream:void 0,isSystemMessage:!0,timestamp:new Date(e.timestamp),parts:[{type:"text",content:"Screenshare ended"}]};const t={...e,timestamp:new Date(e.timestamp),videoStream:void 0,placeholderState:e.placeholderState,taskStatus:e.taskStatus,parts:e.parts||[]};if(0===t.parts?.length&&t.content){const e=t.content.replace(/\n\n__THINKING__$/,"").trim();e&&t.parts&&t.parts.push({type:"text",content:e})}return t}):[],isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading??!1}}persist(e){if(this.chatId)try{const t=e.messages.filter(e=>!e.isPlaceholder||("thinking"===e.placeholderState||"waiting-for-user"===e.placeholderState||(e.parts||[]).length>0)).filter(e=>!(e.isSystemMessage&&"Chat context changed"===e.content)).map(e=>{return{id:e.id,content:(t=e.content,t.replace(/__THINKING__/g,"")),sender:e.sender,timestamp:e.timestamp.toISOString(),mode:e.mode,isScreenAccessRequest:e.isScreenAccessRequest,screenShareStatus:e.screenShareStatus,isSystemMessage:e.isSystemMessage,isPlaceholder:e.isPlaceholder,placeholderState:e.placeholderState,taskStatus:e.taskStatus,parts:e.parts};var t});Os.updateContext({chat_id:this.chatId,messages:t,isTaskRunning:e.isTaskRunning,activeTaskId:e.activeTaskId,currentMode:e.currentMode,isOpen:e.isOpen,isMinimized:e.isMinimized,isLoading:e.isLoading})}catch(t){}}}.getInstance();function As(e,t,n="user-message"){const r=[],o=e.trim();return o&&r.push({type:"text",content:o}),{id:`${n}-${Date.now()}`,content:o,sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,parts:r}}function Ns(e,t,n,r="agent-message"){const o=[],i=e.trim();return i&&o.push({type:"text",content:i}),{id:n||`${r}-${Date.now()}`,content:e,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:t,parts:o}}function Ps(e,t,n="agent",r="system-message"){const o=[];return e&&o.push({type:"text",content:e}),{id:`${r}-${Date.now()}`,content:e,sender:n,timestamp:/* @__PURE__ */new Date,mode:t,isSystemMessage:!0,parts:o}}function Ls(e="show"){const t="Started screenshare";return{id:`started-screenshare-${Date.now()}`,content:t,sender:"user",timestamp:/* @__PURE__ */new Date,mode:e,isSystemMessage:!0,parts:[{type:"text",content:t}]}}function $s(e,t="show"){return{id:`screenshare-${Date.now()}`,content:"",sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,videoStream:e,parts:[]}}var Ds={debug:(e,...t)=>{ys("debug")},info:(e,...t)=>{ys("info")},warn:(e,...t)=>{ys("warn")},error:(e,...t)=>{ys("error")}},Fs=class e{static instance=null;chatId=null;initializationPromise=null;constructor(){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.chatId=this.getStoredChatId(),this.chatId&&Ds.debug("Loaded existing chat ID from storage:",this.chatId))}static getInstance(){return"undefined"==typeof window||"undefined"==typeof document?(e.instance||(e.instance=Object.create(e.prototype),e.instance.chatId=null,e.instance.initializationPromise=null),e.instance):(e.instance||(e.instance=new e),e.instance)}getChatId(){return this.chatId}async getOrCreateChatId(){if(this.chatId)return Ds.debug("Returning existing chat ID:",this.chatId),this.chatId;if(this.initializationPromise)return Ds.debug("Chat ID initialization in progress, waiting..."),this.initializationPromise;const e=this.getStoredChatId();if(e)return this.chatId=e,Ds.debug("Found chat ID in storage:",this.chatId),this.chatId;this.initializationPromise=this.createChatId();try{return await this.initializationPromise}finally{this.initializationPromise=null}}async createChatId(){try{Ds.info("Creating new chat ID...");const e=await fs.chatCreate(void 0);if(!e)throw new Error("API returned empty chat ID");return this.chatId=e,this.storeChatId(e),Ds.info("Created and stored new chat ID:",this.chatId),Rs.createInitialContext(e),e}catch(e){throw Ds.error("Failed to create chat ID:",e),this.initializationPromise=null,e}}getStoredChatId(){return Os.getChatId()}storeChatId(e){Os.setChatId(e)}}.getInstance(),js=class e{static instance=null;abortController=null;chatId=null;status="disconnected";callbacks=/* @__PURE__ */new Set;isIntentionallyDisconnected=!1;reconnectAttempts=0;maxReconnectAttempts=10;reconnectDelay=1e3;maxReconnectDelay=3e4;reconnectTimer=null;config;connectionId=0;tabId=globalThis.crypto.randomUUID();registrationWaiters=/* @__PURE__ */new Set;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}addCallbacks(e){this.callbacks.add(e)}removeCallbacks(e){this.callbacks.delete(e)}getStatus(){return this.status}isConnected(){return"registered"===this.status}async waitUntilRegistered(){this.isConnected()||await new Promise(e=>this.registrationWaiters.add(e))}async connect(e,t){if(this.isIntentionallyDisconnected&&(this.isIntentionallyDisconnected=!1),this.chatId===e&&("connecting"===this.status||"connected"===this.status||"registered"===this.status))return;this.abortController&&(this.abortController.abort(),this.abortController=null),this.chatId=e,t&&(this.config=t),this.setStatus("connecting");const n=++this.connectionId;this.abortController=new AbortController;const r=this.abortController.signal;try{const t={chat_id:e,tab_id:this.tabId};this.config?.mtxId&&this.config?.mtxKey&&(t.marketrix_id=this.config.mtxId,t.marketrix_key=this.config.mtxKey);const o=await fs.widgetStream(t,{signal:r});this.setStatus("connected"),this.consumeEvents(o,n)}catch(o){r.aborted||(this.setStatus("error"),this.notifyError(/* @__PURE__ */new Error("Stream connection failed")),this.scheduleReconnect())}}async consumeEvents(e,t){let n=!1;try{for await(const r of e){if(this.connectionId!==t){n=!0;break}this.handleMessage(r)}}catch(r){this.connectionId!==t?n=!0:this.isIntentionallyDisconnected||this.setStatus("error")}finally{n||this.connectionId!==t||this.isIntentionallyDisconnected||(this.setStatus("disconnected"),this.scheduleReconnect())}}disconnect(){this.isIntentionallyDisconnected=!0,this.clearReconnectTimer(),this.abortController&&(this.abortController.abort(),this.abortController=null),this.setStatus("disconnected"),this.chatId=null}send(e){return this.chatId?fs.widgetMessage({chat_id:this.chatId,tab_id:this.tabId,command:e}).then(()=>{}).catch(e=>{throw this.notifyError(/* @__PURE__ */new Error(`Failed to send message: ${String(e)}`)),e}):Promise.reject(/* @__PURE__ */new Error("No active chat"))}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(t=>t.onStatusChange?.(e)))}notifyError(e){this.callbacks.forEach(t=>t.onError?.(e))}handleMessage(e){if(!this.isIntentionallyDisconnected&&"heartbeat"!==e.type){if("registered"===e.type&&e.chat_id===this.chatId){this.setStatus("registered"),this.reconnectAttempts=0,this.reconnectDelay=1e3;for(const e of this.registrationWaiters)e();this.registrationWaiters.clear(),this.callbacks.forEach(t=>t.onRegistered?.(e.application_id))}"chat/error"===e.type&&"auth"===e.request_id&&(this.isIntentionallyDisconnected=!0),this.callbacks.forEach(t=>t.onMessage?.(e))}}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return void this.notifyError(/* @__PURE__ */new Error("Max reconnect attempts reached"));this.clearReconnectTimer(),this.reconnectAttempts++;const e=Math.min(this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1),this.maxReconnectDelay);this.reconnectTimer=setTimeout(()=>{!this.isIntentionallyDisconnected&&this.chatId&&this.connect(this.chatId,this.config).catch(console.error)},e)}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}};function Us(){return Fs.getChatId()}async function Ws(e,t,n){try{const r=function(e){if(e.userId&&"number"==typeof e.userId)return e.userId;try{const e=localStorage.getItem("marketrix_user_id");if(e){const t=Number(e);if(!isNaN(t))return t}}catch(t){}try{const e=sessionStorage.getItem("marketrix_user_id");if(e){const t=Number(e);if(!isNaN(t))return t}}catch(t){}return null}(e),o={question:t,mode:n,chat_id:Us(),timestamp:/* @__PURE__ */(new Date).toISOString()};null!==r&&(o.user_id=r),e.mtxId&&e.mtxKey&&(o.marketrix_id=e.mtxId,o.marketrix_key=e.mtxKey),fs.activityLogCreate({type:"widget_question",metadata:o}).catch(e=>{})}catch(r){}}function Bs(e){if(!(e&&e instanceof Element))return!1;try{const n=e.tagName.toLowerCase(),r="button"===n;if(!(r||"input"===n||"textarea"===n||"select"===n||"a"===n&&e.hasAttribute("href")||"button"===e.getAttribute("role")||"link"===e.getAttribute("role")||"textbox"===e.getAttribute("role")||"checkbox"===e.getAttribute("role")||"radio"===e.getAttribute("role")||"switch"===e.getAttribute("role")||"tab"===e.getAttribute("role")||"menuitem"===e.getAttribute("role")||"true"===e.getAttribute("contenteditable")||e.hasAttribute("onclick")||e.hasAttribute("tabindex")&&parseInt(e.getAttribute("tabindex")||"-1",10)>=0))return!1;const o=(t,n)=>{if(r){e.tagName,e.id,e.className}};if(!0===e.disabled)return o("disabled","button is disabled"),!1;if("true"===e.getAttribute("aria-disabled"))return o("aria-disabled","aria-disabled is true"),!1;try{let t=e;for(;t;){if(t instanceof HTMLElement&&t.inert)return o("inert","ancestor is inert"),!1;const e=t instanceof Element?t.getRootNode():null;t=t instanceof Element?t.parentElement||(e instanceof ShadowRoot?e.host:null):null}}catch(t){}const i=e.hasAttribute("onclick");if(r&&i)return!0;let s,a;try{s=window.getComputedStyle(e)}catch(t){return o("computed-style","failed to get computed style"),!1}if("none"===s.display)return o("display","display is none"),!1;if("none"===s.pointerEvents)return o("pointer-events","pointer-events is none"),!1;try{a=e.getBoundingClientRect()}catch(t){return o("bounding-rect","failed to get bounding rect"),!1}if(a.width<=0||a.height<=0)return o("dimensions",`width=${a.width}, height=${a.height}`),!1;try{let t=e;for(;t&&t!==document.body;){const e=t.getRootNode(),n=t.parentElement||(e instanceof ShadowRoot?e.host:null);if(!n)break;let i,s;try{i=window.getComputedStyle(n),s=n.getBoundingClientRect()}catch{t=n;continue}if("hidden"===i.overflow||"clip"===i.overflow){const e=a.right<s.left||a.left>s.right||a.bottom<s.top||a.top>s.bottom;if(r){if(e)return o("overflow-clipping","completely outside parent bounds"),!1}else if(e)return!1}t=n}}catch(t){}try{let t=e.getRootNode();for(;t instanceof ShadowRoot;){const e=t.host;let n;try{n=e.getBoundingClientRect()}catch{break}if(n.width<=0||n.height<=0)return!1;t=e.getRootNode()}}catch(t){}return!0}catch(t){return!1}}var Hs=class e{static instance;elementMap=/* @__PURE__ */new Map;elementToSequence=/* @__PURE__ */new WeakMap;selectorMap=/* @__PURE__ */new Map;fingerprintMap=/* @__PURE__ */new Map;indexingInProgress=!1;indexVersion=0;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}generateSelector(e){if(e.id&&1===document.querySelectorAll(`#${CSS.escape(e.id)}`).length)return`#${CSS.escape(e.id)}`;const t=[];let n=e;for(;n&&n!==document.body&&n.parentElement;){let e=n.tagName.toLowerCase();if(n.id){e+=`#${CSS.escape(n.id)}`,t.unshift(e);break}{const t=n.parentElement;if(!t)break;const r=n.tagName,o=Array.from(t.children).filter(e=>e.tagName===r);if(o.length>1){e+=`:nth-of-type(${o.indexOf(n)+1})`}}t.unshift(e),n=n.parentElement}return t.join(" > ")}generateFingerprint(e,t){return{tagName:e.tagName,id:e.id||null,textContent:((e,t=100)=>{if(!e)return null;const n=e.trim().replace(/\s+/g," ");return n.length>t?n.slice(0,t):n})(e.textContent),type:e.getAttribute("type"),role:e.getAttribute("role"),ariaLabel:e.getAttribute("aria-label"),name:e.getAttribute("name"),href:e.getAttribute("href"),selector:t,indexVersion:this.indexVersion}}matchesFingerprint(e,t){return e.tagName===t.tagName&&(!(!t.id||e.id!==t.id)||(!t.type||e.getAttribute("type")===t.type)&&((!t.ariaLabel||e.getAttribute("aria-label")===t.ariaLabel)&&((!t.role||e.getAttribute("role")===t.role)&&((!t.href||"A"!==t.tagName||e.getAttribute("href")===t.href)&&(!t.name||e.getAttribute("name")===t.name)))))}validateElementAtIndex(e){const t=this.fingerprintMap.get(e);if(!t)return{isValid:!0};const n=this.elementMap.get(e);return n&&document.contains(n)?n instanceof HTMLElement&&!this.matchesFingerprint(n,t)?{isValid:!1,mismatchReason:"element_changed"}:{isValid:!0}:{isValid:!1,mismatchReason:"element_removed"}}indexInteractableElements(){if(this.indexingInProgress)return[];try{this.indexingInProgress=!0,this.clearIndex();const e=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{if(e instanceof HTMLElement&&null===e.offsetParent&&"BODY"!==e.tagName){const t=window.getComputedStyle(e),n="fixed"===t.position||"sticky"===t.position;if("none"===t.display)return NodeFilter.FILTER_REJECT;if(!n){let t=e.parentElement,n=!1;for(;t&&t!==document.body;){const e=window.getComputedStyle(t);if("fixed"===e.position||"sticky"===e.position){n=!0;break}t=t.parentElement}if(!n)return NodeFilter.FILTER_REJECT}}return NodeFilter.FILTER_ACCEPT}});let t=e.nextNode(),n=0;const r=[];for(;t;){if(t instanceof HTMLElement){const e=t.matches('a[href], button, input, textarea, select, [role="button"]'),o=t.classList.contains("cursor-pointer")||t.classList.contains("clickable"),i="onclick"in t&&"function"==typeof t.onclick;if(e||o||i||Bs(t)){this.elementMap.set(n,t),this.elementToSequence.set(t,n);const e=this.generateSelector(t);this.selectorMap.set(n,e);const o=this.generateFingerprint(t,e);this.fingerprintMap.set(n,o),r.push([n,t]),n++}}t=e.nextNode()}return this.indexVersion++,r}finally{this.indexingInProgress=!1}}getElementCoordinates(e){const t=e.getBoundingClientRect(),n=this.calculateGlobalZOrder(e);return{x:Math.round(t.left),y:Math.round(t.top),w:Math.round(t.width),h:Math.round(t.height),z:n}}isStackingContext(e){const t=window.getComputedStyle(e),n=t.position;if(("fixed"===n||"absolute"===n||"relative"===n||"sticky"===n)&&"auto"!==t.zIndex)return!0;if("auto"!==t.zIndex&&e.parentElement){const t=window.getComputedStyle(e.parentElement).display;if("flex"===t||"inline-flex"===t||"grid"===t||"inline-grid"===t)return!0}const r=parseFloat(t.opacity);if(!isNaN(r)&&r<1)return!0;if(t.transform&&"none"!==t.transform)return!0;if(t.filter&&"none"!==t.filter)return!0;const o=t.willChange;if(o&&(o.includes("transform")||o.includes("opacity")))return!0;if("isolate"===t.isolation)return!0;const i=t.contain;return!(!i||!(i.includes("layout")||i.includes("style")||i.includes("paint")))}calculateGlobalZOrder(e){let t=e;const n=[];for(;t&&t!==document.body&&t.parentElement;){const e=window.getComputedStyle(t);if(this.isStackingContext(t)){let r=0;if("auto"!==e.zIndex){const t=parseInt(e.zIndex,10);isNaN(t)||(r=t)}let o=0;t.parentElement&&(o=Array.from(t.parentElement.children).indexOf(t)),n.push({element:t,zIndex:r,domOrder:o})}t=t.parentElement}let r=1e6;for(let o=n.length-1;o>=0;o--){const e=n[o];r+=1e4*e.zIndex+e.domOrder}if(e.parentElement){r+=Array.from(e.parentElement.children).indexOf(e)}return r}getSnapshotHtml(){this.indexInteractableElements();const e=document.documentElement.cloneNode(!0);for(const[n,r]of this.elementMap.entries())if(r instanceof HTMLElement){const o=this.selectorMap.get(n);if(o)try{const t=(e.querySelector("body")||e).querySelector(o);if(t)if(t.setAttribute("data-id",n.toString()),"none"===window.getComputedStyle(r).display)t.setAttribute("data-x","0"),t.setAttribute("data-y","0"),t.setAttribute("data-w","0"),t.setAttribute("data-h","0"),t.setAttribute("data-z","0");else{const e=this.getElementCoordinates(r);t.setAttribute("data-x",e.x.toString()),t.setAttribute("data-y",e.y.toString()),t.setAttribute("data-w",e.w.toString()),t.setAttribute("data-h",e.h.toString()),t.setAttribute("data-z",e.z.toString())}}catch(t){}}return e.outerHTML}getInteractableElements(){this.indexInteractableElements();const e=[];for(const[t,n]of this.elementMap.entries())if(n instanceof HTMLElement){const r=this.fingerprintMap.get(t);r&&e.push({index:t,fingerprint:r,coords:this.getElementCoordinates(n),cssClasses:Array.from(n.classList)})}return e}getSequenceForElement(e){return this.elementToSequence.get(e)}clearIndex(){this.elementMap.clear(),this.elementToSequence=/* @__PURE__ */new WeakMap,this.fingerprintMap.clear()}checkInteractability(e,t){if(!document.body.contains(e))return`ELEMENT_NOT_INTERACTABLE: Element ${t} is not in the DOM`;const n=window.getComputedStyle(e);if("none"===n.display)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has display:none`;if("hidden"===n.visibility)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has visibility:hidden`;if(0===parseFloat(n.opacity))return`ELEMENT_NOT_INTERACTABLE: Element ${t} has opacity:0`;const r=e.getBoundingClientRect();if(0===r.width||0===r.height)return`ELEMENT_NOT_INTERACTABLE: Element ${t} has zero dimensions`;if(r.bottom<0||r.top>window.innerHeight||r.right<0||r.left>window.innerWidth)return`ELEMENT_NOT_INTERACTABLE: Element ${t} is off-screen`;const o=r.left+r.width/2,i=r.top+r.height/2,s=document.elementFromPoint(o,i);if(s&&s!==e&&!e.contains(s)&&!(s.closest("#marketrix-show-highlight")||s.closest("#marketrix-show-popup")||s.closest("[data-marketrix-widget]"))){const e=s.tagName.toLowerCase();return`ELEMENT_OBSCURED: Element ${t} is covered by ${s.className?`${e}.${s.className.split(" ")[0]}`:e}. The obscuring element may be a modal or overlay that needs to be dismissed first.`}return null}checkElementInteractable(e,t){return this.checkInteractability(e,t)}getElementByIndex(e){let t=null;if(this.elementMap.has(e)){const n=this.elementMap.get(e);n&&n instanceof HTMLElement&&(t=n)}if(!t&&this.selectorMap.has(e)){const n=this.selectorMap.get(e);if(n)try{const e=document.querySelector(n);e&&e instanceof HTMLElement&&(t=e)}catch(r){}}if(!t)return{element:null,error:`Element ${e} not found`};const n=this.checkInteractability(t,e);return n?{element:null,error:n}:{element:t}}getValidatedElement(e){const t=this.validateElementAtIndex(e);if(!t.isValid)return{element:null,validation:t,error:`DOM_CHANGED: Element at index ${e} ${"element_removed"===t.mismatchReason?"no longer exists":"has changed"}. Call get_html to get updated indices.`};const n=this.elementMap.get(e);if(!n)return{element:null,validation:t,error:`Element ${e} not found`};const r=this.checkInteractability(n,e);return r?{element:null,validation:t,error:r}:{element:n,validation:t}}}.getInstance(),qs=null;async function Vs(){if(qs?.active){const e=qs.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return qs}const e=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!1,preferCurrentTab:!0});if(!e||0===e.getVideoTracks().length)throw new Error("Screen sharing permission denied or no video track available");return qs=e,e.getVideoTracks()[0].addEventListener("ended",()=>{qs=null}),e}function Zs(){return null!==function(){if(qs?.active){const e=qs.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return qs}return qs=null,null}()}var Gs=class e{static instance;currentPopup=null;currentHighlight=null;currentElement=null;currentOptions=null;currentPromise=null;resolvePromise=null;rejectPromise=null;clickHandler=null;scrollHandler=null;updateHighlightPosition=null;rafId=null;mutationObserver=null;visibilityCheckInterval=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}async showToolAction(e){const{element:t,explanation:n,isClickAction:r=!1,browserToolName:o}=e;return this.currentOptions?.element===t&&this.currentOptions.explanation===n&&this.currentOptions.browserToolName===o&&this.currentPromise||(this.cleanup(),this.currentOptions=e,this.currentElement=t,t.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),this.createHighlight(t),this.createPopup(n,r),this.setupPositionUpdates(),this.setupElementMonitoring(),this.setupVisibilityMonitoring(),r&&this.setupClickHandler(),this.currentPromise=new Promise((e,t)=>{this.resolvePromise=e,this.rejectPromise=t}).finally(()=>{this.cleanup()})),this.currentPromise}cleanup(){this.rejectPromise&&(this.rejectPromise("Cancelled by cleanup"),this.rejectPromise=null),this.resolvePromise=null,this.clickHandler&&(document.removeEventListener("click",this.clickHandler,{capture:!0}),this.clickHandler=null),this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler,{capture:!0}),window.removeEventListener("resize",this.scrollHandler),window.removeEventListener("touchmove",this.scrollHandler),window.removeEventListener("wheel",this.scrollHandler),this.scrollHandler=null),null!==this.rafId&&(window.cancelAnimationFrame(this.rafId),this.rafId=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.visibilityCheckInterval&&(clearInterval(this.visibilityCheckInterval),this.visibilityCheckInterval=null),this.updateHighlightPosition=null,this.currentPopup&&(this.currentPopup.remove(),this.currentPopup=null),this.currentHighlight&&(this.currentHighlight.remove(),this.currentHighlight=null);const e=document.getElementById("marketrix-show-popup");e&&e.remove();const t=document.getElementById("marketrix-show-highlight");t&&t.remove(),this.currentElement=null,this.currentOptions=null,this.currentPromise=null,this.resolvePromise=null,this.rejectPromise=null}createHighlight(e){const t=e.getBoundingClientRect(),n=document.createElement("div");n.id="marketrix-show-highlight",n.style.cssText=`\n position: fixed;\n top: ${t.top}px;\n left: ${t.left}px;\n width: ${t.width}px;\n height: ${t.height}px;\n border: 3px solid #3b82f6;\n border-radius: 4px;\n box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2), 0 0 20px rgba(59, 130, 246, 0.4);\n z-index: 2147483645;\n pointer-events: none;\n transition: none;\n `,document.body.appendChild(n),this.currentHighlight=n}createPopup(e,t){const n=document.createElement("div");n.id="marketrix-show-popup",n.innerHTML=t?`<div style="font-weight: 500; color: #1f2937; font-size: 12px;">${this.escapeHtml(e)}</div>`:`<div style="margin-bottom: 12px; font-weight: 500; color: #1f2937; font-size: 12px;">${this.escapeHtml(e)}</div>\n <div style="display: flex; gap: 8px; justify-content: flex-end;">\n <button id="marketrix-show-continue" style="\n background: #3b82f6; color: white; border: none; border-radius: 6px;\n padding: 8px 16px; font-size: 12px; font-weight: 500; cursor: pointer;\n ">Continue</button>\n </div>`,document.body.appendChild(n),this.currentPopup=n,t||this.setupContinueButton(n),this.updatePopupPosition()}setupPositionUpdates(){this.updateHighlightPosition=()=>{if(!this.currentElement||!this.currentHighlight)return;const e=this.currentElement.getBoundingClientRect();this.currentHighlight.style.top=`${e.top}px`,this.currentHighlight.style.left=`${e.left}px`,this.currentHighlight.style.width=`${e.width}px`,this.currentHighlight.style.height=`${e.height}px`,this.updatePopupPosition()},this.scrollHandler=()=>{null!==this.rafId&&window.cancelAnimationFrame(this.rafId),this.updateHighlightPosition?.()},window.addEventListener("scroll",this.scrollHandler,{capture:!0,passive:!0}),window.addEventListener("resize",this.scrollHandler,{passive:!0}),window.addEventListener("touchmove",this.scrollHandler,{passive:!0}),window.addEventListener("wheel",this.scrollHandler,{passive:!0})}updatePopupPosition(){if(!this.currentPopup||!this.currentElement)return;const e=this.currentElement.getBoundingClientRect(),t=320,n=120,r=10,o=e.left+e.width/2,i=e.top+e.height/2,s=[{left:e.right+20,top:i-60},{left:e.left-t-20,top:i-60},{left:o-160,top:e.top-n-20},{left:o-160,top:e.bottom+20}];let a=s[0];for(const d of s)if(d.left>=r&&d.left+t<=window.innerWidth-r&&d.top>=r&&d.top+n<=window.innerHeight-r){a=d;break}const c=Math.max(r,Math.min(a.left,window.innerWidth-t-r)),l=Math.max(r,Math.min(a.top,window.innerHeight-n-r));this.currentPopup.style.cssText+=`\n position: fixed;\n top: ${l}px;\n left: ${c}px;\n width: 320px;\n background: white;\n border-radius: 8px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n z-index: 2147483646;\n padding: 16px;\n `}setupClickHandler(){this.clickHandler=e=>{if(this.currentElement&&this.resolvePromise&&e.composedPath().includes(this.currentElement)){e.preventDefault(),e.stopPropagation();const t=this.resolvePromise;this.resolvePromise=null,this.rejectPromise=null,t(!0)}},document.addEventListener("click",this.clickHandler,{capture:!0})}setupContinueButton(e){window.requestAnimationFrame(()=>{const t=e.querySelector("#marketrix-show-continue");t&&t.addEventListener("click",e=>{if(e.stopPropagation(),this.resolvePromise){const e=this.resolvePromise;this.resolvePromise=null,this.rejectPromise=null,e(!0)}})})}setupElementMonitoring(){this.currentElement&&(this.mutationObserver=new MutationObserver(()=>{this.currentElement&&!document.body.contains(this.currentElement)&&this.failWithElementGone("Element was removed from DOM")}),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}setupVisibilityMonitoring(){this.visibilityCheckInterval=setInterval(()=>{if(!this.currentElement)return;const e=Hs.getSequenceForElement(this.currentElement)??-1,t=Hs.checkElementInteractable(this.currentElement,e);t&&this.failWithElementGone(t)},200)}failWithElementGone(e){if(this.rejectPromise){const t=this.rejectPromise;this.rejectPromise=null,this.resolvePromise=null,t(/* @__PURE__ */new Error(`ELEMENT_GONE: ${e}`))}this.cleanup()}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}}.getInstance(),Ys=class e{static instance;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}async executeTool(e,t,n="do",r=""){try{if("show"===n&&this.requiresHighlight(e)){const n=t.index;if(void 0!==n){const{element:t,error:o}=Hs.getElementByIndex(n);if(!t)return{success:!1,data:{text:""},error:o||`Element ${n} not found`};if(!(await Gs.showToolAction({element:t,explanation:r||`Execute ${e}`,browserToolName:e,isClickAction:"click_element"===e})))return{success:!1,data:{text:""},error:"User cancelled action"}}}switch(e){case"navigate":return this.navigate(t);case"search":return this.search(t);case"click_element":return await this.clickElement(t);case"type_text":return this.typeText(t);case"scroll":return this.scroll(t);case"scroll_to_text":return this.scrollToText(t);case"extract":return this.extract(t);case"go_back":return this.goBack();case"wait":return await this.wait(t);case"select_dropdown_option":return this.selectDropdownOption(t);case"get_dropdown_options":return this.getDropdownOptions(t);case"send_keys":return this.sendKeys(t);case"upload_file":return this.uploadFile(t);case"close_tab":return this.closeTab();case"switch_tab":return this.switchTab(t);case"done":return this.done(t);case"get_html":return this.getHtml();case"get_interactable_elements":return this.getInteractableElements();case"get_screenshot":return await this.getScreenshot();default:return{success:!1,data:{text:""},error:`Unknown tool: ${e}`}}}catch(o){return Gs.cleanup(),{success:!1,data:{text:""},error:o instanceof Error?o.message:String(o)}}}requiresHighlight(e){return Cs.has(e)}navigate(e){return e.url?e.new_tab?(window.open(e.url,"_blank"),{success:!0,data:{text:`Opened ${e.url} in new tab`}}):(window.location.href=e.url,{success:!0,data:{text:`Navigating to ${e.url}`}}):{success:!1,data:{text:""},error:"URL is required"}}search(e){if(!e.query)return{success:!1,data:{text:""},error:"Query is required"};const t=e.engine||"duckduckgo",n=encodeURIComponent(e.query);let r=`https://duckduckgo.com/?q=${n}`;return"google"===t&&(r=`https://www.google.com/search?q=${n}`),"bing"===t&&(r=`https://www.bing.com/search?q=${n}`),window.location.href=r,{success:!0,data:{text:`Searching for "${e.query}" on ${t}`}}}async clickElement(e){if(void 0===e.index)return{success:!1,data:{text:""},error:"Index required"};const{element:t,error:n}=Hs.getValidatedElement(e.index);return t?(t.scrollIntoView({behavior:"smooth",block:"center"}),await new Promise(e=>setTimeout(e,100)),setTimeout(()=>{try{t.click()}catch(e){try{t.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}))}catch(n){}}},50),{success:!0,data:{text:`Clicked element ${e.index}`}}):{success:!1,data:{text:""},error:n||`Element ${e.index} not found`}}typeText(e){if(void 0===e.index||void 0===e.text)return{success:!1,data:{text:""},error:"Index and text required"};const t=!1!==e.clear,{element:n,error:r}=Hs.getValidatedElement(e.index);if(!n)return{success:!1,data:{text:""},error:r||`Element ${e.index} not found`};if(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n.isContentEditable){const r=n;try{r.focus()}catch(o){}const i=t?e.text:r.value+e.text;let s=!1,a=null;if(!s)try{const e="TEXTAREA"===r.tagName.toUpperCase()?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,t=Object.getOwnPropertyDescriptor(e,"value");t?.set&&(t.set.call(r,i),s=!0)}catch(o){a=o}if(!s)try{r.value=i,s=!0}catch(o){a=o}if(!s)try{r.focus(),t&&r.select(),document.execCommand("insertText",!1,e.text)&&(s=!0)}catch(o){a=o}if(!s)try{r.focus(),t&&(r.value="");for(const t of e.text)r.dispatchEvent(new KeyboardEvent("keydown",{key:t,bubbles:!0,cancelable:!0})),r.value+=t,r.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t})),r.dispatchEvent(new KeyboardEvent("keyup",{key:t,bubbles:!0,cancelable:!0}));s=!0}catch(o){a=o}if(!s)return{success:!1,data:{text:""},error:`Failed to set value: ${a instanceof Error?a.message:String(a)}`};try{const t=new InputEvent("input",{bubbles:!0,cancelable:!0,inputType:"insertText",data:e.text});r.dispatchEvent(t),r.dispatchEvent(new Event("change",{bubbles:!0})),r.dispatchEvent(new Event("blur",{bubbles:!0}))}catch(o){}}else if("value"in n)try{n.value=e.text,n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0}))}catch(o){return{success:!1,data:{text:""},error:`Failed to set value on element: ${o instanceof Error?o.message:String(o)}`}}else try{n.textContent=e.text,n.dispatchEvent(new Event("input",{bubbles:!0}))}catch(o){return{success:!1,data:{text:""},error:`Failed to set textContent: ${o instanceof Error?o.message:String(o)}`}}return{success:!0,data:{text:`Typed text into element ${e.index}`}}}scroll(e){const t=.8*window.innerHeight;switch(e.direction){case"down":window.scrollBy({top:t,behavior:"smooth"});break;case"up":window.scrollBy({top:-t,behavior:"smooth"});break;case"left":window.scrollBy({left:-t,behavior:"smooth"});break;case"right":window.scrollBy({left:t,behavior:"smooth"});break;default:return{success:!1,data:{text:""},error:"Invalid direction"}}return{success:!0,data:{text:`Scrolled ${e.direction}`}}}scrollToText(e){if(!e.text)return{success:!1,data:{text:""},error:"Text required"};const t=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT);let n;for(;n=t.nextNode();)if(n.textContent?.includes(e.text)&&n.parentElement)return n.parentElement.scrollIntoView({behavior:"smooth",block:"center"}),{success:!0,data:{text:`Scrolled to "${e.text}"`}};return{success:!1,data:{text:""},error:`Text "${e.text}" not found`}}extract(e){const t=e.start_from_char??0,n=!1!==e.extract_links,r=document.body.innerText;return{success:!0,data:{title:document.title,url:window.location.href,text:r.slice(t,t+1e4),links:n?Array.from(document.querySelectorAll("a[href]")).slice(0,100).map(e=>({text:e.textContent?.trim()||"",href:e.getAttribute("href")})):[]}}}goBack(){return window.history.length>1?(window.history.back(),{success:!0,data:{text:"Navigated back"}}):{success:!1,data:{text:""},error:"No history"}}async wait(e){return void 0===e.seconds?{success:!1,data:{text:""},error:"Seconds required"}:(await new Promise(t=>setTimeout(t,1e3*e.seconds)),{success:!0,data:{text:`Waited ${e.seconds}s`}})}selectDropdownOption(e){if(void 0===e.index||!e.option)return{success:!1,data:{text:""},error:"Index/Option required"};const{element:t,error:n}=Hs.getValidatedElement(e.index);if(!t)return{success:!1,data:{text:""},error:n||`Select ${e.index} not found`};if(!(t instanceof HTMLSelectElement))return{success:!1,data:{text:""},error:`Element ${e.index} is not a select element`};const r=Array.from(t.options).find(t=>t.value===e.option||t.text===e.option);return r?(t.value=r.value,t.dispatchEvent(new Event("change",{bubbles:!0})),{success:!0,data:{text:`Selected ${e.option}`}}):{success:!1,data:{text:""},error:`Option ${e.option} not found`}}getDropdownOptions(e){const t=e.index,{element:n,error:r}=Hs.getValidatedElement(t);return n?n instanceof HTMLSelectElement?{success:!0,data:{options:Array.from(n.options).map(e=>({value:e.value,text:e.text}))}}:{success:!1,data:{options:[]},error:`Element ${t} is not a select element`}:{success:!1,data:{options:[]},error:r||`Select ${t} not found`}}sendKeys(e){if(void 0===e.index||!e.keys)return{success:!1,data:{text:""},error:"Index/Keys required"};const{element:t,error:n}=Hs.getValidatedElement(e.index);return t?(t.focus(),t.dispatchEvent(new KeyboardEvent("keydown",{key:e.keys,bubbles:!0,cancelable:!0})),t.dispatchEvent(new KeyboardEvent("keyup",{key:e.keys,bubbles:!0,cancelable:!0})),{success:!0,data:{text:this.simulateKeyAction(t,e.keys)||`Sent keys ${e.keys}`}}):{success:!1,data:{text:""},error:n||`Element ${e.index} not found`}}simulateKeyAction(e,t){switch(t){case"Tab":{const t=Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent),n=t.indexOf(e);if(-1!==n&&n<t.length-1){const e=t[n+1];return e.focus(),`Tab: moved focus to ${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}`}return"Tab: no next focusable element"}case"Shift+Tab":{const t=Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent),n=t.indexOf(e);if(n>0){const e=t[n-1];return e.focus(),`Shift+Tab: moved focus to ${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}`}return"Shift+Tab: no previous focusable element"}case"Enter":if(e instanceof HTMLButtonElement||"button"===e.getAttribute("role"))return e.click(),"Enter: clicked button";if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.closest("form");if(t){const e=t.querySelector('button[type="submit"], input[type="submit"]');return e?(e.click(),"Enter: clicked form submit button"):(t.requestSubmit(),"Enter: submitted form")}}return e instanceof HTMLAnchorElement?(e.click(),"Enter: clicked link"):"Enter: dispatched event";case"Escape":return e.blur(),document.dispatchEvent(new KeyboardEvent("keydown",{key:"Escape",bubbles:!0,cancelable:!0})),"Escape: blurred element and dispatched to document";case" ":case"Space":return e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type)?(e.click(),`Space: toggled ${e.type}`):e instanceof HTMLButtonElement||"button"===e.getAttribute("role")?(e.click(),"Space: clicked button"):"Space: dispatched event";case"ArrowDown":if(e instanceof HTMLSelectElement){const t=e.selectedIndex;return t<e.options.length-1?(e.selectedIndex=t+1,e.dispatchEvent(new Event("change",{bubbles:!0})),`ArrowDown: selected "${e.options[e.selectedIndex].text}"`):"ArrowDown: already at last option"}return"ArrowDown: dispatched event";case"ArrowUp":if(e instanceof HTMLSelectElement){const t=e.selectedIndex;return t>0?(e.selectedIndex=t-1,e.dispatchEvent(new Event("change",{bubbles:!0})),`ArrowUp: selected "${e.options[e.selectedIndex].text}"`):"ArrowUp: already at first option"}return"ArrowUp: dispatched event";case"Home":return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?(e.setSelectionRange(0,0),"Home: moved cursor to start"):"Home: dispatched event";case"End":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.value.length;return e.setSelectionRange(t,t),"End: moved cursor to end"}return"End: dispatched event";case"Backspace":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.value;if(!t||0===t.length)return"Backspace: input is empty, nothing to delete";let n,r,o=e.selectionStart??t.length,i=e.selectionEnd??t.length;if(0===o&&0===i&&(o=t.length,i=t.length),o===i&&o>0)n=t.slice(0,o-1)+t.slice(i),r=o-1;else{if(o===i)return"Backspace: cursor at start, nothing to delete";n=t.slice(0,o)+t.slice(i),r=o}const s=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return s?s.call(e,n):e.value=n,e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.setSelectionRange(r,r),`Backspace: deleted character, value is now "${n}"`}return"Backspace: dispatched event";case"Delete":if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const t=e.selectionStart||0,n=e.selectionEnd||0,r=e.value;let o;if(t===n&&t<r.length)o=r.slice(0,t)+r.slice(n+1);else{if(t===n)return"Delete: cursor at end, nothing to delete";o=r.slice(0,t)+r.slice(n)}const i=Object.getOwnPropertyDescriptor(e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,"value")?.set;return i?i.call(e,o):e.value=o,e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.setSelectionRange(t,t),`Delete: deleted character, value is now "${o}"`}return"Delete: dispatched event";default:return null}}uploadFile(e){return{success:!1,data:{text:""},error:"File upload not supported via script"}}closeTab(){return window.close(),{success:!0,data:{text:"Attempted close"}}}switchTab(e){return e.tab_id?{success:!1,data:{text:""},error:"Tab switching not supported"}:{success:!1,data:{text:""},error:"tab_id is required"}}done(e){return void 0===e.success?{success:!1,data:{text:""},error:"success parameter is required"}:{success:!0,data:{text:e.message||(e.success?"Task completed":"Task failed")}}}getHtml(){try{return{success:!0,data:{text:Hs.getSnapshotHtml()}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}getInteractableElements(){try{return{success:!0,data:{elements:Hs.getInteractableElements()}}}catch(e){return{success:!1,data:{elements:[]},error:String(e)}}}async getScreenshot(){try{const e=await Vs();if(!e)return{success:!1,data:{text:""},error:"Failed to get stream"};const t=document.createElement("video");t.srcObject=e,t.autoplay=!0,t.style.display="none",document.body.appendChild(t),await new Promise(e=>{t.onloadeddata=()=>e()});const n=document.createElement("canvas");n.width=t.videoWidth,n.height=t.videoHeight,n.getContext("2d")?.drawImage(t,0,0);const r=n.toDataURL("image/jpeg",.75);return t.remove(),{success:!0,data:{text:r}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}}.getInstance(),Js=class e{static instance;config=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadConfig(){const e=Os.getConfig();return e?(this.config=e,e):(this.config={},this.config)}saveConfig(e){Os.setConfig(e),this.config=e}updateConfig(e){this.config||(this.config={}),this.config={...this.config,...e},this.saveConfig(this.config)}getConfig(){return this.config}shouldShowWidget(){return!!this.config&&(this.config.widget_enabled??!1)}}.getInstance();function Ks(e,t={}){return{...t,...e}}var Xs=e=>({state:e,effects:[]});function Qs(e,t,n,r,o,i,s){const a=function(e){return Ts[e]?Ts[e]:e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}(r),c=ks({messages:e,isTaskRunning:t,currentMode:n,requireContent:"failed"===i});if(!c)return e;let l=c.message;const d=t&&"show"===n&&Cs.has(r),u="done"===r,p="show"===n||"do"===n;"in_progress"===i?(u||(l=function(e,t,n){const r=Ss(e),o=r.parts||[],i=[...o],s=o.findIndex(e=>"progress"===e.type&&e.browserToolName===t&&"in_progress"===e.status),a=!_s.has(t),c="default",l=Is(n);return s>=0?i[s]={...i[s],content:l,hideIcon:a,textStyle:c}:i.push({type:"progress",content:l,status:"in_progress",browserToolName:t,hideIcon:a,textStyle:c}),{...r,parts:i}}(l,a,o||a)),t&&p&&(l=Es(l,t,n,d))):"completed"===i?(u||(l=function(e,t){const n=Ss(e),r=n.parts||[],o=[...r];let i=-1;if(t)i=r.map(e=>"progress"===e.type?e.browserToolName:"").lastIndexOf(t);else for(let s=r.length-1;s>=0;s--)if("progress"===r[s].type&&"in_progress"===r[s].status){i=s;break}return i>=0&&(o[i]={...o[i],status:"completed"}),{...n,parts:o}}(l)),t&&p&&(l=Es(l,t,n,!1))):(l=function(e,t,n){const r=Ss(e),o=r.parts||[],i=n.toLowerCase().includes("cancelled by cleanup"),s=[...o];let a=o.map(e=>"progress"===e.type?e.browserToolName:"").lastIndexOf(t);if(-1===a)for(let c=o.length-1;c>=0;c--)if("progress"===o[c].type&&"in_progress"===o[c].status){a=c;break}if(a>=0)if(i){const e=Is(s[a].content);s[a]={...s[a],status:"completed",content:e}}else{const e=Is(n),t=Is(s[a].content);s[a]={...s[a],status:"failed",content:e?`${t} (${e})`:t}}return{...r,parts:s}}(l,a,s||""),t&&p&&(l=Es(l,t,n,!1)));const h=[...e];return h[c.index]=l,h}function ea(e,t,n,r,o,i){return{...e,messages:Qs(e.messages,e.task.isTaskRunning,o,t,n,r,i)}}var ta=n(void 0),na={activeTaskId:null,isTaskRunning:!1},ra=({children:e,previewMode:t=!1,currentMode:n,uiActions:r,initialMessages:o,initialTask:s})=>{const[c,p]=u(()=>({messages:o??[],task:s??na})),h=d(c),f=d(n);f.current=n;const g=d(/* @__PURE__ */new Set),y=d({}),b=i(e=>{const t=h.current,n=e(t);n===t||n.messages===t.messages&&n.task===t.task||(h.current=n,p(n))},[]),w=i(e=>{b(t=>({...t,messages:[...t.messages,e]}))},[b]),v=i((e,t)=>{b(n=>({...n,messages:n.messages.map(n=>n.id===e?{...n,...t}:n)}))},[b]),x=i(e=>{b(t=>({...t,messages:t.messages.filter(t=>t.id!==e)}))},[b]),k=i(e=>{b(t=>({...t,messages:e}))},[b]),S=i(()=>{b(e=>({...e,messages:[]}))},[b]),_=i(e=>{b(t=>({...t,task:{activeTaskId:e.activeTaskId,isTaskRunning:e.isTaskRunning}}))},[b]),C=i(async(e,n,o,i,s)=>{const a=n??f.current;if(t)return s||w(As(e,a)),void w(Ns("This is a preview. In production, I'll respond to your messages here."));let c=Js.getConfig();if(c||(c=Js.loadConfig()),!c||!c.mtxId&&!c.mtxKey&&!c.mtxApp)return void w(Ns("Configuration error: Missing API credentials. Please check your widget settings."));s||w(As(e,a));const l=`temp-${globalThis.crypto.randomUUID()}`,d={id:l,content:vs(""),sender:"agent",timestamp:/* @__PURE__ */new Date,mode:a,isPlaceholder:!0,placeholderState:"thinking",parts:[]};w(d),r.setLoading(!0);const u=o?{...c,mtxApp:o}:c;try{const t=Us();if(t){const e=js.getInstance();if(!e.isConnected()){const n=Js.getConfig();try{await e.connect(t,n?{mtxId:n.mtxId,mtxKey:n.mtxKey,mtxApp:n.mtxApp}:void 0)}catch(p){}}}await async function(e,t){if(!(await Fs.getOrCreateChatId()))throw new Error("Failed to initialize chat session");const n=t.mode||"tell";if(t.message&&await Ws(e,t.message,n),!e.mtxId||!e.mtxKey)throw new Error("mtxId + mtxKey is required");const r={type:`chat/${n}`,request_id:t.requestId||`req_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,content:t.message||""};js.getInstance().send(r)}(u,{message:e,mode:a,requestId:l})}catch(h){b(e=>{const t="I'm sorry, I encountered an error processing your request. Please try again.",n=e.messages.map(e=>{if(e.id!==l)return e;const n=[...e.parts??[],{type:"text",content:t}];return{...e,isPlaceholder:!1,parts:n,content:t}});return{...e,messages:n}})}finally{r.setLoading(!1)}},[t,w,b,r]),I=i(e=>{if(g.current.add(e),g.current.size>1e3){const e=Array.from(g.current);g.current=new Set(e.slice(-500))}},[]),E=i(()=>{const e=y.current;if(e.apiTaskId&&e.agentRunning){const t=e.apiTaskId;y.current={},b(e=>({...e,task:{isTaskRunning:!0,activeTaskId:t}}))}},[b]);a(()=>{if(t)return;const e=js.getInstance(),n=async t=>{const{toolCallId:n,tool:r,args:o,mode:i,explanation:s}=t,a=await Ys.executeTool(r,o,i,s);if(a.success)try{e.send({type:"tool/response",tool_call_id:n,success:!0,data:"string"==typeof a.data?a.data:JSON.stringify(a.data)}).catch(e=>{}),b(e=>ea(e,r,s,"completed",f.current)),"done"===r&&(y.current={},b(e=>function(e,t){const n=ks({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:t,requireContent:!1}),r=[...e.messages];if(n){const e=(n.message.parts??[]).filter(e=>!("progress"===e.type&&"done"===e.browserToolName));r[n.index]={...n.message,taskStatus:"done",parts:e}}return{messages:r,task:{isTaskRunning:!1,activeTaskId:null}}}(e,f.current)))}catch(c){b(e=>ea(e,r,s,"failed",f.current,"Connection error"))}else b(e=>ea(e,r,s,"failed",f.current,a.error||"Tool execution failed")),e.send({type:"tool/response",tool_call_id:n,success:!1,data:"string"==typeof a.data?a.data:JSON.stringify(a.data),error:a.error??void 0}).catch(e=>{})},o={onStatusChange:e=>{r.setAgentAvailable("registered"===e)},onMessage:async t=>{if("tool/call"===t.type){const n=t.tool_call_id;if(g.current.has(n))return;if(I(n),!bs.map(e=>e.id).includes(t.browser_tool))return void e.send({type:"tool/response",tool_call_id:n,success:!1,error:`Unknown tool: ${t.browser_tool}`}).catch(e=>{});h.current.task.isTaskRunning}else if("task/status"!==t.type||"completed"!==t.status&&"failed"!==t.status&&"stopped"!==t.status){if("task/status"===t.type&&"has_question"===t.status)y.current={};else if("task/status"===t.type&&"running"===t.status)return y.current={...y.current,agentRunning:!0,apiTaskId:y.current.apiTaskId||t.task_id||void 0},void E()}else g.current.clear(),y.current={};let o=[];b(e=>{const n=function(e,t,n){switch(t.type){case"tool/call":{const r=e.task.isTaskRunning?e.task:{...e.task,isTaskRunning:!0},o=r.isTaskRunning,i=t.mode||n||"do",s=t.explanation||"";return{state:{messages:Qs(e.messages,o,n,t.browser_tool,s,"in_progress"),task:r},effects:[{type:"executeTool",toolCallId:t.tool_call_id,tool:t.browser_tool,args:t.args,mode:i,explanation:s}]}}case"task/status":{const r=t.message||"";if("running"===t.status)return Xs(e);if("has_question"===t.status){const t=ks({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:n,requireContent:!1}),o=[...e.messages];if(t){const e=Es(t.message,!1,n);o[t.index]={...e,placeholderState:"waiting-for-user",...r&&{content:r}}}return{state:{messages:o,task:{isTaskRunning:!1,activeTaskId:null}},effects:[]}}const o=ks({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:n,requireContent:!1}),i=[...e.messages];if(o){let e="done";"failed"===t.status?e="failed":"stopped"===t.status&&(e="stopped"),i[o.index]={...o.message,taskStatus:e,...r&&{content:r}}}return{state:{messages:i,task:{isTaskRunning:!1,activeTaskId:null}},effects:[]}}case"chat/delta":{const n=e.messages.map(e=>{if(e.id!==t.request_id)return e;const n=[...e.parts??[]],r=n[n.length-1];let o;return"text"===r?.type&&r.streaming?(o=r.content+t.text,n[n.length-1]={...r,content:o}):(o=t.text,n.push({type:"text",content:o,streaming:!0})),{...e,content:o,isPlaceholder:!1,placeholderState:void 0,parts:n}});return{state:{...e,messages:n},effects:[]}}case"chat/response":{const n=e.messages.map(e=>{if(e.id!==t.request_id)return e;const n=[...e.parts??[]],r=n[n.length-1];return"text"===r?.type&&r.streaming?n[n.length-1]={type:"text",content:t.text}:n.push({type:"text",content:t.text}),{...e,content:t.text,isPlaceholder:!1,placeholderState:void 0,parts:n}}),r=[{type:"setLoading",value:!1}];return{state:{...e,messages:n},effects:r}}case"chat/error":{const n=e.messages.map(e=>{if(e.id!==t.request_id)return e;const n=`Error: ${t.error}`,r=[...e.parts??[],{type:"text",content:n}];return{...e,content:n,isPlaceholder:!1,placeholderState:void 0,parts:r}});return{state:{...e,messages:n},effects:[{type:"setLoading",value:!1}]}}default:return Xs(e)}}(e,t,f.current);return o=n.effects,n.state}),(e=>{for(const t of e)"setLoading"===t.type&&r.setLoading(t.value)})(o);const i=o.find(e=>"executeTool"===e.type);"executeTool"===i?.type&&await n(i)},onError:e=>{r.setError(e.message)}};return e.addCallbacks(o),()=>{e.removeCallbacks(o)}},[t,b,E,I,r]);const T=i(async()=>{const e=h.current.task.activeTaskId??void 0;b(e=>function(e,t){const n=ks({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:t,requireContent:!1}),r=[...e.messages];return n&&(r[n.index]={...n.message,taskStatus:"stopped"}),{messages:r,task:{isTaskRunning:!1,activeTaskId:null}}}(e,f.current)),t||js.getInstance().send({type:"chat/stop",...e&&{task_id:e}}).catch(e=>{})},[t,b]),M=l(()=>({addMessage:w,updateMessage:v,removeMessage:x,setMessages:k,clearMessages:S,messageDispatch:C}),[w,v,x,k,S,C]),z=l(()=>({setTaskState:_,stopTask:T}),[_,T]),O=l(()=>({messages:c.messages}),[c.messages]);/* @__PURE__ */
3
3
  return m(ta.Provider,{value:{chatState:O,chatActions:M,taskState:c.task,taskActions:z},children:e})},oa=()=>{const e=s(ta);if(!e)throw new Error("useChatContext must be used within ChatProvider");return e},ia=n(void 0),sa=({children:e,initialMode:t="tell",initialIsOpen:n=!1,initialIsMinimized:r=!1})=>{const[o,i]=u({isOpen:n,isMinimized:r,activeView:"home",currentMode:t,agentAvailable:!1,isLoading:!1}),s=l(()=>({setActiveView:e=>i(t=>({...t,activeView:e})),toggleWidget:()=>i(e=>({...e,isOpen:!e.isOpen,isMinimized:!!e.isOpen})),closeWidget:()=>i(e=>({...e,isOpen:!1,isMinimized:!0})),setMode:e=>i(t=>({...t,currentMode:e})),setLoading:e=>i(t=>({...t,isLoading:e})),setAgentAvailable:e=>i(t=>({...t,agentAvailable:e})),setError:e=>i(t=>({...t,error:e})),clearError:()=>i(e=>({...e,error:void 0})),applyState:e=>i(t=>({...t,...e}))}),[]);/* @__PURE__ */
4
4
  return m(ia.Provider,{value:{uiState:o,uiActions:s},children:e})},aa=()=>{const e=s(ia);if(!e)throw new Error("useUIStateContext must be used within UIStateProvider");return e};var ca=({config:e}={})=>{const{uiState:t,uiActions:n}=aa(),{chatState:r,chatActions:o,taskState:s,taskActions:c}=oa(),d=l(()=>({isOpen:t.isOpen,isMinimized:t.isMinimized,isLoading:t.isLoading,currentMode:t.currentMode,agentAvailable:t.agentAvailable,error:t.error,activeView:t.activeView,messages:r.messages,activeTaskId:s.activeTaskId,isTaskRunning:s.isTaskRunning}),[t,r,s]),u=i(()=>{o.clearMessages(),c.setTaskState({activeTaskId:null,isTaskRunning:!1}),n.setError(void 0)},[o,c,n]),p=l(()=>({setActiveView:n.setActiveView,toggleWidget:n.toggleWidget,closeWidget:n.closeWidget,setMode:n.setMode,setLoading:n.setLoading,setAgentAvailable:n.setAgentAvailable,setError:n.setError,clearError:n.clearError,setTaskState:c.setTaskState,stopTask:c.stopTask,addMessage:o.addMessage,updateMessage:o.updateMessage,removeMessage:o.removeMessage,setMessages:o.setMessages,messageDispatch:o.messageDispatch,clearChatHistory:u}),[n,c,o,u]),h=l(()=>e||Js.getConfig()||{},[e]),f=function(e){return Object.keys(ss.shape).every(t=>void 0!==e[t])}(h);a(()=>{f&&Js.saveConfig(h)},[h,f]);const m=h.isPreviewMode??!1;return{state:d,actions:p,config:h,shouldShow:f&&!0===h.widget_enabled,isPreviewMode:m,configValid:f}},la=(e=/* @__PURE__ */new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),da="-",ua=[],pa=e=>{const t=ma(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith("[")&&e.endsWith("]"))return fa(e);const n=e.split(da),r=""===n[0]&&n.length>1?1:0;return ha(n,r,t)},getConflictingClassGroupIds:(e,t)=>{if(t){const t=r[e],o=n[e];return t?o?((e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n})(o,t):t:o||ua}return n[e]||ua}}},ha=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const r=e[t],o=n.nextPart.get(r);if(o){const n=ha(e,t+1,o);if(n)return n}const i=n.validators;if(null===i)return;const s=0===t?e.join(da):e.slice(t).join(da),a=i.length;for(let c=0;c<a;c++){const e=i[c];if(e.validator(s))return e.classGroupId}},fa=e=>-1===e.slice(1,-1).indexOf(":")?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?"arbitrary.."+r:void 0})(),ma=e=>{const{theme:t,classGroups:n}=e;return ga(n,t)},ga=(e,t)=>{const n=la();for(const r in e){const o=e[r];ya(o,n,r,t)}return n},ya=(e,t,n,r)=>{const o=e.length;for(let i=0;i<o;i++){const o=e[i];ba(o,t,n,r)}},ba=(e,t,n,r)=>{"string"!=typeof e?"function"!=typeof e?xa(e,t,n,r):va(e,t,n,r):wa(e,t,n)},wa=(e,t,n)=>{(""===e?t:ka(t,e)).classGroupId=n},va=(e,t,n,r)=>{Sa(e)?ya(e(r),t,n,r):(null===t.validators&&(t.validators=[]),t.validators.push(((e,t)=>({classGroupId:e,validator:t}))(n,e)))},xa=(e,t,n,r)=>{const o=Object.entries(e),i=o.length;for(let s=0;s<i;s++){const[e,i]=o[s];ya(i,ka(t,e),n,r)}},ka=(e,t)=>{let n=e;const r=t.split(da),o=r.length;for(let i=0;i<o;i++){const e=r[i];let t=n.nextPart.get(e);t||(t=la(),n.nextPart.set(e,t)),n=t}return n},Sa=e=>"isThemeGetter"in e&&!0===e.isThemeGetter,_a=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const o=(o,i)=>{n[o]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];return void 0!==t?t:void 0!==(t=r[e])?(o(e,t),t):void 0},set(e,t){e in n?n[e]=t:o(e,t)}}},Ca=[],Ia=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),Ea=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=e=>{const t=[];let n,r=0,o=0,i=0;const s=e.length;for(let d=0;d<s;d++){const s=e[d];if(0===r&&0===o){if(":"===s){t.push(e.slice(i,d)),i=d+1;continue}if("/"===s){n=d;continue}}"["===s?r++:"]"===s?r--:"("===s?o++:")"===s&&o--}const a=0===t.length?e:e.slice(i);let c=a,l=!1;a.endsWith("!")?(c=a.slice(0,-1),l=!0):a.startsWith("!")&&(c=a.slice(1),l=!0);return Ia(t,l,c,n&&n>i?n-i:void 0)};if(t){const e=t+":",n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):Ia(Ca,!1,t,void 0,!0)}if(n){const e=r;r=t=>n({className:t,parseClassName:e})}return r},Ta=e=>{const t=/* @__PURE__ */new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{const n=[];let r=[];for(let o=0;o<e.length;o++){const i=e[o],s="["===i[0],a=t.has(i);s||a?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(i)):r.push(i)}return r.length>0&&(r.sort(),n.push(...r)),n}},Ma=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},za=/\s+/,Oa=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Oa(e[r]))&&(n&&(n+=" "),n+=t);return n},Ra=(e,...t)=>{let n,r,o,i;const s=e=>{const t=r(e);if(t)return t;const i=((e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:i,postfixLookupClassGroupIds:s}=t,a=[],c=e.trim().split(za);let l="";for(let d=c.length-1;d>=0;d-=1){const e=c[d],{isExternal:t,modifiers:u,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:f}=n(e);if(t){l=e+(l.length>0?" "+l:l);continue}let m,g=!!f;if(g){m=r(h.substring(0,f));const e=m&&s[m]?r(h):void 0;e&&e!==m&&(m=e,g=!1)}else m=r(h);if(!m){if(!g){l=e+(l.length>0?" "+l:l);continue}if(m=r(h),!m){l=e+(l.length>0?" "+l:l);continue}g=!1}const y=0===u.length?"":1===u.length?u[0]:i(u).join(":"),b=p?y+"!":y,w=b+m;if(a.indexOf(w)>-1)continue;a.push(w);const v=o(m,g);for(let n=0;n<v.length;++n){const e=v[n];a.push(b+e)}l=e+(l.length>0?" "+l:l)}return l})(e,n);return o(e,i),i};return i=a=>{const c=t.reduce((e,t)=>t(e),e());return n=(e=>({cache:_a(e.cacheSize),parseClassName:Ea(e),sortModifiers:Ta(e),postfixLookupClassGroupIds:Ma(e),...pa(e)}))(c),r=n.cache.get,o=n.cache.set,i=s,s(a)},(...e)=>i(((...e)=>{let t,n,r=0,o="";for(;r<e.length;)(t=e[r++])&&(n=Oa(t))&&(o&&(o+=" "),o+=n);return o})(...e))},Aa=[],Na=e=>{const t=t=>t[e]||Aa;return t.isThemeGetter=!0,t},Pa=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,La=/^\((?:(\w[\w-]*):)?(.+)\)$/i,$a=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Da=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Fa=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ja=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Ua=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Wa=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ba=e=>$a.test(e),Ha=e=>!!e&&!Number.isNaN(Number(e)),qa=e=>!!e&&Number.isInteger(Number(e)),Va=e=>e.endsWith("%")&&Ha(e.slice(0,-1)),Za=e=>Da.test(e),Ga=()=>!0,Ya=e=>Fa.test(e)&&!ja.test(e),Ja=()=>!1,Ka=e=>Ua.test(e),Xa=e=>Wa.test(e),Qa=e=>!nc(e)&&!dc(e),ec=e=>e.startsWith("@container")&&("/"===e[10]&&void 0!==e[11]||"s"===e[11]&&void 0!==e[16]&&e.startsWith("-size/",10)||"n"===e[11]&&void 0!==e[18]&&e.startsWith("-normal/",10)),tc=e=>bc(e,kc,Ja),nc=e=>Pa.test(e),rc=e=>bc(e,Sc,Ya),oc=e=>bc(e,_c,Ha),ic=e=>bc(e,Ic,Ga),sc=e=>bc(e,Cc,Ja),ac=e=>bc(e,vc,Ja),cc=e=>bc(e,xc,Xa),lc=e=>bc(e,Ec,Ka),dc=e=>La.test(e),uc=e=>wc(e,Sc),pc=e=>wc(e,Cc),hc=e=>wc(e,vc),fc=e=>wc(e,kc),mc=e=>wc(e,xc),gc=e=>wc(e,Ec,!0),yc=e=>wc(e,Ic,!0),bc=(e,t,n)=>{const r=Pa.exec(e);return!!r&&(r[1]?t(r[1]):n(r[2]))},wc=(e,t,n=!1)=>{const r=La.exec(e);return!!r&&(r[1]?t(r[1]):n)},vc=e=>"position"===e||"percentage"===e,xc=e=>"image"===e||"url"===e,kc=e=>"length"===e||"size"===e||"bg-size"===e,Sc=e=>"length"===e,_c=e=>"number"===e,Cc=e=>"family-name"===e,Ic=e=>"number"===e||"weight"===e,Ec=e=>"shadow"===e,Tc=/*#__PURE__*/Ra(()=>{const e=Na("color"),t=Na("font"),n=Na("text"),r=Na("font-weight"),o=Na("tracking"),i=Na("leading"),s=Na("breakpoint"),a=Na("container"),c=Na("spacing"),l=Na("radius"),d=Na("shadow"),u=Na("inset-shadow"),p=Na("text-shadow"),h=Na("drop-shadow"),f=Na("blur"),m=Na("perspective"),g=Na("aspect"),y=Na("ease"),b=Na("animate"),w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",dc,nc],v=()=>[dc,nc,c],x=()=>[Ba,"full","auto",...v()],k=()=>[qa,"none","subgrid",dc,nc],S=()=>["auto",{span:["full",qa,dc,nc]},qa,dc,nc],_=()=>[qa,"auto",dc,nc],C=()=>["auto","min","max","fr",dc,nc],I=()=>["auto",...v()],E=()=>[Ba,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],T=()=>[Ba,"screen","full","dvw","lvw","svw","min","max","fit",...v()],M=()=>[Ba,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],z=()=>[e,dc,nc],O=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",hc,ac,{position:[dc,nc]}],R=()=>["auto","cover","contain",fc,tc,{size:[dc,nc]}],A=()=>[Va,uc,rc],N=()=>["","none","full",l,dc,nc],P=()=>["",Ha,uc,rc],L=()=>[Ha,Va,hc,ac],$=()=>["","none",f,dc,nc],D=()=>["none",Ha,dc,nc],F=()=>["none",Ha,dc,nc],j=()=>[Ha,dc,nc],U=()=>[Ba,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Za],breakpoint:[Za],color:[Ga],container:[Za],"drop-shadow":[Za],ease:["in","out","in-out"],font:[Qa],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Za],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Za],shadow:[Za],spacing:["px",Ha],text:[Za],"text-shadow":[Za],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ba,nc,dc,g]}],container:["container"],"container-type":[{"@container":["","normal","size",dc,nc]}],"container-named":[ec],columns:[{columns:[Ha,nc,dc,a]}],"break-after":[{"break-after":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-before":[{"break-before":["auto","avoid","all","avoid-page","page","left","right","column"]}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:w()}],overflow:[{overflow:["auto","hidden","clip","visible","scroll"]}],"overflow-x":[{"overflow-x":["auto","hidden","clip","visible","scroll"]}],"overflow-y":[{"overflow-y":["auto","hidden","clip","visible","scroll"]}],overscroll:[{overscroll:["auto","contain","none"]}],"overscroll-x":[{"overscroll-x":["auto","contain","none"]}],"overscroll-y":[{"overscroll-y":["auto","contain","none"]}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:x()}],"inset-x":[{"inset-x":x()}],"inset-y":[{"inset-y":x()}],start:[{"inset-s":x(),start:x()}],end:[{"inset-e":x(),end:x()}],"inset-bs":[{"inset-bs":x()}],"inset-be":[{"inset-be":x()}],top:[{top:x()}],right:[{right:x()}],bottom:[{bottom:x()}],left:[{left:x()}],visibility:["visible","invisible","collapse"],z:[{z:[qa,"auto",dc,nc]}],basis:[{basis:[Ba,"full","auto",a,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ha,Ba,"auto","initial","none",nc]}],grow:[{grow:["",Ha,dc,nc]}],shrink:[{shrink:["",Ha,dc,nc]}],order:[{order:[qa,"first","last","none",dc,nc]}],"grid-cols":[{"grid-cols":k()}],"col-start-end":[{col:S()}],"col-start":[{"col-start":_()}],"col-end":[{"col-end":_()}],"grid-rows":[{"grid-rows":k()}],"row-start-end":[{row:S()}],"row-start":[{"row-start":_()}],"row-end":[{"row-end":_()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":C()}],"auto-rows":[{"auto-rows":C()}],gap:[{gap:v()}],"gap-x":[{"gap-x":v()}],"gap-y":[{"gap-y":v()}],"justify-content":[{justify:["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe","normal"]}],"justify-items":[{"justify-items":["start","end","center","stretch","center-safe","end-safe","normal"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],"align-content":[{content:["normal","start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"align-items":[{items:["start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"align-self":[{self:["auto","start","end","center","stretch","center-safe","end-safe",{baseline:["","last"]}]}],"place-content":[{"place-content":["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"]}],"place-items":[{"place-items":["start","end","center","stretch","center-safe","end-safe","baseline"]}],"place-self":[{"place-self":["auto","start","end","center","stretch","center-safe","end-safe"]}],p:[{p:v()}],px:[{px:v()}],py:[{py:v()}],ps:[{ps:v()}],pe:[{pe:v()}],pbs:[{pbs:v()}],pbe:[{pbe:v()}],pt:[{pt:v()}],pr:[{pr:v()}],pb:[{pb:v()}],pl:[{pl:v()}],m:[{m:I()}],mx:[{mx:I()}],my:[{my:I()}],ms:[{ms:I()}],me:[{me:I()}],mbs:[{mbs:I()}],mbe:[{mbe:I()}],mt:[{mt:I()}],mr:[{mr:I()}],mb:[{mb:I()}],ml:[{ml:I()}],"space-x":[{"space-x":v()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":v()}],"space-y-reverse":["space-y-reverse"],size:[{size:E()}],"inline-size":[{inline:["auto",...T()]}],"min-inline-size":[{"min-inline":["auto",...T()]}],"max-inline-size":[{"max-inline":["none",...T()]}],"block-size":[{block:["auto",...M()]}],"min-block-size":[{"min-block":["auto",...M()]}],"max-block-size":[{"max-block":["none",...M()]}],w:[{w:[a,"screen",...E()]}],"min-w":[{"min-w":[a,"screen","none",...E()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},...E()]}],h:[{h:["screen","lh",...E()]}],"min-h":[{"min-h":["screen","lh","none",...E()]}],"max-h":[{"max-h":["screen","lh",...E()]}],"font-size":[{text:["base",n,uc,rc]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,yc,ic]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Va,nc]}],"font-family":[{font:[pc,sc,t]}],"font-features":[{"font-features":[nc]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,dc,nc]}],"line-clamp":[{"line-clamp":[Ha,"none",dc,oc]}],leading:[{leading:[i,...v()]}],"list-image":[{"list-image":["none",dc,nc]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",dc,nc]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:z()}],"text-color":[{text:z()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:["solid","dashed","dotted","double","wavy"]}],"text-decoration-thickness":[{decoration:[Ha,"from-font","auto",dc,rc]}],"text-decoration-color":[{decoration:z()}],"underline-offset":[{"underline-offset":[Ha,"auto",dc,nc]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:v()}],"tab-size":[{tab:[qa,dc,nc]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",dc,nc]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",dc,nc]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:O()}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","space","round"]}]}],"bg-size":[{bg:R()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},qa,dc,nc],radial:["",dc,nc],conic:[qa,dc,nc]},mc,cc]}],"bg-color":[{bg:z()}],"gradient-from-pos":[{from:A()}],"gradient-via-pos":[{via:A()}],"gradient-to-pos":[{to:A()}],"gradient-from":[{from:z()}],"gradient-via":[{via:z()}],"gradient-to":[{to:z()}],rounded:[{rounded:N()}],"rounded-s":[{"rounded-s":N()}],"rounded-e":[{"rounded-e":N()}],"rounded-t":[{"rounded-t":N()}],"rounded-r":[{"rounded-r":N()}],"rounded-b":[{"rounded-b":N()}],"rounded-l":[{"rounded-l":N()}],"rounded-ss":[{"rounded-ss":N()}],"rounded-se":[{"rounded-se":N()}],"rounded-ee":[{"rounded-ee":N()}],"rounded-es":[{"rounded-es":N()}],"rounded-tl":[{"rounded-tl":N()}],"rounded-tr":[{"rounded-tr":N()}],"rounded-br":[{"rounded-br":N()}],"rounded-bl":[{"rounded-bl":N()}],"border-w":[{border:P()}],"border-w-x":[{"border-x":P()}],"border-w-y":[{"border-y":P()}],"border-w-s":[{"border-s":P()}],"border-w-e":[{"border-e":P()}],"border-w-bs":[{"border-bs":P()}],"border-w-be":[{"border-be":P()}],"border-w-t":[{"border-t":P()}],"border-w-r":[{"border-r":P()}],"border-w-b":[{"border-b":P()}],"border-w-l":[{"border-l":P()}],"divide-x":[{"divide-x":P()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":P()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:["solid","dashed","dotted","double","hidden","none"]}],"divide-style":[{divide:["solid","dashed","dotted","double","hidden","none"]}],"border-color":[{border:z()}],"border-color-x":[{"border-x":z()}],"border-color-y":[{"border-y":z()}],"border-color-s":[{"border-s":z()}],"border-color-e":[{"border-e":z()}],"border-color-bs":[{"border-bs":z()}],"border-color-be":[{"border-be":z()}],"border-color-t":[{"border-t":z()}],"border-color-r":[{"border-r":z()}],"border-color-b":[{"border-b":z()}],"border-color-l":[{"border-l":z()}],"divide-color":[{divide:z()}],"outline-style":[{outline:["solid","dashed","dotted","double","none","hidden"]}],"outline-offset":[{"outline-offset":[Ha,dc,nc]}],"outline-w":[{outline:["",Ha,uc,rc]}],"outline-color":[{outline:z()}],shadow:[{shadow:["","none",d,gc,lc]}],"shadow-color":[{shadow:z()}],"inset-shadow":[{"inset-shadow":["none",u,gc,lc]}],"inset-shadow-color":[{"inset-shadow":z()}],"ring-w":[{ring:P()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:z()}],"ring-offset-w":[{"ring-offset":[Ha,rc]}],"ring-offset-color":[{"ring-offset":z()}],"inset-ring-w":[{"inset-ring":P()}],"inset-ring-color":[{"inset-ring":z()}],"text-shadow":[{"text-shadow":["none",p,gc,lc]}],"text-shadow-color":[{"text-shadow":z()}],opacity:[{opacity:[Ha,dc,nc]}],"mix-blend":[{"mix-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"]}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ha]}],"mask-image-linear-from-pos":[{"mask-linear-from":L()}],"mask-image-linear-to-pos":[{"mask-linear-to":L()}],"mask-image-linear-from-color":[{"mask-linear-from":z()}],"mask-image-linear-to-color":[{"mask-linear-to":z()}],"mask-image-t-from-pos":[{"mask-t-from":L()}],"mask-image-t-to-pos":[{"mask-t-to":L()}],"mask-image-t-from-color":[{"mask-t-from":z()}],"mask-image-t-to-color":[{"mask-t-to":z()}],"mask-image-r-from-pos":[{"mask-r-from":L()}],"mask-image-r-to-pos":[{"mask-r-to":L()}],"mask-image-r-from-color":[{"mask-r-from":z()}],"mask-image-r-to-color":[{"mask-r-to":z()}],"mask-image-b-from-pos":[{"mask-b-from":L()}],"mask-image-b-to-pos":[{"mask-b-to":L()}],"mask-image-b-from-color":[{"mask-b-from":z()}],"mask-image-b-to-color":[{"mask-b-to":z()}],"mask-image-l-from-pos":[{"mask-l-from":L()}],"mask-image-l-to-pos":[{"mask-l-to":L()}],"mask-image-l-from-color":[{"mask-l-from":z()}],"mask-image-l-to-color":[{"mask-l-to":z()}],"mask-image-x-from-pos":[{"mask-x-from":L()}],"mask-image-x-to-pos":[{"mask-x-to":L()}],"mask-image-x-from-color":[{"mask-x-from":z()}],"mask-image-x-to-color":[{"mask-x-to":z()}],"mask-image-y-from-pos":[{"mask-y-from":L()}],"mask-image-y-to-pos":[{"mask-y-to":L()}],"mask-image-y-from-color":[{"mask-y-from":z()}],"mask-image-y-to-color":[{"mask-y-to":z()}],"mask-image-radial":[{"mask-radial":[dc,nc]}],"mask-image-radial-from-pos":[{"mask-radial-from":L()}],"mask-image-radial-to-pos":[{"mask-radial-to":L()}],"mask-image-radial-from-color":[{"mask-radial-from":z()}],"mask-image-radial-to-color":[{"mask-radial-to":z()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"]}],"mask-image-conic-pos":[{"mask-conic":[Ha]}],"mask-image-conic-from-pos":[{"mask-conic-from":L()}],"mask-image-conic-to-pos":[{"mask-conic-to":L()}],"mask-image-conic-from-color":[{"mask-conic-from":z()}],"mask-image-conic-to-color":[{"mask-conic-to":z()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:O()}],"mask-repeat":[{mask:["no-repeat",{repeat:["","x","y","space","round"]}]}],"mask-size":[{mask:R()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",dc,nc]}],filter:[{filter:["","none",dc,nc]}],blur:[{blur:$()}],brightness:[{brightness:[Ha,dc,nc]}],contrast:[{contrast:[Ha,dc,nc]}],"drop-shadow":[{"drop-shadow":["","none",h,gc,lc]}],"drop-shadow-color":[{"drop-shadow":z()}],grayscale:[{grayscale:["",Ha,dc,nc]}],"hue-rotate":[{"hue-rotate":[Ha,dc,nc]}],invert:[{invert:["",Ha,dc,nc]}],saturate:[{saturate:[Ha,dc,nc]}],sepia:[{sepia:["",Ha,dc,nc]}],"backdrop-filter":[{"backdrop-filter":["","none",dc,nc]}],"backdrop-blur":[{"backdrop-blur":$()}],"backdrop-brightness":[{"backdrop-brightness":[Ha,dc,nc]}],"backdrop-contrast":[{"backdrop-contrast":[Ha,dc,nc]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ha,dc,nc]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ha,dc,nc]}],"backdrop-invert":[{"backdrop-invert":["",Ha,dc,nc]}],"backdrop-opacity":[{"backdrop-opacity":[Ha,dc,nc]}],"backdrop-saturate":[{"backdrop-saturate":[Ha,dc,nc]}],"backdrop-sepia":[{"backdrop-sepia":["",Ha,dc,nc]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":v()}],"border-spacing-x":[{"border-spacing-x":v()}],"border-spacing-y":[{"border-spacing-y":v()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",dc,nc]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ha,"initial",dc,nc]}],ease:[{ease:["linear","initial",y,dc,nc]}],delay:[{delay:[Ha,dc,nc]}],animate:[{animate:["none",b,dc,nc]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,dc,nc]}],"perspective-origin":[{"perspective-origin":w()}],rotate:[{rotate:D()}],"rotate-x":[{"rotate-x":D()}],"rotate-y":[{"rotate-y":D()}],"rotate-z":[{"rotate-z":D()}],scale:[{scale:F()}],"scale-x":[{"scale-x":F()}],"scale-y":[{"scale-y":F()}],"scale-z":[{"scale-z":F()}],"scale-3d":["scale-3d"],skew:[{skew:j()}],"skew-x":[{"skew-x":j()}],"skew-y":[{"skew-y":j()}],transform:[{transform:[dc,nc,"","none","gpu","cpu"]}],"transform-origin":[{origin:w()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:U()}],"translate-x":[{"translate-x":U()}],"translate-y":[{"translate-y":U()}],"translate-z":[{"translate-z":U()}],"translate-none":["translate-none"],zoom:[{zoom:[qa,dc,nc]}],accent:[{accent:z()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:z()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",dc,nc]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":z()}],"scrollbar-track-color":[{"scrollbar-track":z()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":v()}],"scroll-mx":[{"scroll-mx":v()}],"scroll-my":[{"scroll-my":v()}],"scroll-ms":[{"scroll-ms":v()}],"scroll-me":[{"scroll-me":v()}],"scroll-mbs":[{"scroll-mbs":v()}],"scroll-mbe":[{"scroll-mbe":v()}],"scroll-mt":[{"scroll-mt":v()}],"scroll-mr":[{"scroll-mr":v()}],"scroll-mb":[{"scroll-mb":v()}],"scroll-ml":[{"scroll-ml":v()}],"scroll-p":[{"scroll-p":v()}],"scroll-px":[{"scroll-px":v()}],"scroll-py":[{"scroll-py":v()}],"scroll-ps":[{"scroll-ps":v()}],"scroll-pe":[{"scroll-pe":v()}],"scroll-pbs":[{"scroll-pbs":v()}],"scroll-pbe":[{"scroll-pbe":v()}],"scroll-pt":[{"scroll-pt":v()}],"scroll-pr":[{"scroll-pr":v()}],"scroll-pb":[{"scroll-pb":v()}],"scroll-pl":[{"scroll-pl":v()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",dc,nc]}],fill:[{fill:["none",...z()]}],"stroke-w":[{stroke:[Ha,uc,rc,oc]}],stroke:[{stroke:["none",...z()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function Mc(...e){return Tc(e.filter(Boolean).join(" "))}var zc={none:"none",card:"0 1px 4px rgba(0,0,0,0.1)",section:"0 2px 8px rgba(0,0,0,0.06)",panel:"0 12px 40px rgba(0,0,0,0.16), 0 4px 12px rgba(0,0,0,0.08)",fab:"0 2px 8px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.04)",button:"0 4px 6px -1px rgba(0,0,0,0.1)"},Oc={none:"rounded-none",sm:"rounded-sm",md:"rounded-md",lg:"rounded-lg",xl:"rounded-xl",theme:"rounded-[var(--radius)]",pill:"rounded-full",circle:"rounded-full"},Rc={default:"text-foreground",muted:"text-foreground-muted",faint:"text-foreground-faint",primary:"text-primary",success:"text-success",warning:"text-warning",inherit:"text-inherit"},Ac={tight:"leading-tight",snug:"leading-snug",normal:"leading-normal",relaxed:"leading-relaxed"},Nc={header:{height:40},tabBar:{height:48},launcher:{width:56,height:56},launcherCore:{width:48,height:48}},Pc={info:{background:"#f0f9ff",border:"1px solid #bae6fd",titleColor:"#0c4a6e",bodyColor:"#0369a1",closeColor:"#7dd3fc",closeHoverColor:"#38bdf8",actionBackground:"#e0f2fe"},error:{background:"#fef2f2",border:"1px solid #fecaca",titleColor:"#b91c1c",bodyColor:"#b91c1c",closeColor:"#f87171",closeHoverColor:"#ef4444",actionBackground:"#fee2e2"}};function Lc(e){if(e&&"none"!==e)return{boxShadow:zc[e]}}var $c={none:"0","2xs":"1",xs:"0.5",sm:"1.5",md:"2",lg:"3",xl:"4","2xl":"6"},Dc=/* @__PURE__ */new Set(["padding","paddingX","paddingY","paddingTop","paddingBottom","margin","marginX","marginY","marginTop","marginBottom","gap","align","justify","wrap","grow","shrink","position","inset","overflow","overflowY","width","height","minWidth","minHeight","border","rounded","shadow","cursor","opacity","animate","hidden","as","style"]);function Fc(e){const t=[];if(void 0!==e.padding&&t.push(`p-${$c[e.padding]}`),void 0!==e.paddingX&&t.push(`px-${$c[e.paddingX]}`),void 0!==e.paddingY&&t.push(`py-${$c[e.paddingY]}`),void 0!==e.paddingTop&&t.push(`pt-${$c[e.paddingTop]}`),void 0!==e.paddingBottom&&t.push(`pb-${$c[e.paddingBottom]}`),void 0!==e.margin&&t.push(`m-${$c[e.margin]}`),void 0!==e.marginX&&t.push(`mx-${$c[e.marginX]}`),void 0!==e.marginY&&t.push(`my-${$c[e.marginY]}`),void 0!==e.marginTop&&t.push(`mt-${$c[e.marginTop]}`),void 0!==e.marginBottom&&t.push(`mb-${$c[e.marginBottom]}`),void 0!==e.gap&&t.push(`gap-${$c[e.gap]}`),void 0!==e.align&&t.push(`items-${e.align}`),void 0!==e.justify&&t.push(`justify-${e.justify}`),!0===e.wrap&&t.push("flex-wrap"),!0===e.grow&&t.push("flex-1"),!1===e.shrink&&t.push("flex-shrink-0"),void 0!==e.position&&t.push(e.position),void 0!==e.inset&&t.push("0"===e.inset?"inset-0":`inset-${$c[e.inset]}`),void 0!==e.overflow&&t.push(`overflow-${e.overflow}`),void 0!==e.overflowY&&t.push(`overflow-y-${e.overflowY}`),void 0!==e.width&&t.push(`w-${e.width}`),void 0!==e.height&&t.push(`h-${e.height}`),"0"===e.minWidth&&t.push("min-w-0"),"0"===e.minHeight&&t.push("min-h-0"),void 0!==e.border&&!1!==e.border)if(!0===e.border)t.push("border","border-border");else{const n={top:"t",bottom:"b",left:"l",right:"r"}[e.border];t.push(`border-${n}`,"border-border")}if(void 0!==e.rounded&&!1!==e.rounded)if(!0===e.rounded)t.push(Oc.theme);else if("full"===e.rounded)t.push(Oc.pill);else{const n="lg"===e.rounded?"lg":e.rounded;t.push(Oc[n])}return!0!==e.shadow&&"theme"!==e.shadow||t.push("shadow-[var(--shadow)]"),void 0!==e.cursor&&t.push(`cursor-${e.cursor}`),void 0!==e.opacity&&t.push(`opacity-${e.opacity}`),void 0!==e.animate&&"none"!==e.animate&&t.push({spin:"animate-spin",ping:"animate-ping",pulse:"animate-pulse",fadeIn:"animate-fade-in"}[e.animate]),!0===e.hidden&&t.push("hidden"),t.join(" ")}function jc(e){const t={};for(const n in e)Dc.has(n)||(t[n]=e[n]);return t}var Uc={default:"",card:"bg-card text-card-foreground",transparent:"bg-transparent",muted:"bg-muted",secondary:"bg-secondary-bg",primary:"bg-primary text-primary-foreground"},Wc={none:"",compact:"px-2 py-1.5",card:"px-3 py-2",dialog:"p-4",toast:"py-2 pl-2 pr-3"},Bc=o(function(e,t){const{as:n="div",background:r="default",className:o,elevation:i,paddingPreset:s="none",radius:a,style:c,...l}=e,d=Fc(e);/* @__PURE__ */