@artooi/ag-ui-web-component 0.2.1 → 0.3.0

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.
@@ -1,13 +1,13 @@
1
- var lu=Object.defineProperty;var hs=(e,t)=>{for(var n in t)lu(e,n,{get:t[n],enumerable:!0})};var mr="ag-ui-chat",ms="ag-ui-submit",gs="ag-ui-toggle",We={USER:"user",ASSISTANT:"assistant"},Cn="x-destructive",vs="x-confirm",ys="x-summary",Nn="x-navigates",bs=10,de={PENDING:"pending",DONE:"done",ERROR:"error",DECLINED:"declined"},Xe={MINIMAL:"minimal",COMPACT:"compact",FULL:"full"};var cu=/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;function ha(e,t){let n=[];return{text:e.replace(cu,(o,s)=>{let i=t[s];return i==null||i===""?(n.includes(s)||n.push(s),o):String(i)}),missing:n}}function uu(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.name=="string"&&typeof t.title=="string"&&typeof t.prompt=="string"}function xs(e){return Array.isArray(e)?e.filter(uu):[]}var Rn=class{#e=new Map;register(t){this.#e.set(t.name,t)}has(t){return this.#e.has(t)}get(t){let n=this.#e.get(t);if(n===void 0)throw new Error(`tool "${t}" is not registered`);return n}tools(){return[...this.#e.values()].map(t=>({name:t.name,description:t.description,parameters:t.parameters}))}};function Es(e){return e[Cn]===!0}function _s(e){return e[Nn]===!0}function Ts(e,t){return!t||e===null?[]:[{description:"page_map",value:JSON.stringify(e())}]}var ma=/:([A-Za-z_][A-Za-z0-9_]*)/g;function du(e){let t=[];for(let n of e.matchAll(ma)){let r=n[1];r!==void 0&&t.push(r)}return t}function pu(e,t,n){let r={...n};return{path:t.replace(ma,(s,i)=>{let a=n[i];if(a==null||String(a)==="")throw new Error(`route "${e}" requires path param "${i}"`);return delete r[i],encodeURIComponent(String(a))}),leftover:r}}function fu(e,t){let n=new URLSearchParams;for(let[o,s]of Object.entries(t))n.set(o,String(s));let r=n.toString();return r===""?e:`${e}?${r}`}function Ss(e,t){return[{name:"list_routes",description:"List the routes the app can navigate to. Each route's `pathParams` names the dynamic segments to pass as `params` to `navigate_to_route`.",parameters:{type:"object",properties:{},required:[]},handler:()=>e().map(n=>({...n,pathParams:du(n.path)}))},{name:"navigate_to_route",description:"Navigate to one of the app's routes by its id, filling any dynamic `:name` path segments (and extra query params) from `params`.",parameters:{type:"object",properties:{route_id:{type:"string"},params:{type:"object"}},required:["route_id"],[Nn]:!0},handler:n=>{let r=n.route_id,o=e().find(p=>p.id===r);if(o===void 0)throw new Error(`unknown route "${String(r)}"`);let s=n.params??{},{path:i,leftover:a}=pu(o.id,o.path,s),u=fu(i,a),c=t();return c!==null?c(u):window.location.assign(u),{navigated:!0,path:u}}}]}function ws(e){let t=[{name:`read_${e.name}`,description:`Read the "${e.name}" state.`,parameters:{type:"object",properties:{},required:[]},handler:()=>e.read()}],n=e.write;return n!==void 0&&t.push({name:`set_${e.name}`,description:`Update the "${e.name}" state.`,parameters:{...e.schema??{type:"object"},[Cn]:!0},handler:r=>n(r)}),t}function ga(e,t){let n=document.createElement("button");return n.type="button",n.className=`confirm-btn confirm-btn--${e}`,n.textContent=t,n}function ks(e,t){return new Promise(n=>{let r=document.createElement("div");r.className="confirm",r.setAttribute("data-tool-name",t.toolName),r.setAttribute("role","group"),r.setAttribute("aria-label","Confirm action");let o=document.createElement("div");o.className="confirm-body",o.textContent=t.message??`Run \u201C${t.toolName}\u201D?`;let s=document.createElement("pre");s.className="confirm-args",s.textContent=JSON.stringify(t.args,null,2);let i=document.createElement("div");i.className="confirm-actions";let a=ga("cancel","Cancel"),u=ga("confirm","Confirm"),c=p=>{a.disabled=!0,u.disabled=!0,r.setAttribute("data-resolved",p?"confirmed":"declined"),n(p)};a.addEventListener("click",()=>c(!1)),u.addEventListener("click",()=>c(!0)),i.append(a,u),r.append(o,s,i),e.appendChild(r),u.focus()})}function va(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function hu(e){if(Array.isArray(e))return e}function mu(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,s,i,a=[],u=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(u=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);u=!0);}catch(p){c=!0,o=p}finally{try{if(!u&&n.return!=null&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw o}}return a}}function gu(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vu(e,t){return hu(e)||mu(e,t)||yu(e,t)||gu()}function yu(e,t){if(e){if(typeof e=="string")return va(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?va(e,t):void 0}}var Na=Object.entries,ya=Object.setPrototypeOf,bu=Object.isFrozen,xu=Object.getPrototypeOf,Eu=Object.getOwnPropertyDescriptor,Se=Object.freeze,Ne=Object.seal,rn=Object.create,Ra=typeof Reflect<"u"&&Reflect,Os=Ra.apply,Ms=Ra.construct;Se||(Se=function(t){return t});Ne||(Ne=function(t){return t});Os||(Os=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];return t.apply(n,o)});Ms||(Ms=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new t(...r)});var en=ce(Array.prototype.forEach),_u=ce(Array.prototype.lastIndexOf),ba=ce(Array.prototype.pop),tn=ce(Array.prototype.push),Tu=ce(Array.prototype.splice),Te=Array.isArray,Ln=ce(String.prototype.toLowerCase),As=ce(String.prototype.toString),xa=ce(String.prototype.match),nn=ce(String.prototype.replace),Ea=ce(String.prototype.indexOf),Su=ce(String.prototype.trim),wu=ce(Number.prototype.toString),ku=ce(Boolean.prototype.toString),_a=typeof BigInt>"u"?null:ce(BigInt.prototype.toString),Ta=typeof Symbol>"u"?null:ce(Symbol.prototype.toString),ne=ce(Object.prototype.hasOwnProperty),On=ce(Object.prototype.toString),ge=ce(RegExp.prototype.test),Mn=Au(TypeError);function ce(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Os(e,t,r)}}function Au(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Ms(e,n)}}function P(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ln;if(ya&&ya(e,null),!Te(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){let s=n(o);s!==o&&(bu(t)||(t[r]=s),o=s)}e[o]=!0}return e}function Iu(e){for(let t=0;t<e.length;t++)ne(e,t)||(e[t]=null);return e}function xe(e){let t=rn(null);for(let r of Na(e)){var n=vu(r,2);let o=n[0],s=n[1];ne(e,o)&&(Te(s)?t[o]=Iu(s):s&&typeof s=="object"&&s.constructor===Object?t[o]=xe(s):t[o]=s)}return t}function Cu(e){switch(typeof e){case"string":return e;case"number":return wu(e);case"boolean":return ku(e);case"bigint":return _a?_a(e):"0";case"symbol":return Ta?Ta(e):"Symbol()";case"undefined":return On(e);case"function":case"object":{if(e===null)return On(e);let t=e,n=Ke(t,"toString");if(typeof n=="function"){let r=n(t);return typeof r=="string"?r:On(r)}return On(e)}default:return On(e)}}function Ke(e,t){for(;e!==null;){let r=Eu(e,t);if(r){if(r.get)return ce(r.get);if(typeof r.value=="function")return ce(r.value)}e=xu(e)}function n(){return null}return n}function Nu(e){try{return ge(e,""),!0}catch{return!1}}var Sa=Se(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Is=Se(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Cs=Se(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Ru=Se(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ns=Se(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Ou=Se(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wa=Se(["#text"]),ka=Se(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Rs=Se(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Aa=Se(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),gr=Se(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Mu=Ne(/{{[\w\W]*|^[\w\W]*}}/g),Lu=Ne(/<%[\w\W]*|^[\w\W]*%>/g),Pu=Ne(/\${[\w\W]*/g),Du=Ne(/^data-[\-\w.\u00B7-\uFFFF]+$/),Uu=Ne(/^aria-[\-\w]+$/),Ia=Ne(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Gu=Ne(/^(?:\w+script|data):/i),Fu=Ne(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Hu=Ne(/^html$/i),$u=Ne(/^[a-z][.\w]*(-[.\w]+)+$/i),Ze={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},zu=function(){return typeof window>"u"?null:window},Bu=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null,o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));let s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Ca=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Oa(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:zu(),t=C=>Oa(C);if(t.version="3.4.7",t.removed=[],!e||!e.document||e.document.nodeType!==Ze.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,o=r.currentScript;e.DocumentFragment;let s=e.HTMLTemplateElement,i=e.Node,a=e.Element,u=e.NodeFilter,c=e.NamedNodeMap;c===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let p=e.DOMParser,m=e.trustedTypes,x=a.prototype,f=Ke(x,"cloneNode"),h=Ke(x,"remove"),g=Ke(x,"nextSibling"),_=Ke(x,"childNodes"),S=Ke(x,"parentNode"),b=Ke(x,"shadowRoot"),F=Ke(x,"attributes"),Z=i&&i.prototype?Ke(i.prototype,"nodeType"):null,ae=i&&i.prototype?Ke(i.prototype,"nodeName"):null;if(typeof s=="function"){let C=n.createElement("template");C.content&&C.content.ownerDocument&&(n=C.content.ownerDocument)}let ee,ct="",rr=n,Qo=rr.implementation,Vi=rr.createNodeIterator,Zc=rr.createDocumentFragment,Kc=rr.getElementsByTagName,Yc=r.importNode,pe=Ca();t.isSupported=typeof Na=="function"&&typeof S=="function"&&Qo&&Qo.createHTMLDocument!==void 0;let or=Mu,sr=Lu,ir=Pu,qc=Du,Jc=Uu,Qc=Gu,ji=Fu,eu=$u,Wi=Ia,oe=null,es=P({},[...Sa,...Is,...Cs,...Ns,...wa]),le=null,ts=P({},[...ka,...Rs,...Aa,...gr]),se=Object.seal(rn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Sn=null,ar=null,ut=Object.seal(rn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Xi=!0,ns=!0,Zi=!1,Ki=!0,dt=!1,wn=!0,bt=!1,rs=!1,os=!1,Kt=!1,lr=!1,cr=!1,Yi=!0,qi=!1,Ji="user-content-",ss=!0,kn=!1,Yt={},Be=null,is=P({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Qi=null,ea=P({},["audio","video","img","source","image","track"]),as=null,ta=P({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ur="http://www.w3.org/1998/Math/MathML",dr="http://www.w3.org/2000/svg",Ve="http://www.w3.org/1999/xhtml",qt=Ve,ls=!1,cs=null,tu=P({},[ur,dr,Ve],As),us=P({},["mi","mo","mn","ms","mtext"]),ds=P({},["annotation-xml"]),nu=P({},["title","style","font","a","script"]),An=null,ru=["application/xhtml+xml","text/html"],ou="text/html",ie=null,Jt=null,su=n.createElement("form"),na=function(d){return d instanceof RegExp||d instanceof Function},ps=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Jt&&Jt===d)return;(!d||typeof d!="object")&&(d={}),d=xe(d),An=ru.indexOf(d.PARSER_MEDIA_TYPE)===-1?ou:d.PARSER_MEDIA_TYPE,ie=An==="application/xhtml+xml"?As:Ln,oe=ne(d,"ALLOWED_TAGS")&&Te(d.ALLOWED_TAGS)?P({},d.ALLOWED_TAGS,ie):es,le=ne(d,"ALLOWED_ATTR")&&Te(d.ALLOWED_ATTR)?P({},d.ALLOWED_ATTR,ie):ts,cs=ne(d,"ALLOWED_NAMESPACES")&&Te(d.ALLOWED_NAMESPACES)?P({},d.ALLOWED_NAMESPACES,As):tu,as=ne(d,"ADD_URI_SAFE_ATTR")&&Te(d.ADD_URI_SAFE_ATTR)?P(xe(ta),d.ADD_URI_SAFE_ATTR,ie):ta,Qi=ne(d,"ADD_DATA_URI_TAGS")&&Te(d.ADD_DATA_URI_TAGS)?P(xe(ea),d.ADD_DATA_URI_TAGS,ie):ea,Be=ne(d,"FORBID_CONTENTS")&&Te(d.FORBID_CONTENTS)?P({},d.FORBID_CONTENTS,ie):is,Sn=ne(d,"FORBID_TAGS")&&Te(d.FORBID_TAGS)?P({},d.FORBID_TAGS,ie):xe({}),ar=ne(d,"FORBID_ATTR")&&Te(d.FORBID_ATTR)?P({},d.FORBID_ATTR,ie):xe({}),Yt=ne(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?xe(d.USE_PROFILES):d.USE_PROFILES:!1,Xi=d.ALLOW_ARIA_ATTR!==!1,ns=d.ALLOW_DATA_ATTR!==!1,Zi=d.ALLOW_UNKNOWN_PROTOCOLS||!1,Ki=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,dt=d.SAFE_FOR_TEMPLATES||!1,wn=d.SAFE_FOR_XML!==!1,bt=d.WHOLE_DOCUMENT||!1,Kt=d.RETURN_DOM||!1,lr=d.RETURN_DOM_FRAGMENT||!1,cr=d.RETURN_TRUSTED_TYPE||!1,os=d.FORCE_BODY||!1,Yi=d.SANITIZE_DOM!==!1,qi=d.SANITIZE_NAMED_PROPS||!1,ss=d.KEEP_CONTENT!==!1,kn=d.IN_PLACE||!1,Wi=Nu(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:Ia,qt=typeof d.NAMESPACE=="string"?d.NAMESPACE:Ve,us=ne(d,"MATHML_TEXT_INTEGRATION_POINTS")&&d.MATHML_TEXT_INTEGRATION_POINTS&&typeof d.MATHML_TEXT_INTEGRATION_POINTS=="object"?xe(d.MATHML_TEXT_INTEGRATION_POINTS):P({},["mi","mo","mn","ms","mtext"]),ds=ne(d,"HTML_INTEGRATION_POINTS")&&d.HTML_INTEGRATION_POINTS&&typeof d.HTML_INTEGRATION_POINTS=="object"?xe(d.HTML_INTEGRATION_POINTS):P({},["annotation-xml"]);let y=ne(d,"CUSTOM_ELEMENT_HANDLING")&&d.CUSTOM_ELEMENT_HANDLING&&typeof d.CUSTOM_ELEMENT_HANDLING=="object"?xe(d.CUSTOM_ELEMENT_HANDLING):rn(null);if(se=rn(null),ne(y,"tagNameCheck")&&na(y.tagNameCheck)&&(se.tagNameCheck=y.tagNameCheck),ne(y,"attributeNameCheck")&&na(y.attributeNameCheck)&&(se.attributeNameCheck=y.attributeNameCheck),ne(y,"allowCustomizedBuiltInElements")&&typeof y.allowCustomizedBuiltInElements=="boolean"&&(se.allowCustomizedBuiltInElements=y.allowCustomizedBuiltInElements),dt&&(ns=!1),lr&&(Kt=!0),Yt&&(oe=P({},wa),le=rn(null),Yt.html===!0&&(P(oe,Sa),P(le,ka)),Yt.svg===!0&&(P(oe,Is),P(le,Rs),P(le,gr)),Yt.svgFilters===!0&&(P(oe,Cs),P(le,Rs),P(le,gr)),Yt.mathMl===!0&&(P(oe,Ns),P(le,Aa),P(le,gr))),ut.tagCheck=null,ut.attributeCheck=null,ne(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?ut.tagCheck=d.ADD_TAGS:Te(d.ADD_TAGS)&&(oe===es&&(oe=xe(oe)),P(oe,d.ADD_TAGS,ie))),ne(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?ut.attributeCheck=d.ADD_ATTR:Te(d.ADD_ATTR)&&(le===ts&&(le=xe(le)),P(le,d.ADD_ATTR,ie))),ne(d,"ADD_URI_SAFE_ATTR")&&Te(d.ADD_URI_SAFE_ATTR)&&P(as,d.ADD_URI_SAFE_ATTR,ie),ne(d,"FORBID_CONTENTS")&&Te(d.FORBID_CONTENTS)&&(Be===is&&(Be=xe(Be)),P(Be,d.FORBID_CONTENTS,ie)),ne(d,"ADD_FORBID_CONTENTS")&&Te(d.ADD_FORBID_CONTENTS)&&(Be===is&&(Be=xe(Be)),P(Be,d.ADD_FORBID_CONTENTS,ie)),ss&&(oe["#text"]=!0),bt&&P(oe,["html","head","body"]),oe.table&&(P(oe,["tbody"]),delete Sn.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw Mn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Mn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');ee=d.TRUSTED_TYPES_POLICY,ct=ee.createHTML("")}else ee===void 0&&(ee=Bu(m,o)),ee!==null&&typeof ct=="string"&&(ct=ee.createHTML(""));(pe.uponSanitizeElement.length>0||pe.uponSanitizeAttribute.length>0)&&oe===es&&(oe=xe(oe)),pe.uponSanitizeAttribute.length>0&&le===ts&&(le=xe(le)),Se&&Se(d),Jt=d},ra=P({},[...Is,...Cs,...Ru]),oa=P({},[...Ns,...Ou]),iu=function(d){let y=S(d);(!y||!y.tagName)&&(y={namespaceURI:qt,tagName:"template"});let k=Ln(d.tagName),W=Ln(y.tagName);return cs[d.namespaceURI]?d.namespaceURI===dr?y.namespaceURI===Ve?k==="svg":y.namespaceURI===ur?k==="svg"&&(W==="annotation-xml"||us[W]):!!ra[k]:d.namespaceURI===ur?y.namespaceURI===Ve?k==="math":y.namespaceURI===dr?k==="math"&&ds[W]:!!oa[k]:d.namespaceURI===Ve?y.namespaceURI===dr&&!ds[W]||y.namespaceURI===ur&&!us[W]?!1:!oa[k]&&(nu[k]||!ra[k]):!!(An==="application/xhtml+xml"&&cs[d.namespaceURI]):!1},Pe=function(d){tn(t.removed,{element:d});try{S(d).removeChild(d)}catch{h(d)}},xt=function(d,y){try{tn(t.removed,{attribute:y.getAttributeNode(d),from:y})}catch{tn(t.removed,{attribute:null,from:y})}if(y.removeAttribute(d),d==="is")if(Kt||lr)try{Pe(y)}catch{}else try{y.setAttribute(d,"")}catch{}},sa=function(d){let y=null,k=null;if(os)d="<remove></remove>"+d;else{let Y=xa(d,/^[\r\n\t ]+/);k=Y&&Y[0]}An==="application/xhtml+xml"&&qt===Ve&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");let W=ee?ee.createHTML(d):d;if(qt===Ve)try{y=new p().parseFromString(W,An)}catch{}if(!y||!y.documentElement){y=Qo.createDocument(qt,"template",null);try{y.documentElement.innerHTML=ls?ct:W}catch{}}let $=y.body||y.documentElement;return d&&k&&$.insertBefore(n.createTextNode(k),$.childNodes[0]||null),qt===Ve?Kc.call(y,bt?"html":"body")[0]:bt?y.documentElement:$},ia=function(d){return Vi.call(d.ownerDocument||d,d,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},aa=function(d){d.normalize();let y=Vi.call(d.ownerDocument||d,d,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null),k=y.nextNode();for(;k;){let W=k.data;en([or,sr,ir],$=>{W=nn(W,$," ")}),k.data=W,k=y.nextNode()}},pr=function(d){let y=ae?ae(d):null;return typeof y!="string"||ie(y)!=="form"?!1:typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||d.attributes!==F(d)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==Z(d)||d.childNodes!==_(d)},In=function(d){if(!Z||typeof d!="object"||d===null)return!1;try{return Z(d)===Ze.documentFragment}catch{return!1}},fr=function(d){if(!Z||typeof d!="object"||d===null)return!1;try{return typeof Z(d)=="number"}catch{return!1}};function rt(C,d,y){en(C,k=>{k.call(t,d,y,Jt)})}let la=function(d){let y=null;if(rt(pe.beforeSanitizeElements,d,null),pr(d))return Pe(d),!0;let k=ie(d.nodeName);if(rt(pe.uponSanitizeElement,d,{tagName:k,allowedTags:oe}),wn&&d.hasChildNodes()&&!fr(d.firstElementChild)&&ge(/<[/\w!]/g,d.innerHTML)&&ge(/<[/\w!]/g,d.textContent)||wn&&d.namespaceURI===Ve&&k==="style"&&fr(d.firstElementChild)||d.nodeType===Ze.progressingInstruction||wn&&d.nodeType===Ze.comment&&ge(/<[/\w]/g,d.data))return Pe(d),!0;if(Sn[k]||!(ut.tagCheck instanceof Function&&ut.tagCheck(k))&&!oe[k]){if(!Sn[k]&&ua(k)&&(se.tagNameCheck instanceof RegExp&&ge(se.tagNameCheck,k)||se.tagNameCheck instanceof Function&&se.tagNameCheck(k)))return!1;if(ss&&!Be[k]){let $=S(d),Y=_(d);if(Y&&$){let Ce=Y.length;for(let je=Ce-1;je>=0;--je){let De=f(Y[je],!0);$.insertBefore(De,g(d))}}}return Pe(d),!0}return(Z?Z(d):d.nodeType)===Ze.element&&!iu(d)||(k==="noscript"||k==="noembed"||k==="noframes")&&ge(/<\/no(script|embed|frames)/i,d.innerHTML)?(Pe(d),!0):(dt&&d.nodeType===Ze.text&&(y=d.textContent,en([or,sr,ir],$=>{y=nn(y,$," ")}),d.textContent!==y&&(tn(t.removed,{element:d.cloneNode()}),d.textContent=y)),rt(pe.afterSanitizeElements,d,null),!1)},ca=function(d,y,k){if(ar[y]||Yi&&(y==="id"||y==="name")&&(k in n||k in su))return!1;let W=le[y]||ut.attributeCheck instanceof Function&&ut.attributeCheck(y,d);if(!(ns&&!ar[y]&&ge(qc,y))){if(!(Xi&&ge(Jc,y))){if(!W||ar[y]){if(!(ua(d)&&(se.tagNameCheck instanceof RegExp&&ge(se.tagNameCheck,d)||se.tagNameCheck instanceof Function&&se.tagNameCheck(d))&&(se.attributeNameCheck instanceof RegExp&&ge(se.attributeNameCheck,y)||se.attributeNameCheck instanceof Function&&se.attributeNameCheck(y,d))||y==="is"&&se.allowCustomizedBuiltInElements&&(se.tagNameCheck instanceof RegExp&&ge(se.tagNameCheck,k)||se.tagNameCheck instanceof Function&&se.tagNameCheck(k))))return!1}else if(!as[y]){if(!ge(Wi,nn(k,ji,""))){if(!((y==="src"||y==="xlink:href"||y==="href")&&d!=="script"&&Ea(k,"data:")===0&&Qi[d])){if(!(Zi&&!ge(Qc,nn(k,ji,"")))){if(k)return!1}}}}}}return!0},au=P({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ua=function(d){return!au[Ln(d)]&&ge(eu,d)},da=function(d){rt(pe.beforeSanitizeAttributes,d,null);let y=d.attributes;if(!y||pr(d))return;let k={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:le,forceKeepAttr:void 0},W=y.length;for(;W--;){let $=y[W],Y=$.name,Ce=$.namespaceURI,je=$.value,De=ie(Y),fs=je,fe=Y==="value"?fs:Su(fs);if(k.attrName=De,k.attrValue=fe,k.keepAttr=!0,k.forceKeepAttr=void 0,rt(pe.uponSanitizeAttribute,d,k),fe=k.attrValue,qi&&(De==="id"||De==="name")&&Ea(fe,Ji)!==0&&(xt(Y,d),fe=Ji+fe),wn&&ge(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,fe)){xt(Y,d);continue}if(De==="attributename"&&xa(fe,"href")){xt(Y,d);continue}if(k.forceKeepAttr)continue;if(!k.keepAttr){xt(Y,d);continue}if(!Ki&&ge(/\/>/i,fe)){xt(Y,d);continue}dt&&en([or,sr,ir],fa=>{fe=nn(fe,fa," ")});let pa=ie(d.nodeName);if(!ca(pa,De,fe)){xt(Y,d);continue}if(ee&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Ce)switch(m.getAttributeType(pa,De)){case"TrustedHTML":{fe=ee.createHTML(fe);break}case"TrustedScriptURL":{fe=ee.createScriptURL(fe);break}}if(fe!==fs)try{Ce?d.setAttributeNS(Ce,Y,fe):d.setAttribute(Y,fe),pr(d)?Pe(d):ba(t.removed)}catch{xt(Y,d)}}rt(pe.afterSanitizeAttributes,d,null)},hr=function(d){let y=null,k=ia(d);for(rt(pe.beforeSanitizeShadowDOM,d,null);y=k.nextNode();)if(rt(pe.uponSanitizeShadowNode,y,null),la(y),da(y),In(y.content)&&hr(y.content),(Z?Z(y):y.nodeType)===Ze.element){let $=b?b(y):y.shadowRoot;In($)&&(Qt($),hr($))}rt(pe.afterSanitizeShadowDOM,d,null)},Qt=function(d){let y=Z?Z(d):d.nodeType;if(y===Ze.element){let $=b?b(d):d.shadowRoot;In($)&&(Qt($),hr($))}let k=_?_(d):d.childNodes;if(!k)return;let W=[];en(k,$=>{tn(W,$)});for(let $ of W)Qt($);if(y===Ze.element){let $=ae?ae(d):null;if(typeof $=="string"&&ie($)==="template"){let Y=d.content;In(Y)&&Qt(Y)}}};return t.sanitize=function(C){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=null,k=null,W=null,$=null;if(ls=!C,ls&&(C="<!-->"),typeof C!="string"&&!fr(C)&&(C=Cu(C),typeof C!="string"))throw Mn("dirty is not a string, aborting");if(!t.isSupported)return C;if(rs||ps(d),t.removed=[],typeof C=="string"&&(kn=!1),kn){let je=ae?ae(C):C.nodeName;if(typeof je=="string"){let De=ie(je);if(!oe[De]||Sn[De])throw Mn("root node is forbidden and cannot be sanitized in-place")}if(pr(C))throw Mn("root node is clobbered and cannot be sanitized in-place");Qt(C)}else if(fr(C))y=sa("<!---->"),k=y.ownerDocument.importNode(C,!0),k.nodeType===Ze.element&&k.nodeName==="BODY"||k.nodeName==="HTML"?y=k:y.appendChild(k),Qt(k);else{if(!Kt&&!dt&&!bt&&C.indexOf("<")===-1)return ee&&cr?ee.createHTML(C):C;if(y=sa(C),!y)return Kt?null:cr?ct:""}y&&os&&Pe(y.firstChild);let Y=ia(kn?C:y);for(;W=Y.nextNode();)la(W),da(W),In(W.content)&&hr(W.content);if(kn)return dt&&aa(C),C;if(Kt){if(dt&&aa(y),lr)for($=Zc.call(y.ownerDocument);y.firstChild;)$.appendChild(y.firstChild);else $=y;return(le.shadowroot||le.shadowrootmode)&&($=Yc.call(r,$,!0)),$}let Ce=bt?y.outerHTML:y.innerHTML;return bt&&oe["!doctype"]&&y.ownerDocument&&y.ownerDocument.doctype&&y.ownerDocument.doctype.name&&ge(Hu,y.ownerDocument.doctype.name)&&(Ce="<!DOCTYPE "+y.ownerDocument.doctype.name+`>
3
- `+Ce),dt&&en([or,sr,ir],je=>{Ce=nn(Ce,je," ")}),ee&&cr?ee.createHTML(Ce):Ce},t.setConfig=function(){let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ps(C),rs=!0},t.clearConfig=function(){Jt=null,rs=!1},t.isValidAttribute=function(C,d,y){Jt||ps({});let k=ie(C),W=ie(d);return ca(k,W,y)},t.addHook=function(C,d){typeof d=="function"&&tn(pe[C],d)},t.removeHook=function(C,d){if(d!==void 0){let y=_u(pe[C],d);return y===-1?void 0:Tu(pe[C],y,1)[0]}return ba(pe[C])},t.removeHooks=function(C){pe[C]=[]},t.removeAllHooks=function(){pe=Ca()},t}var Ma=Oa();function Us(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Tt=Us();function $a(e){Tt=e}var Et={exec:()=>null};function on(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),o=t[r];return o||(o=e(r),t[r]=o),o}}function z(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(o,s)=>{let i=typeof s=="string"?s:s.source;return i=i.replace(Ee.caret,"$1"),n=n.replace(o,i),r},getRegex:()=>new RegExp(n,t)};return r}var Vu=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Ee={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:on(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:on(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:on(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:on(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:on(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:on(e=>new RegExp(`^ {0,${e}}>`))},ju=/^(?:[ \t]*(?:\n|$))+/,Wu=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Xu=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Un=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Zu=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Gs=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,za=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ba=z(za).replace(/bull/g,Gs).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ku=z(za).replace(/bull/g,Gs).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Fs=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Yu=/^[^\n]+/,Hs=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,qu=z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Hs).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ju=z(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Gs).getRegex(),Er="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",$s=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Qu=z("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",$s).replace("tag",Er).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Va=z(Fs).replace("hr",Un).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Er).getRegex(),ed=z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Va).getRegex(),zs={blockquote:ed,code:Wu,def:qu,fences:Xu,heading:Zu,hr:Un,html:Qu,lheading:Ba,list:Ju,newline:ju,paragraph:Va,table:Et,text:Yu},La=z("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Un).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Er).getRegex(),td={...zs,lheading:Ku,table:La,paragraph:z(Fs).replace("hr",Un).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",La).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Er).getRegex()},nd={...zs,html:z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",$s).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Et,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:z(Fs).replace("hr",Un).replace("heading",` *#{1,6} *[^
4
- ]`).replace("lheading",Ba).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},rd=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,od=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ja=/^( {2,}|\\)\n(?!\s*$)/,sd=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,sn=/[\p{P}\p{S}]/u,_r=/[\s\p{P}\p{S}]/u,Bs=/[^\s\p{P}\p{S}]/u,id=z(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,_r).getRegex(),Wa=/(?!~)[\p{P}\p{S}]/u,ad=/(?!~)[\s\p{P}\p{S}]/u,ld=/(?:[^\s\p{P}\p{S}]|~)/u,cd=z(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Vu?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Xa=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ud=z(Xa,"u").replace(/punct/g,sn).getRegex(),dd=z(Xa,"u").replace(/punct/g,Wa).getRegex(),Za="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",pd=z(Za,"gu").replace(/notPunctSpace/g,Bs).replace(/punctSpace/g,_r).replace(/punct/g,sn).getRegex(),fd=z(Za,"gu").replace(/notPunctSpace/g,ld).replace(/punctSpace/g,ad).replace(/punct/g,Wa).getRegex(),hd=z("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Bs).replace(/punctSpace/g,_r).replace(/punct/g,sn).getRegex(),md=z(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,sn).getRegex(),gd="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",vd=z(gd,"gu").replace(/notPunctSpace/g,Bs).replace(/punctSpace/g,_r).replace(/punct/g,sn).getRegex(),yd=z(/\\(punct)/,"gu").replace(/punct/g,sn).getRegex(),bd=z(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),xd=z($s).replace("(?:-->|$)","-->").getRegex(),Ed=z("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",xd).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),yr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,_d=z(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",yr).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ka=z(/^!?\[(label)\]\[(ref)\]/).replace("label",yr).replace("ref",Hs).getRegex(),Ya=z(/^!?\[(ref)\](?:\[\])?/).replace("ref",Hs).getRegex(),Td=z("reflink|nolink(?!\\()","g").replace("reflink",Ka).replace("nolink",Ya).getRegex(),Pa=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Vs={_backpedal:Et,anyPunctuation:yd,autolink:bd,blockSkip:cd,br:ja,code:od,del:Et,delLDelim:Et,delRDelim:Et,emStrongLDelim:ud,emStrongRDelimAst:pd,emStrongRDelimUnd:hd,escape:rd,link:_d,nolink:Ya,punctuation:id,reflink:Ka,reflinkSearch:Td,tag:Ed,text:sd,url:Et},Sd={...Vs,link:z(/^!?\[(label)\]\((.*?)\)/).replace("label",yr).getRegex(),reflink:z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",yr).getRegex()},Ls={...Vs,emStrongRDelimAst:fd,emStrongLDelim:dd,delLDelim:md,delRDelim:vd,url:z(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Pa).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:z(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Pa).getRegex()},wd={...Ls,br:z(ja).replace("{2,}","*").getRegex(),text:z(Ls.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},vr={normal:zs,gfm:td,pedantic:nd},Pn={normal:Vs,gfm:Ls,breaks:wd,pedantic:Sd},kd={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Da=e=>kd[e];function Ye(e,t){if(t){if(Ee.escapeTest.test(e))return e.replace(Ee.escapeReplace,Da)}else if(Ee.escapeTestNoEncode.test(e))return e.replace(Ee.escapeReplaceNoEncode,Da);return e}function Ua(e){try{e=encodeURI(e).replace(Ee.percentDecode,"%")}catch{return null}return e}function Ga(e,t){let n=e.replace(Ee.findPipe,(s,i,a)=>{let u=!1,c=i;for(;--c>=0&&a[c]==="\\";)u=!u;return u?"|":" |"}),r=n.split(Ee.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(Ee.slashPipe,"|");return r}function pt(e,t,n){let r=e.length;if(r===0)return"";let o=0;for(;o<r;){let s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function Fa(e){let t=e.split(`
1
+ var cu=Object.defineProperty;var ms=(e,t)=>{for(var n in t)cu(e,n,{get:t[n],enumerable:!0})};var gr="ag-ui-chat",gs="ag-ui-submit",vs="ag-ui-toggle",We={USER:"user",ASSISTANT:"assistant"},Nn="x-destructive",ys="x-confirm",Xe="x-summary",Rn="x-navigates",bs=10,de={PENDING:"pending",DONE:"done",ERROR:"error",DECLINED:"declined"},Ze={MINIMAL:"minimal",COMPACT:"compact",FULL:"full"};var uu=/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;function ma(e,t){let n=[];return{text:e.replace(uu,(o,s)=>{let i=t[s];return i==null||i===""?(n.includes(s)||n.push(s),o):String(i)}),missing:n}}function du(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.name=="string"&&typeof t.title=="string"&&typeof t.prompt=="string"}function xs(e){return Array.isArray(e)?e.filter(du):[]}var On=class{#e=new Map;register(t){this.#e.set(t.name,t)}has(t){return this.#e.has(t)}get(t){let n=this.#e.get(t);if(n===void 0)throw new Error(`tool "${t}" is not registered`);return n}tools(){return[...this.#e.values()].map(t=>({name:t.name,description:t.description,parameters:t.parameters}))}};function Es(e){return e[Nn]===!0}function _s(e){return e[Rn]===!0}function Ts(e,t){return!t||e===null?[]:[{description:"page_map",value:JSON.stringify(e())}]}function Ss(e){let t={};if(!Array.isArray(e))return t;for(let n of e){if(n===null||typeof n!="object")continue;let r=n,o=r.name,s=r.summary;typeof o=="string"&&typeof s=="string"&&(t[o]=s)}return t}var ga=/:([A-Za-z_][A-Za-z0-9_]*)/g;function pu(e){let t=[];for(let n of e.matchAll(ga)){let r=n[1];r!==void 0&&t.push(r)}return t}function fu(e,t,n){let r={...n};return{path:t.replace(ga,(s,i)=>{let a=n[i];if(a==null||String(a)==="")throw new Error(`route "${e}" requires path param "${i}"`);return delete r[i],encodeURIComponent(String(a))}),leftover:r}}function hu(e,t){let n=new URLSearchParams;for(let[o,s]of Object.entries(t))n.set(o,String(s));let r=n.toString();return r===""?e:`${e}?${r}`}function ws(e,t){return[{name:"list_routes",description:"List the routes the app can navigate to. Each route's `pathParams` names the dynamic segments to pass as `params` to `navigate_to_route`.",parameters:{type:"object",properties:{},required:[],[Xe]:"List pages"},handler:()=>e().map(n=>({...n,pathParams:pu(n.path)}))},{name:"navigate_to_route",description:"Navigate to one of the app's routes by its id, filling any dynamic `:name` path segments (and extra query params) from `params`.",parameters:{type:"object",properties:{route_id:{type:"string"},params:{type:"object"}},required:["route_id"],[Rn]:!0,[Xe]:"Navigate"},handler:n=>{let r=n.route_id,o=e().find(p=>p.id===r);if(o===void 0)throw new Error(`unknown route "${String(r)}"`);let s=n.params??{},{path:i,leftover:a}=fu(o.id,o.path,s),u=hu(i,a),c=t();return c!==null?c(u):window.location.assign(u),{navigated:!0,path:u}}}]}function ks(e){let t=[{name:`read_${e.name}`,description:`Read the "${e.name}" state.`,parameters:{type:"object",properties:{},required:[],[Xe]:`Read ${e.name}`},handler:()=>e.read()}],n=e.write;return n!==void 0&&t.push({name:`set_${e.name}`,description:`Update the "${e.name}" state.`,parameters:{...e.schema??{type:"object"},[Nn]:!0,[Xe]:`Update ${e.name}`},handler:r=>n(r)}),t}function va(e,t){let n=document.createElement("button");return n.type="button",n.className=`confirm-btn confirm-btn--${e}`,n.textContent=t,n}function As(e,t){return new Promise(n=>{let r=document.createElement("div");r.className="confirm",r.setAttribute("data-tool-name",t.toolName),r.setAttribute("role","group"),r.setAttribute("aria-label","Confirm action");let o=document.createElement("div");o.className="confirm-body",o.textContent=t.message??`Run \u201C${t.toolName}\u201D?`;let s=document.createElement("pre");s.className="confirm-args",s.textContent=JSON.stringify(t.args,null,2);let i=document.createElement("div");i.className="confirm-actions";let a=va("cancel","Cancel"),u=va("confirm","Confirm"),c=p=>{a.disabled=!0,u.disabled=!0,r.setAttribute("data-resolved",p?"confirmed":"declined"),n(p)};a.addEventListener("click",()=>c(!1)),u.addEventListener("click",()=>c(!0)),i.append(a,u),r.append(o,s,i),e.appendChild(r),u.focus()})}function ya(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function mu(e){if(Array.isArray(e))return e}function gu(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,s,i,a=[],u=!0,c=!1;try{if(s=(n=n.call(e)).next,t!==0)for(;!(u=(r=s.call(n)).done)&&(a.push(r.value),a.length!==t);u=!0);}catch(p){c=!0,o=p}finally{try{if(!u&&n.return!=null&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw o}}return a}}function vu(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yu(e,t){return mu(e)||gu(e,t)||bu(e,t)||vu()}function bu(e,t){if(e){if(typeof e=="string")return ya(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ya(e,t):void 0}}var Ra=Object.entries,ba=Object.setPrototypeOf,xu=Object.isFrozen,Eu=Object.getPrototypeOf,_u=Object.getOwnPropertyDescriptor,Se=Object.freeze,Ne=Object.seal,on=Object.create,Oa=typeof Reflect<"u"&&Reflect,Ms=Oa.apply,Ls=Oa.construct;Se||(Se=function(t){return t});Ne||(Ne=function(t){return t});Ms||(Ms=function(t,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];return t.apply(n,o)});Ls||(Ls=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new t(...r)});var tn=ce(Array.prototype.forEach),Tu=ce(Array.prototype.lastIndexOf),xa=ce(Array.prototype.pop),nn=ce(Array.prototype.push),Su=ce(Array.prototype.splice),Te=Array.isArray,Pn=ce(String.prototype.toLowerCase),Is=ce(String.prototype.toString),Ea=ce(String.prototype.match),rn=ce(String.prototype.replace),_a=ce(String.prototype.indexOf),wu=ce(String.prototype.trim),ku=ce(Number.prototype.toString),Au=ce(Boolean.prototype.toString),Ta=typeof BigInt>"u"?null:ce(BigInt.prototype.toString),Sa=typeof Symbol>"u"?null:ce(Symbol.prototype.toString),ne=ce(Object.prototype.hasOwnProperty),Mn=ce(Object.prototype.toString),ge=ce(RegExp.prototype.test),Ln=Iu(TypeError);function ce(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Ms(e,t,r)}}function Iu(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Ls(e,n)}}function P(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Pn;if(ba&&ba(e,null),!Te(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){let s=n(o);s!==o&&(xu(t)||(t[r]=s),o=s)}e[o]=!0}return e}function Cu(e){for(let t=0;t<e.length;t++)ne(e,t)||(e[t]=null);return e}function xe(e){let t=on(null);for(let r of Ra(e)){var n=yu(r,2);let o=n[0],s=n[1];ne(e,o)&&(Te(s)?t[o]=Cu(s):s&&typeof s=="object"&&s.constructor===Object?t[o]=xe(s):t[o]=s)}return t}function Nu(e){switch(typeof e){case"string":return e;case"number":return ku(e);case"boolean":return Au(e);case"bigint":return Ta?Ta(e):"0";case"symbol":return Sa?Sa(e):"Symbol()";case"undefined":return Mn(e);case"function":case"object":{if(e===null)return Mn(e);let t=e,n=Ye(t,"toString");if(typeof n=="function"){let r=n(t);return typeof r=="string"?r:Mn(r)}return Mn(e)}default:return Mn(e)}}function Ye(e,t){for(;e!==null;){let r=_u(e,t);if(r){if(r.get)return ce(r.get);if(typeof r.value=="function")return ce(r.value)}e=Eu(e)}function n(){return null}return n}function Ru(e){try{return ge(e,""),!0}catch{return!1}}var wa=Se(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Cs=Se(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ns=Se(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Ou=Se(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Rs=Se(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Mu=Se(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ka=Se(["#text"]),Aa=Se(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Os=Se(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ia=Se(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),vr=Se(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Lu=Ne(/{{[\w\W]*|^[\w\W]*}}/g),Pu=Ne(/<%[\w\W]*|^[\w\W]*%>/g),Du=Ne(/\${[\w\W]*/g),Uu=Ne(/^data-[\-\w.\u00B7-\uFFFF]+$/),Gu=Ne(/^aria-[\-\w]+$/),Ca=Ne(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Fu=Ne(/^(?:\w+script|data):/i),Hu=Ne(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$u=Ne(/^html$/i),zu=Ne(/^[a-z][.\w]*(-[.\w]+)+$/i),Ke={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Bu=function(){return typeof window>"u"?null:window},Vu=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null,o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));let s="dompurify"+(r?"#"+r:"");try{return t.createPolicy(s,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},Na=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ma(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Bu(),t=C=>Ma(C);if(t.version="3.4.7",t.removed=[],!e||!e.document||e.document.nodeType!==Ke.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,o=r.currentScript;e.DocumentFragment;let s=e.HTMLTemplateElement,i=e.Node,a=e.Element,u=e.NodeFilter,c=e.NamedNodeMap;c===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let p=e.DOMParser,m=e.trustedTypes,x=a.prototype,f=Ye(x,"cloneNode"),h=Ye(x,"remove"),g=Ye(x,"nextSibling"),_=Ye(x,"childNodes"),S=Ye(x,"parentNode"),b=Ye(x,"shadowRoot"),F=Ye(x,"attributes"),Z=i&&i.prototype?Ye(i.prototype,"nodeType"):null,ae=i&&i.prototype?Ye(i.prototype,"nodeName"):null;if(typeof s=="function"){let C=n.createElement("template");C.content&&C.content.ownerDocument&&(n=C.content.ownerDocument)}let ee,ut="",or=n,es=or.implementation,ji=or.createNodeIterator,Kc=or.createDocumentFragment,Yc=or.getElementsByTagName,qc=r.importNode,pe=Na();t.isSupported=typeof Ra=="function"&&typeof S=="function"&&es&&es.createHTMLDocument!==void 0;let sr=Lu,ir=Pu,ar=Du,Jc=Uu,Qc=Gu,eu=Fu,Wi=Hu,tu=zu,Xi=Ca,oe=null,ts=P({},[...wa,...Cs,...Ns,...Rs,...ka]),le=null,ns=P({},[...Aa,...Os,...Ia,...vr]),se=Object.seal(on(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),wn=null,lr=null,dt=Object.seal(on(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Zi=!0,rs=!0,Ki=!1,Yi=!0,pt=!1,kn=!0,xt=!1,os=!1,ss=!1,Yt=!1,cr=!1,ur=!1,qi=!0,Ji=!1,Qi="user-content-",is=!0,An=!1,qt={},Be=null,as=P({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),ea=null,ta=P({},["audio","video","img","source","image","track"]),ls=null,na=P({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),dr="http://www.w3.org/1998/Math/MathML",pr="http://www.w3.org/2000/svg",Ve="http://www.w3.org/1999/xhtml",Jt=Ve,cs=!1,us=null,nu=P({},[dr,pr,Ve],Is),ds=P({},["mi","mo","mn","ms","mtext"]),ps=P({},["annotation-xml"]),ru=P({},["title","style","font","a","script"]),In=null,ou=["application/xhtml+xml","text/html"],su="text/html",ie=null,Qt=null,iu=n.createElement("form"),ra=function(d){return d instanceof RegExp||d instanceof Function},fs=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Qt&&Qt===d)return;(!d||typeof d!="object")&&(d={}),d=xe(d),In=ou.indexOf(d.PARSER_MEDIA_TYPE)===-1?su:d.PARSER_MEDIA_TYPE,ie=In==="application/xhtml+xml"?Is:Pn,oe=ne(d,"ALLOWED_TAGS")&&Te(d.ALLOWED_TAGS)?P({},d.ALLOWED_TAGS,ie):ts,le=ne(d,"ALLOWED_ATTR")&&Te(d.ALLOWED_ATTR)?P({},d.ALLOWED_ATTR,ie):ns,us=ne(d,"ALLOWED_NAMESPACES")&&Te(d.ALLOWED_NAMESPACES)?P({},d.ALLOWED_NAMESPACES,Is):nu,ls=ne(d,"ADD_URI_SAFE_ATTR")&&Te(d.ADD_URI_SAFE_ATTR)?P(xe(na),d.ADD_URI_SAFE_ATTR,ie):na,ea=ne(d,"ADD_DATA_URI_TAGS")&&Te(d.ADD_DATA_URI_TAGS)?P(xe(ta),d.ADD_DATA_URI_TAGS,ie):ta,Be=ne(d,"FORBID_CONTENTS")&&Te(d.FORBID_CONTENTS)?P({},d.FORBID_CONTENTS,ie):as,wn=ne(d,"FORBID_TAGS")&&Te(d.FORBID_TAGS)?P({},d.FORBID_TAGS,ie):xe({}),lr=ne(d,"FORBID_ATTR")&&Te(d.FORBID_ATTR)?P({},d.FORBID_ATTR,ie):xe({}),qt=ne(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?xe(d.USE_PROFILES):d.USE_PROFILES:!1,Zi=d.ALLOW_ARIA_ATTR!==!1,rs=d.ALLOW_DATA_ATTR!==!1,Ki=d.ALLOW_UNKNOWN_PROTOCOLS||!1,Yi=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,pt=d.SAFE_FOR_TEMPLATES||!1,kn=d.SAFE_FOR_XML!==!1,xt=d.WHOLE_DOCUMENT||!1,Yt=d.RETURN_DOM||!1,cr=d.RETURN_DOM_FRAGMENT||!1,ur=d.RETURN_TRUSTED_TYPE||!1,ss=d.FORCE_BODY||!1,qi=d.SANITIZE_DOM!==!1,Ji=d.SANITIZE_NAMED_PROPS||!1,is=d.KEEP_CONTENT!==!1,An=d.IN_PLACE||!1,Xi=Ru(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:Ca,Jt=typeof d.NAMESPACE=="string"?d.NAMESPACE:Ve,ds=ne(d,"MATHML_TEXT_INTEGRATION_POINTS")&&d.MATHML_TEXT_INTEGRATION_POINTS&&typeof d.MATHML_TEXT_INTEGRATION_POINTS=="object"?xe(d.MATHML_TEXT_INTEGRATION_POINTS):P({},["mi","mo","mn","ms","mtext"]),ps=ne(d,"HTML_INTEGRATION_POINTS")&&d.HTML_INTEGRATION_POINTS&&typeof d.HTML_INTEGRATION_POINTS=="object"?xe(d.HTML_INTEGRATION_POINTS):P({},["annotation-xml"]);let y=ne(d,"CUSTOM_ELEMENT_HANDLING")&&d.CUSTOM_ELEMENT_HANDLING&&typeof d.CUSTOM_ELEMENT_HANDLING=="object"?xe(d.CUSTOM_ELEMENT_HANDLING):on(null);if(se=on(null),ne(y,"tagNameCheck")&&ra(y.tagNameCheck)&&(se.tagNameCheck=y.tagNameCheck),ne(y,"attributeNameCheck")&&ra(y.attributeNameCheck)&&(se.attributeNameCheck=y.attributeNameCheck),ne(y,"allowCustomizedBuiltInElements")&&typeof y.allowCustomizedBuiltInElements=="boolean"&&(se.allowCustomizedBuiltInElements=y.allowCustomizedBuiltInElements),pt&&(rs=!1),cr&&(Yt=!0),qt&&(oe=P({},ka),le=on(null),qt.html===!0&&(P(oe,wa),P(le,Aa)),qt.svg===!0&&(P(oe,Cs),P(le,Os),P(le,vr)),qt.svgFilters===!0&&(P(oe,Ns),P(le,Os),P(le,vr)),qt.mathMl===!0&&(P(oe,Rs),P(le,Ia),P(le,vr))),dt.tagCheck=null,dt.attributeCheck=null,ne(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?dt.tagCheck=d.ADD_TAGS:Te(d.ADD_TAGS)&&(oe===ts&&(oe=xe(oe)),P(oe,d.ADD_TAGS,ie))),ne(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?dt.attributeCheck=d.ADD_ATTR:Te(d.ADD_ATTR)&&(le===ns&&(le=xe(le)),P(le,d.ADD_ATTR,ie))),ne(d,"ADD_URI_SAFE_ATTR")&&Te(d.ADD_URI_SAFE_ATTR)&&P(ls,d.ADD_URI_SAFE_ATTR,ie),ne(d,"FORBID_CONTENTS")&&Te(d.FORBID_CONTENTS)&&(Be===as&&(Be=xe(Be)),P(Be,d.FORBID_CONTENTS,ie)),ne(d,"ADD_FORBID_CONTENTS")&&Te(d.ADD_FORBID_CONTENTS)&&(Be===as&&(Be=xe(Be)),P(Be,d.ADD_FORBID_CONTENTS,ie)),is&&(oe["#text"]=!0),xt&&P(oe,["html","head","body"]),oe.table&&(P(oe,["tbody"]),delete wn.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ln('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ln('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');ee=d.TRUSTED_TYPES_POLICY,ut=ee.createHTML("")}else ee===void 0&&(ee=Vu(m,o)),ee!==null&&typeof ut=="string"&&(ut=ee.createHTML(""));(pe.uponSanitizeElement.length>0||pe.uponSanitizeAttribute.length>0)&&oe===ts&&(oe=xe(oe)),pe.uponSanitizeAttribute.length>0&&le===ns&&(le=xe(le)),Se&&Se(d),Qt=d},oa=P({},[...Cs,...Ns,...Ou]),sa=P({},[...Rs,...Mu]),au=function(d){let y=S(d);(!y||!y.tagName)&&(y={namespaceURI:Jt,tagName:"template"});let k=Pn(d.tagName),W=Pn(y.tagName);return us[d.namespaceURI]?d.namespaceURI===pr?y.namespaceURI===Ve?k==="svg":y.namespaceURI===dr?k==="svg"&&(W==="annotation-xml"||ds[W]):!!oa[k]:d.namespaceURI===dr?y.namespaceURI===Ve?k==="math":y.namespaceURI===pr?k==="math"&&ps[W]:!!sa[k]:d.namespaceURI===Ve?y.namespaceURI===pr&&!ps[W]||y.namespaceURI===dr&&!ds[W]?!1:!sa[k]&&(ru[k]||!oa[k]):!!(In==="application/xhtml+xml"&&us[d.namespaceURI]):!1},Pe=function(d){nn(t.removed,{element:d});try{S(d).removeChild(d)}catch{h(d)}},Et=function(d,y){try{nn(t.removed,{attribute:y.getAttributeNode(d),from:y})}catch{nn(t.removed,{attribute:null,from:y})}if(y.removeAttribute(d),d==="is")if(Yt||cr)try{Pe(y)}catch{}else try{y.setAttribute(d,"")}catch{}},ia=function(d){let y=null,k=null;if(ss)d="<remove></remove>"+d;else{let Y=Ea(d,/^[\r\n\t ]+/);k=Y&&Y[0]}In==="application/xhtml+xml"&&Jt===Ve&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");let W=ee?ee.createHTML(d):d;if(Jt===Ve)try{y=new p().parseFromString(W,In)}catch{}if(!y||!y.documentElement){y=es.createDocument(Jt,"template",null);try{y.documentElement.innerHTML=cs?ut:W}catch{}}let $=y.body||y.documentElement;return d&&k&&$.insertBefore(n.createTextNode(k),$.childNodes[0]||null),Jt===Ve?Yc.call(y,xt?"html":"body")[0]:xt?y.documentElement:$},aa=function(d){return ji.call(d.ownerDocument||d,d,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},la=function(d){d.normalize();let y=ji.call(d.ownerDocument||d,d,u.SHOW_TEXT|u.SHOW_COMMENT|u.SHOW_CDATA_SECTION|u.SHOW_PROCESSING_INSTRUCTION,null),k=y.nextNode();for(;k;){let W=k.data;tn([sr,ir,ar],$=>{W=rn(W,$," ")}),k.data=W,k=y.nextNode()}},fr=function(d){let y=ae?ae(d):null;return typeof y!="string"||ie(y)!=="form"?!1:typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||d.attributes!==F(d)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==Z(d)||d.childNodes!==_(d)},Cn=function(d){if(!Z||typeof d!="object"||d===null)return!1;try{return Z(d)===Ke.documentFragment}catch{return!1}},hr=function(d){if(!Z||typeof d!="object"||d===null)return!1;try{return typeof Z(d)=="number"}catch{return!1}};function ot(C,d,y){tn(C,k=>{k.call(t,d,y,Qt)})}let ca=function(d){let y=null;if(ot(pe.beforeSanitizeElements,d,null),fr(d))return Pe(d),!0;let k=ie(d.nodeName);if(ot(pe.uponSanitizeElement,d,{tagName:k,allowedTags:oe}),kn&&d.hasChildNodes()&&!hr(d.firstElementChild)&&ge(/<[/\w!]/g,d.innerHTML)&&ge(/<[/\w!]/g,d.textContent)||kn&&d.namespaceURI===Ve&&k==="style"&&hr(d.firstElementChild)||d.nodeType===Ke.progressingInstruction||kn&&d.nodeType===Ke.comment&&ge(/<[/\w]/g,d.data))return Pe(d),!0;if(wn[k]||!(dt.tagCheck instanceof Function&&dt.tagCheck(k))&&!oe[k]){if(!wn[k]&&da(k)&&(se.tagNameCheck instanceof RegExp&&ge(se.tagNameCheck,k)||se.tagNameCheck instanceof Function&&se.tagNameCheck(k)))return!1;if(is&&!Be[k]){let $=S(d),Y=_(d);if(Y&&$){let Ce=Y.length;for(let je=Ce-1;je>=0;--je){let De=f(Y[je],!0);$.insertBefore(De,g(d))}}}return Pe(d),!0}return(Z?Z(d):d.nodeType)===Ke.element&&!au(d)||(k==="noscript"||k==="noembed"||k==="noframes")&&ge(/<\/no(script|embed|frames)/i,d.innerHTML)?(Pe(d),!0):(pt&&d.nodeType===Ke.text&&(y=d.textContent,tn([sr,ir,ar],$=>{y=rn(y,$," ")}),d.textContent!==y&&(nn(t.removed,{element:d.cloneNode()}),d.textContent=y)),ot(pe.afterSanitizeElements,d,null),!1)},ua=function(d,y,k){if(lr[y]||qi&&(y==="id"||y==="name")&&(k in n||k in iu))return!1;let W=le[y]||dt.attributeCheck instanceof Function&&dt.attributeCheck(y,d);if(!(rs&&!lr[y]&&ge(Jc,y))){if(!(Zi&&ge(Qc,y))){if(!W||lr[y]){if(!(da(d)&&(se.tagNameCheck instanceof RegExp&&ge(se.tagNameCheck,d)||se.tagNameCheck instanceof Function&&se.tagNameCheck(d))&&(se.attributeNameCheck instanceof RegExp&&ge(se.attributeNameCheck,y)||se.attributeNameCheck instanceof Function&&se.attributeNameCheck(y,d))||y==="is"&&se.allowCustomizedBuiltInElements&&(se.tagNameCheck instanceof RegExp&&ge(se.tagNameCheck,k)||se.tagNameCheck instanceof Function&&se.tagNameCheck(k))))return!1}else if(!ls[y]){if(!ge(Xi,rn(k,Wi,""))){if(!((y==="src"||y==="xlink:href"||y==="href")&&d!=="script"&&_a(k,"data:")===0&&ea[d])){if(!(Ki&&!ge(eu,rn(k,Wi,"")))){if(k)return!1}}}}}}return!0},lu=P({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),da=function(d){return!lu[Pn(d)]&&ge(tu,d)},pa=function(d){ot(pe.beforeSanitizeAttributes,d,null);let y=d.attributes;if(!y||fr(d))return;let k={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:le,forceKeepAttr:void 0},W=y.length;for(;W--;){let $=y[W],Y=$.name,Ce=$.namespaceURI,je=$.value,De=ie(Y),hs=je,fe=Y==="value"?hs:wu(hs);if(k.attrName=De,k.attrValue=fe,k.keepAttr=!0,k.forceKeepAttr=void 0,ot(pe.uponSanitizeAttribute,d,k),fe=k.attrValue,Ji&&(De==="id"||De==="name")&&_a(fe,Qi)!==0&&(Et(Y,d),fe=Qi+fe),kn&&ge(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,fe)){Et(Y,d);continue}if(De==="attributename"&&Ea(fe,"href")){Et(Y,d);continue}if(k.forceKeepAttr)continue;if(!k.keepAttr){Et(Y,d);continue}if(!Yi&&ge(/\/>/i,fe)){Et(Y,d);continue}pt&&tn([sr,ir,ar],ha=>{fe=rn(fe,ha," ")});let fa=ie(d.nodeName);if(!ua(fa,De,fe)){Et(Y,d);continue}if(ee&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!Ce)switch(m.getAttributeType(fa,De)){case"TrustedHTML":{fe=ee.createHTML(fe);break}case"TrustedScriptURL":{fe=ee.createScriptURL(fe);break}}if(fe!==hs)try{Ce?d.setAttributeNS(Ce,Y,fe):d.setAttribute(Y,fe),fr(d)?Pe(d):xa(t.removed)}catch{Et(Y,d)}}ot(pe.afterSanitizeAttributes,d,null)},mr=function(d){let y=null,k=aa(d);for(ot(pe.beforeSanitizeShadowDOM,d,null);y=k.nextNode();)if(ot(pe.uponSanitizeShadowNode,y,null),ca(y),pa(y),Cn(y.content)&&mr(y.content),(Z?Z(y):y.nodeType)===Ke.element){let $=b?b(y):y.shadowRoot;Cn($)&&(en($),mr($))}ot(pe.afterSanitizeShadowDOM,d,null)},en=function(d){let y=Z?Z(d):d.nodeType;if(y===Ke.element){let $=b?b(d):d.shadowRoot;Cn($)&&(en($),mr($))}let k=_?_(d):d.childNodes;if(!k)return;let W=[];tn(k,$=>{nn(W,$)});for(let $ of W)en($);if(y===Ke.element){let $=ae?ae(d):null;if(typeof $=="string"&&ie($)==="template"){let Y=d.content;Cn(Y)&&en(Y)}}};return t.sanitize=function(C){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},y=null,k=null,W=null,$=null;if(cs=!C,cs&&(C="<!-->"),typeof C!="string"&&!hr(C)&&(C=Nu(C),typeof C!="string"))throw Ln("dirty is not a string, aborting");if(!t.isSupported)return C;if(os||fs(d),t.removed=[],typeof C=="string"&&(An=!1),An){let je=ae?ae(C):C.nodeName;if(typeof je=="string"){let De=ie(je);if(!oe[De]||wn[De])throw Ln("root node is forbidden and cannot be sanitized in-place")}if(fr(C))throw Ln("root node is clobbered and cannot be sanitized in-place");en(C)}else if(hr(C))y=ia("<!---->"),k=y.ownerDocument.importNode(C,!0),k.nodeType===Ke.element&&k.nodeName==="BODY"||k.nodeName==="HTML"?y=k:y.appendChild(k),en(k);else{if(!Yt&&!pt&&!xt&&C.indexOf("<")===-1)return ee&&ur?ee.createHTML(C):C;if(y=ia(C),!y)return Yt?null:ur?ut:""}y&&ss&&Pe(y.firstChild);let Y=aa(An?C:y);for(;W=Y.nextNode();)ca(W),pa(W),Cn(W.content)&&mr(W.content);if(An)return pt&&la(C),C;if(Yt){if(pt&&la(y),cr)for($=Kc.call(y.ownerDocument);y.firstChild;)$.appendChild(y.firstChild);else $=y;return(le.shadowroot||le.shadowrootmode)&&($=qc.call(r,$,!0)),$}let Ce=xt?y.outerHTML:y.innerHTML;return xt&&oe["!doctype"]&&y.ownerDocument&&y.ownerDocument.doctype&&y.ownerDocument.doctype.name&&ge($u,y.ownerDocument.doctype.name)&&(Ce="<!DOCTYPE "+y.ownerDocument.doctype.name+`>
3
+ `+Ce),pt&&tn([sr,ir,ar],je=>{Ce=rn(Ce,je," ")}),ee&&ur?ee.createHTML(Ce):Ce},t.setConfig=function(){let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};fs(C),os=!0},t.clearConfig=function(){Qt=null,os=!1},t.isValidAttribute=function(C,d,y){Qt||fs({});let k=ie(C),W=ie(d);return ua(k,W,y)},t.addHook=function(C,d){typeof d=="function"&&nn(pe[C],d)},t.removeHook=function(C,d){if(d!==void 0){let y=Tu(pe[C],d);return y===-1?void 0:Su(pe[C],y,1)[0]}return xa(pe[C])},t.removeHooks=function(C){pe[C]=[]},t.removeAllHooks=function(){pe=Na()},t}var La=Ma();function Gs(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var St=Gs();function za(e){St=e}var _t={exec:()=>null};function sn(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),o=t[r];return o||(o=e(r),t[r]=o),o}}function z(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(o,s)=>{let i=typeof s=="string"?s:s.source;return i=i.replace(Ee.caret,"$1"),n=n.replace(o,i),r},getRegex:()=>new RegExp(n,t)};return r}var ju=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),Ee={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:sn(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:sn(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:sn(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:sn(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:sn(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:sn(e=>new RegExp(`^ {0,${e}}>`))},Wu=/^(?:[ \t]*(?:\n|$))+/,Xu=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Zu=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Gn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Ku=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Fs=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ba=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Va=z(Ba).replace(/bull/g,Fs).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Yu=z(Ba).replace(/bull/g,Fs).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Hs=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,qu=/^[^\n]+/,$s=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ju=z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",$s).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Qu=z(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Fs).getRegex(),_r="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",zs=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ed=z("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",zs).replace("tag",_r).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ja=z(Hs).replace("hr",Gn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_r).getRegex(),td=z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ja).getRegex(),Bs={blockquote:td,code:Xu,def:Ju,fences:Zu,heading:Ku,hr:Gn,html:ed,lheading:Va,list:Qu,newline:Wu,paragraph:ja,table:_t,text:qu},Pa=z("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Gn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_r).getRegex(),nd={...Bs,lheading:Yu,table:Pa,paragraph:z(Hs).replace("hr",Gn).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Pa).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_r).getRegex()},rd={...Bs,html:z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",zs).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:_t,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:z(Hs).replace("hr",Gn).replace("heading",` *#{1,6} *[^
4
+ ]`).replace("lheading",Va).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},od=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,sd=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Wa=/^( {2,}|\\)\n(?!\s*$)/,id=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,an=/[\p{P}\p{S}]/u,Tr=/[\s\p{P}\p{S}]/u,Vs=/[^\s\p{P}\p{S}]/u,ad=z(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Tr).getRegex(),Xa=/(?!~)[\p{P}\p{S}]/u,ld=/(?!~)[\s\p{P}\p{S}]/u,cd=/(?:[^\s\p{P}\p{S}]|~)/u,ud=z(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",ju?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Za=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,dd=z(Za,"u").replace(/punct/g,an).getRegex(),pd=z(Za,"u").replace(/punct/g,Xa).getRegex(),Ka="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",fd=z(Ka,"gu").replace(/notPunctSpace/g,Vs).replace(/punctSpace/g,Tr).replace(/punct/g,an).getRegex(),hd=z(Ka,"gu").replace(/notPunctSpace/g,cd).replace(/punctSpace/g,ld).replace(/punct/g,Xa).getRegex(),md=z("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Vs).replace(/punctSpace/g,Tr).replace(/punct/g,an).getRegex(),gd=z(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,an).getRegex(),vd="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",yd=z(vd,"gu").replace(/notPunctSpace/g,Vs).replace(/punctSpace/g,Tr).replace(/punct/g,an).getRegex(),bd=z(/\\(punct)/,"gu").replace(/punct/g,an).getRegex(),xd=z(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ed=z(zs).replace("(?:-->|$)","-->").getRegex(),_d=z("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ed).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),br=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Td=z(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",br).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ya=z(/^!?\[(label)\]\[(ref)\]/).replace("label",br).replace("ref",$s).getRegex(),qa=z(/^!?\[(ref)\](?:\[\])?/).replace("ref",$s).getRegex(),Sd=z("reflink|nolink(?!\\()","g").replace("reflink",Ya).replace("nolink",qa).getRegex(),Da=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,js={_backpedal:_t,anyPunctuation:bd,autolink:xd,blockSkip:ud,br:Wa,code:sd,del:_t,delLDelim:_t,delRDelim:_t,emStrongLDelim:dd,emStrongRDelimAst:fd,emStrongRDelimUnd:md,escape:od,link:Td,nolink:qa,punctuation:ad,reflink:Ya,reflinkSearch:Sd,tag:_d,text:id,url:_t},wd={...js,link:z(/^!?\[(label)\]\((.*?)\)/).replace("label",br).getRegex(),reflink:z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",br).getRegex()},Ps={...js,emStrongRDelimAst:hd,emStrongLDelim:pd,delLDelim:gd,delRDelim:yd,url:z(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Da).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:z(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Da).getRegex()},kd={...Ps,br:z(Wa).replace("{2,}","*").getRegex(),text:z(Ps.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},yr={normal:Bs,gfm:nd,pedantic:rd},Dn={normal:js,gfm:Ps,breaks:kd,pedantic:wd},Ad={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Ua=e=>Ad[e];function qe(e,t){if(t){if(Ee.escapeTest.test(e))return e.replace(Ee.escapeReplace,Ua)}else if(Ee.escapeTestNoEncode.test(e))return e.replace(Ee.escapeReplaceNoEncode,Ua);return e}function Ga(e){try{e=encodeURI(e).replace(Ee.percentDecode,"%")}catch{return null}return e}function Fa(e,t){let n=e.replace(Ee.findPipe,(s,i,a)=>{let u=!1,c=i;for(;--c>=0&&a[c]==="\\";)u=!u;return u?"|":" |"}),r=n.split(Ee.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(Ee.slashPipe,"|");return r}function ft(e,t,n){let r=e.length;if(r===0)return"";let o=0;for(;o<r;){let s=e.charAt(r-o-1);if(s===t&&!n)o++;else if(s!==t&&n)o++;else break}return e.slice(0,r-o)}function Ha(e){let t=e.split(`
5
5
  `),n=t.length-1;for(;n>=0&&Ee.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
6
- `)}function Ad(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Id(e,t=0){let n=t,r="";for(let o of e)if(o===" "){let s=4-n%4;r+=" ".repeat(s),n+=s}else r+=o,n++;return r}function Ha(e,t,n,r,o){let s=t.href,i=t.title||null,a=e[1].replace(o.other.outputLinkReplace,"$1");r.state.inLink=!0;let u={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:i,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,u}function Cd(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
6
+ `)}function Id(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function Cd(e,t=0){let n=t,r="";for(let o of e)if(o===" "){let s=4-n%4;r+=" ".repeat(s),n+=s}else r+=o,n++;return r}function $a(e,t,n,r,o){let s=t.href,i=t.title||null,a=e[1].replace(o.other.outputLinkReplace,"$1");r.state.inLink=!0;let u={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:i,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,u}function Nd(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let o=r[1];return t.split(`
7
7
  `).map(s=>{let i=s.match(n.other.beginningSpace);if(i===null)return s;let[a]=i;return a.length>=o.length?s.slice(o.length):s}).join(`
8
- `)}var br=class{options;rules;lexer;constructor(e){this.options=e||Tt}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:Fa(t[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=Cd(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=pt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:pt(t[0],`
9
- `),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:pt(t[0],`
10
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=pt(t[0],`
8
+ `)}var xr=class{options;rules;lexer;constructor(e){this.options=e||St}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=this.options.pedantic?t[0]:Ha(t[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=Nd(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=ft(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:ft(t[0],`
9
+ `),depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ft(t[0],`
10
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=ft(t[0],`
11
11
  `).split(`
12
12
  `),r="",o="",s=[];for(;n.length>0;){let i=!1,a=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))a.push(n[u]),i=!0;else if(!i)a.push(n[u]);else break;n=n.slice(u);let c=a.join(`
13
13
  `),p=c.replace(this.rules.other.blockquoteSetextReplace,`
@@ -18,19 +18,19 @@ ${p}`:p;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
18
18
  `),g=this.blockquote(h);s[s.length-1]=g,r=r.substring(0,r.length-f.raw.length)+g.raw,o=o.substring(0,o.length-f.text.length)+g.text;break}else if(x?.type==="list"){let f=x,h=f.raw+`
19
19
  `+n.join(`
20
20
  `),g=this.list(h);s[s.length-1]=g,r=r.substring(0,r.length-x.raw.length)+g.raw,o=o.substring(0,o.length-f.raw.length)+g.raw,n=h.substring(s.at(-1).raw.length).split(`
21
- `);continue}}return{type:"blockquote",raw:r,tokens:s,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),i=!1;for(;e;){let u=!1,c="",p="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let m=Id(t[2].split(`
21
+ `);continue}}return{type:"blockquote",raw:r,tokens:s,text:o}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,o={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),i=!1;for(;e;){let u=!1,c="",p="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let m=Cd(t[2].split(`
22
22
  `,1)[0],t[1].length),x=e.split(`
23
23
  `,1)[0],f=!m.trim(),h=0;if(this.options.pedantic?(h=2,p=m.trimStart()):f?h=t[1].length+1:(h=m.search(this.rules.other.nonSpaceChar),h=h>4?1:h,p=m.slice(h),h+=t[1].length),f&&this.rules.other.blankLine.test(x)&&(c+=x+`
24
24
  `,e=e.substring(x.length+1),u=!0),!u){let g=this.rules.other.nextBulletRegex(h),_=this.rules.other.hrRegex(h),S=this.rules.other.fencesBeginRegex(h),b=this.rules.other.headingBeginRegex(h),F=this.rules.other.htmlBeginRegex(h),Z=this.rules.other.blockquoteBeginRegex(h);for(;e;){let ae=e.split(`
25
25
  `,1)[0],ee;if(x=ae,this.options.pedantic?(x=x.replace(this.rules.other.listReplaceNesting," "),ee=x):ee=x.replace(this.rules.other.tabCharGlobal," "),S.test(x)||b.test(x)||F.test(x)||Z.test(x)||g.test(x)||_.test(x))break;if(ee.search(this.rules.other.nonSpaceChar)>=h||!x.trim())p+=`
26
26
  `+ee.slice(h);else{if(f||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||S.test(m)||b.test(m)||_.test(m))break;p+=`
27
27
  `+x}f=!x.trim(),c+=ae+`
28
- `,e=e.substring(ae.length+1),m=ee.slice(h)}}o.loose||(i?o.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(i=!0)),o.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),o.raw+=c}let a=o.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let u of o.items){this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]);let c=u.tokens[0];if(u.task&&(c?.type==="text"||c?.type==="paragraph")){u.text=u.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let m=this.lexer.inlineQueue.length-1;m>=0;m--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[m].src)){this.lexer.inlineQueue[m].src=this.lexer.inlineQueue[m].src.replace(this.rules.other.listReplaceTask,"");break}let p=this.rules.other.listTaskCheckbox.exec(u.raw);if(p){let m={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};u.checked=m.checked,o.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=m.raw+u.tokens[0].raw,u.tokens[0].text=m.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(m)):u.tokens.unshift({type:"paragraph",raw:m.raw,text:m.raw,tokens:[m]}):u.tokens.unshift(m)}}else u.task&&(u.task=!1);if(!o.loose){let p=u.tokens.filter(x=>x.type==="space"),m=p.length>0&&p.some(x=>this.rules.other.anyLine.test(x.raw));o.loose=m}}if(o.loose)for(let u of o.items){u.loose=!0;for(let c of u.tokens)c.type==="text"&&(c.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=Fa(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:pt(t[0],`
29
- `),href:r,title:o}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Ga(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
30
- `):[],s={type:"table",raw:pt(t[0],`
31
- `),header:[],align:[],rows:[]};if(n.length===r.length){for(let i of r)this.rules.other.tableAlignRight.test(i)?s.align.push("right"):this.rules.other.tableAlignCenter.test(i)?s.align.push("center"):this.rules.other.tableAlignLeft.test(i)?s.align.push("left"):s.align.push(null);for(let i=0;i<n.length;i++)s.header.push({text:n[i],tokens:this.lexer.inline(n[i]),header:!0,align:s.align[i]});for(let i of o)s.rows.push(Ga(i,s.header.length).map((a,u)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:s.align[u]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:pt(t[0],`
28
+ `,e=e.substring(ae.length+1),m=ee.slice(h)}}o.loose||(i?o.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(i=!0)),o.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),o.raw+=c}let a=o.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;o.raw=o.raw.trimEnd();for(let u of o.items){this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]);let c=u.tokens[0];if(u.task&&(c?.type==="text"||c?.type==="paragraph")){u.text=u.text.replace(this.rules.other.listReplaceTask,""),c.raw=c.raw.replace(this.rules.other.listReplaceTask,""),c.text=c.text.replace(this.rules.other.listReplaceTask,"");for(let m=this.lexer.inlineQueue.length-1;m>=0;m--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[m].src)){this.lexer.inlineQueue[m].src=this.lexer.inlineQueue[m].src.replace(this.rules.other.listReplaceTask,"");break}let p=this.rules.other.listTaskCheckbox.exec(u.raw);if(p){let m={type:"checkbox",raw:p[0]+" ",checked:p[0]!=="[ ]"};u.checked=m.checked,o.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=m.raw+u.tokens[0].raw,u.tokens[0].text=m.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(m)):u.tokens.unshift({type:"paragraph",raw:m.raw,text:m.raw,tokens:[m]}):u.tokens.unshift(m)}}else u.task&&(u.task=!1);if(!o.loose){let p=u.tokens.filter(x=>x.type==="space"),m=p.length>0&&p.some(x=>this.rules.other.anyLine.test(x.raw));o.loose=m}}if(o.loose)for(let u of o.items){u.loose=!0;for(let c of u.tokens)c.type==="text"&&(c.type="paragraph")}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){let n=Ha(t[0]);return{type:"html",block:!0,raw:n,pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:ft(t[0],`
29
+ `),href:r,title:o}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Fa(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
30
+ `):[],s={type:"table",raw:ft(t[0],`
31
+ `),header:[],align:[],rows:[]};if(n.length===r.length){for(let i of r)this.rules.other.tableAlignRight.test(i)?s.align.push("right"):this.rules.other.tableAlignCenter.test(i)?s.align.push("center"):this.rules.other.tableAlignLeft.test(i)?s.align.push("left"):s.align.push(null);for(let i=0;i<n.length;i++)s.header.push({text:n[i],tokens:this.lexer.inline(n[i]),header:!0,align:s.align[i]});for(let i of o)s.rows.push(Fa(i,s.header.length).map((a,u)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:s.align[u]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:ft(t[0],`
32
32
  `),depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
33
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=pt(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=Ad(t[2],"()");if(s===-2)return;if(s>-1){let i=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,i).trim(),t[3]=""}}let r=t[2],o="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],o=s[3])}else o=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),Ha(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=t[r.toLowerCase()];if(!o){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return Ha(n,o,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,s,i,a=o,u=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+o);(r=c.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(i=[...s].length,r[3]||r[4]){a+=i;continue}else if((r[5]||r[6])&&o%3&&!((o+i)%3)){u+=i;continue}if(a-=i,a>0)continue;i=Math.min(i,i+a+u);let p=[...r[0]][0].length,m=e.slice(0,o+r.index+p+i);if(Math.min(o,i)%2){let f=m.slice(1,-1);return{type:"em",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}let x=m.slice(2,-2);return{type:"strong",raw:m,text:x,tokens:this.lexer.inlineTokens(x)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,s,i,a=o,u=this.rules.inline.delRDelim;for(u.lastIndex=0,t=t.slice(-1*e.length+o);(r=u.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(i=[...s].length,i!==o))continue;if(r[3]||r[4]){a+=i;continue}if(a-=i,a>0)continue;i=Math.min(i,i+a);let c=[...r[0]][0].length,p=e.slice(0,o+r.index+c+i),m=p.slice(o,-o);return{type:"del",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else{let o;do o=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(o!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},Ue=class Ps{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Tt,this.options.tokenizer=this.options.tokenizer||new br,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Ee,block:vr.normal,inline:Pn.normal};this.options.pedantic?(n.block=vr.pedantic,n.inline=Pn.pedantic):this.options.gfm&&(n.block=vr.gfm,this.options.breaks?n.inline=Pn.breaks:n.inline=Pn.gfm),this.tokenizer.rules=n}static get rules(){return{block:vr,inline:Pn}}static lex(t,n){return new Ps(n).lex(t)}static lexInline(t,n){return new Ps(n).inlineTokens(t)}lex(t){t=t.replace(Ee.carriageReturn,`
33
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=ft(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=Id(t[2],"()");if(s===-2)return;if(s>-1){let i=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,i).trim(),t[3]=""}}let r=t[2],o="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],o=s[3])}else o=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),$a(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=t[r.toLowerCase()];if(!o){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return $a(n,o,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,s,i,a=o,u=0,c=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+o);(r=c.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(i=[...s].length,r[3]||r[4]){a+=i;continue}else if((r[5]||r[6])&&o%3&&!((o+i)%3)){u+=i;continue}if(a-=i,a>0)continue;i=Math.min(i,i+a+u);let p=[...r[0]][0].length,m=e.slice(0,o+r.index+p+i);if(Math.min(o,i)%2){let f=m.slice(1,-1);return{type:"em",raw:m,text:f,tokens:this.lexer.inlineTokens(f)}}let x=m.slice(2,-2);return{type:"strong",raw:m,text:x,tokens:this.lexer.inlineTokens(x)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),o=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&o&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,s,i,a=o,u=this.rules.inline.delRDelim;for(u.lastIndex=0,t=t.slice(-1*e.length+o);(r=u.exec(t))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(i=[...s].length,i!==o))continue;if(r[3]||r[4]){a+=i;continue}if(a-=i,a>0)continue;i=Math.min(i,i+a);let c=[...r[0]][0].length,p=e.slice(0,o+r.index+c+i),m=p.slice(o,-o);return{type:"del",raw:p,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else{let o;do o=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(o!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},Ue=class Ds{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||St,this.options.tokenizer=this.options.tokenizer||new xr,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Ee,block:yr.normal,inline:Dn.normal};this.options.pedantic?(n.block=yr.pedantic,n.inline=Dn.pedantic):this.options.gfm&&(n.block=yr.gfm,this.options.breaks?n.inline=Dn.breaks:n.inline=Dn.gfm),this.tokenizer.rules=n}static get rules(){return{block:yr,inline:Dn}}static lex(t,n){return new Ds(n).lex(t)}static lexInline(t,n){return new Ds(n).inlineTokens(t)}lex(t){t=t.replace(Ee.carriageReturn,`
34
34
  `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(Ee.tabCharGlobal," ").replace(Ee.spaceLine,""));let o=1/0;for(;t;){if(t.length<o)o=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}let s;if(this.options.extensions?.block?.some(a=>(s=a.call({lexer:this},t,n))?(t=t.substring(s.raw.length),n.push(s),!0):!1))continue;if(s=this.tokenizer.space(t)){t=t.substring(s.raw.length);let a=n.at(-1);s.raw.length===1&&a!==void 0?a.raw+=`
35
35
  `:n.push(s);continue}if(s=this.tokenizer.code(t)){t=t.substring(s.raw.length);let a=n.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
36
36
  `)?"":`
@@ -44,9 +44,9 @@ ${p}`:p;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
44
44
  `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(s),r=i.length!==t.length,t=t.substring(s.raw.length);continue}if(s=this.tokenizer.text(t)){t=t.substring(s.raw.length);let a=n.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
45
45
  `)?"":`
46
46
  `)+s.raw,a.text+=`
47
- `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(s);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){this.tokenizer.lexer=this;let r=t,o=null;if(this.tokens.links){let c=Object.keys(this.tokens.links);if(c.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(r))!==null;)c.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(r))!==null;)r=r.slice(0,o.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(o=this.tokenizer.rules.inline.blockSkip.exec(r))!==null;)s=o[2]?o[2].length:0,r=r.slice(0,o.index+s)+"["+"a".repeat(o[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,a="",u=1/0;for(;t;){if(t.length<u)u=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}i||(a=""),i=!1;let c;if(this.options.extensions?.inline?.some(m=>(c=m.call({lexer:this},t,n))?(t=t.substring(c.raw.length),n.push(c),!0):!1))continue;if(c=this.tokenizer.escape(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.tag(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.link(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(c.raw.length);let m=n.at(-1);c.type==="text"&&m?.type==="text"?(m.raw+=c.raw,m.text+=c.text):n.push(c);continue}if(c=this.tokenizer.emStrong(t,r,a)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.codespan(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.br(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.del(t,r,a)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.autolink(t)){t=t.substring(c.raw.length),n.push(c);continue}if(!this.state.inLink&&(c=this.tokenizer.url(t))){t=t.substring(c.raw.length),n.push(c);continue}let p=t;if(this.options.extensions?.startInline){let m=1/0,x=t.slice(1),f;this.options.extensions.startInline.forEach(h=>{f=h.call({lexer:this},x),typeof f=="number"&&f>=0&&(m=Math.min(m,f))}),m<1/0&&m>=0&&(p=t.substring(0,m+1))}if(c=this.tokenizer.inlineText(p)){t=t.substring(c.raw.length),c.raw.slice(-1)!=="_"&&(a=c.raw.slice(-1)),i=!0;let m=n.at(-1);m?.type==="text"?(m.raw+=c.raw,m.text+=c.text):n.push(c);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},xr=class{options;parser;constructor(e){this.options=e||Tt}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(Ee.notSpaceStart)?.[0],o=e.replace(Ee.endingNewline,"")+`
48
- `;return r?'<pre><code class="language-'+Ye(r)+'">'+(n?o:Ye(o,!0))+`</code></pre>
49
- `:"<pre><code>"+(n?o:Ye(o,!0))+`</code></pre>
47
+ `+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(s);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){this.tokenizer.lexer=this;let r=t,o=null;if(this.tokens.links){let c=Object.keys(this.tokens.links);if(c.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(r))!==null;)c.includes(o[0].slice(o[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,o.index)+"["+"a".repeat(o[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.anyPunctuation.exec(r))!==null;)r=r.slice(0,o.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(o=this.tokenizer.rules.inline.blockSkip.exec(r))!==null;)s=o[2]?o[2].length:0,r=r.slice(0,o.index+s)+"["+"a".repeat(o[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let i=!1,a="",u=1/0;for(;t;){if(t.length<u)u=t.length;else{this.infiniteLoopError(t.charCodeAt(0));break}i||(a=""),i=!1;let c;if(this.options.extensions?.inline?.some(m=>(c=m.call({lexer:this},t,n))?(t=t.substring(c.raw.length),n.push(c),!0):!1))continue;if(c=this.tokenizer.escape(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.tag(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.link(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(c.raw.length);let m=n.at(-1);c.type==="text"&&m?.type==="text"?(m.raw+=c.raw,m.text+=c.text):n.push(c);continue}if(c=this.tokenizer.emStrong(t,r,a)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.codespan(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.br(t)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.del(t,r,a)){t=t.substring(c.raw.length),n.push(c);continue}if(c=this.tokenizer.autolink(t)){t=t.substring(c.raw.length),n.push(c);continue}if(!this.state.inLink&&(c=this.tokenizer.url(t))){t=t.substring(c.raw.length),n.push(c);continue}let p=t;if(this.options.extensions?.startInline){let m=1/0,x=t.slice(1),f;this.options.extensions.startInline.forEach(h=>{f=h.call({lexer:this},x),typeof f=="number"&&f>=0&&(m=Math.min(m,f))}),m<1/0&&m>=0&&(p=t.substring(0,m+1))}if(c=this.tokenizer.inlineText(p)){t=t.substring(c.raw.length),c.raw.slice(-1)!=="_"&&(a=c.raw.slice(-1)),i=!0;let m=n.at(-1);m?.type==="text"?(m.raw+=c.raw,m.text+=c.text):n.push(c);continue}if(t){this.infiniteLoopError(t.charCodeAt(0));break}}return n}infiniteLoopError(t){let n="Infinite loop on byte: "+t;if(this.options.silent)console.error(n);else throw new Error(n)}},Er=class{options;parser;constructor(e){this.options=e||St}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(Ee.notSpaceStart)?.[0],o=e.replace(Ee.endingNewline,"")+`
48
+ `;return r?'<pre><code class="language-'+qe(r)+'">'+(n?o:qe(o,!0))+`</code></pre>
49
+ `:"<pre><code>"+(n?o:qe(o,!0))+`</code></pre>
50
50
  `}blockquote({tokens:e}){return`<blockquote>
51
51
  ${this.parser.parse(e)}</blockquote>
52
52
  `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
@@ -62,8 +62,8 @@ ${this.parser.parse(e)}</blockquote>
62
62
  `}tablerow({text:e}){return`<tr>
63
63
  ${e}</tr>
64
64
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
65
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Ye(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),o=Ua(e);if(o===null)return r;e=o;let s='<a href="'+e+'"';return t&&(s+=' title="'+Ye(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=Ua(e);if(o===null)return Ye(n);e=o;let s=`<img src="${e}" alt="${Ye(n)}"`;return t&&(s+=` title="${Ye(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Ye(e.text)}},js=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Ge=class Ds{options;renderer;textRenderer;constructor(t){this.options=t||Tt,this.options.renderer=this.options.renderer||new xr,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new js}static parse(t,n){return new Ds(n).parse(t)}static parseInline(t,n){return new Ds(n).parseInline(t)}parse(t){this.renderer.parser=this;let n="";for(let r=0;r<t.length;r++){let o=t[r];if(this.options.extensions?.renderers?.[o.type]){let i=o,a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){n+=a||"";continue}}let s=o;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let i='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return n}parseInline(t,n=this.renderer){this.renderer.parser=this;let r="";for(let o=0;o<t.length;o++){let s=t[o];if(this.options.extensions?.renderers?.[s.type]){let a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){r+=a||"";continue}}let i=s;switch(i.type){case"escape":{r+=n.text(i);break}case"html":{r+=n.html(i);break}case"link":{r+=n.link(i);break}case"image":{r+=n.image(i);break}case"checkbox":{r+=n.checkbox(i);break}case"strong":{r+=n.strong(i);break}case"em":{r+=n.em(i);break}case"codespan":{r+=n.codespan(i);break}case"br":{r+=n.br(i);break}case"del":{r+=n.del(i);break}case"text":{r+=n.text(i);break}default:{let a='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}},Dn=class{options;block;constructor(e){this.options=e||Tt}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Ue.lex:Ue.lexInline}provideParser(e=this.block){return e?Ge.parse:Ge.parseInline}},Nd=class{defaults=Us();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ge;Renderer=xr;TextRenderer=js;Lexer=Ue;Tokenizer=br;Hooks=Dn;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let o=r;for(let s of o.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of o.rows)for(let i of s)n=n.concat(this.walkTokens(i.tokens,t));break}case"list":{let o=r;n=n.concat(this.walkTokens(o.items,t));break}default:{let o=r;this.defaults.extensions?.childTokens?.[o.type]?this.defaults.extensions.childTokens[o.type].forEach(s=>{let i=o[s].flat(1/0);n=n.concat(this.walkTokens(i,t))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[o.level];s?s.unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){let o=this.defaults.renderer||new xr(this.defaults);for(let s in n.renderer){if(!(s in o))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let i=s,a=n.renderer[i],u=o[i];o[i]=(...c)=>{let p=a.apply(o,c);return p===!1&&(p=u.apply(o,c)),p||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new br(this.defaults);for(let s in n.tokenizer){if(!(s in o))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=s,a=n.tokenizer[i],u=o[i];o[i]=(...c)=>{let p=a.apply(o,c);return p===!1&&(p=u.apply(o,c)),p}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new Dn;for(let s in n.hooks){if(!(s in o))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let i=s,a=n.hooks[i],u=o[i];Dn.passThroughHooks.has(s)?o[i]=c=>{if(this.defaults.async&&Dn.passThroughHooksRespectAsync.has(s))return(async()=>{let m=await a.call(o,c);return u.call(o,m)})();let p=a.call(o,c);return u.call(o,p)}:o[i]=(...c)=>{if(this.defaults.async)return(async()=>{let m=await a.apply(o,c);return m===!1&&(m=await u.apply(o,c)),m})();let p=a.apply(o,c);return p===!1&&(p=u.apply(o,c)),p}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(i){let a=[];return a.push(s.call(this,i)),o&&(a=a.concat(o.call(this,i))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ue.lex(e,t??this.defaults)}parser(e,t){return Ge.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},o={...this.defaults,...r},s=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(o.hooks&&(o.hooks.options=o,o.hooks.block=e),o.async)return(async()=>{let i=o.hooks?await o.hooks.preprocess(t):t,a=await(o.hooks?await o.hooks.provideLexer(e):e?Ue.lex:Ue.lexInline)(i,o),u=o.hooks?await o.hooks.processAllTokens(a):a;o.walkTokens&&await Promise.all(this.walkTokens(u,o.walkTokens));let c=await(o.hooks?await o.hooks.provideParser(e):e?Ge.parse:Ge.parseInline)(u,o);return o.hooks?await o.hooks.postprocess(c):c})().catch(s);try{o.hooks&&(t=o.hooks.preprocess(t));let i=(o.hooks?o.hooks.provideLexer(e):e?Ue.lex:Ue.lexInline)(t,o);o.hooks&&(i=o.hooks.processAllTokens(i)),o.walkTokens&&this.walkTokens(i,o.walkTokens);let a=(o.hooks?o.hooks.provideParser(e):e?Ge.parse:Ge.parseInline)(i,o);return o.hooks&&(a=o.hooks.postprocess(a)),a}catch(i){return s(i)}}}onError(e,t){return n=>{if(n.message+=`
66
- Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+Ye(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},_t=new Nd;function j(e,t){return _t.parse(e,t)}j.options=j.setOptions=function(e){return _t.setOptions(e),j.defaults=_t.defaults,$a(j.defaults),j};j.getDefaults=Us;j.defaults=Tt;j.use=function(...e){return _t.use(...e),j.defaults=_t.defaults,$a(j.defaults),j};j.walkTokens=function(e,t){return _t.walkTokens(e,t)};j.parseInline=_t.parseInline;j.Parser=Ge;j.parser=Ge.parse;j.Renderer=xr;j.TextRenderer=js;j.Lexer=Ue;j.lexer=Ue.lex;j.Tokenizer=br;j.Hooks=Dn;j.parse=j;var ug=j.options,dg=j.setOptions,pg=j.use,fg=j.walkTokens,hg=j.parseInline;var mg=Ge.parse,gg=Ue.lex;j.setOptions({gfm:!0,breaks:!0});var Rd=["a","p","br","strong","em","b","i","u","s","del","code","pre","ul","ol","li","blockquote","h1","h2","h3","h4","h5","h6","hr","span","table","thead","tbody","tr","th","td","img"],Od=["href","title","class","src","alt","width","height"];function Tr(e){let t=j.parse(e,{async:!1}),n=Ma.sanitize(t,{ALLOWED_TAGS:Rd,ALLOWED_ATTR:Od}),r=document.createElement("template");r.innerHTML=n;for(let o of r.content.querySelectorAll("a[href]"))o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer");return r.innerHTML.trim()}function qa(e,t){for(let n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?t.push({node:n,parent:e}):qa(n,t)}function Ja(e){let t=[];qa(e,t);let n=0;for(let{node:r,parent:o}of t){let s=document.createDocumentFragment();for(let i of r.data.split(/(\s+)/)){if(i==="")continue;if(/\s/.test(i)){s.appendChild(document.createTextNode(i));continue}let a=document.createElement("span");a.className="word",a.style.setProperty("--ag-ui-word-index",String(n)),a.textContent=i,s.appendChild(a),n+=1}o.replaceChild(s,r)}}var Sr=class{chips;palette;#e;#n=[];#i=!1;#p=!1;#s=[];#t=0;constructor(t){this.#e=t,this.chips=document.createElement("div"),this.chips.className="skill-chips",this.chips.hidden=!0,this.palette=document.createElement("div"),this.palette.className="skill-palette",this.palette.setAttribute("role","listbox"),this.palette.hidden=!0}setSkills(t){this.#n=t,this.#a()}enableChips(t){this.#i=t,this.#a()}enableSlash(t){this.#p=t}isOpen(){return!this.palette.hidden}onInput(t){this.#p&&t.startsWith("/")?this.#r(t.slice(1)):this.close()}onKeydown(t){return this.isOpen()?t.key==="ArrowDown"?(this.#o(1),!0):t.key==="ArrowUp"?(this.#o(-1),!0):t.key==="Escape"?(this.close(),!0):t.key==="Enter"?(this.#s.slice(this.#t,this.#t+1).forEach(n=>{this.#u(n)}),!0):!1:!1}close(){this.palette.hidden=!0,this.palette.replaceChildren()}#r(t){let n=t.trim().toLowerCase(),r=this.#n.filter(o=>o.name.toLowerCase().includes(n)||o.title.toLowerCase().includes(n));if(r.length===0){this.close();return}this.#s=r,this.#t=0,this.#l(),this.palette.hidden=!1}#o(t){let n=this.#s.length;this.#t=(this.#t+t+n)%n,this.#l()}#u(t){this.close(),this.#e(t)}#a(){this.chips.replaceChildren();let t=this.#i?this.#n.filter(n=>n.chip===!0):[];this.chips.hidden=t.length===0;for(let n of t){let r=document.createElement("button");r.type="button",r.className="skill-chip",r.textContent=n.title,r.addEventListener("click",()=>this.#u(n)),this.chips.appendChild(r)}}#l(){this.palette.replaceChildren(),this.#s.forEach((t,n)=>{let r=document.createElement("button");r.type="button",r.className="skill-item",r.setAttribute("role","option"),r.setAttribute("aria-selected",n===this.#t?"true":"false");let o=document.createElement("span");if(o.className="skill-item-title",o.textContent=t.title,r.appendChild(o),t.description!==void 0){let s=document.createElement("span");s.className="skill-item-desc",s.textContent=t.description,r.appendChild(s)}r.addEventListener("click",()=>this.#u(t)),this.palette.appendChild(r)})}};var Qa=`
65
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${qe(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),o=Ga(e);if(o===null)return r;e=o;let s='<a href="'+e+'"';return t&&(s+=' title="'+qe(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=Ga(e);if(o===null)return qe(n);e=o;let s=`<img src="${e}" alt="${qe(n)}"`;return t&&(s+=` title="${qe(t)}"`),s+=">",s}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:qe(e.text)}},Ws=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Ge=class Us{options;renderer;textRenderer;constructor(t){this.options=t||St,this.options.renderer=this.options.renderer||new Er,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ws}static parse(t,n){return new Us(n).parse(t)}static parseInline(t,n){return new Us(n).parseInline(t)}parse(t){this.renderer.parser=this;let n="";for(let r=0;r<t.length;r++){let o=t[r];if(this.options.extensions?.renderers?.[o.type]){let i=o,a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){n+=a||"";continue}}let s=o;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let i='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return n}parseInline(t,n=this.renderer){this.renderer.parser=this;let r="";for(let o=0;o<t.length;o++){let s=t[o];if(this.options.extensions?.renderers?.[s.type]){let a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){r+=a||"";continue}}let i=s;switch(i.type){case"escape":{r+=n.text(i);break}case"html":{r+=n.html(i);break}case"link":{r+=n.link(i);break}case"image":{r+=n.image(i);break}case"checkbox":{r+=n.checkbox(i);break}case"strong":{r+=n.strong(i);break}case"em":{r+=n.em(i);break}case"codespan":{r+=n.codespan(i);break}case"br":{r+=n.br(i);break}case"del":{r+=n.del(i);break}case"text":{r+=n.text(i);break}default:{let a='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}},Un=class{options;block;constructor(e){this.options=e||St}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Ue.lex:Ue.lexInline}provideParser(e=this.block){return e?Ge.parse:Ge.parseInline}},Rd=class{defaults=Gs();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ge;Renderer=Er;TextRenderer=Ws;Lexer=Ue;Tokenizer=xr;Hooks=Un;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let o=r;for(let s of o.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of o.rows)for(let i of s)n=n.concat(this.walkTokens(i.tokens,t));break}case"list":{let o=r;n=n.concat(this.walkTokens(o.items,t));break}default:{let o=r;this.defaults.extensions?.childTokens?.[o.type]?this.defaults.extensions.childTokens[o.type].forEach(s=>{let i=o[s].flat(1/0);n=n.concat(this.walkTokens(i,t))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(o=>{if(!o.name)throw new Error("extension name required");if("renderer"in o){let s=t.renderers[o.name];s?t.renderers[o.name]=function(...i){let a=o.renderer.apply(this,i);return a===!1&&(a=s.apply(this,i)),a}:t.renderers[o.name]=o.renderer}if("tokenizer"in o){if(!o.level||o.level!=="block"&&o.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[o.level];s?s.unshift(o.tokenizer):t[o.level]=[o.tokenizer],o.start&&(o.level==="block"?t.startBlock?t.startBlock.push(o.start):t.startBlock=[o.start]:o.level==="inline"&&(t.startInline?t.startInline.push(o.start):t.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(t.childTokens[o.name]=o.childTokens)}),r.extensions=t),n.renderer){let o=this.defaults.renderer||new Er(this.defaults);for(let s in n.renderer){if(!(s in o))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let i=s,a=n.renderer[i],u=o[i];o[i]=(...c)=>{let p=a.apply(o,c);return p===!1&&(p=u.apply(o,c)),p||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new xr(this.defaults);for(let s in n.tokenizer){if(!(s in o))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=s,a=n.tokenizer[i],u=o[i];o[i]=(...c)=>{let p=a.apply(o,c);return p===!1&&(p=u.apply(o,c)),p}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new Un;for(let s in n.hooks){if(!(s in o))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let i=s,a=n.hooks[i],u=o[i];Un.passThroughHooks.has(s)?o[i]=c=>{if(this.defaults.async&&Un.passThroughHooksRespectAsync.has(s))return(async()=>{let m=await a.call(o,c);return u.call(o,m)})();let p=a.call(o,c);return u.call(o,p)}:o[i]=(...c)=>{if(this.defaults.async)return(async()=>{let m=await a.apply(o,c);return m===!1&&(m=await u.apply(o,c)),m})();let p=a.apply(o,c);return p===!1&&(p=u.apply(o,c)),p}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(i){let a=[];return a.push(s.call(this,i)),o&&(a=a.concat(o.call(this,i))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ue.lex(e,t??this.defaults)}parser(e,t){return Ge.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},o={...this.defaults,...r},s=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(o.hooks&&(o.hooks.options=o,o.hooks.block=e),o.async)return(async()=>{let i=o.hooks?await o.hooks.preprocess(t):t,a=await(o.hooks?await o.hooks.provideLexer(e):e?Ue.lex:Ue.lexInline)(i,o),u=o.hooks?await o.hooks.processAllTokens(a):a;o.walkTokens&&await Promise.all(this.walkTokens(u,o.walkTokens));let c=await(o.hooks?await o.hooks.provideParser(e):e?Ge.parse:Ge.parseInline)(u,o);return o.hooks?await o.hooks.postprocess(c):c})().catch(s);try{o.hooks&&(t=o.hooks.preprocess(t));let i=(o.hooks?o.hooks.provideLexer(e):e?Ue.lex:Ue.lexInline)(t,o);o.hooks&&(i=o.hooks.processAllTokens(i)),o.walkTokens&&this.walkTokens(i,o.walkTokens);let a=(o.hooks?o.hooks.provideParser(e):e?Ge.parse:Ge.parseInline)(i,o);return o.hooks&&(a=o.hooks.postprocess(a)),a}catch(i){return s(i)}}}onError(e,t){return n=>{if(n.message+=`
66
+ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+qe(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Tt=new Rd;function j(e,t){return Tt.parse(e,t)}j.options=j.setOptions=function(e){return Tt.setOptions(e),j.defaults=Tt.defaults,za(j.defaults),j};j.getDefaults=Gs;j.defaults=St;j.use=function(...e){return Tt.use(...e),j.defaults=Tt.defaults,za(j.defaults),j};j.walkTokens=function(e,t){return Tt.walkTokens(e,t)};j.parseInline=Tt.parseInline;j.Parser=Ge;j.parser=Ge.parse;j.Renderer=Er;j.TextRenderer=Ws;j.Lexer=Ue;j.lexer=Ue.lex;j.Tokenizer=xr;j.Hooks=Un;j.parse=j;var pg=j.options,fg=j.setOptions,hg=j.use,mg=j.walkTokens,gg=j.parseInline;var vg=Ge.parse,yg=Ue.lex;j.setOptions({gfm:!0,breaks:!0});var Od=["a","p","br","strong","em","b","i","u","s","del","code","pre","ul","ol","li","blockquote","h1","h2","h3","h4","h5","h6","hr","span","table","thead","tbody","tr","th","td","img"],Md=["href","title","class","src","alt","width","height"];function Sr(e){let t=j.parse(e,{async:!1}),n=La.sanitize(t,{ALLOWED_TAGS:Od,ALLOWED_ATTR:Md}),r=document.createElement("template");r.innerHTML=n;for(let o of r.content.querySelectorAll("a[href]"))o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer");return r.innerHTML.trim()}function Ja(e,t){for(let n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE?t.push({node:n,parent:e}):Ja(n,t)}function Qa(e){let t=[];Ja(e,t);let n=0;for(let{node:r,parent:o}of t){let s=document.createDocumentFragment();for(let i of r.data.split(/(\s+)/)){if(i==="")continue;if(/\s/.test(i)){s.appendChild(document.createTextNode(i));continue}let a=document.createElement("span");a.className="word",a.style.setProperty("--ag-ui-word-index",String(n)),a.textContent=i,s.appendChild(a),n+=1}o.replaceChild(s,r)}}var wr=class{chips;palette;#e;#n=[];#i=!1;#u=!1;#a=[];#o=0;constructor(t){this.#e=t,this.chips=document.createElement("div"),this.chips.className="skill-chips",this.chips.hidden=!0,this.palette=document.createElement("div"),this.palette.className="skill-palette",this.palette.setAttribute("role","listbox"),this.palette.hidden=!0}setSkills(t){this.#n=t,this.#f()}enableChips(t){this.#i=t,this.#f()}enableSlash(t){this.#u=t}isOpen(){return!this.palette.hidden}onInput(t){this.#u&&t.startsWith("/")?this.#t(t.slice(1)):this.close()}onKeydown(t){return this.isOpen()?t.key==="ArrowDown"?(this.#r(1),!0):t.key==="ArrowUp"?(this.#r(-1),!0):t.key==="Escape"?(this.close(),!0):t.key==="Enter"?(this.#a.slice(this.#o,this.#o+1).forEach(n=>{this.#s(n)}),!0):!1:!1}close(){this.palette.hidden=!0,this.palette.replaceChildren()}#t(t){let n=t.trim().toLowerCase(),r=this.#n.filter(o=>o.name.toLowerCase().includes(n)||o.title.toLowerCase().includes(n));if(r.length===0){this.close();return}this.#a=r,this.#o=0,this.#l(),this.palette.hidden=!1}#r(t){let n=this.#a.length;this.#o=(this.#o+t+n)%n,this.#l()}#s(t){this.close(),this.#e(t)}#f(){this.chips.replaceChildren();let t=this.#i?this.#n.filter(n=>n.chip===!0):[];this.chips.hidden=t.length===0;for(let n of t){let r=document.createElement("button");r.type="button",r.className="skill-chip",r.textContent=n.title,r.addEventListener("click",()=>this.#s(n)),this.chips.appendChild(r)}}#l(){this.palette.replaceChildren(),this.#a.forEach((t,n)=>{let r=document.createElement("button");r.type="button",r.className="skill-item",r.setAttribute("role","option"),r.setAttribute("aria-selected",n===this.#o?"true":"false");let o=document.createElement("span");if(o.className="skill-item-title",o.textContent=t.title,r.appendChild(o),t.description!==void 0){let s=document.createElement("span");s.className="skill-item-desc",s.textContent=t.description,r.appendChild(s)}r.addEventListener("click",()=>this.#s(t)),this.palette.appendChild(r)})}};var el=`
67
67
  :host {
68
68
  /* Colors */
69
69
  --ag-ui-bg: #ffffff;
@@ -302,7 +302,10 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
302
302
  }
303
303
 
304
304
  /* \u2500\u2500 Incoming-text animations (data-text-animation) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
305
- :host([data-text-animation="fade"]) .message--assistant {
305
+ /* .message--restored (rehydrated history) is excluded: entrance animations are
306
+ for freshly-arriving messages, not the whole transcript replaying on reload.
307
+ Word mode is excluded implicitly \u2014 restored bubbles aren't wrapped. */
308
+ :host([data-text-animation="fade"]) .message--assistant:not(.message--restored) {
306
309
  animation: ag-ui-msg-fade 0.25s ease both;
307
310
  }
308
311
 
@@ -689,19 +692,19 @@ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error
689
692
  font-size: 0.85em;
690
693
  color: var(--ag-ui-danger);
691
694
  }
692
- `;var el={[de.PENDING]:"running\u2026",[de.DONE]:"\u2713 done",[de.ERROR]:"\u26A0 error",[de.DECLINED]:"\u2298 declined"},Md={[de.DONE]:"Result",[de.ERROR]:"Error",[de.DECLINED]:"Declined"},Gn=class{element;#e;#n;#i;constructor(t,n,r=Xe.FULL,o){this.#n=r,this.#i=n,this.element=document.createElement("div"),this.element.className="tool-call",this.element.setAttribute("data-tool-name",t),this.element.setAttribute("data-status",de.PENDING),this.element.setAttribute("data-display",r);let s=document.createElement("div");s.className="tool-call-head";let i=document.createElement("span");if(i.className="tool-call-name",i.textContent=`\u{1F527} ${o??t}`,this.#e=document.createElement("span"),this.#e.className="tool-call-status",this.#e.textContent=el[de.PENDING],s.append(i,this.#e),this.element.append(s),r===Xe.FULL){let a=document.createElement("pre");a.className="tool-call-args",a.textContent=JSON.stringify(n,null,2),this.element.append(a)}}settle(t,n){if(this.element.setAttribute("data-status",t),this.#e.textContent=el[t],this.#n===Xe.MINIMAL)return;let r=document.createElement("button");r.type="button",r.className="tool-call-toggle",r.setAttribute("aria-expanded","false");let o=document.createElement("pre");o.className="tool-call-result",o.hidden=!0,this.#n===Xe.COMPACT?(r.textContent="Details",o.textContent=`args: ${JSON.stringify(this.#i)}
695
+ `;var tl={[de.PENDING]:"running\u2026",[de.DONE]:"\u2713 done",[de.ERROR]:"\u26A0 error",[de.DECLINED]:"\u2298 declined"},Ld={[de.DONE]:"Result",[de.ERROR]:"Error",[de.DECLINED]:"Declined"},Fn=class{element;#e;#n;#i;constructor(t,n,r=Ze.FULL,o){this.#n=r,this.#i=n,this.element=document.createElement("div"),this.element.className="tool-call",this.element.setAttribute("data-tool-name",t),this.element.setAttribute("data-status",de.PENDING),this.element.setAttribute("data-display",r);let s=document.createElement("div");s.className="tool-call-head";let i=document.createElement("span");if(i.className="tool-call-name",i.textContent=`\u{1F527} ${o??t}`,this.#e=document.createElement("span"),this.#e.className="tool-call-status",this.#e.textContent=tl[de.PENDING],s.append(i,this.#e),this.element.append(s),r===Ze.FULL){let a=document.createElement("pre");a.className="tool-call-args",a.textContent=JSON.stringify(n,null,2),this.element.append(a)}}settle(t,n){if(this.element.setAttribute("data-status",t),this.#e.textContent=tl[t],this.#n===Ze.MINIMAL)return;let r=document.createElement("button");r.type="button",r.className="tool-call-toggle",r.setAttribute("aria-expanded","false");let o=document.createElement("pre");o.className="tool-call-result",o.hidden=!0,this.#n===Ze.COMPACT?(r.textContent="Details",o.textContent=`args: ${JSON.stringify(this.#i)}
693
696
 
694
- ${n}`):(r.textContent=Md[t],o.textContent=n),r.addEventListener("click",()=>{let s=o.hidden;o.hidden=!s,r.setAttribute("aria-expanded",String(s))}),this.element.append(r,o)}};var ve=[];for(let e=0;e<256;++e)ve.push((e+256).toString(16).slice(1));function tl(e,t=0){return(ve[e[t+0]]+ve[e[t+1]]+ve[e[t+2]]+ve[e[t+3]]+"-"+ve[e[t+4]]+ve[e[t+5]]+"-"+ve[e[t+6]]+ve[e[t+7]]+"-"+ve[e[t+8]]+ve[e[t+9]]+"-"+ve[e[t+10]]+ve[e[t+11]]+ve[e[t+12]]+ve[e[t+13]]+ve[e[t+14]]+ve[e[t+15]]).toLowerCase()}var Ws,Ld=new Uint8Array(16);function Xs(){if(!Ws){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ws=crypto.getRandomValues.bind(crypto)}return Ws(Ld)}var Pd=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Zs={randomUUID:Pd};function Dd(e,t,n){if(Zs.randomUUID&&!t&&!e)return Zs.randomUUID();e=e||{};let r=e.random??e.rng?.()??Xs();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n=n||0,n<0||n+16>t.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let o=0;o<16;++o)t[n+o]=r[o];return t}return tl(r)}var ft=Dd;var l={};hs(l,{BRAND:()=>lp,DIRTY:()=>St,EMPTY_PATH:()=>Hd,INVALID:()=>O,NEVER:()=>Wp,OK:()=>_e,ParseStatus:()=>ye,Schema:()=>U,ZodAny:()=>gt,ZodArray:()=>at,ZodBigInt:()=>kt,ZodBoolean:()=>At,ZodBranded:()=>Hn,ZodCatch:()=>Gt,ZodDate:()=>It,ZodDefault:()=>Ut,ZodDiscriminatedUnion:()=>Ar,ZodEffects:()=>Me,ZodEnum:()=>Pt,ZodError:()=>we,ZodFirstPartyTypeKind:()=>M,ZodFunction:()=>Cr,ZodIntersection:()=>Ot,ZodIssueCode:()=>E,ZodLazy:()=>Mt,ZodLiteral:()=>Lt,ZodMap:()=>pn,ZodNaN:()=>hn,ZodNativeEnum:()=>Dt,ZodNever:()=>Fe,ZodNull:()=>Nt,ZodNullable:()=>Qe,ZodNumber:()=>wt,ZodObject:()=>ke,ZodOptional:()=>Re,ZodParsedType:()=>A,ZodPipeline:()=>$n,ZodPromise:()=>vt,ZodReadonly:()=>Ft,ZodRecord:()=>Ir,ZodSchema:()=>U,ZodSet:()=>fn,ZodString:()=>mt,ZodSymbol:()=>un,ZodTransformer:()=>Me,ZodTuple:()=>Je,ZodType:()=>U,ZodUndefined:()=>Ct,ZodUnion:()=>Rt,ZodUnknown:()=>it,ZodVoid:()=>dn,addIssueToContext:()=>w,any:()=>vp,array:()=>Ep,bigint:()=>pp,boolean:()=>pl,coerce:()=>jp,custom:()=>cl,date:()=>fp,datetimeRegex:()=>al,defaultErrorMap:()=>ot,discriminatedUnion:()=>wp,effect:()=>Up,enum:()=>Lp,function:()=>Rp,getErrorMap:()=>an,getParsedType:()=>qe,instanceof:()=>up,intersection:()=>kp,isAborted:()=>wr,isAsync:()=>ln,isDirty:()=>kr,isValid:()=>ht,late:()=>cp,lazy:()=>Op,literal:()=>Mp,makeIssue:()=>Fn,map:()=>Cp,nan:()=>dp,nativeEnum:()=>Pp,never:()=>bp,null:()=>gp,nullable:()=>Fp,number:()=>dl,object:()=>_p,objectUtil:()=>Ks,oboolean:()=>Vp,onumber:()=>Bp,optional:()=>Gp,ostring:()=>zp,pipeline:()=>$p,preprocess:()=>Hp,promise:()=>Dp,quotelessJson:()=>Ud,record:()=>Ip,set:()=>Np,setErrorMap:()=>Fd,strictObject:()=>Tp,string:()=>ul,symbol:()=>hp,transformer:()=>Up,tuple:()=>Ap,undefined:()=>mp,union:()=>Sp,unknown:()=>yp,util:()=>H,void:()=>xp});var H;(function(e){e.assertEqual=o=>{};function t(o){}e.assertIs=t;function n(o){throw new Error}e.assertNever=n,e.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},e.getValidEnumValues=o=>{let s=e.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return e.objectValues(i)},e.objectValues=o=>e.objectKeys(o).map(function(s){return o[s]}),e.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},e.find=(o,s)=>{for(let i of o)if(s(i))return i},e.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(H||(H={}));var Ks;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Ks||(Ks={}));var A=H.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),qe=e=>{switch(typeof e){case"undefined":return A.undefined;case"string":return A.string;case"number":return Number.isNaN(e)?A.nan:A.number;case"boolean":return A.boolean;case"function":return A.function;case"bigint":return A.bigint;case"symbol":return A.symbol;case"object":return Array.isArray(e)?A.array:e===null?A.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?A.promise:typeof Map<"u"&&e instanceof Map?A.map:typeof Set<"u"&&e instanceof Set?A.set:typeof Date<"u"&&e instanceof Date?A.date:A.object;default:return A.unknown}};var E=H.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"]),Ud=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),we=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){let n=t||function(s){return s.message},r={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)r._errors.push(n(i));else{let a=r,u=0;for(;u<i.path.length;){let c=i.path[u];u===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(i))):a[c]=a[c]||{_errors:[]},a=a[c],u++}}};return o(this),r}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,H.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){let n={},r=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];n[s]=n[s]||[],n[s].push(t(o))}else r.push(t(o));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};we.create=e=>new we(e);var Gd=(e,t)=>{let n;switch(e.code){case E.invalid_type:e.received===A.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case E.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,H.jsonStringifyReplacer)}`;break;case E.unrecognized_keys:n=`Unrecognized key(s) in object: ${H.joinValues(e.keys,", ")}`;break;case E.invalid_union:n="Invalid input";break;case E.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${H.joinValues(e.options)}`;break;case E.invalid_enum_value:n=`Invalid enum value. Expected ${H.joinValues(e.options)}, received '${e.received}'`;break;case E.invalid_arguments:n="Invalid function arguments";break;case E.invalid_return_type:n="Invalid function return type";break;case E.invalid_date:n="Invalid date";break;case E.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:H.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case E.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case E.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case E.custom:n="Invalid input";break;case E.invalid_intersection_types:n="Intersection results could not be merged";break;case E.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case E.not_finite:n="Number must be finite";break;default:n=t.defaultError,H.assertNever(e)}return{message:n}},ot=Gd;var nl=ot;function Fd(e){nl=e}function an(){return nl}var Fn=e=>{let{data:t,path:n,errorMaps:r,issueData:o}=e,s=[...n,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",u=r.filter(c=>!!c).slice().reverse();for(let c of u)a=c(i,{data:t,defaultError:a}).message;return{...o,path:s,message:a}},Hd=[];function w(e,t){let n=an(),r=Fn({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ot?void 0:ot].filter(o=>!!o)});e.common.issues.push(r)}var ye=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){let r=[];for(let o of n){if(o.status==="aborted")return O;o.status==="dirty"&&t.dirty(),r.push(o.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){let r=[];for(let o of n){let s=await o.key,i=await o.value;r.push({key:s,value:i})}return e.mergeObjectSync(t,r)}static mergeObjectSync(t,n){let r={};for(let o of n){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return O;s.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(r[s.value]=i.value)}return{status:t.value,value:r}}},O=Object.freeze({status:"aborted"}),St=e=>({status:"dirty",value:e}),_e=e=>({status:"valid",value:e}),wr=e=>e.status==="aborted",kr=e=>e.status==="dirty",ht=e=>e.status==="valid",ln=e=>typeof Promise<"u"&&e instanceof Promise;var I;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(I||(I={}));var Oe=class{constructor(t,n,r,o){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},rl=(e,t)=>{if(ht(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new we(e.common.issues);return this._error=n,this._error}}};function L(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:o}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(i,a)=>{let{message:u}=e;return i.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:u??r??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:u??n??a.defaultError}},description:o}}var U=class{get description(){return this._def.description}_getType(t){return qe(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:qe(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ye,ctx:{common:t.parent.common,data:t.data,parsedType:qe(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let n=this._parse(t);if(ln(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){let n=this._parse(t);return Promise.resolve(n)}parse(t,n){let r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qe(t)},o=this._parseSync({data:t,path:r.path,parent:r});return rl(r,o)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qe(t)};if(!this["~standard"].async)try{let r=this._parseSync({data:t,path:[],parent:n});return ht(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(r=>ht(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(t,n){let r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:qe(t)},o=this._parse({data:t,path:r.path,parent:r}),s=await(ln(o)?o:Promise.resolve(o));return rl(r,s)}refine(t,n){let r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,s)=>{let i=t(o),a=()=>s.addIssue({code:E.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,o)=>t(r)?!0:(o.addIssue(typeof n=="function"?n(r,o):n),!1))}_refinement(t){return new Me({schema:this,typeName:M.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,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:n=>this["~validate"](n)}}optional(){return Re.create(this,this._def)}nullable(){return Qe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return at.create(this)}promise(){return vt.create(this,this._def)}or(t){return Rt.create([this,t],this._def)}and(t){return Ot.create(this,t,this._def)}transform(t){return new Me({...L(this._def),schema:this,typeName:M.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let n=typeof t=="function"?t:()=>t;return new Ut({...L(this._def),innerType:this,defaultValue:n,typeName:M.ZodDefault})}brand(){return new Hn({typeName:M.ZodBranded,type:this,...L(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new Gt({...L(this._def),innerType:this,catchValue:n,typeName:M.ZodCatch})}describe(t){let n=this.constructor;return new n({...this._def,description:t})}pipe(t){return $n.create(this,t)}readonly(){return Ft.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},$d=/^c[^\s-]{8,}$/i,zd=/^[0-9a-z]+$/,Bd=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Vd=/^[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,jd=/^[a-z0-9_-]{21}$/i,Wd=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Xd=/^[-+]?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)?)??$/,Zd=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Kd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ys,Yd=/^(?:(?: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])$/,qd=/^(?:(?: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])$/,Jd=/^(([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]))$/,Qd=/^(([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])$/,ep=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,tp=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,sl="((\\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])))",np=new RegExp(`^${sl}$`);function il(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function rp(e){return new RegExp(`^${il(e)}$`)}function al(e){let t=`${sl}T${il(e)}`,n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function op(e,t){return!!((t==="v4"||!t)&&Yd.test(e)||(t==="v6"||!t)&&Jd.test(e))}function sp(e,t){if(!Wd.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(r));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function ip(e,t){return!!((t==="v4"||!t)&&qd.test(e)||(t==="v6"||!t)&&Qd.test(e))}var mt=class e extends U{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==A.string){let s=this._getOrReturnCtx(t);return w(s,{code:E.invalid_type,expected:A.string,received:s.parsedType}),O}let r=new ye,o;for(let s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(o=this._getOrReturnCtx(t,o),w(o,{code:E.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(o=this._getOrReturnCtx(t,o),w(o,{code:E.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){let i=t.data.length>s.value,a=t.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(t,o),i?w(o,{code:E.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&w(o,{code:E.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")Zd.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"email",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Ys||(Ys=new RegExp(Kd,"u")),Ys.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"emoji",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")Vd.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"uuid",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")jd.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"nanoid",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")$d.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"cuid",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")zd.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"cuid2",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")Bd.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"ulid",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),w(o,{validation:"url",code:E.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"regex",code:E.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(t,o),w(o,{code:E.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(o=this._getOrReturnCtx(t,o),w(o,{code:E.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(o=this._getOrReturnCtx(t,o),w(o,{code:E.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?al(s).test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{code:E.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?np.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{code:E.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?rp(s).test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{code:E.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?Xd.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"duration",code:E.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?op(t.data,s.version)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"ip",code:E.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?sp(t.data,s.alg)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"jwt",code:E.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?ip(t.data,s.version)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"cidr",code:E.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?ep.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"base64",code:E.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?tp.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"base64url",code:E.invalid_string,message:s.message}),r.dirty()):H.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(o=>t.test(o),{validation:n,code:E.invalid_string,...I.errToObj(r)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...I.errToObj(t)})}url(t){return this._addCheck({kind:"url",...I.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...I.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...I.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...I.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...I.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...I.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...I.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...I.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...I.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...I.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...I.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...I.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...I.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...I.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...I.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...I.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...I.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...I.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...I.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...I.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...I.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...I.errToObj(n)})}nonempty(t){return this.min(1,I.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};mt.create=e=>new mt({checks:[],typeName:M.ZodString,coerce:e?.coerce??!1,...L(e)});function ap(e,t){let n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=n>r?n:r,s=Number.parseInt(e.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return s%i/10**o}var wt=class e extends U{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==A.number){let s=this._getOrReturnCtx(t);return w(s,{code:E.invalid_type,expected:A.number,received:s.parsedType}),O}let r,o=new ye;for(let s of this._def.checks)s.kind==="int"?H.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),w(r,{code:E.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),w(r,{code:E.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),w(r,{code:E.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?ap(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),w(r,{code:E.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),w(r,{code:E.not_finite,message:s.message}),o.dirty()):H.assertNever(s);return{status:o.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,I.toString(n))}gt(t,n){return this.setLimit("min",t,!1,I.toString(n))}lte(t,n){return this.setLimit("max",t,!0,I.toString(n))}lt(t,n){return this.setLimit("max",t,!1,I.toString(n))}setLimit(t,n,r,o){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:I.toString(o)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:I.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:I.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:I.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:I.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:I.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:I.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:I.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:I.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:I.toString(t)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&H.isInteger(t.value))}get isFinite(){let t=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}};wt.create=e=>new wt({checks:[],typeName:M.ZodNumber,coerce:e?.coerce||!1,...L(e)});var kt=class e extends U{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==A.bigint)return this._getInvalidInput(t);let r,o=new ye;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),w(r,{code:E.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),w(r,{code:E.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),w(r,{code:E.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):H.assertNever(s);return{status:o.value,value:t.data}}_getInvalidInput(t){let n=this._getOrReturnCtx(t);return w(n,{code:E.invalid_type,expected:A.bigint,received:n.parsedType}),O}gte(t,n){return this.setLimit("min",t,!0,I.toString(n))}gt(t,n){return this.setLimit("min",t,!1,I.toString(n))}lte(t,n){return this.setLimit("max",t,!0,I.toString(n))}lt(t,n){return this.setLimit("max",t,!1,I.toString(n))}setLimit(t,n,r,o){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:I.toString(o)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:I.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:I.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:I.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:I.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:I.toString(n)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};kt.create=e=>new kt({checks:[],typeName:M.ZodBigInt,coerce:e?.coerce??!1,...L(e)});var At=class extends U{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==A.boolean){let r=this._getOrReturnCtx(t);return w(r,{code:E.invalid_type,expected:A.boolean,received:r.parsedType}),O}return _e(t.data)}};At.create=e=>new At({typeName:M.ZodBoolean,coerce:e?.coerce||!1,...L(e)});var It=class e extends U{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==A.date){let s=this._getOrReturnCtx(t);return w(s,{code:E.invalid_type,expected:A.date,received:s.parsedType}),O}if(Number.isNaN(t.data.getTime())){let s=this._getOrReturnCtx(t);return w(s,{code:E.invalid_date}),O}let r=new ye,o;for(let s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(o=this._getOrReturnCtx(t,o),w(o,{code:E.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(o=this._getOrReturnCtx(t,o),w(o,{code:E.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):H.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:I.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:I.toString(n)})}get minDate(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}};It.create=e=>new It({checks:[],coerce:e?.coerce||!1,typeName:M.ZodDate,...L(e)});var un=class extends U{_parse(t){if(this._getType(t)!==A.symbol){let r=this._getOrReturnCtx(t);return w(r,{code:E.invalid_type,expected:A.symbol,received:r.parsedType}),O}return _e(t.data)}};un.create=e=>new un({typeName:M.ZodSymbol,...L(e)});var Ct=class extends U{_parse(t){if(this._getType(t)!==A.undefined){let r=this._getOrReturnCtx(t);return w(r,{code:E.invalid_type,expected:A.undefined,received:r.parsedType}),O}return _e(t.data)}};Ct.create=e=>new Ct({typeName:M.ZodUndefined,...L(e)});var Nt=class extends U{_parse(t){if(this._getType(t)!==A.null){let r=this._getOrReturnCtx(t);return w(r,{code:E.invalid_type,expected:A.null,received:r.parsedType}),O}return _e(t.data)}};Nt.create=e=>new Nt({typeName:M.ZodNull,...L(e)});var gt=class extends U{constructor(){super(...arguments),this._any=!0}_parse(t){return _e(t.data)}};gt.create=e=>new gt({typeName:M.ZodAny,...L(e)});var it=class extends U{constructor(){super(...arguments),this._unknown=!0}_parse(t){return _e(t.data)}};it.create=e=>new it({typeName:M.ZodUnknown,...L(e)});var Fe=class extends U{_parse(t){let n=this._getOrReturnCtx(t);return w(n,{code:E.invalid_type,expected:A.never,received:n.parsedType}),O}};Fe.create=e=>new Fe({typeName:M.ZodNever,...L(e)});var dn=class extends U{_parse(t){if(this._getType(t)!==A.undefined){let r=this._getOrReturnCtx(t);return w(r,{code:E.invalid_type,expected:A.void,received:r.parsedType}),O}return _e(t.data)}};dn.create=e=>new dn({typeName:M.ZodVoid,...L(e)});var at=class e extends U{_parse(t){let{ctx:n,status:r}=this._processInputParams(t),o=this._def;if(n.parsedType!==A.array)return w(n,{code:E.invalid_type,expected:A.array,received:n.parsedType}),O;if(o.exactLength!==null){let i=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(i||a)&&(w(n,{code:i?E.too_big:E.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),r.dirty())}if(o.minLength!==null&&n.data.length<o.minLength.value&&(w(n,{code:E.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(w(n,{code:E.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((i,a)=>o.type._parseAsync(new Oe(n,i,n.path,a)))).then(i=>ye.mergeArray(r,i));let s=[...n.data].map((i,a)=>o.type._parseSync(new Oe(n,i,n.path,a)));return ye.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:I.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:I.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:I.toString(n)}})}nonempty(t){return this.min(1,t)}};at.create=(e,t)=>new at({type:e,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray,...L(t)});function cn(e){if(e instanceof ke){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Re.create(cn(r))}return new ke({...e._def,shape:()=>t})}else return e instanceof at?new at({...e._def,type:cn(e.element)}):e instanceof Re?Re.create(cn(e.unwrap())):e instanceof Qe?Qe.create(cn(e.unwrap())):e instanceof Je?Je.create(e.items.map(t=>cn(t))):e}var ke=class e extends U{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),n=H.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==A.object){let c=this._getOrReturnCtx(t);return w(c,{code:E.invalid_type,expected:A.object,received:c.parsedType}),O}let{status:r,ctx:o}=this._processInputParams(t),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fe&&this._def.unknownKeys==="strip"))for(let c in o.data)i.includes(c)||a.push(c);let u=[];for(let c of i){let p=s[c],m=o.data[c];u.push({key:{status:"valid",value:c},value:p._parse(new Oe(o,m,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof Fe){let c=this._def.unknownKeys;if(c==="passthrough")for(let p of a)u.push({key:{status:"valid",value:p},value:{status:"valid",value:o.data[p]}});else if(c==="strict")a.length>0&&(w(o,{code:E.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let p of a){let m=o.data[p];u.push({key:{status:"valid",value:p},value:c._parse(new Oe(o,m,o.path,p)),alwaysSet:p in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let c=[];for(let p of u){let m=await p.key,x=await p.value;c.push({key:m,value:x,alwaysSet:p.alwaysSet})}return c}).then(c=>ye.mergeObjectSync(r,c)):ye.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(t){return I.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{let o=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:I.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:M.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let r of H.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let r of H.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new e({...this._def,shape:()=>n})}deepPartial(){return cn(this)}partial(t){let n={};for(let r of H.objectKeys(this.shape)){let o=this.shape[r];t&&!t[r]?n[r]=o:n[r]=o.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let r of H.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Re;)s=s._def.innerType;n[r]=s}return new e({...this._def,shape:()=>n})}keyof(){return ll(H.objectKeys(this.shape))}};ke.create=(e,t)=>new ke({shape:()=>e,unknownKeys:"strip",catchall:Fe.create(),typeName:M.ZodObject,...L(t)});ke.strictCreate=(e,t)=>new ke({shape:()=>e,unknownKeys:"strict",catchall:Fe.create(),typeName:M.ZodObject,...L(t)});ke.lazycreate=(e,t)=>new ke({shape:e,unknownKeys:"strip",catchall:Fe.create(),typeName:M.ZodObject,...L(t)});var Rt=class extends U{_parse(t){let{ctx:n}=this._processInputParams(t),r=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new we(a.ctx.common.issues));return w(n,{code:E.invalid_union,unionErrors:i}),O}if(n.common.async)return Promise.all(r.map(async s=>{let i={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let u of r){let c={...n,common:{...n.common,issues:[]},parent:null},p=u._parseSync({data:n.data,path:n.path,parent:c});if(p.status==="valid")return p;p.status==="dirty"&&!s&&(s={result:p,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(u=>new we(u));return w(n,{code:E.invalid_union,unionErrors:a}),O}}get options(){return this._def.options}};Rt.create=(e,t)=>new Rt({options:e,typeName:M.ZodUnion,...L(t)});var st=e=>e instanceof Mt?st(e.schema):e instanceof Me?st(e.innerType()):e instanceof Lt?[e.value]:e instanceof Pt?e.options:e instanceof Dt?H.objectValues(e.enum):e instanceof Ut?st(e._def.innerType):e instanceof Ct?[void 0]:e instanceof Nt?[null]:e instanceof Re?[void 0,...st(e.unwrap())]:e instanceof Qe?[null,...st(e.unwrap())]:e instanceof Hn||e instanceof Ft?st(e.unwrap()):e instanceof Gt?st(e._def.innerType):[],Ar=class e extends U{_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==A.object)return w(n,{code:E.invalid_type,expected:A.object,received:n.parsedType}),O;let r=this.discriminator,o=n.data[r],s=this.optionsMap.get(o);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(w(n,{code:E.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),O)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let o=new Map;for(let s of n){let i=st(s.shape[t]);if(!i.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);o.set(a,s)}}return new e({typeName:M.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:o,...L(r)})}};function qs(e,t){let n=qe(e),r=qe(t);if(e===t)return{valid:!0,data:e};if(n===A.object&&r===A.object){let o=H.objectKeys(t),s=H.objectKeys(e).filter(a=>o.indexOf(a)!==-1),i={...e,...t};for(let a of s){let u=qs(e[a],t[a]);if(!u.valid)return{valid:!1};i[a]=u.data}return{valid:!0,data:i}}else if(n===A.array&&r===A.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let s=0;s<e.length;s++){let i=e[s],a=t[s],u=qs(i,a);if(!u.valid)return{valid:!1};o.push(u.data)}return{valid:!0,data:o}}else return n===A.date&&r===A.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Ot=class extends U{_parse(t){let{status:n,ctx:r}=this._processInputParams(t),o=(s,i)=>{if(wr(s)||wr(i))return O;let a=qs(s.value,i.value);return a.valid?((kr(s)||kr(i))&&n.dirty(),{status:n.value,value:a.data}):(w(r,{code:E.invalid_intersection_types}),O)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Ot.create=(e,t,n)=>new Ot({left:e,right:t,typeName:M.ZodIntersection,...L(n)});var Je=class e extends U{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==A.array)return w(r,{code:E.invalid_type,expected:A.array,received:r.parsedType}),O;if(r.data.length<this._def.items.length)return w(r,{code:E.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),O;!this._def.rest&&r.data.length>this._def.items.length&&(w(r,{code:E.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((i,a)=>{let u=this._def.items[a]||this._def.rest;return u?u._parse(new Oe(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(s).then(i=>ye.mergeArray(n,i)):ye.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Je.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Je({items:e,typeName:M.ZodTuple,rest:null,...L(t)})};var Ir=class e extends U{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==A.object)return w(r,{code:E.invalid_type,expected:A.object,received:r.parsedType}),O;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in r.data)o.push({key:s._parse(new Oe(r,a,r.path,a)),value:i._parse(new Oe(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?ye.mergeObjectAsync(n,o):ye.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof U?new e({keyType:t,valueType:n,typeName:M.ZodRecord,...L(r)}):new e({keyType:mt.create(),valueType:t,typeName:M.ZodRecord,...L(n)})}},pn=class extends U{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==A.map)return w(r,{code:E.invalid_type,expected:A.map,received:r.parsedType}),O;let o=this._def.keyType,s=this._def.valueType,i=[...r.data.entries()].map(([a,u],c)=>({key:o._parse(new Oe(r,a,r.path,[c,"key"])),value:s._parse(new Oe(r,u,r.path,[c,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let u of i){let c=await u.key,p=await u.value;if(c.status==="aborted"||p.status==="aborted")return O;(c.status==="dirty"||p.status==="dirty")&&n.dirty(),a.set(c.value,p.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let u of i){let c=u.key,p=u.value;if(c.status==="aborted"||p.status==="aborted")return O;(c.status==="dirty"||p.status==="dirty")&&n.dirty(),a.set(c.value,p.value)}return{status:n.value,value:a}}}};pn.create=(e,t,n)=>new pn({valueType:t,keyType:e,typeName:M.ZodMap,...L(n)});var fn=class e extends U{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==A.set)return w(r,{code:E.invalid_type,expected:A.set,received:r.parsedType}),O;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(w(r,{code:E.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(w(r,{code:E.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),n.dirty());let s=this._def.valueType;function i(u){let c=new Set;for(let p of u){if(p.status==="aborted")return O;p.status==="dirty"&&n.dirty(),c.add(p.value)}return{status:n.value,value:c}}let a=[...r.data.values()].map((u,c)=>s._parse(new Oe(r,u,r.path,c)));return r.common.async?Promise.all(a).then(u=>i(u)):i(a)}min(t,n){return new e({...this._def,minSize:{value:t,message:I.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:I.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}};fn.create=(e,t)=>new fn({valueType:e,minSize:null,maxSize:null,typeName:M.ZodSet,...L(t)});var Cr=class e extends U{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==A.function)return w(n,{code:E.invalid_type,expected:A.function,received:n.parsedType}),O;function r(a,u){return Fn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,an(),ot].filter(c=>!!c),issueData:{code:E.invalid_arguments,argumentsError:u}})}function o(a,u){return Fn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,an(),ot].filter(c=>!!c),issueData:{code:E.invalid_return_type,returnTypeError:u}})}let s={errorMap:n.common.contextualErrorMap},i=n.data;if(this._def.returns instanceof vt){let a=this;return _e(async function(...u){let c=new we([]),p=await a._def.args.parseAsync(u,s).catch(f=>{throw c.addIssue(r(u,f)),c}),m=await Reflect.apply(i,this,p);return await a._def.returns._def.type.parseAsync(m,s).catch(f=>{throw c.addIssue(o(m,f)),c})})}else{let a=this;return _e(function(...u){let c=a._def.args.safeParse(u,s);if(!c.success)throw new we([r(u,c.error)]);let p=Reflect.apply(i,this,c.data),m=a._def.returns.safeParse(p,s);if(!m.success)throw new we([o(p,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Je.create(t).rest(it.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new e({args:t||Je.create([]).rest(it.create()),returns:n||it.create(),typeName:M.ZodFunction,...L(r)})}},Mt=class extends U{get schema(){return this._def.getter()}_parse(t){let{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};Mt.create=(e,t)=>new Mt({getter:e,typeName:M.ZodLazy,...L(t)});var Lt=class extends U{_parse(t){if(t.data!==this._def.value){let n=this._getOrReturnCtx(t);return w(n,{received:n.data,code:E.invalid_literal,expected:this._def.value}),O}return{status:"valid",value:t.data}}get value(){return this._def.value}};Lt.create=(e,t)=>new Lt({value:e,typeName:M.ZodLiteral,...L(t)});function ll(e,t){return new Pt({values:e,typeName:M.ZodEnum,...L(t)})}var Pt=class e extends U{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),r=this._def.values;return w(n,{expected:H.joinValues(r),received:n.parsedType,code:E.invalid_type}),O}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let n=this._getOrReturnCtx(t),r=this._def.values;return w(n,{received:n.data,code:E.invalid_enum_value,options:r}),O}return _e(t.data)}get options(){return this._def.values}get enum(){let t={};for(let n of this._def.values)t[n]=n;return t}get Values(){let t={};for(let n of this._def.values)t[n]=n;return t}get Enum(){let t={};for(let n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}};Pt.create=ll;var Dt=class extends U{_parse(t){let n=H.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==A.string&&r.parsedType!==A.number){let o=H.objectValues(n);return w(r,{expected:H.joinValues(o),received:r.parsedType,code:E.invalid_type}),O}if(this._cache||(this._cache=new Set(H.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let o=H.objectValues(n);return w(r,{received:r.data,code:E.invalid_enum_value,options:o}),O}return _e(t.data)}get enum(){return this._def.values}};Dt.create=(e,t)=>new Dt({values:e,typeName:M.ZodNativeEnum,...L(t)});var vt=class extends U{unwrap(){return this._def.type}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==A.promise&&n.common.async===!1)return w(n,{code:E.invalid_type,expected:A.promise,received:n.parsedType}),O;let r=n.parsedType===A.promise?n.data:Promise.resolve(n.data);return _e(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};vt.create=(e,t)=>new vt({type:e,typeName:M.ZodPromise,...L(t)});var Me=class extends U{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===M.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:r}=this._processInputParams(t),o=this._def.effect||null,s={addIssue:i=>{w(r,i),i.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(r.data,s);if(r.common.async)return Promise.resolve(i).then(async a=>{if(n.value==="aborted")return O;let u=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return u.status==="aborted"?O:u.status==="dirty"?St(u.value):n.value==="dirty"?St(u.value):u});{if(n.value==="aborted")return O;let a=this._def.schema._parseSync({data:i,path:r.path,parent:r});return a.status==="aborted"?O:a.status==="dirty"?St(a.value):n.value==="dirty"?St(a.value):a}}if(o.type==="refinement"){let i=a=>{let u=o.refinement(a,s);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?O:(a.status==="dirty"&&n.dirty(),i(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?O:(a.status==="dirty"&&n.dirty(),i(a.value).then(()=>({status:n.value,value:a.value}))))}if(o.type==="transform")if(r.common.async===!1){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ht(i))return O;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>ht(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:n.value,value:a})):O);H.assertNever(o)}};Me.create=(e,t,n)=>new Me({schema:e,typeName:M.ZodEffects,effect:t,...L(n)});Me.createWithPreprocess=(e,t,n)=>new Me({schema:t,effect:{type:"preprocess",transform:e},typeName:M.ZodEffects,...L(n)});var Re=class extends U{_parse(t){return this._getType(t)===A.undefined?_e(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Re.create=(e,t)=>new Re({innerType:e,typeName:M.ZodOptional,...L(t)});var Qe=class extends U{_parse(t){return this._getType(t)===A.null?_e(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Qe.create=(e,t)=>new Qe({innerType:e,typeName:M.ZodNullable,...L(t)});var Ut=class extends U{_parse(t){let{ctx:n}=this._processInputParams(t),r=n.data;return n.parsedType===A.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Ut.create=(e,t)=>new Ut({innerType:e,typeName:M.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...L(t)});var Gt=class extends U{_parse(t){let{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ln(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new we(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new we(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Gt.create=(e,t)=>new Gt({innerType:e,typeName:M.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...L(t)});var hn=class extends U{_parse(t){if(this._getType(t)!==A.nan){let r=this._getOrReturnCtx(t);return w(r,{code:E.invalid_type,expected:A.nan,received:r.parsedType}),O}return{status:"valid",value:t.data}}};hn.create=e=>new hn({typeName:M.ZodNaN,...L(e)});var lp=Symbol("zod_brand"),Hn=class extends U{_parse(t){let{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},$n=class e extends U{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?O:s.status==="dirty"?(n.dirty(),St(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{let o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?O:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(t,n){return new e({in:t,out:n,typeName:M.ZodPipeline})}},Ft=class extends U{_parse(t){let n=this._def.innerType._parse(t),r=o=>(ht(o)&&(o.value=Object.freeze(o.value)),o);return ln(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};Ft.create=(e,t)=>new Ft({innerType:e,typeName:M.ZodReadonly,...L(t)});function ol(e,t){let n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function cl(e,t={},n){return e?gt.create().superRefine((r,o)=>{let s=e(r);if(s instanceof Promise)return s.then(i=>{if(!i){let a=ol(t,r),u=a.fatal??n??!0;o.addIssue({code:"custom",...a,fatal:u})}});if(!s){let i=ol(t,r),a=i.fatal??n??!0;o.addIssue({code:"custom",...i,fatal:a})}}):gt.create()}var cp={object:ke.lazycreate},M;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(M||(M={}));var up=(e,t={message:`Input not instance of ${e.name}`})=>cl(n=>n instanceof e,t),ul=mt.create,dl=wt.create,dp=hn.create,pp=kt.create,pl=At.create,fp=It.create,hp=un.create,mp=Ct.create,gp=Nt.create,vp=gt.create,yp=it.create,bp=Fe.create,xp=dn.create,Ep=at.create,_p=ke.create,Tp=ke.strictCreate,Sp=Rt.create,wp=Ar.create,kp=Ot.create,Ap=Je.create,Ip=Ir.create,Cp=pn.create,Np=fn.create,Rp=Cr.create,Op=Mt.create,Mp=Lt.create,Lp=Pt.create,Pp=Dt.create,Dp=vt.create,Up=Me.create,Gp=Re.create,Fp=Qe.create,Hp=Me.createWithPreprocess,$p=$n.create,zp=()=>ul().optional(),Bp=()=>dl().optional(),Vp=()=>pl().optional(),jp={string:(e=>mt.create({...e,coerce:!0})),number:(e=>wt.create({...e,coerce:!0})),boolean:(e=>At.create({...e,coerce:!0})),bigint:(e=>kt.create({...e,coerce:!0})),date:(e=>It.create({...e,coerce:!0}))};var Wp=O;var Xp=l.object({name:l.string(),arguments:l.string()}),Zp=l.object({id:l.string(),type:l.literal("function"),function:Xp,encryptedValue:l.string().optional()}),Nr=l.object({id:l.string(),role:l.string(),content:l.string().optional(),name:l.string().optional(),encryptedValue:l.string().optional()}),Kp=l.object({type:l.literal("text"),text:l.string()}),Yp=l.object({type:l.literal("data"),value:l.string(),mimeType:l.string()}),qp=l.object({type:l.literal("url"),value:l.string(),mimeType:l.string().optional()}),Rr=l.discriminatedUnion("type",[Yp,qp]),Jp=l.object({type:l.literal("image"),source:Rr,metadata:l.unknown().optional()}),Qp=l.object({type:l.literal("audio"),source:Rr,metadata:l.unknown().optional()}),ef=l.object({type:l.literal("video"),source:Rr,metadata:l.unknown().optional()}),tf=l.object({type:l.literal("document"),source:Rr,metadata:l.unknown().optional()});var fl=l.object({type:l.literal("binary"),mimeType:l.string(),id:l.string().optional(),url:l.string().optional(),data:l.string().optional(),filename:l.string().optional()}),hl=(e,t)=>{!e.id&&!e.url&&!e.data&&t.addIssue({code:l.ZodIssueCode.custom,message:"BinaryInputContent requires at least one of id, url, or data.",path:["id"]})},fv=fl.superRefine((e,t)=>{hl(e,t)}),nf=l.discriminatedUnion("type",[Kp,Jp,Qp,ef,tf,fl]),rf=nf.superRefine((e,t)=>{e.type==="binary"&&hl(e,t)}),of=Nr.extend({role:l.literal("developer"),content:l.string()}),sf=Nr.extend({role:l.literal("system"),content:l.string()}),af=Nr.extend({role:l.literal("assistant"),content:l.string().optional(),toolCalls:l.array(Zp).optional()}),lf=Nr.extend({role:l.literal("user"),content:l.union([l.string(),l.array(rf)])}),cf=l.object({id:l.string(),content:l.string(),role:l.literal("tool"),toolCallId:l.string(),error:l.string().optional(),encryptedValue:l.string().optional()}),uf=l.object({id:l.string(),role:l.literal("activity"),activityType:l.string(),content:l.record(l.any())}),df=l.object({id:l.string(),role:l.literal("reasoning"),content:l.string(),encryptedValue:l.string().optional()}),ml=l.discriminatedUnion("role",[of,sf,af,lf,cf,uf,df]),hv=l.union([l.literal("developer"),l.literal("system"),l.literal("assistant"),l.literal("user"),l.literal("tool"),l.literal("activity"),l.literal("reasoning")]),pf=l.object({description:l.string(),value:l.string()}),gl=l.object({name:l.string(),description:l.string(),parameters:l.any(),metadata:l.record(l.any()).optional()}),ff=l.object({id:l.string(),reason:l.string(),message:l.string().optional(),toolCallId:l.string().optional(),responseSchema:l.record(l.any()).optional(),expiresAt:l.string().optional(),metadata:l.record(l.any()).optional()}),hf=l.object({interruptId:l.string(),status:l.enum(["resolved","cancelled"]),payload:l.any().optional()}),mf=l.object({threadId:l.string(),runId:l.string(),parentRunId:l.string().optional(),state:l.any(),messages:l.array(ml),tools:l.array(gl),context:l.array(pf),forwardedProps:l.any(),resume:l.array(hf).optional()}),gf=l.any(),q=class extends Error{constructor(e){super(e)}},Js=class extends q{constructor(){super("Connect not implemented. This method is not supported by the current agent.")}},vf=l.object({name:l.string(),description:l.string().optional()}),yf=l.object({name:l.string().optional(),type:l.string().optional(),description:l.string().optional(),version:l.string().optional(),provider:l.string().optional(),documentationUrl:l.string().optional(),metadata:l.record(l.unknown()).optional()}),bf=l.object({streaming:l.boolean().optional(),websocket:l.boolean().optional(),httpBinary:l.boolean().optional(),pushNotifications:l.boolean().optional(),resumable:l.boolean().optional()}),xf=l.object({supported:l.boolean().optional(),items:l.array(gl).optional(),parallelCalls:l.boolean().optional(),clientProvided:l.boolean().optional()}),Ef=l.object({structuredOutput:l.boolean().optional(),supportedMimeTypes:l.array(l.string()).optional()}),_f=l.object({snapshots:l.boolean().optional(),deltas:l.boolean().optional(),memory:l.boolean().optional(),persistentState:l.boolean().optional()}),Tf=l.object({supported:l.boolean().optional(),delegation:l.boolean().optional(),handoffs:l.boolean().optional(),subAgents:l.array(vf).optional()}),Sf=l.object({supported:l.boolean().optional(),streaming:l.boolean().optional(),encrypted:l.boolean().optional()}),wf=l.object({image:l.boolean().optional(),audio:l.boolean().optional(),video:l.boolean().optional(),pdf:l.boolean().optional(),file:l.boolean().optional()}),kf=l.object({image:l.boolean().optional(),audio:l.boolean().optional()}),Af=l.object({input:wf.optional(),output:kf.optional()}),If=l.object({codeExecution:l.boolean().optional(),sandboxed:l.boolean().optional(),maxIterations:l.number().optional(),maxExecutionTime:l.number().optional()}),Cf=l.object({supported:l.boolean().optional(),approvals:l.boolean().optional(),interventions:l.boolean().optional(),feedback:l.boolean().optional(),interrupts:l.boolean().optional(),approveWithEdits:l.boolean().optional()}),mv=l.object({identity:yf.optional(),transport:bf.optional(),tools:xf.optional(),output:Ef.optional(),state:_f.optional(),multiAgent:Tf.optional(),reasoning:Sf.optional(),multimodal:Af.optional(),execution:If.optional(),humanInTheLoop:Cf.optional(),custom:l.record(l.unknown()).optional()}),vl=l.union([l.literal("developer"),l.literal("system"),l.literal("assistant"),l.literal("user")]),v=(function(e){return e.TEXT_MESSAGE_START="TEXT_MESSAGE_START",e.TEXT_MESSAGE_CONTENT="TEXT_MESSAGE_CONTENT",e.TEXT_MESSAGE_END="TEXT_MESSAGE_END",e.TEXT_MESSAGE_CHUNK="TEXT_MESSAGE_CHUNK",e.TOOL_CALL_START="TOOL_CALL_START",e.TOOL_CALL_ARGS="TOOL_CALL_ARGS",e.TOOL_CALL_END="TOOL_CALL_END",e.TOOL_CALL_CHUNK="TOOL_CALL_CHUNK",e.TOOL_CALL_RESULT="TOOL_CALL_RESULT",e.THINKING_START="THINKING_START",e.THINKING_END="THINKING_END",e.THINKING_TEXT_MESSAGE_START="THINKING_TEXT_MESSAGE_START",e.THINKING_TEXT_MESSAGE_CONTENT="THINKING_TEXT_MESSAGE_CONTENT",e.THINKING_TEXT_MESSAGE_END="THINKING_TEXT_MESSAGE_END",e.STATE_SNAPSHOT="STATE_SNAPSHOT",e.STATE_DELTA="STATE_DELTA",e.MESSAGES_SNAPSHOT="MESSAGES_SNAPSHOT",e.ACTIVITY_SNAPSHOT="ACTIVITY_SNAPSHOT",e.ACTIVITY_DELTA="ACTIVITY_DELTA",e.RAW="RAW",e.CUSTOM="CUSTOM",e.RUN_STARTED="RUN_STARTED",e.RUN_FINISHED="RUN_FINISHED",e.RUN_ERROR="RUN_ERROR",e.STEP_STARTED="STEP_STARTED",e.STEP_FINISHED="STEP_FINISHED",e.REASONING_START="REASONING_START",e.REASONING_MESSAGE_START="REASONING_MESSAGE_START",e.REASONING_MESSAGE_CONTENT="REASONING_MESSAGE_CONTENT",e.REASONING_MESSAGE_END="REASONING_MESSAGE_END",e.REASONING_MESSAGE_CHUNK="REASONING_MESSAGE_CHUNK",e.REASONING_END="REASONING_END",e.REASONING_ENCRYPTED_VALUE="REASONING_ENCRYPTED_VALUE",e})({}),V=l.object({type:l.nativeEnum(v),timestamp:l.number().optional(),rawEvent:l.any().optional()}).passthrough(),Nf=V.extend({type:l.literal(v.TEXT_MESSAGE_START),messageId:l.string(),role:vl.default("assistant"),name:l.string().optional()}),yl=V.extend({type:l.literal(v.TEXT_MESSAGE_CONTENT),messageId:l.string(),delta:l.string()}),Rf=V.extend({type:l.literal(v.TEXT_MESSAGE_END),messageId:l.string()}),Of=V.extend({type:l.literal(v.TEXT_MESSAGE_CHUNK),messageId:l.string().optional(),role:vl.optional(),delta:l.string().optional(),name:l.string().optional()}),Mf=V.extend({type:l.literal(v.THINKING_TEXT_MESSAGE_START)}),Lf=yl.omit({messageId:!0,type:!0}).extend({type:l.literal(v.THINKING_TEXT_MESSAGE_CONTENT)}),Pf=V.extend({type:l.literal(v.THINKING_TEXT_MESSAGE_END)}),Df=V.extend({type:l.literal(v.TOOL_CALL_START),toolCallId:l.string(),toolCallName:l.string(),parentMessageId:l.string().optional()}),Uf=V.extend({type:l.literal(v.TOOL_CALL_ARGS),toolCallId:l.string(),delta:l.string()}),Gf=V.extend({type:l.literal(v.TOOL_CALL_END),toolCallId:l.string()}),Ff=V.extend({messageId:l.string(),type:l.literal(v.TOOL_CALL_RESULT),toolCallId:l.string(),content:l.string(),role:l.literal("tool").optional()}),Hf=V.extend({type:l.literal(v.TOOL_CALL_CHUNK),toolCallId:l.string().optional(),toolCallName:l.string().optional(),parentMessageId:l.string().optional(),delta:l.string().optional()}),$f=V.extend({type:l.literal(v.THINKING_START),title:l.string().optional()}),zf=V.extend({type:l.literal(v.THINKING_END)}),Bf=V.extend({type:l.literal(v.STATE_SNAPSHOT),snapshot:gf}),Vf=V.extend({type:l.literal(v.STATE_DELTA),delta:l.array(l.any())}),jf=V.extend({type:l.literal(v.MESSAGES_SNAPSHOT),messages:l.array(ml)}),Wf=V.extend({type:l.literal(v.ACTIVITY_SNAPSHOT),messageId:l.string(),activityType:l.string(),content:l.record(l.any()),replace:l.boolean().optional().default(!0)}),Xf=V.extend({type:l.literal(v.ACTIVITY_DELTA),messageId:l.string(),activityType:l.string(),patch:l.array(l.any())}),Zf=V.extend({type:l.literal(v.RAW),event:l.any(),source:l.string().optional()}),Kf=V.extend({type:l.literal(v.CUSTOM),name:l.string(),value:l.any()}),Yf=V.extend({type:l.literal(v.RUN_STARTED),threadId:l.string(),runId:l.string(),parentRunId:l.string().optional(),input:mf.optional()}),qf=l.object({type:l.literal("success")}).strict(),Jf=l.object({type:l.literal("interrupt"),interrupts:l.array(ff).min(1)}).strict(),Qf=l.discriminatedUnion("type",[qf,Jf]),eh=V.extend({type:l.literal(v.RUN_FINISHED),threadId:l.string(),runId:l.string(),result:l.any().optional(),outcome:Qf.nullable().optional().transform(e=>e??void 0)}),th=V.extend({type:l.literal(v.RUN_ERROR),message:l.string(),code:l.string().optional()}),nh=V.extend({type:l.literal(v.STEP_STARTED),stepName:l.string()}),rh=V.extend({type:l.literal(v.STEP_FINISHED),stepName:l.string()}),oh=l.union([l.literal("tool-call"),l.literal("message")]),sh=V.extend({type:l.literal(v.REASONING_START),messageId:l.string()}),ih=V.extend({type:l.literal(v.REASONING_MESSAGE_START),messageId:l.string(),role:l.literal("reasoning")}),ah=V.extend({type:l.literal(v.REASONING_MESSAGE_CONTENT),messageId:l.string(),delta:l.string()}),lh=V.extend({type:l.literal(v.REASONING_MESSAGE_END),messageId:l.string()}),ch=V.extend({type:l.literal(v.REASONING_MESSAGE_CHUNK),messageId:l.string().optional(),delta:l.string().optional()}),uh=V.extend({type:l.literal(v.REASONING_END),messageId:l.string()}),dh=V.extend({type:l.literal(v.REASONING_ENCRYPTED_VALUE),subtype:oh,entityId:l.string(),encryptedValue:l.string()}),Or=l.discriminatedUnion("type",[Nf,yl,Rf,Of,$f,zf,Mf,Lf,Pf,Df,Uf,Gf,Hf,Ff,Bf,Vf,jf,Wf,Xf,Zf,Kf,Yf,eh,th,nh,rh,sh,ih,ah,lh,ch,uh,dh]);var Qs={};hs(Qs,{JsonPatchError:()=>re,_areEquals:()=>Vn,applyOperation:()=>Ht,applyPatch:()=>Fr,applyReducer:()=>gh,deepClone:()=>hh,getValueByPointer:()=>Ur,validate:()=>xl,validator:()=>Gr});var ph=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var s in o)o.hasOwnProperty(s)&&(r[s]=o[s])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),fh=Object.prototype.hasOwnProperty;function Lr(e,t){return fh.call(e,t)}function Pr(e){if(Array.isArray(e)){for(var t=new Array(e.length),n=0;n<t.length;n++)t[n]=""+n;return t}if(Object.keys)return Object.keys(e);var r=[];for(var o in e)Lr(e,o)&&r.push(o);return r}function be(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function Dr(e){for(var t=0,n=e.length,r;t<n;){if(r=e.charCodeAt(t),r>=48&&r<=57){t++;continue}return!1}return!0}function et(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function zn(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Mr(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t<n;t++)if(Mr(e[t]))return!0}else if(typeof e=="object"){for(var r=Pr(e),o=r.length,s=0;s<o;s++)if(Mr(e[r[s]]))return!0}}return!1}function bl(e,t){var n=[e];for(var r in t){var o=typeof t[r]=="object"?JSON.stringify(t[r],null,2):t[r];typeof o<"u"&&n.push(r+": "+o)}return n.join(`
695
- `)}var Bn=(function(e){ph(t,e);function t(n,r,o,s,i){var a=this.constructor,u=e.call(this,bl(n,{name:r,index:o,operation:s,tree:i}))||this;return u.name=r,u.index=o,u.operation=s,u.tree=i,Object.setPrototypeOf(u,a.prototype),u.message=bl(n,{name:r,index:o,operation:s,tree:i}),u}return t})(Error);var re=Bn,hh=be,mn={add:function(e,t,n){return e[t]=this.value,{newDocument:n}},remove:function(e,t,n){var r=e[t];return delete e[t],{newDocument:n,removed:r}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:function(e,t,n){var r=Ur(n,this.path);r&&(r=be(r));var o=Ht(n,{op:"remove",path:this.from}).removed;return Ht(n,{op:"add",path:this.path,value:o}),{newDocument:n,removed:r}},copy:function(e,t,n){var r=Ur(n,this.from);return Ht(n,{op:"add",path:this.path,value:be(r)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:Vn(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},mh={add:function(e,t,n){return Dr(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:n,index:t}},remove:function(e,t,n){var r=e.splice(t,1);return{newDocument:n,removed:r[0]}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:mn.move,copy:mn.copy,test:mn.test,_get:mn._get};function Ur(e,t){if(t=="")return e;var n={op:"_get",path:t};return Ht(e,n),n.value}function Ht(e,t,n,r,o,s){if(n===void 0&&(n=!1),r===void 0&&(r=!0),o===void 0&&(o=!0),s===void 0&&(s=0),n&&(typeof n=="function"?n(t,0,e,t.path):Gr(t,0)),t.path===""){var i={newDocument:e};if(t.op==="add")return i.newDocument=t.value,i;if(t.op==="replace")return i.newDocument=t.value,i.removed=e,i;if(t.op==="move"||t.op==="copy")return i.newDocument=Ur(e,t.from),t.op==="move"&&(i.removed=e),i;if(t.op==="test"){if(i.test=Vn(e,t.value),i.test===!1)throw new re("Test operation failed","TEST_OPERATION_FAILED",s,t,e);return i.newDocument=e,i}else{if(t.op==="remove")return i.removed=e,i.newDocument=null,i;if(t.op==="_get")return t.value=e,i;if(n)throw new re("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",s,t,e);return i}}else{r||(e=be(e));var a=t.path||"",u=a.split("/"),c=e,p=1,m=u.length,x=void 0,f=void 0,h=void 0;for(typeof n=="function"?h=n:h=Gr;;){if(f=u[p],f&&f.indexOf("~")!=-1&&(f=zn(f)),o&&(f=="__proto__"||f=="prototype"&&p>0&&u[p-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&x===void 0&&(c[f]===void 0?x=u.slice(0,p).join("/"):p==m-1&&(x=t.path),x!==void 0&&h(t,0,e,x)),p++,Array.isArray(c)){if(f==="-")f=c.length;else{if(n&&!Dr(f))throw new re("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",s,t,e);Dr(f)&&(f=~~f)}if(p>=m){if(n&&t.op==="add"&&f>c.length)throw new re("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",s,t,e);var i=mh[t.op].call(t,c,f,e);if(i.test===!1)throw new re("Test operation failed","TEST_OPERATION_FAILED",s,t,e);return i}}else if(p>=m){var i=mn[t.op].call(t,c,f,e);if(i.test===!1)throw new re("Test operation failed","TEST_OPERATION_FAILED",s,t,e);return i}if(c=c[f],n&&p<m&&(!c||typeof c!="object"))throw new re("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",s,t,e)}}}function Fr(e,t,n,r,o){if(r===void 0&&(r=!0),o===void 0&&(o=!0),n&&!Array.isArray(t))throw new re("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(e=be(e));for(var s=new Array(t.length),i=0,a=t.length;i<a;i++)s[i]=Ht(e,t[i],n,!0,o,i),e=s[i].newDocument;return s.newDocument=e,s}function gh(e,t,n){var r=Ht(e,t);if(r.test===!1)throw new re("Test operation failed","TEST_OPERATION_FAILED",n,t,e);return r.newDocument}function Gr(e,t,n,r){if(typeof e!="object"||e===null||Array.isArray(e))throw new re("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,n);if(mn[e.op]){if(typeof e.path!="string")throw new re("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,n);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new re('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",t,e,n);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new re("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new re("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&Mr(e.value))throw new re("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,n);if(n){if(e.op=="add"){var o=e.path.split("/").length,s=r.split("/").length;if(o!==s+1&&o!==s)throw new re("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,n)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==r)throw new re("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,n)}else if(e.op==="move"||e.op==="copy"){var i={op:"_get",path:e.from,value:void 0},a=xl([i],n);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new re("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,n)}}}else throw new re("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,n)}function xl(e,t,n){try{if(!Array.isArray(e))throw new re("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)Fr(be(t),be(e),n||!0);else{n=n||Gr;for(var r=0;r<e.length;r++)n(e[r],r,t,void 0)}}catch(o){if(o instanceof re)return o;throw o}}function Vn(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var n=Array.isArray(e),r=Array.isArray(t),o,s,i;if(n&&r){if(s=e.length,s!=t.length)return!1;for(o=s;o--!==0;)if(!Vn(e[o],t[o]))return!1;return!0}if(n!=r)return!1;var a=Object.keys(e);if(s=a.length,s!==Object.keys(t).length)return!1;for(o=s;o--!==0;)if(!t.hasOwnProperty(a[o]))return!1;for(o=s;o--!==0;)if(i=a[o],!Vn(e[i],t[i]))return!1;return!0}return e!==e&&t!==t}var ri={};hs(ri,{compare:()=>Sh,generate:()=>ei,observe:()=>Th,unobserve:()=>_h});var ti=new WeakMap,vh=(function(){function e(t){this.observers=new Map,this.obj=t}return e})(),yh=(function(){function e(t,n){this.callback=t,this.observer=n}return e})();function bh(e){return ti.get(e)}function xh(e,t){return e.observers.get(t)}function Eh(e,t){e.observers.delete(t.callback)}function _h(e,t){t.unobserve()}function Th(e,t){var n=[],r,o=bh(e);if(!o)o=new vh(e),ti.set(e,o);else{var s=xh(o,t);r=s&&s.observer}if(r)return r;if(r={},o.value=be(e),t){r.callback=t,r.next=null;var i=function(){ei(r)},a=function(){clearTimeout(r.next),r.next=setTimeout(i)};typeof window<"u"&&(window.addEventListener("mouseup",a),window.addEventListener("keyup",a),window.addEventListener("mousedown",a),window.addEventListener("keydown",a),window.addEventListener("change",a))}return r.patches=n,r.object=e,r.unobserve=function(){ei(r),clearTimeout(r.next),Eh(o,r),typeof window<"u"&&(window.removeEventListener("mouseup",a),window.removeEventListener("keyup",a),window.removeEventListener("mousedown",a),window.removeEventListener("keydown",a),window.removeEventListener("change",a))},o.observers.set(t,new yh(t,r)),r}function ei(e,t){t===void 0&&(t=!1);var n=ti.get(e.object);ni(n.value,e.object,e.patches,"",t),e.patches.length&&Fr(n.value,e.patches);var r=e.patches;return r.length>0&&(e.patches=[],e.callback&&e.callback(r)),r}function ni(e,t,n,r,o){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var s=Pr(t),i=Pr(e),a=!1,u=!1,c=i.length-1;c>=0;c--){var p=i[c],m=e[p];if(Lr(t,p)&&!(t[p]===void 0&&m!==void 0&&Array.isArray(t)===!1)){var x=t[p];typeof m=="object"&&m!=null&&typeof x=="object"&&x!=null&&Array.isArray(m)===Array.isArray(x)?ni(m,x,n,r+"/"+et(p),o):m!==x&&(a=!0,o&&n.push({op:"test",path:r+"/"+et(p),value:be(m)}),n.push({op:"replace",path:r+"/"+et(p),value:be(x)}))}else Array.isArray(e)===Array.isArray(t)?(o&&n.push({op:"test",path:r+"/"+et(p),value:be(m)}),n.push({op:"remove",path:r+"/"+et(p)}),u=!0):(o&&n.push({op:"test",path:r,value:e}),n.push({op:"replace",path:r,value:t}),a=!0)}if(!(!u&&s.length==i.length))for(var c=0;c<s.length;c++){var p=s[c];!Lr(e,p)&&t[p]!==void 0&&n.push({op:"add",path:r+"/"+et(p),value:be(t[p])})}}}function Sh(e,t,n){n===void 0&&(n=!1);var r=[];return ni(e,t,r,"",n),r}var Hr=Object.assign({},Qs,ri,{JsonPatchError:Bn,deepClone:be,escapePathComponent:et,unescapePathComponent:zn});var oi=function(e,t){return oi=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},oi(e,t)};function tt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");oi(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function El(e,t,n,r){function o(s){return s instanceof n?s:new n(function(i){i(s)})}return new(n||(n=Promise))(function(s,i){function a(p){try{c(r.next(p))}catch(m){i(m)}}function u(p){try{c(r.throw(p))}catch(m){i(m)}}function c(p){p.done?s(p.value):o(p.value).then(a,u)}c((r=r.apply(e,t||[])).next())})}function $r(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,o,s,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(c){return function(p){return u([c,p])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(s=c[0]&2?o.return:c[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,c[1])).done)return s;switch(o=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(p){c=[6,p],o=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function lt(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function gn(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,s=[],i;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(a){i={error:a}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function vn(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function $t(e){return this instanceof $t?(this.v=e,this):new $t(e)}function _l(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(f){return function(h){return Promise.resolve(h).then(f,m)}}function a(f,h){r[f]&&(o[f]=function(g){return new Promise(function(_,S){s.push([f,g,_,S])>1||u(f,g)})},h&&(o[f]=h(o[f])))}function u(f,h){try{c(r[f](h))}catch(g){x(s[0][3],g)}}function c(f){f.value instanceof $t?Promise.resolve(f.value.v).then(p,m):x(s[0][2],f)}function p(f){u("next",f)}function m(f){u("throw",f)}function x(f,h){f(h),s.shift(),s.length&&u(s[0][0],s[0][1])}}function Tl(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof lt=="function"?lt(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(i){return new Promise(function(a,u){i=e[s](i),o(a,u,i.done,i.value)})}}function o(s,i,a,u){Promise.resolve(u).then(function(c){s({value:c,done:a})},i)}}function G(e){return typeof e=="function"}function yn(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var zr=yn(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
697
+ ${n}`):(r.textContent=Ld[t],o.textContent=n),r.addEventListener("click",()=>{let s=o.hidden;o.hidden=!s,r.setAttribute("aria-expanded",String(s))}),this.element.append(r,o)}};var ve=[];for(let e=0;e<256;++e)ve.push((e+256).toString(16).slice(1));function nl(e,t=0){return(ve[e[t+0]]+ve[e[t+1]]+ve[e[t+2]]+ve[e[t+3]]+"-"+ve[e[t+4]]+ve[e[t+5]]+"-"+ve[e[t+6]]+ve[e[t+7]]+"-"+ve[e[t+8]]+ve[e[t+9]]+"-"+ve[e[t+10]]+ve[e[t+11]]+ve[e[t+12]]+ve[e[t+13]]+ve[e[t+14]]+ve[e[t+15]]).toLowerCase()}var Xs,Pd=new Uint8Array(16);function Zs(){if(!Xs){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Xs=crypto.getRandomValues.bind(crypto)}return Xs(Pd)}var Dd=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ks={randomUUID:Dd};function Ud(e,t,n){if(Ks.randomUUID&&!t&&!e)return Ks.randomUUID();e=e||{};let r=e.random??e.rng?.()??Zs();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n=n||0,n<0||n+16>t.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let o=0;o<16;++o)t[n+o]=r[o];return t}return nl(r)}var ht=Ud;var l={};ms(l,{BRAND:()=>cp,DIRTY:()=>wt,EMPTY_PATH:()=>$d,INVALID:()=>O,NEVER:()=>Xp,OK:()=>_e,ParseStatus:()=>ye,Schema:()=>U,ZodAny:()=>vt,ZodArray:()=>lt,ZodBigInt:()=>At,ZodBoolean:()=>It,ZodBranded:()=>$n,ZodCatch:()=>Ft,ZodDate:()=>Ct,ZodDefault:()=>Gt,ZodDiscriminatedUnion:()=>Ir,ZodEffects:()=>Me,ZodEnum:()=>Dt,ZodError:()=>we,ZodFirstPartyTypeKind:()=>M,ZodFunction:()=>Nr,ZodIntersection:()=>Mt,ZodIssueCode:()=>E,ZodLazy:()=>Lt,ZodLiteral:()=>Pt,ZodMap:()=>fn,ZodNaN:()=>mn,ZodNativeEnum:()=>Ut,ZodNever:()=>Fe,ZodNull:()=>Rt,ZodNullable:()=>et,ZodNumber:()=>kt,ZodObject:()=>ke,ZodOptional:()=>Re,ZodParsedType:()=>A,ZodPipeline:()=>zn,ZodPromise:()=>yt,ZodReadonly:()=>Ht,ZodRecord:()=>Cr,ZodSchema:()=>U,ZodSet:()=>hn,ZodString:()=>gt,ZodSymbol:()=>dn,ZodTransformer:()=>Me,ZodTuple:()=>Qe,ZodType:()=>U,ZodUndefined:()=>Nt,ZodUnion:()=>Ot,ZodUnknown:()=>at,ZodVoid:()=>pn,addIssueToContext:()=>w,any:()=>yp,array:()=>_p,bigint:()=>fp,boolean:()=>fl,coerce:()=>Wp,custom:()=>ul,date:()=>hp,datetimeRegex:()=>ll,defaultErrorMap:()=>st,discriminatedUnion:()=>kp,effect:()=>Gp,enum:()=>Pp,function:()=>Op,getErrorMap:()=>ln,getParsedType:()=>Je,instanceof:()=>dp,intersection:()=>Ap,isAborted:()=>kr,isAsync:()=>cn,isDirty:()=>Ar,isValid:()=>mt,late:()=>up,lazy:()=>Mp,literal:()=>Lp,makeIssue:()=>Hn,map:()=>Np,nan:()=>pp,nativeEnum:()=>Dp,never:()=>xp,null:()=>vp,nullable:()=>Hp,number:()=>pl,object:()=>Tp,objectUtil:()=>Ys,oboolean:()=>jp,onumber:()=>Vp,optional:()=>Fp,ostring:()=>Bp,pipeline:()=>zp,preprocess:()=>$p,promise:()=>Up,quotelessJson:()=>Gd,record:()=>Cp,set:()=>Rp,setErrorMap:()=>Hd,strictObject:()=>Sp,string:()=>dl,symbol:()=>mp,transformer:()=>Gp,tuple:()=>Ip,undefined:()=>gp,union:()=>wp,unknown:()=>bp,util:()=>H,void:()=>Ep});var H;(function(e){e.assertEqual=o=>{};function t(o){}e.assertIs=t;function n(o){throw new Error}e.assertNever=n,e.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},e.getValidEnumValues=o=>{let s=e.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return e.objectValues(i)},e.objectValues=o=>e.objectKeys(o).map(function(s){return o[s]}),e.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},e.find=(o,s)=>{for(let i of o)if(s(i))return i},e.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(H||(H={}));var Ys;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Ys||(Ys={}));var A=H.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Je=e=>{switch(typeof e){case"undefined":return A.undefined;case"string":return A.string;case"number":return Number.isNaN(e)?A.nan:A.number;case"boolean":return A.boolean;case"function":return A.function;case"bigint":return A.bigint;case"symbol":return A.symbol;case"object":return Array.isArray(e)?A.array:e===null?A.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?A.promise:typeof Map<"u"&&e instanceof Map?A.map:typeof Set<"u"&&e instanceof Set?A.set:typeof Date<"u"&&e instanceof Date?A.date:A.object;default:return A.unknown}};var E=H.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"]),Gd=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),we=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){let n=t||function(s){return s.message},r={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)r._errors.push(n(i));else{let a=r,u=0;for(;u<i.path.length;){let c=i.path[u];u===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(i))):a[c]=a[c]||{_errors:[]},a=a[c],u++}}};return o(this),r}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,H.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){let n={},r=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];n[s]=n[s]||[],n[s].push(t(o))}else r.push(t(o));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};we.create=e=>new we(e);var Fd=(e,t)=>{let n;switch(e.code){case E.invalid_type:e.received===A.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case E.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,H.jsonStringifyReplacer)}`;break;case E.unrecognized_keys:n=`Unrecognized key(s) in object: ${H.joinValues(e.keys,", ")}`;break;case E.invalid_union:n="Invalid input";break;case E.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${H.joinValues(e.options)}`;break;case E.invalid_enum_value:n=`Invalid enum value. Expected ${H.joinValues(e.options)}, received '${e.received}'`;break;case E.invalid_arguments:n="Invalid function arguments";break;case E.invalid_return_type:n="Invalid function return type";break;case E.invalid_date:n="Invalid date";break;case E.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:H.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case E.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case E.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case E.custom:n="Invalid input";break;case E.invalid_intersection_types:n="Intersection results could not be merged";break;case E.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case E.not_finite:n="Number must be finite";break;default:n=t.defaultError,H.assertNever(e)}return{message:n}},st=Fd;var rl=st;function Hd(e){rl=e}function ln(){return rl}var Hn=e=>{let{data:t,path:n,errorMaps:r,issueData:o}=e,s=[...n,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",u=r.filter(c=>!!c).slice().reverse();for(let c of u)a=c(i,{data:t,defaultError:a}).message;return{...o,path:s,message:a}},$d=[];function w(e,t){let n=ln(),r=Hn({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===st?void 0:st].filter(o=>!!o)});e.common.issues.push(r)}var ye=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){let r=[];for(let o of n){if(o.status==="aborted")return O;o.status==="dirty"&&t.dirty(),r.push(o.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){let r=[];for(let o of n){let s=await o.key,i=await o.value;r.push({key:s,value:i})}return e.mergeObjectSync(t,r)}static mergeObjectSync(t,n){let r={};for(let o of n){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return O;s.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(r[s.value]=i.value)}return{status:t.value,value:r}}},O=Object.freeze({status:"aborted"}),wt=e=>({status:"dirty",value:e}),_e=e=>({status:"valid",value:e}),kr=e=>e.status==="aborted",Ar=e=>e.status==="dirty",mt=e=>e.status==="valid",cn=e=>typeof Promise<"u"&&e instanceof Promise;var I;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(I||(I={}));var Oe=class{constructor(t,n,r,o){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=o}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},ol=(e,t)=>{if(mt(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new we(e.common.issues);return this._error=n,this._error}}};function L(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:o}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:o}:{errorMap:(i,a)=>{let{message:u}=e;return i.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:u??r??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:u??n??a.defaultError}},description:o}}var U=class{get description(){return this._def.description}_getType(t){return Je(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Je(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new ye,ctx:{common:t.parent.common,data:t.data,parsedType:Je(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let n=this._parse(t);if(cn(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){let n=this._parse(t);return Promise.resolve(n)}parse(t,n){let r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Je(t)},o=this._parseSync({data:t,path:r.path,parent:r});return ol(r,o)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Je(t)};if(!this["~standard"].async)try{let r=this._parseSync({data:t,path:[],parent:n});return mt(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(r=>mt(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(t,n){let r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Je(t)},o=this._parse({data:t,path:r.path,parent:r}),s=await(cn(o)?o:Promise.resolve(o));return ol(r,s)}refine(t,n){let r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,s)=>{let i=t(o),a=()=>s.addIssue({code:E.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,o)=>t(r)?!0:(o.addIssue(typeof n=="function"?n(r,o):n),!1))}_refinement(t){return new Me({schema:this,typeName:M.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,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:n=>this["~validate"](n)}}optional(){return Re.create(this,this._def)}nullable(){return et.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return lt.create(this)}promise(){return yt.create(this,this._def)}or(t){return Ot.create([this,t],this._def)}and(t){return Mt.create(this,t,this._def)}transform(t){return new Me({...L(this._def),schema:this,typeName:M.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let n=typeof t=="function"?t:()=>t;return new Gt({...L(this._def),innerType:this,defaultValue:n,typeName:M.ZodDefault})}brand(){return new $n({typeName:M.ZodBranded,type:this,...L(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new Ft({...L(this._def),innerType:this,catchValue:n,typeName:M.ZodCatch})}describe(t){let n=this.constructor;return new n({...this._def,description:t})}pipe(t){return zn.create(this,t)}readonly(){return Ht.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},zd=/^c[^\s-]{8,}$/i,Bd=/^[0-9a-z]+$/,Vd=/^[0-9A-HJKMNP-TV-Z]{26}$/i,jd=/^[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,Wd=/^[a-z0-9_-]{21}$/i,Xd=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Zd=/^[-+]?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)?)??$/,Kd=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Yd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",qs,qd=/^(?:(?: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])$/,Jd=/^(?:(?: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])$/,Qd=/^(([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]))$/,ep=/^(([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])$/,tp=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,np=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,il="((\\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])))",rp=new RegExp(`^${il}$`);function al(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function op(e){return new RegExp(`^${al(e)}$`)}function ll(e){let t=`${il}T${al(e)}`,n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function sp(e,t){return!!((t==="v4"||!t)&&qd.test(e)||(t==="v6"||!t)&&Qd.test(e))}function ip(e,t){if(!Xd.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(r));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||t&&o.alg!==t)}catch{return!1}}function ap(e,t){return!!((t==="v4"||!t)&&Jd.test(e)||(t==="v6"||!t)&&ep.test(e))}var gt=class e extends U{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==A.string){let s=this._getOrReturnCtx(t);return w(s,{code:E.invalid_type,expected:A.string,received:s.parsedType}),O}let r=new ye,o;for(let s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(o=this._getOrReturnCtx(t,o),w(o,{code:E.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(o=this._getOrReturnCtx(t,o),w(o,{code:E.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){let i=t.data.length>s.value,a=t.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(t,o),i?w(o,{code:E.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&w(o,{code:E.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")Kd.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"email",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")qs||(qs=new RegExp(Yd,"u")),qs.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"emoji",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")jd.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"uuid",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")Wd.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"nanoid",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")zd.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"cuid",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")Bd.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"cuid2",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")Vd.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"ulid",code:E.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),w(o,{validation:"url",code:E.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"regex",code:E.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(t,o),w(o,{code:E.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(o=this._getOrReturnCtx(t,o),w(o,{code:E.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(o=this._getOrReturnCtx(t,o),w(o,{code:E.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?ll(s).test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{code:E.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?rp.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{code:E.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?op(s).test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{code:E.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?Zd.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"duration",code:E.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?sp(t.data,s.version)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"ip",code:E.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?ip(t.data,s.alg)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"jwt",code:E.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?ap(t.data,s.version)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"cidr",code:E.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?tp.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"base64",code:E.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?np.test(t.data)||(o=this._getOrReturnCtx(t,o),w(o,{validation:"base64url",code:E.invalid_string,message:s.message}),r.dirty()):H.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(o=>t.test(o),{validation:n,code:E.invalid_string,...I.errToObj(r)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...I.errToObj(t)})}url(t){return this._addCheck({kind:"url",...I.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...I.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...I.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...I.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...I.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...I.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...I.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...I.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...I.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...I.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...I.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...I.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...I.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...I.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...I.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...I.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...I.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...I.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...I.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...I.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...I.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...I.errToObj(n)})}nonempty(t){return this.min(1,I.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};gt.create=e=>new gt({checks:[],typeName:M.ZodString,coerce:e?.coerce??!1,...L(e)});function lp(e,t){let n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=n>r?n:r,s=Number.parseInt(e.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return s%i/10**o}var kt=class e extends U{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==A.number){let s=this._getOrReturnCtx(t);return w(s,{code:E.invalid_type,expected:A.number,received:s.parsedType}),O}let r,o=new ye;for(let s of this._def.checks)s.kind==="int"?H.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),w(r,{code:E.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),w(r,{code:E.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),w(r,{code:E.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?lp(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),w(r,{code:E.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),w(r,{code:E.not_finite,message:s.message}),o.dirty()):H.assertNever(s);return{status:o.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,I.toString(n))}gt(t,n){return this.setLimit("min",t,!1,I.toString(n))}lte(t,n){return this.setLimit("max",t,!0,I.toString(n))}lt(t,n){return this.setLimit("max",t,!1,I.toString(n))}setLimit(t,n,r,o){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:I.toString(o)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:I.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:I.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:I.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:I.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:I.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:I.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:I.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:I.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:I.toString(t)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&H.isInteger(t.value))}get isFinite(){let t=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}};kt.create=e=>new kt({checks:[],typeName:M.ZodNumber,coerce:e?.coerce||!1,...L(e)});var At=class e extends U{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==A.bigint)return this._getInvalidInput(t);let r,o=new ye;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),w(r,{code:E.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),w(r,{code:E.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),w(r,{code:E.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):H.assertNever(s);return{status:o.value,value:t.data}}_getInvalidInput(t){let n=this._getOrReturnCtx(t);return w(n,{code:E.invalid_type,expected:A.bigint,received:n.parsedType}),O}gte(t,n){return this.setLimit("min",t,!0,I.toString(n))}gt(t,n){return this.setLimit("min",t,!1,I.toString(n))}lte(t,n){return this.setLimit("max",t,!0,I.toString(n))}lt(t,n){return this.setLimit("max",t,!1,I.toString(n))}setLimit(t,n,r,o){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:I.toString(o)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:I.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:I.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:I.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:I.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:I.toString(n)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};At.create=e=>new At({checks:[],typeName:M.ZodBigInt,coerce:e?.coerce??!1,...L(e)});var It=class extends U{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==A.boolean){let r=this._getOrReturnCtx(t);return w(r,{code:E.invalid_type,expected:A.boolean,received:r.parsedType}),O}return _e(t.data)}};It.create=e=>new It({typeName:M.ZodBoolean,coerce:e?.coerce||!1,...L(e)});var Ct=class e extends U{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==A.date){let s=this._getOrReturnCtx(t);return w(s,{code:E.invalid_type,expected:A.date,received:s.parsedType}),O}if(Number.isNaN(t.data.getTime())){let s=this._getOrReturnCtx(t);return w(s,{code:E.invalid_date}),O}let r=new ye,o;for(let s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(o=this._getOrReturnCtx(t,o),w(o,{code:E.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(o=this._getOrReturnCtx(t,o),w(o,{code:E.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):H.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:I.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:I.toString(n)})}get minDate(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}};Ct.create=e=>new Ct({checks:[],coerce:e?.coerce||!1,typeName:M.ZodDate,...L(e)});var dn=class extends U{_parse(t){if(this._getType(t)!==A.symbol){let r=this._getOrReturnCtx(t);return w(r,{code:E.invalid_type,expected:A.symbol,received:r.parsedType}),O}return _e(t.data)}};dn.create=e=>new dn({typeName:M.ZodSymbol,...L(e)});var Nt=class extends U{_parse(t){if(this._getType(t)!==A.undefined){let r=this._getOrReturnCtx(t);return w(r,{code:E.invalid_type,expected:A.undefined,received:r.parsedType}),O}return _e(t.data)}};Nt.create=e=>new Nt({typeName:M.ZodUndefined,...L(e)});var Rt=class extends U{_parse(t){if(this._getType(t)!==A.null){let r=this._getOrReturnCtx(t);return w(r,{code:E.invalid_type,expected:A.null,received:r.parsedType}),O}return _e(t.data)}};Rt.create=e=>new Rt({typeName:M.ZodNull,...L(e)});var vt=class extends U{constructor(){super(...arguments),this._any=!0}_parse(t){return _e(t.data)}};vt.create=e=>new vt({typeName:M.ZodAny,...L(e)});var at=class extends U{constructor(){super(...arguments),this._unknown=!0}_parse(t){return _e(t.data)}};at.create=e=>new at({typeName:M.ZodUnknown,...L(e)});var Fe=class extends U{_parse(t){let n=this._getOrReturnCtx(t);return w(n,{code:E.invalid_type,expected:A.never,received:n.parsedType}),O}};Fe.create=e=>new Fe({typeName:M.ZodNever,...L(e)});var pn=class extends U{_parse(t){if(this._getType(t)!==A.undefined){let r=this._getOrReturnCtx(t);return w(r,{code:E.invalid_type,expected:A.void,received:r.parsedType}),O}return _e(t.data)}};pn.create=e=>new pn({typeName:M.ZodVoid,...L(e)});var lt=class e extends U{_parse(t){let{ctx:n,status:r}=this._processInputParams(t),o=this._def;if(n.parsedType!==A.array)return w(n,{code:E.invalid_type,expected:A.array,received:n.parsedType}),O;if(o.exactLength!==null){let i=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(i||a)&&(w(n,{code:i?E.too_big:E.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),r.dirty())}if(o.minLength!==null&&n.data.length<o.minLength.value&&(w(n,{code:E.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(w(n,{code:E.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((i,a)=>o.type._parseAsync(new Oe(n,i,n.path,a)))).then(i=>ye.mergeArray(r,i));let s=[...n.data].map((i,a)=>o.type._parseSync(new Oe(n,i,n.path,a)));return ye.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:I.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:I.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:I.toString(n)}})}nonempty(t){return this.min(1,t)}};lt.create=(e,t)=>new lt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray,...L(t)});function un(e){if(e instanceof ke){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Re.create(un(r))}return new ke({...e._def,shape:()=>t})}else return e instanceof lt?new lt({...e._def,type:un(e.element)}):e instanceof Re?Re.create(un(e.unwrap())):e instanceof et?et.create(un(e.unwrap())):e instanceof Qe?Qe.create(e.items.map(t=>un(t))):e}var ke=class e extends U{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),n=H.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==A.object){let c=this._getOrReturnCtx(t);return w(c,{code:E.invalid_type,expected:A.object,received:c.parsedType}),O}let{status:r,ctx:o}=this._processInputParams(t),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fe&&this._def.unknownKeys==="strip"))for(let c in o.data)i.includes(c)||a.push(c);let u=[];for(let c of i){let p=s[c],m=o.data[c];u.push({key:{status:"valid",value:c},value:p._parse(new Oe(o,m,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof Fe){let c=this._def.unknownKeys;if(c==="passthrough")for(let p of a)u.push({key:{status:"valid",value:p},value:{status:"valid",value:o.data[p]}});else if(c==="strict")a.length>0&&(w(o,{code:E.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let p of a){let m=o.data[p];u.push({key:{status:"valid",value:p},value:c._parse(new Oe(o,m,o.path,p)),alwaysSet:p in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let c=[];for(let p of u){let m=await p.key,x=await p.value;c.push({key:m,value:x,alwaysSet:p.alwaysSet})}return c}).then(c=>ye.mergeObjectSync(r,c)):ye.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(t){return I.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{let o=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:I.errToObj(t).message??o}:{message:o}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:M.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let r of H.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let r of H.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new e({...this._def,shape:()=>n})}deepPartial(){return un(this)}partial(t){let n={};for(let r of H.objectKeys(this.shape)){let o=this.shape[r];t&&!t[r]?n[r]=o:n[r]=o.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let r of H.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Re;)s=s._def.innerType;n[r]=s}return new e({...this._def,shape:()=>n})}keyof(){return cl(H.objectKeys(this.shape))}};ke.create=(e,t)=>new ke({shape:()=>e,unknownKeys:"strip",catchall:Fe.create(),typeName:M.ZodObject,...L(t)});ke.strictCreate=(e,t)=>new ke({shape:()=>e,unknownKeys:"strict",catchall:Fe.create(),typeName:M.ZodObject,...L(t)});ke.lazycreate=(e,t)=>new ke({shape:e,unknownKeys:"strip",catchall:Fe.create(),typeName:M.ZodObject,...L(t)});var Ot=class extends U{_parse(t){let{ctx:n}=this._processInputParams(t),r=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new we(a.ctx.common.issues));return w(n,{code:E.invalid_union,unionErrors:i}),O}if(n.common.async)return Promise.all(r.map(async s=>{let i={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let u of r){let c={...n,common:{...n.common,issues:[]},parent:null},p=u._parseSync({data:n.data,path:n.path,parent:c});if(p.status==="valid")return p;p.status==="dirty"&&!s&&(s={result:p,ctx:c}),c.common.issues.length&&i.push(c.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(u=>new we(u));return w(n,{code:E.invalid_union,unionErrors:a}),O}}get options(){return this._def.options}};Ot.create=(e,t)=>new Ot({options:e,typeName:M.ZodUnion,...L(t)});var it=e=>e instanceof Lt?it(e.schema):e instanceof Me?it(e.innerType()):e instanceof Pt?[e.value]:e instanceof Dt?e.options:e instanceof Ut?H.objectValues(e.enum):e instanceof Gt?it(e._def.innerType):e instanceof Nt?[void 0]:e instanceof Rt?[null]:e instanceof Re?[void 0,...it(e.unwrap())]:e instanceof et?[null,...it(e.unwrap())]:e instanceof $n||e instanceof Ht?it(e.unwrap()):e instanceof Ft?it(e._def.innerType):[],Ir=class e extends U{_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==A.object)return w(n,{code:E.invalid_type,expected:A.object,received:n.parsedType}),O;let r=this.discriminator,o=n.data[r],s=this.optionsMap.get(o);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(w(n,{code:E.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),O)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let o=new Map;for(let s of n){let i=it(s.shape[t]);if(!i.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);o.set(a,s)}}return new e({typeName:M.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:o,...L(r)})}};function Js(e,t){let n=Je(e),r=Je(t);if(e===t)return{valid:!0,data:e};if(n===A.object&&r===A.object){let o=H.objectKeys(t),s=H.objectKeys(e).filter(a=>o.indexOf(a)!==-1),i={...e,...t};for(let a of s){let u=Js(e[a],t[a]);if(!u.valid)return{valid:!1};i[a]=u.data}return{valid:!0,data:i}}else if(n===A.array&&r===A.array){if(e.length!==t.length)return{valid:!1};let o=[];for(let s=0;s<e.length;s++){let i=e[s],a=t[s],u=Js(i,a);if(!u.valid)return{valid:!1};o.push(u.data)}return{valid:!0,data:o}}else return n===A.date&&r===A.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Mt=class extends U{_parse(t){let{status:n,ctx:r}=this._processInputParams(t),o=(s,i)=>{if(kr(s)||kr(i))return O;let a=Js(s.value,i.value);return a.valid?((Ar(s)||Ar(i))&&n.dirty(),{status:n.value,value:a.data}):(w(r,{code:E.invalid_intersection_types}),O)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Mt.create=(e,t,n)=>new Mt({left:e,right:t,typeName:M.ZodIntersection,...L(n)});var Qe=class e extends U{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==A.array)return w(r,{code:E.invalid_type,expected:A.array,received:r.parsedType}),O;if(r.data.length<this._def.items.length)return w(r,{code:E.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),O;!this._def.rest&&r.data.length>this._def.items.length&&(w(r,{code:E.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((i,a)=>{let u=this._def.items[a]||this._def.rest;return u?u._parse(new Oe(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(s).then(i=>ye.mergeArray(n,i)):ye.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Qe.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Qe({items:e,typeName:M.ZodTuple,rest:null,...L(t)})};var Cr=class e extends U{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==A.object)return w(r,{code:E.invalid_type,expected:A.object,received:r.parsedType}),O;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in r.data)o.push({key:s._parse(new Oe(r,a,r.path,a)),value:i._parse(new Oe(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?ye.mergeObjectAsync(n,o):ye.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof U?new e({keyType:t,valueType:n,typeName:M.ZodRecord,...L(r)}):new e({keyType:gt.create(),valueType:t,typeName:M.ZodRecord,...L(n)})}},fn=class extends U{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==A.map)return w(r,{code:E.invalid_type,expected:A.map,received:r.parsedType}),O;let o=this._def.keyType,s=this._def.valueType,i=[...r.data.entries()].map(([a,u],c)=>({key:o._parse(new Oe(r,a,r.path,[c,"key"])),value:s._parse(new Oe(r,u,r.path,[c,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let u of i){let c=await u.key,p=await u.value;if(c.status==="aborted"||p.status==="aborted")return O;(c.status==="dirty"||p.status==="dirty")&&n.dirty(),a.set(c.value,p.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let u of i){let c=u.key,p=u.value;if(c.status==="aborted"||p.status==="aborted")return O;(c.status==="dirty"||p.status==="dirty")&&n.dirty(),a.set(c.value,p.value)}return{status:n.value,value:a}}}};fn.create=(e,t,n)=>new fn({valueType:t,keyType:e,typeName:M.ZodMap,...L(n)});var hn=class e extends U{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==A.set)return w(r,{code:E.invalid_type,expected:A.set,received:r.parsedType}),O;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(w(r,{code:E.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(w(r,{code:E.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),n.dirty());let s=this._def.valueType;function i(u){let c=new Set;for(let p of u){if(p.status==="aborted")return O;p.status==="dirty"&&n.dirty(),c.add(p.value)}return{status:n.value,value:c}}let a=[...r.data.values()].map((u,c)=>s._parse(new Oe(r,u,r.path,c)));return r.common.async?Promise.all(a).then(u=>i(u)):i(a)}min(t,n){return new e({...this._def,minSize:{value:t,message:I.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:I.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}};hn.create=(e,t)=>new hn({valueType:e,minSize:null,maxSize:null,typeName:M.ZodSet,...L(t)});var Nr=class e extends U{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==A.function)return w(n,{code:E.invalid_type,expected:A.function,received:n.parsedType}),O;function r(a,u){return Hn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ln(),st].filter(c=>!!c),issueData:{code:E.invalid_arguments,argumentsError:u}})}function o(a,u){return Hn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ln(),st].filter(c=>!!c),issueData:{code:E.invalid_return_type,returnTypeError:u}})}let s={errorMap:n.common.contextualErrorMap},i=n.data;if(this._def.returns instanceof yt){let a=this;return _e(async function(...u){let c=new we([]),p=await a._def.args.parseAsync(u,s).catch(f=>{throw c.addIssue(r(u,f)),c}),m=await Reflect.apply(i,this,p);return await a._def.returns._def.type.parseAsync(m,s).catch(f=>{throw c.addIssue(o(m,f)),c})})}else{let a=this;return _e(function(...u){let c=a._def.args.safeParse(u,s);if(!c.success)throw new we([r(u,c.error)]);let p=Reflect.apply(i,this,c.data),m=a._def.returns.safeParse(p,s);if(!m.success)throw new we([o(p,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Qe.create(t).rest(at.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,r){return new e({args:t||Qe.create([]).rest(at.create()),returns:n||at.create(),typeName:M.ZodFunction,...L(r)})}},Lt=class extends U{get schema(){return this._def.getter()}_parse(t){let{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};Lt.create=(e,t)=>new Lt({getter:e,typeName:M.ZodLazy,...L(t)});var Pt=class extends U{_parse(t){if(t.data!==this._def.value){let n=this._getOrReturnCtx(t);return w(n,{received:n.data,code:E.invalid_literal,expected:this._def.value}),O}return{status:"valid",value:t.data}}get value(){return this._def.value}};Pt.create=(e,t)=>new Pt({value:e,typeName:M.ZodLiteral,...L(t)});function cl(e,t){return new Dt({values:e,typeName:M.ZodEnum,...L(t)})}var Dt=class e extends U{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),r=this._def.values;return w(n,{expected:H.joinValues(r),received:n.parsedType,code:E.invalid_type}),O}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let n=this._getOrReturnCtx(t),r=this._def.values;return w(n,{received:n.data,code:E.invalid_enum_value,options:r}),O}return _e(t.data)}get options(){return this._def.values}get enum(){let t={};for(let n of this._def.values)t[n]=n;return t}get Values(){let t={};for(let n of this._def.values)t[n]=n;return t}get Enum(){let t={};for(let n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}};Dt.create=cl;var Ut=class extends U{_parse(t){let n=H.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==A.string&&r.parsedType!==A.number){let o=H.objectValues(n);return w(r,{expected:H.joinValues(o),received:r.parsedType,code:E.invalid_type}),O}if(this._cache||(this._cache=new Set(H.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let o=H.objectValues(n);return w(r,{received:r.data,code:E.invalid_enum_value,options:o}),O}return _e(t.data)}get enum(){return this._def.values}};Ut.create=(e,t)=>new Ut({values:e,typeName:M.ZodNativeEnum,...L(t)});var yt=class extends U{unwrap(){return this._def.type}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==A.promise&&n.common.async===!1)return w(n,{code:E.invalid_type,expected:A.promise,received:n.parsedType}),O;let r=n.parsedType===A.promise?n.data:Promise.resolve(n.data);return _e(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};yt.create=(e,t)=>new yt({type:e,typeName:M.ZodPromise,...L(t)});var Me=class extends U{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===M.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:r}=this._processInputParams(t),o=this._def.effect||null,s={addIssue:i=>{w(r,i),i.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(r.data,s);if(r.common.async)return Promise.resolve(i).then(async a=>{if(n.value==="aborted")return O;let u=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return u.status==="aborted"?O:u.status==="dirty"?wt(u.value):n.value==="dirty"?wt(u.value):u});{if(n.value==="aborted")return O;let a=this._def.schema._parseSync({data:i,path:r.path,parent:r});return a.status==="aborted"?O:a.status==="dirty"?wt(a.value):n.value==="dirty"?wt(a.value):a}}if(o.type==="refinement"){let i=a=>{let u=o.refinement(a,s);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?O:(a.status==="dirty"&&n.dirty(),i(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?O:(a.status==="dirty"&&n.dirty(),i(a.value).then(()=>({status:n.value,value:a.value}))))}if(o.type==="transform")if(r.common.async===!1){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!mt(i))return O;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>mt(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:n.value,value:a})):O);H.assertNever(o)}};Me.create=(e,t,n)=>new Me({schema:e,typeName:M.ZodEffects,effect:t,...L(n)});Me.createWithPreprocess=(e,t,n)=>new Me({schema:t,effect:{type:"preprocess",transform:e},typeName:M.ZodEffects,...L(n)});var Re=class extends U{_parse(t){return this._getType(t)===A.undefined?_e(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Re.create=(e,t)=>new Re({innerType:e,typeName:M.ZodOptional,...L(t)});var et=class extends U{_parse(t){return this._getType(t)===A.null?_e(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};et.create=(e,t)=>new et({innerType:e,typeName:M.ZodNullable,...L(t)});var Gt=class extends U{_parse(t){let{ctx:n}=this._processInputParams(t),r=n.data;return n.parsedType===A.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Gt.create=(e,t)=>new Gt({innerType:e,typeName:M.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...L(t)});var Ft=class extends U{_parse(t){let{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return cn(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new we(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new we(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Ft.create=(e,t)=>new Ft({innerType:e,typeName:M.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...L(t)});var mn=class extends U{_parse(t){if(this._getType(t)!==A.nan){let r=this._getOrReturnCtx(t);return w(r,{code:E.invalid_type,expected:A.nan,received:r.parsedType}),O}return{status:"valid",value:t.data}}};mn.create=e=>new mn({typeName:M.ZodNaN,...L(e)});var cp=Symbol("zod_brand"),$n=class extends U{_parse(t){let{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},zn=class e extends U{_parse(t){let{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?O:s.status==="dirty"?(n.dirty(),wt(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{let o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?O:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(t,n){return new e({in:t,out:n,typeName:M.ZodPipeline})}},Ht=class extends U{_parse(t){let n=this._def.innerType._parse(t),r=o=>(mt(o)&&(o.value=Object.freeze(o.value)),o);return cn(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};Ht.create=(e,t)=>new Ht({innerType:e,typeName:M.ZodReadonly,...L(t)});function sl(e,t){let n=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof n=="string"?{message:n}:n}function ul(e,t={},n){return e?vt.create().superRefine((r,o)=>{let s=e(r);if(s instanceof Promise)return s.then(i=>{if(!i){let a=sl(t,r),u=a.fatal??n??!0;o.addIssue({code:"custom",...a,fatal:u})}});if(!s){let i=sl(t,r),a=i.fatal??n??!0;o.addIssue({code:"custom",...i,fatal:a})}}):vt.create()}var up={object:ke.lazycreate},M;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(M||(M={}));var dp=(e,t={message:`Input not instance of ${e.name}`})=>ul(n=>n instanceof e,t),dl=gt.create,pl=kt.create,pp=mn.create,fp=At.create,fl=It.create,hp=Ct.create,mp=dn.create,gp=Nt.create,vp=Rt.create,yp=vt.create,bp=at.create,xp=Fe.create,Ep=pn.create,_p=lt.create,Tp=ke.create,Sp=ke.strictCreate,wp=Ot.create,kp=Ir.create,Ap=Mt.create,Ip=Qe.create,Cp=Cr.create,Np=fn.create,Rp=hn.create,Op=Nr.create,Mp=Lt.create,Lp=Pt.create,Pp=Dt.create,Dp=Ut.create,Up=yt.create,Gp=Me.create,Fp=Re.create,Hp=et.create,$p=Me.createWithPreprocess,zp=zn.create,Bp=()=>dl().optional(),Vp=()=>pl().optional(),jp=()=>fl().optional(),Wp={string:(e=>gt.create({...e,coerce:!0})),number:(e=>kt.create({...e,coerce:!0})),boolean:(e=>It.create({...e,coerce:!0})),bigint:(e=>At.create({...e,coerce:!0})),date:(e=>Ct.create({...e,coerce:!0}))};var Xp=O;var Zp=l.object({name:l.string(),arguments:l.string()}),Kp=l.object({id:l.string(),type:l.literal("function"),function:Zp,encryptedValue:l.string().optional()}),Rr=l.object({id:l.string(),role:l.string(),content:l.string().optional(),name:l.string().optional(),encryptedValue:l.string().optional()}),Yp=l.object({type:l.literal("text"),text:l.string()}),qp=l.object({type:l.literal("data"),value:l.string(),mimeType:l.string()}),Jp=l.object({type:l.literal("url"),value:l.string(),mimeType:l.string().optional()}),Or=l.discriminatedUnion("type",[qp,Jp]),Qp=l.object({type:l.literal("image"),source:Or,metadata:l.unknown().optional()}),ef=l.object({type:l.literal("audio"),source:Or,metadata:l.unknown().optional()}),tf=l.object({type:l.literal("video"),source:Or,metadata:l.unknown().optional()}),nf=l.object({type:l.literal("document"),source:Or,metadata:l.unknown().optional()});var hl=l.object({type:l.literal("binary"),mimeType:l.string(),id:l.string().optional(),url:l.string().optional(),data:l.string().optional(),filename:l.string().optional()}),ml=(e,t)=>{!e.id&&!e.url&&!e.data&&t.addIssue({code:l.ZodIssueCode.custom,message:"BinaryInputContent requires at least one of id, url, or data.",path:["id"]})},mv=hl.superRefine((e,t)=>{ml(e,t)}),rf=l.discriminatedUnion("type",[Yp,Qp,ef,tf,nf,hl]),of=rf.superRefine((e,t)=>{e.type==="binary"&&ml(e,t)}),sf=Rr.extend({role:l.literal("developer"),content:l.string()}),af=Rr.extend({role:l.literal("system"),content:l.string()}),lf=Rr.extend({role:l.literal("assistant"),content:l.string().optional(),toolCalls:l.array(Kp).optional()}),cf=Rr.extend({role:l.literal("user"),content:l.union([l.string(),l.array(of)])}),uf=l.object({id:l.string(),content:l.string(),role:l.literal("tool"),toolCallId:l.string(),error:l.string().optional(),encryptedValue:l.string().optional()}),df=l.object({id:l.string(),role:l.literal("activity"),activityType:l.string(),content:l.record(l.any())}),pf=l.object({id:l.string(),role:l.literal("reasoning"),content:l.string(),encryptedValue:l.string().optional()}),gl=l.discriminatedUnion("role",[sf,af,lf,cf,uf,df,pf]),gv=l.union([l.literal("developer"),l.literal("system"),l.literal("assistant"),l.literal("user"),l.literal("tool"),l.literal("activity"),l.literal("reasoning")]),ff=l.object({description:l.string(),value:l.string()}),vl=l.object({name:l.string(),description:l.string(),parameters:l.any(),metadata:l.record(l.any()).optional()}),hf=l.object({id:l.string(),reason:l.string(),message:l.string().optional(),toolCallId:l.string().optional(),responseSchema:l.record(l.any()).optional(),expiresAt:l.string().optional(),metadata:l.record(l.any()).optional()}),mf=l.object({interruptId:l.string(),status:l.enum(["resolved","cancelled"]),payload:l.any().optional()}),gf=l.object({threadId:l.string(),runId:l.string(),parentRunId:l.string().optional(),state:l.any(),messages:l.array(gl),tools:l.array(vl),context:l.array(ff),forwardedProps:l.any(),resume:l.array(mf).optional()}),vf=l.any(),q=class extends Error{constructor(e){super(e)}},Qs=class extends q{constructor(){super("Connect not implemented. This method is not supported by the current agent.")}},yf=l.object({name:l.string(),description:l.string().optional()}),bf=l.object({name:l.string().optional(),type:l.string().optional(),description:l.string().optional(),version:l.string().optional(),provider:l.string().optional(),documentationUrl:l.string().optional(),metadata:l.record(l.unknown()).optional()}),xf=l.object({streaming:l.boolean().optional(),websocket:l.boolean().optional(),httpBinary:l.boolean().optional(),pushNotifications:l.boolean().optional(),resumable:l.boolean().optional()}),Ef=l.object({supported:l.boolean().optional(),items:l.array(vl).optional(),parallelCalls:l.boolean().optional(),clientProvided:l.boolean().optional()}),_f=l.object({structuredOutput:l.boolean().optional(),supportedMimeTypes:l.array(l.string()).optional()}),Tf=l.object({snapshots:l.boolean().optional(),deltas:l.boolean().optional(),memory:l.boolean().optional(),persistentState:l.boolean().optional()}),Sf=l.object({supported:l.boolean().optional(),delegation:l.boolean().optional(),handoffs:l.boolean().optional(),subAgents:l.array(yf).optional()}),wf=l.object({supported:l.boolean().optional(),streaming:l.boolean().optional(),encrypted:l.boolean().optional()}),kf=l.object({image:l.boolean().optional(),audio:l.boolean().optional(),video:l.boolean().optional(),pdf:l.boolean().optional(),file:l.boolean().optional()}),Af=l.object({image:l.boolean().optional(),audio:l.boolean().optional()}),If=l.object({input:kf.optional(),output:Af.optional()}),Cf=l.object({codeExecution:l.boolean().optional(),sandboxed:l.boolean().optional(),maxIterations:l.number().optional(),maxExecutionTime:l.number().optional()}),Nf=l.object({supported:l.boolean().optional(),approvals:l.boolean().optional(),interventions:l.boolean().optional(),feedback:l.boolean().optional(),interrupts:l.boolean().optional(),approveWithEdits:l.boolean().optional()}),vv=l.object({identity:bf.optional(),transport:xf.optional(),tools:Ef.optional(),output:_f.optional(),state:Tf.optional(),multiAgent:Sf.optional(),reasoning:wf.optional(),multimodal:If.optional(),execution:Cf.optional(),humanInTheLoop:Nf.optional(),custom:l.record(l.unknown()).optional()}),yl=l.union([l.literal("developer"),l.literal("system"),l.literal("assistant"),l.literal("user")]),v=(function(e){return e.TEXT_MESSAGE_START="TEXT_MESSAGE_START",e.TEXT_MESSAGE_CONTENT="TEXT_MESSAGE_CONTENT",e.TEXT_MESSAGE_END="TEXT_MESSAGE_END",e.TEXT_MESSAGE_CHUNK="TEXT_MESSAGE_CHUNK",e.TOOL_CALL_START="TOOL_CALL_START",e.TOOL_CALL_ARGS="TOOL_CALL_ARGS",e.TOOL_CALL_END="TOOL_CALL_END",e.TOOL_CALL_CHUNK="TOOL_CALL_CHUNK",e.TOOL_CALL_RESULT="TOOL_CALL_RESULT",e.THINKING_START="THINKING_START",e.THINKING_END="THINKING_END",e.THINKING_TEXT_MESSAGE_START="THINKING_TEXT_MESSAGE_START",e.THINKING_TEXT_MESSAGE_CONTENT="THINKING_TEXT_MESSAGE_CONTENT",e.THINKING_TEXT_MESSAGE_END="THINKING_TEXT_MESSAGE_END",e.STATE_SNAPSHOT="STATE_SNAPSHOT",e.STATE_DELTA="STATE_DELTA",e.MESSAGES_SNAPSHOT="MESSAGES_SNAPSHOT",e.ACTIVITY_SNAPSHOT="ACTIVITY_SNAPSHOT",e.ACTIVITY_DELTA="ACTIVITY_DELTA",e.RAW="RAW",e.CUSTOM="CUSTOM",e.RUN_STARTED="RUN_STARTED",e.RUN_FINISHED="RUN_FINISHED",e.RUN_ERROR="RUN_ERROR",e.STEP_STARTED="STEP_STARTED",e.STEP_FINISHED="STEP_FINISHED",e.REASONING_START="REASONING_START",e.REASONING_MESSAGE_START="REASONING_MESSAGE_START",e.REASONING_MESSAGE_CONTENT="REASONING_MESSAGE_CONTENT",e.REASONING_MESSAGE_END="REASONING_MESSAGE_END",e.REASONING_MESSAGE_CHUNK="REASONING_MESSAGE_CHUNK",e.REASONING_END="REASONING_END",e.REASONING_ENCRYPTED_VALUE="REASONING_ENCRYPTED_VALUE",e})({}),V=l.object({type:l.nativeEnum(v),timestamp:l.number().optional(),rawEvent:l.any().optional()}).passthrough(),Rf=V.extend({type:l.literal(v.TEXT_MESSAGE_START),messageId:l.string(),role:yl.default("assistant"),name:l.string().optional()}),bl=V.extend({type:l.literal(v.TEXT_MESSAGE_CONTENT),messageId:l.string(),delta:l.string()}),Of=V.extend({type:l.literal(v.TEXT_MESSAGE_END),messageId:l.string()}),Mf=V.extend({type:l.literal(v.TEXT_MESSAGE_CHUNK),messageId:l.string().optional(),role:yl.optional(),delta:l.string().optional(),name:l.string().optional()}),Lf=V.extend({type:l.literal(v.THINKING_TEXT_MESSAGE_START)}),Pf=bl.omit({messageId:!0,type:!0}).extend({type:l.literal(v.THINKING_TEXT_MESSAGE_CONTENT)}),Df=V.extend({type:l.literal(v.THINKING_TEXT_MESSAGE_END)}),Uf=V.extend({type:l.literal(v.TOOL_CALL_START),toolCallId:l.string(),toolCallName:l.string(),parentMessageId:l.string().optional()}),Gf=V.extend({type:l.literal(v.TOOL_CALL_ARGS),toolCallId:l.string(),delta:l.string()}),Ff=V.extend({type:l.literal(v.TOOL_CALL_END),toolCallId:l.string()}),Hf=V.extend({messageId:l.string(),type:l.literal(v.TOOL_CALL_RESULT),toolCallId:l.string(),content:l.string(),role:l.literal("tool").optional()}),$f=V.extend({type:l.literal(v.TOOL_CALL_CHUNK),toolCallId:l.string().optional(),toolCallName:l.string().optional(),parentMessageId:l.string().optional(),delta:l.string().optional()}),zf=V.extend({type:l.literal(v.THINKING_START),title:l.string().optional()}),Bf=V.extend({type:l.literal(v.THINKING_END)}),Vf=V.extend({type:l.literal(v.STATE_SNAPSHOT),snapshot:vf}),jf=V.extend({type:l.literal(v.STATE_DELTA),delta:l.array(l.any())}),Wf=V.extend({type:l.literal(v.MESSAGES_SNAPSHOT),messages:l.array(gl)}),Xf=V.extend({type:l.literal(v.ACTIVITY_SNAPSHOT),messageId:l.string(),activityType:l.string(),content:l.record(l.any()),replace:l.boolean().optional().default(!0)}),Zf=V.extend({type:l.literal(v.ACTIVITY_DELTA),messageId:l.string(),activityType:l.string(),patch:l.array(l.any())}),Kf=V.extend({type:l.literal(v.RAW),event:l.any(),source:l.string().optional()}),Yf=V.extend({type:l.literal(v.CUSTOM),name:l.string(),value:l.any()}),qf=V.extend({type:l.literal(v.RUN_STARTED),threadId:l.string(),runId:l.string(),parentRunId:l.string().optional(),input:gf.optional()}),Jf=l.object({type:l.literal("success")}).strict(),Qf=l.object({type:l.literal("interrupt"),interrupts:l.array(hf).min(1)}).strict(),eh=l.discriminatedUnion("type",[Jf,Qf]),th=V.extend({type:l.literal(v.RUN_FINISHED),threadId:l.string(),runId:l.string(),result:l.any().optional(),outcome:eh.nullable().optional().transform(e=>e??void 0)}),nh=V.extend({type:l.literal(v.RUN_ERROR),message:l.string(),code:l.string().optional()}),rh=V.extend({type:l.literal(v.STEP_STARTED),stepName:l.string()}),oh=V.extend({type:l.literal(v.STEP_FINISHED),stepName:l.string()}),sh=l.union([l.literal("tool-call"),l.literal("message")]),ih=V.extend({type:l.literal(v.REASONING_START),messageId:l.string()}),ah=V.extend({type:l.literal(v.REASONING_MESSAGE_START),messageId:l.string(),role:l.literal("reasoning")}),lh=V.extend({type:l.literal(v.REASONING_MESSAGE_CONTENT),messageId:l.string(),delta:l.string()}),ch=V.extend({type:l.literal(v.REASONING_MESSAGE_END),messageId:l.string()}),uh=V.extend({type:l.literal(v.REASONING_MESSAGE_CHUNK),messageId:l.string().optional(),delta:l.string().optional()}),dh=V.extend({type:l.literal(v.REASONING_END),messageId:l.string()}),ph=V.extend({type:l.literal(v.REASONING_ENCRYPTED_VALUE),subtype:sh,entityId:l.string(),encryptedValue:l.string()}),Mr=l.discriminatedUnion("type",[Rf,bl,Of,Mf,zf,Bf,Lf,Pf,Df,Uf,Gf,Ff,$f,Hf,Vf,jf,Wf,Xf,Zf,Kf,Yf,qf,th,nh,rh,oh,ih,ah,lh,ch,uh,dh,ph]);var ei={};ms(ei,{JsonPatchError:()=>re,_areEquals:()=>jn,applyOperation:()=>$t,applyPatch:()=>Hr,applyReducer:()=>vh,deepClone:()=>mh,getValueByPointer:()=>Gr,validate:()=>El,validator:()=>Fr});var fh=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var s in o)o.hasOwnProperty(s)&&(r[s]=o[s])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),hh=Object.prototype.hasOwnProperty;function Pr(e,t){return hh.call(e,t)}function Dr(e){if(Array.isArray(e)){for(var t=new Array(e.length),n=0;n<t.length;n++)t[n]=""+n;return t}if(Object.keys)return Object.keys(e);var r=[];for(var o in e)Pr(e,o)&&r.push(o);return r}function be(e){switch(typeof e){case"object":return JSON.parse(JSON.stringify(e));case"undefined":return null;default:return e}}function Ur(e){for(var t=0,n=e.length,r;t<n;){if(r=e.charCodeAt(t),r>=48&&r<=57){t++;continue}return!1}return!0}function tt(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function Bn(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Lr(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t<n;t++)if(Lr(e[t]))return!0}else if(typeof e=="object"){for(var r=Dr(e),o=r.length,s=0;s<o;s++)if(Lr(e[r[s]]))return!0}}return!1}function xl(e,t){var n=[e];for(var r in t){var o=typeof t[r]=="object"?JSON.stringify(t[r],null,2):t[r];typeof o<"u"&&n.push(r+": "+o)}return n.join(`
698
+ `)}var Vn=(function(e){fh(t,e);function t(n,r,o,s,i){var a=this.constructor,u=e.call(this,xl(n,{name:r,index:o,operation:s,tree:i}))||this;return u.name=r,u.index=o,u.operation=s,u.tree=i,Object.setPrototypeOf(u,a.prototype),u.message=xl(n,{name:r,index:o,operation:s,tree:i}),u}return t})(Error);var re=Vn,mh=be,gn={add:function(e,t,n){return e[t]=this.value,{newDocument:n}},remove:function(e,t,n){var r=e[t];return delete e[t],{newDocument:n,removed:r}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:function(e,t,n){var r=Gr(n,this.path);r&&(r=be(r));var o=$t(n,{op:"remove",path:this.from}).removed;return $t(n,{op:"add",path:this.path,value:o}),{newDocument:n,removed:r}},copy:function(e,t,n){var r=Gr(n,this.from);return $t(n,{op:"add",path:this.path,value:be(r)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:jn(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},gh={add:function(e,t,n){return Ur(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:n,index:t}},remove:function(e,t,n){var r=e.splice(t,1);return{newDocument:n,removed:r[0]}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:gn.move,copy:gn.copy,test:gn.test,_get:gn._get};function Gr(e,t){if(t=="")return e;var n={op:"_get",path:t};return $t(e,n),n.value}function $t(e,t,n,r,o,s){if(n===void 0&&(n=!1),r===void 0&&(r=!0),o===void 0&&(o=!0),s===void 0&&(s=0),n&&(typeof n=="function"?n(t,0,e,t.path):Fr(t,0)),t.path===""){var i={newDocument:e};if(t.op==="add")return i.newDocument=t.value,i;if(t.op==="replace")return i.newDocument=t.value,i.removed=e,i;if(t.op==="move"||t.op==="copy")return i.newDocument=Gr(e,t.from),t.op==="move"&&(i.removed=e),i;if(t.op==="test"){if(i.test=jn(e,t.value),i.test===!1)throw new re("Test operation failed","TEST_OPERATION_FAILED",s,t,e);return i.newDocument=e,i}else{if(t.op==="remove")return i.removed=e,i.newDocument=null,i;if(t.op==="_get")return t.value=e,i;if(n)throw new re("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",s,t,e);return i}}else{r||(e=be(e));var a=t.path||"",u=a.split("/"),c=e,p=1,m=u.length,x=void 0,f=void 0,h=void 0;for(typeof n=="function"?h=n:h=Fr;;){if(f=u[p],f&&f.indexOf("~")!=-1&&(f=Bn(f)),o&&(f=="__proto__"||f=="prototype"&&p>0&&u[p-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&x===void 0&&(c[f]===void 0?x=u.slice(0,p).join("/"):p==m-1&&(x=t.path),x!==void 0&&h(t,0,e,x)),p++,Array.isArray(c)){if(f==="-")f=c.length;else{if(n&&!Ur(f))throw new re("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",s,t,e);Ur(f)&&(f=~~f)}if(p>=m){if(n&&t.op==="add"&&f>c.length)throw new re("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",s,t,e);var i=gh[t.op].call(t,c,f,e);if(i.test===!1)throw new re("Test operation failed","TEST_OPERATION_FAILED",s,t,e);return i}}else if(p>=m){var i=gn[t.op].call(t,c,f,e);if(i.test===!1)throw new re("Test operation failed","TEST_OPERATION_FAILED",s,t,e);return i}if(c=c[f],n&&p<m&&(!c||typeof c!="object"))throw new re("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",s,t,e)}}}function Hr(e,t,n,r,o){if(r===void 0&&(r=!0),o===void 0&&(o=!0),n&&!Array.isArray(t))throw new re("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(e=be(e));for(var s=new Array(t.length),i=0,a=t.length;i<a;i++)s[i]=$t(e,t[i],n,!0,o,i),e=s[i].newDocument;return s.newDocument=e,s}function vh(e,t,n){var r=$t(e,t);if(r.test===!1)throw new re("Test operation failed","TEST_OPERATION_FAILED",n,t,e);return r.newDocument}function Fr(e,t,n,r){if(typeof e!="object"||e===null||Array.isArray(e))throw new re("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,n);if(gn[e.op]){if(typeof e.path!="string")throw new re("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,n);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new re('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",t,e,n);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new re("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new re("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&Lr(e.value))throw new re("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,n);if(n){if(e.op=="add"){var o=e.path.split("/").length,s=r.split("/").length;if(o!==s+1&&o!==s)throw new re("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,n)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==r)throw new re("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,n)}else if(e.op==="move"||e.op==="copy"){var i={op:"_get",path:e.from,value:void 0},a=El([i],n);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new re("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,n)}}}else throw new re("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,n)}function El(e,t,n){try{if(!Array.isArray(e))throw new re("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)Hr(be(t),be(e),n||!0);else{n=n||Fr;for(var r=0;r<e.length;r++)n(e[r],r,t,void 0)}}catch(o){if(o instanceof re)return o;throw o}}function jn(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var n=Array.isArray(e),r=Array.isArray(t),o,s,i;if(n&&r){if(s=e.length,s!=t.length)return!1;for(o=s;o--!==0;)if(!jn(e[o],t[o]))return!1;return!0}if(n!=r)return!1;var a=Object.keys(e);if(s=a.length,s!==Object.keys(t).length)return!1;for(o=s;o--!==0;)if(!t.hasOwnProperty(a[o]))return!1;for(o=s;o--!==0;)if(i=a[o],!jn(e[i],t[i]))return!1;return!0}return e!==e&&t!==t}var oi={};ms(oi,{compare:()=>wh,generate:()=>ti,observe:()=>Sh,unobserve:()=>Th});var ni=new WeakMap,yh=(function(){function e(t){this.observers=new Map,this.obj=t}return e})(),bh=(function(){function e(t,n){this.callback=t,this.observer=n}return e})();function xh(e){return ni.get(e)}function Eh(e,t){return e.observers.get(t)}function _h(e,t){e.observers.delete(t.callback)}function Th(e,t){t.unobserve()}function Sh(e,t){var n=[],r,o=xh(e);if(!o)o=new yh(e),ni.set(e,o);else{var s=Eh(o,t);r=s&&s.observer}if(r)return r;if(r={},o.value=be(e),t){r.callback=t,r.next=null;var i=function(){ti(r)},a=function(){clearTimeout(r.next),r.next=setTimeout(i)};typeof window<"u"&&(window.addEventListener("mouseup",a),window.addEventListener("keyup",a),window.addEventListener("mousedown",a),window.addEventListener("keydown",a),window.addEventListener("change",a))}return r.patches=n,r.object=e,r.unobserve=function(){ti(r),clearTimeout(r.next),_h(o,r),typeof window<"u"&&(window.removeEventListener("mouseup",a),window.removeEventListener("keyup",a),window.removeEventListener("mousedown",a),window.removeEventListener("keydown",a),window.removeEventListener("change",a))},o.observers.set(t,new bh(t,r)),r}function ti(e,t){t===void 0&&(t=!1);var n=ni.get(e.object);ri(n.value,e.object,e.patches,"",t),e.patches.length&&Hr(n.value,e.patches);var r=e.patches;return r.length>0&&(e.patches=[],e.callback&&e.callback(r)),r}function ri(e,t,n,r,o){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var s=Dr(t),i=Dr(e),a=!1,u=!1,c=i.length-1;c>=0;c--){var p=i[c],m=e[p];if(Pr(t,p)&&!(t[p]===void 0&&m!==void 0&&Array.isArray(t)===!1)){var x=t[p];typeof m=="object"&&m!=null&&typeof x=="object"&&x!=null&&Array.isArray(m)===Array.isArray(x)?ri(m,x,n,r+"/"+tt(p),o):m!==x&&(a=!0,o&&n.push({op:"test",path:r+"/"+tt(p),value:be(m)}),n.push({op:"replace",path:r+"/"+tt(p),value:be(x)}))}else Array.isArray(e)===Array.isArray(t)?(o&&n.push({op:"test",path:r+"/"+tt(p),value:be(m)}),n.push({op:"remove",path:r+"/"+tt(p)}),u=!0):(o&&n.push({op:"test",path:r,value:e}),n.push({op:"replace",path:r,value:t}),a=!0)}if(!(!u&&s.length==i.length))for(var c=0;c<s.length;c++){var p=s[c];!Pr(e,p)&&t[p]!==void 0&&n.push({op:"add",path:r+"/"+tt(p),value:be(t[p])})}}}function wh(e,t,n){n===void 0&&(n=!1);var r=[];return ri(e,t,r,"",n),r}var $r=Object.assign({},ei,oi,{JsonPatchError:Vn,deepClone:be,escapePathComponent:tt,unescapePathComponent:Bn});var si=function(e,t){return si=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},si(e,t)};function nt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");si(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function _l(e,t,n,r){function o(s){return s instanceof n?s:new n(function(i){i(s)})}return new(n||(n=Promise))(function(s,i){function a(p){try{c(r.next(p))}catch(m){i(m)}}function u(p){try{c(r.throw(p))}catch(m){i(m)}}function c(p){p.done?s(p.value):o(p.value).then(a,u)}c((r=r.apply(e,t||[])).next())})}function zr(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,o,s,i=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),typeof Symbol=="function"&&(i[Symbol.iterator]=function(){return this}),i;function a(c){return function(p){return u([c,p])}}function u(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(s=c[0]&2?o.return:c[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,c[1])).done)return s;switch(o=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,o=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(p){c=[6,p],o=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function ct(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function vn(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),o,s=[],i;try{for(;(t===void 0||t-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(a){i={error:a}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function yn(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,s;r<o;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}function zt(e){return this instanceof zt?(this.v=e,this):new zt(e)}function Tl(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),o,s=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",i),o[Symbol.asyncIterator]=function(){return this},o;function i(f){return function(h){return Promise.resolve(h).then(f,m)}}function a(f,h){r[f]&&(o[f]=function(g){return new Promise(function(_,S){s.push([f,g,_,S])>1||u(f,g)})},h&&(o[f]=h(o[f])))}function u(f,h){try{c(r[f](h))}catch(g){x(s[0][3],g)}}function c(f){f.value instanceof zt?Promise.resolve(f.value.v).then(p,m):x(s[0][2],f)}function p(f){u("next",f)}function m(f){u("throw",f)}function x(f,h){f(h),s.shift(),s.length&&u(s[0][0],s[0][1])}}function Sl(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof ct=="function"?ct(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(i){return new Promise(function(a,u){i=e[s](i),o(a,u,i.done,i.value)})}}function o(s,i,a,u){Promise.resolve(u).then(function(c){s({value:c,done:a})},i)}}function G(e){return typeof e=="function"}function bn(e){var t=function(r){Error.call(r),r.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Br=bn(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
696
699
  `+n.map(function(r,o){return o+1+") "+r.toString()}).join(`
697
- `):"",this.name="UnsubscriptionError",this.errors=n}});function jn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var bn=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,o,s;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var a=lt(i),u=a.next();!u.done;u=a.next()){var c=u.value;c.remove(this)}}catch(g){t={error:g}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else i.remove(this);var p=this.initialTeardown;if(G(p))try{p()}catch(g){s=g instanceof zr?g.errors:[g]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var x=lt(m),f=x.next();!f.done;f=x.next()){var h=f.value;try{Sl(h)}catch(g){s=s??[],g instanceof zr?s=vn(vn([],gn(s)),gn(g.errors)):s.push(g)}}}catch(g){r={error:g}}finally{try{f&&!f.done&&(o=x.return)&&o.call(x)}finally{if(r)throw r.error}}}if(s)throw new zr(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)Sl(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&jn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&jn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})();var si=bn.EMPTY;function Br(e){return e instanceof bn||e&&"closed"in e&&G(e.remove)&&G(e.add)&&G(e.unsubscribe)}function Sl(e){G(e)?e():e.unsubscribe()}var He={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var xn={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=xn.delegate;return o?.setTimeout?o.setTimeout.apply(o,vn([e,t],gn(n))):setTimeout.apply(void 0,vn([e,t],gn(n)))},clearTimeout:function(e){var t=xn.delegate;return(t?.clearTimeout||clearTimeout)(e)},delegate:void 0};function Vr(e){xn.setTimeout(function(){var t=He.onUnhandledError;if(t)t(e);else throw e})}function Wn(){}var wl=(function(){return ii("C",void 0,void 0)})();function kl(e){return ii("E",void 0,e)}function Al(e){return ii("N",e,void 0)}function ii(e,t,n){return{kind:e,value:t,error:n}}var zt=null;function En(e){if(He.useDeprecatedSynchronousErrorHandling){var t=!zt;if(t&&(zt={errorThrown:!1,error:null}),e(),t){var n=zt,r=n.errorThrown,o=n.error;if(zt=null,r)throw o}}else e()}function Il(e){He.useDeprecatedSynchronousErrorHandling&&zt&&(zt.errorThrown=!0,zt.error=e)}var Xn=(function(e){tt(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Br(n)&&n.add(r)):r.destination=Ih,r}return t.create=function(n,r,o){return new Wr(n,r,o)},t.prototype.next=function(n){this.isStopped?li(Al(n),this):this._next(n)},t.prototype.error=function(n){this.isStopped?li(kl(n),this):(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped?li(wl,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(bn);var wh=Function.prototype.bind;function ai(e,t){return wh.call(e,t)}var kh=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(r){jr(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){jr(r)}else jr(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){jr(n)}},e})(),Wr=(function(e){tt(t,e);function t(n,r,o){var s=e.call(this)||this,i;if(G(n)||!n)i={next:n??void 0,error:r??void 0,complete:o??void 0};else{var a;s&&He.useDeprecatedNextContext?(a=Object.create(n),a.unsubscribe=function(){return s.unsubscribe()},i={next:n.next&&ai(n.next,a),error:n.error&&ai(n.error,a),complete:n.complete&&ai(n.complete,a)}):i=n}return s.destination=new kh(i),s}return t})(Xn);function jr(e){He.useDeprecatedSynchronousErrorHandling?Il(e):Vr(e)}function Ah(e){throw e}function li(e,t){var n=He.onStoppedNotification;n&&xn.setTimeout(function(){return n(e,t)})}var Ih={closed:!0,next:Wn,error:Ah,complete:Wn};var _n=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Tn(e){return e}function Xr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ci(e)}function ci(e){return e.length===0?Tn:e.length===1?e[0]:function(n){return e.reduce(function(r,o){return o(r)},n)}}var J=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var o=this,s=Nh(t)?t:new Wr(t,n,r);return En(function(){var i=o,a=i.operator,u=i.source;s.add(a?a.call(s,u):u?o._subscribe(s):o._trySubscribe(s))}),s},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=Cl(n),new n(function(o,s){var i=new Wr({next:function(a){try{t(a)}catch(u){s(u),i.unsubscribe()}},error:s,complete:o});r.subscribe(i)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[_n]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ci(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Cl(t),new t(function(r,o){var s;n.subscribe(function(i){return s=i},function(i){return o(i)},function(){return r(s)})})},e.create=function(t){return new e(t)},e})();function Cl(e){var t;return(t=e??He.Promise)!==null&&t!==void 0?t:Promise}function Ch(e){return e&&G(e.next)&&G(e.error)&&G(e.complete)}function Nh(e){return e&&e instanceof Xn||Ch(e)&&Br(e)}function Rh(e){return G(e?.lift)}function ue(e){return function(t){if(Rh(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function he(e,t,n,r,o){return new Oh(e,t,n,r,o)}var Oh=(function(e){tt(t,e);function t(n,r,o,s,i,a){var u=e.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=a,u._next=r?function(c){try{r(c)}catch(p){n.error(p)}}:e.prototype._next,u._error=s?function(c){try{s(c)}catch(p){n.error(p)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=o?function(){try{o()}catch(c){n.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t})(Xn);var Nl=yn(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var nt=(function(e){tt(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new Rl(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Nl},t.prototype.next=function(n){var r=this;En(function(){var o,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=lt(r.currentObservers),a=i.next();!a.done;a=i.next()){var u=a.value;u.next(n)}}catch(c){o={error:c}}finally{try{a&&!a.done&&(s=i.return)&&s.call(i)}finally{if(o)throw o.error}}}})},t.prototype.error=function(n){var r=this;En(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var o=r.observers;o.length;)o.shift().error(n)}})},t.prototype.complete=function(){var n=this;En(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,o=this,s=o.hasError,i=o.isStopped,a=o.observers;return s||i?si:(this.currentObservers=null,a.push(n),new bn(function(){r.currentObservers=null,jn(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,o=r.hasError,s=r.thrownError,i=r.isStopped;o?n.error(s):i&&n.complete()},t.prototype.asObservable=function(){var n=new J;return n.source=this,n},t.create=function(n,r){return new Rl(n,r)},t})(J);var Rl=(function(e){tt(t,e);function t(n,r){var o=e.call(this)||this;return o.destination=n,o.source=r,o}return t.prototype.next=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.next)===null||o===void 0||o.call(r,n)},t.prototype.error=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.error)===null||o===void 0||o.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,o;return(o=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&o!==void 0?o:si},t})(nt);var ui={now:function(){return(ui.delegate||Date).now()},delegate:void 0};var Zr=(function(e){tt(t,e);function t(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=ui);var s=e.call(this)||this;return s._bufferSize=n,s._windowTime=r,s._timestampProvider=o,s._buffer=[],s._infiniteTimeWindow=!0,s._infiniteTimeWindow=r===1/0,s._bufferSize=Math.max(1,n),s._windowTime=Math.max(1,r),s}return t.prototype.next=function(n){var r=this,o=r.isStopped,s=r._buffer,i=r._infiniteTimeWindow,a=r._timestampProvider,u=r._windowTime;o||(s.push(n),!i&&s.push(a.now()+u)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),o=this,s=o._infiniteTimeWindow,i=o._buffer,a=i.slice(),u=0;u<a.length&&!n.closed;u+=s?1:2)n.next(a[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,o=n._timestampProvider,s=n._buffer,i=n._infiniteTimeWindow,a=(i?1:2)*r;if(r<1/0&&a<s.length&&s.splice(0,s.length-a),!i){for(var u=o.now(),c=0,p=1;p<s.length&&s[p]<=u;p+=2)c=p;c&&s.splice(0,c+1)}},t})(nt);var Kr=new J(function(e){return e.complete()});function Ol(e){return e&&G(e.schedule)}function Mh(e){return e[e.length-1]}function Ml(e){return Ol(Mh(e))?e.pop():void 0}var Yr=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function qr(e){return G(e?.then)}function Jr(e){return G(e[_n])}function Qr(e){return Symbol.asyncIterator&&G(e?.[Symbol.asyncIterator])}function eo(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Lh(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var to=Lh();function no(e){return G(e?.[to])}function ro(e){return _l(this,arguments,function(){var n,r,o,s;return $r(this,function(i){switch(i.label){case 0:n=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,$t(n.read())];case 3:return r=i.sent(),o=r.value,s=r.done,s?[4,$t(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,$t(o)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function oo(e){return G(e?.getReader)}function me(e){if(e instanceof J)return e;if(e!=null){if(Jr(e))return Ph(e);if(Yr(e))return Dh(e);if(qr(e))return Uh(e);if(Qr(e))return Ll(e);if(no(e))return Gh(e);if(oo(e))return Fh(e)}throw eo(e)}function Ph(e){return new J(function(t){var n=e[_n]();if(G(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Dh(e){return new J(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function Uh(e){return new J(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,Vr)})}function Gh(e){return new J(function(t){var n,r;try{for(var o=lt(e),s=o.next();!s.done;s=o.next()){var i=s.value;if(t.next(i),t.closed)return}}catch(a){n={error:a}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}t.complete()})}function Ll(e){return new J(function(t){Hh(e,t).catch(function(n){return t.error(n)})})}function Fh(e){return Ll(ro(e))}function Hh(e,t){var n,r,o,s;return El(this,void 0,void 0,function(){var i,a;return $r(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Tl(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=u.sent(),o={error:a},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function Le(e,t,n,r,o){r===void 0&&(r=0),o===void 0&&(o=!1);var s=t.schedule(function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(s),!o)return s}function so(e,t){return t===void 0&&(t=0),ue(function(n,r){n.subscribe(he(r,function(o){return Le(r,e,function(){return r.next(o)},t)},function(){return Le(r,e,function(){return r.complete()},t)},function(o){return Le(r,e,function(){return r.error(o)},t)}))})}function io(e,t){return t===void 0&&(t=0),ue(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Pl(e,t){return me(e).pipe(io(t),so(t))}function Dl(e,t){return me(e).pipe(io(t),so(t))}function Ul(e,t){return new J(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Gl(e,t){return new J(function(n){var r;return Le(n,t,function(){r=e[to](),Le(n,t,function(){var o,s,i;try{o=r.next(),s=o.value,i=o.done}catch(a){n.error(a);return}i?n.complete():n.next(s)},0,!0)}),function(){return G(r?.return)&&r.return()}})}function ao(e,t){if(!e)throw new Error("Iterable cannot be null");return new J(function(n){Le(n,t,function(){var r=e[Symbol.asyncIterator]();Le(n,t,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function Fl(e,t){return ao(ro(e),t)}function Hl(e,t){if(e!=null){if(Jr(e))return Pl(e,t);if(Yr(e))return Ul(e,t);if(qr(e))return Dl(e,t);if(Qr(e))return ao(e,t);if(no(e))return Gl(e,t);if(oo(e))return Fl(e,t)}throw eo(e)}function Bt(e,t){return t?Hl(e,t):me(e)}function te(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ml(e);return Bt(e,n)}function Q(e,t){var n=G(e)?e:function(){return e},r=function(o){return o.error(n())};return new J(t?function(o){return t.schedule(r,0,o)}:r)}var $l=yn(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function lo(e,t){var n=typeof t=="object";return new Promise(function(r,o){var s=!1,i;e.subscribe({next:function(a){i=a,s=!0},error:o,complete:function(){s?r(i):n?r(t.defaultValue):o(new $l)}})})}function Vt(e,t){return ue(function(n,r){var o=0;n.subscribe(he(r,function(s){r.next(e.call(t,s,o++))}))})}function zl(e,t,n,r,o,s,i,a){var u=[],c=0,p=0,m=!1,x=function(){m&&!u.length&&!c&&t.complete()},f=function(g){return c<r?h(g):u.push(g)},h=function(g){s&&t.next(g),c++;var _=!1;me(n(g,p++)).subscribe(he(t,function(S){o?.(S),s?f(S):t.next(S)},function(){_=!0},void 0,function(){if(_)try{c--;for(var S=function(){var b=u.shift();i?Le(t,i,function(){return h(b)}):h(b)};u.length&&c<r;)S();x()}catch(b){t.error(b)}}))};return e.subscribe(he(t,f,function(){m=!0,x()})),function(){a?.()}}function Ae(e,t,n){return n===void 0&&(n=1/0),G(t)?Ae(function(r,o){return Vt(function(s,i){return t(r,s,o,i)})(me(e(r,o)))},n):(typeof t=="number"&&(n=t),ue(function(r,o){return zl(r,o,e,n)}))}function di(e){return e===void 0&&(e=1/0),Ae(Tn,e)}function co(e){return new J(function(t){me(e()).subscribe(t)})}function Zn(e){return ue(function(t,n){var r=null,o=!1,s;r=t.subscribe(he(n,void 0,void 0,function(i){s=me(e(i,Zn(e)(t))),r?(r.unsubscribe(),r=null,s.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,s.subscribe(n))})}function uo(e,t){return G(t)?Ae(e,t,1):Ae(e,1)}function pi(e){return ue(function(t,n){var r=!1;t.subscribe(he(n,function(o){r=!0,n.next(o)},function(){r||n.next(e),n.complete()}))})}function jt(e){return ue(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}function fi(e,t){return ue(function(n,r){var o=null,s=0,i=!1,a=function(){return i&&!o&&r.complete()};n.subscribe(he(r,function(u){o?.unsubscribe();var c=0,p=s++;me(e(u,p)).subscribe(o=he(r,function(m){return r.next(t?t(u,m,p,c++):m)},function(){o=null,a()}))},function(){i=!0,a()}))})}function po(e){return ue(function(t,n){me(e).subscribe(he(n,function(){return n.complete()},Wn)),!n.closed&&t.subscribe(n)})}function hi(e,t,n){var r=G(e)||t||n?{next:e,error:t,complete:n}:e;return r?ue(function(o,s){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var a=!0;o.subscribe(he(s,function(u){var c;(c=r.next)===null||c===void 0||c.call(r,u),s.next(u)},function(){var u;a=!1,(u=r.complete)===null||u===void 0||u.call(r),s.complete()},function(u){var c;a=!1,(c=r.error)===null||c===void 0||c.call(r,u),s.error(u)},function(){var u,c;a&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(c=r.finalize)===null||c===void 0||c.call(r)}))}):Tn}function Bl(e){return` \r
698
- `.indexOf(e)>=0}function fo(e){for(var t=["topLevel"],n=0,r,o,s,i=function(b){return t.push(b)},a=function(b){return t[t.length-1]=b},u=function(b){r==null&&(r=n,o=t.length,s=b)},c=function(b){b===s&&(r=void 0,o=void 0,s=void 0)},p=function(){return t.pop()},m=function(){return n--},x=function(b){if("0"<=b&&b<="9"){i("number");return}switch(b){case'"':i("string");return;case"-":i("numberNeedsDigit");return;case"t":i("true");return;case"f":i("false");return;case"n":i("null");return;case"[":i("arrayNeedsValue");return;case"{":i("objectNeedsKey");return}},f=e.length;n<f;n++){var h=e[n];switch(t[t.length-1]){case"topLevel":x(h);break;case"string":switch(h){case'"':p();break;case"\\":u("stringEscape"),i("stringEscaped");break}break;case"stringEscaped":h==="u"?i("stringUnicode"):(c("stringEscape"),p());break;case"stringUnicode":n-e.lastIndexOf("u",n)===4&&(c("stringEscape"),p());break;case"number":h==="."?a("numberNeedsDigit"):h==="e"||h==="E"?a("numberNeedsExponent"):(h<"0"||h>"9")&&(m(),p());break;case"numberNeedsDigit":a("number");break;case"numberNeedsExponent":a(h==="+"||h==="-"?"numberNeedsDigit":"number");break;case"true":case"false":case"null":(h<"a"||h>"z")&&(m(),p());break;case"arrayNeedsValue":h==="]"?p():Bl(h)||(c("collectionItem"),a("arrayNeedsComma"),x(h));break;case"arrayNeedsComma":h==="]"?p():h===","&&(u("collectionItem"),a("arrayNeedsValue"));break;case"objectNeedsKey":h==="}"?p():h==='"'&&(u("collectionItem"),a("objectNeedsColon"),i("string"));break;case"objectNeedsColon":h===":"&&a("objectNeedsValue");break;case"objectNeedsValue":Bl(h)||(c("collectionItem"),a("objectNeedsComma"),x(h));break;case"objectNeedsComma":h==="}"?p():h===","&&(u("collectionItem"),a("objectNeedsKey"));break}}o!=null&&(t.length=o);for(var g=[r!=null?e.slice(0,r):e],_=function(b){return g.push(b.slice(e.length-e.lastIndexOf(b[0])))},S=t.length-1;S>=0;S--)switch(t[S]){case"string":g.push('"');break;case"numberNeedsDigit":case"numberNeedsExponent":g.push("0");break;case"true":_("true");break;case"false":_("false");break;case"null":_("null");break;case"arrayNeedsValue":case"arrayNeedsComma":g.push("]");break;case"objectNeedsKey":case"objectNeedsColon":case"objectNeedsValue":case"objectNeedsComma":g.push("}");break}return g.join("")}function jl(){let e=0,t=0;for(let r=0;r<28;r+=7){let o=this.buf[this.pos++];if(e|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(n&15)<<28,t=(n&112)>>4,(n&128)==0)return this.assertBounds(),[e,t];for(let r=3;r<=31;r+=7){let o=this.buf[this.pos++];if(t|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function mo(e,t,n){for(let s=0;s<28;s=s+7){let i=e>>>s,a=!(!(i>>>7)&&t==0),u=(a?i|128:i)&255;if(n.push(u),!a)return}let r=e>>>28&15|(t&7)<<4,o=t>>3!=0;if(n.push((o?r|128:r)&255),!!o){for(let s=3;s<31;s=s+7){let i=t>>>s,a=!!(i>>>7),u=(a?i|128:i)&255;if(n.push(u),!a)return}n.push(t>>>31&1)}}var ho=4294967296;function mi(e){let t=e[0]==="-";t&&(e=e.slice(1));let n=1e6,r=0,o=0;function s(i,a){let u=Number(e.slice(i,a));o*=n,r=r*n+u,r>=ho&&(o=o+(r/ho|0),r=r%ho)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),t?Xl(r,o):vi(r,o)}function Wl(e,t){let n=vi(e,t),r=n.hi&2147483648;r&&(n=Xl(n.lo,n.hi));let o=gi(n.lo,n.hi);return r?"-"+o:o}function gi(e,t){if({lo:e,hi:t}=$h(e,t),t<=2097151)return String(ho*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,o=t>>16&65535,s=n+r*6777216+o*6710656,i=r+o*8147497,a=o*2,u=1e7;return s>=u&&(i+=Math.floor(s/u),s%=u),i>=u&&(a+=Math.floor(i/u),i%=u),a.toString()+Vl(i)+Vl(s)}function $h(e,t){return{lo:e>>>0,hi:t>>>0}}function vi(e,t){return{lo:e|0,hi:t|0}}function Xl(e,t){return t=~t,e?e=~e+1:t+=1,vi(e,t)}var Vl=e=>{let t=String(e);return"0000000".slice(t.length)+t};function yi(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e=e>>>7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e=e>>7;t.push(1)}}function Zl(){let e=this.buf[this.pos++],t=e&127;if((e&128)==0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<7,(e&128)==0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<14,(e&128)==0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<21,(e&128)==0)return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let n=5;(e&128)!==0&&n<10;n++)e=this.buf[this.pos++];if((e&128)!=0)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var $e=zh();function zh(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof e.getBigInt64=="function"&&typeof e.getBigUint64=="function"&&typeof e.setBigInt64=="function"&&typeof e.setBigUint64=="function"&&(!!globalThis.Deno||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let n=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),o=BigInt("0"),s=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(i){let a=typeof i=="bigint"?i:BigInt(i);if(a>r||a<n)throw new Error(`invalid int64: ${i}`);return a},uParse(i){let a=typeof i=="bigint"?i:BigInt(i);if(a>s||a<o)throw new Error(`invalid uint64: ${i}`);return a},enc(i){return e.setBigInt64(0,this.parse(i),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(i){return e.setBigInt64(0,this.uParse(i),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(i,a){return e.setInt32(0,i,!0),e.setInt32(4,a,!0),e.getBigInt64(0,!0)},uDec(i,a){return e.setInt32(0,i,!0),e.setInt32(4,a,!0),e.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(n){return typeof n!="string"&&(n=n.toString()),Kl(n),n},uParse(n){return typeof n!="string"&&(n=n.toString()),Yl(n),n},enc(n){return typeof n!="string"&&(n=n.toString()),Kl(n),mi(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),Yl(n),mi(n)},dec(n,r){return Wl(n,r)},uDec(n,r){return gi(n,r)}}}function Kl(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function Yl(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}var bi=Symbol.for("@bufbuild/protobuf/text-encoding");function xi(){if(globalThis[bi]==null){let e=new globalThis.TextEncoder,t=new globalThis.TextDecoder,n;globalThis[bi]={encodeUtf8(r){return e.encode(r)},decodeUtf8(r,o){return o?(n===void 0&&(n=new globalThis.TextDecoder("utf-8",{fatal:!0})),n.decode(r)):t.decode(r)},checkUtf8(r){try{return encodeURIComponent(r),!0}catch{return!1}}}}return globalThis[bi]}var yt;(function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"})(yt||(yt={}));var Bh=34028234663852886e22,Vh=-34028234663852886e22,jh=4294967295,Wh=2147483647,Xh=-2147483648,D=class{constructor(t=xi().encodeUtf8){this.encodeUtf8=t,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let t=0;for(let o=0;o<this.chunks.length;o++)t+=this.chunks[o].length;let n=new Uint8Array(t),r=0;for(let o=0;o<this.chunks.length;o++)n.set(this.chunks[o],r),r+=this.chunks[o].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let t=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(t.byteLength),this.raw(t)}tag(t,n){return this.uint32((t<<3|n)>>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(ql(t);t>127;)this.buf.push(t&127|128),t=t>>>7;return this.buf.push(t),this}int32(t){return Ei(t),yi(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let n=this.encodeUtf8(t);return this.uint32(n.byteLength),this.raw(n)}float(t){Zh(t);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,t,!0),this.raw(n)}double(t){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,t,!0),this.raw(n)}fixed32(t){ql(t);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,t,!0),this.raw(n)}sfixed32(t){Ei(t);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,t,!0),this.raw(n)}sint32(t){return Ei(t),t=(t<<1^t>>31)>>>0,yi(t,this.buf),this}sfixed64(t){let n=new Uint8Array(8),r=new DataView(n.buffer),o=$e.enc(t);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}fixed64(t){let n=new Uint8Array(8),r=new DataView(n.buffer),o=$e.uEnc(t);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}int64(t){let n=$e.enc(t);return mo(n.lo,n.hi,this.buf),this}sint64(t){let n=$e.enc(t),r=n.hi>>31,o=n.lo<<1^r,s=(n.hi<<1|n.lo>>>31)^r;return mo(o,s,this.buf),this}uint64(t){let n=$e.uEnc(t);return mo(n.lo,n.hi,this.buf),this}},T=class{constructor(t,n=xi().decodeUtf8){this.decodeUtf8=n,this.varint64=jl,this.uint32=Zl,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}tag(){let t=this.pos,n=this.uint32(),r=this.pos-t;if(r>5||r==5&&this.buf[this.pos-1]>15)throw new Error("illegal tag: varint overflows uint32");let o=n>>>3,s=n&7;if(o<=0||s>5)throw new Error("illegal tag: field no "+o+" wire type "+s);return[o,s]}skip(t,n){let r=this.pos;switch(t){case yt.Varint:for(;this.buf[this.pos++]&128;);break;case yt.Bit64:this.pos+=4;case yt.Bit32:this.pos+=4;break;case yt.LengthDelimited:let o=this.uint32();this.pos+=o;break;case yt.StartGroup:for(;;){let[s,i]=this.tag();if(i===yt.EndGroup){if(n!==void 0&&s!==n)throw new Error("invalid end group tag");break}this.skip(i,s)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return $e.dec(...this.varint64())}uint64(){return $e.uDec(...this.varint64())}sint64(){let[t,n]=this.varint64(),r=-(t&1);return t=(t>>>1|(n&1)<<31)^r,n=n>>>1^r,$e.dec(t,n)}bool(){let[t,n]=this.varint64();return t!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return $e.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return $e.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),n=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(n,n+t)}string(t){return this.decodeUtf8(this.bytes(),t)}};function Ei(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>Wh||e<Xh)throw new Error("invalid int32: "+e)}function ql(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>jh||e<0)throw new Error("invalid uint32: "+e)}function Zh(e){if(typeof e=="string"){let t=e;if(e=Number(e),Number.isNaN(e)&&t!=="NaN")throw new Error("invalid float32: "+t)}else if(typeof e!="number")throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>Bh||e<Vh))throw new Error("invalid float32: "+e)}var Kh=(function(e){return e[e.NULL_VALUE=0]="NULL_VALUE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e})({});function _i(){return{fields:{}}}var Kn={encode(e,t=new D){return Object.entries(e.fields).forEach(([n,r])=>{r!==void 0&&wi.encode({key:n,value:r},t.uint32(10).fork()).join()}),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=_i();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:{if(s!==10)break;let i=wi.decode(n,n.uint32());i.value!==void 0&&(o.fields[i.key]=i.value);continue}}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Kn.fromPartial(e??{})},fromPartial(e){let t=_i();return t.fields=Object.entries(e.fields??{}).reduce((n,[r,o])=>(o!==void 0&&(n[r]=o),n),{}),t},wrap(e){let t=_i();if(e!==void 0)for(let n of Object.keys(e))t.fields[n]=e[n];return t},unwrap(e){let t={};if(e.fields)for(let n of Object.keys(e.fields))t[n]=e.fields[n];return t}};function Jl(){return{key:"",value:void 0}}var wi={encode(e,t=new D){return e.key!==""&&t.uint32(10).string(e.key),e.value!==void 0&&N.encode(N.wrap(e.value),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Jl();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.key=n.string();continue;case 2:if(s!==18)break;o.value=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return wi.fromPartial(e??{})},fromPartial(e){let t=Jl();return t.key=e.key??"",t.value=e.value??void 0,t}};function Ti(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var N={encode(e,t=new D){return e.nullValue!==void 0&&t.uint32(8).int32(e.nullValue),e.numberValue!==void 0&&t.uint32(17).double(e.numberValue),e.stringValue!==void 0&&t.uint32(26).string(e.stringValue),e.boolValue!==void 0&&t.uint32(32).bool(e.boolValue),e.structValue!==void 0&&Kn.encode(Kn.wrap(e.structValue),t.uint32(42).fork()).join(),e.listValue!==void 0&&Yn.encode(Yn.wrap(e.listValue),t.uint32(50).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Ti();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==8)break;o.nullValue=n.int32();continue;case 2:if(s!==17)break;o.numberValue=n.double();continue;case 3:if(s!==26)break;o.stringValue=n.string();continue;case 4:if(s!==32)break;o.boolValue=n.bool();continue;case 5:if(s!==42)break;o.structValue=Kn.unwrap(Kn.decode(n,n.uint32()));continue;case 6:if(s!==50)break;o.listValue=Yn.unwrap(Yn.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return N.fromPartial(e??{})},fromPartial(e){let t=Ti();return t.nullValue=e.nullValue??void 0,t.numberValue=e.numberValue??void 0,t.stringValue=e.stringValue??void 0,t.boolValue=e.boolValue??void 0,t.structValue=e.structValue??void 0,t.listValue=e.listValue??void 0,t},wrap(e){let t=Ti();if(e===null)t.nullValue=Kh.NULL_VALUE;else if(typeof e=="boolean")t.boolValue=e;else if(typeof e=="number")t.numberValue=e;else if(typeof e=="string")t.stringValue=e;else if(globalThis.Array.isArray(e))t.listValue=e;else if(typeof e=="object")t.structValue=e;else if(typeof e<"u")throw new globalThis.Error("Unsupported any value type: "+typeof e);return t},unwrap(e){if(e.stringValue!==void 0)return e.stringValue;if(e?.numberValue!==void 0)return e.numberValue;if(e?.boolValue!==void 0)return e.boolValue;if(e?.structValue!==void 0)return e.structValue;if(e?.listValue!==void 0)return e.listValue;if(e?.nullValue!==void 0)return null}};function Si(){return{values:[]}}var Yn={encode(e,t=new D){for(let n of e.values)N.encode(N.wrap(n),t.uint32(10).fork()).join();return t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Si();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.values.push(N.unwrap(N.decode(n,n.uint32())));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Yn.fromPartial(e??{})},fromPartial(e){let t=Si();return t.values=e.values?.map(n=>n)||[],t},wrap(e){let t=Si();return t.values=e??[],t},unwrap(e){return e?.hasOwnProperty("values")&&globalThis.Array.isArray(e.values)?e.values:e}},Yh=(function(e){return e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.REPLACE=2]="REPLACE",e[e.MOVE=3]="MOVE",e[e.COPY=4]="COPY",e[e.TEST=5]="TEST",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e})({});function Ql(){return{op:0,path:"",from:void 0,value:void 0}}var vo={encode(e,t=new D){return e.op!==0&&t.uint32(8).int32(e.op),e.path!==""&&t.uint32(18).string(e.path),e.from!==void 0&&t.uint32(26).string(e.from),e.value!==void 0&&N.encode(N.wrap(e.value),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Ql();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==8)break;o.op=n.int32();continue;case 2:if(s!==18)break;o.path=n.string();continue;case 3:if(s!==26)break;o.from=n.string();continue;case 4:if(s!==34)break;o.value=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return vo.fromPartial(e??{})},fromPartial(e){let t=Ql();return t.op=e.op??0,t.path=e.path??"",t.from=e.from??void 0,t.value=e.value??void 0,t}};function ec(){return{id:"",type:"",function:void 0}}var yo={encode(e,t=new D){return e.id!==""&&t.uint32(10).string(e.id),e.type!==""&&t.uint32(18).string(e.type),e.function!==void 0&&bo.encode(e.function,t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=ec();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.id=n.string();continue;case 2:if(s!==18)break;o.type=n.string();continue;case 3:if(s!==26)break;o.function=bo.decode(n,n.uint32());continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return yo.fromPartial(e??{})},fromPartial(e){let t=ec();return t.id=e.id??"",t.type=e.type??"",t.function=e.function!==void 0&&e.function!==null?bo.fromPartial(e.function):void 0,t}};function tc(){return{name:"",arguments:""}}var bo={encode(e,t=new D){return e.name!==""&&t.uint32(10).string(e.name),e.arguments!==""&&t.uint32(18).string(e.arguments),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=tc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.name=n.string();continue;case 2:if(s!==18)break;o.arguments=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return bo.fromPartial(e??{})},fromPartial(e){let t=tc();return t.name=e.name??"",t.arguments=e.arguments??"",t}};function nc(){return{value:"",mimeType:""}}var xo={encode(e,t=new D){return e.value!==""&&t.uint32(10).string(e.value),e.mimeType!==""&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=nc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.value=n.string();continue;case 2:if(s!==18)break;o.mimeType=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return xo.fromPartial(e??{})},fromPartial(e){let t=nc();return t.value=e.value??"",t.mimeType=e.mimeType??"",t}};function rc(){return{value:"",mimeType:void 0}}var Eo={encode(e,t=new D){return e.value!==""&&t.uint32(10).string(e.value),e.mimeType!==void 0&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=rc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.value=n.string();continue;case 2:if(s!==18)break;o.mimeType=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Eo.fromPartial(e??{})},fromPartial(e){let t=rc();return t.value=e.value??"",t.mimeType=e.mimeType??void 0,t}};function oc(){return{data:void 0,url:void 0}}var Ie={encode(e,t=new D){return e.data!==void 0&&xo.encode(e.data,t.uint32(10).fork()).join(),e.url!==void 0&&Eo.encode(e.url,t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=oc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.data=xo.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.url=Eo.decode(n,n.uint32());continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Ie.fromPartial(e??{})},fromPartial(e){let t=oc();return t.data=e.data!==void 0&&e.data!==null?xo.fromPartial(e.data):void 0,t.url=e.url!==void 0&&e.url!==null?Eo.fromPartial(e.url):void 0,t}};function sc(){return{text:""}}var _o={encode(e,t=new D){return e.text!==""&&t.uint32(10).string(e.text),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=sc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.text=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return _o.fromPartial(e??{})},fromPartial(e){let t=sc();return t.text=e.text??"",t}};function ic(){return{source:void 0,metadata:void 0}}var To={encode(e,t=new D){return e.source!==void 0&&Ie.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&N.encode(N.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=ic();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.source=Ie.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.metadata=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return To.fromPartial(e??{})},fromPartial(e){let t=ic();return t.source=e.source!==void 0&&e.source!==null?Ie.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function ac(){return{source:void 0,metadata:void 0}}var So={encode(e,t=new D){return e.source!==void 0&&Ie.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&N.encode(N.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=ac();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.source=Ie.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.metadata=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return So.fromPartial(e??{})},fromPartial(e){let t=ac();return t.source=e.source!==void 0&&e.source!==null?Ie.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function lc(){return{source:void 0,metadata:void 0}}var wo={encode(e,t=new D){return e.source!==void 0&&Ie.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&N.encode(N.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=lc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.source=Ie.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.metadata=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return wo.fromPartial(e??{})},fromPartial(e){let t=lc();return t.source=e.source!==void 0&&e.source!==null?Ie.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function cc(){return{source:void 0,metadata:void 0}}var ko={encode(e,t=new D){return e.source!==void 0&&Ie.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&N.encode(N.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=cc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.source=Ie.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.metadata=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return ko.fromPartial(e??{})},fromPartial(e){let t=cc();return t.source=e.source!==void 0&&e.source!==null?Ie.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function uc(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var Ao={encode(e,t=new D){return e.text!==void 0&&_o.encode(e.text,t.uint32(10).fork()).join(),e.image!==void 0&&To.encode(e.image,t.uint32(18).fork()).join(),e.audio!==void 0&&So.encode(e.audio,t.uint32(26).fork()).join(),e.video!==void 0&&wo.encode(e.video,t.uint32(34).fork()).join(),e.document!==void 0&&ko.encode(e.document,t.uint32(42).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=uc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.text=_o.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.image=To.decode(n,n.uint32());continue;case 3:if(s!==26)break;o.audio=So.decode(n,n.uint32());continue;case 4:if(s!==34)break;o.video=wo.decode(n,n.uint32());continue;case 5:if(s!==42)break;o.document=ko.decode(n,n.uint32());continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Ao.fromPartial(e??{})},fromPartial(e){let t=uc();return t.text=e.text!==void 0&&e.text!==null?_o.fromPartial(e.text):void 0,t.image=e.image!==void 0&&e.image!==null?To.fromPartial(e.image):void 0,t.audio=e.audio!==void 0&&e.audio!==null?So.fromPartial(e.audio):void 0,t.video=e.video!==void 0&&e.video!==null?wo.fromPartial(e.video):void 0,t.document=e.document!==void 0&&e.document!==null?ko.fromPartial(e.document):void 0,t}};function dc(){return{id:"",role:"",content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var Io={encode(e,t=new D){e.id!==""&&t.uint32(10).string(e.id),e.role!==""&&t.uint32(18).string(e.role),e.content!==void 0&&t.uint32(26).string(e.content),e.name!==void 0&&t.uint32(34).string(e.name);for(let n of e.toolCalls)yo.encode(n,t.uint32(42).fork()).join();e.toolCallId!==void 0&&t.uint32(50).string(e.toolCallId),e.error!==void 0&&t.uint32(58).string(e.error);for(let n of e.contentParts)Ao.encode(n,t.uint32(66).fork()).join();return t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=dc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.id=n.string();continue;case 2:if(s!==18)break;o.role=n.string();continue;case 3:if(s!==26)break;o.content=n.string();continue;case 4:if(s!==34)break;o.name=n.string();continue;case 5:if(s!==42)break;o.toolCalls.push(yo.decode(n,n.uint32()));continue;case 6:if(s!==50)break;o.toolCallId=n.string();continue;case 7:if(s!==58)break;o.error=n.string();continue;case 8:if(s!==66)break;o.contentParts.push(Ao.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Io.fromPartial(e??{})},fromPartial(e){let t=dc();return t.id=e.id??"",t.role=e.role??"",t.content=e.content??void 0,t.name=e.name??void 0,t.toolCalls=e.toolCalls?.map(n=>yo.fromPartial(n))||[],t.toolCallId=e.toolCallId??void 0,t.error=e.error??void 0,t.contentParts=e.contentParts?.map(n=>Ao.fromPartial(n))||[],t}};function pc(){return{id:"",reason:"",message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var Co={encode(e,t=new D){return e.id!==""&&t.uint32(10).string(e.id),e.reason!==""&&t.uint32(18).string(e.reason),e.message!==void 0&&t.uint32(26).string(e.message),e.toolCallId!==void 0&&t.uint32(34).string(e.toolCallId),e.responseSchema!==void 0&&N.encode(N.wrap(e.responseSchema),t.uint32(42).fork()).join(),e.expiresAt!==void 0&&t.uint32(50).string(e.expiresAt),e.metadata!==void 0&&N.encode(N.wrap(e.metadata),t.uint32(58).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=pc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.id=n.string();continue;case 2:if(s!==18)break;o.reason=n.string();continue;case 3:if(s!==26)break;o.message=n.string();continue;case 4:if(s!==34)break;o.toolCallId=n.string();continue;case 5:if(s!==42)break;o.responseSchema=N.unwrap(N.decode(n,n.uint32()));continue;case 6:if(s!==50)break;o.expiresAt=n.string();continue;case 7:if(s!==58)break;o.metadata=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Co.fromPartial(e??{})},fromPartial(e){let t=pc();return t.id=e.id??"",t.reason=e.reason??"",t.message=e.message??void 0,t.toolCallId=e.toolCallId??void 0,t.responseSchema=e.responseSchema??void 0,t.expiresAt=e.expiresAt??void 0,t.metadata=e.metadata??void 0,t}},qh=(function(e){return e[e.TEXT_MESSAGE_START=0]="TEXT_MESSAGE_START",e[e.TEXT_MESSAGE_CONTENT=1]="TEXT_MESSAGE_CONTENT",e[e.TEXT_MESSAGE_END=2]="TEXT_MESSAGE_END",e[e.TOOL_CALL_START=3]="TOOL_CALL_START",e[e.TOOL_CALL_ARGS=4]="TOOL_CALL_ARGS",e[e.TOOL_CALL_END=5]="TOOL_CALL_END",e[e.STATE_SNAPSHOT=6]="STATE_SNAPSHOT",e[e.STATE_DELTA=7]="STATE_DELTA",e[e.MESSAGES_SNAPSHOT=8]="MESSAGES_SNAPSHOT",e[e.RAW=9]="RAW",e[e.CUSTOM=10]="CUSTOM",e[e.RUN_STARTED=11]="RUN_STARTED",e[e.RUN_FINISHED=12]="RUN_FINISHED",e[e.RUN_ERROR=13]="RUN_ERROR",e[e.STEP_STARTED=14]="STEP_STARTED",e[e.STEP_FINISHED=15]="STEP_FINISHED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e})({});function fc(){return{type:0,timestamp:void 0,rawEvent:void 0}}var R={encode(e,t=new D){return e.type!==0&&t.uint32(8).int32(e.type),e.timestamp!==void 0&&t.uint32(16).int64(e.timestamp),e.rawEvent!==void 0&&N.encode(N.wrap(e.rawEvent),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=fc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==8)break;o.type=n.int32();continue;case 2:if(s!==16)break;o.timestamp=Jh(n.int64());continue;case 3:if(s!==26)break;o.rawEvent=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return R.fromPartial(e??{})},fromPartial(e){let t=fc();return t.type=e.type??0,t.timestamp=e.timestamp??void 0,t.rawEvent=e.rawEvent??void 0,t}};function hc(){return{baseEvent:void 0,messageId:"",role:void 0,name:void 0}}var No={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.name!==void 0&&t.uint32(34).string(e.name),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=hc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.messageId=n.string();continue;case 3:if(s!==26)break;o.role=n.string();continue;case 4:if(s!==34)break;o.name=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return No.fromPartial(e??{})},fromPartial(e){let t=hc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t.role=e.role??void 0,t.name=e.name??void 0,t}};function mc(){return{baseEvent:void 0,messageId:"",delta:""}}var Ro={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),e.delta!==""&&t.uint32(26).string(e.delta),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=mc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.messageId=n.string();continue;case 3:if(s!==26)break;o.delta=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Ro.fromPartial(e??{})},fromPartial(e){let t=mc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t.delta=e.delta??"",t}};function gc(){return{baseEvent:void 0,messageId:""}}var Oo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=gc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.messageId=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Oo.fromPartial(e??{})},fromPartial(e){let t=gc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t}};function vc(){return{baseEvent:void 0,toolCallId:"",toolCallName:"",parentMessageId:void 0}}var Mo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),e.toolCallName!==""&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=vc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.toolCallId=n.string();continue;case 3:if(s!==26)break;o.toolCallName=n.string();continue;case 4:if(s!==34)break;o.parentMessageId=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Mo.fromPartial(e??{})},fromPartial(e){let t=vc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t.toolCallName=e.toolCallName??"",t.parentMessageId=e.parentMessageId??void 0,t}};function yc(){return{baseEvent:void 0,toolCallId:"",delta:""}}var Lo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),e.delta!==""&&t.uint32(26).string(e.delta),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=yc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.toolCallId=n.string();continue;case 3:if(s!==26)break;o.delta=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Lo.fromPartial(e??{})},fromPartial(e){let t=yc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t.delta=e.delta??"",t}};function bc(){return{baseEvent:void 0,toolCallId:""}}var Po={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=bc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.toolCallId=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Po.fromPartial(e??{})},fromPartial(e){let t=bc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t}};function xc(){return{baseEvent:void 0,snapshot:void 0}}var Do={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.snapshot!==void 0&&N.encode(N.wrap(e.snapshot),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=xc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.snapshot=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Do.fromPartial(e??{})},fromPartial(e){let t=xc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.snapshot=e.snapshot??void 0,t}};function Ec(){return{baseEvent:void 0,delta:[]}}var Uo={encode(e,t=new D){e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.delta)vo.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Ec();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.delta.push(vo.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Uo.fromPartial(e??{})},fromPartial(e){let t=Ec();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.delta=e.delta?.map(n=>vo.fromPartial(n))||[],t}};function _c(){return{baseEvent:void 0,messages:[]}}var Go={encode(e,t=new D){e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.messages)Io.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=_c();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.messages.push(Io.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Go.fromPartial(e??{})},fromPartial(e){let t=_c();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.messages=e.messages?.map(n=>Io.fromPartial(n))||[],t}};function Tc(){return{baseEvent:void 0,event:void 0,source:void 0}}var Fo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.event!==void 0&&N.encode(N.wrap(e.event),t.uint32(18).fork()).join(),e.source!==void 0&&t.uint32(26).string(e.source),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Tc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.event=N.unwrap(N.decode(n,n.uint32()));continue;case 3:if(s!==26)break;o.source=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Fo.fromPartial(e??{})},fromPartial(e){let t=Tc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.event=e.event??void 0,t.source=e.source??void 0,t}};function Sc(){return{baseEvent:void 0,name:"",value:void 0}}var Ho={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.name!==""&&t.uint32(18).string(e.name),e.value!==void 0&&N.encode(N.wrap(e.value),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Sc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.name=n.string();continue;case 3:if(s!==26)break;o.value=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Ho.fromPartial(e??{})},fromPartial(e){let t=Sc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.name=e.name??"",t.value=e.value??void 0,t}};function wc(){return{baseEvent:void 0,threadId:"",runId:""}}var $o={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==""&&t.uint32(18).string(e.threadId),e.runId!==""&&t.uint32(26).string(e.runId),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=wc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.threadId=n.string();continue;case 3:if(s!==26)break;o.runId=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return $o.fromPartial(e??{})},fromPartial(e){let t=wc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??"",t.runId=e.runId??"",t}};function kc(){return{baseEvent:void 0,threadId:"",runId:"",result:void 0,outcome:"",interrupts:[]}}var zo={encode(e,t=new D){e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==""&&t.uint32(18).string(e.threadId),e.runId!==""&&t.uint32(26).string(e.runId),e.result!==void 0&&N.encode(N.wrap(e.result),t.uint32(34).fork()).join(),e.outcome!==""&&t.uint32(42).string(e.outcome);for(let n of e.interrupts)Co.encode(n,t.uint32(50).fork()).join();return t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=kc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.threadId=n.string();continue;case 3:if(s!==26)break;o.runId=n.string();continue;case 4:if(s!==34)break;o.result=N.unwrap(N.decode(n,n.uint32()));continue;case 5:if(s!==42)break;o.outcome=n.string();continue;case 6:if(s!==50)break;o.interrupts.push(Co.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return zo.fromPartial(e??{})},fromPartial(e){let t=kc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??"",t.runId=e.runId??"",t.result=e.result??void 0,t.outcome=e.outcome??"",t.interrupts=e.interrupts?.map(n=>Co.fromPartial(n))||[],t}};function Ac(){return{baseEvent:void 0,code:void 0,message:""}}var Bo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.code!==void 0&&t.uint32(18).string(e.code),e.message!==""&&t.uint32(26).string(e.message),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Ac();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.code=n.string();continue;case 3:if(s!==26)break;o.message=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Bo.fromPartial(e??{})},fromPartial(e){let t=Ac();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.code=e.code??void 0,t.message=e.message??"",t}};function Ic(){return{baseEvent:void 0,stepName:""}}var Vo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==""&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Ic();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.stepName=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Vo.fromPartial(e??{})},fromPartial(e){let t=Ic();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??"",t}};function Cc(){return{baseEvent:void 0,stepName:""}}var jo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==""&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Cc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.stepName=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return jo.fromPartial(e??{})},fromPartial(e){let t=Cc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??"",t}};function Nc(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var Wo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==void 0&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.delta!==void 0&&t.uint32(34).string(e.delta),e.name!==void 0&&t.uint32(42).string(e.name),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Nc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.messageId=n.string();continue;case 3:if(s!==26)break;o.role=n.string();continue;case 4:if(s!==34)break;o.delta=n.string();continue;case 5:if(s!==42)break;o.name=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Wo.fromPartial(e??{})},fromPartial(e){let t=Nc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??void 0,t.role=e.role??void 0,t.delta=e.delta??void 0,t.name=e.name??void 0,t}};function Rc(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var Xo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==void 0&&t.uint32(18).string(e.toolCallId),e.toolCallName!==void 0&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),e.delta!==void 0&&t.uint32(42).string(e.delta),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Rc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.toolCallId=n.string();continue;case 3:if(s!==26)break;o.toolCallName=n.string();continue;case 4:if(s!==34)break;o.parentMessageId=n.string();continue;case 5:if(s!==42)break;o.delta=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Xo.fromPartial(e??{})},fromPartial(e){let t=Rc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??void 0,t.toolCallName=e.toolCallName??void 0,t.parentMessageId=e.parentMessageId??void 0,t.delta=e.delta??void 0,t}};function Oc(){return{textMessageStart:void 0,textMessageContent:void 0,textMessageEnd:void 0,toolCallStart:void 0,toolCallArgs:void 0,toolCallEnd:void 0,stateSnapshot:void 0,stateDelta:void 0,messagesSnapshot:void 0,raw:void 0,custom:void 0,runStarted:void 0,runFinished:void 0,runError:void 0,stepStarted:void 0,stepFinished:void 0,textMessageChunk:void 0,toolCallChunk:void 0}}var Mc={encode(e,t=new D){return e.textMessageStart!==void 0&&No.encode(e.textMessageStart,t.uint32(10).fork()).join(),e.textMessageContent!==void 0&&Ro.encode(e.textMessageContent,t.uint32(18).fork()).join(),e.textMessageEnd!==void 0&&Oo.encode(e.textMessageEnd,t.uint32(26).fork()).join(),e.toolCallStart!==void 0&&Mo.encode(e.toolCallStart,t.uint32(34).fork()).join(),e.toolCallArgs!==void 0&&Lo.encode(e.toolCallArgs,t.uint32(42).fork()).join(),e.toolCallEnd!==void 0&&Po.encode(e.toolCallEnd,t.uint32(50).fork()).join(),e.stateSnapshot!==void 0&&Do.encode(e.stateSnapshot,t.uint32(58).fork()).join(),e.stateDelta!==void 0&&Uo.encode(e.stateDelta,t.uint32(66).fork()).join(),e.messagesSnapshot!==void 0&&Go.encode(e.messagesSnapshot,t.uint32(74).fork()).join(),e.raw!==void 0&&Fo.encode(e.raw,t.uint32(82).fork()).join(),e.custom!==void 0&&Ho.encode(e.custom,t.uint32(90).fork()).join(),e.runStarted!==void 0&&$o.encode(e.runStarted,t.uint32(98).fork()).join(),e.runFinished!==void 0&&zo.encode(e.runFinished,t.uint32(106).fork()).join(),e.runError!==void 0&&Bo.encode(e.runError,t.uint32(114).fork()).join(),e.stepStarted!==void 0&&Vo.encode(e.stepStarted,t.uint32(122).fork()).join(),e.stepFinished!==void 0&&jo.encode(e.stepFinished,t.uint32(130).fork()).join(),e.textMessageChunk!==void 0&&Wo.encode(e.textMessageChunk,t.uint32(138).fork()).join(),e.toolCallChunk!==void 0&&Xo.encode(e.toolCallChunk,t.uint32(146).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Oc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.textMessageStart=No.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.textMessageContent=Ro.decode(n,n.uint32());continue;case 3:if(s!==26)break;o.textMessageEnd=Oo.decode(n,n.uint32());continue;case 4:if(s!==34)break;o.toolCallStart=Mo.decode(n,n.uint32());continue;case 5:if(s!==42)break;o.toolCallArgs=Lo.decode(n,n.uint32());continue;case 6:if(s!==50)break;o.toolCallEnd=Po.decode(n,n.uint32());continue;case 7:if(s!==58)break;o.stateSnapshot=Do.decode(n,n.uint32());continue;case 8:if(s!==66)break;o.stateDelta=Uo.decode(n,n.uint32());continue;case 9:if(s!==74)break;o.messagesSnapshot=Go.decode(n,n.uint32());continue;case 10:if(s!==82)break;o.raw=Fo.decode(n,n.uint32());continue;case 11:if(s!==90)break;o.custom=Ho.decode(n,n.uint32());continue;case 12:if(s!==98)break;o.runStarted=$o.decode(n,n.uint32());continue;case 13:if(s!==106)break;o.runFinished=zo.decode(n,n.uint32());continue;case 14:if(s!==114)break;o.runError=Bo.decode(n,n.uint32());continue;case 15:if(s!==122)break;o.stepStarted=Vo.decode(n,n.uint32());continue;case 16:if(s!==130)break;o.stepFinished=jo.decode(n,n.uint32());continue;case 17:if(s!==138)break;o.textMessageChunk=Wo.decode(n,n.uint32());continue;case 18:if(s!==146)break;o.toolCallChunk=Xo.decode(n,n.uint32());continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Mc.fromPartial(e??{})},fromPartial(e){let t=Oc();return t.textMessageStart=e.textMessageStart!==void 0&&e.textMessageStart!==null?No.fromPartial(e.textMessageStart):void 0,t.textMessageContent=e.textMessageContent!==void 0&&e.textMessageContent!==null?Ro.fromPartial(e.textMessageContent):void 0,t.textMessageEnd=e.textMessageEnd!==void 0&&e.textMessageEnd!==null?Oo.fromPartial(e.textMessageEnd):void 0,t.toolCallStart=e.toolCallStart!==void 0&&e.toolCallStart!==null?Mo.fromPartial(e.toolCallStart):void 0,t.toolCallArgs=e.toolCallArgs!==void 0&&e.toolCallArgs!==null?Lo.fromPartial(e.toolCallArgs):void 0,t.toolCallEnd=e.toolCallEnd!==void 0&&e.toolCallEnd!==null?Po.fromPartial(e.toolCallEnd):void 0,t.stateSnapshot=e.stateSnapshot!==void 0&&e.stateSnapshot!==null?Do.fromPartial(e.stateSnapshot):void 0,t.stateDelta=e.stateDelta!==void 0&&e.stateDelta!==null?Uo.fromPartial(e.stateDelta):void 0,t.messagesSnapshot=e.messagesSnapshot!==void 0&&e.messagesSnapshot!==null?Go.fromPartial(e.messagesSnapshot):void 0,t.raw=e.raw!==void 0&&e.raw!==null?Fo.fromPartial(e.raw):void 0,t.custom=e.custom!==void 0&&e.custom!==null?Ho.fromPartial(e.custom):void 0,t.runStarted=e.runStarted!==void 0&&e.runStarted!==null?$o.fromPartial(e.runStarted):void 0,t.runFinished=e.runFinished!==void 0&&e.runFinished!==null?zo.fromPartial(e.runFinished):void 0,t.runError=e.runError!==void 0&&e.runError!==null?Bo.fromPartial(e.runError):void 0,t.stepStarted=e.stepStarted!==void 0&&e.stepStarted!==null?Vo.fromPartial(e.stepStarted):void 0,t.stepFinished=e.stepFinished!==void 0&&e.stepFinished!==null?jo.fromPartial(e.stepFinished):void 0,t.textMessageChunk=e.textMessageChunk!==void 0&&e.textMessageChunk!==null?Wo.fromPartial(e.textMessageChunk):void 0,t.toolCallChunk=e.toolCallChunk!==void 0&&e.toolCallChunk!==null?Xo.fromPartial(e.toolCallChunk):void 0,t}};function Jh(e){let t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}var go=e=>{if(!(!e||typeof e!="object")){if(e.data)return{type:"data",value:e.data.value,mimeType:e.data.mimeType};if(e.url)return{type:"url",value:e.url.value,mimeType:e.url.mimeType}}},Qh=e=>{if(!(!e||typeof e!="object")){if(e.text)return{type:"text",text:e.text.text};if(e.image)return{type:"image",source:go(e.image.source),metadata:e.image.metadata};if(e.audio)return{type:"audio",source:go(e.audio.source),metadata:e.audio.metadata};if(e.video)return{type:"video",source:go(e.video.source),metadata:e.video.metadata};if(e.document)return{type:"document",source:go(e.document.source),metadata:e.document.metadata}}};function Lc(e){let t=Mc.decode(e),n=Object.values(t).find(r=>r!==void 0);if(!n)throw new Error("Invalid event");if(n.type=qh[n.baseEvent.type],n.timestamp=n.baseEvent.timestamp,n.rawEvent=n.baseEvent.rawEvent,delete n.baseEvent,n.type===v.MESSAGES_SNAPSHOT)for(let r of n.messages){let o=r;if(o.role==="user"&&Array.isArray(o.contentParts)){let s=o.contentParts.map(i=>Qh(i)).filter(i=>i!==void 0);s.length>0&&(o.content=s)}Array.isArray(o.contentParts)&&o.contentParts.length===0&&(o.contentParts=void 0),o.toolCalls?.length===0&&(o.toolCalls=void 0)}if(n.type===v.RUN_FINISHED){let r=n,o=typeof r.outcome=="string"&&r.outcome!==""?r.outcome:void 0,s=Array.isArray(r.interrupts)?r.interrupts:[];delete r.interrupts,o==="interrupt"?r.outcome={type:"interrupt",interrupts:s}:o==="success"?r.outcome={type:"success"}:delete r.outcome}if(n.type===v.STATE_DELTA)for(let r of n.delta)r.op=Yh[r.op].toLowerCase(),Object.keys(r).forEach(o=>{r[o]===void 0&&delete r[o]});return Object.keys(n).forEach(r=>{n[r]===void 0&&delete n[r]}),Or.parse(n)}var ki="application/vnd.ag-ui.event+proto";var tm=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Ai=e=>{if(typeof e!="string")throw new TypeError("Invalid argument expected string");let t=e.match(tm);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},Pc=e=>e==="*"||e==="x"||e==="X",Dc=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},nm=(e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t],rm=(e,t)=>{if(Pc(e)||Pc(t))return 0;let[n,r]=nm(Dc(e),Dc(t));return n>r?1:n<r?-1:0},Ii=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){let r=rm(e[n]||"0",t[n]||"0");if(r!==0)return r}return 0};var qn=(e,t)=>{let n=Ai(e),r=Ai(t),o=n.pop(),s=r.pop(),i=Ii(n,r);return i!==0?i:o&&s?Ii(o.split("."),s.split(".")):o||s?o?-1:1:0};var B=e=>{if(typeof structuredClone=="function")return structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch{return Array.isArray(e)?[...e]:{...e}}};function ze(){return ft()}function Ri(e){if(Object.freeze(e),typeof e=="object"&&e)for(let t of Object.values(e))typeof t=="object"&&t&&!Object.isFrozen(t)&&Ri(t);return e}async function X(e,t,n,r){let o=typeof process<"u"&&process.env!==void 0,s=o&&!!process.env.VITEST_WORKER_ID,i=o&&!!process.env.VITEST_WORKER_ID,a=B(t),u=B(n),c=a,p=u,m;for(let x of e)try{i&&(Ri(c),Ri(p));let f=await r(x,c,p);if(f===void 0)continue;if(f.messages!==void 0&&f.messages!==c&&(c=B(f.messages)),f.state!==void 0&&f.state!==p&&(p=B(f.state)),m=f.stopPropagation,m===!0)break}catch(f){if(i&&f instanceof TypeError){if(s)throw f;console.error("AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.",f)}else s||console.error("Subscriber error:",f);continue}return{...c===a?{}:{messages:i&&Object.isFrozen(c)?B(c):c},...p===u?{}:{state:i&&Object.isFrozen(p)?B(p):p},...m===void 0?{}:{stopPropagation:m}}}function Zo(e){if(!e)return{enabled:!1,events:!1,lifecycle:!1,verbose:!1};if(e===!0)return{enabled:!0,events:!0,lifecycle:!0,verbose:!0};let t=e.events??!0,n=e.lifecycle??!0,r=e.verbose??!1;return{enabled:t||n,events:t,lifecycle:n,verbose:r}}function Jn(e){if(e instanceof Oi)return e;if(e===!0)return new Oi(Zo(!0))}var Oi=class{constructor(e){this.config=e}event(e,t,n,r){this.config.events&&(this.config.verbose?console.debug(`[${e}] ${t}`,typeof n=="string"?n:JSON.stringify(n)):console.debug(`[${e}] ${t}`,r??n))}lifecycle(e,t,n){this.config.lifecycle&&(n?console.debug(`[${e}] ${t}`,n):console.debug(`[${e}] ${t}`))}get eventsEnabled(){return this.config.events}get lifecycleEnabled(){return this.config.lifecycle}get enabled(){return this.config.enabled}};function Ci(e){return e.enabled?new Oi(e):void 0}function om(e,t,n){if(t){let o=e.find(i=>i.id===t);if(o?.role==="assistant")return o;o&&console.warn(`TOOL_CALL_START: parentMessageId '${t}' matches a '${o.role}' message, not assistant \u2014 falling back to toolCallId`);let s={id:o?n:t,role:"assistant",toolCalls:[]};return e.push(s),s}let r={id:n,role:"assistant",toolCalls:[]};return e.push(r),r}var zc=(e,t,n,r,o)=>{let s=Jn(o),i=B(n.messages),a=B(e.state),u={},c=m=>{m.messages!==void 0&&(i=m.messages,u.messages=m.messages),m.state!==void 0&&(a=m.state,u.state=m.state)},p=()=>{let m=B(u);return u={},m.messages!==void 0||m.state!==void 0?te(m):Kr};return t.pipe(uo(async m=>{let x=await X(r,i,a,(f,h,g)=>f.onEvent?.({event:m,agent:n,input:e,messages:h,state:g}));if(c(x),x.stopPropagation===!0?s?.event("APPLY","Event dropped:",m,{type:m.type,reason:"stopPropagation by subscriber"}):s?.event("APPLY","Event applied:",m,{type:m.type,subscribers:r.length}),x.stopPropagation===!0)return p();switch(m.type){case v.TEXT_MESSAGE_START:{let f=await X(r,i,a,(h,g,_)=>h.onTextMessageStartEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{messageId:h,role:g="assistant",name:_}=m;if(!i.find(S=>S.id===h)){let S={id:h,role:g,content:"",..._!==void 0&&{name:_}};i.push(S),c({messages:i})}}return p()}case v.TEXT_MESSAGE_CONTENT:{let{messageId:f,delta:h}=m,g=i.find(S=>S.id===f);if(!g)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${f}'`),p();let _=await X(r,i,a,(S,b,F)=>S.onTextMessageContentEvent?.({event:m,messages:b,state:F,agent:n,input:e,textMessageBuffer:typeof g.content=="string"?g.content:""}));return c(_),_.stopPropagation!==!0&&(g.content=`${typeof g.content=="string"?g.content:""}${h}`,c({messages:i})),p()}case v.TEXT_MESSAGE_END:{let{messageId:f}=m,h=i.find(g=>g.id===f);return h?(c(await X(r,i,a,(g,_,S)=>g.onTextMessageEndEvent?.({event:m,messages:_,state:S,agent:n,input:e,textMessageBuffer:typeof h.content=="string"?h.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:h,messages:i,state:a,agent:n,input:e})})),p()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${f}'`),p())}case v.TOOL_CALL_START:{let f=await X(r,i,a,(h,g,_)=>h.onToolCallStartEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{toolCallId:h,toolCallName:g,parentMessageId:_}=m,S=om(i,_,h);S.toolCalls??=[],S.toolCalls.push({id:h,type:"function",function:{name:g,arguments:""}}),c({messages:i})}return p()}case v.TOOL_CALL_ARGS:{let{toolCallId:f,delta:h}=m,g=i.find(b=>b.toolCalls?.some(F=>F.id===f));if(!g)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${f}'`),p();let _=g.toolCalls?.find(b=>b.id===f);if(!_)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${f}'`),p();let S=await X(r,i,a,(b,F,Z)=>{let ae=_.function.arguments,ee=_.function.name,ct={};try{ct=fo(ae)}catch{}return b.onToolCallArgsEvent?.({event:m,messages:F,state:Z,agent:n,input:e,toolCallBuffer:ae,toolCallName:ee,partialToolCallArgs:ct})});return c(S),S.stopPropagation!==!0&&(_.function.arguments+=h,c({messages:i})),p()}case v.TOOL_CALL_END:{let{toolCallId:f}=m,h=i.find(_=>_.toolCalls?.some(S=>S.id===f));if(!h)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${f}'`),p();let g=h.toolCalls?.find(_=>_.id===f);return g?(c(await X(r,i,a,(_,S,b)=>{let F=g.function.arguments,Z=g.function.name,ae={};try{ae=JSON.parse(F)}catch{}return _.onToolCallEndEvent?.({event:m,messages:S,state:b,agent:n,input:e,toolCallName:Z,toolCallArgs:ae})})),await Promise.all(r.map(_=>{_.onNewToolCall?.({toolCall:g,messages:i,state:a,agent:n,input:e})})),p()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${f}'`),p())}case v.TOOL_CALL_RESULT:{let f=await X(r,i,a,(h,g,_)=>h.onToolCallResultEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{messageId:h,toolCallId:g,content:_,role:S}=m,b={id:h,toolCallId:g,role:S||"tool",content:_};i.push(b),await Promise.all(r.map(F=>{F.onNewMessage?.({message:b,messages:i,state:a,agent:n,input:e})})),c({messages:i})}return p()}case v.STATE_SNAPSHOT:{let f=await X(r,i,a,(h,g,_)=>h.onStateSnapshotEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{snapshot:h}=m;a=h,c({state:a})}return p()}case v.STATE_DELTA:{let f=await X(r,i,a,(h,g,_)=>h.onStateDeltaEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{delta:h}=m;try{a=Hr.applyPatch(a,h,!0,!1).newDocument,c({state:a})}catch(g){let _=g instanceof Error?g.message:String(g);console.warn(`Failed to apply state patch:
700
+ `):"",this.name="UnsubscriptionError",this.errors=n}});function Wn(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var xn=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,r,o,s;if(!this.closed){this.closed=!0;var i=this._parentage;if(i)if(this._parentage=null,Array.isArray(i))try{for(var a=ct(i),u=a.next();!u.done;u=a.next()){var c=u.value;c.remove(this)}}catch(g){t={error:g}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else i.remove(this);var p=this.initialTeardown;if(G(p))try{p()}catch(g){s=g instanceof Br?g.errors:[g]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var x=ct(m),f=x.next();!f.done;f=x.next()){var h=f.value;try{wl(h)}catch(g){s=s??[],g instanceof Br?s=yn(yn([],vn(s)),vn(g.errors)):s.push(g)}}}catch(g){r={error:g}}finally{try{f&&!f.done&&(o=x.return)&&o.call(x)}finally{if(r)throw r.error}}}if(s)throw new Br(s)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)wl(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&Wn(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&Wn(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})();var ii=xn.EMPTY;function Vr(e){return e instanceof xn||e&&"closed"in e&&G(e.remove)&&G(e.add)&&G(e.unsubscribe)}function wl(e){G(e)?e():e.unsubscribe()}var He={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var En={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=En.delegate;return o?.setTimeout?o.setTimeout.apply(o,yn([e,t],vn(n))):setTimeout.apply(void 0,yn([e,t],vn(n)))},clearTimeout:function(e){var t=En.delegate;return(t?.clearTimeout||clearTimeout)(e)},delegate:void 0};function jr(e){En.setTimeout(function(){var t=He.onUnhandledError;if(t)t(e);else throw e})}function Xn(){}var kl=(function(){return ai("C",void 0,void 0)})();function Al(e){return ai("E",void 0,e)}function Il(e){return ai("N",e,void 0)}function ai(e,t,n){return{kind:e,value:t,error:n}}var Bt=null;function _n(e){if(He.useDeprecatedSynchronousErrorHandling){var t=!Bt;if(t&&(Bt={errorThrown:!1,error:null}),e(),t){var n=Bt,r=n.errorThrown,o=n.error;if(Bt=null,r)throw o}}else e()}function Cl(e){He.useDeprecatedSynchronousErrorHandling&&Bt&&(Bt.errorThrown=!0,Bt.error=e)}var Zn=(function(e){nt(t,e);function t(n){var r=e.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Vr(n)&&n.add(r)):r.destination=Ch,r}return t.create=function(n,r,o){return new Xr(n,r,o)},t.prototype.next=function(n){this.isStopped?ci(Il(n),this):this._next(n)},t.prototype.error=function(n){this.isStopped?ci(Al(n),this):(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped?ci(kl,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(xn);var kh=Function.prototype.bind;function li(e,t){return kh.call(e,t)}var Ah=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(r){Wr(r)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(r){Wr(r)}else Wr(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Wr(n)}},e})(),Xr=(function(e){nt(t,e);function t(n,r,o){var s=e.call(this)||this,i;if(G(n)||!n)i={next:n??void 0,error:r??void 0,complete:o??void 0};else{var a;s&&He.useDeprecatedNextContext?(a=Object.create(n),a.unsubscribe=function(){return s.unsubscribe()},i={next:n.next&&li(n.next,a),error:n.error&&li(n.error,a),complete:n.complete&&li(n.complete,a)}):i=n}return s.destination=new Ah(i),s}return t})(Zn);function Wr(e){He.useDeprecatedSynchronousErrorHandling?Cl(e):jr(e)}function Ih(e){throw e}function ci(e,t){var n=He.onStoppedNotification;n&&En.setTimeout(function(){return n(e,t)})}var Ch={closed:!0,next:Xn,error:Ih,complete:Xn};var Tn=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Sn(e){return e}function Zr(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ui(e)}function ui(e){return e.length===0?Sn:e.length===1?e[0]:function(n){return e.reduce(function(r,o){return o(r)},n)}}var J=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,r){var o=this,s=Rh(t)?t:new Xr(t,n,r);return _n(function(){var i=o,a=i.operator,u=i.source;s.add(a?a.call(s,u):u?o._subscribe(s):o._trySubscribe(s))}),s},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var r=this;return n=Nl(n),new n(function(o,s){var i=new Xr({next:function(a){try{t(a)}catch(u){s(u),i.unsubscribe()}},error:s,complete:o});r.subscribe(i)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Tn]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return ui(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=Nl(t),new t(function(r,o){var s;n.subscribe(function(i){return s=i},function(i){return o(i)},function(){return r(s)})})},e.create=function(t){return new e(t)},e})();function Nl(e){var t;return(t=e??He.Promise)!==null&&t!==void 0?t:Promise}function Nh(e){return e&&G(e.next)&&G(e.error)&&G(e.complete)}function Rh(e){return e&&e instanceof Zn||Nh(e)&&Vr(e)}function Oh(e){return G(e?.lift)}function ue(e){return function(t){if(Oh(t))return t.lift(function(n){try{return e(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function he(e,t,n,r,o){return new Mh(e,t,n,r,o)}var Mh=(function(e){nt(t,e);function t(n,r,o,s,i,a){var u=e.call(this,n)||this;return u.onFinalize=i,u.shouldUnsubscribe=a,u._next=r?function(c){try{r(c)}catch(p){n.error(p)}}:e.prototype._next,u._error=s?function(c){try{s(c)}catch(p){n.error(p)}finally{this.unsubscribe()}}:e.prototype._error,u._complete=o?function(){try{o()}catch(c){n.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t})(Zn);var Rl=bn(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var rt=(function(e){nt(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var r=new Ol(this,this);return r.operator=n,r},t.prototype._throwIfClosed=function(){if(this.closed)throw new Rl},t.prototype.next=function(n){var r=this;_n(function(){var o,s;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var i=ct(r.currentObservers),a=i.next();!a.done;a=i.next()){var u=a.value;u.next(n)}}catch(c){o={error:c}}finally{try{a&&!a.done&&(s=i.return)&&s.call(i)}finally{if(o)throw o.error}}}})},t.prototype.error=function(n){var r=this;_n(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var o=r.observers;o.length;)o.shift().error(n)}})},t.prototype.complete=function(){var n=this;_n(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var r=this,o=this,s=o.hasError,i=o.isStopped,a=o.observers;return s||i?ii:(this.currentObservers=null,a.push(n),new xn(function(){r.currentObservers=null,Wn(a,n)}))},t.prototype._checkFinalizedStatuses=function(n){var r=this,o=r.hasError,s=r.thrownError,i=r.isStopped;o?n.error(s):i&&n.complete()},t.prototype.asObservable=function(){var n=new J;return n.source=this,n},t.create=function(n,r){return new Ol(n,r)},t})(J);var Ol=(function(e){nt(t,e);function t(n,r){var o=e.call(this)||this;return o.destination=n,o.source=r,o}return t.prototype.next=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.next)===null||o===void 0||o.call(r,n)},t.prototype.error=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.error)===null||o===void 0||o.call(r,n)},t.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},t.prototype._subscribe=function(n){var r,o;return(o=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&o!==void 0?o:ii},t})(rt);var di={now:function(){return(di.delegate||Date).now()},delegate:void 0};var Kr=(function(e){nt(t,e);function t(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=di);var s=e.call(this)||this;return s._bufferSize=n,s._windowTime=r,s._timestampProvider=o,s._buffer=[],s._infiniteTimeWindow=!0,s._infiniteTimeWindow=r===1/0,s._bufferSize=Math.max(1,n),s._windowTime=Math.max(1,r),s}return t.prototype.next=function(n){var r=this,o=r.isStopped,s=r._buffer,i=r._infiniteTimeWindow,a=r._timestampProvider,u=r._windowTime;o||(s.push(n),!i&&s.push(a.now()+u)),this._trimBuffer(),e.prototype.next.call(this,n)},t.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),o=this,s=o._infiniteTimeWindow,i=o._buffer,a=i.slice(),u=0;u<a.length&&!n.closed;u+=s?1:2)n.next(a[u]);return this._checkFinalizedStatuses(n),r},t.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,o=n._timestampProvider,s=n._buffer,i=n._infiniteTimeWindow,a=(i?1:2)*r;if(r<1/0&&a<s.length&&s.splice(0,s.length-a),!i){for(var u=o.now(),c=0,p=1;p<s.length&&s[p]<=u;p+=2)c=p;c&&s.splice(0,c+1)}},t})(rt);var Yr=new J(function(e){return e.complete()});function Ml(e){return e&&G(e.schedule)}function Lh(e){return e[e.length-1]}function Ll(e){return Ml(Lh(e))?e.pop():void 0}var qr=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function Jr(e){return G(e?.then)}function Qr(e){return G(e[Tn])}function eo(e){return Symbol.asyncIterator&&G(e?.[Symbol.asyncIterator])}function to(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Ph(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var no=Ph();function ro(e){return G(e?.[no])}function oo(e){return Tl(this,arguments,function(){var n,r,o,s;return zr(this,function(i){switch(i.label){case 0:n=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,zt(n.read())];case 3:return r=i.sent(),o=r.value,s=r.done,s?[4,zt(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return[4,zt(o)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function so(e){return G(e?.getReader)}function me(e){if(e instanceof J)return e;if(e!=null){if(Qr(e))return Dh(e);if(qr(e))return Uh(e);if(Jr(e))return Gh(e);if(eo(e))return Pl(e);if(ro(e))return Fh(e);if(so(e))return Hh(e)}throw to(e)}function Dh(e){return new J(function(t){var n=e[Tn]();if(G(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Uh(e){return new J(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function Gh(e){return new J(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,jr)})}function Fh(e){return new J(function(t){var n,r;try{for(var o=ct(e),s=o.next();!s.done;s=o.next()){var i=s.value;if(t.next(i),t.closed)return}}catch(a){n={error:a}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}t.complete()})}function Pl(e){return new J(function(t){$h(e,t).catch(function(n){return t.error(n)})})}function Hh(e){return Pl(oo(e))}function $h(e,t){var n,r,o,s;return _l(this,void 0,void 0,function(){var i,a;return zr(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),n=Sl(e),u.label=1;case 1:return[4,n.next()];case 2:if(r=u.sent(),!!r.done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=u.sent(),o={error:a},[3,11];case 6:return u.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function Le(e,t,n,r,o){r===void 0&&(r=0),o===void 0&&(o=!1);var s=t.schedule(function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(s),!o)return s}function io(e,t){return t===void 0&&(t=0),ue(function(n,r){n.subscribe(he(r,function(o){return Le(r,e,function(){return r.next(o)},t)},function(){return Le(r,e,function(){return r.complete()},t)},function(o){return Le(r,e,function(){return r.error(o)},t)}))})}function ao(e,t){return t===void 0&&(t=0),ue(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function Dl(e,t){return me(e).pipe(ao(t),io(t))}function Ul(e,t){return me(e).pipe(ao(t),io(t))}function Gl(e,t){return new J(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function Fl(e,t){return new J(function(n){var r;return Le(n,t,function(){r=e[no](),Le(n,t,function(){var o,s,i;try{o=r.next(),s=o.value,i=o.done}catch(a){n.error(a);return}i?n.complete():n.next(s)},0,!0)}),function(){return G(r?.return)&&r.return()}})}function lo(e,t){if(!e)throw new Error("Iterable cannot be null");return new J(function(n){Le(n,t,function(){var r=e[Symbol.asyncIterator]();Le(n,t,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function Hl(e,t){return lo(oo(e),t)}function $l(e,t){if(e!=null){if(Qr(e))return Dl(e,t);if(qr(e))return Gl(e,t);if(Jr(e))return Ul(e,t);if(eo(e))return lo(e,t);if(ro(e))return Fl(e,t);if(so(e))return Hl(e,t)}throw to(e)}function Vt(e,t){return t?$l(e,t):me(e)}function te(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Ll(e);return Vt(e,n)}function Q(e,t){var n=G(e)?e:function(){return e},r=function(o){return o.error(n())};return new J(t?function(o){return t.schedule(r,0,o)}:r)}var zl=bn(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function co(e,t){var n=typeof t=="object";return new Promise(function(r,o){var s=!1,i;e.subscribe({next:function(a){i=a,s=!0},error:o,complete:function(){s?r(i):n?r(t.defaultValue):o(new zl)}})})}function jt(e,t){return ue(function(n,r){var o=0;n.subscribe(he(r,function(s){r.next(e.call(t,s,o++))}))})}function Bl(e,t,n,r,o,s,i,a){var u=[],c=0,p=0,m=!1,x=function(){m&&!u.length&&!c&&t.complete()},f=function(g){return c<r?h(g):u.push(g)},h=function(g){s&&t.next(g),c++;var _=!1;me(n(g,p++)).subscribe(he(t,function(S){o?.(S),s?f(S):t.next(S)},function(){_=!0},void 0,function(){if(_)try{c--;for(var S=function(){var b=u.shift();i?Le(t,i,function(){return h(b)}):h(b)};u.length&&c<r;)S();x()}catch(b){t.error(b)}}))};return e.subscribe(he(t,f,function(){m=!0,x()})),function(){a?.()}}function Ae(e,t,n){return n===void 0&&(n=1/0),G(t)?Ae(function(r,o){return jt(function(s,i){return t(r,s,o,i)})(me(e(r,o)))},n):(typeof t=="number"&&(n=t),ue(function(r,o){return Bl(r,o,e,n)}))}function pi(e){return e===void 0&&(e=1/0),Ae(Sn,e)}function uo(e){return new J(function(t){me(e()).subscribe(t)})}function Kn(e){return ue(function(t,n){var r=null,o=!1,s;r=t.subscribe(he(n,void 0,void 0,function(i){s=me(e(i,Kn(e)(t))),r?(r.unsubscribe(),r=null,s.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,s.subscribe(n))})}function po(e,t){return G(t)?Ae(e,t,1):Ae(e,1)}function fi(e){return ue(function(t,n){var r=!1;t.subscribe(he(n,function(o){r=!0,n.next(o)},function(){r||n.next(e),n.complete()}))})}function Wt(e){return ue(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}function hi(e,t){return ue(function(n,r){var o=null,s=0,i=!1,a=function(){return i&&!o&&r.complete()};n.subscribe(he(r,function(u){o?.unsubscribe();var c=0,p=s++;me(e(u,p)).subscribe(o=he(r,function(m){return r.next(t?t(u,m,p,c++):m)},function(){o=null,a()}))},function(){i=!0,a()}))})}function fo(e){return ue(function(t,n){me(e).subscribe(he(n,function(){return n.complete()},Xn)),!n.closed&&t.subscribe(n)})}function mi(e,t,n){var r=G(e)||t||n?{next:e,error:t,complete:n}:e;return r?ue(function(o,s){var i;(i=r.subscribe)===null||i===void 0||i.call(r);var a=!0;o.subscribe(he(s,function(u){var c;(c=r.next)===null||c===void 0||c.call(r,u),s.next(u)},function(){var u;a=!1,(u=r.complete)===null||u===void 0||u.call(r),s.complete()},function(u){var c;a=!1,(c=r.error)===null||c===void 0||c.call(r,u),s.error(u)},function(){var u,c;a&&((u=r.unsubscribe)===null||u===void 0||u.call(r)),(c=r.finalize)===null||c===void 0||c.call(r)}))}):Sn}function Vl(e){return` \r
701
+ `.indexOf(e)>=0}function ho(e){for(var t=["topLevel"],n=0,r,o,s,i=function(b){return t.push(b)},a=function(b){return t[t.length-1]=b},u=function(b){r==null&&(r=n,o=t.length,s=b)},c=function(b){b===s&&(r=void 0,o=void 0,s=void 0)},p=function(){return t.pop()},m=function(){return n--},x=function(b){if("0"<=b&&b<="9"){i("number");return}switch(b){case'"':i("string");return;case"-":i("numberNeedsDigit");return;case"t":i("true");return;case"f":i("false");return;case"n":i("null");return;case"[":i("arrayNeedsValue");return;case"{":i("objectNeedsKey");return}},f=e.length;n<f;n++){var h=e[n];switch(t[t.length-1]){case"topLevel":x(h);break;case"string":switch(h){case'"':p();break;case"\\":u("stringEscape"),i("stringEscaped");break}break;case"stringEscaped":h==="u"?i("stringUnicode"):(c("stringEscape"),p());break;case"stringUnicode":n-e.lastIndexOf("u",n)===4&&(c("stringEscape"),p());break;case"number":h==="."?a("numberNeedsDigit"):h==="e"||h==="E"?a("numberNeedsExponent"):(h<"0"||h>"9")&&(m(),p());break;case"numberNeedsDigit":a("number");break;case"numberNeedsExponent":a(h==="+"||h==="-"?"numberNeedsDigit":"number");break;case"true":case"false":case"null":(h<"a"||h>"z")&&(m(),p());break;case"arrayNeedsValue":h==="]"?p():Vl(h)||(c("collectionItem"),a("arrayNeedsComma"),x(h));break;case"arrayNeedsComma":h==="]"?p():h===","&&(u("collectionItem"),a("arrayNeedsValue"));break;case"objectNeedsKey":h==="}"?p():h==='"'&&(u("collectionItem"),a("objectNeedsColon"),i("string"));break;case"objectNeedsColon":h===":"&&a("objectNeedsValue");break;case"objectNeedsValue":Vl(h)||(c("collectionItem"),a("objectNeedsComma"),x(h));break;case"objectNeedsComma":h==="}"?p():h===","&&(u("collectionItem"),a("objectNeedsKey"));break}}o!=null&&(t.length=o);for(var g=[r!=null?e.slice(0,r):e],_=function(b){return g.push(b.slice(e.length-e.lastIndexOf(b[0])))},S=t.length-1;S>=0;S--)switch(t[S]){case"string":g.push('"');break;case"numberNeedsDigit":case"numberNeedsExponent":g.push("0");break;case"true":_("true");break;case"false":_("false");break;case"null":_("null");break;case"arrayNeedsValue":case"arrayNeedsComma":g.push("]");break;case"objectNeedsKey":case"objectNeedsColon":case"objectNeedsValue":case"objectNeedsComma":g.push("}");break}return g.join("")}function Wl(){let e=0,t=0;for(let r=0;r<28;r+=7){let o=this.buf[this.pos++];if(e|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(n&15)<<28,t=(n&112)>>4,(n&128)==0)return this.assertBounds(),[e,t];for(let r=3;r<=31;r+=7){let o=this.buf[this.pos++];if(t|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function go(e,t,n){for(let s=0;s<28;s=s+7){let i=e>>>s,a=!(!(i>>>7)&&t==0),u=(a?i|128:i)&255;if(n.push(u),!a)return}let r=e>>>28&15|(t&7)<<4,o=t>>3!=0;if(n.push((o?r|128:r)&255),!!o){for(let s=3;s<31;s=s+7){let i=t>>>s,a=!!(i>>>7),u=(a?i|128:i)&255;if(n.push(u),!a)return}n.push(t>>>31&1)}}var mo=4294967296;function gi(e){let t=e[0]==="-";t&&(e=e.slice(1));let n=1e6,r=0,o=0;function s(i,a){let u=Number(e.slice(i,a));o*=n,r=r*n+u,r>=mo&&(o=o+(r/mo|0),r=r%mo)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),t?Zl(r,o):yi(r,o)}function Xl(e,t){let n=yi(e,t),r=n.hi&2147483648;r&&(n=Zl(n.lo,n.hi));let o=vi(n.lo,n.hi);return r?"-"+o:o}function vi(e,t){if({lo:e,hi:t}=zh(e,t),t<=2097151)return String(mo*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,o=t>>16&65535,s=n+r*6777216+o*6710656,i=r+o*8147497,a=o*2,u=1e7;return s>=u&&(i+=Math.floor(s/u),s%=u),i>=u&&(a+=Math.floor(i/u),i%=u),a.toString()+jl(i)+jl(s)}function zh(e,t){return{lo:e>>>0,hi:t>>>0}}function yi(e,t){return{lo:e|0,hi:t|0}}function Zl(e,t){return t=~t,e?e=~e+1:t+=1,yi(e,t)}var jl=e=>{let t=String(e);return"0000000".slice(t.length)+t};function bi(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e=e>>>7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e=e>>7;t.push(1)}}function Kl(){let e=this.buf[this.pos++],t=e&127;if((e&128)==0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<7,(e&128)==0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<14,(e&128)==0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<21,(e&128)==0)return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let n=5;(e&128)!==0&&n<10;n++)e=this.buf[this.pos++];if((e&128)!=0)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var $e=Bh();function Bh(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof e.getBigInt64=="function"&&typeof e.getBigUint64=="function"&&typeof e.setBigInt64=="function"&&typeof e.setBigUint64=="function"&&(!!globalThis.Deno||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let n=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),o=BigInt("0"),s=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(i){let a=typeof i=="bigint"?i:BigInt(i);if(a>r||a<n)throw new Error(`invalid int64: ${i}`);return a},uParse(i){let a=typeof i=="bigint"?i:BigInt(i);if(a>s||a<o)throw new Error(`invalid uint64: ${i}`);return a},enc(i){return e.setBigInt64(0,this.parse(i),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(i){return e.setBigInt64(0,this.uParse(i),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(i,a){return e.setInt32(0,i,!0),e.setInt32(4,a,!0),e.getBigInt64(0,!0)},uDec(i,a){return e.setInt32(0,i,!0),e.setInt32(4,a,!0),e.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(n){return typeof n!="string"&&(n=n.toString()),Yl(n),n},uParse(n){return typeof n!="string"&&(n=n.toString()),ql(n),n},enc(n){return typeof n!="string"&&(n=n.toString()),Yl(n),gi(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),ql(n),gi(n)},dec(n,r){return Xl(n,r)},uDec(n,r){return vi(n,r)}}}function Yl(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function ql(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}var xi=Symbol.for("@bufbuild/protobuf/text-encoding");function Ei(){if(globalThis[xi]==null){let e=new globalThis.TextEncoder,t=new globalThis.TextDecoder,n;globalThis[xi]={encodeUtf8(r){return e.encode(r)},decodeUtf8(r,o){return o?(n===void 0&&(n=new globalThis.TextDecoder("utf-8",{fatal:!0})),n.decode(r)):t.decode(r)},checkUtf8(r){try{return encodeURIComponent(r),!0}catch{return!1}}}}return globalThis[xi]}var bt;(function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32"})(bt||(bt={}));var Vh=34028234663852886e22,jh=-34028234663852886e22,Wh=4294967295,Xh=2147483647,Zh=-2147483648,D=class{constructor(t=Ei().encodeUtf8){this.encodeUtf8=t,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let t=0;for(let o=0;o<this.chunks.length;o++)t+=this.chunks[o].length;let n=new Uint8Array(t),r=0;for(let o=0;o<this.chunks.length;o++)n.set(this.chunks[o],r),r+=this.chunks[o].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let t=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(t.byteLength),this.raw(t)}tag(t,n){return this.uint32((t<<3|n)>>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(Jl(t);t>127;)this.buf.push(t&127|128),t=t>>>7;return this.buf.push(t),this}int32(t){return _i(t),bi(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let n=this.encodeUtf8(t);return this.uint32(n.byteLength),this.raw(n)}float(t){Kh(t);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,t,!0),this.raw(n)}double(t){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,t,!0),this.raw(n)}fixed32(t){Jl(t);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,t,!0),this.raw(n)}sfixed32(t){_i(t);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,t,!0),this.raw(n)}sint32(t){return _i(t),t=(t<<1^t>>31)>>>0,bi(t,this.buf),this}sfixed64(t){let n=new Uint8Array(8),r=new DataView(n.buffer),o=$e.enc(t);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}fixed64(t){let n=new Uint8Array(8),r=new DataView(n.buffer),o=$e.uEnc(t);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}int64(t){let n=$e.enc(t);return go(n.lo,n.hi,this.buf),this}sint64(t){let n=$e.enc(t),r=n.hi>>31,o=n.lo<<1^r,s=(n.hi<<1|n.lo>>>31)^r;return go(o,s,this.buf),this}uint64(t){let n=$e.uEnc(t);return go(n.lo,n.hi,this.buf),this}},T=class{constructor(t,n=Ei().decodeUtf8){this.decodeUtf8=n,this.varint64=Wl,this.uint32=Kl,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}tag(){let t=this.pos,n=this.uint32(),r=this.pos-t;if(r>5||r==5&&this.buf[this.pos-1]>15)throw new Error("illegal tag: varint overflows uint32");let o=n>>>3,s=n&7;if(o<=0||s>5)throw new Error("illegal tag: field no "+o+" wire type "+s);return[o,s]}skip(t,n){let r=this.pos;switch(t){case bt.Varint:for(;this.buf[this.pos++]&128;);break;case bt.Bit64:this.pos+=4;case bt.Bit32:this.pos+=4;break;case bt.LengthDelimited:let o=this.uint32();this.pos+=o;break;case bt.StartGroup:for(;;){let[s,i]=this.tag();if(i===bt.EndGroup){if(n!==void 0&&s!==n)throw new Error("invalid end group tag");break}this.skip(i,s)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return $e.dec(...this.varint64())}uint64(){return $e.uDec(...this.varint64())}sint64(){let[t,n]=this.varint64(),r=-(t&1);return t=(t>>>1|(n&1)<<31)^r,n=n>>>1^r,$e.dec(t,n)}bool(){let[t,n]=this.varint64();return t!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return $e.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return $e.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),n=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(n,n+t)}string(t){return this.decodeUtf8(this.bytes(),t)}};function _i(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>Xh||e<Zh)throw new Error("invalid int32: "+e)}function Jl(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>Wh||e<0)throw new Error("invalid uint32: "+e)}function Kh(e){if(typeof e=="string"){let t=e;if(e=Number(e),Number.isNaN(e)&&t!=="NaN")throw new Error("invalid float32: "+t)}else if(typeof e!="number")throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>Vh||e<jh))throw new Error("invalid float32: "+e)}var Yh=(function(e){return e[e.NULL_VALUE=0]="NULL_VALUE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e})({});function Ti(){return{fields:{}}}var Yn={encode(e,t=new D){return Object.entries(e.fields).forEach(([n,r])=>{r!==void 0&&ki.encode({key:n,value:r},t.uint32(10).fork()).join()}),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Ti();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:{if(s!==10)break;let i=ki.decode(n,n.uint32());i.value!==void 0&&(o.fields[i.key]=i.value);continue}}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Yn.fromPartial(e??{})},fromPartial(e){let t=Ti();return t.fields=Object.entries(e.fields??{}).reduce((n,[r,o])=>(o!==void 0&&(n[r]=o),n),{}),t},wrap(e){let t=Ti();if(e!==void 0)for(let n of Object.keys(e))t.fields[n]=e[n];return t},unwrap(e){let t={};if(e.fields)for(let n of Object.keys(e.fields))t[n]=e.fields[n];return t}};function Ql(){return{key:"",value:void 0}}var ki={encode(e,t=new D){return e.key!==""&&t.uint32(10).string(e.key),e.value!==void 0&&N.encode(N.wrap(e.value),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Ql();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.key=n.string();continue;case 2:if(s!==18)break;o.value=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return ki.fromPartial(e??{})},fromPartial(e){let t=Ql();return t.key=e.key??"",t.value=e.value??void 0,t}};function Si(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var N={encode(e,t=new D){return e.nullValue!==void 0&&t.uint32(8).int32(e.nullValue),e.numberValue!==void 0&&t.uint32(17).double(e.numberValue),e.stringValue!==void 0&&t.uint32(26).string(e.stringValue),e.boolValue!==void 0&&t.uint32(32).bool(e.boolValue),e.structValue!==void 0&&Yn.encode(Yn.wrap(e.structValue),t.uint32(42).fork()).join(),e.listValue!==void 0&&qn.encode(qn.wrap(e.listValue),t.uint32(50).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Si();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==8)break;o.nullValue=n.int32();continue;case 2:if(s!==17)break;o.numberValue=n.double();continue;case 3:if(s!==26)break;o.stringValue=n.string();continue;case 4:if(s!==32)break;o.boolValue=n.bool();continue;case 5:if(s!==42)break;o.structValue=Yn.unwrap(Yn.decode(n,n.uint32()));continue;case 6:if(s!==50)break;o.listValue=qn.unwrap(qn.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return N.fromPartial(e??{})},fromPartial(e){let t=Si();return t.nullValue=e.nullValue??void 0,t.numberValue=e.numberValue??void 0,t.stringValue=e.stringValue??void 0,t.boolValue=e.boolValue??void 0,t.structValue=e.structValue??void 0,t.listValue=e.listValue??void 0,t},wrap(e){let t=Si();if(e===null)t.nullValue=Yh.NULL_VALUE;else if(typeof e=="boolean")t.boolValue=e;else if(typeof e=="number")t.numberValue=e;else if(typeof e=="string")t.stringValue=e;else if(globalThis.Array.isArray(e))t.listValue=e;else if(typeof e=="object")t.structValue=e;else if(typeof e<"u")throw new globalThis.Error("Unsupported any value type: "+typeof e);return t},unwrap(e){if(e.stringValue!==void 0)return e.stringValue;if(e?.numberValue!==void 0)return e.numberValue;if(e?.boolValue!==void 0)return e.boolValue;if(e?.structValue!==void 0)return e.structValue;if(e?.listValue!==void 0)return e.listValue;if(e?.nullValue!==void 0)return null}};function wi(){return{values:[]}}var qn={encode(e,t=new D){for(let n of e.values)N.encode(N.wrap(n),t.uint32(10).fork()).join();return t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=wi();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.values.push(N.unwrap(N.decode(n,n.uint32())));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return qn.fromPartial(e??{})},fromPartial(e){let t=wi();return t.values=e.values?.map(n=>n)||[],t},wrap(e){let t=wi();return t.values=e??[],t},unwrap(e){return e?.hasOwnProperty("values")&&globalThis.Array.isArray(e.values)?e.values:e}},qh=(function(e){return e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.REPLACE=2]="REPLACE",e[e.MOVE=3]="MOVE",e[e.COPY=4]="COPY",e[e.TEST=5]="TEST",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e})({});function ec(){return{op:0,path:"",from:void 0,value:void 0}}var yo={encode(e,t=new D){return e.op!==0&&t.uint32(8).int32(e.op),e.path!==""&&t.uint32(18).string(e.path),e.from!==void 0&&t.uint32(26).string(e.from),e.value!==void 0&&N.encode(N.wrap(e.value),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=ec();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==8)break;o.op=n.int32();continue;case 2:if(s!==18)break;o.path=n.string();continue;case 3:if(s!==26)break;o.from=n.string();continue;case 4:if(s!==34)break;o.value=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return yo.fromPartial(e??{})},fromPartial(e){let t=ec();return t.op=e.op??0,t.path=e.path??"",t.from=e.from??void 0,t.value=e.value??void 0,t}};function tc(){return{id:"",type:"",function:void 0}}var bo={encode(e,t=new D){return e.id!==""&&t.uint32(10).string(e.id),e.type!==""&&t.uint32(18).string(e.type),e.function!==void 0&&xo.encode(e.function,t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=tc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.id=n.string();continue;case 2:if(s!==18)break;o.type=n.string();continue;case 3:if(s!==26)break;o.function=xo.decode(n,n.uint32());continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return bo.fromPartial(e??{})},fromPartial(e){let t=tc();return t.id=e.id??"",t.type=e.type??"",t.function=e.function!==void 0&&e.function!==null?xo.fromPartial(e.function):void 0,t}};function nc(){return{name:"",arguments:""}}var xo={encode(e,t=new D){return e.name!==""&&t.uint32(10).string(e.name),e.arguments!==""&&t.uint32(18).string(e.arguments),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=nc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.name=n.string();continue;case 2:if(s!==18)break;o.arguments=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return xo.fromPartial(e??{})},fromPartial(e){let t=nc();return t.name=e.name??"",t.arguments=e.arguments??"",t}};function rc(){return{value:"",mimeType:""}}var Eo={encode(e,t=new D){return e.value!==""&&t.uint32(10).string(e.value),e.mimeType!==""&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=rc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.value=n.string();continue;case 2:if(s!==18)break;o.mimeType=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Eo.fromPartial(e??{})},fromPartial(e){let t=rc();return t.value=e.value??"",t.mimeType=e.mimeType??"",t}};function oc(){return{value:"",mimeType:void 0}}var _o={encode(e,t=new D){return e.value!==""&&t.uint32(10).string(e.value),e.mimeType!==void 0&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=oc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.value=n.string();continue;case 2:if(s!==18)break;o.mimeType=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return _o.fromPartial(e??{})},fromPartial(e){let t=oc();return t.value=e.value??"",t.mimeType=e.mimeType??void 0,t}};function sc(){return{data:void 0,url:void 0}}var Ie={encode(e,t=new D){return e.data!==void 0&&Eo.encode(e.data,t.uint32(10).fork()).join(),e.url!==void 0&&_o.encode(e.url,t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=sc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.data=Eo.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.url=_o.decode(n,n.uint32());continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Ie.fromPartial(e??{})},fromPartial(e){let t=sc();return t.data=e.data!==void 0&&e.data!==null?Eo.fromPartial(e.data):void 0,t.url=e.url!==void 0&&e.url!==null?_o.fromPartial(e.url):void 0,t}};function ic(){return{text:""}}var To={encode(e,t=new D){return e.text!==""&&t.uint32(10).string(e.text),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=ic();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.text=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return To.fromPartial(e??{})},fromPartial(e){let t=ic();return t.text=e.text??"",t}};function ac(){return{source:void 0,metadata:void 0}}var So={encode(e,t=new D){return e.source!==void 0&&Ie.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&N.encode(N.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=ac();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.source=Ie.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.metadata=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return So.fromPartial(e??{})},fromPartial(e){let t=ac();return t.source=e.source!==void 0&&e.source!==null?Ie.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function lc(){return{source:void 0,metadata:void 0}}var wo={encode(e,t=new D){return e.source!==void 0&&Ie.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&N.encode(N.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=lc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.source=Ie.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.metadata=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return wo.fromPartial(e??{})},fromPartial(e){let t=lc();return t.source=e.source!==void 0&&e.source!==null?Ie.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function cc(){return{source:void 0,metadata:void 0}}var ko={encode(e,t=new D){return e.source!==void 0&&Ie.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&N.encode(N.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=cc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.source=Ie.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.metadata=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return ko.fromPartial(e??{})},fromPartial(e){let t=cc();return t.source=e.source!==void 0&&e.source!==null?Ie.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function uc(){return{source:void 0,metadata:void 0}}var Ao={encode(e,t=new D){return e.source!==void 0&&Ie.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&N.encode(N.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=uc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.source=Ie.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.metadata=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Ao.fromPartial(e??{})},fromPartial(e){let t=uc();return t.source=e.source!==void 0&&e.source!==null?Ie.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function dc(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var Io={encode(e,t=new D){return e.text!==void 0&&To.encode(e.text,t.uint32(10).fork()).join(),e.image!==void 0&&So.encode(e.image,t.uint32(18).fork()).join(),e.audio!==void 0&&wo.encode(e.audio,t.uint32(26).fork()).join(),e.video!==void 0&&ko.encode(e.video,t.uint32(34).fork()).join(),e.document!==void 0&&Ao.encode(e.document,t.uint32(42).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=dc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.text=To.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.image=So.decode(n,n.uint32());continue;case 3:if(s!==26)break;o.audio=wo.decode(n,n.uint32());continue;case 4:if(s!==34)break;o.video=ko.decode(n,n.uint32());continue;case 5:if(s!==42)break;o.document=Ao.decode(n,n.uint32());continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Io.fromPartial(e??{})},fromPartial(e){let t=dc();return t.text=e.text!==void 0&&e.text!==null?To.fromPartial(e.text):void 0,t.image=e.image!==void 0&&e.image!==null?So.fromPartial(e.image):void 0,t.audio=e.audio!==void 0&&e.audio!==null?wo.fromPartial(e.audio):void 0,t.video=e.video!==void 0&&e.video!==null?ko.fromPartial(e.video):void 0,t.document=e.document!==void 0&&e.document!==null?Ao.fromPartial(e.document):void 0,t}};function pc(){return{id:"",role:"",content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var Co={encode(e,t=new D){e.id!==""&&t.uint32(10).string(e.id),e.role!==""&&t.uint32(18).string(e.role),e.content!==void 0&&t.uint32(26).string(e.content),e.name!==void 0&&t.uint32(34).string(e.name);for(let n of e.toolCalls)bo.encode(n,t.uint32(42).fork()).join();e.toolCallId!==void 0&&t.uint32(50).string(e.toolCallId),e.error!==void 0&&t.uint32(58).string(e.error);for(let n of e.contentParts)Io.encode(n,t.uint32(66).fork()).join();return t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=pc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.id=n.string();continue;case 2:if(s!==18)break;o.role=n.string();continue;case 3:if(s!==26)break;o.content=n.string();continue;case 4:if(s!==34)break;o.name=n.string();continue;case 5:if(s!==42)break;o.toolCalls.push(bo.decode(n,n.uint32()));continue;case 6:if(s!==50)break;o.toolCallId=n.string();continue;case 7:if(s!==58)break;o.error=n.string();continue;case 8:if(s!==66)break;o.contentParts.push(Io.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Co.fromPartial(e??{})},fromPartial(e){let t=pc();return t.id=e.id??"",t.role=e.role??"",t.content=e.content??void 0,t.name=e.name??void 0,t.toolCalls=e.toolCalls?.map(n=>bo.fromPartial(n))||[],t.toolCallId=e.toolCallId??void 0,t.error=e.error??void 0,t.contentParts=e.contentParts?.map(n=>Io.fromPartial(n))||[],t}};function fc(){return{id:"",reason:"",message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var No={encode(e,t=new D){return e.id!==""&&t.uint32(10).string(e.id),e.reason!==""&&t.uint32(18).string(e.reason),e.message!==void 0&&t.uint32(26).string(e.message),e.toolCallId!==void 0&&t.uint32(34).string(e.toolCallId),e.responseSchema!==void 0&&N.encode(N.wrap(e.responseSchema),t.uint32(42).fork()).join(),e.expiresAt!==void 0&&t.uint32(50).string(e.expiresAt),e.metadata!==void 0&&N.encode(N.wrap(e.metadata),t.uint32(58).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=fc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.id=n.string();continue;case 2:if(s!==18)break;o.reason=n.string();continue;case 3:if(s!==26)break;o.message=n.string();continue;case 4:if(s!==34)break;o.toolCallId=n.string();continue;case 5:if(s!==42)break;o.responseSchema=N.unwrap(N.decode(n,n.uint32()));continue;case 6:if(s!==50)break;o.expiresAt=n.string();continue;case 7:if(s!==58)break;o.metadata=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return No.fromPartial(e??{})},fromPartial(e){let t=fc();return t.id=e.id??"",t.reason=e.reason??"",t.message=e.message??void 0,t.toolCallId=e.toolCallId??void 0,t.responseSchema=e.responseSchema??void 0,t.expiresAt=e.expiresAt??void 0,t.metadata=e.metadata??void 0,t}},Jh=(function(e){return e[e.TEXT_MESSAGE_START=0]="TEXT_MESSAGE_START",e[e.TEXT_MESSAGE_CONTENT=1]="TEXT_MESSAGE_CONTENT",e[e.TEXT_MESSAGE_END=2]="TEXT_MESSAGE_END",e[e.TOOL_CALL_START=3]="TOOL_CALL_START",e[e.TOOL_CALL_ARGS=4]="TOOL_CALL_ARGS",e[e.TOOL_CALL_END=5]="TOOL_CALL_END",e[e.STATE_SNAPSHOT=6]="STATE_SNAPSHOT",e[e.STATE_DELTA=7]="STATE_DELTA",e[e.MESSAGES_SNAPSHOT=8]="MESSAGES_SNAPSHOT",e[e.RAW=9]="RAW",e[e.CUSTOM=10]="CUSTOM",e[e.RUN_STARTED=11]="RUN_STARTED",e[e.RUN_FINISHED=12]="RUN_FINISHED",e[e.RUN_ERROR=13]="RUN_ERROR",e[e.STEP_STARTED=14]="STEP_STARTED",e[e.STEP_FINISHED=15]="STEP_FINISHED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e})({});function hc(){return{type:0,timestamp:void 0,rawEvent:void 0}}var R={encode(e,t=new D){return e.type!==0&&t.uint32(8).int32(e.type),e.timestamp!==void 0&&t.uint32(16).int64(e.timestamp),e.rawEvent!==void 0&&N.encode(N.wrap(e.rawEvent),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=hc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==8)break;o.type=n.int32();continue;case 2:if(s!==16)break;o.timestamp=Qh(n.int64());continue;case 3:if(s!==26)break;o.rawEvent=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return R.fromPartial(e??{})},fromPartial(e){let t=hc();return t.type=e.type??0,t.timestamp=e.timestamp??void 0,t.rawEvent=e.rawEvent??void 0,t}};function mc(){return{baseEvent:void 0,messageId:"",role:void 0,name:void 0}}var Ro={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.name!==void 0&&t.uint32(34).string(e.name),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=mc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.messageId=n.string();continue;case 3:if(s!==26)break;o.role=n.string();continue;case 4:if(s!==34)break;o.name=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Ro.fromPartial(e??{})},fromPartial(e){let t=mc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t.role=e.role??void 0,t.name=e.name??void 0,t}};function gc(){return{baseEvent:void 0,messageId:"",delta:""}}var Oo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),e.delta!==""&&t.uint32(26).string(e.delta),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=gc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.messageId=n.string();continue;case 3:if(s!==26)break;o.delta=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Oo.fromPartial(e??{})},fromPartial(e){let t=gc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t.delta=e.delta??"",t}};function vc(){return{baseEvent:void 0,messageId:""}}var Mo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=vc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.messageId=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Mo.fromPartial(e??{})},fromPartial(e){let t=vc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t}};function yc(){return{baseEvent:void 0,toolCallId:"",toolCallName:"",parentMessageId:void 0}}var Lo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),e.toolCallName!==""&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=yc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.toolCallId=n.string();continue;case 3:if(s!==26)break;o.toolCallName=n.string();continue;case 4:if(s!==34)break;o.parentMessageId=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Lo.fromPartial(e??{})},fromPartial(e){let t=yc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t.toolCallName=e.toolCallName??"",t.parentMessageId=e.parentMessageId??void 0,t}};function bc(){return{baseEvent:void 0,toolCallId:"",delta:""}}var Po={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),e.delta!==""&&t.uint32(26).string(e.delta),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=bc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.toolCallId=n.string();continue;case 3:if(s!==26)break;o.delta=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Po.fromPartial(e??{})},fromPartial(e){let t=bc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t.delta=e.delta??"",t}};function xc(){return{baseEvent:void 0,toolCallId:""}}var Do={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=xc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.toolCallId=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Do.fromPartial(e??{})},fromPartial(e){let t=xc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t}};function Ec(){return{baseEvent:void 0,snapshot:void 0}}var Uo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.snapshot!==void 0&&N.encode(N.wrap(e.snapshot),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Ec();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.snapshot=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Uo.fromPartial(e??{})},fromPartial(e){let t=Ec();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.snapshot=e.snapshot??void 0,t}};function _c(){return{baseEvent:void 0,delta:[]}}var Go={encode(e,t=new D){e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.delta)yo.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=_c();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.delta.push(yo.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Go.fromPartial(e??{})},fromPartial(e){let t=_c();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.delta=e.delta?.map(n=>yo.fromPartial(n))||[],t}};function Tc(){return{baseEvent:void 0,messages:[]}}var Fo={encode(e,t=new D){e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.messages)Co.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Tc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.messages.push(Co.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Fo.fromPartial(e??{})},fromPartial(e){let t=Tc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.messages=e.messages?.map(n=>Co.fromPartial(n))||[],t}};function Sc(){return{baseEvent:void 0,event:void 0,source:void 0}}var Ho={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.event!==void 0&&N.encode(N.wrap(e.event),t.uint32(18).fork()).join(),e.source!==void 0&&t.uint32(26).string(e.source),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Sc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.event=N.unwrap(N.decode(n,n.uint32()));continue;case 3:if(s!==26)break;o.source=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Ho.fromPartial(e??{})},fromPartial(e){let t=Sc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.event=e.event??void 0,t.source=e.source??void 0,t}};function wc(){return{baseEvent:void 0,name:"",value:void 0}}var $o={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.name!==""&&t.uint32(18).string(e.name),e.value!==void 0&&N.encode(N.wrap(e.value),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=wc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.name=n.string();continue;case 3:if(s!==26)break;o.value=N.unwrap(N.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return $o.fromPartial(e??{})},fromPartial(e){let t=wc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.name=e.name??"",t.value=e.value??void 0,t}};function kc(){return{baseEvent:void 0,threadId:"",runId:""}}var zo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==""&&t.uint32(18).string(e.threadId),e.runId!==""&&t.uint32(26).string(e.runId),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=kc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.threadId=n.string();continue;case 3:if(s!==26)break;o.runId=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return zo.fromPartial(e??{})},fromPartial(e){let t=kc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??"",t.runId=e.runId??"",t}};function Ac(){return{baseEvent:void 0,threadId:"",runId:"",result:void 0,outcome:"",interrupts:[]}}var Bo={encode(e,t=new D){e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==""&&t.uint32(18).string(e.threadId),e.runId!==""&&t.uint32(26).string(e.runId),e.result!==void 0&&N.encode(N.wrap(e.result),t.uint32(34).fork()).join(),e.outcome!==""&&t.uint32(42).string(e.outcome);for(let n of e.interrupts)No.encode(n,t.uint32(50).fork()).join();return t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Ac();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.threadId=n.string();continue;case 3:if(s!==26)break;o.runId=n.string();continue;case 4:if(s!==34)break;o.result=N.unwrap(N.decode(n,n.uint32()));continue;case 5:if(s!==42)break;o.outcome=n.string();continue;case 6:if(s!==50)break;o.interrupts.push(No.decode(n,n.uint32()));continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Bo.fromPartial(e??{})},fromPartial(e){let t=Ac();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??"",t.runId=e.runId??"",t.result=e.result??void 0,t.outcome=e.outcome??"",t.interrupts=e.interrupts?.map(n=>No.fromPartial(n))||[],t}};function Ic(){return{baseEvent:void 0,code:void 0,message:""}}var Vo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.code!==void 0&&t.uint32(18).string(e.code),e.message!==""&&t.uint32(26).string(e.message),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Ic();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.code=n.string();continue;case 3:if(s!==26)break;o.message=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Vo.fromPartial(e??{})},fromPartial(e){let t=Ic();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.code=e.code??void 0,t.message=e.message??"",t}};function Cc(){return{baseEvent:void 0,stepName:""}}var jo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==""&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Cc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.stepName=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return jo.fromPartial(e??{})},fromPartial(e){let t=Cc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??"",t}};function Nc(){return{baseEvent:void 0,stepName:""}}var Wo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==""&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Nc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.stepName=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Wo.fromPartial(e??{})},fromPartial(e){let t=Nc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??"",t}};function Rc(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var Xo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==void 0&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.delta!==void 0&&t.uint32(34).string(e.delta),e.name!==void 0&&t.uint32(42).string(e.name),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Rc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.messageId=n.string();continue;case 3:if(s!==26)break;o.role=n.string();continue;case 4:if(s!==34)break;o.delta=n.string();continue;case 5:if(s!==42)break;o.name=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Xo.fromPartial(e??{})},fromPartial(e){let t=Rc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??void 0,t.role=e.role??void 0,t.delta=e.delta??void 0,t.name=e.name??void 0,t}};function Oc(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var Zo={encode(e,t=new D){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==void 0&&t.uint32(18).string(e.toolCallId),e.toolCallName!==void 0&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),e.delta!==void 0&&t.uint32(42).string(e.delta),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Oc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.baseEvent=R.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.toolCallId=n.string();continue;case 3:if(s!==26)break;o.toolCallName=n.string();continue;case 4:if(s!==34)break;o.parentMessageId=n.string();continue;case 5:if(s!==42)break;o.delta=n.string();continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Zo.fromPartial(e??{})},fromPartial(e){let t=Oc();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??void 0,t.toolCallName=e.toolCallName??void 0,t.parentMessageId=e.parentMessageId??void 0,t.delta=e.delta??void 0,t}};function Mc(){return{textMessageStart:void 0,textMessageContent:void 0,textMessageEnd:void 0,toolCallStart:void 0,toolCallArgs:void 0,toolCallEnd:void 0,stateSnapshot:void 0,stateDelta:void 0,messagesSnapshot:void 0,raw:void 0,custom:void 0,runStarted:void 0,runFinished:void 0,runError:void 0,stepStarted:void 0,stepFinished:void 0,textMessageChunk:void 0,toolCallChunk:void 0}}var Lc={encode(e,t=new D){return e.textMessageStart!==void 0&&Ro.encode(e.textMessageStart,t.uint32(10).fork()).join(),e.textMessageContent!==void 0&&Oo.encode(e.textMessageContent,t.uint32(18).fork()).join(),e.textMessageEnd!==void 0&&Mo.encode(e.textMessageEnd,t.uint32(26).fork()).join(),e.toolCallStart!==void 0&&Lo.encode(e.toolCallStart,t.uint32(34).fork()).join(),e.toolCallArgs!==void 0&&Po.encode(e.toolCallArgs,t.uint32(42).fork()).join(),e.toolCallEnd!==void 0&&Do.encode(e.toolCallEnd,t.uint32(50).fork()).join(),e.stateSnapshot!==void 0&&Uo.encode(e.stateSnapshot,t.uint32(58).fork()).join(),e.stateDelta!==void 0&&Go.encode(e.stateDelta,t.uint32(66).fork()).join(),e.messagesSnapshot!==void 0&&Fo.encode(e.messagesSnapshot,t.uint32(74).fork()).join(),e.raw!==void 0&&Ho.encode(e.raw,t.uint32(82).fork()).join(),e.custom!==void 0&&$o.encode(e.custom,t.uint32(90).fork()).join(),e.runStarted!==void 0&&zo.encode(e.runStarted,t.uint32(98).fork()).join(),e.runFinished!==void 0&&Bo.encode(e.runFinished,t.uint32(106).fork()).join(),e.runError!==void 0&&Vo.encode(e.runError,t.uint32(114).fork()).join(),e.stepStarted!==void 0&&jo.encode(e.stepStarted,t.uint32(122).fork()).join(),e.stepFinished!==void 0&&Wo.encode(e.stepFinished,t.uint32(130).fork()).join(),e.textMessageChunk!==void 0&&Xo.encode(e.textMessageChunk,t.uint32(138).fork()).join(),e.toolCallChunk!==void 0&&Zo.encode(e.toolCallChunk,t.uint32(146).fork()).join(),t},decode(e,t){let n=e instanceof T?e:new T(e),r=t===void 0?n.len:n.pos+t,o=Mc();for(;n.pos<r;){let s=n.uint32();switch(s>>>3){case 1:if(s!==10)break;o.textMessageStart=Ro.decode(n,n.uint32());continue;case 2:if(s!==18)break;o.textMessageContent=Oo.decode(n,n.uint32());continue;case 3:if(s!==26)break;o.textMessageEnd=Mo.decode(n,n.uint32());continue;case 4:if(s!==34)break;o.toolCallStart=Lo.decode(n,n.uint32());continue;case 5:if(s!==42)break;o.toolCallArgs=Po.decode(n,n.uint32());continue;case 6:if(s!==50)break;o.toolCallEnd=Do.decode(n,n.uint32());continue;case 7:if(s!==58)break;o.stateSnapshot=Uo.decode(n,n.uint32());continue;case 8:if(s!==66)break;o.stateDelta=Go.decode(n,n.uint32());continue;case 9:if(s!==74)break;o.messagesSnapshot=Fo.decode(n,n.uint32());continue;case 10:if(s!==82)break;o.raw=Ho.decode(n,n.uint32());continue;case 11:if(s!==90)break;o.custom=$o.decode(n,n.uint32());continue;case 12:if(s!==98)break;o.runStarted=zo.decode(n,n.uint32());continue;case 13:if(s!==106)break;o.runFinished=Bo.decode(n,n.uint32());continue;case 14:if(s!==114)break;o.runError=Vo.decode(n,n.uint32());continue;case 15:if(s!==122)break;o.stepStarted=jo.decode(n,n.uint32());continue;case 16:if(s!==130)break;o.stepFinished=Wo.decode(n,n.uint32());continue;case 17:if(s!==138)break;o.textMessageChunk=Xo.decode(n,n.uint32());continue;case 18:if(s!==146)break;o.toolCallChunk=Zo.decode(n,n.uint32());continue}if((s&7)===4||s===0)break;n.skip(s&7)}return o},create(e){return Lc.fromPartial(e??{})},fromPartial(e){let t=Mc();return t.textMessageStart=e.textMessageStart!==void 0&&e.textMessageStart!==null?Ro.fromPartial(e.textMessageStart):void 0,t.textMessageContent=e.textMessageContent!==void 0&&e.textMessageContent!==null?Oo.fromPartial(e.textMessageContent):void 0,t.textMessageEnd=e.textMessageEnd!==void 0&&e.textMessageEnd!==null?Mo.fromPartial(e.textMessageEnd):void 0,t.toolCallStart=e.toolCallStart!==void 0&&e.toolCallStart!==null?Lo.fromPartial(e.toolCallStart):void 0,t.toolCallArgs=e.toolCallArgs!==void 0&&e.toolCallArgs!==null?Po.fromPartial(e.toolCallArgs):void 0,t.toolCallEnd=e.toolCallEnd!==void 0&&e.toolCallEnd!==null?Do.fromPartial(e.toolCallEnd):void 0,t.stateSnapshot=e.stateSnapshot!==void 0&&e.stateSnapshot!==null?Uo.fromPartial(e.stateSnapshot):void 0,t.stateDelta=e.stateDelta!==void 0&&e.stateDelta!==null?Go.fromPartial(e.stateDelta):void 0,t.messagesSnapshot=e.messagesSnapshot!==void 0&&e.messagesSnapshot!==null?Fo.fromPartial(e.messagesSnapshot):void 0,t.raw=e.raw!==void 0&&e.raw!==null?Ho.fromPartial(e.raw):void 0,t.custom=e.custom!==void 0&&e.custom!==null?$o.fromPartial(e.custom):void 0,t.runStarted=e.runStarted!==void 0&&e.runStarted!==null?zo.fromPartial(e.runStarted):void 0,t.runFinished=e.runFinished!==void 0&&e.runFinished!==null?Bo.fromPartial(e.runFinished):void 0,t.runError=e.runError!==void 0&&e.runError!==null?Vo.fromPartial(e.runError):void 0,t.stepStarted=e.stepStarted!==void 0&&e.stepStarted!==null?jo.fromPartial(e.stepStarted):void 0,t.stepFinished=e.stepFinished!==void 0&&e.stepFinished!==null?Wo.fromPartial(e.stepFinished):void 0,t.textMessageChunk=e.textMessageChunk!==void 0&&e.textMessageChunk!==null?Xo.fromPartial(e.textMessageChunk):void 0,t.toolCallChunk=e.toolCallChunk!==void 0&&e.toolCallChunk!==null?Zo.fromPartial(e.toolCallChunk):void 0,t}};function Qh(e){let t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}var vo=e=>{if(!(!e||typeof e!="object")){if(e.data)return{type:"data",value:e.data.value,mimeType:e.data.mimeType};if(e.url)return{type:"url",value:e.url.value,mimeType:e.url.mimeType}}},em=e=>{if(!(!e||typeof e!="object")){if(e.text)return{type:"text",text:e.text.text};if(e.image)return{type:"image",source:vo(e.image.source),metadata:e.image.metadata};if(e.audio)return{type:"audio",source:vo(e.audio.source),metadata:e.audio.metadata};if(e.video)return{type:"video",source:vo(e.video.source),metadata:e.video.metadata};if(e.document)return{type:"document",source:vo(e.document.source),metadata:e.document.metadata}}};function Pc(e){let t=Lc.decode(e),n=Object.values(t).find(r=>r!==void 0);if(!n)throw new Error("Invalid event");if(n.type=Jh[n.baseEvent.type],n.timestamp=n.baseEvent.timestamp,n.rawEvent=n.baseEvent.rawEvent,delete n.baseEvent,n.type===v.MESSAGES_SNAPSHOT)for(let r of n.messages){let o=r;if(o.role==="user"&&Array.isArray(o.contentParts)){let s=o.contentParts.map(i=>em(i)).filter(i=>i!==void 0);s.length>0&&(o.content=s)}Array.isArray(o.contentParts)&&o.contentParts.length===0&&(o.contentParts=void 0),o.toolCalls?.length===0&&(o.toolCalls=void 0)}if(n.type===v.RUN_FINISHED){let r=n,o=typeof r.outcome=="string"&&r.outcome!==""?r.outcome:void 0,s=Array.isArray(r.interrupts)?r.interrupts:[];delete r.interrupts,o==="interrupt"?r.outcome={type:"interrupt",interrupts:s}:o==="success"?r.outcome={type:"success"}:delete r.outcome}if(n.type===v.STATE_DELTA)for(let r of n.delta)r.op=qh[r.op].toLowerCase(),Object.keys(r).forEach(o=>{r[o]===void 0&&delete r[o]});return Object.keys(n).forEach(r=>{n[r]===void 0&&delete n[r]}),Mr.parse(n)}var Ai="application/vnd.ag-ui.event+proto";var nm=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Ii=e=>{if(typeof e!="string")throw new TypeError("Invalid argument expected string");let t=e.match(nm);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},Dc=e=>e==="*"||e==="x"||e==="X",Uc=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},rm=(e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t],om=(e,t)=>{if(Dc(e)||Dc(t))return 0;let[n,r]=rm(Uc(e),Uc(t));return n>r?1:n<r?-1:0},Ci=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){let r=om(e[n]||"0",t[n]||"0");if(r!==0)return r}return 0};var Jn=(e,t)=>{let n=Ii(e),r=Ii(t),o=n.pop(),s=r.pop(),i=Ci(n,r);return i!==0?i:o&&s?Ci(o.split("."),s.split(".")):o||s?o?-1:1:0};var B=e=>{if(typeof structuredClone=="function")return structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch{return Array.isArray(e)?[...e]:{...e}}};function ze(){return ht()}function Oi(e){if(Object.freeze(e),typeof e=="object"&&e)for(let t of Object.values(e))typeof t=="object"&&t&&!Object.isFrozen(t)&&Oi(t);return e}async function X(e,t,n,r){let o=typeof process<"u"&&process.env!==void 0,s=o&&!!process.env.VITEST_WORKER_ID,i=o&&!!process.env.VITEST_WORKER_ID,a=B(t),u=B(n),c=a,p=u,m;for(let x of e)try{i&&(Oi(c),Oi(p));let f=await r(x,c,p);if(f===void 0)continue;if(f.messages!==void 0&&f.messages!==c&&(c=B(f.messages)),f.state!==void 0&&f.state!==p&&(p=B(f.state)),m=f.stopPropagation,m===!0)break}catch(f){if(i&&f instanceof TypeError){if(s)throw f;console.error("AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.",f)}else s||console.error("Subscriber error:",f);continue}return{...c===a?{}:{messages:i&&Object.isFrozen(c)?B(c):c},...p===u?{}:{state:i&&Object.isFrozen(p)?B(p):p},...m===void 0?{}:{stopPropagation:m}}}function Ko(e){if(!e)return{enabled:!1,events:!1,lifecycle:!1,verbose:!1};if(e===!0)return{enabled:!0,events:!0,lifecycle:!0,verbose:!0};let t=e.events??!0,n=e.lifecycle??!0,r=e.verbose??!1;return{enabled:t||n,events:t,lifecycle:n,verbose:r}}function Qn(e){if(e instanceof Mi)return e;if(e===!0)return new Mi(Ko(!0))}var Mi=class{constructor(e){this.config=e}event(e,t,n,r){this.config.events&&(this.config.verbose?console.debug(`[${e}] ${t}`,typeof n=="string"?n:JSON.stringify(n)):console.debug(`[${e}] ${t}`,r??n))}lifecycle(e,t,n){this.config.lifecycle&&(n?console.debug(`[${e}] ${t}`,n):console.debug(`[${e}] ${t}`))}get eventsEnabled(){return this.config.events}get lifecycleEnabled(){return this.config.lifecycle}get enabled(){return this.config.enabled}};function Ni(e){return e.enabled?new Mi(e):void 0}function sm(e,t,n){if(t){let o=e.find(i=>i.id===t);if(o?.role==="assistant")return o;o&&console.warn(`TOOL_CALL_START: parentMessageId '${t}' matches a '${o.role}' message, not assistant \u2014 falling back to toolCallId`);let s={id:o?n:t,role:"assistant",toolCalls:[]};return e.push(s),s}let r={id:n,role:"assistant",toolCalls:[]};return e.push(r),r}var Bc=(e,t,n,r,o)=>{let s=Qn(o),i=B(n.messages),a=B(e.state),u={},c=m=>{m.messages!==void 0&&(i=m.messages,u.messages=m.messages),m.state!==void 0&&(a=m.state,u.state=m.state)},p=()=>{let m=B(u);return u={},m.messages!==void 0||m.state!==void 0?te(m):Yr};return t.pipe(po(async m=>{let x=await X(r,i,a,(f,h,g)=>f.onEvent?.({event:m,agent:n,input:e,messages:h,state:g}));if(c(x),x.stopPropagation===!0?s?.event("APPLY","Event dropped:",m,{type:m.type,reason:"stopPropagation by subscriber"}):s?.event("APPLY","Event applied:",m,{type:m.type,subscribers:r.length}),x.stopPropagation===!0)return p();switch(m.type){case v.TEXT_MESSAGE_START:{let f=await X(r,i,a,(h,g,_)=>h.onTextMessageStartEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{messageId:h,role:g="assistant",name:_}=m;if(!i.find(S=>S.id===h)){let S={id:h,role:g,content:"",..._!==void 0&&{name:_}};i.push(S),c({messages:i})}}return p()}case v.TEXT_MESSAGE_CONTENT:{let{messageId:f,delta:h}=m,g=i.find(S=>S.id===f);if(!g)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${f}'`),p();let _=await X(r,i,a,(S,b,F)=>S.onTextMessageContentEvent?.({event:m,messages:b,state:F,agent:n,input:e,textMessageBuffer:typeof g.content=="string"?g.content:""}));return c(_),_.stopPropagation!==!0&&(g.content=`${typeof g.content=="string"?g.content:""}${h}`,c({messages:i})),p()}case v.TEXT_MESSAGE_END:{let{messageId:f}=m,h=i.find(g=>g.id===f);return h?(c(await X(r,i,a,(g,_,S)=>g.onTextMessageEndEvent?.({event:m,messages:_,state:S,agent:n,input:e,textMessageBuffer:typeof h.content=="string"?h.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:h,messages:i,state:a,agent:n,input:e})})),p()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${f}'`),p())}case v.TOOL_CALL_START:{let f=await X(r,i,a,(h,g,_)=>h.onToolCallStartEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{toolCallId:h,toolCallName:g,parentMessageId:_}=m,S=sm(i,_,h);S.toolCalls??=[],S.toolCalls.push({id:h,type:"function",function:{name:g,arguments:""}}),c({messages:i})}return p()}case v.TOOL_CALL_ARGS:{let{toolCallId:f,delta:h}=m,g=i.find(b=>b.toolCalls?.some(F=>F.id===f));if(!g)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${f}'`),p();let _=g.toolCalls?.find(b=>b.id===f);if(!_)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${f}'`),p();let S=await X(r,i,a,(b,F,Z)=>{let ae=_.function.arguments,ee=_.function.name,ut={};try{ut=ho(ae)}catch{}return b.onToolCallArgsEvent?.({event:m,messages:F,state:Z,agent:n,input:e,toolCallBuffer:ae,toolCallName:ee,partialToolCallArgs:ut})});return c(S),S.stopPropagation!==!0&&(_.function.arguments+=h,c({messages:i})),p()}case v.TOOL_CALL_END:{let{toolCallId:f}=m,h=i.find(_=>_.toolCalls?.some(S=>S.id===f));if(!h)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${f}'`),p();let g=h.toolCalls?.find(_=>_.id===f);return g?(c(await X(r,i,a,(_,S,b)=>{let F=g.function.arguments,Z=g.function.name,ae={};try{ae=JSON.parse(F)}catch{}return _.onToolCallEndEvent?.({event:m,messages:S,state:b,agent:n,input:e,toolCallName:Z,toolCallArgs:ae})})),await Promise.all(r.map(_=>{_.onNewToolCall?.({toolCall:g,messages:i,state:a,agent:n,input:e})})),p()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${f}'`),p())}case v.TOOL_CALL_RESULT:{let f=await X(r,i,a,(h,g,_)=>h.onToolCallResultEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{messageId:h,toolCallId:g,content:_,role:S}=m,b={id:h,toolCallId:g,role:S||"tool",content:_};i.push(b),await Promise.all(r.map(F=>{F.onNewMessage?.({message:b,messages:i,state:a,agent:n,input:e})})),c({messages:i})}return p()}case v.STATE_SNAPSHOT:{let f=await X(r,i,a,(h,g,_)=>h.onStateSnapshotEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{snapshot:h}=m;a=h,c({state:a})}return p()}case v.STATE_DELTA:{let f=await X(r,i,a,(h,g,_)=>h.onStateDeltaEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{delta:h}=m;try{a=$r.applyPatch(a,h,!0,!1).newDocument,c({state:a})}catch(g){let _=g instanceof Error?g.message:String(g);console.warn(`Failed to apply state patch:
699
702
  Current state: ${JSON.stringify(a,null,2)}
700
703
  Patch operations: ${JSON.stringify(h,null,2)}
701
- Error: ${_}`)}}return p()}case v.MESSAGES_SNAPSHOT:{let f=await X(r,i,a,(h,g,_)=>h.onMessagesSnapshotEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{messages:h}=m,g=new Map(h.map(b=>[b.id,b])),_=b=>b==="activity"||b==="reasoning";i=i.filter(b=>_(b.role)||g.has(b.id)).map(b=>_(b.role)?b:g.get(b.id));let S=new Set(i.map(b=>b.id));for(let b of h)S.has(b.id)||i.push(b);c({messages:i})}return p()}case v.ACTIVITY_SNAPSHOT:{let f=m,h=i.findIndex(F=>F.id===f.messageId),g=h>=0?i[h]:void 0,_=g?.role==="activity"?g:void 0,S=f.replace??!0,b=await X(r,i,a,(F,Z,ae)=>F.onActivitySnapshotEvent?.({event:f,messages:Z,state:ae,agent:n,input:e,activityMessage:_,existingMessage:g}));if(c(b),b.stopPropagation!==!0){let F={id:f.messageId,role:"activity",activityType:f.activityType,content:B(f.content)},Z;h===-1?(i.push(F),Z=F):_?S&&(i[h]={..._,activityType:f.activityType,content:B(f.content)}):S&&(i[h]=F,Z=F),c({messages:i}),Z&&await Promise.all(r.map(ae=>ae.onNewMessage?.({message:Z,messages:i,state:a,agent:n,input:e})))}return p()}case v.ACTIVITY_DELTA:{let f=m,h=i.findIndex(b=>b.id===f.messageId);if(h===-1)return p();let g=i[h];if(g.role!=="activity")return console.warn(`ACTIVITY_DELTA: Message '${f.messageId}' is not an activity message`),p();let _=g,S=await X(r,i,a,(b,F,Z)=>b.onActivityDeltaEvent?.({event:f,messages:F,state:Z,agent:n,input:e,activityMessage:_}));if(c(S),S.stopPropagation!==!0)try{let b=B(_.content??{}),F=Hr.applyPatch(b,f.patch??[],!0,!1).newDocument;i[h]={..._,content:B(F),activityType:f.activityType},c({messages:i})}catch(b){let F=b instanceof Error?b.message:String(b);console.warn(`Failed to apply activity patch for '${f.messageId}': ${F}`)}return p()}case v.RAW:return c(await X(r,i,a,(f,h,g)=>f.onRawEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.CUSTOM:return c(await X(r,i,a,(f,h,g)=>f.onCustomEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.RUN_STARTED:{let f=await X(r,i,a,(h,g,_)=>h.onRunStartedEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let h=m;if(h.input?.messages){for(let g of h.input.messages)i.find(_=>_.id===g.id)||i.push(g);c({messages:i})}}return p()}case v.RUN_FINISHED:{let f=m,h=f.outcome?.type==="interrupt"?{event:f,outcome:"interrupt",interrupts:f.outcome.interrupts}:{event:f,outcome:"success",result:f.result},g=await X(r,i,a,(_,S,b)=>_.onRunFinishedEvent?.({...h,messages:S,state:b,agent:n,input:e}));return c(g),g.stopPropagation!==!0&&(n.pendingInterrupts=h.outcome==="interrupt"?[...h.interrupts]:[]),p()}case v.RUN_ERROR:return c(await X(r,i,a,(f,h,g)=>f.onRunErrorEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.STEP_STARTED:return c(await X(r,i,a,(f,h,g)=>f.onStepStartedEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.STEP_FINISHED:return c(await X(r,i,a,(f,h,g)=>f.onStepFinishedEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.TEXT_MESSAGE_CHUNK:throw Error("TEXT_MESSAGE_CHUNK must be tranformed before being applied");case v.TOOL_CALL_CHUNK:throw Error("TOOL_CALL_CHUNK must be tranformed before being applied");case v.THINKING_START:return p();case v.THINKING_END:return p();case v.THINKING_TEXT_MESSAGE_START:return p();case v.THINKING_TEXT_MESSAGE_CONTENT:return p();case v.THINKING_TEXT_MESSAGE_END:return p();case v.REASONING_START:return c(await X(r,i,a,(f,h,g)=>f.onReasoningStartEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.REASONING_MESSAGE_START:{let f=await X(r,i,a,(h,g,_)=>h.onReasoningMessageStartEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{messageId:h}=m;if(!i.find(g=>g.id===h)){let g={id:h,role:"reasoning",content:""};i.push(g),c({messages:i})}}return p()}case v.REASONING_MESSAGE_CONTENT:{let{messageId:f,delta:h}=m,g=i.find(S=>S.id===f);if(!g)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${f}'`),p();let _=await X(r,i,a,(S,b,F)=>S.onReasoningMessageContentEvent?.({event:m,messages:b,state:F,agent:n,input:e,reasoningMessageBuffer:typeof g.content=="string"?g.content:""}));return c(_),_.stopPropagation!==!0&&(g.content=`${typeof g.content=="string"?g.content:""}${h}`,c({messages:i})),p()}case v.REASONING_MESSAGE_END:{let{messageId:f}=m,h=i.find(g=>g.id===f);return h?(c(await X(r,i,a,(g,_,S)=>g.onReasoningMessageEndEvent?.({event:m,messages:_,state:S,agent:n,input:e,reasoningMessageBuffer:typeof h.content=="string"?h.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:h,messages:i,state:a,agent:n,input:e})})),p()):(console.warn(`REASONING_MESSAGE_END: No message found with ID '${f}'`),p())}case v.REASONING_MESSAGE_CHUNK:throw Error("REASONING_MESSAGE_CHUNK must be transformed before being applied");case v.REASONING_END:return c(await X(r,i,a,(f,h,g)=>f.onReasoningEndEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.REASONING_ENCRYPTED_VALUE:{let{subtype:f,entityId:h,encryptedValue:g}=m,_=await X(r,i,a,(S,b,F)=>S.onReasoningEncryptedValueEvent?.({event:m,messages:b,state:F,agent:n,input:e}));if(c(_),_.stopPropagation!==!0){let S=!1;if(f==="tool-call"){for(let b of i)if(b.role==="assistant"&&b.toolCalls){let F=b.toolCalls.find(Z=>Z.id===h);if(F){F.encryptedValue=g,S=!0;break}}}else{let b=i.find(F=>F.id===h);b?.role!=="activity"&&b&&(b.encryptedValue=g,S=!0)}S&&(u.messages=i)}return p()}}return m.type,p()}),di(),r.length>0?pi({}):m=>m)},Ni=e=>t=>{let n=Jn(e),r=new Map,o=new Map,s=!1,i=!1,a=!1,u=new Map,c=!1,p=!1,m=!1,x=()=>{r.clear(),o.clear(),u.clear(),c=!1,p=!1,s=!1,i=!1,m=!0};return t.pipe(Ae(f=>{let h=f.type;if(n?.event("VERIFY","Event:",f,{type:f.type}),i)return Q(()=>new q(`Cannot send event type '${h}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(s&&h!==v.RUN_ERROR&&h!==v.RUN_STARTED)return Q(()=>new q(`Cannot send event type '${h}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(a){if(h===v.RUN_STARTED){if(m&&!s)return Q(()=>new q("Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run."));s&&x()}}else if(a=!0,h!==v.RUN_STARTED&&h!==v.RUN_ERROR)return Q(()=>new q("First event must be 'RUN_STARTED'"));switch(h){case v.TEXT_MESSAGE_START:{let g=f.messageId;return r.has(g)?Q(()=>new q(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${g}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`)):(r.set(g,!0),te(f))}case v.TEXT_MESSAGE_CONTENT:{let g=f.messageId;return r.has(g)?te(f):Q(()=>new q(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${g}'. Start a text message with 'TEXT_MESSAGE_START' first.`))}case v.TEXT_MESSAGE_END:{let g=f.messageId;return r.has(g)?(r.delete(g),te(f)):Q(()=>new q(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${g}'. A 'TEXT_MESSAGE_START' event must be sent first.`))}case v.TOOL_CALL_START:{let g=f.toolCallId;return o.has(g)?Q(()=>new q(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${g}' is already in progress. Complete it with 'TOOL_CALL_END' first.`)):(o.set(g,!0),te(f))}case v.TOOL_CALL_ARGS:{let g=f.toolCallId;return o.has(g)?te(f):Q(()=>new q(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${g}'. Start a tool call with 'TOOL_CALL_START' first.`))}case v.TOOL_CALL_END:{let g=f.toolCallId;return o.has(g)?(o.delete(g),te(f)):Q(()=>new q(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${g}'. A 'TOOL_CALL_START' event must be sent first.`))}case v.STEP_STARTED:{let g=f.stepName;return u.has(g)?Q(()=>new q(`Step "${g}" is already active for 'STEP_STARTED'`)):(u.set(g,!0),te(f))}case v.STEP_FINISHED:{let g=f.stepName;return u.has(g)?(u.delete(g),te(f)):Q(()=>new q(`Cannot send 'STEP_FINISHED' for step "${g}" that was not started`))}case v.RUN_STARTED:return m=!0,te(f);case v.RUN_FINISHED:if(u.size>0){let g=Array.from(u.keys()).join(", ");return Q(()=>new q(`Cannot send 'RUN_FINISHED' while steps are still active: ${g}`))}if(r.size>0){let g=Array.from(r.keys()).join(", ");return Q(()=>new q(`Cannot send 'RUN_FINISHED' while text messages are still active: ${g}`))}if(o.size>0){let g=Array.from(o.keys()).join(", ");return Q(()=>new q(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${g}`))}return s=!0,te(f);case v.RUN_ERROR:return i=!0,te(f);case v.CUSTOM:return te(f);case v.THINKING_TEXT_MESSAGE_START:return c?p?Q(()=>new q("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.")):(p=!0,te(f)):Q(()=>new q("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first."));case v.THINKING_TEXT_MESSAGE_CONTENT:return p?te(f):Q(()=>new q("Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first."));case v.THINKING_TEXT_MESSAGE_END:return p?(p=!1,te(f)):Q(()=>new q("Cannot send 'THINKING_TEXT_MESSAGE_END' event: No active thinking message found. A 'THINKING_TEXT_MESSAGE_START' event must be sent first."));case v.THINKING_START:return c?Q(()=>new q("Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.")):(c=!0,te(f));case v.THINKING_END:return c?(c=!1,te(f)):Q(()=>new q("Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first."));default:return te(f)}}))},Wt=(function(e){return e.HEADERS="headers",e.DATA="data",e})({}),sm=e=>co(()=>Bt(e())).pipe(fi(t=>{if(!t.ok){let o=t.headers.get("content-type")||"";return Bt(t.text()).pipe(Ae(s=>{let i=s;if(o.includes("application/json"))try{i=JSON.parse(s)}catch{}let a=Error(`HTTP ${t.status}: ${typeof i=="string"?i:JSON.stringify(i)}`);return a.status=t.status,a.payload=i,Q(()=>a)}))}let n={type:Wt.HEADERS,status:t.status,headers:t.headers},r=t.body?.getReader();return r?new J(o=>(o.next(n),(async()=>{try{for(;;){let{done:s,value:i}=await r.read();if(s)break;let a={type:Wt.DATA,data:i};o.next(a)}o.complete()}catch(s){o.error(s)}})(),()=>{r.cancel().catch(s=>{if(s?.name!=="AbortError")throw s})})):Q(()=>Error("Failed to getReader() from response"))})),im=(e,t)=>{let n=Jn(t),r=new nt,o=new TextDecoder("utf-8",{fatal:!1}),s="";e.subscribe({next:a=>{if(a.type!==Wt.HEADERS&&a.type===Wt.DATA&&a.data){let u=o.decode(a.data,{stream:!0});s+=u;let c=s.split(/\n\n/);s=c.pop()||"";for(let p of c)i(p)}},error:a=>r.error(a),complete:()=>{s&&(s+=o.decode(),i(s)),r.complete()}});function i(a){let u=a.split(`
704
+ Error: ${_}`)}}return p()}case v.MESSAGES_SNAPSHOT:{let f=await X(r,i,a,(h,g,_)=>h.onMessagesSnapshotEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{messages:h}=m,g=new Map(h.map(b=>[b.id,b])),_=b=>b==="activity"||b==="reasoning";i=i.filter(b=>_(b.role)||g.has(b.id)).map(b=>_(b.role)?b:g.get(b.id));let S=new Set(i.map(b=>b.id));for(let b of h)S.has(b.id)||i.push(b);c({messages:i})}return p()}case v.ACTIVITY_SNAPSHOT:{let f=m,h=i.findIndex(F=>F.id===f.messageId),g=h>=0?i[h]:void 0,_=g?.role==="activity"?g:void 0,S=f.replace??!0,b=await X(r,i,a,(F,Z,ae)=>F.onActivitySnapshotEvent?.({event:f,messages:Z,state:ae,agent:n,input:e,activityMessage:_,existingMessage:g}));if(c(b),b.stopPropagation!==!0){let F={id:f.messageId,role:"activity",activityType:f.activityType,content:B(f.content)},Z;h===-1?(i.push(F),Z=F):_?S&&(i[h]={..._,activityType:f.activityType,content:B(f.content)}):S&&(i[h]=F,Z=F),c({messages:i}),Z&&await Promise.all(r.map(ae=>ae.onNewMessage?.({message:Z,messages:i,state:a,agent:n,input:e})))}return p()}case v.ACTIVITY_DELTA:{let f=m,h=i.findIndex(b=>b.id===f.messageId);if(h===-1)return p();let g=i[h];if(g.role!=="activity")return console.warn(`ACTIVITY_DELTA: Message '${f.messageId}' is not an activity message`),p();let _=g,S=await X(r,i,a,(b,F,Z)=>b.onActivityDeltaEvent?.({event:f,messages:F,state:Z,agent:n,input:e,activityMessage:_}));if(c(S),S.stopPropagation!==!0)try{let b=B(_.content??{}),F=$r.applyPatch(b,f.patch??[],!0,!1).newDocument;i[h]={..._,content:B(F),activityType:f.activityType},c({messages:i})}catch(b){let F=b instanceof Error?b.message:String(b);console.warn(`Failed to apply activity patch for '${f.messageId}': ${F}`)}return p()}case v.RAW:return c(await X(r,i,a,(f,h,g)=>f.onRawEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.CUSTOM:return c(await X(r,i,a,(f,h,g)=>f.onCustomEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.RUN_STARTED:{let f=await X(r,i,a,(h,g,_)=>h.onRunStartedEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let h=m;if(h.input?.messages){for(let g of h.input.messages)i.find(_=>_.id===g.id)||i.push(g);c({messages:i})}}return p()}case v.RUN_FINISHED:{let f=m,h=f.outcome?.type==="interrupt"?{event:f,outcome:"interrupt",interrupts:f.outcome.interrupts}:{event:f,outcome:"success",result:f.result},g=await X(r,i,a,(_,S,b)=>_.onRunFinishedEvent?.({...h,messages:S,state:b,agent:n,input:e}));return c(g),g.stopPropagation!==!0&&(n.pendingInterrupts=h.outcome==="interrupt"?[...h.interrupts]:[]),p()}case v.RUN_ERROR:return c(await X(r,i,a,(f,h,g)=>f.onRunErrorEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.STEP_STARTED:return c(await X(r,i,a,(f,h,g)=>f.onStepStartedEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.STEP_FINISHED:return c(await X(r,i,a,(f,h,g)=>f.onStepFinishedEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.TEXT_MESSAGE_CHUNK:throw Error("TEXT_MESSAGE_CHUNK must be tranformed before being applied");case v.TOOL_CALL_CHUNK:throw Error("TOOL_CALL_CHUNK must be tranformed before being applied");case v.THINKING_START:return p();case v.THINKING_END:return p();case v.THINKING_TEXT_MESSAGE_START:return p();case v.THINKING_TEXT_MESSAGE_CONTENT:return p();case v.THINKING_TEXT_MESSAGE_END:return p();case v.REASONING_START:return c(await X(r,i,a,(f,h,g)=>f.onReasoningStartEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.REASONING_MESSAGE_START:{let f=await X(r,i,a,(h,g,_)=>h.onReasoningMessageStartEvent?.({event:m,messages:g,state:_,agent:n,input:e}));if(c(f),f.stopPropagation!==!0){let{messageId:h}=m;if(!i.find(g=>g.id===h)){let g={id:h,role:"reasoning",content:""};i.push(g),c({messages:i})}}return p()}case v.REASONING_MESSAGE_CONTENT:{let{messageId:f,delta:h}=m,g=i.find(S=>S.id===f);if(!g)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${f}'`),p();let _=await X(r,i,a,(S,b,F)=>S.onReasoningMessageContentEvent?.({event:m,messages:b,state:F,agent:n,input:e,reasoningMessageBuffer:typeof g.content=="string"?g.content:""}));return c(_),_.stopPropagation!==!0&&(g.content=`${typeof g.content=="string"?g.content:""}${h}`,c({messages:i})),p()}case v.REASONING_MESSAGE_END:{let{messageId:f}=m,h=i.find(g=>g.id===f);return h?(c(await X(r,i,a,(g,_,S)=>g.onReasoningMessageEndEvent?.({event:m,messages:_,state:S,agent:n,input:e,reasoningMessageBuffer:typeof h.content=="string"?h.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:h,messages:i,state:a,agent:n,input:e})})),p()):(console.warn(`REASONING_MESSAGE_END: No message found with ID '${f}'`),p())}case v.REASONING_MESSAGE_CHUNK:throw Error("REASONING_MESSAGE_CHUNK must be transformed before being applied");case v.REASONING_END:return c(await X(r,i,a,(f,h,g)=>f.onReasoningEndEvent?.({event:m,messages:h,state:g,agent:n,input:e}))),p();case v.REASONING_ENCRYPTED_VALUE:{let{subtype:f,entityId:h,encryptedValue:g}=m,_=await X(r,i,a,(S,b,F)=>S.onReasoningEncryptedValueEvent?.({event:m,messages:b,state:F,agent:n,input:e}));if(c(_),_.stopPropagation!==!0){let S=!1;if(f==="tool-call"){for(let b of i)if(b.role==="assistant"&&b.toolCalls){let F=b.toolCalls.find(Z=>Z.id===h);if(F){F.encryptedValue=g,S=!0;break}}}else{let b=i.find(F=>F.id===h);b?.role!=="activity"&&b&&(b.encryptedValue=g,S=!0)}S&&(u.messages=i)}return p()}}return m.type,p()}),pi(),r.length>0?fi({}):m=>m)},Ri=e=>t=>{let n=Qn(e),r=new Map,o=new Map,s=!1,i=!1,a=!1,u=new Map,c=!1,p=!1,m=!1,x=()=>{r.clear(),o.clear(),u.clear(),c=!1,p=!1,s=!1,i=!1,m=!0};return t.pipe(Ae(f=>{let h=f.type;if(n?.event("VERIFY","Event:",f,{type:f.type}),i)return Q(()=>new q(`Cannot send event type '${h}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(s&&h!==v.RUN_ERROR&&h!==v.RUN_STARTED)return Q(()=>new q(`Cannot send event type '${h}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(a){if(h===v.RUN_STARTED){if(m&&!s)return Q(()=>new q("Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run."));s&&x()}}else if(a=!0,h!==v.RUN_STARTED&&h!==v.RUN_ERROR)return Q(()=>new q("First event must be 'RUN_STARTED'"));switch(h){case v.TEXT_MESSAGE_START:{let g=f.messageId;return r.has(g)?Q(()=>new q(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${g}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`)):(r.set(g,!0),te(f))}case v.TEXT_MESSAGE_CONTENT:{let g=f.messageId;return r.has(g)?te(f):Q(()=>new q(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${g}'. Start a text message with 'TEXT_MESSAGE_START' first.`))}case v.TEXT_MESSAGE_END:{let g=f.messageId;return r.has(g)?(r.delete(g),te(f)):Q(()=>new q(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${g}'. A 'TEXT_MESSAGE_START' event must be sent first.`))}case v.TOOL_CALL_START:{let g=f.toolCallId;return o.has(g)?Q(()=>new q(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${g}' is already in progress. Complete it with 'TOOL_CALL_END' first.`)):(o.set(g,!0),te(f))}case v.TOOL_CALL_ARGS:{let g=f.toolCallId;return o.has(g)?te(f):Q(()=>new q(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${g}'. Start a tool call with 'TOOL_CALL_START' first.`))}case v.TOOL_CALL_END:{let g=f.toolCallId;return o.has(g)?(o.delete(g),te(f)):Q(()=>new q(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${g}'. A 'TOOL_CALL_START' event must be sent first.`))}case v.STEP_STARTED:{let g=f.stepName;return u.has(g)?Q(()=>new q(`Step "${g}" is already active for 'STEP_STARTED'`)):(u.set(g,!0),te(f))}case v.STEP_FINISHED:{let g=f.stepName;return u.has(g)?(u.delete(g),te(f)):Q(()=>new q(`Cannot send 'STEP_FINISHED' for step "${g}" that was not started`))}case v.RUN_STARTED:return m=!0,te(f);case v.RUN_FINISHED:if(u.size>0){let g=Array.from(u.keys()).join(", ");return Q(()=>new q(`Cannot send 'RUN_FINISHED' while steps are still active: ${g}`))}if(r.size>0){let g=Array.from(r.keys()).join(", ");return Q(()=>new q(`Cannot send 'RUN_FINISHED' while text messages are still active: ${g}`))}if(o.size>0){let g=Array.from(o.keys()).join(", ");return Q(()=>new q(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${g}`))}return s=!0,te(f);case v.RUN_ERROR:return i=!0,te(f);case v.CUSTOM:return te(f);case v.THINKING_TEXT_MESSAGE_START:return c?p?Q(()=>new q("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.")):(p=!0,te(f)):Q(()=>new q("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first."));case v.THINKING_TEXT_MESSAGE_CONTENT:return p?te(f):Q(()=>new q("Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first."));case v.THINKING_TEXT_MESSAGE_END:return p?(p=!1,te(f)):Q(()=>new q("Cannot send 'THINKING_TEXT_MESSAGE_END' event: No active thinking message found. A 'THINKING_TEXT_MESSAGE_START' event must be sent first."));case v.THINKING_START:return c?Q(()=>new q("Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.")):(c=!0,te(f));case v.THINKING_END:return c?(c=!1,te(f)):Q(()=>new q("Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first."));default:return te(f)}}))},Xt=(function(e){return e.HEADERS="headers",e.DATA="data",e})({}),im=e=>uo(()=>Vt(e())).pipe(hi(t=>{if(!t.ok){let o=t.headers.get("content-type")||"";return Vt(t.text()).pipe(Ae(s=>{let i=s;if(o.includes("application/json"))try{i=JSON.parse(s)}catch{}let a=Error(`HTTP ${t.status}: ${typeof i=="string"?i:JSON.stringify(i)}`);return a.status=t.status,a.payload=i,Q(()=>a)}))}let n={type:Xt.HEADERS,status:t.status,headers:t.headers},r=t.body?.getReader();return r?new J(o=>(o.next(n),(async()=>{try{for(;;){let{done:s,value:i}=await r.read();if(s)break;let a={type:Xt.DATA,data:i};o.next(a)}o.complete()}catch(s){o.error(s)}})(),()=>{r.cancel().catch(s=>{if(s?.name!=="AbortError")throw s})})):Q(()=>Error("Failed to getReader() from response"))})),am=(e,t)=>{let n=Qn(t),r=new rt,o=new TextDecoder("utf-8",{fatal:!1}),s="";e.subscribe({next:a=>{if(a.type!==Xt.HEADERS&&a.type===Xt.DATA&&a.data){let u=o.decode(a.data,{stream:!0});s+=u;let c=s.split(/\n\n/);s=c.pop()||"";for(let p of c)i(p)}},error:a=>r.error(a),complete:()=>{s&&(s+=o.decode(),i(s)),r.complete()}});function i(a){let u=a.split(`
702
705
  `),c=[];for(let p of u)p.startsWith("data:")&&c.push(p.slice(5).replace(/^ /,""));if(c.length>0)try{let p=c.join(`
703
- `),m=JSON.parse(p);n?.event("SSE","Event received:",m,{type:m.type}),r.next(m)}catch(p){r.error(p)}}return r.asObservable()},am=e=>{let t=new nt,n=new Uint8Array;e.subscribe({next:o=>{if(o.type!==Wt.HEADERS&&o.type===Wt.DATA&&o.data){let s=new Uint8Array(n.length+o.data.length);s.set(n,0),s.set(o.data,n.length),n=s,r()}},error:o=>t.error(o),complete:()=>{if(n.length>0)try{r()}catch{console.warn("Incomplete or invalid protocol buffer data at stream end")}t.complete()}});function r(){for(;n.length>=4;){let o=4+new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(n.length<o)break;try{let s=n.slice(4,o),i=Lc(s);t.next(i),n=n.slice(o)}catch(s){let i=s instanceof Error?s.message:String(s);t.error(Error(`Failed to decode protocol buffer message: ${i}`));return}}}return t.asObservable()},lm=(e,t)=>{let n=Jn(t),r=new nt,o=new Zr,s=!1;return e.subscribe({next:i=>{if(o.next(i),i.type===Wt.HEADERS&&!s){s=!0;let a=i.headers.get("content-type");n?.lifecycle("HTTP","Stream format detected:",{contentType:a,parser:a===ki?"protobuf":"sse"}),a===ki?am(o).subscribe({next:u=>r.next(u),error:u=>r.error(u),complete:()=>r.complete()}):im(o,n).subscribe({next:u=>{try{let c=Or.parse(u);n?.event("HTTP","Event validated:",c,{type:c.type,valid:!0}),r.next(c)}catch(c){n?.event("HTTP","Event invalid:",{json:u,error:String(c)}),r.error(c)}},error:u=>{if(u?.name==="AbortError"){r.next({type:v.RUN_ERROR,message:u.message||"Request aborted",code:"abort",rawEvent:u}),r.complete();return}return r.error(u)},complete:()=>r.complete()})}else s||r.error(Error("No headers event received before data events"))},error:i=>{o.error(i),r.error(i)},complete:()=>{o.complete()}}),r.asObservable()},K=l.enum(["TextMessageStart","TextMessageContent","TextMessageEnd","ActionExecutionStart","ActionExecutionArgs","ActionExecutionEnd","ActionExecutionResult","AgentStateMessage","MetaEvent","RunStarted","RunFinished","RunError","NodeStarted","NodeFinished"]),cm=l.enum(["LangGraphInterruptEvent","PredictState","Exit"]),um=l.object({type:l.literal(K.enum.TextMessageStart),messageId:l.string(),parentMessageId:l.string().optional(),role:l.string().optional()}),dm=l.object({type:l.literal(K.enum.TextMessageContent),messageId:l.string(),content:l.string()}),pm=l.object({type:l.literal(K.enum.TextMessageEnd),messageId:l.string()}),fm=l.object({type:l.literal(K.enum.ActionExecutionStart),actionExecutionId:l.string(),actionName:l.string(),parentMessageId:l.string().optional()}),hm=l.object({type:l.literal(K.enum.ActionExecutionArgs),actionExecutionId:l.string(),args:l.string()}),mm=l.object({type:l.literal(K.enum.ActionExecutionEnd),actionExecutionId:l.string()}),gm=l.object({type:l.literal(K.enum.ActionExecutionResult),actionName:l.string(),actionExecutionId:l.string(),result:l.string()}),vm=l.object({type:l.literal(K.enum.AgentStateMessage),threadId:l.string(),agentName:l.string(),nodeName:l.string(),runId:l.string(),active:l.boolean(),role:l.string(),state:l.string(),running:l.boolean()}),ym=l.object({type:l.literal(K.enum.MetaEvent),name:cm,value:l.any()}),bm=l.object({type:l.literal(K.enum.RunError),message:l.string(),code:l.string().optional()});l.discriminatedUnion("type",[um,dm,pm,fm,hm,mm,gm,vm,ym,bm]),l.object({id:l.string(),role:l.string(),content:l.string(),parentMessageId:l.string().optional()}),l.object({id:l.string(),name:l.string(),arguments:l.any(),parentMessageId:l.string().optional()}),l.object({id:l.string(),result:l.any(),actionExecutionId:l.string(),actionName:l.string()});var xm=e=>{if(typeof e=="string")return e;if(!Array.isArray(e))return;let t=e.filter(n=>n.type==="text").map(n=>n.text).filter(n=>n.length>0);if(t.length!==0)return t.join(`
704
- `)},Em=(e,t,n)=>r=>{let o={},s=!0,i=!0,a="",u=null,c=null,p=[],m={},x=f=>{typeof f=="object"&&f&&("messages"in f&&delete f.messages,o=f)};return r.pipe(Ae(f=>{switch(f.type){case v.TEXT_MESSAGE_START:{let h=f;return[{type:K.enum.TextMessageStart,messageId:h.messageId,role:h.role}]}case v.TEXT_MESSAGE_CONTENT:{let h=f;return[{type:K.enum.TextMessageContent,messageId:h.messageId,content:h.delta}]}case v.TEXT_MESSAGE_END:{let h=f;return[{type:K.enum.TextMessageEnd,messageId:h.messageId}]}case v.TOOL_CALL_START:{let h=f;return p.push({id:h.toolCallId,type:"function",function:{name:h.toolCallName,arguments:""}}),i=!0,m[h.toolCallId]=h.toolCallName,[{type:K.enum.ActionExecutionStart,actionExecutionId:h.toolCallId,actionName:h.toolCallName,parentMessageId:h.parentMessageId}]}case v.TOOL_CALL_ARGS:{let h=f,g=p.find(S=>S.id===h.toolCallId);if(!g)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${h.toolCallId}'`),[];g.function.arguments+=h.delta;let _=!1;if(c){let S=c.find(b=>b.tool==g.function.name);if(S)try{let b=JSON.parse(fo(g.function.arguments));S.tool_argument&&S.tool_argument in b?(x({...o,[S.state_key]:b[S.tool_argument]}),_=!0):S.tool_argument||(x({...o,[S.state_key]:b}),_=!0)}catch{}}return[{type:K.enum.ActionExecutionArgs,actionExecutionId:h.toolCallId,args:h.delta},..._?[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify(o),active:i}]:[]]}case v.TOOL_CALL_END:{let h=f;return[{type:K.enum.ActionExecutionEnd,actionExecutionId:h.toolCallId}]}case v.TOOL_CALL_RESULT:{let h=f;return[{type:K.enum.ActionExecutionResult,actionExecutionId:h.toolCallId,result:h.content,actionName:m[h.toolCallId]||"unknown"}]}case v.RAW:return[];case v.CUSTOM:{let h=f;switch(h.name){case"Exit":s=!1;break;case"PredictState":c=h.value;break}return[{type:K.enum.MetaEvent,name:h.name,value:h.value}]}case v.STATE_SNAPSHOT:return x(f.snapshot),[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify(o),active:i}];case v.STATE_DELTA:{let h=f,g=Hr.applyPatch(o,h.delta,!0,!1);return g?(x(g.newDocument),[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify(o),active:i}]):[]}case v.MESSAGES_SNAPSHOT:return u=f.messages,[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify({...o,...u?{messages:u}:{}}),active:!0}];case v.RUN_STARTED:return[];case v.RUN_FINISHED:return u&&(o.messages=u),Object.keys(o).length===0?[]:[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify({...o,...u?{messages:_m(u)}:{}}),active:!1}];case v.RUN_ERROR:{let h=f;return[{type:K.enum.RunError,message:h.message,code:h.code}]}case v.STEP_STARTED:return a=f.stepName,p=[],c=null,[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify(o),active:!0}];case v.STEP_FINISHED:return p=[],c=null,[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify(o),active:!1}];default:return[]}}))};function _m(e){let t=[];for(let n of e)if(n.role==="assistant"||n.role==="user"||n.role==="system"){let r=xm(n.content);if(r){let o={id:n.id,role:n.role,content:r};t.push(o)}if(n.role==="assistant"&&n.toolCalls&&n.toolCalls.length>0)for(let o of n.toolCalls){let s={id:o.id,name:o.function.name,arguments:JSON.parse(o.function.arguments),parentMessageId:n.id};t.push(s)}}else if(n.role==="tool"){let r="unknown";for(let s of e)if(s.role==="assistant"&&s.toolCalls?.length){for(let i of s.toolCalls)if(i.id===n.toolCallId){r=i.function.name;break}}let o={id:n.id,result:n.content,actionExecutionId:n.toolCallId,actionName:r};t.push(o)}return t}var Ko=e=>t=>{let n=Jn(e),r,o,s,i,a=()=>{if(!r||i!=="text")throw Error("No text message to close");let m={type:v.TEXT_MESSAGE_END,messageId:r.messageId};return i=void 0,r=void 0,n?.event("TRANSFORM","TEXT_MESSAGE_END",m,{messageId:m.messageId}),m},u=()=>{if(!o||i!=="tool")throw Error("No tool call to close");let m={type:v.TOOL_CALL_END,toolCallId:o.toolCallId};return i=void 0,o=void 0,n?.event("TRANSFORM","TOOL_CALL_END",m,{toolCallId:m.toolCallId}),m},c=()=>{if(!s||i!=="reasoning")throw Error("No reasoning message to close");let m={type:v.REASONING_MESSAGE_END,messageId:s.messageId};return i=void 0,s=void 0,n?.event("TRANSFORM","REASONING_MESSAGE_END",m,{messageId:m.messageId}),m},p=()=>i==="text"?[a()]:i==="tool"?[u()]:i==="reasoning"?[c()]:[];return t.pipe(Ae(m=>{switch(m.type){case v.TEXT_MESSAGE_START:case v.TEXT_MESSAGE_CONTENT:case v.TEXT_MESSAGE_END:case v.TOOL_CALL_START:case v.TOOL_CALL_ARGS:case v.TOOL_CALL_END:case v.TOOL_CALL_RESULT:case v.STATE_SNAPSHOT:case v.STATE_DELTA:case v.MESSAGES_SNAPSHOT:case v.CUSTOM:case v.RUN_STARTED:case v.RUN_FINISHED:case v.RUN_ERROR:case v.STEP_STARTED:case v.STEP_FINISHED:case v.THINKING_START:case v.THINKING_END:case v.THINKING_TEXT_MESSAGE_START:case v.THINKING_TEXT_MESSAGE_CONTENT:case v.THINKING_TEXT_MESSAGE_END:case v.REASONING_START:case v.REASONING_MESSAGE_START:case v.REASONING_MESSAGE_CONTENT:case v.REASONING_MESSAGE_END:case v.REASONING_END:return[...p(),m];case v.RAW:case v.ACTIVITY_SNAPSHOT:case v.ACTIVITY_DELTA:case v.REASONING_ENCRYPTED_VALUE:return[m];case v.TEXT_MESSAGE_CHUNK:let x=m,f=[];if((i!=="text"||x.messageId!==void 0&&x.messageId!==r?.messageId)&&f.push(...p()),i!=="text"){if(x.messageId===void 0)throw Error("First TEXT_MESSAGE_CHUNK must have a messageId");r={messageId:x.messageId,name:x.name},i="text";let b={type:v.TEXT_MESSAGE_START,messageId:x.messageId,role:x.role||"assistant",...x.name!==void 0&&{name:x.name}};f.push(b),n?.event("TRANSFORM","TEXT_MESSAGE_START",b,{messageId:x.messageId})}if(x.delta!==void 0){let b={type:v.TEXT_MESSAGE_CONTENT,messageId:r.messageId,delta:x.delta};f.push(b),n?.event("TRANSFORM","TEXT_MESSAGE_CONTENT",b,{messageId:r.messageId})}return f;case v.TOOL_CALL_CHUNK:let h=m,g=[];if((i!=="tool"||h.toolCallId!==void 0&&h.toolCallId!==o?.toolCallId)&&g.push(...p()),i!=="tool"){if(h.toolCallId===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallId");if(h.toolCallName===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallName");o={toolCallId:h.toolCallId,toolCallName:h.toolCallName,parentMessageId:h.parentMessageId},i="tool";let b={type:v.TOOL_CALL_START,toolCallId:h.toolCallId,toolCallName:h.toolCallName,parentMessageId:h.parentMessageId};g.push(b),n?.event("TRANSFORM","TOOL_CALL_START",b,{toolCallId:h.toolCallId,toolCallName:h.toolCallName})}if(h.delta!==void 0){let b={type:v.TOOL_CALL_ARGS,toolCallId:o.toolCallId,delta:h.delta};g.push(b),n?.event("TRANSFORM","TOOL_CALL_ARGS",b,{toolCallId:o.toolCallId})}return g;case v.REASONING_MESSAGE_CHUNK:let _=m,S=[];if((i!=="reasoning"||_.messageId&&_.messageId!==s?.messageId)&&S.push(...p()),i!=="reasoning"){if(_.messageId===void 0)throw Error("First REASONING_MESSAGE_CHUNK must have a messageId");s={messageId:_.messageId},i="reasoning";let b={type:v.REASONING_MESSAGE_START,messageId:_.messageId};S.push(b),n?.event("TRANSFORM","REASONING_MESSAGE_START",b,{messageId:_.messageId})}if(_.delta!==void 0){let b={type:v.REASONING_MESSAGE_CONTENT,messageId:s.messageId,delta:_.delta};S.push(b),n?.event("TRANSFORM","REASONING_MESSAGE_CONTENT",b,{messageId:s.messageId})}return S}return m.type,[]}),jt(()=>{p()}))};function Tm(e,t=new Date){return e.expiresAt===void 0?!1:new Date(e.expiresAt)<=t}var Yo=class{runNext(e,t){return t.run(e).pipe(Ko(!1))}runNextWithState(e,t){let n=B(e.messages||[]),r=B(e.state||{}),o=new Zr;return zc(e,o,t,[]).subscribe(s=>{s.messages!==void 0&&(n=s.messages),s.state!==void 0&&(r=s.state)}),this.runNext(e,t).pipe(uo(async s=>(o.next(s),await new Promise(i=>setTimeout(i,0)),{event:s,messages:B(n),state:B(r)})))}},Sm=class extends Yo{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function wm(e){let t=e.content;if(Array.isArray(t)){let n=t.filter(r=>typeof r=="object"&&!!r&&"type"in r&&r.type==="text"&&typeof r.text=="string").map(r=>r.text).join("");return{...e,content:n}}return typeof t=="string"?e:{...e,content:""}}var km=class extends Yo{run(e,t){let{parentRunId:n,...r}=e,o={...r,messages:r.messages.map(wm)};return this.runNext(o,t)}},Uc="THINKING_START",Gc="THINKING_END",Fc="THINKING_TEXT_MESSAGE_START",Hc="THINKING_TEXT_MESSAGE_CONTENT",$c="THINKING_TEXT_MESSAGE_END",Am=class extends Yo{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(e,t){typeof process<"u"&&process.env!==void 0&&process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(e,t).pipe(Vt(n=>this.transformEvent(n)))}transformEvent(e){switch(e.type){case Uc:{this.currentReasoningId=ze();let{title:t,...n}=e;return this.warnAboutTransformation(Uc,v.REASONING_START),{...n,type:v.REASONING_START,messageId:this.currentReasoningId}}case Fc:return this.currentMessageId=ze(),this.warnAboutTransformation(Fc,v.REASONING_MESSAGE_START),{...e,type:v.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:"assistant"};case Hc:{let{delta:t,...n}=e;return this.warnAboutTransformation(Hc,v.REASONING_MESSAGE_CONTENT),{...n,type:v.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??ze(),delta:t}}case $c:{let t=this.currentMessageId??ze();return this.warnAboutTransformation($c,v.REASONING_MESSAGE_END),{...e,type:v.REASONING_MESSAGE_END,messageId:t}}case Gc:{let t=this.currentReasoningId??ze();return this.warnAboutTransformation(Gc,v.REASONING_END),{...e,type:v.REASONING_END,messageId:t}}default:return e}}};function Im(e){return e.startsWith("image/")?"image":e.startsWith("audio/")?"audio":e.startsWith("video/")?"video":"document"}function Cm(e){return typeof e=="object"&&!!e&&"type"in e&&e.type==="binary"&&"mimeType"in e&&typeof e.mimeType=="string"}function Nm(e){let t=Im(e.mimeType);return e.data?{type:t,source:{type:"data",value:e.data,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e.url?{type:t,source:{type:"url",value:e.url,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e}function Rm(e){let t=e.content;if(!Array.isArray(t))return e;let n=t.map(r=>Cm(r)?Nm(r):r);return{...e,content:n}}var Om=class extends Yo{run(e,t){let n={...e,messages:e.messages.map(Rm)};return this.runNext(n,t)}},Mm="0.0.54",Lm=class{get maxVersion(){return Mm}get debug(){return this._debug}set debug(e){this._debug=Zo(e),this._debugLogger=Ci(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(e){typeof e=="boolean"?this._debugLogger=e?Ci(Zo(!0)):void 0:this._debugLogger=e}constructor({agentId:e,description:t,threadId:n,initialMessages:r,initialState:o,debug:s}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.agentId=e,this.description=t??"",this.threadId=n??ft(),this.messages=B(r??[]),this.state=B(o??{}),this._debug=Zo(s),this._debugLogger=Ci(this._debug),qn(this.maxVersion,"0.0.39")<=0&&this.middlewares.unshift(new km),qn(this.maxVersion,"0.0.45")<=0&&this.middlewares.unshift(new Am),qn(this.maxVersion,"0.0.47")<=0&&this.middlewares.unshift(new Om)}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}}use(...e){let t=e.map(n=>typeof n=="function"?new Sm(n):n);return this.middlewares.push(...t),this}async runAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??ft();let n=this.prepareRunAgentInput(e);this.debugLogger?.lifecycle("LIFECYCLE","Run started:",{agentId:this.agentId,threadId:this.threadId});let r,o=new Set(this.messages.map(u=>u.id)),s=[{onRunFinishedEvent:u=>{u.outcome==="success"&&(r=u.result)}},...this.subscribers,t??{}];await this.onInitialize(n,s),this.activeRunDetach$=new nt;let i;this.activeRunCompletionPromise=new Promise(u=>{i=u}),await lo(Xr(()=>this.middlewares.length===0?this.run(n):this.middlewares.reduceRight((u,c)=>({run:p=>c.run(p,u),get messages(){return u.messages},get state(){return u.state}}),this).run(n),Ko(this.debugLogger),Ni(this.debugLogger),u=>u.pipe(po(this.activeRunDetach$)),u=>this.apply(n,u,s),u=>this.processApplyEvents(n,u,s),Zn(u=>(this.debugLogger?.lifecycle("LIFECYCLE","Run errored:",{agentId:this.agentId,error:u instanceof Error?u.message:String(u)}),this.isRunning=!1,this.onError(n,u,s))),jt(()=>{this.debugLogger?.lifecycle("LIFECYCLE","Run finished:",{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(n,s),i?.(),i=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(te(null)));let a=B(this.messages).filter(u=>!o.has(u.id));return{result:r,newMessages:a}}finally{this.isRunning=!1}}connect(e){throw new Js}async connectAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??ft();let n=this.prepareRunAgentInput(e),r,o=new Set(this.messages.map(u=>u.id)),s=[{onRunFinishedEvent:u=>{u.outcome==="success"&&(r=u.result)}},...this.subscribers,t??{}];await this.onInitialize(n,s),this.activeRunDetach$=new nt;let i;this.activeRunCompletionPromise=new Promise(u=>{i=u}),await lo(Xr(()=>co(()=>this.connect(n)),Ko(this.debugLogger),Ni(this.debugLogger),u=>u.pipe(po(this.activeRunDetach$)),u=>this.apply(n,u,s),u=>this.processApplyEvents(n,u,s),Zn(u=>(this.isRunning=!1,u instanceof Js?Kr:this.onError(n,u,s))),jt(()=>{this.isRunning=!1,this.onFinalize(n,s),i?.(),i=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(te(null)),{defaultValue:void 0});let a=B(this.messages).filter(u=>!o.has(u.id));return{result:r,newMessages:a}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){if(!this.activeRunDetach$)return;let e=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),this.activeRunDetach$?.complete(),await e}apply(e,t,n){return zc(e,t,this,n,this.debugLogger)}processApplyEvents(e,t,n){return t.pipe(hi(r=>{r.messages&&(this.messages=r.messages,n.forEach(o=>{o.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),r.state&&(this.state=r.state,n.forEach(o=>{o.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}))}prepareRunAgentInput(e){let t=B(this.messages).filter(n=>n.role!=="activity");return{threadId:this.threadId,runId:e?.runId||ft(),tools:B(e?.tools??[]),context:B(e?.context??[]),forwardedProps:B(e?.forwardedProps??{}),state:B(this.state),messages:t,...e?.resume===void 0?{}:{resume:B(e.resume)}}}async onInitialize(e,t){if(this.pendingInterrupts.length>0){let r=new Set((e.resume??[]).map(s=>s.interruptId)),o=this.pendingInterrupts.map(s=>s.id).filter(s=>!r.has(s));if(o.length>0)throw new q(`Thread has ${o.length} pending interrupt(s) not addressed by resume: ${o.join(", ")}`);for(let s of this.pendingInterrupts)if(Tm(s))throw new q(`Interrupt ${s.id} expired at ${s.expiresAt}`)}let n=await X(t,this.messages,this.state,(r,o,s)=>r.onRunInitialized?.({messages:o,state:s,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages&&(this.messages=n.messages,e.messages=n.messages,t.forEach(r=>{r.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state&&(this.state=n.state,e.state=n.state,t.forEach(r=>{r.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}onError(e,t,n){return Bt(X(n,this.messages,this.state,(r,o,s)=>r.onRunFailed?.({error:t,messages:o,state:s,agent:this,input:e}))).pipe(Vt(r=>{let o=r;if((o.messages!==void 0||o.state!==void 0)&&(o.messages!==void 0&&(this.messages=o.messages,n.forEach(s=>{s.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),o.state!==void 0&&(this.state=o.state,n.forEach(s=>{s.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))),o.stopPropagation!==!0){let s=String(t);if(!(t.name==="AbortError"||t.message==="Fetch is aborted"||t.message==="signal is aborted without reason"||t.message==="component unmounted"||s==="component unmounted"))throw console.error("Agent execution failed:",t),t}return{}}))}async onFinalize(e,t){let n=await X(t,this.messages,this.state,(r,o,s)=>r.onRunFinalized?.({messages:o,state:s,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages!==void 0&&(this.messages=n.messages,t.forEach(r=>{r.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state!==void 0&&(this.state=n.state,t.forEach(r=>{r.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}clone(){let e=Object.create(Object.getPrototypeOf(this));return e.agentId=this.agentId,e.description=this.description,e.threadId=this.threadId,e.messages=B(this.messages),e.state=B(this.state),e._debug=this._debug,e._debugLogger=this._debugLogger,e.isRunning=this.isRunning,e.subscribers=[...this.subscribers],e.middlewares=[...this.middlewares],e.pendingInterrupts=B(this.pendingInterrupts),e}addMessage(e){this.messages.push(e),(async()=>{for(let t of this.subscribers)await t.onNewMessage?.({message:e,messages:this.messages,state:this.state,agent:this});if(e.role==="assistant"&&e.toolCalls)for(let t of e.toolCalls)for(let n of this.subscribers)await n.onNewToolCall?.({toolCall:t,messages:this.messages,state:this.state,agent:this});for(let t of this.subscribers)await t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}addMessages(e){this.messages.push(...e),(async()=>{for(let t of e){for(let n of this.subscribers)await n.onNewMessage?.({message:t,messages:this.messages,state:this.state,agent:this});if(t.role==="assistant"&&t.toolCalls)for(let n of t.toolCalls)for(let r of this.subscribers)await r.onNewToolCall?.({toolCall:n,messages:this.messages,state:this.state,agent:this})}for(let t of this.subscribers)await t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setMessages(e){this.messages=B(e),(async()=>{for(let t of this.subscribers)await t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(e){this.state=B(e),(async()=>{for(let t of this.subscribers)await t.onStateChanged?.({messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(e){this.agentId=this.agentId??ft();let t=this.prepareRunAgentInput(e);return(this.middlewares.length===0?this.run(t):this.middlewares.reduceRight((n,r)=>({run:o=>r.run(o,n),get messages(){return n.messages},get state(){return n.state}}),this).run(t)).pipe(Ko(this.debugLogger),Ni(this.debugLogger),Em(this.threadId,t.runId,this.agentId),n=>n.pipe(Vt(r=>(this.debugLogger?.event("LEGACY","Event:",r,{type:r.type}),r))))}},Bc=class extends Lm{requestInit(e){return{method:"POST",headers:{...this.headers,"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(e),signal:this.abortController.signal}}runAgent(e,t){return this.abortController=e?.abortController??new AbortController,super.runAgent(e,t)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(e){super(e),this.abortController=new AbortController,this.url=e.url,this.headers=B(e.headers??{}),this.fetch=e.fetch??fetch}run(e){return lm(sm(()=>this.fetch(this.url,this.requestInit(e))),this.debugLogger)}clone(){let e=super.clone();e.url=this.url,e.headers=B(this.headers??{}),e.fetch=this.fetch;let t=new AbortController,n=this.abortController.signal;return n.aborted&&t.abort(n.reason),e.abortController=t,e}};var Qn=class{#e;#n;#i;#p;#s;#t;constructor(t){this.#e=t.agent,this.#n=t.handlers,this.#i=t.getTools??(()=>[]),this.#p=t.getContext??(()=>[]),this.#s=t.executeTool??null,this.#t=t.onPersist??(()=>{})}get running(){return this.#e.isRunning}get messages(){return this.#e.messages}async send(t){this.#e.addMessage({id:ze(),role:"user",content:t}),this.#t(this.#e.messages),await this.#r()}async resume(){await this.#r()}addToolResult(t,n){this.#e.addMessage({id:ze(),role:"tool",content:n,toolCallId:t}),this.#t(this.#e.messages)}async#r(){try{await this.#o()}catch(t){this.#n.onError(t instanceof Error?t.message:String(t))}finally{this.#n.onSettled()}}async#o(){for(let t=0;t<bs;t+=1){let n=[];if(await this.#e.runAgent({tools:this.#i(),context:this.#p()},this.#u(n)),this.#t(this.#e.messages),this.#s===null||n.length===0)return;let r=!1;for(let o of n){let s=await this.#s(o);if(s!==null){if(s.halt===!0)return;this.#e.addMessage({id:ze(),role:"tool",content:s.content,toolCallId:o.id}),this.#t(this.#e.messages),r=!0}}if(!r)return}}#u(t){let n=this.#n;return{onRunInitialized(){n.onRunStart()},onTextMessageContentEvent({textMessageBuffer:r}){n.onTextDelta(r)},onTextMessageEndEvent({textMessageBuffer:r}){n.onTextEnd(r)},onToolCallEndEvent({event:r,toolCallName:o,toolCallArgs:s}){let i={id:r.toolCallId,name:o,args:s};t.push(i),n.onToolCall(i)},onToolCallResultEvent({event:r}){n.onToolResult(r.toolCallId,r.content)},onRunErrorEvent({event:r}){n.onError(r.message)},onRunFinalized(){n.onRunEnd()}}}};var Mi="ag-ui-chat:thread",Li="ag-ui-chat:messages:",Pi="ag-ui-chat:checkpoint:",er=class{threadId(){let t=sessionStorage.getItem(Mi);if(t!==null)return t;let n=ze();return sessionStorage.setItem(Mi,n),n}loadMessages(t){return Promise.resolve(this.#e(Li+t))}saveMessages(t,n){sessionStorage.setItem(Li+t,JSON.stringify(n))}loadCheckpoint(t){return this.#e(Pi+t)}saveCheckpoint(t,n){let r=Pi+t;if(n===null){sessionStorage.removeItem(r);return}sessionStorage.setItem(r,JSON.stringify(n))}clear(t){sessionStorage.removeItem(Li+t),sessionStorage.removeItem(Pi+t),sessionStorage.removeItem(Mi)}#e(t){let n=sessionStorage.getItem(t);if(n===null)return null;try{return JSON.parse(n)}catch{return null}}};function Di(e){return new Bc({url:e.endpoint,headers:e.headers??{},fetch:(t,n)=>fetch(t,n),...e.threadId!==void 0?{threadId:e.threadId}:{},...e.initialMessages!==void 0?{initialMessages:[...e.initialMessages]}:{}})}var Vc="ag-ui-chat:collapsed",tr=class extends HTMLElement{agentFactory=Di;headers={};autoConfirm=!1;confirmPredicate=null;getTools=()=>[...this.#w().map(t=>({name:t.name,description:t.description,parameters:t.parameters})),...this.#e.tools()];getContext=()=>Ts(this.getPageMap,this.autoInjectPageMap);routeMap=[];navigate=null;getPageMap=null;autoInjectPageMap=!0;conversationStore=new er;navigationResult=()=>({navigated:!0,url:window.location.href});skillContext=()=>({});#e=new Rn;#n=new Map;#i=new Set;#p;#s;#t;#r;#o;#u;#a;#l;#h=null;#d=null;#m=null;#c="";#v=[];#_=[];#T=[];#S=[];constructor(){super(),this.#p=this.attachShadow({mode:"open"}),this.#s=document.createElement("div"),this.#t=document.createElement("div"),this.#r=document.createElement("textarea"),this.#o=document.createElement("button"),this.#u=document.createElement("span"),this.#l=document.createElement("div"),this.#a=new Sr(t=>this.#L(t))}static get observedAttributes(){return["title-text"]}attributeChangedCallback(t,n,r){this.#u.textContent=r??"Assistant"}registerTool(t){this.#e.register(t)}registerStateHook(t){for(let n of ws(t))this.#e.register(n)}#C(){return this.routeMap.length===0?[]:Ss(()=>this.routeMap,()=>this.navigate)}#N(){let t=this.getPageMap;return t===null?[]:[{name:"read_page",description:"Read the current page's structure (fields, buttons, route). Call after acting to observe the result within the same turn.",parameters:{type:"object",properties:{},required:[]},handler:()=>t()}]}#w(){return[...this.#C(),...this.#N()]}#k(t){let n=this.#w().find(r=>r.name===t);return n!==void 0?n:this.#e.has(t)?this.#e.get(t):null}get endpoint(){return this.getAttribute("endpoint")??""}set endpoint(t){this.setAttribute("endpoint",t)}get toolDisplay(){let t=this.getAttribute("data-tool-display");return t===Xe.MINIMAL||t===Xe.COMPACT?t:Xe.FULL}set toolDisplay(t){this.setAttribute("data-tool-display",t)}connectedCallback(){this.#F(),sessionStorage.getItem(Vc)==="1"&&this.setAttribute("collapsed",""),this.#R(),this.#c=this.conversationStore.threadId(),this.#P()}setSkills(t){this.#S=t,this.#y()}#R(){this.#a.enableChips(this.getAttribute("data-prompt-chips")==="true"),this.#a.enableSlash(this.getAttribute("data-slash-commands")==="true"),this.#T=this.#O(),this.#y(),this.#M()}#O(){let t=this.getAttribute("data-skills");if(t===null)return[];try{return xs(JSON.parse(t))}catch{return[]}}async#M(){let t=this.getAttribute("data-skills-url");if(t!==null)try{let n=await fetch(t,{headers:this.headers});this.#_=xs(await n.json()),this.#y()}catch{}}#y(){let t=new Map;for(let n of[...this.#_,...this.#T,...this.#S])t.set(n.name,n);this.#a.setSkills([...t.values()])}#L(t){let{text:n,missing:r}=ha(t.prompt,this.skillContext());if(r.length>0){this.#l.textContent=`\u201C${t.title}\u201D needs: ${r.join(", ")}`,this.#l.hidden=!1;return}this.#l.hidden=!0,this.#r.value=n,t.sendImmediately===!0?this.#x():this.#r.focus()}get collapsed(){return this.hasAttribute("collapsed")}set collapsed(t){this.setCollapsed(t)}setCollapsed(t){t?this.setAttribute("collapsed",""):this.removeAttribute("collapsed"),sessionStorage.setItem(Vc,t?"1":"0"),this.dispatchEvent(new CustomEvent(gs,{detail:{collapsed:t},bubbles:!0,composed:!0}))}toggleCollapsed(){this.setCollapsed(!this.collapsed)}newChat(){this.conversationStore.clear(this.#c),this.#h=null,this.#d=null,this.#f(),this.#n.clear(),this.#i.clear(),this.#v=[],this.#t.replaceChildren(),this.#c=this.conversationStore.threadId(),this.#o.disabled=!1}async#P(){let t=await this.conversationStore.loadMessages(this.#c);if(t!==null){this.#v=t;for(let r of t)this.#D(r)}let n=this.conversationStore.loadCheckpoint(this.#c);n!==null&&await this.#G(n)}#D(t){let n=typeof t.content=="string"?t.content:"";if(t.role===We.USER){n!==""&&this.appendMessage(We.USER,n);return}if(t.role===We.ASSISTANT){n!==""&&this.#b(this.appendMessage(We.ASSISTANT,n));let r=t.toolCalls;if(r!==void 0)for(let o of r)this.#E({id:o.id,name:o.function.name,args:this.#U(o.function.arguments)});return}if(t.role==="tool"){let r=this.#n.get(t.toolCallId);r!==void 0&&r.settle(de.DONE,t.content)}}#U(t){try{let n=JSON.parse(t);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#b(t){this.getAttribute("data-text-animation")==="word"&&Ja(t)}async#G(t){this.conversationStore.saveCheckpoint(this.#c,null);let n=this.#A();n.addToolResult(t.toolCallId,JSON.stringify(this.navigationResult(t))),await n.resume()}appendMessage(t,n){let r=document.createElement("div");return r.className=`message message--${t}`,t===We.ASSISTANT?r.innerHTML=Tr(n):r.textContent=n,this.#t.appendChild(r),this.#t.scrollTop=this.#t.scrollHeight,r}#F(){let t=document.createElement("style");t.textContent=Qa,this.#s.className="chat";let n=document.createElement("div");n.className="header";let r=this.#u;r.className="header-title",r.textContent=this.getAttribute("title-text")??"Assistant";let o=document.createElement("div");o.className="header-controls";let s=document.createElement("button");s.type="button",s.className="header-btn header-btn--new",s.title="New chat",s.setAttribute("aria-label","New chat"),s.textContent="\u271A",s.addEventListener("click",()=>this.newChat());let i=document.createElement("button");i.type="button",i.className="header-btn header-btn--collapse",i.title="Collapse",i.setAttribute("aria-label","Collapse"),i.textContent="\u2014",i.addEventListener("click",()=>this.toggleCollapsed()),o.append(s,i),n.append(r,o),this.#t.className="messages",this.#t.setAttribute("role","log"),this.#t.setAttribute("aria-live","polite"),this.#t.setAttribute("aria-label","Conversation");let a=document.createElement("div");a.className="input-row",this.#r.className="input",this.#r.setAttribute("aria-label","Message"),this.#r.rows=2,this.#r.placeholder="Ask anything\u2026",this.#r.addEventListener("keydown",u=>this.#$(u)),this.#r.addEventListener("input",()=>this.#H()),this.#o.className="send",this.#o.type="button",this.#o.textContent="Send",this.#o.addEventListener("click",()=>{this.#x()}),this.#l.className="skill-hint",this.#l.hidden=!0,a.append(this.#r,this.#o),this.#s.append(n,this.#t,this.#a.palette,this.#a.chips,this.#l,a),this.#p.append(t,this.#s)}#H(){this.#a.onInput(this.#r.value),this.#l.hidden=!0}#$(t){if(this.#a.onKeydown(t)){t.preventDefault();return}t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.#x())}async#x(){let t=this.#r.value.trim();t!==""&&(this.appendMessage(We.USER,t),this.#r.value="",this.dispatchEvent(new CustomEvent(ms,{detail:{content:t},bubbles:!0,composed:!0})),await this.#z(t))}async#z(t){this.endpoint!==""&&await this.#A().send(t)}#A(){if(this.#h===null){let t=this.agentFactory({endpoint:this.endpoint,headers:this.headers,threadId:this.#c,initialMessages:this.#v});this.#h=new Qn({agent:t,handlers:this.#j(),getTools:()=>this.getTools(),getContext:()=>this.getContext(),executeTool:n=>this.#V(n),onPersist:n=>this.conversationStore.saveMessages(this.#c,n)})}return this.#h}async#B(t,n){return this.autoConfirm?!1:this.confirmPredicate!==null?await this.confirmPredicate(t.name,t.args)===!0:Es(n.parameters)}async#V(t){let n=this.#E(t);this.#n.delete(t.id);let r=this.#k(t.name);if(r===null)return this.#i.has(t.id)||n.settle(de.DONE,"Executed on the server."),null;if(await this.#B(t,r)){let s={toolName:t.name,args:t.args},i=r.parameters[vs];typeof i=="string"&&(s.message=i);let a=ks(this.#t,s);if(this.#t.scrollTop=this.#t.scrollHeight,!await a){let c="User declined the action.";return n.settle(de.DECLINED,c),this.#g(),{content:c}}}let o=_s(r.parameters)&&this.navigate===null;o&&this.conversationStore.saveCheckpoint(this.#c,{toolCallId:t.id});try{let s=await r.handler(t.args);if(o)return n.settle(de.DONE,"Navigating\u2026"),{content:"",halt:!0};let i=JSON.stringify(s??null);return n.settle(de.DONE,i),this.#g(),{content:i}}catch(s){o&&this.conversationStore.saveCheckpoint(this.#c,null);let i=s instanceof Error?s.message:String(s);return n.settle(de.ERROR,i),this.#g(),{content:`Error: ${i}`,error:i}}}#j(){return{onRunStart:()=>{this.#o.disabled=!0,this.#g()},onTextDelta:t=>{this.#f(),this.#I(t)},onTextEnd:t=>{this.#b(this.#I(t)),this.#d=null},onToolCall:t=>{this.#f(),this.#E(t)},onToolResult:(t,n)=>{let r=this.#n.get(t);r!==void 0&&(r.settle(de.DONE,n),this.#i.add(t))},onRunEnd:()=>{this.#f(),this.#o.disabled=!1,this.#d=null},onError:t=>{this.#f(),this.#b(this.appendMessage(We.ASSISTANT,`\u26A0\uFE0F ${t}`)),this.#o.disabled=!1,this.#d=null},onSettled:()=>{this.#f(),this.#o.disabled=!1,this.#d=null}}}#g(){if(this.#m!==null)return;let t=document.createElement("div");t.className="pending",t.setAttribute("role","status"),t.setAttribute("aria-label","Assistant is thinking\u2026");for(let n=0;n<3;n+=1){let r=document.createElement("span");r.className="pending-dot",t.appendChild(r)}this.#m=t,this.#t.appendChild(t),this.#t.scrollTop=this.#t.scrollHeight}#f(){this.#m?.remove(),this.#m=null}#I(t){return this.#d===null&&(this.#d=this.appendMessage(We.ASSISTANT,"")),this.#d.innerHTML=Tr(t),this.#t.scrollTop=this.#t.scrollHeight,this.#d}#E(t){let n=this.#n.get(t.id);if(n!==void 0)return n;let r=this.#k(t.name)?.parameters[ys],o=new Gn(t.name,t.args,this.toolDisplay,typeof r=="string"?r:void 0);return this.#n.set(t.id,o),this.#t.appendChild(o.element),this.#t.scrollTop=this.#t.scrollHeight,o}};function Pm(){customElements.get(mr)===void 0&&customElements.define(mr,tr)}function qo(e,t){return Object.getOwnPropertyDescriptor(e,t).set}var Dm=qo(HTMLInputElement.prototype,"value"),Um=qo(HTMLTextAreaElement.prototype,"value"),Gm=qo(HTMLSelectElement.prototype,"value"),Fm=qo(HTMLInputElement.prototype,"checked");function Xt(e,t){e instanceof HTMLTextAreaElement?Um.call(e,t):e instanceof HTMLSelectElement?Gm.call(e,t):Dm.call(e,t)}function nr(e,t){Fm.call(e,t)}var jc="#4f46e5";function Jo(e){return new Promise(t=>{setTimeout(t,e)})}async function Ui(e,t,n={}){let r=n.charDelayMs??35;Xt(e,""),e.dispatchEvent(new Event("input",{bubbles:!0}));for(let o of t)Xt(e,e.value+o),e.dispatchEvent(new Event("input",{bubbles:!0})),r>0&&await Jo(r);e.dispatchEvent(new Event("change",{bubbles:!0}))}async function Gi(e,t={}){let n=t.highlightMs??280,r=e.style.outline,o=e.style.outlineOffset;e.style.outline=`2px solid ${jc}`,e.style.outlineOffset="2px",await Jo(n),e.style.outline=r,e.style.outlineOffset=o,e.click()}function Zt(e){e.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}async function Fi(e,t={}){let n=t.flashMs??200;e.focus();let r=e.style.boxShadow;e.style.boxShadow="0 0 0 3px rgba(79, 70, 229, 0.4)",await Jo(n),e.style.boxShadow=r}var Wc="0 0 0 3px rgba(79, 70, 229, 0.4)";function Xc(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Hi(e){return e<=0||Xc()?Promise.resolve():Jo(e)}async function $i(e,t={}){let n=t.pressMs??140,r=e.style.transform,o=e.style.transition,s=e.style.boxShadow;e.style.transition="transform 80ms ease",e.style.transform="scale(0.96)",e.style.boxShadow=Wc,await Hi(n),e.style.transform=r,e.style.transition=o,e.style.boxShadow=s,e.click()}function Hm(e,t){for(let n of Array.from(e.options))if(n.value===t||n.text===t)return n;return null}async function zi(e,t,n={}){let r=Hm(e,t);if(r===null)throw new Error(`no <option> matching "${t}"`);let o=n.highlightMs??220,s=e.style.outline,i=e.style.outlineOffset;e.style.outline=`2px solid ${jc}`,e.style.outlineOffset="2px",await Hi(o),Xt(e,r.value),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.style.outline=s,e.style.outlineOffset=i}async function Bi(e,t,n={}){let r=n.flashMs??200,o=e.style.boxShadow;e.style.boxShadow=Wc,await Hi(r),nr(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.style.boxShadow=o}async function $m(e,t,n={}){Zt(e),await Fi(e,{flashMs:n.flashMs??0}),await Ui(e,t,n)}async function zm(e,t={}){Zt(e),await Gi(e,t)}async function Bm(e,t={}){Zt(e),await $i(e,t)}async function Vm(e,t,n={}){Zt(e),await zi(e,t,n)}async function jm(e,t,n={}){Zt(e),await Bi(e,t,n)}function Wm(e,t){e instanceof HTMLInputElement&&e.type==="checkbox"?nr(e,!!t):Xt(e,String(t)),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}var Xm="0.2.1";export{tr as AgUiChat,Qn as AgUiClient,Rn as ClientToolRegistry,mr as ELEMENT_TAG,bs as MAX_TOOL_ROUNDS,We as MESSAGE_ROLE,ms as SUBMIT_EVENT,er as SessionStorageStore,gs as TOGGLE_EVENT,de as TOOL_CALL_STATUS,Xe as TOOL_DISPLAY,Gn as ToolCallCard,Xm as VERSION,vs as X_CONFIRM_KEY,Cn as X_DESTRUCTIVE_KEY,Nn as X_NAVIGATES_KEY,ys as X_SUMMARY_KEY,zm as clickElement,Di as createHttpAgent,Ts as createPageMapContext,Ss as createRouteTools,ws as createStateHookTools,Pm as defineAgUiChat,$m as fillField,Fi as focusWithFlash,Gi as highlightThenClick,Es as isDestructive,_s as isNavigates,Xc as prefersReducedMotion,Bm as pressButton,$i as pressThenClick,Tr as renderMarkdown,ks as requestConfirmation,Zt as scrollIntoCenterView,Vm as selectControl,zi as selectOption,Wm as setControlValue,nr as setNativeChecked,Xt as setNativeValue,jm as toggleCheckbox,Bi as toggleControl,Ui as typeInto};
706
+ `),m=JSON.parse(p);n?.event("SSE","Event received:",m,{type:m.type}),r.next(m)}catch(p){r.error(p)}}return r.asObservable()},lm=e=>{let t=new rt,n=new Uint8Array;e.subscribe({next:o=>{if(o.type!==Xt.HEADERS&&o.type===Xt.DATA&&o.data){let s=new Uint8Array(n.length+o.data.length);s.set(n,0),s.set(o.data,n.length),n=s,r()}},error:o=>t.error(o),complete:()=>{if(n.length>0)try{r()}catch{console.warn("Incomplete or invalid protocol buffer data at stream end")}t.complete()}});function r(){for(;n.length>=4;){let o=4+new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(n.length<o)break;try{let s=n.slice(4,o),i=Pc(s);t.next(i),n=n.slice(o)}catch(s){let i=s instanceof Error?s.message:String(s);t.error(Error(`Failed to decode protocol buffer message: ${i}`));return}}}return t.asObservable()},cm=(e,t)=>{let n=Qn(t),r=new rt,o=new Kr,s=!1;return e.subscribe({next:i=>{if(o.next(i),i.type===Xt.HEADERS&&!s){s=!0;let a=i.headers.get("content-type");n?.lifecycle("HTTP","Stream format detected:",{contentType:a,parser:a===Ai?"protobuf":"sse"}),a===Ai?lm(o).subscribe({next:u=>r.next(u),error:u=>r.error(u),complete:()=>r.complete()}):am(o,n).subscribe({next:u=>{try{let c=Mr.parse(u);n?.event("HTTP","Event validated:",c,{type:c.type,valid:!0}),r.next(c)}catch(c){n?.event("HTTP","Event invalid:",{json:u,error:String(c)}),r.error(c)}},error:u=>{if(u?.name==="AbortError"){r.next({type:v.RUN_ERROR,message:u.message||"Request aborted",code:"abort",rawEvent:u}),r.complete();return}return r.error(u)},complete:()=>r.complete()})}else s||r.error(Error("No headers event received before data events"))},error:i=>{o.error(i),r.error(i)},complete:()=>{o.complete()}}),r.asObservable()},K=l.enum(["TextMessageStart","TextMessageContent","TextMessageEnd","ActionExecutionStart","ActionExecutionArgs","ActionExecutionEnd","ActionExecutionResult","AgentStateMessage","MetaEvent","RunStarted","RunFinished","RunError","NodeStarted","NodeFinished"]),um=l.enum(["LangGraphInterruptEvent","PredictState","Exit"]),dm=l.object({type:l.literal(K.enum.TextMessageStart),messageId:l.string(),parentMessageId:l.string().optional(),role:l.string().optional()}),pm=l.object({type:l.literal(K.enum.TextMessageContent),messageId:l.string(),content:l.string()}),fm=l.object({type:l.literal(K.enum.TextMessageEnd),messageId:l.string()}),hm=l.object({type:l.literal(K.enum.ActionExecutionStart),actionExecutionId:l.string(),actionName:l.string(),parentMessageId:l.string().optional()}),mm=l.object({type:l.literal(K.enum.ActionExecutionArgs),actionExecutionId:l.string(),args:l.string()}),gm=l.object({type:l.literal(K.enum.ActionExecutionEnd),actionExecutionId:l.string()}),vm=l.object({type:l.literal(K.enum.ActionExecutionResult),actionName:l.string(),actionExecutionId:l.string(),result:l.string()}),ym=l.object({type:l.literal(K.enum.AgentStateMessage),threadId:l.string(),agentName:l.string(),nodeName:l.string(),runId:l.string(),active:l.boolean(),role:l.string(),state:l.string(),running:l.boolean()}),bm=l.object({type:l.literal(K.enum.MetaEvent),name:um,value:l.any()}),xm=l.object({type:l.literal(K.enum.RunError),message:l.string(),code:l.string().optional()});l.discriminatedUnion("type",[dm,pm,fm,hm,mm,gm,vm,ym,bm,xm]),l.object({id:l.string(),role:l.string(),content:l.string(),parentMessageId:l.string().optional()}),l.object({id:l.string(),name:l.string(),arguments:l.any(),parentMessageId:l.string().optional()}),l.object({id:l.string(),result:l.any(),actionExecutionId:l.string(),actionName:l.string()});var Em=e=>{if(typeof e=="string")return e;if(!Array.isArray(e))return;let t=e.filter(n=>n.type==="text").map(n=>n.text).filter(n=>n.length>0);if(t.length!==0)return t.join(`
707
+ `)},_m=(e,t,n)=>r=>{let o={},s=!0,i=!0,a="",u=null,c=null,p=[],m={},x=f=>{typeof f=="object"&&f&&("messages"in f&&delete f.messages,o=f)};return r.pipe(Ae(f=>{switch(f.type){case v.TEXT_MESSAGE_START:{let h=f;return[{type:K.enum.TextMessageStart,messageId:h.messageId,role:h.role}]}case v.TEXT_MESSAGE_CONTENT:{let h=f;return[{type:K.enum.TextMessageContent,messageId:h.messageId,content:h.delta}]}case v.TEXT_MESSAGE_END:{let h=f;return[{type:K.enum.TextMessageEnd,messageId:h.messageId}]}case v.TOOL_CALL_START:{let h=f;return p.push({id:h.toolCallId,type:"function",function:{name:h.toolCallName,arguments:""}}),i=!0,m[h.toolCallId]=h.toolCallName,[{type:K.enum.ActionExecutionStart,actionExecutionId:h.toolCallId,actionName:h.toolCallName,parentMessageId:h.parentMessageId}]}case v.TOOL_CALL_ARGS:{let h=f,g=p.find(S=>S.id===h.toolCallId);if(!g)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${h.toolCallId}'`),[];g.function.arguments+=h.delta;let _=!1;if(c){let S=c.find(b=>b.tool==g.function.name);if(S)try{let b=JSON.parse(ho(g.function.arguments));S.tool_argument&&S.tool_argument in b?(x({...o,[S.state_key]:b[S.tool_argument]}),_=!0):S.tool_argument||(x({...o,[S.state_key]:b}),_=!0)}catch{}}return[{type:K.enum.ActionExecutionArgs,actionExecutionId:h.toolCallId,args:h.delta},..._?[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify(o),active:i}]:[]]}case v.TOOL_CALL_END:{let h=f;return[{type:K.enum.ActionExecutionEnd,actionExecutionId:h.toolCallId}]}case v.TOOL_CALL_RESULT:{let h=f;return[{type:K.enum.ActionExecutionResult,actionExecutionId:h.toolCallId,result:h.content,actionName:m[h.toolCallId]||"unknown"}]}case v.RAW:return[];case v.CUSTOM:{let h=f;switch(h.name){case"Exit":s=!1;break;case"PredictState":c=h.value;break}return[{type:K.enum.MetaEvent,name:h.name,value:h.value}]}case v.STATE_SNAPSHOT:return x(f.snapshot),[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify(o),active:i}];case v.STATE_DELTA:{let h=f,g=$r.applyPatch(o,h.delta,!0,!1);return g?(x(g.newDocument),[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify(o),active:i}]):[]}case v.MESSAGES_SNAPSHOT:return u=f.messages,[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify({...o,...u?{messages:u}:{}}),active:!0}];case v.RUN_STARTED:return[];case v.RUN_FINISHED:return u&&(o.messages=u),Object.keys(o).length===0?[]:[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify({...o,...u?{messages:Tm(u)}:{}}),active:!1}];case v.RUN_ERROR:{let h=f;return[{type:K.enum.RunError,message:h.message,code:h.code}]}case v.STEP_STARTED:return a=f.stepName,p=[],c=null,[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify(o),active:!0}];case v.STEP_FINISHED:return p=[],c=null,[{type:K.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:a,runId:t,running:s,role:"assistant",state:JSON.stringify(o),active:!1}];default:return[]}}))};function Tm(e){let t=[];for(let n of e)if(n.role==="assistant"||n.role==="user"||n.role==="system"){let r=Em(n.content);if(r){let o={id:n.id,role:n.role,content:r};t.push(o)}if(n.role==="assistant"&&n.toolCalls&&n.toolCalls.length>0)for(let o of n.toolCalls){let s={id:o.id,name:o.function.name,arguments:JSON.parse(o.function.arguments),parentMessageId:n.id};t.push(s)}}else if(n.role==="tool"){let r="unknown";for(let s of e)if(s.role==="assistant"&&s.toolCalls?.length){for(let i of s.toolCalls)if(i.id===n.toolCallId){r=i.function.name;break}}let o={id:n.id,result:n.content,actionExecutionId:n.toolCallId,actionName:r};t.push(o)}return t}var Yo=e=>t=>{let n=Qn(e),r,o,s,i,a=()=>{if(!r||i!=="text")throw Error("No text message to close");let m={type:v.TEXT_MESSAGE_END,messageId:r.messageId};return i=void 0,r=void 0,n?.event("TRANSFORM","TEXT_MESSAGE_END",m,{messageId:m.messageId}),m},u=()=>{if(!o||i!=="tool")throw Error("No tool call to close");let m={type:v.TOOL_CALL_END,toolCallId:o.toolCallId};return i=void 0,o=void 0,n?.event("TRANSFORM","TOOL_CALL_END",m,{toolCallId:m.toolCallId}),m},c=()=>{if(!s||i!=="reasoning")throw Error("No reasoning message to close");let m={type:v.REASONING_MESSAGE_END,messageId:s.messageId};return i=void 0,s=void 0,n?.event("TRANSFORM","REASONING_MESSAGE_END",m,{messageId:m.messageId}),m},p=()=>i==="text"?[a()]:i==="tool"?[u()]:i==="reasoning"?[c()]:[];return t.pipe(Ae(m=>{switch(m.type){case v.TEXT_MESSAGE_START:case v.TEXT_MESSAGE_CONTENT:case v.TEXT_MESSAGE_END:case v.TOOL_CALL_START:case v.TOOL_CALL_ARGS:case v.TOOL_CALL_END:case v.TOOL_CALL_RESULT:case v.STATE_SNAPSHOT:case v.STATE_DELTA:case v.MESSAGES_SNAPSHOT:case v.CUSTOM:case v.RUN_STARTED:case v.RUN_FINISHED:case v.RUN_ERROR:case v.STEP_STARTED:case v.STEP_FINISHED:case v.THINKING_START:case v.THINKING_END:case v.THINKING_TEXT_MESSAGE_START:case v.THINKING_TEXT_MESSAGE_CONTENT:case v.THINKING_TEXT_MESSAGE_END:case v.REASONING_START:case v.REASONING_MESSAGE_START:case v.REASONING_MESSAGE_CONTENT:case v.REASONING_MESSAGE_END:case v.REASONING_END:return[...p(),m];case v.RAW:case v.ACTIVITY_SNAPSHOT:case v.ACTIVITY_DELTA:case v.REASONING_ENCRYPTED_VALUE:return[m];case v.TEXT_MESSAGE_CHUNK:let x=m,f=[];if((i!=="text"||x.messageId!==void 0&&x.messageId!==r?.messageId)&&f.push(...p()),i!=="text"){if(x.messageId===void 0)throw Error("First TEXT_MESSAGE_CHUNK must have a messageId");r={messageId:x.messageId,name:x.name},i="text";let b={type:v.TEXT_MESSAGE_START,messageId:x.messageId,role:x.role||"assistant",...x.name!==void 0&&{name:x.name}};f.push(b),n?.event("TRANSFORM","TEXT_MESSAGE_START",b,{messageId:x.messageId})}if(x.delta!==void 0){let b={type:v.TEXT_MESSAGE_CONTENT,messageId:r.messageId,delta:x.delta};f.push(b),n?.event("TRANSFORM","TEXT_MESSAGE_CONTENT",b,{messageId:r.messageId})}return f;case v.TOOL_CALL_CHUNK:let h=m,g=[];if((i!=="tool"||h.toolCallId!==void 0&&h.toolCallId!==o?.toolCallId)&&g.push(...p()),i!=="tool"){if(h.toolCallId===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallId");if(h.toolCallName===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallName");o={toolCallId:h.toolCallId,toolCallName:h.toolCallName,parentMessageId:h.parentMessageId},i="tool";let b={type:v.TOOL_CALL_START,toolCallId:h.toolCallId,toolCallName:h.toolCallName,parentMessageId:h.parentMessageId};g.push(b),n?.event("TRANSFORM","TOOL_CALL_START",b,{toolCallId:h.toolCallId,toolCallName:h.toolCallName})}if(h.delta!==void 0){let b={type:v.TOOL_CALL_ARGS,toolCallId:o.toolCallId,delta:h.delta};g.push(b),n?.event("TRANSFORM","TOOL_CALL_ARGS",b,{toolCallId:o.toolCallId})}return g;case v.REASONING_MESSAGE_CHUNK:let _=m,S=[];if((i!=="reasoning"||_.messageId&&_.messageId!==s?.messageId)&&S.push(...p()),i!=="reasoning"){if(_.messageId===void 0)throw Error("First REASONING_MESSAGE_CHUNK must have a messageId");s={messageId:_.messageId},i="reasoning";let b={type:v.REASONING_MESSAGE_START,messageId:_.messageId};S.push(b),n?.event("TRANSFORM","REASONING_MESSAGE_START",b,{messageId:_.messageId})}if(_.delta!==void 0){let b={type:v.REASONING_MESSAGE_CONTENT,messageId:s.messageId,delta:_.delta};S.push(b),n?.event("TRANSFORM","REASONING_MESSAGE_CONTENT",b,{messageId:s.messageId})}return S}return m.type,[]}),Wt(()=>{p()}))};function Sm(e,t=new Date){return e.expiresAt===void 0?!1:new Date(e.expiresAt)<=t}var qo=class{runNext(e,t){return t.run(e).pipe(Yo(!1))}runNextWithState(e,t){let n=B(e.messages||[]),r=B(e.state||{}),o=new Kr;return Bc(e,o,t,[]).subscribe(s=>{s.messages!==void 0&&(n=s.messages),s.state!==void 0&&(r=s.state)}),this.runNext(e,t).pipe(po(async s=>(o.next(s),await new Promise(i=>setTimeout(i,0)),{event:s,messages:B(n),state:B(r)})))}},wm=class extends qo{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function km(e){let t=e.content;if(Array.isArray(t)){let n=t.filter(r=>typeof r=="object"&&!!r&&"type"in r&&r.type==="text"&&typeof r.text=="string").map(r=>r.text).join("");return{...e,content:n}}return typeof t=="string"?e:{...e,content:""}}var Am=class extends qo{run(e,t){let{parentRunId:n,...r}=e,o={...r,messages:r.messages.map(km)};return this.runNext(o,t)}},Gc="THINKING_START",Fc="THINKING_END",Hc="THINKING_TEXT_MESSAGE_START",$c="THINKING_TEXT_MESSAGE_CONTENT",zc="THINKING_TEXT_MESSAGE_END",Im=class extends qo{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(e,t){typeof process<"u"&&process.env!==void 0&&process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(e,t).pipe(jt(n=>this.transformEvent(n)))}transformEvent(e){switch(e.type){case Gc:{this.currentReasoningId=ze();let{title:t,...n}=e;return this.warnAboutTransformation(Gc,v.REASONING_START),{...n,type:v.REASONING_START,messageId:this.currentReasoningId}}case Hc:return this.currentMessageId=ze(),this.warnAboutTransformation(Hc,v.REASONING_MESSAGE_START),{...e,type:v.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:"assistant"};case $c:{let{delta:t,...n}=e;return this.warnAboutTransformation($c,v.REASONING_MESSAGE_CONTENT),{...n,type:v.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??ze(),delta:t}}case zc:{let t=this.currentMessageId??ze();return this.warnAboutTransformation(zc,v.REASONING_MESSAGE_END),{...e,type:v.REASONING_MESSAGE_END,messageId:t}}case Fc:{let t=this.currentReasoningId??ze();return this.warnAboutTransformation(Fc,v.REASONING_END),{...e,type:v.REASONING_END,messageId:t}}default:return e}}};function Cm(e){return e.startsWith("image/")?"image":e.startsWith("audio/")?"audio":e.startsWith("video/")?"video":"document"}function Nm(e){return typeof e=="object"&&!!e&&"type"in e&&e.type==="binary"&&"mimeType"in e&&typeof e.mimeType=="string"}function Rm(e){let t=Cm(e.mimeType);return e.data?{type:t,source:{type:"data",value:e.data,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e.url?{type:t,source:{type:"url",value:e.url,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e}function Om(e){let t=e.content;if(!Array.isArray(t))return e;let n=t.map(r=>Nm(r)?Rm(r):r);return{...e,content:n}}var Mm=class extends qo{run(e,t){let n={...e,messages:e.messages.map(Om)};return this.runNext(n,t)}},Lm="0.0.54",Pm=class{get maxVersion(){return Lm}get debug(){return this._debug}set debug(e){this._debug=Ko(e),this._debugLogger=Ni(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(e){typeof e=="boolean"?this._debugLogger=e?Ni(Ko(!0)):void 0:this._debugLogger=e}constructor({agentId:e,description:t,threadId:n,initialMessages:r,initialState:o,debug:s}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.agentId=e,this.description=t??"",this.threadId=n??ht(),this.messages=B(r??[]),this.state=B(o??{}),this._debug=Ko(s),this._debugLogger=Ni(this._debug),Jn(this.maxVersion,"0.0.39")<=0&&this.middlewares.unshift(new Am),Jn(this.maxVersion,"0.0.45")<=0&&this.middlewares.unshift(new Im),Jn(this.maxVersion,"0.0.47")<=0&&this.middlewares.unshift(new Mm)}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}}use(...e){let t=e.map(n=>typeof n=="function"?new wm(n):n);return this.middlewares.push(...t),this}async runAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??ht();let n=this.prepareRunAgentInput(e);this.debugLogger?.lifecycle("LIFECYCLE","Run started:",{agentId:this.agentId,threadId:this.threadId});let r,o=new Set(this.messages.map(u=>u.id)),s=[{onRunFinishedEvent:u=>{u.outcome==="success"&&(r=u.result)}},...this.subscribers,t??{}];await this.onInitialize(n,s),this.activeRunDetach$=new rt;let i;this.activeRunCompletionPromise=new Promise(u=>{i=u}),await co(Zr(()=>this.middlewares.length===0?this.run(n):this.middlewares.reduceRight((u,c)=>({run:p=>c.run(p,u),get messages(){return u.messages},get state(){return u.state}}),this).run(n),Yo(this.debugLogger),Ri(this.debugLogger),u=>u.pipe(fo(this.activeRunDetach$)),u=>this.apply(n,u,s),u=>this.processApplyEvents(n,u,s),Kn(u=>(this.debugLogger?.lifecycle("LIFECYCLE","Run errored:",{agentId:this.agentId,error:u instanceof Error?u.message:String(u)}),this.isRunning=!1,this.onError(n,u,s))),Wt(()=>{this.debugLogger?.lifecycle("LIFECYCLE","Run finished:",{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(n,s),i?.(),i=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(te(null)));let a=B(this.messages).filter(u=>!o.has(u.id));return{result:r,newMessages:a}}finally{this.isRunning=!1}}connect(e){throw new Qs}async connectAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??ht();let n=this.prepareRunAgentInput(e),r,o=new Set(this.messages.map(u=>u.id)),s=[{onRunFinishedEvent:u=>{u.outcome==="success"&&(r=u.result)}},...this.subscribers,t??{}];await this.onInitialize(n,s),this.activeRunDetach$=new rt;let i;this.activeRunCompletionPromise=new Promise(u=>{i=u}),await co(Zr(()=>uo(()=>this.connect(n)),Yo(this.debugLogger),Ri(this.debugLogger),u=>u.pipe(fo(this.activeRunDetach$)),u=>this.apply(n,u,s),u=>this.processApplyEvents(n,u,s),Kn(u=>(this.isRunning=!1,u instanceof Qs?Yr:this.onError(n,u,s))),Wt(()=>{this.isRunning=!1,this.onFinalize(n,s),i?.(),i=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(te(null)),{defaultValue:void 0});let a=B(this.messages).filter(u=>!o.has(u.id));return{result:r,newMessages:a}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){if(!this.activeRunDetach$)return;let e=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),this.activeRunDetach$?.complete(),await e}apply(e,t,n){return Bc(e,t,this,n,this.debugLogger)}processApplyEvents(e,t,n){return t.pipe(mi(r=>{r.messages&&(this.messages=r.messages,n.forEach(o=>{o.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),r.state&&(this.state=r.state,n.forEach(o=>{o.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}))}prepareRunAgentInput(e){let t=B(this.messages).filter(n=>n.role!=="activity");return{threadId:this.threadId,runId:e?.runId||ht(),tools:B(e?.tools??[]),context:B(e?.context??[]),forwardedProps:B(e?.forwardedProps??{}),state:B(this.state),messages:t,...e?.resume===void 0?{}:{resume:B(e.resume)}}}async onInitialize(e,t){if(this.pendingInterrupts.length>0){let r=new Set((e.resume??[]).map(s=>s.interruptId)),o=this.pendingInterrupts.map(s=>s.id).filter(s=>!r.has(s));if(o.length>0)throw new q(`Thread has ${o.length} pending interrupt(s) not addressed by resume: ${o.join(", ")}`);for(let s of this.pendingInterrupts)if(Sm(s))throw new q(`Interrupt ${s.id} expired at ${s.expiresAt}`)}let n=await X(t,this.messages,this.state,(r,o,s)=>r.onRunInitialized?.({messages:o,state:s,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages&&(this.messages=n.messages,e.messages=n.messages,t.forEach(r=>{r.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state&&(this.state=n.state,e.state=n.state,t.forEach(r=>{r.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}onError(e,t,n){return Vt(X(n,this.messages,this.state,(r,o,s)=>r.onRunFailed?.({error:t,messages:o,state:s,agent:this,input:e}))).pipe(jt(r=>{let o=r;if((o.messages!==void 0||o.state!==void 0)&&(o.messages!==void 0&&(this.messages=o.messages,n.forEach(s=>{s.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),o.state!==void 0&&(this.state=o.state,n.forEach(s=>{s.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))),o.stopPropagation!==!0){let s=String(t);if(!(t.name==="AbortError"||t.message==="Fetch is aborted"||t.message==="signal is aborted without reason"||t.message==="component unmounted"||s==="component unmounted"))throw console.error("Agent execution failed:",t),t}return{}}))}async onFinalize(e,t){let n=await X(t,this.messages,this.state,(r,o,s)=>r.onRunFinalized?.({messages:o,state:s,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages!==void 0&&(this.messages=n.messages,t.forEach(r=>{r.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state!==void 0&&(this.state=n.state,t.forEach(r=>{r.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}clone(){let e=Object.create(Object.getPrototypeOf(this));return e.agentId=this.agentId,e.description=this.description,e.threadId=this.threadId,e.messages=B(this.messages),e.state=B(this.state),e._debug=this._debug,e._debugLogger=this._debugLogger,e.isRunning=this.isRunning,e.subscribers=[...this.subscribers],e.middlewares=[...this.middlewares],e.pendingInterrupts=B(this.pendingInterrupts),e}addMessage(e){this.messages.push(e),(async()=>{for(let t of this.subscribers)await t.onNewMessage?.({message:e,messages:this.messages,state:this.state,agent:this});if(e.role==="assistant"&&e.toolCalls)for(let t of e.toolCalls)for(let n of this.subscribers)await n.onNewToolCall?.({toolCall:t,messages:this.messages,state:this.state,agent:this});for(let t of this.subscribers)await t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}addMessages(e){this.messages.push(...e),(async()=>{for(let t of e){for(let n of this.subscribers)await n.onNewMessage?.({message:t,messages:this.messages,state:this.state,agent:this});if(t.role==="assistant"&&t.toolCalls)for(let n of t.toolCalls)for(let r of this.subscribers)await r.onNewToolCall?.({toolCall:n,messages:this.messages,state:this.state,agent:this})}for(let t of this.subscribers)await t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setMessages(e){this.messages=B(e),(async()=>{for(let t of this.subscribers)await t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(e){this.state=B(e),(async()=>{for(let t of this.subscribers)await t.onStateChanged?.({messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(e){this.agentId=this.agentId??ht();let t=this.prepareRunAgentInput(e);return(this.middlewares.length===0?this.run(t):this.middlewares.reduceRight((n,r)=>({run:o=>r.run(o,n),get messages(){return n.messages},get state(){return n.state}}),this).run(t)).pipe(Yo(this.debugLogger),Ri(this.debugLogger),_m(this.threadId,t.runId,this.agentId),n=>n.pipe(jt(r=>(this.debugLogger?.event("LEGACY","Event:",r,{type:r.type}),r))))}},Vc=class extends Pm{requestInit(e){return{method:"POST",headers:{...this.headers,"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(e),signal:this.abortController.signal}}runAgent(e,t){return this.abortController=e?.abortController??new AbortController,super.runAgent(e,t)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(e){super(e),this.abortController=new AbortController,this.url=e.url,this.headers=B(e.headers??{}),this.fetch=e.fetch??fetch}run(e){return cm(im(()=>this.fetch(this.url,this.requestInit(e))),this.debugLogger)}clone(){let e=super.clone();e.url=this.url,e.headers=B(this.headers??{}),e.fetch=this.fetch;let t=new AbortController,n=this.abortController.signal;return n.aborted&&t.abort(n.reason),e.abortController=t,e}};var er=class{#e;#n;#i;#u;#a;#o;constructor(t){this.#e=t.agent,this.#n=t.handlers,this.#i=t.getTools??(()=>[]),this.#u=t.getContext??(()=>[]),this.#a=t.executeTool??null,this.#o=t.onPersist??(()=>{})}get running(){return this.#e.isRunning}get messages(){return this.#e.messages}async send(t){this.#e.addMessage({id:ze(),role:"user",content:t}),this.#o(this.#e.messages),await this.#t()}async resume(){await this.#t()}addToolResult(t,n){this.#e.addMessage({id:ze(),role:"tool",content:n,toolCallId:t}),this.#o(this.#e.messages)}async#t(){try{await this.#r()}catch(t){this.#n.onError(t instanceof Error?t.message:String(t))}finally{this.#n.onSettled()}}async#r(){for(let t=0;t<bs;t+=1){let n=[];if(await this.#e.runAgent({tools:this.#i(),context:this.#u()},this.#s(n)),this.#o(this.#e.messages),this.#a===null||n.length===0)return;let r=!1;for(let o of n){let s=await this.#a(o);if(s!==null){if(s.halt===!0)return;this.#e.addMessage({id:ze(),role:"tool",content:s.content,toolCallId:o.id}),this.#o(this.#e.messages),r=!0}}if(!r)return}}#s(t){let n=this.#n;return{onRunInitialized(){n.onRunStart()},onTextMessageContentEvent({textMessageBuffer:r}){n.onTextDelta(r)},onTextMessageEndEvent({textMessageBuffer:r}){n.onTextEnd(r)},onToolCallEndEvent({event:r,toolCallName:o,toolCallArgs:s}){let i={id:r.toolCallId,name:o,args:s};t.push(i),n.onToolCall(i)},onToolCallResultEvent({event:r}){n.onToolResult(r.toolCallId,r.content)},onRunErrorEvent({event:r}){n.onError(r.message)},onRunFinalized(){n.onRunEnd()}}}};var Li="ag-ui-chat:thread",Pi="ag-ui-chat:messages:",Di="ag-ui-chat:checkpoint:",tr=class{threadId(){let t=sessionStorage.getItem(Li);if(t!==null)return t;let n=ze();return sessionStorage.setItem(Li,n),n}loadMessages(t){return Promise.resolve(this.#e(Pi+t))}saveMessages(t,n){sessionStorage.setItem(Pi+t,JSON.stringify(n))}loadCheckpoint(t){return this.#e(Di+t)}saveCheckpoint(t,n){let r=Di+t;if(n===null){sessionStorage.removeItem(r);return}sessionStorage.setItem(r,JSON.stringify(n))}clear(t){sessionStorage.removeItem(Pi+t),sessionStorage.removeItem(Di+t),sessionStorage.removeItem(Li)}#e(t){let n=sessionStorage.getItem(t);if(n===null)return null;try{return JSON.parse(n)}catch{return null}}};function Ui(e){return new Vc({url:e.endpoint,headers:e.headers??{},fetch:(t,n)=>fetch(t,n),...e.threadId!==void 0?{threadId:e.threadId}:{},...e.initialMessages!==void 0?{initialMessages:[...e.initialMessages]}:{}})}var jc="ag-ui-chat:collapsed",nr=class extends HTMLElement{agentFactory=Ui;headers={};autoConfirm=!1;confirmPredicate=null;getTools=()=>[...this.#k().map(t=>({name:t.name,description:t.description,parameters:t.parameters})),...this.#n.tools()];getContext=()=>Ts(this.getPageMap,this.autoInjectPageMap);routeMap=[];navigate=null;getPageMap=null;autoInjectPageMap=!0;conversationStore=new tr;navigationResult=()=>({navigated:!0,url:window.location.href});skillContext=()=>({});toolSummaries={};#e={};#n=new On;#i=new Map;#u=new Set;#a;#o;#t;#r;#s;#f;#l;#p;#m=null;#d=null;#y=0;#g=null;#c="";#b=[];#T=[];#S=[];#w=[];constructor(){super(),this.#a=this.attachShadow({mode:"open"}),this.#o=document.createElement("div"),this.#t=document.createElement("div"),this.#r=document.createElement("textarea"),this.#s=document.createElement("button"),this.#f=document.createElement("span"),this.#p=document.createElement("div"),this.#l=new wr(t=>this.#U(t))}static get observedAttributes(){return["title-text"]}attributeChangedCallback(t,n,r){this.#f.textContent=r??"Assistant"}registerTool(t){this.#n.register(t)}registerStateHook(t){for(let n of ks(t))this.#n.register(n)}#R(){return this.routeMap.length===0?[]:ws(()=>this.routeMap,()=>this.navigate)}#O(){let t=this.getPageMap;return t===null?[]:[{name:"read_page",description:"Read the current page's structure (fields, buttons, route). Call after acting to observe the result within the same turn.",parameters:{type:"object",properties:{},required:[],[Xe]:"Read the page"},handler:()=>t()}]}#k(){return[...this.#R(),...this.#O()]}#A(t){let n=this.#k().find(r=>r.name===t);return n!==void 0?n:this.#n.has(t)?this.#n.get(t):null}get endpoint(){return this.getAttribute("endpoint")??""}set endpoint(t){this.setAttribute("endpoint",t)}get toolDisplay(){let t=this.getAttribute("data-tool-display");return t===Ze.MINIMAL||t===Ze.COMPACT?t:Ze.FULL}set toolDisplay(t){this.setAttribute("data-tool-display",t)}connectedCallback(){this.#z(),sessionStorage.getItem(jc)==="1"&&this.setAttribute("collapsed",""),this.#L(),this.#M(),this.#c=this.conversationStore.threadId(),this.#G()}async#M(){let t=this.getAttribute("data-tools-url");if(t!==null)try{let n=await fetch(t,{headers:this.headers});this.#e=Ss(await n.json())}catch{}}setSkills(t){this.#w=t,this.#x()}#L(){this.#l.enableChips(this.getAttribute("data-prompt-chips")==="true"),this.#l.enableSlash(this.getAttribute("data-slash-commands")==="true"),this.#S=this.#P(),this.#x(),this.#D()}#P(){let t=this.getAttribute("data-skills");if(t===null)return[];try{return xs(JSON.parse(t))}catch{return[]}}async#D(){let t=this.getAttribute("data-skills-url");if(t!==null)try{let n=await fetch(t,{headers:this.headers});this.#T=xs(await n.json()),this.#x()}catch{}}#x(){let t=new Map;for(let n of[...this.#T,...this.#S,...this.#w])t.set(n.name,n);this.#l.setSkills([...t.values()])}#U(t){let{text:n,missing:r}=ma(t.prompt,this.skillContext());if(r.length>0){this.#p.textContent=`\u201C${t.title}\u201D needs: ${r.join(", ")}`,this.#p.hidden=!1;return}this.#p.hidden=!0,this.#r.value=n,t.sendImmediately===!0?this.#E():this.#r.focus()}get collapsed(){return this.hasAttribute("collapsed")}set collapsed(t){this.setCollapsed(t)}setCollapsed(t){t?this.setAttribute("collapsed",""):this.removeAttribute("collapsed"),sessionStorage.setItem(jc,t?"1":"0"),this.dispatchEvent(new CustomEvent(vs,{detail:{collapsed:t},bubbles:!0,composed:!0}))}toggleCollapsed(){this.setCollapsed(!this.collapsed)}newChat(){this.conversationStore.clear(this.#c),this.#m=null,this.#d=null,this.#h(),this.#i.clear(),this.#u.clear(),this.#b=[],this.#t.replaceChildren(),this.#c=this.conversationStore.threadId(),this.#s.disabled=!1}async#G(){let t=await this.conversationStore.loadMessages(this.#c);if(t!==null){this.#b=t;for(let r of t)this.#F(r)}let n=this.conversationStore.loadCheckpoint(this.#c);n!==null&&await this.#$(n)}#F(t){let n=typeof t.content=="string"?t.content:"";if(t.role===We.USER){n!==""&&this.appendMessage(We.USER,n);return}if(t.role===We.ASSISTANT){n!==""&&this.appendMessage(We.ASSISTANT,n).classList.add("message--restored");let r=t.toolCalls;if(r!==void 0)for(let o of r)this.#_({id:o.id,name:o.function.name,args:this.#H(o.function.arguments)});return}if(t.role==="tool"){let r=this.#i.get(t.toolCallId);r!==void 0&&r.settle(de.DONE,t.content)}}#H(t){try{let n=JSON.parse(t);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#I(t){this.getAttribute("data-text-animation")==="word"&&Qa(t)}async#$(t){this.conversationStore.saveCheckpoint(this.#c,null);let n=this.#C();n.addToolResult(t.toolCallId,JSON.stringify(this.navigationResult(t))),await n.resume()}appendMessage(t,n){let r=document.createElement("div");return r.className=`message message--${t}`,t===We.ASSISTANT?r.innerHTML=Sr(n):r.textContent=n,this.#t.appendChild(r),this.#t.scrollTop=this.#t.scrollHeight,r}#z(){let t=document.createElement("style");t.textContent=el,this.#o.className="chat";let n=document.createElement("div");n.className="header";let r=this.#f;r.className="header-title",r.textContent=this.getAttribute("title-text")??"Assistant";let o=document.createElement("div");o.className="header-controls";let s=document.createElement("button");s.type="button",s.className="header-btn header-btn--new",s.title="New chat",s.setAttribute("aria-label","New chat"),s.textContent="\u271A",s.addEventListener("click",()=>this.newChat());let i=document.createElement("button");i.type="button",i.className="header-btn header-btn--collapse",i.title="Collapse",i.setAttribute("aria-label","Collapse"),i.textContent="\u2014",i.addEventListener("click",()=>this.toggleCollapsed()),o.append(s,i),n.append(r,o),this.#t.className="messages",this.#t.setAttribute("role","log"),this.#t.setAttribute("aria-live","polite"),this.#t.setAttribute("aria-label","Conversation");let a=document.createElement("div");a.className="input-row",this.#r.className="input",this.#r.setAttribute("aria-label","Message"),this.#r.rows=2,this.#r.placeholder="Ask anything\u2026",this.#r.addEventListener("keydown",u=>this.#V(u)),this.#r.addEventListener("input",()=>this.#B()),this.#s.className="send",this.#s.type="button",this.#s.textContent="Send",this.#s.addEventListener("click",()=>{this.#E()}),this.#p.className="skill-hint",this.#p.hidden=!0,a.append(this.#r,this.#s),this.#o.append(n,this.#t,this.#l.palette,this.#l.chips,this.#p,a),this.#a.append(t,this.#o)}#B(){this.#l.onInput(this.#r.value),this.#p.hidden=!0}#V(t){if(this.#l.onKeydown(t)){t.preventDefault();return}t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.#E())}async#E(){let t=this.#r.value.trim();t!==""&&(this.appendMessage(We.USER,t),this.#r.value="",this.dispatchEvent(new CustomEvent(gs,{detail:{content:t},bubbles:!0,composed:!0})),await this.#j(t))}async#j(t){this.endpoint!==""&&await this.#C().send(t)}#C(){if(this.#m===null){let t=this.agentFactory({endpoint:this.endpoint,headers:this.headers,threadId:this.#c,initialMessages:this.#b});this.#m=new er({agent:t,handlers:this.#Z(),getTools:()=>this.getTools(),getContext:()=>this.getContext(),executeTool:n=>this.#X(n),onPersist:n=>this.conversationStore.saveMessages(this.#c,n)})}return this.#m}async#W(t,n){return this.autoConfirm?!1:this.confirmPredicate!==null?await this.confirmPredicate(t.name,t.args)===!0:Es(n.parameters)}async#X(t){let n=this.#_(t);this.#i.delete(t.id);let r=this.#A(t.name);if(r===null)return this.#u.has(t.id)||n.settle(de.DONE,"No result returned."),null;if(await this.#W(t,r)){let s={toolName:t.name,args:t.args},i=r.parameters[ys];typeof i=="string"&&(s.message=i);let a=As(this.#t,s);if(this.#t.scrollTop=this.#t.scrollHeight,!await a){let c="User declined the action.";return n.settle(de.DECLINED,c),this.#v(),{content:c}}}let o=_s(r.parameters)&&this.navigate===null;o&&this.conversationStore.saveCheckpoint(this.#c,{toolCallId:t.id});try{let s=await r.handler(t.args);if(o)return n.settle(de.DONE,"Navigating\u2026"),{content:"",halt:!0};let i=JSON.stringify(s??null);return n.settle(de.DONE,i),this.#v(),{content:i}}catch(s){o&&this.conversationStore.saveCheckpoint(this.#c,null);let i=s instanceof Error?s.message:String(s);return n.settle(de.ERROR,i),this.#v(),{content:`Error: ${i}`,error:i}}}#Z(){return{onRunStart:()=>{this.#s.disabled=!0,this.#v()},onTextDelta:t=>{this.#h(),this.#N(t),this.#y+=1},onTextEnd:t=>{let n=this.#N(t);this.#y<=1&&this.#I(n),this.#d=null},onToolCall:t=>{this.#h(),this.#_(t)},onToolResult:(t,n)=>{let r=this.#i.get(t);r!==void 0&&(r.settle(de.DONE,n),this.#u.add(t))},onRunEnd:()=>{this.#h(),this.#s.disabled=!1,this.#d=null},onError:t=>{this.#h(),this.#I(this.appendMessage(We.ASSISTANT,`\u26A0\uFE0F ${t}`)),this.#s.disabled=!1,this.#d=null},onSettled:()=>{this.#h(),this.#s.disabled=!1,this.#d=null}}}#v(){if(this.#g!==null)return;let t=document.createElement("div");t.className="pending",t.setAttribute("role","status"),t.setAttribute("aria-label","Assistant is thinking\u2026");for(let n=0;n<3;n+=1){let r=document.createElement("span");r.className="pending-dot",t.appendChild(r)}this.#g=t,this.#t.appendChild(t),this.#t.scrollTop=this.#t.scrollHeight}#h(){this.#g?.remove(),this.#g=null}#N(t){return this.#d===null&&(this.#d=this.appendMessage(We.ASSISTANT,""),this.#y=0),this.#d.innerHTML=Sr(t),this.#t.scrollTop=this.#t.scrollHeight,this.#d}#_(t){let n=this.#i.get(t.id);if(n!==void 0)return n;let r=this.#A(t.name)?.parameters[Xe],o=typeof r=="string"?r:this.toolSummaries[t.name]??this.#e[t.name],s=new Fn(t.name,t.args,this.toolDisplay,o);return this.#i.set(t.id,s),this.#t.appendChild(s.element),this.#t.scrollTop=this.#t.scrollHeight,s}};function Dm(){customElements.get(gr)===void 0&&customElements.define(gr,nr)}function Jo(e,t){return Object.getOwnPropertyDescriptor(e,t).set}var Um=Jo(HTMLInputElement.prototype,"value"),Gm=Jo(HTMLTextAreaElement.prototype,"value"),Fm=Jo(HTMLSelectElement.prototype,"value"),Hm=Jo(HTMLInputElement.prototype,"checked");function Zt(e,t){e instanceof HTMLTextAreaElement?Gm.call(e,t):e instanceof HTMLSelectElement?Fm.call(e,t):Um.call(e,t)}function rr(e,t){Hm.call(e,t)}var Wc="#4f46e5";function Qo(e){return new Promise(t=>{setTimeout(t,e)})}async function Gi(e,t,n={}){let r=n.charDelayMs??35;Zt(e,""),e.dispatchEvent(new Event("input",{bubbles:!0}));for(let o of t)Zt(e,e.value+o),e.dispatchEvent(new Event("input",{bubbles:!0})),r>0&&await Qo(r);e.dispatchEvent(new Event("change",{bubbles:!0}))}async function Fi(e,t={}){let n=t.highlightMs??280,r=e.style.outline,o=e.style.outlineOffset;e.style.outline=`2px solid ${Wc}`,e.style.outlineOffset="2px",await Qo(n),e.style.outline=r,e.style.outlineOffset=o,e.click()}function Kt(e){e.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}async function Hi(e,t={}){let n=t.flashMs??200;e.focus();let r=e.style.boxShadow;e.style.boxShadow="0 0 0 3px rgba(79, 70, 229, 0.4)",await Qo(n),e.style.boxShadow=r}var Xc="0 0 0 3px rgba(79, 70, 229, 0.4)";function Zc(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function $i(e){return e<=0||Zc()?Promise.resolve():Qo(e)}async function zi(e,t={}){let n=t.pressMs??140,r=e.style.transform,o=e.style.transition,s=e.style.boxShadow;e.style.transition="transform 80ms ease",e.style.transform="scale(0.96)",e.style.boxShadow=Xc,await $i(n),e.style.transform=r,e.style.transition=o,e.style.boxShadow=s,e.click()}function $m(e,t){for(let n of Array.from(e.options))if(n.value===t||n.text===t)return n;return null}async function Bi(e,t,n={}){let r=$m(e,t);if(r===null)throw new Error(`no <option> matching "${t}"`);let o=n.highlightMs??220,s=e.style.outline,i=e.style.outlineOffset;e.style.outline=`2px solid ${Wc}`,e.style.outlineOffset="2px",await $i(o),Zt(e,r.value),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.style.outline=s,e.style.outlineOffset=i}async function Vi(e,t,n={}){let r=n.flashMs??200,o=e.style.boxShadow;e.style.boxShadow=Xc,await $i(r),rr(e,t),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0})),e.style.boxShadow=o}async function zm(e,t,n={}){Kt(e),await Hi(e,{flashMs:n.flashMs??0}),await Gi(e,t,n)}async function Bm(e,t={}){Kt(e),await Fi(e,t)}async function Vm(e,t={}){Kt(e),await zi(e,t)}async function jm(e,t,n={}){Kt(e),await Bi(e,t,n)}async function Wm(e,t,n={}){Kt(e),await Vi(e,t,n)}function Xm(e,t){e instanceof HTMLInputElement&&e.type==="checkbox"?rr(e,!!t):Zt(e,String(t)),e.dispatchEvent(new Event("input",{bubbles:!0})),e.dispatchEvent(new Event("change",{bubbles:!0}))}var Zm="0.3.0";export{nr as AgUiChat,er as AgUiClient,On as ClientToolRegistry,gr as ELEMENT_TAG,bs as MAX_TOOL_ROUNDS,We as MESSAGE_ROLE,gs as SUBMIT_EVENT,tr as SessionStorageStore,vs as TOGGLE_EVENT,de as TOOL_CALL_STATUS,Ze as TOOL_DISPLAY,Fn as ToolCallCard,Zm as VERSION,ys as X_CONFIRM_KEY,Nn as X_DESTRUCTIVE_KEY,Rn as X_NAVIGATES_KEY,Xe as X_SUMMARY_KEY,Bm as clickElement,Ui as createHttpAgent,Ts as createPageMapContext,ws as createRouteTools,ks as createStateHookTools,Dm as defineAgUiChat,zm as fillField,Hi as focusWithFlash,Fi as highlightThenClick,Es as isDestructive,_s as isNavigates,Ss as parseToolCatalog,Zc as prefersReducedMotion,Vm as pressButton,zi as pressThenClick,Sr as renderMarkdown,As as requestConfirmation,Kt as scrollIntoCenterView,jm as selectControl,Bi as selectOption,Xm as setControlValue,rr as setNativeChecked,Zt as setNativeValue,Wm as toggleCheckbox,Vi as toggleControl,Gi as typeInto};
705
708
  /*! Bundled license information:
706
709
 
707
710
  dompurify/dist/purify.es.mjs: