@marketrix.ai/widget 3.8.445 → 3.8.447

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,9 +1,9 @@
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 _(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}function S(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 I=e=>e?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):/* @__PURE__ */(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),C=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:_(e.widget_text_color,.6),foregroundFaint:_(e.widget_text_color,.4),border:e.widget_border_color,borderMuted:_(e.widget_border_color,.3),primary:e.widget_accent_color,primaryForeground:k(e.widget_accent_color),primaryHover:_(e.widget_accent_color,.85),primaryMuted:_(e.widget_accent_color,.3),secondary:e.widget_secondary_color,secondaryForeground:"#ffffff",secondaryBg:_(e.widget_secondary_color,.2),secondaryHover:_(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.14/otel/config__"]}function N(e,t={},n){return(A()?.tracer)?.startSpan(e,t,n)}function P(e,t,n={}){if(!e)return;const r=function(e){if(e instanceof Error){const t={message:e.message,name:e.name,stack:e.stack};return!("code"in e)||"string"!=typeof e.code&&"number"!=typeof e.code||(t.code=e.code),t}return{message:String(e)}}(t);e.recordException(r),n.signal?.aborted&&n.signal.reason===t||e.setStatus({code:2,message:r.message})}async function L({name:e,context:t,...n},r){const o=A()?.tracer;if(!o)return r();const i=async e=>{try{return await r(e)}catch(t){throw P(e,t,n),t}finally{e.end()}};return t?o.startActiveSpan(e,n,t,i):o.startActiveSpan(e,n,i)}async function $(e,t){const n=A();if(!e||!n)return t();const r=n.trace.setSpan(n.context.active(),e);return n.context.with(r,t)}function D(e){return!(!e||"object"!=typeof e)&&("next"in e&&"function"==typeof e.next&&Symbol.asyncIterator in e&&"function"==typeof e[Symbol.asyncIterator])}var F=Symbol.asyncDispose??Symbol.for("asyncDispose"),j=class{#e=!1;#t=!1;#n;#r;constructor(e,t){this.#n=t,this.#r=function(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}(async()=>{if(this.#e)return{done:!0,value:void 0};try{const t=await e();return t.done&&(this.#e=!0),t}catch(t){throw this.#e=!0,t}finally{this.#e&&!this.#t&&(this.#t=!0,await this.#n("next"))}})}next(){return this.#r()}async return(e){return this.#e=!0,this.#t||(this.#t=!0,await this.#n("return")),{done:!0,value:e}}async throw(e){throw this.#e=!0,this.#t||(this.#t=!0,await this.#n("throw")),e}async[F](){this.#e=!0,this.#t||(this.#t=!0,await this.#n("dispose"))}[Symbol.asyncIterator](){return this}};function U({name:e,...t},n){let r;return new j(async()=>{r??=N(e);try{const e=await $(r,()=>n.next());return r?.addEvent(e.done?"completed":"yielded"),e}catch(o){throw P(r,o,t),o}},async e=>{try{"next"!==e&&await $(r,()=>n.return?.())}catch(o){throw P(r,o,t),o}finally{r?.end()}})}function W(e,t,n){const r=(t,o)=>{const i=e[o];return i?i({...t,next:(e=t)=>r(e,o+1)}):n(t)};return r(t,0)}function B(e){if(e)return JSON.parse(e)}function H(e){return JSON.stringify(e)}function q(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function Z(e){return!!e&&("object"==typeof e||"function"==typeof e)}function V(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 K,J={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.14/error/ORPC_ERROR_CONSTRUCTORS__");globalThis[t]??=/* @__PURE__ */new WeakSet,(K=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||J[e]?.message||e}(e,n.message);super(r,n),this.code=e,this.status=function(e,t){return t??J[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(K.has(this)){const t=function(e){return Z(e)?Object.getPrototypeOf(e)?.constructor:null}(e);if(t&&K.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 Z(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&&Z(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&&Z(i)&&(i=we(i,e))}return{done:r,value:i}},async()=>{try{await(e.return?.())}catch(t){throw await n(t)}})}function _e(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):_e(e,{...t,path:[...n,o]})}))}function Se(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 $(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 Z(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 Z(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 $(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 Ie(e,t,n={}){if(e instanceof ReadableStream)return e;const r=t.get("content-disposition");return t.delete("content-type"),t.delete("content-disposition"),void 0!==e?e instanceof Blob?(t.set("content-type",e.type),t.set("content-length",e.size.toString()),t.set("content-disposition",r??function(e,t="inline"){return`${t}; filename="${e.replace(/[^\x20-\x7E]/g,"_").replace(/"/g,'\\"')}"; filename*=utf-8''${encodeURIComponent(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}(e instanceof File?e.name:"blob")),e):e instanceof FormData||e instanceof URLSearchParams?e:D(e)?(t.set("content-type","text/event-stream"),function(e,t={}){const n=t.eventIteratorKeepAliveEnabled??!0,r=t.eventIteratorKeepAliveInterval??5e3,o=t.eventIteratorKeepAliveComment??"",i=t.eventIteratorInitialCommentEnabled??!0,s=t.eventIteratorInitialComment??"";let a,c,l=!1;return new ReadableStream({start(e){c=N("stream_event_iterator"),i&&e.enqueue(ye({comments:[s]}))},async pull(t){try{n&&(a=setInterval(()=>{t.enqueue(ye({comments:[o]})),c?.addEvent("keepalive")},r));const i=await $(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 $(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 Ce(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=Ie(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(".")),D(t)&&(t=U({name:"consume_event_iterator_input",signal:n.signal},t)),W(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{const o=A();let i;const s=o?.trace.getActiveSpan()??r;s&&o&&(i=o?.trace.setSpan(o.context.active(),s));const a=await L({name:"encode_request",context:i},()=>this.codec.encode(e,t,n)),c=await W(this.clientInterceptors,{...n,input:t,path:e,request:a},({input:e,path:t,request:n,...r})=>L({name:"send_request",signal:r.signal,context:i},()=>this.sender.call(n,r,t,e))),l=await L({name:"decode_response",context:i},()=>this.codec.decode(c,n,e,t));return D(l)?U({name:"consume_event_iterator_output",signal:n.signal},l):l})))}},ze=0,Oe=1,Re=2,Ae=3,Ne=4,Pe=5,Le=6,$e=7,De=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([$e,...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 $e: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?Ce(e):e}(await V(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 V(this.expectedMethod,n,e,t),i=await V(this.baseUrl,n,e,t),s=new URL(i);s.pathname=`${s.pathname.replace(/\/$/,"")}${function(e){return`/${e.map(encodeURIComponent).join("/")}`}(e)}`;const a=this.serializer.serialize(t);if(!("GET"!==o||a instanceof FormData||D(a))){const i=await V(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(J).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 D(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 D(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 De(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(()=>Se(e,t)),status:e.status,get headers(){const t=Ce(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 Ze(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 Ve=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 Ke(e){return e&&Object.assign(Ye,e),Ye}function Je(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 _t(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}var St=(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})},It=Ze("$ZodError",St),Ct=Ze("$ZodError",St,{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 Ve;if(s.issues.length){const t=new(o?.Err??e)(s.issues.map(e=>xt(e,i,Ke())));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,Ke())));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 Ve;return i.issues.length?{success:!1,error:new(e??It)(i.issues.map(e=>xt(e,o,Ke())))}:{success:!0,data:i.value}},zt=/* @__PURE__*/Mt(Ct),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,Ke())))}:{success:!0,data:i.value}},Rt=/* @__PURE__*/Ot(Ct),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),$t=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Mt(e)(t,n,o)},Dt=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}$/,Zt=/^[a-zA-Z0-9_-]{21}$/,Vt=/^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)$/,Kt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Jt=/^(?:(?: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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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})}}),_n=/*@__PURE__*/Ze("$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=()=>{})}),Sn=/*@__PURE__*/Ze("$ZodCheckRegex",(e,t)=>{_n.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})}}),In=/*@__PURE__*/Ze("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=pn),_n.init(e,t)}),Cn=/*@__PURE__*/Ze("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=hn),_n.init(e,t)}),En=/*@__PURE__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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 Ve;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 Ve;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 Ve;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__*/Ze("$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__*/Ze("$ZodStringFormat",(e,t)=>{_n.init(e,t),Nn.init(e,t)}),Ln=/*@__PURE__*/Ze("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Gt),Pn.init(e,t)}),$n=/*@__PURE__*/Ze("$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)}),Dn=/*@__PURE__*/Ze("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Kt),Pn.init(e,t)}),Fn=/*@__PURE__*/Ze("$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__*/Ze("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Pn.init(e,t)}),Un=/*@__PURE__*/Ze("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Zt),Pn.init(e,t)}),Wn=/*@__PURE__*/Ze("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ut),Pn.init(e,t)}),Bn=/*@__PURE__*/Ze("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Wt),Pn.init(e,t)}),Hn=/*@__PURE__*/Ze("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Bt),Pn.init(e,t)}),qn=/*@__PURE__*/Ze("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ht),Pn.init(e,t)}),Zn=/*@__PURE__*/Ze("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=qt),Pn.init(e,t)}),Vn=/*@__PURE__*/Ze("$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__*/Ze("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=an),Pn.init(e,t)}),Yn=/*@__PURE__*/Ze("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${cn(t)}$`)),Pn.init(e,t)}),Kn=/*@__PURE__*/Ze("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Vt),Pn.init(e,t)}),Jn=/*@__PURE__*/Ze("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Jt),Pn.init(e,t),e._zod.bag.format="ipv4"}),Xn=/*@__PURE__*/Ze("$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__*/Ze("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Qt),Pn.init(e,t)}),er=/*@__PURE__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$ZodE164",(e,t)=>{t.pattern??(t.pattern=on),Pn.init(e,t)});var ir=/*@__PURE__*/Ze("$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__*/Ze("$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__*/Ze("$ZodNumberFormat",(e,t)=>{wn.init(e,t),sr.init(e,t)}),cr=/*@__PURE__*/Ze("$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__*/Ze("$ZodUnknown",(e,t)=>{An.init(e,t),e._zod.parse=e=>e}),dr=/*@__PURE__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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&&lt.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,Ke())))}),t)}var vr=/*@__PURE__*/Ze("$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__*/Ze("$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])=>_r(e,t,n)):_r(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 _r(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 Sr=/*@__PURE__*/Ze("$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,Ke())),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,Ke())),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}}),Ir=/*@__PURE__*/Ze("$ZodEnum",(e,t)=>{An.init(e,t);const n=Je(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}}),Cr=/*@__PURE__*/Ze("$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__*/Ze("$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 Ve;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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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 $r=/*@__PURE__*/Ze("$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,Ke()))},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,Ke()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Dr=/*@__PURE__*/Ze("$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__*/Ze("$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__*/Ze("$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(_t(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 Zr=globalThis.__zod_globalRegistry;function Vr(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...mt(t)})}function Gr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...mt(t)})}function Yr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...mt(t)})}function Kr(e,t){return new gn({check:"less_than",...mt(t),value:e,inclusive:!1})}function Jr(e,t){return new gn({check:"less_than",...mt(t),value:e,inclusive:!0})}function Xr(e,t){return new yn({check:"greater_than",...mt(t),value:e,inclusive:!1})}function Qr(e,t){return new yn({check:"greater_than",...mt(t),value:e,inclusive:!0})}function eo(e,t){return new bn({check:"multiple_of",...mt(t),value:e})}function to(e,t){return new vn({check:"max_length",...mt(t),maximum:e})}function no(e,t){return new xn({check:"min_length",...mt(t),minimum:e})}function ro(e,t){return new kn({check:"length_equals",...mt(t),length:e})}function oo(e){return new zn({check:"overwrite",tx:e})}function io(e,t){const n=new fn({check:"custom",...mt(t)});return n._zod.check=e,n}function so(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??Zr,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 ao(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),ao(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&&uo(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 co(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 lo(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:po(t,"input",e.processors),output:po(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function uo(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 uo(r.element,n);if("set"===r.type)return uo(r.valueType,n);if("lazy"===r.type)return uo(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 uo(r.innerType,n);if("intersection"===r.type)return uo(r.left,n)||uo(r.right,n);if("record"===r.type||"map"===r.type)return uo(r.keyType,n)||uo(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(uo(r.in,n)||uo(r.out,n));if("object"===r.type){for(const e in r.shape)if(uo(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(uo(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(uo(e,n))return!0;return!(!r.rest||!uo(r.rest,n))}return!1}var po=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=so({...o??{},target:i,io:t,processors:n});return ao(e,s),co(s,e),lo(s,e)},ho={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},fo=(e,t,n,r)=>{const o=e._zod.def;ao(o.innerType,t,r);t.seen.get(e).ref=o.innerType},mo=/*@__PURE__*/Ze("ZodISODateTime",(e,t)=>{Vn.init(e,t),Bo.init(e,t)});function go(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...mt(t)})}(mo,e)}var yo=/*@__PURE__*/Ze("ZodISODate",(e,t)=>{Gn.init(e,t),Bo.init(e,t)});function bo(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...mt(t)})}(yo,e)}var wo=/*@__PURE__*/Ze("ZodISOTime",(e,t)=>{Yn.init(e,t),Bo.init(e,t)});function vo(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...mt(t)})}(wo,e)}var xo=/*@__PURE__*/Ze("ZodISODuration",(e,t)=>{Kn.init(e,t),Bo.init(e,t)});function ko(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...mt(t)})}(xo,e)}var _o=(e,t)=>{It.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}})},So=/*@__PURE__*/Ze("ZodError",_o,{Parent:Error}),Io=/* @__PURE__ */Et(So),Co=/* @__PURE__ */Tt(So),Eo=/* @__PURE__ */Mt(So),To=/* @__PURE__ */Ot(So),Mo=/* @__PURE__ */At(So),zo=/* @__PURE__ */Nt(So),Oo=/* @__PURE__ */Pt(So),Ro=/* @__PURE__ */Lt(So),Ao=/* @__PURE__ */$t(So),No=/* @__PURE__ */Dt(So),Po=/* @__PURE__ */Ft(So),Lo=/* @__PURE__ */jt(So),$o=/* @__PURE__ */new WeakMap;function Do(e,t,n){const r=Object.getPrototypeOf(e);let o=$o.get(r);if(o||(o=/* @__PURE__ */new Set,$o.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 Fo=/*@__PURE__*/Ze("ZodType",(e,t)=>(An.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:po(e,"input"),output:po(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=so({...n,processors:t});return ao(e,r),co(r,e),lo(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Io(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Eo(e,t,n),e.parseAsync=async(t,n)=>Co(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>To(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Mo(e,t,n),e.decode=(t,n)=>zo(e,t,n),e.encodeAsync=async(t,n)=>Oo(e,t,n),e.decodeAsync=async(t,n)=>Ro(e,t,n),e.safeEncode=(t,n)=>Ao(e,t,n),e.safeDecode=(t,n)=>No(e,t,n),e.safeEncodeAsync=async(t,n)=>Po(e,t,n),e.safeDecodeAsync=async(t,n)=>Lo(e,t,n),Do(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)})}(qi,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=/* @__PURE__ */io(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(_t(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(_t(r))}},e(t.value,t)),t);return n}(e,t)}(e,t))},overwrite(e){return this.check(oo(e))},optional(){return Ni(this)},exactOptional(){return new Pi({type:"optional",innerType:this})},nullable(){return $i(this)},nullish(){return Ni($i(this))},nonoptional(e){return function(e,t){return new ji({type:"nonoptional",innerType:e,...mt(t)})}(this,e)},array(){return xi(this)},or(e){return Ii([this,e])},and(e){return new Ci({type:"intersection",left:this,right:e})},transform(e){return Bi(this,new Ri({type:"transform",transform:e}))},default(e){return t=e,new Di({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():ut(t)}});var t},prefault(e){return t=e,new Fi({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():ut(t)}});var t},catch(e){return new Ui({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Bi(this,e)},readonly(){return new Hi({type:"readonly",innerType:this})},describe(e){const t=this.clone();return Zr.add(t,{description:e}),t},meta(...e){if(0===e.length)return Zr.get(this);const t=this.clone();return Zr.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:()=>Zr.get(e)?.description,configurable:!0}),e)),jo=/*@__PURE__*/Ze("_ZodString",(e,t)=>{Nn.init(e,t),Fo.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=ho[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,Do(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new Sn({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(no(...e))},max(...e){return this.check(to(...e))},length(...e){return this.check(ro(...e))},nonempty(...e){return this.check(no(1,...e))},lowercase(e){return this.check(function(e){return new In({check:"string_format",format:"lowercase",...mt(e)})}(e))},uppercase(e){return this.check(function(e){return new Cn({check:"string_format",format:"uppercase",...mt(e)})}(e))},trim(){return this.check(/* @__PURE__ */oo(e=>e.trim()))},normalize(...e){return this.check(function(e){/* @__PURE__ */
2
- return oo(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(/* @__PURE__ */oo(e=>e.toLowerCase()))},toUpperCase(){return this.check(/* @__PURE__ */oo(e=>e.toUpperCase()))},slugify(){return this.check(/* @__PURE__ */oo(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Uo=/*@__PURE__*/Ze("ZodString",(e,t)=>{Nn.init(e,t),jo.init(e,t),e.email=t=>e.check(Vr(Ho,t)),e.url=t=>e.check(Yr(Vo,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...mt(t)})}(ci,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...mt(t)})}(Go,t)),e.guid=t=>e.check(Gr(qo,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...mt(t)})}(Zo,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)})}(Zo,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)})}(Zo,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)})}(Zo,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...mt(t)})}(Yo,t)),e.guid=t=>e.check(Gr(qo,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...mt(t)})}(Ko,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...mt(t)})}(Jo,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...mt(t)})}(Xo,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...mt(t)})}(ii,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...mt(t)})}(si,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...mt(t)})}(Qo,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...mt(t)})}(ei,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...mt(t)})}(ti,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...mt(t)})}(ni,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...mt(t)})}(ri,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...mt(t)})}(oi,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...mt(t)})}(ai,t)),e.datetime=t=>e.check(go(t)),e.date=t=>e.check(bo(t)),e.time=t=>e.check(vo(t)),e.duration=t=>e.check(ko(t))});function Wo(e){return function(e,t){return new e({type:"string",...mt(t)})}(Uo,e)}var Bo=/*@__PURE__*/Ze("ZodStringFormat",(e,t)=>{Pn.init(e,t),jo.init(e,t)}),Ho=/*@__PURE__*/Ze("ZodEmail",(e,t)=>{Dn.init(e,t),Bo.init(e,t)});var qo=/*@__PURE__*/Ze("ZodGUID",(e,t)=>{Ln.init(e,t),Bo.init(e,t)}),Zo=/*@__PURE__*/Ze("ZodUUID",(e,t)=>{$n.init(e,t),Bo.init(e,t)}),Vo=/*@__PURE__*/Ze("ZodURL",(e,t)=>{Fn.init(e,t),Bo.init(e,t)});var Go=/*@__PURE__*/Ze("ZodEmoji",(e,t)=>{jn.init(e,t),Bo.init(e,t)}),Yo=/*@__PURE__*/Ze("ZodNanoID",(e,t)=>{Un.init(e,t),Bo.init(e,t)}),Ko=/*@__PURE__*/Ze("ZodCUID",(e,t)=>{Wn.init(e,t),Bo.init(e,t)}),Jo=/*@__PURE__*/Ze("ZodCUID2",(e,t)=>{Bn.init(e,t),Bo.init(e,t)}),Xo=/*@__PURE__*/Ze("ZodULID",(e,t)=>{Hn.init(e,t),Bo.init(e,t)}),Qo=/*@__PURE__*/Ze("ZodXID",(e,t)=>{qn.init(e,t),Bo.init(e,t)}),ei=/*@__PURE__*/Ze("ZodKSUID",(e,t)=>{Zn.init(e,t),Bo.init(e,t)}),ti=/*@__PURE__*/Ze("ZodIPv4",(e,t)=>{Jn.init(e,t),Bo.init(e,t)}),ni=/*@__PURE__*/Ze("ZodIPv6",(e,t)=>{Xn.init(e,t),Bo.init(e,t)}),ri=/*@__PURE__*/Ze("ZodCIDRv4",(e,t)=>{Qn.init(e,t),Bo.init(e,t)}),oi=/*@__PURE__*/Ze("ZodCIDRv6",(e,t)=>{er.init(e,t),Bo.init(e,t)}),ii=/*@__PURE__*/Ze("ZodBase64",(e,t)=>{nr.init(e,t),Bo.init(e,t)}),si=/*@__PURE__*/Ze("ZodBase64URL",(e,t)=>{rr.init(e,t),Bo.init(e,t)}),ai=/*@__PURE__*/Ze("ZodE164",(e,t)=>{or.init(e,t),Bo.init(e,t)}),ci=/*@__PURE__*/Ze("ZodJWT",(e,t)=>{ir.init(e,t),Bo.init(e,t)}),li=/*@__PURE__*/Ze("ZodNumber",(e,t)=>{sr.init(e,t),Fo.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),Do(e,"ZodNumber",{gt(e,t){return this.check(Xr(e,t))},gte(e,t){return this.check(Qr(e,t))},min(e,t){return this.check(Qr(e,t))},lt(e,t){return this.check(Kr(e,t))},lte(e,t){return this.check(Jr(e,t))},max(e,t){return this.check(Jr(e,t))},int(e){return this.check(pi(e))},safe(e){return this.check(pi(e))},positive(e){return this.check(Xr(0,e))},nonnegative(e){return this.check(Qr(0,e))},negative(e){return this.check(Kr(0,e))},nonpositive(e){return this.check(Jr(0,e))},multipleOf(e,t){return this.check(eo(e,t))},step(e,t){return this.check(eo(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 di(e){return function(e,t){return new e({type:"number",checks:[],...mt(t)})}(li,e)}var ui=/*@__PURE__*/Ze("ZodNumberFormat",(e,t)=>{ar.init(e,t),li.init(e,t)});function pi(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...mt(t)})}(ui,e)}var hi=/*@__PURE__*/Ze("ZodBoolean",(e,t)=>{cr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function fi(e){return function(e,t){return new e({type:"boolean",...mt(t)})}(hi,e)}var mi=/*@__PURE__*/Ze("ZodUnknown",(e,t)=>{lr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function gi(){return new mi({type:"unknown"})}var yi=/*@__PURE__*/Ze("ZodNever",(e,t)=>{dr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function bi(e){return function(e,t){return new e({type:"never",...mt(t)})}(yi,e)}var wi=/*@__PURE__*/Ze("ZodDate",(e,t)=>{ur.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Date cannot be represented in JSON Schema")})(0,e),e.min=(t,n)=>e.check(Qr(t,n)),e.max=(t,n)=>e.check(Jr(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}),vi=/*@__PURE__*/Ze("ZodArray",(e,t)=>{hr.init(e,t),Fo.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=ao(i.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,Do(e,"ZodArray",{min(e,t){return this.check(no(e,t))},nonempty(e){return this.check(no(1,e))},max(e,t){return this.check(to(e,t))},length(e,t){return this.check(ro(e,t))},unwrap(){return this.element}})});function xi(e,t){return function(e,t,n){return new e({type:"array",element:t,...mt(n)})}(vi,e,t)}var ki=/*@__PURE__*/Ze("ZodObject",(e,t)=>{br.init(e,t),Fo.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]=ao(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=ao(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)})(e,t,n,r),rt(e,"shape",()=>t.shape),Do(e,"ZodObject",{keyof(){return zi(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:gi()})},loose(){return this.clone({...this._zod.def,catchall:gi()})},strict(){return this.clone({...this._zod.def,catchall:bi()})},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:[]}))}(Ai,this,e[0])},required(...e){return t=ji,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 _i(e,t){const n={type:"object",shape:e??{},...mt(t)};return new ki(n)}var Si=/*@__PURE__*/Ze("ZodUnion",(e,t)=>{vr.init(e,t),Fo.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)=>ao(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 Ii(e,t){return new Si({type:"union",options:e,...mt(t)})}var Ci=/*@__PURE__*/Ze("ZodIntersection",(e,t)=>{xr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=ao(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=ao(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 Ei=/*@__PURE__*/Ze("ZodRecord",(e,t)=>{Sr.init(e,t),Fo.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=ao(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=ao(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=ao(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 Ti(e,t,n){return t&&t._zod?new Ei({type:"record",keyType:e,valueType:t,...mt(n)}):new Ei({type:"record",keyType:Wo(),valueType:e,...mt(t)})}var Mi=/*@__PURE__*/Ze("ZodEnum",(e,t)=>{Ir.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=Je(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 Mi({...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 Mi({...t,checks:[],...mt(r),entries:o})}});function zi(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Mi({type:"enum",entries:n,...mt(t)})}var Oi=/*@__PURE__*/Ze("ZodLiteral",(e,t)=>{Cr.init(e,t),Fo.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 Ri=/*@__PURE__*/Ze("ZodTransform",(e,t)=>{Er.init(e,t),Fo.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(_t(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(_t(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 Ai=/*@__PURE__*/Ze("ZodOptional",(e,t)=>{Mr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Ni(e){return new Ai({type:"optional",innerType:e})}var Pi=/*@__PURE__*/Ze("ZodExactOptional",(e,t)=>{zr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Li=/*@__PURE__*/Ze("ZodNullable",(e,t)=>{Or.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=ao(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 $i(e){return new Li({type:"nullable",innerType:e})}var Di=/*@__PURE__*/Ze("ZodDefault",(e,t)=>{Rr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;ao(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 Fi=/*@__PURE__*/Ze("ZodPrefault",(e,t)=>{Nr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;ao(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 ji=/*@__PURE__*/Ze("ZodNonOptional",(e,t)=>{Pr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;ao(o.innerType,t,r),t.seen.get(e).ref=o.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Ui=/*@__PURE__*/Ze("ZodCatch",(e,t)=>{$r.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;let i;ao(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 Wi=/*@__PURE__*/Ze("ZodPipe",(e,t)=>{Dr.init(e,t),Fo.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;ao(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function Bi(e,t){return new Wi({type:"pipe",in:e,out:t})}var Hi=/*@__PURE__*/Ze("ZodReadonly",(e,t)=>{jr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;ao(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 qi=/*@__PURE__*/Ze("ZodCustom",(e,t)=>{Br.init(e,t),Fo.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 Zi(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...mt(t)})}(li,e)}function Vi(e){return function(e,t){return new e({type:"date",coerce:!0,...mt(t)})}(wi,e)}var Gi,Yi,Ki=zi(["created","active","suspended"]),Ji=_i({id:di().optional(),created_at:Vi().optional(),updated_at:Vi().optional()}),Xi=(_i({id:Zi()}),_i({slug:Wo()}),_i({widget_id:Zi()}),_i({simulation_id:Zi()}),_i({application_id:Zi()}),_i({user_id:Zi()}),_i({limit:Zi().optional().default(50),offset:Zi().optional().default(0)}),Ii([fi(),Wo()]).transform(e=>"boolean"==typeof e?e:"true"===e||"false"!==e&&void 0).optional(),_i({success:function(e,t){return new Oi({type:"literal",values:Array.isArray(e)?e:[e],...mt(t)})}(!0)})),Qi=(Xi.extend({message:Wo()}),_i({name:Wo().min(1),params:Ti(Wo(),gi()).default({}),result:Ti(Wo(),gi()).default({})}),Yr(Vo,Gi).refine(e=>/^https:\/\/hooks\.slack\.com\//.test(e),{message:"Slack webhook URL must start with https://hooks.slack.com/"}),_i({start:Wo(),end:Wo(),action:Wo()}).passthrough()),es=_i({id:Wo(),label:Wo(),purpose:Wo(),elements:xi(Ti(Wo(),gi())).default([]),bbox:Ti(Wo(),gi()).default({}),screenshot:Wo().default(""),embedding:xi(di()).nullish()}).passthrough(),ts=_i({id:Wo(),title:Wo(),url:Wo(),summary:Wo().default(""),screenshot:Wo().default(""),sections:xi(es).default([]),sequence_ids:xi(di()).default([]),embedding:xi(di()).nullish()}).passthrough(),ns=(_i({nodes:xi(ts),edges:xi(Qi)}),zi(["free","startup","growth","enterprise"])),rs=zi(["document","video"]),os=zi(["user","research"]),is=zi(["queued","running","creating_knowledge","has_question","completed","failed","stopped"]),ss=zi(["pending","generating","completed","failed"]),as=zi(["app","website"]),cs=zi(["widget"]),ls=(zi(["tell","show","do"]),zi(["password","oauth"])),ds=zi(["admin","member"]),us=(Ji.extend({is_super:fi(),status:Ki,email:function(e){return Vr(Ho,e)}(),external_id:Wo().nullish(),first_name:Wo().nullish(),last_name:Wo().nullish(),password:Wo().nullish(),image_url:Wo().nullish(),last_login_at:Vi().nullish(),auth_method:ls.nullish(),workspace_role:ds.nullish()}),Ji.extend({name:Wo(),slug:Wo(),status:Ki,package:ns,ending_date:Vi().nullish(),external_workspace_id:Wo().nullish(),slack_webhook_configured:fi().optional(),notify_all_members_on_question:fi().optional()}),Ji.extend({workspace_id:di(),application_id:di().optional(),file_name:Wo().min(1),file_size:Zi(),file_type:rs,file_url:Wo(),source_url:Wo().nullish(),source:os.default("user").optional(),persona_id:di().nullish(),ingest_status:zi(["pending","embedding","ready","failed","unsupported"]).default("pending").optional(),ingest_error:Wo().nullish(),extracted_chars:di().default(0).optional()}),Ji.extend({workspace_id:di(),application_id:di(),persona_id:di(),file_name:Wo().min(1),file_size:Zi(),file_type:Wo(),file_url:Wo()}),zi(["desktop","tablet","mobile"])),ps=(_i({journey_id:di().int(),persona_id:di().int()}),zi(["positive","neutral","negative"])),hs=_i({step_index:di(),screenshot_ref:Wo().nullable(),reaction:Wo(),sentiment:ps}),fs=_i({id:di(),run_id:di().nullable(),persona_id:di().nullable(),user_index:di().nullable(),simulation_id:di().nullable(),study_variant_id:di().nullable(),study_task_id:di().nullable(),journey_reaction:Wo().nullable(),journey_sentiment:ps.nullable(),status:zi(["pending","completed","failed"]),step_reactions:xi(hs).default([]),question_answers:xi(_i({study_question_id:di(),answer:Wo()})).default([])}),ms=(Ji.extend({application_id:di(),job_id:Wo(),browser_session_id:Wo().nullish(),status:is,status_message:Wo(),path:Wo().nullish(),instructions:Wo(),name:Wo().nullish(),type:zi(["direct","uxr","survey","ab","qa"]),pinned:fi().optional(),source:zi(["direct","qa"]).optional(),graph_id:Wo().nullish(),source_metadata:Ti(Wo(),gi()).nullish(),step_count:di().int().nonnegative().nullish(),started_at:Vi().nullish(),completed_at:Vi().nullish(),output_persisted_at:Vi().nullish(),graph_status:ss.optional(),graph_steps_processed:di().int().nonnegative().optional(),graph_steps_total:di().int().nonnegative().optional(),graph_error:Wo().nullish(),created_by_user_id:di().nullish(),has_question:fi().optional(),riders:xi(_i({persona_id:di(),user_count:di().int().positive()})).default([]),reactions:xi(fs).default([]),driver_persona_id:di().nullable().default(null),viewport:us.default("desktop")}),Ji.extend({workspace_id:di(),name:Wo(),slug:Wo(),type:as,url:Wo(),username:Wo().nullish(),password:Wo().nullish(),allowed_domains:xi(Wo()).default([])}).omit({password:!0}),_i({chip_mode:zi(["show","tell","do"]),chip_text:Wo()})),gs=_i({widget_enabled:fi(),widget_appearance:zi(["default","compact","full","hidden"]),widget_position:zi(["bottom_left","bottom_right","top_left","top_right"]),widget_device:zi(["desktop","mobile","desktop_mobile"]),widget_header:Wo(),widget_body:Wo(),widget_greeting:Wo(),widget_greeting_toast:fi(),widget_recording:fi(),widget_feature_tell:fi(),widget_feature_show:fi(),widget_feature_do:fi(),widget_feature_human:fi(),widget_background_color:Wo(),widget_text_color:Wo(),widget_border_color:Wo(),widget_accent_color:Wo(),widget_secondary_color:Wo(),widget_border_radius:Wo(),widget_font_size:Wo(),widget_width:Wo(),widget_height:Wo(),widget_shadow:Wo(),widget_animation_duration:Wo(),widget_fade_duration:Wo(),widget_bounce_effect:fi(),widget_chips:xi(ms)}),ys=(Ji.extend({application_id:di(),type:cs,settings:gs,status:Ki,marketrix_id:Wo(),marketrix_key:Wo(),snippet:Wo().nullish()}),Ji.extend({widget_id:di(),url_pattern:Wo(),message:xi(Wo()),description:Wo().optional()}),zi(["created","running","finalizing","completed","failed","stopped"]),zi(["passed","failed","indecisive"]),zi(["passed","failed"]),zi(["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"])),bs=_i({details:Wo().optional(),id:di().optional(),type:Wo().optional(),name:Wo().optional(),target_user_id:di().optional(),target_user_email:Wo().optional(),reason:Wo().optional(),assigned_role:Wo().optional(),new_role:Wo().optional(),previous_role:Wo().optional(),workspace_name:Wo().optional(),workspace_slug:Wo().optional(),ip_address:Wo().optional(),user_agent:Wo().optional(),widget_type:Wo().optional(),created_by:di().optional()}).passthrough(),ws=(Ji.extend({workspace_id:di(),user_id:di().nullable(),type:ys,metadata:bs.optional()}).partial().extend({type:ys}),null),vs="";function xs(e){return _e(new qe({url:e,headers:()=>{const e={};return ws&&(e.Authorization=`Bearer ${ws}`),e}}))}Yi=xs("");var ks=e=>{if(!e?.trim())throw new Error("API URL is required for SDK configuration");e!==vs&&(vs=e,Yi=xs(e))},_s={setAuthToken:e=>{ws=e},clearAuthToken:()=>{ws=null},getAuthToken:()=>ws,configure:ks},Ss=new Proxy({},{get:(e,t)=>t in _s?_s[t]:Yi[t]}),Is="undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&!window.location.hostname.includes("localhost")?"error":"debug",Cs={debug:0,info:1,warn:2,error:3};function Es(e){return Cs[e]>=Cs[Is]}var Ts=[{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 Ms(e){return e.includes("__THINKING__")}function zs(e){return Ms(e)?e:`${e}\n\n__THINKING__`}function Os(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 Rs(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=Os(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=Os(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=Os(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 As(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 Ns=/* @__PURE__ */new Set(["click_element","type_text","send_keys","select_dropdown_option","upload_file","scroll"]),Ps=/* @__PURE__ */new Set(["click_element","type_text","select_dropdown_option","send_keys","upload_file"]);function Ls(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 $s(e,t,n,r=!1){const o=As(e);if(!t||"show"!==n&&"do"!==n)return Ms(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 Ms(o.content)?o.placeholderState!==i?{...o,placeholderState:i}:o:{...o,content:zs(o.content),placeholderState:i}}var Ds=Object.fromEntries(Ts.map(e=>[e.id,e.displayAction]));var Fs="marketrix_chat_context",js={chat_id:null,messages:[],isTaskRunning:!1,activeTaskId:null,currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1,config:null,timestamp:Date.now()},Us=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={...js},this.context;try{const e=localStorage.getItem(Fs);if(e){const t=JSON.parse(e);return Date.now()-t.timestamp>6048e5?(this.context={...js},this.saveContext(),this.context):(this.context=t,this.context)}}catch(e){}return this.context={...js},this.context}saveContext(){if("undefined"!=typeof window&&this.context)try{this.context.timestamp=Date.now(),localStorage.setItem(Fs,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)}getConfig(){return this.getContext().config}setConfig(e){this.updateContext({config:e})}hasValidContext(){const e=this.getContext();return null!==e.chat_id&&e.chat_id.length>0}}.getInstance(),Ws=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(Us.hasValidContext())return;Us.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=Us.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});Us.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 Bs(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 Hs(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 qs(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 Zs(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 Vs(e,t="show"){return{id:`screenshare-${Date.now()}`,content:"",sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,videoStream:e,parts:[]}}var Gs={debug:(e,...t)=>{Es("debug")},info:(e,...t)=>{Es("info")},warn:(e,...t)=>{Es("warn")},error:(e,...t)=>{Es("error")}},Ys=class e{static instance=null;chatId=null;initializationPromise=null;constructor(){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.chatId=this.getStoredChatId(),this.chatId&&Gs.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 Gs.debug("Returning existing chat ID:",this.chatId),this.chatId;if(this.initializationPromise)return Gs.debug("Chat ID initialization in progress, waiting..."),this.initializationPromise;const e=this.getStoredChatId();if(e)return this.chatId=e,Gs.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{Gs.info("Creating new chat ID...");const e=await Ss.chatCreate(void 0);if(!e)throw new Error("API returned empty chat ID");return this.chatId=e,this.storeChatId(e),Gs.info("Created and stored new chat ID:",this.chatId),Ws.createInitialContext(e),e}catch(e){throw Gs.error("Failed to create chat ID:",e),this.initializationPromise=null,e}}getStoredChatId(){return Us.getChatId()}storeChatId(e){Us.setChatId(e)}}.getInstance(),Ks=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 Ss.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?Ss.widgetMessagePost({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 Js(){return Ys.getChatId()}async function Xs(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:Js(),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),Ss.activityLogCreate({type:"widget_question",metadata:o}).catch(e=>{})}catch(r){}}function Qs(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 ea=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||Qs(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(),ta=null;async function na(){if(ta?.active){const e=ta.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return ta}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 ta=e,e.getVideoTracks()[0].addEventListener("ended",()=>{ta=null}),e}function ra(){return null!==function(){if(ta?.active){const e=ta.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return ta}return ta=null,null}()}var oa=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=ea.getSequenceForElement(this.currentElement)??-1,t=ea.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(),ia=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}=ea.getElementByIndex(n);if(!t)return{success:!1,data:{text:""},error:o||`Element ${n} not found`};if(!(await oa.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 oa.cleanup(),{success:!1,data:{text:""},error:o instanceof Error?o.message:String(o)}}}requiresHighlight(e){return Ps.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}=ea.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}=ea.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}=ea.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}=ea.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}=ea.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:ea.getSnapshotHtml()}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}getInteractableElements(){try{return{success:!0,data:{elements:ea.getInteractableElements()}}}catch(e){return{success:!1,data:{elements:[]},error:String(e)}}}async getScreenshot(){try{const e=await na();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(),sa=class e{static instance;config=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadConfig(){const e=Us.getConfig();return e?(this.config=e,e):(this.config={},this.config)}saveConfig(e){Us.setConfig(e),this.config=e}getConfig(){return this.config}}.getInstance();function aa(e,t={}){return{...t,...e}}var ca=e=>({state:e,effects:[]});function la(e,t,n,r,o,i,s){const a=function(e){return Ds[e]?Ds[e]:e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}(r),c=Rs({messages:e,isTaskRunning:t,currentMode:n,requireContent:"failed"===i});if(!c)return e;let l=c.message;const d=t&&"show"===n&&Ps.has(r),u="done"===r,p="show"===n||"do"===n;"in_progress"===i?(u||(l=function(e,t,n){const r=As(e),o=r.parts||[],i=[...o],s=o.findIndex(e=>"progress"===e.type&&e.browserToolName===t&&"in_progress"===e.status),a=!Ns.has(t),c="default",l=Ls(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=$s(l,t,n,d))):"completed"===i?(u||(l=function(e,t){const n=As(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=$s(l,t,n,!1))):(l=function(e,t,n){const r=As(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=Ls(s[a].content);s[a]={...s[a],status:"completed",content:e}}else{const e=Ls(n),t=Ls(s[a].content);s[a]={...s[a],status:"failed",content:e?`${t} (${e})`:t}}return{...r,parts:s}}(l,a,s||""),t&&p&&(l=$s(l,t,n,!1)));const h=[...e];return h[c.index]=l,h}function da(e,t,n,r,o,i){return{...e,messages:la(e.messages,e.task.isTaskRunning,o,t,n,r,i)}}var ua=n(void 0),pa={activeTaskId:null,isTaskRunning:!1},ha=({children:e,previewMode:t=!1,currentMode:n,uiActions:r,initialMessages:o,initialTask:s})=>{const[c,p]=u(()=>({messages:o??[],task:s??pa})),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]),_=i(()=>{b(e=>({...e,messages:[]}))},[b]),S=i(e=>{b(t=>({...t,task:{activeTaskId:e.activeTaskId,isTaskRunning:e.isTaskRunning}}))},[b]),I=i(async(e,n,o,i,s)=>{const a=n??f.current;if(t)return s||w(Bs(e,a)),void w(Hs("This is a preview. In production, I'll respond to your messages here."));let c=sa.getConfig();if(c||(c=sa.loadConfig()),!c||!c.mtxId&&!c.mtxKey&&!c.mtxApp)return void w(Hs("Configuration error: Missing API credentials. Please check your widget settings."));s||w(Bs(e,a));const l=`temp-${globalThis.crypto.randomUUID()}`,d={id:l,content:zs(""),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=Js();if(t){const e=Ks.getInstance();if(!e.isConnected()){const n=sa.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 Ys.getOrCreateChatId()))throw new Error("Failed to initialize chat session");const n=t.mode||"tell";if(t.message&&await Xs(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||""};Ks.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]),C=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=Ks.getInstance(),n=async t=>{const{toolCallId:n,tool:r,args:o,mode:i,explanation:s}=t,a=await ia.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=>da(e,r,s,"completed",f.current)),"done"===r&&(y.current={},b(e=>function(e,t){const n=Rs({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=>da(e,r,s,"failed",f.current,"Connection error"))}else b(e=>da(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(C(n),!Ts.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:la(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 ca(e);if("has_question"===t.status){const t=Rs({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:n,requireContent:!1}),o=[...e.messages];if(t){const e=$s(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=Rs({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 ca(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,C,r]);const T=i(async()=>{const e=h.current.task.activeTaskId??void 0;b(e=>function(e,t){const n=Rs({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||Ks.getInstance().send({type:"chat/stop",...e&&{task_id:e}}).catch(e=>{})},[t,b]),M=l(()=>({addMessage:w,updateMessage:v,removeMessage:x,setMessages:k,clearMessages:_,messageDispatch:I}),[w,v,x,k,_,I]),z=l(()=>({setTaskState:S,stopTask:T}),[S,T]),O=l(()=>({messages:c.messages}),[c.messages]);/* @__PURE__ */
1
+ import*as e from"react";import t,{createContext as n,createElement as r,forwardRef as o,useCallback as i,useContext as s,useEffect as a,useLayoutEffect as c,useMemo as l,useRef as d,useState as u,useSyncExternalStore as p}from"react";import{createRoot as h}from"react-dom/client";import{Fragment as f,jsx as m,jsxs as g}from"react/jsx-runtime";import*as y from"react-dom";var b=2147483002,w=2147483001,v=2147483005;function x(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?{r:parseInt(t[1],16),g:parseInt(t[2],16),b:parseInt(t[3],16)}:null}function k(e){return function(e){const t=x(e);if(!t)return.5;const[n,r,o]=[t.r/255,t.g/255,t.b/255].map(e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4));return.2126*n+.7152*r+.0722*o}(e)>.5?"#000000":"#ffffff"}function S(e,t){if(e.startsWith("rgba")||e.startsWith("rgb")){const n=e.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(n)return`rgba(${n[1]}, ${n[2]}, ${n[3]}, ${t})`}const n=x(e);return n?`rgba(${n.r}, ${n.g}, ${n.b}, ${t})`:e}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 I=e=>e?e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):/* @__PURE__ */(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),C=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.14/otel/config__"]}function N(e,t={},n){return(A()?.tracer)?.startSpan(e,t,n)}function P(e,t,n={}){if(!e)return;const r=function(e){if(e instanceof Error){const t={message:e.message,name:e.name,stack:e.stack};return!("code"in e)||"string"!=typeof e.code&&"number"!=typeof e.code||(t.code=e.code),t}return{message:String(e)}}(t);e.recordException(r),n.signal?.aborted&&n.signal.reason===t||e.setStatus({code:2,message:r.message})}async function L({name:e,context:t,...n},r){const o=A()?.tracer;if(!o)return r();const i=async e=>{try{return await r(e)}catch(t){throw P(e,t,n),t}finally{e.end()}};return t?o.startActiveSpan(e,n,t,i):o.startActiveSpan(e,n,i)}async function $(e,t){const n=A();if(!e||!n)return t();const r=n.trace.setSpan(n.context.active(),e);return n.context.with(r,t)}function D(e){return!(!e||"object"!=typeof e)&&("next"in e&&"function"==typeof e.next&&Symbol.asyncIterator in e&&"function"==typeof e[Symbol.asyncIterator])}var F=Symbol.asyncDispose??Symbol.for("asyncDispose"),j=class{#e=!1;#t=!1;#n;#r;constructor(e,t){this.#n=t,this.#r=function(e){let t=Promise.resolve();return(...n)=>t=t.catch(()=>{}).then(()=>e(...n))}(async()=>{if(this.#e)return{done:!0,value:void 0};try{const t=await e();return t.done&&(this.#e=!0),t}catch(t){throw this.#e=!0,t}finally{this.#e&&!this.#t&&(this.#t=!0,await this.#n("next"))}})}next(){return this.#r()}async return(e){return this.#e=!0,this.#t||(this.#t=!0,await this.#n("return")),{done:!0,value:e}}async throw(e){throw this.#e=!0,this.#t||(this.#t=!0,await this.#n("throw")),e}async[F](){this.#e=!0,this.#t||(this.#t=!0,await this.#n("dispose"))}[Symbol.asyncIterator](){return this}};function U({name:e,...t},n){let r;return new j(async()=>{r??=N(e);try{const e=await $(r,()=>n.next());return r?.addEvent(e.done?"completed":"yielded"),e}catch(o){throw P(r,o,t),o}},async e=>{try{"next"!==e&&await $(r,()=>n.return?.())}catch(o){throw P(r,o,t),o}finally{r?.end()}})}function W(e,t,n){const r=(t,o)=>{const i=e[o];return i?i({...t,next:(e=t)=>r(e,o+1)}):n(t)};return r(t,0)}function B(e){if(e)return JSON.parse(e)}function H(e){return JSON.stringify(e)}function q(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||!t||!t.constructor}function Z(e){return!!e&&("object"==typeof e||"function"==typeof e)}function V(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 K,J={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.14/error/ORPC_ERROR_CONSTRUCTORS__");globalThis[t]??=/* @__PURE__ */new WeakSet,(K=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||J[e]?.message||e}(e,n.message);super(r,n),this.code=e,this.status=function(e,t){return t??J[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(K.has(this)){const t=function(e){return Z(e)?Object.getPrototypeOf(e)?.constructor:null}(e);if(t&&K.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 Z(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&&Z(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&&Z(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 $(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 Z(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 Z(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 $(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 Ie(e,t,n={}){if(e instanceof ReadableStream)return e;const r=t.get("content-disposition");return t.delete("content-type"),t.delete("content-disposition"),void 0!==e?e instanceof Blob?(t.set("content-type",e.type),t.set("content-length",e.size.toString()),t.set("content-disposition",r??function(e,t="inline"){return`${t}; filename="${e.replace(/[^\x20-\x7E]/g,"_").replace(/"/g,'\\"')}"; filename*=utf-8''${encodeURIComponent(e).replace(/['()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`).replace(/%(7C|60|5E)/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}`}(e instanceof File?e.name:"blob")),e):e instanceof FormData||e instanceof URLSearchParams?e:D(e)?(t.set("content-type","text/event-stream"),function(e,t={}){const n=t.eventIteratorKeepAliveEnabled??!0,r=t.eventIteratorKeepAliveInterval??5e3,o=t.eventIteratorKeepAliveComment??"",i=t.eventIteratorInitialCommentEnabled??!0,s=t.eventIteratorInitialComment??"";let a,c,l=!1;return new ReadableStream({start(e){c=N("stream_event_iterator"),i&&e.enqueue(ye({comments:[s]}))},async pull(t){try{n&&(a=setInterval(()=>{t.enqueue(ye({comments:[o]})),c?.addEvent("keepalive")},r));const i=await $(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 $(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 Ce(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=Ie(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(".")),D(t)&&(t=U({name:"consume_event_iterator_input",signal:n.signal},t)),W(this.interceptors,{...n,path:e,input:t},async({path:e,input:t,...n})=>{const o=A();let i;const s=o?.trace.getActiveSpan()??r;s&&o&&(i=o?.trace.setSpan(o.context.active(),s));const a=await L({name:"encode_request",context:i},()=>this.codec.encode(e,t,n)),c=await W(this.clientInterceptors,{...n,input:t,path:e,request:a},({input:e,path:t,request:n,...r})=>L({name:"send_request",signal:r.signal,context:i},()=>this.sender.call(n,r,t,e))),l=await L({name:"decode_response",context:i},()=>this.codec.decode(c,n,e,t));return D(l)?U({name:"consume_event_iterator_output",signal:n.signal},l):l})))}},ze=0,Oe=1,Re=2,Ae=3,Ne=4,Pe=5,Le=6,$e=7,De=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([$e,...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 $e: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?Ce(e):e}(await V(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 V(this.expectedMethod,n,e,t),i=await V(this.baseUrl,n,e,t),s=new URL(i);s.pathname=`${s.pathname.replace(/\/$/,"")}${function(e){return`/${e.map(encodeURIComponent).join("/")}`}(e)}`;const a=this.serializer.serialize(t);if(!("GET"!==o||a instanceof FormData||D(a))){const i=await V(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(J).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 D(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 D(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 De(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=Ce(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 Ze(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 Ve=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 Ke(e){return e&&Object.assign(Ye,e),Ye}function Je(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})},It=Ze("$ZodError",_t),Ct=Ze("$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 Ve;if(s.issues.length){const t=new(o?.Err??e)(s.issues.map(e=>xt(e,i,Ke())));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,Ke())));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 Ve;return i.issues.length?{success:!1,error:new(e??It)(i.issues.map(e=>xt(e,o,Ke())))}:{success:!0,data:i.value}},zt=/* @__PURE__*/Mt(Ct),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,Ke())))}:{success:!0,data:i.value}},Rt=/* @__PURE__*/Ot(Ct),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),$t=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Mt(e)(t,n,o)},Dt=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}$/,Zt=/^[a-zA-Z0-9_-]{21}$/,Vt=/^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)$/,Kt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Jt=/^(?:(?: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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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})}}),In=/*@__PURE__*/Ze("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=pn),Sn.init(e,t)}),Cn=/*@__PURE__*/Ze("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=hn),Sn.init(e,t)}),En=/*@__PURE__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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 Ve;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 Ve;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 Ve;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__*/Ze("$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__*/Ze("$ZodStringFormat",(e,t)=>{Sn.init(e,t),Nn.init(e,t)}),Ln=/*@__PURE__*/Ze("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Gt),Pn.init(e,t)}),$n=/*@__PURE__*/Ze("$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)}),Dn=/*@__PURE__*/Ze("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Kt),Pn.init(e,t)}),Fn=/*@__PURE__*/Ze("$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__*/Ze("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Pn.init(e,t)}),Un=/*@__PURE__*/Ze("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Zt),Pn.init(e,t)}),Wn=/*@__PURE__*/Ze("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ut),Pn.init(e,t)}),Bn=/*@__PURE__*/Ze("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Wt),Pn.init(e,t)}),Hn=/*@__PURE__*/Ze("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Bt),Pn.init(e,t)}),qn=/*@__PURE__*/Ze("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ht),Pn.init(e,t)}),Zn=/*@__PURE__*/Ze("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=qt),Pn.init(e,t)}),Vn=/*@__PURE__*/Ze("$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__*/Ze("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=an),Pn.init(e,t)}),Yn=/*@__PURE__*/Ze("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${cn(t)}$`)),Pn.init(e,t)}),Kn=/*@__PURE__*/Ze("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Vt),Pn.init(e,t)}),Jn=/*@__PURE__*/Ze("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Jt),Pn.init(e,t),e._zod.bag.format="ipv4"}),Xn=/*@__PURE__*/Ze("$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__*/Ze("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Qt),Pn.init(e,t)}),er=/*@__PURE__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$ZodE164",(e,t)=>{t.pattern??(t.pattern=on),Pn.init(e,t)});var ir=/*@__PURE__*/Ze("$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__*/Ze("$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__*/Ze("$ZodNumberFormat",(e,t)=>{wn.init(e,t),sr.init(e,t)}),cr=/*@__PURE__*/Ze("$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__*/Ze("$ZodUnknown",(e,t)=>{An.init(e,t),e._zod.parse=e=>e}),dr=/*@__PURE__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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&&lt.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,Ke())))}),t)}var vr=/*@__PURE__*/Ze("$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__*/Ze("$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__*/Ze("$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,Ke())),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,Ke())),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}}),Ir=/*@__PURE__*/Ze("$ZodEnum",(e,t)=>{An.init(e,t);const n=Je(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}}),Cr=/*@__PURE__*/Ze("$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__*/Ze("$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 Ve;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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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__*/Ze("$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 $r=/*@__PURE__*/Ze("$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,Ke()))},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,Ke()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Dr=/*@__PURE__*/Ze("$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__*/Ze("$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__*/Ze("$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 Zr=globalThis.__zod_globalRegistry;function Vr(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...mt(t)})}function Gr(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...mt(t)})}function Yr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...mt(t)})}function Kr(e,t){return new gn({check:"less_than",...mt(t),value:e,inclusive:!1})}function Jr(e,t){return new gn({check:"less_than",...mt(t),value:e,inclusive:!0})}function Xr(e,t){return new yn({check:"greater_than",...mt(t),value:e,inclusive:!1})}function Qr(e,t){return new yn({check:"greater_than",...mt(t),value:e,inclusive:!0})}function eo(e,t){return new bn({check:"multiple_of",...mt(t),value:e})}function to(e,t){return new vn({check:"max_length",...mt(t),maximum:e})}function no(e,t){return new xn({check:"min_length",...mt(t),minimum:e})}function ro(e,t){return new kn({check:"length_equals",...mt(t),length:e})}function oo(e){return new zn({check:"overwrite",tx:e})}function io(e,t){const n=new fn({check:"custom",...mt(t)});return n._zod.check=e,n}function so(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??Zr,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 ao(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),ao(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&&uo(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 co(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 lo(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:po(t,"input",e.processors),output:po(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(a){throw new Error("Error converting schema to JSON.")}}function uo(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 uo(r.element,n);if("set"===r.type)return uo(r.valueType,n);if("lazy"===r.type)return uo(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 uo(r.innerType,n);if("intersection"===r.type)return uo(r.left,n)||uo(r.right,n);if("record"===r.type||"map"===r.type)return uo(r.keyType,n)||uo(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(uo(r.in,n)||uo(r.out,n));if("object"===r.type){for(const e in r.shape)if(uo(r.shape[e],n))return!0;return!1}if("union"===r.type){for(const e of r.options)if(uo(e,n))return!0;return!1}if("tuple"===r.type){for(const e of r.items)if(uo(e,n))return!0;return!(!r.rest||!uo(r.rest,n))}return!1}var po=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=so({...o??{},target:i,io:t,processors:n});return ao(e,s),co(s,e),lo(s,e)},ho={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},fo=(e,t,n,r)=>{const o=e._zod.def;ao(o.innerType,t,r);t.seen.get(e).ref=o.innerType},mo=/*@__PURE__*/Ze("ZodISODateTime",(e,t)=>{Vn.init(e,t),Bo.init(e,t)});function go(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...mt(t)})}(mo,e)}var yo=/*@__PURE__*/Ze("ZodISODate",(e,t)=>{Gn.init(e,t),Bo.init(e,t)});function bo(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...mt(t)})}(yo,e)}var wo=/*@__PURE__*/Ze("ZodISOTime",(e,t)=>{Yn.init(e,t),Bo.init(e,t)});function vo(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...mt(t)})}(wo,e)}var xo=/*@__PURE__*/Ze("ZodISODuration",(e,t)=>{Kn.init(e,t),Bo.init(e,t)});function ko(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...mt(t)})}(xo,e)}var So=(e,t)=>{It.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}})},_o=/*@__PURE__*/Ze("ZodError",So,{Parent:Error}),Io=/* @__PURE__ */Et(_o),Co=/* @__PURE__ */Tt(_o),Eo=/* @__PURE__ */Mt(_o),To=/* @__PURE__ */Ot(_o),Mo=/* @__PURE__ */At(_o),zo=/* @__PURE__ */Nt(_o),Oo=/* @__PURE__ */Pt(_o),Ro=/* @__PURE__ */Lt(_o),Ao=/* @__PURE__ */$t(_o),No=/* @__PURE__ */Dt(_o),Po=/* @__PURE__ */Ft(_o),Lo=/* @__PURE__ */jt(_o),$o=/* @__PURE__ */new WeakMap;function Do(e,t,n){const r=Object.getPrototypeOf(e);let o=$o.get(r);if(o||(o=/* @__PURE__ */new Set,$o.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 Fo=/*@__PURE__*/Ze("ZodType",(e,t)=>(An.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:po(e,"input"),output:po(e,"output")}}),e.toJSONSchema=((e,t={})=>n=>{const r=so({...n,processors:t});return ao(e,r),co(r,e),lo(r,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Io(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Eo(e,t,n),e.parseAsync=async(t,n)=>Co(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>To(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Mo(e,t,n),e.decode=(t,n)=>zo(e,t,n),e.encodeAsync=async(t,n)=>Oo(e,t,n),e.decodeAsync=async(t,n)=>Ro(e,t,n),e.safeEncode=(t,n)=>Ao(e,t,n),e.safeDecode=(t,n)=>No(e,t,n),e.safeEncodeAsync=async(t,n)=>Po(e,t,n),e.safeDecodeAsync=async(t,n)=>Lo(e,t,n),Do(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)})}(qi,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return function(e,t){const n=/* @__PURE__ */io(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(oo(e))},optional(){return Ni(this)},exactOptional(){return new Pi({type:"optional",innerType:this})},nullable(){return $i(this)},nullish(){return Ni($i(this))},nonoptional(e){return function(e,t){return new ji({type:"nonoptional",innerType:e,...mt(t)})}(this,e)},array(){return xi(this)},or(e){return Ii([this,e])},and(e){return new Ci({type:"intersection",left:this,right:e})},transform(e){return Bi(this,new Ri({type:"transform",transform:e}))},default(e){return t=e,new Di({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():ut(t)}});var t},prefault(e){return t=e,new Fi({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():ut(t)}});var t},catch(e){return new Ui({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:()=>t});var t},pipe(e){return Bi(this,e)},readonly(){return new Hi({type:"readonly",innerType:this})},describe(e){const t=this.clone();return Zr.add(t,{description:e}),t},meta(...e){if(0===e.length)return Zr.get(this);const t=this.clone();return Zr.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:()=>Zr.get(e)?.description,configurable:!0}),e)),jo=/*@__PURE__*/Ze("_ZodString",(e,t)=>{Nn.init(e,t),Fo.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=ho[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,Do(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(no(...e))},max(...e){return this.check(to(...e))},length(...e){return this.check(ro(...e))},nonempty(...e){return this.check(no(1,...e))},lowercase(e){return this.check(function(e){return new In({check:"string_format",format:"lowercase",...mt(e)})}(e))},uppercase(e){return this.check(function(e){return new Cn({check:"string_format",format:"uppercase",...mt(e)})}(e))},trim(){return this.check(/* @__PURE__ */oo(e=>e.trim()))},normalize(...e){return this.check(function(e){/* @__PURE__ */
2
+ return oo(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(/* @__PURE__ */oo(e=>e.toLowerCase()))},toUpperCase(){return this.check(/* @__PURE__ */oo(e=>e.toUpperCase()))},slugify(){return this.check(/* @__PURE__ */oo(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})}),Uo=/*@__PURE__*/Ze("ZodString",(e,t)=>{Nn.init(e,t),jo.init(e,t),e.email=t=>e.check(Vr(Ho,t)),e.url=t=>e.check(Yr(Vo,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...mt(t)})}(ci,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...mt(t)})}(Go,t)),e.guid=t=>e.check(Gr(qo,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...mt(t)})}(Zo,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)})}(Zo,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)})}(Zo,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)})}(Zo,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...mt(t)})}(Yo,t)),e.guid=t=>e.check(Gr(qo,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...mt(t)})}(Ko,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...mt(t)})}(Jo,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...mt(t)})}(Xo,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...mt(t)})}(ii,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...mt(t)})}(si,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...mt(t)})}(Qo,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...mt(t)})}(ei,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...mt(t)})}(ti,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...mt(t)})}(ni,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...mt(t)})}(ri,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...mt(t)})}(oi,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...mt(t)})}(ai,t)),e.datetime=t=>e.check(go(t)),e.date=t=>e.check(bo(t)),e.time=t=>e.check(vo(t)),e.duration=t=>e.check(ko(t))});function Wo(e){return function(e,t){return new e({type:"string",...mt(t)})}(Uo,e)}var Bo=/*@__PURE__*/Ze("ZodStringFormat",(e,t)=>{Pn.init(e,t),jo.init(e,t)}),Ho=/*@__PURE__*/Ze("ZodEmail",(e,t)=>{Dn.init(e,t),Bo.init(e,t)});var qo=/*@__PURE__*/Ze("ZodGUID",(e,t)=>{Ln.init(e,t),Bo.init(e,t)}),Zo=/*@__PURE__*/Ze("ZodUUID",(e,t)=>{$n.init(e,t),Bo.init(e,t)}),Vo=/*@__PURE__*/Ze("ZodURL",(e,t)=>{Fn.init(e,t),Bo.init(e,t)});var Go=/*@__PURE__*/Ze("ZodEmoji",(e,t)=>{jn.init(e,t),Bo.init(e,t)}),Yo=/*@__PURE__*/Ze("ZodNanoID",(e,t)=>{Un.init(e,t),Bo.init(e,t)}),Ko=/*@__PURE__*/Ze("ZodCUID",(e,t)=>{Wn.init(e,t),Bo.init(e,t)}),Jo=/*@__PURE__*/Ze("ZodCUID2",(e,t)=>{Bn.init(e,t),Bo.init(e,t)}),Xo=/*@__PURE__*/Ze("ZodULID",(e,t)=>{Hn.init(e,t),Bo.init(e,t)}),Qo=/*@__PURE__*/Ze("ZodXID",(e,t)=>{qn.init(e,t),Bo.init(e,t)}),ei=/*@__PURE__*/Ze("ZodKSUID",(e,t)=>{Zn.init(e,t),Bo.init(e,t)}),ti=/*@__PURE__*/Ze("ZodIPv4",(e,t)=>{Jn.init(e,t),Bo.init(e,t)}),ni=/*@__PURE__*/Ze("ZodIPv6",(e,t)=>{Xn.init(e,t),Bo.init(e,t)}),ri=/*@__PURE__*/Ze("ZodCIDRv4",(e,t)=>{Qn.init(e,t),Bo.init(e,t)}),oi=/*@__PURE__*/Ze("ZodCIDRv6",(e,t)=>{er.init(e,t),Bo.init(e,t)}),ii=/*@__PURE__*/Ze("ZodBase64",(e,t)=>{nr.init(e,t),Bo.init(e,t)}),si=/*@__PURE__*/Ze("ZodBase64URL",(e,t)=>{rr.init(e,t),Bo.init(e,t)}),ai=/*@__PURE__*/Ze("ZodE164",(e,t)=>{or.init(e,t),Bo.init(e,t)}),ci=/*@__PURE__*/Ze("ZodJWT",(e,t)=>{ir.init(e,t),Bo.init(e,t)}),li=/*@__PURE__*/Ze("ZodNumber",(e,t)=>{sr.init(e,t),Fo.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),Do(e,"ZodNumber",{gt(e,t){return this.check(Xr(e,t))},gte(e,t){return this.check(Qr(e,t))},min(e,t){return this.check(Qr(e,t))},lt(e,t){return this.check(Kr(e,t))},lte(e,t){return this.check(Jr(e,t))},max(e,t){return this.check(Jr(e,t))},int(e){return this.check(pi(e))},safe(e){return this.check(pi(e))},positive(e){return this.check(Xr(0,e))},nonnegative(e){return this.check(Qr(0,e))},negative(e){return this.check(Kr(0,e))},nonpositive(e){return this.check(Jr(0,e))},multipleOf(e,t){return this.check(eo(e,t))},step(e,t){return this.check(eo(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 di(e){return function(e,t){return new e({type:"number",checks:[],...mt(t)})}(li,e)}var ui=/*@__PURE__*/Ze("ZodNumberFormat",(e,t)=>{ar.init(e,t),li.init(e,t)});function pi(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...mt(t)})}(ui,e)}var hi=/*@__PURE__*/Ze("ZodBoolean",(e,t)=>{cr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function fi(e){return function(e,t){return new e({type:"boolean",...mt(t)})}(hi,e)}var mi=/*@__PURE__*/Ze("ZodUnknown",(e,t)=>{lr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function gi(){return new mi({type:"unknown"})}var yi=/*@__PURE__*/Ze("ZodNever",(e,t)=>{dr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function bi(e){return function(e,t){return new e({type:"never",...mt(t)})}(yi,e)}var wi=/*@__PURE__*/Ze("ZodDate",(e,t)=>{ur.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t)=>{if("throw"===t.unrepresentable)throw new Error("Date cannot be represented in JSON Schema")})(0,e),e.min=(t,n)=>e.check(Qr(t,n)),e.max=(t,n)=>e.check(Jr(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}),vi=/*@__PURE__*/Ze("ZodArray",(e,t)=>{hr.init(e,t),Fo.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=ao(i.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element,Do(e,"ZodArray",{min(e,t){return this.check(no(e,t))},nonempty(e){return this.check(no(1,e))},max(e,t){return this.check(to(e,t))},length(e,t){return this.check(ro(e,t))},unwrap(){return this.element}})});function xi(e,t){return function(e,t,n){return new e({type:"array",element:t,...mt(n)})}(vi,e,t)}var ki=/*@__PURE__*/Ze("ZodObject",(e,t)=>{br.init(e,t),Fo.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]=ao(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=ao(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(o.additionalProperties=!1)})(e,t,n,r),rt(e,"shape",()=>t.shape),Do(e,"ZodObject",{keyof(){return zi(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:gi()})},loose(){return this.clone({...this._zod.def,catchall:gi()})},strict(){return this.clone({...this._zod.def,catchall:bi()})},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:[]}))}(Ai,this,e[0])},required(...e){return t=ji,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 Si(e,t){const n={type:"object",shape:e??{},...mt(t)};return new ki(n)}var _i=/*@__PURE__*/Ze("ZodUnion",(e,t)=>{vr.init(e,t),Fo.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)=>ao(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 Ii(e,t){return new _i({type:"union",options:e,...mt(t)})}var Ci=/*@__PURE__*/Ze("ZodIntersection",(e,t)=>{xr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=ao(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=ao(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 Ei=/*@__PURE__*/Ze("ZodRecord",(e,t)=>{_r.init(e,t),Fo.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=ao(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=ao(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=ao(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 Ti(e,t,n){return t&&t._zod?new Ei({type:"record",keyType:e,valueType:t,...mt(n)}):new Ei({type:"record",keyType:Wo(),valueType:e,...mt(t)})}var Mi=/*@__PURE__*/Ze("ZodEnum",(e,t)=>{Ir.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{const r=Je(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 Mi({...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 Mi({...t,checks:[],...mt(r),entries:o})}});function zi(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Mi({type:"enum",entries:n,...mt(t)})}var Oi=/*@__PURE__*/Ze("ZodLiteral",(e,t)=>{Cr.init(e,t),Fo.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 Ri=/*@__PURE__*/Ze("ZodTransform",(e,t)=>{Er.init(e,t),Fo.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 Ai=/*@__PURE__*/Ze("ZodOptional",(e,t)=>{Mr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function Ni(e){return new Ai({type:"optional",innerType:e})}var Pi=/*@__PURE__*/Ze("ZodExactOptional",(e,t)=>{zr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fo(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Li=/*@__PURE__*/Ze("ZodNullable",(e,t)=>{Or.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def,i=ao(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 $i(e){return new Li({type:"nullable",innerType:e})}var Di=/*@__PURE__*/Ze("ZodDefault",(e,t)=>{Rr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;ao(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 Fi=/*@__PURE__*/Ze("ZodPrefault",(e,t)=>{Nr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;ao(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 ji=/*@__PURE__*/Ze("ZodNonOptional",(e,t)=>{Pr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;ao(o.innerType,t,r),t.seen.get(e).ref=o.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Ui=/*@__PURE__*/Ze("ZodCatch",(e,t)=>{$r.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;let i;ao(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 Wi=/*@__PURE__*/Ze("ZodPipe",(e,t)=>{Dr.init(e,t),Fo.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;ao(s,t,r),t.seen.get(e).ref=s})(e,t,0,r),e.in=t.in,e.out=t.out});function Bi(e,t){return new Wi({type:"pipe",in:e,out:t})}var Hi=/*@__PURE__*/Ze("ZodReadonly",(e,t)=>{jr.init(e,t),Fo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{const o=e._zod.def;ao(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 qi=/*@__PURE__*/Ze("ZodCustom",(e,t)=>{Br.init(e,t),Fo.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 Zi(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...mt(t)})}(li,e)}function Vi(e){return function(e,t){return new e({type:"date",coerce:!0,...mt(t)})}(wi,e)}var Gi,Yi,Ki=zi(["created","active","suspended"]),Ji=Si({id:di().optional(),created_at:Vi().optional(),updated_at:Vi().optional()}),Xi=(Si({id:Zi()}),Si({slug:Wo()}),Si({widget_id:Zi()}),Si({simulation_id:Zi()}),Si({application_id:Zi()}),Si({user_id:Zi()}),Si({limit:Zi().optional().default(50),offset:Zi().optional().default(0)}),Ii([fi(),Wo()]).transform(e=>"boolean"==typeof e?e:"true"===e||"false"!==e&&void 0).optional(),Si({success:function(e,t){return new Oi({type:"literal",values:Array.isArray(e)?e:[e],...mt(t)})}(!0)})),Qi=(Xi.extend({message:Wo()}),Si({name:Wo().min(1),params:Ti(Wo(),gi()).default({}),result:Ti(Wo(),gi()).default({})}),Yr(Vo,Gi).refine(e=>/^https:\/\/hooks\.slack\.com\//.test(e),{message:"Slack webhook URL must start with https://hooks.slack.com/"}),Si({start:Wo(),end:Wo(),action:Wo()}).passthrough()),es=Si({id:Wo(),label:Wo(),purpose:Wo(),elements:xi(Ti(Wo(),gi())).default([]),bbox:Ti(Wo(),gi()).default({}),screenshot:Wo().default(""),embedding:xi(di()).nullish()}).passthrough(),ts=Si({id:Wo(),title:Wo(),url:Wo(),summary:Wo().default(""),screenshot:Wo().default(""),sections:xi(es).default([]),sequence_ids:xi(di()).default([]),embedding:xi(di()).nullish()}).passthrough(),ns=(Si({nodes:xi(ts),edges:xi(Qi)}),zi(["free","startup","growth","enterprise"])),rs=zi(["document","video"]),os=zi(["user","research"]),is=zi(["queued","running","creating_knowledge","has_question","completed","failed","stopped"]),ss=zi(["pending","generating","completed","failed"]),as=zi(["app","website"]),cs=zi(["widget"]),ls=(zi(["tell","show","do"]),zi(["password","oauth"])),ds=zi(["admin","member"]),us=(Ji.extend({is_super:fi(),status:Ki,email:function(e){return Vr(Ho,e)}(),external_id:Wo().nullish(),first_name:Wo().nullish(),last_name:Wo().nullish(),password:Wo().nullish(),image_url:Wo().nullish(),last_login_at:Vi().nullish(),auth_method:ls.nullish(),workspace_role:ds.nullish()}),Ji.extend({name:Wo(),slug:Wo(),status:Ki,package:ns,ending_date:Vi().nullish(),external_workspace_id:Wo().nullish(),slack_webhook_configured:fi().optional(),notify_all_members_on_question:fi().optional()}),Ji.extend({workspace_id:di(),application_id:di().optional(),file_name:Wo().min(1),file_size:Zi(),file_type:rs,file_url:Wo(),source_url:Wo().nullish(),source:os.default("user").optional(),persona_id:di().nullish(),ingest_status:zi(["pending","embedding","ready","failed","unsupported"]).default("pending").optional(),ingest_error:Wo().nullish(),extracted_chars:di().default(0).optional()}),Ji.extend({workspace_id:di(),application_id:di(),persona_id:di(),file_name:Wo().min(1),file_size:Zi(),file_type:Wo(),file_url:Wo()}),zi(["desktop","tablet","mobile"])),ps=(Si({journey_id:di().int(),persona_id:di().int()}),zi(["positive","neutral","negative"])),hs=Si({step_index:di(),screenshot_ref:Wo().nullable(),reaction:Wo(),sentiment:ps}),fs=Si({id:di(),run_id:di().nullable(),persona_id:di().nullable(),user_index:di().nullable(),simulation_id:di().nullable(),study_variant_id:di().nullable(),study_task_id:di().nullable(),journey_reaction:Wo().nullable(),journey_sentiment:ps.nullable(),status:zi(["pending","completed","failed"]),step_reactions:xi(hs).default([]),question_answers:xi(Si({study_question_id:di(),answer:Wo()})).default([])}),ms=(Ji.extend({application_id:di(),job_id:Wo(),browser_session_id:Wo().nullish(),status:is,status_message:Wo(),path:Wo().nullish(),instructions:Wo(),name:Wo().nullish(),type:zi(["direct","uxr","survey","ab","qa"]),pinned:fi().optional(),source:zi(["direct","qa"]).optional(),graph_id:Wo().nullish(),source_metadata:Ti(Wo(),gi()).nullish(),step_count:di().int().nonnegative().nullish(),started_at:Vi().nullish(),completed_at:Vi().nullish(),output_persisted_at:Vi().nullish(),graph_status:ss.optional(),graph_steps_processed:di().int().nonnegative().optional(),graph_steps_total:di().int().nonnegative().optional(),graph_error:Wo().nullish(),created_by_user_id:di().nullish(),has_question:fi().optional(),riders:xi(Si({persona_id:di(),user_count:di().int().positive()})).default([]),reactions:xi(fs).default([]),driver_persona_id:di().nullable().default(null),viewport:us.default("desktop")}),Ji.extend({workspace_id:di(),name:Wo(),slug:Wo(),type:as,url:Wo(),username:Wo().nullish(),password:Wo().nullish(),allowed_domains:xi(Wo()).default([])}).omit({password:!0}),Si({chip_mode:zi(["show","tell","do"]),chip_text:Wo()})),gs=Si({widget_enabled:fi(),widget_appearance:zi(["default","compact","full","hidden"]),widget_position:zi(["bottom_left","bottom_right","top_left","top_right"]),widget_device:zi(["desktop","mobile","desktop_mobile"]),widget_header:Wo(),widget_body:Wo(),widget_greeting:Wo(),widget_greeting_toast:fi(),widget_recording:fi(),widget_feature_tell:fi(),widget_feature_show:fi(),widget_feature_do:fi(),widget_feature_human:fi(),widget_background_color:Wo(),widget_text_color:Wo(),widget_border_color:Wo(),widget_accent_color:Wo(),widget_secondary_color:Wo(),widget_border_radius:Wo(),widget_font_size:Wo(),widget_width:Wo(),widget_height:Wo(),widget_shadow:Wo(),widget_animation_duration:Wo(),widget_fade_duration:Wo(),widget_bounce_effect:fi(),widget_chips:xi(ms)}),ys=(Ji.extend({application_id:di(),type:cs,settings:gs,status:Ki,marketrix_id:Wo(),marketrix_key:Wo(),snippet:Wo().nullish()}),Ji.extend({widget_id:di(),url_pattern:Wo(),message:xi(Wo()),description:Wo().optional()}),zi(["created","running","finalizing","completed","failed","stopped"]),zi(["passed","failed","indecisive"]),zi(["passed","failed"]),zi(["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"])),bs=Si({details:Wo().optional(),id:di().optional(),type:Wo().optional(),name:Wo().optional(),target_user_id:di().optional(),target_user_email:Wo().optional(),reason:Wo().optional(),assigned_role:Wo().optional(),new_role:Wo().optional(),previous_role:Wo().optional(),workspace_name:Wo().optional(),workspace_slug:Wo().optional(),ip_address:Wo().optional(),user_agent:Wo().optional(),widget_type:Wo().optional(),created_by:di().optional()}).passthrough(),ws=(Ji.extend({workspace_id:di(),user_id:di().nullable(),type:ys,metadata:bs.optional()}).partial().extend({type:ys}),null),vs="";function xs(e){return Se(new qe({url:e,headers:()=>{const e={};return ws&&(e.Authorization=`Bearer ${ws}`),e}}))}Yi=xs("");var ks=e=>{if(!e?.trim())throw new Error("API URL is required for SDK configuration");e!==vs&&(vs=e,Yi=xs(e))},Ss={setAuthToken:e=>{ws=e},clearAuthToken:()=>{ws=null},getAuthToken:()=>ws,configure:ks},_s=new Proxy({},{get:(e,t)=>t in Ss?Ss[t]:Yi[t]}),Is="undefined"==typeof window||"localhost"!==window.location.hostname&&"127.0.0.1"!==window.location.hostname&&!window.location.hostname.includes("localhost")?"error":"debug",Cs={debug:0,info:1,warn:2,error:3};function Es(e){return Cs[e]>=Cs[Is]}var Ts=[{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 Ms(e){return e.includes("__THINKING__")}function zs(e){return Ms(e)?e:`${e}\n\n__THINKING__`}function Os(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 Rs(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=Os(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=Os(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=Os(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 As(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 Ns=/* @__PURE__ */new Set(["click_element","type_text","send_keys","select_dropdown_option","upload_file","scroll"]),Ps=/* @__PURE__ */new Set(["click_element","type_text","select_dropdown_option","send_keys","upload_file"]);function Ls(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 $s(e,t,n,r=!1){const o=As(e);if(!t||"show"!==n&&"do"!==n)return Ms(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 Ms(o.content)?o.placeholderState!==i?{...o,placeholderState:i}:o:{...o,content:zs(o.content),placeholderState:i}}var Ds=Object.fromEntries(Ts.map(e=>[e.id,e.displayAction]));var Fs="marketrix_chat_context",js={chat_id:null,messages:[],isTaskRunning:!1,activeTaskId:null,currentMode:"tell",isOpen:!1,isMinimized:!1,isLoading:!1,config:null,timestamp:Date.now()},Us=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={...js},this.context;try{const e=localStorage.getItem(Fs);if(e){const t=JSON.parse(e);return Date.now()-t.timestamp>6048e5?(this.context={...js},this.saveContext(),this.context):(this.context=t,this.context)}}catch(e){}return this.context={...js},this.context}saveContext(){if("undefined"!=typeof window&&this.context)try{this.context.timestamp=Date.now(),localStorage.setItem(Fs,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)}getConfig(){return this.getContext().config}setConfig(e){this.updateContext({config:e})}hasValidContext(){const e=this.getContext();return null!==e.chat_id&&e.chat_id.length>0}}.getInstance(),Ws=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(Us.hasValidContext())return;Us.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=Us.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});Us.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 Bs(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 Hs(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 qs(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 Zs(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 Vs(e,t="show"){return{id:`screenshare-${Date.now()}`,content:"",sender:"user",timestamp:/* @__PURE__ */new Date,mode:t,videoStream:e,parts:[]}}var Gs={debug:(e,...t)=>{Es("debug")},info:(e,...t)=>{Es("info")},warn:(e,...t)=>{Es("warn")},error:(e,...t)=>{Es("error")}},Ys=class e{static instance=null;chatId=null;initializationPromise=null;constructor(){"undefined"!=typeof window&&"undefined"!=typeof document&&(this.chatId=this.getStoredChatId(),this.chatId&&Gs.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 Gs.debug("Returning existing chat ID:",this.chatId),this.chatId;if(this.initializationPromise)return Gs.debug("Chat ID initialization in progress, waiting..."),this.initializationPromise;const e=this.getStoredChatId();if(e)return this.chatId=e,Gs.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{Gs.info("Creating new chat ID...");const e=await _s.chatCreate(void 0);if(!e)throw new Error("API returned empty chat ID");return this.chatId=e,this.storeChatId(e),Gs.info("Created and stored new chat ID:",this.chatId),Ws.createInitialContext(e),e}catch(e){throw Gs.error("Failed to create chat ID:",e),this.initializationPromise=null,e}}getStoredChatId(){return Us.getChatId()}storeChatId(e){Us.setChatId(e)}}.getInstance(),Ks=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,t)=>this.registrationWaiters.add({resolve:e,reject:t}))}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 _s.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;for(const e of this.registrationWaiters)e.reject(/* @__PURE__ */new Error("Stream disconnected before registration"));this.registrationWaiters.clear()}send(e){return this.chatId?_s.widgetMessagePost({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.resolve();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 Js(){return Ys.getChatId()}async function Xs(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:Js(),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),_s.activityLogCreate({type:"widget_question",metadata:o}).catch(e=>{})}catch(r){}}function Qs(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 ea=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||Qs(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(),ta=null;async function na(){if(ta?.active){const e=ta.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return ta}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 ta=e,e.getVideoTracks()[0].addEventListener("ended",()=>{ta=null}),e}function ra(){return null!==function(){if(ta?.active){const e=ta.getVideoTracks();if(e.length>0&&"live"===e[0].readyState)return ta}return ta=null,null}()}var oa=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=ea.getSequenceForElement(this.currentElement)??-1,t=ea.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(),ia=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}=ea.getElementByIndex(n);if(!t)return{success:!1,data:{text:""},error:o||`Element ${n} not found`};if(!(await oa.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 oa.cleanup(),{success:!1,data:{text:""},error:o instanceof Error?o.message:String(o)}}}requiresHighlight(e){return Ps.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}=ea.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}=ea.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}=ea.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}=ea.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}=ea.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:ea.getSnapshotHtml()}}}catch(e){return{success:!1,data:{text:""},error:String(e)}}}getInteractableElements(){try{return{success:!0,data:{elements:ea.getInteractableElements()}}}catch(e){return{success:!1,data:{elements:[]},error:String(e)}}}async getScreenshot(){try{const e=await na();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(),sa=class e{static instance;config=null;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}loadConfig(){const e=Us.getConfig();return e?(this.config=e,e):(this.config={},this.config)}saveConfig(e){Us.setConfig(e),this.config=e}getConfig(){return this.config}}.getInstance();function aa(e,t={}){return{...t,...e}}var ca=e=>({state:e,effects:[]});function la(e,t,n,r,o,i,s){const a=function(e){return Ds[e]?Ds[e]:e.replace(/([A-Z])/g," $1").replace(/_/g," ").trim().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}(r),c=Rs({messages:e,isTaskRunning:t,currentMode:n,requireContent:"failed"===i});if(!c)return e;let l=c.message;const d=t&&"show"===n&&Ps.has(r),u="done"===r,p="show"===n||"do"===n;"in_progress"===i?(u||(l=function(e,t,n){const r=As(e),o=r.parts||[],i=[...o],s=o.findIndex(e=>"progress"===e.type&&e.browserToolName===t&&"in_progress"===e.status),a=!Ns.has(t),c="default",l=Ls(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=$s(l,t,n,d))):"completed"===i?(u||(l=function(e,t){const n=As(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=$s(l,t,n,!1))):(l=function(e,t,n){const r=As(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=Ls(s[a].content);s[a]={...s[a],status:"completed",content:e}}else{const e=Ls(n),t=Ls(s[a].content);s[a]={...s[a],status:"failed",content:e?`${t} (${e})`:t}}return{...r,parts:s}}(l,a,s||""),t&&p&&(l=$s(l,t,n,!1)));const h=[...e];return h[c.index]=l,h}function da(e,t,n,r,o,i){return{...e,messages:la(e.messages,e.task.isTaskRunning,o,t,n,r,i)}}var ua=n(void 0),pa={activeTaskId:null,isTaskRunning:!1},ha=({children:e,previewMode:t=!1,currentMode:n,uiActions:r,initialMessages:o,initialTask:s})=>{const[c,p]=u(()=>({messages:o??[],task:s??pa})),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]),I=i(async(e,n,o,i,s)=>{const a=n??f.current;if(t)return s||w(Bs(e,a)),void w(Hs("This is a preview. In production, I'll respond to your messages here."));let c=sa.getConfig();if(c||(c=sa.loadConfig()),!c||!c.mtxId&&!c.mtxKey&&!c.mtxApp)return void w(Hs("Configuration error: Missing API credentials. Please check your widget settings."));s||w(Bs(e,a));const l=`temp-${globalThis.crypto.randomUUID()}`,d={id:l,content:zs(""),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=Js();if(t){const e=Ks.getInstance();if(!e.isConnected()){const n=sa.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 Ys.getOrCreateChatId()))throw new Error("Failed to initialize chat session");const n=t.mode||"tell";if(t.message&&await Xs(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||""};Ks.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]),C=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=Ks.getInstance(),n=async t=>{const{toolCallId:n,tool:r,args:o,mode:i,explanation:s}=t,a=await ia.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=>da(e,r,s,"completed",f.current)),"done"===r&&(y.current={},b(e=>function(e,t){const n=Rs({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=>da(e,r,s,"failed",f.current,"Connection error"))}else b(e=>da(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(C(n),!Ts.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:la(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 ca(e);if("has_question"===t.status){const t=Rs({messages:e.messages,isTaskRunning:e.task.isTaskRunning,currentMode:n,requireContent:!1}),o=[...e.messages];if(t){const e=$s(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=Rs({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 ca(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,C,r]);const T=i(async()=>{const e=h.current.task.activeTaskId??void 0;b(e=>function(e,t){const n=Rs({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||Ks.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:I}),[w,v,x,k,S,I]),z=l(()=>({setTaskState:_,stopTask:T}),[_,T]),O=l(()=>({messages:c.messages}),[c.messages]);/* @__PURE__ */
3
3
  return m(ua.Provider,{value:{chatState:O,chatActions:M,taskState:c.task,taskActions:z},children:e})},fa=()=>{const e=s(ua);if(!e)throw new Error("useChatContext must be used within ChatProvider");return e},ma=n(void 0),ga=({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
- return m(ma.Provider,{value:{uiState:o,uiActions:s},children:e})},ya=()=>{const e=s(ma);if(!e)throw new Error("useUIStateContext must be used within UIStateProvider");return e};var ba=({config:e}={})=>{const{uiState:t,uiActions:n}=ya(),{chatState:r,chatActions:o,taskState:s,taskActions:c}=fa(),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||sa.getConfig()||{},[e]),f=function(e){return Object.keys(gs.shape).every(t=>void 0!==e[t])}(h);a(()=>{f&&sa.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}},wa=(e=/* @__PURE__ */new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),va="-",xa=[],ka=e=>{const t=Ia(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith("[")&&e.endsWith("]"))return Sa(e);const n=e.split(va),r=""===n[0]&&n.length>1?1:0;return _a(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||xa}return n[e]||xa}}},_a=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const r=e[t],o=n.nextPart.get(r);if(o){const n=_a(e,t+1,o);if(n)return n}const i=n.validators;if(null===i)return;const s=0===t?e.join(va):e.slice(t).join(va),a=i.length;for(let c=0;c<a;c++){const e=i[c];if(e.validator(s))return e.classGroupId}},Sa=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})(),Ia=e=>{const{theme:t,classGroups:n}=e;return Ca(n,t)},Ca=(e,t)=>{const n=wa();for(const r in e){const o=e[r];Ea(o,n,r,t)}return n},Ea=(e,t,n,r)=>{const o=e.length;for(let i=0;i<o;i++){const o=e[i];Ta(o,t,n,r)}},Ta=(e,t,n,r)=>{"string"!=typeof e?"function"!=typeof e?Oa(e,t,n,r):za(e,t,n,r):Ma(e,t,n)},Ma=(e,t,n)=>{(""===e?t:Ra(t,e)).classGroupId=n},za=(e,t,n,r)=>{Aa(e)?Ea(e(r),t,n,r):(null===t.validators&&(t.validators=[]),t.validators.push(((e,t)=>({classGroupId:e,validator:t}))(n,e)))},Oa=(e,t,n,r)=>{const o=Object.entries(e),i=o.length;for(let s=0;s<i;s++){const[e,i]=o[s];Ea(i,Ra(t,e),n,r)}},Ra=(e,t)=>{let n=e;const r=t.split(va),o=r.length;for(let i=0;i<o;i++){const e=r[i];let t=n.nextPart.get(e);t||(t=wa(),n.nextPart.set(e,t)),n=t}return n},Aa=e=>"isThemeGetter"in e&&!0===e.isThemeGetter,Na=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)}}},Pa=[],La=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),$a=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 La(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)):La(Pa,!1,t,void 0,!0)}if(n){const e=r;r=t=>n({className:t,parseClassName:e})}return r},Da=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}},Fa=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},ja=/\s+/,Ua=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Ua(e[r]))&&(n&&(n+=" "),n+=t);return n},Wa=(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(ja);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:Na(e.cacheSize),parseClassName:$a(e),sortModifiers:Da(e),postfixLookupClassGroupIds:Fa(e),...ka(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=Ua(t))&&(o&&(o+=" "),o+=n);return o})(...e))},Ba=[],Ha=e=>{const t=t=>t[e]||Ba;return t.isThemeGetter=!0,t},qa=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Za=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Va=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Ga=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ya=/\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$/,Ka=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Ja=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Xa=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Qa=e=>Va.test(e),ec=e=>!!e&&!Number.isNaN(Number(e)),tc=e=>!!e&&Number.isInteger(Number(e)),nc=e=>e.endsWith("%")&&ec(e.slice(0,-1)),rc=e=>Ga.test(e),oc=()=>!0,ic=e=>Ya.test(e)&&!Ka.test(e),sc=()=>!1,ac=e=>Ja.test(e),cc=e=>Xa.test(e),lc=e=>!pc(e)&&!vc(e),dc=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)),uc=e=>Tc(e,Rc,sc),pc=e=>qa.test(e),hc=e=>Tc(e,Ac,ic),fc=e=>Tc(e,Nc,ec),mc=e=>Tc(e,Lc,oc),gc=e=>Tc(e,Pc,sc),yc=e=>Tc(e,zc,sc),bc=e=>Tc(e,Oc,cc),wc=e=>Tc(e,$c,ac),vc=e=>Za.test(e),xc=e=>Mc(e,Ac),kc=e=>Mc(e,Pc),_c=e=>Mc(e,zc),Sc=e=>Mc(e,Rc),Ic=e=>Mc(e,Oc),Cc=e=>Mc(e,$c,!0),Ec=e=>Mc(e,Lc,!0),Tc=(e,t,n)=>{const r=qa.exec(e);return!!r&&(r[1]?t(r[1]):n(r[2]))},Mc=(e,t,n=!1)=>{const r=Za.exec(e);return!!r&&(r[1]?t(r[1]):n)},zc=e=>"position"===e||"percentage"===e,Oc=e=>"image"===e||"url"===e,Rc=e=>"length"===e||"size"===e||"bg-size"===e,Ac=e=>"length"===e,Nc=e=>"number"===e,Pc=e=>"family-name"===e,Lc=e=>"number"===e||"weight"===e,$c=e=>"shadow"===e,Dc=/*#__PURE__*/Wa(()=>{const e=Ha("color"),t=Ha("font"),n=Ha("text"),r=Ha("font-weight"),o=Ha("tracking"),i=Ha("leading"),s=Ha("breakpoint"),a=Ha("container"),c=Ha("spacing"),l=Ha("radius"),d=Ha("shadow"),u=Ha("inset-shadow"),p=Ha("text-shadow"),h=Ha("drop-shadow"),f=Ha("blur"),m=Ha("perspective"),g=Ha("aspect"),y=Ha("ease"),b=Ha("animate"),w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",vc,pc],v=()=>[vc,pc,c],x=()=>[Qa,"full","auto",...v()],k=()=>[tc,"none","subgrid",vc,pc],_=()=>["auto",{span:["full",tc,vc,pc]},tc,vc,pc],S=()=>[tc,"auto",vc,pc],I=()=>["auto","min","max","fr",vc,pc],C=()=>["auto",...v()],E=()=>[Qa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],T=()=>[Qa,"screen","full","dvw","lvw","svw","min","max","fit",...v()],M=()=>[Qa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],z=()=>[e,vc,pc],O=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",_c,yc,{position:[vc,pc]}],R=()=>["auto","cover","contain",Sc,uc,{size:[vc,pc]}],A=()=>[nc,xc,hc],N=()=>["","none","full",l,vc,pc],P=()=>["",ec,xc,hc],L=()=>[ec,nc,_c,yc],$=()=>["","none",f,vc,pc],D=()=>["none",ec,vc,pc],F=()=>["none",ec,vc,pc],j=()=>[ec,vc,pc],U=()=>[Qa,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[rc],breakpoint:[rc],color:[oc],container:[rc],"drop-shadow":[rc],ease:["in","out","in-out"],font:[lc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[rc],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[rc],shadow:[rc],spacing:["px",ec],text:[rc],"text-shadow":[rc],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Qa,pc,vc,g]}],container:["container"],"container-type":[{"@container":["","normal","size",vc,pc]}],"container-named":[dc],columns:[{columns:[ec,pc,vc,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:[tc,"auto",vc,pc]}],basis:[{basis:[Qa,"full","auto",a,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ec,Qa,"auto","initial","none",pc]}],grow:[{grow:["",ec,vc,pc]}],shrink:[{shrink:["",ec,vc,pc]}],order:[{order:[tc,"first","last","none",vc,pc]}],"grid-cols":[{"grid-cols":k()}],"col-start-end":[{col:_()}],"col-start":[{"col-start":S()}],"col-end":[{"col-end":S()}],"grid-rows":[{"grid-rows":k()}],"row-start-end":[{row:_()}],"row-start":[{"row-start":S()}],"row-end":[{"row-end":S()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],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:C()}],mx:[{mx:C()}],my:[{my:C()}],ms:[{ms:C()}],me:[{me:C()}],mbs:[{mbs:C()}],mbe:[{mbe:C()}],mt:[{mt:C()}],mr:[{mr:C()}],mb:[{mb:C()}],ml:[{ml:C()}],"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,xc,hc]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Ec,mc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",nc,pc]}],"font-family":[{font:[kc,gc,t]}],"font-features":[{"font-features":[pc]}],"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,vc,pc]}],"line-clamp":[{"line-clamp":[ec,"none",vc,fc]}],leading:[{leading:[i,...v()]}],"list-image":[{"list-image":["none",vc,pc]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",vc,pc]}],"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:[ec,"from-font","auto",vc,hc]}],"text-decoration-color":[{decoration:z()}],"underline-offset":[{"underline-offset":[ec,"auto",vc,pc]}],"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:[tc,vc,pc]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",vc,pc]}],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",vc,pc]}],"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"]},tc,vc,pc],radial:["",vc,pc],conic:[tc,vc,pc]},Ic,bc]}],"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":[ec,vc,pc]}],"outline-w":[{outline:["",ec,xc,hc]}],"outline-color":[{outline:z()}],shadow:[{shadow:["","none",d,Cc,wc]}],"shadow-color":[{shadow:z()}],"inset-shadow":[{"inset-shadow":["none",u,Cc,wc]}],"inset-shadow-color":[{"inset-shadow":z()}],"ring-w":[{ring:P()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:z()}],"ring-offset-w":[{"ring-offset":[ec,hc]}],"ring-offset-color":[{"ring-offset":z()}],"inset-ring-w":[{"inset-ring":P()}],"inset-ring-color":[{"inset-ring":z()}],"text-shadow":[{"text-shadow":["none",p,Cc,wc]}],"text-shadow-color":[{"text-shadow":z()}],opacity:[{opacity:[ec,vc,pc]}],"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":[ec]}],"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":[vc,pc]}],"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":[ec]}],"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",vc,pc]}],filter:[{filter:["","none",vc,pc]}],blur:[{blur:$()}],brightness:[{brightness:[ec,vc,pc]}],contrast:[{contrast:[ec,vc,pc]}],"drop-shadow":[{"drop-shadow":["","none",h,Cc,wc]}],"drop-shadow-color":[{"drop-shadow":z()}],grayscale:[{grayscale:["",ec,vc,pc]}],"hue-rotate":[{"hue-rotate":[ec,vc,pc]}],invert:[{invert:["",ec,vc,pc]}],saturate:[{saturate:[ec,vc,pc]}],sepia:[{sepia:["",ec,vc,pc]}],"backdrop-filter":[{"backdrop-filter":["","none",vc,pc]}],"backdrop-blur":[{"backdrop-blur":$()}],"backdrop-brightness":[{"backdrop-brightness":[ec,vc,pc]}],"backdrop-contrast":[{"backdrop-contrast":[ec,vc,pc]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ec,vc,pc]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ec,vc,pc]}],"backdrop-invert":[{"backdrop-invert":["",ec,vc,pc]}],"backdrop-opacity":[{"backdrop-opacity":[ec,vc,pc]}],"backdrop-saturate":[{"backdrop-saturate":[ec,vc,pc]}],"backdrop-sepia":[{"backdrop-sepia":["",ec,vc,pc]}],"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",vc,pc]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ec,"initial",vc,pc]}],ease:[{ease:["linear","initial",y,vc,pc]}],delay:[{delay:[ec,vc,pc]}],animate:[{animate:["none",b,vc,pc]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,vc,pc]}],"perspective-origin":[{"perspective-origin":w()}],rotate:[{rotate:D()}],"rotate-x":[{"rotate-x":D()}],"rotate-y":[{"rotate-y":D()}],"rotate-z":[{"rotate-z":D()}],scale:[{scale:F()}],"scale-x":[{"scale-x":F()}],"scale-y":[{"scale-y":F()}],"scale-z":[{"scale-z":F()}],"scale-3d":["scale-3d"],skew:[{skew:j()}],"skew-x":[{"skew-x":j()}],"skew-y":[{"skew-y":j()}],transform:[{transform:[vc,pc,"","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:[tc,vc,pc]}],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",vc,pc]}],"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",vc,pc]}],fill:[{fill:["none",...z()]}],"stroke-w":[{stroke:[ec,xc,hc,fc]}],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 Fc(...e){return Dc(e.filter(Boolean).join(" "))}var jc={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)"},Uc={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"},Wc={default:"text-foreground",muted:"text-foreground-muted",faint:"text-foreground-faint",primary:"text-primary",success:"text-success",warning:"text-warning",inherit:"text-inherit"},Bc={tight:"leading-tight",snug:"leading-snug",normal:"leading-normal",relaxed:"leading-relaxed"},Hc={header:{height:40},tabBar:{height:48},launcher:{width:56,height:56},launcherCore:{width:48,height:48}},qc={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 Zc(e){if(e&&"none"!==e)return{boxShadow:jc[e]}}var Vc={none:"0","2xs":"1",xs:"0.5",sm:"1.5",md:"2",lg:"3",xl:"4","2xl":"6"},Gc=/* @__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 Yc(e){const t=[];if(void 0!==e.padding&&t.push(`p-${Vc[e.padding]}`),void 0!==e.paddingX&&t.push(`px-${Vc[e.paddingX]}`),void 0!==e.paddingY&&t.push(`py-${Vc[e.paddingY]}`),void 0!==e.paddingTop&&t.push(`pt-${Vc[e.paddingTop]}`),void 0!==e.paddingBottom&&t.push(`pb-${Vc[e.paddingBottom]}`),void 0!==e.margin&&t.push(`m-${Vc[e.margin]}`),void 0!==e.marginX&&t.push(`mx-${Vc[e.marginX]}`),void 0!==e.marginY&&t.push(`my-${Vc[e.marginY]}`),void 0!==e.marginTop&&t.push(`mt-${Vc[e.marginTop]}`),void 0!==e.marginBottom&&t.push(`mb-${Vc[e.marginBottom]}`),void 0!==e.gap&&t.push(`gap-${Vc[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-${Vc[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(Uc.theme);else if("full"===e.rounded)t.push(Uc.pill);else{const n="lg"===e.rounded?"lg":e.rounded;t.push(Uc[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 Kc(e){const t={};for(const n in e)Gc.has(n)||(t[n]=e[n]);return t}var Jc={default:"",card:"bg-card text-card-foreground",transparent:"bg-transparent",muted:"bg-muted",secondary:"bg-secondary-bg",primary:"bg-primary text-primary-foreground"},Xc={none:"",compact:"px-2 py-1.5",card:"px-3 py-2",dialog:"p-4",toast:"py-2 pl-2 pr-3"},Qc=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=Yc(e),u=Kc(l);/* @__PURE__ */
4
+ return m(ma.Provider,{value:{uiState:o,uiActions:s},children:e})},ya=()=>{const e=s(ma);if(!e)throw new Error("useUIStateContext must be used within UIStateProvider");return e};var ba=({config:e}={})=>{const{uiState:t,uiActions:n}=ya(),{chatState:r,chatActions:o,taskState:s,taskActions:c}=fa(),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||sa.getConfig()||{},[e]),f=function(e){return gs.safeParse(e).success}(h);a(()=>{f&&sa.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}},wa=(e=/* @__PURE__ */new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),va="-",xa=[],ka=e=>{const t=Ia(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith("[")&&e.endsWith("]"))return _a(e);const n=e.split(va),r=""===n[0]&&n.length>1?1:0;return Sa(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||xa}return n[e]||xa}}},Sa=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const r=e[t],o=n.nextPart.get(r);if(o){const n=Sa(e,t+1,o);if(n)return n}const i=n.validators;if(null===i)return;const s=0===t?e.join(va):e.slice(t).join(va),a=i.length;for(let c=0;c<a;c++){const e=i[c];if(e.validator(s))return e.classGroupId}},_a=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})(),Ia=e=>{const{theme:t,classGroups:n}=e;return Ca(n,t)},Ca=(e,t)=>{const n=wa();for(const r in e){const o=e[r];Ea(o,n,r,t)}return n},Ea=(e,t,n,r)=>{const o=e.length;for(let i=0;i<o;i++){const o=e[i];Ta(o,t,n,r)}},Ta=(e,t,n,r)=>{"string"!=typeof e?"function"!=typeof e?Oa(e,t,n,r):za(e,t,n,r):Ma(e,t,n)},Ma=(e,t,n)=>{(""===e?t:Ra(t,e)).classGroupId=n},za=(e,t,n,r)=>{Aa(e)?Ea(e(r),t,n,r):(null===t.validators&&(t.validators=[]),t.validators.push(((e,t)=>({classGroupId:e,validator:t}))(n,e)))},Oa=(e,t,n,r)=>{const o=Object.entries(e),i=o.length;for(let s=0;s<i;s++){const[e,i]=o[s];Ea(i,Ra(t,e),n,r)}},Ra=(e,t)=>{let n=e;const r=t.split(va),o=r.length;for(let i=0;i<o;i++){const e=r[i];let t=n.nextPart.get(e);t||(t=wa(),n.nextPart.set(e,t)),n=t}return n},Aa=e=>"isThemeGetter"in e&&!0===e.isThemeGetter,Na=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)}}},Pa=[],La=(e,t,n,r,o)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),$a=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 La(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)):La(Pa,!1,t,void 0,!0)}if(n){const e=r;r=t=>n({className:t,parseClassName:e})}return r},Da=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}},Fa=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},ja=/\s+/,Ua=e=>{if("string"==typeof e)return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Ua(e[r]))&&(n&&(n+=" "),n+=t);return n},Wa=(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(ja);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:Na(e.cacheSize),parseClassName:$a(e),sortModifiers:Da(e),postfixLookupClassGroupIds:Fa(e),...ka(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=Ua(t))&&(o&&(o+=" "),o+=n);return o})(...e))},Ba=[],Ha=e=>{const t=t=>t[e]||Ba;return t.isThemeGetter=!0,t},qa=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Za=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Va=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Ga=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Ya=/\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$/,Ka=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Ja=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Xa=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Qa=e=>Va.test(e),ec=e=>!!e&&!Number.isNaN(Number(e)),tc=e=>!!e&&Number.isInteger(Number(e)),nc=e=>e.endsWith("%")&&ec(e.slice(0,-1)),rc=e=>Ga.test(e),oc=()=>!0,ic=e=>Ya.test(e)&&!Ka.test(e),sc=()=>!1,ac=e=>Ja.test(e),cc=e=>Xa.test(e),lc=e=>!pc(e)&&!vc(e),dc=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)),uc=e=>Tc(e,Rc,sc),pc=e=>qa.test(e),hc=e=>Tc(e,Ac,ic),fc=e=>Tc(e,Nc,ec),mc=e=>Tc(e,Lc,oc),gc=e=>Tc(e,Pc,sc),yc=e=>Tc(e,zc,sc),bc=e=>Tc(e,Oc,cc),wc=e=>Tc(e,$c,ac),vc=e=>Za.test(e),xc=e=>Mc(e,Ac),kc=e=>Mc(e,Pc),Sc=e=>Mc(e,zc),_c=e=>Mc(e,Rc),Ic=e=>Mc(e,Oc),Cc=e=>Mc(e,$c,!0),Ec=e=>Mc(e,Lc,!0),Tc=(e,t,n)=>{const r=qa.exec(e);return!!r&&(r[1]?t(r[1]):n(r[2]))},Mc=(e,t,n=!1)=>{const r=Za.exec(e);return!!r&&(r[1]?t(r[1]):n)},zc=e=>"position"===e||"percentage"===e,Oc=e=>"image"===e||"url"===e,Rc=e=>"length"===e||"size"===e||"bg-size"===e,Ac=e=>"length"===e,Nc=e=>"number"===e,Pc=e=>"family-name"===e,Lc=e=>"number"===e||"weight"===e,$c=e=>"shadow"===e,Dc=/*#__PURE__*/Wa(()=>{const e=Ha("color"),t=Ha("font"),n=Ha("text"),r=Ha("font-weight"),o=Ha("tracking"),i=Ha("leading"),s=Ha("breakpoint"),a=Ha("container"),c=Ha("spacing"),l=Ha("radius"),d=Ha("shadow"),u=Ha("inset-shadow"),p=Ha("text-shadow"),h=Ha("drop-shadow"),f=Ha("blur"),m=Ha("perspective"),g=Ha("aspect"),y=Ha("ease"),b=Ha("animate"),w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",vc,pc],v=()=>[vc,pc,c],x=()=>[Qa,"full","auto",...v()],k=()=>[tc,"none","subgrid",vc,pc],S=()=>["auto",{span:["full",tc,vc,pc]},tc,vc,pc],_=()=>[tc,"auto",vc,pc],I=()=>["auto","min","max","fr",vc,pc],C=()=>["auto",...v()],E=()=>[Qa,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],T=()=>[Qa,"screen","full","dvw","lvw","svw","min","max","fit",...v()],M=()=>[Qa,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],z=()=>[e,vc,pc],O=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom",Sc,yc,{position:[vc,pc]}],R=()=>["auto","cover","contain",_c,uc,{size:[vc,pc]}],A=()=>[nc,xc,hc],N=()=>["","none","full",l,vc,pc],P=()=>["",ec,xc,hc],L=()=>[ec,nc,Sc,yc],$=()=>["","none",f,vc,pc],D=()=>["none",ec,vc,pc],F=()=>["none",ec,vc,pc],j=()=>[ec,vc,pc],U=()=>[Qa,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[rc],breakpoint:[rc],color:[oc],container:[rc],"drop-shadow":[rc],ease:["in","out","in-out"],font:[lc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[rc],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[rc],shadow:[rc],spacing:["px",ec],text:[rc],"text-shadow":[rc],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Qa,pc,vc,g]}],container:["container"],"container-type":[{"@container":["","normal","size",vc,pc]}],"container-named":[dc],columns:[{columns:[ec,pc,vc,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:[tc,"auto",vc,pc]}],basis:[{basis:[Qa,"full","auto",a,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ec,Qa,"auto","initial","none",pc]}],grow:[{grow:["",ec,vc,pc]}],shrink:[{shrink:["",ec,vc,pc]}],order:[{order:[tc,"first","last","none",vc,pc]}],"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":I()}],"auto-rows":[{"auto-rows":I()}],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:C()}],mx:[{mx:C()}],my:[{my:C()}],ms:[{ms:C()}],me:[{me:C()}],mbs:[{mbs:C()}],mbe:[{mbe:C()}],mt:[{mt:C()}],mr:[{mr:C()}],mb:[{mb:C()}],ml:[{ml:C()}],"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,xc,hc]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Ec,mc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",nc,pc]}],"font-family":[{font:[kc,gc,t]}],"font-features":[{"font-features":[pc]}],"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,vc,pc]}],"line-clamp":[{"line-clamp":[ec,"none",vc,fc]}],leading:[{leading:[i,...v()]}],"list-image":[{"list-image":["none",vc,pc]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",vc,pc]}],"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:[ec,"from-font","auto",vc,hc]}],"text-decoration-color":[{decoration:z()}],"underline-offset":[{"underline-offset":[ec,"auto",vc,pc]}],"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:[tc,vc,pc]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",vc,pc]}],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",vc,pc]}],"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"]},tc,vc,pc],radial:["",vc,pc],conic:[tc,vc,pc]},Ic,bc]}],"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":[ec,vc,pc]}],"outline-w":[{outline:["",ec,xc,hc]}],"outline-color":[{outline:z()}],shadow:[{shadow:["","none",d,Cc,wc]}],"shadow-color":[{shadow:z()}],"inset-shadow":[{"inset-shadow":["none",u,Cc,wc]}],"inset-shadow-color":[{"inset-shadow":z()}],"ring-w":[{ring:P()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:z()}],"ring-offset-w":[{"ring-offset":[ec,hc]}],"ring-offset-color":[{"ring-offset":z()}],"inset-ring-w":[{"inset-ring":P()}],"inset-ring-color":[{"inset-ring":z()}],"text-shadow":[{"text-shadow":["none",p,Cc,wc]}],"text-shadow-color":[{"text-shadow":z()}],opacity:[{opacity:[ec,vc,pc]}],"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":[ec]}],"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":[vc,pc]}],"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":[ec]}],"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",vc,pc]}],filter:[{filter:["","none",vc,pc]}],blur:[{blur:$()}],brightness:[{brightness:[ec,vc,pc]}],contrast:[{contrast:[ec,vc,pc]}],"drop-shadow":[{"drop-shadow":["","none",h,Cc,wc]}],"drop-shadow-color":[{"drop-shadow":z()}],grayscale:[{grayscale:["",ec,vc,pc]}],"hue-rotate":[{"hue-rotate":[ec,vc,pc]}],invert:[{invert:["",ec,vc,pc]}],saturate:[{saturate:[ec,vc,pc]}],sepia:[{sepia:["",ec,vc,pc]}],"backdrop-filter":[{"backdrop-filter":["","none",vc,pc]}],"backdrop-blur":[{"backdrop-blur":$()}],"backdrop-brightness":[{"backdrop-brightness":[ec,vc,pc]}],"backdrop-contrast":[{"backdrop-contrast":[ec,vc,pc]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ec,vc,pc]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ec,vc,pc]}],"backdrop-invert":[{"backdrop-invert":["",ec,vc,pc]}],"backdrop-opacity":[{"backdrop-opacity":[ec,vc,pc]}],"backdrop-saturate":[{"backdrop-saturate":[ec,vc,pc]}],"backdrop-sepia":[{"backdrop-sepia":["",ec,vc,pc]}],"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",vc,pc]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ec,"initial",vc,pc]}],ease:[{ease:["linear","initial",y,vc,pc]}],delay:[{delay:[ec,vc,pc]}],animate:[{animate:["none",b,vc,pc]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,vc,pc]}],"perspective-origin":[{"perspective-origin":w()}],rotate:[{rotate:D()}],"rotate-x":[{"rotate-x":D()}],"rotate-y":[{"rotate-y":D()}],"rotate-z":[{"rotate-z":D()}],scale:[{scale:F()}],"scale-x":[{"scale-x":F()}],"scale-y":[{"scale-y":F()}],"scale-z":[{"scale-z":F()}],"scale-3d":["scale-3d"],skew:[{skew:j()}],"skew-x":[{"skew-x":j()}],"skew-y":[{"skew-y":j()}],transform:[{transform:[vc,pc,"","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:[tc,vc,pc]}],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",vc,pc]}],"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",vc,pc]}],fill:[{fill:["none",...z()]}],"stroke-w":[{stroke:[ec,xc,hc,fc]}],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 Fc(...e){return Dc(e.filter(Boolean).join(" "))}var jc={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)"},Uc={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"},Wc={default:"text-foreground",muted:"text-foreground-muted",faint:"text-foreground-faint",primary:"text-primary",success:"text-success",warning:"text-warning",inherit:"text-inherit"},Bc={tight:"leading-tight",snug:"leading-snug",normal:"leading-normal",relaxed:"leading-relaxed"},Hc={header:{height:40},tabBar:{height:48},launcher:{width:56,height:56},launcherCore:{width:48,height:48}},qc={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 Zc(e){if(e&&"none"!==e)return{boxShadow:jc[e]}}var Vc={none:"0","2xs":"1",xs:"0.5",sm:"1.5",md:"2",lg:"3",xl:"4","2xl":"6"},Gc=/* @__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 Yc(e){const t=[];if(void 0!==e.padding&&t.push(`p-${Vc[e.padding]}`),void 0!==e.paddingX&&t.push(`px-${Vc[e.paddingX]}`),void 0!==e.paddingY&&t.push(`py-${Vc[e.paddingY]}`),void 0!==e.paddingTop&&t.push(`pt-${Vc[e.paddingTop]}`),void 0!==e.paddingBottom&&t.push(`pb-${Vc[e.paddingBottom]}`),void 0!==e.margin&&t.push(`m-${Vc[e.margin]}`),void 0!==e.marginX&&t.push(`mx-${Vc[e.marginX]}`),void 0!==e.marginY&&t.push(`my-${Vc[e.marginY]}`),void 0!==e.marginTop&&t.push(`mt-${Vc[e.marginTop]}`),void 0!==e.marginBottom&&t.push(`mb-${Vc[e.marginBottom]}`),void 0!==e.gap&&t.push(`gap-${Vc[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-${Vc[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(Uc.theme);else if("full"===e.rounded)t.push(Uc.pill);else{const n="lg"===e.rounded?"lg":e.rounded;t.push(Uc[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 Kc(e){const t={};for(const n in e)Gc.has(n)||(t[n]=e[n]);return t}var Jc={default:"",card:"bg-card text-card-foreground",transparent:"bg-transparent",muted:"bg-muted",secondary:"bg-secondary-bg",primary:"bg-primary text-primary-foreground"},Xc={none:"",compact:"px-2 py-1.5",card:"px-3 py-2",dialog:"p-4",toast:"py-2 pl-2 pr-3"},Qc=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=Yc(e),u=Kc(l);/* @__PURE__ */
5
5
  return m(n,{...u,ref:t,className:Fc(Jc[r],Xc[s],a&&Yc({rounded:a}),d,o),style:{...Zc(i),...c}})}),el="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%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",tl={sm:"w-5 h-5",md:"w-8 h-8",lg:"w-12 h-12"};function nl(e){const{src:t,alt:n,elevation:r,fit:o="contain",size:i="md",rounded:s,className:a,style:c,ref:l,...d}=e,u="string"==typeof i,p=u?tl[i]:void 0,h=u?c:{width:i,height:i,...c};/* @__PURE__ */
6
- return m("img",{...d,ref:l,alt:n,className:Fc("flex-shrink-0","contain"===o?"object-contain":"object-cover",p,!0===s||"theme"===s?Uc.theme:"full"===s?Uc.pill:s?Uc[s]:void 0,a),src:t,style:{...Zc(r),...h}})}function rl(){return"undefined"!=typeof window}function ol(e){return sl(e)?(e.nodeName||"").toLowerCase():"#document"}function il(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function sl(e){return!!rl()&&(e instanceof Node||e instanceof il(e).Node)}function al(e){return!!rl()&&(e instanceof Element||e instanceof il(e).Element)}function cl(e){return!!rl()&&(e instanceof HTMLElement||e instanceof il(e).HTMLElement)}function ll(e){return!(!rl()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof il(e).ShadowRoot)}function dl(e){return/^(html|body|#document)$/.test(ol(e))}function ul(e){return il(e).getComputedStyle(e)}function pl(e){if("html"===ol(e))return e;const t=e.assignedSlot||e.parentNode||ll(e)&&e.host||function(e){var t;return null==(t=(sl(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}(e);return ll(t)?t.host:t}var hl={...e},fl={};function ml(t,n){const r=e.useRef(fl);return r.current===fl&&(r.current=t(n)),r}var gl=hl.useInsertionEffect,yl=gl&&gl!==hl.useLayoutEffect?gl:e=>e();function bl(e){const t=ml(wl).current;return t.next=e,yl(t.effect),t.trampoline}function wl(){const e={next:void 0,callback:vl,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function vl(){}var xl="undefined"!=typeof document?e.useLayoutEffect:()=>{};function kl(e,t){return e&&!t?e:!e&&t?t:e||t?{...e,...t}:void 0}var _l={};function Sl(e,t,n,r,o){if(!(n||r||o||e))return Il(t);let i=Il(e);return t&&(i=Cl(i,t)),n&&(i=Cl(i,n)),r&&(i=Cl(i,r)),o&&(i=Cl(i,o)),i}function Il(e){return Tl(e)?{...Ml(e,_l)}:function(e){const t={...e};for(const n in t){const e=t[n];El(n,e)&&(t[n]=Ol(e))}return t}(e)}function Cl(e,t){return Tl(t)?Ml(t,e):function(e,t){if(!t)return e;for(const n in t){const r=t[n];switch(n){case"style":e[n]=kl(e.style,r);break;case"className":e[n]=Al(e.className,r);break;default:El(n,r)?e[n]=zl(e[n],r):e[n]=r}}return e}(e,t)}function El(e,t){const n=e.charCodeAt(0),r=e.charCodeAt(1),o=e.charCodeAt(2);return 111===n&&110===r&&o>=65&&o<=90&&("function"==typeof t||void 0===t)}function Tl(e){return"function"==typeof e}function Ml(e,t){return Tl(e)?e(t):e??_l}function zl(e,t){return t?e?(...n)=>{const r=n[0];if(Nl(r)){const o=r;Rl(o);const i=t(...n);return o.baseUIHandlerPrevented||e?.(...n),i}const o=t(...n);return e?.(...n),o}:Ol(t):e}function Ol(e){return e?(...t)=>{const n=t[0];return Nl(n)&&Rl(n),e(...t)}:e}function Rl(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Al(e,t){return t?e?t+" "+e:t:e}function Nl(e){return null!=e&&"object"==typeof e&&"nativeEvent"in e}var Pl,Ll,$l=(Pl="https://base-ui.com/production-error",Ll="Base UI",function(e,...t){const n=new URL(Pl);return n.searchParams.set("code",e.toString()),t.forEach(e=>n.searchParams.append("args[]",e)),`${Ll} error #${e}; visit ${n} for the full message.`}),Dl=/*#__PURE__*/e.createContext(void 0);function Fl(e){return e?.ownerDocument||document}function jl(e,t,{detail:n=0}={}){e.dispatchEvent(new(il(e).PointerEvent)("click",{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Ul(t={}){const{disabled:n=!1,focusableWhenDisabled:r,tabIndex:o=0,native:i=!0,composite:s}=t,a=e.useRef(null),c=function(t=!1){const n=e.useContext(Dl);if(void 0===n&&!t)throw new Error($l(16));return n}(!0),l=s??void 0!==c,{props:d}=function(t){const{focusableWhenDisabled:n,disabled:r,composite:o=!1,tabIndex:i=0,isNativeButton:s}=t,a=o&&!1!==n,c=o&&!1===n;return{props:e.useMemo(()=>{const e={onKeyDown(e){r&&n&&"Tab"!==e.key&&e.preventDefault()}};return o||(e.tabIndex=i,!s&&r&&(e.tabIndex=n?i:-1)),(s&&(n||a)||!s&&r)&&(e["aria-disabled"]=r),!s||n&&!c||(e.disabled=r),e},[o,r,n,a,c,s,i])}}({focusableWhenDisabled:r,disabled:n,composite:l,tabIndex:o,isNativeButton:i}),u=e.useCallback(()=>{const e=a.current;Wl(e)&&l&&n&&void 0===d.disabled&&e.disabled&&(e.disabled=!1)},[n,d.disabled,l]);return xl(u,[u]),{getButtonProps:e.useCallback((e={})=>{const{onClick:t,onMouseDown:r,onKeyUp:o,onKeyDown:s,onPointerDown:a,...c}=e;return Sl({onClick(e){n?e.preventDefault():t?.(e)},onMouseDown(e){n||r?.(e)},onKeyDown(e){if(n)return;if(Rl(e),s?.(e),e.baseUIHandlerPrevented)return;const t=e.target===e.currentTarget,r=e.currentTarget,o=Wl(r),a=!i&&(cl(c=r)&&"A"===c.tagName&&Boolean(c.href));var c;const d=t&&(i?o:!a),u="Enter"===e.key,p=" "===e.key,h=r.getAttribute("role"),f=h?.startsWith("menuitem")||"option"===h||"gridcell"===h;if(t&&l&&p){if(e.defaultPrevented&&f)return;return e.preventDefault(),void(i&&!o||(e.preventBaseUIHandler(),jl(r,e)))}d&&!i&&(p||u)?e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),jl(r,e))):t&&a&&p&&e.preventDefault()},onKeyUp(e){n||(Rl(e),o?.(e),e.target===e.currentTarget&&i&&l&&Wl(e.currentTarget)&&" "===e.key?e.preventDefault():e.baseUIHandlerPrevented||e.target!==e.currentTarget||i||l||e.defaultPrevented||" "!==e.key||(e.preventBaseUIHandler(),jl(e.currentTarget,e)))},onPointerDown(e){n?e.preventDefault():a?.(e)}},i?{type:"button"}:{role:"button"},d,c)},[n,d,l,i]),buttonRef:bl(e=>{a.current=e,u()})}}function Wl(e){return cl(e)&&"BUTTON"===e.tagName}function Bl(e,t,n,r){const o=ml(Hl).current;return function(e,t,n,r,o){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==o}(o,e,t,n,r)&&ql(o,[e,t,n,r]),o.callback}function Hl(){return{callback:null,cleanup:null,refs:[]}}function ql(e,t){e.refs=t,t.every(e=>null==e)?e.callback=null:e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),null!=n){const r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){const o=t[e];if(null!=o)switch(typeof o){case"function":{const t=o(n);"function"==typeof t&&(r[e]=t);break}case"object":o.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){const n=t[e];if(null!=n)switch(typeof n){case"function":{const t=r[e];"function"==typeof t?t():n(null);break}case"object":n.current=null}}}}}}var Zl=parseInt(e.version,10);function Vl(e){return Zl>=e}function Gl(t){if(!/*#__PURE__*/e.isValidElement(t))return null;const n=t,r=n.props;return(Vl(19)?r?.ref:n.ref)??null}function Yl(){}var Kl=Object.freeze([]),Jl=Object.freeze({});function Xl(t,n,o={}){const i=n.render,s=function(e,t={}){const{className:n,style:r,render:o}=e,{state:i=Jl,ref:s,props:a,stateAttributesMapping:c,enabled:l=!0}=t,d=l?function(e,t){return"function"==typeof e?e(t):e}(n,i):void 0,u=l?function(e,t){return"function"==typeof e?e(t):e}(r,i):void 0,p=l?function(e,t){const n={};for(const r in e){const o=e[r];if(t?.hasOwnProperty(r)){const e=t[r](o);null!=e&&Object.assign(n,e);continue}!0===o?n[`data-${r.toLowerCase()}`]="":o&&(n[`data-${r.toLowerCase()}`]=o.toString())}return n}(i,c):Jl,h=l&&a?function(e){return Array.isArray(e)?function(e){if(0===e.length)return _l;if(1===e.length)return Il(e[0]);let t=Il(e[0]);for(let n=1;n<e.length;n+=1)t=Cl(t,e[n]);return t}(e):Sl(void 0,e)}(a):void 0,f=l?kl(p,h)??{}:Jl;"undefined"!=typeof document&&(l?Array.isArray(s)?f.ref=function(e){const t=ml(Hl).current;return function(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}(t,e)&&ql(t,e),t.callback}([f.ref,Gl(o),...s]):f.ref=Bl(f.ref,Gl(o),s):Bl(null,null));if(!l)return Jl;void 0!==d&&(f.className=Al(f.className,d));void 0!==u&&(f.style=kl(f.style,u));return f}(n,o);return!1===o.enabled?null:function(t,n,o,i){if(n){if("function"==typeof n)return n(o,i);const t=Sl(o,n.props);t.ref=o.ref;let r=n;return r?.$$typeof===Ql&&(r=e.Children.toArray(n)[0]),/*#__PURE__*/e.cloneElement(r,t)}if(t&&"string"==typeof t)return function(t,n){return"button"===t?/*#__PURE__*/r("button",{type:"button",...n,key:n.key}):"img"===t?/*#__PURE__*/r("img",{alt:"",...n,key:n.key}):/*#__PURE__*/e.createElement(t,n)}(t,o);throw new Error($l(8))}(t,i,s,o.state??Jl)}var Ql=Symbol.for("react.lazy");var ed=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,disabled:o=!1,focusableWhenDisabled:i=!1,nativeButton:s=!0,style:a,...c}=e,{getButtonProps:l,buttonRef:d}=Ul({disabled:o,focusableWhenDisabled:i,native:s});return Xl("button",e,{state:{disabled:o},ref:[t,d],props:[c,l]})}),td={primary:"bg-primary text-primary-foreground border-transparent hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground border-transparent hover:bg-secondary/80",ghost:"bg-transparent text-foreground border-border hover:bg-muted",bare:"bg-transparent text-inherit border-transparent hover:bg-transparent p-0 min-h-0",chip:"bg-secondary-bg text-foreground border-transparent hover:bg-primary hover:text-primary-foreground hover:border-primary",tab:"bg-transparent text-foreground-muted border-transparent hover:text-foreground hover:bg-transparent p-0 min-h-0",inline:"bg-transparent text-primary border-transparent hover:bg-transparent hover:text-primary p-0 min-h-0",toolbar:"bg-transparent text-foreground border-transparent opacity-60 hover:opacity-100"},nd={sm:"px-2 py-1 text-xs min-h-7",md:"px-4 py-2 text-sm min-h-9"},rd={default:"rounded-lg",theme:Uc.theme,pill:Uc.pill};function od({active:e=!1,className:t,disabled:n,elevation:r,full:o,loading:i=!1,shape:s="default",size:a="md",stacked:c=!1,type:l="button",variant:d="primary",style:u,ref:p,...h}){const f=!["bare","inline","tab","toolbar"].includes(d),g=n||i;/* @__PURE__ */
6
+ return m("img",{...d,ref:l,alt:n,className:Fc("flex-shrink-0","contain"===o?"object-contain":"object-cover",p,!0===s||"theme"===s?Uc.theme:"full"===s?Uc.pill:s?Uc[s]:void 0,a),src:t,style:{...Zc(r),...h}})}function rl(){return"undefined"!=typeof window}function ol(e){return sl(e)?(e.nodeName||"").toLowerCase():"#document"}function il(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function sl(e){return!!rl()&&(e instanceof Node||e instanceof il(e).Node)}function al(e){return!!rl()&&(e instanceof Element||e instanceof il(e).Element)}function cl(e){return!!rl()&&(e instanceof HTMLElement||e instanceof il(e).HTMLElement)}function ll(e){return!(!rl()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof il(e).ShadowRoot)}function dl(e){return/^(html|body|#document)$/.test(ol(e))}function ul(e){return il(e).getComputedStyle(e)}function pl(e){if("html"===ol(e))return e;const t=e.assignedSlot||e.parentNode||ll(e)&&e.host||function(e){var t;return null==(t=(sl(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}(e);return ll(t)?t.host:t}var hl={...e},fl={};function ml(t,n){const r=e.useRef(fl);return r.current===fl&&(r.current=t(n)),r}var gl=hl.useInsertionEffect,yl=gl&&gl!==hl.useLayoutEffect?gl:e=>e();function bl(e){const t=ml(wl).current;return t.next=e,yl(t.effect),t.trampoline}function wl(){const e={next:void 0,callback:vl,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function vl(){}var xl="undefined"!=typeof document?e.useLayoutEffect:()=>{};function kl(e,t){return e&&!t?e:!e&&t?t:e||t?{...e,...t}:void 0}var Sl={};function _l(e,t,n,r,o){if(!(n||r||o||e))return Il(t);let i=Il(e);return t&&(i=Cl(i,t)),n&&(i=Cl(i,n)),r&&(i=Cl(i,r)),o&&(i=Cl(i,o)),i}function Il(e){return Tl(e)?{...Ml(e,Sl)}:function(e){const t={...e};for(const n in t){const e=t[n];El(n,e)&&(t[n]=Ol(e))}return t}(e)}function Cl(e,t){return Tl(t)?Ml(t,e):function(e,t){if(!t)return e;for(const n in t){const r=t[n];switch(n){case"style":e[n]=kl(e.style,r);break;case"className":e[n]=Al(e.className,r);break;default:El(n,r)?e[n]=zl(e[n],r):e[n]=r}}return e}(e,t)}function El(e,t){const n=e.charCodeAt(0),r=e.charCodeAt(1),o=e.charCodeAt(2);return 111===n&&110===r&&o>=65&&o<=90&&("function"==typeof t||void 0===t)}function Tl(e){return"function"==typeof e}function Ml(e,t){return Tl(e)?e(t):e??Sl}function zl(e,t){return t?e?(...n)=>{const r=n[0];if(Nl(r)){const o=r;Rl(o);const i=t(...n);return o.baseUIHandlerPrevented||e?.(...n),i}const o=t(...n);return e?.(...n),o}:Ol(t):e}function Ol(e){return e?(...t)=>{const n=t[0];return Nl(n)&&Rl(n),e(...t)}:e}function Rl(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Al(e,t){return t?e?t+" "+e:t:e}function Nl(e){return null!=e&&"object"==typeof e&&"nativeEvent"in e}var Pl,Ll,$l=(Pl="https://base-ui.com/production-error",Ll="Base UI",function(e,...t){const n=new URL(Pl);return n.searchParams.set("code",e.toString()),t.forEach(e=>n.searchParams.append("args[]",e)),`${Ll} error #${e}; visit ${n} for the full message.`}),Dl=/*#__PURE__*/e.createContext(void 0);function Fl(e){return e?.ownerDocument||document}function jl(e,t,{detail:n=0}={}){e.dispatchEvent(new(il(e).PointerEvent)("click",{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Ul(t={}){const{disabled:n=!1,focusableWhenDisabled:r,tabIndex:o=0,native:i=!0,composite:s}=t,a=e.useRef(null),c=function(t=!1){const n=e.useContext(Dl);if(void 0===n&&!t)throw new Error($l(16));return n}(!0),l=s??void 0!==c,{props:d}=function(t){const{focusableWhenDisabled:n,disabled:r,composite:o=!1,tabIndex:i=0,isNativeButton:s}=t,a=o&&!1!==n,c=o&&!1===n;return{props:e.useMemo(()=>{const e={onKeyDown(e){r&&n&&"Tab"!==e.key&&e.preventDefault()}};return o||(e.tabIndex=i,!s&&r&&(e.tabIndex=n?i:-1)),(s&&(n||a)||!s&&r)&&(e["aria-disabled"]=r),!s||n&&!c||(e.disabled=r),e},[o,r,n,a,c,s,i])}}({focusableWhenDisabled:r,disabled:n,composite:l,tabIndex:o,isNativeButton:i}),u=e.useCallback(()=>{const e=a.current;Wl(e)&&l&&n&&void 0===d.disabled&&e.disabled&&(e.disabled=!1)},[n,d.disabled,l]);return xl(u,[u]),{getButtonProps:e.useCallback((e={})=>{const{onClick:t,onMouseDown:r,onKeyUp:o,onKeyDown:s,onPointerDown:a,...c}=e;return _l({onClick(e){n?e.preventDefault():t?.(e)},onMouseDown(e){n||r?.(e)},onKeyDown(e){if(n)return;if(Rl(e),s?.(e),e.baseUIHandlerPrevented)return;const t=e.target===e.currentTarget,r=e.currentTarget,o=Wl(r),a=!i&&(cl(c=r)&&"A"===c.tagName&&Boolean(c.href));var c;const d=t&&(i?o:!a),u="Enter"===e.key,p=" "===e.key,h=r.getAttribute("role"),f=h?.startsWith("menuitem")||"option"===h||"gridcell"===h;if(t&&l&&p){if(e.defaultPrevented&&f)return;return e.preventDefault(),void(i&&!o||(e.preventBaseUIHandler(),jl(r,e)))}d&&!i&&(p||u)?e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),jl(r,e))):t&&a&&p&&e.preventDefault()},onKeyUp(e){n||(Rl(e),o?.(e),e.target===e.currentTarget&&i&&l&&Wl(e.currentTarget)&&" "===e.key?e.preventDefault():e.baseUIHandlerPrevented||e.target!==e.currentTarget||i||l||e.defaultPrevented||" "!==e.key||(e.preventBaseUIHandler(),jl(e.currentTarget,e)))},onPointerDown(e){n?e.preventDefault():a?.(e)}},i?{type:"button"}:{role:"button"},d,c)},[n,d,l,i]),buttonRef:bl(e=>{a.current=e,u()})}}function Wl(e){return cl(e)&&"BUTTON"===e.tagName}function Bl(e,t,n,r){const o=ml(Hl).current;return function(e,t,n,r,o){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==o}(o,e,t,n,r)&&ql(o,[e,t,n,r]),o.callback}function Hl(){return{callback:null,cleanup:null,refs:[]}}function ql(e,t){e.refs=t,t.every(e=>null==e)?e.callback=null:e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),null!=n){const r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){const o=t[e];if(null!=o)switch(typeof o){case"function":{const t=o(n);"function"==typeof t&&(r[e]=t);break}case"object":o.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){const n=t[e];if(null!=n)switch(typeof n){case"function":{const t=r[e];"function"==typeof t?t():n(null);break}case"object":n.current=null}}}}}}var Zl=parseInt(e.version,10);function Vl(e){return Zl>=e}function Gl(t){if(!/*#__PURE__*/e.isValidElement(t))return null;const n=t,r=n.props;return(Vl(19)?r?.ref:n.ref)??null}function Yl(){}var Kl=Object.freeze([]),Jl=Object.freeze({});function Xl(t,n,o={}){const i=n.render,s=function(e,t={}){const{className:n,style:r,render:o}=e,{state:i=Jl,ref:s,props:a,stateAttributesMapping:c,enabled:l=!0}=t,d=l?function(e,t){return"function"==typeof e?e(t):e}(n,i):void 0,u=l?function(e,t){return"function"==typeof e?e(t):e}(r,i):void 0,p=l?function(e,t){const n={};for(const r in e){const o=e[r];if(t?.hasOwnProperty(r)){const e=t[r](o);null!=e&&Object.assign(n,e);continue}!0===o?n[`data-${r.toLowerCase()}`]="":o&&(n[`data-${r.toLowerCase()}`]=o.toString())}return n}(i,c):Jl,h=l&&a?function(e){return Array.isArray(e)?function(e){if(0===e.length)return Sl;if(1===e.length)return Il(e[0]);let t=Il(e[0]);for(let n=1;n<e.length;n+=1)t=Cl(t,e[n]);return t}(e):_l(void 0,e)}(a):void 0,f=l?kl(p,h)??{}:Jl;"undefined"!=typeof document&&(l?Array.isArray(s)?f.ref=function(e){const t=ml(Hl).current;return function(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}(t,e)&&ql(t,e),t.callback}([f.ref,Gl(o),...s]):f.ref=Bl(f.ref,Gl(o),s):Bl(null,null));if(!l)return Jl;void 0!==d&&(f.className=Al(f.className,d));void 0!==u&&(f.style=kl(f.style,u));return f}(n,o);return!1===o.enabled?null:function(t,n,o,i){if(n){if("function"==typeof n)return n(o,i);const t=_l(o,n.props);t.ref=o.ref;let r=n;return r?.$$typeof===Ql&&(r=e.Children.toArray(n)[0]),/*#__PURE__*/e.cloneElement(r,t)}if(t&&"string"==typeof t)return function(t,n){return"button"===t?/*#__PURE__*/r("button",{type:"button",...n,key:n.key}):"img"===t?/*#__PURE__*/r("img",{alt:"",...n,key:n.key}):/*#__PURE__*/e.createElement(t,n)}(t,o);throw new Error($l(8))}(t,i,s,o.state??Jl)}var Ql=Symbol.for("react.lazy");var ed=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,disabled:o=!1,focusableWhenDisabled:i=!1,nativeButton:s=!0,style:a,...c}=e,{getButtonProps:l,buttonRef:d}=Ul({disabled:o,focusableWhenDisabled:i,native:s});return Xl("button",e,{state:{disabled:o},ref:[t,d],props:[c,l]})}),td={primary:"bg-primary text-primary-foreground border-transparent hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground border-transparent hover:bg-secondary/80",ghost:"bg-transparent text-foreground border-border hover:bg-muted",bare:"bg-transparent text-inherit border-transparent hover:bg-transparent p-0 min-h-0",chip:"bg-secondary-bg text-foreground border-transparent hover:bg-primary hover:text-primary-foreground hover:border-primary",tab:"bg-transparent text-foreground-muted border-transparent hover:text-foreground hover:bg-transparent p-0 min-h-0",inline:"bg-transparent text-primary border-transparent hover:bg-transparent hover:text-primary p-0 min-h-0",toolbar:"bg-transparent text-foreground border-transparent opacity-60 hover:opacity-100"},nd={sm:"px-2 py-1 text-xs min-h-7",md:"px-4 py-2 text-sm min-h-9"},rd={default:"rounded-lg",theme:Uc.theme,pill:Uc.pill};function od({active:e=!1,className:t,disabled:n,elevation:r,full:o,loading:i=!1,shape:s="default",size:a="md",stacked:c=!1,type:l="button",variant:d="primary",style:u,ref:p,...h}){const f=!["bare","inline","tab","toolbar"].includes(d),g=n||i;/* @__PURE__ */
7
7
  return m(ed,{...h,ref:p,className:Fc("inline-flex items-center justify-center gap-2 font-medium cursor-pointer transition-all focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2",f&&"border",rd[s],td[d],"bare"!==d&&"inline"!==d&&"tab"!==d&&nd[a],c&&"flex-col gap-0.5","tab"===d&&"h-full min-w-0 flex-1",e&&"tab"===d&&"text-primary font-semibold",g&&"opacity-50 cursor-not-allowed pointer-events-none",i&&"opacity-70 cursor-wait pointer-events-none",o&&"w-full",t),"aria-busy":i?"true":void 0,"data-disabled":n?"true":"false","data-loading":i?"true":"false","data-size":a,"data-variant":d,disabled:g,style:{...Zc(r),...u},type:l})}var id=o(function(e,t){const{className:n,direction:r,...o}=e;/* @__PURE__ */
8
8
  return m(Qc,{...o,ref:t,className:Fc("flex","column"===r&&"flex-col",n)})}),sd={checkCircle:{viewBox:"0 0 512 512",paths:[{d:"M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z",fill:"currentColor"}]},circle:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z",fill:"currentColor"}]},exclamationCircle:{viewBox:"0 0 512 512",paths:[{d:"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z",fill:"currentColor"}]},timesCircle:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z",fill:"currentColor"}]},ban:{viewBox:"0 0 512 512",paths:[{d:"M256 8C119.034 8 8 119.033 8 256s111.034 248 248 248 248-111.034 248-248S392.967 8 256 8zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676zM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676z",fill:"currentColor"}]},arrowUp:{viewBox:"0 0 448 512",paths:[{d:"M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z",fill:"currentColor"}]},arrowDown:{viewBox:"0 0 448 512",paths:[{d:"M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z",fill:"currentColor"}]},x:{viewBox:"0 0 24 24",paths:[{d:"M18 6L6 18",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M6 6L18 18",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},chatBubble:{viewBox:"0 0 512 512",paths:[{d:"M87.48 380c1.2-4.38-1.43-10.47-3.94-14.86a42.63 42.63 0 0 0-2.54-3.8 199.81 199.81 0 0 1-33-110C47.64 139.09 140.72 48 255.82 48 356.2 48 440 117.54 459.57 209.85a199 199 0 0 1 4.43 41.64c0 112.41-89.49 204.93-204.59 204.93-18.31 0-43-4.6-56.47-8.37s-26.92-8.77-30.39-10.11a31.14 31.14 0 0 0-11.13-2.07 30.7 30.7 0 0 0-12.08 2.43L81.5 462.78a15.92 15.92 0 0 1-4.66 1.22 9.61 9.61 0 0 1-9.58-9.74 15.85 15.85 0 0 1 .6-3.29z",fill:"none",stroke:"currentColor",strokeWidth:32,strokeLinecap:"round"},{d:"M160 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"},{d:"M256 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"},{d:"M352 256 m-32 0 a32 32 0 1 1 64 0 a32 32 0 1 1 -64 0",fill:"currentColor"}]},stop:{viewBox:"0 0 512 512",paths:[{d:"M392 432H120a40 40 0 0 1-40-40V120a40 40 0 0 1 40-40h272a40 40 0 0 1 40 40v272a40 40 0 0 1-40 40z",fill:"currentColor"}]},mousePointerClick:{viewBox:"0 0 24 24",paths:[{d:"M14 4.1 12 6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"m5.1 8-2.9-.8",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"m6 12-1.9 2",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M7.2 2.2 8 5.1",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},ticktick:{viewBox:"0 0 24 24",paths:[{d:"M12 0C5.383 0 0 5.383 0 12s5.383 12 12 12 12-5.383 12-12h-2.7c0 5.128-4.172 9.3-9.3 9.3-5.128 0-9.3-4.172-9.3-9.3 0-5.128 4.172-9.3 9.3-9.3V0Zm7.4 2.583-7.505 9.371L8.388 9.08l-2.002 2.436 4.741 3.888a1.573 1.573 0 0 0 2.231-.233l8.504-10.617L19.4 2.583Z",fill:"currentColor"}]},home:{viewBox:"0 0 24 24",paths:[{d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},chat:{viewBox:"0 0 24 24",paths:[{d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},send:{viewBox:"0 0 24 24",paths:[{d:"M5 12h14m-7-7l7 7-7 7",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},closeSmall:{viewBox:"0 0 12 12",paths:[{d:"M9 3L3 9M3 3l6 6",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}]},close:{viewBox:"0 0 20 20",paths:[{d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd"}]},chevronDown:{viewBox:"0 0 24 24",paths:[{d:"M19 9l-7 7-7-7",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round"}]},screenShare:{viewBox:"0 0 24 24",paths:[{d:"M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]},alertCircle:{viewBox:"0 0 24 24",paths:[{d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}]}};function ad({name:e,size:t=16,className:n,ref:r,...o}){const i=sd[e];return i?/* @__PURE__ */m("svg",{...o,ref:r,"aria-hidden":"true",className:Fc("inline-block flex-shrink-0",n),fill:"none",height:t,viewBox:i.viewBox,width:t,xmlns:"http://www.w3.org/2000/svg",children:i.paths.map((e,t)=>/* @__PURE__ */m("path",{clipRule:e.clipRule,d:e.d,fill:e.fill??(e.stroke?"none":"currentColor"),fillRule:e.fillRule,stroke:e.stroke,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin,strokeMiterlimit:e.strokeMiterlimit,strokeWidth:e.strokeWidth},t))}):null}var cd={primary:"bg-primary text-primary-foreground hover:bg-primary-hover",secondary:"bg-secondary-bg text-foreground hover:bg-secondary-hover",ghost:"bg-transparent text-foreground opacity-60 hover:opacity-100",toolbar:"bg-transparent text-foreground opacity-60 hover:opacity-100"},ld={xs:"w-5 h-5 min-w-5",sm:"w-7 h-7 min-w-7"},dd={circle:Uc.circle,theme:Uc.theme};function ud({variant:e="ghost",size:t="sm",shape:n="circle",tone:r,label:o,disabled:i,elevation:s,className:a,children:c,style:l,ref:d,...u}){/* @__PURE__ */
9
9
  return m("button",{...u,ref:d,type:"button",disabled:i,"aria-label":o,className:Fc("inline-flex items-center justify-center flex-shrink-0 border-none cursor-pointer transition-all",dd[n],cd[e],r&&Wc[r],ld[t],i&&"opacity-50 cursor-not-allowed pointer-events-none",a),style:{...Zc(s),...l},children:c})}function pd(e){const{background:t="default",className:n,elevation:r,paddingPreset:o="none",radius:i,ref:s,style:a,...c}=e,l=Yc(e),d=Kc(c);/* @__PURE__ */
@@ -12,51 +12,51 @@ return m(e,{...y,ref:f,className:Fc(Wc[o?"inherit":a??{default:"default",muted:"
12
12
  return m(Qc,{position:"fixed",style:{zIndex:v,maxWidth:"420px",opacity:c?0:1,transition:"opacity 0.3s ease-out",animation:c?"none":"fadeIn 0.3s ease-out",...yd(s)},children:/* @__PURE__ */g(id,{align:"center",gap:"md",rounded:"pill",paddingPreset:"toast",elevation:"panel",style:{backgroundColor:p.background,border:p.border},children:[
13
13
  /* @__PURE__ */m(nl,{src:el,alt:"",size:28,rounded:"full"}),
14
14
  /* @__PURE__ */g(pd,{grow:!0,minWidth:"0",children:[/* @__PURE__ */m(gd,{as:"span",block:!0,inheritColor:!0,weight:"medium",style:{fontSize:"13px",color:p.titleColor,whiteSpace:o?"normal":"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),n&&/* @__PURE__ */m(gd,{as:"span",block:!0,inheritColor:!0,style:{fontSize:"12px",color:p.bodyColor,opacity:.8,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n})]}),o&&/* @__PURE__ */m(od,{type:"button",variant:"ghost",shape:"pill",size:"sm",onClick:()=>{o(),d()},style:{color:p.titleColor,backgroundColor:p.actionBackground,border:p.border},"aria-label":"Retry",children:"Retry"}),
15
- /* @__PURE__ */m(ud,{label:"Dismiss",onClick:e=>{e.stopPropagation(),d()},shape:"circle",size:"xs",tone:"inherit",style:{color:p.closeColor,padding:"2px"},children:/* @__PURE__ */m(ad,{name:"closeSmall",size:12})})]})})},wd=20,vd=(e,t,n,r,o)=>{switch(e){case"top_left":return{x:wd,y:wd};case"top_right":return{x:t-wd-r,y:wd};case"bottom_left":return{x:wd,y:n-wd-o};default:return{x:t-wd-r,y:n-wd-o}}},xd=(e,t,n,r,o,i)=>{const s=vd(e,n,r,o,i),a=s.x+o/2,c=s.y+i/2;let l,d;switch(t){case"top_left":l=wd+o/2,d=wd+i/2;break;case"top_right":l=n-wd-o/2,d=wd+i/2;break;case"bottom_left":l=wd+o/2,d=r-wd-i/2;break;default:l=n-wd-o/2,d=r-wd-i/2}return{dx:l-a,dy:d-c}},kd="cubic-bezier(0.16, 1, 0.3, 1)";function _d({position:e,onDrag:n,isPreviewMode:r=!1,wrapperRef:o}){const[s,a]=u(!1),[l,p]=u({w:56,h:56}),[,h]=u(0),f=d(null),m=d(null),g=d(null),y=d(0),b=d([]),w=d(0);t.useEffect(()=>()=>{null!==g.current&&window.cancelAnimationFrame(g.current)},[]),t.useEffect(()=>{if(r)return;const e=()=>h(e=>e+1);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[r]);const v=i(()=>{if(!o.current||"undefined"==typeof window)return;const e=o.current.getBoundingClientRect();p(t=>t.w===e.width&&t.h===e.height?t:{w:e.width,h:e.height})},[o]);c(()=>{v();const e="undefined"!=typeof window&&o.current?new ResizeObserver(v):null;return e&&o.current&&e.observe(o.current),()=>e?.disconnect()},[v,e,o]);const x="undefined"!=typeof window?window.innerWidth:0,k="undefined"!=typeof window?window.innerHeight:0,_=vd(e,x,k,l.w,l.h),S=!r&&x>0&&k>0?{left:_.x,top:_.y}:void 0,I=(e,t=.999)=>e/1e3*t/(1-t),C=()=>{null!==g.current&&(window.cancelAnimationFrame(g.current),g.current=null),o.current&&(o.current.style.transform="",o.current.style.willChange="",o.current.style.transition="")},E=i((e,t)=>{if(f.current)return;let r=!1;const i=()=>{r||(r=!0,f.current=null,t.style.transition="none",t.style.willChange="",n(e),a(!1),requestAnimationFrame(()=>{o.current&&(o.current.style.transition="")}))};f.current=i;const s=window.setTimeout(i,650);t.addEventListener("transitionend",function e(n){n.target===t&&"left"===n.propertyName&&(window.clearTimeout(s),t.removeEventListener("transitionend",e),i())})},[n,o]),T=i((t,r,i)=>{if(!o.current||!S)return C(),n(t),void a(!1);null!==g.current&&(window.cancelAnimationFrame(g.current),g.current=null);const s=o.current,c=vd(e,x,k,l.w,l.h),d=vd(t,x,k,l.w,l.h);s.style.transition="none",s.style.transform="none",s.style.willChange="left, top",s.style.left=`${c.x+r}px`,s.style.top=`${c.y+i}px`,requestAnimationFrame(()=>{s.style.transition=`left 600ms ${kd}, top 600ms ${kd}`,s.style.left=`${d.x}px`,s.style.top=`${d.y}px`}),E(t,s)},[E,n,S,e,x,k,l.w,l.h,o]);return{isDragging:s,pixelPositionStyle:S,onPointerDown:e=>{m.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,dragging:!1,lastX:0,lastY:0},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{const t=m.current;if(t?.pointerId!==e.pointerId)return;const n=e.clientX-t.startX,r=e.clientY-t.startY;if(!t.dragging&&Math.hypot(n,r)>5&&(t.dragging=!0,a(!0),b.current=[],w.current=0,o.current&&(o.current.style.willChange="transform",o.current.style.transition="none")),!t.dragging)return;t.lastX=n,t.lastY=r;const i=Date.now();i-w.current>=10&&(w.current=i,b.current=[...b.current.slice(-5),{x:e.clientX,y:e.clientY,t:i}]),null===g.current&&(g.current=window.requestAnimationFrame(()=>{g.current=null;const e=m.current,t=o.current;t&&e&&(t.style.transform=`translate3d(${e.lastX}px, ${e.lastY}px, 0)`)}))},onPointerUp:t=>{const n=m.current;if(n?.pointerId===t.pointerId){if(n.dragging){const r=(()=>{const e=b.current;if(e.length<2)return{x:0,y:0};const t=e[e.length-1].t-e[0].t;return t<=0?{x:0,y:0}:{x:(e[e.length-1].x-e[0].x)/t*1e3,y:(e[e.length-1].y-e[0].y)/t*1e3}})(),i=I(r.x),s=I(r.y),a={dx:n.lastX+i,dy:n.lastY+s};let c;if("undefined"!=typeof window&&o.current){const t=o.current.getBoundingClientRect();c=((e,t,n,r,o,i)=>{const s=["top_left","top_right","bottom_left","bottom_right"];let a=t,c=1/0;for(const l of s){const s=xd(t,l,n,r,o,i),d=Math.hypot(e.dx-s.dx,e.dy-s.dy);d<c&&(c=d,a=l)}return a})(a,e,window.innerWidth,window.innerHeight,t.width,t.height)}else c=e;return T(c,n.lastX,n.lastY),y.current=Date.now()+600,m.current=null,void t.currentTarget.releasePointerCapture(t.pointerId)}C(),m.current=null,a(!1),t.currentTarget.releasePointerCapture(t.pointerId)}},onPointerCancel:e=>{m.current?.pointerId===e.pointerId&&(C(),m.current=null,a(!1),e.currentTarget.releasePointerCapture(e.pointerId))},suppressUntilRef:y}}var Sd=({open:e,processing:t=!1,error:n=!1,taskRunning:r=!1,onClick:o,onStop:i,accentColor:s,backgroundColor:a,borderRadius:c="12px",tooltipBgColor:l,tooltipTextColor:u,zIndex:p=50,position:h,onDrag:f,isPreviewMode:y=!1})=>{const b=!e&&(t||r),w=!e&&r&&null!=i,v=n?"marketrix-widget-button-error-glow":"marketrix-widget-button-processing-glow",x=n?"marketrix-widget-button-error-activity-ring":"marketrix-widget-button-processing-activity-ring",k=Math.max(6,Math.min(22,Number.parseFloat(c)||12)),_=d(null),{isDragging:S,pixelPositionStyle:I,onPointerDown:C,onPointerMove:E,onPointerUp:T,onPointerCancel:M,suppressUntilRef:z}=_d({position:h,onDrag:f,isPreviewMode:y,wrapperRef:_}),O=(e=>{switch(e){case"bottom_right":default:return"bottom-5 right-5";case"bottom_left":return"bottom-5 left-5";case"top_right":return"top-5 right-5";case"top_left":return"top-5 left-5"}})(h),R=y?"absolute":"fixed",A=y?h.includes("top")?{top:"20px",...h.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...h.includes("right")?{right:"20px"}:{left:"20px"}}:{};/* @__PURE__ */
16
- return g(Qc,{ref:_,className:`${R} ${I?"":O} ${S?"":"transition-transform duration-300 ease-in-out"}`,style:{zIndex:p,pointerEvents:e?"none":"auto",...A,...I},children:[/* @__PURE__ */g(Qc,{className:`\n group relative w-14 h-14 overflow-visible transition-all duration-300 ease-in-out\n ${e?"scale-0 opacity-0 pointer-events-none":"scale-100 opacity-100 hover:scale-110"}\n `,children:[b&&/* @__PURE__ */m(Qc,{className:v,"aria-hidden":!0}),w&&!S&&/* @__PURE__ */m(od,{type:"button",variant:"secondary",size:"sm",onClick:e=>{e.preventDefault(),e.stopPropagation(),i?.()},className:"absolute top-1/2 z-20 -translate-y-1/2 rounded-full border border-white/25 bg-gray-900 px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wide text-white shadow-lg opacity-0 transition-opacity duration-150 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto "+(h.includes("left")?"left-full ml-2":"right-full mr-2"),style:{border:"1px solid rgba(255,255,255,0.25)"},"aria-label":"Stop simulation",children:"Stop"}),
17
- /* @__PURE__ */m(od,{type:"button",variant:"bare",onClick:()=>{Date.now()<z.current||o()},onDragStart:e=>e.preventDefault(),onPointerDown:C,onPointerMove:E,onPointerUp:T,onPointerCancel:M,className:"relative z-10 w-14 h-14 min-w-14",style:{touchAction:"none",cursor:S?"grabbing":"grab",userSelect:"none",WebkitUserSelect:"none"},"aria-label":e?"Close":"Open","aria-live":"polite",children:/* @__PURE__ */m(id,{className:"w-full h-full items-center justify-center relative",children:/* @__PURE__ */g(Qc,{className:"\n relative w-12 h-12 overflow-hidden transition-[transform,opacity,background-color] duration-[167ms] ease-[cubic-bezier(0.33,0,0,1)]\n hover:scale-110 hover:duration-[250ms] active:scale-[0.85] active:duration-[134ms] active:ease-[cubic-bezier(0.45,0,0.2,1)]\n animate-launcher-entrance\n ",style:{borderRadius:c,backgroundColor:e?a:s,boxShadow:jc.fab},children:[b&&/* @__PURE__ */m("svg",{className:x,viewBox:"0 0 54 54",fill:"none","aria-hidden":!0,children:/* @__PURE__ */m("rect",{x:"1.25",y:"1.25",width:"51.5",height:"51.5",rx:k+1,ry:k+1})}),
15
+ /* @__PURE__ */m(ud,{label:"Dismiss",onClick:e=>{e.stopPropagation(),d()},shape:"circle",size:"xs",tone:"inherit",style:{color:p.closeColor,padding:"2px"},children:/* @__PURE__ */m(ad,{name:"closeSmall",size:12})})]})})},wd=20,vd=(e,t,n,r,o)=>{switch(e){case"top_left":return{x:wd,y:wd};case"top_right":return{x:t-wd-r,y:wd};case"bottom_left":return{x:wd,y:n-wd-o};default:return{x:t-wd-r,y:n-wd-o}}},xd=(e,t,n,r,o,i)=>{const s=vd(e,n,r,o,i),a=s.x+o/2,c=s.y+i/2;let l,d;switch(t){case"top_left":l=wd+o/2,d=wd+i/2;break;case"top_right":l=n-wd-o/2,d=wd+i/2;break;case"bottom_left":l=wd+o/2,d=r-wd-i/2;break;default:l=n-wd-o/2,d=r-wd-i/2}return{dx:l-a,dy:d-c}},kd="cubic-bezier(0.16, 1, 0.3, 1)";function Sd({position:e,onDrag:n,isPreviewMode:r=!1,wrapperRef:o}){const[s,a]=u(!1),[l,p]=u({w:56,h:56}),[,h]=u(0),f=d(null),m=d(null),g=d(null),y=d(0),b=d([]),w=d(0);t.useEffect(()=>()=>{null!==g.current&&window.cancelAnimationFrame(g.current)},[]),t.useEffect(()=>{if(r)return;const e=()=>h(e=>e+1);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[r]);const v=i(()=>{if(!o.current||"undefined"==typeof window)return;const e=o.current.getBoundingClientRect();p(t=>t.w===e.width&&t.h===e.height?t:{w:e.width,h:e.height})},[o]);c(()=>{v();const e="undefined"!=typeof window&&o.current?new ResizeObserver(v):null;return e&&o.current&&e.observe(o.current),()=>e?.disconnect()},[v,e,o]);const x="undefined"!=typeof window?window.innerWidth:0,k="undefined"!=typeof window?window.innerHeight:0,S=vd(e,x,k,l.w,l.h),_=!r&&x>0&&k>0?{left:S.x,top:S.y}:void 0,I=(e,t=.999)=>e/1e3*t/(1-t),C=()=>{null!==g.current&&(window.cancelAnimationFrame(g.current),g.current=null),o.current&&(o.current.style.transform="",o.current.style.willChange="",o.current.style.transition="")},E=i((e,t)=>{if(f.current)return;let r=!1;const i=()=>{r||(r=!0,f.current=null,t.style.transition="none",t.style.willChange="",n(e),a(!1),requestAnimationFrame(()=>{o.current&&(o.current.style.transition="")}))};f.current=i;const s=window.setTimeout(i,650);t.addEventListener("transitionend",function e(n){n.target===t&&"left"===n.propertyName&&(window.clearTimeout(s),t.removeEventListener("transitionend",e),i())})},[n,o]),T=i((t,r,i)=>{if(!o.current||!_)return C(),n(t),void a(!1);null!==g.current&&(window.cancelAnimationFrame(g.current),g.current=null);const s=o.current,c=vd(e,x,k,l.w,l.h),d=vd(t,x,k,l.w,l.h);s.style.transition="none",s.style.transform="none",s.style.willChange="left, top",s.style.left=`${c.x+r}px`,s.style.top=`${c.y+i}px`,requestAnimationFrame(()=>{s.style.transition=`left 600ms ${kd}, top 600ms ${kd}`,s.style.left=`${d.x}px`,s.style.top=`${d.y}px`}),E(t,s)},[E,n,_,e,x,k,l.w,l.h,o]);return{isDragging:s,pixelPositionStyle:_,onPointerDown:e=>{m.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,dragging:!1,lastX:0,lastY:0},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{const t=m.current;if(t?.pointerId!==e.pointerId)return;const n=e.clientX-t.startX,r=e.clientY-t.startY;if(!t.dragging&&Math.hypot(n,r)>5&&(t.dragging=!0,a(!0),b.current=[],w.current=0,o.current&&(o.current.style.willChange="transform",o.current.style.transition="none")),!t.dragging)return;t.lastX=n,t.lastY=r;const i=Date.now();i-w.current>=10&&(w.current=i,b.current=[...b.current.slice(-5),{x:e.clientX,y:e.clientY,t:i}]),null===g.current&&(g.current=window.requestAnimationFrame(()=>{g.current=null;const e=m.current,t=o.current;t&&e&&(t.style.transform=`translate3d(${e.lastX}px, ${e.lastY}px, 0)`)}))},onPointerUp:t=>{const n=m.current;if(n?.pointerId===t.pointerId){if(n.dragging){const r=(()=>{const e=b.current;if(e.length<2)return{x:0,y:0};const t=e[e.length-1].t-e[0].t;return t<=0?{x:0,y:0}:{x:(e[e.length-1].x-e[0].x)/t*1e3,y:(e[e.length-1].y-e[0].y)/t*1e3}})(),i=I(r.x),s=I(r.y),a={dx:n.lastX+i,dy:n.lastY+s};let c;if("undefined"!=typeof window&&o.current){const t=o.current.getBoundingClientRect();c=((e,t,n,r,o,i)=>{const s=["top_left","top_right","bottom_left","bottom_right"];let a=t,c=1/0;for(const l of s){const s=xd(t,l,n,r,o,i),d=Math.hypot(e.dx-s.dx,e.dy-s.dy);d<c&&(c=d,a=l)}return a})(a,e,window.innerWidth,window.innerHeight,t.width,t.height)}else c=e;return T(c,n.lastX,n.lastY),y.current=Date.now()+600,m.current=null,void t.currentTarget.releasePointerCapture(t.pointerId)}C(),m.current=null,a(!1),t.currentTarget.releasePointerCapture(t.pointerId)}},onPointerCancel:e=>{m.current?.pointerId===e.pointerId&&(C(),m.current=null,a(!1),e.currentTarget.releasePointerCapture(e.pointerId))},suppressUntilRef:y}}var _d=({open:e,processing:t=!1,error:n=!1,taskRunning:r=!1,onClick:o,onStop:i,accentColor:s,backgroundColor:a,borderRadius:c="12px",tooltipBgColor:l,tooltipTextColor:u,zIndex:p=50,position:h,onDrag:f,isPreviewMode:y=!1})=>{const b=!e&&(t||r),w=!e&&r&&null!=i,v=n?"marketrix-widget-button-error-glow":"marketrix-widget-button-processing-glow",x=n?"marketrix-widget-button-error-activity-ring":"marketrix-widget-button-processing-activity-ring",k=Math.max(6,Math.min(22,Number.parseFloat(c)||12)),S=d(null),{isDragging:_,pixelPositionStyle:I,onPointerDown:C,onPointerMove:E,onPointerUp:T,onPointerCancel:M,suppressUntilRef:z}=Sd({position:h,onDrag:f,isPreviewMode:y,wrapperRef:S}),O=(e=>{switch(e){case"bottom_right":default:return"bottom-5 right-5";case"bottom_left":return"bottom-5 left-5";case"top_right":return"top-5 right-5";case"top_left":return"top-5 left-5"}})(h),R=y?"absolute":"fixed",A=y?h.includes("top")?{top:"20px",...h.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...h.includes("right")?{right:"20px"}:{left:"20px"}}:{};/* @__PURE__ */
16
+ return g(Qc,{ref:S,className:`${R} ${I?"":O} ${_?"":"transition-transform duration-300 ease-in-out"}`,style:{zIndex:p,pointerEvents:e?"none":"auto",...A,...I},children:[/* @__PURE__ */g(Qc,{className:`\n group relative w-14 h-14 overflow-visible transition-all duration-300 ease-in-out\n ${e?"scale-0 opacity-0 pointer-events-none":"scale-100 opacity-100 hover:scale-110"}\n `,children:[b&&/* @__PURE__ */m(Qc,{className:v,"aria-hidden":!0}),w&&!_&&/* @__PURE__ */m(od,{type:"button",variant:"secondary",size:"sm",onClick:e=>{e.preventDefault(),e.stopPropagation(),i?.()},className:"absolute top-1/2 z-20 -translate-y-1/2 rounded-full border border-white/25 bg-gray-900 px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wide text-white shadow-lg opacity-0 transition-opacity duration-150 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto "+(h.includes("left")?"left-full ml-2":"right-full mr-2"),style:{border:"1px solid rgba(255,255,255,0.25)"},"aria-label":"Stop simulation",children:"Stop"}),
17
+ /* @__PURE__ */m(od,{type:"button",variant:"bare",onClick:()=>{Date.now()<z.current||o()},onDragStart:e=>e.preventDefault(),onPointerDown:C,onPointerMove:E,onPointerUp:T,onPointerCancel:M,className:"relative z-10 w-14 h-14 min-w-14",style:{touchAction:"none",cursor:_?"grabbing":"grab",userSelect:"none",WebkitUserSelect:"none"},"aria-label":e?"Close":"Open","aria-live":"polite",children:/* @__PURE__ */m(id,{className:"w-full h-full items-center justify-center relative",children:/* @__PURE__ */g(Qc,{className:"\n relative w-12 h-12 overflow-hidden transition-[transform,opacity,background-color] duration-[167ms] ease-[cubic-bezier(0.33,0,0,1)]\n hover:scale-110 hover:duration-[250ms] active:scale-[0.85] active:duration-[134ms] active:ease-[cubic-bezier(0.45,0,0.2,1)]\n animate-launcher-entrance\n ",style:{borderRadius:c,backgroundColor:e?a:s,boxShadow:jc.fab},children:[b&&/* @__PURE__ */m("svg",{className:x,viewBox:"0 0 54 54",fill:"none","aria-hidden":!0,children:/* @__PURE__ */m("rect",{x:"1.25",y:"1.25",width:"51.5",height:"51.5",rx:k+1,ry:k+1})}),
18
18
  /* @__PURE__ */m(id,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(30deg) scale(0)":"rotate(0deg) scale(1)",opacity:e?0:1,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":e,children:/* @__PURE__ */m(nl,{src:el,alt:"",className:"relative z-10 w-full h-full object-contain",draggable:!1,onDragStart:e=>e.preventDefault(),style:{borderRadius:c,border:"none",outline:"none",backgroundColor:"transparent",pointerEvents:"none",userSelect:"none"}})}),
19
- /* @__PURE__ */m(id,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(0deg) scale(1)":"rotate(-30deg) scale(0)",opacity:e?1:0,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":!e,children:/* @__PURE__ */m(ad,{name:"chevronDown",size:24,className:"relative z-10 text-foreground pointer-events-none"})})]})})})]}),!e&&/* @__PURE__ */g(Qc,{className:`absolute bottom-16 ${h.includes("left")?"left-0":"right-0"} mb-2 px-3 py-2 text-sm rounded-lg shadow-lg whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity duration-200`,style:{backgroundColor:l,color:u},children:[/* @__PURE__ */m(gd,{as:"span",className:"text-inherit",children:"Support Agent"}),/* @__PURE__ */m(Qc,{"aria-hidden":!0,className:`absolute top-full ${h.includes("left")?"left-4":"right-4"} w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent`,style:{borderTopColor:l}})]})]})};function Id(e){return Array.from(e.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent&&!e.hasAttribute("aria-hidden"))}function Cd(e){if(!e)return 360;const t=parseInt(e.replace(/px|rem|em/gi,""),10);return isNaN(t)?360:t}function Ed(e,t,n){return Math.min(Math.max(e,t),n)}function Td(e,t,n,r,o){const i={"bottom-right":"nwse-resize","bottom-left":"nesw-resize","top-right":"nesw-resize","top-left":"nwse-resize"};switch(e){case"bottom-right":return{dx:r-t,dy:o-n,cursor:i[e]};case"bottom-left":return{dx:t-r,dy:o-n,cursor:i[e]};case"top-right":return{dx:r-t,dy:n-o,cursor:i[e]};case"top-left":return{dx:t-r,dy:n-o,cursor:i[e]}}}var Md=({title:e,subtitle:t,minimized:n=!1,onClose:r,controls:o})=>/* @__PURE__ */g(id,n?{align:"center",justify:"between",paddingX:"lg",border:"bottom",shrink:!1,style:Hc.header,children:[/* @__PURE__ */m(gd,{size:"sm",weight:"medium",children:e}),/* @__PURE__ */m(ud,{variant:"toolbar",size:"sm",label:"Close",onClick:r,children:/* @__PURE__ */m(ad,{name:"close",size:16})})]}:{align:"center",justify:"between",paddingX:"lg",paddingY:"md",border:"bottom",shrink:!1,elevation:"section",children:[/* @__PURE__ */g(id,{align:"center",gap:"md",minWidth:"0",grow:!0,children:[/* @__PURE__ */m(nl,{src:el,alt:"",size:"md",rounded:"theme",elevation:"card"}),/* @__PURE__ */g(pd,{minWidth:"0",children:[/* @__PURE__ */m(gd,{size:"sm",weight:"semibold",truncate:!0,leading:"tight",children:e}),null!=t&&/* @__PURE__ */m(gd,{as:"p",size:"xs",variant:"muted",truncate:!0,children:t})]})]}),/* @__PURE__ */g(id,{align:"center",gap:"xs",shrink:!1,children:[o,/* @__PURE__ */m(ud,{variant:"toolbar",size:"sm",label:"Close",onClick:r,children:/* @__PURE__ */m(ad,{name:"close",size:16})})]})]});function zd({onScreenSharingChange:e,onStartScreenShareRef:t,onStopScreenShareRef:n,onAddMessage:r,onUpdateMessage:o,onRemoveMessage:i,onSendMessage:s,pendingMessage:c,setPendingMessage:l}){const[p,h]=u(!1),[f,m]=u(null),[g,y]=u(null),[b,w]=u(null),[v,x]=u(!1),k=d(p),_=d(g),S=d(r),I=d(i),C=d(e);a(()=>{k.current=p},[p]),a(()=>{_.current=g},[g]),a(()=>{S.current=r},[r]),a(()=>{I.current=i},[i]),a(()=>{C.current=e},[e]),a(()=>{const e=()=>{const e=ra(),t=k.current,n=_.current;if(e!==t&&(k.current=e,h(e),C.current?.(e)),t&&!e&&n){I.current?.(n);const e=qs("Stopped screenshare","show","user","stopped-sharing");S.current(e),y(null)}};e();const t=setInterval(e,1e3);return()=>clearInterval(t)},[]);const E=()=>{x(!0)},T=()=>{ta&&(ta.getTracks().forEach(e=>e.stop()),ta=null),h(!1),m(null),e?.(!1),g&&i&&i(g),r(qs("Stopped screenshare","show","user","stopped-sharing")),y(null)};return a(()=>(t&&(t.current=E),n&&(n.current=T),()=>{t&&(t.current=null),n&&(n.current=null)})),{isScreenSharing:p,screenStream:f,showScreenAccessDialog:v,handleScreenAccessDialogAllow:async()=>{x(!1);try{const t=await na();h(!0),m(t),e?.(!0),r(Zs("show"));const n=Vs(t,"show");y(n.id),r(n)}catch(t){h(!1),m(null),e?.(!1)}},handleScreenAccessDialogDeny:()=>{x(!1)},handleScreenAccessAllow:async()=>{try{const t=await na();h(!0),m(t),e?.(!0),b&&(o(b,{screenShareStatus:"allowed"}),w(null)),r(Zs("show"));const n=Vs(t,"show");if(y(n.id),r(n),c){const e=c;l(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}catch(t){if(h(!1),m(null),e?.(!1),b&&(o(b,{screenShareStatus:"denied"}),w(null)),c){const e=c;l(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}},handleScreenAccessDeny:()=>{if(b&&(o(b,{screenShareStatus:"denied"}),w(null)),c){const e=c;l(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}},requestScreenAccess:e=>{if(b)return;const t=function(e){const t="Can I take a look at your screen?";return{id:`screen-access-request-${Date.now()}`,content:t,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:e,isScreenAccessRequest:!0,parts:[{type:"text",content:t}]}}(e);w(t.id),r(t)}}}function Od(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})}}function Rd({value:e,onChange:t,onSubmit:n,modes:r=[],activeMode:o,onModeChange:s,disabled:c=!1,taskRunning:l=!1,onStop:u,placeholder:p="Ask anything",ref:h}){const f=d(null);a(()=>{const e=f.current;if(e){e.style.height="auto";const t=e.scrollHeight,n=Math.min(t,66);e.style.height=`${n}px`,e.style.overflowY=t>66?"auto":"hidden"}},[e]);const y=i(e=>{t(e.target.value);const n=e.target;n.style.height="auto";const r=Math.min(n.scrollHeight,66);n.style.height=`${r}px`,n.style.overflowY=n.scrollHeight>66?"auto":"hidden"},[t]),b=i(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),n())},[n]),w=Boolean(e.trim())&&!c;/* @__PURE__ */
19
+ /* @__PURE__ */m(id,{className:"absolute inset-0 items-center justify-center transition-[transform,opacity] duration-[160ms] linear",style:{transform:e?"rotate(0deg) scale(1)":"rotate(-30deg) scale(0)",opacity:e?1:0,transitionProperty:"transform, opacity",transitionDuration:"0.16s, 0.08s",transitionTimingFunction:"linear"},"aria-hidden":!e,children:/* @__PURE__ */m(ad,{name:"chevronDown",size:24,className:"relative z-10 text-foreground pointer-events-none"})})]})})})]}),!e&&/* @__PURE__ */g(Qc,{className:`absolute bottom-16 ${h.includes("left")?"left-0":"right-0"} mb-2 px-3 py-2 text-sm rounded-lg shadow-lg whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity duration-200`,style:{backgroundColor:l,color:u},children:[/* @__PURE__ */m(gd,{as:"span",className:"text-inherit",children:"Support Agent"}),/* @__PURE__ */m(Qc,{"aria-hidden":!0,className:`absolute top-full ${h.includes("left")?"left-4":"right-4"} w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent`,style:{borderTopColor:l}})]})]})};function Id(e){return Array.from(e.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(e=>null!==e.offsetParent&&!e.hasAttribute("aria-hidden"))}function Cd(e){if(!e)return 360;const t=parseInt(e.replace(/px|rem|em/gi,""),10);return isNaN(t)?360:t}function Ed(e,t,n){return Math.min(Math.max(e,t),n)}function Td(e,t,n,r,o){const i={"bottom-right":"nwse-resize","bottom-left":"nesw-resize","top-right":"nesw-resize","top-left":"nwse-resize"};switch(e){case"bottom-right":return{dx:r-t,dy:o-n,cursor:i[e]};case"bottom-left":return{dx:t-r,dy:o-n,cursor:i[e]};case"top-right":return{dx:r-t,dy:n-o,cursor:i[e]};case"top-left":return{dx:t-r,dy:n-o,cursor:i[e]}}}var Md=({title:e,subtitle:t,minimized:n=!1,onClose:r,controls:o})=>/* @__PURE__ */g(id,n?{align:"center",justify:"between",paddingX:"lg",border:"bottom",shrink:!1,style:Hc.header,children:[/* @__PURE__ */m(gd,{size:"sm",weight:"medium",children:e}),/* @__PURE__ */m(ud,{variant:"toolbar",size:"sm",label:"Close",onClick:r,children:/* @__PURE__ */m(ad,{name:"close",size:16})})]}:{align:"center",justify:"between",paddingX:"lg",paddingY:"md",border:"bottom",shrink:!1,elevation:"section",children:[/* @__PURE__ */g(id,{align:"center",gap:"md",minWidth:"0",grow:!0,children:[/* @__PURE__ */m(nl,{src:el,alt:"",size:"md",rounded:"theme",elevation:"card"}),/* @__PURE__ */g(pd,{minWidth:"0",children:[/* @__PURE__ */m(gd,{size:"sm",weight:"semibold",truncate:!0,leading:"tight",children:e}),null!=t&&/* @__PURE__ */m(gd,{as:"p",size:"xs",variant:"muted",truncate:!0,children:t})]})]}),/* @__PURE__ */g(id,{align:"center",gap:"xs",shrink:!1,children:[o,/* @__PURE__ */m(ud,{variant:"toolbar",size:"sm",label:"Close",onClick:r,children:/* @__PURE__ */m(ad,{name:"close",size:16})})]})]});function zd({onScreenSharingChange:e,onStartScreenShareRef:t,onStopScreenShareRef:n,onAddMessage:r,onUpdateMessage:o,onRemoveMessage:i,onSendMessage:s,pendingMessage:c,setPendingMessage:l}){const[p,h]=u(!1),[f,m]=u(null),[g,y]=u(null),[b,w]=u(null),[v,x]=u(!1),k=d(p),S=d(g),_=d(r),I=d(i),C=d(e);a(()=>{k.current=p},[p]),a(()=>{S.current=g},[g]),a(()=>{_.current=r},[r]),a(()=>{I.current=i},[i]),a(()=>{C.current=e},[e]),a(()=>{const e=()=>{const e=ra(),t=k.current,n=S.current;if(e!==t&&(k.current=e,h(e),C.current?.(e)),t&&!e&&n){I.current?.(n);const e=qs("Stopped screenshare","show","user","stopped-sharing");_.current(e),y(null)}};e();const t=setInterval(e,1e3);return()=>clearInterval(t)},[]);const E=()=>{x(!0)},T=()=>{ta&&(ta.getTracks().forEach(e=>e.stop()),ta=null),h(!1),m(null),e?.(!1),g&&i&&i(g),r(qs("Stopped screenshare","show","user","stopped-sharing")),y(null)};return a(()=>(t&&(t.current=E),n&&(n.current=T),()=>{t&&(t.current=null),n&&(n.current=null)})),{isScreenSharing:p,screenStream:f,showScreenAccessDialog:v,handleScreenAccessDialogAllow:async()=>{x(!1);try{const t=await na();h(!0),m(t),e?.(!0),r(Zs("show"));const n=Vs(t,"show");y(n.id),r(n)}catch(t){h(!1),m(null),e?.(!1)}},handleScreenAccessDialogDeny:()=>{x(!1)},handleScreenAccessAllow:async()=>{try{const t=await na();h(!0),m(t),e?.(!0),b&&(o(b,{screenShareStatus:"allowed"}),w(null)),r(Zs("show"));const n=Vs(t,"show");if(y(n.id),r(n),c){const e=c;l(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}catch(t){if(h(!1),m(null),e?.(!1),b&&(o(b,{screenShareStatus:"denied"}),w(null)),c){const e=c;l(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}}},handleScreenAccessDeny:()=>{if(b&&(o(b,{screenShareStatus:"denied"}),w(null)),c){const e=c;l(null),s(e.content,e.mode,e.applicationId,e.question,e.alreadyAdded)}},requestScreenAccess:e=>{if(b)return;const t=function(e){const t="Can I take a look at your screen?";return{id:`screen-access-request-${Date.now()}`,content:t,sender:"agent",timestamp:/* @__PURE__ */new Date,mode:e,isScreenAccessRequest:!0,parts:[{type:"text",content:t}]}}(e);w(t.id),r(t)}}}function Od(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})}}function Rd({value:e,onChange:t,onSubmit:n,modes:r=[],activeMode:o,onModeChange:s,disabled:c=!1,taskRunning:l=!1,onStop:u,placeholder:p="Ask anything",ref:h}){const f=d(null);a(()=>{const e=f.current;if(e){e.style.height="auto";const t=e.scrollHeight,n=Math.min(t,66);e.style.height=`${n}px`,e.style.overflowY=t>66?"auto":"hidden"}},[e]);const y=i(e=>{t(e.target.value);const n=e.target;n.style.height="auto";const r=Math.min(n.scrollHeight,66);n.style.height=`${r}px`,n.style.overflowY=n.scrollHeight>66?"auto":"hidden"},[t]),b=i(e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),n())},[n]),w=Boolean(e.trim())&&!c;/* @__PURE__ */
20
20
  return g(pd,{background:"card",rounded:"xl",border:!0,overflow:"hidden",className:"focus-within:border-foreground-faint transition-colors",children:[/* @__PURE__ */m("textarea",{ref:Od(f,h),value:e,onChange:y,onKeyDown:b,placeholder:p,disabled:c,rows:1,className:"block w-full min-h-0 resize-none rounded-none border-none bg-transparent px-3 text-sm text-foreground transition-colors placeholder:text-foreground-faint focus:ring-0 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",style:{lineHeight:"20px",paddingTop:"4px",paddingBottom:"2px",minHeight:"unset"}}),/* @__PURE__ */g(id,{align:"center",justify:"between",paddingX:"sm",paddingTop:"2xs",paddingBottom:"sm",children:[/* @__PURE__ */m(id,{align:"center",gap:"2xs",children:r.map(e=>{const t=o===e.id;/* @__PURE__ */
21
- return g("button",{type:"button",className:Fc("inline-flex cursor-pointer items-center gap-0.5 border-none px-2 py-0.5 text-[11px] font-medium transition-all duration-200",Uc.pill,t?"bg-primary text-primary-foreground shadow-sm":"bg-secondary-bg text-foreground-muted"),onClick:t=>{t.preventDefault(),t.stopPropagation(),s?.(e.id)},children:[/* @__PURE__ */m(ad,{name:e.icon,size:12}),/* @__PURE__ */m(gd,{as:"span",inheritColor:!0,children:e.label})]},e.id)})}),/* @__PURE__ */m(ud,{variant:l?"secondary":"primary",size:"sm",disabled:!l&&!w,label:l?"Stop simulation":"Send message",onClick:e=>{e.preventDefault(),e.stopPropagation(),l&&u?u():n()},children:/* @__PURE__ */m(ad,l?{name:"stop",size:14}:{name:"send",size:16})})]})]})}var Ad=/*#__PURE__*/e.createContext(void 0);function Nd(t){const n=e.useContext(Ad);if(!t&&void 0===n)throw new Error($l(27));return n}var Pd=/*#__PURE__*/function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e}({}),Ld={"data-starting-style":""},$d={"data-ending-style":""},Dd={transitionStatus:e=>"starting"===e?Ld:"ending"===e?$d:null},Fd=(function(e){e.open="data-open",e.closed="data-closed",e[e.startingStyle=Pd.startingStyle]="startingStyle",e[e.endingStyle=Pd.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e.side="data-side",e.align="data-align"}({}),{"data-open":""}),jd={"data-closed":""},Ud={"data-anchor-hidden":""},Wd={open:e=>e?Fd:jd,anchorHidden:e=>e?Ud:null},Bd={...Wd,...Dd},Hd=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,style:o,forceRender:i=!1,...s}=e,a=Nd(),c=a.useState("open"),l=a.useState("nested"),d=a.useState("mounted");return Xl("div",e,{state:{open:c,transitionStatus:a.useState("transitionStatus")},ref:[a.context.backdropRef,t],stateAttributesMapping:Bd,props:[{role:"presentation",hidden:!d,style:{userSelect:"none",WebkitUserSelect:"none"}},s],enabled:i||!l})});function qd(e,t,n,r){let o=!1,i=!1;const s=r??Jl;return{reason:e,event:t??new Event("base-ui"),cancel(){o=!0},allowPropagation(){i=!0},get isCanceled(){return o},get isPropagationAllowed(){return i},trigger:n,...s}}var Zd=0;var Vd=hl.useId;function Gd(t,n){if(void 0!==Vd){const e=Vd();return t??(n?`${n}-${e}`:e)}return function(t,n="mui"){const[r,o]=e.useState(t),i=t||r;return e.useEffect(()=>{null==r&&o(`${n}-${Zd+=1}`)},[r,n]),i}(t,n)}function Yd(e){return Gd(e,"base-ui")}var Kd=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,style:o,id:i,...s}=e,a=Nd(),c=Yd(i);return a.useSyncedValueWithCleanup("descriptionElementId",c),Xl("p",e,{ref:t,props:[{id:c},s]})});function Jd(t){e.useEffect(t,Kl)}var Xd=class e{static create(){return new e}currentId=0;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=0,t()},e)}isStarted(){return 0!==this.currentId}clear=()=>{0!==this.currentId&&(clearTimeout(this.currentId),this.currentId=0)};disposeEffect=()=>this.clear};function Qd(){const e=ml(Xd.create).current;return Jd(e.disposeEffect),e}var{userAgent:eu,platform:tu,maxTouchPoints:nu}="undefined"==typeof navigator?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0},ru=eu.toLowerCase(),ou=tu.toLowerCase(),iu=/^i(os$|p)/.test(ou)||"macintel"===ou&&nu>1,su="android",au=ou===su||ru.includes(su),cu=!iu&&ou.startsWith("mac"),lu=(ou.startsWith("win"),!au&&/^(linux|chrome os)/.test(ou),cu||iu),du="undefined"!=typeof CSS&&!!CSS.supports?.("-webkit-backdrop-filter:none"),uu=(!du&&ru.includes("firefox"),!du&&ru.includes("chrom"),lu),pu=/jsdom|happydom/.test(ru);var hu="data-base-ui-focusable";function fu(e){let t=e.activeElement;for(;null!=t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function mu(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&ll(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function gu(e){return"composedPath"in e?e.composedPath()[0]:e.target}function yu(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}function bu(e){return cl(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function wu(e){return!!e&&("combobox"===e.getAttribute("role")&&bu(e))}function vu(e){return e?e.hasAttribute("data-base-ui-focusable")?e:e.querySelector("[data-base-ui-focusable]")||e:null}function xu(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function ku(...e){return()=>{for(let t=0;t<e.length;t+=1){const n=e[t];n&&n()}}}function _u(e){const t=ml(Su,e).current;return t.next=e,xl(t.effect),t}function Su(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Iu=null;globalThis.requestAnimationFrame;var Cu=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;const t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let r=0;r<t.length;r+=1)t[r]?.(e)};request(e){const t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||(requestAnimationFrame(this.tick),this.isScheduled=!0),t}cancel(e){const t=e-this.startId;t<0||t>=this.callbacks.length||(this.callbacks[t]=null,this.callbacksCount-=1)}},Eu=class e{static create(){return new e}static request(e){return Cu.request(e)}static cancel(e){return Cu.cancel(e)}currentId=Iu;request(e){this.cancel(),this.currentId=Cu.request(()=>{this.currentId=Iu,e()})}cancel=()=>{this.currentId!==Iu&&(Cu.cancel(this.currentId),this.currentId=Iu)};disposeEffect=()=>this.cancel};function Tu(){const e=ml(Eu.create).current;return Jd(e.disposeEffect),e}var Mu={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},zu={...Mu,position:"fixed",top:0,left:0},Ou=/*#__PURE__*/e.forwardRef(function(t,n){const[r,o]=e.useState();xl(()=>{uu&&du&&o("button")},[]);/*#__PURE__*/
22
- return m("span",{...t,ref:n,style:zu,"aria-hidden":!r||void 0,...{tabIndex:0,role:r},"data-base-ui-focus-guard":""})});function Ru(e,t=(e?ul(e):null)){return!(!(e&&e.isConnected&&t)||function(e){return"hidden"===e.visibility||"collapse"===e.visibility}(t))&&("function"==typeof e.checkVisibility?e.checkVisibility():"none"!==t.display&&"contents"!==t.display)}function Au(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.getRootNode();return ll(n)?n.host:null}function Nu(e){for(const t of Array.from(e.children))if("summary"===ol(t))return t;return null}function Pu(e,t){const n=Nu(t);return!!n&&(e===n||mu(n,e))}function Lu(e){const t=e?ol(e):"";return null!=e&&e.matches('a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]')&&("summary"!==t||null!=e.parentElement&&"details"===ol(e.parentElement)&&Nu(e.parentElement)===e)&&("details"!==t||null==Nu(e))&&("input"!==t||"hidden"!==e.type)}function $u(e){if(!Lu(e)||!e.isConnected||e.matches(":disabled"))return!1;for(let t=e;t;t=Au(t)){const n=t!==e,r="slot"===ol(t);if(t.hasAttribute("inert"))return!1;if(n&&"details"===ol(t)&&!t.open&&!Pu(e,t)||t.hasAttribute("hidden")||!r&&!Du(t,n))return!1}return!0}function Du(e,t){const n=ul(e);return t?"none"!==n.display:Ru(e,n)}function Fu(e){const t=e.tabIndex;if(t<0){const t=ol(e);if("details"===t||"audio"===t||"video"===t||cl(e)&&e.isContentEditable)return 0}return t}function ju(e){if("input"!==ol(e))return null;const t=e;return"radio"===t.type&&""!==t.name?t:null}function Uu(e){if(cl(e)&&"slot"===ol(e)){const t=e.assignedElements({flatten:!0});if(t.length>0)return t}return cl(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function Wu(e,t){Uu(e).forEach(e=>{Lu(e)&&t.push(e),Wu(e,t)})}function Bu(e,t,n){Uu(e).forEach(e=>{cl(e)&&e.matches(t)&&n.push(e),Bu(e,t,n)})}function Hu(e){return $u(e)&&Fu(e)>=0}function qu(e){const t=[];return Wu(e,t),t.filter($u)}function Zu(e){const t=qu(e);return t.filter(e=>Fu(e)>=0&&function(e,t){const n=ju(e);if(!n)return!0;const r=t.find(e=>{const t=ju(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{const t=ju(e);return t?.name===n.name&&t.form===n.form})===n}(e,t))}function Vu(e,t){const n=Zu(e),r=n.length;if(0===r)return;const o=fu(Fl(e)),i=n.indexOf(o);return n[-1===i?1===t?0:r-1:i+t]}function Gu(e){return Vu(Fl(e).body,1)||e}function Yu(e){return Vu(Fl(e).body,-1)||e}function Ku(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!mu(n,r)}function Ju(e){const t=[];Bu(e,"[data-tabindex]",t),t.forEach(e=>{const t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")})}function Xu(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...Xu(e,t.id,n)])}function Qu(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){const t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function ep(e){return`data-base-ui-${e}`}var tp=0;function np(e,t={}){const{preventScroll:n=!1,sync:r=!1,shouldFocus:o}=t;function i(){o&&!o()||e?.focus({preventScroll:n})}if(cancelAnimationFrame(tp),r)return i(),Yl;const s=requestAnimationFrame(i);return tp=s,()=>{tp===s&&(cancelAnimationFrame(s),tp=0)}}var rp={inert:/* @__PURE__ */new WeakMap,"aria-hidden":/* @__PURE__ */new WeakMap},op="data-base-ui-inert",ip={inert:/* @__PURE__ */new WeakSet,"aria-hidden":/* @__PURE__ */new WeakSet},sp=/* @__PURE__ */new WeakMap,ap=0;function cp(e){return e?ll(e)?e.host:cp(e.parentNode):null}var lp=(e,t)=>t.map(t=>{if(e.contains(t))return t;const n=cp(t);return e.contains(n)?n:null}).filter(e=>null!=e),dp=e=>{const t=/* @__PURE__ */new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},up=(e,t,n)=>{const r=[],o=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{"script"!==ol(e)&&(t.has(e)?o(e):r.push(e))})};return o(e),r};function pp(e,t,n,r,{mark:o=!0}){let i=null;r?i="inert":n&&(i="aria-hidden");let s=null,a=null;const c=lp(t,e),l=o?up(t,dp(c),new Set(c)):[],d=[],u=[];if(i){const e=rp[i],n=function(e){return ip[e]}(i);a=n,s=e;const r=lp(t,Array.from(t.querySelectorAll("[aria-live]"))),o=c.concat(r);up(t,dp(o),new Set(o)).forEach(t=>{const r=t.getAttribute(i),o=null!==r&&"false"!==r,s=(e.get(t)||0)+1;e.set(t,s),d.push(t),1===s&&o&&n.add(t),o||t.setAttribute(i,"inert"===i?"":"true")})}return o&&l.forEach(e=>{const t=(sp.get(e)||0)+1;sp.set(e,t),u.push(e),1===t&&e.setAttribute(op,"")}),ap+=1,()=>{s&&d.forEach(e=>{const t=(s.get(e)||0)-1;s.set(e,t),t||(!a?.has(e)&&i&&e.removeAttribute(i),a?.delete(e))}),o&&u.forEach(e=>{const t=(sp.get(e)||0)-1;sp.set(e,t),t||e.removeAttribute(op)}),(ap-=1)||(rp.inert=/* @__PURE__ */new WeakMap,rp["aria-hidden"]=/* @__PURE__ */new WeakMap,ip.inert=/* @__PURE__ */new WeakSet,ip["aria-hidden"]=/* @__PURE__ */new WeakSet,sp=/* @__PURE__ */new WeakMap)}}function hp(e,t={}){const{ariaHidden:n=!1,inert:r=!1,mark:o=!0}=t;return pp(e,Fl(e[0]).body,n,r,{mark:o})}var fp={clipPath:"inset(50%)",position:"fixed",top:0,left:0},mp=/*#__PURE__*/e.createContext(null),gp=()=>e.useContext(mp),yp=ep("portal");var bp=/*#__PURE__*/e.forwardRef(function(t,n){const{render:r,className:o,style:i,children:s,container:a,...c}=t,{node:l,nodeId:d,subtree:u}=function(t={}){const{ref:n,container:r,componentProps:o=Jl,elementProps:i}=t,s=Gd(),a=gp()?.portalNode,[c,l]=e.useState(null),[d,u]=e.useState(null),p=bl(e=>{null!==e&&u(e)}),h=e.useRef(null);xl(()=>{if(null===r)return void(h.current&&(h.current=null,u(null),l(null)));const e=(r&&(sl(r)?r:r.current))??a??document.body;null!=e?h.current!==e&&(h.current=e,u(null),l(e)):h.current&&(h.current=null,u(null),l(null))},[r,a]);const f=Xl("div",o,{ref:[n,p],props:[{id:s,[yp]:""},i]}),m=c&&f?/*#__PURE__*/y.createPortal(f,c):null;return{node:d,nodeId:/*#__PURE__*/e.isValidElement(f)?f.props.id:void 0,subtree:m}}({container:a,ref:n,componentProps:t,elementProps:c}),p=e.useRef(null),h=e.useRef(null),f=e.useRef(null),b=e.useRef(null),[w,v]=e.useState(null),x=e.useRef(!1),k=w?.modal,_=w?.open,S=!!w&&!w.modal&&w.open&&!!l;e.useEffect(()=>{if(l&&!k)return ku(xu(l,"focusin",e,!0),xu(l,"focusout",e,!0));function e(e){l&&e.relatedTarget&&Ku(e)&&("focusin"===e.type?x.current&&(Ju(l),x.current=!1):(!function(e){Zu(e).forEach(e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")})}(l),x.current=!0))}},[l,k]),xl(()=>{l&&!0===_&&x.current&&(Ju(l),x.current=!1)},[_,l]);const I=e.useMemo(()=>({beforeOutsideRef:p,afterOutsideRef:h,beforeInsideRef:f,afterInsideRef:b,portalNode:l,setFocusManagerState:v}),[l]);/*#__PURE__*/
23
- return g(e.Fragment,{children:[u,/*#__PURE__*/g(mp.Provider,{value:I,children:[S&&l&&/*#__PURE__*/m(Ou,{"data-type":"outside",ref:p,onFocus:e=>{if(Ku(e,l))f.current?.focus();else{const e=w?w.domReference:null;Yu(e)?.focus()}}}),S&&l&&/*#__PURE__*/m("span",{"aria-owns":d,style:fp}),l&&/*#__PURE__*/y.createPortal(s,l),S&&l&&/*#__PURE__*/m(Ou,{"data-type":"outside",ref:h,onFocus:e=>{if(Ku(e,l))b.current?.focus();else{const t=w?w.domReference:null;Gu(t)?.focus(),w?.closeOnFocusOut&&w?.onOpenChange(!1,qd("focus-out",e.nativeEvent))}}})]})]})});function wp(){const e=/* @__PURE__ */new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,/* @__PURE__ */new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var vp=/*#__PURE__*/e.createContext(null),xp=/*#__PURE__*/e.createContext(null),kp=t=>{const n=e.useContext(xp);return t??n};function _p(e){return null==e?e:"current"in e?e.current:e}var Sp=[];function Ip(){Sp=Sp.filter(e=>e.deref()?.isConnected)}function Cp(e){Ip(),e&&"body"!==ol(e)&&(Sp.push(new WeakRef(e)),Sp.length>20&&(Sp=Sp.slice(-20)))}function Ep(){return Ip(),Sp[Sp.length-1]?.deref()}function Tp(e){if(e.hasAttribute("tabindex")&&!e.hasAttribute("data-tabindex"))return;if(!e.getAttribute("role")?.includes("dialog"))return;const t=qu(e).filter(e=>{const t=e.getAttribute("data-tabindex")||"";return Hu(e)||e.hasAttribute("data-tabindex")&&!t.startsWith("-")}),n=e.getAttribute("tabindex");0===t.length?"0"!==n&&(e.setAttribute("tabindex","0"),e.setAttribute("data-tabindex","0")):("-1"!==n||e.hasAttribute("data-tabindex")&&"-1"!==e.getAttribute("data-tabindex"))&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function Mp(t){const{context:n,children:r,disabled:o=!1,initialFocus:i=!0,returnFocus:s=!0,restoreFocus:a=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:d="",nextFocusableElement:u,previousFocusableElement:p,beforeContentFocusGuardRef:h,externalTree:f,getInsideElements:y}=t,b="rootStore"in n?n.rootStore:n,w=b.useState("open"),v=b.useState("domReferenceElement"),x=b.useState("floatingElement"),{events:k,dataRef:_}=b.context,S=bl(()=>_.current.floatingContext?.nodeId),I=!1===i,C=wu(v)&&I,E=_u(i),T=_u(s),M=_u(d),z=_u(w),O=kp(f),R=gp(),A=e.useRef(!1),N=e.useRef(!1),P=e.useRef(!1),L=e.useRef(null),$=e.useRef(""),D=e.useRef(""),F=e.useRef(null),j=e.useRef(null),U=Bl(F,h,R?.beforeInsideRef),W=Bl(j,R?.afterInsideRef),B=Qd(),H=Qd(),q=Tu(),Z=null!=R,V=vu(x),G=bl((e=V)=>e?Zu(e):[]),Y=bl(()=>y?.().filter(e=>null!=e)??[]);e.useEffect(()=>{if(o||!c)return;return xu(Fl(V),"keydown",function(e){"Tab"===e.key&&mu(V,fu(Fl(V)))&&0===G().length&&!C&&function(e){e.preventDefault(),e.stopPropagation()}(e)})},[o,V,c,C,G]),e.useEffect(()=>{if(o||!w)return;const e=Fl(V);function t(){P.current=!1}return ku(xu(e,"pointerdown",function(e){const t=gu(e),n=Y(),r=mu(x,t)||mu(v,t)||mu(R?.portalNode,t)||n.some(e=>e===t||mu(e,t));P.current=!r,D.current=e.pointerType||"keyboard",t?.closest("[data-base-ui-click-trigger]")&&(N.current=!0,H.start(0,()=>{N.current=!1}))},!0),xu(e,"pointerup",t,!0),xu(e,"pointercancel",t,!0),xu(e,"keydown",function(){D.current="keyboard"},!0),t)},[o,x,v,V,w,R,H,Y]),e.useEffect(()=>{if(o||!l)return;const e=Fl(V);function t(t){const n=t.relatedTarget,r=t.currentTarget,o=gu(t);c&&null==n&&null!=o&&mu(x,o)&&Cp(o),queueMicrotask(()=>{const i=S(),s=b.context.triggerElements,l=Y(),d=n?.hasAttribute(ep("focus-guard"))&&[F.current,j.current,R?.beforeInsideRef.current,R?.afterInsideRef.current,R?.beforeOutsideRef.current,R?.afterOutsideRef.current,_p(p),_p(u)].includes(n),h=!(mu(v,n)||mu(x,n)||mu(n,x)||mu(R?.portalNode,n)||l.some(e=>e===n||mu(e,n))||s.hasMatchingElement(e=>mu(e,n))||d||O&&(Xu(O.nodesRef.current,i).find(e=>mu(e.context?.elements.floating,n)||mu(e.context?.elements.domReference,n))||Qu(O.nodesRef.current,i).find(e=>[e.context?.elements.floating,vu(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===v&&V&&Tp(V),a&&r!==v&&!Ru(o)&&fu(e)===e.body){if(cl(V)&&(V.focus(),"popup"===a))return void q.request(()=>{V.focus()});const e=G(),t=L.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||V;cl(n)&&n.focus()}_.current.insideReactTree?_.current.insideReactTree=!1:!C&&c||!n||!h||N.current||!C&&n===Ep()||(A.current=!0,b.setOpen(!1,qd("focus-out",t)))})}const n=cl(v)?v:null;return x||n?ku(n&&xu(n,"focusout",t),n&&xu(n,"pointerdown",function(){N.current=!0,H.start(0,()=>{N.current=!1})}),x&&xu(x,"focusin",function(e){const t=gu(e);Hu(t)&&(L.current=t)}),x&&xu(x,"focusout",t),x&&R&&xu(x,"focusout",function(){P.current||(_.current.insideReactTree=!0,B.start(0,()=>{_.current.insideReactTree=!1}))},!0)):void 0},[o,v,x,V,c,O,R,b,l,a,G,C,S,_,B,H,q,u,p,Y]),e.useEffect(()=>{if(o||!x||!w)return;const e=Array.from(R?.portalNode?.querySelectorAll(`[${ep("portal")}]`)||[]),t=(O?Qu(O.nodesRef.current,S()):[]).find(e=>wu(e.context?.elements.domReference||null))?.context?.elements.domReference,n=hp([x,...e,F.current,j.current,R?.beforeOutsideRef.current,R?.afterOutsideRef.current,...Y(),t,_p(p),_p(u),C?v:null].filter(e=>null!=e),{ariaHidden:c||C,mark:!1}),r=hp([x,...e].filter(e=>null!=e));return()=>{r(),n()}},[w,o,v,x,c,R,C,O,S,u,p,Y]),xl(()=>{if(!w||o||!cl(V))return;$.current="",D.current="";const e=Fl(V),t=fu(e);queueMicrotask(()=>{const n=E.current,r="function"==typeof n?n(M.current||""):n;if(void 0===r||!1===r)return;if(mu(V,t))return;let o=null;const i=()=>(null==o&&(o=G(V)),o[0]||V);let s;s=!0===r||null===r?i():_p(r),s=s||i();const a=mu(V,fu(e));np(s,{preventScroll:s===V,shouldFocus(){if(!z.current)return!1;if(a)return!0;const t=fu(e);return!(t!==s&&mu(V,t))}})})},[o,w,V,G,E,M,z]),xl(()=>{if(o||!V)return;const e=Fl(V),t=fu(e),n=null==M.current;function r(e){var t;if(e.open||($.current=function(e,t){const n=il(gu(e));return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(0===e.detail?"keyboard":"mouse"):""}(e.nativeEvent,D.current)),"trigger-hover"===e.reason&&"mouseleave"===e.nativeEvent.type&&(A.current=!0),"outside-press"===e.reason)if(e.nested)A.current=!1;else if(""===(t=e.nativeEvent).pointerType&&t.isTrusted||(au&&t.pointerType?"click"===t.type&&1===t.buttons:0===t.detail&&!t.pointerType)||function(e){return!pu&&(!au&&0===e.width&&0===e.height||au&&1===e.width&&1===e.height&&0===e.pressure&&0===e.detail&&"mouse"===e.pointerType||e.width<1&&e.height<1&&0===e.pressure&&0===e.detail&&"touch"===e.pointerType)}(e.nativeEvent))A.current=!1;else{let e=!1;Fl(V).createElement("div").focus({get preventScroll(){return e=!0,!1}}),A.current=!e}}return Cp(t),k.on("openchange",r),()=>{k.off("openchange",r);const o=fu(e),i=Y(),s=mu(x,o)||i.some(e=>e===o||mu(e,o))||O&&Xu(O.nodesRef.current,S(),!1).some(e=>mu(e.context?.elements.floating,o)),a=T.current,c=$.current,l=function(e){const r=T.current;let o="function"==typeof r?r(e):r;if(void 0===o||!1===o)return null;null===o&&(o=!0);const i=v?.isConnected?v:null,s=t?.isConnected&&"body"!==ol(t)?t:null;let a=n?s||i:i||s;return a||(a=Ep()||null),"boolean"==typeof o?a:_p(o)||a||null}(c);queueMicrotask(()=>{const t=(n=l)?Hu(n)?n:Zu(n)[0]||n:null;var n;const r="boolean"!=typeof a;if(a&&!A.current&&cl(t)&&(r||t===o||o===e.body||s)){const e={preventScroll:!0};"keyboard"===c&&(e.focusVisible=!0),t.focus(e)}A.current=!1})}},[o,x,V,T,M,k,O,v,S,Y]),xl(()=>{if(!du||w||!x)return;const e=fu(Fl(x));cl(e)&&bu(e)&&mu(x,e)&&e.blur()},[w,x]),xl(()=>{if(!o&&R)return R.setFocusManagerState({modal:c,closeOnFocusOut:l,open:w,onOpenChange:b.setOpen,domReference:v}),()=>{R.setFocusManagerState(null)}},[o,R,c,w,b,l,v]),xl(()=>{if(!o&&V)return Tp(V),()=>{queueMicrotask(Ip)}},[o,V]);const K=!o&&(!c||!C)&&(Z||c);/*#__PURE__*/
24
- return g(e.Fragment,{children:[K&&/*#__PURE__*/m(Ou,{"data-type":"inside",ref:U,onFocus:e=>{if(c){const e=G();np(e[e.length-1])}else R?.portalNode&&(A.current=!1,Ku(e,R.portalNode)?Gu(v)?.focus():_p(p??R.beforeOutsideRef)?.focus())}}),r,K&&/*#__PURE__*/m(Ou,{"data-type":"inside",ref:W,onFocus:e=>{c?np(G()[0]):R?.portalNode&&(l&&(A.current=!0),Ku(e,R.portalNode)?Yu(v)?.focus():_p(u??R.afterOutsideRef)?.focus())}})]})}function zp(){return!1}function Op(t,n={}){const{enabled:r=!0,escapeKey:o=!0,outsidePress:i=!0,outsidePressEvent:s="sloppy",referencePress:a=zp,bubbles:c,externalTree:l}=n,d="rootStore"in t?t.rootStore:t,u=d.useState("open"),p=d.useState("floatingElement"),{dataRef:h}=d.context,f=kp(l),m=bl("function"==typeof i?i:()=>!1),g="function"==typeof i?m:i,y=!1!==g,b=bl(()=>s),{escapeKey:w,outsidePress:v}={escapeKey:"boolean"==typeof(x=c)?x:x?.escapeKey??!1,outsidePress:"boolean"==typeof x?x:x?.outsidePress??!0};var x;const k=e.useRef(!1),_=e.useRef(!1),S=e.useRef(!1),I=e.useRef(!1),C=e.useRef(""),E=e.useRef(null),T=Qd(),M=Qd(),z=bl(()=>{M.clear(),h.current.insideReactTree=!1}),O=bl(e=>{const t=h.current.floatingContext?.nodeId;return(f?Xu(f.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),R=bl(e=>yu(e,d.select("floatingElement"))||yu(e,d.select("domReferenceElement"))),A=bl(e=>{a()&&d.setOpen(!1,qd("trigger-press",e.nativeEvent))}),N=bl(e=>{if(!u||!r||!o||"Escape"!==e.key)return;if(I.current)return;if(!w&&O("__escapeKeyBubbles"))return;const t=qd("escape-key",function(e){return"nativeEvent"in e}(e)?e.nativeEvent:e);d.setOpen(!1,t),t.isCanceled||e.preventDefault(),w||t.isPropagationAllowed||e.stopPropagation()}),P=bl(()=>{h.current.insideReactTree=!0,M.start(0,z)}),L=bl(e=>{if(!u||!r||0!==e.button)return;const t=gu(e.nativeEvent);mu(d.select("floatingElement"),t)&&(k.current||(k.current=!0,_.current=!1))}),$=bl(e=>{u&&r&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&k.current&&(_.current=!0)});e.useEffect(()=>{if(!u||!r)return z;h.current.__escapeKeyBubbles=w,h.current.__outsidePressBubbles=v;const e=new Xd,t=new Xd;function n(){S.current=!0,t.start(0,()=>{S.current=!1})}function i(){k.current=!1,_.current=!1}function s(){const e=C.current,t="pen"!==e&&e?e:"mouse",n=b(),r="function"==typeof n?n():n;return"string"==typeof r?r:r[t]}function a(e){const t=h.current.floatingContext?.nodeId,n=f&&Xu(f.nodesRef.current,t).some(t=>yu(e,t.context?.elements.floating));return R(e)||n}function c(e){if(function(e){const t=s();return"intentional"===t&&"click"!==e.type||"sloppy"===t&&"click"===e.type}(e))return"click"===e.type||R(e)||(t.clear(),S.current=!1),void z();if(h.current.insideReactTree)return void z();const n=gu(e),r=`[${ep("inert")}]`,o=al(n)?n.getRootNode():null,i=Array.from((ll(o)?o:Fl(d.select("floatingElement"))).querySelectorAll(r)),c=d.context.triggerElements;if(n&&(c.hasElement(n)||c.hasMatchingElement(e=>mu(e,n))))return;let l=al(n)?n:null;for(;l&&!dl(l);){const e=pl(l);if(dl(e)||!al(e))break;l=e}if(!i.length||!al(n)||n.matches("html,body")||mu(n,d.select("floatingElement"))||!i.every(e=>!mu(l,e))){if(cl(n)&&!("touches"in e)){const t=dl(n),r=ul(n),o=/auto|scroll/,i=t||o.test(r.overflowX),s=t||o.test(r.overflowY),a=i&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=s&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l="rtl"===r.direction,d=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),u=a&&e.offsetY>n.clientHeight;if(d||u)return}if(!a(e))return"intentional"===s()&&S.current?(t.clear(),void(S.current=!1)):void(("function"!=typeof g||g(e))&&(O("__outsidePressBubbles")||(d.setOpen(!1,qd("outside-press",e)),z())))}}function l(e){if("sloppy"!==s()||!d.select("open")||!r||R(e))return;const t=e.touches[0];t&&(E.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},T.start(1e3,()=>{E.current&&(E.current.dismissOnTouchEnd=!1,E.current.dismissOnMouseDown=!1)}))}function m(e,t){const n=gu(e);if(!n)return;const r=xu(n,e.type,()=>{t(e),r()})}function x(e){T.clear(),"pointerdown"===e.type&&(C.current=e.pointerType),"mousedown"===e.type&&E.current&&!E.current.dismissOnMouseDown||m(e,e=>{"pointerdown"===e.type?function(e){"sloppy"===s()&&"touch"!==e.pointerType&&d.select("open")&&r&&!R(e)&&c(e)}(e):c(e)})}function M(e){if(!k.current)return;const r=_.current;i(),"intentional"===s()&&("pointercancel"!==e.type?a(e)||(r?n():("function"!=typeof g||g(e))&&(t.clear(),S.current=!0,z())):r&&n())}function A(e){if("sloppy"!==s()||!E.current||R(e))return;const t=e.touches[0];if(!t)return;const n=Math.abs(t.clientX-E.current.startX),r=Math.abs(t.clientY-E.current.startY),o=Math.sqrt(n*n+r*r);o>5&&(E.current.dismissOnTouchEnd=!0),o>10&&(c(e),T.clear(),E.current=null)}function P(e){"sloppy"===s()&&E.current&&!R(e)&&(E.current.dismissOnTouchEnd&&c(e),T.clear(),E.current=null)}const L=Fl(p),$=ku(o&&ku(xu(L,"keydown",N),xu(L,"compositionstart",function(){e.clear(),I.current=!0}),xu(L,"compositionend",function(){e.start(du?5:0,()=>{I.current=!1})})),y&&ku(xu(L,"click",x,!0),xu(L,"pointerdown",x,!0),xu(L,"pointerup",M,!0),xu(L,"pointercancel",M,!0),xu(L,"mousedown",x,!0),xu(L,"mouseup",M,!0),xu(L,"touchstart",function(e){C.current="touch",m(e,l)},!0),xu(L,"touchmove",function(e){m(e,A)},!0),xu(L,"touchend",function(e){m(e,P)},!0)));return()=>{$(),e.clear(),t.clear(),i(),S.current=!1,z()}},[h,p,o,y,g,u,r,w,v,N,z,b,O,R,f,d,T]);const D=e.useMemo(()=>({onKeyDown:N,onPointerDown:A,onClick:A}),[N,A]),F=e.useMemo(()=>({onKeyDown:N,onPointerDown:$,onMouseDown:$,onClickCapture:P,onMouseDownCapture(e){P(),L(e)},onPointerDownCapture(e){P(),L(e)},onMouseUpCapture:P,onTouchEndCapture:P,onTouchMoveCapture:P}),[N,P,L,$]);return e.useMemo(()=>r?{reference:D,floating:F,trigger:D}:{},[r,D,F])}var Rp=[];var Ap,Np=Vl(19)?function(t,n,r,o,i){const s=void 0;if(!s)return function(t,n,r,o,i){const s=e.useCallback(()=>n(t.getSnapshot(),r,o,i),[t,n,r,o,i]);return p(t.subscribe,s,s)}(t,n,r,o,i);const a=s.syncIndex;let c;s.syncIndex+=1,s.didInitialize?(c=s.syncHooks[a],c.store===t&&c.selector===n&&Object.is(c.a1,r)&&Object.is(c.a2,o)&&Object.is(c.a3,i)||(c.store!==t&&(s.didChangeStore=!0),c.store=t,c.selector=n,c.a1=r,c.a2=o,c.a3=i,c.value=n(t.getSnapshot(),r,o,i))):(c={store:t,selector:n,a1:r,a2:o,a3:i,value:n(t.getSnapshot(),r,o,i)},s.syncHooks.push(c));return c.value}:function(e,t,n,r,o){return function(){throw new Error("React 19 uses its native useSyncExternalStore")}(e.subscribe,e.getSnapshot,e.getSnapshot)};function Pp(e,t,n,r,o){return Np(e,t,n,r,o)}Ap={before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){const r=e.syncHooks[n],o=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,o)||(t=!0,r.value=o)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{const n=/* @__PURE__ */new Set;for(const o of e.syncHooks)n.add(o.store);const r=[];for(const e of n)r.push(e.subscribe(t));return()=>{for(const e of r)e()}}),p(e.subscribe,e.getSnapshot,e.getSnapshot))}},Rp.push(Ap);var Lp=class{constructor(e){this.state=e,this.listeners=/* @__PURE__ */new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;const t=this.updateTick;for(const n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(const t in e)if(!Object.is(this.state[t],e[t]))return void this.setState({...this.state,...e})}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){const e={...this.state};this.setState(e)}use(e,t,n,r){return Pp(this,e,t,n,r)}},$p=class extends Lp{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(t,n){e.useDebugValue(t);const r=this;xl(()=>{r.state[t]!==n&&r.set(t,n)},[r,t,n])}useSyncedValueWithCleanup(e,t){const n=this;xl(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){const t=this,n=Object.values(e);xl(()=>{t.update(e)},[t,...n])}useControlledProp(t,n){e.useDebugValue(t);const r=this,o=void 0!==n;xl(()=>{o&&!Object.is(r.state[t],n)&&r.setState({...r.state,[t]:n})},[r,t,n,o])}select(e,t,n,r){return(0,this.selectors[e])(this.state,t,n,r)}useState(t,n,r,o){return e.useDebugValue(t),Pp(this,this.selectors[t],n,r,o)}useContextCallback(t,n){e.useDebugValue(t);const r=bl(n??Yl);this.context[t]=r}useStateSetter(t){const n=e.useRef(void 0);return void 0===n.current&&(n.current=e=>{this.set(t,e)}),n.current}observe(e,t){let n;n="function"==typeof e?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{const o=n(e);if(!Object.is(r,o)){const e=r;r=o,t(o,e,this)}})}},Dp={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},Fp=class extends $p{constructor(e){const{syncOnly:t,nested:n,onOpenChange:r,triggerElements:o,...i}=e;super({...i,positionReference:i.referenceElement,domReferenceElement:i.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:wp(),nested:n,triggerElements:o},Dp),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||null!=t&&function(e){const t=e.type;return"click"===t||"mousedown"===t||"keydown"===t||"keyup"===t}(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);const n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit("openchange",n)};setOpen=(e,t)=>{this.syncOnly||this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function jp(t){const{enabled:n=!0,open:r,ref:o,onComplete:i}=t,s=bl(i),a=function(e,t=!1){const n=Tu();return bl((r,o=null)=>{n.cancel();const i=_p(e);if(null==i)return;const s=i,a=()=>{y.flushSync(r)};if("function"!=typeof s.getAnimations||globalThis.BASE_UI_ANIMATIONS_DISABLED)r();else{if(t){const e="data-starting-style";if(!s.hasAttribute(e))return void n.request(c);const t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),c())});return t.observe(s,{attributes:!0,attributeFilter:[e]}),void o?.addEventListener("abort",()=>t.disconnect(),{once:!0})}n.request(c)}function c(){Promise.all(s.getAnimations().map(e=>e.finished)).then(()=>{o?.aborted||a()},()=>{o?.aborted||(s.getAnimations().some(e=>e.pending||"finished"!==e.playState)?c():a())})}})}(o,r);e.useEffect(()=>{if(!n)return;const e=new AbortController;return a(s,e.signal),()=>{e.abort()}},[n,r,s,a])}var Up={tabIndex:-1,[hu]:""};function Wp(t,n=!1){const r=Gd(),o=null!=(e.useContext(vp)?.id||null),i=ml(()=>t(r,o)).current;return function(t){const{popupStore:n,treatPopupAsFloatingElement:r=!1,floatingRootContext:o,floatingId:i,nested:s,onOpenChange:a}=t,c=n.useState("open"),l=n.useState("activeTriggerElement"),d=n.useState(r?"popupElement":"positionerElement"),u=n.context.triggerElements,p=a,h=e.useRef(null);void 0===o&&null===h.current&&(h.current=new Fp({open:c,transitionStatus:void 0,referenceElement:l,floatingElement:d,triggerElements:u,onOpenChange:p,floatingId:i,syncOnly:!0,nested:s}));const f=o??h.current;n.useSyncedValue("floatingId",i),xl(()=>{const e={open:c,floatingId:i,referenceElement:l,floatingElement:d};al(l)&&(e.domReferenceElement=l),f.state.positionReference===f.state.referenceElement&&(e.positionReference=l),f.update(e)},[c,i,l,d,f]),f.context.onOpenChange=p,f.context.nested=s}({popupStore:i,treatPopupAsFloatingElement:n,floatingRootContext:i.state.floatingRootContext,floatingId:r,nested:o,onOpenChange:i.setOpen}),i}function Bp({handle:e,store:t}){return xl(()=>e.attachStore(t),[e,t]),null}function Hp(t,n,r){const{mounted:o,setMounted:i,transitionStatus:s}=function(t,n=!1,r=!1){const[o,i]=e.useState(t&&n?"idle":void 0),[s,a]=e.useState(t);return t&&!s&&(a(!0),i("starting")),t||!s||"ending"===o||r||i("ending"),t||s||"ending"!==o||i(void 0),xl(()=>{if(!t&&s&&"ending"!==o&&r){const e=Eu.request(()=>{i("ending")});return()=>{Eu.cancel(e)}}},[t,s,o,r]),xl(()=>{if(!t||n)return;const e=Eu.request(()=>{i(void 0)});return()=>{Eu.cancel(e)}},[n,t]),xl(()=>{if(!t||!n)return;t&&s&&"idle"!==o&&i("starting");const e=Eu.request(()=>{i("idle")});return()=>{Eu.cancel(e)}},[n,t,s,o]),{mounted:s,setMounted:a,transitionStatus:o}}(t),a=n.useState("preventUnmountingOnClose"),c=!t&&a;n.useSyncedValues({mounted:o,transitionStatus:s,preventUnmountingOnClose:c});const l=bl(()=>{i(!1),n.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),r?.(),n.context.onOpenChangeComplete?.(!1)});return jp({enabled:o&&!t&&!c,open:t,ref:n.context.popupRef,onComplete(){t||l()}}),{forceUnmount:l,transitionStatus:s}}var qp=class{constructor(){this.idMap=/* @__PURE__ */new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(const t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(const t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function Zp(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new Fp({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new qp,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0}),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Jl,inactiveTriggerProps:Jl,popupProps:Jl}}var Vp=e=>e.triggerIdProp??e.activeTriggerId,Gp=e=>e.openProp??e.open,Yp=e=>(e.popupElement?.id??e.floatingId)||void 0;function Kp(e,t){return void 0!==t&&Gp(e)&&Vp(e)===t}var Jp={open:Gp,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Vp,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Yp,isTriggerActive:(e,t)=>void 0!==t&&Vp(e)===t,isOpenedByTrigger:(e,t)=>Kp(e,t),isMountedByTrigger:(e,t)=>void 0!==t&&Vp(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>function(e,t){return!!Kp(e,t)||void 0!==t&&Gp(e)&&null==Vp(e)&&1===e.triggerCount}(e,t)?Yp(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement},Xp=/*#__PURE__*/e.createContext(void 0);var Qp=/* @__PURE__ */new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),eh={...Wd,...Dd,nestedDialogOpen:e=>e?{"data-nested-dialog-open":""}:null},th=/*#__PURE__*/e.forwardRef(function(t,n){const{render:r,className:o,style:i,finalFocus:s,initialFocus:a,...c}=t,l=Nd(),d=l.useState("descriptionElementId"),u=l.useState("disablePointerDismissal"),p=l.useState("floatingRootContext"),h=l.useState("popupProps"),f=l.useState("modal"),g=l.useState("mounted"),y=l.useState("nested"),b=l.useState("nestedOpenDialogCount"),w=l.useState("open"),v=l.useState("openMethod"),x=l.useState("titleElementId"),k=l.useState("transitionStatus"),_=l.useState("role"),S=p.useState("floatingId");!function(){const t=e.useContext(Xp);if(void 0===t)throw new Error($l(26))}(),jp({open:w,ref:l.context.popupRef,onComplete(){w&&l.context.onOpenChangeComplete?.(!0)}});const I=void 0===a?(C=l.context.popupRef,e=>"touch"!==e||C.current):a;var C;const E=b>0,T=l.useStateSetter("popupElement"),M=Xl("div",t,{state:{open:w,nested:y,transitionStatus:k,nestedDialogOpen:E},props:[h,{id:S,"aria-labelledby":x,"aria-describedby":d,role:_,...Up,hidden:!g,onKeyDown(e){Qp.has(e.key)&&e.stopPropagation()},style:{"--nested-dialogs":b}},c],ref:[n,l.context.popupRef,T],stateAttributesMapping:eh});/*#__PURE__*/
21
+ return g("button",{type:"button",className:Fc("inline-flex cursor-pointer items-center gap-0.5 border-none px-2 py-0.5 text-[11px] font-medium transition-all duration-200",Uc.pill,t?"bg-primary text-primary-foreground shadow-sm":"bg-secondary-bg text-foreground-muted"),onClick:t=>{t.preventDefault(),t.stopPropagation(),s?.(e.id)},children:[/* @__PURE__ */m(ad,{name:e.icon,size:12}),/* @__PURE__ */m(gd,{as:"span",inheritColor:!0,children:e.label})]},e.id)})}),/* @__PURE__ */m(ud,{variant:l?"secondary":"primary",size:"sm",disabled:!l&&!w,label:l?"Stop simulation":"Send message",onClick:e=>{e.preventDefault(),e.stopPropagation(),l&&u?u():n()},children:/* @__PURE__ */m(ad,l?{name:"stop",size:14}:{name:"send",size:16})})]})]})}var Ad=/*#__PURE__*/e.createContext(void 0);function Nd(t){const n=e.useContext(Ad);if(!t&&void 0===n)throw new Error($l(27));return n}var Pd=/*#__PURE__*/function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e}({}),Ld={"data-starting-style":""},$d={"data-ending-style":""},Dd={transitionStatus:e=>"starting"===e?Ld:"ending"===e?$d:null},Fd=(function(e){e.open="data-open",e.closed="data-closed",e[e.startingStyle=Pd.startingStyle]="startingStyle",e[e.endingStyle=Pd.endingStyle]="endingStyle",e.anchorHidden="data-anchor-hidden",e.side="data-side",e.align="data-align"}({}),{"data-open":""}),jd={"data-closed":""},Ud={"data-anchor-hidden":""},Wd={open:e=>e?Fd:jd,anchorHidden:e=>e?Ud:null},Bd={...Wd,...Dd},Hd=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,style:o,forceRender:i=!1,...s}=e,a=Nd(),c=a.useState("open"),l=a.useState("nested"),d=a.useState("mounted");return Xl("div",e,{state:{open:c,transitionStatus:a.useState("transitionStatus")},ref:[a.context.backdropRef,t],stateAttributesMapping:Bd,props:[{role:"presentation",hidden:!d,style:{userSelect:"none",WebkitUserSelect:"none"}},s],enabled:i||!l})});function qd(e,t,n,r){let o=!1,i=!1;const s=r??Jl;return{reason:e,event:t??new Event("base-ui"),cancel(){o=!0},allowPropagation(){i=!0},get isCanceled(){return o},get isPropagationAllowed(){return i},trigger:n,...s}}var Zd=0;var Vd=hl.useId;function Gd(t,n){if(void 0!==Vd){const e=Vd();return t??(n?`${n}-${e}`:e)}return function(t,n="mui"){const[r,o]=e.useState(t),i=t||r;return e.useEffect(()=>{null==r&&o(`${n}-${Zd+=1}`)},[r,n]),i}(t,n)}function Yd(e){return Gd(e,"base-ui")}var Kd=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,style:o,id:i,...s}=e,a=Nd(),c=Yd(i);return a.useSyncedValueWithCleanup("descriptionElementId",c),Xl("p",e,{ref:t,props:[{id:c},s]})});function Jd(t){e.useEffect(t,Kl)}var Xd=class e{static create(){return new e}currentId=0;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=0,t()},e)}isStarted(){return 0!==this.currentId}clear=()=>{0!==this.currentId&&(clearTimeout(this.currentId),this.currentId=0)};disposeEffect=()=>this.clear};function Qd(){const e=ml(Xd.create).current;return Jd(e.disposeEffect),e}var{userAgent:eu,platform:tu,maxTouchPoints:nu}="undefined"==typeof navigator?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0},ru=eu.toLowerCase(),ou=tu.toLowerCase(),iu=/^i(os$|p)/.test(ou)||"macintel"===ou&&nu>1,su="android",au=ou===su||ru.includes(su),cu=!iu&&ou.startsWith("mac"),lu=(ou.startsWith("win"),!au&&/^(linux|chrome os)/.test(ou),cu||iu),du="undefined"!=typeof CSS&&!!CSS.supports?.("-webkit-backdrop-filter:none"),uu=(!du&&ru.includes("firefox"),!du&&ru.includes("chrom"),lu),pu=/jsdom|happydom/.test(ru);var hu="data-base-ui-focusable";function fu(e){let t=e.activeElement;for(;null!=t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function mu(e,t){if(!e||!t)return!1;const n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&ll(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function gu(e){return"composedPath"in e?e.composedPath()[0]:e.target}function yu(e,t){if(null==t)return!1;if("composedPath"in e)return e.composedPath().includes(t);const n=e;return null!=n.target&&t.contains(n.target)}function bu(e){return cl(e)&&e.matches("input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])")}function wu(e){return!!e&&("combobox"===e.getAttribute("role")&&bu(e))}function vu(e){return e?e.hasAttribute("data-base-ui-focusable")?e:e.querySelector("[data-base-ui-focusable]")||e:null}function xu(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function ku(...e){return()=>{for(let t=0;t<e.length;t+=1){const n=e[t];n&&n()}}}function Su(e){const t=ml(_u,e).current;return t.next=e,xl(t.effect),t}function _u(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Iu=null;globalThis.requestAnimationFrame;var Cu=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;const t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let r=0;r<t.length;r+=1)t[r]?.(e)};request(e){const t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||(requestAnimationFrame(this.tick),this.isScheduled=!0),t}cancel(e){const t=e-this.startId;t<0||t>=this.callbacks.length||(this.callbacks[t]=null,this.callbacksCount-=1)}},Eu=class e{static create(){return new e}static request(e){return Cu.request(e)}static cancel(e){return Cu.cancel(e)}currentId=Iu;request(e){this.cancel(),this.currentId=Cu.request(()=>{this.currentId=Iu,e()})}cancel=()=>{this.currentId!==Iu&&(Cu.cancel(this.currentId),this.currentId=Iu)};disposeEffect=()=>this.cancel};function Tu(){const e=ml(Eu.create).current;return Jd(e.disposeEffect),e}var Mu={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},zu={...Mu,position:"fixed",top:0,left:0},Ou=/*#__PURE__*/e.forwardRef(function(t,n){const[r,o]=e.useState();xl(()=>{uu&&du&&o("button")},[]);/*#__PURE__*/
22
+ return m("span",{...t,ref:n,style:zu,"aria-hidden":!r||void 0,...{tabIndex:0,role:r},"data-base-ui-focus-guard":""})});function Ru(e,t=(e?ul(e):null)){return!(!(e&&e.isConnected&&t)||function(e){return"hidden"===e.visibility||"collapse"===e.visibility}(t))&&("function"==typeof e.checkVisibility?e.checkVisibility():"none"!==t.display&&"contents"!==t.display)}function Au(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.getRootNode();return ll(n)?n.host:null}function Nu(e){for(const t of Array.from(e.children))if("summary"===ol(t))return t;return null}function Pu(e,t){const n=Nu(t);return!!n&&(e===n||mu(n,e))}function Lu(e){const t=e?ol(e):"";return null!=e&&e.matches('a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]')&&("summary"!==t||null!=e.parentElement&&"details"===ol(e.parentElement)&&Nu(e.parentElement)===e)&&("details"!==t||null==Nu(e))&&("input"!==t||"hidden"!==e.type)}function $u(e){if(!Lu(e)||!e.isConnected||e.matches(":disabled"))return!1;for(let t=e;t;t=Au(t)){const n=t!==e,r="slot"===ol(t);if(t.hasAttribute("inert"))return!1;if(n&&"details"===ol(t)&&!t.open&&!Pu(e,t)||t.hasAttribute("hidden")||!r&&!Du(t,n))return!1}return!0}function Du(e,t){const n=ul(e);return t?"none"!==n.display:Ru(e,n)}function Fu(e){const t=e.tabIndex;if(t<0){const t=ol(e);if("details"===t||"audio"===t||"video"===t||cl(e)&&e.isContentEditable)return 0}return t}function ju(e){if("input"!==ol(e))return null;const t=e;return"radio"===t.type&&""!==t.name?t:null}function Uu(e){if(cl(e)&&"slot"===ol(e)){const t=e.assignedElements({flatten:!0});if(t.length>0)return t}return cl(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function Wu(e,t){Uu(e).forEach(e=>{Lu(e)&&t.push(e),Wu(e,t)})}function Bu(e,t,n){Uu(e).forEach(e=>{cl(e)&&e.matches(t)&&n.push(e),Bu(e,t,n)})}function Hu(e){return $u(e)&&Fu(e)>=0}function qu(e){const t=[];return Wu(e,t),t.filter($u)}function Zu(e){const t=qu(e);return t.filter(e=>Fu(e)>=0&&function(e,t){const n=ju(e);if(!n)return!0;const r=t.find(e=>{const t=ju(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{const t=ju(e);return t?.name===n.name&&t.form===n.form})===n}(e,t))}function Vu(e,t){const n=Zu(e),r=n.length;if(0===r)return;const o=fu(Fl(e)),i=n.indexOf(o);return n[-1===i?1===t?0:r-1:i+t]}function Gu(e){return Vu(Fl(e).body,1)||e}function Yu(e){return Vu(Fl(e).body,-1)||e}function Ku(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!mu(n,r)}function Ju(e){const t=[];Bu(e,"[data-tabindex]",t),t.forEach(e=>{const t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")})}function Xu(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...Xu(e,t.id,n)])}function Qu(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){const t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function ep(e){return`data-base-ui-${e}`}var tp=0;function np(e,t={}){const{preventScroll:n=!1,sync:r=!1,shouldFocus:o}=t;function i(){o&&!o()||e?.focus({preventScroll:n})}if(cancelAnimationFrame(tp),r)return i(),Yl;const s=requestAnimationFrame(i);return tp=s,()=>{tp===s&&(cancelAnimationFrame(s),tp=0)}}var rp={inert:/* @__PURE__ */new WeakMap,"aria-hidden":/* @__PURE__ */new WeakMap},op="data-base-ui-inert",ip={inert:/* @__PURE__ */new WeakSet,"aria-hidden":/* @__PURE__ */new WeakSet},sp=/* @__PURE__ */new WeakMap,ap=0;function cp(e){return e?ll(e)?e.host:cp(e.parentNode):null}var lp=(e,t)=>t.map(t=>{if(e.contains(t))return t;const n=cp(t);return e.contains(n)?n:null}).filter(e=>null!=e),dp=e=>{const t=/* @__PURE__ */new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},up=(e,t,n)=>{const r=[],o=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{"script"!==ol(e)&&(t.has(e)?o(e):r.push(e))})};return o(e),r};function pp(e,t,n,r,{mark:o=!0}){let i=null;r?i="inert":n&&(i="aria-hidden");let s=null,a=null;const c=lp(t,e),l=o?up(t,dp(c),new Set(c)):[],d=[],u=[];if(i){const e=rp[i],n=function(e){return ip[e]}(i);a=n,s=e;const r=lp(t,Array.from(t.querySelectorAll("[aria-live]"))),o=c.concat(r);up(t,dp(o),new Set(o)).forEach(t=>{const r=t.getAttribute(i),o=null!==r&&"false"!==r,s=(e.get(t)||0)+1;e.set(t,s),d.push(t),1===s&&o&&n.add(t),o||t.setAttribute(i,"inert"===i?"":"true")})}return o&&l.forEach(e=>{const t=(sp.get(e)||0)+1;sp.set(e,t),u.push(e),1===t&&e.setAttribute(op,"")}),ap+=1,()=>{s&&d.forEach(e=>{const t=(s.get(e)||0)-1;s.set(e,t),t||(!a?.has(e)&&i&&e.removeAttribute(i),a?.delete(e))}),o&&u.forEach(e=>{const t=(sp.get(e)||0)-1;sp.set(e,t),t||e.removeAttribute(op)}),(ap-=1)||(rp.inert=/* @__PURE__ */new WeakMap,rp["aria-hidden"]=/* @__PURE__ */new WeakMap,ip.inert=/* @__PURE__ */new WeakSet,ip["aria-hidden"]=/* @__PURE__ */new WeakSet,sp=/* @__PURE__ */new WeakMap)}}function hp(e,t={}){const{ariaHidden:n=!1,inert:r=!1,mark:o=!0}=t;return pp(e,Fl(e[0]).body,n,r,{mark:o})}var fp={clipPath:"inset(50%)",position:"fixed",top:0,left:0},mp=/*#__PURE__*/e.createContext(null),gp=()=>e.useContext(mp),yp=ep("portal");var bp=/*#__PURE__*/e.forwardRef(function(t,n){const{render:r,className:o,style:i,children:s,container:a,...c}=t,{node:l,nodeId:d,subtree:u}=function(t={}){const{ref:n,container:r,componentProps:o=Jl,elementProps:i}=t,s=Gd(),a=gp()?.portalNode,[c,l]=e.useState(null),[d,u]=e.useState(null),p=bl(e=>{null!==e&&u(e)}),h=e.useRef(null);xl(()=>{if(null===r)return void(h.current&&(h.current=null,u(null),l(null)));const e=(r&&(sl(r)?r:r.current))??a??document.body;null!=e?h.current!==e&&(h.current=e,u(null),l(e)):h.current&&(h.current=null,u(null),l(null))},[r,a]);const f=Xl("div",o,{ref:[n,p],props:[{id:s,[yp]:""},i]}),m=c&&f?/*#__PURE__*/y.createPortal(f,c):null;return{node:d,nodeId:/*#__PURE__*/e.isValidElement(f)?f.props.id:void 0,subtree:m}}({container:a,ref:n,componentProps:t,elementProps:c}),p=e.useRef(null),h=e.useRef(null),f=e.useRef(null),b=e.useRef(null),[w,v]=e.useState(null),x=e.useRef(!1),k=w?.modal,S=w?.open,_=!!w&&!w.modal&&w.open&&!!l;e.useEffect(()=>{if(l&&!k)return ku(xu(l,"focusin",e,!0),xu(l,"focusout",e,!0));function e(e){l&&e.relatedTarget&&Ku(e)&&("focusin"===e.type?x.current&&(Ju(l),x.current=!1):(!function(e){Zu(e).forEach(e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")})}(l),x.current=!0))}},[l,k]),xl(()=>{l&&!0===S&&x.current&&(Ju(l),x.current=!1)},[S,l]);const I=e.useMemo(()=>({beforeOutsideRef:p,afterOutsideRef:h,beforeInsideRef:f,afterInsideRef:b,portalNode:l,setFocusManagerState:v}),[l]);/*#__PURE__*/
23
+ return g(e.Fragment,{children:[u,/*#__PURE__*/g(mp.Provider,{value:I,children:[_&&l&&/*#__PURE__*/m(Ou,{"data-type":"outside",ref:p,onFocus:e=>{if(Ku(e,l))f.current?.focus();else{const e=w?w.domReference:null;Yu(e)?.focus()}}}),_&&l&&/*#__PURE__*/m("span",{"aria-owns":d,style:fp}),l&&/*#__PURE__*/y.createPortal(s,l),_&&l&&/*#__PURE__*/m(Ou,{"data-type":"outside",ref:h,onFocus:e=>{if(Ku(e,l))b.current?.focus();else{const t=w?w.domReference:null;Gu(t)?.focus(),w?.closeOnFocusOut&&w?.onOpenChange(!1,qd("focus-out",e.nativeEvent))}}})]})]})});function wp(){const e=/* @__PURE__ */new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,/* @__PURE__ */new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var vp=/*#__PURE__*/e.createContext(null),xp=/*#__PURE__*/e.createContext(null),kp=t=>{const n=e.useContext(xp);return t??n};function Sp(e){return null==e?e:"current"in e?e.current:e}var _p=[];function Ip(){_p=_p.filter(e=>e.deref()?.isConnected)}function Cp(e){Ip(),e&&"body"!==ol(e)&&(_p.push(new WeakRef(e)),_p.length>20&&(_p=_p.slice(-20)))}function Ep(){return Ip(),_p[_p.length-1]?.deref()}function Tp(e){if(e.hasAttribute("tabindex")&&!e.hasAttribute("data-tabindex"))return;if(!e.getAttribute("role")?.includes("dialog"))return;const t=qu(e).filter(e=>{const t=e.getAttribute("data-tabindex")||"";return Hu(e)||e.hasAttribute("data-tabindex")&&!t.startsWith("-")}),n=e.getAttribute("tabindex");0===t.length?"0"!==n&&(e.setAttribute("tabindex","0"),e.setAttribute("data-tabindex","0")):("-1"!==n||e.hasAttribute("data-tabindex")&&"-1"!==e.getAttribute("data-tabindex"))&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}function Mp(t){const{context:n,children:r,disabled:o=!1,initialFocus:i=!0,returnFocus:s=!0,restoreFocus:a=!1,modal:c=!0,closeOnFocusOut:l=!0,openInteractionType:d="",nextFocusableElement:u,previousFocusableElement:p,beforeContentFocusGuardRef:h,externalTree:f,getInsideElements:y}=t,b="rootStore"in n?n.rootStore:n,w=b.useState("open"),v=b.useState("domReferenceElement"),x=b.useState("floatingElement"),{events:k,dataRef:S}=b.context,_=bl(()=>S.current.floatingContext?.nodeId),I=!1===i,C=wu(v)&&I,E=Su(i),T=Su(s),M=Su(d),z=Su(w),O=kp(f),R=gp(),A=e.useRef(!1),N=e.useRef(!1),P=e.useRef(!1),L=e.useRef(null),$=e.useRef(""),D=e.useRef(""),F=e.useRef(null),j=e.useRef(null),U=Bl(F,h,R?.beforeInsideRef),W=Bl(j,R?.afterInsideRef),B=Qd(),H=Qd(),q=Tu(),Z=null!=R,V=vu(x),G=bl((e=V)=>e?Zu(e):[]),Y=bl(()=>y?.().filter(e=>null!=e)??[]);e.useEffect(()=>{if(o||!c)return;return xu(Fl(V),"keydown",function(e){"Tab"===e.key&&mu(V,fu(Fl(V)))&&0===G().length&&!C&&function(e){e.preventDefault(),e.stopPropagation()}(e)})},[o,V,c,C,G]),e.useEffect(()=>{if(o||!w)return;const e=Fl(V);function t(){P.current=!1}return ku(xu(e,"pointerdown",function(e){const t=gu(e),n=Y(),r=mu(x,t)||mu(v,t)||mu(R?.portalNode,t)||n.some(e=>e===t||mu(e,t));P.current=!r,D.current=e.pointerType||"keyboard",t?.closest("[data-base-ui-click-trigger]")&&(N.current=!0,H.start(0,()=>{N.current=!1}))},!0),xu(e,"pointerup",t,!0),xu(e,"pointercancel",t,!0),xu(e,"keydown",function(){D.current="keyboard"},!0),t)},[o,x,v,V,w,R,H,Y]),e.useEffect(()=>{if(o||!l)return;const e=Fl(V);function t(t){const n=t.relatedTarget,r=t.currentTarget,o=gu(t);c&&null==n&&null!=o&&mu(x,o)&&Cp(o),queueMicrotask(()=>{const i=_(),s=b.context.triggerElements,l=Y(),d=n?.hasAttribute(ep("focus-guard"))&&[F.current,j.current,R?.beforeInsideRef.current,R?.afterInsideRef.current,R?.beforeOutsideRef.current,R?.afterOutsideRef.current,Sp(p),Sp(u)].includes(n),h=!(mu(v,n)||mu(x,n)||mu(n,x)||mu(R?.portalNode,n)||l.some(e=>e===n||mu(e,n))||s.hasMatchingElement(e=>mu(e,n))||d||O&&(Xu(O.nodesRef.current,i).find(e=>mu(e.context?.elements.floating,n)||mu(e.context?.elements.domReference,n))||Qu(O.nodesRef.current,i).find(e=>[e.context?.elements.floating,vu(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===v&&V&&Tp(V),a&&r!==v&&!Ru(o)&&fu(e)===e.body){if(cl(V)&&(V.focus(),"popup"===a))return void q.request(()=>{V.focus()});const e=G(),t=L.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||V;cl(n)&&n.focus()}S.current.insideReactTree?S.current.insideReactTree=!1:!C&&c||!n||!h||N.current||!C&&n===Ep()||(A.current=!0,b.setOpen(!1,qd("focus-out",t)))})}const n=cl(v)?v:null;return x||n?ku(n&&xu(n,"focusout",t),n&&xu(n,"pointerdown",function(){N.current=!0,H.start(0,()=>{N.current=!1})}),x&&xu(x,"focusin",function(e){const t=gu(e);Hu(t)&&(L.current=t)}),x&&xu(x,"focusout",t),x&&R&&xu(x,"focusout",function(){P.current||(S.current.insideReactTree=!0,B.start(0,()=>{S.current.insideReactTree=!1}))},!0)):void 0},[o,v,x,V,c,O,R,b,l,a,G,C,_,S,B,H,q,u,p,Y]),e.useEffect(()=>{if(o||!x||!w)return;const e=Array.from(R?.portalNode?.querySelectorAll(`[${ep("portal")}]`)||[]),t=(O?Qu(O.nodesRef.current,_()):[]).find(e=>wu(e.context?.elements.domReference||null))?.context?.elements.domReference,n=hp([x,...e,F.current,j.current,R?.beforeOutsideRef.current,R?.afterOutsideRef.current,...Y(),t,Sp(p),Sp(u),C?v:null].filter(e=>null!=e),{ariaHidden:c||C,mark:!1}),r=hp([x,...e].filter(e=>null!=e));return()=>{r(),n()}},[w,o,v,x,c,R,C,O,_,u,p,Y]),xl(()=>{if(!w||o||!cl(V))return;$.current="",D.current="";const e=Fl(V),t=fu(e);queueMicrotask(()=>{const n=E.current,r="function"==typeof n?n(M.current||""):n;if(void 0===r||!1===r)return;if(mu(V,t))return;let o=null;const i=()=>(null==o&&(o=G(V)),o[0]||V);let s;s=!0===r||null===r?i():Sp(r),s=s||i();const a=mu(V,fu(e));np(s,{preventScroll:s===V,shouldFocus(){if(!z.current)return!1;if(a)return!0;const t=fu(e);return!(t!==s&&mu(V,t))}})})},[o,w,V,G,E,M,z]),xl(()=>{if(o||!V)return;const e=Fl(V),t=fu(e),n=null==M.current;function r(e){var t;if(e.open||($.current=function(e,t){const n=il(gu(e));return e instanceof n.KeyboardEvent?"keyboard":e instanceof n.FocusEvent?t||"keyboard":"pointerType"in e?e.pointerType||"keyboard":"touches"in e?"touch":e instanceof n.MouseEvent?t||(0===e.detail?"keyboard":"mouse"):""}(e.nativeEvent,D.current)),"trigger-hover"===e.reason&&"mouseleave"===e.nativeEvent.type&&(A.current=!0),"outside-press"===e.reason)if(e.nested)A.current=!1;else if(""===(t=e.nativeEvent).pointerType&&t.isTrusted||(au&&t.pointerType?"click"===t.type&&1===t.buttons:0===t.detail&&!t.pointerType)||function(e){return!pu&&(!au&&0===e.width&&0===e.height||au&&1===e.width&&1===e.height&&0===e.pressure&&0===e.detail&&"mouse"===e.pointerType||e.width<1&&e.height<1&&0===e.pressure&&0===e.detail&&"touch"===e.pointerType)}(e.nativeEvent))A.current=!1;else{let e=!1;Fl(V).createElement("div").focus({get preventScroll(){return e=!0,!1}}),A.current=!e}}return Cp(t),k.on("openchange",r),()=>{k.off("openchange",r);const o=fu(e),i=Y(),s=mu(x,o)||i.some(e=>e===o||mu(e,o))||O&&Xu(O.nodesRef.current,_(),!1).some(e=>mu(e.context?.elements.floating,o)),a=T.current,c=$.current,l=function(e){const r=T.current;let o="function"==typeof r?r(e):r;if(void 0===o||!1===o)return null;null===o&&(o=!0);const i=v?.isConnected?v:null,s=t?.isConnected&&"body"!==ol(t)?t:null;let a=n?s||i:i||s;return a||(a=Ep()||null),"boolean"==typeof o?a:Sp(o)||a||null}(c);queueMicrotask(()=>{const t=(n=l)?Hu(n)?n:Zu(n)[0]||n:null;var n;const r="boolean"!=typeof a;if(a&&!A.current&&cl(t)&&(r||t===o||o===e.body||s)){const e={preventScroll:!0};"keyboard"===c&&(e.focusVisible=!0),t.focus(e)}A.current=!1})}},[o,x,V,T,M,k,O,v,_,Y]),xl(()=>{if(!du||w||!x)return;const e=fu(Fl(x));cl(e)&&bu(e)&&mu(x,e)&&e.blur()},[w,x]),xl(()=>{if(!o&&R)return R.setFocusManagerState({modal:c,closeOnFocusOut:l,open:w,onOpenChange:b.setOpen,domReference:v}),()=>{R.setFocusManagerState(null)}},[o,R,c,w,b,l,v]),xl(()=>{if(!o&&V)return Tp(V),()=>{queueMicrotask(Ip)}},[o,V]);const K=!o&&(!c||!C)&&(Z||c);/*#__PURE__*/
24
+ return g(e.Fragment,{children:[K&&/*#__PURE__*/m(Ou,{"data-type":"inside",ref:U,onFocus:e=>{if(c){const e=G();np(e[e.length-1])}else R?.portalNode&&(A.current=!1,Ku(e,R.portalNode)?Gu(v)?.focus():Sp(p??R.beforeOutsideRef)?.focus())}}),r,K&&/*#__PURE__*/m(Ou,{"data-type":"inside",ref:W,onFocus:e=>{c?np(G()[0]):R?.portalNode&&(l&&(A.current=!0),Ku(e,R.portalNode)?Yu(v)?.focus():Sp(u??R.afterOutsideRef)?.focus())}})]})}function zp(){return!1}function Op(t,n={}){const{enabled:r=!0,escapeKey:o=!0,outsidePress:i=!0,outsidePressEvent:s="sloppy",referencePress:a=zp,bubbles:c,externalTree:l}=n,d="rootStore"in t?t.rootStore:t,u=d.useState("open"),p=d.useState("floatingElement"),{dataRef:h}=d.context,f=kp(l),m=bl("function"==typeof i?i:()=>!1),g="function"==typeof i?m:i,y=!1!==g,b=bl(()=>s),{escapeKey:w,outsidePress:v}={escapeKey:"boolean"==typeof(x=c)?x:x?.escapeKey??!1,outsidePress:"boolean"==typeof x?x:x?.outsidePress??!0};var x;const k=e.useRef(!1),S=e.useRef(!1),_=e.useRef(!1),I=e.useRef(!1),C=e.useRef(""),E=e.useRef(null),T=Qd(),M=Qd(),z=bl(()=>{M.clear(),h.current.insideReactTree=!1}),O=bl(e=>{const t=h.current.floatingContext?.nodeId;return(f?Xu(f.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),R=bl(e=>yu(e,d.select("floatingElement"))||yu(e,d.select("domReferenceElement"))),A=bl(e=>{a()&&d.setOpen(!1,qd("trigger-press",e.nativeEvent))}),N=bl(e=>{if(!u||!r||!o||"Escape"!==e.key)return;if(I.current)return;if(!w&&O("__escapeKeyBubbles"))return;const t=qd("escape-key",function(e){return"nativeEvent"in e}(e)?e.nativeEvent:e);d.setOpen(!1,t),t.isCanceled||e.preventDefault(),w||t.isPropagationAllowed||e.stopPropagation()}),P=bl(()=>{h.current.insideReactTree=!0,M.start(0,z)}),L=bl(e=>{if(!u||!r||0!==e.button)return;const t=gu(e.nativeEvent);mu(d.select("floatingElement"),t)&&(k.current||(k.current=!0,S.current=!1))}),$=bl(e=>{u&&r&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&k.current&&(S.current=!0)});e.useEffect(()=>{if(!u||!r)return z;h.current.__escapeKeyBubbles=w,h.current.__outsidePressBubbles=v;const e=new Xd,t=new Xd;function n(){_.current=!0,t.start(0,()=>{_.current=!1})}function i(){k.current=!1,S.current=!1}function s(){const e=C.current,t="pen"!==e&&e?e:"mouse",n=b(),r="function"==typeof n?n():n;return"string"==typeof r?r:r[t]}function a(e){const t=h.current.floatingContext?.nodeId,n=f&&Xu(f.nodesRef.current,t).some(t=>yu(e,t.context?.elements.floating));return R(e)||n}function c(e){if(function(e){const t=s();return"intentional"===t&&"click"!==e.type||"sloppy"===t&&"click"===e.type}(e))return"click"===e.type||R(e)||(t.clear(),_.current=!1),void z();if(h.current.insideReactTree)return void z();const n=gu(e),r=`[${ep("inert")}]`,o=al(n)?n.getRootNode():null,i=Array.from((ll(o)?o:Fl(d.select("floatingElement"))).querySelectorAll(r)),c=d.context.triggerElements;if(n&&(c.hasElement(n)||c.hasMatchingElement(e=>mu(e,n))))return;let l=al(n)?n:null;for(;l&&!dl(l);){const e=pl(l);if(dl(e)||!al(e))break;l=e}if(!i.length||!al(n)||n.matches("html,body")||mu(n,d.select("floatingElement"))||!i.every(e=>!mu(l,e))){if(cl(n)&&!("touches"in e)){const t=dl(n),r=ul(n),o=/auto|scroll/,i=t||o.test(r.overflowX),s=t||o.test(r.overflowY),a=i&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=s&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l="rtl"===r.direction,d=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),u=a&&e.offsetY>n.clientHeight;if(d||u)return}if(!a(e))return"intentional"===s()&&_.current?(t.clear(),void(_.current=!1)):void(("function"!=typeof g||g(e))&&(O("__outsidePressBubbles")||(d.setOpen(!1,qd("outside-press",e)),z())))}}function l(e){if("sloppy"!==s()||!d.select("open")||!r||R(e))return;const t=e.touches[0];t&&(E.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},T.start(1e3,()=>{E.current&&(E.current.dismissOnTouchEnd=!1,E.current.dismissOnMouseDown=!1)}))}function m(e,t){const n=gu(e);if(!n)return;const r=xu(n,e.type,()=>{t(e),r()})}function x(e){T.clear(),"pointerdown"===e.type&&(C.current=e.pointerType),"mousedown"===e.type&&E.current&&!E.current.dismissOnMouseDown||m(e,e=>{"pointerdown"===e.type?function(e){"sloppy"===s()&&"touch"!==e.pointerType&&d.select("open")&&r&&!R(e)&&c(e)}(e):c(e)})}function M(e){if(!k.current)return;const r=S.current;i(),"intentional"===s()&&("pointercancel"!==e.type?a(e)||(r?n():("function"!=typeof g||g(e))&&(t.clear(),_.current=!0,z())):r&&n())}function A(e){if("sloppy"!==s()||!E.current||R(e))return;const t=e.touches[0];if(!t)return;const n=Math.abs(t.clientX-E.current.startX),r=Math.abs(t.clientY-E.current.startY),o=Math.sqrt(n*n+r*r);o>5&&(E.current.dismissOnTouchEnd=!0),o>10&&(c(e),T.clear(),E.current=null)}function P(e){"sloppy"===s()&&E.current&&!R(e)&&(E.current.dismissOnTouchEnd&&c(e),T.clear(),E.current=null)}const L=Fl(p),$=ku(o&&ku(xu(L,"keydown",N),xu(L,"compositionstart",function(){e.clear(),I.current=!0}),xu(L,"compositionend",function(){e.start(du?5:0,()=>{I.current=!1})})),y&&ku(xu(L,"click",x,!0),xu(L,"pointerdown",x,!0),xu(L,"pointerup",M,!0),xu(L,"pointercancel",M,!0),xu(L,"mousedown",x,!0),xu(L,"mouseup",M,!0),xu(L,"touchstart",function(e){C.current="touch",m(e,l)},!0),xu(L,"touchmove",function(e){m(e,A)},!0),xu(L,"touchend",function(e){m(e,P)},!0)));return()=>{$(),e.clear(),t.clear(),i(),_.current=!1,z()}},[h,p,o,y,g,u,r,w,v,N,z,b,O,R,f,d,T]);const D=e.useMemo(()=>({onKeyDown:N,onPointerDown:A,onClick:A}),[N,A]),F=e.useMemo(()=>({onKeyDown:N,onPointerDown:$,onMouseDown:$,onClickCapture:P,onMouseDownCapture(e){P(),L(e)},onPointerDownCapture(e){P(),L(e)},onMouseUpCapture:P,onTouchEndCapture:P,onTouchMoveCapture:P}),[N,P,L,$]);return e.useMemo(()=>r?{reference:D,floating:F,trigger:D}:{},[r,D,F])}var Rp=[];var Ap,Np=Vl(19)?function(t,n,r,o,i){const s=void 0;if(!s)return function(t,n,r,o,i){const s=e.useCallback(()=>n(t.getSnapshot(),r,o,i),[t,n,r,o,i]);return p(t.subscribe,s,s)}(t,n,r,o,i);const a=s.syncIndex;let c;s.syncIndex+=1,s.didInitialize?(c=s.syncHooks[a],c.store===t&&c.selector===n&&Object.is(c.a1,r)&&Object.is(c.a2,o)&&Object.is(c.a3,i)||(c.store!==t&&(s.didChangeStore=!0),c.store=t,c.selector=n,c.a1=r,c.a2=o,c.a3=i,c.value=n(t.getSnapshot(),r,o,i))):(c={store:t,selector:n,a1:r,a2:o,a3:i,value:n(t.getSnapshot(),r,o,i)},s.syncHooks.push(c));return c.value}:function(e,t,n,r,o){return function(){throw new Error("React 19 uses its native useSyncExternalStore")}(e.subscribe,e.getSnapshot,e.getSnapshot)};function Pp(e,t,n,r,o){return Np(e,t,n,r,o)}Ap={before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){const r=e.syncHooks[n],o=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,o)||(t=!0,r.value=o)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{const n=/* @__PURE__ */new Set;for(const o of e.syncHooks)n.add(o.store);const r=[];for(const e of n)r.push(e.subscribe(t));return()=>{for(const e of r)e()}}),p(e.subscribe,e.getSnapshot,e.getSnapshot))}},Rp.push(Ap);var Lp=class{constructor(e){this.state=e,this.listeners=/* @__PURE__ */new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;const t=this.updateTick;for(const n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(const t in e)if(!Object.is(this.state[t],e[t]))return void this.setState({...this.state,...e})}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){const e={...this.state};this.setState(e)}use(e,t,n,r){return Pp(this,e,t,n,r)}},$p=class extends Lp{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(t,n){e.useDebugValue(t);const r=this;xl(()=>{r.state[t]!==n&&r.set(t,n)},[r,t,n])}useSyncedValueWithCleanup(e,t){const n=this;xl(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){const t=this,n=Object.values(e);xl(()=>{t.update(e)},[t,...n])}useControlledProp(t,n){e.useDebugValue(t);const r=this,o=void 0!==n;xl(()=>{o&&!Object.is(r.state[t],n)&&r.setState({...r.state,[t]:n})},[r,t,n,o])}select(e,t,n,r){return(0,this.selectors[e])(this.state,t,n,r)}useState(t,n,r,o){return e.useDebugValue(t),Pp(this,this.selectors[t],n,r,o)}useContextCallback(t,n){e.useDebugValue(t);const r=bl(n??Yl);this.context[t]=r}useStateSetter(t){const n=e.useRef(void 0);return void 0===n.current&&(n.current=e=>{this.set(t,e)}),n.current}observe(e,t){let n;n="function"==typeof e?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{const o=n(e);if(!Object.is(r,o)){const e=r;r=o,t(o,e,this)}})}},Dp={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},Fp=class extends $p{constructor(e){const{syncOnly:t,nested:n,onOpenChange:r,triggerElements:o,...i}=e;super({...i,positionReference:i.referenceElement,domReferenceElement:i.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:wp(),nested:n,triggerElements:o},Dp),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||null!=t&&function(e){const t=e.type;return"click"===t||"mousedown"===t||"keydown"===t||"keyup"===t}(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);const n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit("openchange",n)};setOpen=(e,t)=>{this.syncOnly||this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function jp(t){const{enabled:n=!0,open:r,ref:o,onComplete:i}=t,s=bl(i),a=function(e,t=!1){const n=Tu();return bl((r,o=null)=>{n.cancel();const i=Sp(e);if(null==i)return;const s=i,a=()=>{y.flushSync(r)};if("function"!=typeof s.getAnimations||globalThis.BASE_UI_ANIMATIONS_DISABLED)r();else{if(t){const e="data-starting-style";if(!s.hasAttribute(e))return void n.request(c);const t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),c())});return t.observe(s,{attributes:!0,attributeFilter:[e]}),void o?.addEventListener("abort",()=>t.disconnect(),{once:!0})}n.request(c)}function c(){Promise.all(s.getAnimations().map(e=>e.finished)).then(()=>{o?.aborted||a()},()=>{o?.aborted||(s.getAnimations().some(e=>e.pending||"finished"!==e.playState)?c():a())})}})}(o,r);e.useEffect(()=>{if(!n)return;const e=new AbortController;return a(s,e.signal),()=>{e.abort()}},[n,r,s,a])}var Up={tabIndex:-1,[hu]:""};function Wp(t,n=!1){const r=Gd(),o=null!=(e.useContext(vp)?.id||null),i=ml(()=>t(r,o)).current;return function(t){const{popupStore:n,treatPopupAsFloatingElement:r=!1,floatingRootContext:o,floatingId:i,nested:s,onOpenChange:a}=t,c=n.useState("open"),l=n.useState("activeTriggerElement"),d=n.useState(r?"popupElement":"positionerElement"),u=n.context.triggerElements,p=a,h=e.useRef(null);void 0===o&&null===h.current&&(h.current=new Fp({open:c,transitionStatus:void 0,referenceElement:l,floatingElement:d,triggerElements:u,onOpenChange:p,floatingId:i,syncOnly:!0,nested:s}));const f=o??h.current;n.useSyncedValue("floatingId",i),xl(()=>{const e={open:c,floatingId:i,referenceElement:l,floatingElement:d};al(l)&&(e.domReferenceElement=l),f.state.positionReference===f.state.referenceElement&&(e.positionReference=l),f.update(e)},[c,i,l,d,f]),f.context.onOpenChange=p,f.context.nested=s}({popupStore:i,treatPopupAsFloatingElement:n,floatingRootContext:i.state.floatingRootContext,floatingId:r,nested:o,onOpenChange:i.setOpen}),i}function Bp({handle:e,store:t}){return xl(()=>e.attachStore(t),[e,t]),null}function Hp(t,n,r){const{mounted:o,setMounted:i,transitionStatus:s}=function(t,n=!1,r=!1){const[o,i]=e.useState(t&&n?"idle":void 0),[s,a]=e.useState(t);return t&&!s&&(a(!0),i("starting")),t||!s||"ending"===o||r||i("ending"),t||s||"ending"!==o||i(void 0),xl(()=>{if(!t&&s&&"ending"!==o&&r){const e=Eu.request(()=>{i("ending")});return()=>{Eu.cancel(e)}}},[t,s,o,r]),xl(()=>{if(!t||n)return;const e=Eu.request(()=>{i(void 0)});return()=>{Eu.cancel(e)}},[n,t]),xl(()=>{if(!t||!n)return;t&&s&&"idle"!==o&&i("starting");const e=Eu.request(()=>{i("idle")});return()=>{Eu.cancel(e)}},[n,t,s,o]),{mounted:s,setMounted:a,transitionStatus:o}}(t),a=n.useState("preventUnmountingOnClose"),c=!t&&a;n.useSyncedValues({mounted:o,transitionStatus:s,preventUnmountingOnClose:c});const l=bl(()=>{i(!1),n.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),r?.(),n.context.onOpenChangeComplete?.(!1)});return jp({enabled:o&&!t&&!c,open:t,ref:n.context.popupRef,onComplete(){t||l()}}),{forceUnmount:l,transitionStatus:s}}var qp=class{constructor(){this.idMap=/* @__PURE__ */new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(const t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(const t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function Zp(){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new Fp({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:new qp,floatingId:void 0,syncOnly:!1,nested:!1,onOpenChange:void 0}),floatingId:void 0,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:Jl,inactiveTriggerProps:Jl,popupProps:Jl}}var Vp=e=>e.triggerIdProp??e.activeTriggerId,Gp=e=>e.openProp??e.open,Yp=e=>(e.popupElement?.id??e.floatingId)||void 0;function Kp(e,t){return void 0!==t&&Gp(e)&&Vp(e)===t}var Jp={open:Gp,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Vp,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Yp,isTriggerActive:(e,t)=>void 0!==t&&Vp(e)===t,isOpenedByTrigger:(e,t)=>Kp(e,t),isMountedByTrigger:(e,t)=>void 0!==t&&Vp(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>function(e,t){return!!Kp(e,t)||void 0!==t&&Gp(e)&&null==Vp(e)&&1===e.triggerCount}(e,t)?Yp(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement},Xp=/*#__PURE__*/e.createContext(void 0);var Qp=/* @__PURE__ */new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End"]),eh={...Wd,...Dd,nestedDialogOpen:e=>e?{"data-nested-dialog-open":""}:null},th=/*#__PURE__*/e.forwardRef(function(t,n){const{render:r,className:o,style:i,finalFocus:s,initialFocus:a,...c}=t,l=Nd(),d=l.useState("descriptionElementId"),u=l.useState("disablePointerDismissal"),p=l.useState("floatingRootContext"),h=l.useState("popupProps"),f=l.useState("modal"),g=l.useState("mounted"),y=l.useState("nested"),b=l.useState("nestedOpenDialogCount"),w=l.useState("open"),v=l.useState("openMethod"),x=l.useState("titleElementId"),k=l.useState("transitionStatus"),S=l.useState("role"),_=p.useState("floatingId");!function(){const t=e.useContext(Xp);if(void 0===t)throw new Error($l(26))}(),jp({open:w,ref:l.context.popupRef,onComplete(){w&&l.context.onOpenChangeComplete?.(!0)}});const I=void 0===a?(C=l.context.popupRef,e=>"touch"!==e||C.current):a;var C;const E=b>0,T=l.useStateSetter("popupElement"),M=Xl("div",t,{state:{open:w,nested:y,transitionStatus:k,nestedDialogOpen:E},props:[h,{id:_,"aria-labelledby":x,"aria-describedby":d,role:S,...Up,hidden:!g,onKeyDown(e){Qp.has(e.key)&&e.stopPropagation()},style:{"--nested-dialogs":b}},c],ref:[n,l.context.popupRef,T],stateAttributesMapping:eh});/*#__PURE__*/
25
25
  return m(Mp,{context:p,openInteractionType:v,disabled:!g,closeOnFocusOut:!u,initialFocus:I,returnFocus:s,modal:!1!==f,restoreFocus:"popup",children:M})});function nh(e){return Vl(19)?e:e?"true":void 0}var rh=/*#__PURE__*/e.forwardRef(function(e,t){const{cutout:n,...r}=e;let o;if(n){const e=n.getBoundingClientRect();o=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}/*#__PURE__*/
26
- return m("div",{ref:t,role:"presentation","data-base-ui-inert":"",...r,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:o}})}),oh=/*#__PURE__*/e.forwardRef(function(e,t){const{keepMounted:n=!1,...r}=e,o=Nd(),i=o.useState("mounted"),s=o.useState("modal"),a=o.useState("open");return i||n?/*#__PURE__*/m(Xp.Provider,{value:n,children:/*#__PURE__*/g(bp,{ref:t,...r,children:[i&&!0===s&&/*#__PURE__*/m(rh,{ref:o.context.internalBackdropRef,inert:nh(!a)}),e.children]})}):null}),ih={},sh={},ah="";function ch(e,t){return function(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ul(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&"inline"!==o&&"contents"!==o}(e)?e:t}function lh(e,t,n){return/hidden|clip/.test(e.getComputedStyle(ch(t,n)).overflowY)}function dh(e){const t=Fl(e),n=t.documentElement,r=t.body,o=il(n);let i=0,s=0,a=!1;const c=Eu.create();if(du&&1!==(o.visualViewport?.scale??1))return()=>{};function l(){const t=o.getComputedStyle(n),c=o.getComputedStyle(r),l=(t.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";i=n.scrollTop,s=n.scrollLeft,ih={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},ah=n.style.scrollBehavior,sh={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const d=n.scrollHeight>n.clientHeight,u=n.scrollWidth>n.clientWidth,p="scroll"===t.overflowY||"scroll"===c.overflowY,h="scroll"===t.overflowX||"scroll"===c.overflowX,f=Math.max(0,o.innerWidth-r.clientWidth),m=Math.max(0,o.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),y=parseFloat(c.marginLeft)+parseFloat(c.marginRight),b=ch(n,r);if(a=function(e){if("undefined"==typeof CSS||!CSS.supports||!CSS.supports("scrollbar-gutter","stable")||"undefined"==typeof document)return!1;const t=Fl(e),n=t.documentElement,r=ch(n,t.body),o=r.style.overflowY,i=n.style.scrollbarGutter;n.style.scrollbarGutter="stable",r.style.overflowY="scroll";const s=r.offsetWidth;r.style.overflowY="hidden";const a=r.offsetWidth;return r.style.overflowY=o,n.style.scrollbarGutter=i,s===a}(e),a)return n.style.scrollbarGutter=l,b.style.overflowY="hidden",void(b.style.overflowX="hidden");Object.assign(n.style,{scrollbarGutter:l,overflowY:"hidden",overflowX:"hidden"}),(d||p)&&(n.style.overflowY="scroll"),(u||h)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:g||m?`calc(100dvh - ${g+m}px)`:"100dvh",width:y||f?`calc(100vw - ${y+f}px)`:"100vw",boxSizing:"border-box",overflowY:"hidden",overflowX:"hidden",scrollBehavior:"unset"}),r.scrollTop=i,r.scrollLeft=s,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function d(){Object.assign(n.style,ih),Object.assign(r.style,sh),a||(n.scrollTop=i,n.scrollLeft=s,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=ah)}l();const u=xu(o,"resize",function(){d(),c.request(l)});return()=>{c.cancel(),d(),"function"==typeof o.removeEventListener&&u()}}var uh=new class{lockCount=0;restore=null;timeoutLock=Xd.create();timeoutUnlock=Xd.create();acquire(e){return this.lockCount+=1,1===this.lockCount&&null===this.restore&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{this.lockCount-=1,0===this.lockCount&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{0===this.lockCount&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(0===this.lockCount||null!==this.restore)return;const t=Fl(e),n=t.documentElement,r=t.body,o=il(n);if(lh(o,n,r)){const t=new o.MutationObserver(()=>{lh(o,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),i={attributes:!0};return t.observe(n,i),t.observe(r,i),void(this.restore=()=>t.disconnect())}const i=iu||!function(e){if("undefined"==typeof document)return!1;const t=Fl(e);return il(t).innerWidth-t.documentElement.clientWidth>0}(e);this.restore=i?function(e){const t=Fl(e),n=ch(t.documentElement,t.body),r={overflowY:n.style.overflowY,overflowX:n.style.overflowX};return Object.assign(n.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(n.style,r)}}(e):dh(e)}};function ph({store:t,parentContext:n,isDrawer:r}){const o=t.useState("open"),i=t.useState("disablePointerDismissal"),s=t.useState("modal"),a=t.useState("popupElement"),c=t.useState("floatingRootContext"),[l,d]=e.useState(0),[u,p]=e.useState(0),h=0===l,f=Op(c,{outsidePressEvent:()=>t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:"trap-focus"===s?"sloppy":"intentional",touch:"sloppy"},outsidePress(e){if(!t.context.outsidePressEnabledRef.current)return!1;if("button"in e&&0!==e.button)return!1;if("touches"in e)if("touchend"===e.type){if(1!==e.changedTouches.length||0!==e.touches.length)return!1}else if(1!==e.touches.length)return!1;const n=gu(e);if(h&&!i){if(s){const e=t.context.internalBackdropRef.current,r=t.context.backdropRef.current;return!e&&!r||(e===n||r===n||mu(n,a)&&!n?.hasAttribute("data-base-ui-portal"))}return!0}return!1},escapeKey:h});return function(e=!0,t=null){xl(()=>{if(e)return uh.acquire(t)},[e,t])}(o&&!0===s,a),t.useContextCallback("onNestedDialogOpen",(e,t)=>{d(e),p(t)}),xl(()=>(n?.onNestedDialogOpen&&(o?n.onNestedDialogOpen(l+1,u+(r?1:0)):n.onNestedDialogOpen(0,0)),()=>{n?.onNestedDialogOpen&&o&&n.onNestedDialogOpen(0,0)}),[r,o,l,u,n]),function(e,t){e.useSyncedValues(t),xl(()=>()=>{e.update({activeTriggerProps:Jl,inactiveTriggerProps:Jl,popupProps:Jl})},[e])}(t,{activeTriggerProps:f.reference,inactiveTriggerProps:f.trigger,popupProps:f.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:u}),null}var hh={...Jp,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},fh=class extends $p{constructor(t,n,r){const o=new qp,i=function(e,t,n,r=!1){const o={...Zp(),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e};return o.floatingRootContext=function(e,t,n=!1){return new Fp({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0})}(t,n,r),o}(t,o,n,r);super(i,function(t){return{popupRef:/*#__PURE__*/e.createRef(),backdropRef:/*#__PURE__*/e.createRef(),internalBackdropRef:/*#__PURE__*/e.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:t,onOpenChange:void 0,onOpenChangeComplete:void 0}}(o),hh)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},e||null!=t.trigger||null==this.state.activeTriggerId||(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);const n={open:e};!function(e,t,n,r=!1){t?e.preventUnmountingOnClose=!1:r&&(e.preventUnmountingOnClose=!0);const o=n?.id??null;(o||t)&&(e.activeTriggerId=o,e.activeTriggerElement=n??null)}(n,e,t.trigger),this.update(n)}};function mh(t,n){const{children:r,open:o,defaultOpen:i=!1,onOpenChange:s,onOpenChangeComplete:a,disablePointerDismissal:c=!1,modal:l=!0,actionsRef:d,handle:u,triggerId:p,defaultTriggerId:h=null}=n,f="drawer"===t,y="alert-dialog"===t,b=!!y||l,w=y||c,v=y?"alertdialog":"dialog",x=Nd(!0),k={modal:b,disablePointerDismissal:w,nested:null!=x,role:v},_=Wp((e,t)=>new fh({open:i,openProp:o,activeTriggerId:h,triggerIdProp:p,...k},e,t),!0);_.useControlledProp("openProp",o),_.useControlledProp("triggerIdProp",p),_.useSyncedValues(k),_.useContextCallback("onOpenChange",s),_.useContextCallback("onOpenChangeComplete",a);const S=_.useState("open"),I=_.useState("mounted"),C=_.useState("payload");!function(e,t){xl(()=>{t||null===e.state.openMethod||e.set("openMethod",null)},[t,e]),xl(()=>()=>{null!==e.state.openMethod&&e.set("openMethod",null)},[e])}(_,S),function(t,n={}){const{closeOnActiveTriggerUnmount:r=!1}=n,o=e.useRef(null),i=t.useState("open"),s=t.useState("triggerCount"),a=t.useState("activeTriggerId"),c=t.useState("activeTriggerElement");xl(()=>{if(!i)return o.current=null,void(0!==t.state.triggerCount&&t.set("triggerCount",0));const e=t.context.triggerElements.size,n={};t.state.triggerCount!==e&&(n.triggerCount=e);const s=t.select("activeTriggerId");let a=null;if(s){const e=t.context.triggerElements.getById(s);if(e)o.current=s,e!==t.state.activeTriggerElement&&(n.activeTriggerElement=e);else{for(const[e,r]of t.context.triggerElements.entries())if(r===t.state.activeTriggerElement){n.activeTriggerId=e,n.activeTriggerElement=r,o.current=e;break}void 0===n.activeTriggerId&&(o.current===s?a=s:o.current=null)}}else o.current=null;if(!a&&!s&&1===e){const e=t.context.triggerElements.entries().next();if(!e.done){const[t,r]=e.value;n.activeTriggerId=t,n.activeTriggerElement=r,o.current=t}}void 0===n.triggerCount&&void 0===n.activeTriggerId&&void 0===n.activeTriggerElement||t.update(n),a&&r&&queueMicrotask(()=>{if(t.select("open")&&t.select("activeTriggerId")===a&&!t.context.triggerElements.getById(a)){const e=qd("none");t.setOpen(!1,e),e.isCanceled||t.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,t,s,a,c,r])}(_);const{forceUnmount:E}=Hp(S,_);e.useImperativeHandle(d,()=>({unmount:E,close:()=>_.setOpen(!1,qd("imperative-action"))}),[E,_]);const T=S||I;/*#__PURE__*/
27
- return g(Ad.Provider,{value:_,children:[u&&/*#__PURE__*/m(Bp,{handle:u,store:_}),T&&/*#__PURE__*/m(ph,{store:_,parentContext:x?.context,isDrawer:f}),"function"==typeof r?r({payload:C}):r]})}function gh(e){return mh("dialog",e)}var yh=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,style:o,id:i,...s}=e,a=Nd(),c=Yd(i);return a.useSyncedValueWithCleanup("titleElementId",c),Xl("h2",e,{ref:t,props:[{id:c},s]})}),bh=n(null),wh=({previewMode:e})=>{const{uiState:t}=ya(),{chatState:n,taskState:r}=fa();return a(()=>{e||Ws.persist({messages:n.messages,isTaskRunning:r.isTaskRunning,activeTaskId:r.activeTaskId,currentMode:t.currentMode,isOpen:t.isOpen,isMinimized:t.isMinimized,isLoading:t.isLoading})},[e,n.messages,r.isTaskRunning,r.activeTaskId,t.currentMode,t.isOpen,t.isMinimized,t.isLoading]),null},vh=({children:e,previewMode:t})=>{const{uiActions:n}=ya(),{chatActions:r,taskActions:o}=fa();return a(()=>{if(t)return;(async()=>{const e=await Ys.getOrCreateChatId();Ws.createInitialContext(e),Ws.getInitError()&&n.setError("Widget failed to initialise — please refresh the page."),Ws.initialize(e);const t=Ws.restore();if(n.applyState({isLoading:t.isLoading,currentMode:t.currentMode,isOpen:t.isOpen,isMinimized:t.isMinimized}),r.setMessages(t.messages),o.setTaskState({activeTaskId:t.isTaskRunning?t.activeTaskId:null,isTaskRunning:t.isTaskRunning}),e){const t=Ks.getInstance(),n=sa.getConfig();t.connect(e,n?{mtxId:n.mtxId,mtxKey:n.mtxKey,mtxApp:n.mtxApp}:void 0).catch(e=>{})}})()},[]),/* @__PURE__ */g(f,{children:[e,/* @__PURE__ */m(wh,{previewMode:t})]})},xh=({children:e,previewMode:t})=>{const{uiState:n,uiActions:r}=ya();/* @__PURE__ */
28
- return m(ha,{previewMode:t,currentMode:n.currentMode,uiActions:r,children:/* @__PURE__ */m(vh,{previewMode:t,children:e})})},kh=({children:e,previewMode:t=!1,portalContainer:n})=>/* @__PURE__ */m(bh,{value:n??null,children:/* @__PURE__ */m(ga,{children:/* @__PURE__ */m(xh,{previewMode:t,children:e})})}),_h=({open:e,onClose:t,title:n,description:r,onConfirm:o,confirmLabel:i="Confirm",cancelLabel:a="Cancel"})=>{const c=s(bh)??document.body;/* @__PURE__ */
26
+ return m("div",{ref:t,role:"presentation","data-base-ui-inert":"",...r,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:o}})}),oh=/*#__PURE__*/e.forwardRef(function(e,t){const{keepMounted:n=!1,...r}=e,o=Nd(),i=o.useState("mounted"),s=o.useState("modal"),a=o.useState("open");return i||n?/*#__PURE__*/m(Xp.Provider,{value:n,children:/*#__PURE__*/g(bp,{ref:t,...r,children:[i&&!0===s&&/*#__PURE__*/m(rh,{ref:o.context.internalBackdropRef,inert:nh(!a)}),e.children]})}):null}),ih={},sh={},ah="";function ch(e,t){return function(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=ul(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&"inline"!==o&&"contents"!==o}(e)?e:t}function lh(e,t,n){return/hidden|clip/.test(e.getComputedStyle(ch(t,n)).overflowY)}function dh(e){const t=Fl(e),n=t.documentElement,r=t.body,o=il(n);let i=0,s=0,a=!1;const c=Eu.create();if(du&&1!==(o.visualViewport?.scale??1))return()=>{};function l(){const t=o.getComputedStyle(n),c=o.getComputedStyle(r),l=(t.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";i=n.scrollTop,s=n.scrollLeft,ih={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},ah=n.style.scrollBehavior,sh={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const d=n.scrollHeight>n.clientHeight,u=n.scrollWidth>n.clientWidth,p="scroll"===t.overflowY||"scroll"===c.overflowY,h="scroll"===t.overflowX||"scroll"===c.overflowX,f=Math.max(0,o.innerWidth-r.clientWidth),m=Math.max(0,o.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),y=parseFloat(c.marginLeft)+parseFloat(c.marginRight),b=ch(n,r);if(a=function(e){if("undefined"==typeof CSS||!CSS.supports||!CSS.supports("scrollbar-gutter","stable")||"undefined"==typeof document)return!1;const t=Fl(e),n=t.documentElement,r=ch(n,t.body),o=r.style.overflowY,i=n.style.scrollbarGutter;n.style.scrollbarGutter="stable",r.style.overflowY="scroll";const s=r.offsetWidth;r.style.overflowY="hidden";const a=r.offsetWidth;return r.style.overflowY=o,n.style.scrollbarGutter=i,s===a}(e),a)return n.style.scrollbarGutter=l,b.style.overflowY="hidden",void(b.style.overflowX="hidden");Object.assign(n.style,{scrollbarGutter:l,overflowY:"hidden",overflowX:"hidden"}),(d||p)&&(n.style.overflowY="scroll"),(u||h)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:g||m?`calc(100dvh - ${g+m}px)`:"100dvh",width:y||f?`calc(100vw - ${y+f}px)`:"100vw",boxSizing:"border-box",overflowY:"hidden",overflowX:"hidden",scrollBehavior:"unset"}),r.scrollTop=i,r.scrollLeft=s,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function d(){Object.assign(n.style,ih),Object.assign(r.style,sh),a||(n.scrollTop=i,n.scrollLeft=s,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=ah)}l();const u=xu(o,"resize",function(){d(),c.request(l)});return()=>{c.cancel(),d(),"function"==typeof o.removeEventListener&&u()}}var uh=new class{lockCount=0;restore=null;timeoutLock=Xd.create();timeoutUnlock=Xd.create();acquire(e){return this.lockCount+=1,1===this.lockCount&&null===this.restore&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{this.lockCount-=1,0===this.lockCount&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{0===this.lockCount&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(0===this.lockCount||null!==this.restore)return;const t=Fl(e),n=t.documentElement,r=t.body,o=il(n);if(lh(o,n,r)){const t=new o.MutationObserver(()=>{lh(o,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),i={attributes:!0};return t.observe(n,i),t.observe(r,i),void(this.restore=()=>t.disconnect())}const i=iu||!function(e){if("undefined"==typeof document)return!1;const t=Fl(e);return il(t).innerWidth-t.documentElement.clientWidth>0}(e);this.restore=i?function(e){const t=Fl(e),n=ch(t.documentElement,t.body),r={overflowY:n.style.overflowY,overflowX:n.style.overflowX};return Object.assign(n.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(n.style,r)}}(e):dh(e)}};function ph({store:t,parentContext:n,isDrawer:r}){const o=t.useState("open"),i=t.useState("disablePointerDismissal"),s=t.useState("modal"),a=t.useState("popupElement"),c=t.useState("floatingRootContext"),[l,d]=e.useState(0),[u,p]=e.useState(0),h=0===l,f=Op(c,{outsidePressEvent:()=>t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:"trap-focus"===s?"sloppy":"intentional",touch:"sloppy"},outsidePress(e){if(!t.context.outsidePressEnabledRef.current)return!1;if("button"in e&&0!==e.button)return!1;if("touches"in e)if("touchend"===e.type){if(1!==e.changedTouches.length||0!==e.touches.length)return!1}else if(1!==e.touches.length)return!1;const n=gu(e);if(h&&!i){if(s){const e=t.context.internalBackdropRef.current,r=t.context.backdropRef.current;return!e&&!r||(e===n||r===n||mu(n,a)&&!n?.hasAttribute("data-base-ui-portal"))}return!0}return!1},escapeKey:h});return function(e=!0,t=null){xl(()=>{if(e)return uh.acquire(t)},[e,t])}(o&&!0===s,a),t.useContextCallback("onNestedDialogOpen",(e,t)=>{d(e),p(t)}),xl(()=>(n?.onNestedDialogOpen&&(o?n.onNestedDialogOpen(l+1,u+(r?1:0)):n.onNestedDialogOpen(0,0)),()=>{n?.onNestedDialogOpen&&o&&n.onNestedDialogOpen(0,0)}),[r,o,l,u,n]),function(e,t){e.useSyncedValues(t),xl(()=>()=>{e.update({activeTriggerProps:Jl,inactiveTriggerProps:Jl,popupProps:Jl})},[e])}(t,{activeTriggerProps:f.reference,inactiveTriggerProps:f.trigger,popupProps:f.floating,nestedOpenDialogCount:l,nestedOpenDrawerCount:u}),null}var hh={...Jp,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},fh=class extends $p{constructor(t,n,r){const o=new qp,i=function(e,t,n,r=!1){const o={...Zp(),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e};return o.floatingRootContext=function(e,t,n=!1){return new Fp({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0})}(t,n,r),o}(t,o,n,r);super(i,function(t){return{popupRef:/*#__PURE__*/e.createRef(),backdropRef:/*#__PURE__*/e.createRef(),internalBackdropRef:/*#__PURE__*/e.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:t,onOpenChange:void 0,onOpenChangeComplete:void 0}}(o),hh)}setOpen=(e,t)=>{if(t.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},e||null!=t.trigger||null==this.state.activeTriggerId||(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);const n={open:e};!function(e,t,n,r=!1){t?e.preventUnmountingOnClose=!1:r&&(e.preventUnmountingOnClose=!0);const o=n?.id??null;(o||t)&&(e.activeTriggerId=o,e.activeTriggerElement=n??null)}(n,e,t.trigger),this.update(n)}};function mh(t,n){const{children:r,open:o,defaultOpen:i=!1,onOpenChange:s,onOpenChangeComplete:a,disablePointerDismissal:c=!1,modal:l=!0,actionsRef:d,handle:u,triggerId:p,defaultTriggerId:h=null}=n,f="drawer"===t,y="alert-dialog"===t,b=!!y||l,w=y||c,v=y?"alertdialog":"dialog",x=Nd(!0),k={modal:b,disablePointerDismissal:w,nested:null!=x,role:v},S=Wp((e,t)=>new fh({open:i,openProp:o,activeTriggerId:h,triggerIdProp:p,...k},e,t),!0);S.useControlledProp("openProp",o),S.useControlledProp("triggerIdProp",p),S.useSyncedValues(k),S.useContextCallback("onOpenChange",s),S.useContextCallback("onOpenChangeComplete",a);const _=S.useState("open"),I=S.useState("mounted"),C=S.useState("payload");!function(e,t){xl(()=>{t||null===e.state.openMethod||e.set("openMethod",null)},[t,e]),xl(()=>()=>{null!==e.state.openMethod&&e.set("openMethod",null)},[e])}(S,_),function(t,n={}){const{closeOnActiveTriggerUnmount:r=!1}=n,o=e.useRef(null),i=t.useState("open"),s=t.useState("triggerCount"),a=t.useState("activeTriggerId"),c=t.useState("activeTriggerElement");xl(()=>{if(!i)return o.current=null,void(0!==t.state.triggerCount&&t.set("triggerCount",0));const e=t.context.triggerElements.size,n={};t.state.triggerCount!==e&&(n.triggerCount=e);const s=t.select("activeTriggerId");let a=null;if(s){const e=t.context.triggerElements.getById(s);if(e)o.current=s,e!==t.state.activeTriggerElement&&(n.activeTriggerElement=e);else{for(const[e,r]of t.context.triggerElements.entries())if(r===t.state.activeTriggerElement){n.activeTriggerId=e,n.activeTriggerElement=r,o.current=e;break}void 0===n.activeTriggerId&&(o.current===s?a=s:o.current=null)}}else o.current=null;if(!a&&!s&&1===e){const e=t.context.triggerElements.entries().next();if(!e.done){const[t,r]=e.value;n.activeTriggerId=t,n.activeTriggerElement=r,o.current=t}}void 0===n.triggerCount&&void 0===n.activeTriggerId&&void 0===n.activeTriggerElement||t.update(n),a&&r&&queueMicrotask(()=>{if(t.select("open")&&t.select("activeTriggerId")===a&&!t.context.triggerElements.getById(a)){const e=qd("none");t.setOpen(!1,e),e.isCanceled||t.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,t,s,a,c,r])}(S);const{forceUnmount:E}=Hp(_,S);e.useImperativeHandle(d,()=>({unmount:E,close:()=>S.setOpen(!1,qd("imperative-action"))}),[E,S]);const T=_||I;/*#__PURE__*/
27
+ return g(Ad.Provider,{value:S,children:[u&&/*#__PURE__*/m(Bp,{handle:u,store:S}),T&&/*#__PURE__*/m(ph,{store:S,parentContext:x?.context,isDrawer:f}),"function"==typeof r?r({payload:C}):r]})}function gh(e){return mh("dialog",e)}var yh=/*#__PURE__*/e.forwardRef(function(e,t){const{render:n,className:r,style:o,id:i,...s}=e,a=Nd(),c=Yd(i);return a.useSyncedValueWithCleanup("titleElementId",c),Xl("h2",e,{ref:t,props:[{id:c},s]})}),bh=n(null),wh=({previewMode:e})=>{const{uiState:t}=ya(),{chatState:n,taskState:r}=fa();return a(()=>{e||Ws.persist({messages:n.messages,isTaskRunning:r.isTaskRunning,activeTaskId:r.activeTaskId,currentMode:t.currentMode,isOpen:t.isOpen,isMinimized:t.isMinimized,isLoading:t.isLoading})},[e,n.messages,r.isTaskRunning,r.activeTaskId,t.currentMode,t.isOpen,t.isMinimized,t.isLoading]),null},vh=({children:e,previewMode:t})=>{const{uiActions:n}=ya(),{chatActions:r,taskActions:o}=fa();return a(()=>{if(t)return;let e=!1;return(async()=>{const t=await Ys.getOrCreateChatId();if(e)return;Ws.createInitialContext(t),Ws.getInitError()&&n.setError("Widget failed to initialise — please refresh the page."),Ws.initialize(t);const i=Ws.restore();if(n.applyState({isLoading:i.isLoading,currentMode:i.currentMode,isOpen:i.isOpen,isMinimized:i.isMinimized}),r.setMessages(i.messages),o.setTaskState({activeTaskId:i.isTaskRunning?i.activeTaskId:null,isTaskRunning:i.isTaskRunning}),t){const e=Ks.getInstance(),n=sa.getConfig();e.connect(t,n?{mtxId:n.mtxId,mtxKey:n.mtxKey,mtxApp:n.mtxApp}:void 0).catch(e=>{})}})().catch(t=>{e||n.setError("Widget failed to initialise — please refresh the page.")}),()=>{e=!0}},[]),/* @__PURE__ */g(f,{children:[e,/* @__PURE__ */m(wh,{previewMode:t})]})},xh=({children:e,previewMode:t})=>{const{uiState:n,uiActions:r}=ya();/* @__PURE__ */
28
+ return m(ha,{previewMode:t,currentMode:n.currentMode,uiActions:r,children:/* @__PURE__ */m(vh,{previewMode:t,children:e})})},kh=({children:e,previewMode:t=!1,portalContainer:n})=>/* @__PURE__ */m(bh,{value:n??null,children:/* @__PURE__ */m(ga,{children:/* @__PURE__ */m(xh,{previewMode:t,children:e})})}),Sh=({open:e,onClose:t,title:n,description:r,onConfirm:o,confirmLabel:i="Confirm",cancelLabel:a="Cancel"})=>{const c=s(bh)??document.body;/* @__PURE__ */
29
29
  return m(gh,{open:e,onOpenChange:(e,n)=>{e||"none"===n.reason||t()},children:/* @__PURE__ */g(oh,{container:c,children:[/* @__PURE__ */m(Hd,{className:"fixed inset-0 z-(--layer-dialog) bg-black/20 animate-dialog-overlay-in"}),/* @__PURE__ */g(th,{className:"fixed top-1/2 left-1/2 z-[calc(var(--layer-dialog)+1)] flex max-h-[85vh] w-full max-w-sm -translate-x-1/2 -translate-y-1/2 flex-col overflow-auto rounded-lg bg-card p-4 animate-dialog-content-in",style:Zc("panel"),children:[
30
30
  /* @__PURE__ */m(yh,{className:"mb-1 text-base font-semibold text-foreground",children:n}),null!=r&&/* @__PURE__ */m(Kd,{className:"mb-4 text-sm leading-relaxed text-muted-foreground",children:r}),
31
- /* @__PURE__ */g(id,{gap:"md",justify:"end",children:[/* @__PURE__ */m(od,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},children:a}),/* @__PURE__ */m(od,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),o?.()},children:i})]})]})]})})},Sh={sm:"h-3.5 w-3.5 border-[1.5px]",md:"h-5 w-5 border-2",lg:"h-6 w-6 border-2"};function Ih({label:e,size:t="md",className:n,style:r,ref:o}){/* @__PURE__ */
31
+ /* @__PURE__ */g(id,{gap:"md",justify:"end",children:[/* @__PURE__ */m(od,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},children:a}),/* @__PURE__ */m(od,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:e=>{e.preventDefault(),e.stopPropagation(),o?.()},children:i})]})]})]})})},_h={sm:"h-3.5 w-3.5 border-[1.5px]",md:"h-5 w-5 border-2",lg:"h-6 w-6 border-2"};function Ih({label:e,size:t="md",className:n,style:r,ref:o}){/* @__PURE__ */
32
32
  return g("div",{ref:o,className:Fc("inline-flex items-center gap-1.5",n),"data-size":t,role:"status",style:r,children:[
33
- /* @__PURE__ */m("div",{"aria-hidden":"true",className:Fc("animate-spin rounded-full border-current border-t-transparent flex-shrink-0",Sh[t])}),null!=e&&/* @__PURE__ */m("span",{children:e}),
33
+ /* @__PURE__ */m("div",{"aria-hidden":"true",className:Fc("animate-spin rounded-full border-current border-t-transparent flex-shrink-0",_h[t])}),null!=e&&/* @__PURE__ */m("span",{children:e}),
34
34
  /* @__PURE__ */m("span",{className:"sr-only",children:"Loading"})]})}var Ch=({content:e,status:t,hideIcon:n=!1,textStyle:r="default"})=>{const{config:o}=ba(),i=o.widget_accent_color;/* @__PURE__ */
35
- return g(id,{align:"start",gap:"md",children:[!n&&(()=>{switch(t){case"completed":/* @__PURE__ */return m(ad,{name:"checkCircle",style:{color:i,marginTop:"2px",flexShrink:0},size:16});case"failed":/* @__PURE__ */return m(ad,{name:"timesCircle",style:{opacity:.65,marginTop:"2px",flexShrink:0},size:16});case"stopped":/* @__PURE__ */return m(ad,{name:"ban",style:{opacity:.5,marginTop:"2px",flexShrink:0},size:16});default:/* @__PURE__ */return m(Ih,{size:"sm",style:{color:i,marginTop:"2px"}})}})(),/* @__PURE__ */m(gd,{as:"span",size:"xs",weight:"medium",style:{flex:1,whiteSpace:"pre-wrap",lineHeight:"tight",opacity:"muted"===r?.5:1},children:e})]})},Eh=({isWaitingForUser:e})=>/* @__PURE__ */g(id,{align:"center",gap:"sm",paddingY:"xs",children:[/* @__PURE__ */m(Ih,{size:"sm"}),/* @__PURE__ */m(gd,{as:"span",size:"xs",weight:"normal",variant:"faint",children:e?"Waiting for you to complete the action":"Thinking"})]}),Th=({message:e,isLastMessage:t})=>{const{state:n}=ba(),r="waiting-for-user"===(e.placeholderState||"thinking");return e.parts&&e.parts.length>0?/* @__PURE__ */g(pd,{gap:"sm",children:[e.parts.map((t,n)=>{if("text"===t.type){let e=(r=t.content,r.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,"")).trim();return e=e.replace(/\(Cancelled by cleanup\)/gi,"").replace(/\s+/g," ").trim(),e?/* @__PURE__ */m(gd,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap",marginBottom:"4px"},children:e},`part-${n}`):null}return"progress"===t.type?"done"===t.browserToolName&&"done"===e.taskStatus?null:/* @__PURE__ */m(Ch,{content:t.content,status:t.status||"in_progress",...void 0!==t.hideIcon?{hideIcon:t.hideIcon}:{},...void 0!==t.textStyle?{textStyle:t.textStyle}:{}},`part-${n}`):null;var r}),(e.isPlaceholder&&!e.parts.some(e=>"text"===e.type)||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode))&&/* @__PURE__ */m(Eh,{isWaitingForUser:r})]}):e.isPlaceholder||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode)?/* @__PURE__ */m(Eh,{isWaitingForUser:r}):e.content?/* @__PURE__ */m(gd,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap"},children:e.content}):/* @__PURE__ */m(Qc,{})},Mh=({status:e})=>{const{config:t}=ba(),n=t.widget_accent_color;switch(e){case"done":/* @__PURE__ */return m(ad,{name:"checkCircle",style:{color:n,flexShrink:0},size:14});case"failed":/* @__PURE__ */return m(ad,{name:"exclamationCircle",style:{color:_(n,.75),flexShrink:0},size:14});case"stopped":/* @__PURE__ */return m(ad,{name:"circle",style:{color:_(n,.5),flexShrink:0},size:14});default:/* @__PURE__ */return m(Ih,{size:"sm",style:{color:n}})}},zh="8px 8px 0 0",Oh="#111827",Rh="rgba(255,255,255,0.7)",Ah=({stream:e})=>{const t=d(null),n=d(null),[r,o]=u(!1),[i,s]=u(!1);return a(()=>{if(t.current&&e){const r=t.current;o(!1),s(!1),n.current&&(n.current.catch(()=>{}),n.current=null),r.srcObject=e;const i=()=>{o(!0)},a=()=>{s(!0),o(!1)};r.addEventListener("loadedmetadata",i),r.addEventListener("error",a);const c=r.play();return n.current=c,c.then(()=>{o(!0)}).catch(e=>{e instanceof Error&&"AbortError"!==e.name&&s(!0),n.current=null}),()=>{r.removeEventListener("loadedmetadata",i),r.removeEventListener("error",a)}}return()=>{n.current&&(n.current.catch(()=>{}),n.current=null),t.current&&(t.current.srcObject=null),o(!1),s(!1)}},[e]),e?/* @__PURE__ */g(Qc,{width:"full",overflow:"hidden",position:"relative",style:{marginBottom:"4px",borderRadius:zh,backgroundColor:"#000000",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06)"},children:[!r&&!i&&/* @__PURE__ */m(id,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:Oh,borderRadius:zh,zIndex:10,transition:"opacity 300ms",opacity:r?0:1},children:/* @__PURE__ */g(id,{direction:"column",align:"center",gap:"md",children:[/* @__PURE__ */m(Ih,{size:"lg",style:{color:"white"}}),/* @__PURE__ */m(gd,{as:"span",size:"xs",weight:"medium",style:{color:Rh},children:"Loading stream..."})]})}),i&&/* @__PURE__ */m(id,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:Oh,borderRadius:zh,zIndex:10},children:/* @__PURE__ */g(id,{direction:"column",align:"center",gap:"md",style:{textAlign:"center",paddingLeft:"16px",paddingRight:"16px"},children:[/* @__PURE__ */m(ad,{name:"alertCircle",size:32,style:{color:"#9ca3af"}}),/* @__PURE__ */m(gd,{as:"span",size:"xs",weight:"medium",style:{color:Rh},children:"Failed to load stream"})]})}),
35
+ return g(id,{align:"start",gap:"md",children:[!n&&(()=>{switch(t){case"completed":/* @__PURE__ */return m(ad,{name:"checkCircle",style:{color:i,marginTop:"2px",flexShrink:0},size:16});case"failed":/* @__PURE__ */return m(ad,{name:"timesCircle",style:{opacity:.65,marginTop:"2px",flexShrink:0},size:16});case"stopped":/* @__PURE__ */return m(ad,{name:"ban",style:{opacity:.5,marginTop:"2px",flexShrink:0},size:16});default:/* @__PURE__ */return m(Ih,{size:"sm",style:{color:i,marginTop:"2px"}})}})(),/* @__PURE__ */m(gd,{as:"span",size:"xs",weight:"medium",style:{flex:1,whiteSpace:"pre-wrap",lineHeight:"tight",opacity:"muted"===r?.5:1},children:e})]})},Eh=({isWaitingForUser:e})=>/* @__PURE__ */g(id,{align:"center",gap:"sm",paddingY:"xs",children:[/* @__PURE__ */m(Ih,{size:"sm"}),/* @__PURE__ */m(gd,{as:"span",size:"xs",weight:"normal",variant:"faint",children:e?"Waiting for you to complete the action":"Thinking"})]}),Th=({message:e,isLastMessage:t})=>{const{state:n}=ba(),r="waiting-for-user"===(e.placeholderState||"thinking");return e.parts&&e.parts.length>0?/* @__PURE__ */g(pd,{gap:"sm",children:[e.parts.map((t,n)=>{if("text"===t.type){let e=(r=t.content,r.replace(/\n\n__THINKING__$/,"").replace(/__THINKING__/g,"")).trim();return e=e.replace(/\(Cancelled by cleanup\)/gi,"").replace(/\s+/g," ").trim(),e?/* @__PURE__ */m(gd,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap",marginBottom:"4px"},children:e},`part-${n}`):null}return"progress"===t.type?"done"===t.browserToolName&&"done"===e.taskStatus?null:/* @__PURE__ */m(Ch,{content:t.content,status:t.status||"in_progress",...void 0!==t.hideIcon?{hideIcon:t.hideIcon}:{},...void 0!==t.textStyle?{textStyle:t.textStyle}:{}},`part-${n}`):null;var r}),(e.isPlaceholder&&!e.parts.some(e=>"text"===e.type)||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode))&&/* @__PURE__ */m(Eh,{isWaitingForUser:r})]}):e.isPlaceholder||n.isTaskRunning&&t&&("show"===e.mode||"do"===e.mode)?/* @__PURE__ */m(Eh,{isWaitingForUser:r}):e.content?/* @__PURE__ */m(gd,{as:"div",size:"sm",weight:"medium",style:{lineHeight:"tight",wordBreak:"break-word",whiteSpace:"pre-wrap"},children:e.content}):/* @__PURE__ */m(Qc,{})},Mh=({status:e})=>{const{config:t}=ba(),n=t.widget_accent_color;switch(e){case"done":/* @__PURE__ */return m(ad,{name:"checkCircle",style:{color:n,flexShrink:0},size:14});case"failed":/* @__PURE__ */return m(ad,{name:"exclamationCircle",style:{color:S(n,.75),flexShrink:0},size:14});case"stopped":/* @__PURE__ */return m(ad,{name:"circle",style:{color:S(n,.5),flexShrink:0},size:14});default:/* @__PURE__ */return m(Ih,{size:"sm",style:{color:n}})}},zh="8px 8px 0 0",Oh="#111827",Rh="rgba(255,255,255,0.7)",Ah=({stream:e})=>{const t=d(null),n=d(null),[r,o]=u(!1),[i,s]=u(!1);return a(()=>{if(t.current&&e){const r=t.current;o(!1),s(!1),n.current&&(n.current.catch(()=>{}),n.current=null),r.srcObject=e;const i=()=>{o(!0)},a=()=>{s(!0),o(!1)};r.addEventListener("loadedmetadata",i),r.addEventListener("error",a);const c=r.play();return n.current=c,c.then(()=>{o(!0)}).catch(e=>{e instanceof Error&&"AbortError"!==e.name&&s(!0),n.current=null}),()=>{r.removeEventListener("loadedmetadata",i),r.removeEventListener("error",a)}}return()=>{n.current&&(n.current.catch(()=>{}),n.current=null),t.current&&(t.current.srcObject=null),o(!1),s(!1)}},[e]),e?/* @__PURE__ */g(Qc,{width:"full",overflow:"hidden",position:"relative",style:{marginBottom:"4px",borderRadius:zh,backgroundColor:"#000000",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06)"},children:[!r&&!i&&/* @__PURE__ */m(id,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:Oh,borderRadius:zh,zIndex:10,transition:"opacity 300ms",opacity:r?0:1},children:/* @__PURE__ */g(id,{direction:"column",align:"center",gap:"md",children:[/* @__PURE__ */m(Ih,{size:"lg",style:{color:"white"}}),/* @__PURE__ */m(gd,{as:"span",size:"xs",weight:"medium",style:{color:Rh},children:"Loading stream..."})]})}),i&&/* @__PURE__ */m(id,{position:"absolute",inset:"0",align:"center",justify:"center",style:{backgroundColor:Oh,borderRadius:zh,zIndex:10},children:/* @__PURE__ */g(id,{direction:"column",align:"center",gap:"md",style:{textAlign:"center",paddingLeft:"16px",paddingRight:"16px"},children:[/* @__PURE__ */m(ad,{name:"alertCircle",size:32,style:{color:"#9ca3af"}}),/* @__PURE__ */m(gd,{as:"span",size:"xs",weight:"medium",style:{color:Rh},children:"Failed to load stream"})]})}),
36
36
  /* @__PURE__ */m("video",{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"auto",maxHeight:"192px",objectFit:"contain",borderRadius:zh,transition:"opacity 500ms",opacity:r?1:0,minHeight:"120px",background:"linear-gradient(135deg, #111827 0%, #374151 100%)"}}),r&&!i&&/* @__PURE__ */g(id,{position:"absolute",align:"center",gap:"sm",animate:"fadeIn",style:{top:"8px",right:"8px",padding:"4px 8px",borderRadius:"9999px",backgroundColor:"rgba(55,65,81,0.9)",backdropFilter:"blur(4px)",zIndex:20,boxShadow:"0 2px 8px rgba(31, 41, 55, 0.4)"},children:[/* @__PURE__ */g(id,{position:"relative",align:"center",justify:"center",children:[/* @__PURE__ */m(Qc,{position:"absolute",rounded:"full",animate:"ping",style:{width:"8px",height:"8px",backgroundColor:"white",opacity:.75}}),/* @__PURE__ */m(Qc,{position:"relative",rounded:"full",style:{width:"6px",height:"6px",backgroundColor:"white"}})]}),/* @__PURE__ */m(gd,{as:"span",size:"xs",weight:"semibold",style:{color:"white",textTransform:"uppercase",letterSpacing:"0.05em",fontSize:"10px"},children:"Live"})]}),
37
37
  /* @__PURE__ */m(id,{position:"absolute",inset:"0",align:"center",justify:"center",style:{borderRadius:zh,backgroundColor:"rgba(0,0,0,0)",zIndex:30,pointerEvents:"none"},children:/* @__PURE__ */m(Qc,{rounded:"lg",style:{padding:"4px 12px",backgroundColor:"rgba(0,0,0,0.7)",backdropFilter:"blur(4px)"},children:/* @__PURE__ */m(gd,{as:"div",size:"xs",weight:"medium",style:{color:"white"},children:"Screen Sharing Active"})})})]}):null},Nh=({message:e,index:t,isLastMessage:n,onScreenAccessAllow:r,onScreenAccessDeny:o})=>{if(e.isSystemMessage)/* @__PURE__ */return m(id,{justify:"center",align:"center",children:/* @__PURE__ */m(gd,{as:"span",variant:"faint",weight:"normal",style:{fontSize:"10px"},children:e.content})},`message-${e.id}-${t}`);const i="user"===e.sender,s=i?"show"===e.mode||"do"===e.mode?"mousePointerClick":void 0:e.isScreenAccessRequest||"waiting-for-user"===e.placeholderState?"checkCircle":void 0;/* @__PURE__ */
38
38
  return g(pd,{style:{marginTop:"10px"},role:"article","aria-roledescription":"message","aria-label":i?"You said…":"Agent says…",animate:n?"fadeIn":void 0,children:[/* @__PURE__ */g(id,{align:"start",gap:"sm",width:"full",children:[
39
39
  /* @__PURE__ */m(id,{shrink:!1,style:{width:"20px",height:"20px",marginTop:"6px"},children:!i&&/* @__PURE__ */m(nl,{src:"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%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",alt:"Marketrix AI",size:20,fit:"cover",rounded:"theme",style:{border:"none",outline:"none",display:"block",backgroundColor:"transparent"}})}),
40
40
  /* @__PURE__ */g(pd,{grow:!0,position:"relative",rounded:"theme",elevation:"card",style:{padding:e.videoStream?"0":"8px 10px",border:"1px solid transparent",backgroundColor:i?"var(--primary)":void 0,color:i?"var(--primary-foreground)":"var(--foreground)"},children:[e.videoStream&&/* @__PURE__ */m(Ah,{stream:e.videoStream}),!e.videoStream&&(s?/* @__PURE__ */g(id,{align:"start",gap:"sm",children:[/* @__PURE__ */m(id,{shrink:!1,style:{marginTop:"3px"},children:/* @__PURE__ */m(ad,{name:s,size:13})}),/* @__PURE__ */m(pd,{grow:!0,children:/* @__PURE__ */m(Th,{message:e,isLastMessage:n})})]}):/* @__PURE__ */m(Th,{message:e,isLastMessage:n})),e.isScreenAccessRequest&&!e.screenShareStatus&&/* @__PURE__ */g(id,{align:"center",gap:"sm",style:{marginTop:"6px"},children:[/* @__PURE__ */m(od,{type:"button",variant:"primary",size:"sm",shape:"pill",onClick:()=>r?.(),children:"Yes"}),/* @__PURE__ */m(od,{type:"button",variant:"secondary",size:"sm",shape:"pill",onClick:()=>o?.(),children:"No"})]}),e.isScreenAccessRequest&&e.screenShareStatus&&/* @__PURE__ */m(gd,{as:"div",variant:"faint",size:"xs",italic:!0,style:{marginTop:"2px"},children:"allowed"===e.screenShareStatus?"Sure":"Check HTML Instead"}),!i&&e.taskStatus&&/* @__PURE__ */m(id,{position:"absolute",align:"center",justify:"center",style:{bottom:"4px",right:"4px"},children:/* @__PURE__ */m(Mh,{status:e.taskStatus})})]}),
41
- /* @__PURE__ */m(id,{shrink:!1,style:{width:"20px"}})]}),!e.isPlaceholder&&/* @__PURE__ */m(gd,{as:"div",variant:"faint",size:"xxs",align:"right",style:{marginTop:"2px",marginRight:"26px"},children:I(e.timestamp)})]},`message-${e.id}-${t}`)},Ph={boxShadow:jc.button,backgroundColor:"var(--card)",border:"1px solid var(--border)",pointerEvents:"auto"},Lh=({messages:e,messagesEndRef:t,config:n,onScreenAccessAllow:r,onScreenAccessDeny:o,onClearChat:i})=>{const{config:s,state:c,isPreviewMode:p}=ba({config:n}),[h,f]=u(!1),[y,b]=u(!1),w=d(null),v=l(()=>({id:"welcome",content:s.widget_body??"How can I help you today?",sender:"agent",timestamp:/* @__PURE__ */new Date,isPlaceholder:!1}),[s.widget_body]),x=l(()=>[v,...e],[v,e]),k=()=>{if(w.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=w.current;f(e>200);const r=Math.abs(t-e-n)<50;b(!r&&t>n)}};a(()=>{window.requestAnimationFrame(()=>{t.current&&(!p&&t.current.scrollIntoView({behavior:"auto"}),!p&&k())})},[e.length,p]);const S=e[e.length-1]?.content?.length??0;return a(()=>{const e=w.current;e&&!p&&e.scrollHeight-e.scrollTop-e.clientHeight<120&&window.requestAnimationFrame(()=>t.current?.scrollIntoView({behavior:"auto"}))},[S,p,t]),/* @__PURE__ */g(Qc,{position:"relative",height:"full",children:[
42
- /* @__PURE__ */g(Qc,{ref:w,onScroll:k,role:"log","aria-relevant":"additions",height:"full",overflowY:"auto",paddingX:"lg",paddingY:"sm",style:{backgroundColor:s.widget_background_color.includes("gradient")?"transparent":s.widget_background_color,backgroundImage:s.widget_background_color.includes("gradient")?s.widget_background_color:`linear-gradient(135deg, ${s.widget_background_color} 0%, ${s.widget_background_color} 100%)`,scrollbarColor:`${_(s.widget_border_color,.3)} ${_(s.widget_border_color,.1)}`,scrollbarWidth:"thin"},children:[0===e.length&&c.isLoading&&/* @__PURE__ */g(pd,{align:"center",justify:"center",gap:"lg",paddingY:"2xl",paddingX:"xl",role:"status","aria-live":"polite",children:[/* @__PURE__ */m(Ih,{size:"lg"}),/* @__PURE__ */m(gd,{as:"p",size:"sm",align:"center",children:"Connecting…"})]}),x.map((e,t)=>/* @__PURE__ */m(Nh,{message:e,index:t,isLastMessage:t===x.length-1,onScreenAccessAllow:r,onScreenAccessDeny:o},`message-${e.id}-${t}`)),e.length>0&&i&&/* @__PURE__ */m(id,{justify:"center",style:{marginTop:"12px",marginBottom:"4px"},children:/* @__PURE__ */m(od,{type:"button",variant:"bare",onClick:()=>{const e=i();e instanceof Promise&&e.catch(e=>{})},children:/* @__PURE__ */m(gd,{size:"xs",variant:"muted",style:{cursor:"pointer"},children:"Clear conversation"})})}),
43
- /* @__PURE__ */m(Qc,{ref:t},"scroll-anchor")]},"message-list-container"),h&&/* @__PURE__ */m(id,{position:"absolute",justify:"center",style:{top:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */m(ud,{variant:"secondary",size:"sm",label:"Scroll to top",onClick:()=>{w.current?.scrollTo({top:0,behavior:"smooth"})},style:Ph,children:/* @__PURE__ */m(ad,{name:"arrowUp",size:10,style:{color:s.widget_accent_color}})})}),y&&/* @__PURE__ */m(id,{position:"absolute",justify:"center",style:{bottom:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */m(ud,{variant:"secondary",size:"sm",label:"Scroll to bottom",onClick:()=>{t.current&&!p&&t.current.scrollIntoView({behavior:"smooth"})},style:Ph,children:/* @__PURE__ */m(ad,{name:"arrowDown",size:10,style:{color:s.widget_accent_color}})})})]})},$h=class extends t.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){}render(){return this.state.hasError?/* @__PURE__ */m(gd,{as:"div",size:"xs",align:"center",style:{padding:"16px",color:"var(--muted-foreground)"},children:"Something went wrong displaying messages. Please refresh."}):this.props.children}},Dh={show:"mousePointerClick",tell:"chatBubble",do:"ticktick"},Fh=["tell","show","do"];var jh=({config:e,messages:t,currentMode:n,isTaskRunning:r=!1,onSendMessage:o,onSetMode:i,onAddMessage:s,onUpdateMessage:a,onRemoveMessage:c,onStopTask:l,onClearChat:p,onScreenSharingChange:h,onStartScreenShareRef:f,onStopScreenShareRef:y,messageInputRef:b})=>{const[w,v]=u(""),x=d(null),[k,_]=u(null),{isScreenSharing:S,showScreenAccessDialog:I,handleScreenAccessDialogAllow:E,handleScreenAccessDialogDeny:T,handleScreenAccessAllow:M,handleScreenAccessDeny:z,requestScreenAccess:O}=zd({onScreenSharingChange:h,onStartScreenShareRef:f,onStopScreenShareRef:y,onAddMessage:s,onUpdateMessage:a,onRemoveMessage:c,onSendMessage:o,pendingMessage:k,setPendingMessage:_}),R=e;/* @__PURE__ */
44
- return g(pd,{height:"full",id:"view-chat",role:"tabpanel","aria-labelledby":"tab-chat",children:[I&&/* @__PURE__ */m(_h,{open:I,onClose:T,title:"Can I take a look at your screen?",description:"By allowing screen access, Marketrix can understand your current context to guide you better and complete tasks on your behalf.",onConfirm:E,confirmLabel:"Yes",cancelLabel:"No"}),
41
+ /* @__PURE__ */m(id,{shrink:!1,style:{width:"20px"}})]}),!e.isPlaceholder&&/* @__PURE__ */m(gd,{as:"div",variant:"faint",size:"xxs",align:"right",style:{marginTop:"2px",marginRight:"26px"},children:I(e.timestamp)})]},`message-${e.id}-${t}`)},Ph={boxShadow:jc.button,backgroundColor:"var(--card)",border:"1px solid var(--border)",pointerEvents:"auto"},Lh=({messages:e,messagesEndRef:t,config:n,onScreenAccessAllow:r,onScreenAccessDeny:o,onClearChat:i})=>{const{config:s,state:c,isPreviewMode:p}=ba({config:n}),[h,f]=u(!1),[y,b]=u(!1),w=d(null),v=l(()=>({id:"welcome",content:s.widget_body??"How can I help you today?",sender:"agent",timestamp:/* @__PURE__ */new Date,isPlaceholder:!1}),[s.widget_body]),x=l(()=>[v,...e],[v,e]),k=()=>{if(w.current){const{scrollTop:e,scrollHeight:t,clientHeight:n}=w.current;f(e>200);const r=Math.abs(t-e-n)<50;b(!r&&t>n)}};a(()=>{window.requestAnimationFrame(()=>{t.current&&(!p&&t.current.scrollIntoView({behavior:"auto"}),!p&&k())})},[e.length,p]);const _=e[e.length-1]?.content?.length??0;return a(()=>{const e=w.current;e&&!p&&e.scrollHeight-e.scrollTop-e.clientHeight<120&&window.requestAnimationFrame(()=>t.current?.scrollIntoView({behavior:"auto"}))},[_,p,t]),/* @__PURE__ */g(Qc,{position:"relative",height:"full",children:[
42
+ /* @__PURE__ */g(Qc,{ref:w,onScroll:k,role:"log","aria-relevant":"additions",height:"full",overflowY:"auto",paddingX:"lg",paddingY:"sm",style:{backgroundColor:s.widget_background_color.includes("gradient")?"transparent":s.widget_background_color,backgroundImage:s.widget_background_color.includes("gradient")?s.widget_background_color:`linear-gradient(135deg, ${s.widget_background_color} 0%, ${s.widget_background_color} 100%)`,scrollbarColor:`${S(s.widget_border_color,.3)} ${S(s.widget_border_color,.1)}`,scrollbarWidth:"thin"},children:[0===e.length&&c.isLoading&&/* @__PURE__ */g(pd,{align:"center",justify:"center",gap:"lg",paddingY:"2xl",paddingX:"xl",role:"status","aria-live":"polite",children:[/* @__PURE__ */m(Ih,{size:"lg"}),/* @__PURE__ */m(gd,{as:"p",size:"sm",align:"center",children:"Connecting…"})]}),x.map((e,t)=>/* @__PURE__ */m(Nh,{message:e,index:t,isLastMessage:t===x.length-1,onScreenAccessAllow:r,onScreenAccessDeny:o},`message-${e.id}-${t}`)),e.length>0&&i&&/* @__PURE__ */m(id,{justify:"center",style:{marginTop:"12px",marginBottom:"4px"},children:/* @__PURE__ */m(od,{type:"button",variant:"bare",onClick:()=>{const e=i();e instanceof Promise&&e.catch(e=>{})},children:/* @__PURE__ */m(gd,{size:"xs",variant:"muted",style:{cursor:"pointer"},children:"Clear conversation"})})}),
43
+ /* @__PURE__ */m(Qc,{ref:t},"scroll-anchor")]},"message-list-container"),h&&/* @__PURE__ */m(id,{position:"absolute",justify:"center",style:{top:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */m(ud,{variant:"secondary",size:"sm",label:"Scroll to top",onClick:()=>{w.current?.scrollTo({top:0,behavior:"smooth"})},style:Ph,children:/* @__PURE__ */m(ad,{name:"arrowUp",size:10,style:{color:s.widget_accent_color}})})}),y&&/* @__PURE__ */m(id,{position:"absolute",justify:"center",style:{bottom:"8px",left:0,right:0,zIndex:10,pointerEvents:"none"},children:/* @__PURE__ */m(ud,{variant:"secondary",size:"sm",label:"Scroll to bottom",onClick:()=>{t.current&&!p&&t.current.scrollIntoView({behavior:"smooth"})},style:Ph,children:/* @__PURE__ */m(ad,{name:"arrowDown",size:10,style:{color:s.widget_accent_color}})})})]})},$h=class extends t.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){}render(){return this.state.hasError?/* @__PURE__ */m(gd,{as:"div",size:"xs",align:"center",style:{padding:"16px",color:"var(--muted-foreground)"},children:"Something went wrong displaying messages. Please refresh."}):this.props.children}},Dh={show:"mousePointerClick",tell:"chatBubble",do:"ticktick"},Fh=["tell","show","do"];var jh=({config:e,messages:t,currentMode:n,isTaskRunning:r=!1,onSendMessage:o,onSetMode:i,onAddMessage:s,onUpdateMessage:a,onRemoveMessage:c,onStopTask:l,onClearChat:p,onScreenSharingChange:h,onStartScreenShareRef:f,onStopScreenShareRef:y,messageInputRef:b})=>{const[w,v]=u(""),x=d(null),[k,S]=u(null),{isScreenSharing:_,showScreenAccessDialog:I,handleScreenAccessDialogAllow:E,handleScreenAccessDialogDeny:T,handleScreenAccessAllow:M,handleScreenAccessDeny:z,requestScreenAccess:O}=zd({onScreenSharingChange:h,onStartScreenShareRef:f,onStopScreenShareRef:y,onAddMessage:s,onUpdateMessage:a,onRemoveMessage:c,onSendMessage:o,pendingMessage:k,setPendingMessage:S}),R=e;/* @__PURE__ */
44
+ return g(pd,{height:"full",id:"view-chat",role:"tabpanel","aria-labelledby":"tab-chat",children:[I&&/* @__PURE__ */m(Sh,{open:I,onClose:T,title:"Can I take a look at your screen?",description:"By allowing screen access, Marketrix can understand your current context to guide you better and complete tasks on your behalf.",onConfirm:E,confirmLabel:"Yes",cancelLabel:"No"}),
45
45
  /* @__PURE__ */m(Qc,{grow:!0,overflow:"hidden",paddingY:"xs",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */m($h,{children:/* @__PURE__ */m(Lh,{messages:t,messagesEndRef:x,config:e,onScreenAccessAllow:M,onScreenAccessDeny:z,onClearChat:p})})}),
46
- /* @__PURE__ */m(Qc,{background:"card",border:!0,elevation:"card",paddingPreset:"card",radius:"xl",style:{margin:"0 12px 12px 12px",marginTop:"auto"},children:/* @__PURE__ */m(Rd,{ref:b,value:w,onChange:v,onSubmit:()=>{const r=t.some(e=>e.isPlaceholder);if(w.trim()&&!r){const t=w.trim();v(""),s(Bs(t,n)),!1===e.use_screenshare||"show"!==n&&"do"!==n||S?o(t,n,void 0,void 0,!0):(_({content:t,mode:n,alreadyAdded:!0}),O(n))}},modes:Fh.filter(e=>function(e){return[...e.widget_feature_show?["show"]:[],...e.widget_feature_tell?["tell"]:[],...e.widget_feature_do?["do"]:[]]}(R).includes(e)).map(e=>({id:e,icon:Dh[e],label:C(e)})),activeMode:n,onModeChange:e=>(e=>{e!==n&&(s(qs(`Switched to ${{show:"Show",tell:"Tell",do:"Do"}[e]} mode`,e,"agent","mode-change")),i(e))})(e),disabled:t.some(e=>e.isPlaceholder),taskRunning:r,onStop:()=>{oa.cleanup(),l?.()}})})]})},Uh=[{id:"show-add-product",text:"Show me how to add a new product",icon:/* @__PURE__ */m(ad,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"show-login",text:"Show me how to login",icon:/* @__PURE__ */m(ad,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"do-login",text:"Do the login process for me",icon:/* @__PURE__ */m(ad,{name:"ticktick",size:16}),type:"do",isShow:!1},{id:"show-revenue",text:"Show me the revenue metrics",icon:/* @__PURE__ */m(ad,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"tell-conversion-rate",text:"What does my conversion rate mean and how can I improve it?",icon:/* @__PURE__ */m(ad,{name:"chatBubble",size:20}),type:"tell",isShow:!1}];function Wh(e){switch(e){case"do":/* @__PURE__ */return m(ad,{name:"ticktick",size:12});case"show":/* @__PURE__ */return m(ad,{name:"mousePointerClick",size:12});default:/* @__PURE__ */return m(ad,{name:"chatBubble",size:12})}}var Bh=({actions:e,onActionClick:t})=>{const{config:n}=ba();return 0===e.length?null:/* @__PURE__ */m(pd,{gap:"sm",children:e.map((e,r)=>/* @__PURE__ */m(od,{elevation:"card",shape:"theme",size:"sm",variant:"chip",full:!0,onClick:n=>t(e,n),style:{color:n.widget_text_color,paddingTop:"8px",paddingBottom:"8px"},children:/* @__PURE__ */m(gd,{as:"span",weight:"normal",leading:"tight",children:"show"===e.type?/* @__PURE__ */g(f,{children:["Show me ",e.text.replace(/^Show me\s*/i,"")]}):"do"===e.type?/* @__PURE__ */g(f,{children:["Do ",e.text.replace(/^Do\s*/i,"")]}):e.text})},`welcome-chip-${e.id}-${r}`))})},Hh=({config:e,messages:t,onNavigateToChat:n,onChipClick:r})=>{const o=function(e){const t=e.widget_chips;if(t&&Array.isArray(t)&&t.length>0){const e=/* @__PURE__ */new Set;return t.map((t,n)=>{const r=t.chip_text,o=t.chip_mode,i=`chip-${r.replace(/\s+/g,"-").toLowerCase()}-${n}`;let s=i,a=0;for(;e.has(s);)a++,s=`${i}-${a}`;return e.add(s),{id:s,text:r,icon:Wh(o),type:o,isShow:"show"===o}})}return Uh}(e);/* @__PURE__ */
46
+ /* @__PURE__ */m(Qc,{background:"card",border:!0,elevation:"card",paddingPreset:"card",radius:"xl",style:{margin:"0 12px 12px 12px",marginTop:"auto"},children:/* @__PURE__ */m(Rd,{ref:b,value:w,onChange:v,onSubmit:()=>{const r=t.some(e=>e.isPlaceholder);if(w.trim()&&!r){const t=w.trim();v(""),s(Bs(t,n)),!1===e.use_screenshare||"show"!==n&&"do"!==n||_?o(t,n,void 0,void 0,!0):(S({content:t,mode:n,alreadyAdded:!0}),O(n))}},modes:Fh.filter(e=>function(e){return[...e.widget_feature_show?["show"]:[],...e.widget_feature_tell?["tell"]:[],...e.widget_feature_do?["do"]:[]]}(R).includes(e)).map(e=>({id:e,icon:Dh[e],label:C(e)})),activeMode:n,onModeChange:e=>(e=>{e!==n&&(s(qs(`Switched to ${{show:"Show",tell:"Tell",do:"Do"}[e]} mode`,e,"agent","mode-change")),i(e))})(e),disabled:t.some(e=>e.isPlaceholder),taskRunning:r,onStop:()=>{oa.cleanup(),l?.()}})})]})},Uh=[{id:"show-add-product",text:"Show me how to add a new product",icon:/* @__PURE__ */m(ad,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"show-login",text:"Show me how to login",icon:/* @__PURE__ */m(ad,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"do-login",text:"Do the login process for me",icon:/* @__PURE__ */m(ad,{name:"ticktick",size:16}),type:"do",isShow:!1},{id:"show-revenue",text:"Show me the revenue metrics",icon:/* @__PURE__ */m(ad,{name:"mousePointerClick",size:24}),type:"show",isShow:!0},{id:"tell-conversion-rate",text:"What does my conversion rate mean and how can I improve it?",icon:/* @__PURE__ */m(ad,{name:"chatBubble",size:20}),type:"tell",isShow:!1}];function Wh(e){switch(e){case"do":/* @__PURE__ */return m(ad,{name:"ticktick",size:12});case"show":/* @__PURE__ */return m(ad,{name:"mousePointerClick",size:12});default:/* @__PURE__ */return m(ad,{name:"chatBubble",size:12})}}var Bh=({actions:e,onActionClick:t})=>{const{config:n}=ba();return 0===e.length?null:/* @__PURE__ */m(pd,{gap:"sm",children:e.map((e,r)=>/* @__PURE__ */m(od,{elevation:"card",shape:"theme",size:"sm",variant:"chip",full:!0,onClick:n=>t(e,n),style:{color:n.widget_text_color,paddingTop:"8px",paddingBottom:"8px"},children:/* @__PURE__ */m(gd,{as:"span",weight:"normal",leading:"tight",children:"show"===e.type?/* @__PURE__ */g(f,{children:["Show me ",e.text.replace(/^Show me\s*/i,"")]}):"do"===e.type?/* @__PURE__ */g(f,{children:["Do ",e.text.replace(/^Do\s*/i,"")]}):e.text})},`welcome-chip-${e.id}-${r}`))})},Hh=({config:e,messages:t,onNavigateToChat:n,onChipClick:r})=>{const o=function(e){const t=e.widget_chips;if(t&&Array.isArray(t)&&t.length>0){const e=/* @__PURE__ */new Set;return t.map((t,n)=>{const r=t.chip_text,o=t.chip_mode,i=`chip-${r.replace(/\s+/g,"-").toLowerCase()}-${n}`;let s=i,a=0;for(;e.has(s);)a++,s=`${i}-${a}`;return e.add(s),{id:s,text:r,icon:Wh(o),type:o,isShow:"show"===o}})}return Uh}(e);/* @__PURE__ */
47
47
  return g(pd,{height:"full",overflow:"hidden",id:"view-home",role:"tabpanel","aria-labelledby":"tab-home",children:[/* @__PURE__ */g(pd,{grow:!0,overflowY:"auto",padding:"lg",children:[/* @__PURE__ */g(Qc,{style:{textAlign:"center",paddingTop:"8px",paddingBottom:"16px"},children:[/* @__PURE__ */m(gd,{as:"h2",size:"lg",weight:"semibold",children:e.widget_greeting??"Hey There!"}),/* @__PURE__ */m(gd,{as:"p",variant:"muted",size:"sm",style:{marginTop:"2px"},children:e.widget_body??"How can I help you today?"})]}),/* @__PURE__ */g(pd,{gap:"sm",children:[/* @__PURE__ */g(od,{type:"button",variant:"primary",full:!0,onClick:n,"aria-label":"Ask a question",style:{paddingTop:"10px",paddingBottom:"10px"},children:[/* @__PURE__ */m(ad,{name:"chat",size:16}),"Ask a question"]}),/* @__PURE__ */m(Bh,{actions:o,onActionClick:async(e,t)=>{t.preventDefault(),t.stopPropagation(),n(),r(e)}})]})]}),t.length>0&&/* @__PURE__ */g(Qc,{background:"card",border:!0,elevation:"card",paddingPreset:"card",radius:"xl",style:{margin:"0 12px 12px 12px"},children:[
48
48
  /* @__PURE__ */m(gd,{as:"p",size:"xs",weight:"semibold",style:{marginBottom:"2px"},children:"Recent conversation"}),
49
49
  /* @__PURE__ */m(gd,{as:"p",size:"xs",variant:"muted",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:t[t.length-1].content||"Message"}),
50
50
  /* @__PURE__ */m(gd,{as:"p",size:"xs",variant:"muted",onClick:n,style:{marginTop:"4px",cursor:"pointer"},children:"Continue conversation →"})]})]})},qh=["top-left","top-right","bottom-left","bottom-right"];function Zh(e){const t=e.startsWith("top"),n=e.endsWith("left");return{position:"absolute",width:"20px",height:"20px",padding:"4px",touchAction:"none",zIndex:10,display:"flex",alignItems:t?"flex-start":"flex-end",justifyContent:n?"flex-start":"flex-end",cursor:t&&n||!t&&!n?"nwse-resize":"nesw-resize",top:t?0:void 0,bottom:t?void 0:0,left:n?0:void 0,right:n?void 0:0}}var Vh,Gh=({onResizeStart:e})=>/* @__PURE__ */m(f,{children:qh.map(t=>/* @__PURE__ */m("div",{role:"separator","aria-label":`Resize widget from ${t.replace("-"," ")}`,title:"Drag to resize",style:Zh(t),onMouseDown:e(t)},t))}),Yh=[{id:"home",icon:"home",label:"Home"},{id:"chat",icon:"chat",label:"Chat"}],Kh=({activeView:e,onChange:t})=>/* @__PURE__ */m(id,{role:"tablist",align:"center",justify:"around",shrink:!1,border:"top",style:Hc.tabBar,children:Yh.map(n=>{const r=e===n.id;/* @__PURE__ */
51
51
  return g(od,{role:"tab","aria-selected":r,"aria-controls":`view-${n.id}`,id:`tab-${n.id}`,onClick:()=>t(n.id),active:r,stacked:!0,variant:"tab",children:[r&&/* @__PURE__ */m(gd,{as:"span",inheritColor:!0,style:{position:"absolute",top:0,left:"25%",right:"25%"},children:/* @__PURE__ */m("span",{className:"block h-0.5 w-full rounded-full bg-primary"})}),
52
52
  /* @__PURE__ */m(gd,{as:"span",inheritColor:!0,"aria-hidden":"true",children:/* @__PURE__ */m(ad,{name:n.icon,size:20})}),
53
- /* @__PURE__ */m(gd,{as:"span",size:"xs",align:"center",inheritColor:!0,truncate:!0,block:!0,children:n.label})]},n.id)})}),Jh=({config:e,isOpen:t,isMinimized:n,messages:r,currentMode:o,isTaskRunning:s=!1,activeView:c,onClose:p,onSendMessage:h,onSetMode:y,onAddMessage:b,onUpdateMessage:w,onRemoveMessage:v,onStopTask:x,onClearChat:k,onScreenSharingChange:_,setActiveView:S})=>{const{config:I,isPreviewMode:C}=ba({config:e}),E=l(()=>e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default"),[e.mtxId,e.mtxApp]),{widthPx:T,heightPx:M,onResizeStart:z,containerRef:O}=function(e,t,n,r,o){const s=l(()=>`marketrix_widget_size_${n}`,[n]),a=d({width:360,height:450}),c=d(null),[p,h]=u(()=>{if("undefined"==typeof localStorage)return{width:Cd(e),height:Cd(t)};const n=localStorage.getItem(s);if(n)try{const e=JSON.parse(n);if("number"==typeof e.width&&"number"==typeof e.height){const t=Ed(e.width,280,600),n=Ed(e.height,320,Math.floor(.85*window.innerHeight));return a.current={width:t,height:n},{width:t,height:n}}}catch{}const r=Cd(e),o=Cd(t);return a.current={width:r,height:o},{width:r,height:o}});a.current=p;const f=i(e=>t=>{if(t.preventDefault(),t.stopPropagation(),r||o)return;const n=t.clientX,i=t.clientY,l=a.current.width,d=a.current.height,{cursor:u}=Td(e,n,i,n,i);c.current&&(c.current.dataset.resizing="true");const p=t=>{const{dx:r,dy:o}=Td(e,n,i,t.clientX,t.clientY),s=Math.floor(.85*window.innerHeight),u={width:Ed(l+r,280,600),height:Ed(d+o,320,s)};a.current=u,c.current&&(c.current.style.width=`${u.width}px`,c.current.style.height=`${u.height}px`)},f=()=>{if(document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",f),document.body.style.cursor="",document.body.style.userSelect="",c.current&&delete c.current.dataset.resizing,h({...a.current}),!o&&"undefined"!=typeof localStorage){const{width:e,height:t}=a.current;localStorage.setItem(s,JSON.stringify({width:e,height:t}))}};document.body.style.cursor=u,document.body.style.userSelect="none",document.addEventListener("mousemove",p),document.addEventListener("mouseup",f)},[r,o,s]);return{width:p.width,height:p.height,widthPx:`${p.width}px`,heightPx:`${p.height}px`,onResizeStart:f,containerRef:c}}(I.widget_width,I.widget_height,E,n,C),R=d(null),[A,N]=u("forward"),P=d(c);a(()=>{P.current!==c&&(N("chat"===c?"forward":"back"),P.current=c)},[c]),function(e,t,n){const r=d(!1),o=d(null),s=i(()=>{const t=e.current;if(!t)return;const r=n?.focusTargetRef?.current;if(r)return void r.focus({preventScroll:!0});const o=Id(t);o[0]&&o[0].focus({preventScroll:!0})},[e,n?.focusTargetRef]);a(()=>{if(!t)return r.current&&(o.current?.focus({preventScroll:!0}),o.current=null),void(r.current=!1);r.current||(o.current=document.activeElement||null),r.current=!0;const i=e.current;if(!i)return;s();const a=e=>{if("Escape"===e.key)return void n?.onEscape?.();if("Tab"!==e.key)return;const t=Id(i);if(0===t.length)return;const r=document.activeElement,o=t.indexOf(r);-1!==o&&(e.shiftKey?0===o&&(e.preventDefault(),t[t.length-1].focus()):o===t.length-1&&(e.preventDefault(),t[0].focus()))};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[t,e,s,n?.onEscape])}(O,t,{onEscape:p,focusTargetRef:"chat"===c?R:void 0});const L=I.widget_position,$=I.widget_position_z_index??40,D=(e=>{const t="20px",n="20px";switch(e){case"bottom_right":default:return{bottom:t,right:n};case"bottom_left":return{bottom:t,left:n};case"top_right":return{top:t,right:n};case"top_left":return{top:t,left:n}}})(L),[F,j]=u(!1),U=d(null),W=d(null),B=i(e=>{j(e),_?.(e)},[_]);if(!t)return null;const H=I.widget_background_color.includes("gradient")?I.widget_background_color:`linear-gradient(135deg, ${I.widget_background_color} 0%, ${I.widget_background_color} 100%)`,q={width:T,height:n?"48px":M,fontSize:I.widget_font_size,backgroundImage:H,zIndex:$},Z=C?"absolute":"fixed",V=C?L.includes("top")?{top:"20px",...L.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...L.includes("right")?{right:"20px"}:{left:"20px"}}:{},G=`${L.includes("top")?"top":"bottom"} ${L.includes("right")?"right":"left"}`,Y="chat"===c&&!1!==e.use_screenshare?()=>{F?W.current?.():U.current?.()}:void 0;/* @__PURE__ */
53
+ /* @__PURE__ */m(gd,{as:"span",size:"xs",align:"center",inheritColor:!0,truncate:!0,block:!0,children:n.label})]},n.id)})}),Jh=({config:e,isOpen:t,isMinimized:n,messages:r,currentMode:o,isTaskRunning:s=!1,activeView:c,onClose:p,onSendMessage:h,onSetMode:y,onAddMessage:b,onUpdateMessage:w,onRemoveMessage:v,onStopTask:x,onClearChat:k,onScreenSharingChange:S,setActiveView:_})=>{const{config:I,isPreviewMode:C}=ba({config:e}),E=l(()=>e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default"),[e.mtxId,e.mtxApp]),{widthPx:T,heightPx:M,onResizeStart:z,containerRef:O}=function(e,t,n,r,o){const s=l(()=>`marketrix_widget_size_${n}`,[n]),a=d({width:360,height:450}),c=d(null),[p,h]=u(()=>{if("undefined"==typeof localStorage)return{width:Cd(e),height:Cd(t)};const n=localStorage.getItem(s);if(n)try{const e=JSON.parse(n);if("number"==typeof e.width&&"number"==typeof e.height){const t=Ed(e.width,280,600),n=Ed(e.height,320,Math.floor(.85*window.innerHeight));return a.current={width:t,height:n},{width:t,height:n}}}catch{}const r=Cd(e),o=Cd(t);return a.current={width:r,height:o},{width:r,height:o}});a.current=p;const f=i(e=>t=>{if(t.preventDefault(),t.stopPropagation(),r||o)return;const n=t.clientX,i=t.clientY,l=a.current.width,d=a.current.height,{cursor:u}=Td(e,n,i,n,i);c.current&&(c.current.dataset.resizing="true");const p=t=>{const{dx:r,dy:o}=Td(e,n,i,t.clientX,t.clientY),s=Math.floor(.85*window.innerHeight),u={width:Ed(l+r,280,600),height:Ed(d+o,320,s)};a.current=u,c.current&&(c.current.style.width=`${u.width}px`,c.current.style.height=`${u.height}px`)},f=()=>{if(document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",f),document.body.style.cursor="",document.body.style.userSelect="",c.current&&delete c.current.dataset.resizing,h({...a.current}),!o&&"undefined"!=typeof localStorage){const{width:e,height:t}=a.current;localStorage.setItem(s,JSON.stringify({width:e,height:t}))}};document.body.style.cursor=u,document.body.style.userSelect="none",document.addEventListener("mousemove",p),document.addEventListener("mouseup",f)},[r,o,s]);return{width:p.width,height:p.height,widthPx:`${p.width}px`,heightPx:`${p.height}px`,onResizeStart:f,containerRef:c}}(I.widget_width,I.widget_height,E,n,C),R=d(null),[A,N]=u("forward"),P=d(c);a(()=>{P.current!==c&&(N("chat"===c?"forward":"back"),P.current=c)},[c]),function(e,t,n){const r=d(!1),o=d(null),s=i(()=>{const t=e.current;if(!t)return;const r=n?.focusTargetRef?.current;if(r)return void r.focus({preventScroll:!0});const o=Id(t);o[0]&&o[0].focus({preventScroll:!0})},[e,n?.focusTargetRef]);a(()=>{if(!t)return r.current&&(o.current?.focus({preventScroll:!0}),o.current=null),void(r.current=!1);r.current||(o.current=document.activeElement||null),r.current=!0;const i=e.current;if(!i)return;s();const a=e=>{if("Escape"===e.key)return void n?.onEscape?.();if("Tab"!==e.key)return;const t=Id(i);if(0===t.length)return;const r=document.activeElement,o=t.indexOf(r);-1!==o&&(e.shiftKey?0===o&&(e.preventDefault(),t[t.length-1].focus()):o===t.length-1&&(e.preventDefault(),t[0].focus()))};return document.addEventListener("keydown",a,!0),()=>document.removeEventListener("keydown",a,!0)},[t,e,s,n?.onEscape])}(O,t,{onEscape:p,focusTargetRef:"chat"===c?R:void 0});const L=I.widget_position,$=I.widget_position_z_index??40,D=(e=>{const t="20px",n="20px";switch(e){case"bottom_right":default:return{bottom:t,right:n};case"bottom_left":return{bottom:t,left:n};case"top_right":return{top:t,right:n};case"top_left":return{top:t,left:n}}})(L),[F,j]=u(!1),U=d(null),W=d(null),B=i(e=>{j(e),S?.(e)},[S]);if(!t)return null;const H=I.widget_background_color.includes("gradient")?I.widget_background_color:`linear-gradient(135deg, ${I.widget_background_color} 0%, ${I.widget_background_color} 100%)`,q={width:T,height:n?"48px":M,fontSize:I.widget_font_size,backgroundImage:H,zIndex:$},Z=C?"absolute":"fixed",V=C?L.includes("top")?{top:"20px",...L.includes("right")?{right:"20px"}:{left:"20px"}}:{bottom:"20px",...L.includes("right")?{right:"20px"}:{left:"20px"}}:{},G=`${L.includes("top")?"top":"bottom"} ${L.includes("right")?"right":"left"}`,Y="chat"===c&&!1!==e.use_screenshare?()=>{F?W.current?.():U.current?.()}:void 0;/* @__PURE__ */
54
54
  return g(pd,{ref:O,position:Z,rounded:"theme",border:!0,overflow:"hidden",style:{zIndex:$,backgroundImage:H,transformOrigin:G,...q,...C?V:D,pointerEvents:"auto",scrollbarWidth:"thin",animation:"messenger-entrance 300ms cubic-bezier(0, 1.2, 1, 1)",boxShadow:jc.panel},children:[
55
- /* @__PURE__ */m(Md,{title:e.widget_header??"AI Agent",subtitle:n?void 0:e.widget_body??"How can I help?",minimized:n,onClose:p,controls:Y&&/* @__PURE__ */g(ud,{variant:"ghost",size:"sm",label:F?"Stop screen sharing":"Start screen sharing",onClick:Y,children:[F&&/* @__PURE__ */g("span",{className:"absolute top-0.5 right-0.5 inline-flex h-1.5 w-1.5",children:[/* @__PURE__ */m("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-75"}),/* @__PURE__ */m("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-current"})]}),/* @__PURE__ */m(ad,{name:"screenShare",size:16})]})}),!n&&/* @__PURE__ */g(f,{children:[/* @__PURE__ */m(Qc,{grow:!0,overflow:"hidden",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */g(Qc,{"data-view-transition":!0,"data-direction":A,style:{width:"100%",height:"100%"},children:["home"===c&&/* @__PURE__ */m(Hh,{config:e,messages:r,onNavigateToChat:()=>{N("forward"),S("chat")},onChipClick:e=>{b(Bs(e.text,e.type,"chip-message")),y(e.type),h(e.text,e.type,void 0,void 0,!0)}}),"chat"===c&&/* @__PURE__ */m(jh,{config:e,messages:r,currentMode:o,isTaskRunning:s,onSendMessage:h,onSetMode:y,onAddMessage:b,onUpdateMessage:w,onRemoveMessage:v,onStopTask:x,onClearChat:k,onScreenSharingChange:B,onStartScreenShareRef:U,onStopScreenShareRef:W,messageInputRef:R})]},c)}),/* @__PURE__ */m(Kh,{activeView:c,onChange:S})]}),!n&&!C&&/* @__PURE__ */m(Gh,{onResizeStart:z})]})},Xh=class extends t.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){}render(){return this.state.hasError?null:this.props.children}},Qh=({config:e})=>{const[t,n]=u(!1),{state:r,actions:o,config:i,shouldShow:s,isPreviewMode:c,configValid:d}=ba({config:e});var p;p=r.isOpen,a(()=>{if(!p)return;if(!window.matchMedia("(max-width: 767px)").matches)return;const e=document.documentElement,t=document.body,n=e.style.overflow,r=t.style.overflow;return e.style.overflow="hidden",t.style.overflow="hidden",()=>{e.style.overflow=n,t.style.overflow=r}},[p]);const[h,f]=u(e.widget_position??"bottom_right"),y=l(()=>`marketrix_widget_position_${e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default")}`,[e.mtxApp,e.mtxId]);a(()=>{const e=i.widget_position??"bottom_right";f(e)},[i.widget_position]),a(()=>{if(c||"undefined"==typeof localStorage)return;const e=i.widget_position??"bottom_right",t=localStorage.getItem(y);"bottom_left"!==t&&"bottom_right"!==t&&"top_left"!==t&&"top_right"!==t?(localStorage.setItem(y,e),f(e)):f(t)},[c,y,i.widget_position]),a(()=>{if(r.isOpen||c||"default"!==i.widget_appearance||!i.widget_greeting_toast)return void n(!1);const e=setTimeout(()=>n(!0),2e3);return()=>clearTimeout(e)},[r.isOpen,c,i.widget_appearance,i.widget_greeting_toast]);if(!d)return null;if(!(c||s&&i.widget_enabled&&!1!==e.show_widget&&"hidden"!==i.widget_appearance))return null;const v=T(i),x={"--background":(I=v).color.background,"--foreground":I.color.foreground,"--card":I.color.background,"--card-foreground":I.color.foreground,"--popover":I.color.background,"--popover-foreground":I.color.foreground,"--primary":I.color.primary,"--foreground-muted":I.color.foregroundMuted,"--foreground-faint":I.color.foregroundFaint,"--border-muted":I.color.borderMuted,"--primary-foreground":I.color.primaryForeground,"--primary-hover":I.color.primaryHover,"--primary-muted":I.color.primaryMuted,"--secondary":I.color.secondary,"--secondary-foreground":I.color.secondaryForeground,"--secondary-bg":I.color.secondaryBg,"--secondary-hover":I.color.secondaryHover,"--muted":I.color.border,"--muted-foreground":I.color.secondary,"--accent":I.color.background,"--accent-foreground":I.color.foreground,"--border":I.color.border,"--input":I.color.border,"--ring":I.color.primary,"--radius":I.radius,"--shadow":I.shadow,"--duration-animation":I.motion.durationAnimation,"--duration-fade":I.motion.durationFade,"--widget-width":I.size.widgetWidth,"--widget-height":I.size.widgetHeight};var I;const C=Math.max(i.widget_position_z_index??0,b),E={...i,widget_position:h,widget_position_z_index:C,show_widget:e.show_widget,use_screenshare:e.use_screenshare},M=r.isLoading||r.isTaskRunning,z={...x,"--widget-z-index":C};/* @__PURE__ */
56
- return g(Qc,{"data-marketrix-widget":!0,position:"relative",style:{...z,...c&&{width:"100%",height:"100%"}},"data-widget-mode":i?.widget_feature_human?"hybrid":"ai",children:[M&&/* @__PURE__ */m(Qc,{"data-screen-edge-glow":!0,position:"fixed",inset:"0",style:{boxShadow:`inset 0 0 22px 2px ${_(i.widget_accent_color,.72)}, inset 0 0 46px 10px ${_(i.widget_accent_color,.28)}`,pointerEvents:"none",zIndex:w}}),
55
+ /* @__PURE__ */m(Md,{title:e.widget_header??"AI Agent",subtitle:n?void 0:e.widget_body??"How can I help?",minimized:n,onClose:p,controls:Y&&/* @__PURE__ */g(ud,{variant:"ghost",size:"sm",label:F?"Stop screen sharing":"Start screen sharing",onClick:Y,children:[F&&/* @__PURE__ */g("span",{className:"absolute top-0.5 right-0.5 inline-flex h-1.5 w-1.5",children:[/* @__PURE__ */m("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-75"}),/* @__PURE__ */m("span",{className:"relative inline-flex h-1.5 w-1.5 rounded-full bg-current"})]}),/* @__PURE__ */m(ad,{name:"screenShare",size:16})]})}),!n&&/* @__PURE__ */g(f,{children:[/* @__PURE__ */m(Qc,{grow:!0,overflow:"hidden",style:{display:"flex",flexDirection:"column",minHeight:0},children:/* @__PURE__ */g(Qc,{"data-view-transition":!0,"data-direction":A,style:{width:"100%",height:"100%"},children:["home"===c&&/* @__PURE__ */m(Hh,{config:e,messages:r,onNavigateToChat:()=>{N("forward"),_("chat")},onChipClick:e=>{b(Bs(e.text,e.type,"chip-message")),y(e.type),h(e.text,e.type,void 0,void 0,!0)}}),"chat"===c&&/* @__PURE__ */m(jh,{config:e,messages:r,currentMode:o,isTaskRunning:s,onSendMessage:h,onSetMode:y,onAddMessage:b,onUpdateMessage:w,onRemoveMessage:v,onStopTask:x,onClearChat:k,onScreenSharingChange:B,onStartScreenShareRef:U,onStopScreenShareRef:W,messageInputRef:R})]},c)}),/* @__PURE__ */m(Kh,{activeView:c,onChange:_})]}),!n&&!C&&/* @__PURE__ */m(Gh,{onResizeStart:z})]})},Xh=class extends t.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){}render(){return this.state.hasError?null:this.props.children}},Qh=({config:e})=>{const[t,n]=u(!1),{state:r,actions:o,config:i,shouldShow:s,isPreviewMode:c,configValid:d}=ba({config:e});var p;p=r.isOpen,a(()=>{if(!p)return;if(!window.matchMedia("(max-width: 767px)").matches)return;const e=document.documentElement,t=document.body,n=e.style.overflow,r=t.style.overflow;return e.style.overflow="hidden",t.style.overflow="hidden",()=>{e.style.overflow=n,t.style.overflow=r}},[p]);const[h,f]=u(e.widget_position??"bottom_right"),y=l(()=>`marketrix_widget_position_${e.mtxId??(null!=e.mtxApp?String(e.mtxApp):"default")}`,[e.mtxApp,e.mtxId]);a(()=>{const e=i.widget_position??"bottom_right";f(e)},[i.widget_position]),a(()=>{if(c||"undefined"==typeof localStorage)return;const e=i.widget_position??"bottom_right",t=localStorage.getItem(y);"bottom_left"!==t&&"bottom_right"!==t&&"top_left"!==t&&"top_right"!==t?(localStorage.setItem(y,e),f(e)):f(t)},[c,y,i.widget_position]),a(()=>{if(r.isOpen||c||"default"!==i.widget_appearance||!i.widget_greeting_toast)return void n(!1);const e=setTimeout(()=>n(!0),2e3);return()=>clearTimeout(e)},[r.isOpen,c,i.widget_appearance,i.widget_greeting_toast]);if(!d)return null;if(!(c||s&&i.widget_enabled&&!1!==e.show_widget&&"hidden"!==i.widget_appearance))return null;const v=T(i),x={"--background":(I=v).color.background,"--foreground":I.color.foreground,"--card":I.color.background,"--card-foreground":I.color.foreground,"--popover":I.color.background,"--popover-foreground":I.color.foreground,"--primary":I.color.primary,"--foreground-muted":I.color.foregroundMuted,"--foreground-faint":I.color.foregroundFaint,"--border-muted":I.color.borderMuted,"--primary-foreground":I.color.primaryForeground,"--primary-hover":I.color.primaryHover,"--primary-muted":I.color.primaryMuted,"--secondary":I.color.secondary,"--secondary-foreground":I.color.secondaryForeground,"--secondary-bg":I.color.secondaryBg,"--secondary-hover":I.color.secondaryHover,"--muted":I.color.border,"--muted-foreground":I.color.secondary,"--accent":I.color.background,"--accent-foreground":I.color.foreground,"--border":I.color.border,"--input":I.color.border,"--ring":I.color.primary,"--radius":I.radius,"--shadow":I.shadow,"--duration-animation":I.motion.durationAnimation,"--duration-fade":I.motion.durationFade,"--widget-width":I.size.widgetWidth,"--widget-height":I.size.widgetHeight};var I;const C=Math.max(i.widget_position_z_index??0,b),E={...i,widget_position:h,widget_position_z_index:C,show_widget:e.show_widget,use_screenshare:e.use_screenshare},M=r.isLoading||r.isTaskRunning,z={...x,"--widget-z-index":C};/* @__PURE__ */
56
+ return g(Qc,{"data-marketrix-widget":!0,position:"relative",style:{...z,...c&&{width:"100%",height:"100%"}},"data-widget-mode":i?.widget_feature_human?"hybrid":"ai",children:[M&&/* @__PURE__ */m(Qc,{"data-screen-edge-glow":!0,position:"fixed",inset:"0",style:{boxShadow:`inset 0 0 22px 2px ${S(i.widget_accent_color,.72)}, inset 0 0 46px 10px ${S(i.widget_accent_color,.28)}`,pointerEvents:"none",zIndex:w}}),
57
57
  /* @__PURE__ */m(Xh,{children:/* @__PURE__ */m(Jh,{config:E,isOpen:r.isOpen,isMinimized:r.isMinimized,messages:r.messages,currentMode:r.currentMode,isTaskRunning:r.isTaskRunning,activeView:r.activeView,onClose:o.closeWidget,onSendMessage:o.messageDispatch,onSetMode:o.setMode,onAddMessage:o.addMessage,onUpdateMessage:o.updateMessage,onRemoveMessage:o.removeMessage,onStopTask:o.stopTask,onClearChat:o.clearChatHistory,setActiveView:o.setActiveView})}),
58
- /* @__PURE__ */m(Sd,{open:r.isOpen,processing:r.isLoading,error:!!r.error,taskRunning:r.isTaskRunning,onClick:o.toggleWidget,onStop:o.stopTask,accentColor:E.widget_accent_color,backgroundColor:E.widget_background_color,borderRadius:E.widget_border_radius,tooltipBgColor:S(E.widget_accent_color,.3),tooltipTextColor:k(S(E.widget_accent_color,.3)),zIndex:E.widget_position_z_index??50,position:h,onDrag:e=>{f(e),c||"undefined"==typeof localStorage||localStorage.setItem(y,e)},isPreviewMode:c}),r.error&&/* @__PURE__ */m(bd,{tone:"error",title:r.error,onDismiss:()=>o.clearError(),onRetry:()=>o.clearError(),position:h.includes("top")?"bottom-center":"above-fab"}),t&&!r.error&&i.widget_greeting&&/* @__PURE__ */m(bd,{tone:"info",title:i.widget_greeting,body:i.widget_body,onDismiss:()=>n(!1),position:"bottom-center"})]})},ef=Object.defineProperty,tf=(e,t,n)=>((e,t,n)=>t in e?ef(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),nf=/* @__PURE__ */(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e[e.Asset=7]="Asset",e))(nf||{}),rf=/* @__PURE__ */(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(rf||{}),of=/* @__PURE__ */(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(of||{}),sf=/* @__PURE__ */(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(sf||{}),af=/* @__PURE__ */(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(af||{}),cf=/* @__PURE__ */(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(cf||{}),lf=/* @__PURE__ */(e=>(e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e))(lf||{}),df={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},uf={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},pf={},hf={};function ff(e){if(pf[e])return pf[e];const t=globalThis[e],n=t.prototype,r=e in df?df[e]:void 0,o=Boolean(r&&r.every(e=>{var t,r;return Boolean(null==(r=null==(t=Object.getOwnPropertyDescriptor(n,e))?void 0:t.get)?void 0:r.toString().includes("[native code]"))})),i=e in uf?uf[e]:void 0,s=Boolean(i&&i.every(e=>{var t;return"function"==typeof n[e]&&(null==(t=n[e])?void 0:t.toString().includes("[native code]"))}));if(o&&s&&!globalThis.Zone)return pf[e]=t.prototype,t.prototype;try{const r=document.createElement("iframe");r.style.display="none",document.body.appendChild(r);const o=r.contentWindow;if(!o)return t.prototype;const i=o[e].prototype;if(!i)return r.remove(),n;const s=navigator.userAgent;return s.includes("Safari")&&!s.includes("Chrome")?(r.classList.add("rr-block"),r.setAttribute("__rrwebUntaintedMutationObserver",""),hf[e]=()=>r.remove()):r.remove(),pf[e]=i}catch{return n}}var mf={};function gf(e,t,n){var r;const o=`${e}.${String(n)}`;if(mf[o])return mf[o].call(t);const i=ff(e),s=null==(r=Object.getOwnPropertyDescriptor(i,n))?void 0:r.get;return s?(mf[o]=s,s.call(t)):t[n]}var yf={};function bf(e,t,n){const r=`${e}.${String(n)}`;if(yf[r])return yf[r].bind(t);const o=ff(e)[n];return"function"!=typeof o?t[n]:(yf[r]=o,o.bind(t))}function wf(){return[ff("MutationObserver").constructor,hf.MutationObserver??(()=>{})]}var vf=Date.now;function xf(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch{return()=>{}}}/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())||(vf=()=>/* @__PURE__ */(new Date).getTime());var kf={ownerDocument:function(e){return gf("Node",e,"ownerDocument")},childNodes:function(e){return gf("Node",e,"childNodes")},parentNode:function(e){return gf("Node",e,"parentNode")},parentElement:function(e){return gf("Node",e,"parentElement")},textContent:function(e){return gf("Node",e,"textContent")},contains:function(e,t){return bf("Node",e,"contains")(t)},getRootNode:function(e){return bf("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?gf("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?gf("Element",e,"shadowRoot"):null},querySelector:function(e,t){return gf("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return gf("Element",e,"querySelectorAll")(t)},nowTimestamp:vf,mutationObserverCtor:wf,patch:xf};function _f(e){return e.nodeType===e.ELEMENT_NODE}function Sf(e){const t=e&&"host"in e&&"mode"in e&&kf.host(e)||null;return Boolean(t&&"shadowRoot"in t&&kf.shadowRoot(t)===e)}function If(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function Cf(e){try{const n=e.rules||e.cssRules;if(!n)return null;let r=e.href;return!r&&e.ownerNode&&(r=e.ownerNode.baseURI),(t=Array.from(n,e=>Ef(e,r)).join("")).includes(" background-clip: text;")&&!t.includes(" -webkit-background-clip: text;")&&(t=t.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),t}catch(n){return null}var t}function Ef(e,t){if(function(e){return"styleSheet"in e}(e)){let t;try{t=Cf(e.styleSheet)||function(e){const{cssText:t}=e;if(t.split('"').length<3)return t;const n=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?n.push("layer"):e.layerName&&n.push(`layer(${e.layerName})`),e.supportsText&&n.push(`supports(${e.supportsText})`),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}(e)}catch(n){t=e.cssText}return e.styleSheet.href?Df(t,e.styleSheet.href):t}{let n=e.cssText;return function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":")&&(n=n.replace(/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,"$1\\$2")),t?Df(n,t):n}}var Tf=class{constructor(){tf(this,"idNodeMap",/* @__PURE__ */new Map),tf(this,"nodeMetaMap",/* @__PURE__ */new WeakMap)}getId(e){var t;return e?(null==(t=this.getMeta(e))?void 0:t.id)??-1:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){const n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)}replace(e,t){const n=this.getNode(e);if(n){const e=this.nodeMetaMap.get(n);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=/* @__PURE__ */new Map,this.nodeMetaMap=/* @__PURE__ */new WeakMap}};function Mf({element:e,maskInputOptions:t,tagName:n,type:r,value:o,maskInputFn:i}){let s=o||"";const a=r&&zf(r);return(t[n.toLowerCase()]||a&&t[a])&&(s=i?i(s,e):"*".repeat(s.length)),s}function zf(e){return e.toLowerCase()}var Of="__rrweb_original__";function Rf(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?zf(t):null}function Af(e,t){let n;try{n=new URL(e,t??window.location.href)}catch(o){return null}const r=n.pathname.match(/\.([0-9a-z]+)(?:$)/i);return(null==r?void 0:r[1])??null}var Nf=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Pf=/^(?:[a-z+]+:)?\/\//i,Lf=/^www\..*/i,$f=/^(data:)([^,]*),(.*)/i;function Df(e,t){return(e||"").replace(Nf,(e,n,r,o,i,s)=>{const a=r||i||s,c=n||o||"";if(!a)return e;if(Pf.test(a)||Lf.test(a))return`url(${c}${a}${c})`;if($f.test(a))return`url(${c}${a}${c})`;if("/"===a[0])return`url(${c}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${c})`;const l=a.split("#")[0],d=a.substring(l.length),u=t.split("#")[0].split("/"),p=l.split("/");u.pop();for(const t of p){if("."===t)continue;".."===t?u.pop():u.push(t)}return`url(${c}${u.join("/")}${d}${c})`})}function Ff(e,t=!1){return t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}function jf(e,t){return function(e,t,n=!1){const r=Array.from(t.childNodes),o=[];let i=0;if(r.length>1&&e&&"string"==typeof e){let t=Ff(e,n);const s=t.length/e.length;for(let a=1;a<r.length;a++)if(r[a].textContent&&"string"==typeof r[a].textContent){const c=Ff(r[a].textContent,n),l=100;let d=3;for(;d<c.length&&(c[d].match(/[a-zA-Z0-9]/)||-1!==c.indexOf(c.substring(0,d),1));d++);for(;d<c.length;d++){let u=c.substring(0,d),p=t.split(u),h=-1;if(2===p.length)h=p[0].length;else if(p.length>2&&""===p[0]&&""!==r[a-1].textContent)h=t.indexOf(u,1);else if(1===p.length){if(u=u.substring(0,u.length-1),p=t.split(u),p.length<=1)return o.push(e),o;d=101}else d===c.length-1&&(h=t.indexOf(u));if(p.length>=2&&d>l){const e=r[a-1].textContent;if(e&&"string"==typeof e){const n=Ff(e).length;h=t.indexOf(u,n)}-1===h&&(h=p[0].length)}if(-1!==h){let a=Math.floor(h/s);for(;a>0&&a<e.length;){if(i+=1,i>50*r.length)return o.push(e),o;const c=Ff(e.substring(0,a),n);if(c.length===h){o.push(e.substring(0,a)),e=e.substring(a),t=t.substring(h);break}c.length<h?a+=Math.max(1,Math.floor((h-c.length)/s)):a-=Math.max(1,Math.floor((c.length-h)*s))}break}}}}return o.push(e),o}(e,t).join("/* rr_split */")}var Uf,Wf,Bf=1,Hf=/* @__PURE__ */new RegExp("[^a-z0-9-_:]");function qf(){return Bf++}var Zf=/^[^ \t\n\r\u000c]+/,Vf=/^[, \t\n\r\u000c]+/;var Gf=/* @__PURE__ */new WeakMap;function Yf(e,t){return t&&""!==t.trim()?Jf(e,t):t}function Kf(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function Jf(e,t){let n=Gf.get(e);if(n||(n=e.createElement("a"),Gf.set(e,n)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return n.setAttribute("href",t),n.href}function Xf(e,t,n,r){return r?"src"===n||"href"===n&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&"#"!==r[0]||"background"===n&&["table","td","th"].includes(t)?Yf(e,r):"srcset"===n?function(e,t){if(""===t.trim())return t;let n=0;function r(e){let r;const o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}const o=[];for(;r(Vf),!(n>=t.length);){let i=r(Zf);if(","===i.slice(-1))i=Yf(e,i.substring(0,i.length-1)),o.push(i);else{let r="";i=Yf(e,i);let s=!1;for(;;){const e=t.charAt(n);if(""===e){o.push((i+r).trim());break}if(s)")"===e&&(s=!1);else{if(","===e){n+=1,o.push((i+r).trim());break}"("===e&&(s=!0)}r+=e,n+=1}}}return o.join(", ")}(e,r):"style"===n?Df(r,Jf(e)):"object"===t&&"data"===n?Yf(e,r):r:r}function Qf(e,t,n){return["video","audio"].includes(e)&&"autoplay"===t}function em(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&em(kf.parentNode(e),t,n);for(let r=e.classList.length;r--;){const n=e.classList[r];if(t.test(n))return!0}return!!n&&em(kf.parentNode(e),t,n)}function tm(e,t,n,r){let o;if(_f(e)){if(o=e,!kf.childNodes(o).length)return!1}else{if(null===kf.parentElement(e))return!1;o=kf.parentElement(e)}try{if("string"==typeof t){if(r){if(o.closest(`.${t}`))return!0}else if(o.classList.contains(t))return!0}else if(em(o,t,r))return!0;if(n)if(r){if(o.closest(n))return!0}else if(o.matches(n))return!0}catch(i){}return!1}function nm(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:s,inlineStylesheet:a,maskInputOptions:c={},maskTextFn:l,maskInputFn:d,dataURLOptions:u={},inlineImages:p,recordCanvas:h,keepIframeSrcFn:f,newlyAddedElement:m=!1,cssCaptured:g=!1}=t,y=function(e,t){if(!t.hasNode(e))return;const n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:lf.Document,childNodes:[],compatMode:e.compatMode}:{type:lf.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:lf.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:y};case e.ELEMENT_NODE:return function(e,t){const{doc:n,blockClass:r,blockSelector:o,inlineStylesheet:i,maskInputOptions:s={},maskInputFn:a,dataURLOptions:c={},inlineImages:l,recordCanvas:d,keepIframeSrcFn:u,newlyAddedElement:p=!1,rootId:h}=t,f=function(e,t,n){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){const r=e.classList[n];if(t.test(r))return!0}if(n)return e.matches(n)}catch(r){}return!1}(e,r,o),m=function(e){if(e instanceof HTMLFormElement)return"form";const t=zf(e.tagName);return Hf.test(t)?"div":t}(e);let g={};const y=e.attributes.length;for(let v=0;v<y;v++){const t=e.attributes[v];Qf(m,t.name,t.value)||(g[t.name]=Xf(n,m,zf(t.name),t.value))}if("link"===m&&i){const t=Array.from(n.styleSheets).find(t=>t.href===e.href);let r=null;t&&(r=Cf(t)),r&&(delete g.rel,delete g.href,g._cssText=r)}if("style"===m&&e.sheet){let t=Cf(e.sheet);t&&(e.childNodes.length>1&&(t=jf(t,e)),g._cssText=t)}if(["input","textarea","select"].includes(m)){const t=e.value,n=e.checked;"radio"!==g.type&&"checkbox"!==g.type&&"submit"!==g.type&&"button"!==g.type&&t?g.value=Mf({element:e,type:Rf(e),tagName:m,value:t,maskInputOptions:s,maskInputFn:a}):n&&(g.checked=n)}"option"===m&&(e.selected&&!s.select?g.selected=!0:delete g.selected);"dialog"===m&&e.open&&(g.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal");if("canvas"===m&&d)if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let n=0;n<e.width;n+=50)for(let r=0;r<e.height;r+=50){const o=t.getImageData,i=Of in o?o[Of]:o;if(new Uint32Array(i.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some(e=>0!==e))return!1}return!0})(e)||(g.rr_dataURL=e.toDataURL(c.type,c.quality));else if(!("__context"in e)){const t=e.toDataURL(c.type,c.quality),r=n.createElement("canvas");r.width=e.width,r.height=e.height,t!==r.toDataURL(c.type,c.quality)&&(g.rr_dataURL=t)}if("img"===m&&l){Uf||(Uf=n.createElement("canvas"),Wf=Uf.getContext("2d"));const t=e,r=(t.currentSrc||t.getAttribute("src"),t.crossOrigin),o=()=>{t.removeEventListener("load",o);try{Uf.width=t.naturalWidth,Uf.height=t.naturalHeight,Wf.drawImage(t,0,0),g.rr_dataURL=Uf.toDataURL(c.type,c.quality)}catch(e){if("anonymous"!==t.crossOrigin)return t.crossOrigin="anonymous",void(t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o))}"anonymous"===t.crossOrigin&&(r?g.crossOrigin=r:t.removeAttribute("crossorigin"))};t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o)}if(["audio","video"].includes(m)){const t=g;t.rr_mediaState=e.paused?"paused":"played",t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}p||(e.scrollLeft&&(g.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(g.rr_scrollTop=e.scrollTop));if(f){const{width:t,height:n}=e.getBoundingClientRect();g={class:g.class,rr_width:`${t}px`,rr_height:`${n}px`}}"iframe"!==m||u(g.src)||(e.contentDocument||(g.rr_src=g.src),delete g.src);let b;try{customElements.get(m)&&(b=!0)}catch(w){}return{type:lf.Element,tagName:m,attributes:g,childNodes:[],isSVG:Kf(e)||void 0,needBlock:f,rootId:h,isCustom:b}}(e,{doc:n,blockClass:o,blockSelector:i,inlineStylesheet:a,maskInputOptions:c,maskInputFn:d,dataURLOptions:u,inlineImages:p,recordCanvas:h,keepIframeSrcFn:f,newlyAddedElement:m,rootId:y});case e.TEXT_NODE:return function(e,t){const{needsMask:n,maskTextFn:r,rootId:o,cssCaptured:i}=t,s=kf.parentNode(e),a=s&&s.tagName;let c="";const l="STYLE"===a||void 0,d="SCRIPT"===a||void 0;d?c="SCRIPT_PLACEHOLDER":i||(c=kf.textContent(e),l&&c&&(c=Df(c,Jf(t.doc))));!l&&!d&&c&&n&&(c=r?r(c,kf.parentElement(e)):c.replace(/[\S]/g,"*"));return{type:lf.Text,textContent:c||"",rootId:o}}(e,{doc:n,needsMask:s,maskTextFn:l,rootId:y,cssCaptured:g});case e.CDATA_SECTION_NODE:return{type:lf.CDATA,textContent:"",rootId:y};case e.COMMENT_NODE:return{type:lf.Comment,textContent:kf.textContent(e)||"",rootId:y};default:return!1}}function rm(e){return null==e?"":e.toLowerCase()}function om(e){return!0===e||"all"===e?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===e,headMetaDescKeywords:"all"===e,headTitleMutations:"all"===e}:e||{}}function im(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:i,maskTextClass:s,maskTextSelector:a,skipChild:c=!1,inlineStylesheet:l=!0,maskInputOptions:d={},maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f={},inlineImages:m=!1,recordCanvas:g=!1,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:w=5e3,onStylesheetLoad:v,stylesheetLoadTimeout:x=5e3,keepIframeSrcFn:k=()=>!1,newlyAddedElement:_=!1,cssCaptured:S=!1}=t;let{needsMask:I}=t,{preserveWhiteSpace:C=!0}=t;I||(I=tm(e,s,a,void 0===I));const E=nm(e,{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:I,inlineStylesheet:l,maskInputOptions:d,maskTextFn:u,maskInputFn:p,dataURLOptions:f,inlineImages:m,recordCanvas:g,keepIframeSrcFn:k,newlyAddedElement:_,cssCaptured:S});if(!E)return null;let T;T=r.hasNode(e)?r.getId(e):function(e,t){if(t.comment&&e.type===lf.Comment)return!0;if(e.type===lf.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel&&"script"===e.attributes.as||"modulepreload"===e.attributes.rel)||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&"js"===Af(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(rm(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===rm(e.attributes.name)||"icon"===rm(e.attributes.rel)||"apple-touch-icon"===rm(e.attributes.rel)||"shortcut icon"===rm(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&rm(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(rm(e.attributes.property).match(/^(og|twitter|fb):/)||rm(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===rm(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===rm(e.attributes.name)||"googlebot"===rm(e.attributes.name)||"bingbot"===rm(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===rm(e.attributes.name)||"generator"===rm(e.attributes.name)||"framework"===rm(e.attributes.name)||"publisher"===rm(e.attributes.name)||"progid"===rm(e.attributes.name)||rm(e.attributes.property).match(/^article:/)||rm(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===rm(e.attributes.name)||"yandex-verification"===rm(e.attributes.name)||"csrf-token"===rm(e.attributes.name)||"p:domain_verify"===rm(e.attributes.name)||"verify-v1"===rm(e.attributes.name)||"verification"===rm(e.attributes.name)||"shopify-checkout-api-token"===rm(e.attributes.name)))return!0}}return!1}(E,h)||!C&&E.type===lf.Text&&!E.textContent.replace(/^\s+|\s+$/gm,"").length?-2:qf();const M=Object.assign(E,{id:T});if(r.add(e,M),-2===T)return null;y&&y(e);let z=!c;if(M.type===lf.Element){z=z&&!M.needBlock,delete M.needBlock;const t=kf.shadowRoot(e);t&&If(t)&&(M.isShadowHost=!0)}if((M.type===lf.Document||M.type===lf.Element)&&z){h.headWhitespace&&M.type===lf.Element&&"head"===M.tagName&&(C=!1);const t={doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:I,maskTextClass:s,maskTextSelector:a,skipChild:c,inlineStylesheet:l,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:C,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:w,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k,cssCaptured:!1};if(M.type===lf.Element&&"textarea"===M.tagName&&void 0!==M.attributes.value);else{M.type===lf.Element&&void 0!==M.attributes._cssText&&"string"==typeof M.attributes._cssText&&(t.cssCaptured=!0);for(const n of Array.from(kf.childNodes(e))){const e=im(n,t);e&&M.childNodes.push(e)}}let _=null;if(_f(e)&&(_=kf.shadowRoot(e)))for(const e of Array.from(kf.childNodes(_))){const n=im(e,t);n&&(If(_)&&(n.isShadow=!0),M.childNodes.push(n))}}const O=kf.parentNode(e);return O&&Sf(O)&&If(O)&&(M.isShadow=!0),M.type===lf.Element&&"iframe"===M.tagName&&function(e,t,n){const r=e.contentWindow;if(!r)return;let o,i=!1;try{o=r.document.readyState}catch(a){return}if("complete"!==o){const r=setTimeout(()=>{i||(t(),i=!0)},n);return void e.addEventListener("load",()=>{clearTimeout(r),i=!0,t()})}const s="about:blank";if(r.location.href!==s||e.src===s||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}(e,()=>{const t=e.contentDocument;if(t&&b){const n=im(t,{doc:t,mirror:r,blockClass:o,blockSelector:i,needsMask:I,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:l,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:C,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:w,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k});n&&b(e,n)}},w),M.type===lf.Element&&"link"===M.tagName&&"string"==typeof M.attributes.rel&&("stylesheet"===M.attributes.rel||"preload"===M.attributes.rel&&"string"==typeof M.attributes.href&&"css"===Af(M.attributes.href))&&function(e,t,n){let r,o=!1;try{r=e.sheet}catch(s){return}if(r)return;const i=setTimeout(()=>{o||(t(),o=!0)},n);e.addEventListener("load",()=>{clearTimeout(i),o=!0,t()})}(e,()=>{if(v){const t=im(e,{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:I,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:l,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:C,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:w,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k});t&&v(e,t)}},x),M}var sm=class e{constructor(...e){tf(this,"parentElement",null),tf(this,"parentNode",null),tf(this,"ownerDocument"),tf(this,"firstChild",null),tf(this,"lastChild",null),tf(this,"previousSibling",null),tf(this,"nextSibling",null),tf(this,"ELEMENT_NODE",1),tf(this,"TEXT_NODE",3),tf(this,"nodeType"),tf(this,"nodeName"),tf(this,"RRNodeType")}get childNodes(){const e=[];let t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(t){if(!(t instanceof e))return!1;if(t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,t){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}};function am(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}var cm={map:{},getId:()=>-1,getNode:()=>null,removeNodeFromMap(){},has:()=>!1,reset(){}};function lm(e,t,n={}){let r=null,o=0;return function(...i){const s=Date.now();o||!1!==n.leading||(o=s);const a=t-(s-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=s,e.apply(c,i)):r||!1===n.trailing||(r=setTimeout(()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,i)},a))}}function dm(e,t,n,r,o=window){const i=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),i&&i.set&&i.set.call(this,e)}}),()=>dm(e,t,i||{},!0)}function um(e){var t,n,r,o;const i=e.document;return{left:i.scrollingElement?i.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:i.documentElement.scrollLeft||(null==i?void 0:i.body)&&(null==(t=kf.parentElement(i.body))?void 0:t.scrollLeft)||(null==(n=null==i?void 0:i.body)?void 0:n.scrollLeft)||0,top:i.scrollingElement?i.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==i?void 0:i.documentElement.scrollTop)||(null==i?void 0:i.body)&&(null==(r=kf.parentElement(i.body))?void 0:r.scrollTop)||(null==(o=null==i?void 0:i.body)?void 0:o.scrollTop)||0}}function pm(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function hm(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function fm(e){return e?e.nodeType===e.ELEMENT_NODE?e:kf.parentElement(e):null}function mm(e,t,n,r){if(!e)return!1;const o=fm(e);if(!o)return!1;try{if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(em(o,t,r))return!0}catch(i){}if(n){if(o.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function gm(e,t,n){return!("TITLE"!==e.tagName||!n.headTitleMutations)||-2===t.getId(e)}function ym(e,t){if(Sf(e))return!1;const n=t.getId(e);if(!t.has(n))return!0;const r=kf.parentNode(e);return(!r||r.nodeType!==e.DOCUMENT_NODE)&&(!r||ym(r,t))}function bm(e){return Boolean(e.changedTouches)}function wm(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function vm(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function xm(e){return!!e&&(e instanceof sm&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(kf.shadowRoot(e)))}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(cm=new Proxy(cm,{get:(e,t,n)=>Reflect.get(e,t,n)}));var km=class{constructor(){tf(this,"id",1),tf(this,"styleIDMap",/* @__PURE__ */new WeakMap),tf(this,"idStyleMap",/* @__PURE__ */new Map)}getId(e){return this.styleIDMap.get(e)??-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=/* @__PURE__ */new WeakMap,this.idStyleMap=/* @__PURE__ */new Map,this.id=1}generateId(){return this.id++}};function _m(e){var t;let n=null;return"getRootNode"in e&&(null==(t=kf.getRootNode(e))?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&kf.host(kf.getRootNode(e))&&(n=kf.host(kf.getRootNode(e))),n}function Sm(e){const t=kf.ownerDocument(e);if(!t)return!1;const n=function(e){let t,n=e;for(;t=_m(n);)n=t;return n}(e);return kf.contains(t,n)}function Im(e){const t=kf.ownerDocument(e);return!!t&&(kf.contains(t,e)||Sm(e))}function Cm(e){return"__ln"in e}var Em,Tm=class{constructor(){tf(this,"length",0),tf(this,"head",null),tf(this,"tail",null)}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&Cm(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&Cm(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}},Mm=(e,t)=>`${e}@${t}`,zm=class{constructor(){tf(this,"frozen",!1),tf(this,"locked",!1),tf(this,"texts",[]),tf(this,"attributes",[]),tf(this,"attributeMap",/* @__PURE__ */new WeakMap),tf(this,"removes",[]),tf(this,"mapRemoves",[]),tf(this,"movedMap",{}),tf(this,"addedSet",/* @__PURE__ */new Set),tf(this,"movedSet",/* @__PURE__ */new Set),tf(this,"droppedSet",/* @__PURE__ */new Set),tf(this,"removesSubTreeCache",/* @__PURE__ */new Set),tf(this,"mutationCb"),tf(this,"blockClass"),tf(this,"blockSelector"),tf(this,"maskTextClass"),tf(this,"maskTextSelector"),tf(this,"inlineStylesheet"),tf(this,"maskInputOptions"),tf(this,"maskTextFn"),tf(this,"maskInputFn"),tf(this,"keepIframeSrcFn"),tf(this,"recordCanvas"),tf(this,"inlineImages"),tf(this,"slimDOMOptions"),tf(this,"dataURLOptions"),tf(this,"doc"),tf(this,"mirror"),tf(this,"iframeManager"),tf(this,"stylesheetManager"),tf(this,"shadowDomManager"),tf(this,"canvasManager"),tf(this,"processedNodeManager"),tf(this,"unattachedDoc"),tf(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),tf(this,"emit",()=>{if(this.frozen||this.locked)return;const e=[],t=/* @__PURE__ */new Set,n=new Tm,r=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{const i=kf.parentNode(o);if(!i||!Im(o))return;let s=!1;if(o.nodeType===Node.TEXT_NODE){const e=i.tagName;if("TEXTAREA"===e)return;"STYLE"===e&&this.addedSet.has(i)&&(s=!0)}const a=Sf(i)?this.mirror.getId(_m(o)):this.mirror.getId(i),c=r(o);if(-1===a||-1===c)return n.addNode(o);const l=im(o,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{wm(e,this.mirror)&&this.iframeManager.addIframe(e),vm(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),xm(o)&&this.shadowDomManager.addShadowRoot(kf.shadowRoot(o),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)},cssCaptured:s});l&&(e.push({parentId:a,nextId:c,node:l}),t.add(l.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of this.movedSet)Rm(this.removesSubTreeCache,a,this.mirror)&&!this.movedSet.has(kf.parentNode(a))||o(a);for(const a of this.addedSet)Am(this.droppedSet,a)||Rm(this.removesSubTreeCache,a,this.mirror)?Am(this.movedSet,a)?o(a):this.droppedSet.add(a):o(a);let i=null;for(;n.length;){let e=null;if(i){const t=this.mirror.getId(kf.parentNode(i.value)),n=r(i.value);-1!==t&&-1!==n&&(e=i)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(kf.parentNode(n.value));if(-1===r(n.value))continue;if(-1!==t){e=n;break}{const t=n.value,r=kf.parentNode(t);if(r&&r.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const t=kf.host(r);if(-1!==this.mirror.getId(t)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}i=e.previous,n.removeNode(e.value),o(e.value)}const s={texts:this.texts.map(e=>{const t=e.node,n=kf.parentNode(t);return n&&"TEXTAREA"===n.tagName&&this.genTextAreaValueMutation(n),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>{const{attributes:t}=e;if("string"==typeof t.style){const n=JSON.stringify(e.styleDiff),r=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+r).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.attributeMap=/* @__PURE__ */new WeakMap,this.removes=[],this.addedSet=/* @__PURE__ */new Set,this.movedSet=/* @__PURE__ */new Set,this.droppedSet=/* @__PURE__ */new Set,this.removesSubTreeCache=/* @__PURE__ */new Set,this.movedMap={},this.mutationCb(s))}),tf(this,"genTextAreaValueMutation",e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t));const n=Array.from(kf.childNodes(e),e=>kf.textContent(e)||"").join("");t.attributes.value=Mf({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:Rf(e),value:n,maskInputFn:this.maskInputFn})}),tf(this,"processMutation",e=>{if(!gm(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{const t=kf.textContent(e.target);mm(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:tm(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,fm(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const n=e.target;let r=e.attributeName,o=e.target.getAttribute(r);if("value"===r){const e=Rf(n);o=Mf({element:n,maskInputOptions:this.maskInputOptions,tagName:n.tagName,type:e,value:o,maskInputFn:this.maskInputFn})}if(mm(e.target,this.blockClass,this.blockSelector,!1)||o===e.oldValue)return;let i=this.attributeMap.get(e.target);if("IFRAME"===n.tagName&&"src"===r&&!this.keepIframeSrcFn(o)){if(n.contentDocument)return;r="rr_src"}if(i||(i={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(i),this.attributeMap.set(e.target,i)),"type"===r&&"INPUT"===n.tagName&&"password"===(e.oldValue||"").toLowerCase()&&n.setAttribute("data-rr-is-password","true"),!Qf(n.tagName,r))if(i.attributes[r]=Xf(this.doc,zf(n.tagName),zf(r),o),"style"===r){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(t){this.unattachedDoc=this.doc}const r=this.unattachedDoc.createElement("span");e.oldValue&&r.setAttribute("style",e.oldValue);for(const e of Array.from(n.style)){const t=n.style.getPropertyValue(e),o=n.style.getPropertyPriority(e);t!==r.style.getPropertyValue(e)||o!==r.style.getPropertyPriority(e)?i.styleDiff[e]=""===o?t:[t,o]:i._unchangedStyles[e]=[t,o]}for(const e of Array.from(r.style))""===n.style.getPropertyValue(e)&&(i.styleDiff[e]=!1)}else"open"===r&&"DIALOG"===n.tagName&&(n.matches("dialog:modal")?i.attributes.rr_open_mode="modal":i.attributes.rr_open_mode="non-modal");break}case"childList":if(mm(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const n=this.mirror.getId(t),r=Sf(e.target)?this.mirror.getId(kf.host(e.target)):this.mirror.getId(e.target);mm(e.target,this.blockClass,this.blockSelector,!1)||gm(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(Om(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||ym(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Mm(n,r)]?Om(this.movedSet,t):(this.removes.push({parentId:r,id:n,isShadow:!(!Sf(e.target)||!If(e.target))||void 0}),function(e,t){const n=[e];for(;n.length;){const e=n.pop();t.has(e)||(t.add(e),kf.childNodes(e).forEach(e=>n.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.push(t))})}}),tf(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(gm(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[Mm(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);mm(e,this.blockClass,this.blockSelector,!1)||(kf.childNodes(e).forEach(e=>this.genAdds(e)),xm(e)&&kf.childNodes(kf.shadowRoot(e)).forEach(t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)}))}})}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(t=>{this[t]=e[t]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}};function Om(e,t){e.delete(t),kf.childNodes(t).forEach(t=>Om(e,t))}function Rm(e,t,n){return 0!==e.size&&function(e,t){const n=kf.parentNode(t);return!!n&&e.has(n)}(e,t)}function Am(e,t){return 0!==e.size&&Nm(e,t)}function Nm(e,t){const n=kf.parentNode(t);return!!n&&(!!e.has(n)||Nm(e,n))}var Pm=e=>{if(!Em)return e;return(...t)=>{try{return e(...t)}catch(n){if(Em&&!0===Em(n))return;throw n}}},Lm=[];function $m(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch{}return e&&e.target}function Dm(e,t){const n=new zm;Lm.push(n),n.init(e);const[r,o]=wf(),i=new r(Pm(n.processMutations.bind(n)));return i.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),[i,o]}function Fm({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){if(!1===i.mouseInteraction)return()=>{};const s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,a=[];let c=null;return Object.keys(of).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]).forEach(i=>{let s=zf(i);const l=(t=>i=>{const s=$m(i);if(mm(s,r,o,!0))return;let a=null,l=t;if("pointerType"in i){switch(i.pointerType){case"mouse":a=sf.Mouse;break;case"touch":a=sf.Touch;break;case"pen":a=sf.Pen}a===sf.Touch?of[t]===of.MouseDown?l="TouchStart":of[t]===of.MouseUp&&(l="TouchEnd"):sf.Pen}else bm(i)&&(a=sf.Touch);null!==a?(c=a,(l.startsWith("Touch")&&a===sf.Touch||l.startsWith("Mouse")&&a===sf.Mouse)&&(a=null)):of[t]===of.Click&&(a=c,c=null);const d=bm(i)?i.changedTouches[0]:i;if(!d)return;const u=n.getId(s),{clientX:p,clientY:h}=d;Pm(e)({type:of[l],id:u,x:p,y:h,...null!==a&&{pointerType:a}})})(i);if(window.PointerEvent)switch(of[i]){case of.MouseDown:case of.MouseUp:s=s.replace("mouse","pointer");break;case of.TouchStart:case of.TouchEnd:return}a.push(am(s,l,t))}),Pm(()=>{a.forEach(e=>e())})}function jm({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){return am("scroll",Pm(lm(Pm(i=>{const s=$m(i);if(!s||mm(s,r,o,!0))return;const a=n.getId(s);if(s===t&&t.defaultView){const n=um(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:s.scrollLeft,y:s.scrollTop})}),i.scroll||100)),t)}var Um=["INPUT","TEXTAREA","SELECT"],Wm=/* @__PURE__ */new WeakMap;function Bm(e){return function e(t,n){if(Vm("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||Vm("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||Vm("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||Vm("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){const r=Array.from(t.parentRule.cssRules).indexOf(t);return n.unshift(r),e(t.parentRule,n)}if(t.parentStyleSheet){const e=Array.from(t.parentStyleSheet.cssRules).indexOf(t);n.unshift(e)}return n}(e,[])}function Hm(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function qm({mirror:e,stylesheetManager:t},n){var r,o,i;let s=null;s="#document"===n.nodeName?e.getId(n):e.getId(kf.host(n));const a="#document"===n.nodeName?null==(r=n.defaultView)?void 0:r.Document:null==(i=null==(o=n.ownerDocument)?void 0:o.defaultView)?void 0:i.ShadowRoot,c=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==s&&-1!==s&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null==(e=c.get)?void 0:e.call(this)},set(e){var n;const r=null==(n=c.set)?void 0:n.call(this,e);if(null!==s&&-1!==s)try{t.adoptStyleSheets(e,s)}catch(o){}return r}}),Pm(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})})):()=>{}}function Zm(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let r;!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:i,viewportResizeCb:s,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:u,fontCb:p,selectionCb:h,customElementCb:f}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),i(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),s(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),p(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),h(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),f(...e)}}(e,t);let o=()=>{};e.recordDOM&&([r,o]=Dm(e,e.doc));const i=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,i="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let s,a=[];const c=lm(Pm(t=>{const n=Date.now()-s;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],s=null}),i),l=Pm(lm(Pm(e=>{const t=$m(e),{clientX:n,clientY:o}=bm(e)?e.changedTouches[0]:e;s||(s=vf()),a.push({x:n,y:o,id:r.getId(t),timeOffset:vf()-s}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?rf.Drag:e instanceof MouseEvent?rf.MouseMove:rf.TouchMove)}),o,{trailing:!1})),d=[am("mousemove",l,n),am("touchmove",l,n),am("drag",l,n)];return Pm(()=>{d.forEach(e=>e())})}(e),s=Fm(e),a=jm(e),c=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return am("resize",Pm(lm(Pm(()=>{const t=pm(),o=hm();n===t&&r===o||(e({width:Number(o),height:Number(t)}),n=t,r=o)}),200)),t)}(e,{win:n}),l=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:i,ignoreSelector:s,maskInputOptions:a,maskInputFn:c,sampling:l,userTriggeredOnInput:d}){function u(e){let n=$m(e);const l=e.isTrusted,u=n&&n.tagName;if(n&&"OPTION"===u&&(n=kf.parentElement(n)),!n||!u||Um.indexOf(u)<0||mm(n,r,o,!0))return;if(n.classList.contains(i)||s&&n.matches(s))return;let h=n.value,f=!1;const m=Rf(n)||"";"radio"===m||"checkbox"===m?f=n.checked:(a[u.toLowerCase()]||a[m])&&(h=Mf({element:n,maskInputOptions:a,tagName:u,type:m,value:h,maskInputFn:c})),p(n,d?{text:h,isChecked:f,userTriggered:l}:{text:h,isChecked:f});const g=n.name;"radio"===m&&g&&f&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(e=>{if(e!==n){const t=e.value;p(e,d?{text:t,isChecked:!f,userTriggered:!1}:{text:t,isChecked:!f})}})}function p(t,r){const o=Wm.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){Wm.set(t,r);const o=n.getId(t);Pm(e)({...r,id:o})}}const h=("last"===l.input?["change"]:["input","change"]).map(e=>am(e,Pm(u),t)),f=t.defaultView;if(!f)return()=>{h.forEach(e=>e())};const m=f.Object.getOwnPropertyDescriptor(f.HTMLInputElement.prototype,"value"),g=[[f.HTMLInputElement.prototype,"value"],[f.HTMLInputElement.prototype,"checked"],[f.HTMLSelectElement.prototype,"value"],[f.HTMLTextAreaElement.prototype,"value"],[f.HTMLSelectElement.prototype,"selectedIndex"],[f.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&h.push(...g.map(e=>dm(e[0],e[1],{set(){Pm(u)({target:this,isTrusted:!1})}},!1,f))),Pm(()=>{h.forEach(e=>e())})}(e),d=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o,doc:i}){const s=Pm(i=>lm(Pm(o=>{const s=$m(o);if(!s||mm(s,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d,loop:u}=s;e({type:i,id:r.getId(s),currentTime:a,volume:c,muted:l,playbackRate:d,loop:u})}),o.media||500)),a=[am("play",s(cf.Play),i),am("pause",s(cf.Pause),i),am("seeked",s(cf.Seeked),i),am("volumechange",s(cf.VolumeChange),i),am("ratechange",s(cf.RateChange),i)];return Pm(()=>{a.forEach(e=>e())})}(e);let u=()=>{},p=()=>{},h=()=>{},f=()=>{};e.recordDOM&&(u=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(o,{apply:Pm((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=Hm(o,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:a}]}),r.apply(o,i)})}),r.CSSStyleSheet.prototype.addRule=function(e,t,n=this.cssRules.length){const o=`${e} { ${t} }`;return r.CSSStyleSheet.prototype.insertRule.apply(this,[o,n])};const i=r.CSSStyleSheet.prototype.deleteRule;let s,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(i,{apply:Pm((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Hm(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:s}]}),r.apply(o,i)})}),r.CSSStyleSheet.prototype.removeRule=function(e){return r.CSSStyleSheet.prototype.deleteRule.apply(this,[e])},r.CSSStyleSheet.prototype.replace&&(s=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(s,{apply:Pm((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Hm(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replace:s}),r.apply(o,i)})})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:Pm((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Hm(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replaceSync:s}),r.apply(o,i)})}));const c={};Gm("CSSGroupingRule")?c.CSSGroupingRule=r.CSSGroupingRule:(Gm("CSSMediaRule")&&(c.CSSMediaRule=r.CSSMediaRule),Gm("CSSConditionRule")&&(c.CSSConditionRule=r.CSSConditionRule),Gm("CSSSupportsRule")&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach(([r,o])=>{l[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=new Proxy(l[r].insertRule,{apply:Pm((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=Hm(o.parentStyleSheet,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:[...Bm(o),a||0]}]}),r.apply(o,i)})}),o.prototype.deleteRule=new Proxy(l[r].deleteRule,{apply:Pm((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Hm(o.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:[...Bm(o),s]}]}),r.apply(o,i)})})}),Pm(()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=i,s&&(r.CSSStyleSheet.prototype.replace=s),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule})})}(e,{win:n}),p=qm(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const i=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(i,{apply:Pm((o,s,a)=>{var c;const[l,d,u]=a;if(n.has(l))return i.apply(s,[l,d,u]);const{id:p,styleId:h}=Hm(null==(c=s.parentRule)?void 0:c.parentStyleSheet,t,r.styleMirror);return(p&&-1!==p||h&&-1!==h)&&e({id:p,styleId:h,set:{property:l,value:d,priority:u},index:Bm(s.parentRule)}),o.apply(s,a)})});const s=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(s,{apply:Pm((o,i,a)=>{var c;const[l]=a;if(n.has(l))return s.apply(i,[l]);const{id:d,styleId:u}=Hm(null==(c=i.parentRule)?void 0:c.parentStyleSheet,t,r.styleMirror);return(d&&-1!==d||u&&-1!==u)&&e({id:d,styleId:u,remove:{property:l},index:Bm(i.parentRule)}),o.apply(i,a)})}),Pm(()=>{o.CSSStyleDeclaration.prototype.setProperty=i,o.CSSStyleDeclaration.prototype.removeProperty=s})}(e,{win:n}),e.collectFonts&&(f=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=/* @__PURE__ */new WeakMap,i=n.FontFace;n.FontFace=function(e,t,n){const r=new i(e,t,n);return o.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const s=xf(t.fonts,"add",function(t){return function(n){return setTimeout(Pm(()=>{const t=o.get(n);t&&(e(t),o.delete(n))}),0),t.apply(this,[n])}});return r.push(()=>{n.FontFace=i}),r.push(s),Pm(()=>{r.forEach(e=>e())})}(e)));const m=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:i}=e;let s=!0;const a=Pm(()=>{const e=t.getSelection();if(!e||s&&(null==e?void 0:e.isCollapsed))return;s=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const{startContainer:i,startOffset:s,endContainer:c,endOffset:l}=e.getRangeAt(t);mm(i,r,o,!0)||mm(c,r,o,!0)||a.push({start:n.getId(i),startOffset:s,end:n.getId(c),endOffset:l})}i({ranges:a})});return a(),am("selectionchange",a)}(e),g=function({doc:e,customElementCb:t}){const n=e.defaultView;return n&&n.customElements?xf(n.customElements,"define",function(e){return function(n,r,o){try{t({define:{name:n}})}catch(i){}return e.apply(this,[n,r,o])}}):()=>{}}(e),y=[];for(const b of e.plugins)y.push(b.observer(b.callback,n,b.options));return Pm(()=>{Lm.forEach(e=>e.reset()),r?.disconnect(),o(),i(),s(),a(),c(),l(),d(),u(),p(),h(),f(),m(),g(),y.forEach(e=>e())})}function Vm(e){return void 0!==window[e]}function Gm(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}for(var Ym=class{constructor(e){tf(this,"iframeIdToRemoteIdMap",/* @__PURE__ */new WeakMap),tf(this,"iframeRemoteIdToIdMap",/* @__PURE__ */new WeakMap),this.generateIdFn=e}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),i=r||this.getRemoteIdToIdMap(e);let s=o.get(t);return s||(s=this.generateIdFn(),o.set(t,s),i.set(s,t)),s}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,r))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const o=r.get(t);return o||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,n))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=/* @__PURE__ */new WeakMap,void(this.iframeRemoteIdToIdMap=/* @__PURE__ */new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=/* @__PURE__ */new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=/* @__PURE__ */new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}},Km=class{constructor(e){tf(this,"iframes",/* @__PURE__ */new WeakMap),tf(this,"crossOriginIframeMap",/* @__PURE__ */new WeakMap),tf(this,"crossOriginIframeMirror",new Ym(qf)),tf(this,"crossOriginIframeStyleMirror"),tf(this,"crossOriginIframeRootIdMap",/* @__PURE__ */new WeakMap),tf(this,"mirror"),tf(this,"mutationCb"),tf(this,"wrappedEmit"),tf(this,"loadListener"),tf(this,"stylesheetManager"),tf(this,"recordCrossOriginIframes"),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Ym(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n,r;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&(null==(n=e.contentWindow)||n.addEventListener("message",this.handleMessage.bind(this))),null==(r=this.loadListener)||r.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const n=this.crossOriginIframeMap.get(e.source);if(!n)return;const r=this.transformCrossOriginEvent(n,t.data.event);r&&this.wrappedEmit(r,t.data.isCheckout)}transformCrossOriginEvent(e,t){var n;switch(t.type){case nf.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const n=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,n),this.patchRootIdOnNode(t.data.node,n),{timestamp:t.timestamp,type:nf.IncrementalSnapshot,data:{source:rf.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case nf.Meta:case nf.Load:case nf.DomContentLoaded:return!1;case nf.Plugin:return t;case nf.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case nf.IncrementalSnapshot:switch(t.data.source){case rf.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(t.node,n)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,["id"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case rf.Drag:case rf.TouchMove:case rf.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case rf.ViewportResize:return!1;case rf.MediaInteraction:case rf.MouseInteraction:case rf.Scroll:case rf.CanvasMutation:case rf.Input:return this.replaceIds(t.data,e,["id"]),t;case rf.StyleSheetRule:case rf.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case rf.Font:return t;case rf.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case rf.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null==(n=t.data.styles)||n.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}return!1}replace(e,t,n,r){for(const o of r)(Array.isArray(t[o])||"number"==typeof t[o])&&(Array.isArray(t[o])?t[o]=e.getIds(n,t[o]):t[o]=e.getId(n,t[o]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}patchRootIdOnNode(e,t){e.type===lf.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}},Jm=class{constructor(e){tf(this,"shadowDoms",/* @__PURE__ */new WeakSet),tf(this,"mutationCb"),tf(this,"scrollCb"),tf(this,"bypassOptions"),tf(this,"mirror"),tf(this,"restoreHandlers",[]),this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){if(!If(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const[n]=Dm({...this.bypassOptions,doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},e);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(jm({...this.bypassOptions,scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(kf.host(e))),this.restoreHandlers.push(qm({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))},0)}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){const n=this;this.restoreHandlers.push(xf(e.prototype,"attachShadow",function(e){return function(r){const o=e.call(this,r),i=kf.shadowRoot(this);return i&&Im(this)&&n.addShadowRoot(i,t),o}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch(t){}}),this.restoreHandlers=[],this.shadowDoms=/* @__PURE__ */new WeakSet}},Xm="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Qm="undefined"==typeof Uint8Array?[]:/* @__PURE__ */new Uint8Array(256),eg=0;eg<64;eg++)Qm[Xm.charCodeAt(eg)]=eg;var tg=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=Xm[n[t]>>2],o+=Xm[(3&n[t])<<4|n[t+1]>>4],o+=Xm[(15&n[t+1])<<2|n[t+2]>>6],o+=Xm[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o},ng=/* @__PURE__ */new Map;var rg=(e,t,n)=>{if(!e||!sg(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=ng.get(e);return n||(n=/* @__PURE__ */new Map,ng.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function og(e,t,n){if(e instanceof Array)return e.map(e=>og(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:tg(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[og(e.buffer,t,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}return e instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:e.toDataURL()}:e instanceof ImageData?{rr_type:e.constructor.name,args:[og(e.data,t,n),e.width,e.height]}:sg(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:rg(e,t,n)}:e}var ig=(e,t,n)=>e.map(e=>og(e,t,n)),sg=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function ag(e,t,n,r){const o=[];try{const i=xf(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(o,...i){if(!mm(this,t,n,!0)){const e=function(e){return"experimental-webgl"===e?"webgl":e}(o);if("__context"in this||(this.__context=e),r&&["webgl","webgl2"].includes(e))if(i[0]&&"object"==typeof i[0]){const e=i[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else i.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[o,...i])}});o.push(i)}catch{}return()=>{o.forEach(e=>e())}}function cg(e,t,n,r,o,i){const s=[],a=Object.getOwnPropertyNames(e);for(const c of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(c))try{if("function"!=typeof e[c])continue;const a=xf(e,c,function(e){return function(...s){const a=e.apply(this,s);if(rg(a,i,this),"tagName"in this.canvas&&!mm(this.canvas,r,o,!0)){const e=ig(s,i,this),r={type:t,property:c,args:e};n(this.canvas,r)}return a}});s.push(a)}catch{const r=dm(e,c,{set(e){n(this.canvas,{type:t,property:c,args:[e],setter:!0})}});s.push(r)}return s}var lg='(function() {\n "use strict";\n var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";\n var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);\n for (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n }\n var encode = function(arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";\n for (i2 = 0; i2 < len; i2 += 3) {\n base64 += chars[bytes[i2] >> 2];\n base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];\n base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];\n base64 += chars[bytes[i2 + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + "=";\n } else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + "==";\n }\n return base64;\n };\n const lastBlobMap = /* @__PURE__ */ new Map();\n const transparentBlobMap = /* @__PURE__ */ new Map();\n async function getTransparentBlobFor(width, height, dataURLOptions) {\n const id = `${width}-${height}`;\n if ("OffscreenCanvas" in globalThis) {\n if (transparentBlobMap.has(id)) return transparentBlobMap.get(id);\n const offscreen = new OffscreenCanvas(width, height);\n offscreen.getContext("2d");\n const blob = await offscreen.convertToBlob(dataURLOptions);\n const arrayBuffer = await blob.arrayBuffer();\n const base64 = encode(arrayBuffer);\n transparentBlobMap.set(id, base64);\n return base64;\n } else {\n return "";\n }\n }\n const worker = self;\n worker.onmessage = async function(e) {\n if ("OffscreenCanvas" in globalThis) {\n const { id, bitmap, width, height, dataURLOptions } = e.data;\n const transparentBase64 = getTransparentBlobFor(\n width,\n height,\n dataURLOptions\n );\n const offscreen = new OffscreenCanvas(width, height);\n const ctx = offscreen.getContext("2d");\n ctx.drawImage(bitmap, 0, 0);\n bitmap.close();\n const blob = await offscreen.convertToBlob(dataURLOptions);\n const type = blob.type;\n const arrayBuffer = await blob.arrayBuffer();\n const base64 = encode(arrayBuffer);\n if (!lastBlobMap.has(id) && await transparentBase64 === base64) {\n lastBlobMap.set(id, base64);\n return worker.postMessage({ id });\n }\n if (lastBlobMap.get(id) === base64) return worker.postMessage({ id });\n worker.postMessage({\n id,\n type,\n base64,\n width,\n height\n });\n lastBlobMap.set(id, base64);\n } else {\n return worker.postMessage({ id: e.data.id });\n }\n };\n})();\n//# sourceMappingURL=image-bitmap-data-url-worker-IJpC7g_b.js.map\n',dg="undefined"!=typeof self&&self.Blob&&new Blob([lg],{type:"text/javascript;charset=utf-8"});function ug(e){let t;try{if(t=dg&&(self.URL||self.webkitURL).createObjectURL(dg),!t)throw"";const n=new Worker(t,{name:null==e?void 0:e.name});return n.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch(n){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(lg),{name:null==e?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}var pg,hg,fg,mg=class{constructor(e){tf(this,"pendingCanvasMutations",/* @__PURE__ */new Map),tf(this,"rafStamps",{latestId:0,invokeId:null}),tf(this,"mirror"),tf(this,"mutationCb"),tf(this,"resetObservers"),tf(this,"frozen",!1),tf(this,"locked",!1),tf(this,"processMutation",(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});const{sampling:t="all",win:n,blockClass:r,blockSelector:o,recordCanvas:i,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,i&&"all"===t&&this.initCanvasMutationObserver(n,r,o),i&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,o){const i=ag(t,n,r,!0),s=/* @__PURE__ */new Map,a=new ug;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:i}=e.data;this.mutationCb({id:t,type:af["2D"],commands:[{property:"clearRect",args:[0,0,o,i]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{mm(t,n,r,!0)||e.push(t)}),e})().forEach(async e=>{var t;const n=this.mirror.getId(e);if(s.get(n))return;if(0===e.width||0===e.height)return;if(s.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null==(t=null==n?void 0:n.getContextAttributes())?void 0:t.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}const r=await createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])})),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{i(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=ag(e,t,n,!1),o=function(e,t,n,r){const o=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of i)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const i=xf(t.CanvasRenderingContext2D.prototype,s,function(o){return function(...i){return mm(this.canvas,n,r,!0)||setTimeout(()=>{const n=ig(i,t,this);e(this.canvas,{type:af["2D"],property:s,args:n})},0),o.apply(this,i)}});o.push(i)}catch{const n=dm(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:af["2D"],property:s,args:[t],setter:!0})}});o.push(n)}return()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),i=function(e,t,n,r){const o=[];return void 0!==t.WebGLRenderingContext&&o.push(...cg(t.WebGLRenderingContext.prototype,af.WebGL,e,n,r,t)),void 0!==t.WebGL2RenderingContext&&o.push(...cg(t.WebGL2RenderingContext.prototype,af.WebGL2,e,n,r,t)),()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n);this.resetObservers=()=>{r(),o(),i()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const{type:t,...n}=e;return n}),{type:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}},gg=class{constructor(e){tf(this,"trackedLinkElements",/* @__PURE__ */new WeakSet),tf(this,"mutationCb"),tf(this,"adoptedStyleSheetCb"),tf(this,"styleMirror",new km),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const o of e){let e;this.styleMirror.has(o)?e=this.styleMirror.getId(o):(e=this.styleMirror.add(o),r.push({styleId:e,rules:Array.from(o.rules||CSSRule,(e,t)=>({rule:Ef(e,o.href),index:t}))})),n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=/* @__PURE__ */new WeakSet}trackStylesheetInLinkElement(e){}},yg=class{constructor(){tf(this,"nodeMap",/* @__PURE__ */new WeakMap),tf(this,"active",!1)}inOtherBuffer(e,t){const n=this.nodeMap.get(e);return n&&Array.from(n).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=/* @__PURE__ */new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||/* @__PURE__ */new Set).add(t))}destroy(){}},bg=!1;try{if(2!==Array.from([1],e=>2*e)[0]){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=(null==(Vh=e.contentWindow)?void 0:Vh.Array.from)||Array.from,document.body.removeChild(e)}}catch(cy){}var wg=new Tf;function vg(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:i=null,ignoreClass:s="rr-ignore",ignoreSelector:a=null,maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:p,slimDOMOptions:h,maskInputFn:f,maskTextFn:m,hooks:g,packFn:y,sampling:b={},dataURLOptions:w={},mousemoveWait:v,recordDOM:x=!0,recordCanvas:k=!1,recordCrossOriginIframes:_=!1,recordAfter:S=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:I=!1,collectFonts:C=!1,inlineImages:E=!1,plugins:T,keepIframeSrcFn:M=()=>!1,ignoreCSSAttributes:z=/* @__PURE__ */new Set([]),errorHandler:O}=e;Em=O;const R=!_||window.parent===window;let A=!1;if(!R)try{window.parent.document&&(A=!1)}catch(Z){A=!0}if(R&&!t)throw new Error("emit function is required");if(!R&&!A)return()=>{};void 0!==v&&void 0===b.mousemove&&(b.mousemove=v),wg.reset();const N=!0===u?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==p?p:{password:!0},P=om(h);let L;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach)}();let $=0;const D=e=>{for(const t of T||[])t.eventProcessor&&(e=t.eventProcessor(e));return y&&!A&&(e=y(e)),e};pg=(e,o)=>{var i;const s=e;if(s.timestamp=vf(),!(null==(i=Lm[0])?void 0:i.isFrozen())||s.type===nf.FullSnapshot||s.type===nf.IncrementalSnapshot&&s.data.source===rf.Mutation||Lm.forEach(e=>e.unfreeze()),R)t?.(D(s),o);else if(A){const e={type:"rrweb",event:D(s),origin:window.location.origin,isCheckout:o};window.parent.postMessage(e,"*")}if(s.type===nf.FullSnapshot)L=s,$=0;else if(s.type===nf.IncrementalSnapshot){if(s.data.source===rf.Mutation&&s.data.isAttachIframe)return;$++;const e=r&&$>=r,t=n&&s.timestamp-L.timestamp>n;(e||t)&&hg(!0)}};const F=e=>{pg({type:nf.IncrementalSnapshot,data:{source:rf.Mutation,...e}})},j=e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.Scroll,...e}}),U=e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.CanvasMutation,...e}}),W=new gg({mutationCb:F,adoptedStyleSheetCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.AdoptedStyleSheet,...e}})}),B=new Km({mirror:wg,mutationCb:F,stylesheetManager:W,recordCrossOriginIframes:_,wrappedEmit:pg});for(const G of T||[])G.getMirror&&G.getMirror({nodeMirror:wg,crossOriginIframeMirror:B.crossOriginIframeMirror,crossOriginIframeStyleMirror:B.crossOriginIframeStyleMirror});const H=new yg;fg=new mg({recordCanvas:k,mutationCb:U,win:window,blockClass:o,blockSelector:i,mirror:wg,sampling:b.canvas,dataURLOptions:w});const q=new Jm({mutationCb:F,scrollCb:j,bypassOptions:{blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:N,dataURLOptions:w,maskTextFn:m,maskInputFn:f,recordCanvas:k,inlineImages:E,sampling:b,slimDOMOptions:P,iframeManager:B,stylesheetManager:W,canvasManager:fg,keepIframeSrcFn:M,processedNodeManager:H},mirror:wg});hg=(e=!1)=>{if(!x)return;pg({type:nf.Meta,data:{href:window.location.href,width:hm(),height:pm()}},e),W.reset(),q.init(),Lm.forEach(e=>e.lock());const t=function(e,t){const{mirror:n=new Tf,blockClass:r="rr-block",blockSelector:o=null,maskTextClass:i="rr-mask",maskTextSelector:s=null,inlineStylesheet:a=!0,inlineImages:c=!1,recordCanvas:l=!1,maskAllInputs:d=!1,maskTextFn:u,maskInputFn:p,slimDOM:h=!1,dataURLOptions:f,preserveWhiteSpace:m,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:w,stylesheetLoadTimeout:v,keepIframeSrcFn:x=()=>!1}=t;return im(e,{doc:e,mirror:n,blockClass:r,blockSelector:o,maskTextClass:i,maskTextSelector:s,skipChild:!1,inlineStylesheet:a,maskInputOptions:!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===d?{password:!0}:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:om(h),dataURLOptions:f,inlineImages:c,recordCanvas:l,preserveWhiteSpace:m,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:w,stylesheetLoadTimeout:v,keepIframeSrcFn:x,newlyAddedElement:!1})}(document,{mirror:wg,blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:N,maskTextFn:m,maskInputFn:f,slimDOM:P,dataURLOptions:w,recordCanvas:k,inlineImages:E,onSerialize:e=>{wm(e,wg)&&B.addIframe(e),vm(e,wg)&&W.trackLinkElement(e),xm(e)&&q.addShadowRoot(kf.shadowRoot(e),document)},onIframeLoad:(e,t)=>{B.attachIframe(e,t),q.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{W.attachLinkElement(e,t)},keepIframeSrcFn:M});t&&(pg({type:nf.FullSnapshot,data:{node:t,initialOffset:um(window)}},e),Lm.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&W.adoptStyleSheets(document.adoptedStyleSheets,wg.getId(document)))};try{const e=[],t=e=>{var t;return Pm(Zm)({mutationCb:F,mousemoveCb:(e,t)=>pg({type:nf.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.MouseInteraction,...e}}),scrollCb:j,viewportResizeCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.ViewportResize,...e}}),inputCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.Input,...e}}),mediaInteractionCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.MediaInteraction,...e}}),styleSheetRuleCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.StyleSheetRule,...e}}),styleDeclarationCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.StyleDeclaration,...e}}),canvasMutationCb:U,fontCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.Font,...e}}),selectionCb:e=>{pg({type:nf.IncrementalSnapshot,data:{source:rf.Selection,...e}})},customElementCb:e=>{pg({type:nf.IncrementalSnapshot,data:{source:rf.CustomElement,...e}})},blockClass:o,ignoreClass:s,ignoreSelector:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:N,inlineStylesheet:d,sampling:b,recordDOM:x,recordCanvas:k,inlineImages:E,userTriggeredOnInput:I,collectFonts:C,doc:e,maskInputFn:f,maskTextFn:m,keepIframeSrcFn:M,blockSelector:i,slimDOMOptions:P,dataURLOptions:w,mirror:wg,iframeManager:B,stylesheetManager:W,shadowDomManager:q,processedNodeManager:H,canvasManager:fg,ignoreCSSAttributes:z,plugins:(null==(t=null==T?void 0:T.filter(e=>e.observer))?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>pg({type:nf.Plugin,data:{plugin:e.name,payload:t}})})))||[]},g)};B.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(r){}});const n=()=>{hg(),e.push(t(document)),bg=!0};return["interactive","complete"].includes(document.readyState)?n():(e.push(am("DOMContentLoaded",()=>{pg({type:nf.DomContentLoaded,data:{}}),"DOMContentLoaded"===S&&n()})),e.push(am("load",()=>{pg({type:nf.Load,data:{}}),"load"===S&&n()},window))),()=>{e.forEach(e=>{try{e()}catch(t){String(t).toLowerCase().includes("cross-origin")}}),H.destroy(),bg=!1,Em=void 0}}catch(V){}}vg.addCustomEvent=(e,t)=>{if(!bg)throw new Error("please add custom event after start recording");pg({type:nf.Custom,data:{tag:e,payload:t}})},vg.freezePage=()=>{Lm.forEach(e=>e.freeze())},vg.takeFullSnapshot=e=>{if(!bg)throw new Error("please take full snapshot after start recording");hg(e)},vg.mirror=wg;var xg=class{chatId;applicationId;events=[];sessionId=globalThis.crypto.randomUUID();stopRecording=null;flushTimer=null;flushPromise=Promise.resolve();constructor(e,t){this.chatId=e,this.applicationId=t}async start(){this.stopRecording||(await Ss.widgetMessagePost({chat_id:this.chatId,command:{type:"rrweb/metadata",rrweb_session_id:this.sessionId,chat_id:this.chatId,application_id:this.applicationId,url:window.location.href,user_agent:navigator.userAgent,timestamp:Date.now(),viewport:{width:window.innerWidth,height:window.innerHeight}}}),this.stopRecording=vg({emit:e=>this.buffer(e),maskAllInputs:!0,maskTextClass:/^(rr-mask|mtx-mask)$/,blockClass:/^(rr-block|mtx-block)$/}))}stop(){this.stopRecording?.(),this.stopRecording=null,this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=null,this.flush()}buffer(e){this.events.push(e),this.flushTimer||(this.flushTimer=setTimeout(()=>{this.flush()},500))}flush(){return this.flushPromise=this.flushPromise.then(async()=>{this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=null;const e=this.events.splice(0);if(e.length)try{await Ss.widgetMessagePost({chat_id:this.chatId,command:{type:"rrweb/events",rrweb_session_id:this.sessionId,events:e}})}catch(t){this.events.unshift(...e)}}),this.flushPromise}};function kg(e,t="Unknown error"){return e instanceof Error?e.message:"string"==typeof e?e:t}function _g(e,t="Operation",n){const r=kg(e);return function(e){const t=e instanceof Error?e.message:String(e);return t.includes("Failed to fetch")||t.includes("ERR_CONNECTION_REFUSED")||t.includes("NetworkError")||t.includes("Network request failed")}(e)?{isValid:!1,error:`Cannot connect to API server. Please ensure the API server is running at ${n?.mtxApiHost||"configured API server"}. Error: ${r}`}:{isValid:!1,error:`${t} failed: ${r}`}}async function Sg(e){return e.mtxId&&e.mtxKey?async function(e,t,n){try{const{items:n}=await Ss.widgetSearch({marketrix_id:e,marketrix_key:t});if(!n||0===n.length)return{isValid:!1,error:"Widget not found or invalid credentials"};const o=n.find(e=>"widget"===e.type&&"active"===e.status);if(!o){const e=n.filter(e=>"widget"===e.type);return e.length>0?{isValid:!1,error:`Found widget(s) but none are active. Current status(es): ${e.map(e=>e.status).join(", ")}. Please activate the widget in the dashboard.`}:0===n.length?{isValid:!1,error:"No widgets found for the provided marketrix_id and marketrix_key. Please verify your credentials."}:{isValid:!1,error:`No widget found. Found widget type(s): ${n.map(e=>e.type).join(", ")}. Please create a widget.`}}if(!o.application_id)return{isValid:!1,error:"Widget missing application_id",widget:o};try{return{isValid:!0,widget:o,application:await Ss.applicationGet({application_id:o.application_id})}}catch(r){return{isValid:!1,error:`Failed to validate application: ${kg(r)}`,widget:o}}}catch(o){return _g(o,"Widget validation",n)}}(e.mtxId,e.mtxKey,e):{isValid:!1,error:"Please provide mtxId + mtxKey"}}function Ig(e,t){return"object"==typeof e&&null!==e&&t in e}function Cg(e){return null!==e&&e instanceof HTMLElement}var Eg=null;function Tg(e){return e.settings?function(e){return"object"==typeof e&&null!==e}(t=e.settings)&&Ig(t,"widget_enabled")&&"boolean"==typeof t.widget_enabled&&Ig(t,"widget_appearance")&&"string"==typeof t.widget_appearance&&Ig(t,"widget_position")&&"string"==typeof t.widget_position?e.settings:null:null;var t}var Mg="#6b7280",zg="#1f2937",Og="rgba(255, 255, 255, 0.95)",Rg="rgba(255, 255, 255, 0.2)",Ag="rgba(0, 0, 0, 0.15)",Ng=({message:e="Loading widget settings..."})=>{const[t,n]=u(!1),r=e?.includes("marketrix_id")||e?.includes("marketrix_key");return t?null:/* @__PURE__ */g(Qc,{position:"fixed",style:{bottom:"20px",left:"50%",transform:"translateX(-50%)",maxWidth:"420px",backgroundColor:Og,borderRadius:r?"18px":"999px",boxShadow:`0 2px 12px ${Ag}`,display:"flex",flexDirection:"column",alignItems:"stretch",gap:"8px",padding:"10px 12px",border:`1px solid ${Rg}`,zIndex:9999,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[/* @__PURE__ */g(id,{align:"center",style:{gap:"10px"},children:[
58
+ /* @__PURE__ */m(_d,{open:r.isOpen,processing:r.isLoading,error:!!r.error,taskRunning:r.isTaskRunning,onClick:o.toggleWidget,onStop:o.stopTask,accentColor:E.widget_accent_color,backgroundColor:E.widget_background_color,borderRadius:E.widget_border_radius,tooltipBgColor:_(E.widget_accent_color,.3),tooltipTextColor:k(_(E.widget_accent_color,.3)),zIndex:E.widget_position_z_index??50,position:h,onDrag:e=>{f(e),c||"undefined"==typeof localStorage||localStorage.setItem(y,e)},isPreviewMode:c}),r.error&&/* @__PURE__ */m(bd,{tone:"error",title:r.error,onDismiss:()=>o.clearError(),onRetry:()=>o.clearError(),position:h.includes("top")?"bottom-center":"above-fab"}),t&&!r.error&&i.widget_greeting&&/* @__PURE__ */m(bd,{tone:"info",title:i.widget_greeting,body:i.widget_body,onDismiss:()=>n(!1),position:"bottom-center"})]})},ef=Object.defineProperty,tf=(e,t,n)=>((e,t,n)=>t in e?ef(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),nf=/* @__PURE__ */(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e[e.Asset=7]="Asset",e))(nf||{}),rf=/* @__PURE__ */(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(rf||{}),of=/* @__PURE__ */(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(of||{}),sf=/* @__PURE__ */(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(sf||{}),af=/* @__PURE__ */(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(af||{}),cf=/* @__PURE__ */(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(cf||{}),lf=/* @__PURE__ */(e=>(e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e))(lf||{}),df={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},uf={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},pf={},hf={};function ff(e){if(pf[e])return pf[e];const t=globalThis[e],n=t.prototype,r=e in df?df[e]:void 0,o=Boolean(r&&r.every(e=>{var t,r;return Boolean(null==(r=null==(t=Object.getOwnPropertyDescriptor(n,e))?void 0:t.get)?void 0:r.toString().includes("[native code]"))})),i=e in uf?uf[e]:void 0,s=Boolean(i&&i.every(e=>{var t;return"function"==typeof n[e]&&(null==(t=n[e])?void 0:t.toString().includes("[native code]"))}));if(o&&s&&!globalThis.Zone)return pf[e]=t.prototype,t.prototype;try{const r=document.createElement("iframe");r.style.display="none",document.body.appendChild(r);const o=r.contentWindow;if(!o)return t.prototype;const i=o[e].prototype;if(!i)return r.remove(),n;const s=navigator.userAgent;return s.includes("Safari")&&!s.includes("Chrome")?(r.classList.add("rr-block"),r.setAttribute("__rrwebUntaintedMutationObserver",""),hf[e]=()=>r.remove()):r.remove(),pf[e]=i}catch{return n}}var mf={};function gf(e,t,n){var r;const o=`${e}.${String(n)}`;if(mf[o])return mf[o].call(t);const i=ff(e),s=null==(r=Object.getOwnPropertyDescriptor(i,n))?void 0:r.get;return s?(mf[o]=s,s.call(t)):t[n]}var yf={};function bf(e,t,n){const r=`${e}.${String(n)}`;if(yf[r])return yf[r].bind(t);const o=ff(e)[n];return"function"!=typeof o?t[n]:(yf[r]=o,o.bind(t))}function wf(){return[ff("MutationObserver").constructor,hf.MutationObserver??(()=>{})]}var vf=Date.now;function xf(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch{return()=>{}}}/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())||(vf=()=>/* @__PURE__ */(new Date).getTime());var kf={ownerDocument:function(e){return gf("Node",e,"ownerDocument")},childNodes:function(e){return gf("Node",e,"childNodes")},parentNode:function(e){return gf("Node",e,"parentNode")},parentElement:function(e){return gf("Node",e,"parentElement")},textContent:function(e){return gf("Node",e,"textContent")},contains:function(e,t){return bf("Node",e,"contains")(t)},getRootNode:function(e){return bf("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?gf("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?gf("Element",e,"shadowRoot"):null},querySelector:function(e,t){return gf("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return gf("Element",e,"querySelectorAll")(t)},nowTimestamp:vf,mutationObserverCtor:wf,patch:xf};function Sf(e){return e.nodeType===e.ELEMENT_NODE}function _f(e){const t=e&&"host"in e&&"mode"in e&&kf.host(e)||null;return Boolean(t&&"shadowRoot"in t&&kf.shadowRoot(t)===e)}function If(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function Cf(e){try{const n=e.rules||e.cssRules;if(!n)return null;let r=e.href;return!r&&e.ownerNode&&(r=e.ownerNode.baseURI),(t=Array.from(n,e=>Ef(e,r)).join("")).includes(" background-clip: text;")&&!t.includes(" -webkit-background-clip: text;")&&(t=t.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;")),t}catch(n){return null}var t}function Ef(e,t){if(function(e){return"styleSheet"in e}(e)){let t;try{t=Cf(e.styleSheet)||function(e){const{cssText:t}=e;if(t.split('"').length<3)return t;const n=["@import",`url(${JSON.stringify(e.href)})`];return""===e.layerName?n.push("layer"):e.layerName&&n.push(`layer(${e.layerName})`),e.supportsText&&n.push(`supports(${e.supportsText})`),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}(e)}catch(n){t=e.cssText}return e.styleSheet.href?Df(t,e.styleSheet.href):t}{let n=e.cssText;return function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":")&&(n=n.replace(/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,"$1\\$2")),t?Df(n,t):n}}var Tf=class{constructor(){tf(this,"idNodeMap",/* @__PURE__ */new Map),tf(this,"nodeMetaMap",/* @__PURE__ */new WeakMap)}getId(e){var t;return e?(null==(t=this.getMeta(e))?void 0:t.id)??-1:-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){const n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)}replace(e,t){const n=this.getNode(e);if(n){const e=this.nodeMetaMap.get(n);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=/* @__PURE__ */new Map,this.nodeMetaMap=/* @__PURE__ */new WeakMap}};function Mf({element:e,maskInputOptions:t,tagName:n,type:r,value:o,maskInputFn:i}){let s=o||"";const a=r&&zf(r);return(t[n.toLowerCase()]||a&&t[a])&&(s=i?i(s,e):"*".repeat(s.length)),s}function zf(e){return e.toLowerCase()}var Of="__rrweb_original__";function Rf(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?zf(t):null}function Af(e,t){let n;try{n=new URL(e,t??window.location.href)}catch(o){return null}const r=n.pathname.match(/\.([0-9a-z]+)(?:$)/i);return(null==r?void 0:r[1])??null}var Nf=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Pf=/^(?:[a-z+]+:)?\/\//i,Lf=/^www\..*/i,$f=/^(data:)([^,]*),(.*)/i;function Df(e,t){return(e||"").replace(Nf,(e,n,r,o,i,s)=>{const a=r||i||s,c=n||o||"";if(!a)return e;if(Pf.test(a)||Lf.test(a))return`url(${c}${a}${c})`;if($f.test(a))return`url(${c}${a}${c})`;if("/"===a[0])return`url(${c}${function(e){let t="";return t=e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0],t=t.split("?")[0],t}(t)+a}${c})`;const l=a.split("#")[0],d=a.substring(l.length),u=t.split("#")[0].split("/"),p=l.split("/");u.pop();for(const t of p){if("."===t)continue;".."===t?u.pop():u.push(t)}return`url(${c}${u.join("/")}${d}${c})`})}function Ff(e,t=!1){return t?e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,""):e.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}function jf(e,t){return function(e,t,n=!1){const r=Array.from(t.childNodes),o=[];let i=0;if(r.length>1&&e&&"string"==typeof e){let t=Ff(e,n);const s=t.length/e.length;for(let a=1;a<r.length;a++)if(r[a].textContent&&"string"==typeof r[a].textContent){const c=Ff(r[a].textContent,n),l=100;let d=3;for(;d<c.length&&(c[d].match(/[a-zA-Z0-9]/)||-1!==c.indexOf(c.substring(0,d),1));d++);for(;d<c.length;d++){let u=c.substring(0,d),p=t.split(u),h=-1;if(2===p.length)h=p[0].length;else if(p.length>2&&""===p[0]&&""!==r[a-1].textContent)h=t.indexOf(u,1);else if(1===p.length){if(u=u.substring(0,u.length-1),p=t.split(u),p.length<=1)return o.push(e),o;d=101}else d===c.length-1&&(h=t.indexOf(u));if(p.length>=2&&d>l){const e=r[a-1].textContent;if(e&&"string"==typeof e){const n=Ff(e).length;h=t.indexOf(u,n)}-1===h&&(h=p[0].length)}if(-1!==h){let a=Math.floor(h/s);for(;a>0&&a<e.length;){if(i+=1,i>50*r.length)return o.push(e),o;const c=Ff(e.substring(0,a),n);if(c.length===h){o.push(e.substring(0,a)),e=e.substring(a),t=t.substring(h);break}c.length<h?a+=Math.max(1,Math.floor((h-c.length)/s)):a-=Math.max(1,Math.floor((c.length-h)*s))}break}}}}return o.push(e),o}(e,t).join("/* rr_split */")}var Uf,Wf,Bf=1,Hf=/* @__PURE__ */new RegExp("[^a-z0-9-_:]");function qf(){return Bf++}var Zf=/^[^ \t\n\r\u000c]+/,Vf=/^[, \t\n\r\u000c]+/;var Gf=/* @__PURE__ */new WeakMap;function Yf(e,t){return t&&""!==t.trim()?Jf(e,t):t}function Kf(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function Jf(e,t){let n=Gf.get(e);if(n||(n=e.createElement("a"),Gf.set(e,n)),t){if(t.startsWith("blob:")||t.startsWith("data:"))return t}else t="";return n.setAttribute("href",t),n.href}function Xf(e,t,n,r){return r?"src"===n||"href"===n&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&"#"!==r[0]||"background"===n&&["table","td","th"].includes(t)?Yf(e,r):"srcset"===n?function(e,t){if(""===t.trim())return t;let n=0;function r(e){let r;const o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}const o=[];for(;r(Vf),!(n>=t.length);){let i=r(Zf);if(","===i.slice(-1))i=Yf(e,i.substring(0,i.length-1)),o.push(i);else{let r="";i=Yf(e,i);let s=!1;for(;;){const e=t.charAt(n);if(""===e){o.push((i+r).trim());break}if(s)")"===e&&(s=!1);else{if(","===e){n+=1,o.push((i+r).trim());break}"("===e&&(s=!0)}r+=e,n+=1}}}return o.join(", ")}(e,r):"style"===n?Df(r,Jf(e)):"object"===t&&"data"===n?Yf(e,r):r:r}function Qf(e,t,n){return["video","audio"].includes(e)&&"autoplay"===t}function em(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&em(kf.parentNode(e),t,n);for(let r=e.classList.length;r--;){const n=e.classList[r];if(t.test(n))return!0}return!!n&&em(kf.parentNode(e),t,n)}function tm(e,t,n,r){let o;if(Sf(e)){if(o=e,!kf.childNodes(o).length)return!1}else{if(null===kf.parentElement(e))return!1;o=kf.parentElement(e)}try{if("string"==typeof t){if(r){if(o.closest(`.${t}`))return!0}else if(o.classList.contains(t))return!0}else if(em(o,t,r))return!0;if(n)if(r){if(o.closest(n))return!0}else if(o.matches(n))return!0}catch(i){}return!1}function nm(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:s,inlineStylesheet:a,maskInputOptions:c={},maskTextFn:l,maskInputFn:d,dataURLOptions:u={},inlineImages:p,recordCanvas:h,keepIframeSrcFn:f,newlyAddedElement:m=!1,cssCaptured:g=!1}=t,y=function(e,t){if(!t.hasNode(e))return;const n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:lf.Document,childNodes:[],compatMode:e.compatMode}:{type:lf.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:lf.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:y};case e.ELEMENT_NODE:return function(e,t){const{doc:n,blockClass:r,blockSelector:o,inlineStylesheet:i,maskInputOptions:s={},maskInputFn:a,dataURLOptions:c={},inlineImages:l,recordCanvas:d,keepIframeSrcFn:u,newlyAddedElement:p=!1,rootId:h}=t,f=function(e,t,n){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){const r=e.classList[n];if(t.test(r))return!0}if(n)return e.matches(n)}catch(r){}return!1}(e,r,o),m=function(e){if(e instanceof HTMLFormElement)return"form";const t=zf(e.tagName);return Hf.test(t)?"div":t}(e);let g={};const y=e.attributes.length;for(let v=0;v<y;v++){const t=e.attributes[v];Qf(m,t.name,t.value)||(g[t.name]=Xf(n,m,zf(t.name),t.value))}if("link"===m&&i){const t=Array.from(n.styleSheets).find(t=>t.href===e.href);let r=null;t&&(r=Cf(t)),r&&(delete g.rel,delete g.href,g._cssText=r)}if("style"===m&&e.sheet){let t=Cf(e.sheet);t&&(e.childNodes.length>1&&(t=jf(t,e)),g._cssText=t)}if(["input","textarea","select"].includes(m)){const t=e.value,n=e.checked;"radio"!==g.type&&"checkbox"!==g.type&&"submit"!==g.type&&"button"!==g.type&&t?g.value=Mf({element:e,type:Rf(e),tagName:m,value:t,maskInputOptions:s,maskInputFn:a}):n&&(g.checked=n)}"option"===m&&(e.selected&&!s.select?g.selected=!0:delete g.selected);"dialog"===m&&e.open&&(g.rr_open_mode=e.matches("dialog:modal")?"modal":"non-modal");if("canvas"===m&&d)if("2d"===e.__context)(function(e){const t=e.getContext("2d");if(!t)return!0;for(let n=0;n<e.width;n+=50)for(let r=0;r<e.height;r+=50){const o=t.getImageData,i=Of in o?o[Of]:o;if(new Uint32Array(i.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some(e=>0!==e))return!1}return!0})(e)||(g.rr_dataURL=e.toDataURL(c.type,c.quality));else if(!("__context"in e)){const t=e.toDataURL(c.type,c.quality),r=n.createElement("canvas");r.width=e.width,r.height=e.height,t!==r.toDataURL(c.type,c.quality)&&(g.rr_dataURL=t)}if("img"===m&&l){Uf||(Uf=n.createElement("canvas"),Wf=Uf.getContext("2d"));const t=e,r=(t.currentSrc||t.getAttribute("src"),t.crossOrigin),o=()=>{t.removeEventListener("load",o);try{Uf.width=t.naturalWidth,Uf.height=t.naturalHeight,Wf.drawImage(t,0,0),g.rr_dataURL=Uf.toDataURL(c.type,c.quality)}catch(e){if("anonymous"!==t.crossOrigin)return t.crossOrigin="anonymous",void(t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o))}"anonymous"===t.crossOrigin&&(r?g.crossOrigin=r:t.removeAttribute("crossorigin"))};t.complete&&0!==t.naturalWidth?o():t.addEventListener("load",o)}if(["audio","video"].includes(m)){const t=g;t.rr_mediaState=e.paused?"paused":"played",t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}p||(e.scrollLeft&&(g.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(g.rr_scrollTop=e.scrollTop));if(f){const{width:t,height:n}=e.getBoundingClientRect();g={class:g.class,rr_width:`${t}px`,rr_height:`${n}px`}}"iframe"!==m||u(g.src)||(e.contentDocument||(g.rr_src=g.src),delete g.src);let b;try{customElements.get(m)&&(b=!0)}catch(w){}return{type:lf.Element,tagName:m,attributes:g,childNodes:[],isSVG:Kf(e)||void 0,needBlock:f,rootId:h,isCustom:b}}(e,{doc:n,blockClass:o,blockSelector:i,inlineStylesheet:a,maskInputOptions:c,maskInputFn:d,dataURLOptions:u,inlineImages:p,recordCanvas:h,keepIframeSrcFn:f,newlyAddedElement:m,rootId:y});case e.TEXT_NODE:return function(e,t){const{needsMask:n,maskTextFn:r,rootId:o,cssCaptured:i}=t,s=kf.parentNode(e),a=s&&s.tagName;let c="";const l="STYLE"===a||void 0,d="SCRIPT"===a||void 0;d?c="SCRIPT_PLACEHOLDER":i||(c=kf.textContent(e),l&&c&&(c=Df(c,Jf(t.doc))));!l&&!d&&c&&n&&(c=r?r(c,kf.parentElement(e)):c.replace(/[\S]/g,"*"));return{type:lf.Text,textContent:c||"",rootId:o}}(e,{doc:n,needsMask:s,maskTextFn:l,rootId:y,cssCaptured:g});case e.CDATA_SECTION_NODE:return{type:lf.CDATA,textContent:"",rootId:y};case e.COMMENT_NODE:return{type:lf.Comment,textContent:kf.textContent(e)||"",rootId:y};default:return!1}}function rm(e){return null==e?"":e.toLowerCase()}function om(e){return!0===e||"all"===e?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===e,headMetaDescKeywords:"all"===e,headTitleMutations:"all"===e}:e||{}}function im(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:i,maskTextClass:s,maskTextSelector:a,skipChild:c=!1,inlineStylesheet:l=!0,maskInputOptions:d={},maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f={},inlineImages:m=!1,recordCanvas:g=!1,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:w=5e3,onStylesheetLoad:v,stylesheetLoadTimeout:x=5e3,keepIframeSrcFn:k=()=>!1,newlyAddedElement:S=!1,cssCaptured:_=!1}=t;let{needsMask:I}=t,{preserveWhiteSpace:C=!0}=t;I||(I=tm(e,s,a,void 0===I));const E=nm(e,{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:I,inlineStylesheet:l,maskInputOptions:d,maskTextFn:u,maskInputFn:p,dataURLOptions:f,inlineImages:m,recordCanvas:g,keepIframeSrcFn:k,newlyAddedElement:S,cssCaptured:_});if(!E)return null;let T;T=r.hasNode(e)?r.getId(e):function(e,t){if(t.comment&&e.type===lf.Comment)return!0;if(e.type===lf.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel&&"script"===e.attributes.as||"modulepreload"===e.attributes.rel)||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&"js"===Af(e.attributes.href)))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(rm(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===rm(e.attributes.name)||"icon"===rm(e.attributes.rel)||"apple-touch-icon"===rm(e.attributes.rel)||"shortcut icon"===rm(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&rm(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(rm(e.attributes.property).match(/^(og|twitter|fb):/)||rm(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===rm(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===rm(e.attributes.name)||"googlebot"===rm(e.attributes.name)||"bingbot"===rm(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===rm(e.attributes.name)||"generator"===rm(e.attributes.name)||"framework"===rm(e.attributes.name)||"publisher"===rm(e.attributes.name)||"progid"===rm(e.attributes.name)||rm(e.attributes.property).match(/^article:/)||rm(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===rm(e.attributes.name)||"yandex-verification"===rm(e.attributes.name)||"csrf-token"===rm(e.attributes.name)||"p:domain_verify"===rm(e.attributes.name)||"verify-v1"===rm(e.attributes.name)||"verification"===rm(e.attributes.name)||"shopify-checkout-api-token"===rm(e.attributes.name)))return!0}}return!1}(E,h)||!C&&E.type===lf.Text&&!E.textContent.replace(/^\s+|\s+$/gm,"").length?-2:qf();const M=Object.assign(E,{id:T});if(r.add(e,M),-2===T)return null;y&&y(e);let z=!c;if(M.type===lf.Element){z=z&&!M.needBlock,delete M.needBlock;const t=kf.shadowRoot(e);t&&If(t)&&(M.isShadowHost=!0)}if((M.type===lf.Document||M.type===lf.Element)&&z){h.headWhitespace&&M.type===lf.Element&&"head"===M.tagName&&(C=!1);const t={doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:I,maskTextClass:s,maskTextSelector:a,skipChild:c,inlineStylesheet:l,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:C,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:w,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k,cssCaptured:!1};if(M.type===lf.Element&&"textarea"===M.tagName&&void 0!==M.attributes.value);else{M.type===lf.Element&&void 0!==M.attributes._cssText&&"string"==typeof M.attributes._cssText&&(t.cssCaptured=!0);for(const n of Array.from(kf.childNodes(e))){const e=im(n,t);e&&M.childNodes.push(e)}}let S=null;if(Sf(e)&&(S=kf.shadowRoot(e)))for(const e of Array.from(kf.childNodes(S))){const n=im(e,t);n&&(If(S)&&(n.isShadow=!0),M.childNodes.push(n))}}const O=kf.parentNode(e);return O&&_f(O)&&If(O)&&(M.isShadow=!0),M.type===lf.Element&&"iframe"===M.tagName&&function(e,t,n){const r=e.contentWindow;if(!r)return;let o,i=!1;try{o=r.document.readyState}catch(a){return}if("complete"!==o){const r=setTimeout(()=>{i||(t(),i=!0)},n);return void e.addEventListener("load",()=>{clearTimeout(r),i=!0,t()})}const s="about:blank";if(r.location.href!==s||e.src===s||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}(e,()=>{const t=e.contentDocument;if(t&&b){const n=im(t,{doc:t,mirror:r,blockClass:o,blockSelector:i,needsMask:I,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:l,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:C,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:w,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k});n&&b(e,n)}},w),M.type===lf.Element&&"link"===M.tagName&&"string"==typeof M.attributes.rel&&("stylesheet"===M.attributes.rel||"preload"===M.attributes.rel&&"string"==typeof M.attributes.href&&"css"===Af(M.attributes.href))&&function(e,t,n){let r,o=!1;try{r=e.sheet}catch(s){return}if(r)return;const i=setTimeout(()=>{o||(t(),o=!0)},n);e.addEventListener("load",()=>{clearTimeout(i),o=!0,t()})}(e,()=>{if(v){const t=im(e,{doc:n,mirror:r,blockClass:o,blockSelector:i,needsMask:I,maskTextClass:s,maskTextSelector:a,skipChild:!1,inlineStylesheet:l,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:f,inlineImages:m,recordCanvas:g,preserveWhiteSpace:C,onSerialize:y,onIframeLoad:b,iframeLoadTimeout:w,onStylesheetLoad:v,stylesheetLoadTimeout:x,keepIframeSrcFn:k});t&&v(e,t)}},x),M}var sm=class e{constructor(...e){tf(this,"parentElement",null),tf(this,"parentNode",null),tf(this,"ownerDocument"),tf(this,"firstChild",null),tf(this,"lastChild",null),tf(this,"previousSibling",null),tf(this,"nextSibling",null),tf(this,"ELEMENT_NODE",1),tf(this,"TEXT_NODE",3),tf(this,"nodeType"),tf(this,"nodeName"),tf(this,"RRNodeType")}get childNodes(){const e=[];let t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(t){if(!(t instanceof e))return!1;if(t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,t){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}};function am(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}var cm={map:{},getId:()=>-1,getNode:()=>null,removeNodeFromMap(){},has:()=>!1,reset(){}};function lm(e,t,n={}){let r=null,o=0;return function(...i){const s=Date.now();o||!1!==n.leading||(o=s);const a=t-(s-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=s,e.apply(c,i)):r||!1===n.trailing||(r=setTimeout(()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,i)},a))}}function dm(e,t,n,r,o=window){const i=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),i&&i.set&&i.set.call(this,e)}}),()=>dm(e,t,i||{},!0)}function um(e){var t,n,r,o;const i=e.document;return{left:i.scrollingElement?i.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:i.documentElement.scrollLeft||(null==i?void 0:i.body)&&(null==(t=kf.parentElement(i.body))?void 0:t.scrollLeft)||(null==(n=null==i?void 0:i.body)?void 0:n.scrollLeft)||0,top:i.scrollingElement?i.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==i?void 0:i.documentElement.scrollTop)||(null==i?void 0:i.body)&&(null==(r=kf.parentElement(i.body))?void 0:r.scrollTop)||(null==(o=null==i?void 0:i.body)?void 0:o.scrollTop)||0}}function pm(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function hm(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function fm(e){return e?e.nodeType===e.ELEMENT_NODE?e:kf.parentElement(e):null}function mm(e,t,n,r){if(!e)return!1;const o=fm(e);if(!o)return!1;try{if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(em(o,t,r))return!0}catch(i){}if(n){if(o.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function gm(e,t,n){return!("TITLE"!==e.tagName||!n.headTitleMutations)||-2===t.getId(e)}function ym(e,t){if(_f(e))return!1;const n=t.getId(e);if(!t.has(n))return!0;const r=kf.parentNode(e);return(!r||r.nodeType!==e.DOCUMENT_NODE)&&(!r||ym(r,t))}function bm(e){return Boolean(e.changedTouches)}function wm(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function vm(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function xm(e){return!!e&&(e instanceof sm&&"shadowRoot"in e?Boolean(e.shadowRoot):Boolean(kf.shadowRoot(e)))}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(cm=new Proxy(cm,{get:(e,t,n)=>Reflect.get(e,t,n)}));var km=class{constructor(){tf(this,"id",1),tf(this,"styleIDMap",/* @__PURE__ */new WeakMap),tf(this,"idStyleMap",/* @__PURE__ */new Map)}getId(e){return this.styleIDMap.get(e)??-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=/* @__PURE__ */new WeakMap,this.idStyleMap=/* @__PURE__ */new Map,this.id=1}generateId(){return this.id++}};function Sm(e){var t;let n=null;return"getRootNode"in e&&(null==(t=kf.getRootNode(e))?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&kf.host(kf.getRootNode(e))&&(n=kf.host(kf.getRootNode(e))),n}function _m(e){const t=kf.ownerDocument(e);if(!t)return!1;const n=function(e){let t,n=e;for(;t=Sm(n);)n=t;return n}(e);return kf.contains(t,n)}function Im(e){const t=kf.ownerDocument(e);return!!t&&(kf.contains(t,e)||_m(e))}function Cm(e){return"__ln"in e}var Em,Tm=class{constructor(){tf(this,"length",0),tf(this,"head",null),tf(this,"tail",null)}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&Cm(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&Cm(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}},Mm=(e,t)=>`${e}@${t}`,zm=class{constructor(){tf(this,"frozen",!1),tf(this,"locked",!1),tf(this,"texts",[]),tf(this,"attributes",[]),tf(this,"attributeMap",/* @__PURE__ */new WeakMap),tf(this,"removes",[]),tf(this,"mapRemoves",[]),tf(this,"movedMap",{}),tf(this,"addedSet",/* @__PURE__ */new Set),tf(this,"movedSet",/* @__PURE__ */new Set),tf(this,"droppedSet",/* @__PURE__ */new Set),tf(this,"removesSubTreeCache",/* @__PURE__ */new Set),tf(this,"mutationCb"),tf(this,"blockClass"),tf(this,"blockSelector"),tf(this,"maskTextClass"),tf(this,"maskTextSelector"),tf(this,"inlineStylesheet"),tf(this,"maskInputOptions"),tf(this,"maskTextFn"),tf(this,"maskInputFn"),tf(this,"keepIframeSrcFn"),tf(this,"recordCanvas"),tf(this,"inlineImages"),tf(this,"slimDOMOptions"),tf(this,"dataURLOptions"),tf(this,"doc"),tf(this,"mirror"),tf(this,"iframeManager"),tf(this,"stylesheetManager"),tf(this,"shadowDomManager"),tf(this,"canvasManager"),tf(this,"processedNodeManager"),tf(this,"unattachedDoc"),tf(this,"processMutations",e=>{e.forEach(this.processMutation),this.emit()}),tf(this,"emit",()=>{if(this.frozen||this.locked)return;const e=[],t=/* @__PURE__ */new Set,n=new Tm,r=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{const i=kf.parentNode(o);if(!i||!Im(o))return;let s=!1;if(o.nodeType===Node.TEXT_NODE){const e=i.tagName;if("TEXTAREA"===e)return;"STYLE"===e&&this.addedSet.has(i)&&(s=!0)}const a=_f(i)?this.mirror.getId(Sm(o)):this.mirror.getId(i),c=r(o);if(-1===a||-1===c)return n.addNode(o);const l=im(o,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{wm(e,this.mirror)&&this.iframeManager.addIframe(e),vm(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),xm(o)&&this.shadowDomManager.addShadowRoot(kf.shadowRoot(o),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)},cssCaptured:s});l&&(e.push({parentId:a,nextId:c,node:l}),t.add(l.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of this.movedSet)Rm(this.removesSubTreeCache,a,this.mirror)&&!this.movedSet.has(kf.parentNode(a))||o(a);for(const a of this.addedSet)Am(this.droppedSet,a)||Rm(this.removesSubTreeCache,a,this.mirror)?Am(this.movedSet,a)?o(a):this.droppedSet.add(a):o(a);let i=null;for(;n.length;){let e=null;if(i){const t=this.mirror.getId(kf.parentNode(i.value)),n=r(i.value);-1!==t&&-1!==n&&(e=i)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(kf.parentNode(n.value));if(-1===r(n.value))continue;if(-1!==t){e=n;break}{const t=n.value,r=kf.parentNode(t);if(r&&r.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const t=kf.host(r);if(-1!==this.mirror.getId(t)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}i=e.previous,n.removeNode(e.value),o(e.value)}const s={texts:this.texts.map(e=>{const t=e.node,n=kf.parentNode(t);return n&&"TEXTAREA"===n.tagName&&this.genTextAreaValueMutation(n),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>{const{attributes:t}=e;if("string"==typeof t.style){const n=JSON.stringify(e.styleDiff),r=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+r).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.attributeMap=/* @__PURE__ */new WeakMap,this.removes=[],this.addedSet=/* @__PURE__ */new Set,this.movedSet=/* @__PURE__ */new Set,this.droppedSet=/* @__PURE__ */new Set,this.removesSubTreeCache=/* @__PURE__ */new Set,this.movedMap={},this.mutationCb(s))}),tf(this,"genTextAreaValueMutation",e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t));const n=Array.from(kf.childNodes(e),e=>kf.textContent(e)||"").join("");t.attributes.value=Mf({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:Rf(e),value:n,maskInputFn:this.maskInputFn})}),tf(this,"processMutation",e=>{if(!gm(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case"characterData":{const t=kf.textContent(e.target);mm(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:tm(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,fm(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const n=e.target;let r=e.attributeName,o=e.target.getAttribute(r);if("value"===r){const e=Rf(n);o=Mf({element:n,maskInputOptions:this.maskInputOptions,tagName:n.tagName,type:e,value:o,maskInputFn:this.maskInputFn})}if(mm(e.target,this.blockClass,this.blockSelector,!1)||o===e.oldValue)return;let i=this.attributeMap.get(e.target);if("IFRAME"===n.tagName&&"src"===r&&!this.keepIframeSrcFn(o)){if(n.contentDocument)return;r="rr_src"}if(i||(i={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(i),this.attributeMap.set(e.target,i)),"type"===r&&"INPUT"===n.tagName&&"password"===(e.oldValue||"").toLowerCase()&&n.setAttribute("data-rr-is-password","true"),!Qf(n.tagName,r))if(i.attributes[r]=Xf(this.doc,zf(n.tagName),zf(r),o),"style"===r){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(t){this.unattachedDoc=this.doc}const r=this.unattachedDoc.createElement("span");e.oldValue&&r.setAttribute("style",e.oldValue);for(const e of Array.from(n.style)){const t=n.style.getPropertyValue(e),o=n.style.getPropertyPriority(e);t!==r.style.getPropertyValue(e)||o!==r.style.getPropertyPriority(e)?i.styleDiff[e]=""===o?t:[t,o]:i._unchangedStyles[e]=[t,o]}for(const e of Array.from(r.style))""===n.style.getPropertyValue(e)&&(i.styleDiff[e]=!1)}else"open"===r&&"DIALOG"===n.tagName&&(n.matches("dialog:modal")?i.attributes.rr_open_mode="modal":i.attributes.rr_open_mode="non-modal");break}case"childList":if(mm(e.target,this.blockClass,this.blockSelector,!0))return;if("TEXTAREA"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const n=this.mirror.getId(t),r=_f(e.target)?this.mirror.getId(kf.host(e.target)):this.mirror.getId(e.target);mm(e.target,this.blockClass,this.blockSelector,!1)||gm(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(Om(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||ym(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Mm(n,r)]?Om(this.movedSet,t):(this.removes.push({parentId:r,id:n,isShadow:!(!_f(e.target)||!If(e.target))||void 0}),function(e,t){const n=[e];for(;n.length;){const e=n.pop();t.has(e)||(t.add(e),kf.childNodes(e).forEach(e=>n.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.push(t))})}}),tf(this,"genAdds",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(gm(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[Mm(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);mm(e,this.blockClass,this.blockSelector,!1)||(kf.childNodes(e).forEach(e=>this.genAdds(e)),xm(e)&&kf.childNodes(kf.shadowRoot(e)).forEach(t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)}))}})}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(t=>{this[t]=e[t]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}};function Om(e,t){e.delete(t),kf.childNodes(t).forEach(t=>Om(e,t))}function Rm(e,t,n){return 0!==e.size&&function(e,t){const n=kf.parentNode(t);return!!n&&e.has(n)}(e,t)}function Am(e,t){return 0!==e.size&&Nm(e,t)}function Nm(e,t){const n=kf.parentNode(t);return!!n&&(!!e.has(n)||Nm(e,n))}var Pm=e=>{if(!Em)return e;return(...t)=>{try{return e(...t)}catch(n){if(Em&&!0===Em(n))return;throw n}}},Lm=[];function $m(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch{}return e&&e.target}function Dm(e,t){const n=new zm;Lm.push(n),n.init(e);const[r,o]=wf(),i=new r(Pm(n.processMutations.bind(n)));return i.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),[i,o]}function Fm({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){if(!1===i.mouseInteraction)return()=>{};const s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,a=[];let c=null;return Object.keys(of).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]).forEach(i=>{let s=zf(i);const l=(t=>i=>{const s=$m(i);if(mm(s,r,o,!0))return;let a=null,l=t;if("pointerType"in i){switch(i.pointerType){case"mouse":a=sf.Mouse;break;case"touch":a=sf.Touch;break;case"pen":a=sf.Pen}a===sf.Touch?of[t]===of.MouseDown?l="TouchStart":of[t]===of.MouseUp&&(l="TouchEnd"):sf.Pen}else bm(i)&&(a=sf.Touch);null!==a?(c=a,(l.startsWith("Touch")&&a===sf.Touch||l.startsWith("Mouse")&&a===sf.Mouse)&&(a=null)):of[t]===of.Click&&(a=c,c=null);const d=bm(i)?i.changedTouches[0]:i;if(!d)return;const u=n.getId(s),{clientX:p,clientY:h}=d;Pm(e)({type:of[l],id:u,x:p,y:h,...null!==a&&{pointerType:a}})})(i);if(window.PointerEvent)switch(of[i]){case of.MouseDown:case of.MouseUp:s=s.replace("mouse","pointer");break;case of.TouchStart:case of.TouchEnd:return}a.push(am(s,l,t))}),Pm(()=>{a.forEach(e=>e())})}function jm({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){return am("scroll",Pm(lm(Pm(i=>{const s=$m(i);if(!s||mm(s,r,o,!0))return;const a=n.getId(s);if(s===t&&t.defaultView){const n=um(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:s.scrollLeft,y:s.scrollTop})}),i.scroll||100)),t)}var Um=["INPUT","TEXTAREA","SELECT"],Wm=/* @__PURE__ */new WeakMap;function Bm(e){return function e(t,n){if(Vm("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||Vm("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||Vm("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||Vm("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){const r=Array.from(t.parentRule.cssRules).indexOf(t);return n.unshift(r),e(t.parentRule,n)}if(t.parentStyleSheet){const e=Array.from(t.parentStyleSheet.cssRules).indexOf(t);n.unshift(e)}return n}(e,[])}function Hm(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function qm({mirror:e,stylesheetManager:t},n){var r,o,i;let s=null;s="#document"===n.nodeName?e.getId(n):e.getId(kf.host(n));const a="#document"===n.nodeName?null==(r=n.defaultView)?void 0:r.Document:null==(i=null==(o=n.ownerDocument)?void 0:o.defaultView)?void 0:i.ShadowRoot,c=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==s&&-1!==s&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null==(e=c.get)?void 0:e.call(this)},set(e){var n;const r=null==(n=c.set)?void 0:n.call(this,e);if(null!==s&&-1!==s)try{t.adoptStyleSheets(e,s)}catch(o){}return r}}),Pm(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})})):()=>{}}function Zm(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let r;!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:i,viewportResizeCb:s,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:u,fontCb:p,selectionCb:h,customElementCb:f}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),i(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),s(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),p(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),h(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),f(...e)}}(e,t);let o=()=>{};e.recordDOM&&([r,o]=Dm(e,e.doc));const i=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,i="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let s,a=[];const c=lm(Pm(t=>{const n=Date.now()-s;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],s=null}),i),l=Pm(lm(Pm(e=>{const t=$m(e),{clientX:n,clientY:o}=bm(e)?e.changedTouches[0]:e;s||(s=vf()),a.push({x:n,y:o,id:r.getId(t),timeOffset:vf()-s}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?rf.Drag:e instanceof MouseEvent?rf.MouseMove:rf.TouchMove)}),o,{trailing:!1})),d=[am("mousemove",l,n),am("touchmove",l,n),am("drag",l,n)];return Pm(()=>{d.forEach(e=>e())})}(e),s=Fm(e),a=jm(e),c=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return am("resize",Pm(lm(Pm(()=>{const t=pm(),o=hm();n===t&&r===o||(e({width:Number(o),height:Number(t)}),n=t,r=o)}),200)),t)}(e,{win:n}),l=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:i,ignoreSelector:s,maskInputOptions:a,maskInputFn:c,sampling:l,userTriggeredOnInput:d}){function u(e){let n=$m(e);const l=e.isTrusted,u=n&&n.tagName;if(n&&"OPTION"===u&&(n=kf.parentElement(n)),!n||!u||Um.indexOf(u)<0||mm(n,r,o,!0))return;if(n.classList.contains(i)||s&&n.matches(s))return;let h=n.value,f=!1;const m=Rf(n)||"";"radio"===m||"checkbox"===m?f=n.checked:(a[u.toLowerCase()]||a[m])&&(h=Mf({element:n,maskInputOptions:a,tagName:u,type:m,value:h,maskInputFn:c})),p(n,d?{text:h,isChecked:f,userTriggered:l}:{text:h,isChecked:f});const g=n.name;"radio"===m&&g&&f&&t.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(e=>{if(e!==n){const t=e.value;p(e,d?{text:t,isChecked:!f,userTriggered:!1}:{text:t,isChecked:!f})}})}function p(t,r){const o=Wm.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){Wm.set(t,r);const o=n.getId(t);Pm(e)({...r,id:o})}}const h=("last"===l.input?["change"]:["input","change"]).map(e=>am(e,Pm(u),t)),f=t.defaultView;if(!f)return()=>{h.forEach(e=>e())};const m=f.Object.getOwnPropertyDescriptor(f.HTMLInputElement.prototype,"value"),g=[[f.HTMLInputElement.prototype,"value"],[f.HTMLInputElement.prototype,"checked"],[f.HTMLSelectElement.prototype,"value"],[f.HTMLTextAreaElement.prototype,"value"],[f.HTMLSelectElement.prototype,"selectedIndex"],[f.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&h.push(...g.map(e=>dm(e[0],e[1],{set(){Pm(u)({target:this,isTrusted:!1})}},!1,f))),Pm(()=>{h.forEach(e=>e())})}(e),d=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o,doc:i}){const s=Pm(i=>lm(Pm(o=>{const s=$m(o);if(!s||mm(s,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d,loop:u}=s;e({type:i,id:r.getId(s),currentTime:a,volume:c,muted:l,playbackRate:d,loop:u})}),o.media||500)),a=[am("play",s(cf.Play),i),am("pause",s(cf.Pause),i),am("seeked",s(cf.Seeked),i),am("volumechange",s(cf.VolumeChange),i),am("ratechange",s(cf.RateChange),i)];return Pm(()=>{a.forEach(e=>e())})}(e);let u=()=>{},p=()=>{},h=()=>{},f=()=>{};e.recordDOM&&(u=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(o,{apply:Pm((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=Hm(o,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:a}]}),r.apply(o,i)})}),r.CSSStyleSheet.prototype.addRule=function(e,t,n=this.cssRules.length){const o=`${e} { ${t} }`;return r.CSSStyleSheet.prototype.insertRule.apply(this,[o,n])};const i=r.CSSStyleSheet.prototype.deleteRule;let s,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(i,{apply:Pm((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Hm(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:s}]}),r.apply(o,i)})}),r.CSSStyleSheet.prototype.removeRule=function(e){return r.CSSStyleSheet.prototype.deleteRule.apply(this,[e])},r.CSSStyleSheet.prototype.replace&&(s=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(s,{apply:Pm((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Hm(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replace:s}),r.apply(o,i)})})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:Pm((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Hm(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replaceSync:s}),r.apply(o,i)})}));const c={};Gm("CSSGroupingRule")?c.CSSGroupingRule=r.CSSGroupingRule:(Gm("CSSMediaRule")&&(c.CSSMediaRule=r.CSSMediaRule),Gm("CSSConditionRule")&&(c.CSSConditionRule=r.CSSConditionRule),Gm("CSSSupportsRule")&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach(([r,o])=>{l[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=new Proxy(l[r].insertRule,{apply:Pm((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=Hm(o.parentStyleSheet,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:[...Bm(o),a||0]}]}),r.apply(o,i)})}),o.prototype.deleteRule=new Proxy(l[r].deleteRule,{apply:Pm((r,o,i)=>{const[s]=i,{id:a,styleId:c}=Hm(o.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:[...Bm(o),s]}]}),r.apply(o,i)})})}),Pm(()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=i,s&&(r.CSSStyleSheet.prototype.replace=s),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule})})}(e,{win:n}),p=qm(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const i=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(i,{apply:Pm((o,s,a)=>{var c;const[l,d,u]=a;if(n.has(l))return i.apply(s,[l,d,u]);const{id:p,styleId:h}=Hm(null==(c=s.parentRule)?void 0:c.parentStyleSheet,t,r.styleMirror);return(p&&-1!==p||h&&-1!==h)&&e({id:p,styleId:h,set:{property:l,value:d,priority:u},index:Bm(s.parentRule)}),o.apply(s,a)})});const s=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(s,{apply:Pm((o,i,a)=>{var c;const[l]=a;if(n.has(l))return s.apply(i,[l]);const{id:d,styleId:u}=Hm(null==(c=i.parentRule)?void 0:c.parentStyleSheet,t,r.styleMirror);return(d&&-1!==d||u&&-1!==u)&&e({id:d,styleId:u,remove:{property:l},index:Bm(i.parentRule)}),o.apply(i,a)})}),Pm(()=>{o.CSSStyleDeclaration.prototype.setProperty=i,o.CSSStyleDeclaration.prototype.removeProperty=s})}(e,{win:n}),e.collectFonts&&(f=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=/* @__PURE__ */new WeakMap,i=n.FontFace;n.FontFace=function(e,t,n){const r=new i(e,t,n);return o.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const s=xf(t.fonts,"add",function(t){return function(n){return setTimeout(Pm(()=>{const t=o.get(n);t&&(e(t),o.delete(n))}),0),t.apply(this,[n])}});return r.push(()=>{n.FontFace=i}),r.push(s),Pm(()=>{r.forEach(e=>e())})}(e)));const m=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:i}=e;let s=!0;const a=Pm(()=>{const e=t.getSelection();if(!e||s&&(null==e?void 0:e.isCollapsed))return;s=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const{startContainer:i,startOffset:s,endContainer:c,endOffset:l}=e.getRangeAt(t);mm(i,r,o,!0)||mm(c,r,o,!0)||a.push({start:n.getId(i),startOffset:s,end:n.getId(c),endOffset:l})}i({ranges:a})});return a(),am("selectionchange",a)}(e),g=function({doc:e,customElementCb:t}){const n=e.defaultView;return n&&n.customElements?xf(n.customElements,"define",function(e){return function(n,r,o){try{t({define:{name:n}})}catch(i){}return e.apply(this,[n,r,o])}}):()=>{}}(e),y=[];for(const b of e.plugins)y.push(b.observer(b.callback,n,b.options));return Pm(()=>{Lm.forEach(e=>e.reset()),r?.disconnect(),o(),i(),s(),a(),c(),l(),d(),u(),p(),h(),f(),m(),g(),y.forEach(e=>e())})}function Vm(e){return void 0!==window[e]}function Gm(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}for(var Ym=class{constructor(e){tf(this,"iframeIdToRemoteIdMap",/* @__PURE__ */new WeakMap),tf(this,"iframeRemoteIdToIdMap",/* @__PURE__ */new WeakMap),this.generateIdFn=e}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),i=r||this.getRemoteIdToIdMap(e);let s=o.get(t);return s||(s=this.generateIdFn(),o.set(t,s),i.set(s,t)),s}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,r))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const o=r.get(t);return o||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,n))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=/* @__PURE__ */new WeakMap,void(this.iframeRemoteIdToIdMap=/* @__PURE__ */new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=/* @__PURE__ */new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=/* @__PURE__ */new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}},Km=class{constructor(e){tf(this,"iframes",/* @__PURE__ */new WeakMap),tf(this,"crossOriginIframeMap",/* @__PURE__ */new WeakMap),tf(this,"crossOriginIframeMirror",new Ym(qf)),tf(this,"crossOriginIframeStyleMirror"),tf(this,"crossOriginIframeRootIdMap",/* @__PURE__ */new WeakMap),tf(this,"mirror"),tf(this,"mutationCb"),tf(this,"wrappedEmit"),tf(this,"loadListener"),tf(this,"stylesheetManager"),tf(this,"recordCrossOriginIframes"),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Ym(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n,r;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&(null==(n=e.contentWindow)||n.addEventListener("message",this.handleMessage.bind(this))),null==(r=this.loadListener)||r.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const n=this.crossOriginIframeMap.get(e.source);if(!n)return;const r=this.transformCrossOriginEvent(n,t.data.event);r&&this.wrappedEmit(r,t.data.isCheckout)}transformCrossOriginEvent(e,t){var n;switch(t.type){case nf.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const n=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,n),this.patchRootIdOnNode(t.data.node,n),{timestamp:t.timestamp,type:nf.IncrementalSnapshot,data:{source:rf.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case nf.Meta:case nf.Load:case nf.DomContentLoaded:return!1;case nf.Plugin:return t;case nf.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case nf.IncrementalSnapshot:switch(t.data.source){case rf.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(t.node,n)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,["parentId","id"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,["id"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case rf.Drag:case rf.TouchMove:case rf.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,["id"])}),t;case rf.ViewportResize:return!1;case rf.MediaInteraction:case rf.MouseInteraction:case rf.Scroll:case rf.CanvasMutation:case rf.Input:return this.replaceIds(t.data,e,["id"]),t;case rf.StyleSheetRule:case rf.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case rf.Font:return t;case rf.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,["start","end"])}),t;case rf.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null==(n=t.data.styles)||n.forEach(t=>{this.replaceStyleIds(t,e,["styleId"])}),t}}return!1}replace(e,t,n,r){for(const o of r)(Array.isArray(t[o])||"number"==typeof t[o])&&(Array.isArray(t[o])?t[o]=e.getIds(n,t[o]):t[o]=e.getId(n,t[o]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}patchRootIdOnNode(e,t){e.type===lf.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}},Jm=class{constructor(e){tf(this,"shadowDoms",/* @__PURE__ */new WeakSet),tf(this,"mutationCb"),tf(this,"scrollCb"),tf(this,"bypassOptions"),tf(this,"mirror"),tf(this,"restoreHandlers",[]),this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){if(!If(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const[n]=Dm({...this.bypassOptions,doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},e);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(jm({...this.bypassOptions,scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(kf.host(e))),this.restoreHandlers.push(qm({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))},0)}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){const n=this;this.restoreHandlers.push(xf(e.prototype,"attachShadow",function(e){return function(r){const o=e.call(this,r),i=kf.shadowRoot(this);return i&&Im(this)&&n.addShadowRoot(i,t),o}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch(t){}}),this.restoreHandlers=[],this.shadowDoms=/* @__PURE__ */new WeakSet}},Xm="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Qm="undefined"==typeof Uint8Array?[]:/* @__PURE__ */new Uint8Array(256),eg=0;eg<64;eg++)Qm[Xm.charCodeAt(eg)]=eg;var tg=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=Xm[n[t]>>2],o+=Xm[(3&n[t])<<4|n[t+1]>>4],o+=Xm[(15&n[t+1])<<2|n[t+2]>>6],o+=Xm[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o},ng=/* @__PURE__ */new Map;var rg=(e,t,n)=>{if(!e||!sg(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=ng.get(e);return n||(n=/* @__PURE__ */new Map,ng.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function og(e,t,n){if(e instanceof Array)return e.map(e=>og(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:tg(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[og(e.buffer,t,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}return e instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:e.toDataURL()}:e instanceof ImageData?{rr_type:e.constructor.name,args:[og(e.data,t,n),e.width,e.height]}:sg(e,t)||"object"==typeof e?{rr_type:e.constructor.name,index:rg(e,t,n)}:e}var ig=(e,t,n)=>e.map(e=>og(e,t,n)),sg=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(e=>"function"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function ag(e,t,n,r){const o=[];try{const i=xf(e.HTMLCanvasElement.prototype,"getContext",function(e){return function(o,...i){if(!mm(this,t,n,!0)){const e=function(e){return"experimental-webgl"===e?"webgl":e}(o);if("__context"in this||(this.__context=e),r&&["webgl","webgl2"].includes(e))if(i[0]&&"object"==typeof i[0]){const e=i[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else i.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[o,...i])}});o.push(i)}catch{}return()=>{o.forEach(e=>e())}}function cg(e,t,n,r,o,i){const s=[],a=Object.getOwnPropertyNames(e);for(const c of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(c))try{if("function"!=typeof e[c])continue;const a=xf(e,c,function(e){return function(...s){const a=e.apply(this,s);if(rg(a,i,this),"tagName"in this.canvas&&!mm(this.canvas,r,o,!0)){const e=ig(s,i,this),r={type:t,property:c,args:e};n(this.canvas,r)}return a}});s.push(a)}catch{const r=dm(e,c,{set(e){n(this.canvas,{type:t,property:c,args:[e],setter:!0})}});s.push(r)}return s}var lg='(function() {\n "use strict";\n var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";\n var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);\n for (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n }\n var encode = function(arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";\n for (i2 = 0; i2 < len; i2 += 3) {\n base64 += chars[bytes[i2] >> 2];\n base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];\n base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];\n base64 += chars[bytes[i2 + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + "=";\n } else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + "==";\n }\n return base64;\n };\n const lastBlobMap = /* @__PURE__ */ new Map();\n const transparentBlobMap = /* @__PURE__ */ new Map();\n async function getTransparentBlobFor(width, height, dataURLOptions) {\n const id = `${width}-${height}`;\n if ("OffscreenCanvas" in globalThis) {\n if (transparentBlobMap.has(id)) return transparentBlobMap.get(id);\n const offscreen = new OffscreenCanvas(width, height);\n offscreen.getContext("2d");\n const blob = await offscreen.convertToBlob(dataURLOptions);\n const arrayBuffer = await blob.arrayBuffer();\n const base64 = encode(arrayBuffer);\n transparentBlobMap.set(id, base64);\n return base64;\n } else {\n return "";\n }\n }\n const worker = self;\n worker.onmessage = async function(e) {\n if ("OffscreenCanvas" in globalThis) {\n const { id, bitmap, width, height, dataURLOptions } = e.data;\n const transparentBase64 = getTransparentBlobFor(\n width,\n height,\n dataURLOptions\n );\n const offscreen = new OffscreenCanvas(width, height);\n const ctx = offscreen.getContext("2d");\n ctx.drawImage(bitmap, 0, 0);\n bitmap.close();\n const blob = await offscreen.convertToBlob(dataURLOptions);\n const type = blob.type;\n const arrayBuffer = await blob.arrayBuffer();\n const base64 = encode(arrayBuffer);\n if (!lastBlobMap.has(id) && await transparentBase64 === base64) {\n lastBlobMap.set(id, base64);\n return worker.postMessage({ id });\n }\n if (lastBlobMap.get(id) === base64) return worker.postMessage({ id });\n worker.postMessage({\n id,\n type,\n base64,\n width,\n height\n });\n lastBlobMap.set(id, base64);\n } else {\n return worker.postMessage({ id: e.data.id });\n }\n };\n})();\n//# sourceMappingURL=image-bitmap-data-url-worker-IJpC7g_b.js.map\n',dg="undefined"!=typeof self&&self.Blob&&new Blob([lg],{type:"text/javascript;charset=utf-8"});function ug(e){let t;try{if(t=dg&&(self.URL||self.webkitURL).createObjectURL(dg),!t)throw"";const n=new Worker(t,{name:null==e?void 0:e.name});return n.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch(n){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(lg),{name:null==e?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}var pg,hg,fg,mg=class{constructor(e){tf(this,"pendingCanvasMutations",/* @__PURE__ */new Map),tf(this,"rafStamps",{latestId:0,invokeId:null}),tf(this,"mirror"),tf(this,"mutationCb"),tf(this,"resetObservers"),tf(this,"frozen",!1),tf(this,"locked",!1),tf(this,"processMutation",(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});const{sampling:t="all",win:n,blockClass:r,blockSelector:o,recordCanvas:i,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,i&&"all"===t&&this.initCanvasMutationObserver(n,r,o),i&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,o){const i=ag(t,n,r,!0),s=/* @__PURE__ */new Map,a=new ug;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:i}=e.data;this.mutationCb({id:t,type:af["2D"],commands:[{property:"clearRect",args:[0,0,o,i]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,d=0;const u=e=>{d&&e-d<c||(d=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach(t=>{mm(t,n,r,!0)||e.push(t)}),e})().forEach(async e=>{var t;const n=this.mirror.getId(e);if(s.get(n))return;if(0===e.width||0===e.height)return;if(s.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null==(t=null==n?void 0:n.getContextAttributes())?void 0:t.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}const r=await createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])})),l=requestAnimationFrame(u)};l=requestAnimationFrame(u),this.resetObservers=()=>{i(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=ag(e,t,n,!1),o=function(e,t,n,r){const o=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of i)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const i=xf(t.CanvasRenderingContext2D.prototype,s,function(o){return function(...i){return mm(this.canvas,n,r,!0)||setTimeout(()=>{const n=ig(i,t,this);e(this.canvas,{type:af["2D"],property:s,args:n})},0),o.apply(this,i)}});o.push(i)}catch{const n=dm(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:af["2D"],property:s,args:[t],setter:!0})}});o.push(n)}return()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),i=function(e,t,n,r){const o=[];return void 0!==t.WebGLRenderingContext&&o.push(...cg(t.WebGLRenderingContext.prototype,af.WebGL,e,n,r,t)),void 0!==t.WebGL2RenderingContext&&o.push(...cg(t.WebGL2RenderingContext.prototype,af.WebGL2,e,n,r,t)),()=>{o.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n);this.resetObservers=()=>{r(),o(),i()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map(e=>{const{type:t,...n}=e;return n}),{type:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}},gg=class{constructor(e){tf(this,"trackedLinkElements",/* @__PURE__ */new WeakSet),tf(this,"mutationCb"),tf(this,"adoptedStyleSheetCb"),tf(this,"styleMirror",new km),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const o of e){let e;this.styleMirror.has(o)?e=this.styleMirror.getId(o):(e=this.styleMirror.add(o),r.push({styleId:e,rules:Array.from(o.rules||CSSRule,(e,t)=>({rule:Ef(e,o.href),index:t}))})),n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=/* @__PURE__ */new WeakSet}trackStylesheetInLinkElement(e){}},yg=class{constructor(){tf(this,"nodeMap",/* @__PURE__ */new WeakMap),tf(this,"active",!1)}inOtherBuffer(e,t){const n=this.nodeMap.get(e);return n&&Array.from(n).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=/* @__PURE__ */new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||/* @__PURE__ */new Set).add(t))}destroy(){}},bg=!1;try{if(2!==Array.from([1],e=>2*e)[0]){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=(null==(Vh=e.contentWindow)?void 0:Vh.Array.from)||Array.from,document.body.removeChild(e)}}catch(sy){}var wg=new Tf;function vg(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:i=null,ignoreClass:s="rr-ignore",ignoreSelector:a=null,maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:p,slimDOMOptions:h,maskInputFn:f,maskTextFn:m,hooks:g,packFn:y,sampling:b={},dataURLOptions:w={},mousemoveWait:v,recordDOM:x=!0,recordCanvas:k=!1,recordCrossOriginIframes:S=!1,recordAfter:_=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:I=!1,collectFonts:C=!1,inlineImages:E=!1,plugins:T,keepIframeSrcFn:M=()=>!1,ignoreCSSAttributes:z=/* @__PURE__ */new Set([]),errorHandler:O}=e;Em=O;const R=!S||window.parent===window;let A=!1;if(!R)try{window.parent.document&&(A=!1)}catch(Z){A=!0}if(R&&!t)throw new Error("emit function is required");if(!R&&!A)return()=>{};void 0!==v&&void 0===b.mousemove&&(b.mousemove=v),wg.reset();const N=!0===u?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==p?p:{password:!0},P=om(h);let L;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach)}();let $=0;const D=e=>{for(const t of T||[])t.eventProcessor&&(e=t.eventProcessor(e));return y&&!A&&(e=y(e)),e};pg=(e,o)=>{var i;const s=e;if(s.timestamp=vf(),!(null==(i=Lm[0])?void 0:i.isFrozen())||s.type===nf.FullSnapshot||s.type===nf.IncrementalSnapshot&&s.data.source===rf.Mutation||Lm.forEach(e=>e.unfreeze()),R)t?.(D(s),o);else if(A){const e={type:"rrweb",event:D(s),origin:window.location.origin,isCheckout:o};window.parent.postMessage(e,"*")}if(s.type===nf.FullSnapshot)L=s,$=0;else if(s.type===nf.IncrementalSnapshot){if(s.data.source===rf.Mutation&&s.data.isAttachIframe)return;$++;const e=r&&$>=r,t=n&&s.timestamp-L.timestamp>n;(e||t)&&hg(!0)}};const F=e=>{pg({type:nf.IncrementalSnapshot,data:{source:rf.Mutation,...e}})},j=e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.Scroll,...e}}),U=e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.CanvasMutation,...e}}),W=new gg({mutationCb:F,adoptedStyleSheetCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.AdoptedStyleSheet,...e}})}),B=new Km({mirror:wg,mutationCb:F,stylesheetManager:W,recordCrossOriginIframes:S,wrappedEmit:pg});for(const G of T||[])G.getMirror&&G.getMirror({nodeMirror:wg,crossOriginIframeMirror:B.crossOriginIframeMirror,crossOriginIframeStyleMirror:B.crossOriginIframeStyleMirror});const H=new yg;fg=new mg({recordCanvas:k,mutationCb:U,win:window,blockClass:o,blockSelector:i,mirror:wg,sampling:b.canvas,dataURLOptions:w});const q=new Jm({mutationCb:F,scrollCb:j,bypassOptions:{blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:N,dataURLOptions:w,maskTextFn:m,maskInputFn:f,recordCanvas:k,inlineImages:E,sampling:b,slimDOMOptions:P,iframeManager:B,stylesheetManager:W,canvasManager:fg,keepIframeSrcFn:M,processedNodeManager:H},mirror:wg});hg=(e=!1)=>{if(!x)return;pg({type:nf.Meta,data:{href:window.location.href,width:hm(),height:pm()}},e),W.reset(),q.init(),Lm.forEach(e=>e.lock());const t=function(e,t){const{mirror:n=new Tf,blockClass:r="rr-block",blockSelector:o=null,maskTextClass:i="rr-mask",maskTextSelector:s=null,inlineStylesheet:a=!0,inlineImages:c=!1,recordCanvas:l=!1,maskAllInputs:d=!1,maskTextFn:u,maskInputFn:p,slimDOM:h=!1,dataURLOptions:f,preserveWhiteSpace:m,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:w,stylesheetLoadTimeout:v,keepIframeSrcFn:x=()=>!1}=t;return im(e,{doc:e,mirror:n,blockClass:r,blockSelector:o,maskTextClass:i,maskTextSelector:s,skipChild:!1,inlineStylesheet:a,maskInputOptions:!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===d?{password:!0}:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:om(h),dataURLOptions:f,inlineImages:c,recordCanvas:l,preserveWhiteSpace:m,onSerialize:g,onIframeLoad:y,iframeLoadTimeout:b,onStylesheetLoad:w,stylesheetLoadTimeout:v,keepIframeSrcFn:x,newlyAddedElement:!1})}(document,{mirror:wg,blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:d,maskAllInputs:N,maskTextFn:m,maskInputFn:f,slimDOM:P,dataURLOptions:w,recordCanvas:k,inlineImages:E,onSerialize:e=>{wm(e,wg)&&B.addIframe(e),vm(e,wg)&&W.trackLinkElement(e),xm(e)&&q.addShadowRoot(kf.shadowRoot(e),document)},onIframeLoad:(e,t)=>{B.attachIframe(e,t),q.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{W.attachLinkElement(e,t)},keepIframeSrcFn:M});t&&(pg({type:nf.FullSnapshot,data:{node:t,initialOffset:um(window)}},e),Lm.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&W.adoptStyleSheets(document.adoptedStyleSheets,wg.getId(document)))};try{const e=[],t=e=>{var t;return Pm(Zm)({mutationCb:F,mousemoveCb:(e,t)=>pg({type:nf.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.MouseInteraction,...e}}),scrollCb:j,viewportResizeCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.ViewportResize,...e}}),inputCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.Input,...e}}),mediaInteractionCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.MediaInteraction,...e}}),styleSheetRuleCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.StyleSheetRule,...e}}),styleDeclarationCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.StyleDeclaration,...e}}),canvasMutationCb:U,fontCb:e=>pg({type:nf.IncrementalSnapshot,data:{source:rf.Font,...e}}),selectionCb:e=>{pg({type:nf.IncrementalSnapshot,data:{source:rf.Selection,...e}})},customElementCb:e=>{pg({type:nf.IncrementalSnapshot,data:{source:rf.CustomElement,...e}})},blockClass:o,ignoreClass:s,ignoreSelector:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:N,inlineStylesheet:d,sampling:b,recordDOM:x,recordCanvas:k,inlineImages:E,userTriggeredOnInput:I,collectFonts:C,doc:e,maskInputFn:f,maskTextFn:m,keepIframeSrcFn:M,blockSelector:i,slimDOMOptions:P,dataURLOptions:w,mirror:wg,iframeManager:B,stylesheetManager:W,shadowDomManager:q,processedNodeManager:H,canvasManager:fg,ignoreCSSAttributes:z,plugins:(null==(t=null==T?void 0:T.filter(e=>e.observer))?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>pg({type:nf.Plugin,data:{plugin:e.name,payload:t}})})))||[]},g)};B.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(r){}});const n=()=>{hg(),e.push(t(document)),bg=!0};return["interactive","complete"].includes(document.readyState)?n():(e.push(am("DOMContentLoaded",()=>{pg({type:nf.DomContentLoaded,data:{}}),"DOMContentLoaded"===_&&n()})),e.push(am("load",()=>{pg({type:nf.Load,data:{}}),"load"===_&&n()},window))),()=>{e.forEach(e=>{try{e()}catch(t){String(t).toLowerCase().includes("cross-origin")}}),H.destroy(),bg=!1,Em=void 0}}catch(V){}}vg.addCustomEvent=(e,t)=>{if(!bg)throw new Error("please add custom event after start recording");pg({type:nf.Custom,data:{tag:e,payload:t}})},vg.freezePage=()=>{Lm.forEach(e=>e.freeze())},vg.takeFullSnapshot=e=>{if(!bg)throw new Error("please take full snapshot after start recording");hg(e)},vg.mirror=wg;var xg=class{chatId;applicationId;events=[];sessionId=globalThis.crypto.randomUUID();stopRecording=null;flushTimer=null;flushPromise=Promise.resolve();stopped=!1;constructor(e,t){this.chatId=e,this.applicationId=t}async start(){this.stopRecording||this.stopped||(await _s.widgetMessagePost({chat_id:this.chatId,command:{type:"rrweb/metadata",rrweb_session_id:this.sessionId,chat_id:this.chatId,application_id:this.applicationId,url:window.location.href,user_agent:navigator.userAgent,timestamp:Date.now(),viewport:{width:window.innerWidth,height:window.innerHeight}}}),this.stopped||(this.stopRecording=vg({emit:e=>this.buffer(e),maskAllInputs:!0,maskTextClass:/^(rr-mask|mtx-mask)$/,blockClass:/^(rr-block|mtx-block)$/})))}stop(){this.stopped=!0,this.stopRecording?.(),this.stopRecording=null,this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=null,this.flush()}buffer(e){this.events.push(e),this.flushTimer||(this.flushTimer=setTimeout(()=>{this.flush()},500))}flush(){return this.flushPromise=this.flushPromise.then(async()=>{this.flushTimer&&clearTimeout(this.flushTimer),this.flushTimer=null;const e=this.events.splice(0);if(e.length)try{await _s.widgetMessagePost({chat_id:this.chatId,command:{type:"rrweb/events",rrweb_session_id:this.sessionId,events:e}})}catch(t){this.events.unshift(...e)}}),this.flushPromise}};function kg(e){return e instanceof Error?e.message:"string"==typeof e?e:"Unknown error"}function Sg(e,t){const n=new Error(e);return n.cause=t,n}async function _g(e){const{mtxId:t,mtxKey:n}=e;if(!t||!n)throw new Error("Please provide mtxId + mtxKey");let r;try{({items:r}=await _s.widgetSearch({marketrix_id:t,marketrix_key:n}))}catch(a){throw function(e,t){const n=kg(e);return n.includes("Failed to fetch")||n.includes("ERR_CONNECTION_REFUSED")||n.includes("NetworkError")||n.includes("Network request failed")?Sg(`Cannot connect to API server. Please ensure the API server is running at ${t.mtxApiHost||"configured API server"}. Error: ${n}`,e):Sg(`Widget validation failed: ${n}`,e)}(a,e)}if(!r.length)throw new Error("Widget not found or invalid credentials");const o=r.find(e=>"widget"===e.type&&"active"===e.status);if(!o){const e=r.filter(e=>"widget"===e.type);if(e.length){const t=e.map(e=>e.status).join(", ");throw new Error(`Found widget(s) but none are active. Current status(es): ${t}. Please activate the widget in the dashboard.`)}const t=r.map(e=>e.type).join(", ");throw new Error(`No widget found. Found widget type(s): ${t}. Please create a widget.`)}if(!o.application_id)throw new Error("Widget missing application_id");try{await _s.applicationGet({application_id:o.application_id})}catch(a){throw Sg(`Failed to validate application: ${kg(a)}`,a)}let i;try{i=await _s.widgetDefaultGet({type:"widget"})}catch(a){throw Sg(`Failed to fetch widget settings from API: ${kg(a)}`,a)}const s=gs.safeParse({...i,...o.settings});if(!s.success){const e=[...new Set(s.error.issues.map(e=>e.path.join(".")||"settings"))];throw new Error(`Widget settings are invalid: ${e.join(", ")}`)}return{...aa(s.data,e),mtxApp:o.application_id}}var Ig="#6b7280",Cg="#1f2937",Eg="rgba(255, 255, 255, 0.95)",Tg="rgba(255, 255, 255, 0.2)",Mg="rgba(0, 0, 0, 0.15)",zg=({message:e="Loading widget settings..."})=>{const[t,n]=u(!1),r=e?.includes("marketrix_id")||e?.includes("marketrix_key");return t?null:/* @__PURE__ */g(Qc,{position:"fixed",style:{bottom:"20px",left:"50%",transform:"translateX(-50%)",maxWidth:"420px",backgroundColor:Eg,borderRadius:r?"18px":"999px",boxShadow:`0 2px 12px ${Mg}`,display:"flex",flexDirection:"column",alignItems:"stretch",gap:"8px",padding:"10px 12px",border:`1px solid ${Tg}`,zIndex:9999,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[/* @__PURE__ */g(id,{align:"center",style:{gap:"10px"},children:[
59
59
  /* @__PURE__ */m(nl,{src:el,alt:"",size:28,style:{borderRadius:"50%",overflow:"hidden",flexShrink:0}}),
60
- /* @__PURE__ */m(gd,{as:"span",style:{fontSize:"13px",color:zg,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:e}),
61
- /* @__PURE__ */m(ud,{label:"Dismiss",onClick:()=>n(!0),style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:Mg,borderRadius:"50%",width:"20px",height:"20px",minWidth:"unset"},children:/* @__PURE__ */m(ad,{name:"closeSmall",size:12})})]}),r?/* @__PURE__ */m(gd,{as:"p",style:{fontSize:"12px",color:Mg,textAlign:"left",margin:0},children:"Please configure marketrix_id and marketrix_key"}):null]})},Pg='/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:var(--font-sans);--font-serif:var(--font-serif);--font-mono:var(--font-mono);--color-red-500:oklch(63.7% .237 25.331);--color-blue-500:oklch(62.3% .214 259.815);--color-gray-900:oklch(21% .034 264.665);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-normal:0em;--tracking-wide:.025em;--leading-tight:1.25;--leading-snug:1.375;--leading-normal:1.5;--leading-relaxed:1.625;--shadow-2xs:var(--shadow-2xs);--shadow-xs:var(--shadow-xs);--shadow-sm:var(--shadow-sm);--shadow-md:var(--shadow-md);--shadow-lg:var(--shadow-lg);--shadow-xl:var(--shadow-xl);--shadow-2xl:var(--shadow-2xl);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0, 0, .2, 1) infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--shadow:var(--shadow)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{border-color:var(--border);outline-color:var(--ring)}@supports (color:color-mix(in lab, red, red)){*{outline-color:color-mix(in oklab, var(--ring) 50%, transparent)}}body{background-color:var(--background);color:var(--foreground)}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:0}.inset-2{inset:calc(var(--spacing) * 2)}.inset-3{inset:calc(var(--spacing) * 3)}.top-0\\.5{top:calc(var(--spacing) * .5)}.top-1\\/2{top:50%}.top-5{top:calc(var(--spacing) * 5)}.top-full{top:100%}.right-0{right:0}.right-0\\.5{right:calc(var(--spacing) * .5)}.right-4{right:calc(var(--spacing) * 4)}.right-5{right:calc(var(--spacing) * 5)}.right-full{right:100%}.bottom-5{bottom:calc(var(--spacing) * 5)}.bottom-16{bottom:calc(var(--spacing) * 16)}.left-0{left:0}.left-1\\/2{left:50%}.left-4{left:calc(var(--spacing) * 4)}.left-5{left:calc(var(--spacing) * 5)}.left-full{left:100%}.isolate{isolation:isolate}.z-\\(--layer-dialog\\){z-index:var(--layer-dialog)}.z-10{z-index:10}.z-20{z-index:20}.z-\\[calc\\(var\\(--layer-dialog\\)\\+1\\)\\]{z-index:calc(var(--layer-dialog) + 1)}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.m-0{margin:0}.m-2{margin:calc(var(--spacing) * 2)}.m-32{margin:calc(var(--spacing) * 32)}.mx-3{margin-inline:calc(var(--spacing) * 3)}.my-0\\.5{margin-block:calc(var(--spacing) * .5)}.mt-0\\.5{margin-top:calc(var(--spacing) * .5)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mb-1{margin-bottom:var(--spacing)}.mb-1\\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.ml-2{margin-left:calc(var(--spacing) * 2)}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.inline-grid{display:inline-grid}.table{display:table}.h-0{height:0}.h-0\\.5{height:calc(var(--spacing) * .5)}.h-1\\.5{height:calc(var(--spacing) * 1.5)}.h-3\\.5{height:calc(var(--spacing) * 3.5)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-12{height:calc(var(--spacing) * 12)}.h-14{height:calc(var(--spacing) * 14)}.h-auto{height:auto}.h-full{height:100%}.max-h-\\[85vh\\]{max-height:85vh}.min-h-0{min-height:0}.min-h-7{min-height:calc(var(--spacing) * 7)}.min-h-9{min-height:calc(var(--spacing) * 9)}.w-0{width:0}.w-1\\.5{width:calc(var(--spacing) * 1.5)}.w-3\\.5{width:calc(var(--spacing) * 3.5)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-12{width:calc(var(--spacing) * 12)}.w-14{width:calc(var(--spacing) * 14)}.w-auto{width:auto}.w-full{width:100%}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:0}.min-w-5{min-width:calc(var(--spacing) * 5)}.min-w-7{min-width:calc(var(--spacing) * 7)}.min-w-14{min-width:calc(var(--spacing) * 14)}.flex-1{flex:1}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.grow{flex-grow:1}.-translate-x-1\\/2{--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.scale-0{--tw-scale-x:0%;--tw-scale-y:0%;--tw-scale-z:0%;scale:var(--tw-scale-x) var(--tw-scale-y)}.scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x) var(--tw-scale-y)}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-dialog-content-in{animation:dialog-content-in var(--duration-animation) ease-out}.animate-dialog-overlay-in{animation:dialog-overlay-in var(--duration-fade) ease-out}.animate-fade-in{animation:.5s ease-out fade-in}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-wait{cursor:wait}.resize{resize:both}.resize-none{resize:none}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-around{justify-content:space-around}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-0\\.5{gap:calc(var(--spacing) * .5)}.gap-1\\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-4{gap:calc(var(--spacing) * 4)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-scroll{overflow:scroll}.overflow-visible{overflow:visible}.overflow-y-auto{overflow-y:auto}.overflow-y-hidden{overflow-y:hidden}.rounded{border-radius:.25rem}.rounded-\\[var\\(--radius\\)\\]{border-radius:var(--radius)}.rounded-full{border-radius:2147483647px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-none{border-radius:0}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-\\[1\\.5px\\]{border-style:var(--tw-border-style);border-width:1.5px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-4{border-top-style:var(--tw-border-style);border-top-width:4px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-4{border-right-style:var(--tw-border-style);border-right-width:4px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-none{--tw-border-style:none;border-style:none}.border-border{border-color:var(--border)}.border-current{border-color:currentColor}.border-transparent{border-color:#0000}.border-white\\/25{border-color:#ffffff40}@supports (color:color-mix(in lab, red, red)){.border-white\\/25{border-color:color-mix(in oklab, var(--color-white) 25%, transparent)}}.border-t-transparent{border-top-color:#0000}.bg-black\\/20{background-color:#0003}@supports (color:color-mix(in lab, red, red)){.bg-black\\/20{background-color:color-mix(in oklab, var(--color-black) 20%, transparent)}}.bg-card{background-color:var(--card)}.bg-current{background-color:currentColor}.bg-gray-900{background-color:var(--color-gray-900)}.bg-muted{background-color:var(--muted)}.bg-primary{background-color:var(--primary)}.bg-secondary{background-color:var(--secondary)}.bg-secondary-bg{background-color:var(--secondary-bg)}.bg-transparent{background-color:#0000}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.p-0{padding:0}.p-0\\.5{padding:calc(var(--spacing) * .5)}.p-1\\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-4{padding-block:calc(var(--spacing) * 4)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pl-2{padding-left:calc(var(--spacing) * 2)}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.leading-normal{--tw-leading:var(--leading-normal);line-height:var(--leading-normal)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.whitespace-nowrap{white-space:nowrap}.text-blue-500{color:var(--color-blue-500)}.text-card-foreground{color:var(--card-foreground)}.text-foreground{color:var(--foreground)}.text-foreground-faint{color:var(--foreground-faint)}.text-foreground-muted{color:var(--foreground-muted)}.text-inherit{color:inherit}.text-muted-foreground{color:var(--muted-foreground)}.text-primary{color:var(--primary)}.text-primary-foreground{color:var(--primary-foreground)}.text-red-500{color:var(--color-red-500)}.text-secondary-foreground{color:var(--secondary-foreground)}.text-success{color:var(--success)}.text-warning{color:var(--warning)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-100{opacity:1}.shadow,.shadow-\\[var\\(--shadow\\)\\]{--tw-shadow:var(--shadow);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:var(--shadow-lg);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-sm{--tw-shadow:var(--shadow-sm);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-filter{backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[transform\\,opacity\\,background-color\\]{transition-property:transform,opacity,background-color;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[transform\\,opacity\\]{transition-property:transform,opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-\\[160ms\\]{--tw-duration:.16s;transition-duration:.16s}.duration-\\[167ms\\]{--tw-duration:.167s;transition-duration:.167s}.ease-\\[cubic-bezier\\(0\\.33\\,0\\,0\\,1\\)\\]{--tw-ease:cubic-bezier(.33,0,0,1);transition-timing-function:cubic-bezier(.33,0,0,1)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.group-focus-within\\:pointer-events-auto:is(:where(.group):focus-within *){pointer-events:auto}.group-focus-within\\:opacity-100:is(:where(.group):focus-within *){opacity:1}@media (hover:hover){.group-hover\\:pointer-events-auto:is(:where(.group):hover *){pointer-events:auto}.group-hover\\:opacity-100:is(:where(.group):hover *){opacity:1}}.placeholder\\:text-foreground-faint::placeholder{color:var(--foreground-faint)}.focus-within\\:border-foreground-faint:focus-within{border-color:var(--foreground-faint)}@media (hover:hover){.hover\\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x) var(--tw-scale-y)}.hover\\:border-primary:hover{border-color:var(--primary)}.hover\\:bg-muted:hover{background-color:var(--muted)}.hover\\:bg-primary:hover{background-color:var(--primary)}.hover\\:bg-primary-hover:hover{background-color:var(--primary-hover)}.hover\\:bg-primary\\/90:hover{background-color:var(--primary)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-primary\\/90:hover{background-color:color-mix(in oklab, var(--primary) 90%, transparent)}}.hover\\:bg-secondary-hover:hover{background-color:var(--secondary-hover)}.hover\\:bg-secondary\\/80:hover{background-color:var(--secondary)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-secondary\\/80:hover{background-color:color-mix(in oklab, var(--secondary) 80%, transparent)}}.hover\\:bg-transparent:hover{background-color:#0000}.hover\\:text-foreground:hover{color:var(--foreground)}.hover\\:text-primary:hover{color:var(--primary)}.hover\\:text-primary-foreground:hover{color:var(--primary-foreground)}.hover\\:opacity-100:hover{opacity:1}.hover\\:duration-\\[250ms\\]:hover{--tw-duration:.25s;transition-duration:.25s}}.focus\\:ring-0:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\\:outline-ring:focus-visible{outline-color:var(--ring)}.active\\:scale-\\[0\\.85\\]:active{scale:.85}.active\\:duration-\\[134ms\\]:active{--tw-duration:.134s;transition-duration:.134s}.active\\:ease-\\[cubic-bezier\\(0\\.45\\,0\\,0\\.2\\,1\\)\\]:active{--tw-ease:cubic-bezier(.45,0,.2,1);transition-timing-function:cubic-bezier(.45,0,.2,1)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:opacity-50:disabled{opacity:.5}}:root,:host{--background:oklch(100% 0 0);--foreground:oklch(14.5% 0 0);--card:oklch(100% 0 0);--card-foreground:oklch(14.5% 0 0);--popover:oklch(100% 0 0);--popover-foreground:oklch(14.5% 0 0);--primary:oklch(20.5% 0 0);--primary-foreground:oklch(98.5% 0 0);--secondary:oklch(97% 0 0);--secondary-foreground:oklch(20.5% 0 0);--muted:oklch(97% 0 0);--muted-foreground:oklch(55.6% 0 0);--accent:oklch(97% 0 0);--accent-foreground:oklch(20.5% 0 0);--destructive:oklch(57.7% .245 27.325);--destructive-foreground:oklch(100% 0 0);--success:oklch(60% .2 145);--success-foreground:oklch(100% 0 0);--warning:oklch(75% .18 85);--warning-foreground:oklch(20% 0 0);--border:oklch(92.2% 0 0);--input:oklch(92.2% 0 0);--ring:oklch(70.8% 0 0);--chart-1:oklch(81% .1 252);--chart-2:oklch(62% .19 260);--chart-3:oklch(55% .22 263);--chart-4:oklch(49% .22 264);--chart-5:oklch(42% .18 266);--sidebar:oklch(98.5% 0 0);--sidebar-foreground:oklch(14.5% 0 0);--sidebar-primary:oklch(20.5% 0 0);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(97% 0 0);--sidebar-accent-foreground:oklch(20.5% 0 0);--sidebar-border:oklch(92.2% 0 0);--sidebar-ring:oklch(70.8% 0 0);--foreground-muted:#1f293799;--foreground-faint:#1f293766;--border-muted:#e5e7eb4d;--primary-hover:#3b82f6d9;--primary-muted:#3b82f64d;--secondary-bg:#6b728033;--secondary-hover:#6b72804d;--font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--radius:.625rem;--shadow-x:0;--shadow-y:1px;--shadow-blur:3px;--shadow-spread:0px;--shadow-opacity:.1;--shadow-color:oklch(0% 0 0);--shadow-2xs:0 1px 3px 0px #0000000d;--shadow-xs:0 1px 3px 0px #0000000d;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-md:0 1px 3px 0px #0000001a, 0 2px 4px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--shadow-xl:0 1px 3px 0px #0000001a, 0 8px 10px -1px #0000001a;--shadow-2xl:0 1px 3px 0px #00000040;--tracking-normal:0em;--spacing:.25rem;--duration-animation:.3s;--duration-fade:.2s;--widget-width:400px;--widget-height:520px;--layer-tooltip:1000;--layer-popover:1050;--layer-dialog:1100;--layer-toast:1200}.dark,:host(.dark){--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20.5% 0 0);--card-foreground:oklch(98.5% 0 0);--popover:oklch(26.9% 0 0);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(92.2% 0 0);--primary-foreground:oklch(20.5% 0 0);--secondary:oklch(26.9% 0 0);--secondary-foreground:oklch(98.5% 0 0);--muted:oklch(26.9% 0 0);--muted-foreground:oklch(70.8% 0 0);--accent:oklch(37.1% 0 0);--accent-foreground:oklch(98.5% 0 0);--destructive:oklch(70.4% .191 22.216);--destructive-foreground:oklch(98.5% 0 0);--success:oklch(55% .2 145);--success-foreground:oklch(100% 0 0);--warning:oklch(70% .18 85);--warning-foreground:oklch(20% 0 0);--border:oklch(27.5% 0 0);--input:oklch(32.5% 0 0);--ring:oklch(55.6% 0 0);--chart-1:oklch(81% .1 252);--chart-2:oklch(62% .19 260);--chart-3:oklch(55% .22 263);--chart-4:oklch(49% .22 264);--chart-5:oklch(42% .18 266);--sidebar:oklch(20.5% 0 0);--sidebar-foreground:oklch(98.5% 0 0);--sidebar-primary:oklch(48.8% .243 264.376);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(26.9% 0 0);--sidebar-accent-foreground:oklch(98.5% 0 0);--sidebar-border:oklch(27.5% 0 0);--sidebar-ring:oklch(43.9% 0 0);--font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--radius:.625rem;--shadow-x:0;--shadow-y:1px;--shadow-blur:3px;--shadow-spread:0px;--shadow-opacity:.1;--shadow-color:oklch(0% 0 0);--shadow-2xs:0 1px 3px 0px #0000000d;--shadow-xs:0 1px 3px 0px #0000000d;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-md:0 1px 3px 0px #0000001a, 0 2px 4px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--shadow-xl:0 1px 3px 0px #0000001a, 0 8px 10px -1px #0000001a;--shadow-2xl:0 1px 3px 0px #00000040}@media (prefers-reduced-motion:reduce){:root{--duration-animation:0s;--duration-fade:0s}}@keyframes dialog-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes dialog-content-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}@keyframes menu-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes popover-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@keyframes tooltip-in{0%{opacity:0;transform:scale(.96)}to{opacity:1;transform:scale(1)}}@keyframes toast-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}@keyframes fade-in{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes slide-in-left{0%{opacity:0;transform:translate(-30px)}to{opacity:1;transform:translate(0)}}@keyframes slide-in-right{0%{opacity:0;transform:translate(30px)}to{opacity:1;transform:translate(0)}}.marketrix-widget,[data-marketrix-widget]{font-family:var(--font-sans);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.marketrix-widget-container{z-index:var(--widget-z-index,1210);pointer-events:auto;position:fixed}.marketrix-widget,.marketrix-widget *,[data-marketrix-widget],[data-marketrix-widget] *{pointer-events:auto;box-sizing:border-box;transition:color .2s ease-in-out,background-color .2s ease-in-out,border-color .2s ease-in-out,opacity .2s ease-in-out,box-shadow .2s ease-in-out,transform .2s ease-in-out}.marketrix-widget button,.marketrix-widget input,.marketrix-widget textarea,.marketrix-widget select,[data-marketrix-widget] button,[data-marketrix-widget] input,[data-marketrix-widget] textarea,[data-marketrix-widget] select{font:inherit}[data-resizing=true],[data-resizing=true] *{transition:none!important}.gradient-border{border:2px solid;border-image:linear-gradient(to right, var(--foreground), var(--foreground)) 1}.marketrix-widget ::-webkit-scrollbar{width:6px;height:6px}.marketrix-widget * ::-webkit-scrollbar{width:6px;height:6px}.marketrix-widget ::-webkit-scrollbar-track{background:var(--muted);border-radius:3px}.marketrix-widget * ::-webkit-scrollbar-track{background:var(--muted);border-radius:3px}.marketrix-widget ::-webkit-scrollbar-thumb{background:var(--muted-foreground);border-radius:3px}.marketrix-widget * ::-webkit-scrollbar-thumb{background:var(--muted-foreground);border-radius:3px}.marketrix-widget ::-webkit-scrollbar-thumb:hover{background:var(--foreground)}.marketrix-widget * ::-webkit-scrollbar-thumb:hover{background:var(--foreground)}.marketrix-widget{scrollbar-color:var(--muted) var(--muted-foreground);scrollbar-width:thin}.marketrix-widget ::-webkit-scrollbar-button{width:0;height:0;display:none!important}.marketrix-widget * ::-webkit-scrollbar-button{width:0;height:0;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:start:decrement{display:none!important}.marketrix-widget ::-webkit-scrollbar-button:end:increment{display:none!important}.marketrix-widget * ::-webkit-scrollbar-button:start:decrement{display:none!important}.marketrix-widget * ::-webkit-scrollbar-button:end:increment{display:none!important}.marketrix-widget ::-webkit-scrollbar-corner{display:none!important}.marketrix-widget * ::-webkit-scrollbar-corner{display:none!important}.marketrix-widget ::-webkit-scrollbar-button:vertical:start:decrement{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:vertical:end:increment{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:horizontal:start:decrement{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:horizontal:end:increment{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button{background:0 0!important;border:none!important;width:0!important;height:0!important;display:none!important}@keyframes glow-border-pulse{0%,to{border-color:#fff9;box-shadow:0 0 #ffffff4d,0 0 #1f293766}50%{border-color:#fff;box-shadow:0 0 0 2px #fff9,0 0 0 4px #1f29374d}}@keyframes marketrix-screen-edge-pulse{0%,to{opacity:.55}50%{opacity:1}}.marketrix-screen-edge-glow,[data-screen-edge-glow]{animation:1.6s ease-in-out infinite marketrix-screen-edge-pulse}.marketrix-widget-button-processing-glow,.marketrix-widget-button-error-glow{pointer-events:none;filter:blur(14px);will-change:transform, opacity;border-radius:50%;width:140%;height:140%;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}@keyframes widget-activity-dash-travel{0%{stroke-dashoffset:0;opacity:.5}18%{stroke-dashoffset:-112px;opacity:1}35%{stroke-dashoffset:-160px;opacity:.65}60%{stroke-dashoffset:-160px;opacity:.45}82%{stroke-dashoffset:-272px;opacity:1}to{stroke-dashoffset:-320px;opacity:.6}}.marketrix-widget-button-processing-activity-ring,.marketrix-widget-button-error-activity-ring{pointer-events:none;z-index:0;position:absolute;inset:-3px;overflow:visible}.marketrix-widget-button-processing-activity-ring rect,.marketrix-widget-button-error-activity-ring rect{fill:none;stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:40 120;animation:1.9s cubic-bezier(.4,0,.2,1) infinite widget-activity-dash-travel}.marketrix-widget-button-processing-activity-ring rect{stroke:#31d06d;filter:drop-shadow(0 0 3px #31d06db3)}.marketrix-widget-button-error-activity-ring rect{stroke:#d0342c;filter:drop-shadow(0 0 3px #d0342cb3)}@keyframes widget-glow-green{0%,to{opacity:.72;background:radial-gradient(circle,#31d06d00 38%,#31d06d61 58%,#31d06d3d 68%,#0000 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:1;background:radial-gradient(circle,#31d06d00 34%,#31d06d8c 56%,#31d06d54 68%,#0000 80%);transform:translate(-50%,-50%)scale(1.1)}}.marketrix-widget-button-processing-glow{animation:2s ease-in-out infinite widget-glow-green}@keyframes widget-glow-red{0%,to{opacity:.65;background:radial-gradient(circle,#d0342c00 38%,#d0342c57 58%,#d0342c38 68%,#0000 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:.95;background:radial-gradient(circle,#d0342c00 34%,#d0342c80 56%,#d0342c4d 68%,#0000 80%);transform:translate(-50%,-50%)scale(1.1)}}.marketrix-widget-button-error-glow{animation:1.5s ease-in-out infinite widget-glow-red}@keyframes launcher-entrance{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}.animate-launcher-entrance{animation:.25s ease-out forwards launcher-entrance}@keyframes messenger-entrance{0%{opacity:0;transform:scale(0)}40%{opacity:1}to{transform:scale(1)}}@keyframes messenger-exit{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)translateY(8px)}}.animate-messenger-entrance{animation:.3s cubic-bezier(0,1.2,1,1) messenger-entrance}.animate-messenger-exit{animation:.2s cubic-bezier(.4,0,.2,1) forwards messenger-exit}@keyframes message-enter{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.animate-message-enter{animation:.2s ease-out message-enter}.view-slide-enter.forward{opacity:0;transform:translate(20px)}.view-slide-enter.back{opacity:0;transform:translate(-20px)}.view-slide-enter-active{opacity:1;transition:transform .15s .15s,opacity .15s .15s;transform:translate(0)}.view-slide-enter-active.forward,.view-slide-enter-active.back{opacity:1;transform:translate(0)}.view-slide-exit-active.forward{opacity:0;transition:transform .15s,opacity .15s;transform:translate(-20px)}.view-slide-exit-active.back{opacity:0;transition:transform .15s,opacity .15s;transform:translate(20px)}[data-view-transition][data-direction=forward]{animation:.3s both viewSlideForward}[data-view-transition][data-direction=back]{animation:.3s both viewSlideBack}@keyframes viewSlideForward{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}@keyframes viewSlideBack{0%{opacity:0;transform:translate(-20px)}to{opacity:1;transform:translate(0)}}@media print{.marketrix-widget{display:none!important}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}',Lg=null,$g=null,Dg=null,Fg=!1,jg=0,Ug=(e,t)=>{const n=t||"marketrix-widget-container-"+ ++jg;let r;if(e){if(e.querySelector(`#${n}`))throw new Error(`Widget container with ID ${n} already exists`);r=document.createElement("div"),r.id=n,r.className="marketrix-widget-container",r.style.width="100%",r.style.height="100%",r.style.position="relative",r.style.overflow="visible",e.appendChild(r)}else{if(document.getElementById(n))throw new Error(`Widget container with ID ${n} already exists`);r=document.createElement("div"),r.id=n,r.className="marketrix-widget-container",document.body.appendChild(r)}if(r.style.pointerEvents="auto",!Cg(r))throw new Error("Container is not an HTMLElement");if(r.shadowRoot)throw new Error("Container already has a shadow root");const o=r.attachShadow({mode:"closed"}),i=document.createElement("style");if(i.textContent=Pg,o.appendChild(i),o.querySelector("#marketrix-widget-root"))throw new Error("Mount element already exists in shadow root");const s=document.createElement("div");return s.id="marketrix-widget-root",s.style.pointerEvents="auto",s.style.width="100%",s.style.height="100%",s.style.position="relative",o.appendChild(s),{container:r,shadowRoot:o,mountEl:s}},Wg=(e,n,r=!1)=>{const o=h(e),i=e.getRootNode();return o.render(/* @__PURE__ */m(t.StrictMode,{children:/* @__PURE__ */m(kh,{previewMode:r,portalContainer:i,children:/* @__PURE__ */m(Qh,{config:n})})})),o},Bg=e=>{if(!e)throw new Error("Container is required");e.remove()},Hg=()=>$g,qg=()=>null!==Lg,Zg=e=>{Fg=e},Vg=e=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(Dg){const e=document.getElementById("marketrix-widget-loader-container");e&&e.remove(),Dg.unmount(),Dg=null}if(document.getElementById("marketrix-widget-loader-container"))throw new Error("Widget loader container already exists");const n=document.createElement("div");n.id="marketrix-widget-loader-container",n.className="marketrix-widget-loader-container",document.body.appendChild(n);const r=n.attachShadow({mode:"closed"}),o=document.createElement("style");o.textContent=Pg,r.appendChild(o);const i=document.createElement("div");i.id="marketrix-widget-loader-root",r.appendChild(i);const s=h(i);Dg=s,s.render(/* @__PURE__ */m(t.StrictMode,{children:/* @__PURE__ */m(Ng,{message:e})}))},Gg=()=>{if(Dg){Dg.unmount(),Dg=null;const e=document.getElementById("marketrix-widget-loader-container");e&&e.remove()}},Yg=null,Kg=()=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(window.__mtx?.state)return;if(!Yg)return;const e=document.querySelectorAll("script[mtx-id]"),t=e[e.length-1];if(!(t&&(n=t,null!==n&&n instanceof HTMLScriptElement)))return;var n;const r=t,o=r.getAttribute("mtx-id"),i=r.getAttribute("mtx-key"),s=r.getAttribute("mtx-api-host"),a=r.getAttribute("mtx-use-screenshare");if(o&&i){const e={mtxId:o,mtxKey:i};s&&(e.mtxApiHost=s),"false"===a&&(e.use_screenshare=!1),Yg(e).catch(e=>{})}else{if(qg()||Fg)return;Vg("Please configure mtx-id and mtx-key")}},Jg=null,Xg=null,Qg=!1;async function ey(e,t){if(!t.isValid)throw new Error(t.error||"Widget validation failed");Vg("Loading widget settings...");try{const t=await async function(e,t){if(!e||!t)return null;try{Eg||(Eg=await Ss.widgetDefaultGet({type:"widget"}));const n=Eg;if(!n)throw new Error("Failed to fetch default widget settings from API. The API must return widget settings.");const{items:r}=await Ss.widgetSearch({type:"widget",marketrix_id:e,marketrix_key:t}),o=r?.find(e=>"active"===e.status&&"widget"===e.type)||null;if(o?.settings){const e=Tg(o);if(e){const t={...n,...e};return{...o,settings:t}}}const i=/* @__PURE__ */new Date;return{id:0,application_id:0,type:"widget",settings:n,status:"active",marketrix_id:e,marketrix_key:t,created_at:i,updated_at:i}}catch(n){const e=n instanceof Error?n.message:"Unknown error",t=/* @__PURE__ */new Error(`Failed to fetch widget settings from API: ${e}`);throw t.cause=n,t}}(e.mtxId,e.mtxKey),n=t?Tg(t):null;if(!n)throw new Error("Widget settings request did not return settings");const r=["widget_enabled","widget_appearance","widget_position","widget_device","widget_header","widget_body","widget_greeting","widget_greeting_toast","widget_recording","widget_feature_tell","widget_feature_show","widget_feature_do","widget_feature_human","widget_background_color","widget_text_color","widget_border_color","widget_accent_color","widget_secondary_color","widget_border_radius","widget_font_size","widget_width","widget_height","widget_shadow","widget_animation_duration","widget_fade_duration","widget_bounce_effect","widget_chips"].filter(e=>void 0===n[e]);if(r.length>0)throw new Error(`Widget settings are incomplete. Missing required fields: ${r.join(", ")}. The API must return all widget settings.`);return{...aa(n,e),mtxApp:t?.application_id??e.mtxApp}}catch(cy){throw cy}finally{Gg()}}async function ty(e,t){Zg(!0),window.__mtx={state:"initializing"},e.mtxApiHost&&ks(e.mtxApiHost),Vg("Validating widget configuration...");const n=await Sg(e);if(!n.isValid)return Vg(n.error||"Widget validation failed. Please check your configuration."),Zg(!1),void(window.__mtx=void 0);let r;try{r=await ey(e,n)}catch(i){const e=i instanceof Error?i.message:"Failed to initialize widget";return Vg(e),Zg(!1),void(window.__mtx=void 0)}(e=>{$g=e})(r);const{mountEl:o}=Ug(t);(e=>{Lg=e})(Wg(o,r)),Zg(!1),window.__mtx={state:"active"},Qg=!0,r.widget_recording&&r.mtxApp&&Ks.getInstance().waitUntilRegistered().then(async()=>{if(!Qg)return;const e=await Ys.getOrCreateChatId();Qg&&(Xg=new xg(e,r.mtxApp),await Xg.start())}).catch(e=>{})}var ny=async(e,t)=>{if(!window.__mtx?.state){if(Jg)return Jg;if(!qg()){Jg=ty(e,t);try{await Jg}finally{Jg=null}}}},ry=()=>{Qg=!1,Ks.getInstance().disconnect(),Xg?.stop(),Xg=null;if(Lg){Lg.unmount(),Lg=null,$g=null;const e=document.querySelector(".marketrix-widget-container");e&&Bg(e)}Jg=null,window.__mtx=void 0,Gg()},oy=async e=>{if(qg()){const t=Hg();if(!t)throw new Error("Widget not initialized");const n={...t,...e};ry(),await ny(n)}},iy=({settings:e,container:t,mtxId:n,mtxKey:r,mtxApiHost:o})=>{const i=d(null),s=d(null),c=d(null),l=d(null);return a(()=>{const a=t??i?.current?.parentElement??document.body;if(!a||!Cg(a))return;l.current||(l.current=`marketrix-widget-${Date.now()}-${Math.random().toString(36).slice(2,11)}`);const{container:d,shadowRoot:u,mountEl:p}=Ug(a,l.current);c.current=d;const f={...aa(e,{mtxId:n,mtxKey:r,mtxApiHost:o}),isPreviewMode:!0,widget_enabled:e.widget_enabled??!0};s.current&&(s.current.unmount(),s.current=null);const g=h(p);return s.current=g,g.render(/* @__PURE__ */m(kh,{previewMode:!0,portalContainer:u,children:/* @__PURE__ */m(Qh,{config:f})})),()=>{s.current&&(s.current.unmount(),s.current=null),c.current&&(Bg(c.current),c.current=null,l.current=null)}},[e,t]),t?null:/* @__PURE__ */m("div",{ref:i,style:{width:"100%",height:"100%",position:"relative"}})},sy=async e=>{Zg(!0);const t=e.container;if("settings"in e&&void 0!==e.settings){const{settings:n,container:r,...o}=e,i={...aa(n,o),isPreviewMode:!0},{mountEl:s}=Ug(t);Wg(s,i,!0),Zg(!1)}else{if(!("mtxId"in e)||void 0===e.mtxId||void 0===e.mtxKey)throw Zg(!1),new Error("Invalid configuration: provide either settings (preview) or mtxId+mtxKey (production)");{const{mtxId:n,mtxKey:r,container:o,...i}=e;await ny({mtxId:n,mtxKey:r,...i},t)}}};"undefined"!=typeof window&&setTimeout(()=>{try{(e=>{"function"==typeof e&&(Yg=e,Kg())})(ny)}catch(e){}},0);var ay={MarketrixWidget:iy,mountWidget:sy,initWidget:ny,unmountWidget:ry,updateMarketrixConfig:oy,getCurrentConfig:Hg};export{iy as MarketrixWidget,ay as default,Hg as getCurrentConfig,ny as initWidget,sy as mountWidget,ry as unmountWidget,oy as updateMarketrixConfig};
60
+ /* @__PURE__ */m(gd,{as:"span",style:{fontSize:"13px",color:Cg,fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:e}),
61
+ /* @__PURE__ */m(ud,{label:"Dismiss",onClick:()=>n(!0),style:{background:"none",border:"none",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:Ig,borderRadius:"50%",width:"20px",height:"20px",minWidth:"unset"},children:/* @__PURE__ */m(ad,{name:"closeSmall",size:12})})]}),r?/* @__PURE__ */m(gd,{as:"p",style:{fontSize:"12px",color:Ig,textAlign:"left",margin:0},children:"Please configure marketrix_id and marketrix_key"}):null]})},Og='/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:var(--font-sans);--font-serif:var(--font-serif);--font-mono:var(--font-mono);--color-red-500:oklch(63.7% .237 25.331);--color-blue-500:oklch(62.3% .214 259.815);--color-gray-900:oklch(21% .034 264.665);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-normal:0em;--tracking-wide:.025em;--leading-tight:1.25;--leading-snug:1.375;--leading-normal:1.5;--leading-relaxed:1.625;--shadow-2xs:var(--shadow-2xs);--shadow-xs:var(--shadow-xs);--shadow-sm:var(--shadow-sm);--shadow-md:var(--shadow-md);--shadow-lg:var(--shadow-lg);--shadow-xl:var(--shadow-xl);--shadow-2xl:var(--shadow-2xl);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0, 0, .2, 1) infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--shadow:var(--shadow)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{border-color:var(--border);outline-color:var(--ring)}@supports (color:color-mix(in lab, red, red)){*{outline-color:color-mix(in oklab, var(--ring) 50%, transparent)}}body{background-color:var(--background);color:var(--foreground)}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:0}.inset-2{inset:calc(var(--spacing) * 2)}.inset-3{inset:calc(var(--spacing) * 3)}.top-0\\.5{top:calc(var(--spacing) * .5)}.top-1\\/2{top:50%}.top-5{top:calc(var(--spacing) * 5)}.top-full{top:100%}.right-0{right:0}.right-0\\.5{right:calc(var(--spacing) * .5)}.right-4{right:calc(var(--spacing) * 4)}.right-5{right:calc(var(--spacing) * 5)}.right-full{right:100%}.bottom-5{bottom:calc(var(--spacing) * 5)}.bottom-16{bottom:calc(var(--spacing) * 16)}.left-0{left:0}.left-1\\/2{left:50%}.left-4{left:calc(var(--spacing) * 4)}.left-5{left:calc(var(--spacing) * 5)}.left-full{left:100%}.isolate{isolation:isolate}.z-\\(--layer-dialog\\){z-index:var(--layer-dialog)}.z-10{z-index:10}.z-20{z-index:20}.z-\\[calc\\(var\\(--layer-dialog\\)\\+1\\)\\]{z-index:calc(var(--layer-dialog) + 1)}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.m-0{margin:0}.m-2{margin:calc(var(--spacing) * 2)}.m-32{margin:calc(var(--spacing) * 32)}.mx-3{margin-inline:calc(var(--spacing) * 3)}.my-0\\.5{margin-block:calc(var(--spacing) * .5)}.mt-0\\.5{margin-top:calc(var(--spacing) * .5)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mb-1{margin-bottom:var(--spacing)}.mb-1\\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.ml-2{margin-left:calc(var(--spacing) * 2)}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.inline-grid{display:inline-grid}.table{display:table}.h-0{height:0}.h-0\\.5{height:calc(var(--spacing) * .5)}.h-1\\.5{height:calc(var(--spacing) * 1.5)}.h-3\\.5{height:calc(var(--spacing) * 3.5)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-12{height:calc(var(--spacing) * 12)}.h-14{height:calc(var(--spacing) * 14)}.h-auto{height:auto}.h-full{height:100%}.max-h-\\[85vh\\]{max-height:85vh}.min-h-0{min-height:0}.min-h-7{min-height:calc(var(--spacing) * 7)}.min-h-9{min-height:calc(var(--spacing) * 9)}.w-0{width:0}.w-1\\.5{width:calc(var(--spacing) * 1.5)}.w-3\\.5{width:calc(var(--spacing) * 3.5)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-12{width:calc(var(--spacing) * 12)}.w-14{width:calc(var(--spacing) * 14)}.w-auto{width:auto}.w-full{width:100%}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:0}.min-w-5{min-width:calc(var(--spacing) * 5)}.min-w-7{min-width:calc(var(--spacing) * 7)}.min-w-14{min-width:calc(var(--spacing) * 14)}.flex-1{flex:1}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.grow{flex-grow:1}.-translate-x-1\\/2{--tw-translate-x:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.scale-0{--tw-scale-x:0%;--tw-scale-y:0%;--tw-scale-z:0%;scale:var(--tw-scale-x) var(--tw-scale-y)}.scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x) var(--tw-scale-y)}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-dialog-content-in{animation:dialog-content-in var(--duration-animation) ease-out}.animate-dialog-overlay-in{animation:dialog-overlay-in var(--duration-fade) ease-out}.animate-fade-in{animation:.5s ease-out fade-in}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-wait{cursor:wait}.resize{resize:both}.resize-none{resize:none}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-around{justify-content:space-around}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-0\\.5{gap:calc(var(--spacing) * .5)}.gap-1\\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-4{gap:calc(var(--spacing) * 4)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-scroll{overflow:scroll}.overflow-visible{overflow:visible}.overflow-y-auto{overflow-y:auto}.overflow-y-hidden{overflow-y:hidden}.rounded{border-radius:.25rem}.rounded-\\[var\\(--radius\\)\\]{border-radius:var(--radius)}.rounded-full{border-radius:2147483647px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-none{border-radius:0}.rounded-sm{border-radius:calc(var(--radius) - 4px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-\\[1\\.5px\\]{border-style:var(--tw-border-style);border-width:1.5px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-4{border-top-style:var(--tw-border-style);border-top-width:4px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-4{border-right-style:var(--tw-border-style);border-right-width:4px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-none{--tw-border-style:none;border-style:none}.border-border{border-color:var(--border)}.border-current{border-color:currentColor}.border-transparent{border-color:#0000}.border-white\\/25{border-color:#ffffff40}@supports (color:color-mix(in lab, red, red)){.border-white\\/25{border-color:color-mix(in oklab, var(--color-white) 25%, transparent)}}.border-t-transparent{border-top-color:#0000}.bg-black\\/20{background-color:#0003}@supports (color:color-mix(in lab, red, red)){.bg-black\\/20{background-color:color-mix(in oklab, var(--color-black) 20%, transparent)}}.bg-card{background-color:var(--card)}.bg-current{background-color:currentColor}.bg-gray-900{background-color:var(--color-gray-900)}.bg-muted{background-color:var(--muted)}.bg-primary{background-color:var(--primary)}.bg-secondary{background-color:var(--secondary)}.bg-secondary-bg{background-color:var(--secondary-bg)}.bg-transparent{background-color:#0000}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.p-0{padding:0}.p-0\\.5{padding:calc(var(--spacing) * .5)}.p-1\\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-4{padding-block:calc(var(--spacing) * 4)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pl-2{padding-left:calc(var(--spacing) * 2)}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\\[10px\\]{font-size:10px}.text-\\[11px\\]{font-size:11px}.leading-normal{--tw-leading:var(--leading-normal);line-height:var(--leading-normal)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-snug{--tw-leading:var(--leading-snug);line-height:var(--leading-snug)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.whitespace-nowrap{white-space:nowrap}.text-blue-500{color:var(--color-blue-500)}.text-card-foreground{color:var(--card-foreground)}.text-foreground{color:var(--foreground)}.text-foreground-faint{color:var(--foreground-faint)}.text-foreground-muted{color:var(--foreground-muted)}.text-inherit{color:inherit}.text-muted-foreground{color:var(--muted-foreground)}.text-primary{color:var(--primary)}.text-primary-foreground{color:var(--primary-foreground)}.text-red-500{color:var(--color-red-500)}.text-secondary-foreground{color:var(--secondary-foreground)}.text-success{color:var(--success)}.text-warning{color:var(--warning)}.text-white{color:var(--color-white)}.uppercase{text-transform:uppercase}.italic{font-style:italic}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-100{opacity:1}.shadow,.shadow-\\[var\\(--shadow\\)\\]{--tw-shadow:var(--shadow);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:var(--shadow-lg);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-sm{--tw-shadow:var(--shadow-sm);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.backdrop-filter{backdrop-filter:var(--tw-backdrop-blur,) var(--tw-backdrop-brightness,) var(--tw-backdrop-contrast,) var(--tw-backdrop-grayscale,) var(--tw-backdrop-hue-rotate,) var(--tw-backdrop-invert,) var(--tw-backdrop-opacity,) var(--tw-backdrop-saturate,) var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[transform\\,opacity\\,background-color\\]{transition-property:transform,opacity,background-color;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\\[transform\\,opacity\\]{transition-property:transform,opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-\\[160ms\\]{--tw-duration:.16s;transition-duration:.16s}.duration-\\[167ms\\]{--tw-duration:.167s;transition-duration:.167s}.ease-\\[cubic-bezier\\(0\\.33\\,0\\,0\\,1\\)\\]{--tw-ease:cubic-bezier(.33,0,0,1);transition-timing-function:cubic-bezier(.33,0,0,1)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.group-focus-within\\:pointer-events-auto:is(:where(.group):focus-within *){pointer-events:auto}.group-focus-within\\:opacity-100:is(:where(.group):focus-within *){opacity:1}@media (hover:hover){.group-hover\\:pointer-events-auto:is(:where(.group):hover *){pointer-events:auto}.group-hover\\:opacity-100:is(:where(.group):hover *){opacity:1}}.placeholder\\:text-foreground-faint::placeholder{color:var(--foreground-faint)}.focus-within\\:border-foreground-faint:focus-within{border-color:var(--foreground-faint)}@media (hover:hover){.hover\\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x) var(--tw-scale-y)}.hover\\:border-primary:hover{border-color:var(--primary)}.hover\\:bg-muted:hover{background-color:var(--muted)}.hover\\:bg-primary:hover{background-color:var(--primary)}.hover\\:bg-primary-hover:hover{background-color:var(--primary-hover)}.hover\\:bg-primary\\/90:hover{background-color:var(--primary)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-primary\\/90:hover{background-color:color-mix(in oklab, var(--primary) 90%, transparent)}}.hover\\:bg-secondary-hover:hover{background-color:var(--secondary-hover)}.hover\\:bg-secondary\\/80:hover{background-color:var(--secondary)}@supports (color:color-mix(in lab, red, red)){.hover\\:bg-secondary\\/80:hover{background-color:color-mix(in oklab, var(--secondary) 80%, transparent)}}.hover\\:bg-transparent:hover{background-color:#0000}.hover\\:text-foreground:hover{color:var(--foreground)}.hover\\:text-primary:hover{color:var(--primary)}.hover\\:text-primary-foreground:hover{color:var(--primary-foreground)}.hover\\:opacity-100:hover{opacity:1}.hover\\:duration-\\[250ms\\]:hover{--tw-duration:.25s;transition-duration:.25s}}.focus\\:ring-0:focus{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\\:outline-ring:focus-visible{outline-color:var(--ring)}.active\\:scale-\\[0\\.85\\]:active{scale:.85}.active\\:duration-\\[134ms\\]:active{--tw-duration:.134s;transition-duration:.134s}.active\\:ease-\\[cubic-bezier\\(0\\.45\\,0\\,0\\.2\\,1\\)\\]:active{--tw-ease:cubic-bezier(.45,0,.2,1);transition-timing-function:cubic-bezier(.45,0,.2,1)}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\\:opacity-50:disabled{opacity:.5}}:root,:host{--background:oklch(100% 0 0);--foreground:oklch(14.5% 0 0);--card:oklch(100% 0 0);--card-foreground:oklch(14.5% 0 0);--popover:oklch(100% 0 0);--popover-foreground:oklch(14.5% 0 0);--primary:oklch(20.5% 0 0);--primary-foreground:oklch(98.5% 0 0);--secondary:oklch(97% 0 0);--secondary-foreground:oklch(20.5% 0 0);--muted:oklch(97% 0 0);--muted-foreground:oklch(55.6% 0 0);--accent:oklch(97% 0 0);--accent-foreground:oklch(20.5% 0 0);--destructive:oklch(57.7% .245 27.325);--destructive-foreground:oklch(100% 0 0);--success:oklch(60% .2 145);--success-foreground:oklch(100% 0 0);--warning:oklch(75% .18 85);--warning-foreground:oklch(20% 0 0);--border:oklch(92.2% 0 0);--input:oklch(92.2% 0 0);--ring:oklch(70.8% 0 0);--chart-1:oklch(81% .1 252);--chart-2:oklch(62% .19 260);--chart-3:oklch(55% .22 263);--chart-4:oklch(49% .22 264);--chart-5:oklch(42% .18 266);--sidebar:oklch(98.5% 0 0);--sidebar-foreground:oklch(14.5% 0 0);--sidebar-primary:oklch(20.5% 0 0);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(97% 0 0);--sidebar-accent-foreground:oklch(20.5% 0 0);--sidebar-border:oklch(92.2% 0 0);--sidebar-ring:oklch(70.8% 0 0);--foreground-muted:#1f293799;--foreground-faint:#1f293766;--border-muted:#e5e7eb4d;--primary-hover:#3b82f6d9;--primary-muted:#3b82f64d;--secondary-bg:#6b728033;--secondary-hover:#6b72804d;--font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--radius:.625rem;--shadow-x:0;--shadow-y:1px;--shadow-blur:3px;--shadow-spread:0px;--shadow-opacity:.1;--shadow-color:oklch(0% 0 0);--shadow-2xs:0 1px 3px 0px #0000000d;--shadow-xs:0 1px 3px 0px #0000000d;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-md:0 1px 3px 0px #0000001a, 0 2px 4px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--shadow-xl:0 1px 3px 0px #0000001a, 0 8px 10px -1px #0000001a;--shadow-2xl:0 1px 3px 0px #00000040;--tracking-normal:0em;--spacing:.25rem;--duration-animation:.3s;--duration-fade:.2s;--widget-width:400px;--widget-height:520px;--layer-tooltip:1000;--layer-popover:1050;--layer-dialog:1100;--layer-toast:1200}.dark,:host(.dark){--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20.5% 0 0);--card-foreground:oklch(98.5% 0 0);--popover:oklch(26.9% 0 0);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(92.2% 0 0);--primary-foreground:oklch(20.5% 0 0);--secondary:oklch(26.9% 0 0);--secondary-foreground:oklch(98.5% 0 0);--muted:oklch(26.9% 0 0);--muted-foreground:oklch(70.8% 0 0);--accent:oklch(37.1% 0 0);--accent-foreground:oklch(98.5% 0 0);--destructive:oklch(70.4% .191 22.216);--destructive-foreground:oklch(98.5% 0 0);--success:oklch(55% .2 145);--success-foreground:oklch(100% 0 0);--warning:oklch(70% .18 85);--warning-foreground:oklch(20% 0 0);--border:oklch(27.5% 0 0);--input:oklch(32.5% 0 0);--ring:oklch(55.6% 0 0);--chart-1:oklch(81% .1 252);--chart-2:oklch(62% .19 260);--chart-3:oklch(55% .22 263);--chart-4:oklch(49% .22 264);--chart-5:oklch(42% .18 266);--sidebar:oklch(20.5% 0 0);--sidebar-foreground:oklch(98.5% 0 0);--sidebar-primary:oklch(48.8% .243 264.376);--sidebar-primary-foreground:oklch(98.5% 0 0);--sidebar-accent:oklch(26.9% 0 0);--sidebar-accent-foreground:oklch(98.5% 0 0);--sidebar-border:oklch(27.5% 0 0);--sidebar-ring:oklch(43.9% 0 0);--font-sans:"Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--radius:.625rem;--shadow-x:0;--shadow-y:1px;--shadow-blur:3px;--shadow-spread:0px;--shadow-opacity:.1;--shadow-color:oklch(0% 0 0);--shadow-2xs:0 1px 3px 0px #0000000d;--shadow-xs:0 1px 3px 0px #0000000d;--shadow-sm:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow:0 1px 3px 0px #0000001a, 0 1px 2px -1px #0000001a;--shadow-md:0 1px 3px 0px #0000001a, 0 2px 4px -1px #0000001a;--shadow-lg:0 1px 3px 0px #0000001a, 0 4px 6px -1px #0000001a;--shadow-xl:0 1px 3px 0px #0000001a, 0 8px 10px -1px #0000001a;--shadow-2xl:0 1px 3px 0px #00000040}@media (prefers-reduced-motion:reduce){:root{--duration-animation:0s;--duration-fade:0s}}@keyframes dialog-overlay-in{0%{opacity:0}to{opacity:1}}@keyframes dialog-content-in{0%{opacity:0;scale:.96}to{opacity:1;scale:1}}@keyframes menu-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes popover-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@keyframes tooltip-in{0%{opacity:0;transform:scale(.96)}to{opacity:1;transform:scale(1)}}@keyframes toast-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}@keyframes fade-in{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes slide-in-left{0%{opacity:0;transform:translate(-30px)}to{opacity:1;transform:translate(0)}}@keyframes slide-in-right{0%{opacity:0;transform:translate(30px)}to{opacity:1;transform:translate(0)}}.marketrix-widget,[data-marketrix-widget]{font-family:var(--font-sans);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.marketrix-widget-container{z-index:var(--widget-z-index,1210);pointer-events:auto;position:fixed}.marketrix-widget,.marketrix-widget *,[data-marketrix-widget],[data-marketrix-widget] *{pointer-events:auto;box-sizing:border-box;transition:color .2s ease-in-out,background-color .2s ease-in-out,border-color .2s ease-in-out,opacity .2s ease-in-out,box-shadow .2s ease-in-out,transform .2s ease-in-out}.marketrix-widget button,.marketrix-widget input,.marketrix-widget textarea,.marketrix-widget select,[data-marketrix-widget] button,[data-marketrix-widget] input,[data-marketrix-widget] textarea,[data-marketrix-widget] select{font:inherit}[data-resizing=true],[data-resizing=true] *{transition:none!important}.gradient-border{border:2px solid;border-image:linear-gradient(to right, var(--foreground), var(--foreground)) 1}.marketrix-widget ::-webkit-scrollbar{width:6px;height:6px}.marketrix-widget * ::-webkit-scrollbar{width:6px;height:6px}.marketrix-widget ::-webkit-scrollbar-track{background:var(--muted);border-radius:3px}.marketrix-widget * ::-webkit-scrollbar-track{background:var(--muted);border-radius:3px}.marketrix-widget ::-webkit-scrollbar-thumb{background:var(--muted-foreground);border-radius:3px}.marketrix-widget * ::-webkit-scrollbar-thumb{background:var(--muted-foreground);border-radius:3px}.marketrix-widget ::-webkit-scrollbar-thumb:hover{background:var(--foreground)}.marketrix-widget * ::-webkit-scrollbar-thumb:hover{background:var(--foreground)}.marketrix-widget{scrollbar-color:var(--muted) var(--muted-foreground);scrollbar-width:thin}.marketrix-widget ::-webkit-scrollbar-button{width:0;height:0;display:none!important}.marketrix-widget * ::-webkit-scrollbar-button{width:0;height:0;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:start:decrement{display:none!important}.marketrix-widget ::-webkit-scrollbar-button:end:increment{display:none!important}.marketrix-widget * ::-webkit-scrollbar-button:start:decrement{display:none!important}.marketrix-widget * ::-webkit-scrollbar-button:end:increment{display:none!important}.marketrix-widget ::-webkit-scrollbar-corner{display:none!important}.marketrix-widget * ::-webkit-scrollbar-corner{display:none!important}.marketrix-widget ::-webkit-scrollbar-button:vertical:start:decrement{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:vertical:end:increment{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:horizontal:start:decrement{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button:horizontal:end:increment{width:0!important;height:0!important;display:none!important}.marketrix-widget ::-webkit-scrollbar-button{background:0 0!important;border:none!important;width:0!important;height:0!important;display:none!important}@keyframes glow-border-pulse{0%,to{border-color:#fff9;box-shadow:0 0 #ffffff4d,0 0 #1f293766}50%{border-color:#fff;box-shadow:0 0 0 2px #fff9,0 0 0 4px #1f29374d}}@keyframes marketrix-screen-edge-pulse{0%,to{opacity:.55}50%{opacity:1}}.marketrix-screen-edge-glow,[data-screen-edge-glow]{animation:1.6s ease-in-out infinite marketrix-screen-edge-pulse}.marketrix-widget-button-processing-glow,.marketrix-widget-button-error-glow{pointer-events:none;filter:blur(14px);will-change:transform, opacity;border-radius:50%;width:140%;height:140%;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}@keyframes widget-activity-dash-travel{0%{stroke-dashoffset:0;opacity:.5}18%{stroke-dashoffset:-112px;opacity:1}35%{stroke-dashoffset:-160px;opacity:.65}60%{stroke-dashoffset:-160px;opacity:.45}82%{stroke-dashoffset:-272px;opacity:1}to{stroke-dashoffset:-320px;opacity:.6}}.marketrix-widget-button-processing-activity-ring,.marketrix-widget-button-error-activity-ring{pointer-events:none;z-index:0;position:absolute;inset:-3px;overflow:visible}.marketrix-widget-button-processing-activity-ring rect,.marketrix-widget-button-error-activity-ring rect{fill:none;stroke-width:2.5px;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:40 120;animation:1.9s cubic-bezier(.4,0,.2,1) infinite widget-activity-dash-travel}.marketrix-widget-button-processing-activity-ring rect{stroke:#31d06d;filter:drop-shadow(0 0 3px #31d06db3)}.marketrix-widget-button-error-activity-ring rect{stroke:#d0342c;filter:drop-shadow(0 0 3px #d0342cb3)}@keyframes widget-glow-green{0%,to{opacity:.72;background:radial-gradient(circle,#31d06d00 38%,#31d06d61 58%,#31d06d3d 68%,#0000 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:1;background:radial-gradient(circle,#31d06d00 34%,#31d06d8c 56%,#31d06d54 68%,#0000 80%);transform:translate(-50%,-50%)scale(1.1)}}.marketrix-widget-button-processing-glow{animation:2s ease-in-out infinite widget-glow-green}@keyframes widget-glow-red{0%,to{opacity:.65;background:radial-gradient(circle,#d0342c00 38%,#d0342c57 58%,#d0342c38 68%,#0000 78%);transform:translate(-50%,-50%)scale(1)}50%{opacity:.95;background:radial-gradient(circle,#d0342c00 34%,#d0342c80 56%,#d0342c4d 68%,#0000 80%);transform:translate(-50%,-50%)scale(1.1)}}.marketrix-widget-button-error-glow{animation:1.5s ease-in-out infinite widget-glow-red}@keyframes launcher-entrance{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}.animate-launcher-entrance{animation:.25s ease-out forwards launcher-entrance}@keyframes messenger-entrance{0%{opacity:0;transform:scale(0)}40%{opacity:1}to{transform:scale(1)}}@keyframes messenger-exit{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)translateY(8px)}}.animate-messenger-entrance{animation:.3s cubic-bezier(0,1.2,1,1) messenger-entrance}.animate-messenger-exit{animation:.2s cubic-bezier(.4,0,.2,1) forwards messenger-exit}@keyframes message-enter{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.animate-message-enter{animation:.2s ease-out message-enter}.view-slide-enter.forward{opacity:0;transform:translate(20px)}.view-slide-enter.back{opacity:0;transform:translate(-20px)}.view-slide-enter-active{opacity:1;transition:transform .15s .15s,opacity .15s .15s;transform:translate(0)}.view-slide-enter-active.forward,.view-slide-enter-active.back{opacity:1;transform:translate(0)}.view-slide-exit-active.forward{opacity:0;transition:transform .15s,opacity .15s;transform:translate(-20px)}.view-slide-exit-active.back{opacity:0;transition:transform .15s,opacity .15s;transform:translate(20px)}[data-view-transition][data-direction=forward]{animation:.3s both viewSlideForward}[data-view-transition][data-direction=back]{animation:.3s both viewSlideBack}@keyframes viewSlideForward{0%{opacity:0;transform:translate(20px)}to{opacity:1;transform:translate(0)}}@keyframes viewSlideBack{0%{opacity:0;transform:translate(-20px)}to{opacity:1;transform:translate(0)}}@media print{.marketrix-widget{display:none!important}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}';function Rg(e){return null!==e&&e instanceof HTMLElement}var Ag=null,Ng=null,Pg=null,Lg=!1,$g=0,Dg=(e,t)=>{const n=t||"marketrix-widget-container-"+ ++$g;let r;if(e){if(e.querySelector(`#${n}`))throw new Error(`Widget container with ID ${n} already exists`);r=document.createElement("div"),r.id=n,r.className="marketrix-widget-container",r.style.width="100%",r.style.height="100%",r.style.position="relative",r.style.overflow="visible",e.appendChild(r)}else{if(document.getElementById(n))throw new Error(`Widget container with ID ${n} already exists`);r=document.createElement("div"),r.id=n,r.className="marketrix-widget-container",document.body.appendChild(r)}if(r.style.pointerEvents="auto",!Rg(r))throw new Error("Container is not an HTMLElement");if(r.shadowRoot)throw new Error("Container already has a shadow root");const o=r.attachShadow({mode:"closed"}),i=document.createElement("style");if(i.textContent=Og,o.appendChild(i),o.querySelector("#marketrix-widget-root"))throw new Error("Mount element already exists in shadow root");const s=document.createElement("div");return s.id="marketrix-widget-root",s.style.pointerEvents="auto",s.style.width="100%",s.style.height="100%",s.style.position="relative",o.appendChild(s),{container:r,shadowRoot:o,mountEl:s}},Fg=(e,n,r=!1)=>{const o=h(e),i=e.getRootNode();return o.render(/* @__PURE__ */m(t.StrictMode,{children:/* @__PURE__ */m(kh,{previewMode:r,portalContainer:i,children:/* @__PURE__ */m(Qh,{config:n})})})),o},jg=e=>{if(!e)throw new Error("Container is required");e.remove()},Ug=e=>{Ag=e},Wg=()=>Ng,Bg=e=>{Ng=e},Hg=()=>null!==Ag,qg=e=>{Lg=e},Zg=e=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(Pg){const e=document.getElementById("marketrix-widget-loader-container");e&&e.remove(),Pg.unmount(),Pg=null}if(document.getElementById("marketrix-widget-loader-container"))throw new Error("Widget loader container already exists");const n=document.createElement("div");n.id="marketrix-widget-loader-container",n.className="marketrix-widget-loader-container",document.body.appendChild(n);const r=n.attachShadow({mode:"closed"}),o=document.createElement("style");o.textContent=Og,r.appendChild(o);const i=document.createElement("div");i.id="marketrix-widget-loader-root",r.appendChild(i);const s=h(i);Pg=s,s.render(/* @__PURE__ */m(t.StrictMode,{children:/* @__PURE__ */m(zg,{message:e})}))},Vg=()=>{if(Pg){Pg.unmount(),Pg=null;const e=document.getElementById("marketrix-widget-loader-container");e&&e.remove()}},Gg=null,Yg=()=>{if("undefined"==typeof window||"undefined"==typeof document)return;if(window.__mtx?.state)return;if(!Gg)return;const e=document.querySelectorAll("script[mtx-id]"),t=e[e.length-1];if(!(t&&(n=t,null!==n&&n instanceof HTMLScriptElement)))return;var n;const r=t,o=r.getAttribute("mtx-id"),i=r.getAttribute("mtx-key"),s=r.getAttribute("mtx-api-host"),a=r.getAttribute("mtx-use-screenshare");if(o&&i){const e={mtxId:o,mtxKey:i};s&&(e.mtxApiHost=s),"false"===a&&(e.use_screenshare=!1),Gg(e).catch(e=>{})}else{if(Hg()||Lg)return;Zg("Please configure mtx-id and mtx-key")}},Kg=null,Jg=0,Xg=null,Qg=null;var ey=(e,t)=>{if(Kg)return Kg;if(window.__mtx?.state)return Promise.resolve();if(Hg())return Promise.resolve();const n=async function(e,t,n){let r;qg(!0),window.__mtx={state:"initializing"},e.mtxApiHost&&ks(e.mtxApiHost),Zg("Loading widget settings...");try{r=await _g(e)}catch(a){if(n!==Jg)return;return Zg(a instanceof Error?a.message:"Failed to initialize widget"),qg(!1),void(window.__mtx=void 0)}if(n!==Jg)return;Vg(),Bg(r);const{container:o,mountEl:i}=Dg(t);Xg=o;const s=Fg(i,r);Ug(s),qg(!1),window.__mtx={state:"active"},r.widget_recording&&r.mtxApp&&(async()=>{try{if(await Ks.getInstance().waitUntilRegistered(),n!==Jg)return;const e=await Ys.getOrCreateChatId();if(n!==Jg)return;const t=new xg(e,r.mtxApp);Qg=t,await t.start(),n!==Jg&&(t.stop(),Qg===t&&(Qg=null))}catch(a){}})()}(e,t,++Jg);return Kg=n,n.then(()=>{Kg===n&&(Kg=null)},()=>{Kg===n&&(Kg=null)}),n},ty=()=>{Jg++,Ks.getInstance().disconnect(),Qg?.stop(),Qg=null;const e=Ag;e&&e.unmount(),Ag=null,Ng=null,Xg&&(jg(Xg),Xg=null),Kg=null,window.__mtx=void 0,qg(!1),Vg()},ny=async e=>{if(Hg()){const t=Wg();if(!t)throw new Error("Widget not initialized");const n={...t,...e};ty(),await ey(n)}},ry=({settings:e,container:t,mtxId:n,mtxKey:r,mtxApiHost:o})=>{const i=d(null),s=d(null),c=d(null),l=d(null);return a(()=>{const a=t??i?.current?.parentElement??document.body;if(!a||!Rg(a))return;l.current||(l.current=`marketrix-widget-${Date.now()}-${Math.random().toString(36).slice(2,11)}`);const{container:d,shadowRoot:u,mountEl:p}=Dg(a,l.current);c.current=d;const f={...aa(e,{mtxId:n,mtxKey:r,mtxApiHost:o}),isPreviewMode:!0,widget_enabled:e.widget_enabled??!0};s.current&&(s.current.unmount(),s.current=null);const g=h(p);return s.current=g,g.render(/* @__PURE__ */m(kh,{previewMode:!0,portalContainer:u,children:/* @__PURE__ */m(Qh,{config:f})})),()=>{s.current&&(s.current.unmount(),s.current=null),c.current&&(jg(c.current),c.current=null,l.current=null)}},[e,t,n,r,o]),t?null:/* @__PURE__ */m("div",{ref:i,style:{width:"100%",height:"100%",position:"relative"}})},oy=async e=>{const t=e.container;if("settings"in e&&void 0!==e.settings){ty(),qg(!0);const{settings:n,container:r,...o}=e,i={...aa(n,o),isPreviewMode:!0},{container:s,mountEl:a}=Dg(t),c=Fg(a,i,!0);Xg=s,Ug(c),Bg(i),qg(!1)}else{if(!("mtxId"in e)||void 0===e.mtxId||void 0===e.mtxKey)throw new Error("Invalid configuration: provide either settings (preview) or mtxId+mtxKey (production)");{const{mtxId:n,mtxKey:r,container:o,...i}=e;await ey({mtxId:n,mtxKey:r,...i},t)}}};"undefined"!=typeof window&&setTimeout(()=>{try{(e=>{"function"==typeof e&&(Gg=e,Yg())})(ey)}catch(e){}},0);var iy={MarketrixWidget:ry,mountWidget:oy,initWidget:ey,unmountWidget:ty,updateMarketrixConfig:ny,getCurrentConfig:Wg};export{ry as MarketrixWidget,iy as default,Wg as getCurrentConfig,ey as initWidget,oy as mountWidget,ty as unmountWidget,ny as updateMarketrixConfig};
62
62
  //# sourceMappingURL=widget.mjs.map