@web-applets/inspector 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,326 @@
1
+ var rs=t=>{throw TypeError(t)};var Qr=(t,e,r)=>e.has(t)||rs("Cannot "+r);var A=(t,e,r)=>(Qr(t,e,"read from private field"),r?r.call(t):e.get(t)),H=(t,e,r)=>e.has(t)?rs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),q=(t,e,r,n)=>(Qr(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r),he=(t,e,r)=>(Qr(t,e,"access private method"),r);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&n(i)}).observe(document,{childList:!0,subtree:!0});function r(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function n(s){if(s.ep)return;s.ep=!0;const a=r(s);fetch(s.href,a)}})();/**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */const wr=globalThis,Dn=wr.ShadowRoot&&(wr.ShadyCSS===void 0||wr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Vs=Symbol(),ns=new WeakMap;let Li=class{constructor(e,r,n){if(this._$cssResult$=!0,n!==Vs)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=r}get styleSheet(){let e=this.o;const r=this.t;if(Dn&&e===void 0){const n=r!==void 0&&r.length===1;n&&(e=ns.get(r)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&ns.set(r,e))}return e}toString(){return this.cssText}};const Vi=t=>new Li(typeof t=="string"?t:t+"",void 0,Vs),Fi=(t,e)=>{if(Dn)t.adoptedStyleSheets=e.map(r=>r instanceof CSSStyleSheet?r:r.styleSheet);else for(const r of e){const n=document.createElement("style"),s=wr.litNonce;s!==void 0&&n.setAttribute("nonce",s),n.textContent=r.cssText,t.appendChild(n)}},ss=Dn?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let r="";for(const n of e.cssRules)r+=n.cssText;return Vi(r)})(t):t;/**
6
+ * @license
7
+ * Copyright 2017 Google LLC
8
+ * SPDX-License-Identifier: BSD-3-Clause
9
+ */const{is:Bi,defineProperty:zi,getOwnPropertyDescriptor:qi,getOwnPropertyNames:Ji,getOwnPropertySymbols:Hi,getPrototypeOf:Wi}=Object,Je=globalThis,as=Je.trustedTypes,Yi=as?as.emptyScript:"",en=Je.reactiveElementPolyfillSupport,Nt=(t,e)=>t,kr={toAttribute(t,e){switch(e){case Boolean:t=t?Yi:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let r=t;switch(e){case Boolean:r=t!==null;break;case Number:r=t===null?null:Number(t);break;case Object:case Array:try{r=JSON.parse(t)}catch{r=null}}return r}},Zn=(t,e)=>!Bi(t,e),is={attribute:!0,type:String,converter:kr,reflect:!1,hasChanged:Zn};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Je.litPropertyMetadata??(Je.litPropertyMetadata=new WeakMap);class mt extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,r=is){if(r.state&&(r.attribute=!1),this._$Ei(),this.elementProperties.set(e,r),!r.noAccessor){const n=Symbol(),s=this.getPropertyDescriptor(e,n,r);s!==void 0&&zi(this.prototype,e,s)}}static getPropertyDescriptor(e,r,n){const{get:s,set:a}=qi(this.prototype,e)??{get(){return this[r]},set(i){this[r]=i}};return{get(){return s==null?void 0:s.call(this)},set(i){const o=s==null?void 0:s.call(this);a.call(this,i),this.requestUpdate(e,o,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??is}static _$Ei(){if(this.hasOwnProperty(Nt("elementProperties")))return;const e=Wi(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Nt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Nt("properties"))){const r=this.properties,n=[...Ji(r),...Hi(r)];for(const s of n)this.createProperty(s,r[s])}const e=this[Symbol.metadata];if(e!==null){const r=litPropertyMetadata.get(e);if(r!==void 0)for(const[n,s]of r)this.elementProperties.set(n,s)}this._$Eh=new Map;for(const[r,n]of this.elementProperties){const s=this._$Eu(r,n);s!==void 0&&this._$Eh.set(s,r)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const r=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const s of n)r.unshift(ss(s))}else e!==void 0&&r.push(ss(e));return r}static _$Eu(e,r){const n=r.attribute;return n===!1?void 0:typeof n=="string"?n:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(r=>this.enableUpdating=r),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(r=>r(this))}addController(e){var r;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((r=e.hostConnected)==null||r.call(e))}removeController(e){var r;(r=this._$EO)==null||r.delete(e)}_$E_(){const e=new Map,r=this.constructor.elementProperties;for(const n of r.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Fi(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(r=>{var n;return(n=r.hostConnected)==null?void 0:n.call(r)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(r=>{var n;return(n=r.hostDisconnected)==null?void 0:n.call(r)})}attributeChangedCallback(e,r,n){this._$AK(e,n)}_$EC(e,r){var a;const n=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,n);if(s!==void 0&&n.reflect===!0){const i=(((a=n.converter)==null?void 0:a.toAttribute)!==void 0?n.converter:kr).toAttribute(r,n.type);this._$Em=e,i==null?this.removeAttribute(s):this.setAttribute(s,i),this._$Em=null}}_$AK(e,r){var a;const n=this.constructor,s=n._$Eh.get(e);if(s!==void 0&&this._$Em!==s){const i=n.getPropertyOptions(s),o=typeof i.converter=="function"?{fromAttribute:i.converter}:((a=i.converter)==null?void 0:a.fromAttribute)!==void 0?i.converter:kr;this._$Em=s,this[s]=o.fromAttribute(r,i.type),this._$Em=null}}requestUpdate(e,r,n){if(e!==void 0){if(n??(n=this.constructor.getPropertyOptions(e)),!(n.hasChanged??Zn)(this[e],r))return;this.P(e,r,n)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(e,r,n){this._$AL.has(e)||this._$AL.set(e,r),n.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(r){Promise.reject(r)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var n;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[a,i]of this._$Ep)this[a]=i;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[a,i]of s)i.wrapped!==!0||this._$AL.has(a)||this[a]===void 0||this.P(a,this[a],i)}let e=!1;const r=this._$AL;try{e=this.shouldUpdate(r),e?(this.willUpdate(r),(n=this._$EO)==null||n.forEach(s=>{var a;return(a=s.hostUpdate)==null?void 0:a.call(s)}),this.update(r)):this._$EU()}catch(s){throw e=!1,this._$EU(),s}e&&this._$AE(r)}willUpdate(e){}_$AE(e){var r;(r=this._$EO)==null||r.forEach(n=>{var s;return(s=n.hostUpdated)==null?void 0:s.call(n)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(r=>this._$EC(r,this[r]))),this._$EU()}updated(e){}firstUpdated(e){}}mt.elementStyles=[],mt.shadowRootOptions={mode:"open"},mt[Nt("elementProperties")]=new Map,mt[Nt("finalized")]=new Map,en==null||en({ReactiveElement:mt}),(Je.reactiveElementVersions??(Je.reactiveElementVersions=[])).push("2.0.4");/**
10
+ * @license
11
+ * Copyright 2017 Google LLC
12
+ * SPDX-License-Identifier: BSD-3-Clause
13
+ */const Mt=globalThis,Sr=Mt.trustedTypes,os=Sr?Sr.createPolicy("lit-html",{createHTML:t=>t}):void 0,Fs="$lit$",Be=`lit$${Math.random().toFixed(9).slice(2)}$`,Bs="?"+Be,Gi=`<${Bs}>`,nt=document,Ut=()=>nt.createComment(""),Lt=t=>t===null||typeof t!="object"&&typeof t!="function",Un=Array.isArray,Ki=t=>Un(t)||typeof(t==null?void 0:t[Symbol.iterator])=="function",tn=`[
14
+ \f\r]`,Ct=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ls=/-->/g,cs=/>/g,Ke=RegExp(`>|${tn}(?:([^\\s"'>=/]+)(${tn}*=${tn}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),us=/'/g,ds=/"/g,zs=/^(?:script|style|textarea|title)$/i,Xi=t=>(e,...r)=>({_$litType$:t,strings:e,values:r}),J=Xi(1),st=Symbol.for("lit-noChange"),K=Symbol.for("lit-nothing"),ps=new WeakMap,et=nt.createTreeWalker(nt,129);function qs(t,e){if(!Un(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return os!==void 0?os.createHTML(e):e}const Qi=(t,e)=>{const r=t.length-1,n=[];let s,a=e===2?"<svg>":e===3?"<math>":"",i=Ct;for(let o=0;o<r;o++){const l=t[o];let c,d,p=-1,g=0;for(;g<l.length&&(i.lastIndex=g,d=i.exec(l),d!==null);)g=i.lastIndex,i===Ct?d[1]==="!--"?i=ls:d[1]!==void 0?i=cs:d[2]!==void 0?(zs.test(d[2])&&(s=RegExp("</"+d[2],"g")),i=Ke):d[3]!==void 0&&(i=Ke):i===Ke?d[0]===">"?(i=s??Ct,p=-1):d[1]===void 0?p=-2:(p=i.lastIndex-d[2].length,c=d[1],i=d[3]===void 0?Ke:d[3]==='"'?ds:us):i===ds||i===us?i=Ke:i===ls||i===cs?i=Ct:(i=Ke,s=void 0);const S=i===Ke&&t[o+1].startsWith("/>")?" ":"";a+=i===Ct?l+Gi:p>=0?(n.push(c),l.slice(0,p)+Fs+l.slice(p)+Be+S):l+Be+(p===-2?o:S)}return[qs(t,a+(t[r]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),n]};class Vt{constructor({strings:e,_$litType$:r},n){let s;this.parts=[];let a=0,i=0;const o=e.length-1,l=this.parts,[c,d]=Qi(e,r);if(this.el=Vt.createElement(c,n),et.currentNode=this.el.content,r===2||r===3){const p=this.el.content.firstChild;p.replaceWith(...p.childNodes)}for(;(s=et.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes())for(const p of s.getAttributeNames())if(p.endsWith(Fs)){const g=d[i++],S=s.getAttribute(p).split(Be),_=/([.?@])?(.*)/.exec(g);l.push({type:1,index:a,name:_[2],strings:S,ctor:_[1]==="."?to:_[1]==="?"?ro:_[1]==="@"?no:qr}),s.removeAttribute(p)}else p.startsWith(Be)&&(l.push({type:6,index:a}),s.removeAttribute(p));if(zs.test(s.tagName)){const p=s.textContent.split(Be),g=p.length-1;if(g>0){s.textContent=Sr?Sr.emptyScript:"";for(let S=0;S<g;S++)s.append(p[S],Ut()),et.nextNode(),l.push({type:2,index:++a});s.append(p[g],Ut())}}}else if(s.nodeType===8)if(s.data===Bs)l.push({type:2,index:a});else{let p=-1;for(;(p=s.data.indexOf(Be,p+1))!==-1;)l.push({type:7,index:a}),p+=Be.length-1}a++}}static createElement(e,r){const n=nt.createElement("template");return n.innerHTML=e,n}}function _t(t,e,r=t,n){var i,o;if(e===st)return e;let s=n!==void 0?(i=r._$Co)==null?void 0:i[n]:r._$Cl;const a=Lt(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==a&&((o=s==null?void 0:s._$AO)==null||o.call(s,!1),a===void 0?s=void 0:(s=new a(t),s._$AT(t,r,n)),n!==void 0?(r._$Co??(r._$Co=[]))[n]=s:r._$Cl=s),s!==void 0&&(e=_t(t,s._$AS(t,e.values),s,n)),e}class eo{constructor(e,r){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=r}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:r},parts:n}=this._$AD,s=((e==null?void 0:e.creationScope)??nt).importNode(r,!0);et.currentNode=s;let a=et.nextNode(),i=0,o=0,l=n[0];for(;l!==void 0;){if(i===l.index){let c;l.type===2?c=new hr(a,a.nextSibling,this,e):l.type===1?c=new l.ctor(a,l.name,l.strings,this,e):l.type===6&&(c=new so(a,this,e)),this._$AV.push(c),l=n[++o]}i!==(l==null?void 0:l.index)&&(a=et.nextNode(),i++)}return et.currentNode=nt,s}p(e){let r=0;for(const n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(e,n,r),r+=n.strings.length-2):n._$AI(e[r])),r++}}class hr{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,r,n,s){this.type=2,this._$AH=K,this._$AN=void 0,this._$AA=e,this._$AB=r,this._$AM=n,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const r=this._$AM;return r!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=r.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,r=this){e=_t(this,e,r),Lt(e)?e===K||e==null||e===""?(this._$AH!==K&&this._$AR(),this._$AH=K):e!==this._$AH&&e!==st&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Ki(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==K&&Lt(this._$AH)?this._$AA.nextSibling.data=e:this.T(nt.createTextNode(e)),this._$AH=e}$(e){var a;const{values:r,_$litType$:n}=e,s=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=Vt.createElement(qs(n.h,n.h[0]),this.options)),n);if(((a=this._$AH)==null?void 0:a._$AD)===s)this._$AH.p(r);else{const i=new eo(s,this),o=i.u(this.options);i.p(r),this.T(o),this._$AH=i}}_$AC(e){let r=ps.get(e.strings);return r===void 0&&ps.set(e.strings,r=new Vt(e)),r}k(e){Un(this._$AH)||(this._$AH=[],this._$AR());const r=this._$AH;let n,s=0;for(const a of e)s===r.length?r.push(n=new hr(this.O(Ut()),this.O(Ut()),this,this.options)):n=r[s],n._$AI(a),s++;s<r.length&&(this._$AR(n&&n._$AB.nextSibling,s),r.length=s)}_$AR(e=this._$AA.nextSibling,r){var n;for((n=this._$AP)==null?void 0:n.call(this,!1,!0,r);e&&e!==this._$AB;){const s=e.nextSibling;e.remove(),e=s}}setConnected(e){var r;this._$AM===void 0&&(this._$Cv=e,(r=this._$AP)==null||r.call(this,e))}}class qr{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,r,n,s,a){this.type=1,this._$AH=K,this._$AN=void 0,this.element=e,this.name=r,this._$AM=s,this.options=a,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=K}_$AI(e,r=this,n,s){const a=this.strings;let i=!1;if(a===void 0)e=_t(this,e,r,0),i=!Lt(e)||e!==this._$AH&&e!==st,i&&(this._$AH=e);else{const o=e;let l,c;for(e=a[0],l=0;l<a.length-1;l++)c=_t(this,o[n+l],r,l),c===st&&(c=this._$AH[l]),i||(i=!Lt(c)||c!==this._$AH[l]),c===K?e=K:e!==K&&(e+=(c??"")+a[l+1]),this._$AH[l]=c}i&&!s&&this.j(e)}j(e){e===K?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class to extends qr{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===K?void 0:e}}class ro extends qr{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==K)}}class no extends qr{constructor(e,r,n,s,a){super(e,r,n,s,a),this.type=5}_$AI(e,r=this){if((e=_t(this,e,r,0)??K)===st)return;const n=this._$AH,s=e===K&&n!==K||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,a=e!==K&&(n===K||s);s&&this.element.removeEventListener(this.name,this,n),a&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var r;typeof this._$AH=="function"?this._$AH.call(((r=this.options)==null?void 0:r.host)??this.element,e):this._$AH.handleEvent(e)}}let so=class{constructor(e,r,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=r,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){_t(this,e)}};const rn=Mt.litHtmlPolyfillSupport;rn==null||rn(Vt,hr),(Mt.litHtmlVersions??(Mt.litHtmlVersions=[])).push("3.2.1");const ao=(t,e,r)=>{const n=(r==null?void 0:r.renderBefore)??e;let s=n._$litPart$;if(s===void 0){const a=(r==null?void 0:r.renderBefore)??null;n._$litPart$=s=new hr(e.insertBefore(Ut(),a),a,void 0,r??{})}return s._$AI(t),s};/**
16
+ * @license
17
+ * Copyright 2017 Google LLC
18
+ * SPDX-License-Identifier: BSD-3-Clause
19
+ */let _e=class extends mt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var r;const e=super.createRenderRoot();return(r=this.renderOptions).renderBefore??(r.renderBefore=e.firstChild),e}update(e){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=ao(r,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return st}};var Ls;_e._$litElement$=!0,_e.finalized=!0,(Ls=globalThis.litElementHydrateSupport)==null||Ls.call(globalThis,{LitElement:_e});const nn=globalThis.litElementPolyfillSupport;nn==null||nn({LitElement:_e});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");/**
20
+ * @license
21
+ * Copyright 2017 Google LLC
22
+ * SPDX-License-Identifier: BSD-3-Clause
23
+ */const je=t=>(e,r)=>{r!==void 0?r.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)};/**
24
+ * @license
25
+ * Copyright 2017 Google LLC
26
+ * SPDX-License-Identifier: BSD-3-Clause
27
+ */const io={attribute:!0,type:String,converter:kr,reflect:!1,hasChanged:Zn},oo=(t=io,e,r)=>{const{kind:n,metadata:s}=r;let a=globalThis.litPropertyMetadata.get(s);if(a===void 0&&globalThis.litPropertyMetadata.set(s,a=new Map),a.set(r.name,t),n==="accessor"){const{name:i}=r;return{set(o){const l=e.get.call(this);e.set.call(this,o),this.requestUpdate(i,l,t)},init(o){return o!==void 0&&this.P(i,void 0,t),o}}}if(n==="setter"){const{name:i}=r;return function(o){const l=this[i];e.call(this,o),this.requestUpdate(i,l,t)}}throw Error("Unsupported decorator location: "+n)};function me(t){return(e,r)=>typeof r=="object"?oo(t,e,r):((n,s,a)=>{const i=s.hasOwnProperty(a);return s.constructor.createProperty(a,i?{...n,wrapped:!0}:n),i?Object.getOwnPropertyDescriptor(s,a):void 0})(t,e,r)}/**
28
+ * @license
29
+ * Copyright 2017 Google LLC
30
+ * SPDX-License-Identifier: BSD-3-Clause
31
+ */function lo(t){return me({...t,state:!0,attribute:!1})}let ze={appletUrl:"",settings:{},settingsDialogOpen:!1};localStorage.getItem("data")&&(ze=JSON.parse(localStorage.getItem("data")));const Ln=new Set;function co(t){ze={...ze,...t},localStorage.setItem("data",JSON.stringify({appletUrl:ze.appletUrl,settings:ze.settings})),Ln.forEach(e=>e(ze))}function uo(){return ze}function po(t){return t(ze),Ln.add(t),()=>Js(t)}function Js(t){Ln.delete(t)}const we={get:uo,update:co,subscribe:po,unsubscribe:Js};var ho=Object.getOwnPropertyDescriptor,fo=(t,e,r,n)=>{for(var s=n>1?void 0:n?ho(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(s=i(s)||s);return s};let hs=class extends _e{createRenderRoot(){return this}connectedCallback(){super.connectedCallback()}handleKeyDown(e){if(e.key==="Enter"){const r=e.target;r.value&&!r.value.startsWith("http://")&&!r.value.startsWith("https://")&&(r.value=`http://${r.value}`),we.update({appletUrl:r.value})}}render(){return J`<input
32
+ value=${we.get().appletUrl}
33
+ type="text"
34
+ placeholder="Enter an applet URL to inspect..."
35
+ @keydown=${this.handleKeyDown.bind(this)}
36
+ />`}};hs=fo([je("url-input")],hs);var mo=Object.getOwnPropertyDescriptor,go=(t,e,r,n)=>{for(var s=n>1?void 0:n?mo(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(s=i(s)||s);return s};let fs=class extends _e{createRenderRoot(){return this}openDialog(){we.update({settingsDialogOpen:!0})}render(){return J`
37
+ <button
38
+ aria-label="open settings"
39
+ class="menu-button"
40
+ @click="${this.openDialog}"
41
+ >
42
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
43
+ <path d="M10.0001 16.6667C11.7682 16.6667 13.4639 15.9643 14.7141 14.7141C15.9644 13.4638 16.6667 11.7681 16.6667 10C16.6667 8.23191 15.9644 6.53622 14.7141 5.28598C13.4639 4.03573 11.7682 3.33335 10.0001 3.33335M10.0001 16.6667C8.23197 16.6667 6.53628 15.9643 5.28604 14.7141C4.03579 13.4638 3.33341 11.7681 3.33341 10M10.0001 16.6667V18.3334M10.0001 3.33335C8.23197 3.33335 6.53628 4.03573 5.28604 5.28598C4.03579 6.53622 3.33341 8.23191 3.33341 10M10.0001 3.33335V1.66669M3.33341 10H1.66675M11.6667 10C11.6667 10.442 11.4912 10.866 11.1786 11.1785C10.866 11.4911 10.4421 11.6667 10.0001 11.6667C9.55805 11.6667 9.13413 11.4911 8.82157 11.1785C8.50901 10.866 8.33341 10.442 8.33341 10C8.33341 9.55799 8.50901 9.13407 8.82157 8.82151C9.13413 8.50895 9.55805 8.33335 10.0001 8.33335C10.4421 8.33335 10.866 8.50895 11.1786 8.82151C11.4912 9.13407 11.6667 9.55799 11.6667 10ZM11.6667 10H18.3334M14.1667 17.2166L13.3334 15.775M9.16675 8.55843L5.83341 2.78343M17.2169 14.1667L15.7752 13.3334M2.78328 5.83335L4.22495 6.66669M17.2169 5.83335L15.7752 6.66669M2.78328 14.1667L4.22495 13.3334M14.1667 2.78343L13.3334 4.22509M9.16675 11.4417L5.83341 17.2167" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
44
+ </svg>
45
+ </button>
46
+ `}};fs=go([je("settings-button")],fs);/**
47
+ * @license
48
+ * Copyright 2017 Google LLC
49
+ * SPDX-License-Identifier: BSD-3-Clause
50
+ */const Hs={CHILD:2},Ws=t=>(...e)=>({_$litDirective$:t,values:e});class Ys{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,r,n){this._$Ct=e,this._$AM=r,this._$Ci=n}_$AS(e,r){return this.update(e,r)}update(e,r){return this.render(...r)}}/**
51
+ * @license
52
+ * Copyright 2017 Google LLC
53
+ * SPDX-License-Identifier: BSD-3-Clause
54
+ */let vn=class extends Ys{constructor(e){if(super(e),this.it=K,e.type!==Hs.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===K||e==null)return this._t=void 0,this.it=e;if(e===st)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const r=[e];return r.raw=r,this._t={_$litType$:this.constructor.resultType,strings:r,values:[]}}};vn.directiveName="unsafeHTML",vn.resultType=1;const yo=Ws(vn);var vo=Object.defineProperty,_o=Object.getOwnPropertyDescriptor,Jr=(t,e,r,n)=>{for(var s=n>1?void 0:n?_o(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(s=(n?i(e,r,s):i(s))||s);return n&&s&&vo(e,r,s),s};const bo=`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
55
+ <path d="M12.5 2.5V17.5M8.33333 12.5L5.83333 10L8.33333 7.5M4.16667 2.5H15.8333C16.7538 2.5 17.5 3.24619 17.5 4.16667V15.8333C17.5 16.7538 16.7538 17.5 15.8333 17.5H4.16667C3.24619 17.5 2.5 16.7538 2.5 15.8333V4.16667C2.5 3.24619 3.24619 2.5 4.16667 2.5Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
56
+ </svg>
57
+ `;let Ft=class extends _e{constructor(){super(...arguments),this.variableName="",this.defaultValue="1fr",this.icon=bo}createRenderRoot(){return this}toggle(){const t=document.querySelector("main");if(!t){console.error("Main element not found.");return}getComputedStyle(t).getPropertyValue(this.variableName).trim()==="0px"?t.style.setProperty(this.variableName,this.defaultValue):t.style.setProperty(this.variableName,"0px")}render(){return J`
58
+ <button class="menu-button" @click=${this.toggle}>
59
+ ${yo(this.icon)}
60
+ </button>
61
+ `}};Jr([me({type:String})],Ft.prototype,"variableName",2);Jr([me({type:String})],Ft.prototype,"defaultValue",2);Jr([me({type:String})],Ft.prototype,"icon",2);Ft=Jr([je("toggle-css-variable-button")],Ft);var wo=Object.getOwnPropertyDescriptor,xo=(t,e,r,n)=>{for(var s=n>1?void 0:n?wo(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(s=i(s)||s);return s};let ms=class extends _e{createRenderRoot(){return this}render(){return J`
62
+ <toggle-css-variable-button
63
+ variableName="--sidebar-width"
64
+ defaultValue="1fr"
65
+ >
66
+ </toggle-css-variable-button>
67
+ <h1>Applet Inspector</h1>
68
+ <div class="center-group">
69
+ <url-input></url-input>
70
+ <settings-button></settings-button>
71
+ </div>
72
+ <toggle-css-variable-button
73
+ variableName="--history-width"
74
+ defaultValue="1.5fr"
75
+ icon='<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
76
+ <path d="M7.5 2.5V17.5M11.6667 7.5L14.1667 10L11.6667 12.5M4.16667 2.5H15.8333C16.7538 2.5 17.5 3.24619 17.5 4.16667V15.8333C17.5 16.7538 16.7538 17.5 15.8333 17.5H4.16667C3.24619 17.5 2.5 16.7538 2.5 15.8333V4.16667C2.5 3.24619 3.24619 2.5 4.16667 2.5Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
77
+ </svg>'
78
+ >
79
+ </toggle-css-variable-button>
80
+ `}};ms=xo([je("app-header")],ms);(()=>{var g,S,_,h,v,k,E,I,j,C,_n,Gs,bn,wn,Ne,ce,ge,re,ne,ie,W,Ae,V,F,Ks,Xs,Qs,ea,ta,ra,ye,X,ue,pe,Te,xe,Ee,na,sa,G;var t=class extends Error{constructor(L){super(L),this.name="AppletExecutionError"}},e=class extends Error{constructor(L){super(L),this.name="AppletConnectionError"}};function r(L){typeof this[`on${L.type}`]=="function"&&this[`on${L.type}`](L),this.dispatchEvent(L)}var n=class extends Event{constructor(L,w){super(L,{bubbles:w==null?void 0:w.bubbles,composed:w==null?void 0:w.composed,cancelable:w==null?void 0:w.cancelable}),this.data=w==null?void 0:w.data,this.actions=w==null?void 0:w.actions}};function s(L,...w){}var a={log:s},i=(Ne=class extends EventTarget{constructor(w){super();H(this,C);H(this,g);H(this,S,{});H(this,_);H(this,h);H(this,v);H(this,k);H(this,E);H(this,I);H(this,j);q(this,g,w),q(this,v,r.bind(this)),he(this,C,_n).call(this);let y=O=>{O.source===A(this,g)&&"type"in O.data&&O.data.type==="appletconnect"&&(a.log("Applet","Recieved message",O.data),he(this,C,_n).call(this),this.removeEventListener("message",y))};window.addEventListener("message",y)}async sendAction(w,y){let O={id:crypto.randomUUID(),type:"action",actionId:w,arguments:y};return new Promise((N,de)=>{A(this,E).call(this,O);let pt=setTimeout(()=>{de(new t("Applet action handler failed to complete before timeout (10000ms)"))},1e4),gr=yr=>{let It=yr.data;if(["actioncomplete","actionerror"].includes(It.type)&&"id"in It&&It.id===O.id)if(A(this,k).removeEventListener("message",gr),clearTimeout(pt),It.type==="actionerror"){let Ui=It;de(new t(Ui.message))}else N()};A(this,k).addEventListener("message",gr)})}get data(){return A(this,h)}set data(w){q(this,h,w);let y={type:"data",data:w};A(this,E).call(this,y)}get window(){return A(this,g)}get manifest(){return A(this,_)}get actions(){return A(this,S)}get width(){return A(this,I)}get height(){return A(this,j)}},g=new WeakMap,S=new WeakMap,_=new WeakMap,h=new WeakMap,v=new WeakMap,k=new WeakMap,E=new WeakMap,I=new WeakMap,j=new WeakMap,C=new WeakSet,_n=function(){A(this,k)&&A(this,k).close();let w=new MessageChannel,y={type:"appletconnect"};q(this,k,w.port1),A(this,k).onmessage=he(this,C,Gs).bind(this),A(this,g).postMessage(y,"*",[w.port2]),q(this,E,A(this,k).postMessage.bind(A(this,k)))},Gs=function(w){let y=w.data;switch(y.type){case"register":let O=y;q(this,_,O.manifest);let N=new n("connect");A(this,v).call(this,N),q(this,S,O.actions),he(this,C,wn).call(this,O.actions),q(this,h,O.data),he(this,C,bn).call(this,O.data);break;case"data":let de=y;q(this,h,de.data),he(this,C,bn).call(this,de.data);break;case"resize":let pt=y;q(this,I,pt.width),q(this,j,pt.height);let gr=new n("resize");A(this,v).call(this,gr);break;case"actions":let yr=y;q(this,S,yr.actions),he(this,C,wn).call(this,yr.actions);break}},bn=function(w){let y=new n("data",{data:w});A(this,v).call(this,y)},wn=function(w){let y=new n("actions",{actions:w});A(this,v).call(this,y)},Ne);function o(L){return Object.keys(L).length===0}var l=(ye=class extends EventTarget{constructor(w){super();H(this,F);H(this,ce,{});H(this,ge);H(this,re);H(this,ne);H(this,ie);H(this,W);H(this,Ae);H(this,V);q(this,ie,r.bind(this)),w&&q(this,ge,w);let y=N=>{if(N.source===window.parent&&N.data.type==="appletconnect"&&N.ports&&N.ports.length>0){a.log("AppletScope","Recieved message",N.data);let de=N.ports[0];q(this,W,de.postMessage.bind(de)),de.onmessage=he(this,F,Xs).bind(this),this.removeEventListener("message",y),he(this,F,Ks).call(this)}};window.addEventListener("message",y);let O={type:"appletconnect"};window.parent.postMessage(O,"*")}setActionHandler(w,y){A(this,ce)[w]=y}defineAction(w,y){let{handler:O,...N}=y;O&&(A(this,ce)[w]=O),this.actions={...this.actions,[w]:N}}set actions(w){if(!w)return;q(this,re,w);let y={type:"actions",actions:A(this,re)};A(this,W)&&A(this,W).call(this,y);let O=new n("actions",{actions:w});setTimeout(()=>A(this,ie).call(this,O),1)}get actions(){return A(this,re)}get manifest(){return A(this,ge)}get actionHandlers(){return A(this,ce)}set actionHandlers(w){q(this,ce,w)}set data(w){q(this,ne,w);let y={type:"data",data:w};A(this,W)&&A(this,W).call(this,y);let O=new n("data",{data:w});setTimeout(()=>A(this,ie).call(this,O),1)}get data(){return A(this,ne)}get width(){return A(this,Ae)}get height(){return A(this,V)}},ce=new WeakMap,ge=new WeakMap,re=new WeakMap,ne=new WeakMap,ie=new WeakMap,W=new WeakMap,Ae=new WeakMap,V=new WeakMap,F=new WeakSet,Ks=async function(){let w=this.manifest??await he(this,F,ra).call(this);q(this,ge,w||{}),q(this,re,A(this,re)||(w==null?void 0:w.actions)||{});let y={type:"register",manifest:A(this,ge),actions:A(this,re),data:A(this,ne)};A(this,W).call(this,y);let O=new n("connect");A(this,ie).call(this,O),he(this,F,ea).call(this)},Xs=function(w){let y=w.data;switch(y.type){case"data":"data"in y&&(this.data=y.data);break;case"action":"type"in y&&y.type==="action"&&"id"in y&&typeof y.id=="string"&&"actionId"in y&&typeof y.actionId=="string"&&"arguments"in y&&he(this,F,Qs).call(this,y);break}},Qs=async function(w){let{actionId:y,arguments:O,id:N}=w;if(Object.keys(A(this,ce)).includes(y))try{await A(this,ce)[y](O);let de={type:"actioncomplete",id:N};A(this,W).call(this,de)}catch(de){let pt={type:"actionerror",id:N,message:de.message};A(this,W).call(this,pt),console.error(de)}},ea=function(){new ResizeObserver(w=>{for(let y of w)he(this,F,ta).call(this,{width:y.contentRect.width,height:y.contentRect.height})}).observe(document.querySelector("html"))},ta=function({width:w,height:y}){q(this,Ae,w),q(this,V,y);let O={type:"resize",width:w,height:y};A(this,W).call(this,O)},ra=async function(){let w=document.querySelector('link[rel="manifest"]');if(!w){console.warn("No manifest link found");return}try{let y=await(await fetch(w.href)).json();for(let O in y.actions){let N=y.actions[O];N.params_schema&&!o(A(this,re).params_schema)&&(N.params_schema=void 0)}return y}catch{return}},ye),c=class{async connect(L){return new Promise((w,y)=>{let O=new i(L),N=setTimeout(()=>{y(new e("Applet failed to connect before the timeout was reached (10000ms)"))},1e4),de=()=>{w(O),O.removeEventListener("connect",de),clearTimeout(N)};O.addEventListener("connect",de)})}register(L){return new l(L)}},d=new c,p=(G=class extends HTMLElement{constructor(){super(...arguments);H(this,Ee);H(this,X);H(this,ue);H(this,pe);H(this,Te,r.bind(this));H(this,xe,document.createElement("iframe"))}connectedCallback(){q(this,X,this.attachShadow({mode:"closed"})),A(this,X).appendChild(A(this,xe));let y=document.createElement("style");y.textContent=this.styles,A(this,X).appendChild(y),this.src=this.getAttribute("src")}get contentWindow(){return A(this,xe).contentWindow}set src(y){q(this,ue,y),q(this,pe,void 0),he(this,Ee,na).call(this,y)}get src(){return A(this,ue)||""}attributeChangedCallback(y,O,N){y==="src"&&(this.src=N)}get applet(){return A(this,pe)}set data(y){if(this.applet)this.applet.data=y;else{let O=()=>{this.applet&&(this.applet.data=y),this.removeEventListener("load",O)};this.addEventListener("load",O)}}get styles(){return`
81
+ :host {
82
+ background: white;
83
+ display: flex;
84
+ flex-direction: column;
85
+ height: 350px;
86
+ }
87
+
88
+ iframe {
89
+ border: none;
90
+ height: 100%;
91
+ width: 100%;
92
+ }
93
+ `}},X=new WeakMap,ue=new WeakMap,pe=new WeakMap,Te=new WeakMap,xe=new WeakMap,Ee=new WeakSet,na=async function(y){A(this,xe).src=y;let O=A(this,xe).contentWindow;O&&(q(this,pe,await d.connect(O)),A(this,pe).ondata=N=>{A(this,Te).call(this,N)},A(this,pe).onresize=N=>{he(this,Ee,sa).call(this,{width:A(this,pe).width,height:A(this,pe).height})},A(this,pe).onactions=N=>{A(this,Te).call(this,N)},A(this,Te).call(this,new Event("load")),this.load&&typeof this.load=="function"&&this.onload(new Event("load")))},sa=function(y){this.style.height=`${y.height}px`},G.observedAttributes=["src"],G);customElements.define("applet-frame",p)})();var ko=Object.defineProperty,So=Object.getOwnPropertyDescriptor,Hr=(t,e,r,n)=>{for(var s=n>1?void 0:n?So(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(s=(n?i(e,r,s):i(s))||s);return n&&s&&ko(e,r,s),s};let Bt=class extends _e{constructor(){super(...arguments),this.renderRoot=this,this.appletUrl="",this.mode="gui",this.data={}}connectedCallback(){we.subscribe(t=>{this.appletUrl=t.appletUrl,t.applet&&(this.data=t.applet.data,t.applet.ondata=()=>this.data=t.applet.data)}),super.connectedCallback()}updated(){const t=document.querySelector("applet-frame");t&&(t.onload=()=>{we.update({applet:t.applet}),window.applet=t.applet,window.applet.ondata=e=>this.data=e.data})}render(){var e,r,n,s,a;const t=J`<div class="applet-header">
94
+ ${(r=(e=window.applet)==null?void 0:e.manifest)!=null&&r.icons?J`<img
95
+ src="${this.appletUrl}/${(s=(n=window.applet)==null?void 0:n.manifest.icons[0])==null?void 0:s.src}"
96
+ class="applet-icon"
97
+ />`:""}
98
+ <div class="applet-title">${(a=window.applet)==null?void 0:a.manifest.name}</div>
99
+ <div class="toggle">
100
+ <button
101
+ data-selected=${this.mode==="gui"}
102
+ @mousedown=${()=>this.mode="gui"}
103
+ >
104
+ GUI
105
+ </button>
106
+ <button
107
+ data-selected=${this.mode==="data"}
108
+ @mousedown=${()=>this.mode="data"}
109
+ >
110
+ Data
111
+ </button>
112
+ </div>
113
+ </div>`;return J`
114
+ <div class="container">
115
+ ${t}
116
+ <applet-frame
117
+ src=${this.appletUrl}
118
+ class=${this.mode==="gui"?"":"hidden"}
119
+ ></applet-frame>
120
+ <pre class=${this.mode==="gui"?"hidden":"data-view"}>
121
+ ${JSON.stringify(this.data,null,2)}</pre
122
+ >
123
+ </div>
124
+ `}};Hr([me()],Bt.prototype,"appletUrl",2);Hr([me()],Bt.prototype,"mode",2);Hr([me({attribute:!1})],Bt.prototype,"data",2);Bt=Hr([je("app-viewer")],Bt);function aa(t){return Object.keys(t).length===0}class Ao{constructor(){this.interactions=[],this.subscribers=new Set}addInteraction(e){this.interactions.push(e),this.notify()}getAllInteractions(){return[...this.interactions]}getRecentInteractions(e=10){return this.interactions.slice(-e)}clearHistory(){this.interactions=[],this.notify()}subscribe(e){return this.subscribers.add(e),e([...this.interactions]),()=>{this.subscribers.delete(e)}}notify(){for(const e of this.subscribers)e([...this.interactions])}}const Ar=new Ao;var To=Object.defineProperty,Eo=Object.getOwnPropertyDescriptor,ct=(t,e,r,n)=>{for(var s=n>1?void 0:n?Eo(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(s=(n?i(e,r,s):i(s))||s);return n&&s&&To(e,r,s),s};let zt=class extends _e{constructor(){super(...arguments),this.renderRoot=this,this.selected=0,this.actions={},this.schemaError=""}connectedCallback(){we.subscribe(t=>{t.applet&&(this.actions=t.applet.actions,t.applet.onactions=e=>this.actions=e.actions)}),super.connectedCallback()}handleSelect(t){const e=t.target;this.selected=e.selectedIndex}handleSchemaChange(t){const e=t.target,r=e.value.trim();if(!r){this.schemaError="",e.setCustomValidity("");return}try{const n=JSON.parse(r),s=JSON.stringify(n,null,2);e.value=s,this.schemaError="",e.setCustomValidity("")}catch(n){this.schemaError=n.message,e.setCustomValidity("Invalid JSON")}}handleSchemaFocus(t){t.target.setCustomValidity("")}async handleSubmit(t){t.preventDefault();const e=t.target,r=new FormData(e),n=r.get("action-id"),s=r.get("params");await window.applet.sendAction(n,JSON.parse(s)),Ar.addInteraction({input:{type:"action",text:n},outputs:[{type:n,...JSON.parse(s)},{type:"data",content:window.applet.data}],timestamp:Date.now()})}render(){if(!this.actions||aa(this.actions))return J`<p class="status-message">No actions available.</p>`;const t=Object.values(this.actions)[this.selected],e=JSON.stringify(t==null?void 0:t.params_schema,null,2)??"None";return J`
125
+ <form @submit=${this.handleSubmit.bind(this)}>
126
+ <fieldset class="select">
127
+ <label>Select an action</label>
128
+ <action-select
129
+ .actions=${this.actions}
130
+ name="action-id"
131
+ @change=${this.handleSelect.bind(this)}
132
+ ></action-select>
133
+ </fieldset>
134
+ <fieldset>
135
+ <label>Description</label>
136
+ <p class="description">${t==null?void 0:t.description}</p>
137
+ </fieldset>
138
+ <fieldset>
139
+ <label>Schema</label>
140
+ <pre class="schema">${e}</pre>
141
+ </fieldset>
142
+ <fieldset>
143
+ <label>Parameters</label>
144
+ <textarea
145
+ rows=${6}
146
+ name="params"
147
+ @focus=${this.handleSchemaFocus}
148
+ @change=${this.handleSchemaChange.bind(this)}
149
+ >
150
+ {}</textarea
151
+ >
152
+ ${this.schemaError?J`<div class="error-message">${this.schemaError}</div>`:""}
153
+ </fieldset>
154
+ <fieldset>
155
+ <input type="submit" value="Dispatch action" />
156
+ </fieldset>
157
+ </form>
158
+ `}};ct([me({type:Number})],zt.prototype,"selected",2);ct([me({attribute:!1})],zt.prototype,"actions",2);ct([me({type:String})],zt.prototype,"schemaError",2);zt=ct([je("app-sidebar")],zt);let Tr=class extends _e{constructor(){super(...arguments),this.renderRoot=this}render(){return J`
159
+ <select name=${this.name}>
160
+ ${Object.keys(this.actions).map(t=>J`<option id="action">${t}</option>`)}
161
+ </select>
162
+ `}};ct([me({type:String})],Tr.prototype,"name",2);ct([me({attribute:!1})],Tr.prototype,"actions",2);Tr=ct([je("action-select")],Tr);var ia="vercel.ai.error",$o=Symbol.for(ia),oa,Io=class la extends Error{constructor({name:e,message:r,cause:n}){super(r),this[oa]=!0,this.name=e,this.cause=n}static isInstance(e){return la.hasMarker(e,ia)}static hasMarker(e,r){const n=Symbol.for(r);return e!=null&&typeof e=="object"&&n in e&&typeof e[n]=="boolean"&&e[n]===!0}};oa=$o;var Z=Io,ca="AI_APICallError",ua=`vercel.ai.error.${ca}`,Co=Symbol.for(ua),da,Me=class extends Z{constructor({message:t,url:e,requestBodyValues:r,statusCode:n,responseHeaders:s,responseBody:a,cause:i,isRetryable:o=n!=null&&(n===408||n===409||n===429||n>=500),data:l}){super({name:ca,message:t,cause:i}),this[da]=!0,this.url=e,this.requestBodyValues=r,this.statusCode=n,this.responseHeaders=s,this.responseBody=a,this.isRetryable=o,this.data=l}static isInstance(t){return Z.hasMarker(t,ua)}};da=Co;var pa="AI_EmptyResponseBodyError",ha=`vercel.ai.error.${pa}`,Oo=Symbol.for(ha),fa,Ro=class extends Z{constructor({message:t="Empty response body"}={}){super({name:pa,message:t}),this[fa]=!0}static isInstance(t){return Z.hasMarker(t,ha)}};fa=Oo;function ma(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var ga="AI_InvalidArgumentError",ya=`vercel.ai.error.${ga}`,Po=Symbol.for(ya),va,jo=class extends Z{constructor({message:e,cause:r,argument:n}){super({name:ga,message:e,cause:r}),this[va]=!0,this.argument=n}static isInstance(e){return Z.hasMarker(e,ya)}};va=Po;var _a="AI_InvalidPromptError",ba=`vercel.ai.error.${_a}`,No=Symbol.for(ba),wa,Qe=class extends Z{constructor({prompt:t,message:e,cause:r}){super({name:_a,message:`Invalid prompt: ${e}`,cause:r}),this[wa]=!0,this.prompt=t}static isInstance(t){return Z.hasMarker(t,ba)}};wa=No;var xa="AI_InvalidResponseDataError",ka=`vercel.ai.error.${xa}`,Mo=Symbol.for(ka),Sa,sn=class extends Z{constructor({data:t,message:e=`Invalid response data: ${JSON.stringify(t)}.`}){super({name:xa,message:e}),this[Sa]=!0,this.data=t}static isInstance(t){return Z.hasMarker(t,ka)}};Sa=Mo;var Aa="AI_JSONParseError",Ta=`vercel.ai.error.${Aa}`,Do=Symbol.for(Ta),Ea,qt=class extends Z{constructor({text:t,cause:e}){super({name:Aa,message:`JSON parsing failed: Text: ${t}.
163
+ Error message: ${ma(e)}`,cause:e}),this[Ea]=!0,this.text=t}static isInstance(t){return Z.hasMarker(t,Ta)}};Ea=Do;var $a="AI_LoadAPIKeyError",Ia=`vercel.ai.error.${$a}`,Zo=Symbol.for(Ia),Ca,vr=class extends Z{constructor({message:t}){super({name:$a,message:t}),this[Ca]=!0}static isInstance(t){return Z.hasMarker(t,Ia)}};Ca=Zo;var Oa="AI_TooManyEmbeddingValuesForCallError",Ra=`vercel.ai.error.${Oa}`,Uo=Symbol.for(Ra),Pa,Lo=class extends Z{constructor(t){super({name:Oa,message:`Too many values for a single embedding call. The ${t.provider} model "${t.modelId}" can only embed up to ${t.maxEmbeddingsPerCall} values per call, but ${t.values.length} values were provided.`}),this[Pa]=!0,this.provider=t.provider,this.modelId=t.modelId,this.maxEmbeddingsPerCall=t.maxEmbeddingsPerCall,this.values=t.values}static isInstance(t){return Z.hasMarker(t,Ra)}};Pa=Uo;var ja="AI_TypeValidationError",Na=`vercel.ai.error.${ja}`,Vo=Symbol.for(Na),Ma,Fo=class xn extends Z{constructor({value:e,cause:r}){super({name:ja,message:`Type validation failed: Value: ${JSON.stringify(e)}.
164
+ Error message: ${ma(r)}`,cause:r}),this[Ma]=!0,this.value=e}static isInstance(e){return Z.hasMarker(e,Na)}static wrap({value:e,cause:r}){return xn.isInstance(r)&&r.value===e?r:new xn({value:e,cause:r})}};Ma=Vo;var Ve=Fo,Da="AI_UnsupportedFunctionalityError",Za=`vercel.ai.error.${Da}`,Bo=Symbol.for(Za),Ua,oe=class extends Z{constructor({functionality:t,message:e=`'${t}' functionality not supported.`}){super({name:Da,message:e}),this[Ua]=!0,this.functionality=t}static isInstance(t){return Z.hasMarker(t,Za)}};Ua=Bo;function Er(t){return t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"?!0:Array.isArray(t)?t.every(Er):typeof t=="object"?Object.entries(t).every(([e,r])=>typeof e=="string"&&Er(r)):!1}function gs(t){return Array.isArray(t)&&t.every(Er)}function kn(t){return t!=null&&typeof t=="object"&&Object.entries(t).every(([e,r])=>typeof e=="string"&&Er(r))}let zo=(t,e=21)=>(r=e)=>{let n="",s=r|0;for(;s--;)n+=t[Math.random()*t.length|0];return n};function qo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xe={exports:{}},ys;function Jo(){if(ys)return Xe.exports;ys=1;const t=typeof Buffer<"u",e=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,r=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function n(o,l,c){c==null&&l!==null&&typeof l=="object"&&(c=l,l=void 0),t&&Buffer.isBuffer(o)&&(o=o.toString()),o&&o.charCodeAt(0)===65279&&(o=o.slice(1));const d=JSON.parse(o,l);if(d===null||typeof d!="object")return d;const p=c&&c.protoAction||"error",g=c&&c.constructorAction||"error";if(p==="ignore"&&g==="ignore")return d;if(p!=="ignore"&&g!=="ignore"){if(e.test(o)===!1&&r.test(o)===!1)return d}else if(p!=="ignore"&&g==="ignore"){if(e.test(o)===!1)return d}else if(r.test(o)===!1)return d;return s(d,{protoAction:p,constructorAction:g,safe:c&&c.safe})}function s(o,{protoAction:l="error",constructorAction:c="error",safe:d}={}){let p=[o];for(;p.length;){const g=p;p=[];for(const S of g){if(l!=="ignore"&&Object.prototype.hasOwnProperty.call(S,"__proto__")){if(d===!0)return null;if(l==="error")throw new SyntaxError("Object contains forbidden prototype property");delete S.__proto__}if(c!=="ignore"&&Object.prototype.hasOwnProperty.call(S,"constructor")&&Object.prototype.hasOwnProperty.call(S.constructor,"prototype")){if(d===!0)return null;if(c==="error")throw new SyntaxError("Object contains forbidden prototype property");delete S.constructor}for(const _ in S){const h=S[_];h&&typeof h=="object"&&p.push(h)}}}return o}function a(o,l,c){const d=Error.stackTraceLimit;Error.stackTraceLimit=0;try{return n(o,l,c)}finally{Error.stackTraceLimit=d}}function i(o,l){const c=Error.stackTraceLimit;Error.stackTraceLimit=0;try{return n(o,l,{safe:!0})}catch{return null}finally{Error.stackTraceLimit=c}}return Xe.exports=a,Xe.exports.default=a,Xe.exports.parse=a,Xe.exports.safeParse=i,Xe.exports.scan=s,Xe.exports}var Ho=Jo();const Vn=qo(Ho);var Wo=Object.defineProperty,Yo=(t,e,r)=>e in t?Wo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_r=(t,e,r)=>Yo(t,typeof e!="symbol"?e+"":e,r);class vs extends Error{constructor(e,r){super(e),_r(this,"type"),_r(this,"field"),_r(this,"value"),_r(this,"line"),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}}function an(t){}function Go(t){const{onEvent:e=an,onError:r=an,onRetry:n=an,onComment:s}=t;let a="",i=!0,o,l="",c="";function d(h){const v=i?h.replace(/^\xEF\xBB\xBF/,""):h,[k,E]=Ko(`${a}${v}`);for(const I of k)p(I);a=E,i=!1}function p(h){if(h===""){S();return}if(h.startsWith(":")){s&&s(h.slice(h.startsWith(": ")?2:1));return}const v=h.indexOf(":");if(v!==-1){const k=h.slice(0,v),E=h[v+1]===" "?2:1,I=h.slice(v+E);g(k,I,h);return}g(h,"",h)}function g(h,v,k){switch(h){case"event":c=v;break;case"data":l=`${l}${v}
165
+ `;break;case"id":o=v.includes("\0")?void 0:v;break;case"retry":/^\d+$/.test(v)?n(parseInt(v,10)):r(new vs(`Invalid \`retry\` value: "${v}"`,{type:"invalid-retry",value:v,line:k}));break;default:r(new vs(`Unknown field "${h.length>20?`${h.slice(0,20)}…`:h}"`,{type:"unknown-field",field:h,value:v,line:k}));break}}function S(){l.length>0&&e({id:o,event:c||void 0,data:l.endsWith(`
166
+ `)?l.slice(0,-1):l}),o=void 0,l="",c=""}function _(h={}){a&&h.consume&&p(a),o=void 0,l="",c="",a=""}return{feed:d,reset:_}}function Ko(t){const e=[];let r="";const n=t.length;for(let s=0;s<n;s++){const a=t[s];a==="\r"&&t[s+1]===`
167
+ `?(e.push(r),r="",s++):a==="\r"||a===`
168
+ `?(e.push(r),r=""):r+=a}return[e,r]}class Xo extends TransformStream{constructor({onError:e,onRetry:r,onComment:n}={}){let s;super({start(a){s=Go({onEvent:i=>{a.enqueue(i)},onError(i){e==="terminate"?a.error(i):typeof e=="function"&&e(i)},onRetry:r,onComment:n})},transform(a){s.feed(a)}})}}var Qo={};function bt(...t){return t.reduce((e,r)=>({...e,...r??{}}),{})}function el(t){return new ReadableStream({async pull(e){try{const{value:r,done:n}=await t.next();n?e.close():e.enqueue(r)}catch(r){e.error(r)}},cancel(){}})}async function tl(t){return t==null?Promise.resolve():new Promise(e=>setTimeout(e,t))}function Wr(t){const e={};return t.headers.forEach((r,n)=>{e[n]=r}),e}var ut=({prefix:t,size:e=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:n="-"}={})=>{const s=zo(r,e);if(t==null)return s;if(r.includes(n))throw new jo({argument:"separator",message:`The separator "${n}" must not be part of the alphabet "${r}".`});return a=>`${t}${n}${s(a)}`},Ot=ut();function rl(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}function nl(t){return Object.fromEntries(Object.entries(t).filter(([e,r])=>r!=null))}function xr(t){return t instanceof Error&&(t.name==="AbortError"||t.name==="TimeoutError")}function sl({apiKey:t,environmentVariableName:e,apiKeyParameterName:r="apiKey",description:n}){if(typeof t=="string")return t;if(t!=null)throw new vr({message:`${n} API key must be a string.`});if(typeof process>"u")throw new vr({message:`${n} API key is missing. Pass it using the '${r}' parameter. Environment variables is not supported in this environment.`});if(t=Qo[e],t==null)throw new vr({message:`${n} API key is missing. Pass it using the '${r}' parameter or the ${e} environment variable.`});if(typeof t!="string")throw new vr({message:`${n} API key must be a string. The value of the ${e} environment variable is not a string.`});return t}var $r=Symbol.for("vercel.ai.validator");function al(t){return{[$r]:!0,validate:t}}function il(t){return typeof t=="object"&&t!==null&&$r in t&&t[$r]===!0&&"validate"in t}function ol(t){return il(t)?t:ll(t)}function ll(t){return al(e=>{const r=t.safeParse(e);return r.success?{success:!0,value:r.data}:{success:!1,error:r.error}})}function cl({value:t,schema:e}){const r=at({value:t,schema:e});if(!r.success)throw Ve.wrap({value:t,cause:r.error});return r.value}function at({value:t,schema:e}){const r=ol(e);try{if(r.validate==null)return{success:!0,value:t};const n=r.validate(t);return n.success?n:{success:!1,error:Ve.wrap({value:t,cause:n.error})}}catch(n){return{success:!1,error:Ve.wrap({value:t,cause:n})}}}function ul({text:t,schema:e}){try{const r=Vn.parse(t);return e==null?r:cl({value:r,schema:e})}catch(r){throw qt.isInstance(r)||Ve.isInstance(r)?r:new qt({text:t,cause:r})}}function wt({text:t,schema:e}){try{const r=Vn.parse(t);if(e==null)return{success:!0,value:r,rawValue:r};const n=at({value:r,schema:e});return n.success?{...n,rawValue:r}:n}catch(r){return{success:!1,error:qt.isInstance(r)?r:new qt({text:t,cause:r})}}}function _s(t){try{return Vn.parse(t),!0}catch{return!1}}var dl=()=>globalThis.fetch,xt=async({url:t,headers:e,body:r,failedResponseHandler:n,successfulResponseHandler:s,abortSignal:a,fetch:i})=>pl({url:t,headers:{"Content-Type":"application/json",...e},body:{content:JSON.stringify(r),values:r},failedResponseHandler:n,successfulResponseHandler:s,abortSignal:a,fetch:i}),pl=async({url:t,headers:e={},body:r,successfulResponseHandler:n,failedResponseHandler:s,abortSignal:a,fetch:i=dl()})=>{try{const o=await i(t,{method:"POST",headers:nl(e),body:r.content,signal:a}),l=Wr(o);if(!o.ok){let c;try{c=await s({response:o,url:t,requestBodyValues:r.values})}catch(d){throw xr(d)||Me.isInstance(d)?d:new Me({message:"Failed to process error response",cause:d,statusCode:o.status,url:t,responseHeaders:l,requestBodyValues:r.values})}throw c.value}try{return await n({response:o,url:t,requestBodyValues:r.values})}catch(c){throw c instanceof Error&&(xr(c)||Me.isInstance(c))?c:new Me({message:"Failed to process successful response",cause:c,statusCode:o.status,url:t,responseHeaders:l,requestBodyValues:r.values})}}catch(o){if(xr(o))throw o;if(o instanceof TypeError&&o.message==="fetch failed"){const l=o.cause;if(l!=null)throw new Me({message:`Cannot connect to API: ${l.message}`,cause:l,url:t,requestBodyValues:r.values,isRetryable:!0})}throw o}},hl=({errorSchema:t,errorToMessage:e,isRetryable:r})=>async({response:n,url:s,requestBodyValues:a})=>{const i=await n.text(),o=Wr(n);if(i.trim()==="")return{responseHeaders:o,value:new Me({message:n.statusText,url:s,requestBodyValues:a,statusCode:n.status,responseHeaders:o,responseBody:i,isRetryable:r==null?void 0:r(n)})};try{const l=ul({text:i,schema:t});return{responseHeaders:o,value:new Me({message:e(l),url:s,requestBodyValues:a,statusCode:n.status,responseHeaders:o,responseBody:i,data:l,isRetryable:r==null?void 0:r(n,l)})}}catch{return{responseHeaders:o,value:new Me({message:n.statusText,url:s,requestBodyValues:a,statusCode:n.status,responseHeaders:o,responseBody:i,isRetryable:r==null?void 0:r(n)})}}},La=t=>async({response:e})=>{const r=Wr(e);if(e.body==null)throw new Ro({});return{responseHeaders:r,value:e.body.pipeThrough(new TextDecoderStream).pipeThrough(new Xo).pipeThrough(new TransformStream({transform({data:n},s){n!=="[DONE]"&&s.enqueue(wt({text:n,schema:t}))}}))}},Yr=t=>async({response:e,url:r,requestBodyValues:n})=>{const s=await e.text(),a=wt({text:s,schema:t}),i=Wr(e);if(!a.success)throw new Me({message:"Invalid JSON response",cause:a.error,statusCode:e.status,responseHeaders:i,responseBody:s,url:r,requestBodyValues:n});return{responseHeaders:i,value:a.value,rawValue:a.rawValue}},{btoa:fl,atob:ml}=globalThis;function gl(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),r=ml(e);return Uint8Array.from(r,n=>n.codePointAt(0))}function Sn(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCodePoint(t[r]);return fl(e)}function yl(t){return t==null?void 0:t.replace(/\/$/,"")}var D;(function(t){t.assertEqual=s=>s;function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},t.getValidEnumValues=s=>{const a=t.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(a){return s[a]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},t.find=(s,a)=>{for(const i of s)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(D||(D={}));var An;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(An||(An={}));const x=D.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Le=t=>{switch(typeof t){case"undefined":return x.undefined;case"string":return x.string;case"number":return isNaN(t)?x.nan:x.number;case"boolean":return x.boolean;case"function":return x.function;case"bigint":return x.bigint;case"symbol":return x.symbol;case"object":return Array.isArray(t)?x.array:t===null?x.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?x.promise:typeof Map<"u"&&t instanceof Map?x.map:typeof Set<"u"&&t instanceof Set?x.set:typeof Date<"u"&&t instanceof Date?x.date:x.object;default:return x.unknown}},f=D.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),vl=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Se extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let o=n,l=0;for(;l<i.path.length;){const c=i.path[l];l===i.path.length-1?(o[c]=o[c]||{_errors:[]},o[c]._errors.push(r(i))):o[c]=o[c]||{_errors:[]},o=o[c],l++}}};return s(this),n}static assert(e){if(!(e instanceof Se))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,D.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}Se.create=t=>new Se(t);const kt=(t,e)=>{let r;switch(t.code){case f.invalid_type:t.received===x.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,D.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${D.joinValues(t.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${D.joinValues(t.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${D.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:D.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case f.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case f.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=e.defaultError,D.assertNever(t)}return{message:r}};let Va=kt;function _l(t){Va=t}function Ir(){return Va}const Cr=t=>{const{data:e,path:r,errorMaps:n,issueData:s}=t,a=[...r,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const l=n.filter(c=>!!c).slice().reverse();for(const c of l)o=c(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},bl=[];function b(t,e){const r=Ir(),n=Cr({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===kt?void 0:kt].filter(s=>!!s)});t.common.issues.push(n)}class fe{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const s of r){if(s.status==="aborted")return $;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const s of r){const a=await s.key,i=await s.value;n.push({key:a,value:i})}return fe.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const s of r){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return $;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const $=Object.freeze({status:"aborted"}),yt=t=>({status:"dirty",value:t}),be=t=>({status:"valid",value:t}),Tn=t=>t.status==="aborted",En=t=>t.status==="dirty",it=t=>t.status==="valid",Jt=t=>typeof Promise<"u"&&t instanceof Promise;function Or(t,e,r,n){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function Fa(t,e,r,n,s){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,r),r}var T;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(T||(T={}));var Pt,jt;class De{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const bs=(t,e)=>{if(it(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new Se(t.common.issues);return this._error=r,this._error}}};function R(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{var l,c;const{message:d}=t;return i.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:(l=d??n)!==null&&l!==void 0?l:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(c=d??r)!==null&&c!==void 0?c:o.defaultError}},description:s}}class P{get description(){return this._def.description}_getType(e){return Le(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Le(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new fe,ctx:{common:e.parent.common,data:e.data,parsedType:Le(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Jt(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;const s={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Le(e)},a=this._parseSync({data:e,path:s.path,parent:s});return bs(s,a)}"~validate"(e){var r,n;const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Le(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:s});return it(a)?{value:a.value}:{issues:s.common.issues}}catch(a){!((n=(r=a==null?void 0:a.message)===null||r===void 0?void 0:r.toLowerCase())===null||n===void 0)&&n.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(a=>it(a)?{value:a.value}:{issues:s.common.issues})}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Le(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Jt(s)?s:Promise.resolve(s));return bs(n,a)}refine(e,r){const n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:f.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(l=>l?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new Pe({schema:this,typeName:m.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Re.create(this,this._def)}nullable(){return Ge.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Oe.create(this)}promise(){return At.create(this,this._def)}or(e){return Gt.create([this,e],this._def)}and(e){return Kt.create(this,e,this._def)}transform(e){return new Pe({...R(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new rr({...R(this._def),innerType:this,defaultValue:r,typeName:m.ZodDefault})}brand(){return new Fn({typeName:m.ZodBranded,type:this,...R(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new nr({...R(this._def),innerType:this,catchValue:r,typeName:m.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return fr.create(this,e)}readonly(){return sr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const wl=/^c[^\s-]{8,}$/i,xl=/^[0-9a-z]+$/,kl=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Sl=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Al=/^[a-z0-9_-]{21}$/i,Tl=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,El=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,$l=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Il="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let on;const Cl=/^(?:(?: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])$/,Ol=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Rl=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Pl=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,jl=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Nl=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ba="((\\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])))",Ml=new RegExp(`^${Ba}$`);function za(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Dl(t){return new RegExp(`^${za(t)}$`)}function qa(t){let e=`${Ba}T${za(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Zl(t,e){return!!((e==="v4"||!e)&&Cl.test(t)||(e==="v6"||!e)&&Rl.test(t))}function Ul(t,e){if(!Tl.test(t))return!1;try{const[r]=t.split("."),n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||!s.typ||!s.alg||e&&s.alg!==e)}catch{return!1}}function Ll(t,e){return!!((e==="v4"||!e)&&Ol.test(t)||(e==="v6"||!e)&&Pl.test(t))}class Ce extends P{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==x.string){const a=this._getOrReturnCtx(e);return b(a,{code:f.invalid_type,expected:x.string,received:a.parsedType}),$}const n=new fe;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),b(s,{code:f.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),b(s,{code:f.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?b(s,{code:f.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&b(s,{code:f.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")$l.test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"email",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")on||(on=new RegExp(Il,"u")),on.test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"emoji",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Sl.test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"uuid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")Al.test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"nanoid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")wl.test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"cuid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")xl.test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"cuid2",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")kl.test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"ulid",code:f.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),b(s,{validation:"url",code:f.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"regex",code:f.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),b(s,{code:f.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),b(s,{code:f.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),b(s,{code:f.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?qa(a).test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{code:f.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Ml.test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{code:f.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Dl(a).test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{code:f.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?El.test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"duration",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Zl(e.data,a.version)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"ip",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Ul(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"jwt",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Ll(e.data,a.version)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"cidr",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?jl.test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"base64",code:f.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Nl.test(e.data)||(s=this._getOrReturnCtx(e,s),b(s,{validation:"base64url",code:f.invalid_string,message:a.message}),n.dirty()):D.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:f.invalid_string,...T.errToObj(n)})}_addCheck(e){return new Ce({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...T.errToObj(e)})}url(e){return this._addCheck({kind:"url",...T.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...T.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...T.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...T.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...T.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...T.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...T.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...T.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...T.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...T.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...T.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...T.errToObj(e)})}datetime(e){var r,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(r=e==null?void 0:e.offset)!==null&&r!==void 0?r:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...T.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...T.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...T.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...T.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...T.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...T.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...T.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...T.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...T.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...T.errToObj(r)})}nonempty(e){return this.min(1,T.errToObj(e))}trim(){return new Ce({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ce({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ce({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Ce.create=t=>{var e;return new Ce({checks:[],typeName:m.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...R(t)})};function Vl(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,a=parseInt(t.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class He extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==x.number){const a=this._getOrReturnCtx(e);return b(a,{code:f.invalid_type,expected:x.number,received:a.parsedType}),$}let n;const s=new fe;for(const a of this._def.checks)a.kind==="int"?D.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{code:f.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),b(n,{code:f.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),b(n,{code:f.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Vl(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),b(n,{code:f.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{code:f.not_finite,message:a.message}),s.dirty()):D.assertNever(a);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,T.toString(r))}gt(e,r){return this.setLimit("min",e,!1,T.toString(r))}lte(e,r){return this.setLimit("max",e,!0,T.toString(r))}lt(e,r){return this.setLimit("max",e,!1,T.toString(r))}setLimit(e,r,n,s){return new He({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:T.toString(s)}]})}_addCheck(e){return new He({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:T.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:T.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:T.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:T.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:T.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:T.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:T.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:T.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:T.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&D.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}He.create=t=>new He({checks:[],typeName:m.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...R(t)});class We extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==x.bigint)return this._getInvalidInput(e);let n;const s=new fe;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),b(n,{code:f.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),b(n,{code:f.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),b(n,{code:f.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):D.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return b(r,{code:f.invalid_type,expected:x.bigint,received:r.parsedType}),$}gte(e,r){return this.setLimit("min",e,!0,T.toString(r))}gt(e,r){return this.setLimit("min",e,!1,T.toString(r))}lte(e,r){return this.setLimit("max",e,!0,T.toString(r))}lt(e,r){return this.setLimit("max",e,!1,T.toString(r))}setLimit(e,r,n,s){return new We({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:T.toString(s)}]})}_addCheck(e){return new We({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:T.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:T.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:T.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:T.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:T.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}We.create=t=>{var e;return new We({checks:[],typeName:m.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...R(t)})};class Ht extends P{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==x.boolean){const n=this._getOrReturnCtx(e);return b(n,{code:f.invalid_type,expected:x.boolean,received:n.parsedType}),$}return be(e.data)}}Ht.create=t=>new Ht({typeName:m.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...R(t)});class ot extends P{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==x.date){const a=this._getOrReturnCtx(e);return b(a,{code:f.invalid_type,expected:x.date,received:a.parsedType}),$}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return b(a,{code:f.invalid_date}),$}const n=new fe;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),b(s,{code:f.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),b(s,{code:f.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):D.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ot({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:T.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:T.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}ot.create=t=>new ot({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:m.ZodDate,...R(t)});class Rr extends P{_parse(e){if(this._getType(e)!==x.symbol){const n=this._getOrReturnCtx(e);return b(n,{code:f.invalid_type,expected:x.symbol,received:n.parsedType}),$}return be(e.data)}}Rr.create=t=>new Rr({typeName:m.ZodSymbol,...R(t)});class Wt extends P{_parse(e){if(this._getType(e)!==x.undefined){const n=this._getOrReturnCtx(e);return b(n,{code:f.invalid_type,expected:x.undefined,received:n.parsedType}),$}return be(e.data)}}Wt.create=t=>new Wt({typeName:m.ZodUndefined,...R(t)});class Yt extends P{_parse(e){if(this._getType(e)!==x.null){const n=this._getOrReturnCtx(e);return b(n,{code:f.invalid_type,expected:x.null,received:n.parsedType}),$}return be(e.data)}}Yt.create=t=>new Yt({typeName:m.ZodNull,...R(t)});class St extends P{constructor(){super(...arguments),this._any=!0}_parse(e){return be(e.data)}}St.create=t=>new St({typeName:m.ZodAny,...R(t)});class rt extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return be(e.data)}}rt.create=t=>new rt({typeName:m.ZodUnknown,...R(t)});class Fe extends P{_parse(e){const r=this._getOrReturnCtx(e);return b(r,{code:f.invalid_type,expected:x.never,received:r.parsedType}),$}}Fe.create=t=>new Fe({typeName:m.ZodNever,...R(t)});class Pr extends P{_parse(e){if(this._getType(e)!==x.undefined){const n=this._getOrReturnCtx(e);return b(n,{code:f.invalid_type,expected:x.void,received:n.parsedType}),$}return be(e.data)}}Pr.create=t=>new Pr({typeName:m.ZodVoid,...R(t)});class Oe extends P{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==x.array)return b(r,{code:f.invalid_type,expected:x.array,received:r.parsedType}),$;if(s.exactLength!==null){const i=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(i||o)&&(b(r,{code:i?f.too_big:f.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(b(r,{code:f.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(b(r,{code:f.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,o)=>s.type._parseAsync(new De(r,i,r.path,o)))).then(i=>fe.mergeArray(n,i));const a=[...r.data].map((i,o)=>s.type._parseSync(new De(r,i,r.path,o)));return fe.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new Oe({...this._def,minLength:{value:e,message:T.toString(r)}})}max(e,r){return new Oe({...this._def,maxLength:{value:e,message:T.toString(r)}})}length(e,r){return new Oe({...this._def,exactLength:{value:e,message:T.toString(r)}})}nonempty(e){return this.min(1,e)}}Oe.create=(t,e)=>new Oe({type:t,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,...R(e)});function gt(t){if(t instanceof Q){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=Re.create(gt(n))}return new Q({...t._def,shape:()=>e})}else return t instanceof Oe?new Oe({...t._def,type:gt(t.element)}):t instanceof Re?Re.create(gt(t.unwrap())):t instanceof Ge?Ge.create(gt(t.unwrap())):t instanceof Ze?Ze.create(t.items.map(e=>gt(e))):t}class Q extends P{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=D.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==x.object){const c=this._getOrReturnCtx(e);return b(c,{code:f.invalid_type,expected:x.object,received:c.parsedType}),$}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Fe&&this._def.unknownKeys==="strip"))for(const c in s.data)i.includes(c)||o.push(c);const l=[];for(const c of i){const d=a[c],p=s.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new De(s,p,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof Fe){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of o)l.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(c==="strict")o.length>0&&(b(s,{code:f.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of o){const p=s.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new De(s,p,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const p=await d.key,g=await d.value;c.push({key:p,value:g,alwaysSet:d.alwaysSet})}return c}).then(c=>fe.mergeObjectSync(n,c)):fe.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return T.errToObj,new Q({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var s,a,i,o;const l=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,r,n).message)!==null&&i!==void 0?i:n.defaultError;return r.code==="unrecognized_keys"?{message:(o=T.errToObj(e).message)!==null&&o!==void 0?o:l}:{message:l}}}:{}})}strip(){return new Q({...this._def,unknownKeys:"strip"})}passthrough(){return new Q({...this._def,unknownKeys:"passthrough"})}extend(e){return new Q({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Q({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:m.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Q({...this._def,catchall:e})}pick(e){const r={};return D.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new Q({...this._def,shape:()=>r})}omit(e){const r={};return D.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new Q({...this._def,shape:()=>r})}deepPartial(){return gt(this)}partial(e){const r={};return D.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}),new Q({...this._def,shape:()=>r})}required(e){const r={};return D.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Re;)a=a._def.innerType;r[n]=a}}),new Q({...this._def,shape:()=>r})}keyof(){return Ja(D.objectKeys(this.shape))}}Q.create=(t,e)=>new Q({shape:()=>t,unknownKeys:"strip",catchall:Fe.create(),typeName:m.ZodObject,...R(e)});Q.strictCreate=(t,e)=>new Q({shape:()=>t,unknownKeys:"strict",catchall:Fe.create(),typeName:m.ZodObject,...R(e)});Q.lazycreate=(t,e)=>new Q({shape:t,unknownKeys:"strip",catchall:Fe.create(),typeName:m.ZodObject,...R(e)});class Gt extends P{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Se(o.ctx.common.issues));return b(r,{code:f.invalid_union,unionErrors:i}),$}if(r.common.async)return Promise.all(n.map(async a=>{const i={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const l of n){const c={...r,common:{...r.common,issues:[]},parent:null},d=l._parseSync({data:r.data,path:r.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!a&&(a={result:d,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(l=>new Se(l));return b(r,{code:f.invalid_union,unionErrors:o}),$}}get options(){return this._def.options}}Gt.create=(t,e)=>new Gt({options:t,typeName:m.ZodUnion,...R(e)});const Ue=t=>t instanceof Qt?Ue(t.schema):t instanceof Pe?Ue(t.innerType()):t instanceof er?[t.value]:t instanceof Ye?t.options:t instanceof tr?D.objectValues(t.enum):t instanceof rr?Ue(t._def.innerType):t instanceof Wt?[void 0]:t instanceof Yt?[null]:t instanceof Re?[void 0,...Ue(t.unwrap())]:t instanceof Ge?[null,...Ue(t.unwrap())]:t instanceof Fn||t instanceof sr?Ue(t.unwrap()):t instanceof nr?Ue(t._def.innerType):[];class Gr extends P{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==x.object)return b(r,{code:f.invalid_type,expected:x.object,received:r.parsedType}),$;const n=this.discriminator,s=r.data[n],a=this.optionsMap.get(s);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(b(r,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),$)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const s=new Map;for(const a of r){const i=Ue(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Gr({typeName:m.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...R(n)})}}function $n(t,e){const r=Le(t),n=Le(e);if(t===e)return{valid:!0,data:t};if(r===x.object&&n===x.object){const s=D.objectKeys(e),a=D.objectKeys(t).filter(o=>s.indexOf(o)!==-1),i={...t,...e};for(const o of a){const l=$n(t[o],e[o]);if(!l.valid)return{valid:!1};i[o]=l.data}return{valid:!0,data:i}}else if(r===x.array&&n===x.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<t.length;a++){const i=t[a],o=e[a],l=$n(i,o);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return r===x.date&&n===x.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Kt extends P{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Tn(a)||Tn(i))return $;const o=$n(a.value,i.value);return o.valid?((En(a)||En(i))&&r.dirty(),{status:r.value,value:o.data}):(b(n,{code:f.invalid_intersection_types}),$)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Kt.create=(t,e,r)=>new Kt({left:t,right:e,typeName:m.ZodIntersection,...R(r)});class Ze extends P{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.array)return b(n,{code:f.invalid_type,expected:x.array,received:n.parsedType}),$;if(n.data.length<this._def.items.length)return b(n,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),$;!this._def.rest&&n.data.length>this._def.items.length&&(b(n,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...n.data].map((i,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new De(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>fe.mergeArray(r,i)):fe.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Ze({...this._def,rest:e})}}Ze.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ze({items:t,typeName:m.ZodTuple,rest:null,...R(e)})};class Xt extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.object)return b(n,{code:f.invalid_type,expected:x.object,received:n.parsedType}),$;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new De(n,o,n.path,o)),value:i._parse(new De(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?fe.mergeObjectAsync(r,s):fe.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof P?new Xt({keyType:e,valueType:r,typeName:m.ZodRecord,...R(n)}):new Xt({keyType:Ce.create(),valueType:e,typeName:m.ZodRecord,...R(r)})}}class jr extends P{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.map)return b(n,{code:f.invalid_type,expected:x.map,received:n.parsedType}),$;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,l],c)=>({key:s._parse(new De(n,o,n.path,[c,"key"])),value:a._parse(new De(n,l,n.path,[c,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of i){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return $;(c.status==="dirty"||d.status==="dirty")&&r.dirty(),o.set(c.value,d.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const l of i){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return $;(c.status==="dirty"||d.status==="dirty")&&r.dirty(),o.set(c.value,d.value)}return{status:r.value,value:o}}}}jr.create=(t,e,r)=>new jr({valueType:e,keyType:t,typeName:m.ZodMap,...R(r)});class lt extends P{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.set)return b(n,{code:f.invalid_type,expected:x.set,received:n.parsedType}),$;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(b(n,{code:f.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(b(n,{code:f.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());const a=this._def.valueType;function i(l){const c=new Set;for(const d of l){if(d.status==="aborted")return $;d.status==="dirty"&&r.dirty(),c.add(d.value)}return{status:r.value,value:c}}const o=[...n.data.values()].map((l,c)=>a._parse(new De(n,l,n.path,c)));return n.common.async?Promise.all(o).then(l=>i(l)):i(o)}min(e,r){return new lt({...this._def,minSize:{value:e,message:T.toString(r)}})}max(e,r){return new lt({...this._def,maxSize:{value:e,message:T.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}lt.create=(t,e)=>new lt({valueType:t,minSize:null,maxSize:null,typeName:m.ZodSet,...R(e)});class vt extends P{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==x.function)return b(r,{code:f.invalid_type,expected:x.function,received:r.parsedType}),$;function n(o,l){return Cr({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ir(),kt].filter(c=>!!c),issueData:{code:f.invalid_arguments,argumentsError:l}})}function s(o,l){return Cr({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ir(),kt].filter(c=>!!c),issueData:{code:f.invalid_return_type,returnTypeError:l}})}const a={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof At){const o=this;return be(async function(...l){const c=new Se([]),d=await o._def.args.parseAsync(l,a).catch(S=>{throw c.addIssue(n(l,S)),c}),p=await Reflect.apply(i,this,d);return await o._def.returns._def.type.parseAsync(p,a).catch(S=>{throw c.addIssue(s(p,S)),c})})}else{const o=this;return be(function(...l){const c=o._def.args.safeParse(l,a);if(!c.success)throw new Se([n(l,c.error)]);const d=Reflect.apply(i,this,c.data),p=o._def.returns.safeParse(d,a);if(!p.success)throw new Se([s(d,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new vt({...this._def,args:Ze.create(e).rest(rt.create())})}returns(e){return new vt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new vt({args:e||Ze.create([]).rest(rt.create()),returns:r||rt.create(),typeName:m.ZodFunction,...R(n)})}}class Qt extends P{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Qt.create=(t,e)=>new Qt({getter:t,typeName:m.ZodLazy,...R(e)});class er extends P{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return b(r,{received:r.data,code:f.invalid_literal,expected:this._def.value}),$}return{status:"valid",value:e.data}}get value(){return this._def.value}}er.create=(t,e)=>new er({value:t,typeName:m.ZodLiteral,...R(e)});function Ja(t,e){return new Ye({values:t,typeName:m.ZodEnum,...R(e)})}class Ye extends P{constructor(){super(...arguments),Pt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return b(r,{expected:D.joinValues(n),received:r.parsedType,code:f.invalid_type}),$}if(Or(this,Pt)||Fa(this,Pt,new Set(this._def.values)),!Or(this,Pt).has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return b(r,{received:r.data,code:f.invalid_enum_value,options:n}),$}return be(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return Ye.create(e,{...this._def,...r})}exclude(e,r=this._def){return Ye.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}Pt=new WeakMap;Ye.create=Ja;class tr extends P{constructor(){super(...arguments),jt.set(this,void 0)}_parse(e){const r=D.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==x.string&&n.parsedType!==x.number){const s=D.objectValues(r);return b(n,{expected:D.joinValues(s),received:n.parsedType,code:f.invalid_type}),$}if(Or(this,jt)||Fa(this,jt,new Set(D.getValidEnumValues(this._def.values))),!Or(this,jt).has(e.data)){const s=D.objectValues(r);return b(n,{received:n.data,code:f.invalid_enum_value,options:s}),$}return be(e.data)}get enum(){return this._def.values}}jt=new WeakMap;tr.create=(t,e)=>new tr({values:t,typeName:m.ZodNativeEnum,...R(e)});class At extends P{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==x.promise&&r.common.async===!1)return b(r,{code:f.invalid_type,expected:x.promise,received:r.parsedType}),$;const n=r.parsedType===x.promise?r.data:Promise.resolve(r.data);return be(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}At.create=(t,e)=>new At({type:t,typeName:m.ZodPromise,...R(e)});class Pe extends P{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{b(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(r.value==="aborted")return $;const l=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return l.status==="aborted"?$:l.status==="dirty"||r.value==="dirty"?yt(l.value):l});{if(r.value==="aborted")return $;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?$:o.status==="dirty"||r.value==="dirty"?yt(o.value):o}}if(s.type==="refinement"){const i=o=>{const l=s.refinement(o,a);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?$:(o.status==="dirty"&&r.dirty(),i(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?$:(o.status==="dirty"&&r.dirty(),i(o.value).then(()=>({status:r.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!it(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>it(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:r.value,value:o})):i);D.assertNever(s)}}Pe.create=(t,e,r)=>new Pe({schema:t,typeName:m.ZodEffects,effect:e,...R(r)});Pe.createWithPreprocess=(t,e,r)=>new Pe({schema:e,effect:{type:"preprocess",transform:t},typeName:m.ZodEffects,...R(r)});class Re extends P{_parse(e){return this._getType(e)===x.undefined?be(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Re.create=(t,e)=>new Re({innerType:t,typeName:m.ZodOptional,...R(e)});class Ge extends P{_parse(e){return this._getType(e)===x.null?be(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ge.create=(t,e)=>new Ge({innerType:t,typeName:m.ZodNullable,...R(e)});class rr extends P{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===x.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}rr.create=(t,e)=>new rr({innerType:t,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...R(e)});class nr extends P{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Jt(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Se(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Se(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}nr.create=(t,e)=>new nr({innerType:t,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...R(e)});class Nr extends P{_parse(e){if(this._getType(e)!==x.nan){const n=this._getOrReturnCtx(e);return b(n,{code:f.invalid_type,expected:x.nan,received:n.parsedType}),$}return{status:"valid",value:e.data}}}Nr.create=t=>new Nr({typeName:m.ZodNaN,...R(t)});const Fl=Symbol("zod_brand");class Fn extends P{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class fr extends P{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?$:a.status==="dirty"?(r.dirty(),yt(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?$:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new fr({in:e,out:r,typeName:m.ZodPipeline})}}class sr extends P{_parse(e){const r=this._def.innerType._parse(e),n=s=>(it(s)&&(s.value=Object.freeze(s.value)),s);return Jt(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}}sr.create=(t,e)=>new sr({innerType:t,typeName:m.ZodReadonly,...R(e)});function ws(t,e){const r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Ha(t,e={},r){return t?St.create().superRefine((n,s)=>{var a,i;const o=t(n);if(o instanceof Promise)return o.then(l=>{var c,d;if(!l){const p=ws(e,n),g=(d=(c=p.fatal)!==null&&c!==void 0?c:r)!==null&&d!==void 0?d:!0;s.addIssue({code:"custom",...p,fatal:g})}});if(!o){const l=ws(e,n),c=(i=(a=l.fatal)!==null&&a!==void 0?a:r)!==null&&i!==void 0?i:!0;s.addIssue({code:"custom",...l,fatal:c})}}):St.create()}const Bl={object:Q.lazycreate};var m;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(m||(m={}));const zl=(t,e={message:`Input not instance of ${t.name}`})=>Ha(r=>r instanceof t,e),Wa=Ce.create,Ya=He.create,ql=Nr.create,Jl=We.create,Ga=Ht.create,Hl=ot.create,Wl=Rr.create,Yl=Wt.create,Gl=Yt.create,Kl=St.create,Xl=rt.create,Ql=Fe.create,ec=Pr.create,tc=Oe.create,rc=Q.create,nc=Q.strictCreate,sc=Gt.create,ac=Gr.create,ic=Kt.create,oc=Ze.create,lc=Xt.create,cc=jr.create,uc=lt.create,dc=vt.create,pc=Qt.create,hc=er.create,fc=Ye.create,mc=tr.create,gc=At.create,xs=Pe.create,yc=Re.create,vc=Ge.create,_c=Pe.createWithPreprocess,bc=fr.create,wc=()=>Wa().optional(),xc=()=>Ya().optional(),kc=()=>Ga().optional(),Sc={string:t=>Ce.create({...t,coerce:!0}),number:t=>He.create({...t,coerce:!0}),boolean:t=>Ht.create({...t,coerce:!0}),bigint:t=>We.create({...t,coerce:!0}),date:t=>ot.create({...t,coerce:!0})},Ac=$;var u=Object.freeze({__proto__:null,defaultErrorMap:kt,setErrorMap:_l,getErrorMap:Ir,makeIssue:Cr,EMPTY_PATH:bl,addIssueToContext:b,ParseStatus:fe,INVALID:$,DIRTY:yt,OK:be,isAborted:Tn,isDirty:En,isValid:it,isAsync:Jt,get util(){return D},get objectUtil(){return An},ZodParsedType:x,getParsedType:Le,ZodType:P,datetimeRegex:qa,ZodString:Ce,ZodNumber:He,ZodBigInt:We,ZodBoolean:Ht,ZodDate:ot,ZodSymbol:Rr,ZodUndefined:Wt,ZodNull:Yt,ZodAny:St,ZodUnknown:rt,ZodNever:Fe,ZodVoid:Pr,ZodArray:Oe,ZodObject:Q,ZodUnion:Gt,ZodDiscriminatedUnion:Gr,ZodIntersection:Kt,ZodTuple:Ze,ZodRecord:Xt,ZodMap:jr,ZodSet:lt,ZodFunction:vt,ZodLazy:Qt,ZodLiteral:er,ZodEnum:Ye,ZodNativeEnum:tr,ZodPromise:At,ZodEffects:Pe,ZodTransformer:Pe,ZodOptional:Re,ZodNullable:Ge,ZodDefault:rr,ZodCatch:nr,ZodNaN:Nr,BRAND:Fl,ZodBranded:Fn,ZodPipeline:fr,ZodReadonly:sr,custom:Ha,Schema:P,ZodSchema:P,late:Bl,get ZodFirstPartyTypeKind(){return m},coerce:Sc,any:Kl,array:tc,bigint:Jl,boolean:Ga,date:Hl,discriminatedUnion:ac,effect:xs,enum:fc,function:dc,instanceof:zl,intersection:ic,lazy:pc,literal:hc,map:cc,nan:ql,nativeEnum:mc,never:Ql,null:Gl,nullable:vc,number:Ya,object:rc,oboolean:kc,onumber:xc,optional:yc,ostring:wc,pipeline:bc,preprocess:_c,promise:gc,record:lc,set:uc,strictObject:nc,string:Wa,symbol:Wl,transformer:xs,tuple:oc,undefined:Yl,union:sc,unknown:Xl,void:ec,NEVER:Ac,ZodIssueCode:f,quotelessJson:vl,ZodError:Se});function Tc({prompt:t,useLegacyFunctionCalling:e=!1,systemMessageMode:r="system"}){const n=[];for(const{role:s,content:a}of t)switch(s){case"system":{switch(r){case"system":{n.push({role:"system",content:a});break}case"developer":{n.push({role:"developer",content:a});break}case"remove":break;default:{const i=r;throw new Error(`Unsupported system message mode: ${i}`)}}break}case"user":{if(a.length===1&&a[0].type==="text"){n.push({role:"user",content:a[0].text});break}n.push({role:"user",content:a.map(i=>{var o,l,c;switch(i.type){case"text":return{type:"text",text:i.text};case"image":return{type:"image_url",image_url:{url:i.image instanceof URL?i.image.toString():`data:${(o=i.mimeType)!=null?o:"image/jpeg"};base64,${Sn(i.image)}`,detail:(c=(l=i.providerMetadata)==null?void 0:l.openai)==null?void 0:c.imageDetail}};case"file":{if(i.data instanceof URL)throw new oe({functionality:"'File content parts with URL data' functionality not supported."});switch(i.mimeType){case"audio/wav":return{type:"input_audio",input_audio:{data:i.data,format:"wav"}};case"audio/mp3":case"audio/mpeg":return{type:"input_audio",input_audio:{data:i.data,format:"mp3"}};default:throw new oe({functionality:`File content part type ${i.mimeType} in user messages`})}}}})});break}case"assistant":{let i="";const o=[];for(const l of a)switch(l.type){case"text":{i+=l.text;break}case"redacted-reasoning":case"reasoning":break;case"tool-call":{o.push({id:l.toolCallId,type:"function",function:{name:l.toolName,arguments:JSON.stringify(l.args)}});break}default:{const c=l;throw new Error(`Unsupported part: ${c}`)}}if(e){if(o.length>1)throw new oe({functionality:"useLegacyFunctionCalling with multiple tool calls in one message"});n.push({role:"assistant",content:i,function_call:o.length>0?o[0].function:void 0})}else n.push({role:"assistant",content:i,tool_calls:o.length>0?o:void 0});break}case"tool":{for(const i of a)e?n.push({role:"function",name:i.toolName,content:JSON.stringify(i.result)}):n.push({role:"tool",tool_call_id:i.toolCallId,content:JSON.stringify(i.result)});break}default:{const i=s;throw new Error(`Unsupported role: ${i}`)}}return n}function ks(t){var e,r;return(r=(e=t==null?void 0:t.content)==null?void 0:e.map(({token:n,logprob:s,top_logprobs:a})=>({token:n,logprob:s,topLogprobs:a?a.map(({token:i,logprob:o})=>({token:i,logprob:o})):[]})))!=null?r:void 0}function Mr(t){switch(t){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}var Bn=u.object({error:u.object({message:u.string(),type:u.string().nullish(),param:u.any().nullish(),code:u.union([u.string(),u.number()]).nullish()})}),Tt=hl({errorSchema:Bn,errorToMessage:t=>t.error.message});function Dr({id:t,model:e,created:r}){return{id:t??void 0,modelId:e??void 0,timestamp:r!=null?new Date(r*1e3):void 0}}function Ec({mode:t,useLegacyFunctionCalling:e=!1,structuredOutputs:r}){var n;const s=(n=t.tools)!=null&&n.length?t.tools:void 0,a=[];if(s==null)return{tools:void 0,tool_choice:void 0,toolWarnings:a};const i=t.toolChoice;if(e){const c=[];for(const p of s)p.type==="provider-defined"?a.push({type:"unsupported-tool",tool:p}):c.push({name:p.name,description:p.description,parameters:p.parameters});if(i==null)return{functions:c,function_call:void 0,toolWarnings:a};switch(i.type){case"auto":case"none":case void 0:return{functions:c,function_call:void 0,toolWarnings:a};case"required":throw new oe({functionality:"useLegacyFunctionCalling and toolChoice: required"});default:return{functions:c,function_call:{name:i.toolName},toolWarnings:a}}}const o=[];for(const c of s)c.type==="provider-defined"?a.push({type:"unsupported-tool",tool:c}):o.push({type:"function",function:{name:c.name,description:c.description,parameters:c.parameters,strict:r?!0:void 0}});if(i==null)return{tools:o,tool_choice:void 0,toolWarnings:a};const l=i.type;switch(l){case"auto":case"none":case"required":return{tools:o,tool_choice:l,toolWarnings:a};case"tool":return{tools:o,tool_choice:{type:"function",function:{name:i.toolName}},toolWarnings:a};default:{const c=l;throw new oe({functionality:`Unsupported tool choice type: ${c}`})}}}var $c=class{constructor(t,e,r){this.specificationVersion="v1",this.modelId=t,this.settings=e,this.config=r}get supportsStructuredOutputs(){var t;return(t=this.settings.structuredOutputs)!=null?t:In(this.modelId)}get defaultObjectGenerationMode(){return Oc(this.modelId)?"tool":this.supportsStructuredOutputs?"json":"tool"}get provider(){return this.config.provider}get supportsImageUrls(){return!this.settings.downloadImages}getArgs({mode:t,prompt:e,maxTokens:r,temperature:n,topP:s,topK:a,frequencyPenalty:i,presencePenalty:o,stopSequences:l,responseFormat:c,seed:d,providerMetadata:p}){var g,S,_,h,v,k,E,I;const j=t.type,C=[];a!=null&&C.push({type:"unsupported-setting",setting:"topK"}),(c==null?void 0:c.type)==="json"&&c.schema!=null&&!this.supportsStructuredOutputs&&C.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format schema is only supported with structuredOutputs"});const ee=this.settings.useLegacyFunctionCalling;if(ee&&this.settings.parallelToolCalls===!0)throw new oe({functionality:"useLegacyFunctionCalling with parallelToolCalls"});if(ee&&this.supportsStructuredOutputs)throw new oe({functionality:"structuredOutputs with useLegacyFunctionCalling"});Ss(this.modelId)==="remove"&&e.some(le=>le.role==="system")&&C.push({type:"other",message:"system messages are removed for this model"});const M={model:this.modelId,logit_bias:this.settings.logitBias,logprobs:this.settings.logprobs===!0||typeof this.settings.logprobs=="number"?!0:void 0,top_logprobs:typeof this.settings.logprobs=="number"?this.settings.logprobs:typeof this.settings.logprobs=="boolean"&&this.settings.logprobs?0:void 0,user:this.settings.user,parallel_tool_calls:this.settings.parallelToolCalls,max_tokens:r,temperature:n,top_p:s,frequency_penalty:i,presence_penalty:o,response_format:(c==null?void 0:c.type)==="json"?this.supportsStructuredOutputs&&c.schema!=null?{type:"json_schema",json_schema:{schema:c.schema,strict:!0,name:(g=c.name)!=null?g:"response",description:c.description}}:{type:"json_object"}:void 0,stop:l,seed:d,max_completion_tokens:(S=p==null?void 0:p.openai)==null?void 0:S.maxCompletionTokens,store:(_=p==null?void 0:p.openai)==null?void 0:_.store,metadata:(h=p==null?void 0:p.openai)==null?void 0:h.metadata,prediction:(v=p==null?void 0:p.openai)==null?void 0:v.prediction,reasoning_effort:(E=(k=p==null?void 0:p.openai)==null?void 0:k.reasoningEffort)!=null?E:this.settings.reasoningEffort,messages:Tc({prompt:e,useLegacyFunctionCalling:ee,systemMessageMode:Ss(this.modelId)})};switch(In(this.modelId)&&(M.temperature!=null&&(M.temperature=void 0,C.push({type:"unsupported-setting",setting:"temperature",details:"temperature is not supported for reasoning models"})),M.top_p!=null&&(M.top_p=void 0,C.push({type:"unsupported-setting",setting:"topP",details:"topP is not supported for reasoning models"})),M.frequency_penalty!=null&&(M.frequency_penalty=void 0,C.push({type:"unsupported-setting",setting:"frequencyPenalty",details:"frequencyPenalty is not supported for reasoning models"})),M.presence_penalty!=null&&(M.presence_penalty=void 0,C.push({type:"unsupported-setting",setting:"presencePenalty",details:"presencePenalty is not supported for reasoning models"})),M.logit_bias!=null&&(M.logit_bias=void 0,C.push({type:"other",message:"logitBias is not supported for reasoning models"})),M.logprobs!=null&&(M.logprobs=void 0,C.push({type:"other",message:"logprobs is not supported for reasoning models"})),M.top_logprobs!=null&&(M.top_logprobs=void 0,C.push({type:"other",message:"topLogprobs is not supported for reasoning models"})),M.max_tokens!=null&&(M.max_completion_tokens==null&&(M.max_completion_tokens=M.max_tokens),M.max_tokens=void 0)),j){case"regular":{const{tools:le,tool_choice:dt,functions:Ne,function_call:ce,toolWarnings:ge}=Ec({mode:t,useLegacyFunctionCalling:ee,structuredOutputs:this.supportsStructuredOutputs});return{args:{...M,tools:le,tool_choice:dt,functions:Ne,function_call:ce},warnings:[...C,...ge]}}case"object-json":return{args:{...M,response_format:this.supportsStructuredOutputs&&t.schema!=null?{type:"json_schema",json_schema:{schema:t.schema,strict:!0,name:(I=t.name)!=null?I:"response",description:t.description}}:{type:"json_object"}},warnings:C};case"object-tool":return{args:ee?{...M,function_call:{name:t.tool.name},functions:[{name:t.tool.name,description:t.tool.description,parameters:t.tool.parameters}]}:{...M,tool_choice:{type:"function",function:{name:t.tool.name}},tools:[{type:"function",function:{name:t.tool.name,description:t.tool.description,parameters:t.tool.parameters,strict:this.supportsStructuredOutputs?!0:void 0}}]},warnings:C};default:{const le=j;throw new Error(`Unsupported type: ${le}`)}}}async doGenerate(t){var e,r,n,s,a,i,o,l;const{args:c,warnings:d}=this.getArgs(t),{responseHeaders:p,value:g,rawValue:S}=await xt({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:bt(this.config.headers(),t.headers),body:c,failedResponseHandler:Tt,successfulResponseHandler:Yr(Ic),abortSignal:t.abortSignal,fetch:this.config.fetch}),{messages:_,...h}=c,v=g.choices[0],k=(e=g.usage)==null?void 0:e.completion_tokens_details,E=(r=g.usage)==null?void 0:r.prompt_tokens_details,I={openai:{}};return(k==null?void 0:k.reasoning_tokens)!=null&&(I.openai.reasoningTokens=k==null?void 0:k.reasoning_tokens),(k==null?void 0:k.accepted_prediction_tokens)!=null&&(I.openai.acceptedPredictionTokens=k==null?void 0:k.accepted_prediction_tokens),(k==null?void 0:k.rejected_prediction_tokens)!=null&&(I.openai.rejectedPredictionTokens=k==null?void 0:k.rejected_prediction_tokens),(E==null?void 0:E.cached_tokens)!=null&&(I.openai.cachedPromptTokens=E==null?void 0:E.cached_tokens),{text:(n=v.message.content)!=null?n:void 0,toolCalls:this.settings.useLegacyFunctionCalling&&v.message.function_call?[{toolCallType:"function",toolCallId:Ot(),toolName:v.message.function_call.name,args:v.message.function_call.arguments}]:(s=v.message.tool_calls)==null?void 0:s.map(j=>{var C;return{toolCallType:"function",toolCallId:(C=j.id)!=null?C:Ot(),toolName:j.function.name,args:j.function.arguments}}),finishReason:Mr(v.finish_reason),usage:{promptTokens:(i=(a=g.usage)==null?void 0:a.prompt_tokens)!=null?i:NaN,completionTokens:(l=(o=g.usage)==null?void 0:o.completion_tokens)!=null?l:NaN},rawCall:{rawPrompt:_,rawSettings:h},rawResponse:{headers:p,body:S},request:{body:JSON.stringify(c)},response:Dr(g),warnings:d,logprobs:ks(v.logprobs),providerMetadata:I}}async doStream(t){if(this.settings.simulateStreaming){const h=await this.doGenerate(t);return{stream:new ReadableStream({start(k){if(k.enqueue({type:"response-metadata",...h.response}),h.text&&k.enqueue({type:"text-delta",textDelta:h.text}),h.toolCalls)for(const E of h.toolCalls)k.enqueue({type:"tool-call-delta",toolCallType:"function",toolCallId:E.toolCallId,toolName:E.toolName,argsTextDelta:E.args}),k.enqueue({type:"tool-call",...E});k.enqueue({type:"finish",finishReason:h.finishReason,usage:h.usage,logprobs:h.logprobs,providerMetadata:h.providerMetadata}),k.close()}}),rawCall:h.rawCall,rawResponse:h.rawResponse,warnings:h.warnings}}const{args:e,warnings:r}=this.getArgs(t),n={...e,stream:!0,stream_options:this.config.compatibility==="strict"?{include_usage:!0}:void 0},{responseHeaders:s,value:a}=await xt({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:bt(this.config.headers(),t.headers),body:n,failedResponseHandler:Tt,successfulResponseHandler:La(Cc),abortSignal:t.abortSignal,fetch:this.config.fetch}),{messages:i,...o}=e,l=[];let c="unknown",d={promptTokens:void 0,completionTokens:void 0},p,g=!0;const{useLegacyFunctionCalling:S}=this.settings,_={openai:{}};return{stream:a.pipeThrough(new TransformStream({transform(h,v){var k,E,I,j,C,ee,M,le,dt,Ne,ce,ge;if(!h.success){c="error",v.enqueue({type:"error",error:h.error});return}const re=h.value;if("error"in re){c="error",v.enqueue({type:"error",error:re.error});return}if(g&&(g=!1,v.enqueue({type:"response-metadata",...Dr(re)})),re.usage!=null){const{prompt_tokens:V,completion_tokens:F,prompt_tokens_details:se,completion_tokens_details:z}=re.usage;d={promptTokens:V??void 0,completionTokens:F??void 0},(z==null?void 0:z.reasoning_tokens)!=null&&(_.openai.reasoningTokens=z==null?void 0:z.reasoning_tokens),(z==null?void 0:z.accepted_prediction_tokens)!=null&&(_.openai.acceptedPredictionTokens=z==null?void 0:z.accepted_prediction_tokens),(z==null?void 0:z.rejected_prediction_tokens)!=null&&(_.openai.rejectedPredictionTokens=z==null?void 0:z.rejected_prediction_tokens),(se==null?void 0:se.cached_tokens)!=null&&(_.openai.cachedPromptTokens=se==null?void 0:se.cached_tokens)}const ne=re.choices[0];if((ne==null?void 0:ne.finish_reason)!=null&&(c=Mr(ne.finish_reason)),(ne==null?void 0:ne.delta)==null)return;const ie=ne.delta;ie.content!=null&&v.enqueue({type:"text-delta",textDelta:ie.content});const W=ks(ne==null?void 0:ne.logprobs);W!=null&&W.length&&(p===void 0&&(p=[]),p.push(...W));const Ae=S&&ie.function_call!=null?[{type:"function",id:Ot(),function:ie.function_call,index:0}]:ie.tool_calls;if(Ae!=null)for(const V of Ae){const F=V.index;if(l[F]==null){if(V.type!=="function")throw new sn({data:V,message:"Expected 'function' type."});if(V.id==null)throw new sn({data:V,message:"Expected 'id' to be a string."});if(((k=V.function)==null?void 0:k.name)==null)throw new sn({data:V,message:"Expected 'function.name' to be a string."});l[F]={id:V.id,type:"function",function:{name:V.function.name,arguments:(E=V.function.arguments)!=null?E:""},hasFinished:!1};const z=l[F];((I=z.function)==null?void 0:I.name)!=null&&((j=z.function)==null?void 0:j.arguments)!=null&&(z.function.arguments.length>0&&v.enqueue({type:"tool-call-delta",toolCallType:"function",toolCallId:z.id,toolName:z.function.name,argsTextDelta:z.function.arguments}),_s(z.function.arguments)&&(v.enqueue({type:"tool-call",toolCallType:"function",toolCallId:(C=z.id)!=null?C:Ot(),toolName:z.function.name,args:z.function.arguments}),z.hasFinished=!0));continue}const se=l[F];se.hasFinished||(((ee=V.function)==null?void 0:ee.arguments)!=null&&(se.function.arguments+=(le=(M=V.function)==null?void 0:M.arguments)!=null?le:""),v.enqueue({type:"tool-call-delta",toolCallType:"function",toolCallId:se.id,toolName:se.function.name,argsTextDelta:(dt=V.function.arguments)!=null?dt:""}),((Ne=se.function)==null?void 0:Ne.name)!=null&&((ce=se.function)==null?void 0:ce.arguments)!=null&&_s(se.function.arguments)&&(v.enqueue({type:"tool-call",toolCallType:"function",toolCallId:(ge=se.id)!=null?ge:Ot(),toolName:se.function.name,args:se.function.arguments}),se.hasFinished=!0))}},flush(h){var v,k;h.enqueue({type:"finish",finishReason:c,logprobs:p,usage:{promptTokens:(v=d.promptTokens)!=null?v:NaN,completionTokens:(k=d.completionTokens)!=null?k:NaN},..._!=null?{providerMetadata:_}:{}})}})),rawCall:{rawPrompt:i,rawSettings:o},rawResponse:{headers:s},request:{body:JSON.stringify(n)},warnings:r}}},Ka=u.object({prompt_tokens:u.number().nullish(),completion_tokens:u.number().nullish(),prompt_tokens_details:u.object({cached_tokens:u.number().nullish()}).nullish(),completion_tokens_details:u.object({reasoning_tokens:u.number().nullish(),accepted_prediction_tokens:u.number().nullish(),rejected_prediction_tokens:u.number().nullish()}).nullish()}).nullish(),Ic=u.object({id:u.string().nullish(),created:u.number().nullish(),model:u.string().nullish(),choices:u.array(u.object({message:u.object({role:u.literal("assistant").nullish(),content:u.string().nullish(),function_call:u.object({arguments:u.string(),name:u.string()}).nullish(),tool_calls:u.array(u.object({id:u.string().nullish(),type:u.literal("function"),function:u.object({name:u.string(),arguments:u.string()})})).nullish()}),index:u.number(),logprobs:u.object({content:u.array(u.object({token:u.string(),logprob:u.number(),top_logprobs:u.array(u.object({token:u.string(),logprob:u.number()}))})).nullable()}).nullish(),finish_reason:u.string().nullish()})),usage:Ka}),Cc=u.union([u.object({id:u.string().nullish(),created:u.number().nullish(),model:u.string().nullish(),choices:u.array(u.object({delta:u.object({role:u.enum(["assistant"]).nullish(),content:u.string().nullish(),function_call:u.object({name:u.string().optional(),arguments:u.string().optional()}).nullish(),tool_calls:u.array(u.object({index:u.number(),id:u.string().nullish(),type:u.literal("function").optional(),function:u.object({name:u.string().nullish(),arguments:u.string().nullish()})})).nullish()}).nullish(),logprobs:u.object({content:u.array(u.object({token:u.string(),logprob:u.number(),top_logprobs:u.array(u.object({token:u.string(),logprob:u.number()}))})).nullable()}).nullish(),finish_reason:u.string().nullable().optional(),index:u.number()})),usage:Ka}),Bn]);function In(t){return t==="o1"||t.startsWith("o1-")||t==="o3"||t.startsWith("o3-")}function Oc(t){return t.startsWith("gpt-4o-audio-preview")}function Ss(t){var e,r;return In(t)?(r=(e=Rc[t])==null?void 0:e.systemMessageMode)!=null?r:"developer":"system"}var Rc={"o1-mini":{systemMessageMode:"remove"},"o1-mini-2024-09-12":{systemMessageMode:"remove"},"o1-preview":{systemMessageMode:"remove"},"o1-preview-2024-09-12":{systemMessageMode:"remove"},"o3-mini":{systemMessageMode:"developer"},"o3-mini-2025-01-31":{systemMessageMode:"developer"}};function Pc({prompt:t,inputFormat:e,user:r="user",assistant:n="assistant"}){if(e==="prompt"&&t.length===1&&t[0].role==="user"&&t[0].content.length===1&&t[0].content[0].type==="text")return{prompt:t[0].content[0].text};let s="";t[0].role==="system"&&(s+=`${t[0].content}
169
+
170
+ `,t=t.slice(1));for(const{role:a,content:i}of t)switch(a){case"system":throw new Qe({message:"Unexpected system message in prompt: ${content}",prompt:t});case"user":{const o=i.map(l=>{switch(l.type){case"text":return l.text;case"image":throw new oe({functionality:"images"})}}).join("");s+=`${r}:
171
+ ${o}
172
+
173
+ `;break}case"assistant":{const o=i.map(l=>{switch(l.type){case"text":return l.text;case"tool-call":throw new oe({functionality:"tool-call messages"})}}).join("");s+=`${n}:
174
+ ${o}
175
+
176
+ `;break}case"tool":throw new oe({functionality:"tool messages"});default:{const o=a;throw new Error(`Unsupported role: ${o}`)}}return s+=`${n}:
177
+ `,{prompt:s,stopSequences:[`
178
+ ${r}:`]}}function As(t){return t==null?void 0:t.tokens.map((e,r)=>({token:e,logprob:t.token_logprobs[r],topLogprobs:t.top_logprobs?Object.entries(t.top_logprobs[r]).map(([n,s])=>({token:n,logprob:s})):[]}))}var jc=class{constructor(t,e,r){this.specificationVersion="v1",this.defaultObjectGenerationMode=void 0,this.modelId=t,this.settings=e,this.config=r}get provider(){return this.config.provider}getArgs({mode:t,inputFormat:e,prompt:r,maxTokens:n,temperature:s,topP:a,topK:i,frequencyPenalty:o,presencePenalty:l,stopSequences:c,responseFormat:d,seed:p}){var g;const S=t.type,_=[];i!=null&&_.push({type:"unsupported-setting",setting:"topK"}),d!=null&&d.type!=="text"&&_.push({type:"unsupported-setting",setting:"responseFormat",details:"JSON response format is not supported."});const{prompt:h,stopSequences:v}=Pc({prompt:r,inputFormat:e}),k=[...v??[],...c??[]],E={model:this.modelId,echo:this.settings.echo,logit_bias:this.settings.logitBias,logprobs:typeof this.settings.logprobs=="number"?this.settings.logprobs:typeof this.settings.logprobs=="boolean"&&this.settings.logprobs?0:void 0,suffix:this.settings.suffix,user:this.settings.user,max_tokens:n,temperature:s,top_p:a,frequency_penalty:o,presence_penalty:l,seed:p,prompt:h,stop:k.length>0?k:void 0};switch(S){case"regular":{if((g=t.tools)!=null&&g.length)throw new oe({functionality:"tools"});if(t.toolChoice)throw new oe({functionality:"toolChoice"});return{args:E,warnings:_}}case"object-json":throw new oe({functionality:"object-json mode"});case"object-tool":throw new oe({functionality:"object-tool mode"});default:{const I=S;throw new Error(`Unsupported type: ${I}`)}}}async doGenerate(t){const{args:e,warnings:r}=this.getArgs(t),{responseHeaders:n,value:s,rawValue:a}=await xt({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:bt(this.config.headers(),t.headers),body:e,failedResponseHandler:Tt,successfulResponseHandler:Yr(Nc),abortSignal:t.abortSignal,fetch:this.config.fetch}),{prompt:i,...o}=e,l=s.choices[0];return{text:l.text,usage:{promptTokens:s.usage.prompt_tokens,completionTokens:s.usage.completion_tokens},finishReason:Mr(l.finish_reason),logprobs:As(l.logprobs),rawCall:{rawPrompt:i,rawSettings:o},rawResponse:{headers:n,body:a},response:Dr(s),warnings:r,request:{body:JSON.stringify(e)}}}async doStream(t){const{args:e,warnings:r}=this.getArgs(t),n={...e,stream:!0,stream_options:this.config.compatibility==="strict"?{include_usage:!0}:void 0},{responseHeaders:s,value:a}=await xt({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:bt(this.config.headers(),t.headers),body:n,failedResponseHandler:Tt,successfulResponseHandler:La(Mc),abortSignal:t.abortSignal,fetch:this.config.fetch}),{prompt:i,...o}=e;let l="unknown",c={promptTokens:Number.NaN,completionTokens:Number.NaN},d,p=!0;return{stream:a.pipeThrough(new TransformStream({transform(g,S){if(!g.success){l="error",S.enqueue({type:"error",error:g.error});return}const _=g.value;if("error"in _){l="error",S.enqueue({type:"error",error:_.error});return}p&&(p=!1,S.enqueue({type:"response-metadata",...Dr(_)})),_.usage!=null&&(c={promptTokens:_.usage.prompt_tokens,completionTokens:_.usage.completion_tokens});const h=_.choices[0];(h==null?void 0:h.finish_reason)!=null&&(l=Mr(h.finish_reason)),(h==null?void 0:h.text)!=null&&S.enqueue({type:"text-delta",textDelta:h.text});const v=As(h==null?void 0:h.logprobs);v!=null&&v.length&&(d===void 0&&(d=[]),d.push(...v))},flush(g){g.enqueue({type:"finish",finishReason:l,logprobs:d,usage:c})}})),rawCall:{rawPrompt:i,rawSettings:o},rawResponse:{headers:s},warnings:r,request:{body:JSON.stringify(n)}}}},Nc=u.object({id:u.string().nullish(),created:u.number().nullish(),model:u.string().nullish(),choices:u.array(u.object({text:u.string(),finish_reason:u.string(),logprobs:u.object({tokens:u.array(u.string()),token_logprobs:u.array(u.number()),top_logprobs:u.array(u.record(u.string(),u.number())).nullable()}).nullish()})),usage:u.object({prompt_tokens:u.number(),completion_tokens:u.number()})}),Mc=u.union([u.object({id:u.string().nullish(),created:u.number().nullish(),model:u.string().nullish(),choices:u.array(u.object({text:u.string(),finish_reason:u.string().nullish(),index:u.number(),logprobs:u.object({tokens:u.array(u.string()),token_logprobs:u.array(u.number()),top_logprobs:u.array(u.record(u.string(),u.number())).nullable()}).nullish()})),usage:u.object({prompt_tokens:u.number(),completion_tokens:u.number()}).nullish()}),Bn]),Dc=class{constructor(t,e,r){this.specificationVersion="v1",this.modelId=t,this.settings=e,this.config=r}get provider(){return this.config.provider}get maxEmbeddingsPerCall(){var t;return(t=this.settings.maxEmbeddingsPerCall)!=null?t:2048}get supportsParallelCalls(){var t;return(t=this.settings.supportsParallelCalls)!=null?t:!0}async doEmbed({values:t,headers:e,abortSignal:r}){if(t.length>this.maxEmbeddingsPerCall)throw new Lo({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:t});const{responseHeaders:n,value:s}=await xt({url:this.config.url({path:"/embeddings",modelId:this.modelId}),headers:bt(this.config.headers(),e),body:{model:this.modelId,input:t,encoding_format:"float",dimensions:this.settings.dimensions,user:this.settings.user},failedResponseHandler:Tt,successfulResponseHandler:Yr(Zc),abortSignal:r,fetch:this.config.fetch});return{embeddings:s.data.map(a=>a.embedding),usage:s.usage?{tokens:s.usage.prompt_tokens}:void 0,rawResponse:{headers:n}}}},Zc=u.object({data:u.array(u.object({embedding:u.array(u.number())})),usage:u.object({prompt_tokens:u.number()}).nullish()}),Uc={"dall-e-3":1,"dall-e-2":10},Lc=class{constructor(t,e,r){this.modelId=t,this.settings=e,this.config=r,this.specificationVersion="v1"}get maxImagesPerCall(){var t,e;return(e=(t=this.settings.maxImagesPerCall)!=null?t:Uc[this.modelId])!=null?e:1}get provider(){return this.config.provider}async doGenerate({prompt:t,n:e,size:r,aspectRatio:n,seed:s,providerOptions:a,headers:i,abortSignal:o}){var l,c,d,p;const g=[];n!=null&&g.push({type:"unsupported-setting",setting:"aspectRatio",details:"This model does not support aspect ratio. Use `size` instead."}),s!=null&&g.push({type:"unsupported-setting",setting:"seed"});const S=(d=(c=(l=this.config._internal)==null?void 0:l.currentDate)==null?void 0:c.call(l))!=null?d:new Date,{value:_,responseHeaders:h}=await xt({url:this.config.url({path:"/images/generations",modelId:this.modelId}),headers:bt(this.config.headers(),i),body:{model:this.modelId,prompt:t,n:e,size:r,...(p=a.openai)!=null?p:{},response_format:"b64_json"},failedResponseHandler:Tt,successfulResponseHandler:Yr(Vc),abortSignal:o,fetch:this.config.fetch});return{images:_.data.map(v=>v.b64_json),warnings:g,response:{timestamp:S,modelId:this.modelId,headers:h}}}},Vc=u.object({data:u.array(u.object({b64_json:u.string()}))});function Xa(t={}){var e,r,n;const s=(e=yl(t.baseURL))!=null?e:"https://api.openai.com/v1",a=(r=t.compatibility)!=null?r:"compatible",i=(n=t.name)!=null?n:"openai",o=()=>({Authorization:`Bearer ${sl({apiKey:t.apiKey,environmentVariableName:"OPENAI_API_KEY",description:"OpenAI"})}`,"OpenAI-Organization":t.organization,"OpenAI-Project":t.project,...t.headers}),l=(_,h={})=>new $c(_,h,{provider:`${i}.chat`,url:({path:v})=>`${s}${v}`,headers:o,compatibility:a,fetch:t.fetch}),c=(_,h={})=>new jc(_,h,{provider:`${i}.completion`,url:({path:v})=>`${s}${v}`,headers:o,compatibility:a,fetch:t.fetch}),d=(_,h={})=>new Dc(_,h,{provider:`${i}.embedding`,url:({path:v})=>`${s}${v}`,headers:o,fetch:t.fetch}),p=(_,h={})=>new Lc(_,h,{provider:`${i}.image`,url:({path:v})=>`${s}${v}`,headers:o,fetch:t.fetch}),g=(_,h)=>{if(new.target)throw new Error("The OpenAI model function cannot be called with the new keyword.");return _==="gpt-3.5-turbo-instruct"?c(_,h):l(_,h)},S=function(_,h){return g(_,h)};return S.languageModel=g,S.chat=l,S.completion=c,S.embedding=d,S.textEmbedding=d,S.textEmbeddingModel=d,S.image=p,S.imageModel=p,S}Xa({compatibility:"strict"});const Fc=Symbol("Let zodToJsonSchema decide on which parser to use"),Ts={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Bc=t=>typeof t=="string"?{...Ts,name:t}:{...Ts,...t},zc=t=>{const e=Bc(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return{...e,currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};function Qa(t,e,r,n){n!=null&&n.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function B(t,e,r,n,s){t[e]=r,Qa(t,e,n,s)}function qc(){return{}}function Jc(t,e){var n,s,a;const r={type:"array"};return(n=t.type)!=null&&n._def&&((a=(s=t.type)==null?void 0:s._def)==null?void 0:a.typeName)!==m.ZodAny&&(r.items=U(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&B(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&B(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(B(r,"minItems",t.exactLength.value,t.exactLength.message,e),B(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function Hc(t,e){const r={type:"integer",format:"int64"};if(!t.checks)return r;for(const n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?B(r,"minimum",n.value,n.message,e):B(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),B(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?B(r,"maximum",n.value,n.message,e):B(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),B(r,"maximum",n.value,n.message,e));break;case"multipleOf":B(r,"multipleOf",n.value,n.message,e);break}return r}function Wc(){return{type:"boolean"}}function ei(t,e){return U(t.type._def,e)}const Yc=(t,e)=>U(t.innerType._def,e);function ti(t,e,r){const n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,a)=>ti(t,e,s))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Gc(t,e)}}const Gc=(t,e)=>{const r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(const n of t.checks)switch(n.kind){case"min":B(r,"minimum",n.value,n.message,e);break;case"max":B(r,"maximum",n.value,n.message,e);break}return r};function Kc(t,e){return{...U(t.innerType._def,e),default:t.defaultValue()}}function Xc(t,e){return e.effectStrategy==="input"?U(t.schema._def,e):{}}function Qc(t){return{type:"string",enum:Array.from(t.values)}}const eu=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function tu(t,e){const r=[U(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),U(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(a=>!!a);let n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0;const s=[];return r.forEach(a=>{if(eu(a))s.push(...a.allOf),a.unevaluatedProperties===void 0&&(n=void 0);else{let i=a;if("additionalProperties"in a&&a.additionalProperties===!1){const{additionalProperties:o,...l}=a;i=l}else n=void 0;s.push(i)}}),s.length?{allOf:s,...n}:void 0}function ru(t,e){const r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}let ln;const $e={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(ln===void 0&&(ln=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ln),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ri(t,e){const r={type:"string"};if(t.checks)for(const n of t.checks)switch(n.kind){case"min":B(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":B(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Ie(r,"email",n.message,e);break;case"format:idn-email":Ie(r,"idn-email",n.message,e);break;case"pattern:zod":ve(r,$e.email,n.message,e);break}break;case"url":Ie(r,"uri",n.message,e);break;case"uuid":Ie(r,"uuid",n.message,e);break;case"regex":ve(r,n.regex,n.message,e);break;case"cuid":ve(r,$e.cuid,n.message,e);break;case"cuid2":ve(r,$e.cuid2,n.message,e);break;case"startsWith":ve(r,RegExp(`^${cn(n.value,e)}`),n.message,e);break;case"endsWith":ve(r,RegExp(`${cn(n.value,e)}$`),n.message,e);break;case"datetime":Ie(r,"date-time",n.message,e);break;case"date":Ie(r,"date",n.message,e);break;case"time":Ie(r,"time",n.message,e);break;case"duration":Ie(r,"duration",n.message,e);break;case"length":B(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),B(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{ve(r,RegExp(cn(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&Ie(r,"ipv4",n.message,e),n.version!=="v4"&&Ie(r,"ipv6",n.message,e);break}case"base64url":ve(r,$e.base64url,n.message,e);break;case"jwt":ve(r,$e.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&ve(r,$e.ipv4Cidr,n.message,e),n.version!=="v4"&&ve(r,$e.ipv6Cidr,n.message,e);break}case"emoji":ve(r,$e.emoji(),n.message,e);break;case"ulid":{ve(r,$e.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{Ie(r,"binary",n.message,e);break}case"contentEncoding:base64":{B(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{ve(r,$e.base64,n.message,e);break}}break}case"nanoid":ve(r,$e.nanoid,n.message,e)}return r}function cn(t,e){return e.patternStrategy==="escape"?su(t):t}const nu=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function su(t){let e="";for(let r=0;r<t.length;r++)nu.has(t[r])||(e+="\\"),e+=t[r];return e}function Ie(t,e,r,n){var s;t.format||(s=t.anyOf)!=null&&s.some(a=>a.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format,...t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}}}),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push({format:e,...r&&n.errorMessages&&{errorMessage:{format:r}}})):B(t,"format",e,r,n)}function ve(t,e,r,n){var s;t.pattern||(s=t.allOf)!=null&&s.some(a=>a.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern,...t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}}}),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push({pattern:Es(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):B(t,"pattern",Es(e,n),r,n)}function Es(t,e){var l;if(!e.applyRegexFlags||!t.flags)return t.source;const r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source;let s="",a=!1,i=!1,o=!1;for(let c=0;c<n.length;c++){if(a){s+=n[c],a=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){o?(s+=n[c],s+=`${n[c-2]}-${n[c]}`.toUpperCase(),o=!1):n[c+1]==="-"&&((l=n[c+2])!=null&&l.match(/[a-z]/))?(s+=n[c],o=!0):s+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){s+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){s+=`(^|(?<=[\r
179
+ ]))`;continue}else if(n[c]==="$"){s+=`($|(?=[\r
180
+ ]))`;continue}}if(r.s&&n[c]==="."){s+=i?`${n[c]}\r
181
+ `:`[${n[c]}\r
182
+ ]`;continue}s+=n[c],n[c]==="\\"?a=!0:i&&n[c]==="]"?i=!1:!i&&n[c]==="["&&(i=!0)}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return s}function ni(t,e){var n,s,a,i,o,l;if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&((n=t.keyType)==null?void 0:n._def.typeName)===m.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((c,d)=>({...c,[d]:U(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",d]})??{}}),{}),additionalProperties:!1};const r={type:"object",additionalProperties:U(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??{}};if(e.target==="openApi3")return r;if(((s=t.keyType)==null?void 0:s._def.typeName)===m.ZodString&&((a=t.keyType._def.checks)!=null&&a.length)){const{type:c,...d}=ri(t.keyType._def,e);return{...r,propertyNames:d}}else{if(((i=t.keyType)==null?void 0:i._def.typeName)===m.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(((o=t.keyType)==null?void 0:o._def.typeName)===m.ZodBranded&&t.keyType._def.type._def.typeName===m.ZodString&&((l=t.keyType._def.type._def.checks)!=null&&l.length)){const{type:c,...d}=ei(t.keyType._def,e);return{...r,propertyNames:d}}}return r}function au(t,e){if(e.mapStrategy==="record")return ni(t,e);const r=U(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||{},n=U(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function iu(t){const e=t.values,n=Object.keys(t.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),s=Array.from(new Set(n.map(a=>typeof a)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n}}function ou(){return{not:{}}}function lu(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}const Zr={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function cu(t,e){if(e.target==="openApi3")return $s(t,e);const r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in Zr&&(!n._def.checks||!n._def.checks.length))){const n=r.reduce((s,a)=>{const i=Zr[a._def.typeName];return i&&!s.includes(i)?[...s,i]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){const n=r.reduce((s,a)=>{const i=typeof a._def.value;switch(i){case"string":case"number":case"boolean":return[...s,i];case"bigint":return[...s,"integer"];case"object":if(a._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){const s=n.filter((a,i,o)=>o.indexOf(a)===i);return{type:s.length>1?s:s[0],enum:r.reduce((a,i)=>a.includes(i._def.value)?a:[...a,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(a=>!n.includes(a))],[])};return $s(t,e)}const $s=(t,e)=>{const r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>U(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${s}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function uu(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:Zr[t.innerType._def.typeName],nullable:!0}:{type:[Zr[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){const n=U(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}const r=U(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function du(t,e){const r={type:"number"};if(!t.checks)return r;for(const n of t.checks)switch(n.kind){case"int":r.type="integer",Qa(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?B(r,"minimum",n.value,n.message,e):B(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),B(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?B(r,"maximum",n.value,n.message,e):B(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),B(r,"maximum",n.value,n.message,e));break;case"multipleOf":B(r,"multipleOf",n.value,n.message,e);break}return r}function pu(t,e){return e.removeAdditionalStrategy==="strict"?t.catchall._def.typeName==="ZodNever"?t.unknownKeys!=="strict":U(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??!0:t.catchall._def.typeName==="ZodNever"?t.unknownKeys==="passthrough":U(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??!0}function hu(t,e){const r=e.target==="openAi",n={type:"object",...Object.entries(t.shape()).reduce((s,[a,i])=>{if(i===void 0||i._def===void 0)return s;let o=i.isOptional();o&&r&&(i instanceof Re&&(i=i._def.innerType),i.isNullable()||(i=i.nullable()),o=!1);const l=U(i._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});return l===void 0?s:{properties:{...s.properties,[a]:l},required:o?s.required:[...s.required,a]}},{properties:{},required:[]}),additionalProperties:pu(t,e)};return n.required.length||delete n.required,n}const fu=(t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return U(t.innerType._def,e);const r=U(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:{}},r]}:{}},mu=(t,e)=>{if(e.pipeStrategy==="input")return U(t.in._def,e);if(e.pipeStrategy==="output")return U(t.out._def,e);const r=U(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=U(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}};function gu(t,e){return U(t.type._def,e)}function yu(t,e){const n={type:"array",uniqueItems:!0,items:U(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&B(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&B(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function vu(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>U(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:U(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>U(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function _u(){return{not:{}}}function bu(){return{}}const wu=(t,e)=>U(t.innerType._def,e),xu=(t,e,r)=>{switch(e){case m.ZodString:return ri(t,r);case m.ZodNumber:return du(t,r);case m.ZodObject:return hu(t,r);case m.ZodBigInt:return Hc(t,r);case m.ZodBoolean:return Wc();case m.ZodDate:return ti(t,r);case m.ZodUndefined:return _u();case m.ZodNull:return lu(r);case m.ZodArray:return Jc(t,r);case m.ZodUnion:case m.ZodDiscriminatedUnion:return cu(t,r);case m.ZodIntersection:return tu(t,r);case m.ZodTuple:return vu(t,r);case m.ZodRecord:return ni(t,r);case m.ZodLiteral:return ru(t,r);case m.ZodEnum:return Qc(t);case m.ZodNativeEnum:return iu(t);case m.ZodNullable:return uu(t,r);case m.ZodOptional:return fu(t,r);case m.ZodMap:return au(t,r);case m.ZodSet:return yu(t,r);case m.ZodLazy:return()=>t.getter()._def;case m.ZodPromise:return gu(t,r);case m.ZodNaN:case m.ZodNever:return ou();case m.ZodEffects:return Xc(t,r);case m.ZodAny:return qc();case m.ZodUnknown:return bu();case m.ZodDefault:return Kc(t,r);case m.ZodBranded:return ei(t,r);case m.ZodReadonly:return wu(t,r);case m.ZodCatch:return Yc(t,r);case m.ZodPipeline:return mu(t,r);case m.ZodFunction:case m.ZodVoid:case m.ZodSymbol:return;default:return(n=>{})()}};function U(t,e,r=!1){var o;const n=e.seen.get(t);if(e.override){const l=(o=e.override)==null?void 0:o.call(e,t,e,n,r);if(l!==Fc)return l}if(n&&!r){const l=ku(n,e);if(l!==void 0)return l}const s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);const a=xu(t,t.typeName,e),i=typeof a=="function"?U(a(),e):a;if(i&&Au(t,e,i),e.postProcess){const l=e.postProcess(i,t,e);return s.jsonSchema=i,l}return s.jsonSchema=i,i}const ku=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Su(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},Su=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")},Au=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r),Tu=(t,e)=>{const r=zc(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((l,[c,d])=>({...l,[c]:U(d._def,{...r,currentPath:[...r.basePath,r.definitionPath,c]},!0)??{}}),{}):void 0,s=typeof e=="string"?e:(e==null?void 0:e.nameStrategy)==="title"||e==null?void 0:e.name,a=U(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??{},i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(a.title=i);const o=s===void 0?n?{...a,[r.definitionPath]:n}:a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...n,[s]:a}};return r.target==="jsonSchema7"?o.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in o||"oneOf"in o||"allOf"in o||"type"in o&&Array.isArray(o.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),o};var ar={code:"0",name:"text",parse:t=>{if(typeof t!="string")throw new Error('"text" parts expect a string value.');return{type:"text",value:t}}},ir={code:"3",name:"error",parse:t=>{if(typeof t!="string")throw new Error('"error" parts expect a string value.');return{type:"error",value:t}}},or={code:"4",name:"assistant_message",parse:t=>{if(t==null||typeof t!="object"||!("id"in t)||!("role"in t)||!("content"in t)||typeof t.id!="string"||typeof t.role!="string"||t.role!=="assistant"||!Array.isArray(t.content)||!t.content.every(e=>e!=null&&typeof e=="object"&&"type"in e&&e.type==="text"&&"text"in e&&e.text!=null&&typeof e.text=="object"&&"value"in e.text&&typeof e.text.value=="string"))throw new Error('"assistant_message" parts expect an object with an "id", "role", and "content" property.');return{type:"assistant_message",value:t}}},lr={code:"5",name:"assistant_control_data",parse:t=>{if(t==null||typeof t!="object"||!("threadId"in t)||!("messageId"in t)||typeof t.threadId!="string"||typeof t.messageId!="string")throw new Error('"assistant_control_data" parts expect an object with a "threadId" and "messageId" property.');return{type:"assistant_control_data",value:{threadId:t.threadId,messageId:t.messageId}}}},cr={code:"6",name:"data_message",parse:t=>{if(t==null||typeof t!="object"||!("role"in t)||!("data"in t)||typeof t.role!="string"||t.role!=="data")throw new Error('"data_message" parts expect an object with a "role" and "data" property.');return{type:"data_message",value:t}}},Eu=[ar,ir,or,lr,cr];ar.code+"",ir.code+"",or.code+"",lr.code+"",cr.code+"";ar.name+"",ar.code,ir.name+"",ir.code,or.name+"",or.code,lr.name+"",lr.code,cr.name+"",cr.code;Eu.map(t=>t.code);function $u(t){const e=["ROOT"];let r=-1,n=null;function s(l,c,d){switch(l){case'"':{r=c,e.pop(),e.push(d),e.push("INSIDE_STRING");break}case"f":case"t":case"n":{r=c,n=c,e.pop(),e.push(d),e.push("INSIDE_LITERAL");break}case"-":{e.pop(),e.push(d),e.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=c,e.pop(),e.push(d),e.push("INSIDE_NUMBER");break}case"{":{r=c,e.pop(),e.push(d),e.push("INSIDE_OBJECT_START");break}case"[":{r=c,e.pop(),e.push(d),e.push("INSIDE_ARRAY_START");break}}}function a(l,c){switch(l){case",":{e.pop(),e.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{r=c,e.pop();break}}}function i(l,c){switch(l){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=c,e.pop();break}}}for(let l=0;l<t.length;l++){const c=t[l];switch(e[e.length-1]){case"ROOT":s(c,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(c){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY");break}case"}":{r=l,e.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(c){case'"':{e.pop(),e.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(c){case'"':{e.pop(),e.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(c){case":":{e.pop(),e.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{s(c,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{a(c,l);break}case"INSIDE_STRING":{switch(c){case'"':{e.pop(),r=l;break}case"\\":{e.push("INSIDE_STRING_ESCAPE");break}default:r=l}break}case"INSIDE_ARRAY_START":{switch(c){case"]":{r=l,e.pop();break}default:{r=l,s(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(c){case",":{e.pop(),e.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=l,e.pop();break}default:{r=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{s(c,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{e.pop(),r=l;break}case"INSIDE_NUMBER":{switch(c){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=l;break}case"e":case"E":case"-":case".":break;case",":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(c,l),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&a(c,l);break}case"}":{e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&a(c,l);break}case"]":{e.pop(),e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(c,l);break}default:{e.pop();break}}break}case"INSIDE_LITERAL":{const p=t.substring(n,l+1);!"false".startsWith(p)&&!"true".startsWith(p)&&!"null".startsWith(p)?(e.pop(),e[e.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?a(c,l):e[e.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&i(c,l)):r=l;break}}}let o=t.slice(0,r+1);for(let l=e.length-1;l>=0;l--)switch(e[l]){case"INSIDE_STRING":{o+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{o+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{o+="]";break}case"INSIDE_LITERAL":{const d=t.substring(n,t.length);"true".startsWith(d)?o+="true".slice(d.length):"false".startsWith(d)?o+="false".slice(d.length):"null".startsWith(d)&&(o+="null".slice(d.length))}}return o}function Iu(t){if(t===void 0)return{value:void 0,state:"undefined-input"};let e=wt({text:t});return e.success?{value:e.value,state:"successful-parse"}:(e=wt({text:$u(t)}),e.success?{value:e.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}var Cu={code:"0",name:"text",parse:t=>{if(typeof t!="string")throw new Error('"text" parts expect a string value.');return{type:"text",value:t}}},Ou={code:"2",name:"data",parse:t=>{if(!Array.isArray(t))throw new Error('"data" parts expect an array value.');return{type:"data",value:t}}},Ru={code:"3",name:"error",parse:t=>{if(typeof t!="string")throw new Error('"error" parts expect a string value.');return{type:"error",value:t}}},Pu={code:"8",name:"message_annotations",parse:t=>{if(!Array.isArray(t))throw new Error('"message_annotations" parts expect an array value.');return{type:"message_annotations",value:t}}},ju={code:"9",name:"tool_call",parse:t=>{if(t==null||typeof t!="object"||!("toolCallId"in t)||typeof t.toolCallId!="string"||!("toolName"in t)||typeof t.toolName!="string"||!("args"in t)||typeof t.args!="object")throw new Error('"tool_call" parts expect an object with a "toolCallId", "toolName", and "args" property.');return{type:"tool_call",value:t}}},Nu={code:"a",name:"tool_result",parse:t=>{if(t==null||typeof t!="object"||!("toolCallId"in t)||typeof t.toolCallId!="string"||!("result"in t))throw new Error('"tool_result" parts expect an object with a "toolCallId" and a "result" property.');return{type:"tool_result",value:t}}},Mu={code:"b",name:"tool_call_streaming_start",parse:t=>{if(t==null||typeof t!="object"||!("toolCallId"in t)||typeof t.toolCallId!="string"||!("toolName"in t)||typeof t.toolName!="string")throw new Error('"tool_call_streaming_start" parts expect an object with a "toolCallId" and "toolName" property.');return{type:"tool_call_streaming_start",value:t}}},Du={code:"c",name:"tool_call_delta",parse:t=>{if(t==null||typeof t!="object"||!("toolCallId"in t)||typeof t.toolCallId!="string"||!("argsTextDelta"in t)||typeof t.argsTextDelta!="string")throw new Error('"tool_call_delta" parts expect an object with a "toolCallId" and "argsTextDelta" property.');return{type:"tool_call_delta",value:t}}},Zu={code:"d",name:"finish_message",parse:t=>{if(t==null||typeof t!="object"||!("finishReason"in t)||typeof t.finishReason!="string")throw new Error('"finish_message" parts expect an object with a "finishReason" property.');const e={finishReason:t.finishReason};return"usage"in t&&t.usage!=null&&typeof t.usage=="object"&&"promptTokens"in t.usage&&"completionTokens"in t.usage&&(e.usage={promptTokens:typeof t.usage.promptTokens=="number"?t.usage.promptTokens:Number.NaN,completionTokens:typeof t.usage.completionTokens=="number"?t.usage.completionTokens:Number.NaN}),{type:"finish_message",value:e}}},Uu={code:"e",name:"finish_step",parse:t=>{if(t==null||typeof t!="object"||!("finishReason"in t)||typeof t.finishReason!="string")throw new Error('"finish_step" parts expect an object with a "finishReason" property.');const e={finishReason:t.finishReason,isContinued:!1};return"usage"in t&&t.usage!=null&&typeof t.usage=="object"&&"promptTokens"in t.usage&&"completionTokens"in t.usage&&(e.usage={promptTokens:typeof t.usage.promptTokens=="number"?t.usage.promptTokens:Number.NaN,completionTokens:typeof t.usage.completionTokens=="number"?t.usage.completionTokens:Number.NaN}),"isContinued"in t&&typeof t.isContinued=="boolean"&&(e.isContinued=t.isContinued),{type:"finish_step",value:e}}},Lu={code:"f",name:"start_step",parse:t=>{if(t==null||typeof t!="object"||!("messageId"in t)||typeof t.messageId!="string")throw new Error('"start_step" parts expect an object with an "id" property.');return{type:"start_step",value:{messageId:t.messageId}}}},Vu={code:"g",name:"reasoning",parse:t=>{if(typeof t!="string")throw new Error('"reasoning" parts expect a string value.');return{type:"reasoning",value:t}}},Fu={code:"h",name:"source",parse:t=>{if(t==null||typeof t!="object")throw new Error('"source" parts expect a Source object.');return{type:"source",value:t}}},Bu={code:"i",name:"redacted_reasoning",parse:t=>{if(t==null||typeof t!="object"||!("data"in t)||typeof t.data!="string")throw new Error('"redacted_reasoning" parts expect an object with a "data" property.');return{type:"redacted_reasoning",value:{data:t.data}}}},zu={code:"j",name:"reasoning_signature",parse:t=>{if(t==null||typeof t!="object"||!("signature"in t)||typeof t.signature!="string")throw new Error('"reasoning_signature" parts expect an object with a "signature" property.');return{type:"reasoning_signature",value:{signature:t.signature}}}},Kr=[Cu,Ou,Ru,Pu,ju,Nu,Mu,Du,Zu,Uu,Lu,Vu,Fu,Bu,zu];Object.fromEntries(Kr.map(t=>[t.code,t]));Object.fromEntries(Kr.map(t=>[t.name,t.code]));Kr.map(t=>t.code);function si(t,e){const r=Kr.find(n=>n.name===t);if(!r)throw new Error(`Invalid stream part type: ${t}`);return`${r.code}:${JSON.stringify(e)}
183
+ `}function qu(t,e){var r;const n=(r=void 0)!=null?r:!1;return On(Tu(t,{$refStrategy:n?"root":"none",target:"jsonSchema7"}),{validate:s=>{const a=t.safeParse(s);return a.success?{success:!0,value:a.data}:{success:!1,error:a.error}}})}var Cn=Symbol.for("vercel.ai.schema");function On(t,{validate:e}={}){return{[Cn]:!0,_type:void 0,[$r]:!0,jsonSchema:t,validate:e}}function Ju(t){return typeof t=="object"&&t!==null&&Cn in t&&t[Cn]===!0&&"jsonSchema"in t&&"validate"in t}function Rn(t){return Ju(t)?t:qu(t)}var Hu=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},tt="1.9.0",Is=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function Wu(t){var e=new Set([t]),r=new Set,n=t.match(Is);if(!n)return function(){return!1};var s={major:+n[1],minor:+n[2],patch:+n[3],prerelease:n[4]};if(s.prerelease!=null)return function(l){return l===t};function a(o){return r.add(o),!1}function i(o){return e.add(o),!0}return function(l){if(e.has(l))return!0;if(r.has(l))return!1;var c=l.match(Is);if(!c)return a(l);var d={major:+c[1],minor:+c[2],patch:+c[3],prerelease:c[4]};return d.prerelease!=null||s.major!==d.major?a(l):s.major===0?s.minor===d.minor&&s.patch<=d.patch?i(l):a(l):s.minor<=d.minor?i(l):a(l)}}var Yu=Wu(tt),Gu=tt.split(".")[0],ur=Symbol.for("opentelemetry.js.api."+Gu),dr=Hu;function zn(t,e,r,n){var s;n===void 0&&(n=!1);var a=dr[ur]=(s=dr[ur])!==null&&s!==void 0?s:{version:tt};if(!n&&a[t]){var i=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+t);return r.error(i.stack||i.message),!1}if(a.version!==tt){var i=new Error("@opentelemetry/api: Registration of version v"+a.version+" for "+t+" does not match previously registered API v"+tt);return r.error(i.stack||i.message),!1}return a[t]=e,r.debug("@opentelemetry/api: Registered a global for "+t+" v"+tt+"."),!0}function pr(t){var e,r,n=(e=dr[ur])===null||e===void 0?void 0:e.version;if(!(!n||!Yu(n)))return(r=dr[ur])===null||r===void 0?void 0:r[t]}function qn(t,e){e.debug("@opentelemetry/api: Unregistering a global for "+t+" v"+tt+".");var r=dr[ur];r&&delete r[t]}var Ku=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,a=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)a.push(s.value)}catch(o){i={error:o}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return a},Xu=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,a;n<s;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},Qu=function(){function t(e){this._namespace=e.namespace||"DiagComponentLogger"}return t.prototype.debug=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Rt("debug",this._namespace,e)},t.prototype.error=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Rt("error",this._namespace,e)},t.prototype.info=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Rt("info",this._namespace,e)},t.prototype.warn=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Rt("warn",this._namespace,e)},t.prototype.verbose=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return Rt("verbose",this._namespace,e)},t}();function Rt(t,e,r){var n=pr("diag");if(n)return r.unshift(e),n[t].apply(n,Xu([],Ku(r),!1))}var ke;(function(t){t[t.NONE=0]="NONE",t[t.ERROR=30]="ERROR",t[t.WARN=50]="WARN",t[t.INFO=60]="INFO",t[t.DEBUG=70]="DEBUG",t[t.VERBOSE=80]="VERBOSE",t[t.ALL=9999]="ALL"})(ke||(ke={}));function ed(t,e){t<ke.NONE?t=ke.NONE:t>ke.ALL&&(t=ke.ALL),e=e||{};function r(n,s){var a=e[n];return typeof a=="function"&&t>=s?a.bind(e):function(){}}return{error:r("error",ke.ERROR),warn:r("warn",ke.WARN),info:r("info",ke.INFO),debug:r("debug",ke.DEBUG),verbose:r("verbose",ke.VERBOSE)}}var td=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,a=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)a.push(s.value)}catch(o){i={error:o}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return a},rd=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,a;n<s;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},nd="diag",Ur=function(){function t(){function e(s){return function(){for(var a=[],i=0;i<arguments.length;i++)a[i]=arguments[i];var o=pr("diag");if(o)return o[s].apply(o,rd([],td(a),!1))}}var r=this,n=function(s,a){var i,o,l;if(a===void 0&&(a={logLevel:ke.INFO}),s===r){var c=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((i=c.stack)!==null&&i!==void 0?i:c.message),!1}typeof a=="number"&&(a={logLevel:a});var d=pr("diag"),p=ed((o=a.logLevel)!==null&&o!==void 0?o:ke.INFO,s);if(d&&!a.suppressOverrideMessage){var g=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";d.warn("Current logger will be overwritten from "+g),p.warn("Current logger will overwrite one already registered from "+g)}return zn("diag",p,r,!0)};r.setLogger=n,r.disable=function(){qn(nd,r)},r.createComponentLogger=function(s){return new Qu(s)},r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}return t.instance=function(){return this._instance||(this._instance=new t),this._instance},t}();function sd(t){return Symbol.for(t)}var ad=function(){function t(e){var r=this;r._currentContext=e?new Map(e):new Map,r.getValue=function(n){return r._currentContext.get(n)},r.setValue=function(n,s){var a=new t(r._currentContext);return a._currentContext.set(n,s),a},r.deleteValue=function(n){var s=new t(r._currentContext);return s._currentContext.delete(n),s}}return t}(),id=new ad,od=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,a=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)a.push(s.value)}catch(o){i={error:o}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return a},ld=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,a;n<s;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},cd=function(){function t(){}return t.prototype.active=function(){return id},t.prototype.with=function(e,r,n){for(var s=[],a=3;a<arguments.length;a++)s[a-3]=arguments[a];return r.call.apply(r,ld([n],od(s),!1))},t.prototype.bind=function(e,r){return r},t.prototype.enable=function(){return this},t.prototype.disable=function(){return this},t}(),ud=function(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),s,a=[],i;try{for(;(e===void 0||e-- >0)&&!(s=n.next()).done;)a.push(s.value)}catch(o){i={error:o}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(i)throw i.error}}return a},dd=function(t,e,r){if(r||arguments.length===2)for(var n=0,s=e.length,a;n<s;n++)(a||!(n in e))&&(a||(a=Array.prototype.slice.call(e,0,n)),a[n]=e[n]);return t.concat(a||Array.prototype.slice.call(e))},un="context",pd=new cd,ai=function(){function t(){}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalContextManager=function(e){return zn(un,e,Ur.instance())},t.prototype.active=function(){return this._getContextManager().active()},t.prototype.with=function(e,r,n){for(var s,a=[],i=3;i<arguments.length;i++)a[i-3]=arguments[i];return(s=this._getContextManager()).with.apply(s,dd([e,r,n],ud(a),!1))},t.prototype.bind=function(e,r){return this._getContextManager().bind(e,r)},t.prototype._getContextManager=function(){return pr(un)||pd},t.prototype.disable=function(){this._getContextManager().disable(),qn(un,Ur.instance())},t}(),Pn;(function(t){t[t.NONE=0]="NONE",t[t.SAMPLED=1]="SAMPLED"})(Pn||(Pn={}));var ii="0000000000000000",oi="00000000000000000000000000000000",hd={traceId:oi,spanId:ii,traceFlags:Pn.NONE},Dt=function(){function t(e){e===void 0&&(e=hd),this._spanContext=e}return t.prototype.spanContext=function(){return this._spanContext},t.prototype.setAttribute=function(e,r){return this},t.prototype.setAttributes=function(e){return this},t.prototype.addEvent=function(e,r){return this},t.prototype.addLink=function(e){return this},t.prototype.addLinks=function(e){return this},t.prototype.setStatus=function(e){return this},t.prototype.updateName=function(e){return this},t.prototype.end=function(e){},t.prototype.isRecording=function(){return!1},t.prototype.recordException=function(e,r){},t}(),Jn=sd("OpenTelemetry Context Key SPAN");function Hn(t){return t.getValue(Jn)||void 0}function fd(){return Hn(ai.getInstance().active())}function Wn(t,e){return t.setValue(Jn,e)}function md(t){return t.deleteValue(Jn)}function gd(t,e){return Wn(t,new Dt(e))}function li(t){var e;return(e=Hn(t))===null||e===void 0?void 0:e.spanContext()}var yd=/^([0-9a-f]{32})$/i,vd=/^[0-9a-f]{16}$/i;function _d(t){return yd.test(t)&&t!==oi}function bd(t){return vd.test(t)&&t!==ii}function ci(t){return _d(t.traceId)&&bd(t.spanId)}function wd(t){return new Dt(t)}var dn=ai.getInstance(),ui=function(){function t(){}return t.prototype.startSpan=function(e,r,n){n===void 0&&(n=dn.active());var s=!!(r!=null&&r.root);if(s)return new Dt;var a=n&&li(n);return xd(a)&&ci(a)?new Dt(a):new Dt},t.prototype.startActiveSpan=function(e,r,n,s){var a,i,o;if(!(arguments.length<2)){arguments.length===2?o=r:arguments.length===3?(a=r,o=n):(a=r,i=n,o=s);var l=i??dn.active(),c=this.startSpan(e,a,l),d=Wn(l,c);return dn.with(d,o,void 0,c)}},t}();function xd(t){return typeof t=="object"&&typeof t.spanId=="string"&&typeof t.traceId=="string"&&typeof t.traceFlags=="number"}var kd=new ui,Sd=function(){function t(e,r,n,s){this._provider=e,this.name=r,this.version=n,this.options=s}return t.prototype.startSpan=function(e,r,n){return this._getTracer().startSpan(e,r,n)},t.prototype.startActiveSpan=function(e,r,n,s){var a=this._getTracer();return Reflect.apply(a.startActiveSpan,a,arguments)},t.prototype._getTracer=function(){if(this._delegate)return this._delegate;var e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):kd},t}(),Ad=function(){function t(){}return t.prototype.getTracer=function(e,r,n){return new ui},t}(),Td=new Ad,Cs=function(){function t(){}return t.prototype.getTracer=function(e,r,n){var s;return(s=this.getDelegateTracer(e,r,n))!==null&&s!==void 0?s:new Sd(this,e,r,n)},t.prototype.getDelegate=function(){var e;return(e=this._delegate)!==null&&e!==void 0?e:Td},t.prototype.setDelegate=function(e){this._delegate=e},t.prototype.getDelegateTracer=function(e,r,n){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(e,r,n)},t}(),Lr;(function(t){t[t.UNSET=0]="UNSET",t[t.OK=1]="OK",t[t.ERROR=2]="ERROR"})(Lr||(Lr={}));var pn="trace",Ed=function(){function t(){this._proxyTracerProvider=new Cs,this.wrapSpanContext=wd,this.isSpanContextValid=ci,this.deleteSpan=md,this.getSpan=Hn,this.getActiveSpan=fd,this.getSpanContext=li,this.setSpan=Wn,this.setSpanContext=gd}return t.getInstance=function(){return this._instance||(this._instance=new t),this._instance},t.prototype.setGlobalTracerProvider=function(e){var r=zn(pn,this._proxyTracerProvider,Ur.instance());return r&&this._proxyTracerProvider.setDelegate(e),r},t.prototype.getTracerProvider=function(){return pr(pn)||this._proxyTracerProvider},t.prototype.getTracer=function(e,r){return this.getTracerProvider().getTracer(e,r)},t.prototype.disable=function(){qn(pn,Ur.instance()),this._proxyTracerProvider=new Cs},t}(),$d=Ed.getInstance(),Id=Object.defineProperty,Yn=(t,e)=>{for(var r in e)Id(t,r,{get:e[r],enumerable:!0})};function Gn(t,{contentType:e,dataStreamVersion:r}){const n=new Headers(t??{});return n.has("Content-Type")||n.set("Content-Type",e),r!==void 0&&n.set("X-Vercel-AI-Data-Stream",r),n}var di="AI_InvalidArgumentError",pi=`vercel.ai.error.${di}`,Cd=Symbol.for(pi),hi,Y=class extends Z{constructor({parameter:t,value:e,message:r}){super({name:di,message:`Invalid argument for parameter ${t}: ${r}`}),this[hi]=!0,this.parameter=t,this.value=e}static isInstance(t){return Z.hasMarker(t,pi)}};hi=Cd;var fi="AI_RetryError",mi=`vercel.ai.error.${fi}`,Od=Symbol.for(mi),gi,Os=class extends Z{constructor({message:t,reason:e,errors:r}){super({name:fi,message:t}),this[gi]=!0,this.reason=e,this.errors=r,this.lastError=r[r.length-1]}static isInstance(t){return Z.hasMarker(t,mi)}};gi=Od;var Rd=({maxRetries:t=2,initialDelayInMs:e=2e3,backoffFactor:r=2}={})=>async n=>yi(n,{maxRetries:t,delayInMs:e,backoffFactor:r});async function yi(t,{maxRetries:e,delayInMs:r,backoffFactor:n},s=[]){try{return await t()}catch(a){if(xr(a)||e===0)throw a;const i=rl(a),o=[...s,a],l=o.length;if(l>e)throw new Os({message:`Failed after ${l} attempts. Last error: ${i}`,reason:"maxRetriesExceeded",errors:o});if(a instanceof Error&&Me.isInstance(a)&&a.isRetryable===!0&&l<=e)return await tl(r),yi(t,{maxRetries:e,delayInMs:n*r,backoffFactor:n},o);throw l===1?a:new Os({message:`Failed after ${l} attempts with non-retryable error: '${i}'`,reason:"errorNotRetryable",errors:o})}}function Pd({maxRetries:t}){if(t!=null){if(!Number.isInteger(t))throw new Y({parameter:"maxRetries",value:t,message:"maxRetries must be an integer"});if(t<0)throw new Y({parameter:"maxRetries",value:t,message:"maxRetries must be >= 0"})}const e=t??2;return{maxRetries:e,retry:Rd({maxRetries:e})}}function hn({operationId:t,telemetry:e}){return{"operation.name":`${t}${(e==null?void 0:e.functionId)!=null?` ${e.functionId}`:""}`,"resource.name":e==null?void 0:e.functionId,"ai.operationId":t,"ai.telemetry.functionId":e==null?void 0:e.functionId}}function jd({model:t,settings:e,telemetry:r,headers:n}){var s;return{"ai.model.provider":t.provider,"ai.model.id":t.modelId,...Object.entries(e).reduce((a,[i,o])=>(a[`ai.settings.${i}`]=o,a),{}),...Object.entries((s=r==null?void 0:r.metadata)!=null?s:{}).reduce((a,[i,o])=>(a[`ai.telemetry.metadata.${i}`]=o,a),{}),...Object.entries(n??{}).reduce((a,[i,o])=>(o!==void 0&&(a[`ai.request.headers.${i}`]=o),a),{})}}var Nd={startSpan(){return br},startActiveSpan(t,e,r,n){if(typeof e=="function")return e(br);if(typeof r=="function")return r(br);if(typeof n=="function")return n(br)}},br={spanContext(){return Md},setAttribute(){return this},setAttributes(){return this},addEvent(){return this},addLink(){return this},addLinks(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording(){return!1},recordException(){return this}},Md={traceId:"",spanId:"",traceFlags:0};function Dd({isEnabled:t=!1,tracer:e}={}){return t?e||$d.getTracer("ai"):Nd}function fn({name:t,tracer:e,attributes:r,fn:n,endWhenDone:s=!0}){return e.startActiveSpan(t,{attributes:r},async a=>{try{const i=await n(a);return s&&a.end(),i}catch(i){try{i instanceof Error?(a.recordException({name:i.name,message:i.message,stack:i.stack}),a.setStatus({code:Lr.ERROR,message:i.message})):a.setStatus({code:Lr.ERROR})}finally{a.end()}throw i}})}function ht({telemetry:t,attributes:e}){return(t==null?void 0:t.isEnabled)!==!0?{}:Object.entries(e).reduce((r,[n,s])=>{if(s===void 0)return r;if(typeof s=="object"&&"input"in s&&typeof s.input=="function"){if((t==null?void 0:t.recordInputs)===!1)return r;const a=s.input();return a===void 0?r:{...r,[n]:a}}if(typeof s=="object"&&"output"in s&&typeof s.output=="function"){if((t==null?void 0:t.recordOutputs)===!1)return r;const a=s.output();return a===void 0?r:{...r,[n]:a}}return{...r,[n]:s}},{})}var vi="AI_NoObjectGeneratedError",_i=`vercel.ai.error.${vi}`,Zd=Symbol.for(_i),bi,qe=class extends Z{constructor({message:t="No object generated.",cause:e,text:r,response:n,usage:s}){super({name:vi,message:t,cause:e}),this[bi]=!0,this.text=r,this.response=n,this.usage=s}static isInstance(t){return Z.hasMarker(t,_i)}};bi=Zd;var wi="AI_DownloadError",xi=`vercel.ai.error.${wi}`,Ud=Symbol.for(xi),ki,mn=class extends Z{constructor({url:t,statusCode:e,statusText:r,cause:n,message:s=n==null?`Failed to download ${t}: ${e} ${r}`:`Failed to download ${t}: ${n}`}){super({name:wi,message:s,cause:n}),this[ki]=!0,this.url=t,this.statusCode=e,this.statusText=r}static isInstance(t){return Z.hasMarker(t,xi)}};ki=Ud;async function Ld({url:t,fetchImplementation:e=fetch}){var r;const n=t.toString();try{const s=await e(n);if(!s.ok)throw new mn({url:n,statusCode:s.status,statusText:s.statusText});return{data:new Uint8Array(await s.arrayBuffer()),mimeType:(r=s.headers.get("content-type"))!=null?r:void 0}}catch(s){throw mn.isInstance(s)?s:new mn({url:n,cause:s})}}var Vd=[{mimeType:"image/gif",bytes:[71,73,70]},{mimeType:"image/png",bytes:[137,80,78,71]},{mimeType:"image/jpeg",bytes:[255,216]},{mimeType:"image/webp",bytes:[82,73,70,70]}];function Fd(t){for(const{bytes:e,mimeType:r}of Vd)if(t.length>=e.length&&e.every((n,s)=>t[s]===n))return r}var Si="AI_InvalidDataContentError",Ai=`vercel.ai.error.${Si}`,Bd=Symbol.for(Ai),Ti,Rs=class extends Z{constructor({content:t,cause:e,message:r=`Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof t}.`}){super({name:Si,message:r,cause:e}),this[Ti]=!0,this.content=t}static isInstance(t){return Z.hasMarker(t,Ai)}};Ti=Bd;var Ei=u.union([u.string(),u.instanceof(Uint8Array),u.instanceof(ArrayBuffer),u.custom(t=>{var e,r;return(r=(e=globalThis.Buffer)==null?void 0:e.isBuffer(t))!=null?r:!1},{message:"Must be a Buffer"})]);function zd(t){return typeof t=="string"?t:t instanceof ArrayBuffer?Sn(new Uint8Array(t)):Sn(t)}function Vr(t){if(t instanceof Uint8Array)return t;if(typeof t=="string")try{return gl(t)}catch(e){throw new Rs({message:"Invalid data content. Content string is not a base64-encoded media.",content:t,cause:e})}if(t instanceof ArrayBuffer)return new Uint8Array(t);throw new Rs({content:t})}function qd(t){try{return new TextDecoder().decode(t)}catch{throw new Error("Error decoding Uint8Array to text")}}var $i="AI_InvalidMessageRoleError",Ii=`vercel.ai.error.${$i}`,Jd=Symbol.for(Ii),Ci,Hd=class extends Z{constructor({role:t,message:e=`Invalid message role: '${t}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:$i,message:e}),this[Ci]=!0,this.role=t}static isInstance(t){return Z.hasMarker(t,Ii)}};Ci=Jd;function Wd(t){try{const[e,r]=t.split(",");return{mimeType:e.split(";")[0].split(":")[1],base64Content:r}}catch{return{mimeType:void 0,base64Content:void 0}}}async function Ps({prompt:t,modelSupportsImageUrls:e=!0,modelSupportsUrl:r=()=>!1,downloadImplementation:n=Ld}){const s=await Gd(t.messages,n,e,r);return[...t.system!=null?[{role:"system",content:t.system}]:[],...t.messages.map(a=>Yd(a,s))]}function Yd(t,e){var r,n,s,a,i,o;const l=t.role;switch(l){case"system":return{role:"system",content:t.content,providerMetadata:(r=t.providerOptions)!=null?r:t.experimental_providerMetadata};case"user":return typeof t.content=="string"?{role:"user",content:[{type:"text",text:t.content}],providerMetadata:(n=t.providerOptions)!=null?n:t.experimental_providerMetadata}:{role:"user",content:t.content.map(c=>Kd(c,e)).filter(c=>c.type!=="text"||c.text!==""),providerMetadata:(s=t.providerOptions)!=null?s:t.experimental_providerMetadata};case"assistant":return typeof t.content=="string"?{role:"assistant",content:[{type:"text",text:t.content}],providerMetadata:(a=t.providerOptions)!=null?a:t.experimental_providerMetadata}:{role:"assistant",content:t.content.filter(c=>c.type!=="text"||c.text!=="").map(c=>{const{experimental_providerMetadata:d,providerOptions:p,...g}=c;return{...g,providerMetadata:p??d}}),providerMetadata:(i=t.providerOptions)!=null?i:t.experimental_providerMetadata};case"tool":return{role:"tool",content:t.content.map(c=>{var d;return{type:"tool-result",toolCallId:c.toolCallId,toolName:c.toolName,result:c.result,content:c.experimental_content,isError:c.isError,providerMetadata:(d=c.providerOptions)!=null?d:c.experimental_providerMetadata}}),providerMetadata:(o=t.providerOptions)!=null?o:t.experimental_providerMetadata};default:{const c=l;throw new Hd({role:c})}}}async function Gd(t,e,r,n){const s=t.filter(i=>i.role==="user").map(i=>i.content).filter(i=>Array.isArray(i)).flat().filter(i=>i.type==="image"||i.type==="file").filter(i=>!(i.type==="image"&&r===!0)).map(i=>i.type==="image"?i.image:i.data).map(i=>typeof i=="string"&&(i.startsWith("http:")||i.startsWith("https:"))?new URL(i):i).filter(i=>i instanceof URL).filter(i=>!n(i)),a=await Promise.all(s.map(async i=>({url:i,data:await e({url:i})})));return Object.fromEntries(a.map(({url:i,data:o})=>[i.toString(),o]))}function Kd(t,e){var r,n,s,a;if(t.type==="text")return{type:"text",text:t.text,providerMetadata:(r=t.providerOptions)!=null?r:t.experimental_providerMetadata};let i=t.mimeType,o,l,c;const d=t.type;switch(d){case"image":o=t.image;break;case"file":o=t.data;break;default:throw new Error(`Unsupported part type: ${d}`)}try{l=typeof o=="string"?new URL(o):o}catch{l=o}if(l instanceof URL)if(l.protocol==="data:"){const{mimeType:p,base64Content:g}=Wd(l.toString());if(p==null||g==null)throw new Error(`Invalid data URL format in part ${d}`);i=p,c=Vr(g)}else{const p=e[l.toString()];p?(c=p.data,i??(i=p.mimeType)):c=l}else c=Vr(l);switch(d){case"image":return c instanceof Uint8Array&&(i=(n=Fd(c))!=null?n:i),{type:"image",image:c,mimeType:i,providerMetadata:(s=t.providerOptions)!=null?s:t.experimental_providerMetadata};case"file":{if(i==null)throw new Error("Mime type is missing for file part");return{type:"file",data:c instanceof Uint8Array?zd(c):c,mimeType:i,providerMetadata:(a=t.providerOptions)!=null?a:t.experimental_providerMetadata}}}}function js({maxTokens:t,temperature:e,topP:r,topK:n,presencePenalty:s,frequencyPenalty:a,stopSequences:i,seed:o}){if(t!=null){if(!Number.isInteger(t))throw new Y({parameter:"maxTokens",value:t,message:"maxTokens must be an integer"});if(t<1)throw new Y({parameter:"maxTokens",value:t,message:"maxTokens must be >= 1"})}if(e!=null&&typeof e!="number")throw new Y({parameter:"temperature",value:e,message:"temperature must be a number"});if(r!=null&&typeof r!="number")throw new Y({parameter:"topP",value:r,message:"topP must be a number"});if(n!=null&&typeof n!="number")throw new Y({parameter:"topK",value:n,message:"topK must be a number"});if(s!=null&&typeof s!="number")throw new Y({parameter:"presencePenalty",value:s,message:"presencePenalty must be a number"});if(a!=null&&typeof a!="number")throw new Y({parameter:"frequencyPenalty",value:a,message:"frequencyPenalty must be a number"});if(o!=null&&!Number.isInteger(o))throw new Y({parameter:"seed",value:o,message:"seed must be an integer"});return{maxTokens:t,temperature:e??0,topP:r,topK:n,presencePenalty:s,frequencyPenalty:a,stopSequences:i!=null&&i.length>0?i:void 0,seed:o}}function Xd(t){var e,r,n;const s=[];for(const a of t){let i;try{i=new URL(a.url)}catch{throw new Error(`Invalid URL: ${a.url}`)}switch(i.protocol){case"http:":case"https:":{if((e=a.contentType)!=null&&e.startsWith("image/"))s.push({type:"image",image:i});else{if(!a.contentType)throw new Error("If the attachment is not an image, it must specify a content type");s.push({type:"file",data:i,mimeType:a.contentType})}break}case"data:":{let o,l,c;try{[o,l]=a.url.split(","),c=o.split(";")[0].split(":")[1]}catch{throw new Error(`Error processing data URL: ${a.url}`)}if(c==null||l==null)throw new Error(`Invalid data URL format: ${a.url}`);if((r=a.contentType)!=null&&r.startsWith("image/"))s.push({type:"image",image:Vr(l)});else if((n=a.contentType)!=null&&n.startsWith("text/"))s.push({type:"text",text:qd(Vr(l))});else{if(!a.contentType)throw new Error("If the attachment is not an image or text, it must specify a content type");s.push({type:"file",data:l,mimeType:a.contentType})}break}default:throw new Error(`Unsupported URL protocol: ${i.protocol}`)}}return s}var Oi="AI_MessageConversionError",Ri=`vercel.ai.error.${Oi}`,Qd=Symbol.for(Ri),Pi,gn=class extends Z{constructor({originalMessage:t,message:e}){super({name:Oi,message:e}),this[Pi]=!0,this.originalMessage=t}static isInstance(t){return Z.hasMarker(t,Ri)}};Pi=Qd;function ep(t,e){var r,n;const s=(r=e==null?void 0:e.tools)!=null?r:{},a=[];for(let i=0;i<t.length;i++){const o=t[i],l=i===t.length-1,{role:c,content:d,experimental_attachments:p}=o;switch(c){case"system":{a.push({role:"system",content:d});break}case"user":{a.push({role:"user",content:p?[{type:"text",text:d},...Xd(p)]:d});break}case"assistant":{if(o.parts!=null){let _=function(){const E=[];for(const j of k)switch(j.type){case"text":E.push({type:"text",text:j.text});break;case"reasoning":{for(const C of j.details)switch(C.type){case"text":E.push({type:"reasoning",text:C.text,signature:C.signature});break;case"redacted":E.push({type:"redacted-reasoning",data:C.data});break}break}case"tool-invocation":E.push({type:"tool-call",toolCallId:j.toolInvocation.toolCallId,toolName:j.toolInvocation.toolName,args:j.toolInvocation.args});break;default:{const C=j;throw new Error(`Unsupported part: ${C}`)}}a.push({role:"assistant",content:E});const I=k.filter(j=>j.type==="tool-invocation").map(j=>j.toolInvocation);I.length>0&&a.push({role:"tool",content:I.map(j=>{if(!("result"in j))throw new gn({originalMessage:o,message:"ToolInvocation must have a result: "+JSON.stringify(j)});const{toolCallId:C,toolName:ee,result:M}=j,le=s[ee];return(le==null?void 0:le.experimental_toToolResultContent)!=null?{type:"tool-result",toolCallId:C,toolName:ee,result:le.experimental_toToolResultContent(M),experimental_content:le.experimental_toToolResultContent(M)}:{type:"tool-result",toolCallId:C,toolName:ee,result:M}})}),k=[],v=!1,h++},h=0,v=!1,k=[];for(const E of o.parts)switch(E.type){case"reasoning":k.push(E);break;case"text":{v&&_(),k.push(E);break}case"tool-invocation":{((n=E.toolInvocation.step)!=null?n:0)!==h&&_(),k.push(E),v=!0;break}}_();break}const g=o.toolInvocations;if(g==null||g.length===0){a.push({role:"assistant",content:d});break}const S=g.reduce((_,h)=>{var v;return Math.max(_,(v=h.step)!=null?v:0)},0);for(let _=0;_<=S;_++){const h=g.filter(v=>{var k;return((k=v.step)!=null?k:0)===_});h.length!==0&&(a.push({role:"assistant",content:[...l&&d&&_===0?[{type:"text",text:d}]:[],...h.map(({toolCallId:v,toolName:k,args:E})=>({type:"tool-call",toolCallId:v,toolName:k,args:E}))]}),a.push({role:"tool",content:h.map(v=>{if(!("result"in v))throw new gn({originalMessage:o,message:"ToolInvocation must have a result: "+JSON.stringify(v)});const{toolCallId:k,toolName:E,result:I}=v,j=s[E];return(j==null?void 0:j.experimental_toToolResultContent)!=null?{type:"tool-result",toolCallId:k,toolName:E,result:j.experimental_toToolResultContent(I),experimental_content:j.experimental_toToolResultContent(I)}:{type:"tool-result",toolCallId:k,toolName:E,result:I}})}))}d&&!l&&a.push({role:"assistant",content:d});break}case"data":break;default:{const g=c;throw new gn({originalMessage:o,message:`Unsupported role: ${g}`})}}}return a}function tp(t){if(!Array.isArray(t))return"other";if(t.length===0)return"messages";const e=t.map(rp);return e.some(r=>r==="has-ui-specific-parts")?"ui-messages":e.every(r=>r==="has-core-specific-parts"||r==="message")?"messages":"other"}function rp(t){return typeof t=="object"&&t!==null&&(t.role==="function"||t.role==="data"||"toolInvocations"in t||"experimental_attachments"in t)?"has-ui-specific-parts":typeof t=="object"&&t!==null&&"content"in t&&(Array.isArray(t.content)||"experimental_providerMetadata"in t||"providerOptions"in t)?"has-core-specific-parts":typeof t=="object"&&t!==null&&"role"in t&&"content"in t&&typeof t.content=="string"&&["system","user","assistant","tool"].includes(t.role)?"message":"other"}var jn=u.lazy(()=>u.union([u.null(),u.string(),u.number(),u.boolean(),u.record(u.string(),jn),u.array(jn)])),te=u.record(u.string(),u.record(u.string(),jn)),np=u.array(u.union([u.object({type:u.literal("text"),text:u.string()}),u.object({type:u.literal("image"),data:u.string(),mimeType:u.string().optional()})])),ji=u.object({type:u.literal("text"),text:u.string(),providerOptions:te.optional(),experimental_providerMetadata:te.optional()}),sp=u.object({type:u.literal("image"),image:u.union([Ei,u.instanceof(URL)]),mimeType:u.string().optional(),providerOptions:te.optional(),experimental_providerMetadata:te.optional()}),ap=u.object({type:u.literal("file"),data:u.union([Ei,u.instanceof(URL)]),mimeType:u.string(),providerOptions:te.optional(),experimental_providerMetadata:te.optional()}),ip=u.object({type:u.literal("reasoning"),text:u.string(),providerOptions:te.optional(),experimental_providerMetadata:te.optional()}),op=u.object({type:u.literal("redacted-reasoning"),data:u.string(),providerOptions:te.optional(),experimental_providerMetadata:te.optional()}),lp=u.object({type:u.literal("tool-call"),toolCallId:u.string(),toolName:u.string(),args:u.unknown(),providerOptions:te.optional(),experimental_providerMetadata:te.optional()}),cp=u.object({type:u.literal("tool-result"),toolCallId:u.string(),toolName:u.string(),result:u.unknown(),content:np.optional(),isError:u.boolean().optional(),providerOptions:te.optional(),experimental_providerMetadata:te.optional()}),up=u.object({role:u.literal("system"),content:u.string(),providerOptions:te.optional(),experimental_providerMetadata:te.optional()}),dp=u.object({role:u.literal("user"),content:u.union([u.string(),u.array(u.union([ji,sp,ap]))]),providerOptions:te.optional(),experimental_providerMetadata:te.optional()}),pp=u.object({role:u.literal("assistant"),content:u.union([u.string(),u.array(u.union([ji,ip,op,lp]))]),providerOptions:te.optional(),experimental_providerMetadata:te.optional()}),hp=u.object({role:u.literal("tool"),content:u.array(cp),providerOptions:te.optional(),experimental_providerMetadata:te.optional()}),fp=u.union([up,dp,pp,hp]);function Ns({prompt:t,tools:e}){if(t.prompt==null&&t.messages==null)throw new Qe({prompt:t,message:"prompt or messages must be defined"});if(t.prompt!=null&&t.messages!=null)throw new Qe({prompt:t,message:"prompt and messages cannot be defined at the same time"});if(t.system!=null&&typeof t.system!="string")throw new Qe({prompt:t,message:"system must be a string"});if(t.prompt!=null){if(typeof t.prompt!="string")throw new Qe({prompt:t,message:"prompt must be a string"});return{type:"prompt",system:t.system,messages:[{role:"user",content:t.prompt}]}}if(t.messages!=null){const r=tp(t.messages);if(r==="other")throw new Qe({prompt:t,message:"messages must be an array of CoreMessage or UIMessage"});const n=r==="ui-messages"?ep(t.messages,{tools:e}):t.messages,s=at({value:n,schema:u.array(fp)});if(!s.success)throw new Qe({prompt:t,message:"messages must be an array of CoreMessage or UIMessage",cause:s.error});return{type:"messages",messages:n,system:t.system}}throw new Error("unreachable")}function ft({promptTokens:t,completionTokens:e}){return{promptTokens:t,completionTokens:e,totalTokens:t+e}}var mp="JSON schema:",gp="You MUST answer with a JSON object that matches the JSON schema above.",yp="You MUST answer with JSON.";function Nn({prompt:t,schema:e,schemaPrefix:r=e!=null?mp:void 0,schemaSuffix:n=e!=null?gp:yp}){return[t!=null&&t.length>0?t:void 0,t!=null&&t.length>0?"":void 0,r,e!=null?JSON.stringify(e):void 0,n].filter(s=>s!=null).join(`
184
+ `)}function vp(t){const e=t.pipeThrough(new TransformStream);return e[Symbol.asyncIterator]=()=>{const r=e.getReader();return{async next(){const{done:n,value:s}=await r.read();return n?{done:!0,value:void 0}:{done:!1,value:s}}}},e}var _p={type:"no-schema",jsonSchema:void 0,validatePartialResult({value:t,textDelta:e}){return{success:!0,value:{partial:t,textDelta:e}}},validateFinalResult(t,e){return t===void 0?{success:!1,error:new qe({message:"No object generated: response did not match schema.",text:e.text,response:e.response,usage:e.usage})}:{success:!0,value:t}},createElementStream(){throw new oe({functionality:"element streams in no-schema mode"})}},bp=t=>({type:"object",jsonSchema:t.jsonSchema,validatePartialResult({value:e,textDelta:r}){return{success:!0,value:{partial:e,textDelta:r}}},validateFinalResult(e){return at({value:e,schema:t})},createElementStream(){throw new oe({functionality:"element streams in object mode"})}}),wp=t=>{const{$schema:e,...r}=t.jsonSchema;return{type:"enum",jsonSchema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{elements:{type:"array",items:r}},required:["elements"],additionalProperties:!1},validatePartialResult({value:n,latestObject:s,isFirstDelta:a,isFinalDelta:i}){var o;if(!kn(n)||!gs(n.elements))return{success:!1,error:new Ve({value:n,cause:"value must be an object that contains an array of elements"})};const l=n.elements,c=[];for(let g=0;g<l.length;g++){const S=l[g],_=at({value:S,schema:t});if(!(g===l.length-1&&!i)){if(!_.success)return _;c.push(_.value)}}const d=(o=s==null?void 0:s.length)!=null?o:0;let p="";return a&&(p+="["),d>0&&(p+=","),p+=c.slice(d).map(g=>JSON.stringify(g)).join(","),i&&(p+="]"),{success:!0,value:{partial:c,textDelta:p}}},validateFinalResult(n){if(!kn(n)||!gs(n.elements))return{success:!1,error:new Ve({value:n,cause:"value must be an object that contains an array of elements"})};const s=n.elements;for(const a of s){const i=at({value:a,schema:t});if(!i.success)return i}return{success:!0,value:s}},createElementStream(n){let s=0;return vp(n.pipeThrough(new TransformStream({transform(a,i){switch(a.type){case"object":{const o=a.object;for(;s<o.length;s++)i.enqueue(o[s]);break}case"text-delta":case"finish":case"error":break;default:{const o=a;throw new Error(`Unsupported chunk type: ${o}`)}}}})))}}},xp=t=>({type:"enum",jsonSchema:{$schema:"http://json-schema.org/draft-07/schema#",type:"object",properties:{result:{type:"string",enum:t}},required:["result"],additionalProperties:!1},validateFinalResult(e){if(!kn(e)||typeof e.result!="string")return{success:!1,error:new Ve({value:e,cause:'value must be an object that contains a string in the "result" property.'})};const r=e.result;return t.includes(r)?{success:!0,value:r}:{success:!1,error:new Ve({value:e,cause:"value must be a string in the enum"})}},validatePartialResult(){throw new oe({functionality:"partial results in enum mode"})},createElementStream(){throw new oe({functionality:"element streams in enum mode"})}});function kp({output:t,schema:e,enumValues:r}){switch(t){case"object":return bp(Rn(e));case"array":return wp(Rn(e));case"enum":return xp(r);case"no-schema":return _p;default:{const n=t;throw new Error(`Unsupported output: ${n}`)}}}function Sp({output:t,mode:e,schema:r,schemaName:n,schemaDescription:s,enumValues:a}){if(t!=null&&t!=="object"&&t!=="array"&&t!=="enum"&&t!=="no-schema")throw new Y({parameter:"output",value:t,message:"Invalid output type."});if(t==="no-schema"){if(e==="auto"||e==="tool")throw new Y({parameter:"mode",value:e,message:'Mode must be "json" for no-schema output.'});if(r!=null)throw new Y({parameter:"schema",value:r,message:"Schema is not supported for no-schema output."});if(s!=null)throw new Y({parameter:"schemaDescription",value:s,message:"Schema description is not supported for no-schema output."});if(n!=null)throw new Y({parameter:"schemaName",value:n,message:"Schema name is not supported for no-schema output."});if(a!=null)throw new Y({parameter:"enumValues",value:a,message:"Enum values are not supported for no-schema output."})}if(t==="object"){if(r==null)throw new Y({parameter:"schema",value:r,message:"Schema is required for object output."});if(a!=null)throw new Y({parameter:"enumValues",value:a,message:"Enum values are not supported for object output."})}if(t==="array"){if(r==null)throw new Y({parameter:"schema",value:r,message:"Element schema is required for array output."});if(a!=null)throw new Y({parameter:"enumValues",value:a,message:"Enum values are not supported for array output."})}if(t==="enum"){if(r!=null)throw new Y({parameter:"schema",value:r,message:"Schema is not supported for enum output."});if(s!=null)throw new Y({parameter:"schemaDescription",value:s,message:"Schema description is not supported for enum output."});if(n!=null)throw new Y({parameter:"schemaName",value:n,message:"Schema name is not supported for enum output."});if(a==null)throw new Y({parameter:"enumValues",value:a,message:"Enum values are required for enum output."});for(const i of a)if(typeof i!="string")throw new Y({parameter:"enumValues",value:i,message:"Enum values must be strings."})}}var Ap=ut({prefix:"aiobj",size:24});async function Tp({model:t,enum:e,schema:r,schemaName:n,schemaDescription:s,mode:a,output:i="object",system:o,prompt:l,messages:c,maxRetries:d,abortSignal:p,headers:g,experimental_repairText:S,experimental_telemetry:_,experimental_providerMetadata:h,providerOptions:v=h,_internal:{generateId:k=Ap,currentDate:E=()=>new Date}={},...I}){Sp({output:i,mode:a,schema:r,schemaName:n,schemaDescription:s,enumValues:e});const{maxRetries:j,retry:C}=Pd({maxRetries:d}),ee=kp({output:i,schema:r,enumValues:e});ee.type==="no-schema"&&a===void 0&&(a="json");const M=jd({model:t,telemetry:_,headers:g,settings:{...I,maxRetries:j}}),le=Dd(_);return fn({name:"ai.generateObject",attributes:ht({telemetry:_,attributes:{...hn({operationId:"ai.generateObject",telemetry:_}),...M,"ai.prompt":{input:()=>JSON.stringify({system:o,prompt:l,messages:c})},"ai.schema":ee.jsonSchema!=null?{input:()=>JSON.stringify(ee.jsonSchema)}:void 0,"ai.schema.name":n,"ai.schema.description":s,"ai.settings.output":ee.type,"ai.settings.mode":a}}),tracer:le,fn:async dt=>{var Ne,ce,ge,re;(a==="auto"||a==null)&&(a=t.defaultObjectGenerationMode);let ne,ie,W,Ae,V,F,se,z,Xr;switch(a){case"json":{const ae=Ns({prompt:{system:ee.jsonSchema==null?Nn({prompt:o}):t.supportsStructuredOutputs?o:Nn({prompt:o,schema:ee.jsonSchema}),prompt:l,messages:c},tools:void 0}),ye=await Ps({prompt:ae,modelSupportsImageUrls:t.supportsImageUrls,modelSupportsUrl:(Ne=t.supportsUrl)==null?void 0:Ne.bind(t)}),X=await C(()=>fn({name:"ai.generateObject.doGenerate",attributes:ht({telemetry:_,attributes:{...hn({operationId:"ai.generateObject.doGenerate",telemetry:_}),...M,"ai.prompt.format":{input:()=>ae.type},"ai.prompt.messages":{input:()=>JSON.stringify(ye)},"ai.settings.mode":a,"gen_ai.system":t.provider,"gen_ai.request.model":t.modelId,"gen_ai.request.frequency_penalty":I.frequencyPenalty,"gen_ai.request.max_tokens":I.maxTokens,"gen_ai.request.presence_penalty":I.presencePenalty,"gen_ai.request.temperature":I.temperature,"gen_ai.request.top_k":I.topK,"gen_ai.request.top_p":I.topP}}),tracer:le,fn:async ue=>{var pe,Te,xe,Ee,Et,$t;const G=await t.doGenerate({mode:{type:"object-json",schema:ee.jsonSchema,name:n,description:s},...js(I),inputFormat:ae.type,prompt:ye,providerMetadata:v,abortSignal:p,headers:g}),L={id:(Te=(pe=G.response)==null?void 0:pe.id)!=null?Te:k(),timestamp:(Ee=(xe=G.response)==null?void 0:xe.timestamp)!=null?Ee:E(),modelId:($t=(Et=G.response)==null?void 0:Et.modelId)!=null?$t:t.modelId};if(G.text===void 0)throw new qe({message:"No object generated: the model did not return a response.",response:L,usage:ft(G.usage)});return ue.setAttributes(ht({telemetry:_,attributes:{"ai.response.finishReason":G.finishReason,"ai.response.object":{output:()=>G.text},"ai.response.id":L.id,"ai.response.model":L.modelId,"ai.response.timestamp":L.timestamp.toISOString(),"ai.usage.promptTokens":G.usage.promptTokens,"ai.usage.completionTokens":G.usage.completionTokens,"gen_ai.response.finish_reasons":[G.finishReason],"gen_ai.response.id":L.id,"gen_ai.response.model":L.modelId,"gen_ai.usage.prompt_tokens":G.usage.promptTokens,"gen_ai.usage.completion_tokens":G.usage.completionTokens}})),{...G,objectText:G.text,responseData:L}}}));ne=X.objectText,ie=X.finishReason,W=X.usage,Ae=X.warnings,V=X.rawResponse,z=X.logprobs,Xr=X.providerMetadata,se=(ce=X.request)!=null?ce:{},F=X.responseData;break}case"tool":{const ae=Ns({prompt:{system:o,prompt:l,messages:c},tools:void 0}),ye=await Ps({prompt:ae,modelSupportsImageUrls:t.supportsImageUrls,modelSupportsUrl:(ge=t.supportsUrl)==null?void 0:ge.bind(t)}),X=ae.type,ue=await C(()=>fn({name:"ai.generateObject.doGenerate",attributes:ht({telemetry:_,attributes:{...hn({operationId:"ai.generateObject.doGenerate",telemetry:_}),...M,"ai.prompt.format":{input:()=>X},"ai.prompt.messages":{input:()=>JSON.stringify(ye)},"ai.settings.mode":a,"gen_ai.system":t.provider,"gen_ai.request.model":t.modelId,"gen_ai.request.frequency_penalty":I.frequencyPenalty,"gen_ai.request.max_tokens":I.maxTokens,"gen_ai.request.presence_penalty":I.presencePenalty,"gen_ai.request.temperature":I.temperature,"gen_ai.request.top_k":I.topK,"gen_ai.request.top_p":I.topP}}),tracer:le,fn:async pe=>{var Te,xe,Ee,Et,$t,G,L,w;const y=await t.doGenerate({mode:{type:"object-tool",tool:{type:"function",name:n??"json",description:s??"Respond with a JSON object.",parameters:ee.jsonSchema}},...js(I),inputFormat:X,prompt:ye,providerMetadata:v,abortSignal:p,headers:g}),O=(xe=(Te=y.toolCalls)==null?void 0:Te[0])==null?void 0:xe.args,N={id:(Et=(Ee=y.response)==null?void 0:Ee.id)!=null?Et:k(),timestamp:(G=($t=y.response)==null?void 0:$t.timestamp)!=null?G:E(),modelId:(w=(L=y.response)==null?void 0:L.modelId)!=null?w:t.modelId};if(O===void 0)throw new qe({message:"No object generated: the tool was not called.",response:N,usage:ft(y.usage)});return pe.setAttributes(ht({telemetry:_,attributes:{"ai.response.finishReason":y.finishReason,"ai.response.object":{output:()=>O},"ai.response.id":N.id,"ai.response.model":N.modelId,"ai.response.timestamp":N.timestamp.toISOString(),"ai.usage.promptTokens":y.usage.promptTokens,"ai.usage.completionTokens":y.usage.completionTokens,"gen_ai.response.finish_reasons":[y.finishReason],"gen_ai.response.id":N.id,"gen_ai.response.model":N.modelId,"gen_ai.usage.input_tokens":y.usage.promptTokens,"gen_ai.usage.output_tokens":y.usage.completionTokens}})),{...y,objectText:O,responseData:N}}}));ne=ue.objectText,ie=ue.finishReason,W=ue.usage,Ae=ue.warnings,V=ue.rawResponse,z=ue.logprobs,Xr=ue.providerMetadata,se=(re=ue.request)!=null?re:{},F=ue.responseData;break}case void 0:throw new Error("Model does not have a default object generation mode.");default:{const ae=a;throw new Error(`Unsupported mode: ${ae}`)}}function ts(ae){const ye=wt({text:ae});if(!ye.success)throw new qe({message:"No object generated: could not parse the response.",cause:ye.error,text:ae,response:F,usage:ft(W)});const X=ee.validateFinalResult(ye.value,{text:ae,response:F,usage:ft(W)});if(!X.success)throw new qe({message:"No object generated: response did not match schema.",cause:X.error,text:ae,response:F,usage:ft(W)});return X.value}let mr;try{mr=ts(ne)}catch(ae){if(S!=null&&qe.isInstance(ae)&&(qt.isInstance(ae.cause)||Ve.isInstance(ae.cause))){const ye=await S({text:ne,error:ae.cause});if(ye===null)throw ae;mr=ts(ye)}else throw ae}return dt.setAttributes(ht({telemetry:_,attributes:{"ai.response.finishReason":ie,"ai.response.object":{output:()=>JSON.stringify(mr)},"ai.usage.promptTokens":W.promptTokens,"ai.usage.completionTokens":W.completionTokens}})),new Ep({object:mr,finishReason:ie,usage:ft(W),warnings:Ae,request:se,response:{...F,headers:V==null?void 0:V.headers,body:V==null?void 0:V.body},logprobs:z,providerMetadata:Xr})}})}var Ep=class{constructor(t){this.object=t.object,this.finishReason=t.finishReason,this.usage=t.usage,this.warnings=t.warnings,this.providerMetadata=t.providerMetadata,this.experimental_providerMetadata=t.providerMetadata,this.response=t.response,this.request=t.request,this.logprobs=t.logprobs}toJsonResponse(t){var e;return new Response(JSON.stringify(this.object),{status:(e=t==null?void 0:t.status)!=null?e:200,headers:Gn(t==null?void 0:t.headers,{contentType:"application/json; charset=utf-8"})})}};ut({prefix:"aiobj",size:24});ut({prefix:"aitxt",size:24});ut({prefix:"msg",size:24});var $p={};Yn($p,{object:()=>Cp,text:()=>Ip});var Ip=()=>({type:"text",responseFormat:()=>({type:"text"}),injectIntoSystemPrompt({system:t}){return t},parsePartial({text:t}){return{partial:t}},parseOutput({text:t}){return t}}),Cp=({schema:t})=>{const e=Rn(t);return{type:"object",responseFormat:({model:r})=>({type:"json",schema:r.supportsStructuredOutputs?e.jsonSchema:void 0}),injectIntoSystemPrompt({system:r,model:n}){return n.supportsStructuredOutputs?r:Nn({prompt:r,schema:e.jsonSchema})},parsePartial({text:r}){const n=Iu(r);switch(n.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:n.value};default:{const s=n.state;throw new Error(`Unsupported parse state: ${s}`)}}},parseOutput({text:r},n){const s=wt({text:r});if(!s.success)throw new qe({message:"No object generated: could not parse the response.",cause:s.error,text:r,response:n.response,usage:n.usage});const a=at({value:s.value,schema:e});if(!a.success)throw new qe({message:"No object generated: response did not match schema.",cause:a.error,text:r,response:n.response,usage:n.usage});return a.value}}};function Ni(t,e){const r=t.getReader(),n=e.getReader();let s,a,i=!1,o=!1;async function l(d){try{s==null&&(s=r.read());const p=await s;s=void 0,p.done?d.close():d.enqueue(p.value)}catch(p){d.error(p)}}async function c(d){try{a==null&&(a=n.read());const p=await a;a=void 0,p.done?d.close():d.enqueue(p.value)}catch(p){d.error(p)}}return new ReadableStream({async pull(d){try{if(i){await c(d);return}if(o){await l(d);return}s==null&&(s=r.read()),a==null&&(a=n.read());const{result:p,reader:g}=await Promise.race([s.then(S=>({result:S,reader:r})),a.then(S=>({result:S,reader:n}))]);p.done||d.enqueue(p.value),g===r?(s=void 0,p.done&&(await c(d),i=!0)):(a=void 0,p.done&&(o=!0,await l(d)))}catch(p){d.error(p)}},cancel(){r.cancel(),n.cancel()}})}ut({prefix:"aitxt",size:24});ut({prefix:"msg",size:24});var Op={};Yn(Op,{mergeIntoDataStream:()=>jp,toDataStream:()=>Rp,toDataStreamResponse:()=>Pp});function Mi(t={}){const e=new TextEncoder;let r="";return new TransformStream({async start(){t.onStart&&await t.onStart()},async transform(n,s){s.enqueue(e.encode(n)),r+=n,t.onToken&&await t.onToken(n),t.onText&&typeof n=="string"&&await t.onText(n)},async flush(){t.onCompletion&&await t.onCompletion(r),t.onFinal&&await t.onFinal(r)}})}function Kn(t,e){return t.pipeThrough(new TransformStream({transform:async(r,n)=>{var s;if(typeof r=="string"){n.enqueue(r);return}if("event"in r){r.event==="on_chat_model_stream"&&Ms((s=r.data)==null?void 0:s.chunk,n);return}Ms(r,n)}})).pipeThrough(Mi(e)).pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({transform:async(r,n)=>{n.enqueue(si("text",r))}}))}function Rp(t,e){return Kn(t,e).pipeThrough(new TextEncoderStream)}function Pp(t,e){var r;const n=Kn(t,e==null?void 0:e.callbacks).pipeThrough(new TextEncoderStream),s=e==null?void 0:e.data,a=e==null?void 0:e.init,i=s?Ni(s.stream,n):n;return new Response(i,{status:(r=a==null?void 0:a.status)!=null?r:200,statusText:a==null?void 0:a.statusText,headers:Gn(a==null?void 0:a.headers,{contentType:"text/plain; charset=utf-8",dataStreamVersion:"v1"})})}function jp(t,e){e.dataStream.merge(Kn(t,e.callbacks))}function Ms(t,e){if(typeof t.content=="string")e.enqueue(t.content);else{const r=t.content;for(const n of r)n.type==="text"&&e.enqueue(n.text)}}var Np={};Yn(Np,{mergeIntoDataStream:()=>Zp,toDataStream:()=>Mp,toDataStreamResponse:()=>Dp});function Xn(t,e){const r=Up();return el(t[Symbol.asyncIterator]()).pipeThrough(new TransformStream({async transform(n,s){s.enqueue(r(n.delta))}})).pipeThrough(Mi(e)).pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({transform:async(n,s)=>{s.enqueue(si("text",n))}}))}function Mp(t,e){return Xn(t,e).pipeThrough(new TextEncoderStream)}function Dp(t,e={}){var r;const{init:n,data:s,callbacks:a}=e,i=Xn(t,a).pipeThrough(new TextEncoderStream),o=s?Ni(s.stream,i):i;return new Response(o,{status:(r=n==null?void 0:n.status)!=null?r:200,statusText:n==null?void 0:n.statusText,headers:Gn(n==null?void 0:n.headers,{contentType:"text/plain; charset=utf-8",dataStreamVersion:"v1"})})}function Zp(t,e){e.dataStream.merge(Xn(t,e.callbacks))}function Up(){let t=!0;return e=>(t&&(e=e.trimStart(),e&&(t=!1)),e)}function Lp(t){return t?` In this environment you have access to a set of tools. Here are the functions available in JSONSchema format:
185
+ ${JSON.stringify(t.actions)}
186
+ This is the start data that the tools have provided: ${JSON.stringify(t.data)}
187
+ Choose to respond as text and/or one or more functions to call to respond to the user's query.
188
+ `:void 0}function Vp(t){if(!t)return On({type:"object",properties:{text:{type:"string"}},additionalProperties:!1});const e={type:"object",properties:{text:{type:"string"},tools:{type:"array",items:{anyOf:Object.keys(t.actions).map(r=>{const n=t.actions[r],s={type:"object",properties:{id:{type:"string",enum:[r]}},additionalProperties:!1,required:["id"]};return n.params_schema&&!aa(n.params_schema.properties)&&(s.properties.arguments=n.params_schema,s.properties.arguments.required||(s.properties.arguments.required=Object.keys(s.properties.arguments.properties)),s.properties.arguments.additionalProperties=!1,s.required.push("arguments")),s})},additionalProperties:!1}},additionalProperties:!1};return On(e)}async function Fp(t,e,r){var p;const n=JSON.stringify(e),s=n?`${n}
189
+ ${t}`:t,a=(p=we.get().settings)==null?void 0:p.openAIAPIToken,o=Xa({apiKey:a,compatibility:"strict"})("gpt-4o-mini"),l=Lp(r),c=Vp(r),{object:d}=await Tp({model:o,prompt:s,system:l,schema:c});return d}const Bp={getModelResponse:Fp};var zp=Object.defineProperty,qp=Object.getOwnPropertyDescriptor,Qn=(t,e,r,n)=>{for(var s=n>1?void 0:n?qp(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(s=(n?i(e,r,s):i(s))||s);return n&&s&&zp(e,r,s),s};let Fr=class extends _e{constructor(){super(...arguments),this.openAIAPIToken="",this.promptState="idle"}createRenderRoot(){return this}connectedCallback(){we.subscribe(t=>{var e;this.openAIAPIToken=(e=t.settings)==null?void 0:e.openAIAPIToken}),super.connectedCallback()}async onSubmit(t){t.preventDefault();const r=t.target.elements.namedItem("prompt"),n=r.value.trim();if(!n)return;const s=Ar.getRecentInteractions();this.promptState="thinking",r.value="";const a=await Bp.getModelResponse(n,s,window.applet),i=[];a.text&&i.push({type:"text",content:a.text}),a.tools&&a.tools.length>0&&await Promise.all(a.tools.map(async o=>{await window.applet.sendAction(o.id,o.arguments),i.push({type:o.id,arguments:o.arguments}),window.applet.data&&i.push({type:"data",content:window.applet.data})})),Ar.addInteraction({input:{type:"command",text:n},outputs:i,timestamp:Date.now()}),this.promptState="idle",setTimeout(()=>document.getElementById("prompt").focus())}render(){return J`
190
+ <form @submit="${this.onSubmit}">
191
+ <input
192
+ autocomplete="off"
193
+ id="prompt"
194
+ name="prompt"
195
+ autofocus
196
+ .disabled="${!this.openAIAPIToken||this.promptState==="thinking"}"
197
+ placeholder="${this.openAIAPIToken?this.promptState==="thinking"?"Thinking…":"Start typing to interact…":"Update your OpenAI API key in the settings dialog to interact via the prompt."}"
198
+ />
199
+ ${this.promptState==="thinking"?J`
200
+ <svg
201
+ xmlns="http://www.w3.org/2000/svg"
202
+ width="24"
203
+ height="24"
204
+ viewBox="0 0 24 24"
205
+ fill="none"
206
+ stroke="currentColor"
207
+ stroke-width="1"
208
+ stroke-linecap="round"
209
+ stroke-linejoin="round"
210
+ class="loader"
211
+ >
212
+ <circle cx="12" cy="12" r="9" />
213
+ </svg>
214
+ `:K}
215
+ </form>
216
+ `}};Qn([me({type:String})],Fr.prototype,"openAIAPIToken",2);Qn([me({type:String})],Fr.prototype,"promptState",2);Fr=Qn([je("app-prompt")],Fr);var Jp=Object.defineProperty,Hp=Object.getOwnPropertyDescriptor,Di=(t,e,r,n)=>{for(var s=n>1?void 0:n?Hp(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(s=(n?i(e,r,s):i(s))||s);return n&&s&&Jp(e,r,s),s};let Mn=class extends _e{constructor(){super(...arguments),this.interactions=[]}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.unsubscribe=Ar.subscribe(t=>{this.interactions=[...t]})}disconnectedCallback(){this.unsubscribe&&this.unsubscribe(),super.disconnectedCallback()}render(){const t=e=>Object.entries(e).filter(([r])=>r!=="type").map(([r,n])=>typeof n=="object"&&n!==null?`${r}: ${JSON.stringify(n)}`:`${r}: ${n}`).join(", ");return J`
217
+ <div class="history">
218
+ ${this.interactions.length<=0?J`
219
+ <div class="action-output">
220
+ <span class="status-message">Enter a message below to interact</span>
221
+ </div>
222
+ `:J``}
223
+ ${this.interactions.map(e=>{const r=e.input.type==="command"?J`
224
+ <div class="bubble-container user-bubble-container">
225
+ <div class="bubble user">
226
+ <strong>You:</strong>
227
+ <span>${e.input.text}</span>
228
+ </div>
229
+ </div>
230
+ `:J``,n=e.outputs.filter(s=>s.type!=="data").map(s=>e.input.type==="command"?s.type==="text"?J`
231
+ <div class="bubble-container assistant-bubble-container">
232
+ <div class="bubble assistant">
233
+ <strong>Assistant:</strong>
234
+ <span>${s.content}</span>
235
+ </div>
236
+ </div>
237
+ `:J`
238
+ <div class="action-output">
239
+ <strong>Action: ${s.type}</strong>
240
+ <span>${t(s)}</span>
241
+ </div>
242
+ `:e.input.type==="action"?J`
243
+ <div class="action-output">
244
+ <strong>Action: ${e.input.text}</strong>
245
+ <span>{${t(s)}}</span>
246
+ </div>
247
+ `:J``);return J`${r}${n}`})}
248
+ </div>
249
+ `}};Di([lo()],Mn.prototype,"interactions",2);Mn=Di([je("app-history")],Mn);/**
250
+ * @license
251
+ * Copyright 2020 Google LLC
252
+ * SPDX-License-Identifier: BSD-3-Clause
253
+ */const Wp=t=>t.strings===void 0;/**
254
+ * @license
255
+ * Copyright 2017 Google LLC
256
+ * SPDX-License-Identifier: BSD-3-Clause
257
+ */const Zt=(t,e)=>{var n;const r=t._$AN;if(r===void 0)return!1;for(const s of r)(n=s._$AO)==null||n.call(s,e,!1),Zt(s,e);return!0},Br=t=>{let e,r;do{if((e=t._$AM)===void 0)break;r=e._$AN,r.delete(t),t=e}while((r==null?void 0:r.size)===0)},Zi=t=>{for(let e;e=t._$AM;t=e){let r=e._$AN;if(r===void 0)e._$AN=r=new Set;else if(r.has(t))break;r.add(t),Kp(e)}};function Yp(t){this._$AN!==void 0?(Br(this),this._$AM=t,Zi(this)):this._$AM=t}function Gp(t,e=!1,r=0){const n=this._$AH,s=this._$AN;if(s!==void 0&&s.size!==0)if(e)if(Array.isArray(n))for(let a=r;a<n.length;a++)Zt(n[a],!1),Br(n[a]);else n!=null&&(Zt(n,!1),Br(n));else Zt(this,t)}const Kp=t=>{t.type==Hs.CHILD&&(t._$AP??(t._$AP=Gp),t._$AQ??(t._$AQ=Yp))};class Xp extends Ys{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,r,n){super._$AT(e,r,n),Zi(this),this.isConnected=e._$AU}_$AO(e,r=!0){var n,s;e!==this.isConnected&&(this.isConnected=e,e?(n=this.reconnected)==null||n.call(this):(s=this.disconnected)==null||s.call(this)),r&&(Zt(this,e),Br(this))}setValue(e){if(Wp(this._$Ct))this._$Ct._$AI(e,this);else{const r=[...this._$Ct._$AH];r[this._$Ci]=e,this._$Ct._$AI(r,this,0)}}disconnected(){}reconnected(){}}/**
258
+ * @license
259
+ * Copyright 2020 Google LLC
260
+ * SPDX-License-Identifier: BSD-3-Clause
261
+ */const Ds=()=>new Qp;class Qp{}const yn=new WeakMap,Zs=Ws(class extends Xp{render(t){return K}update(t,[e]){var n;const r=e!==this.Y;return r&&this.Y!==void 0&&this.rt(void 0),(r||this.lt!==this.ct)&&(this.Y=e,this.ht=(n=t.options)==null?void 0:n.host,this.rt(this.ct=t.element)),K}rt(t){if(this.isConnected||(t=void 0),typeof this.Y=="function"){const e=this.ht??globalThis;let r=yn.get(e);r===void 0&&(r=new WeakMap,yn.set(e,r)),r.get(this.Y)!==void 0&&this.Y.call(this.ht,void 0),r.set(this.Y,t),t!==void 0&&this.Y.call(this.ht,t)}else this.Y.value=t}get lt(){var t,e;return typeof this.Y=="function"?(t=yn.get(this.ht??globalThis))==null?void 0:t.get(this.Y):(e=this.Y)==null?void 0:e.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var eh=Object.defineProperty,th=Object.getOwnPropertyDescriptor,es=(t,e,r,n)=>{for(var s=n>1?void 0:n?th(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(s=(n?i(e,r,s):i(s))||s);return n&&s&&eh(e,r,s),s};let zr=class extends _e{constructor(){super(...arguments),this.open=!1,this.openAIAPIToken="",this.dialogRef=Ds(),this.formRef=Ds()}createRenderRoot(){return this}connectedCallback(){we.subscribe(t=>{var e;this.openAIAPIToken=(e=t.settings)==null?void 0:e.openAIAPIToken,this.open=t.settingsDialogOpen}),super.connectedCallback()}updated(t){var e,r;t.has("open")&&(this.open?(e=this.dialogRef.value)==null||e.showModal():(r=this.dialogRef.value)==null||r.close())}onSave(t){t.preventDefault();const n=t.target.elements.namedItem("openAIAPIToken").value,s=we.get().settings;we.update({settings:{openAIAPIToken:n,...s}}),this.onDismiss()}onClear(t){t.preventDefault();const e=we.get().settings;delete e.openAIAPIToken,we.update({settings:e})}onDismiss(){var t;(t=this.formRef.value)==null||t.reset(),we.update({settingsDialogOpen:!1})}render(){return J`
262
+ <dialog ${Zs(this.dialogRef)}>
263
+ <div class="dialog-header">
264
+ <h2>Settings</h2>
265
+ <button
266
+ aria-label="close dialog"
267
+ class="close-dialog-button"
268
+ @click="${this.onDismiss}"
269
+ >
270
+ <svg
271
+ focusable="false"
272
+ xmlns="http://www.w3.org/2000/svg"
273
+ width="24"
274
+ height="24"
275
+ viewBox="0 0 24 24"
276
+ fill="none"
277
+ stroke="currentColor"
278
+ stroke-width="1"
279
+ stroke-linecap="round"
280
+ stroke-linejoin="round"
281
+ >
282
+ <path d="M18 6 6 18" />
283
+ <path d="m6 6 12 12" />
284
+ </svg>
285
+ </button>
286
+ </div>
287
+ <div class="dialog-content">
288
+ <form
289
+ ${Zs(this.formRef)}
290
+ id="settings-form"
291
+ class="settings-form"
292
+ @submit="${this.onSave}"
293
+ >
294
+ <fieldset .disabled=${!!this.openAIAPIToken}>
295
+ <label for="openAIAPIToken">OpenAI API token</label>
296
+
297
+ <input
298
+ id="openAIAPIToken"
299
+ name="openAIAPIToken"
300
+ placeholder="${this.openAIAPIToken?"••••••••••••••••••••":""}"
301
+ />
302
+ </fieldset>
303
+ ${this.openAIAPIToken?J`<button
304
+ class="clear-button"
305
+ ?disabled=${!1}
306
+ @click="${this.onClear}"
307
+ >
308
+ Clear
309
+ </button>`:K}
310
+ </form>
311
+ </div>
312
+ <div class="dialog-footer">
313
+ <button type="submit" form="settings-form">Save</button>
314
+ <button @click="${this.onDismiss}">Cancel</button>
315
+ </div>
316
+ </dialog>
317
+ `}};es([me({type:Boolean})],zr.prototype,"open",2);es([me({type:String})],zr.prototype,"openAIAPIToken",2);zr=es([je("settings-dialog")],zr);var rh=Object.getOwnPropertyDescriptor,nh=(t,e,r,n)=>{for(var s=n>1?void 0:n?rh(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(s=i(s)||s);return s};let Us=class extends _e{createRenderRoot(){return this}render(){return J`
318
+ <app-header></app-header>
319
+ <main>
320
+ <app-sidebar></app-sidebar>
321
+ <app-viewer></app-viewer>
322
+ <app-history></app-history>
323
+ <app-prompt></app-prompt>
324
+ </main>
325
+ <settings-dialog></settings-dialog>
326
+ `}};Us=nh([je("app-root")],Us);
@@ -0,0 +1 @@
1
+ app-root{width:100%;height:100%;display:flex;flex-direction:column}app-root main{flex-grow:1;overflow:auto;display:grid;grid-template-areas:"sidebar viewer history" "sidebar viewer prompt";grid-template-columns:var(--sidebar-width, 350px) 2fr var( --history-width, 350px );grid-template-rows:1fr auto}app-header{display:flex;align-items:center;border-bottom:var(--panel-border);padding:var(--space-xs) var(--space-lg);gap:var(--space-xs);flex-shrink:0}app-header h1{font-size:var(--text-lg);line-height:calc(var(--space-unit) * 6);display:flex;flex-shrink:0;margin-inline-end:auto}.center-group{flex-grow:1;display:flex;align-items:center;justify-content:center;margin-left:-70px}url-input{align-self:stretch;max-width:600px;width:100%}url-input input{height:100%;width:100%}.menu-button{display:flex;cursor:pointer;border:none;color:var(--color-text);border-radius:var(--rounded);border:1px solid transparent}.menu-button:hover{background:transparent;color:var(--color-action)}app-viewer{background:var(--color-background);display:flex;overflow:auto;grid-area:viewer}app-viewer .hidden{display:none}app-viewer .container{display:flex;flex-direction:column;background:var(--color-raised);flex-grow:1;overflow:hidden}applet-frame{flex-grow:1}app-viewer .data-view{flex-grow:1;background:var(--color-raised);padding:var(--space-md);margin:0;white-space:pre-wrap;overflow:auto}app-viewer .applet-header{border-bottom:1px solid var(--color-border);padding:var(--space-unit) var(--space-md);display:flex;align-items:center;gap:var(--space-md);background:var(--color-background)}app-viewer .applet-header label{font-size:var(--text-sm)}app-viewer .applet-header .toggle{background:var(--color-neutral-50);border:var(--panel-border);display:flex;padding:1px;border-radius:var(--rounded);gap:var(--space-xxs)}app-viewer .applet-header button{cursor:pointer;border:none;padding:var(--space-xxs) var(--space-xs)}app-viewer .applet-header button[data-selected=true]{border:var(--button-border);background:var(--color-raised)}app-viewer .applet-header button[data-selected=true]:hover{color:var(--text-color)}applet-frame{width:100%;height:100%}app-viewer .applet-icon{width:18px}app-viewer .applet-title{font-weight:600;flex-grow:1}app-sidebar{border-right:var(--panel-border);padding:var(--space-lg);height:100%;grid-area:sidebar;display:flex}app-sidebar form{width:100%;height:100%;display:flex;gap:var(--space-lg);flex-direction:column}app-sidebar fieldset{display:flex;flex-direction:column;gap:var(--space-md);border:none;padding:0;margin:0;min-width:0}app-sidebar .status-message{display:flex;align-items:center;justify-content:center;flex-grow:1;padding:0;margin:0}app-sidebar select{width:100%}.schema{margin:0;background:var(--color-raised);padding:var(--space-md);font-size:var(--text-sm);border-radius:var(--rounded);border:1px solid var(--color-border);overflow:auto;white-space:pre-wrap}app-sidebar textarea{resize:none}app-sidebar .error-message{padding:var(--space-xs);border-radius:var(--rounded);color:var(--color-negative);border:solid 1px var(--color-negative)}app-prompt{border-left:var(--panel-border);padding-inline:16px;padding-block-end:16px;grid-area:prompt}app-prompt form{position:relative}app-prompt input{width:100%}app-prompt .loader{position:absolute;inset-block-start:var(--space-sm);inset-inline-end:var(--space-sm);stroke-dasharray:40 56;stroke-dashoffset:0;animation:spin 1.5s linear infinite,dashOffset 2s ease-in-out infinite;transform-origin:center}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes dashOffset{0%{stroke-dashoffset:0}to{stroke-dashoffset:-96}}app-history{border-left:var(--panel-border);padding:var(--space-lg);grid-area:history;display:flex;overflow:hidden}app-history .history{flex:1;display:flex;flex-direction:column;gap:var(--space-md);overflow-y:scroll;justify-content:end}app-history .bubble-container{display:flex;font-size:var(--text-base)}app-history .assistant-bubble-container{justify-content:flex-start}app-history .user-bubble-container{justify-content:flex-end}app-history .action-output{justify-content:center;display:flex;gap:var(--space-sm);color:var(--color-neutral-600);flex-direction:column}app-history .action-output span{word-break:break-all;font-family:monospace;font-size:11px}app-history .action-output:only-child{flex-grow:1;align-items:center}app-history .bubble{background-color:var(--color-neutral-0);border-radius:var(--rounded-md);padding:var(--space-sm) var(--space-md);max-width:64ch;text-align:left;word-break:break-word}app-history .user{background-color:var(--color-background);border:1px solid var(--color-border)}app-history .assistant{border:1px solid var(--color-border)}app-history span{white-space:pre-line}settings-dialog dialog{display:none;flex-direction:column;border:1px solid var(--color-border);padding:0;border-radius:var(--rounded);pointer-events:none;width:400px;min-height:200px}settings-dialog dialog[open]{display:flex;pointer-events:auto}settings-dialog .dialog-header,settings-dialog .dialog-content,settings-dialog .dialog-footer{padding-block:var(--space-xs);padding-inline:var(--space-md)}settings-dialog .dialog-header{border-block-end:var(--panel-border);position:relative}settings-dialog .close-dialog-button{display:flex;position:absolute;inset-block-start:var(--space-xs);inset-inline-end:var(--space-sm);padding:0;border:none}settings-dialog .dialog-content{flex-grow:1}settings-dialog .dialog-footer{border-block-start:var(--panel-border);display:flex;flex-direction:row-reverse;gap:var(--space-sm)}settings-dialog .dialog-header h2{font-size:var(--text-md);margin:var(--space-xs) 0}settings-dialog form{display:flex;flex-direction:row;gap:var(--space-xs);padding-block:var(--space-sm)}settings-dialog fieldset{border:none;margin:0;padding:0;display:flex;flex-direction:column;flex-grow:1;gap:var(--space-sm)}settings-dialog input{width:100%}settings-dialog .clear-button{align-self:end}:root{--color-action: oklch(45.2% .313214 264.052);--color-highlight: oklch(93.59% .1528 101.65);--color-neutral-0: oklch(99.39% .002854 264.5422);--color-neutral-50: oklch(96.79% .0029 264.54);--color-neutral-100: oklch(92.17% .0029 264.54);--color-neutral-200: oklch(85.5% .0029 264.54);--color-neutral-300: oklch(77.32% .0044 271.36);--color-neutral-400: oklch(65.8% .0029 264.54);--color-neutral-500: oklch(53.92% .0046 286.24);--color-neutral-600: oklch(45.5% .0029 264.54);--color-neutral-700: oklch(38.2% .0029 264.54);--color-neutral-800: oklch(35.1% .0029 264.54);--color-neutral-900: oklch(32.11% .0029 264.54);--color-neutral-1000: oklch(24.11% .0029 264.54);--color-background: var(--color-neutral-50);--color-border: var(--color-neutral-200);--color-raised: var(--color-neutral-0);--color-text: var(--color-neutral-1000);--color-text-muted: var(--color-neutral-700);--color-text-disabled: var(--color-neutral-500);--color-button-text-hover: var(--color-neutral-0);--text-scale: 1.125;--text-lg: calc(var(--text-md) * var(--text-scale));--text-md: calc(var(--text-base) * var(--text-scale));--text-base: 14px;--text-sm: calc(var(--text-base) / var(--text-scale));--text-xs: calc(var(--text-sm) / var(--text-scale));--space-unit: 4px;--space-xxs: calc(var(--space-unit) * .5);--space-xs: var(--space-unit);--space-sm: calc(var(--space-unit) * 2);--space-md: calc(var(--space-unit) * 3);--space-lg: calc(var(--space-unit) * 4);--space-xl: calc(var(--space-unit) * 6);--space-2xl: calc(var(--space-unit) * 8);--space-3xl: calc(var(--space-unit) * 12);--space-4xl: calc(var(--space-unit) * 16);--rounded-sm: calc(var(--space-unit) / 1.5);--rounded: var(--space-unit);--rounded-md: calc(var(--space-unit) * 1.5);--rounded-lg: calc(var(--space-unit) * 2);--shadow: 0 2px 4px color-mix(in srgb, var(--color-neutral-1000), transparent 90%);--panel-border: 1px solid var(--color-border);--input-border: 1px solid var(--color-border);--button-border: 1px solid var(--color-border);--history-width: 300px}@media (prefers-color-scheme: dark){:root{--color-neutral-0: oklch(24.11% .0029 264.54);--color-neutral-50: oklch(32.11% .0029 264.54);--color-neutral-100: oklch(35.1% .0029 264.54);--color-neutral-200: oklch(38.2% .0029 264.54);--color-neutral-300: oklch(45.5% .0029 264.54);--color-neutral-400: oklch(53.92% .0046 286.24);--color-neutral-500: oklch(65.8% .0029 264.54);--color-neutral-600: oklch(77.32% .0044 271.36);--color-neutral-700: oklch(85.5% .0029 264.54);--color-neutral-800: oklch(92.17% .0029 264.54);--color-neutral-900: oklch(95.79% .0029 264.54);--color-neutral-1000: oklch(99.39% .002854 264.5422);--color-button-text-hover: var(--color-neutral-1000)}}*{box-sizing:border-box}html,body{width:100%;height:100%;padding:0;margin:0}input,button{color:inherit;background-color:inherit}label{font-size:var(--text-sm);font-weight:500}body{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif;font-size:var(--text-sm);text-rendering:geometricPrecision;line-height:var(--space-lg);background:var(--color-background);color:var(--color-text)}header{display:flex}h1,h2,h3,h4,h5{padding:0;margin:0}p{margin:0}select{-webkit-appearance:unset;-moz-appearance:unset;appearance:unset;color:var(--color-text);background-image:url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-position:right var(--space-sm) center;background-repeat:no-repeat;cursor:pointer}textarea,input,select{background-color:var(--color-neutral-0);border:var(--input-border);border-radius:var(--rounded);padding:var(--space-sm)}input::placeholder,textarea::placeholder,select::placeholder{color:var(--color-neutral-500)}button,input[type=submit]{border:var(--button-border);border-radius:var(--rounded);cursor:pointer}button:hover,input[type=submit]:hover{background:var(--color-action);color:var(--color-button-text-hover)}.status-message{color:var(--color-neutral-700)}
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Web Applets Inspector</title>
7
+ <script type="module" crossorigin src="/assets/index-AMdeMxa5.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-DGr96Ien.css">
9
+ </head>
10
+ <body>
11
+ <app-root></app-root>
12
+ </body>
13
+ </html>
package/package.json CHANGED
@@ -33,8 +33,10 @@
33
33
  "@types/express": "^5.0.0",
34
34
  "@types/fs-extra": "^11.0.4",
35
35
  "@types/node": "^22.7.5",
36
- "typescript": "^5.6.2",
37
- "rollup": "^4.34.9"
36
+ "typescript": "^5.6.2"
38
37
  },
39
- "version": "0.2.2"
38
+ "optionalDependencies": {
39
+ "@rollup/rollup-linux-x64-gnu": "4.9.5"
40
+ },
41
+ "version": "0.2.3"
40
42
  }