@marketrix.ai/widget 3.8.425 → 3.8.427
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,5 +1,5 @@
|
|
|
1
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.13/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 D(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 $(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 D(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 D(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.13/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}},ie=/\r\n|\r(?!\n)|\n/,se=/(?:\r\n|\r(?!\n)|\n){2}/,ae=/(?:\r\n|\r(?!\n)|\n){2}/g;function ce(e){const t={data:void 0,event:void 0,id:void 0,retry:void 0,comments:[]};for(const n of e.split(ie)){if(""===n)continue;const e=n.indexOf(":"),r=-1===e?"":n.slice(32===n.charCodeAt(e+1)?e+2:e+1);if(0!==e)switch(-1===e?n:n.slice(0,e)){case"data":t.data=void 0===t.data?r:`${t.data}\n${r}`;break;case"event":t.event=r;break;case"id":t.id=r;break;case"retry":{const e=Number.parseInt(r,10);e>=0&&e.toString()===r&&(t.retry=e);break}}else t.comments.push(r)}return t}var le=class{constructor(e={}){this.options=e}pending=[];tail="";discardLeadingLF=!1;feed(e){if(""===e)return;if(this.discardLeadingLF&&(this.discardLeadingLF=!1,10===e.charCodeAt(0)&&""===(e=e.slice(1))))return;const t=this.tail+e;if(!se.test(t))return this.pending.push(e),void(this.tail=t.slice(-3));this.pending.push(e);const n=1===this.pending.length?e:this.pending.join(""),r=n.length-t.length,o=[];let i=0;for(const a of t.matchAll(ae))o.push(n.slice(i,r+a.index)),i=r+a.index+a[0].length;const s=n.slice(i);this.pending.length=0,this.tail=s.slice(-3),""===s?this.discardLeadingLF=13===e.charCodeAt(e.length-1):this.pending.push(s);for(const a of o){const e=ce(a);this.options.onEvent&&this.options.onEvent(e)}}end(){if(0!==this.pending.length)throw new re("Event Iterator ended before complete")}},de=class extends TransformStream{constructor(){let e;super({start(t){e=new le({onEvent:e=>{t.enqueue(e)}})},transform(t){e.feed(t)},flush(){e.end()}})}},ue=/\r\n|[\n\r]/,pe=/\r\n|[\n\r]/g;function he(e){return ue.test(e)}function fe(e){if(he(e))throw new ne("Event's id must not contain a carriage return or newline character")}function me(e){if(!Number.isInteger(e)||e<0)throw new ne("Event's retry must be a integer and >= 0")}function ge(e){if(he(e))throw new ne("Event's comment must not contain a carriage return or newline character")}function ye(e){let t="";var n;return t+=function(e){let t="";for(const n of e??[])ge(n),t+=`: ${n}\n`;return t}(e.comments),void 0!==e.event&&(!function(e){if(he(e))throw new ne("Event's event must not contain a carriage return or newline character")}(e.event),t+=`event: ${e.event}\n`),void 0!==e.retry&&(me(e.retry),t+=`retry: ${e.retry}\n`),void 0!==e.id&&(fe(e.id),t+=`id: ${e.id}\n`),t+=void 0===(n=e.data)?"":`data: ${n.replace(pe,"\ndata: ")}\n`,t+="\n",t}var be=Symbol("ORPC_EVENT_SOURCE_META");function we(e,t){if(void 0===t.id&&void 0===t.retry&&!t.comments?.length)return e;if(void 0!==t.id&&fe(t.id),void 0!==t.retry&&me(t.retry),void 0!==t.comments)for(const n of t.comments)ge(n);return new Proxy(e,{get:(e,n,r)=>n===be?t:Reflect.get(e,n,r)})}function ve(e){return V(e)?Reflect.get(e,be):void 0}function xe(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 ke(e,t){const n=async e=>{let n=await t.error(e);if(n!==e){const t=ve(e);t&&V(n)&&(n=we(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=ve(o);e&&V(i)&&(i=we(i,e))}return{done:r,value:i}},async()=>{try{await(e.return?.())}catch(t){throw await n(t)}})}function Se(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):Se(e,{...t,path:[...n,o]})}))}function _e(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=xe(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 de))?.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 D(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=we(e,t)),r?.addEvent("message"),{done:!1,value:e}}case"error":{let e=new oe({data:B(t.data)});throw e=we(e,t),r?.addEvent("error"),e}case"done":{let e=B(t.data);return V(e)&&(e=we(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 D(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 Ce(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:$(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(ye({comments:[s]}))},async pull(t){try{n&&(a=setInterval(()=>{t.enqueue(ye({comments:[o]})),c?.addEvent("keepalive")},r));const i=await D(c,()=>e.next());if(clearInterval(a),l)return;const s=ve(i.value);if(!i.done||void 0!==i.value||void 0!==s){const e=i.done?"done":"message";t.enqueue(ye({...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(ye({...ve(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 D(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 Ie(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 Ee(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=Ce(e.body,n,t);return new Request(e.url,{signal:e.signal,method:e.method,headers:n,body:r})}var Te=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)}},Me=class{constructor(e,t,n={}){this.codec=e,this.sender=t,new Te(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(".")),$(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 $(l)?U({name:"consume_event_iterator_output",signal:n.signal},l):l})))}},ze=0,Oe=1,Re=2,Ae=3,Ne=4,Pe=5,Le=6,De=7,$e=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([ze,...t]),[e.toString(),n,r,o];if(e instanceof Date)return n.push([Oe,...t]),Number.isNaN(e.getTime())?[null,n,r,o]:[e.toISOString(),n,r,o];if(Number.isNaN(e))return n.push([Re,...t]),[null,n,r,o];if(e instanceof URL)return n.push([Ne,...t]),[e.toString(),n,r,o];if(e instanceof RegExp)return n.push([Pe,...t]),[e.toString(),n,r,o];if(e instanceof Set){const i=this.serialize(Array.from(e),t,n,r,o);return n.push([Le,...t]),i}if(e instanceof Map){const i=this.serialize(Array.from(e.entries()),t,n,r,o);return n.push([De,...t]),i}if(Array.isArray(e))return[e.map((e,i)=>void 0===e?(n.push([Ae,...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 ze:t[n]=BigInt(t[n]);break;case Oe:t[n]=new Date(t[n]??"Invalid Date");break;case Re:t[n]=NaN;break;case Ae:t[n]=void 0;break;case Ne:t[n]=new URL(t[n]);break;case Pe:{const[,e,r]=t[n].match(/^\/(.*)\/([a-z]*)$/);t[n]=new RegExp(e,r);break}case Le:t[n]=new Set(t[n]);break;case De:t[n]=new Map(t[n])}}return o.data}};var Fe,je=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?Ie(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||$(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}},Ue=class{constructor(e){this.jsonSerializer=e}serialize(e){return $(e)?ke(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 $(e)?ke(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()))}},We=class extends Me{constructor(e,t){const n=new $e(t),r=new Ue(n);super(new je(r,t),e,t)}},Be=class extends Te{initRuntimeAdapter(e){for(const t of this.plugins)t.initRuntimeAdapter?.(e)}},He=class{fetch;toFetchRequestOptions;adapterInterceptors;constructor(e){new Be(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=Ee(e,this.toFetchRequestOptions);return function(e,t={}){return{body:R(()=>_e(e,t)),status:e.status,get headers(){const t=Ie(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})}},qe=class extends We{constructor(e){super(new He(e),e)}};function Ve(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 Ze=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Ge=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Fe=globalThis).__zod_globalConfig??(Fe.__zod_globalConfig={});var Ye=globalThis.__zod_globalConfig;function Je(e){return e&&Object.assign(Ye,e),Ye}function Ke(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 Xe(e,t){return"bigint"==typeof t?t.toString():t}function Qe(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function et(e){return null==e}function tt(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}var nt=/* @__PURE__*/Symbol("evaluating");function rt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==nt)return void 0===r&&(r=nt,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ot(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function it(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function st(e){return JSON.stringify(e)}var at="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ct(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var lt=/* @__PURE__*/Qe(()=>{if(Ye.jitless)return!1;if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function dt(e){if(!1===ct(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!==ct(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function ut(e){return dt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var pt=/* @__PURE__*/new Set(["string","number","symbol"]);function ht(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ft(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function mt(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 gt={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 yt(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 bt(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 wt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function vt(e){return"string"==typeof e?e:e?.message}function xt(e,t,n){const r=e.message?e.message:vt(e.inst?._zod.def?.error?.(e))??vt(t?.error?.(e))??vt(n.customError?.(e))??vt(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 kt(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function St(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}var _t=(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,Xe,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ct=Ve("$ZodError",_t),It=Ve("$ZodError",_t,{Parent:Error});var Et=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 Ze;if(s.issues.length){const t=new(o?.Err??e)(s.issues.map(e=>xt(e,i,Je())));throw at(t,o?.callee),t}return s.value},Tt=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=>xt(e,i,Je())));throw at(t,o?.callee),t}return s.value},Mt=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 Ze;return i.issues.length?{success:!1,error:new(e??Ct)(i.issues.map(e=>xt(e,o,Je())))}:{success:!0,data:i.value}},zt=/* @__PURE__*/Mt(It),Ot=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=>xt(e,o,Je())))}:{success:!0,data:i.value}},Rt=/* @__PURE__*/Ot(It),At=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Et(e)(t,n,o)},Nt=e=>(t,n,r)=>Et(e)(t,n,r),Pt=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Tt(e)(t,n,o)},Lt=e=>async(t,n,r)=>Tt(e)(t,n,r),Dt=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Mt(e)(t,n,o)},$t=e=>(t,n,r)=>Mt(e)(t,n,r),Ft=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ot(e)(t,n,o)},jt=e=>async(t,n,r)=>Ot(e)(t,n,r),Ut=/^[cC][0-9a-z]{6,}$/,Wt=/^[0-9a-z]+$/,Bt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ht=/^[0-9a-vA-V]{20}$/,qt=/^[A-Za-z0-9]{27}$/,Vt=/^[a-zA-Z0-9_-]{21}$/,Zt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Gt=/^([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})$/,Yt=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)$/,Jt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Kt=/^(?:(?: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])$/,Xt=/^(([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}|:))$/,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])\/([0-9]|[1-2][0-9]|3[0-2])$/,en=/^(([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])$/,tn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,nn=/^[A-Za-z0-9_-]*$/,rn=/^https?$/,on=/^\+[1-9]\d{6,14}$/,sn="(?:(?:\\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])))",an=/*@__PURE__*/new RegExp(`^${sn}$`);function cn(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 ln=/^-?\d+$/,dn=/^-?\d+(?:\.\d+)?$/,un=/^(?:true|false)$/i,pn=/^[^A-Z]*$/,hn=/^[^a-z]*$/,fn=/*@__PURE__*/Ve("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),mn={number:"number",bigint:"bigint",object:"date"},gn=/*@__PURE__*/Ve("$ZodCheckLessThan",(e,t)=>{fn.init(e,t);const n=mn[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})}}),yn=/*@__PURE__*/Ve("$ZodCheckGreaterThan",(e,t)=>{fn.init(e,t);const n=mn[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})}}),bn=/*@__PURE__*/Ve("$ZodCheckMultipleOf",(e,t)=>{fn.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})}}),wn=/*@__PURE__*/Ve("$ZodCheckNumberFormat",(e,t)=>{fn.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=gt[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=ln)}),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})}}),vn=/*@__PURE__*/Ve("$ZodCheckMaxLength",(e,t)=>{var n;fn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!et(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=kt(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xn=/*@__PURE__*/Ve("$ZodCheckMinLength",(e,t)=>{var n;fn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!et(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=kt(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),kn=/*@__PURE__*/Ve("$ZodCheckLengthEquals",(e,t)=>{var n;fn.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!et(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=kt(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})}}),Sn=/*@__PURE__*/Ve("$ZodCheckStringFormat",(e,t)=>{var n,r;fn.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=()=>{})}),_n=/*@__PURE__*/Ve("$ZodCheckRegex",(e,t)=>{Sn.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})}}),Cn=/*@__PURE__*/Ve("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=pn),Sn.init(e,t)}),In=/*@__PURE__*/Ve("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=hn),Sn.init(e,t)}),En=/*@__PURE__*/Ve("$ZodCheckIncludes",(e,t)=>{fn.init(e,t);const n=ht(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})}}),Tn=/*@__PURE__*/Ve("$ZodCheckStartsWith",(e,t)=>{fn.init(e,t);const n=new RegExp(`^${ht(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})}}),Mn=/*@__PURE__*/Ve("$ZodCheckEndsWith",(e,t)=>{fn.init(e,t);const n=new RegExp(`.*${ht(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})}}),zn=/*@__PURE__*/Ve("$ZodCheckOverwrite",(e,t)=>{fn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),On=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"))}},Rn={major:4,minor:4,patch:3},An=/*@__PURE__*/Ve("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Rn;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=yt(e);for(const i of t){if(i._zod.def.when){if(bt(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 Ze;if(r||s instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await s,e.issues.length!==t&&(o||(o=yt(e,t)))});else{if(e.issues.length===t)continue;o||(o=yt(e,t))}}return r?r.then(()=>e):e},n=(n,o,i)=>{if(yt(n))return n.aborted=!0,n;const s=t(o,r,i);if(s instanceof Promise){if(!1===i.async)throw new Ze;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 Ze;return s.then(e=>t(e,r,i))}return t(s,r,i)}}rt(e,"~standard",()=>({validate:t=>{try{const n=zt(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return Rt(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Nn=/*@__PURE__*/Ve("$ZodString",(e,t)=>{var n;An.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}}),Pn=/*@__PURE__*/Ve("$ZodStringFormat",(e,t)=>{Sn.init(e,t),Nn.init(e,t)}),Ln=/*@__PURE__*/Ve("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Gt),Pn.init(e,t)}),Dn=/*@__PURE__*/Ve("$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=Yt(e))}else t.pattern??(t.pattern=Yt());Pn.init(e,t)}),$n=/*@__PURE__*/Ve("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Jt),Pn.init(e,t)}),Fn=/*@__PURE__*/Ve("$ZodURL",(e,t)=>{Pn.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===rn.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})}}}),jn=/*@__PURE__*/Ve("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Pn.init(e,t)}),Un=/*@__PURE__*/Ve("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Vt),Pn.init(e,t)}),Wn=/*@__PURE__*/Ve("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ut),Pn.init(e,t)}),Bn=/*@__PURE__*/Ve("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Wt),Pn.init(e,t)}),Hn=/*@__PURE__*/Ve("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Bt),Pn.init(e,t)}),qn=/*@__PURE__*/Ve("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ht),Pn.init(e,t)}),Vn=/*@__PURE__*/Ve("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=qt),Pn.init(e,t)}),Zn=/*@__PURE__*/Ve("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=cn({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(`^${sn}T(?:${r})$`)}(t)),Pn.init(e,t)}),Gn=/*@__PURE__*/Ve("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=an),Pn.init(e,t)}),Yn=/*@__PURE__*/Ve("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${cn(t)}$`)),Pn.init(e,t)}),Jn=/*@__PURE__*/Ve("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Zt),Pn.init(e,t)}),Kn=/*@__PURE__*/Ve("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Kt),Pn.init(e,t),e._zod.bag.format="ipv4"}),Xn=/*@__PURE__*/Ve("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Xt),Pn.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})}}}),Qn=/*@__PURE__*/Ve("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Qt),Pn.init(e,t)}),er=/*@__PURE__*/Ve("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=en),Pn.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 tr(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 nr=/*@__PURE__*/Ve("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=tn),Pn.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{tr(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});var rr=/*@__PURE__*/Ve("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=nn),Pn.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!nn.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return tr(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})}}),or=/*@__PURE__*/Ve("$ZodE164",(e,t)=>{t.pattern??(t.pattern=on),Pn.init(e,t)});var ir=/*@__PURE__*/Ve("$ZodJWT",(e,t)=>{Pn.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})}}),sr=/*@__PURE__*/Ve("$ZodNumber",(e,t)=>{An.init(e,t),e._zod.pattern=e._zod.bag.pattern??dn,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}}),ar=/*@__PURE__*/Ve("$ZodNumberFormat",(e,t)=>{wn.init(e,t),sr.init(e,t)}),cr=/*@__PURE__*/Ve("$ZodBoolean",(e,t)=>{An.init(e,t),e._zod.pattern=un,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}}),lr=/*@__PURE__*/Ve("$ZodUnknown",(e,t)=>{An.init(e,t),e._zod.parse=e=>e}),dr=/*@__PURE__*/Ve("$ZodNever",(e,t)=>{An.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),ur=/*@__PURE__*/Ve("$ZodDate",(e,t)=>{An.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 pr(e,t,n){e.issues.length&&t.issues.push(...wt(n,e.issues)),t.value[n]=e.value}var hr=/*@__PURE__*/Ve("$ZodArray",(e,t)=>{An.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=>pr(t,n,e))):pr(a,n,e)}return i.length?Promise.all(i).then(()=>n):n}});function fr(e,t,n,r,o,i){const s=n in r;if(e.issues.length){if(o&&i&&!s)return;t.issues.push(...wt(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 mr(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 gr(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=>fr(e,n,p,t,d,u))):fr(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 yr=/*@__PURE__*/Ve("$ZodObject",(e,t)=>{if(An.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=Qe(()=>mr(t));rt(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=ct,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=>fr(n,t,e,a,r,o))):fr(i,t,e,a,r,o)}return o?gr(c,a,t,s,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),br=/*@__PURE__*/Ve("$ZodObjectJIT",(e,t)=>{yr.init(e,t);const n=e._zod.parse,r=Qe(()=>mr(t));let o;const i=ct,s=!Ye.jitless,a=s&<.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 On(["shape","payload","ctx"]),n=r.value,o=e=>{const t=st(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=st(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?gr([],p,d,u,l,e):d):n(d,u):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}});function wr(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=>!yt(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=>xt(e,r,Je())))}),t)}var vr=/*@__PURE__*/Ve("$ZodUnion",(e,t)=>{An.init(e,t),rt(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),rt(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),rt(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),rt(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=>tt(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=>wr(t,r,e,o)):wr(s,r,e,o)}}),xr=/*@__PURE__*/Ve("$ZodIntersection",(e,t)=>{An.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])=>Sr(e,t,n)):Sr(e,o,i)}});function kr(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(dt(e)&&dt(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=kr(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=kr(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 Sr(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}),yt(e))return e;const s=kr(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 _r=/*@__PURE__*/Ve("$ZodRecord",(e,t)=>{An.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!dt(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=>xt(e,r,Je())),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(...wt(l,e.issues)),n.value[c]=e.value})):(d.issues.length&&n.issues.push(...wt(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&&dn.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=>xt(e,r,Je())),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(...wt(s,e.issues)),n.value[a.value]=e.value})):(c.issues.length&&n.issues.push(...wt(s,c.issues)),n.value[a.value]=c.value)}}return i.length?Promise.all(i).then(()=>n):n}}),Cr=/*@__PURE__*/Ve("$ZodEnum",(e,t)=>{An.init(e,t);const n=Ke(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>pt.has(typeof e)).map(e=>"string"==typeof e?ht(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}}),Ir=/*@__PURE__*/Ve("$ZodLiteral",(e,t)=>{if(An.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?ht(e):e?ht(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}}),Er=/*@__PURE__*/Ve("$ZodTransform",(e,t)=>{An.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new Ge(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 Ze;return n.value=o,n.fallback=!0,n}});function Tr(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var Mr=/*@__PURE__*/Ve("$ZodOptional",(e,t)=>{An.init(e,t),e._zod.optin="optional",e._zod.optout="optional",rt(e._zod,"values",()=>t.innerType._zod.values?/* @__PURE__ */new Set([...t.innerType._zod.values,void 0]):void 0),rt(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${tt(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=>Tr(e,r)):Tr(o,r)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),zr=/*@__PURE__*/Ve("$ZodExactOptional",(e,t)=>{Mr.init(e,t),rt(e._zod,"values",()=>t.innerType._zod.values),rt(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Or=/*@__PURE__*/Ve("$ZodNullable",(e,t)=>{An.init(e,t),rt(e._zod,"optin",()=>t.innerType._zod.optin),rt(e._zod,"optout",()=>t.innerType._zod.optout),rt(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${tt(e.source)}|null)$`):void 0}),rt(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)}),Rr=/*@__PURE__*/Ve("$ZodDefault",(e,t)=>{An.init(e,t),e._zod.optin="optional",rt(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=>Ar(e,t)):Ar(r,t)}});function Ar(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var Nr=/*@__PURE__*/Ve("$ZodPrefault",(e,t)=>{An.init(e,t),e._zod.optin="optional",rt(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))}),Pr=/*@__PURE__*/Ve("$ZodNonOptional",(e,t)=>{An.init(e,t),rt(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=>Lr(t,e)):Lr(o,e)}});function Lr(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 Dr=/*@__PURE__*/Ve("$ZodCatch",(e,t)=>{An.init(e,t),e._zod.optin="optional",rt(e._zod,"optout",()=>t.innerType._zod.optout),rt(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=>xt(e,n,Je()))},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=>xt(e,n,Je()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),$r=/*@__PURE__*/Ve("$ZodPipe",(e,t)=>{An.init(e,t),rt(e._zod,"values",()=>t.in._zod.values),rt(e._zod,"optin",()=>t.in._zod.optin),rt(e._zod,"optout",()=>t.out._zod.optout),rt(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=>Fr(e,t.in,n)):Fr(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Fr(e,t.out,n)):Fr(r,t.out,n)}});function Fr(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 jr=/*@__PURE__*/Ve("$ZodReadonly",(e,t)=>{An.init(e,t),rt(e._zod,"propValues",()=>t.innerType._zod.propValues),rt(e._zod,"values",()=>t.innerType._zod.values),rt(e._zod,"optin",()=>t.innerType?._zod?.optin),rt(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(Ur):Ur(r)}});function Ur(e){return e.value=Object.freeze(e.value),e}var Wr,Br=/*@__PURE__*/Ve("$ZodCustom",(e,t)=>{fn.init(e,t),An.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=>Hr(t,n,r,e));Hr(o,n,r,e)}});function Hr(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(St(e))}}var qr=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)}};(Wr=globalThis).__zod_globalRegistry??(Wr.__zod_globalRegistry=new qr);var Vr=globalThis.__zod_globalRegistry;function Zr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...mt(t)})}function Gr(e,t){return new gn({check:"less_than",...mt(t),value:e,inclusive:!1})}function Yr(e,t){return new gn({check:"less_than",...mt(t),value:e,inclusive:!0})}function Jr(e,t){return new yn({check:"greater_than",...mt(t),value:e,inclusive:!1})}function Kr(e,t){return new yn({check:"greater_than",...mt(t),value:e,inclusive:!0})}function Xr(e,t){return new bn({check:"multiple_of",...mt(t),value:e})}function Qr(e,t){return new vn({check:"max_length",...mt(t),maximum:e})}function eo(e,t){return new xn({check:"min_length",...mt(t),minimum:e})}function to(e,t){return new kn({check:"length_equals",...mt(t),length:e})}function no(e){return new zn({check:"overwrite",tx:e})}function ro(e,t){const n=new fn({check:"custom",...mt(t)});return n._zod.check=e,n}function oo(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??Vr,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 io(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),io(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&&co(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 so(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 ao(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:lo(t,"input",e.processors),output:lo(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function co(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 co(r.element,n);if("set"===r.type)return co(r.valueType,n);if("lazy"===r.type)return co(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 co(r.innerType,n);if("intersection"===r.type)return co(r.left,n)||co(r.right,n);if("record"===r.type||"map"===r.type)return co(r.keyType,n)||co(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(co(r.in,n)||co(r.out,n));if("object"===r.type){for(const e in r.shape)if(co(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(co(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(co(e,n))return!0;return!(!r.rest||!co(r.rest,n))}return!1}var lo=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=oo({...o??{},target:i,io:t,processors:n});return io(e,s),so(s,e),ao(s,e)},uo={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},po=(e,t,n,r)=>{const o=e._zod.def;io(o.innerType,t,r);t.seen.get(e).ref=o.innerType},ho=/*@__PURE__*/Ve("ZodISODateTime",(e,t)=>{Zn.init(e,t),Uo.init(e,t)});function fo(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...mt(t)})}(ho,e)}var mo=/*@__PURE__*/Ve("ZodISODate",(e,t)=>{Gn.init(e,t),Uo.init(e,t)});function go(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...mt(t)})}(mo,e)}var yo=/*@__PURE__*/Ve("ZodISOTime",(e,t)=>{Yn.init(e,t),Uo.init(e,t)});function bo(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...mt(t)})}(yo,e)}var wo=/*@__PURE__*/Ve("ZodISODuration",(e,t)=>{Jn.init(e,t),Uo.init(e,t)});function vo(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...mt(t)})}(wo,e)}var xo=(e,t)=>{Ct.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,Xe,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Xe,2)}},isEmpty:{get:()=>0===e.issues.length}})},ko=/*@__PURE__*/Ve("ZodError",xo,{Parent:Error}),So=/* @__PURE__ */Et(ko),_o=/* @__PURE__ */Tt(ko),Co=/* @__PURE__ */Mt(ko),Io=/* @__PURE__ */Ot(ko),Eo=/* @__PURE__ */At(ko),To=/* @__PURE__ */Nt(ko),Mo=/* @__PURE__ */Pt(ko),zo=/* @__PURE__ */Lt(ko),Oo=/* @__PURE__ */Dt(ko),Ro=/* @__PURE__ */$t(ko),Ao=/* @__PURE__ */Ft(ko),No=/* @__PURE__ */jt(ko),Po=/* @__PURE__ */new WeakMap;function Lo(e,t,n){const r=Object.getPrototypeOf(e);let o=Po.get(r);if(o||(o=/* @__PURE__ */new Set,Po.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 Do=/*@__PURE__*/Ve("ZodType",(e,t)=>(An.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:lo(e,"input"),output:lo(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=oo({...n,processors:t});return io(e,r),so(r,e),ao(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>So(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Co(e,t,n),e.parseAsync=async(t,n)=>_o(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Io(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Eo(e,t,n),e.decode=(t,n)=>To(e,t,n),e.encodeAsync=async(t,n)=>Mo(e,t,n),e.decodeAsync=async(t,n)=>zo(e,t,n),e.safeEncode=(t,n)=>Oo(e,t,n),e.safeDecode=(t,n)=>Ro(e,t,n),e.safeEncodeAsync=async(t,n)=>Ao(e,t,n),e.safeDecodeAsync=async(t,n)=>No(e,t,n),Lo(e,"ZodType",{check(...e){const t=this.def;return this.clone(it(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 ft(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,...mt(n)})}(Bi,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=/* @__PURE__ */ro(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(St(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(St(r))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check(no(e))},optional(){return Ri(this)},exactOptional(){return new Ai({type:"optional",innerType:this})},nullable(){return Pi(this)},nullish(){return Ri(Pi(this))},nonoptional(e){return function(e,t){return new $i({type:"nonoptional",innerType:e,...mt(t)})}(this,e)},array(){return wi(this)},or(e){return Si([this,e])},and(e){return new _i({type:"intersection",left:this,right:e})},transform(e){return Ui(this,new zi({type:"transform",transform:e}))},default(e){return t=e,new Li({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():ut(t)}});var t},prefault(e){return t=e,new Di({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():ut(t)}});var t},catch(e){return new Fi({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Ui(this,e)},readonly(){return new Wi({type:"readonly",innerType:this})},describe(e){const t=this.clone();return Vr.add(t,{description:e}),t},meta(...e){if(0===e.length)return Vr.get(this);const t=this.clone();return Vr.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:()=>Vr.get(e)?.description,configurable:!0}),e)),$o=/*@__PURE__*/Ve("_ZodString",(e,t)=>{Nn.init(e,t),Do.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=uo[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,Lo(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new _n({check:"string_format",format:"regex",...mt(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new En({check:"string_format",format:"includes",...mt(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new Tn({check:"string_format",format:"starts_with",...mt(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Mn({check:"string_format",format:"ends_with",...mt(t),suffix:e})}(...e))},min(...e){return this.check(eo(...e))},max(...e){return this.check(Qr(...e))},length(...e){return this.check(to(...e))},nonempty(...e){return this.check(eo(1,...e))},lowercase(e){return this.check(function(e){return new Cn({check:"string_format",format:"lowercase",...mt(e)})}(e))},uppercase(e){return this.check(function(e){return new In({check:"string_format",format:"uppercase",...mt(e)})}(e))},trim(){return this.check(/* @__PURE__ */no(e=>e.trim()))},normalize(...e){return this.check(function(e){/* @__PURE__ */
|
|
2
|
-
return no(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(/* @__PURE__ */no(e=>e.toLowerCase()))},toUpperCase(){return this.check(/* @__PURE__ */no(e=>e.toUpperCase()))},slugify(){return this.check(/* @__PURE__ */no(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Fo=/*@__PURE__*/Ve("ZodString",(e,t)=>{Nn.init(e,t),$o.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...mt(t)})}(Wo,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...mt(t)})}(qo,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...mt(t)})}(si,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...mt(t)})}(Vo,t)),e.guid=t=>e.check(Zr(Bo,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...mt(t)})}(Ho,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...mt(t)})}(Ho,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...mt(t)})}(Ho,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...mt(t)})}(Ho,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...mt(t)})}(Zo,t)),e.guid=t=>e.check(Zr(Bo,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...mt(t)})}(Go,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...mt(t)})}(Yo,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...mt(t)})}(Jo,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...mt(t)})}(ri,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...mt(t)})}(oi,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...mt(t)})}(Ko,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...mt(t)})}(Xo,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...mt(t)})}(Qo,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...mt(t)})}(ei,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...mt(t)})}(ti,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...mt(t)})}(ni,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...mt(t)})}(ii,t)),e.datetime=t=>e.check(fo(t)),e.date=t=>e.check(go(t)),e.time=t=>e.check(bo(t)),e.duration=t=>e.check(vo(t))});function jo(e){return function(e,t){return new e({type:"string",...mt(t)})}(Fo,e)}var Uo=/*@__PURE__*/Ve("ZodStringFormat",(e,t)=>{Pn.init(e,t),$o.init(e,t)}),Wo=/*@__PURE__*/Ve("ZodEmail",(e,t)=>{$n.init(e,t),Uo.init(e,t)}),Bo=/*@__PURE__*/Ve("ZodGUID",(e,t)=>{Ln.init(e,t),Uo.init(e,t)}),Ho=/*@__PURE__*/Ve("ZodUUID",(e,t)=>{Dn.init(e,t),Uo.init(e,t)}),qo=/*@__PURE__*/Ve("ZodURL",(e,t)=>{Fn.init(e,t),Uo.init(e,t)}),Vo=/*@__PURE__*/Ve("ZodEmoji",(e,t)=>{jn.init(e,t),Uo.init(e,t)}),Zo=/*@__PURE__*/Ve("ZodNanoID",(e,t)=>{Un.init(e,t),Uo.init(e,t)}),Go=/*@__PURE__*/Ve("ZodCUID",(e,t)=>{Wn.init(e,t),Uo.init(e,t)}),Yo=/*@__PURE__*/Ve("ZodCUID2",(e,t)=>{Bn.init(e,t),Uo.init(e,t)}),Jo=/*@__PURE__*/Ve("ZodULID",(e,t)=>{Hn.init(e,t),Uo.init(e,t)}),Ko=/*@__PURE__*/Ve("ZodXID",(e,t)=>{qn.init(e,t),Uo.init(e,t)}),Xo=/*@__PURE__*/Ve("ZodKSUID",(e,t)=>{Vn.init(e,t),Uo.init(e,t)}),Qo=/*@__PURE__*/Ve("ZodIPv4",(e,t)=>{Kn.init(e,t),Uo.init(e,t)}),ei=/*@__PURE__*/Ve("ZodIPv6",(e,t)=>{Xn.init(e,t),Uo.init(e,t)}),ti=/*@__PURE__*/Ve("ZodCIDRv4",(e,t)=>{Qn.init(e,t),Uo.init(e,t)}),ni=/*@__PURE__*/Ve("ZodCIDRv6",(e,t)=>{er.init(e,t),Uo.init(e,t)}),ri=/*@__PURE__*/Ve("ZodBase64",(e,t)=>{nr.init(e,t),Uo.init(e,t)}),oi=/*@__PURE__*/Ve("ZodBase64URL",(e,t)=>{rr.init(e,t),Uo.init(e,t)}),ii=/*@__PURE__*/Ve("ZodE164",(e,t)=>{or.init(e,t),Uo.init(e,t)}),si=/*@__PURE__*/Ve("ZodJWT",(e,t)=>{ir.init(e,t),Uo.init(e,t)}),ai=/*@__PURE__*/Ve("ZodNumber",(e,t)=>{sr.init(e,t),Do.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),Lo(e,"ZodNumber",{gt(e,t){return this.check(Jr(e,t))},gte(e,t){return this.check(Kr(e,t))},min(e,t){return this.check(Kr(e,t))},lt(e,t){return this.check(Gr(e,t))},lte(e,t){return this.check(Yr(e,t))},max(e,t){return this.check(Yr(e,t))},int(e){return this.check(di(e))},safe(e){return this.check(di(e))},positive(e){return this.check(Jr(0,e))},nonnegative(e){return this.check(Kr(0,e))},negative(e){return this.check(Gr(0,e))},nonpositive(e){return this.check(Yr(0,e))},multipleOf(e,t){return this.check(Xr(e,t))},step(e,t){return this.check(Xr(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 ci(e){return function(e,t){return new e({type:"number",checks:[],...mt(t)})}(ai,e)}var li=/*@__PURE__*/Ve("ZodNumberFormat",(e,t)=>{ar.init(e,t),ai.init(e,t)});function di(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...mt(t)})}(li,e)}var ui=/*@__PURE__*/Ve("ZodBoolean",(e,t)=>{cr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function pi(e){return function(e,t){return new e({type:"boolean",...mt(t)})}(ui,e)}var hi=/*@__PURE__*/Ve("ZodUnknown",(e,t)=>{lr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function fi(){return new hi({type:"unknown"})}var mi=/*@__PURE__*/Ve("ZodNever",(e,t)=>{dr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function gi(e){return function(e,t){return new e({type:"never",...mt(t)})}(mi,e)}var yi=/*@__PURE__*/Ve("ZodDate",(e,t)=>{ur.init(e,t),Do.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(Kr(t,n)),e.max=(t,n)=>e.check(Yr(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}),bi=/*@__PURE__*/Ve("ZodArray",(e,t)=>{hr.init(e,t),Do.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=io(i.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,Lo(e,"ZodArray",{min(e,t){return this.check(eo(e,t))},nonempty(e){return this.check(eo(1,e))},max(e,t){return this.check(Qr(e,t))},length(e,t){return this.check(to(e,t))},unwrap(){return this.element}})});function wi(e,t){return function(e,t,n){return new e({type:"array",element:t,...mt(n)})}(bi,e,t)}var vi=/*@__PURE__*/Ve("ZodObject",(e,t)=>{br.init(e,t),Do.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]=io(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=io(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)})(e,t,n,r),rt(e,"shape",()=>t.shape),Lo(e,"ZodObject",{keyof(){return Ti(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:fi()})},loose(){return this.clone({...this._zod.def,catchall:fi()})},strict(){return this.clone({...this._zod.def,catchall:gi()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!dt(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 ft(e,it(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return ot(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!dt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return ft(e,it(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return ot(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 ft(e,it(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return ot(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 ft(e,it(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 ot(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 ft(e,it(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 ot(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 ft(t,it(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 ot(this,"shape",o),o},checks:[]}))}(Oi,this,e[0])},required(...e){return t=$i,n=this,r=e[0],ft(n,it(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 ot(this,"shape",o),o}}));var t,n,r}})});function xi(e,t){const n={type:"object",shape:e??{},...mt(t)};return new vi(n)}var ki=/*@__PURE__*/Ve("ZodUnion",(e,t)=>{vr.init(e,t),Do.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)=>io(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 Si(e,t){return new ki({type:"union",options:e,...mt(t)})}var _i=/*@__PURE__*/Ve("ZodIntersection",(e,t)=>{xr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=io(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=io(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 Ci=/*@__PURE__*/Ve("ZodRecord",(e,t)=>{_r.init(e,t),Do.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=io(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=io(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=io(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 Ii(e,t,n){return t&&t._zod?new Ci({type:"record",keyType:e,valueType:t,...mt(n)}):new Ci({type:"record",keyType:jo(),valueType:e,...mt(t)})}var Ei=/*@__PURE__*/Ve("ZodEnum",(e,t)=>{Cr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=Ke(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 Ei({...t,checks:[],...mt(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 Ei({...t,checks:[],...mt(r),entries:o})}});function Ti(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ei({type:"enum",entries:n,...mt(t)})}var Mi=/*@__PURE__*/Ve("ZodLiteral",(e,t)=>{Ir.init(e,t),Do.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 zi=/*@__PURE__*/Ve("ZodTransform",(e,t)=>{Er.init(e,t),Do.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 Ge(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(St(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(St(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 Oi=/*@__PURE__*/Ve("ZodOptional",(e,t)=>{Mr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Ri(e){return new Oi({type:"optional",innerType:e})}var Ai=/*@__PURE__*/Ve("ZodExactOptional",(e,t)=>{zr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Ni=/*@__PURE__*/Ve("ZodNullable",(e,t)=>{Or.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=io(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 Pi(e){return new Ni({type:"nullable",innerType:e})}var Li=/*@__PURE__*/Ve("ZodDefault",(e,t)=>{Rr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;io(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 Di=/*@__PURE__*/Ve("ZodPrefault",(e,t)=>{Nr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;io(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 $i=/*@__PURE__*/Ve("ZodNonOptional",(e,t)=>{Pr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;io(o.innerType,t,r),t.seen.get(e).ref=o.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Fi=/*@__PURE__*/Ve("ZodCatch",(e,t)=>{Dr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;let i;io(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 ji=/*@__PURE__*/Ve("ZodPipe",(e,t)=>{$r.init(e,t),Do.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;io(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function Ui(e,t){return new ji({type:"pipe",in:e,out:t})}var Wi=/*@__PURE__*/Ve("ZodReadonly",(e,t)=>{jr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;io(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 Bi=/*@__PURE__*/Ve("ZodCustom",(e,t)=>{Br.init(e,t),Do.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 Hi(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...mt(t)})}(ai,e)}function qi(e){return function(e,t){return new e({type:"date",coerce:!0,...mt(t)})}(yi,e)}var Vi,Zi=Ti(["created","active","suspended"]),Gi=xi({id:ci().optional(),created_at:qi().optional(),updated_at:qi().optional()}),Yi=(xi({id:Hi()}),xi({slug:jo()}),xi({widget_id:Hi()}),xi({simulation_id:Hi()}),xi({application_id:Hi()}),xi({user_id:Hi()}),xi({limit:Hi().optional().default(50),offset:Hi().optional().default(0)}),Si([pi(),jo()]).transform(e=>"boolean"==typeof e?e:"true"===e||"false"!==e&&void 0).optional(),xi({success:function(e,t){return new Mi({type:"literal",values:Array.isArray(e)?e:[e],...mt(t)})}(!0)})),Ji=(Yi.extend({message:jo()}),xi({name:jo().min(1),params:Ii(jo(),fi()).default({}),result:Ii(jo(),fi()).default({})}),jo().url().refine(e=>/^https:\/\/hooks\.slack\.com\//.test(e),{message:"Slack webhook URL must start with https://hooks.slack.com/"}),xi({start:jo(),end:jo(),action:jo()}).passthrough()),Ki=xi({id:jo(),label:jo(),purpose:jo(),elements:wi(Ii(jo(),fi())).default([]),bbox:Ii(jo(),fi()).default({}),screenshot:jo().default(""),embedding:wi(ci()).nullish()}).passthrough(),Xi=xi({id:jo(),title:jo(),url:jo(),summary:jo().default(""),screenshot:jo().default(""),sections:wi(Ki).default([]),sequence_ids:wi(ci()).default([]),embedding:wi(ci()).nullish()}).passthrough(),Qi=(xi({nodes:wi(Xi),edges:wi(Ji)}),Ti(["free","startup","growth","enterprise"])),es=Ti(["document","video"]),ts=Ti(["user","research"]),ns=Ti(["queued","running","creating_knowledge","has_question","completed","failed","stopped"]),rs=Ti(["pending","generating","completed","failed"]),os=Ti(["app","website"]),is=Ti(["widget"]),ss=(Ti(["tell","show","do"]),Ti(["password","oauth"])),as=Ti(["admin","member"]),cs=(Gi.extend({is_super:pi(),status:Zi,email:jo().email(),external_id:jo().nullish(),first_name:jo().nullish(),last_name:jo().nullish(),password:jo().nullish(),image_url:jo().nullish(),last_login_at:qi().nullish(),auth_method:ss.nullish(),workspace_role:as.nullish()}),Gi.extend({name:jo(),slug:jo(),status:Zi,package:Qi,ending_date:qi().nullish(),external_workspace_id:jo().nullish(),slack_webhook_configured:pi().optional(),notify_all_members_on_question:pi().optional()}),Gi.extend({workspace_id:ci(),application_id:ci().optional(),file_name:jo().min(1),file_size:Hi(),file_type:es,file_url:jo(),source_url:jo().nullish(),source:ts.default("user").optional(),persona_id:ci().nullish(),ingest_status:Ti(["pending","embedding","ready","failed","unsupported"]).default("pending").optional(),ingest_error:jo().nullish(),extracted_chars:ci().default(0).optional()}),Gi.extend({workspace_id:ci(),application_id:ci(),persona_id:ci(),file_name:jo().min(1),file_size:Hi(),file_type:jo(),file_url:jo()}),Ti(["desktop","tablet","mobile"])),ls=Ti(["positive","neutral","negative"]),ds=xi({step_index:ci(),screenshot_ref:jo().nullable(),reaction:jo(),sentiment:ls}),us=xi({id:ci(),run_id:ci().nullable(),persona_id:ci().nullable(),user_index:ci().nullable(),simulation_id:ci().nullable(),study_variant_id:ci().nullable(),study_task_id:ci().nullable(),journey_reaction:jo().nullable(),journey_sentiment:ls.nullable(),status:Ti(["pending","completed","failed"]),step_reactions:wi(ds).default([]),question_answers:wi(xi({study_question_id:ci(),answer:jo()})).default([])}),ps=(Gi.extend({application_id:ci(),job_id:jo(),browser_session_id:jo().nullish(),status:ns,status_message:jo(),path:jo().nullish(),instructions:jo(),name:jo().nullish(),type:Ti(["direct","uxr","survey","ab","qa"]),pinned:pi().optional(),source:Ti(["direct","qa"]).optional(),graph_id:jo().nullish(),source_metadata:Ii(jo(),fi()).nullish(),step_count:ci().int().nonnegative().nullish(),started_at:qi().nullish(),completed_at:qi().nullish(),output_persisted_at:qi().nullish(),graph_status:rs.optional(),graph_steps_processed:ci().int().nonnegative().optional(),graph_steps_total:ci().int().nonnegative().optional(),graph_error:jo().nullish(),created_by_user_id:ci().nullish(),has_question:pi().optional(),riders:wi(xi({persona_id:ci(),user_count:ci().int().positive()})).default([]),reactions:wi(us).default([]),driver_persona_id:ci().nullable().default(null),viewport:cs.default("desktop")}),Gi.extend({workspace_id:ci(),name:jo(),slug:jo(),type:os,url:jo(),username:jo().nullish(),password:jo().nullish(),allowed_domains:wi(jo()).default([])}).omit({password:!0}),xi({chip_mode:Ti(["show","tell","do"]),chip_text:jo()})),hs=xi({widget_enabled:pi(),widget_appearance:Ti(["default","compact","full","hidden"]),widget_position:Ti(["bottom_left","bottom_right","top_left","top_right"]),widget_device:Ti(["desktop","mobile","desktop_mobile"]),widget_header:jo(),widget_body:jo(),widget_greeting:jo(),widget_greeting_toast:pi(),widget_recording:pi(),widget_feature_tell:pi(),widget_feature_show:pi(),widget_feature_do:pi(),widget_feature_human:pi(),widget_background_color:jo(),widget_text_color:jo(),widget_border_color:jo(),widget_accent_color:jo(),widget_secondary_color:jo(),widget_border_radius:jo(),widget_font_size:jo(),widget_width:jo(),widget_height:jo(),widget_shadow:jo(),widget_animation_duration:jo(),widget_fade_duration:jo(),widget_bounce_effect:pi(),widget_chips:wi(ps)}),fs=(Gi.extend({application_id:ci(),type:is,settings:hs,status:Zi,marketrix_id:jo(),marketrix_key:jo(),snippet:jo().nullish()}),Gi.extend({widget_id:ci(),url_pattern:jo(),message:wi(jo()),description:jo().optional()}),Ti(["created","running","finalizing","completed","failed","stopped"]),Ti(["passed","failed","indecisive"]),Ti(["passed","failed"]),Ti(["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","request_membership","invite_user","widget_question","qa_run_started","start_simulation","create_workflow","update_workflow","delete_workflow","toggle_workflow","slack_command","create_form","update_form","delete_form","duplicate_form","publish_form","unpublish_form","archive_form","submit_form_response","delete_form_response"])),ms=xi({details:jo().optional(),id:ci().optional(),type:jo().optional(),name:jo().optional(),target_user_id:ci().optional(),target_user_email:jo().optional(),reason:jo().optional(),assigned_role:jo().optional(),new_role:jo().optional(),previous_role:jo().optional(),workspace_name:jo().optional(),workspace_slug:jo().optional(),ip_address:jo().optional(),user_agent:jo().optional(),widget_type:jo().optional(),created_by:ci().optional()}).passthrough(),gs=(Gi.extend({workspace_id:ci(),user_id:ci().nullable(),type:fs,metadata:ms.optional()}).partial().extend({type:fs}),null),ys="";function bs(e){return Se(new qe({url:e,headers:()=>{const e={};return gs&&(e.Authorization=`Bearer ${gs}`),e}}))}Vi=bs("");var ws=e=>{if(!e?.trim())throw new Error("API URL is required for SDK configuration");e!==ys&&(ys=e,Vi=bs(e))},vs={setAuthToken:e=>{gs=e},clearAuthToken:()=>{gs=null},getAuthToken:()=>gs,configure:ws},xs=new Proxy({},{get:(e,t)=>t in vs?vs[t]:Vi[t]}),ks="undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&!window.location.hostname.includes("localhost")?"error":"debug",Ss={debug:0,info:1,warn:2,error:3};function _s(e){return Ss[e]>=Ss[ks]}var Cs=[{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 Is(e){return e.includes("__THINKING__")}function Es(e){return Is(e)?e:`${e}\n\n__THINKING__`}function Ts(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 Ms(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=Ts(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=Ts(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=Ts(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 zs(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 Os=/* @__PURE__ */new Set(["click_element","type_text","send_keys","select_dropdown_option","upload_file","scroll"]),Rs=/* @__PURE__ */new Set(["click_element","type_text","select_dropdown_option","send_keys","upload_file"]);function As(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 Ns(e,t,n,r=!1){const o=zs(e);if(!t||"show"!==n&&"do"!==n)return Is(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 Is(o.content)?o.placeholderState!==i?{...o,placeholderState:i}:o:{...o,content:Es(o.content),placeholderState:i}}var Ps=Object.fromEntries(Cs.map(e=>[e.id,e.displayAction]));var Ls="marketrix_chat_context",Ds={chat_id:null,messages:[],isTaskRunning:!1,activeTaskId:null,currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1,config:null,timestamp:Date.now()},$s=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={...Ds},this.context;try{const e=localStorage.getItem(Ls);if(e){const t=JSON.parse(e);return Date.now()-t.timestamp>6048e5?(this.context={...Ds},this.saveContext(),this.context):(this.context=t,this.context)}}catch(e){}return this.context={...Ds},this.context}saveContext(){if("undefined"!=typeof window&&this.context)try{this.context.timestamp=Date.now(),localStorage.setItem(Ls,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={...Ds},"undefined"!=typeof window&&localStorage.removeItem(Ls)}hasValidContext(){const e=this.getContext();return null!==e.chat_id&&e.chat_id.length>0}}.getInstance(),Fs=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($s.hasValidContext())return;$s.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=$s.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});$s.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 js(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 Us(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 Ws(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 Bs(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 Hs(e,t="show"){return{id:`screenshare-${Date.now()}`,content:"",sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,videoStream:e,parts:[]}}var qs={debug:(e,...t)=>{_s("debug")},info:(e,...t)=>{_s("info")},warn:(e,...t)=>{_s("warn")},error:(e,...t)=>{_s("error")}},Vs=class e{static instance=null;chatId=null;initializationPromise=null;constructor(){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.chatId=this.getStoredChatId(),this.chatId&&qs.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 qs.debug("Returning existing chat ID:",this.chatId),this.chatId;if(this.initializationPromise)return qs.debug("Chat ID initialization in progress, waiting..."),this.initializationPromise;const e=this.getStoredChatId();if(e)return this.chatId=e,qs.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{qs.info("Creating new chat ID...");const e=await xs.chatCreate(void 0);if(!e)throw new Error("API returned empty chat ID");return this.chatId=e,this.storeChatId(e),qs.info("Created and stored new chat ID:",this.chatId),Fs.createInitialContext(e),e}catch(e){throw qs.error("Failed to create chat ID:",e),this.initializationPromise=null,e}}getStoredChatId(){return $s.getChatId()}storeChatId(e){$s.setChatId(e)}}.getInstance(),Zs=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 xs.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?xs.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 Gs(){return Vs.getChatId()}async function Ys(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:Gs(),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),xs.activityLogCreate({type:"widget_question",metadata:o}).catch(e=>{})}catch(r){}}function Js(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 Ks=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||Js(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(),Xs=null;async function Qs(){if(Xs?.active){const e=Xs.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return Xs}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 Xs=e,e.getVideoTracks()[0].addEventListener("ended",()=>{Xs=null}),e}function ea(){return null!==function(){if(Xs?.active){const e=Xs.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return Xs}return Xs=null,null}()}var ta=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=Ks.getSequenceForElement(this.currentElement)??-1,t=Ks.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(),na=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}=Ks.getElementByIndex(n);if(!t)return{success:!1,data:{text:""},error:o||`Element ${n} not found`};if(!(await ta.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 ta.cleanup(),{success:!1,data:{text:""},error:o instanceof Error?o.message:String(o)}}}requiresHighlight(e){return Rs.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}=Ks.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}=Ks.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}=Ks.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}=Ks.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}=Ks.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:Ks.getSnapshotHtml()}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}getInteractableElements(){try{return{success:!0,data:{elements:Ks.getInteractableElements()}}}catch(e){return{success:!1,data:{elements:[]},error:String(e)}}}async getScreenshot(){try{const e=await Qs();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(),ra=class e{static instance;config=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadConfig(){const e=$s.getConfig();return e?(this.config=e,e):(this.config={},this.config)}saveConfig(e){$s.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 oa(e,t={}){return{...t,...e}}var ia=e=>({state:e,effects:[]});function sa(e,t,n,r,o,i,s){const a=function(e){return Ps[e]?Ps[e]:e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}(r),c=Ms({messages:e,isTaskRunning:t,currentMode:n,requireContent:"failed"===i});if(!c)return e;let l=c.message;const d=t&&"show"===n&&Rs.has(r),u="done"===r,p="show"===n||"do"===n;"in_progress"===i?(u||(l=function(e,t,n){const r=zs(e),o=r.parts||[],i=[...o],s=o.findIndex(e=>"progress"===e.type&&e.browserToolName===t&&"in_progress"===e.status),a=!Os.has(t),c="default",l=As(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=Ns(l,t,n,d))):"completed"===i?(u||(l=function(e,t){const n=zs(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=Ns(l,t,n,!1))):(l=function(e,t,n){const r=zs(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=As(s[a].content);s[a]={...s[a],status:"completed",content:e}}else{const e=As(n),t=As(s[a].content);s[a]={...s[a],status:"failed",content:e?`${t} (${e})`:t}}return{...r,parts:s}}(l,a,s||""),t&&p&&(l=Ns(l,t,n,!1)));const h=[...e];return h[c.index]=l,h}function aa(e,t,n,r,o,i){return{...e,messages:sa(e.messages,e.task.isTaskRunning,o,t,n,r,i)}}var ca=n(void 0),la={activeTaskId:null,isTaskRunning:!1},da=({children:e,previewMode:t=!1,currentMode:n,uiActions:r,initialMessages:o,initialTask:s})=>{const[c,p]=u(()=>({messages:o??[],task:s??la})),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(js(e,a)),void w(Us("This is a preview. In production, I'll respond to your messages here."));let c=ra.getConfig();if(c||(c=ra.loadConfig()),!c||!c.mtxId&&!c.mtxKey&&!c.mtxApp)return void w(Us("Configuration error: Missing API credentials. Please check your widget settings."));s||w(js(e,a));const l=`temp-${globalThis.crypto.randomUUID()}`,d={id:l,content:Es(""),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=Gs();if(t){const e=Zs.getInstance();if(!e.isConnected()){const n=ra.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 Vs.getOrCreateChatId()))throw new Error("Failed to initialize chat session");const n=t.mode||"tell";if(t.message&&await Ys(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||""};Zs.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=Zs.getInstance(),n=async t=>{const{toolCallId:n,tool:r,args:o,mode:i,explanation:s}=t,a=await na.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=>aa(e,r,s,"completed",f.current)),"done"===r&&(y.current={},b(e=>function(e,t){const n=Ms({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=>aa(e,r,s,"failed",f.current,"Connection error"))}else b(e=>aa(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),!Cs.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:sa(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 ia(e);if("has_question"===t.status){const t=Ms({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:n,requireContent:!1}),o=[...e.messages];if(t){const e=Ns(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=Ms({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 ia(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=Ms({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||Zs.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__ */
|
|
2
|
+
return no(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(/* @__PURE__ */no(e=>e.toLowerCase()))},toUpperCase(){return this.check(/* @__PURE__ */no(e=>e.toUpperCase()))},slugify(){return this.check(/* @__PURE__ */no(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Fo=/*@__PURE__*/Ve("ZodString",(e,t)=>{Nn.init(e,t),$o.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...mt(t)})}(Wo,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...mt(t)})}(qo,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...mt(t)})}(si,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...mt(t)})}(Vo,t)),e.guid=t=>e.check(Zr(Bo,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...mt(t)})}(Ho,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...mt(t)})}(Ho,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...mt(t)})}(Ho,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...mt(t)})}(Ho,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...mt(t)})}(Zo,t)),e.guid=t=>e.check(Zr(Bo,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...mt(t)})}(Go,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...mt(t)})}(Yo,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...mt(t)})}(Jo,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...mt(t)})}(ri,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...mt(t)})}(oi,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...mt(t)})}(Ko,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...mt(t)})}(Xo,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...mt(t)})}(Qo,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...mt(t)})}(ei,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...mt(t)})}(ti,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...mt(t)})}(ni,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...mt(t)})}(ii,t)),e.datetime=t=>e.check(fo(t)),e.date=t=>e.check(go(t)),e.time=t=>e.check(bo(t)),e.duration=t=>e.check(vo(t))});function jo(e){return function(e,t){return new e({type:"string",...mt(t)})}(Fo,e)}var Uo=/*@__PURE__*/Ve("ZodStringFormat",(e,t)=>{Pn.init(e,t),$o.init(e,t)}),Wo=/*@__PURE__*/Ve("ZodEmail",(e,t)=>{$n.init(e,t),Uo.init(e,t)}),Bo=/*@__PURE__*/Ve("ZodGUID",(e,t)=>{Ln.init(e,t),Uo.init(e,t)}),Ho=/*@__PURE__*/Ve("ZodUUID",(e,t)=>{Dn.init(e,t),Uo.init(e,t)}),qo=/*@__PURE__*/Ve("ZodURL",(e,t)=>{Fn.init(e,t),Uo.init(e,t)}),Vo=/*@__PURE__*/Ve("ZodEmoji",(e,t)=>{jn.init(e,t),Uo.init(e,t)}),Zo=/*@__PURE__*/Ve("ZodNanoID",(e,t)=>{Un.init(e,t),Uo.init(e,t)}),Go=/*@__PURE__*/Ve("ZodCUID",(e,t)=>{Wn.init(e,t),Uo.init(e,t)}),Yo=/*@__PURE__*/Ve("ZodCUID2",(e,t)=>{Bn.init(e,t),Uo.init(e,t)}),Jo=/*@__PURE__*/Ve("ZodULID",(e,t)=>{Hn.init(e,t),Uo.init(e,t)}),Ko=/*@__PURE__*/Ve("ZodXID",(e,t)=>{qn.init(e,t),Uo.init(e,t)}),Xo=/*@__PURE__*/Ve("ZodKSUID",(e,t)=>{Vn.init(e,t),Uo.init(e,t)}),Qo=/*@__PURE__*/Ve("ZodIPv4",(e,t)=>{Kn.init(e,t),Uo.init(e,t)}),ei=/*@__PURE__*/Ve("ZodIPv6",(e,t)=>{Xn.init(e,t),Uo.init(e,t)}),ti=/*@__PURE__*/Ve("ZodCIDRv4",(e,t)=>{Qn.init(e,t),Uo.init(e,t)}),ni=/*@__PURE__*/Ve("ZodCIDRv6",(e,t)=>{er.init(e,t),Uo.init(e,t)}),ri=/*@__PURE__*/Ve("ZodBase64",(e,t)=>{nr.init(e,t),Uo.init(e,t)}),oi=/*@__PURE__*/Ve("ZodBase64URL",(e,t)=>{rr.init(e,t),Uo.init(e,t)}),ii=/*@__PURE__*/Ve("ZodE164",(e,t)=>{or.init(e,t),Uo.init(e,t)}),si=/*@__PURE__*/Ve("ZodJWT",(e,t)=>{ir.init(e,t),Uo.init(e,t)}),ai=/*@__PURE__*/Ve("ZodNumber",(e,t)=>{sr.init(e,t),Do.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),Lo(e,"ZodNumber",{gt(e,t){return this.check(Jr(e,t))},gte(e,t){return this.check(Kr(e,t))},min(e,t){return this.check(Kr(e,t))},lt(e,t){return this.check(Gr(e,t))},lte(e,t){return this.check(Yr(e,t))},max(e,t){return this.check(Yr(e,t))},int(e){return this.check(di(e))},safe(e){return this.check(di(e))},positive(e){return this.check(Jr(0,e))},nonnegative(e){return this.check(Kr(0,e))},negative(e){return this.check(Gr(0,e))},nonpositive(e){return this.check(Yr(0,e))},multipleOf(e,t){return this.check(Xr(e,t))},step(e,t){return this.check(Xr(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 ci(e){return function(e,t){return new e({type:"number",checks:[],...mt(t)})}(ai,e)}var li=/*@__PURE__*/Ve("ZodNumberFormat",(e,t)=>{ar.init(e,t),ai.init(e,t)});function di(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...mt(t)})}(li,e)}var ui=/*@__PURE__*/Ve("ZodBoolean",(e,t)=>{cr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function pi(e){return function(e,t){return new e({type:"boolean",...mt(t)})}(ui,e)}var hi=/*@__PURE__*/Ve("ZodUnknown",(e,t)=>{lr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function fi(){return new hi({type:"unknown"})}var mi=/*@__PURE__*/Ve("ZodNever",(e,t)=>{dr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function gi(e){return function(e,t){return new e({type:"never",...mt(t)})}(mi,e)}var yi=/*@__PURE__*/Ve("ZodDate",(e,t)=>{ur.init(e,t),Do.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(Kr(t,n)),e.max=(t,n)=>e.check(Yr(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}),bi=/*@__PURE__*/Ve("ZodArray",(e,t)=>{hr.init(e,t),Do.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=io(i.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,Lo(e,"ZodArray",{min(e,t){return this.check(eo(e,t))},nonempty(e){return this.check(eo(1,e))},max(e,t){return this.check(Qr(e,t))},length(e,t){return this.check(to(e,t))},unwrap(){return this.element}})});function wi(e,t){return function(e,t,n){return new e({type:"array",element:t,...mt(n)})}(bi,e,t)}var vi=/*@__PURE__*/Ve("ZodObject",(e,t)=>{br.init(e,t),Do.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]=io(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=io(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)})(e,t,n,r),rt(e,"shape",()=>t.shape),Lo(e,"ZodObject",{keyof(){return Ti(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:fi()})},loose(){return this.clone({...this._zod.def,catchall:fi()})},strict(){return this.clone({...this._zod.def,catchall:gi()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!dt(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 ft(e,it(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return ot(this,"shape",n),n}}))}(this,e)},safeExtend(e){return function(e,t){if(!dt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return ft(e,it(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return ot(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 ft(e,it(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return ot(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 ft(e,it(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 ot(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 ft(e,it(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 ot(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 ft(t,it(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 ot(this,"shape",o),o},checks:[]}))}(Oi,this,e[0])},required(...e){return t=$i,n=this,r=e[0],ft(n,it(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 ot(this,"shape",o),o}}));var t,n,r}})});function xi(e,t){const n={type:"object",shape:e??{},...mt(t)};return new vi(n)}var ki=/*@__PURE__*/Ve("ZodUnion",(e,t)=>{vr.init(e,t),Do.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)=>io(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 Si(e,t){return new ki({type:"union",options:e,...mt(t)})}var _i=/*@__PURE__*/Ve("ZodIntersection",(e,t)=>{xr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=io(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=io(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 Ci=/*@__PURE__*/Ve("ZodRecord",(e,t)=>{_r.init(e,t),Do.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=io(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=io(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=io(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 Ii(e,t,n){return t&&t._zod?new Ci({type:"record",keyType:e,valueType:t,...mt(n)}):new Ci({type:"record",keyType:jo(),valueType:e,...mt(t)})}var Ei=/*@__PURE__*/Ve("ZodEnum",(e,t)=>{Cr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=Ke(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 Ei({...t,checks:[],...mt(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 Ei({...t,checks:[],...mt(r),entries:o})}});function Ti(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ei({type:"enum",entries:n,...mt(t)})}var Mi=/*@__PURE__*/Ve("ZodLiteral",(e,t)=>{Ir.init(e,t),Do.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 zi=/*@__PURE__*/Ve("ZodTransform",(e,t)=>{Er.init(e,t),Do.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 Ge(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(St(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(St(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 Oi=/*@__PURE__*/Ve("ZodOptional",(e,t)=>{Mr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Ri(e){return new Oi({type:"optional",innerType:e})}var Ai=/*@__PURE__*/Ve("ZodExactOptional",(e,t)=>{zr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>po(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Ni=/*@__PURE__*/Ve("ZodNullable",(e,t)=>{Or.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=io(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 Pi(e){return new Ni({type:"nullable",innerType:e})}var Li=/*@__PURE__*/Ve("ZodDefault",(e,t)=>{Rr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;io(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 Di=/*@__PURE__*/Ve("ZodPrefault",(e,t)=>{Nr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;io(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 $i=/*@__PURE__*/Ve("ZodNonOptional",(e,t)=>{Pr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;io(o.innerType,t,r),t.seen.get(e).ref=o.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Fi=/*@__PURE__*/Ve("ZodCatch",(e,t)=>{Dr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;let i;io(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 ji=/*@__PURE__*/Ve("ZodPipe",(e,t)=>{$r.init(e,t),Do.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;io(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function Ui(e,t){return new ji({type:"pipe",in:e,out:t})}var Wi=/*@__PURE__*/Ve("ZodReadonly",(e,t)=>{jr.init(e,t),Do.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;io(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 Bi=/*@__PURE__*/Ve("ZodCustom",(e,t)=>{Br.init(e,t),Do.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 Hi(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...mt(t)})}(ai,e)}function qi(e){return function(e,t){return new e({type:"date",coerce:!0,...mt(t)})}(yi,e)}var Vi,Zi=Ti(["created","active","suspended"]),Gi=xi({id:ci().optional(),created_at:qi().optional(),updated_at:qi().optional()}),Yi=(xi({id:Hi()}),xi({slug:jo()}),xi({widget_id:Hi()}),xi({simulation_id:Hi()}),xi({application_id:Hi()}),xi({user_id:Hi()}),xi({limit:Hi().optional().default(50),offset:Hi().optional().default(0)}),Si([pi(),jo()]).transform(e=>"boolean"==typeof e?e:"true"===e||"false"!==e&&void 0).optional(),xi({success:function(e,t){return new Mi({type:"literal",values:Array.isArray(e)?e:[e],...mt(t)})}(!0)})),Ji=(Yi.extend({message:jo()}),xi({name:jo().min(1),params:Ii(jo(),fi()).default({}),result:Ii(jo(),fi()).default({})}),jo().url().refine(e=>/^https:\/\/hooks\.slack\.com\//.test(e),{message:"Slack webhook URL must start with https://hooks.slack.com/"}),xi({start:jo(),end:jo(),action:jo()}).passthrough()),Ki=xi({id:jo(),label:jo(),purpose:jo(),elements:wi(Ii(jo(),fi())).default([]),bbox:Ii(jo(),fi()).default({}),screenshot:jo().default(""),embedding:wi(ci()).nullish()}).passthrough(),Xi=xi({id:jo(),title:jo(),url:jo(),summary:jo().default(""),screenshot:jo().default(""),sections:wi(Ki).default([]),sequence_ids:wi(ci()).default([]),embedding:wi(ci()).nullish()}).passthrough(),Qi=(xi({nodes:wi(Xi),edges:wi(Ji)}),Ti(["free","startup","growth","enterprise"])),es=Ti(["document","video"]),ts=Ti(["user","research"]),ns=Ti(["queued","running","creating_knowledge","has_question","completed","failed","stopped"]),rs=Ti(["pending","generating","completed","failed"]),os=Ti(["app","website"]),is=Ti(["widget"]),ss=(Ti(["tell","show","do"]),Ti(["password","oauth"])),as=Ti(["admin","member"]),cs=(Gi.extend({is_super:pi(),status:Zi,email:jo().email(),external_id:jo().nullish(),first_name:jo().nullish(),last_name:jo().nullish(),password:jo().nullish(),image_url:jo().nullish(),last_login_at:qi().nullish(),auth_method:ss.nullish(),workspace_role:as.nullish()}),Gi.extend({name:jo(),slug:jo(),status:Zi,package:Qi,ending_date:qi().nullish(),external_workspace_id:jo().nullish(),slack_webhook_configured:pi().optional(),notify_all_members_on_question:pi().optional()}),Gi.extend({workspace_id:ci(),application_id:ci().optional(),file_name:jo().min(1),file_size:Hi(),file_type:es,file_url:jo(),source_url:jo().nullish(),source:ts.default("user").optional(),persona_id:ci().nullish(),ingest_status:Ti(["pending","embedding","ready","failed","unsupported"]).default("pending").optional(),ingest_error:jo().nullish(),extracted_chars:ci().default(0).optional()}),Gi.extend({workspace_id:ci(),application_id:ci(),persona_id:ci(),file_name:jo().min(1),file_size:Hi(),file_type:jo(),file_url:jo()}),Ti(["desktop","tablet","mobile"])),ls=Ti(["positive","neutral","negative"]),ds=xi({step_index:ci(),screenshot_ref:jo().nullable(),reaction:jo(),sentiment:ls}),us=xi({id:ci(),run_id:ci().nullable(),persona_id:ci().nullable(),user_index:ci().nullable(),simulation_id:ci().nullable(),study_variant_id:ci().nullable(),study_task_id:ci().nullable(),journey_reaction:jo().nullable(),journey_sentiment:ls.nullable(),status:Ti(["pending","completed","failed"]),step_reactions:wi(ds).default([]),question_answers:wi(xi({study_question_id:ci(),answer:jo()})).default([])}),ps=(Gi.extend({application_id:ci(),job_id:jo(),browser_session_id:jo().nullish(),status:ns,status_message:jo(),path:jo().nullish(),instructions:jo(),name:jo().nullish(),type:Ti(["direct","uxr","survey","ab","qa"]),pinned:pi().optional(),source:Ti(["direct","qa"]).optional(),graph_id:jo().nullish(),source_metadata:Ii(jo(),fi()).nullish(),step_count:ci().int().nonnegative().nullish(),started_at:qi().nullish(),completed_at:qi().nullish(),output_persisted_at:qi().nullish(),graph_status:rs.optional(),graph_steps_processed:ci().int().nonnegative().optional(),graph_steps_total:ci().int().nonnegative().optional(),graph_error:jo().nullish(),created_by_user_id:ci().nullish(),has_question:pi().optional(),riders:wi(xi({persona_id:ci(),user_count:ci().int().positive()})).default([]),reactions:wi(us).default([]),driver_persona_id:ci().nullable().default(null),viewport:cs.default("desktop")}),Gi.extend({workspace_id:ci(),name:jo(),slug:jo(),type:os,url:jo(),username:jo().nullish(),password:jo().nullish(),allowed_domains:wi(jo()).default([])}).omit({password:!0}),xi({chip_mode:Ti(["show","tell","do"]),chip_text:jo()})),hs=xi({widget_enabled:pi(),widget_appearance:Ti(["default","compact","full","hidden"]),widget_position:Ti(["bottom_left","bottom_right","top_left","top_right"]),widget_device:Ti(["desktop","mobile","desktop_mobile"]),widget_header:jo(),widget_body:jo(),widget_greeting:jo(),widget_greeting_toast:pi(),widget_recording:pi(),widget_feature_tell:pi(),widget_feature_show:pi(),widget_feature_do:pi(),widget_feature_human:pi(),widget_background_color:jo(),widget_text_color:jo(),widget_border_color:jo(),widget_accent_color:jo(),widget_secondary_color:jo(),widget_border_radius:jo(),widget_font_size:jo(),widget_width:jo(),widget_height:jo(),widget_shadow:jo(),widget_animation_duration:jo(),widget_fade_duration:jo(),widget_bounce_effect:pi(),widget_chips:wi(ps)}),fs=(Gi.extend({application_id:ci(),type:is,settings:hs,status:Zi,marketrix_id:jo(),marketrix_key:jo(),snippet:jo().nullish()}),Gi.extend({widget_id:ci(),url_pattern:jo(),message:wi(jo()),description:jo().optional()}),Ti(["created","running","finalizing","completed","failed","stopped"]),Ti(["passed","failed","indecisive"]),Ti(["passed","failed"]),Ti(["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","request_membership","invite_user","create_workspace","trial_started","trial_ending_soon","trial_ended","subscription_created","subscription_canceled","plan_changed","payment_succeeded","payment_failed","widget_question","qa_run_started","start_simulation","create_workflow","update_workflow","delete_workflow","toggle_workflow","slack_command","create_form","update_form","delete_form","duplicate_form","publish_form","unpublish_form","archive_form","submit_form_response","delete_form_response"])),ms=xi({details:jo().optional(),id:ci().optional(),type:jo().optional(),name:jo().optional(),target_user_id:ci().optional(),target_user_email:jo().optional(),reason:jo().optional(),assigned_role:jo().optional(),new_role:jo().optional(),previous_role:jo().optional(),workspace_name:jo().optional(),workspace_slug:jo().optional(),ip_address:jo().optional(),user_agent:jo().optional(),widget_type:jo().optional(),created_by:ci().optional()}).passthrough(),gs=(Gi.extend({workspace_id:ci(),user_id:ci().nullable(),type:fs,metadata:ms.optional()}).partial().extend({type:fs}),null),ys="";function bs(e){return Se(new qe({url:e,headers:()=>{const e={};return gs&&(e.Authorization=`Bearer ${gs}`),e}}))}Vi=bs("");var ws=e=>{if(!e?.trim())throw new Error("API URL is required for SDK configuration");e!==ys&&(ys=e,Vi=bs(e))},vs={setAuthToken:e=>{gs=e},clearAuthToken:()=>{gs=null},getAuthToken:()=>gs,configure:ws},xs=new Proxy({},{get:(e,t)=>t in vs?vs[t]:Vi[t]}),ks="undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&!window.location.hostname.includes("localhost")?"error":"debug",Ss={debug:0,info:1,warn:2,error:3};function _s(e){return Ss[e]>=Ss[ks]}var Cs=[{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 Is(e){return e.includes("__THINKING__")}function Es(e){return Is(e)?e:`${e}\n\n__THINKING__`}function Ts(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 Ms(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=Ts(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=Ts(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=Ts(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 zs(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 Os=/* @__PURE__ */new Set(["click_element","type_text","send_keys","select_dropdown_option","upload_file","scroll"]),Rs=/* @__PURE__ */new Set(["click_element","type_text","select_dropdown_option","send_keys","upload_file"]);function As(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 Ns(e,t,n,r=!1){const o=zs(e);if(!t||"show"!==n&&"do"!==n)return Is(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 Is(o.content)?o.placeholderState!==i?{...o,placeholderState:i}:o:{...o,content:Es(o.content),placeholderState:i}}var Ps=Object.fromEntries(Cs.map(e=>[e.id,e.displayAction]));var Ls="marketrix_chat_context",Ds={chat_id:null,messages:[],isTaskRunning:!1,activeTaskId:null,currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1,config:null,timestamp:Date.now()},$s=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={...Ds},this.context;try{const e=localStorage.getItem(Ls);if(e){const t=JSON.parse(e);return Date.now()-t.timestamp>6048e5?(this.context={...Ds},this.saveContext(),this.context):(this.context=t,this.context)}}catch(e){}return this.context={...Ds},this.context}saveContext(){if("undefined"!=typeof window&&this.context)try{this.context.timestamp=Date.now(),localStorage.setItem(Ls,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={...Ds},"undefined"!=typeof window&&localStorage.removeItem(Ls)}hasValidContext(){const e=this.getContext();return null!==e.chat_id&&e.chat_id.length>0}}.getInstance(),Fs=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($s.hasValidContext())return;$s.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=$s.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});$s.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 js(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 Us(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 Ws(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 Bs(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 Hs(e,t="show"){return{id:`screenshare-${Date.now()}`,content:"",sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,videoStream:e,parts:[]}}var qs={debug:(e,...t)=>{_s("debug")},info:(e,...t)=>{_s("info")},warn:(e,...t)=>{_s("warn")},error:(e,...t)=>{_s("error")}},Vs=class e{static instance=null;chatId=null;initializationPromise=null;constructor(){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.chatId=this.getStoredChatId(),this.chatId&&qs.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 qs.debug("Returning existing chat ID:",this.chatId),this.chatId;if(this.initializationPromise)return qs.debug("Chat ID initialization in progress, waiting..."),this.initializationPromise;const e=this.getStoredChatId();if(e)return this.chatId=e,qs.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{qs.info("Creating new chat ID...");const e=await xs.chatCreate(void 0);if(!e)throw new Error("API returned empty chat ID");return this.chatId=e,this.storeChatId(e),qs.info("Created and stored new chat ID:",this.chatId),Fs.createInitialContext(e),e}catch(e){throw qs.error("Failed to create chat ID:",e),this.initializationPromise=null,e}}getStoredChatId(){return $s.getChatId()}storeChatId(e){$s.setChatId(e)}}.getInstance(),Zs=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 xs.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?xs.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 Gs(){return Vs.getChatId()}async function Ys(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:Gs(),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),xs.activityLogCreate({type:"widget_question",metadata:o}).catch(e=>{})}catch(r){}}function Js(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 Ks=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||Js(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(),Xs=null;async function Qs(){if(Xs?.active){const e=Xs.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return Xs}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 Xs=e,e.getVideoTracks()[0].addEventListener("ended",()=>{Xs=null}),e}function ea(){return null!==function(){if(Xs?.active){const e=Xs.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return Xs}return Xs=null,null}()}var ta=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=Ks.getSequenceForElement(this.currentElement)??-1,t=Ks.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(),na=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}=Ks.getElementByIndex(n);if(!t)return{success:!1,data:{text:""},error:o||`Element ${n} not found`};if(!(await ta.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 ta.cleanup(),{success:!1,data:{text:""},error:o instanceof Error?o.message:String(o)}}}requiresHighlight(e){return Rs.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}=Ks.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}=Ks.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}=Ks.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}=Ks.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}=Ks.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:Ks.getSnapshotHtml()}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}getInteractableElements(){try{return{success:!0,data:{elements:Ks.getInteractableElements()}}}catch(e){return{success:!1,data:{elements:[]},error:String(e)}}}async getScreenshot(){try{const e=await Qs();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(),ra=class e{static instance;config=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadConfig(){const e=$s.getConfig();return e?(this.config=e,e):(this.config={},this.config)}saveConfig(e){$s.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 oa(e,t={}){return{...t,...e}}var ia=e=>({state:e,effects:[]});function sa(e,t,n,r,o,i,s){const a=function(e){return Ps[e]?Ps[e]:e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}(r),c=Ms({messages:e,isTaskRunning:t,currentMode:n,requireContent:"failed"===i});if(!c)return e;let l=c.message;const d=t&&"show"===n&&Rs.has(r),u="done"===r,p="show"===n||"do"===n;"in_progress"===i?(u||(l=function(e,t,n){const r=zs(e),o=r.parts||[],i=[...o],s=o.findIndex(e=>"progress"===e.type&&e.browserToolName===t&&"in_progress"===e.status),a=!Os.has(t),c="default",l=As(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=Ns(l,t,n,d))):"completed"===i?(u||(l=function(e,t){const n=zs(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=Ns(l,t,n,!1))):(l=function(e,t,n){const r=zs(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=As(s[a].content);s[a]={...s[a],status:"completed",content:e}}else{const e=As(n),t=As(s[a].content);s[a]={...s[a],status:"failed",content:e?`${t} (${e})`:t}}return{...r,parts:s}}(l,a,s||""),t&&p&&(l=Ns(l,t,n,!1)));const h=[...e];return h[c.index]=l,h}function aa(e,t,n,r,o,i){return{...e,messages:sa(e.messages,e.task.isTaskRunning,o,t,n,r,i)}}var ca=n(void 0),la={activeTaskId:null,isTaskRunning:!1},da=({children:e,previewMode:t=!1,currentMode:n,uiActions:r,initialMessages:o,initialTask:s})=>{const[c,p]=u(()=>({messages:o??[],task:s??la})),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(js(e,a)),void w(Us("This is a preview. In production, I'll respond to your messages here."));let c=ra.getConfig();if(c||(c=ra.loadConfig()),!c||!c.mtxId&&!c.mtxKey&&!c.mtxApp)return void w(Us("Configuration error: Missing API credentials. Please check your widget settings."));s||w(js(e,a));const l=`temp-${globalThis.crypto.randomUUID()}`,d={id:l,content:Es(""),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=Gs();if(t){const e=Zs.getInstance();if(!e.isConnected()){const n=ra.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 Vs.getOrCreateChatId()))throw new Error("Failed to initialize chat session");const n=t.mode||"tell";if(t.message&&await Ys(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||""};Zs.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=Zs.getInstance(),n=async t=>{const{toolCallId:n,tool:r,args:o,mode:i,explanation:s}=t,a=await na.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=>aa(e,r,s,"completed",f.current)),"done"===r&&(y.current={},b(e=>function(e,t){const n=Ms({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=>aa(e,r,s,"failed",f.current,"Connection error"))}else b(e=>aa(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),!Cs.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:sa(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 ia(e);if("has_question"===t.status){const t=Ms({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:n,requireContent:!1}),o=[...e.messages];if(t){const e=Ns(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=Ms({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 ia(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=Ms({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||Zs.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(ca.Provider,{value:{chatState:O,chatActions:M,taskState:c.task,taskActions:z},children:e})},ua=()=>{const e=s(ca);if(!e)throw new Error("useChatContext must be used within ChatProvider");return e},pa=n(void 0),ha=({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(pa.Provider,{value:{uiState:o,uiActions:s},children:e})},fa=()=>{const e=s(pa);if(!e)throw new Error("useUIStateContext must be used within UIStateProvider");return e};var ma=({config:e}={})=>{const{uiState:t,uiActions:n}=fa(),{chatState:r,chatActions:o,taskState:s,taskActions:c}=ua(),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||ra.getConfig()||{},[e]),f=function(e){return Object.keys(hs.shape).every(t=>void 0!==e[t])}(h);a(()=>{f&&ra.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}},ga=(e=/* @__PURE__ */new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),ya="-",ba=[],wa=e=>{const t=ka(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith("[")&&e.endsWith("]"))return xa(e);const n=e.split(ya),r=""===n[0]&&n.length>1?1:0;return va(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||ba}return n[e]||ba}}},va=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const r=e[t],o=n.nextPart.get(r);if(o){const n=va(e,t+1,o);if(n)return n}const i=n.validators;if(null===i)return;const s=0===t?e.join(ya):e.slice(t).join(ya),a=i.length;for(let c=0;c<a;c++){const e=i[c];if(e.validator(s))return e.classGroupId}},xa=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})(),ka=e=>{const{theme:t,classGroups:n}=e;return Sa(n,t)},Sa=(e,t)=>{const n=ga();for(const r in e){const o=e[r];_a(o,n,r,t)}return n},_a=(e,t,n,r)=>{const o=e.length;for(let i=0;i<o;i++){const o=e[i];Ca(o,t,n,r)}},Ca=(e,t,n,r)=>{"string"!=typeof e?"function"!=typeof e?Ta(e,t,n,r):Ea(e,t,n,r):Ia(e,t,n)},Ia=(e,t,n)=>{(""===e?t:Ma(t,e)).classGroupId=n},Ea=(e,t,n,r)=>{za(e)?_a(e(r),t,n,r):(null===t.validators&&(t.validators=[]),t.validators.push(((e,t)=>({classGroupId:e,validator:t}))(n,e)))},Ta=(e,t,n,r)=>{const o=Object.entries(e),i=o.length;for(let s=0;s<i;s++){const[e,i]=o[s];_a(i,Ma(t,e),n,r)}},Ma=(e,t)=>{let n=e;const r=t.split(ya),o=r.length;for(let i=0;i<o;i++){const e=r[i];let t=n.nextPart.get(e);t||(t=ga(),n.nextPart.set(e,t)),n=t}return n},za=e=>"isThemeGetter"in e&&!0===e.isThemeGetter,Oa=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)}}},Ra=[],Aa=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),Na=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 Aa(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)):Aa(Ra,!1,t,void 0,!0)}if(n){const e=r;r=t=>n({className:t,parseClassName:e})}return r},Pa=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}},La=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},Da=/\s+/,$a=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=$a(e[r]))&&(n&&(n+=" "),n+=t);return n},Fa=(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(Da);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:Oa(e.cacheSize),parseClassName:Na(e),sortModifiers:Pa(e),postfixLookupClassGroupIds:La(e),...wa(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=$a(t))&&(o&&(o+=" "),o+=n);return o})(...e))},ja=[],Ua=e=>{const t=t=>t[e]||ja;return t.isThemeGetter=!0,t},Wa=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ba=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Ha=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,qa=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Va=/\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$/,Za=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Ga=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ya=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ja=e=>Ha.test(e),Ka=e=>!!e&&!Number.isNaN(Number(e)),Xa=e=>!!e&&Number.isInteger(Number(e)),Qa=e=>e.endsWith("%")&&Ka(e.slice(0,-1)),ec=e=>qa.test(e),tc=()=>!0,nc=e=>Va.test(e)&&!Za.test(e),rc=()=>!1,oc=e=>Ga.test(e),ic=e=>Ya.test(e),sc=e=>!lc(e)&&!yc(e),ac=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)),cc=e=>Cc(e,Mc,rc),lc=e=>Wa.test(e),dc=e=>Cc(e,zc,nc),uc=e=>Cc(e,Oc,Ka),pc=e=>Cc(e,Ac,tc),hc=e=>Cc(e,Rc,rc),fc=e=>Cc(e,Ec,rc),mc=e=>Cc(e,Tc,ic),gc=e=>Cc(e,Nc,oc),yc=e=>Ba.test(e),bc=e=>Ic(e,zc),wc=e=>Ic(e,Rc),vc=e=>Ic(e,Ec),xc=e=>Ic(e,Mc),kc=e=>Ic(e,Tc),Sc=e=>Ic(e,Nc,!0),_c=e=>Ic(e,Ac,!0),Cc=(e,t,n)=>{const r=Wa.exec(e);return!!r&&(r[1]?t(r[1]):n(r[2]))},Ic=(e,t,n=!1)=>{const r=Ba.exec(e);return!!r&&(r[1]?t(r[1]):n)},Ec=e=>"position"===e||"percentage"===e,Tc=e=>"image"===e||"url"===e,Mc=e=>"length"===e||"size"===e||"bg-size"===e,zc=e=>"length"===e,Oc=e=>"number"===e,Rc=e=>"family-name"===e,Ac=e=>"number"===e||"weight"===e,Nc=e=>"shadow"===e,Pc=/*#__PURE__*/Fa(()=>{const e=Ua("color"),t=Ua("font"),n=Ua("text"),r=Ua("font-weight"),o=Ua("tracking"),i=Ua("leading"),s=Ua("breakpoint"),a=Ua("container"),c=Ua("spacing"),l=Ua("radius"),d=Ua("shadow"),u=Ua("inset-shadow"),p=Ua("text-shadow"),h=Ua("drop-shadow"),f=Ua("blur"),m=Ua("perspective"),g=Ua("aspect"),y=Ua("ease"),b=Ua("animate"),w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",yc,lc],v=()=>[yc,lc,c],x=()=>[Ja,"full","auto",...v()],k=()=>[Xa,"none","subgrid",yc,lc],S=()=>["auto",{span:["full",Xa,yc,lc]},Xa,yc,lc],_=()=>[Xa,"auto",yc,lc],C=()=>["auto","min","max","fr",yc,lc],I=()=>["auto",...v()],E=()=>[Ja,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],T=()=>[Ja,"screen","full","dvw","lvw","svw","min","max","fit",...v()],M=()=>[Ja,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],z=()=>[e,yc,lc],O=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",vc,fc,{position:[yc,lc]}],R=()=>["auto","cover","contain",xc,cc,{size:[yc,lc]}],A=()=>[Qa,bc,dc],N=()=>["","none","full",l,yc,lc],P=()=>["",Ka,bc,dc],L=()=>[Ka,Qa,vc,fc],D=()=>["","none",f,yc,lc],$=()=>["none",Ka,yc,lc],F=()=>["none",Ka,yc,lc],j=()=>[Ka,yc,lc],U=()=>[Ja,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ec],breakpoint:[ec],color:[tc],container:[ec],"drop-shadow":[ec],ease:["in","out","in-out"],font:[sc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ec],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ec],shadow:[ec],spacing:["px",Ka],text:[ec],"text-shadow":[ec],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ja,lc,yc,g]}],container:["container"],"container-type":[{"@container":["","normal","size",yc,lc]}],"container-named":[ac],columns:[{columns:[Ka,lc,yc,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:[Xa,"auto",yc,lc]}],basis:[{basis:[Ja,"full","auto",a,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ka,Ja,"auto","initial","none",lc]}],grow:[{grow:["",Ka,yc,lc]}],shrink:[{shrink:["",Ka,yc,lc]}],order:[{order:[Xa,"first","last","none",yc,lc]}],"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,bc,dc]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,_c,pc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Qa,lc]}],"font-family":[{font:[wc,hc,t]}],"font-features":[{"font-features":[lc]}],"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,yc,lc]}],"line-clamp":[{"line-clamp":[Ka,"none",yc,uc]}],leading:[{leading:[i,...v()]}],"list-image":[{"list-image":["none",yc,lc]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",yc,lc]}],"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:[Ka,"from-font","auto",yc,dc]}],"text-decoration-color":[{decoration:z()}],"underline-offset":[{"underline-offset":[Ka,"auto",yc,lc]}],"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:[Xa,yc,lc]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",yc,lc]}],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",yc,lc]}],"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"]},Xa,yc,lc],radial:["",yc,lc],conic:[Xa,yc,lc]},kc,mc]}],"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":[Ka,yc,lc]}],"outline-w":[{outline:["",Ka,bc,dc]}],"outline-color":[{outline:z()}],shadow:[{shadow:["","none",d,Sc,gc]}],"shadow-color":[{shadow:z()}],"inset-shadow":[{"inset-shadow":["none",u,Sc,gc]}],"inset-shadow-color":[{"inset-shadow":z()}],"ring-w":[{ring:P()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:z()}],"ring-offset-w":[{"ring-offset":[Ka,dc]}],"ring-offset-color":[{"ring-offset":z()}],"inset-ring-w":[{"inset-ring":P()}],"inset-ring-color":[{"inset-ring":z()}],"text-shadow":[{"text-shadow":["none",p,Sc,gc]}],"text-shadow-color":[{"text-shadow":z()}],opacity:[{opacity:[Ka,yc,lc]}],"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":[Ka]}],"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":[yc,lc]}],"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":[Ka]}],"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",yc,lc]}],filter:[{filter:["","none",yc,lc]}],blur:[{blur:D()}],brightness:[{brightness:[Ka,yc,lc]}],contrast:[{contrast:[Ka,yc,lc]}],"drop-shadow":[{"drop-shadow":["","none",h,Sc,gc]}],"drop-shadow-color":[{"drop-shadow":z()}],grayscale:[{grayscale:["",Ka,yc,lc]}],"hue-rotate":[{"hue-rotate":[Ka,yc,lc]}],invert:[{invert:["",Ka,yc,lc]}],saturate:[{saturate:[Ka,yc,lc]}],sepia:[{sepia:["",Ka,yc,lc]}],"backdrop-filter":[{"backdrop-filter":["","none",yc,lc]}],"backdrop-blur":[{"backdrop-blur":D()}],"backdrop-brightness":[{"backdrop-brightness":[Ka,yc,lc]}],"backdrop-contrast":[{"backdrop-contrast":[Ka,yc,lc]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ka,yc,lc]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ka,yc,lc]}],"backdrop-invert":[{"backdrop-invert":["",Ka,yc,lc]}],"backdrop-opacity":[{"backdrop-opacity":[Ka,yc,lc]}],"backdrop-saturate":[{"backdrop-saturate":[Ka,yc,lc]}],"backdrop-sepia":[{"backdrop-sepia":["",Ka,yc,lc]}],"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",yc,lc]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ka,"initial",yc,lc]}],ease:[{ease:["linear","initial",y,yc,lc]}],delay:[{delay:[Ka,yc,lc]}],animate:[{animate:["none",b,yc,lc]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,yc,lc]}],"perspective-origin":[{"perspective-origin":w()}],rotate:[{rotate:$()}],"rotate-x":[{"rotate-x":$()}],"rotate-y":[{"rotate-y":$()}],"rotate-z":[{"rotate-z":$()}],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:[yc,lc,"","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:[Xa,yc,lc]}],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",yc,lc]}],"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",yc,lc]}],fill:[{fill:["none",...z()]}],"stroke-w":[{stroke:[Ka,bc,dc,uc]}],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 Lc(...e){return Pc(e.filter(Boolean).join(" "))}var Dc={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)"},$c={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"},Fc={default:"text-foreground",muted:"text-foreground-muted",faint:"text-foreground-faint",primary:"text-primary",success:"text-success",warning:"text-warning",inherit:"text-inherit"},jc={tight:"leading-tight",snug:"leading-snug",normal:"leading-normal",relaxed:"leading-relaxed"},Uc={header:{height:40},tabBar:{height:48},launcher:{width:56,height:56},launcherCore:{width:48,height:48}},Wc={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 Bc(e){if(e&&"none"!==e)return{boxShadow:Dc[e]}}var Hc={none:"0","2xs":"1",xs:"0.5",sm:"1.5",md:"2",lg:"3",xl:"4","2xl":"6"},qc=/* @__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 Vc(e){const t=[];if(void 0!==e.padding&&t.push(`p-${Hc[e.padding]}`),void 0!==e.paddingX&&t.push(`px-${Hc[e.paddingX]}`),void 0!==e.paddingY&&t.push(`py-${Hc[e.paddingY]}`),void 0!==e.paddingTop&&t.push(`pt-${Hc[e.paddingTop]}`),void 0!==e.paddingBottom&&t.push(`pb-${Hc[e.paddingBottom]}`),void 0!==e.margin&&t.push(`m-${Hc[e.margin]}`),void 0!==e.marginX&&t.push(`mx-${Hc[e.marginX]}`),void 0!==e.marginY&&t.push(`my-${Hc[e.marginY]}`),void 0!==e.marginTop&&t.push(`mt-${Hc[e.marginTop]}`),void 0!==e.marginBottom&&t.push(`mb-${Hc[e.marginBottom]}`),void 0!==e.gap&&t.push(`gap-${Hc[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-${Hc[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($c.theme);else if("full"===e.rounded)t.push($c.pill);else{const n="lg"===e.rounded?"lg":e.rounded;t.push($c[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 Zc(e){const t={};for(const n in e)qc.has(n)||(t[n]=e[n]);return t}var Gc={default:"",card:"bg-card text-card-foreground",transparent:"bg-transparent",muted:"bg-muted",secondary:"bg-secondary-bg",primary:"bg-primary text-primary-foreground"},Yc={none:"",compact:"px-2 py-1.5",card:"px-3 py-2",dialog:"p-4",toast:"py-2 pl-2 pr-3"},Jc=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=Vc(e),u=Zc(l);/* @__PURE__ */
|
|
5
5
|
return m(n,{...u,ref:t,className:Lc(Gc[r],Yc[s],a&&Vc({rounded:a}),d,o),style:{...Bc(i),...c}})}),Kc="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20viewBox='0%200%20361%20360'%3e%3c!--%20Generator:%20Adobe%20Illustrator%2030.1.0,%20SVG%20Export%20Plug-In%20.%20SVG%20Version:%202.1.1%20Build%20136)%20--%3e%3cdefs%3e%3cstyle%3e%20.st0%20{%20display:%20none;%20fill:%20none;%20stroke:%20%23cdc9c2;%20stroke-width:%201.3px;%20}%20.st1%20{%20fill:%20%23fff;%20}%20.st2,%20.st3%20{%20fill:%20%237cffa6;%20}%20.st3%20{%20stroke:%20%237cffa6;%20stroke-width:%20.38px;%20}%20.st4%20{%20fill:%20%23101828;%20}%20%3c/style%3e%3c/defs%3e%3crect%20class='st4'%20x='.5'%20width='360'%20height='360'/%3e%3cpath%20class='st2'%20d='M83.37,209.58c15.35,0,27.8-12.45,27.8-27.8s-12.44-27.79-27.8-27.79-27.8,12.44-27.8,27.79,12.44,27.8,27.8,27.8Z'/%3e%3cpath%20class='st1'%20d='M85.86,68.28l152.45,223.44h67.29l-70.62-113.77,68.13-109.67h-67.29l-41.12,65.31-41.54-65.31h-67.29Z'/%3e%3cpath%20class='st3'%20d='M176.61,249.83l-35.08-51-57.82,92.71h66.85l26.05-41.7Z'/%3e%3crect%20class='st0'%20x='1.25'%20y='.65'%20width='358.7'%20height='358.7'%20rx='43.35'%20ry='43.35'/%3e%3c/svg%3e",Xc={sm:"w-5 h-5",md:"w-8 h-8",lg:"w-12 h-12"},Qc=o(function({src:e,alt:t,elevation:n,fit:r="contain",size:o="md",rounded:i,className:s,style:a,...c},l){const d="string"==typeof o,u=d?Xc[o]:void 0,p=d?a:{width:o,height:o,...a};/* @__PURE__ */
|