@artooi/ag-ui-web-component 0.20.0 → 0.21.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.
- package/CHANGELOG.md +135 -1
- package/README.md +286 -20
- package/dist/ag-ui-web-component.bundle.js +407 -382
- package/dist/ag-ui-web-component.bundle.js.map +4 -4
- package/dist/core/ag_ui_chat.d.ts +82 -1
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/core/create_http_agent.d.ts +9 -0
- package/dist/core/create_http_agent.d.ts.map +1 -1
- package/dist/core/remote_conversation_store.d.ts +8 -1
- package/dist/core/remote_conversation_store.d.ts.map +1 -1
- package/dist/core/run_index.d.ts +8 -1
- package/dist/core/run_index.d.ts.map +1 -1
- package/dist/core/transcribe_audio.d.ts +7 -0
- package/dist/core/transcribe_audio.d.ts.map +1 -1
- package/dist/core/upload_attachment.d.ts +9 -0
- package/dist/core/upload_attachment.d.ts.map +1 -1
- package/dist/core/utils.d.ts +12 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/dom/animations.d.ts +51 -11
- package/dist/dom/animations.d.ts.map +1 -1
- package/dist/dom/dom_driver.d.ts +12 -7
- package/dist/dom/dom_driver.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +766 -430
- package/dist/index.js.map +3 -3
- package/dist/ui/styles.d.ts +1 -1
- package/dist/ui/styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/ag_ui_chat.ts +292 -31
- package/src/core/create_http_agent.ts +14 -3
- package/src/core/remote_conversation_store.ts +25 -6
- package/src/core/run_index.ts +27 -5
- package/src/core/transcribe_audio.ts +20 -5
- package/src/core/upload_attachment.ts +13 -0
- package/src/core/utils.ts +18 -0
- package/src/dom/animations.ts +175 -31
- package/src/dom/dom_driver.ts +18 -12
- package/src/index.ts +2 -0
- package/src/ui/styles.ts +377 -352
- package/src/version.ts +1 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var Rd=Object.defineProperty;var $i=(t,e)=>{for(var n in e)Rd(t,n,{get:e[n],enumerable:!0})};var Rr="ag-ui-chat",Bi="ag-ui-submit",Vi="ag-ui-toggle",ji="ag-ui-state",qi="ag-ui-attachments",Ve={USER:"user",ASSISTANT:"assistant"},zn="x-destructive",Wi="x-confirm",Le="x-summary",Fn="x-navigates",Xi="read_page",Yi=10,pe={PENDING:"pending",DONE:"done",ERROR:"error",DECLINED:"declined"},Pe={UPLOADING:"uploading",READY:"ready",ERROR:"error"},Ki=10*1024*1024,dn={INLINE:"inline",MINIMAL:"minimal",COMPACT:"compact",FULL:"full"},Zi="compaction",Ji="load_capability";var Nd=/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;function sl(t,e){let n=[];return{text:t.replace(Nd,(o,i)=>{let s=e[i];return s==null||s===""?(n.includes(i)||n.push(i),o):String(s)}),missing:n}}function Od(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.name=="string"&&typeof e.title=="string"&&(e.prompt===void 0||typeof e.prompt=="string")}function Qi(t){return Array.isArray(t)?t.filter(Od):[]}var $n=class{#n=new Map;register(e){this.#n.set(e.name,e)}has(e){return this.#n.has(e)}get(e){let n=this.#n.get(e);if(n===void 0)throw new Error(`tool "${e}" is not registered`);return n}tools(){return[...this.#n.values()].map(e=>({name:e.name,description:e.description,parameters:e.parameters}))}};function es(t){return t[zn]===!0}function Nr(t){return t[Fn]===!0}function Or(t,e){return Object.getOwnPropertyDescriptor(t,e).set}var Md=Or(HTMLInputElement.prototype,"value"),Ld=Or(HTMLTextAreaElement.prototype,"value"),Pd=Or(HTMLSelectElement.prototype,"value"),Dd=Or(HTMLInputElement.prototype,"checked");function Rt(t,e){t instanceof HTMLTextAreaElement?Ld.call(t,e):t instanceof HTMLSelectElement?Pd.call(t,e):Md.call(t,e)}function Bn(t,e){Dd.call(t,e)}var al="#4f46e5";function Mr(t){return new Promise(e=>{setTimeout(e,t)})}async function ts(t,e,n={}){let r=n.charDelayMs??35;Rt(t,""),t.dispatchEvent(new Event("input",{bubbles:!0}));for(let o of e)Rt(t,t.value+o),t.dispatchEvent(new Event("input",{bubbles:!0})),r>0&&await Mr(r);t.dispatchEvent(new Event("change",{bubbles:!0}))}async function ns(t,e={}){let n=e.highlightMs??280,r=t.style.outline,o=t.style.outlineOffset;t.style.outline=`2px solid ${al}`,t.style.outlineOffset="2px",await Mr(n),t.style.outline=r,t.style.outlineOffset=o,t.click()}function at(t){t.scrollIntoView({block:"center",inline:"nearest",behavior:"smooth"})}async function rs(t,e={}){let n=e.flashMs??200;t.focus();let r=t.style.boxShadow;t.style.boxShadow="0 0 0 3px rgba(79, 70, 229, 0.4)",await Mr(n),t.style.boxShadow=r}var ll="0 0 0 3px rgba(79, 70, 229, 0.4)";function cl(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function os(t){return t<=0||cl()?Promise.resolve():Mr(t)}async function is(t,e={}){let n=e.pressMs??140,r=t.style.transform,o=t.style.transition,i=t.style.boxShadow;t.style.transition="transform 80ms ease",t.style.transform="scale(0.96)",t.style.boxShadow=ll,await os(n),t.style.transform=r,t.style.transition=o,t.style.boxShadow=i,t.click()}function Ud(t,e){for(let n of Array.from(t.options))if(n.value===e||n.text===e)return n;return null}async function ss(t,e,n={}){let r=Ud(t,e);if(r===null)throw new Error(`no <option> matching "${e}"`);let o=n.highlightMs??220,i=t.style.outline,s=t.style.outlineOffset;t.style.outline=`2px solid ${al}`,t.style.outlineOffset="2px",await os(o),Rt(t,r.value),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),t.style.outline=i,t.style.outlineOffset=s}async function as(t,e,n={}){let r=n.flashMs??200,o=t.style.boxShadow;t.style.boxShadow=ll,await os(r),Bn(t,e),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),t.style.boxShadow=o}var ls={SCROLL:"scroll",DRAG:"drag"};function cs(t,e){let n=[];return t.has(ls.SCROLL)&&n.push(Hd(e)),t.has(ls.DRAG)&&n.push(Gd(e)),n}function Hd(t){return{name:"scroll_to",description:"Scroll a target into view. `target` is `top`, `bottom`, or a CSS selector / page-map element id. Read-only: it changes nothing on the page.",parameters:{type:"object",properties:{target:{type:"string"}},required:["target"],[Le]:"Scroll into view"},handler:e=>{let n=String(e.target??"");if(n==="top"||n==="bottom"){let o=n==="top"?0:document.body.scrollHeight;return window.scrollTo({top:o,behavior:"smooth"}),{scrolled:!0,target:n}}let r=t(n);if(r===null)throw new Error(`no element matching "${n}"`);return at(r),{scrolled:!0,target:n}}}}function Gd(t){return{name:"drag_and_drop",description:"Drag the `from` element onto the `to` element (CSS selectors or page-map element ids), firing the page's native drag-and-drop. Use for reordering sortable lists. The page decides what the drop commits.",parameters:{type:"object",properties:{from:{type:"string"},to:{type:"string"}},required:["from","to"],[Le]:"Drag and drop"},handler:e=>{let n=String(e.from??""),r=String(e.to??""),o=t(n);if(o===null)throw new Error(`no element matching "${n}"`);let i=t(r);if(i===null)throw new Error(`no element matching "${r}"`);return zd(o,i),{dragged:!0,from:n,to:r}}}}function zd(t,e){let n=new DataTransfer;Vn(t,"dragstart",n),Vn(e,"dragenter",n),Vn(e,"dragover",n),Vn(e,"drop",n),Vn(t,"dragend",n)}function Vn(t,e,n){let r=new Event(e,{bubbles:!0,cancelable:!0});r.dataTransfer=n,t.dispatchEvent(r)}function us(t,e){return!e||t===null?[]:[{description:"page_map",value:JSON.stringify(t())}]}function Lr(t){let e=[{name:`read_${t.name}`,description:`Read the "${t.name}" state.`,parameters:{type:"object",properties:{},required:[],[Le]:`Read ${t.name}`},handler:()=>t.read()}],n=t.write;return n!==void 0&&e.push({name:`set_${t.name}`,description:`Update the "${t.name}" state.`,parameters:{...t.schema??{type:"object"},[zn]:!0,[Le]:`Update ${t.name}`},handler:r=>n(r)}),e}var Fd=Lr;function ds(t){let e={};if(!Array.isArray(t))return e;for(let n of t){if(n===null||typeof n!="object")continue;let r=n,o=r.name,i=r.summary;typeof o=="string"&&typeof i=="string"&&(e[o]=i)}return e}var ul=/:([A-Za-z_][A-Za-z0-9_]*)/g;function $d(t){return[...t.matchAll(ul)].map(e=>e[0].slice(1))}function Bd(t,e,n){let r={...n};return{path:e.replace(ul,(i,s)=>{let a=n[s];if(a==null||String(a)==="")throw new Error(`route "${t}" requires path param "${s}"`);return delete r[s],encodeURIComponent(String(a))}),leftover:r}}function Vd(t,e){let n=new URLSearchParams;for(let[o,i]of Object.entries(e))n.set(o,String(i));let r=n.toString();return r===""?t:`${t}?${r}`}function ps(t,e){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:[],[Le]:"List pages"},handler:()=>t().map(n=>({...n,pathParams:$d(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"],[Fn]:!0,[Le]:"Navigate"},handler:n=>{let r=n.route_id,o=t().find(h=>h.id===r);if(o===void 0)throw new Error(`unknown route "${String(r)}"`);let i=n.params??{},{path:s,leftover:a}=Bd(o.id,o.path,i),l=Vd(s,a),c=e();return c!==null?c(l):window.location.assign(l),{navigated:!0,path:l}}}]}var ae={title:"Assistant",chatHistory:"Chat history",newChat:"New chat",collapse:"Collapse",expand:"Expand",toggleTheme:"Toggle theme",copyCode:"Copy",copied:"Copied",copyFailed:"Copy failed",checkpoints:"Continue a run",noCheckpoints:"Nothing to continue yet.",resumeRun:"Resume",forkRun:"Fork",forkedRun:"branched",conversation:"Conversation",thinking:"Assistant is thinking\u2026",thoughts:"Thoughts",stopped:"\u23F9 Stopped",connectionLost:"Connection lost",noResult:"No result returned.",declinedAction:"User declined the action.",navigating:"Navigating\u2026",historyCompacted:"Earlier turns condensed to fit the context window ({count} removed)",usingSkill:"Using skill {name}",runInterrupted:"The previous response didn\u2019t finish \u2014 the page changed before it arrived.",pageMoved:"The page changed since you last looked at it. Call read_page to see the current page, then retry.",attachmentsStillUploading:"{n} file still uploading \u2014 it was not sent with this message and is still attached.",skillNeeds:"\u201C{title}\u201D needs {fields} \u2014 fill it in below, then send.",message:"Message",inputPlaceholder:"Ask anything\u2026",send:"Send",stop:"Stop",attachFiles:"Attach files",recordVoice:"Record voice",stopRecording:"Stop recording",transcribing:"Transcribing\u2026",transcriptionFailed:"Transcription failed",toolRunning:"running\u2026",toolDone:"\u2713 done",toolError:"\u26A0 error",toolDeclined:"\u2298 declined",resizePanel:"Resize the chat panel",decisionApproved:"approved by you",decisionDeclined:"declined by you",argumentsLabel:"Arguments",resultLabel:"Result",errorLabel:"Error",declinedLabel:"Declined",details:"Details",confirmAction:"Confirm action",confirmRun:"Run \u201C{tool}\u201D?",confirm:"Confirm",cancel:"Cancel",approveAction:"Approve action",approvalPrompt:"Approve this action?",approve:"Approve",deny:"Deny",askUserAction:"Question",otherOption:"Other\u2026",answerPlaceholder:"Type your answer\u2026",submit:"Submit",chats:"Chats",noConversations:"No conversations yet.",rename:"Rename",renameConversation:"Rename conversation",delete:"Delete",deleteConversation:"Delete conversation",deletePrompt:"Delete?",tooLarge:"Too large (max {size})",fileTypeNotAllowed:"File type not allowed",uploadFailed:"upload failed",retry:"Retry",retryUpload:"Retry upload",remove:"Remove",removeAttachment:"Remove attachment",justNow:"just now",minutesAgo:"{n}m ago",hoursAgo:"{n}h ago",daysAgo:"{n}d ago",weeksAgo:"{n}w ago"};function hs(t){let e={...ae};for(let n of Object.keys(t)){let r=t[n];r!==void 0&&(e[n]=r)}return e}function dl(t,e){let n=document.createElement("button");return n.type="button",n.className=`approval-btn approval-btn--${t}`,n.setAttribute("part",`approval-button approval-${t}`),n.textContent=e,n}function fs(t,e,n={}){let r=n.strings??ae;return new Promise(o=>{let i=document.createElement("div");i.className="approval",i.setAttribute("part","approval"),e.toolName!==void 0&&i.setAttribute("data-tool-name",e.toolName),i.setAttribute("role","group"),i.setAttribute("aria-label",r.approveAction);let s=document.createElement("div");s.className="approval-body",s.setAttribute("part","approval-body"),s.textContent=e.message??r.approvalPrompt;let a=document.createElement("div");a.className="approval-actions",a.setAttribute("part","approval-actions");let l=dl("deny",r.deny),c=dl("approve",r.approve),h=!1,m=y=>{h||(h=!0,l.disabled=!0,c.disabled=!0,i.setAttribute("data-resolved",y?"approved":"denied"),o(y))};if(l.addEventListener("click",()=>m(!1)),c.addEventListener("click",()=>m(!0)),n.signal?.addEventListener("abort",()=>m(!1),{once:!0}),a.append(l,c),i.append(s,a),t.appendChild(i),n.signal?.aborted===!0){m(!1);return}c.focus()})}function ms(t,e){for(let n of Array.from(t.querySelectorAll("pre"))){let r=n.querySelector("code");r===null||n.querySelector(".code-copy")!==null||(n.classList.add("has-copy"),n.append(jd(r,e)))}}function jd(t,e){let n=t.textContent,r=document.createElement("button");return r.type="button",r.className="code-copy",r.setAttribute("part","code-copy"),r.textContent=e.copyCode,r.title=e.copyCode,r.setAttribute("aria-label",e.copyCode),r.addEventListener("click",()=>{qd(n).then(o=>{Wd(r,o?e.copied:e.copyFailed,e)})}),r}async function qd(t){let e=navigator.clipboard;if(e===void 0)return!1;try{return await e.writeText(t),!0}catch{return!1}}function Wd(t,e,n){t.textContent=e,t.dataset.state=e===n.copied?"copied":"failed",setTimeout(()=>{t.textContent=n.copyCode,delete t.dataset.state},1500)}function gs(t){let e=document.createElement("div");e.className="attachment-chips",e.setAttribute("part","attachment-chips");for(let n of t)e.appendChild(Xd(n));return e}function Xd(t){let e=document.createElement("div");e.className="attachment-chip attachment-chip--ready",e.setAttribute("part","attachment-chip");let n=document.createElement("span");n.className="attachment-chip-icon",n.setAttribute("part","attachment-chip-icon"),n.textContent=vs(t.mime),n.setAttribute("aria-hidden","true");let r=document.createElement("span");r.className="attachment-chip-name",r.setAttribute("part","attachment-chip-name"),r.textContent=t.name,r.title=t.name;let o=document.createElement("span");return o.className="attachment-chip-size",o.setAttribute("part","attachment-chip-size"),o.textContent=Pr(t.size),e.append(n,r,o),e}function vs(t){return t.startsWith("image/")?"\u{1F5BC}":t==="application/pdf"?"\u{1F4D5}":t.startsWith("text/")?"\u{1F4C4}":"\u{1F4CE}"}function Pr(t){if(t<1024)return`${t} B`;let e=["KB","MB","GB"],n=t/1024,r=0;for(;n>=1024&&r<e.length-1;)n/=1024,r+=1;return`${n<10?Math.round(n*10)/10:Math.round(n)} ${e[r]}`}var xe=[];for(let t=0;t<256;++t)xe.push((t+256).toString(16).slice(1));function pl(t,e=0){return(xe[t[e+0]]+xe[t[e+1]]+xe[t[e+2]]+xe[t[e+3]]+"-"+xe[t[e+4]]+xe[t[e+5]]+"-"+xe[t[e+6]]+xe[t[e+7]]+"-"+xe[t[e+8]]+xe[t[e+9]]+"-"+xe[t[e+10]]+xe[t[e+11]]+xe[t[e+12]]+xe[t[e+13]]+xe[t[e+14]]+xe[t[e+15]]).toLowerCase()}var bs,Yd=new Uint8Array(16);function ys(){if(!bs){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");bs=crypto.getRandomValues.bind(crypto)}return bs(Yd)}var Kd=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),xs={randomUUID:Kd};function Zd(t,e,n){if(xs.randomUUID&&!e&&!t)return xs.randomUUID();t=t||{};let r=t.random??t.rng?.()??ys();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,e){if(n=n||0,n<0||n+16>e.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let o=0;o<16;++o)e[n+o]=r[o];return e}return pl(r)}var yt=Zd;var u={};$i(u,{BRAND:()=>wp,DIRTY:()=>Nt,EMPTY_PATH:()=>tp,INVALID:()=>P,NEVER:()=>ah,OK:()=>_e,ParseStatus:()=>Ee,Schema:()=>$,ZodAny:()=>Tt,ZodArray:()=>dt,ZodBigInt:()=>Mt,ZodBoolean:()=>Lt,ZodBranded:()=>qn,ZodCatch:()=>jt,ZodDate:()=>Pt,ZodDefault:()=>Vt,ZodDiscriminatedUnion:()=>Hr,ZodEffects:()=>Fe,ZodEnum:()=>$t,ZodError:()=>Ne,ZodFirstPartyTypeKind:()=>D,ZodFunction:()=>zr,ZodIntersection:()=>Gt,ZodIssueCode:()=>T,ZodLazy:()=>zt,ZodLiteral:()=>Ft,ZodMap:()=>vn,ZodNaN:()=>yn,ZodNativeEnum:()=>Bt,ZodNever:()=>je,ZodNull:()=>Ut,ZodNullable:()=>nt,ZodNumber:()=>Ot,ZodObject:()=>Oe,ZodOptional:()=>Ge,ZodParsedType:()=>I,ZodPipeline:()=>Wn,ZodPromise:()=>wt,ZodReadonly:()=>qt,ZodRecord:()=>Gr,ZodSchema:()=>$,ZodSet:()=>bn,ZodString:()=>Et,ZodSymbol:()=>mn,ZodTransformer:()=>Fe,ZodTuple:()=>tt,ZodType:()=>$,ZodUndefined:()=>Dt,ZodUnion:()=>Ht,ZodUnknown:()=>ut,ZodVoid:()=>gn,addIssueToContext:()=>k,any:()=>Op,array:()=>Dp,bigint:()=>kp,boolean:()=>wl,coerce:()=>sh,custom:()=>xl,date:()=>Ip,datetimeRegex:()=>bl,defaultErrorMap:()=>lt,discriminatedUnion:()=>zp,effect:()=>Jp,enum:()=>Yp,function:()=>qp,getErrorMap:()=>pn,getParsedType:()=>et,instanceof:()=>_p,intersection:()=>Fp,isAborted:()=>Dr,isAsync:()=>hn,isDirty:()=>Ur,isValid:()=>xt,late:()=>Sp,lazy:()=>Wp,literal:()=>Xp,makeIssue:()=>jn,map:()=>Vp,nan:()=>Ap,nativeEnum:()=>Kp,never:()=>Lp,null:()=>Np,nullable:()=>eh,number:()=>Tl,object:()=>Up,objectUtil:()=>Es,oboolean:()=>ih,onumber:()=>oh,optional:()=>Qp,ostring:()=>rh,pipeline:()=>nh,preprocess:()=>th,promise:()=>Zp,quotelessJson:()=>Jd,record:()=>Bp,set:()=>jp,setErrorMap:()=>ep,strictObject:()=>Hp,string:()=>El,symbol:()=>Cp,transformer:()=>Jp,tuple:()=>$p,undefined:()=>Rp,union:()=>Gp,unknown:()=>Mp,util:()=>V,void:()=>Pp});var V;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function n(o){throw new Error}t.assertNever=n,t.arrayToEnum=o=>{let i={};for(let s of o)i[s]=s;return i},t.getValidEnumValues=o=>{let i=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),s={};for(let a of i)s[a]=o[a];return t.objectValues(s)},t.objectValues=o=>t.objectKeys(o).map(function(i){return o[i]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let i=[];for(let s in o)Object.prototype.hasOwnProperty.call(o,s)&&i.push(s);return i},t.find=(o,i)=>{for(let s of o)if(i(s))return s},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,i=" | "){return o.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(o,i)=>typeof i=="bigint"?i.toString():i})(V||(V={}));var Es;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Es||(Es={}));var I=V.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),et=t=>{switch(typeof t){case"undefined":return I.undefined;case"string":return I.string;case"number":return Number.isNaN(t)?I.nan:I.number;case"boolean":return I.boolean;case"function":return I.function;case"bigint":return I.bigint;case"symbol":return I.symbol;case"object":return Array.isArray(t)?I.array:t===null?I.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?I.promise:typeof Map<"u"&&t instanceof Map?I.map:typeof Set<"u"&&t instanceof Set?I.set:typeof Date<"u"&&t instanceof Date?I.date:I.object;default:return I.unknown}};var T=V.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"]),Jd=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Ne=class t extends Error{get errors(){return this.issues}constructor(e){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=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},o=i=>{for(let s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(o);else if(s.code==="invalid_return_type")o(s.returnTypeError);else if(s.code==="invalid_arguments")o(s.argumentsError);else if(s.path.length===0)r._errors.push(n(s));else{let a=r,l=0;for(;l<s.path.length;){let c=s.path[l];l===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(s))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return o(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,V.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let o of this.issues)if(o.path.length>0){let i=o.path[0];n[i]=n[i]||[],n[i].push(e(o))}else r.push(e(o));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};Ne.create=t=>new Ne(t);var Qd=(t,e)=>{let n;switch(t.code){case T.invalid_type:t.received===I.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case T.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,V.jsonStringifyReplacer)}`;break;case T.unrecognized_keys:n=`Unrecognized key(s) in object: ${V.joinValues(t.keys,", ")}`;break;case T.invalid_union:n="Invalid input";break;case T.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${V.joinValues(t.options)}`;break;case T.invalid_enum_value:n=`Invalid enum value. Expected ${V.joinValues(t.options)}, received '${t.received}'`;break;case T.invalid_arguments:n="Invalid function arguments";break;case T.invalid_return_type:n="Invalid function return type";break;case T.invalid_date:n="Invalid date";break;case T.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:V.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case T.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case T.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case T.custom:n="Invalid input";break;case T.invalid_intersection_types:n="Intersection results could not be merged";break;case T.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case T.not_finite:n="Number must be finite";break;default:n=e.defaultError,V.assertNever(t)}return{message:n}},lt=Qd;var hl=lt;function ep(t){hl=t}function pn(){return hl}var jn=t=>{let{data:e,path:n,errorMaps:r,issueData:o}=t,i=[...n,...o.path||[]],s={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let a="",l=r.filter(c=>!!c).slice().reverse();for(let c of l)a=c(s,{data:e,defaultError:a}).message;return{...o,path:i,message:a}},tp=[];function k(t,e){let n=pn(),r=jn({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===lt?void 0:lt].filter(o=>!!o)});t.common.issues.push(r)}var Ee=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let o of n){if(o.status==="aborted")return P;o.status==="dirty"&&e.dirty(),r.push(o.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let o of n){let i=await o.key,s=await o.value;r.push({key:i,value:s})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let o of n){let{key:i,value:s}=o;if(i.status==="aborted"||s.status==="aborted")return P;i.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof s.value<"u"||o.alwaysSet)&&(r[i.value]=s.value)}return{status:e.value,value:r}}},P=Object.freeze({status:"aborted"}),Nt=t=>({status:"dirty",value:t}),_e=t=>({status:"valid",value:t}),Dr=t=>t.status==="aborted",Ur=t=>t.status==="dirty",xt=t=>t.status==="valid",hn=t=>typeof Promise<"u"&&t instanceof Promise;var R;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(R||(R={}));var ze=class{constructor(e,n,r,o){this._cachedPath=[],this.parent=e,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}},fl=(t,e)=>{if(xt(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new Ne(t.common.issues);return this._error=n,this._error}}};function z(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:o}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(s,a)=>{let{message:l}=t;return s.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:o}}var $=class{get description(){return this._def.description}_getType(e){return et(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:et(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ee,ctx:{common:e.parent.common,data:e.data,parsedType:et(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(hn(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:et(e)},o=this._parseSync({data:e,path:r.path,parent:r});return fl(r,o)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:et(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return xt(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:e,path:[],parent:n}).then(r=>xt(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:et(e)},o=this._parse({data:e,path:r.path,parent:r}),i=await(hn(o)?o:Promise.resolve(o));return fl(r,i)}refine(e,n){let r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,i)=>{let s=e(o),a=()=>i.addIssue({code:T.custom,...r(o)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,o)=>e(r)?!0:(o.addIssue(typeof n=="function"?n(r,o):n),!1))}_refinement(e){return new Fe({schema:this,typeName:D.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ge.create(this,this._def)}nullable(){return nt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dt.create(this)}promise(){return wt.create(this,this._def)}or(e){return Ht.create([this,e],this._def)}and(e){return Gt.create(this,e,this._def)}transform(e){return new Fe({...z(this._def),schema:this,typeName:D.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Vt({...z(this._def),innerType:this,defaultValue:n,typeName:D.ZodDefault})}brand(){return new qn({typeName:D.ZodBranded,type:this,...z(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new jt({...z(this._def),innerType:this,catchValue:n,typeName:D.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Wn.create(this,e)}readonly(){return qt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},np=/^c[^\s-]{8,}$/i,rp=/^[0-9a-z]+$/,op=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ip=/^[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,sp=/^[a-z0-9_-]{21}$/i,ap=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,lp=/^[-+]?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)?)??$/,cp=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,up="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ts,dp=/^(?:(?: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])$/,pp=/^(?:(?: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])$/,hp=/^(([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]))$/,fp=/^(([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])$/,mp=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,gp=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,gl="((\\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])))",vp=new RegExp(`^${gl}$`);function vl(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function bp(t){return new RegExp(`^${vl(t)}$`)}function bl(t){let e=`${gl}T${vl(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function yp(t,e){return!!((e==="v4"||!e)&&dp.test(t)||(e==="v6"||!e)&&hp.test(t))}function xp(t,e){if(!ap.test(t))return!1;try{let[n]=t.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||e&&o.alg!==e)}catch{return!1}}function Ep(t,e){return!!((e==="v4"||!e)&&pp.test(t)||(e==="v6"||!e)&&fp.test(t))}var Et=class t extends ${_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==I.string){let i=this._getOrReturnCtx(e);return k(i,{code:T.invalid_type,expected:I.string,received:i.parsedType}),P}let r=new Ee,o;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:T.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:T.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let s=e.data.length>i.value,a=e.data.length<i.value;(s||a)&&(o=this._getOrReturnCtx(e,o),s?k(o,{code:T.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&k(o,{code:T.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")cp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"email",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Ts||(Ts=new RegExp(up,"u")),Ts.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"emoji",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")ip.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"uuid",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")sp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"nanoid",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")np.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")rp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid2",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")op.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ulid",code:T.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),k(o,{validation:"url",code:T.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"regex",code:T.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(o=this._getOrReturnCtx(e,o),k(o,{code:T.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(o=this._getOrReturnCtx(e,o),k(o,{code:T.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(o=this._getOrReturnCtx(e,o),k(o,{code:T.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?bl(i).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:T.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?vp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:T.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?bp(i).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:T.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?lp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"duration",code:T.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?yp(e.data,i.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ip",code:T.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?xp(e.data,i.alg)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"jwt",code:T.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Ep(e.data,i.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cidr",code:T.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?mp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64",code:T.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?gp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64url",code:T.invalid_string,message:i.message}),r.dirty()):V.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(o=>e.test(o),{validation:n,code:T.invalid_string,...R.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...R.errToObj(e)})}url(e){return this._addCheck({kind:"url",...R.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...R.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...R.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...R.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...R.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...R.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...R.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...R.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...R.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...R.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...R.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...R.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...R.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...R.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...R.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...R.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...R.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...R.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...R.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...R.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...R.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...R.errToObj(n)})}nonempty(e){return this.min(1,R.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Et.create=t=>new Et({checks:[],typeName:D.ZodString,coerce:t?.coerce??!1,...z(t)});function Tp(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,o=n>r?n:r,i=Number.parseInt(t.toFixed(o).replace(".","")),s=Number.parseInt(e.toFixed(o).replace(".",""));return i%s/10**o}var Ot=class t extends ${constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==I.number){let i=this._getOrReturnCtx(e);return k(i,{code:T.invalid_type,expected:I.number,received:i.parsedType}),P}let r,o=new Ee;for(let i of this._def.checks)i.kind==="int"?V.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:T.invalid_type,expected:"integer",received:"float",message:i.message}),o.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),k(r,{code:T.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),k(r,{code:T.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?Tp(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),k(r,{code:T.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:T.not_finite,message:i.message}),o.dirty()):V.assertNever(i);return{status:o.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,R.toString(n))}gt(e,n){return this.setLimit("min",e,!1,R.toString(n))}lte(e,n){return this.setLimit("max",e,!0,R.toString(n))}lt(e,n){return this.setLimit("max",e,!1,R.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:R.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:R.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:R.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:R.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:R.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:R.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:R.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&V.isInteger(e.value))}get isFinite(){let e=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"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};Ot.create=t=>new Ot({checks:[],typeName:D.ZodNumber,coerce:t?.coerce||!1,...z(t)});var Mt=class t extends ${constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==I.bigint)return this._getInvalidInput(e);let r,o=new Ee;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),k(r,{code:T.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),k(r,{code:T.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),k(r,{code:T.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):V.assertNever(i);return{status:o.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return k(n,{code:T.invalid_type,expected:I.bigint,received:n.parsedType}),P}gte(e,n){return this.setLimit("min",e,!0,R.toString(n))}gt(e,n){return this.setLimit("min",e,!1,R.toString(n))}lte(e,n){return this.setLimit("max",e,!0,R.toString(n))}lt(e,n){return this.setLimit("max",e,!1,R.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:R.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:R.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:R.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Mt.create=t=>new Mt({checks:[],typeName:D.ZodBigInt,coerce:t?.coerce??!1,...z(t)});var Lt=class extends ${_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==I.boolean){let r=this._getOrReturnCtx(e);return k(r,{code:T.invalid_type,expected:I.boolean,received:r.parsedType}),P}return _e(e.data)}};Lt.create=t=>new Lt({typeName:D.ZodBoolean,coerce:t?.coerce||!1,...z(t)});var Pt=class t extends ${_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==I.date){let i=this._getOrReturnCtx(e);return k(i,{code:T.invalid_type,expected:I.date,received:i.parsedType}),P}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return k(i,{code:T.invalid_date}),P}let r=new Ee,o;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:T.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:T.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):V.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:R.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:R.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};Pt.create=t=>new Pt({checks:[],coerce:t?.coerce||!1,typeName:D.ZodDate,...z(t)});var mn=class extends ${_parse(e){if(this._getType(e)!==I.symbol){let r=this._getOrReturnCtx(e);return k(r,{code:T.invalid_type,expected:I.symbol,received:r.parsedType}),P}return _e(e.data)}};mn.create=t=>new mn({typeName:D.ZodSymbol,...z(t)});var Dt=class extends ${_parse(e){if(this._getType(e)!==I.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:T.invalid_type,expected:I.undefined,received:r.parsedType}),P}return _e(e.data)}};Dt.create=t=>new Dt({typeName:D.ZodUndefined,...z(t)});var Ut=class extends ${_parse(e){if(this._getType(e)!==I.null){let r=this._getOrReturnCtx(e);return k(r,{code:T.invalid_type,expected:I.null,received:r.parsedType}),P}return _e(e.data)}};Ut.create=t=>new Ut({typeName:D.ZodNull,...z(t)});var Tt=class extends ${constructor(){super(...arguments),this._any=!0}_parse(e){return _e(e.data)}};Tt.create=t=>new Tt({typeName:D.ZodAny,...z(t)});var ut=class extends ${constructor(){super(...arguments),this._unknown=!0}_parse(e){return _e(e.data)}};ut.create=t=>new ut({typeName:D.ZodUnknown,...z(t)});var je=class extends ${_parse(e){let n=this._getOrReturnCtx(e);return k(n,{code:T.invalid_type,expected:I.never,received:n.parsedType}),P}};je.create=t=>new je({typeName:D.ZodNever,...z(t)});var gn=class extends ${_parse(e){if(this._getType(e)!==I.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:T.invalid_type,expected:I.void,received:r.parsedType}),P}return _e(e.data)}};gn.create=t=>new gn({typeName:D.ZodVoid,...z(t)});var dt=class t extends ${_parse(e){let{ctx:n,status:r}=this._processInputParams(e),o=this._def;if(n.parsedType!==I.array)return k(n,{code:T.invalid_type,expected:I.array,received:n.parsedType}),P;if(o.exactLength!==null){let s=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(s||a)&&(k(n,{code:s?T.too_big:T.too_small,minimum:a?o.exactLength.value:void 0,maximum:s?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&&(k(n,{code:T.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&&(k(n,{code:T.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((s,a)=>o.type._parseAsync(new ze(n,s,n.path,a)))).then(s=>Ee.mergeArray(r,s));let i=[...n.data].map((s,a)=>o.type._parseSync(new ze(n,s,n.path,a)));return Ee.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:R.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:R.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:R.toString(n)}})}nonempty(e){return this.min(1,e)}};dt.create=(t,e)=>new dt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...z(e)});function fn(t){if(t instanceof Oe){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Ge.create(fn(r))}return new Oe({...t._def,shape:()=>e})}else return t instanceof dt?new dt({...t._def,type:fn(t.element)}):t instanceof Ge?Ge.create(fn(t.unwrap())):t instanceof nt?nt.create(fn(t.unwrap())):t instanceof tt?tt.create(t.items.map(e=>fn(e))):t}var Oe=class t extends ${constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=V.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==I.object){let c=this._getOrReturnCtx(e);return k(c,{code:T.invalid_type,expected:I.object,received:c.parsedType}),P}let{status:r,ctx:o}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof je&&this._def.unknownKeys==="strip"))for(let c in o.data)s.includes(c)||a.push(c);let l=[];for(let c of s){let h=i[c],m=o.data[c];l.push({key:{status:"valid",value:c},value:h._parse(new ze(o,m,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof je){let c=this._def.unknownKeys;if(c==="passthrough")for(let h of a)l.push({key:{status:"valid",value:h},value:{status:"valid",value:o.data[h]}});else if(c==="strict")a.length>0&&(k(o,{code:T.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 h of a){let m=o.data[h];l.push({key:{status:"valid",value:h},value:c._parse(new ze(o,m,o.path,h)),alwaysSet:h in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let c=[];for(let h of l){let m=await h.key,y=await h.value;c.push({key:m,value:y,alwaysSet:h.alwaysSet})}return c}).then(c=>Ee.mergeObjectSync(r,c)):Ee.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return R.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let o=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:R.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:D.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of V.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of V.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return fn(this)}partial(e){let n={};for(let r of V.objectKeys(this.shape)){let o=this.shape[r];e&&!e[r]?n[r]=o:n[r]=o.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of V.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Ge;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return yl(V.objectKeys(this.shape))}};Oe.create=(t,e)=>new Oe({shape:()=>t,unknownKeys:"strip",catchall:je.create(),typeName:D.ZodObject,...z(e)});Oe.strictCreate=(t,e)=>new Oe({shape:()=>t,unknownKeys:"strict",catchall:je.create(),typeName:D.ZodObject,...z(e)});Oe.lazycreate=(t,e)=>new Oe({shape:t,unknownKeys:"strip",catchall:je.create(),typeName:D.ZodObject,...z(e)});var Ht=class extends ${_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function o(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let s=i.map(a=>new Ne(a.ctx.common.issues));return k(n,{code:T.invalid_union,unionErrors:s}),P}if(n.common.async)return Promise.all(r.map(async i=>{let s={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(o);{let i,s=[];for(let l of r){let c={...n,common:{...n.common,issues:[]},parent:null},h=l._parseSync({data:n.data,path:n.path,parent:c});if(h.status==="valid")return h;h.status==="dirty"&&!i&&(i={result:h,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=s.map(l=>new Ne(l));return k(n,{code:T.invalid_union,unionErrors:a}),P}}get options(){return this._def.options}};Ht.create=(t,e)=>new Ht({options:t,typeName:D.ZodUnion,...z(e)});var ct=t=>t instanceof zt?ct(t.schema):t instanceof Fe?ct(t.innerType()):t instanceof Ft?[t.value]:t instanceof $t?t.options:t instanceof Bt?V.objectValues(t.enum):t instanceof Vt?ct(t._def.innerType):t instanceof Dt?[void 0]:t instanceof Ut?[null]:t instanceof Ge?[void 0,...ct(t.unwrap())]:t instanceof nt?[null,...ct(t.unwrap())]:t instanceof qn||t instanceof qt?ct(t.unwrap()):t instanceof jt?ct(t._def.innerType):[],Hr=class t extends ${_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==I.object)return k(n,{code:T.invalid_type,expected:I.object,received:n.parsedType}),P;let r=this.discriminator,o=n.data[r],i=this.optionsMap.get(o);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(k(n,{code:T.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),P)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let o=new Map;for(let i of n){let s=ct(i.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of s){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,i)}}return new t({typeName:D.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:o,...z(r)})}};function ws(t,e){let n=et(t),r=et(e);if(t===e)return{valid:!0,data:t};if(n===I.object&&r===I.object){let o=V.objectKeys(e),i=V.objectKeys(t).filter(a=>o.indexOf(a)!==-1),s={...t,...e};for(let a of i){let l=ws(t[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(n===I.array&&r===I.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let i=0;i<t.length;i++){let s=t[i],a=e[i],l=ws(s,a);if(!l.valid)return{valid:!1};o.push(l.data)}return{valid:!0,data:o}}else return n===I.date&&r===I.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Gt=class extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(i,s)=>{if(Dr(i)||Dr(s))return P;let a=ws(i.value,s.value);return a.valid?((Ur(i)||Ur(s))&&n.dirty(),{status:n.value,value:a.data}):(k(r,{code:T.invalid_intersection_types}),P)};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(([i,s])=>o(i,s)):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}))}};Gt.create=(t,e,n)=>new Gt({left:t,right:e,typeName:D.ZodIntersection,...z(n)});var tt=class t extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.array)return k(r,{code:T.invalid_type,expected:I.array,received:r.parsedType}),P;if(r.data.length<this._def.items.length)return k(r,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),P;!this._def.rest&&r.data.length>this._def.items.length&&(k(r,{code:T.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((s,a)=>{let l=this._def.items[a]||this._def.rest;return l?l._parse(new ze(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(i).then(s=>Ee.mergeArray(n,s)):Ee.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};tt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new tt({items:t,typeName:D.ZodTuple,rest:null,...z(e)})};var Gr=class t extends ${get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.object)return k(r,{code:T.invalid_type,expected:I.object,received:r.parsedType}),P;let o=[],i=this._def.keyType,s=this._def.valueType;for(let a in r.data)o.push({key:i._parse(new ze(r,a,r.path,a)),value:s._parse(new ze(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Ee.mergeObjectAsync(n,o):Ee.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof $?new t({keyType:e,valueType:n,typeName:D.ZodRecord,...z(r)}):new t({keyType:Et.create(),valueType:e,typeName:D.ZodRecord,...z(n)})}},vn=class extends ${get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.map)return k(r,{code:T.invalid_type,expected:I.map,received:r.parsedType}),P;let o=this._def.keyType,i=this._def.valueType,s=[...r.data.entries()].map(([a,l],c)=>({key:o._parse(new ze(r,a,r.path,[c,"key"])),value:i._parse(new ze(r,l,r.path,[c,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of s){let c=await l.key,h=await l.value;if(c.status==="aborted"||h.status==="aborted")return P;(c.status==="dirty"||h.status==="dirty")&&n.dirty(),a.set(c.value,h.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let l of s){let c=l.key,h=l.value;if(c.status==="aborted"||h.status==="aborted")return P;(c.status==="dirty"||h.status==="dirty")&&n.dirty(),a.set(c.value,h.value)}return{status:n.value,value:a}}}};vn.create=(t,e,n)=>new vn({valueType:e,keyType:t,typeName:D.ZodMap,...z(n)});var bn=class t extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==I.set)return k(r,{code:T.invalid_type,expected:I.set,received:r.parsedType}),P;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(k(r,{code:T.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&&(k(r,{code:T.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),n.dirty());let i=this._def.valueType;function s(l){let c=new Set;for(let h of l){if(h.status==="aborted")return P;h.status==="dirty"&&n.dirty(),c.add(h.value)}return{status:n.value,value:c}}let a=[...r.data.values()].map((l,c)=>i._parse(new ze(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>s(l)):s(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:R.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:R.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};bn.create=(t,e)=>new bn({valueType:t,minSize:null,maxSize:null,typeName:D.ZodSet,...z(e)});var zr=class t extends ${constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==I.function)return k(n,{code:T.invalid_type,expected:I.function,received:n.parsedType}),P;function r(a,l){return jn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,pn(),lt].filter(c=>!!c),issueData:{code:T.invalid_arguments,argumentsError:l}})}function o(a,l){return jn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,pn(),lt].filter(c=>!!c),issueData:{code:T.invalid_return_type,returnTypeError:l}})}let i={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof wt){let a=this;return _e(async function(...l){let c=new Ne([]),h=await a._def.args.parseAsync(l,i).catch(f=>{throw c.addIssue(r(l,f)),c}),m=await Reflect.apply(s,this,h);return await a._def.returns._def.type.parseAsync(m,i).catch(f=>{throw c.addIssue(o(m,f)),c})})}else{let a=this;return _e(function(...l){let c=a._def.args.safeParse(l,i);if(!c.success)throw new Ne([r(l,c.error)]);let h=Reflect.apply(s,this,c.data),m=a._def.returns.safeParse(h,i);if(!m.success)throw new Ne([o(h,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:tt.create(e).rest(ut.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||tt.create([]).rest(ut.create()),returns:n||ut.create(),typeName:D.ZodFunction,...z(r)})}},zt=class extends ${get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};zt.create=(t,e)=>new zt({getter:t,typeName:D.ZodLazy,...z(e)});var Ft=class extends ${_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return k(n,{received:n.data,code:T.invalid_literal,expected:this._def.value}),P}return{status:"valid",value:e.data}}get value(){return this._def.value}};Ft.create=(t,e)=>new Ft({value:t,typeName:D.ZodLiteral,...z(e)});function yl(t,e){return new $t({values:t,typeName:D.ZodEnum,...z(e)})}var $t=class t extends ${_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return k(n,{expected:V.joinValues(r),received:n.parsedType,code:T.invalid_type}),P}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return k(n,{received:n.data,code:T.invalid_enum_value,options:r}),P}return _e(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};$t.create=yl;var Bt=class extends ${_parse(e){let n=V.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==I.string&&r.parsedType!==I.number){let o=V.objectValues(n);return k(r,{expected:V.joinValues(o),received:r.parsedType,code:T.invalid_type}),P}if(this._cache||(this._cache=new Set(V.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=V.objectValues(n);return k(r,{received:r.data,code:T.invalid_enum_value,options:o}),P}return _e(e.data)}get enum(){return this._def.values}};Bt.create=(t,e)=>new Bt({values:t,typeName:D.ZodNativeEnum,...z(e)});var wt=class extends ${unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==I.promise&&n.common.async===!1)return k(n,{code:T.invalid_type,expected:I.promise,received:n.parsedType}),P;let r=n.parsedType===I.promise?n.data:Promise.resolve(n.data);return _e(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};wt.create=(t,e)=>new wt({type:t,typeName:D.ZodPromise,...z(e)});var Fe=class extends ${innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===D.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=this._def.effect||null,i={addIssue:s=>{k(r,s),s.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),o.type==="preprocess"){let s=o.transform(r.data,i);if(r.common.async)return Promise.resolve(s).then(async a=>{if(n.value==="aborted")return P;let l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?P:l.status==="dirty"?Nt(l.value):n.value==="dirty"?Nt(l.value):l});{if(n.value==="aborted")return P;let a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?P:a.status==="dirty"?Nt(a.value):n.value==="dirty"?Nt(a.value):a}}if(o.type==="refinement"){let s=a=>{let l=o.refinement(a,i);if(r.common.async)return Promise.resolve(l);if(l 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"?P:(a.status==="dirty"&&n.dirty(),s(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"?P:(a.status==="dirty"&&n.dirty(),s(a.value).then(()=>({status:n.value,value:a.value}))))}if(o.type==="transform")if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!xt(s))return P;let a=o.transform(s.value,i);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(s=>xt(s)?Promise.resolve(o.transform(s.value,i)).then(a=>({status:n.value,value:a})):P);V.assertNever(o)}};Fe.create=(t,e,n)=>new Fe({schema:t,typeName:D.ZodEffects,effect:e,...z(n)});Fe.createWithPreprocess=(t,e,n)=>new Fe({schema:e,effect:{type:"preprocess",transform:t},typeName:D.ZodEffects,...z(n)});var Ge=class extends ${_parse(e){return this._getType(e)===I.undefined?_e(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ge.create=(t,e)=>new Ge({innerType:t,typeName:D.ZodOptional,...z(e)});var nt=class extends ${_parse(e){return this._getType(e)===I.null?_e(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};nt.create=(t,e)=>new nt({innerType:t,typeName:D.ZodNullable,...z(e)});var Vt=class extends ${_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===I.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Vt.create=(t,e)=>new Vt({innerType:t,typeName:D.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...z(e)});var jt=class extends ${_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return hn(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ne(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ne(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};jt.create=(t,e)=>new jt({innerType:t,typeName:D.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...z(e)});var yn=class extends ${_parse(e){if(this._getType(e)!==I.nan){let r=this._getOrReturnCtx(e);return k(r,{code:T.invalid_type,expected:I.nan,received:r.parsedType}),P}return{status:"valid",value:e.data}}};yn.create=t=>new yn({typeName:D.ZodNaN,...z(t)});var wp=Symbol("zod_brand"),qn=class extends ${_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Wn=class t extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?P:i.status==="dirty"?(n.dirty(),Nt(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?P:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:D.ZodPipeline})}},qt=class extends ${_parse(e){let n=this._def.innerType._parse(e),r=o=>(xt(o)&&(o.value=Object.freeze(o.value)),o);return hn(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};qt.create=(t,e)=>new qt({innerType:t,typeName:D.ZodReadonly,...z(e)});function ml(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function xl(t,e={},n){return t?Tt.create().superRefine((r,o)=>{let i=t(r);if(i instanceof Promise)return i.then(s=>{if(!s){let a=ml(e,r),l=a.fatal??n??!0;o.addIssue({code:"custom",...a,fatal:l})}});if(!i){let s=ml(e,r),a=s.fatal??n??!0;o.addIssue({code:"custom",...s,fatal:a})}}):Tt.create()}var Sp={object:Oe.lazycreate},D;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(D||(D={}));var _p=(t,e={message:`Input not instance of ${t.name}`})=>xl(n=>n instanceof t,e),El=Et.create,Tl=Ot.create,Ap=yn.create,kp=Mt.create,wl=Lt.create,Ip=Pt.create,Cp=mn.create,Rp=Dt.create,Np=Ut.create,Op=Tt.create,Mp=ut.create,Lp=je.create,Pp=gn.create,Dp=dt.create,Up=Oe.create,Hp=Oe.strictCreate,Gp=Ht.create,zp=Hr.create,Fp=Gt.create,$p=tt.create,Bp=Gr.create,Vp=vn.create,jp=bn.create,qp=zr.create,Wp=zt.create,Xp=Ft.create,Yp=$t.create,Kp=Bt.create,Zp=wt.create,Jp=Fe.create,Qp=Ge.create,eh=nt.create,th=Fe.createWithPreprocess,nh=Wn.create,rh=()=>El().optional(),oh=()=>Tl().optional(),ih=()=>wl().optional(),sh={string:(t=>Et.create({...t,coerce:!0})),number:(t=>Ot.create({...t,coerce:!0})),boolean:(t=>Lt.create({...t,coerce:!0})),bigint:(t=>Mt.create({...t,coerce:!0})),date:(t=>Pt.create({...t,coerce:!0}))};var ah=P;var lh=u.object({name:u.string(),arguments:u.string()}),ch=u.object({id:u.string(),type:u.literal("function"),function:lh,encryptedValue:u.string().optional()}),Fr=u.object({id:u.string(),role:u.string(),content:u.string().optional(),name:u.string().optional(),encryptedValue:u.string().optional()}),uh=u.object({type:u.literal("text"),text:u.string()}),dh=u.object({type:u.literal("data"),value:u.string(),mimeType:u.string()}),ph=u.object({type:u.literal("url"),value:u.string(),mimeType:u.string().optional()}),$r=u.discriminatedUnion("type",[dh,ph]),hh=u.object({type:u.literal("image"),source:$r,metadata:u.unknown().optional()}),fh=u.object({type:u.literal("audio"),source:$r,metadata:u.unknown().optional()}),mh=u.object({type:u.literal("video"),source:$r,metadata:u.unknown().optional()}),gh=u.object({type:u.literal("document"),source:$r,metadata:u.unknown().optional()});var Sl=u.object({type:u.literal("binary"),mimeType:u.string(),id:u.string().optional(),url:u.string().optional(),data:u.string().optional(),filename:u.string().optional()}),_l=(t,e)=>{!t.id&&!t.url&&!t.data&&e.addIssue({code:u.ZodIssueCode.custom,message:"BinaryInputContent requires at least one of id, url, or data.",path:["id"]})},iy=Sl.superRefine((t,e)=>{_l(t,e)}),vh=u.discriminatedUnion("type",[uh,hh,fh,mh,gh,Sl]),bh=vh.superRefine((t,e)=>{t.type==="binary"&&_l(t,e)}),yh=Fr.extend({role:u.literal("developer"),content:u.string()}),xh=Fr.extend({role:u.literal("system"),content:u.string()}),Eh=Fr.extend({role:u.literal("assistant"),content:u.string().optional(),toolCalls:u.array(ch).optional()}),Th=Fr.extend({role:u.literal("user"),content:u.union([u.string(),u.array(bh)])}),wh=u.object({id:u.string(),content:u.string(),role:u.literal("tool"),toolCallId:u.string(),error:u.string().optional(),encryptedValue:u.string().optional()}),Sh=u.object({id:u.string(),role:u.literal("activity"),activityType:u.string(),content:u.record(u.any())}),_h=u.object({id:u.string(),role:u.literal("reasoning"),content:u.string(),encryptedValue:u.string().optional()}),Al=u.discriminatedUnion("role",[yh,xh,Eh,Th,wh,Sh,_h]),sy=u.union([u.literal("developer"),u.literal("system"),u.literal("assistant"),u.literal("user"),u.literal("tool"),u.literal("activity"),u.literal("reasoning")]),Ah=u.object({description:u.string(),value:u.string()}),kl=u.object({name:u.string(),description:u.string(),parameters:u.any(),metadata:u.record(u.any()).optional()}),kh=u.object({id:u.string(),reason:u.string(),message:u.string().optional(),toolCallId:u.string().optional(),responseSchema:u.record(u.any()).optional(),expiresAt:u.string().optional(),metadata:u.record(u.any()).optional()}),Ih=u.object({interruptId:u.string(),status:u.enum(["resolved","cancelled"]),payload:u.any().optional()}),Ch=u.object({threadId:u.string(),runId:u.string(),parentRunId:u.string().optional(),state:u.any(),messages:u.array(Al),tools:u.array(kl),context:u.array(Ah),forwardedProps:u.any(),resume:u.array(Ih).optional()}),Rh=u.any(),ee=class extends Error{constructor(t){super(t)}},Ss=class extends ee{constructor(){super("Connect not implemented. This method is not supported by the current agent.")}},Nh=u.object({name:u.string(),description:u.string().optional()}),Oh=u.object({name:u.string().optional(),type:u.string().optional(),description:u.string().optional(),version:u.string().optional(),provider:u.string().optional(),documentationUrl:u.string().optional(),metadata:u.record(u.unknown()).optional()}),Mh=u.object({streaming:u.boolean().optional(),websocket:u.boolean().optional(),httpBinary:u.boolean().optional(),pushNotifications:u.boolean().optional(),resumable:u.boolean().optional()}),Lh=u.object({supported:u.boolean().optional(),items:u.array(kl).optional(),parallelCalls:u.boolean().optional(),clientProvided:u.boolean().optional()}),Ph=u.object({structuredOutput:u.boolean().optional(),supportedMimeTypes:u.array(u.string()).optional()}),Dh=u.object({snapshots:u.boolean().optional(),deltas:u.boolean().optional(),memory:u.boolean().optional(),persistentState:u.boolean().optional()}),Uh=u.object({supported:u.boolean().optional(),delegation:u.boolean().optional(),handoffs:u.boolean().optional(),subAgents:u.array(Nh).optional()}),Hh=u.object({supported:u.boolean().optional(),streaming:u.boolean().optional(),encrypted:u.boolean().optional()}),Gh=u.object({image:u.boolean().optional(),audio:u.boolean().optional(),video:u.boolean().optional(),pdf:u.boolean().optional(),file:u.boolean().optional()}),zh=u.object({image:u.boolean().optional(),audio:u.boolean().optional()}),Fh=u.object({input:Gh.optional(),output:zh.optional()}),$h=u.object({codeExecution:u.boolean().optional(),sandboxed:u.boolean().optional(),maxIterations:u.number().optional(),maxExecutionTime:u.number().optional()}),Bh=u.object({supported:u.boolean().optional(),approvals:u.boolean().optional(),interventions:u.boolean().optional(),feedback:u.boolean().optional(),interrupts:u.boolean().optional(),approveWithEdits:u.boolean().optional()}),ay=u.object({identity:Oh.optional(),transport:Mh.optional(),tools:Lh.optional(),output:Ph.optional(),state:Dh.optional(),multiAgent:Uh.optional(),reasoning:Hh.optional(),multimodal:Fh.optional(),execution:$h.optional(),humanInTheLoop:Bh.optional(),custom:u.record(u.unknown()).optional()}),Il=u.union([u.literal("developer"),u.literal("system"),u.literal("assistant"),u.literal("user")]),v=(function(t){return t.TEXT_MESSAGE_START="TEXT_MESSAGE_START",t.TEXT_MESSAGE_CONTENT="TEXT_MESSAGE_CONTENT",t.TEXT_MESSAGE_END="TEXT_MESSAGE_END",t.TEXT_MESSAGE_CHUNK="TEXT_MESSAGE_CHUNK",t.TOOL_CALL_START="TOOL_CALL_START",t.TOOL_CALL_ARGS="TOOL_CALL_ARGS",t.TOOL_CALL_END="TOOL_CALL_END",t.TOOL_CALL_CHUNK="TOOL_CALL_CHUNK",t.TOOL_CALL_RESULT="TOOL_CALL_RESULT",t.THINKING_START="THINKING_START",t.THINKING_END="THINKING_END",t.THINKING_TEXT_MESSAGE_START="THINKING_TEXT_MESSAGE_START",t.THINKING_TEXT_MESSAGE_CONTENT="THINKING_TEXT_MESSAGE_CONTENT",t.THINKING_TEXT_MESSAGE_END="THINKING_TEXT_MESSAGE_END",t.STATE_SNAPSHOT="STATE_SNAPSHOT",t.STATE_DELTA="STATE_DELTA",t.MESSAGES_SNAPSHOT="MESSAGES_SNAPSHOT",t.ACTIVITY_SNAPSHOT="ACTIVITY_SNAPSHOT",t.ACTIVITY_DELTA="ACTIVITY_DELTA",t.RAW="RAW",t.CUSTOM="CUSTOM",t.RUN_STARTED="RUN_STARTED",t.RUN_FINISHED="RUN_FINISHED",t.RUN_ERROR="RUN_ERROR",t.STEP_STARTED="STEP_STARTED",t.STEP_FINISHED="STEP_FINISHED",t.REASONING_START="REASONING_START",t.REASONING_MESSAGE_START="REASONING_MESSAGE_START",t.REASONING_MESSAGE_CONTENT="REASONING_MESSAGE_CONTENT",t.REASONING_MESSAGE_END="REASONING_MESSAGE_END",t.REASONING_MESSAGE_CHUNK="REASONING_MESSAGE_CHUNK",t.REASONING_END="REASONING_END",t.REASONING_ENCRYPTED_VALUE="REASONING_ENCRYPTED_VALUE",t})({}),X=u.object({type:u.nativeEnum(v),timestamp:u.number().optional(),rawEvent:u.any().optional()}).passthrough(),Vh=X.extend({type:u.literal(v.TEXT_MESSAGE_START),messageId:u.string(),role:Il.default("assistant"),name:u.string().optional()}),Cl=X.extend({type:u.literal(v.TEXT_MESSAGE_CONTENT),messageId:u.string(),delta:u.string()}),jh=X.extend({type:u.literal(v.TEXT_MESSAGE_END),messageId:u.string()}),qh=X.extend({type:u.literal(v.TEXT_MESSAGE_CHUNK),messageId:u.string().optional(),role:Il.optional(),delta:u.string().optional(),name:u.string().optional()}),Wh=X.extend({type:u.literal(v.THINKING_TEXT_MESSAGE_START)}),Xh=Cl.omit({messageId:!0,type:!0}).extend({type:u.literal(v.THINKING_TEXT_MESSAGE_CONTENT)}),Yh=X.extend({type:u.literal(v.THINKING_TEXT_MESSAGE_END)}),Kh=X.extend({type:u.literal(v.TOOL_CALL_START),toolCallId:u.string(),toolCallName:u.string(),parentMessageId:u.string().optional()}),Zh=X.extend({type:u.literal(v.TOOL_CALL_ARGS),toolCallId:u.string(),delta:u.string()}),Jh=X.extend({type:u.literal(v.TOOL_CALL_END),toolCallId:u.string()}),Qh=X.extend({messageId:u.string(),type:u.literal(v.TOOL_CALL_RESULT),toolCallId:u.string(),content:u.string(),role:u.literal("tool").optional()}),ef=X.extend({type:u.literal(v.TOOL_CALL_CHUNK),toolCallId:u.string().optional(),toolCallName:u.string().optional(),parentMessageId:u.string().optional(),delta:u.string().optional()}),tf=X.extend({type:u.literal(v.THINKING_START),title:u.string().optional()}),nf=X.extend({type:u.literal(v.THINKING_END)}),rf=X.extend({type:u.literal(v.STATE_SNAPSHOT),snapshot:Rh}),of=X.extend({type:u.literal(v.STATE_DELTA),delta:u.array(u.any())}),sf=X.extend({type:u.literal(v.MESSAGES_SNAPSHOT),messages:u.array(Al)}),af=X.extend({type:u.literal(v.ACTIVITY_SNAPSHOT),messageId:u.string(),activityType:u.string(),content:u.record(u.any()),replace:u.boolean().optional().default(!0)}),lf=X.extend({type:u.literal(v.ACTIVITY_DELTA),messageId:u.string(),activityType:u.string(),patch:u.array(u.any())}),cf=X.extend({type:u.literal(v.RAW),event:u.any(),source:u.string().optional()}),uf=X.extend({type:u.literal(v.CUSTOM),name:u.string(),value:u.any()}),df=X.extend({type:u.literal(v.RUN_STARTED),threadId:u.string(),runId:u.string(),parentRunId:u.string().optional(),input:Ch.optional()}),pf=u.object({type:u.literal("success")}).strict(),hf=u.object({type:u.literal("interrupt"),interrupts:u.array(kh).min(1)}).strict(),ff=u.discriminatedUnion("type",[pf,hf]),mf=X.extend({type:u.literal(v.RUN_FINISHED),threadId:u.string(),runId:u.string(),result:u.any().optional(),outcome:ff.nullable().optional().transform(t=>t??void 0)}),gf=X.extend({type:u.literal(v.RUN_ERROR),message:u.string(),code:u.string().optional()}),vf=X.extend({type:u.literal(v.STEP_STARTED),stepName:u.string()}),bf=X.extend({type:u.literal(v.STEP_FINISHED),stepName:u.string()}),yf=u.union([u.literal("tool-call"),u.literal("message")]),xf=X.extend({type:u.literal(v.REASONING_START),messageId:u.string()}),Ef=X.extend({type:u.literal(v.REASONING_MESSAGE_START),messageId:u.string(),role:u.literal("reasoning")}),Tf=X.extend({type:u.literal(v.REASONING_MESSAGE_CONTENT),messageId:u.string(),delta:u.string()}),wf=X.extend({type:u.literal(v.REASONING_MESSAGE_END),messageId:u.string()}),Sf=X.extend({type:u.literal(v.REASONING_MESSAGE_CHUNK),messageId:u.string().optional(),delta:u.string().optional()}),_f=X.extend({type:u.literal(v.REASONING_END),messageId:u.string()}),Af=X.extend({type:u.literal(v.REASONING_ENCRYPTED_VALUE),subtype:yf,entityId:u.string(),encryptedValue:u.string()}),Br=u.discriminatedUnion("type",[Vh,Cl,jh,qh,tf,nf,Wh,Xh,Yh,Kh,Zh,Jh,ef,Qh,rf,of,sf,af,lf,cf,uf,df,mf,gf,vf,bf,xf,Ef,Tf,wf,Sf,_f,Af]);var _s={};$i(_s,{JsonPatchError:()=>he,_areEquals:()=>Kn,applyOperation:()=>Wt,applyPatch:()=>Kr,applyReducer:()=>Nf,deepClone:()=>Cf,getValueByPointer:()=>Xr,validate:()=>Nl,validator:()=>Yr});var kf=(function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var i in o)o.hasOwnProperty(i)&&(r[i]=o[i])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),If=Object.prototype.hasOwnProperty;function jr(t,e){return If.call(t,e)}function qr(t){if(Array.isArray(t)){for(var e=new Array(t.length),n=0;n<e.length;n++)e[n]=""+n;return e}if(Object.keys)return Object.keys(t);var r=[];for(var o in t)jr(t,o)&&r.push(o);return r}function Te(t){switch(typeof t){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t}}function Wr(t){for(var e=0,n=t.length,r;e<n;){if(r=t.charCodeAt(e),r>=48&&r<=57){e++;continue}return!1}return!0}function rt(t){return t.indexOf("/")===-1&&t.indexOf("~")===-1?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function Xn(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Vr(t){if(t===void 0)return!0;if(t){if(Array.isArray(t)){for(var e=0,n=t.length;e<n;e++)if(Vr(t[e]))return!0}else if(typeof t=="object"){for(var r=qr(t),o=r.length,i=0;i<o;i++)if(Vr(t[r[i]]))return!0}}return!1}function Rl(t,e){var n=[t];for(var r in e){var o=typeof e[r]=="object"?JSON.stringify(e[r],null,2):e[r];typeof o<"u"&&n.push(r+": "+o)}return n.join(`
|
|
2
|
-
`)}var Yn=(function(t){kf(e,t);function e(n,r,o,i,s){var a=this.constructor,l=t.call(this,Rl(n,{name:r,index:o,operation:i,tree:s}))||this;return l.name=r,l.index=o,l.operation=i,l.tree=s,Object.setPrototypeOf(l,a.prototype),l.message=Rl(n,{name:r,index:o,operation:i,tree:s}),l}return e})(Error);var he=Yn,Cf=Te,xn={add:function(t,e,n){return t[e]=this.value,{newDocument:n}},remove:function(t,e,n){var r=t[e];return delete t[e],{newDocument:n,removed:r}},replace:function(t,e,n){var r=t[e];return t[e]=this.value,{newDocument:n,removed:r}},move:function(t,e,n){var r=Xr(n,this.path);r&&(r=Te(r));var o=Wt(n,{op:"remove",path:this.from}).removed;return Wt(n,{op:"add",path:this.path,value:o}),{newDocument:n,removed:r}},copy:function(t,e,n){var r=Xr(n,this.from);return Wt(n,{op:"add",path:this.path,value:Te(r)}),{newDocument:n}},test:function(t,e,n){return{newDocument:n,test:Kn(t[e],this.value)}},_get:function(t,e,n){return this.value=t[e],{newDocument:n}}},Rf={add:function(t,e,n){return Wr(e)?t.splice(e,0,this.value):t[e]=this.value,{newDocument:n,index:e}},remove:function(t,e,n){var r=t.splice(e,1);return{newDocument:n,removed:r[0]}},replace:function(t,e,n){var r=t[e];return t[e]=this.value,{newDocument:n,removed:r}},move:xn.move,copy:xn.copy,test:xn.test,_get:xn._get};function Xr(t,e){if(e=="")return t;var n={op:"_get",path:e};return Wt(t,n),n.value}function Wt(t,e,n,r,o,i){if(n===void 0&&(n=!1),r===void 0&&(r=!0),o===void 0&&(o=!0),i===void 0&&(i=0),n&&(typeof n=="function"?n(e,0,t,e.path):Yr(e,0)),e.path===""){var s={newDocument:t};if(e.op==="add")return s.newDocument=e.value,s;if(e.op==="replace")return s.newDocument=e.value,s.removed=t,s;if(e.op==="move"||e.op==="copy")return s.newDocument=Xr(t,e.from),e.op==="move"&&(s.removed=t),s;if(e.op==="test"){if(s.test=Kn(t,e.value),s.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",i,e,t);return s.newDocument=t,s}else{if(e.op==="remove")return s.removed=t,s.newDocument=null,s;if(e.op==="_get")return e.value=t,s;if(n)throw new he("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",i,e,t);return s}}else{r||(t=Te(t));var a=e.path||"",l=a.split("/"),c=t,h=1,m=l.length,y=void 0,f=void 0,p=void 0;for(typeof n=="function"?p=n:p=Yr;;){if(f=l[h],f&&f.indexOf("~")!=-1&&(f=Xn(f)),o&&(f=="__proto__"||f=="prototype"&&h>0&&l[h-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&&y===void 0&&(c[f]===void 0?y=l.slice(0,h).join("/"):h==m-1&&(y=e.path),y!==void 0&&p(e,0,t,y)),h++,Array.isArray(c)){if(f==="-")f=c.length;else{if(n&&!Wr(f))throw new he("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",i,e,t);Wr(f)&&(f=~~f)}if(h>=m){if(n&&e.op==="add"&&f>c.length)throw new he("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",i,e,t);var s=Rf[e.op].call(e,c,f,t);if(s.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",i,e,t);return s}}else if(h>=m){var s=xn[e.op].call(e,c,f,t);if(s.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",i,e,t);return s}if(c=c[f],n&&h<m&&(!c||typeof c!="object"))throw new he("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",i,e,t)}}}function Kr(t,e,n,r,o){if(r===void 0&&(r=!0),o===void 0&&(o=!0),n&&!Array.isArray(e))throw new he("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(t=Te(t));for(var i=new Array(e.length),s=0,a=e.length;s<a;s++)i[s]=Wt(t,e[s],n,!0,o,s),t=i[s].newDocument;return i.newDocument=t,i}function Nf(t,e,n){var r=Wt(t,e);if(r.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",n,e,t);return r.newDocument}function Yr(t,e,n,r){if(typeof t!="object"||t===null||Array.isArray(t))throw new he("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,t,n);if(xn[t.op]){if(typeof t.path!="string")throw new he("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,t,n);if(t.path.indexOf("/")!==0&&t.path.length>0)throw new he('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,t,n);if((t.op==="move"||t.op==="copy")&&typeof t.from!="string")throw new he("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,t,n);if((t.op==="add"||t.op==="replace"||t.op==="test")&&t.value===void 0)throw new he("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,t,n);if((t.op==="add"||t.op==="replace"||t.op==="test")&&Vr(t.value))throw new he("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,t,n);if(n){if(t.op=="add"){var o=t.path.split("/").length,i=r.split("/").length;if(o!==i+1&&o!==i)throw new he("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,t,n)}else if(t.op==="replace"||t.op==="remove"||t.op==="_get"){if(t.path!==r)throw new he("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,t,n)}else if(t.op==="move"||t.op==="copy"){var s={op:"_get",path:t.from,value:void 0},a=Nl([s],n);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new he("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,t,n)}}}else throw new he("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,t,n)}function Nl(t,e,n){try{if(!Array.isArray(t))throw new he("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)Kr(Te(e),Te(t),n||!0);else{n=n||Yr;for(var r=0;r<t.length;r++)n(t[r],r,e,void 0)}}catch(o){if(o instanceof he)return o;throw o}}function Kn(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var n=Array.isArray(t),r=Array.isArray(e),o,i,s;if(n&&r){if(i=t.length,i!=e.length)return!1;for(o=i;o--!==0;)if(!Kn(t[o],e[o]))return!1;return!0}if(n!=r)return!1;var a=Object.keys(t);if(i=a.length,i!==Object.keys(e).length)return!1;for(o=i;o--!==0;)if(!e.hasOwnProperty(a[o]))return!1;for(o=i;o--!==0;)if(s=a[o],!Kn(t[s],e[s]))return!1;return!0}return t!==t&&e!==e}var Cs={};$i(Cs,{compare:()=>Gf,generate:()=>As,observe:()=>Hf,unobserve:()=>Uf});var ks=new WeakMap,Of=(function(){function t(e){this.observers=new Map,this.obj=e}return t})(),Mf=(function(){function t(e,n){this.callback=e,this.observer=n}return t})();function Lf(t){return ks.get(t)}function Pf(t,e){return t.observers.get(e)}function Df(t,e){t.observers.delete(e.callback)}function Uf(t,e){e.unobserve()}function Hf(t,e){var n=[],r,o=Lf(t);if(!o)o=new Of(t),ks.set(t,o);else{var i=Pf(o,e);r=i&&i.observer}if(r)return r;if(r={},o.value=Te(t),e){r.callback=e,r.next=null;var s=function(){As(r)},a=function(){clearTimeout(r.next),r.next=setTimeout(s)};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=t,r.unobserve=function(){As(r),clearTimeout(r.next),Df(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(e,new Mf(e,r)),r}function As(t,e){e===void 0&&(e=!1);var n=ks.get(t.object);Is(n.value,t.object,t.patches,"",e),t.patches.length&&Kr(n.value,t.patches);var r=t.patches;return r.length>0&&(t.patches=[],t.callback&&t.callback(r)),r}function Is(t,e,n,r,o){if(e!==t){typeof e.toJSON=="function"&&(e=e.toJSON());for(var i=qr(e),s=qr(t),a=!1,l=!1,c=s.length-1;c>=0;c--){var h=s[c],m=t[h];if(jr(e,h)&&!(e[h]===void 0&&m!==void 0&&Array.isArray(e)===!1)){var y=e[h];typeof m=="object"&&m!=null&&typeof y=="object"&&y!=null&&Array.isArray(m)===Array.isArray(y)?Is(m,y,n,r+"/"+rt(h),o):m!==y&&(a=!0,o&&n.push({op:"test",path:r+"/"+rt(h),value:Te(m)}),n.push({op:"replace",path:r+"/"+rt(h),value:Te(y)}))}else Array.isArray(t)===Array.isArray(e)?(o&&n.push({op:"test",path:r+"/"+rt(h),value:Te(m)}),n.push({op:"remove",path:r+"/"+rt(h)}),l=!0):(o&&n.push({op:"test",path:r,value:t}),n.push({op:"replace",path:r,value:e}),a=!0)}if(!(!l&&i.length==s.length))for(var c=0;c<i.length;c++){var h=i[c];!jr(t,h)&&e[h]!==void 0&&n.push({op:"add",path:r+"/"+rt(h),value:Te(e[h])})}}}function Gf(t,e,n){n===void 0&&(n=!1);var r=[];return Is(t,e,r,"",n),r}var Zr=Object.assign({},_s,Cs,{JsonPatchError:Yn,deepClone:Te,escapePathComponent:rt,unescapePathComponent:Xn});var Rs=function(t,e){return Rs=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])},Rs(t,e)};function ot(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Rs(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function Ol(t,e,n,r){function o(i){return i instanceof n?i:new n(function(s){s(i)})}return new(n||(n=Promise))(function(i,s){function a(h){try{c(r.next(h))}catch(m){s(m)}}function l(h){try{c(r.throw(h))}catch(m){s(m)}}function c(h){h.done?i(h.value):o(h.value).then(a,l)}c((r=r.apply(t,e||[])).next())})}function Jr(t,e){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=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(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1],i=c;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(c);break}i[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(h){c=[6,h],o=0}finally{r=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function pt(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function En(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=r.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return i}function Tn(t,e,n){if(n||arguments.length===2)for(var r=0,o=e.length,i;r<o;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}function Xt(t){return this instanceof Xt?(this.v=t,this):new Xt(t)}function Ml(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(f){return function(p){return Promise.resolve(p).then(f,m)}}function a(f,p){r[f]&&(o[f]=function(g){return new Promise(function(x,_){i.push([f,g,x,_])>1||l(f,g)})},p&&(o[f]=p(o[f])))}function l(f,p){try{c(r[f](p))}catch(g){y(i[0][3],g)}}function c(f){f.value instanceof Xt?Promise.resolve(f.value.v).then(h,m):y(i[0][2],f)}function h(f){l("next",f)}function m(f){l("throw",f)}function y(f,p){f(p),i.shift(),i.length&&l(i[0][0],i[0][1])}}function Ll(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof pt=="function"?pt(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(i){n[i]=t[i]&&function(s){return new Promise(function(a,l){s=t[i](s),o(a,l,s.done,s.value)})}}function o(i,s,a,l){Promise.resolve(l).then(function(c){i({value:c,done:a})},s)}}function B(t){return typeof t=="function"}function wn(t){var e=function(r){Error.call(r),r.stack=new Error().stack},n=t(e);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Qr=wn(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
1
|
+
var Pd=Object.defineProperty;var ji=(t,e)=>{for(var n in e)Pd(t,n,{get:e[n],enumerable:!0})};var Or="ag-ui-chat",qi="ag-ui-submit",Wi="ag-ui-toggle",Xi="ag-ui-state",Yi="ag-ui-attachments",je={USER:"user",ASSISTANT:"assistant"},Fn="x-destructive",Ki="x-confirm",Le="x-summary",$n="x-navigates",Zi="read_page",Ji=10,pe={PENDING:"pending",DONE:"done",ERROR:"error",DECLINED:"declined"},Pe={UPLOADING:"uploading",READY:"ready",ERROR:"error"},Qi=10*1024*1024,pn={INLINE:"inline",MINIMAL:"minimal",COMPACT:"compact",FULL:"full"},es="compaction",ts="load_capability";var Dd=/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;function pl(t,e){let n=[];return{text:t.replace(Dd,(o,i)=>{let s=e[i];return s==null||s===""?(n.includes(i)||n.push(i),o):String(s)}),missing:n}}function Ud(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.name=="string"&&typeof e.title=="string"&&(e.prompt===void 0||typeof e.prompt=="string")}function ns(t){return Array.isArray(t)?t.filter(Ud):[]}var Bn=class{#n=new Map;register(e){this.#n.set(e.name,e)}has(e){return this.#n.has(e)}get(e){let n=this.#n.get(e);if(n===void 0)throw new Error(`tool "${e}" is not registered`);return n}tools(){return[...this.#n.values()].map(e=>({name:e.name,description:e.description,parameters:e.parameters}))}};function rs(t){return t[Fn]===!0}function Mr(t){return t[$n]===!0}function Lr(t,e){return Object.getOwnPropertyDescriptor(t,e).set}var Hd=Lr(HTMLInputElement.prototype,"value"),zd=Lr(HTMLTextAreaElement.prototype,"value"),Gd=Lr(HTMLSelectElement.prototype,"value"),Fd=Lr(HTMLInputElement.prototype,"checked");function Nt(t,e){t instanceof HTMLTextAreaElement?zd.call(t,e):t instanceof HTMLSelectElement?Gd.call(t,e):Hd.call(t,e)}function Vn(t,e){Fd.call(t,e)}var os="#4f46e5",$d="rgba(79, 70, 229, 0.4)",Bd="--ag-ui-accent";function jn(t){return new Promise(e=>{setTimeout(e,t)})}function Pr(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function is(t){return t<=0||Pr()?Promise.resolve():jn(t)}function Dr(t,e){let n=window.getComputedStyle(t).getPropertyValue(Bd).trim();return n===""?e:n}function hl(t){return`0 0 0 3px ${Dr(t,$d)}`}async function ss(t,e,n={}){let r=n.charDelayMs??35;Nt(t,""),t.dispatchEvent(new Event("input",{bubbles:!0}));for(let o of e)Nt(t,t.value+o),t.dispatchEvent(new Event("input",{bubbles:!0})),r>0&&await jn(r);t.dispatchEvent(new Event("change",{bubbles:!0}))}async function as(t,e={}){let n=e.highlightMs??280,r=t.style.outline,o=t.style.outlineOffset;t.style.outline=`2px solid ${Dr(t,os)}`,t.style.outlineOffset="2px",await jn(n),t.style.outline=r,t.style.outlineOffset=o,t.click()}var Vd=600,jd=100;function lt(t,e={}){let n=Pr();return t.scrollIntoView({block:"center",inline:"nearest",behavior:n?"auto":"smooth"}),n?Promise.resolve():new Promise(r=>{let o,i=()=>{clearTimeout(o),document.removeEventListener("scroll",s,!0),document.removeEventListener("scrollend",i,!0),r()},s=()=>{document.removeEventListener("scroll",s,!0),clearTimeout(o),o=setTimeout(i,e.settleMs??Vd)};o=setTimeout(i,jd),document.addEventListener("scroll",s,!0),document.addEventListener("scrollend",i,!0)})}var qd=1200,Wd=1/3;async function fl(t,e,n){(e.focus??n)&&t.focus({preventScroll:!0});let r=e.flashMs??qd;if(r<=0)return;let o=t.style.outline,i=t.style.outlineOffset,s=t.style.transition,a=e.color??Dr(t,os);t.style.outline=`3px solid ${a}`,t.style.outlineOffset="2px";let l=Pr()?0:Math.round(r*Wd);await jn(r-l),l>0&&(t.style.transition=`outline-color ${l}ms ease-out`,t.style.outline="3px solid transparent",await jn(l)),t.style.outline=o,t.style.outlineOffset=i,t.style.transition=s}function Xd(t,e={}){return fl(t,e,!1)}function ls(t,e={}){return fl(t,e,!0)}async function cs(t,e={}){let n=e.pressMs??140,r=t.style.transform,o=t.style.transition,i=t.style.boxShadow;t.style.transition="transform 80ms ease",t.style.transform="scale(0.96)",t.style.boxShadow=hl(t),await is(n),t.style.transform=r,t.style.transition=o,t.style.boxShadow=i,t.click()}function Yd(t,e){for(let n of Array.from(t.options))if(n.value===e||n.text===e)return n;return null}async function us(t,e,n={}){let r=Yd(t,e);if(r===null)throw new Error(`no <option> matching "${e}"`);let o=n.highlightMs??220,i=t.style.outline,s=t.style.outlineOffset;t.style.outline=`2px solid ${Dr(t,os)}`,t.style.outlineOffset="2px",await is(o),Nt(t,r.value),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),t.style.outline=i,t.style.outlineOffset=s}async function ds(t,e,n={}){let r=n.flashMs??200,o=t.style.boxShadow;t.style.boxShadow=hl(t),await is(r),Vn(t,e),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),t.style.boxShadow=o}var ps={SCROLL:"scroll",DRAG:"drag"};function hs(t,e){let n=[];return t.has(ps.SCROLL)&&n.push(Kd(e)),t.has(ps.DRAG)&&n.push(Zd(e)),n}function Kd(t){return{name:"scroll_to",description:"Scroll a target into view. `target` is `top`, `bottom`, or a CSS selector / page-map element id. Read-only: it changes nothing on the page.",parameters:{type:"object",properties:{target:{type:"string"}},required:["target"],[Le]:"Scroll into view"},handler:e=>{let n=String(e.target??"");if(n==="top"||n==="bottom"){let o=n==="top"?0:document.body.scrollHeight;return window.scrollTo({top:o,behavior:"smooth"}),{scrolled:!0,target:n}}let r=t(n);if(r===null)throw new Error(`no element matching "${n}"`);return lt(r),{scrolled:!0,target:n}}}}function Zd(t){return{name:"drag_and_drop",description:"Drag the `from` element onto the `to` element (CSS selectors or page-map element ids), firing the page's native drag-and-drop. Use for reordering sortable lists. The page decides what the drop commits.",parameters:{type:"object",properties:{from:{type:"string"},to:{type:"string"}},required:["from","to"],[Le]:"Drag and drop"},handler:e=>{let n=String(e.from??""),r=String(e.to??""),o=t(n);if(o===null)throw new Error(`no element matching "${n}"`);let i=t(r);if(i===null)throw new Error(`no element matching "${r}"`);return Jd(o,i),{dragged:!0,from:n,to:r}}}}function Jd(t,e){let n=new DataTransfer;qn(t,"dragstart",n),qn(e,"dragenter",n),qn(e,"dragover",n),qn(e,"drop",n),qn(t,"dragend",n)}function qn(t,e,n){let r=new Event(e,{bubbles:!0,cancelable:!0});r.dataTransfer=n,t.dispatchEvent(r)}function fs(t,e){return!e||t===null?[]:[{description:"page_map",value:JSON.stringify(t())}]}function Ur(t){let e=[{name:`read_${t.name}`,description:`Read the "${t.name}" state.`,parameters:{type:"object",properties:{},required:[],[Le]:`Read ${t.name}`},handler:()=>t.read()}],n=t.write;return n!==void 0&&e.push({name:`set_${t.name}`,description:`Update the "${t.name}" state.`,parameters:{...t.schema??{type:"object"},[Fn]:!0,[Le]:`Update ${t.name}`},handler:r=>n(r)}),e}var Qd=Ur;function ms(t){let e={};if(!Array.isArray(t))return e;for(let n of t){if(n===null||typeof n!="object")continue;let r=n,o=r.name,i=r.summary;typeof o=="string"&&typeof i=="string"&&(e[o]=i)}return e}var ml=/:([A-Za-z_][A-Za-z0-9_]*)/g;function ep(t){return[...t.matchAll(ml)].map(e=>e[0].slice(1))}function tp(t,e,n){let r={...n};return{path:e.replace(ml,(i,s)=>{let a=n[s];if(a==null||String(a)==="")throw new Error(`route "${t}" requires path param "${s}"`);return delete r[s],encodeURIComponent(String(a))}),leftover:r}}function np(t,e){let n=new URLSearchParams;for(let[o,i]of Object.entries(e))n.set(o,String(i));let r=n.toString();return r===""?t:`${t}?${r}`}function gs(t,e){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:[],[Le]:"List pages"},handler:()=>t().map(n=>({...n,pathParams:ep(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"],[$n]:!0,[Le]:"Navigate"},handler:n=>{let r=n.route_id,o=t().find(h=>h.id===r);if(o===void 0)throw new Error(`unknown route "${String(r)}"`);let i=n.params??{},{path:s,leftover:a}=tp(o.id,o.path,i),l=np(s,a),c=e();return c!==null?c(l):window.location.assign(l),{navigated:!0,path:l}}}]}var ae={title:"Assistant",chatHistory:"Chat history",newChat:"New chat",collapse:"Collapse",expand:"Expand",toggleTheme:"Toggle theme",copyCode:"Copy",copied:"Copied",copyFailed:"Copy failed",checkpoints:"Continue a run",noCheckpoints:"Nothing to continue yet.",resumeRun:"Resume",forkRun:"Fork",forkedRun:"branched",conversation:"Conversation",thinking:"Assistant is thinking\u2026",thoughts:"Thoughts",stopped:"\u23F9 Stopped",connectionLost:"Connection lost",noResult:"No result returned.",declinedAction:"User declined the action.",navigating:"Navigating\u2026",historyCompacted:"Earlier turns condensed to fit the context window ({count} removed)",usingSkill:"Using skill {name}",runInterrupted:"The previous response didn\u2019t finish \u2014 the page changed before it arrived.",pageMoved:"The page changed since you last looked at it. Call read_page to see the current page, then retry.",attachmentsStillUploading:"{n} file still uploading \u2014 it was not sent with this message and is still attached.",skillNeeds:"\u201C{title}\u201D needs {fields} \u2014 fill it in below, then send.",message:"Message",inputPlaceholder:"Ask anything\u2026",send:"Send",stop:"Stop",attachFiles:"Attach files",recordVoice:"Record voice",stopRecording:"Stop recording",transcribing:"Transcribing\u2026",transcriptionFailed:"Transcription failed",toolRunning:"running\u2026",toolDone:"\u2713 done",toolError:"\u26A0 error",toolDeclined:"\u2298 declined",resizePanel:"Resize the chat panel",decisionApproved:"approved by you",decisionDeclined:"declined by you",argumentsLabel:"Arguments",resultLabel:"Result",errorLabel:"Error",declinedLabel:"Declined",details:"Details",confirmAction:"Confirm action",confirmRun:"Run \u201C{tool}\u201D?",confirm:"Confirm",cancel:"Cancel",approveAction:"Approve action",approvalPrompt:"Approve this action?",approve:"Approve",deny:"Deny",askUserAction:"Question",otherOption:"Other\u2026",answerPlaceholder:"Type your answer\u2026",submit:"Submit",chats:"Chats",noConversations:"No conversations yet.",rename:"Rename",renameConversation:"Rename conversation",delete:"Delete",deleteConversation:"Delete conversation",deletePrompt:"Delete?",tooLarge:"Too large (max {size})",fileTypeNotAllowed:"File type not allowed",uploadFailed:"upload failed",retry:"Retry",retryUpload:"Retry upload",remove:"Remove",removeAttachment:"Remove attachment",justNow:"just now",minutesAgo:"{n}m ago",hoursAgo:"{n}h ago",daysAgo:"{n}d ago",weeksAgo:"{n}w ago"};function vs(t){let e={...ae};for(let n of Object.keys(t)){let r=t[n];r!==void 0&&(e[n]=r)}return e}function gl(t,e){let n=document.createElement("button");return n.type="button",n.className=`approval-btn approval-btn--${t}`,n.setAttribute("part",`approval-button approval-${t}`),n.textContent=e,n}function bs(t,e,n={}){let r=n.strings??ae;return new Promise(o=>{let i=document.createElement("div");i.className="approval",i.setAttribute("part","approval"),e.toolName!==void 0&&i.setAttribute("data-tool-name",e.toolName),i.setAttribute("role","group"),i.setAttribute("aria-label",r.approveAction);let s=document.createElement("div");s.className="approval-body",s.setAttribute("part","approval-body"),s.textContent=e.message??r.approvalPrompt;let a=document.createElement("div");a.className="approval-actions",a.setAttribute("part","approval-actions");let l=gl("deny",r.deny),c=gl("approve",r.approve),h=!1,m=y=>{h||(h=!0,l.disabled=!0,c.disabled=!0,i.setAttribute("data-resolved",y?"approved":"denied"),o(y))};if(l.addEventListener("click",()=>m(!1)),c.addEventListener("click",()=>m(!0)),n.signal?.addEventListener("abort",()=>m(!1),{once:!0}),a.append(l,c),i.append(s,a),t.appendChild(i),n.signal?.aborted===!0){m(!1);return}c.focus()})}function ys(t,e){for(let n of Array.from(t.querySelectorAll("pre"))){let r=n.querySelector("code");r===null||n.querySelector(".code-copy")!==null||(n.classList.add("has-copy"),n.append(rp(r,e)))}}function rp(t,e){let n=t.textContent,r=document.createElement("button");return r.type="button",r.className="code-copy",r.setAttribute("part","code-copy"),r.textContent=e.copyCode,r.title=e.copyCode,r.setAttribute("aria-label",e.copyCode),r.addEventListener("click",()=>{op(n).then(o=>{ip(r,o?e.copied:e.copyFailed,e)})}),r}async function op(t){let e=navigator.clipboard;if(e===void 0)return!1;try{return await e.writeText(t),!0}catch{return!1}}function ip(t,e,n){t.textContent=e,t.dataset.state=e===n.copied?"copied":"failed",setTimeout(()=>{t.textContent=n.copyCode,delete t.dataset.state},1500)}function xs(t){let e=document.createElement("div");e.className="attachment-chips",e.setAttribute("part","attachment-chips");for(let n of t)e.appendChild(sp(n));return e}function sp(t){let e=document.createElement("div");e.className="attachment-chip attachment-chip--ready",e.setAttribute("part","attachment-chip");let n=document.createElement("span");n.className="attachment-chip-icon",n.setAttribute("part","attachment-chip-icon"),n.textContent=Es(t.mime),n.setAttribute("aria-hidden","true");let r=document.createElement("span");r.className="attachment-chip-name",r.setAttribute("part","attachment-chip-name"),r.textContent=t.name,r.title=t.name;let o=document.createElement("span");return o.className="attachment-chip-size",o.setAttribute("part","attachment-chip-size"),o.textContent=Hr(t.size),e.append(n,r,o),e}function Es(t){return t.startsWith("image/")?"\u{1F5BC}":t==="application/pdf"?"\u{1F4D5}":t.startsWith("text/")?"\u{1F4C4}":"\u{1F4CE}"}function Hr(t){if(t<1024)return`${t} B`;let e=["KB","MB","GB"],n=t/1024,r=0;for(;n>=1024&&r<e.length-1;)n/=1024,r+=1;return`${n<10?Math.round(n*10)/10:Math.round(n)} ${e[r]}`}var xe=[];for(let t=0;t<256;++t)xe.push((t+256).toString(16).slice(1));function vl(t,e=0){return(xe[t[e+0]]+xe[t[e+1]]+xe[t[e+2]]+xe[t[e+3]]+"-"+xe[t[e+4]]+xe[t[e+5]]+"-"+xe[t[e+6]]+xe[t[e+7]]+"-"+xe[t[e+8]]+xe[t[e+9]]+"-"+xe[t[e+10]]+xe[t[e+11]]+xe[t[e+12]]+xe[t[e+13]]+xe[t[e+14]]+xe[t[e+15]]).toLowerCase()}var _s,ap=new Uint8Array(16);function Ts(){if(!_s){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");_s=crypto.getRandomValues.bind(crypto)}return _s(ap)}var lp=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ws={randomUUID:lp};function cp(t,e,n){if(ws.randomUUID&&!e&&!t)return ws.randomUUID();t=t||{};let r=t.random??t.rng?.()??Ts();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,e){if(n=n||0,n<0||n+16>e.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let o=0;o<16;++o)e[n+o]=r[o];return e}return vl(r)}var xt=cp;var u={};ji(u,{BRAND:()=>Pp,DIRTY:()=>Ot,EMPTY_PATH:()=>hp,INVALID:()=>P,NEVER:()=>yh,OK:()=>Se,ParseStatus:()=>Ee,Schema:()=>$,ZodAny:()=>Tt,ZodArray:()=>pt,ZodBigInt:()=>Lt,ZodBoolean:()=>Pt,ZodBranded:()=>Xn,ZodCatch:()=>qt,ZodDate:()=>Dt,ZodDefault:()=>jt,ZodDiscriminatedUnion:()=>Fr,ZodEffects:()=>Fe,ZodEnum:()=>Bt,ZodError:()=>Ne,ZodFirstPartyTypeKind:()=>D,ZodFunction:()=>Br,ZodIntersection:()=>Gt,ZodIssueCode:()=>_,ZodLazy:()=>Ft,ZodLiteral:()=>$t,ZodMap:()=>bn,ZodNaN:()=>xn,ZodNativeEnum:()=>Vt,ZodNever:()=>qe,ZodNull:()=>Ht,ZodNullable:()=>rt,ZodNumber:()=>Mt,ZodObject:()=>Oe,ZodOptional:()=>ze,ZodParsedType:()=>C,ZodPipeline:()=>Yn,ZodPromise:()=>wt,ZodReadonly:()=>Wt,ZodRecord:()=>$r,ZodSchema:()=>$,ZodSet:()=>yn,ZodString:()=>_t,ZodSymbol:()=>gn,ZodTransformer:()=>Fe,ZodTuple:()=>nt,ZodType:()=>$,ZodUndefined:()=>Ut,ZodUnion:()=>zt,ZodUnknown:()=>dt,ZodVoid:()=>vn,addIssueToContext:()=>k,any:()=>Vp,array:()=>Xp,bigint:()=>zp,boolean:()=>Cl,coerce:()=>bh,custom:()=>Sl,date:()=>Gp,datetimeRegex:()=>Tl,defaultErrorMap:()=>ct,discriminatedUnion:()=>Jp,effect:()=>uh,enum:()=>ah,function:()=>oh,getErrorMap:()=>hn,getParsedType:()=>tt,instanceof:()=>Up,intersection:()=>Qp,isAborted:()=>zr,isAsync:()=>fn,isDirty:()=>Gr,isValid:()=>Et,late:()=>Dp,lazy:()=>ih,literal:()=>sh,makeIssue:()=>Wn,map:()=>nh,nan:()=>Hp,nativeEnum:()=>lh,never:()=>qp,null:()=>Bp,nullable:()=>ph,number:()=>kl,object:()=>Yp,objectUtil:()=>Ss,oboolean:()=>vh,onumber:()=>gh,optional:()=>dh,ostring:()=>mh,pipeline:()=>fh,preprocess:()=>hh,promise:()=>ch,quotelessJson:()=>up,record:()=>th,set:()=>rh,setErrorMap:()=>pp,strictObject:()=>Kp,string:()=>Al,symbol:()=>Fp,transformer:()=>uh,tuple:()=>eh,undefined:()=>$p,union:()=>Zp,unknown:()=>jp,util:()=>V,void:()=>Wp});var V;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function n(o){throw new Error}t.assertNever=n,t.arrayToEnum=o=>{let i={};for(let s of o)i[s]=s;return i},t.getValidEnumValues=o=>{let i=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),s={};for(let a of i)s[a]=o[a];return t.objectValues(s)},t.objectValues=o=>t.objectKeys(o).map(function(i){return o[i]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let i=[];for(let s in o)Object.prototype.hasOwnProperty.call(o,s)&&i.push(s);return i},t.find=(o,i)=>{for(let s of o)if(i(s))return s},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,i=" | "){return o.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(o,i)=>typeof i=="bigint"?i.toString():i})(V||(V={}));var Ss;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Ss||(Ss={}));var C=V.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),tt=t=>{switch(typeof t){case"undefined":return C.undefined;case"string":return C.string;case"number":return Number.isNaN(t)?C.nan:C.number;case"boolean":return C.boolean;case"function":return C.function;case"bigint":return C.bigint;case"symbol":return C.symbol;case"object":return Array.isArray(t)?C.array:t===null?C.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?C.promise:typeof Map<"u"&&t instanceof Map?C.map:typeof Set<"u"&&t instanceof Set?C.set:typeof Date<"u"&&t instanceof Date?C.date:C.object;default:return C.unknown}};var _=V.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"]),up=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Ne=class t extends Error{get errors(){return this.issues}constructor(e){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=e}format(e){let n=e||function(i){return i.message},r={_errors:[]},o=i=>{for(let s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(o);else if(s.code==="invalid_return_type")o(s.returnTypeError);else if(s.code==="invalid_arguments")o(s.argumentsError);else if(s.path.length===0)r._errors.push(n(s));else{let a=r,l=0;for(;l<s.path.length;){let c=s.path[l];l===s.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(s))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return o(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,V.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let o of this.issues)if(o.path.length>0){let i=o.path[0];n[i]=n[i]||[],n[i].push(e(o))}else r.push(e(o));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};Ne.create=t=>new Ne(t);var dp=(t,e)=>{let n;switch(t.code){case _.invalid_type:t.received===C.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case _.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,V.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:n=`Unrecognized key(s) in object: ${V.joinValues(t.keys,", ")}`;break;case _.invalid_union:n="Invalid input";break;case _.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${V.joinValues(t.options)}`;break;case _.invalid_enum_value:n=`Invalid enum value. Expected ${V.joinValues(t.options)}, received '${t.received}'`;break;case _.invalid_arguments:n="Invalid function arguments";break;case _.invalid_return_type:n="Invalid function return type";break;case _.invalid_date:n="Invalid date";break;case _.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:V.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case _.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case _.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case _.custom:n="Invalid input";break;case _.invalid_intersection_types:n="Intersection results could not be merged";break;case _.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case _.not_finite:n="Number must be finite";break;default:n=e.defaultError,V.assertNever(t)}return{message:n}},ct=dp;var bl=ct;function pp(t){bl=t}function hn(){return bl}var Wn=t=>{let{data:e,path:n,errorMaps:r,issueData:o}=t,i=[...n,...o.path||[]],s={...o,path:i};if(o.message!==void 0)return{...o,path:i,message:o.message};let a="",l=r.filter(c=>!!c).slice().reverse();for(let c of l)a=c(s,{data:e,defaultError:a}).message;return{...o,path:i,message:a}},hp=[];function k(t,e){let n=hn(),r=Wn({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ct?void 0:ct].filter(o=>!!o)});t.common.issues.push(r)}var Ee=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let o of n){if(o.status==="aborted")return P;o.status==="dirty"&&e.dirty(),r.push(o.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let o of n){let i=await o.key,s=await o.value;r.push({key:i,value:s})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let o of n){let{key:i,value:s}=o;if(i.status==="aborted"||s.status==="aborted")return P;i.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof s.value<"u"||o.alwaysSet)&&(r[i.value]=s.value)}return{status:e.value,value:r}}},P=Object.freeze({status:"aborted"}),Ot=t=>({status:"dirty",value:t}),Se=t=>({status:"valid",value:t}),zr=t=>t.status==="aborted",Gr=t=>t.status==="dirty",Et=t=>t.status==="valid",fn=t=>typeof Promise<"u"&&t instanceof Promise;var R;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(R||(R={}));var Ge=class{constructor(e,n,r,o){this._cachedPath=[],this.parent=e,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}},yl=(t,e)=>{if(Et(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new Ne(t.common.issues);return this._error=n,this._error}}};function G(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:o}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(s,a)=>{let{message:l}=t;return s.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:o}}var $=class{get description(){return this._def.description}_getType(e){return tt(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:tt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ee,ctx:{common:e.parent.common,data:e.data,parsedType:tt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(fn(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:tt(e)},o=this._parseSync({data:e,path:r.path,parent:r});return yl(r,o)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:tt(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Et(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:e,path:[],parent:n}).then(r=>Et(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:tt(e)},o=this._parse({data:e,path:r.path,parent:r}),i=await(fn(o)?o:Promise.resolve(o));return yl(r,i)}refine(e,n){let r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,i)=>{let s=e(o),a=()=>i.addIssue({code:_.custom,...r(o)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,o)=>e(r)?!0:(o.addIssue(typeof n=="function"?n(r,o):n),!1))}_refinement(e){return new Fe({schema:this,typeName:D.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return ze.create(this,this._def)}nullable(){return rt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pt.create(this)}promise(){return wt.create(this,this._def)}or(e){return zt.create([this,e],this._def)}and(e){return Gt.create(this,e,this._def)}transform(e){return new Fe({...G(this._def),schema:this,typeName:D.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new jt({...G(this._def),innerType:this,defaultValue:n,typeName:D.ZodDefault})}brand(){return new Xn({typeName:D.ZodBranded,type:this,...G(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new qt({...G(this._def),innerType:this,catchValue:n,typeName:D.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Yn.create(this,e)}readonly(){return Wt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},fp=/^c[^\s-]{8,}$/i,mp=/^[0-9a-z]+$/,gp=/^[0-9A-HJKMNP-TV-Z]{26}$/i,vp=/^[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,bp=/^[a-z0-9_-]{21}$/i,yp=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,xp=/^[-+]?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)?)??$/,Ep=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_p="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",As,Tp=/^(?:(?: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])$/,wp=/^(?:(?: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])$/,Sp=/^(([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]))$/,Ap=/^(([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])$/,kp=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Cp=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,El="((\\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])))",Ip=new RegExp(`^${El}$`);function _l(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Rp(t){return new RegExp(`^${_l(t)}$`)}function Tl(t){let e=`${El}T${_l(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Np(t,e){return!!((e==="v4"||!e)&&Tp.test(t)||(e==="v6"||!e)&&Sp.test(t))}function Op(t,e){if(!yp.test(t))return!1;try{let[n]=t.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||e&&o.alg!==e)}catch{return!1}}function Mp(t,e){return!!((e==="v4"||!e)&&wp.test(t)||(e==="v6"||!e)&&Ap.test(t))}var _t=class t extends ${_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==C.string){let i=this._getOrReturnCtx(e);return k(i,{code:_.invalid_type,expected:C.string,received:i.parsedType}),P}let r=new Ee,o;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:_.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:_.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){let s=e.data.length>i.value,a=e.data.length<i.value;(s||a)&&(o=this._getOrReturnCtx(e,o),s?k(o,{code:_.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&k(o,{code:_.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")Ep.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"email",code:_.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")As||(As=new RegExp(_p,"u")),As.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"emoji",code:_.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")vp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"uuid",code:_.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")bp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"nanoid",code:_.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")fp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid",code:_.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")mp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid2",code:_.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")gp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ulid",code:_.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),k(o,{validation:"url",code:_.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"regex",code:_.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(o=this._getOrReturnCtx(e,o),k(o,{code:_.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(o=this._getOrReturnCtx(e,o),k(o,{code:_.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(o=this._getOrReturnCtx(e,o),k(o,{code:_.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?Tl(i).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:_.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Ip.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:_.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?Rp(i).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:_.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?xp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"duration",code:_.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?Np(e.data,i.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ip",code:_.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?Op(e.data,i.alg)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"jwt",code:_.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?Mp(e.data,i.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cidr",code:_.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?kp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64",code:_.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Cp.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64url",code:_.invalid_string,message:i.message}),r.dirty()):V.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(o=>e.test(o),{validation:n,code:_.invalid_string,...R.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...R.errToObj(e)})}url(e){return this._addCheck({kind:"url",...R.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...R.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...R.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...R.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...R.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...R.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...R.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...R.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...R.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...R.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...R.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...R.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...R.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...R.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...R.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...R.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...R.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...R.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...R.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...R.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...R.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...R.errToObj(n)})}nonempty(e){return this.min(1,R.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};_t.create=t=>new _t({checks:[],typeName:D.ZodString,coerce:t?.coerce??!1,...G(t)});function Lp(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,o=n>r?n:r,i=Number.parseInt(t.toFixed(o).replace(".","")),s=Number.parseInt(e.toFixed(o).replace(".",""));return i%s/10**o}var Mt=class t extends ${constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==C.number){let i=this._getOrReturnCtx(e);return k(i,{code:_.invalid_type,expected:C.number,received:i.parsedType}),P}let r,o=new Ee;for(let i of this._def.checks)i.kind==="int"?V.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:_.invalid_type,expected:"integer",received:"float",message:i.message}),o.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),k(r,{code:_.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),k(r,{code:_.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?Lp(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),k(r,{code:_.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:_.not_finite,message:i.message}),o.dirty()):V.assertNever(i);return{status:o.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,R.toString(n))}gt(e,n){return this.setLimit("min",e,!1,R.toString(n))}lte(e,n){return this.setLimit("max",e,!0,R.toString(n))}lt(e,n){return this.setLimit("max",e,!1,R.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:R.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:R.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:R.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:R.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:R.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:R.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:R.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&V.isInteger(e.value))}get isFinite(){let e=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"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};Mt.create=t=>new Mt({checks:[],typeName:D.ZodNumber,coerce:t?.coerce||!1,...G(t)});var Lt=class t extends ${constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==C.bigint)return this._getInvalidInput(e);let r,o=new Ee;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),k(r,{code:_.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),k(r,{code:_.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),o.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),k(r,{code:_.not_multiple_of,multipleOf:i.value,message:i.message}),o.dirty()):V.assertNever(i);return{status:o.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return k(n,{code:_.invalid_type,expected:C.bigint,received:n.parsedType}),P}gte(e,n){return this.setLimit("min",e,!0,R.toString(n))}gt(e,n){return this.setLimit("min",e,!1,R.toString(n))}lte(e,n){return this.setLimit("max",e,!0,R.toString(n))}lt(e,n){return this.setLimit("max",e,!1,R.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:R.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:R.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:R.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Lt.create=t=>new Lt({checks:[],typeName:D.ZodBigInt,coerce:t?.coerce??!1,...G(t)});var Pt=class extends ${_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==C.boolean){let r=this._getOrReturnCtx(e);return k(r,{code:_.invalid_type,expected:C.boolean,received:r.parsedType}),P}return Se(e.data)}};Pt.create=t=>new Pt({typeName:D.ZodBoolean,coerce:t?.coerce||!1,...G(t)});var Dt=class t extends ${_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==C.date){let i=this._getOrReturnCtx(e);return k(i,{code:_.invalid_type,expected:C.date,received:i.parsedType}),P}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return k(i,{code:_.invalid_date}),P}let r=new Ee,o;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:_.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:_.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):V.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:R.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:R.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};Dt.create=t=>new Dt({checks:[],coerce:t?.coerce||!1,typeName:D.ZodDate,...G(t)});var gn=class extends ${_parse(e){if(this._getType(e)!==C.symbol){let r=this._getOrReturnCtx(e);return k(r,{code:_.invalid_type,expected:C.symbol,received:r.parsedType}),P}return Se(e.data)}};gn.create=t=>new gn({typeName:D.ZodSymbol,...G(t)});var Ut=class extends ${_parse(e){if(this._getType(e)!==C.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:_.invalid_type,expected:C.undefined,received:r.parsedType}),P}return Se(e.data)}};Ut.create=t=>new Ut({typeName:D.ZodUndefined,...G(t)});var Ht=class extends ${_parse(e){if(this._getType(e)!==C.null){let r=this._getOrReturnCtx(e);return k(r,{code:_.invalid_type,expected:C.null,received:r.parsedType}),P}return Se(e.data)}};Ht.create=t=>new Ht({typeName:D.ZodNull,...G(t)});var Tt=class extends ${constructor(){super(...arguments),this._any=!0}_parse(e){return Se(e.data)}};Tt.create=t=>new Tt({typeName:D.ZodAny,...G(t)});var dt=class extends ${constructor(){super(...arguments),this._unknown=!0}_parse(e){return Se(e.data)}};dt.create=t=>new dt({typeName:D.ZodUnknown,...G(t)});var qe=class extends ${_parse(e){let n=this._getOrReturnCtx(e);return k(n,{code:_.invalid_type,expected:C.never,received:n.parsedType}),P}};qe.create=t=>new qe({typeName:D.ZodNever,...G(t)});var vn=class extends ${_parse(e){if(this._getType(e)!==C.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:_.invalid_type,expected:C.void,received:r.parsedType}),P}return Se(e.data)}};vn.create=t=>new vn({typeName:D.ZodVoid,...G(t)});var pt=class t extends ${_parse(e){let{ctx:n,status:r}=this._processInputParams(e),o=this._def;if(n.parsedType!==C.array)return k(n,{code:_.invalid_type,expected:C.array,received:n.parsedType}),P;if(o.exactLength!==null){let s=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(s||a)&&(k(n,{code:s?_.too_big:_.too_small,minimum:a?o.exactLength.value:void 0,maximum:s?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&&(k(n,{code:_.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&&(k(n,{code:_.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((s,a)=>o.type._parseAsync(new Ge(n,s,n.path,a)))).then(s=>Ee.mergeArray(r,s));let i=[...n.data].map((s,a)=>o.type._parseSync(new Ge(n,s,n.path,a)));return Ee.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:R.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:R.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:R.toString(n)}})}nonempty(e){return this.min(1,e)}};pt.create=(t,e)=>new pt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...G(e)});function mn(t){if(t instanceof Oe){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=ze.create(mn(r))}return new Oe({...t._def,shape:()=>e})}else return t instanceof pt?new pt({...t._def,type:mn(t.element)}):t instanceof ze?ze.create(mn(t.unwrap())):t instanceof rt?rt.create(mn(t.unwrap())):t instanceof nt?nt.create(t.items.map(e=>mn(e))):t}var Oe=class t extends ${constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=V.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==C.object){let c=this._getOrReturnCtx(e);return k(c,{code:_.invalid_type,expected:C.object,received:c.parsedType}),P}let{status:r,ctx:o}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof qe&&this._def.unknownKeys==="strip"))for(let c in o.data)s.includes(c)||a.push(c);let l=[];for(let c of s){let h=i[c],m=o.data[c];l.push({key:{status:"valid",value:c},value:h._parse(new Ge(o,m,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof qe){let c=this._def.unknownKeys;if(c==="passthrough")for(let h of a)l.push({key:{status:"valid",value:h},value:{status:"valid",value:o.data[h]}});else if(c==="strict")a.length>0&&(k(o,{code:_.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 h of a){let m=o.data[h];l.push({key:{status:"valid",value:h},value:c._parse(new Ge(o,m,o.path,h)),alwaysSet:h in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let c=[];for(let h of l){let m=await h.key,y=await h.value;c.push({key:m,value:y,alwaysSet:h.alwaysSet})}return c}).then(c=>Ee.mergeObjectSync(r,c)):Ee.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return R.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let o=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:R.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:D.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of V.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of V.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return mn(this)}partial(e){let n={};for(let r of V.objectKeys(this.shape)){let o=this.shape[r];e&&!e[r]?n[r]=o:n[r]=o.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of V.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof ze;)i=i._def.innerType;n[r]=i}return new t({...this._def,shape:()=>n})}keyof(){return wl(V.objectKeys(this.shape))}};Oe.create=(t,e)=>new Oe({shape:()=>t,unknownKeys:"strip",catchall:qe.create(),typeName:D.ZodObject,...G(e)});Oe.strictCreate=(t,e)=>new Oe({shape:()=>t,unknownKeys:"strict",catchall:qe.create(),typeName:D.ZodObject,...G(e)});Oe.lazycreate=(t,e)=>new Oe({shape:t,unknownKeys:"strip",catchall:qe.create(),typeName:D.ZodObject,...G(e)});var zt=class extends ${_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function o(i){for(let a of i)if(a.result.status==="valid")return a.result;for(let a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let s=i.map(a=>new Ne(a.ctx.common.issues));return k(n,{code:_.invalid_union,unionErrors:s}),P}if(n.common.async)return Promise.all(r.map(async i=>{let s={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(o);{let i,s=[];for(let l of r){let c={...n,common:{...n.common,issues:[]},parent:null},h=l._parseSync({data:n.data,path:n.path,parent:c});if(h.status==="valid")return h;h.status==="dirty"&&!i&&(i={result:h,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let a=s.map(l=>new Ne(l));return k(n,{code:_.invalid_union,unionErrors:a}),P}}get options(){return this._def.options}};zt.create=(t,e)=>new zt({options:t,typeName:D.ZodUnion,...G(e)});var ut=t=>t instanceof Ft?ut(t.schema):t instanceof Fe?ut(t.innerType()):t instanceof $t?[t.value]:t instanceof Bt?t.options:t instanceof Vt?V.objectValues(t.enum):t instanceof jt?ut(t._def.innerType):t instanceof Ut?[void 0]:t instanceof Ht?[null]:t instanceof ze?[void 0,...ut(t.unwrap())]:t instanceof rt?[null,...ut(t.unwrap())]:t instanceof Xn||t instanceof Wt?ut(t.unwrap()):t instanceof qt?ut(t._def.innerType):[],Fr=class t extends ${_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==C.object)return k(n,{code:_.invalid_type,expected:C.object,received:n.parsedType}),P;let r=this.discriminator,o=n.data[r],i=this.optionsMap.get(o);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(k(n,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),P)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let o=new Map;for(let i of n){let s=ut(i.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of s){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,i)}}return new t({typeName:D.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:o,...G(r)})}};function ks(t,e){let n=tt(t),r=tt(e);if(t===e)return{valid:!0,data:t};if(n===C.object&&r===C.object){let o=V.objectKeys(e),i=V.objectKeys(t).filter(a=>o.indexOf(a)!==-1),s={...t,...e};for(let a of i){let l=ks(t[a],e[a]);if(!l.valid)return{valid:!1};s[a]=l.data}return{valid:!0,data:s}}else if(n===C.array&&r===C.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let i=0;i<t.length;i++){let s=t[i],a=e[i],l=ks(s,a);if(!l.valid)return{valid:!1};o.push(l.data)}return{valid:!0,data:o}}else return n===C.date&&r===C.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Gt=class extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(i,s)=>{if(zr(i)||zr(s))return P;let a=ks(i.value,s.value);return a.valid?((Gr(i)||Gr(s))&&n.dirty(),{status:n.value,value:a.data}):(k(r,{code:_.invalid_intersection_types}),P)};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(([i,s])=>o(i,s)):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}))}};Gt.create=(t,e,n)=>new Gt({left:t,right:e,typeName:D.ZodIntersection,...G(n)});var nt=class t extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==C.array)return k(r,{code:_.invalid_type,expected:C.array,received:r.parsedType}),P;if(r.data.length<this._def.items.length)return k(r,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),P;!this._def.rest&&r.data.length>this._def.items.length&&(k(r,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...r.data].map((s,a)=>{let l=this._def.items[a]||this._def.rest;return l?l._parse(new Ge(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(i).then(s=>Ee.mergeArray(n,s)):Ee.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};nt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new nt({items:t,typeName:D.ZodTuple,rest:null,...G(e)})};var $r=class t extends ${get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==C.object)return k(r,{code:_.invalid_type,expected:C.object,received:r.parsedType}),P;let o=[],i=this._def.keyType,s=this._def.valueType;for(let a in r.data)o.push({key:i._parse(new Ge(r,a,r.path,a)),value:s._parse(new Ge(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Ee.mergeObjectAsync(n,o):Ee.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof $?new t({keyType:e,valueType:n,typeName:D.ZodRecord,...G(r)}):new t({keyType:_t.create(),valueType:e,typeName:D.ZodRecord,...G(n)})}},bn=class extends ${get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==C.map)return k(r,{code:_.invalid_type,expected:C.map,received:r.parsedType}),P;let o=this._def.keyType,i=this._def.valueType,s=[...r.data.entries()].map(([a,l],c)=>({key:o._parse(new Ge(r,a,r.path,[c,"key"])),value:i._parse(new Ge(r,l,r.path,[c,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of s){let c=await l.key,h=await l.value;if(c.status==="aborted"||h.status==="aborted")return P;(c.status==="dirty"||h.status==="dirty")&&n.dirty(),a.set(c.value,h.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let l of s){let c=l.key,h=l.value;if(c.status==="aborted"||h.status==="aborted")return P;(c.status==="dirty"||h.status==="dirty")&&n.dirty(),a.set(c.value,h.value)}return{status:n.value,value:a}}}};bn.create=(t,e,n)=>new bn({valueType:e,keyType:t,typeName:D.ZodMap,...G(n)});var yn=class t extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==C.set)return k(r,{code:_.invalid_type,expected:C.set,received:r.parsedType}),P;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(k(r,{code:_.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&&(k(r,{code:_.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),n.dirty());let i=this._def.valueType;function s(l){let c=new Set;for(let h of l){if(h.status==="aborted")return P;h.status==="dirty"&&n.dirty(),c.add(h.value)}return{status:n.value,value:c}}let a=[...r.data.values()].map((l,c)=>i._parse(new Ge(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>s(l)):s(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:R.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:R.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};yn.create=(t,e)=>new yn({valueType:t,minSize:null,maxSize:null,typeName:D.ZodSet,...G(e)});var Br=class t extends ${constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==C.function)return k(n,{code:_.invalid_type,expected:C.function,received:n.parsedType}),P;function r(a,l){return Wn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,hn(),ct].filter(c=>!!c),issueData:{code:_.invalid_arguments,argumentsError:l}})}function o(a,l){return Wn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,hn(),ct].filter(c=>!!c),issueData:{code:_.invalid_return_type,returnTypeError:l}})}let i={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof wt){let a=this;return Se(async function(...l){let c=new Ne([]),h=await a._def.args.parseAsync(l,i).catch(f=>{throw c.addIssue(r(l,f)),c}),m=await Reflect.apply(s,this,h);return await a._def.returns._def.type.parseAsync(m,i).catch(f=>{throw c.addIssue(o(m,f)),c})})}else{let a=this;return Se(function(...l){let c=a._def.args.safeParse(l,i);if(!c.success)throw new Ne([r(l,c.error)]);let h=Reflect.apply(s,this,c.data),m=a._def.returns.safeParse(h,i);if(!m.success)throw new Ne([o(h,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:nt.create(e).rest(dt.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||nt.create([]).rest(dt.create()),returns:n||dt.create(),typeName:D.ZodFunction,...G(r)})}},Ft=class extends ${get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};Ft.create=(t,e)=>new Ft({getter:t,typeName:D.ZodLazy,...G(e)});var $t=class extends ${_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return k(n,{received:n.data,code:_.invalid_literal,expected:this._def.value}),P}return{status:"valid",value:e.data}}get value(){return this._def.value}};$t.create=(t,e)=>new $t({value:t,typeName:D.ZodLiteral,...G(e)});function wl(t,e){return new Bt({values:t,typeName:D.ZodEnum,...G(e)})}var Bt=class t extends ${_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return k(n,{expected:V.joinValues(r),received:n.parsedType,code:_.invalid_type}),P}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return k(n,{received:n.data,code:_.invalid_enum_value,options:r}),P}return Se(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};Bt.create=wl;var Vt=class extends ${_parse(e){let n=V.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==C.string&&r.parsedType!==C.number){let o=V.objectValues(n);return k(r,{expected:V.joinValues(o),received:r.parsedType,code:_.invalid_type}),P}if(this._cache||(this._cache=new Set(V.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=V.objectValues(n);return k(r,{received:r.data,code:_.invalid_enum_value,options:o}),P}return Se(e.data)}get enum(){return this._def.values}};Vt.create=(t,e)=>new Vt({values:t,typeName:D.ZodNativeEnum,...G(e)});var wt=class extends ${unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==C.promise&&n.common.async===!1)return k(n,{code:_.invalid_type,expected:C.promise,received:n.parsedType}),P;let r=n.parsedType===C.promise?n.data:Promise.resolve(n.data);return Se(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};wt.create=(t,e)=>new wt({type:t,typeName:D.ZodPromise,...G(e)});var Fe=class extends ${innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===D.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=this._def.effect||null,i={addIssue:s=>{k(r,s),s.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),o.type==="preprocess"){let s=o.transform(r.data,i);if(r.common.async)return Promise.resolve(s).then(async a=>{if(n.value==="aborted")return P;let l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?P:l.status==="dirty"?Ot(l.value):n.value==="dirty"?Ot(l.value):l});{if(n.value==="aborted")return P;let a=this._def.schema._parseSync({data:s,path:r.path,parent:r});return a.status==="aborted"?P:a.status==="dirty"?Ot(a.value):n.value==="dirty"?Ot(a.value):a}}if(o.type==="refinement"){let s=a=>{let l=o.refinement(a,i);if(r.common.async)return Promise.resolve(l);if(l 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"?P:(a.status==="dirty"&&n.dirty(),s(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"?P:(a.status==="dirty"&&n.dirty(),s(a.value).then(()=>({status:n.value,value:a.value}))))}if(o.type==="transform")if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Et(s))return P;let a=o.transform(s.value,i);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(s=>Et(s)?Promise.resolve(o.transform(s.value,i)).then(a=>({status:n.value,value:a})):P);V.assertNever(o)}};Fe.create=(t,e,n)=>new Fe({schema:t,typeName:D.ZodEffects,effect:e,...G(n)});Fe.createWithPreprocess=(t,e,n)=>new Fe({schema:e,effect:{type:"preprocess",transform:t},typeName:D.ZodEffects,...G(n)});var ze=class extends ${_parse(e){return this._getType(e)===C.undefined?Se(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ze.create=(t,e)=>new ze({innerType:t,typeName:D.ZodOptional,...G(e)});var rt=class extends ${_parse(e){return this._getType(e)===C.null?Se(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};rt.create=(t,e)=>new rt({innerType:t,typeName:D.ZodNullable,...G(e)});var jt=class extends ${_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===C.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};jt.create=(t,e)=>new jt({innerType:t,typeName:D.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...G(e)});var qt=class extends ${_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return fn(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ne(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ne(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};qt.create=(t,e)=>new qt({innerType:t,typeName:D.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...G(e)});var xn=class extends ${_parse(e){if(this._getType(e)!==C.nan){let r=this._getOrReturnCtx(e);return k(r,{code:_.invalid_type,expected:C.nan,received:r.parsedType}),P}return{status:"valid",value:e.data}}};xn.create=t=>new xn({typeName:D.ZodNaN,...G(t)});var Pp=Symbol("zod_brand"),Xn=class extends ${_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Yn=class t extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?P:i.status==="dirty"?(n.dirty(),Ot(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{let o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?P:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:D.ZodPipeline})}},Wt=class extends ${_parse(e){let n=this._def.innerType._parse(e),r=o=>(Et(o)&&(o.value=Object.freeze(o.value)),o);return fn(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};Wt.create=(t,e)=>new Wt({innerType:t,typeName:D.ZodReadonly,...G(e)});function xl(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Sl(t,e={},n){return t?Tt.create().superRefine((r,o)=>{let i=t(r);if(i instanceof Promise)return i.then(s=>{if(!s){let a=xl(e,r),l=a.fatal??n??!0;o.addIssue({code:"custom",...a,fatal:l})}});if(!i){let s=xl(e,r),a=s.fatal??n??!0;o.addIssue({code:"custom",...s,fatal:a})}}):Tt.create()}var Dp={object:Oe.lazycreate},D;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(D||(D={}));var Up=(t,e={message:`Input not instance of ${t.name}`})=>Sl(n=>n instanceof t,e),Al=_t.create,kl=Mt.create,Hp=xn.create,zp=Lt.create,Cl=Pt.create,Gp=Dt.create,Fp=gn.create,$p=Ut.create,Bp=Ht.create,Vp=Tt.create,jp=dt.create,qp=qe.create,Wp=vn.create,Xp=pt.create,Yp=Oe.create,Kp=Oe.strictCreate,Zp=zt.create,Jp=Fr.create,Qp=Gt.create,eh=nt.create,th=$r.create,nh=bn.create,rh=yn.create,oh=Br.create,ih=Ft.create,sh=$t.create,ah=Bt.create,lh=Vt.create,ch=wt.create,uh=Fe.create,dh=ze.create,ph=rt.create,hh=Fe.createWithPreprocess,fh=Yn.create,mh=()=>Al().optional(),gh=()=>kl().optional(),vh=()=>Cl().optional(),bh={string:(t=>_t.create({...t,coerce:!0})),number:(t=>Mt.create({...t,coerce:!0})),boolean:(t=>Pt.create({...t,coerce:!0})),bigint:(t=>Lt.create({...t,coerce:!0})),date:(t=>Dt.create({...t,coerce:!0}))};var yh=P;var xh=u.object({name:u.string(),arguments:u.string()}),Eh=u.object({id:u.string(),type:u.literal("function"),function:xh,encryptedValue:u.string().optional()}),Vr=u.object({id:u.string(),role:u.string(),content:u.string().optional(),name:u.string().optional(),encryptedValue:u.string().optional()}),_h=u.object({type:u.literal("text"),text:u.string()}),Th=u.object({type:u.literal("data"),value:u.string(),mimeType:u.string()}),wh=u.object({type:u.literal("url"),value:u.string(),mimeType:u.string().optional()}),jr=u.discriminatedUnion("type",[Th,wh]),Sh=u.object({type:u.literal("image"),source:jr,metadata:u.unknown().optional()}),Ah=u.object({type:u.literal("audio"),source:jr,metadata:u.unknown().optional()}),kh=u.object({type:u.literal("video"),source:jr,metadata:u.unknown().optional()}),Ch=u.object({type:u.literal("document"),source:jr,metadata:u.unknown().optional()});var Il=u.object({type:u.literal("binary"),mimeType:u.string(),id:u.string().optional(),url:u.string().optional(),data:u.string().optional(),filename:u.string().optional()}),Rl=(t,e)=>{!t.id&&!t.url&&!t.data&&e.addIssue({code:u.ZodIssueCode.custom,message:"BinaryInputContent requires at least one of id, url, or data.",path:["id"]})},vy=Il.superRefine((t,e)=>{Rl(t,e)}),Ih=u.discriminatedUnion("type",[_h,Sh,Ah,kh,Ch,Il]),Rh=Ih.superRefine((t,e)=>{t.type==="binary"&&Rl(t,e)}),Nh=Vr.extend({role:u.literal("developer"),content:u.string()}),Oh=Vr.extend({role:u.literal("system"),content:u.string()}),Mh=Vr.extend({role:u.literal("assistant"),content:u.string().optional(),toolCalls:u.array(Eh).optional()}),Lh=Vr.extend({role:u.literal("user"),content:u.union([u.string(),u.array(Rh)])}),Ph=u.object({id:u.string(),content:u.string(),role:u.literal("tool"),toolCallId:u.string(),error:u.string().optional(),encryptedValue:u.string().optional()}),Dh=u.object({id:u.string(),role:u.literal("activity"),activityType:u.string(),content:u.record(u.any())}),Uh=u.object({id:u.string(),role:u.literal("reasoning"),content:u.string(),encryptedValue:u.string().optional()}),Nl=u.discriminatedUnion("role",[Nh,Oh,Mh,Lh,Ph,Dh,Uh]),by=u.union([u.literal("developer"),u.literal("system"),u.literal("assistant"),u.literal("user"),u.literal("tool"),u.literal("activity"),u.literal("reasoning")]),Hh=u.object({description:u.string(),value:u.string()}),Ol=u.object({name:u.string(),description:u.string(),parameters:u.any(),metadata:u.record(u.any()).optional()}),zh=u.object({id:u.string(),reason:u.string(),message:u.string().optional(),toolCallId:u.string().optional(),responseSchema:u.record(u.any()).optional(),expiresAt:u.string().optional(),metadata:u.record(u.any()).optional()}),Gh=u.object({interruptId:u.string(),status:u.enum(["resolved","cancelled"]),payload:u.any().optional()}),Fh=u.object({threadId:u.string(),runId:u.string(),parentRunId:u.string().optional(),state:u.any(),messages:u.array(Nl),tools:u.array(Ol),context:u.array(Hh),forwardedProps:u.any(),resume:u.array(Gh).optional()}),$h=u.any(),ee=class extends Error{constructor(t){super(t)}},Cs=class extends ee{constructor(){super("Connect not implemented. This method is not supported by the current agent.")}},Bh=u.object({name:u.string(),description:u.string().optional()}),Vh=u.object({name:u.string().optional(),type:u.string().optional(),description:u.string().optional(),version:u.string().optional(),provider:u.string().optional(),documentationUrl:u.string().optional(),metadata:u.record(u.unknown()).optional()}),jh=u.object({streaming:u.boolean().optional(),websocket:u.boolean().optional(),httpBinary:u.boolean().optional(),pushNotifications:u.boolean().optional(),resumable:u.boolean().optional()}),qh=u.object({supported:u.boolean().optional(),items:u.array(Ol).optional(),parallelCalls:u.boolean().optional(),clientProvided:u.boolean().optional()}),Wh=u.object({structuredOutput:u.boolean().optional(),supportedMimeTypes:u.array(u.string()).optional()}),Xh=u.object({snapshots:u.boolean().optional(),deltas:u.boolean().optional(),memory:u.boolean().optional(),persistentState:u.boolean().optional()}),Yh=u.object({supported:u.boolean().optional(),delegation:u.boolean().optional(),handoffs:u.boolean().optional(),subAgents:u.array(Bh).optional()}),Kh=u.object({supported:u.boolean().optional(),streaming:u.boolean().optional(),encrypted:u.boolean().optional()}),Zh=u.object({image:u.boolean().optional(),audio:u.boolean().optional(),video:u.boolean().optional(),pdf:u.boolean().optional(),file:u.boolean().optional()}),Jh=u.object({image:u.boolean().optional(),audio:u.boolean().optional()}),Qh=u.object({input:Zh.optional(),output:Jh.optional()}),ef=u.object({codeExecution:u.boolean().optional(),sandboxed:u.boolean().optional(),maxIterations:u.number().optional(),maxExecutionTime:u.number().optional()}),tf=u.object({supported:u.boolean().optional(),approvals:u.boolean().optional(),interventions:u.boolean().optional(),feedback:u.boolean().optional(),interrupts:u.boolean().optional(),approveWithEdits:u.boolean().optional()}),yy=u.object({identity:Vh.optional(),transport:jh.optional(),tools:qh.optional(),output:Wh.optional(),state:Xh.optional(),multiAgent:Yh.optional(),reasoning:Kh.optional(),multimodal:Qh.optional(),execution:ef.optional(),humanInTheLoop:tf.optional(),custom:u.record(u.unknown()).optional()}),Ml=u.union([u.literal("developer"),u.literal("system"),u.literal("assistant"),u.literal("user")]),v=(function(t){return t.TEXT_MESSAGE_START="TEXT_MESSAGE_START",t.TEXT_MESSAGE_CONTENT="TEXT_MESSAGE_CONTENT",t.TEXT_MESSAGE_END="TEXT_MESSAGE_END",t.TEXT_MESSAGE_CHUNK="TEXT_MESSAGE_CHUNK",t.TOOL_CALL_START="TOOL_CALL_START",t.TOOL_CALL_ARGS="TOOL_CALL_ARGS",t.TOOL_CALL_END="TOOL_CALL_END",t.TOOL_CALL_CHUNK="TOOL_CALL_CHUNK",t.TOOL_CALL_RESULT="TOOL_CALL_RESULT",t.THINKING_START="THINKING_START",t.THINKING_END="THINKING_END",t.THINKING_TEXT_MESSAGE_START="THINKING_TEXT_MESSAGE_START",t.THINKING_TEXT_MESSAGE_CONTENT="THINKING_TEXT_MESSAGE_CONTENT",t.THINKING_TEXT_MESSAGE_END="THINKING_TEXT_MESSAGE_END",t.STATE_SNAPSHOT="STATE_SNAPSHOT",t.STATE_DELTA="STATE_DELTA",t.MESSAGES_SNAPSHOT="MESSAGES_SNAPSHOT",t.ACTIVITY_SNAPSHOT="ACTIVITY_SNAPSHOT",t.ACTIVITY_DELTA="ACTIVITY_DELTA",t.RAW="RAW",t.CUSTOM="CUSTOM",t.RUN_STARTED="RUN_STARTED",t.RUN_FINISHED="RUN_FINISHED",t.RUN_ERROR="RUN_ERROR",t.STEP_STARTED="STEP_STARTED",t.STEP_FINISHED="STEP_FINISHED",t.REASONING_START="REASONING_START",t.REASONING_MESSAGE_START="REASONING_MESSAGE_START",t.REASONING_MESSAGE_CONTENT="REASONING_MESSAGE_CONTENT",t.REASONING_MESSAGE_END="REASONING_MESSAGE_END",t.REASONING_MESSAGE_CHUNK="REASONING_MESSAGE_CHUNK",t.REASONING_END="REASONING_END",t.REASONING_ENCRYPTED_VALUE="REASONING_ENCRYPTED_VALUE",t})({}),X=u.object({type:u.nativeEnum(v),timestamp:u.number().optional(),rawEvent:u.any().optional()}).passthrough(),nf=X.extend({type:u.literal(v.TEXT_MESSAGE_START),messageId:u.string(),role:Ml.default("assistant"),name:u.string().optional()}),Ll=X.extend({type:u.literal(v.TEXT_MESSAGE_CONTENT),messageId:u.string(),delta:u.string()}),rf=X.extend({type:u.literal(v.TEXT_MESSAGE_END),messageId:u.string()}),of=X.extend({type:u.literal(v.TEXT_MESSAGE_CHUNK),messageId:u.string().optional(),role:Ml.optional(),delta:u.string().optional(),name:u.string().optional()}),sf=X.extend({type:u.literal(v.THINKING_TEXT_MESSAGE_START)}),af=Ll.omit({messageId:!0,type:!0}).extend({type:u.literal(v.THINKING_TEXT_MESSAGE_CONTENT)}),lf=X.extend({type:u.literal(v.THINKING_TEXT_MESSAGE_END)}),cf=X.extend({type:u.literal(v.TOOL_CALL_START),toolCallId:u.string(),toolCallName:u.string(),parentMessageId:u.string().optional()}),uf=X.extend({type:u.literal(v.TOOL_CALL_ARGS),toolCallId:u.string(),delta:u.string()}),df=X.extend({type:u.literal(v.TOOL_CALL_END),toolCallId:u.string()}),pf=X.extend({messageId:u.string(),type:u.literal(v.TOOL_CALL_RESULT),toolCallId:u.string(),content:u.string(),role:u.literal("tool").optional()}),hf=X.extend({type:u.literal(v.TOOL_CALL_CHUNK),toolCallId:u.string().optional(),toolCallName:u.string().optional(),parentMessageId:u.string().optional(),delta:u.string().optional()}),ff=X.extend({type:u.literal(v.THINKING_START),title:u.string().optional()}),mf=X.extend({type:u.literal(v.THINKING_END)}),gf=X.extend({type:u.literal(v.STATE_SNAPSHOT),snapshot:$h}),vf=X.extend({type:u.literal(v.STATE_DELTA),delta:u.array(u.any())}),bf=X.extend({type:u.literal(v.MESSAGES_SNAPSHOT),messages:u.array(Nl)}),yf=X.extend({type:u.literal(v.ACTIVITY_SNAPSHOT),messageId:u.string(),activityType:u.string(),content:u.record(u.any()),replace:u.boolean().optional().default(!0)}),xf=X.extend({type:u.literal(v.ACTIVITY_DELTA),messageId:u.string(),activityType:u.string(),patch:u.array(u.any())}),Ef=X.extend({type:u.literal(v.RAW),event:u.any(),source:u.string().optional()}),_f=X.extend({type:u.literal(v.CUSTOM),name:u.string(),value:u.any()}),Tf=X.extend({type:u.literal(v.RUN_STARTED),threadId:u.string(),runId:u.string(),parentRunId:u.string().optional(),input:Fh.optional()}),wf=u.object({type:u.literal("success")}).strict(),Sf=u.object({type:u.literal("interrupt"),interrupts:u.array(zh).min(1)}).strict(),Af=u.discriminatedUnion("type",[wf,Sf]),kf=X.extend({type:u.literal(v.RUN_FINISHED),threadId:u.string(),runId:u.string(),result:u.any().optional(),outcome:Af.nullable().optional().transform(t=>t??void 0)}),Cf=X.extend({type:u.literal(v.RUN_ERROR),message:u.string(),code:u.string().optional()}),If=X.extend({type:u.literal(v.STEP_STARTED),stepName:u.string()}),Rf=X.extend({type:u.literal(v.STEP_FINISHED),stepName:u.string()}),Nf=u.union([u.literal("tool-call"),u.literal("message")]),Of=X.extend({type:u.literal(v.REASONING_START),messageId:u.string()}),Mf=X.extend({type:u.literal(v.REASONING_MESSAGE_START),messageId:u.string(),role:u.literal("reasoning")}),Lf=X.extend({type:u.literal(v.REASONING_MESSAGE_CONTENT),messageId:u.string(),delta:u.string()}),Pf=X.extend({type:u.literal(v.REASONING_MESSAGE_END),messageId:u.string()}),Df=X.extend({type:u.literal(v.REASONING_MESSAGE_CHUNK),messageId:u.string().optional(),delta:u.string().optional()}),Uf=X.extend({type:u.literal(v.REASONING_END),messageId:u.string()}),Hf=X.extend({type:u.literal(v.REASONING_ENCRYPTED_VALUE),subtype:Nf,entityId:u.string(),encryptedValue:u.string()}),qr=u.discriminatedUnion("type",[nf,Ll,rf,of,ff,mf,sf,af,lf,cf,uf,df,hf,pf,gf,vf,bf,yf,xf,Ef,_f,Tf,kf,Cf,If,Rf,Of,Mf,Lf,Pf,Df,Uf,Hf]);var Is={};ji(Is,{JsonPatchError:()=>he,_areEquals:()=>Jn,applyOperation:()=>Xt,applyPatch:()=>Qr,applyReducer:()=>Bf,deepClone:()=>Ff,getValueByPointer:()=>Zr,validate:()=>Dl,validator:()=>Jr});var zf=(function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,o){r.__proto__=o}||function(r,o){for(var i in o)o.hasOwnProperty(i)&&(r[i]=o[i])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),Gf=Object.prototype.hasOwnProperty;function Xr(t,e){return Gf.call(t,e)}function Yr(t){if(Array.isArray(t)){for(var e=new Array(t.length),n=0;n<e.length;n++)e[n]=""+n;return e}if(Object.keys)return Object.keys(t);var r=[];for(var o in t)Xr(t,o)&&r.push(o);return r}function _e(t){switch(typeof t){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t}}function Kr(t){for(var e=0,n=t.length,r;e<n;){if(r=t.charCodeAt(e),r>=48&&r<=57){e++;continue}return!1}return!0}function ot(t){return t.indexOf("/")===-1&&t.indexOf("~")===-1?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function Kn(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Wr(t){if(t===void 0)return!0;if(t){if(Array.isArray(t)){for(var e=0,n=t.length;e<n;e++)if(Wr(t[e]))return!0}else if(typeof t=="object"){for(var r=Yr(t),o=r.length,i=0;i<o;i++)if(Wr(t[r[i]]))return!0}}return!1}function Pl(t,e){var n=[t];for(var r in e){var o=typeof e[r]=="object"?JSON.stringify(e[r],null,2):e[r];typeof o<"u"&&n.push(r+": "+o)}return n.join(`
|
|
2
|
+
`)}var Zn=(function(t){zf(e,t);function e(n,r,o,i,s){var a=this.constructor,l=t.call(this,Pl(n,{name:r,index:o,operation:i,tree:s}))||this;return l.name=r,l.index=o,l.operation=i,l.tree=s,Object.setPrototypeOf(l,a.prototype),l.message=Pl(n,{name:r,index:o,operation:i,tree:s}),l}return e})(Error);var he=Zn,Ff=_e,En={add:function(t,e,n){return t[e]=this.value,{newDocument:n}},remove:function(t,e,n){var r=t[e];return delete t[e],{newDocument:n,removed:r}},replace:function(t,e,n){var r=t[e];return t[e]=this.value,{newDocument:n,removed:r}},move:function(t,e,n){var r=Zr(n,this.path);r&&(r=_e(r));var o=Xt(n,{op:"remove",path:this.from}).removed;return Xt(n,{op:"add",path:this.path,value:o}),{newDocument:n,removed:r}},copy:function(t,e,n){var r=Zr(n,this.from);return Xt(n,{op:"add",path:this.path,value:_e(r)}),{newDocument:n}},test:function(t,e,n){return{newDocument:n,test:Jn(t[e],this.value)}},_get:function(t,e,n){return this.value=t[e],{newDocument:n}}},$f={add:function(t,e,n){return Kr(e)?t.splice(e,0,this.value):t[e]=this.value,{newDocument:n,index:e}},remove:function(t,e,n){var r=t.splice(e,1);return{newDocument:n,removed:r[0]}},replace:function(t,e,n){var r=t[e];return t[e]=this.value,{newDocument:n,removed:r}},move:En.move,copy:En.copy,test:En.test,_get:En._get};function Zr(t,e){if(e=="")return t;var n={op:"_get",path:e};return Xt(t,n),n.value}function Xt(t,e,n,r,o,i){if(n===void 0&&(n=!1),r===void 0&&(r=!0),o===void 0&&(o=!0),i===void 0&&(i=0),n&&(typeof n=="function"?n(e,0,t,e.path):Jr(e,0)),e.path===""){var s={newDocument:t};if(e.op==="add")return s.newDocument=e.value,s;if(e.op==="replace")return s.newDocument=e.value,s.removed=t,s;if(e.op==="move"||e.op==="copy")return s.newDocument=Zr(t,e.from),e.op==="move"&&(s.removed=t),s;if(e.op==="test"){if(s.test=Jn(t,e.value),s.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",i,e,t);return s.newDocument=t,s}else{if(e.op==="remove")return s.removed=t,s.newDocument=null,s;if(e.op==="_get")return e.value=t,s;if(n)throw new he("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",i,e,t);return s}}else{r||(t=_e(t));var a=e.path||"",l=a.split("/"),c=t,h=1,m=l.length,y=void 0,f=void 0,p=void 0;for(typeof n=="function"?p=n:p=Jr;;){if(f=l[h],f&&f.indexOf("~")!=-1&&(f=Kn(f)),o&&(f=="__proto__"||f=="prototype"&&h>0&&l[h-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&&y===void 0&&(c[f]===void 0?y=l.slice(0,h).join("/"):h==m-1&&(y=e.path),y!==void 0&&p(e,0,t,y)),h++,Array.isArray(c)){if(f==="-")f=c.length;else{if(n&&!Kr(f))throw new he("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",i,e,t);Kr(f)&&(f=~~f)}if(h>=m){if(n&&e.op==="add"&&f>c.length)throw new he("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",i,e,t);var s=$f[e.op].call(e,c,f,t);if(s.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",i,e,t);return s}}else if(h>=m){var s=En[e.op].call(e,c,f,t);if(s.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",i,e,t);return s}if(c=c[f],n&&h<m&&(!c||typeof c!="object"))throw new he("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",i,e,t)}}}function Qr(t,e,n,r,o){if(r===void 0&&(r=!0),o===void 0&&(o=!0),n&&!Array.isArray(e))throw new he("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(t=_e(t));for(var i=new Array(e.length),s=0,a=e.length;s<a;s++)i[s]=Xt(t,e[s],n,!0,o,s),t=i[s].newDocument;return i.newDocument=t,i}function Bf(t,e,n){var r=Xt(t,e);if(r.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",n,e,t);return r.newDocument}function Jr(t,e,n,r){if(typeof t!="object"||t===null||Array.isArray(t))throw new he("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,t,n);if(En[t.op]){if(typeof t.path!="string")throw new he("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,t,n);if(t.path.indexOf("/")!==0&&t.path.length>0)throw new he('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,t,n);if((t.op==="move"||t.op==="copy")&&typeof t.from!="string")throw new he("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,t,n);if((t.op==="add"||t.op==="replace"||t.op==="test")&&t.value===void 0)throw new he("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,t,n);if((t.op==="add"||t.op==="replace"||t.op==="test")&&Wr(t.value))throw new he("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,t,n);if(n){if(t.op=="add"){var o=t.path.split("/").length,i=r.split("/").length;if(o!==i+1&&o!==i)throw new he("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,t,n)}else if(t.op==="replace"||t.op==="remove"||t.op==="_get"){if(t.path!==r)throw new he("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,t,n)}else if(t.op==="move"||t.op==="copy"){var s={op:"_get",path:t.from,value:void 0},a=Dl([s],n);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new he("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,t,n)}}}else throw new he("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,t,n)}function Dl(t,e,n){try{if(!Array.isArray(t))throw new he("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)Qr(_e(e),_e(t),n||!0);else{n=n||Jr;for(var r=0;r<t.length;r++)n(t[r],r,e,void 0)}}catch(o){if(o instanceof he)return o;throw o}}function Jn(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var n=Array.isArray(t),r=Array.isArray(e),o,i,s;if(n&&r){if(i=t.length,i!=e.length)return!1;for(o=i;o--!==0;)if(!Jn(t[o],e[o]))return!1;return!0}if(n!=r)return!1;var a=Object.keys(t);if(i=a.length,i!==Object.keys(e).length)return!1;for(o=i;o--!==0;)if(!e.hasOwnProperty(a[o]))return!1;for(o=i;o--!==0;)if(s=a[o],!Jn(t[s],e[s]))return!1;return!0}return t!==t&&e!==e}var Ms={};ji(Ms,{compare:()=>Zf,generate:()=>Rs,observe:()=>Kf,unobserve:()=>Yf});var Ns=new WeakMap,Vf=(function(){function t(e){this.observers=new Map,this.obj=e}return t})(),jf=(function(){function t(e,n){this.callback=e,this.observer=n}return t})();function qf(t){return Ns.get(t)}function Wf(t,e){return t.observers.get(e)}function Xf(t,e){t.observers.delete(e.callback)}function Yf(t,e){e.unobserve()}function Kf(t,e){var n=[],r,o=qf(t);if(!o)o=new Vf(t),Ns.set(t,o);else{var i=Wf(o,e);r=i&&i.observer}if(r)return r;if(r={},o.value=_e(t),e){r.callback=e,r.next=null;var s=function(){Rs(r)},a=function(){clearTimeout(r.next),r.next=setTimeout(s)};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=t,r.unobserve=function(){Rs(r),clearTimeout(r.next),Xf(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(e,new jf(e,r)),r}function Rs(t,e){e===void 0&&(e=!1);var n=Ns.get(t.object);Os(n.value,t.object,t.patches,"",e),t.patches.length&&Qr(n.value,t.patches);var r=t.patches;return r.length>0&&(t.patches=[],t.callback&&t.callback(r)),r}function Os(t,e,n,r,o){if(e!==t){typeof e.toJSON=="function"&&(e=e.toJSON());for(var i=Yr(e),s=Yr(t),a=!1,l=!1,c=s.length-1;c>=0;c--){var h=s[c],m=t[h];if(Xr(e,h)&&!(e[h]===void 0&&m!==void 0&&Array.isArray(e)===!1)){var y=e[h];typeof m=="object"&&m!=null&&typeof y=="object"&&y!=null&&Array.isArray(m)===Array.isArray(y)?Os(m,y,n,r+"/"+ot(h),o):m!==y&&(a=!0,o&&n.push({op:"test",path:r+"/"+ot(h),value:_e(m)}),n.push({op:"replace",path:r+"/"+ot(h),value:_e(y)}))}else Array.isArray(t)===Array.isArray(e)?(o&&n.push({op:"test",path:r+"/"+ot(h),value:_e(m)}),n.push({op:"remove",path:r+"/"+ot(h)}),l=!0):(o&&n.push({op:"test",path:r,value:t}),n.push({op:"replace",path:r,value:e}),a=!0)}if(!(!l&&i.length==s.length))for(var c=0;c<i.length;c++){var h=i[c];!Xr(t,h)&&e[h]!==void 0&&n.push({op:"add",path:r+"/"+ot(h),value:_e(e[h])})}}}function Zf(t,e,n){n===void 0&&(n=!1);var r=[];return Os(t,e,r,"",n),r}var eo=Object.assign({},Is,Ms,{JsonPatchError:Zn,deepClone:_e,escapePathComponent:ot,unescapePathComponent:Kn});var Ls=function(t,e){return Ls=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])},Ls(t,e)};function it(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ls(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function Ul(t,e,n,r){function o(i){return i instanceof n?i:new n(function(s){s(i)})}return new(n||(n=Promise))(function(i,s){function a(h){try{c(r.next(h))}catch(m){s(m)}}function l(h){try{c(r.throw(h))}catch(m){s(m)}}function c(h){h.done?i(h.value):o(h.value).then(a,l)}c((r=r.apply(t,e||[])).next())})}function to(t,e){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},r,o,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,o&&(i=c[0]&2?o.return:c[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,c[1])).done)return i;switch(o=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=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(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1],i=c;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(c);break}i[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(h){c=[6,h],o=0}finally{r=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function ht(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function _n(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=r.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return i}function Tn(t,e,n){if(n||arguments.length===2)for(var r=0,o=e.length,i;r<o;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}function Yt(t){return this instanceof Yt?(this.v=t,this):new Yt(t)}function Hl(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),o[Symbol.asyncIterator]=function(){return this},o;function s(f){return function(p){return Promise.resolve(p).then(f,m)}}function a(f,p){r[f]&&(o[f]=function(g){return new Promise(function(x,S){i.push([f,g,x,S])>1||l(f,g)})},p&&(o[f]=p(o[f])))}function l(f,p){try{c(r[f](p))}catch(g){y(i[0][3],g)}}function c(f){f.value instanceof Yt?Promise.resolve(f.value.v).then(h,m):y(i[0][2],f)}function h(f){l("next",f)}function m(f){l("throw",f)}function y(f,p){f(p),i.shift(),i.length&&l(i[0][0],i[0][1])}}function zl(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof ht=="function"?ht(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(i){n[i]=t[i]&&function(s){return new Promise(function(a,l){s=t[i](s),o(a,l,s.done,s.value)})}}function o(i,s,a,l){Promise.resolve(l).then(function(c){i({value:c,done:a})},s)}}function B(t){return typeof t=="function"}function wn(t){var e=function(r){Error.call(r),r.stack=new Error().stack},n=t(e);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var no=wn(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
3
3
|
`+n.map(function(r,o){return o+1+") "+r.toString()}).join(`
|
|
4
|
-
`):"",this.name="UnsubscriptionError",this.errors=n}});function Zn(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var Sn=(function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,n,r,o,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=pt(s),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(g){e={error:g}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}else s.remove(this);var h=this.initialTeardown;if(B(h))try{h()}catch(g){i=g instanceof Qr?g.errors:[g]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var y=pt(m),f=y.next();!f.done;f=y.next()){var p=f.value;try{Pl(p)}catch(g){i=i??[],g instanceof Qr?i=Tn(Tn([],En(i)),En(g.errors)):i.push(g)}}}catch(g){r={error:g}}finally{try{f&&!f.done&&(o=y.return)&&o.call(y)}finally{if(r)throw r.error}}}if(i)throw new Qr(i)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)Pl(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(e)}},t.prototype._hasParent=function(e){var n=this._parentage;return n===e||Array.isArray(n)&&n.includes(e)},t.prototype._addParent=function(e){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(e),n):n?[n,e]:e},t.prototype._removeParent=function(e){var n=this._parentage;n===e?this._parentage=null:Array.isArray(n)&&Zn(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&Zn(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=(function(){var e=new t;return e.closed=!0,e})(),t})();var Ns=Sn.EMPTY;function eo(t){return t instanceof Sn||t&&"closed"in t&&B(t.remove)&&B(t.add)&&B(t.unsubscribe)}function Pl(t){B(t)?t():t.unsubscribe()}var qe={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var _n={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=_n.delegate;return o?.setTimeout?o.setTimeout.apply(o,Tn([t,e],En(n))):setTimeout.apply(void 0,Tn([t,e],En(n)))},clearTimeout:function(t){var e=_n.delegate;return(e?.clearTimeout||clearTimeout)(t)},delegate:void 0};function to(t){_n.setTimeout(function(){var e=qe.onUnhandledError;if(e)e(t);else throw t})}function Jn(){}var Dl=(function(){return Os("C",void 0,void 0)})();function Ul(t){return Os("E",void 0,t)}function Hl(t){return Os("N",t,void 0)}function Os(t,e,n){return{kind:t,value:e,error:n}}var Yt=null;function An(t){if(qe.useDeprecatedSynchronousErrorHandling){var e=!Yt;if(e&&(Yt={errorThrown:!1,error:null}),t(),e){var n=Yt,r=n.errorThrown,o=n.error;if(Yt=null,r)throw o}}else t()}function Gl(t){qe.useDeprecatedSynchronousErrorHandling&&Yt&&(Yt.errorThrown=!0,Yt.error=t)}var Qn=(function(t){ot(e,t);function e(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,eo(n)&&n.add(r)):r.destination=Bf,r}return e.create=function(n,r,o){return new ro(n,r,o)},e.prototype.next=function(n){this.isStopped?Ls(Hl(n),this):this._next(n)},e.prototype.error=function(n){this.isStopped?Ls(Ul(n),this):(this.isStopped=!0,this._error(n))},e.prototype.complete=function(){this.isStopped?Ls(Dl,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(n){this.destination.next(n)},e.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e})(Sn);var zf=Function.prototype.bind;function Ms(t,e){return zf.call(t,e)}var Ff=(function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var n=this.partialObserver;if(n.next)try{n.next(e)}catch(r){no(r)}},t.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(r){no(r)}else no(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){no(n)}},t})(),ro=(function(t){ot(e,t);function e(n,r,o){var i=t.call(this)||this,s;if(B(n)||!n)s={next:n??void 0,error:r??void 0,complete:o??void 0};else{var a;i&&qe.useDeprecatedNextContext?(a=Object.create(n),a.unsubscribe=function(){return i.unsubscribe()},s={next:n.next&&Ms(n.next,a),error:n.error&&Ms(n.error,a),complete:n.complete&&Ms(n.complete,a)}):s=n}return i.destination=new Ff(s),i}return e})(Qn);function no(t){qe.useDeprecatedSynchronousErrorHandling?Gl(t):to(t)}function $f(t){throw t}function Ls(t,e){var n=qe.onStoppedNotification;n&&_n.setTimeout(function(){return n(t,e)})}var Bf={closed:!0,next:Jn,error:$f,complete:Jn};var kn=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function In(t){return t}function oo(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Ps(t)}function Ps(t){return t.length===0?In:t.length===1?t[0]:function(n){return t.reduce(function(r,o){return o(r)},n)}}var te=(function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(e,n,r){var o=this,i=jf(e)?e:new ro(e,n,r);return An(function(){var s=o,a=s.operator,l=s.source;i.add(a?a.call(i,l):l?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(n){e.error(n)}},t.prototype.forEach=function(e,n){var r=this;return n=zl(n),new n(function(o,i){var s=new ro({next:function(a){try{e(a)}catch(l){i(l),s.unsubscribe()}},error:i,complete:o});r.subscribe(s)})},t.prototype._subscribe=function(e){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(e)},t.prototype[kn]=function(){return this},t.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return Ps(e)(this)},t.prototype.toPromise=function(e){var n=this;return e=zl(e),new e(function(r,o){var i;n.subscribe(function(s){return i=s},function(s){return o(s)},function(){return r(i)})})},t.create=function(e){return new t(e)},t})();function zl(t){var e;return(e=t??qe.Promise)!==null&&e!==void 0?e:Promise}function Vf(t){return t&&B(t.next)&&B(t.error)&&B(t.complete)}function jf(t){return t&&t instanceof Qn||Vf(t)&&eo(t)}function qf(t){return B(t?.lift)}function fe(t){return function(e){if(qf(e))return e.lift(function(n){try{return t(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function ge(t,e,n,r,o){return new Wf(t,e,n,r,o)}var Wf=(function(t){ot(e,t);function e(n,r,o,i,s,a){var l=t.call(this,n)||this;return l.onFinalize=s,l.shouldUnsubscribe=a,l._next=r?function(c){try{r(c)}catch(h){n.error(h)}}:t.prototype._next,l._error=i?function(c){try{i(c)}catch(h){n.error(h)}finally{this.unsubscribe()}}:t.prototype._error,l._complete=o?function(){try{o()}catch(c){n.error(c)}finally{this.unsubscribe()}}:t.prototype._complete,l}return e.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},e})(Qn);var Fl=wn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var it=(function(t){ot(e,t);function e(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return e.prototype.lift=function(n){var r=new $l(this,this);return r.operator=n,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new Fl},e.prototype.next=function(n){var r=this;An(function(){var o,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=pt(r.currentObservers),a=s.next();!a.done;a=s.next()){var l=a.value;l.next(n)}}catch(c){o={error:c}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}}})},e.prototype.error=function(n){var r=this;An(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)}})},e.prototype.complete=function(){var n=this;An(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},e.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},e.prototype._innerSubscribe=function(n){var r=this,o=this,i=o.hasError,s=o.isStopped,a=o.observers;return i||s?Ns:(this.currentObservers=null,a.push(n),new Sn(function(){r.currentObservers=null,Zn(a,n)}))},e.prototype._checkFinalizedStatuses=function(n){var r=this,o=r.hasError,i=r.thrownError,s=r.isStopped;o?n.error(i):s&&n.complete()},e.prototype.asObservable=function(){var n=new te;return n.source=this,n},e.create=function(n,r){return new $l(n,r)},e})(te);var $l=(function(t){ot(e,t);function e(n,r){var o=t.call(this)||this;return o.destination=n,o.source=r,o}return e.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)},e.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)},e.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)},e.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:Ns},e})(it);var Ds={now:function(){return(Ds.delegate||Date).now()},delegate:void 0};var io=(function(t){ot(e,t);function e(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=Ds);var i=t.call(this)||this;return i._bufferSize=n,i._windowTime=r,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,n),i._windowTime=Math.max(1,r),i}return e.prototype.next=function(n){var r=this,o=r.isStopped,i=r._buffer,s=r._infiniteTimeWindow,a=r._timestampProvider,l=r._windowTime;o||(i.push(n),!s&&i.push(a.now()+l)),this._trimBuffer(),t.prototype.next.call(this,n)},e.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),o=this,i=o._infiniteTimeWindow,s=o._buffer,a=s.slice(),l=0;l<a.length&&!n.closed;l+=i?1:2)n.next(a[l]);return this._checkFinalizedStatuses(n),r},e.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,o=n._timestampProvider,i=n._buffer,s=n._infiniteTimeWindow,a=(s?1:2)*r;if(r<1/0&&a<i.length&&i.splice(0,i.length-a),!s){for(var l=o.now(),c=0,h=1;h<i.length&&i[h]<=l;h+=2)c=h;c&&i.splice(0,c+1)}},e})(it);var so=new te(function(t){return t.complete()});function Bl(t){return t&&B(t.schedule)}function Xf(t){return t[t.length-1]}function Vl(t){return Bl(Xf(t))?t.pop():void 0}var ao=(function(t){return t&&typeof t.length=="number"&&typeof t!="function"});function lo(t){return B(t?.then)}function co(t){return B(t[kn])}function uo(t){return Symbol.asyncIterator&&B(t?.[Symbol.asyncIterator])}function po(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Yf(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ho=Yf();function fo(t){return B(t?.[ho])}function mo(t){return Ml(this,arguments,function(){var n,r,o,i;return Jr(this,function(s){switch(s.label){case 0:n=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,Xt(n.read())];case 3:return r=s.sent(),o=r.value,i=r.done,i?[4,Xt(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,Xt(o)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function go(t){return B(t?.getReader)}function ve(t){if(t instanceof te)return t;if(t!=null){if(co(t))return Kf(t);if(ao(t))return Zf(t);if(lo(t))return Jf(t);if(uo(t))return jl(t);if(fo(t))return Qf(t);if(go(t))return em(t)}throw po(t)}function Kf(t){return new te(function(e){var n=t[kn]();if(B(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Zf(t){return new te(function(e){for(var n=0;n<t.length&&!e.closed;n++)e.next(t[n]);e.complete()})}function Jf(t){return new te(function(e){t.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,to)})}function Qf(t){return new te(function(e){var n,r;try{for(var o=pt(t),i=o.next();!i.done;i=o.next()){var s=i.value;if(e.next(s),e.closed)return}}catch(a){n={error:a}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}e.complete()})}function jl(t){return new te(function(e){tm(t,e).catch(function(n){return e.error(n)})})}function em(t){return jl(mo(t))}function tm(t,e){var n,r,o,i;return Ol(this,void 0,void 0,function(){var s,a;return Jr(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=Ll(t),l.label=1;case 1:return[4,n.next()];case 2:if(r=l.sent(),!!r.done)return[3,4];if(s=r.value,e.next(s),e.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),o={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),r&&!r.done&&(i=n.return)?[4,i.call(n)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function $e(t,e,n,r,o){r===void 0&&(r=0),o===void 0&&(o=!1);var i=e.schedule(function(){n(),o?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(i),!o)return i}function vo(t,e){return e===void 0&&(e=0),fe(function(n,r){n.subscribe(ge(r,function(o){return $e(r,t,function(){return r.next(o)},e)},function(){return $e(r,t,function(){return r.complete()},e)},function(o){return $e(r,t,function(){return r.error(o)},e)}))})}function bo(t,e){return e===void 0&&(e=0),fe(function(n,r){r.add(t.schedule(function(){return n.subscribe(r)},e))})}function ql(t,e){return ve(t).pipe(bo(e),vo(e))}function Wl(t,e){return ve(t).pipe(bo(e),vo(e))}function Xl(t,e){return new te(function(n){var r=0;return e.schedule(function(){r===t.length?n.complete():(n.next(t[r++]),n.closed||this.schedule())})})}function Yl(t,e){return new te(function(n){var r;return $e(n,e,function(){r=t[ho](),$e(n,e,function(){var o,i,s;try{o=r.next(),i=o.value,s=o.done}catch(a){n.error(a);return}s?n.complete():n.next(i)},0,!0)}),function(){return B(r?.return)&&r.return()}})}function yo(t,e){if(!t)throw new Error("Iterable cannot be null");return new te(function(n){$e(n,e,function(){var r=t[Symbol.asyncIterator]();$e(n,e,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function Kl(t,e){return yo(mo(t),e)}function Zl(t,e){if(t!=null){if(co(t))return ql(t,e);if(ao(t))return Xl(t,e);if(lo(t))return Wl(t,e);if(uo(t))return yo(t,e);if(fo(t))return Yl(t,e);if(go(t))return Kl(t,e)}throw po(t)}function Kt(t,e){return e?Zl(t,e):ve(t)}function ue(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Vl(t);return Kt(t,n)}function ne(t,e){var n=B(t)?t:function(){return t},r=function(o){return o.error(n())};return new te(e?function(o){return e.schedule(r,0,o)}:r)}var Jl=wn(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}});function xo(t,e){var n=typeof e=="object";return new Promise(function(r,o){var i=!1,s;t.subscribe({next:function(a){s=a,i=!0},error:o,complete:function(){i?r(s):n?r(e.defaultValue):o(new Jl)}})})}function Zt(t,e){return fe(function(n,r){var o=0;n.subscribe(ge(r,function(i){r.next(t.call(e,i,o++))}))})}function Ql(t,e,n,r,o,i,s,a){var l=[],c=0,h=0,m=!1,y=function(){m&&!l.length&&!c&&e.complete()},f=function(g){return c<r?p(g):l.push(g)},p=function(g){i&&e.next(g),c++;var x=!1;ve(n(g,h++)).subscribe(ge(e,function(_){o?.(_),i?f(_):e.next(_)},function(){x=!0},void 0,function(){if(x)try{c--;for(var _=function(){var w=l.shift();s?$e(e,s,function(){return p(w)}):p(w)};l.length&&c<r;)_();y()}catch(w){e.error(w)}}))};return t.subscribe(ge(e,f,function(){m=!0,y()})),function(){a?.()}}function Me(t,e,n){return n===void 0&&(n=1/0),B(e)?Me(function(r,o){return Zt(function(i,s){return e(r,i,o,s)})(ve(t(r,o)))},n):(typeof e=="number"&&(n=e),fe(function(r,o){return Ql(r,o,t,n)}))}function Us(t){return t===void 0&&(t=1/0),Me(In,t)}function Eo(t){return new te(function(e){ve(t()).subscribe(e)})}function er(t){return fe(function(e,n){var r=null,o=!1,i;r=e.subscribe(ge(n,void 0,void 0,function(s){i=ve(t(s,er(t)(e))),r?(r.unsubscribe(),r=null,i.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,i.subscribe(n))})}function To(t,e){return B(e)?Me(t,e,1):Me(t,1)}function Hs(t){return fe(function(e,n){var r=!1;e.subscribe(ge(n,function(o){r=!0,n.next(o)},function(){r||n.next(t),n.complete()}))})}function Jt(t){return fe(function(e,n){try{e.subscribe(n)}finally{n.add(t)}})}function Gs(t,e){return fe(function(n,r){var o=null,i=0,s=!1,a=function(){return s&&!o&&r.complete()};n.subscribe(ge(r,function(l){o?.unsubscribe();var c=0,h=i++;ve(t(l,h)).subscribe(o=ge(r,function(m){return r.next(e?e(l,m,h,c++):m)},function(){o=null,a()}))},function(){s=!0,a()}))})}function wo(t){return fe(function(e,n){ve(t).subscribe(ge(n,function(){return n.complete()},Jn)),!n.closed&&e.subscribe(n)})}function zs(t,e,n){var r=B(t)||e||n?{next:t,error:e,complete:n}:t;return r?fe(function(o,i){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var a=!0;o.subscribe(ge(i,function(l){var c;(c=r.next)===null||c===void 0||c.call(r,l),i.next(l)},function(){var l;a=!1,(l=r.complete)===null||l===void 0||l.call(r),i.complete()},function(l){var c;a=!1,(c=r.error)===null||c===void 0||c.call(r,l),i.error(l)},function(){var l,c;a&&((l=r.unsubscribe)===null||l===void 0||l.call(r)),(c=r.finalize)===null||c===void 0||c.call(r)}))}):In}function ec(t){return` \r
|
|
5
|
-
`.indexOf(t)>=0}function So(t){for(var e=["topLevel"],n=0,r,o,i,s=function(w){return e.push(w)},a=function(w){return e[e.length-1]=w},l=function(w){r==null&&(r=n,o=e.length,i=w)},c=function(w){w===i&&(r=void 0,o=void 0,i=void 0)},h=function(){return e.pop()},m=function(){return n--},y=function(w){if("0"<=w&&w<="9"){s("number");return}switch(w){case'"':s("string");return;case"-":s("numberNeedsDigit");return;case"t":s("true");return;case"f":s("false");return;case"n":s("null");return;case"[":s("arrayNeedsValue");return;case"{":s("objectNeedsKey");return}},f=t.length;n<f;n++){var p=t[n];switch(e[e.length-1]){case"topLevel":y(p);break;case"string":switch(p){case'"':h();break;case"\\":l("stringEscape"),s("stringEscaped");break}break;case"stringEscaped":p==="u"?s("stringUnicode"):(c("stringEscape"),h());break;case"stringUnicode":n-t.lastIndexOf("u",n)===4&&(c("stringEscape"),h());break;case"number":p==="."?a("numberNeedsDigit"):p==="e"||p==="E"?a("numberNeedsExponent"):(p<"0"||p>"9")&&(m(),h());break;case"numberNeedsDigit":a("number");break;case"numberNeedsExponent":a(p==="+"||p==="-"?"numberNeedsDigit":"number");break;case"true":case"false":case"null":(p<"a"||p>"z")&&(m(),h());break;case"arrayNeedsValue":p==="]"?h():ec(p)||(c("collectionItem"),a("arrayNeedsComma"),y(p));break;case"arrayNeedsComma":p==="]"?h():p===","&&(l("collectionItem"),a("arrayNeedsValue"));break;case"objectNeedsKey":p==="}"?h():p==='"'&&(l("collectionItem"),a("objectNeedsColon"),s("string"));break;case"objectNeedsColon":p===":"&&a("objectNeedsValue");break;case"objectNeedsValue":ec(p)||(c("collectionItem"),a("objectNeedsComma"),y(p));break;case"objectNeedsComma":p==="}"?h():p===","&&(l("collectionItem"),a("objectNeedsKey"));break}}o!=null&&(e.length=o);for(var g=[r!=null?t.slice(0,r):t],x=function(w){return g.push(w.slice(t.length-t.lastIndexOf(w[0])))},_=e.length-1;_>=0;_--)switch(e[_]){case"string":g.push('"');break;case"numberNeedsDigit":case"numberNeedsExponent":g.push("0");break;case"true":x("true");break;case"false":x("false");break;case"null":x("null");break;case"arrayNeedsValue":case"arrayNeedsComma":g.push("]");break;case"objectNeedsKey":case"objectNeedsColon":case"objectNeedsValue":case"objectNeedsComma":g.push("}");break}return g.join("")}function nc(){let t=0,e=0;for(let r=0;r<28;r+=7){let o=this.buf[this.pos++];if(t|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(n&15)<<28,e=(n&112)>>4,(n&128)==0)return this.assertBounds(),[t,e];for(let r=3;r<=31;r+=7){let o=this.buf[this.pos++];if(e|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Ao(t,e,n){for(let i=0;i<28;i=i+7){let s=t>>>i,a=!(!(s>>>7)&&e==0),l=(a?s|128:s)&255;if(n.push(l),!a)return}let r=t>>>28&15|(e&7)<<4,o=e>>3!=0;if(n.push((o?r|128:r)&255),!!o){for(let i=3;i<31;i=i+7){let s=e>>>i,a=!!(s>>>7),l=(a?s|128:s)&255;if(n.push(l),!a)return}n.push(e>>>31&1)}}var _o=4294967296;function Fs(t){let e=t[0]==="-";e&&(t=t.slice(1));let n=1e6,r=0,o=0;function i(s,a){let l=Number(t.slice(s,a));o*=n,r=r*n+l,r>=_o&&(o=o+(r/_o|0),r=r%_o)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),e?oc(r,o):Bs(r,o)}function rc(t,e){let n=Bs(t,e),r=n.hi&2147483648;r&&(n=oc(n.lo,n.hi));let o=$s(n.lo,n.hi);return r?"-"+o:o}function $s(t,e){if({lo:t,hi:e}=nm(t,e),e<=2097151)return String(_o*e+t);let n=t&16777215,r=(t>>>24|e<<8)&16777215,o=e>>16&65535,i=n+r*6777216+o*6710656,s=r+o*8147497,a=o*2,l=1e7;return i>=l&&(s+=Math.floor(i/l),i%=l),s>=l&&(a+=Math.floor(s/l),s%=l),a.toString()+tc(s)+tc(i)}function nm(t,e){return{lo:t>>>0,hi:e>>>0}}function Bs(t,e){return{lo:t|0,hi:e|0}}function oc(t,e){return e=~e,t?t=~t+1:e+=1,Bs(t,e)}var tc=t=>{let e=String(t);return"0000000".slice(e.length)+e};function Vs(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let n=0;n<9;n++)e.push(t&127|128),t=t>>7;e.push(1)}}function ic(){let t=this.buf[this.pos++],e=t&127;if((t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<7,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,(t&128)==0)return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let n=5;(t&128)!==0&&n<10;n++)t=this.buf[this.pos++];if((t&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var We=rm();function rm(){let t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(!!globalThis.Deno||!!globalThis.Bun||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let n=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),o=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(s){let a=typeof s=="bigint"?s:BigInt(s);if(a>r||a<n)throw new Error(`invalid int64: ${s}`);return a},uParse(s){let a=typeof s=="bigint"?s:BigInt(s);if(a>i||a<o)throw new Error(`invalid uint64: ${s}`);return a},enc(s){return t.setBigInt64(0,this.parse(s),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(s){return t.setBigInt64(0,this.uParse(s),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec(s,a){return t.setInt32(0,s,!0),t.setInt32(4,a,!0),t.getBigInt64(0,!0)},uDec(s,a){return t.setInt32(0,s,!0),t.setInt32(4,a,!0),t.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(n){return typeof n!="string"&&(n=n.toString()),sc(n),n},uParse(n){return typeof n!="string"&&(n=n.toString()),ac(n),n},enc(n){return typeof n!="string"&&(n=n.toString()),sc(n),Fs(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),ac(n),Fs(n)},dec(n,r){return rc(n,r)},uDec(n,r){return $s(n,r)}}}function sc(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function ac(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}var js=Symbol.for("@bufbuild/protobuf/text-encoding");function qs(){if(globalThis[js]==null){let t=new globalThis.TextEncoder,e=new globalThis.TextDecoder,n;globalThis[js]={encodeUtf8(r){return t.encode(r)},decodeUtf8(r,o){return o?(n===void 0&&(n=new globalThis.TextDecoder("utf-8",{fatal:!0})),n.decode(r)):e.decode(r)},checkUtf8(r){try{return encodeURIComponent(r),!0}catch{return!1}}}}return globalThis[js]}var St;(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(St||(St={}));var om=34028234663852886e22,im=-34028234663852886e22,sm=4294967295,am=2147483647,lm=-2147483648,F=class{constructor(e=qs().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let o=0;o<this.chunks.length;o++)e+=this.chunks[o].length;let n=new Uint8Array(e),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 e=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(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(lc(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Ws(e),Vs(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.encodeUtf8(e);return this.uint32(n.byteLength),this.raw(n)}float(e){cm(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){lc(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){Ws(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return Ws(e),e=(e<<1^e>>31)>>>0,Vs(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),o=We.enc(e);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),o=We.uEnc(e);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}int64(e){let n=We.enc(e);return Ao(n.lo,n.hi,this.buf),this}sint64(e){let n=We.enc(e),r=n.hi>>31,o=n.lo<<1^r,i=(n.hi<<1|n.lo>>>31)^r;return Ao(o,i,this.buf),this}uint64(e){let n=We.uEnc(e);return Ao(n.lo,n.hi,this.buf),this}},A=class{constructor(e,n=qs().decodeUtf8){this.decodeUtf8=n,this.varint64=nc,this.uint32=ic,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.pos,n=this.uint32(),r=this.pos-e;if(r>5||r==5&&this.buf[this.pos-1]>15)throw new Error("illegal tag: varint overflows uint32");let o=n>>>3,i=n&7;if(o<=0||i>5)throw new Error("illegal tag: field no "+o+" wire type "+i);return[o,i]}skip(e,n,r=100){let o=this.pos;switch(e){case St.Varint:for(;this.buf[this.pos++]&128;);break;case St.Bit64:this.pos+=4;case St.Bit32:this.pos+=4;break;case St.LengthDelimited:let i=this.uint32();this.pos+=i;break;case St.StartGroup:if(r<=0)throw new Error("maximum recursion depth reached");for(;;){let[s,a]=this.tag();if(a===St.EndGroup){if(n!==void 0&&s!==n)throw new Error("invalid end group tag");break}this.skip(a,s,r-1)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(o,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return We.dec(...this.varint64())}uint64(){return We.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),r=-(e&1);return e=(e>>>1|(n&1)<<31)^r,n=n>>>1^r,We.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==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 We.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return We.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 e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(e){return this.decodeUtf8(this.bytes(),e)}};function Ws(t){if(typeof t=="string")t=Number(t);else if(typeof t!="number")throw new Error("invalid int32: "+typeof t);if(!Number.isInteger(t)||t>am||t<lm)throw new Error("invalid int32: "+t)}function lc(t){if(typeof t=="string")t=Number(t);else if(typeof t!="number")throw new Error("invalid uint32: "+typeof t);if(!Number.isInteger(t)||t>sm||t<0)throw new Error("invalid uint32: "+t)}function cm(t){if(typeof t=="string"){let e=t;if(t=Number(t),Number.isNaN(t)&&e!=="NaN")throw new Error("invalid float32: "+e)}else if(typeof t!="number")throw new Error("invalid float32: "+typeof t);if(Number.isFinite(t)&&(t>om||t<im))throw new Error("invalid float32: "+t)}var um=(function(t){return t[t.NULL_VALUE=0]="NULL_VALUE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function Xs(){return{fields:{}}}var tr={encode(t,e=new F){return Object.entries(t.fields).forEach(([n,r])=>{r!==void 0&&Zs.encode({key:n,value:r},e.uint32(10).fork()).join()}),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Xs();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:{if(i!==10)break;let s=Zs.decode(n,n.uint32());s.value!==void 0&&(o.fields[s.key]=s.value);continue}}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return tr.fromPartial(t??{})},fromPartial(t){let e=Xs();return e.fields=Object.entries(t.fields??{}).reduce((n,[r,o])=>(o!==void 0&&(n[r]=o),n),{}),e},wrap(t){let e=Xs();if(t!==void 0)for(let n of Object.keys(t))e.fields[n]=t[n];return e},unwrap(t){let e={};if(t.fields)for(let n of Object.keys(t.fields))e[n]=t.fields[n];return e}};function cc(){return{key:"",value:void 0}}var Zs={encode(t,e=new F){return t.key!==""&&e.uint32(10).string(t.key),t.value!==void 0&&O.encode(O.wrap(t.value),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=cc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.key=n.string();continue;case 2:if(i!==18)break;o.value=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Zs.fromPartial(t??{})},fromPartial(t){let e=cc();return e.key=t.key??"",e.value=t.value??void 0,e}};function Ys(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var O={encode(t,e=new F){return t.nullValue!==void 0&&e.uint32(8).int32(t.nullValue),t.numberValue!==void 0&&e.uint32(17).double(t.numberValue),t.stringValue!==void 0&&e.uint32(26).string(t.stringValue),t.boolValue!==void 0&&e.uint32(32).bool(t.boolValue),t.structValue!==void 0&&tr.encode(tr.wrap(t.structValue),e.uint32(42).fork()).join(),t.listValue!==void 0&&nr.encode(nr.wrap(t.listValue),e.uint32(50).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ys();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==8)break;o.nullValue=n.int32();continue;case 2:if(i!==17)break;o.numberValue=n.double();continue;case 3:if(i!==26)break;o.stringValue=n.string();continue;case 4:if(i!==32)break;o.boolValue=n.bool();continue;case 5:if(i!==42)break;o.structValue=tr.unwrap(tr.decode(n,n.uint32()));continue;case 6:if(i!==50)break;o.listValue=nr.unwrap(nr.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return O.fromPartial(t??{})},fromPartial(t){let e=Ys();return e.nullValue=t.nullValue??void 0,e.numberValue=t.numberValue??void 0,e.stringValue=t.stringValue??void 0,e.boolValue=t.boolValue??void 0,e.structValue=t.structValue??void 0,e.listValue=t.listValue??void 0,e},wrap(t){let e=Ys();if(t===null)e.nullValue=um.NULL_VALUE;else if(typeof t=="boolean")e.boolValue=t;else if(typeof t=="number")e.numberValue=t;else if(typeof t=="string")e.stringValue=t;else if(globalThis.Array.isArray(t))e.listValue=t;else if(typeof t=="object")e.structValue=t;else if(typeof t<"u")throw new globalThis.Error("Unsupported any value type: "+typeof t);return e},unwrap(t){if(t.stringValue!==void 0)return t.stringValue;if(t?.numberValue!==void 0)return t.numberValue;if(t?.boolValue!==void 0)return t.boolValue;if(t?.structValue!==void 0)return t.structValue;if(t?.listValue!==void 0)return t.listValue;if(t?.nullValue!==void 0)return null}};function Ks(){return{values:[]}}var nr={encode(t,e=new F){for(let n of t.values)O.encode(O.wrap(n),e.uint32(10).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ks();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.values.push(O.unwrap(O.decode(n,n.uint32())));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return nr.fromPartial(t??{})},fromPartial(t){let e=Ks();return e.values=t.values?.map(n=>n)||[],e},wrap(t){let e=Ks();return e.values=t??[],e},unwrap(t){return t?.hasOwnProperty("values")&&globalThis.Array.isArray(t.values)?t.values:t}},dm=(function(t){return t[t.ADD=0]="ADD",t[t.REMOVE=1]="REMOVE",t[t.REPLACE=2]="REPLACE",t[t.MOVE=3]="MOVE",t[t.COPY=4]="COPY",t[t.TEST=5]="TEST",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function uc(){return{op:0,path:"",from:void 0,value:void 0}}var Io={encode(t,e=new F){return t.op!==0&&e.uint32(8).int32(t.op),t.path!==""&&e.uint32(18).string(t.path),t.from!==void 0&&e.uint32(26).string(t.from),t.value!==void 0&&O.encode(O.wrap(t.value),e.uint32(34).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=uc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==8)break;o.op=n.int32();continue;case 2:if(i!==18)break;o.path=n.string();continue;case 3:if(i!==26)break;o.from=n.string();continue;case 4:if(i!==34)break;o.value=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Io.fromPartial(t??{})},fromPartial(t){let e=uc();return e.op=t.op??0,e.path=t.path??"",e.from=t.from??void 0,e.value=t.value??void 0,e}};function dc(){return{id:"",type:"",function:void 0}}var Co={encode(t,e=new F){return t.id!==""&&e.uint32(10).string(t.id),t.type!==""&&e.uint32(18).string(t.type),t.function!==void 0&&Ro.encode(t.function,e.uint32(26).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=dc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=n.string();continue;case 2:if(i!==18)break;o.type=n.string();continue;case 3:if(i!==26)break;o.function=Ro.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Co.fromPartial(t??{})},fromPartial(t){let e=dc();return e.id=t.id??"",e.type=t.type??"",e.function=t.function!==void 0&&t.function!==null?Ro.fromPartial(t.function):void 0,e}};function pc(){return{name:"",arguments:""}}var Ro={encode(t,e=new F){return t.name!==""&&e.uint32(10).string(t.name),t.arguments!==""&&e.uint32(18).string(t.arguments),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=pc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.name=n.string();continue;case 2:if(i!==18)break;o.arguments=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ro.fromPartial(t??{})},fromPartial(t){let e=pc();return e.name=t.name??"",e.arguments=t.arguments??"",e}};function hc(){return{value:"",mimeType:""}}var No={encode(t,e=new F){return t.value!==""&&e.uint32(10).string(t.value),t.mimeType!==""&&e.uint32(18).string(t.mimeType),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=hc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.value=n.string();continue;case 2:if(i!==18)break;o.mimeType=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return No.fromPartial(t??{})},fromPartial(t){let e=hc();return e.value=t.value??"",e.mimeType=t.mimeType??"",e}};function fc(){return{value:"",mimeType:void 0}}var Oo={encode(t,e=new F){return t.value!==""&&e.uint32(10).string(t.value),t.mimeType!==void 0&&e.uint32(18).string(t.mimeType),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=fc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.value=n.string();continue;case 2:if(i!==18)break;o.mimeType=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Oo.fromPartial(t??{})},fromPartial(t){let e=fc();return e.value=t.value??"",e.mimeType=t.mimeType??void 0,e}};function mc(){return{data:void 0,url:void 0}}var De={encode(t,e=new F){return t.data!==void 0&&No.encode(t.data,e.uint32(10).fork()).join(),t.url!==void 0&&Oo.encode(t.url,e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=mc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.data=No.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.url=Oo.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return De.fromPartial(t??{})},fromPartial(t){let e=mc();return e.data=t.data!==void 0&&t.data!==null?No.fromPartial(t.data):void 0,e.url=t.url!==void 0&&t.url!==null?Oo.fromPartial(t.url):void 0,e}};function gc(){return{text:""}}var Mo={encode(t,e=new F){return t.text!==""&&e.uint32(10).string(t.text),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=gc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.text=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Mo.fromPartial(t??{})},fromPartial(t){let e=gc();return e.text=t.text??"",e}};function vc(){return{source:void 0,metadata:void 0}}var Lo={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=vc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Lo.fromPartial(t??{})},fromPartial(t){let e=vc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function bc(){return{source:void 0,metadata:void 0}}var Po={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=bc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Po.fromPartial(t??{})},fromPartial(t){let e=bc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function yc(){return{source:void 0,metadata:void 0}}var Do={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=yc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Do.fromPartial(t??{})},fromPartial(t){let e=yc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function xc(){return{source:void 0,metadata:void 0}}var Uo={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=xc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Uo.fromPartial(t??{})},fromPartial(t){let e=xc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Ec(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var Ho={encode(t,e=new F){return t.text!==void 0&&Mo.encode(t.text,e.uint32(10).fork()).join(),t.image!==void 0&&Lo.encode(t.image,e.uint32(18).fork()).join(),t.audio!==void 0&&Po.encode(t.audio,e.uint32(26).fork()).join(),t.video!==void 0&&Do.encode(t.video,e.uint32(34).fork()).join(),t.document!==void 0&&Uo.encode(t.document,e.uint32(42).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ec();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.text=Mo.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.image=Lo.decode(n,n.uint32());continue;case 3:if(i!==26)break;o.audio=Po.decode(n,n.uint32());continue;case 4:if(i!==34)break;o.video=Do.decode(n,n.uint32());continue;case 5:if(i!==42)break;o.document=Uo.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ho.fromPartial(t??{})},fromPartial(t){let e=Ec();return e.text=t.text!==void 0&&t.text!==null?Mo.fromPartial(t.text):void 0,e.image=t.image!==void 0&&t.image!==null?Lo.fromPartial(t.image):void 0,e.audio=t.audio!==void 0&&t.audio!==null?Po.fromPartial(t.audio):void 0,e.video=t.video!==void 0&&t.video!==null?Do.fromPartial(t.video):void 0,e.document=t.document!==void 0&&t.document!==null?Uo.fromPartial(t.document):void 0,e}};function Tc(){return{id:"",role:"",content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var Go={encode(t,e=new F){t.id!==""&&e.uint32(10).string(t.id),t.role!==""&&e.uint32(18).string(t.role),t.content!==void 0&&e.uint32(26).string(t.content),t.name!==void 0&&e.uint32(34).string(t.name);for(let n of t.toolCalls)Co.encode(n,e.uint32(42).fork()).join();t.toolCallId!==void 0&&e.uint32(50).string(t.toolCallId),t.error!==void 0&&e.uint32(58).string(t.error);for(let n of t.contentParts)Ho.encode(n,e.uint32(66).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Tc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=n.string();continue;case 2:if(i!==18)break;o.role=n.string();continue;case 3:if(i!==26)break;o.content=n.string();continue;case 4:if(i!==34)break;o.name=n.string();continue;case 5:if(i!==42)break;o.toolCalls.push(Co.decode(n,n.uint32()));continue;case 6:if(i!==50)break;o.toolCallId=n.string();continue;case 7:if(i!==58)break;o.error=n.string();continue;case 8:if(i!==66)break;o.contentParts.push(Ho.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Go.fromPartial(t??{})},fromPartial(t){let e=Tc();return e.id=t.id??"",e.role=t.role??"",e.content=t.content??void 0,e.name=t.name??void 0,e.toolCalls=t.toolCalls?.map(n=>Co.fromPartial(n))||[],e.toolCallId=t.toolCallId??void 0,e.error=t.error??void 0,e.contentParts=t.contentParts?.map(n=>Ho.fromPartial(n))||[],e}};function wc(){return{id:"",reason:"",message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var zo={encode(t,e=new F){return t.id!==""&&e.uint32(10).string(t.id),t.reason!==""&&e.uint32(18).string(t.reason),t.message!==void 0&&e.uint32(26).string(t.message),t.toolCallId!==void 0&&e.uint32(34).string(t.toolCallId),t.responseSchema!==void 0&&O.encode(O.wrap(t.responseSchema),e.uint32(42).fork()).join(),t.expiresAt!==void 0&&e.uint32(50).string(t.expiresAt),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(58).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=wc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=n.string();continue;case 2:if(i!==18)break;o.reason=n.string();continue;case 3:if(i!==26)break;o.message=n.string();continue;case 4:if(i!==34)break;o.toolCallId=n.string();continue;case 5:if(i!==42)break;o.responseSchema=O.unwrap(O.decode(n,n.uint32()));continue;case 6:if(i!==50)break;o.expiresAt=n.string();continue;case 7:if(i!==58)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return zo.fromPartial(t??{})},fromPartial(t){let e=wc();return e.id=t.id??"",e.reason=t.reason??"",e.message=t.message??void 0,e.toolCallId=t.toolCallId??void 0,e.responseSchema=t.responseSchema??void 0,e.expiresAt=t.expiresAt??void 0,e.metadata=t.metadata??void 0,e}},pm=(function(t){return t[t.TEXT_MESSAGE_START=0]="TEXT_MESSAGE_START",t[t.TEXT_MESSAGE_CONTENT=1]="TEXT_MESSAGE_CONTENT",t[t.TEXT_MESSAGE_END=2]="TEXT_MESSAGE_END",t[t.TOOL_CALL_START=3]="TOOL_CALL_START",t[t.TOOL_CALL_ARGS=4]="TOOL_CALL_ARGS",t[t.TOOL_CALL_END=5]="TOOL_CALL_END",t[t.STATE_SNAPSHOT=6]="STATE_SNAPSHOT",t[t.STATE_DELTA=7]="STATE_DELTA",t[t.MESSAGES_SNAPSHOT=8]="MESSAGES_SNAPSHOT",t[t.RAW=9]="RAW",t[t.CUSTOM=10]="CUSTOM",t[t.RUN_STARTED=11]="RUN_STARTED",t[t.RUN_FINISHED=12]="RUN_FINISHED",t[t.RUN_ERROR=13]="RUN_ERROR",t[t.STEP_STARTED=14]="STEP_STARTED",t[t.STEP_FINISHED=15]="STEP_FINISHED",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function Sc(){return{type:0,timestamp:void 0,rawEvent:void 0}}var M={encode(t,e=new F){return t.type!==0&&e.uint32(8).int32(t.type),t.timestamp!==void 0&&e.uint32(16).int64(t.timestamp),t.rawEvent!==void 0&&O.encode(O.wrap(t.rawEvent),e.uint32(26).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Sc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==8)break;o.type=n.int32();continue;case 2:if(i!==16)break;o.timestamp=hm(n.int64());continue;case 3:if(i!==26)break;o.rawEvent=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return M.fromPartial(t??{})},fromPartial(t){let e=Sc();return e.type=t.type??0,e.timestamp=t.timestamp??void 0,e.rawEvent=t.rawEvent??void 0,e}};function _c(){return{baseEvent:void 0,messageId:"",role:void 0,name:void 0}}var Fo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==""&&e.uint32(18).string(t.messageId),t.role!==void 0&&e.uint32(26).string(t.role),t.name!==void 0&&e.uint32(34).string(t.name),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=_c();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue;case 3:if(i!==26)break;o.role=n.string();continue;case 4:if(i!==34)break;o.name=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Fo.fromPartial(t??{})},fromPartial(t){let e=_c();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e.role=t.role??void 0,e.name=t.name??void 0,e}};function Ac(){return{baseEvent:void 0,messageId:"",delta:""}}var $o={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==""&&e.uint32(18).string(t.messageId),t.delta!==""&&e.uint32(26).string(t.delta),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ac();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue;case 3:if(i!==26)break;o.delta=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return $o.fromPartial(t??{})},fromPartial(t){let e=Ac();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e.delta=t.delta??"",e}};function kc(){return{baseEvent:void 0,messageId:""}}var Bo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==""&&e.uint32(18).string(t.messageId),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=kc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Bo.fromPartial(t??{})},fromPartial(t){let e=kc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e}};function Ic(){return{baseEvent:void 0,toolCallId:"",toolCallName:"",parentMessageId:void 0}}var Vo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==""&&e.uint32(18).string(t.toolCallId),t.toolCallName!==""&&e.uint32(26).string(t.toolCallName),t.parentMessageId!==void 0&&e.uint32(34).string(t.parentMessageId),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ic();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue;case 3:if(i!==26)break;o.toolCallName=n.string();continue;case 4:if(i!==34)break;o.parentMessageId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Vo.fromPartial(t??{})},fromPartial(t){let e=Ic();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e.toolCallName=t.toolCallName??"",e.parentMessageId=t.parentMessageId??void 0,e}};function Cc(){return{baseEvent:void 0,toolCallId:"",delta:""}}var jo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==""&&e.uint32(18).string(t.toolCallId),t.delta!==""&&e.uint32(26).string(t.delta),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Cc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue;case 3:if(i!==26)break;o.delta=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return jo.fromPartial(t??{})},fromPartial(t){let e=Cc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e.delta=t.delta??"",e}};function Rc(){return{baseEvent:void 0,toolCallId:""}}var qo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==""&&e.uint32(18).string(t.toolCallId),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Rc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return qo.fromPartial(t??{})},fromPartial(t){let e=Rc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e}};function Nc(){return{baseEvent:void 0,snapshot:void 0}}var Wo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.snapshot!==void 0&&O.encode(O.wrap(t.snapshot),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Nc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.snapshot=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Wo.fromPartial(t??{})},fromPartial(t){let e=Nc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.snapshot=t.snapshot??void 0,e}};function Oc(){return{baseEvent:void 0,delta:[]}}var Xo={encode(t,e=new F){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.delta)Io.encode(n,e.uint32(18).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Oc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.delta.push(Io.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Xo.fromPartial(t??{})},fromPartial(t){let e=Oc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.delta=t.delta?.map(n=>Io.fromPartial(n))||[],e}};function Mc(){return{baseEvent:void 0,messages:[]}}var Yo={encode(t,e=new F){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.messages)Go.encode(n,e.uint32(18).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Mc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messages.push(Go.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Yo.fromPartial(t??{})},fromPartial(t){let e=Mc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messages=t.messages?.map(n=>Go.fromPartial(n))||[],e}};function Lc(){return{baseEvent:void 0,event:void 0,source:void 0}}var Ko={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.event!==void 0&&O.encode(O.wrap(t.event),e.uint32(18).fork()).join(),t.source!==void 0&&e.uint32(26).string(t.source),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Lc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.event=O.unwrap(O.decode(n,n.uint32()));continue;case 3:if(i!==26)break;o.source=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ko.fromPartial(t??{})},fromPartial(t){let e=Lc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.event=t.event??void 0,e.source=t.source??void 0,e}};function Pc(){return{baseEvent:void 0,name:"",value:void 0}}var Zo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.name!==""&&e.uint32(18).string(t.name),t.value!==void 0&&O.encode(O.wrap(t.value),e.uint32(26).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Pc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.name=n.string();continue;case 3:if(i!==26)break;o.value=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Zo.fromPartial(t??{})},fromPartial(t){let e=Pc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.name=t.name??"",e.value=t.value??void 0,e}};function Dc(){return{baseEvent:void 0,threadId:"",runId:""}}var Jo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.threadId!==""&&e.uint32(18).string(t.threadId),t.runId!==""&&e.uint32(26).string(t.runId),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Dc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.threadId=n.string();continue;case 3:if(i!==26)break;o.runId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Jo.fromPartial(t??{})},fromPartial(t){let e=Dc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.threadId=t.threadId??"",e.runId=t.runId??"",e}};function Uc(){return{baseEvent:void 0,threadId:"",runId:"",result:void 0,outcome:"",interrupts:[]}}var Qo={encode(t,e=new F){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.threadId!==""&&e.uint32(18).string(t.threadId),t.runId!==""&&e.uint32(26).string(t.runId),t.result!==void 0&&O.encode(O.wrap(t.result),e.uint32(34).fork()).join(),t.outcome!==""&&e.uint32(42).string(t.outcome);for(let n of t.interrupts)zo.encode(n,e.uint32(50).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Uc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.threadId=n.string();continue;case 3:if(i!==26)break;o.runId=n.string();continue;case 4:if(i!==34)break;o.result=O.unwrap(O.decode(n,n.uint32()));continue;case 5:if(i!==42)break;o.outcome=n.string();continue;case 6:if(i!==50)break;o.interrupts.push(zo.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Qo.fromPartial(t??{})},fromPartial(t){let e=Uc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.threadId=t.threadId??"",e.runId=t.runId??"",e.result=t.result??void 0,e.outcome=t.outcome??"",e.interrupts=t.interrupts?.map(n=>zo.fromPartial(n))||[],e}};function Hc(){return{baseEvent:void 0,code:void 0,message:""}}var ei={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.code!==void 0&&e.uint32(18).string(t.code),t.message!==""&&e.uint32(26).string(t.message),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Hc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.code=n.string();continue;case 3:if(i!==26)break;o.message=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ei.fromPartial(t??{})},fromPartial(t){let e=Hc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.code=t.code??void 0,e.message=t.message??"",e}};function Gc(){return{baseEvent:void 0,stepName:""}}var ti={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.stepName!==""&&e.uint32(18).string(t.stepName),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Gc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.stepName=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ti.fromPartial(t??{})},fromPartial(t){let e=Gc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e}};function zc(){return{baseEvent:void 0,stepName:""}}var ni={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.stepName!==""&&e.uint32(18).string(t.stepName),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=zc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.stepName=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ni.fromPartial(t??{})},fromPartial(t){let e=zc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e}};function Fc(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var ri={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==void 0&&e.uint32(18).string(t.messageId),t.role!==void 0&&e.uint32(26).string(t.role),t.delta!==void 0&&e.uint32(34).string(t.delta),t.name!==void 0&&e.uint32(42).string(t.name),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Fc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue;case 3:if(i!==26)break;o.role=n.string();continue;case 4:if(i!==34)break;o.delta=n.string();continue;case 5:if(i!==42)break;o.name=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ri.fromPartial(t??{})},fromPartial(t){let e=Fc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??void 0,e.role=t.role??void 0,e.delta=t.delta??void 0,e.name=t.name??void 0,e}};function $c(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var oi={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==void 0&&e.uint32(18).string(t.toolCallId),t.toolCallName!==void 0&&e.uint32(26).string(t.toolCallName),t.parentMessageId!==void 0&&e.uint32(34).string(t.parentMessageId),t.delta!==void 0&&e.uint32(42).string(t.delta),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=$c();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue;case 3:if(i!==26)break;o.toolCallName=n.string();continue;case 4:if(i!==34)break;o.parentMessageId=n.string();continue;case 5:if(i!==42)break;o.delta=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return oi.fromPartial(t??{})},fromPartial(t){let e=$c();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??void 0,e.toolCallName=t.toolCallName??void 0,e.parentMessageId=t.parentMessageId??void 0,e.delta=t.delta??void 0,e}};function Bc(){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 Vc={encode(t,e=new F){return t.textMessageStart!==void 0&&Fo.encode(t.textMessageStart,e.uint32(10).fork()).join(),t.textMessageContent!==void 0&&$o.encode(t.textMessageContent,e.uint32(18).fork()).join(),t.textMessageEnd!==void 0&&Bo.encode(t.textMessageEnd,e.uint32(26).fork()).join(),t.toolCallStart!==void 0&&Vo.encode(t.toolCallStart,e.uint32(34).fork()).join(),t.toolCallArgs!==void 0&&jo.encode(t.toolCallArgs,e.uint32(42).fork()).join(),t.toolCallEnd!==void 0&&qo.encode(t.toolCallEnd,e.uint32(50).fork()).join(),t.stateSnapshot!==void 0&&Wo.encode(t.stateSnapshot,e.uint32(58).fork()).join(),t.stateDelta!==void 0&&Xo.encode(t.stateDelta,e.uint32(66).fork()).join(),t.messagesSnapshot!==void 0&&Yo.encode(t.messagesSnapshot,e.uint32(74).fork()).join(),t.raw!==void 0&&Ko.encode(t.raw,e.uint32(82).fork()).join(),t.custom!==void 0&&Zo.encode(t.custom,e.uint32(90).fork()).join(),t.runStarted!==void 0&&Jo.encode(t.runStarted,e.uint32(98).fork()).join(),t.runFinished!==void 0&&Qo.encode(t.runFinished,e.uint32(106).fork()).join(),t.runError!==void 0&&ei.encode(t.runError,e.uint32(114).fork()).join(),t.stepStarted!==void 0&&ti.encode(t.stepStarted,e.uint32(122).fork()).join(),t.stepFinished!==void 0&&ni.encode(t.stepFinished,e.uint32(130).fork()).join(),t.textMessageChunk!==void 0&&ri.encode(t.textMessageChunk,e.uint32(138).fork()).join(),t.toolCallChunk!==void 0&&oi.encode(t.toolCallChunk,e.uint32(146).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Bc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.textMessageStart=Fo.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.textMessageContent=$o.decode(n,n.uint32());continue;case 3:if(i!==26)break;o.textMessageEnd=Bo.decode(n,n.uint32());continue;case 4:if(i!==34)break;o.toolCallStart=Vo.decode(n,n.uint32());continue;case 5:if(i!==42)break;o.toolCallArgs=jo.decode(n,n.uint32());continue;case 6:if(i!==50)break;o.toolCallEnd=qo.decode(n,n.uint32());continue;case 7:if(i!==58)break;o.stateSnapshot=Wo.decode(n,n.uint32());continue;case 8:if(i!==66)break;o.stateDelta=Xo.decode(n,n.uint32());continue;case 9:if(i!==74)break;o.messagesSnapshot=Yo.decode(n,n.uint32());continue;case 10:if(i!==82)break;o.raw=Ko.decode(n,n.uint32());continue;case 11:if(i!==90)break;o.custom=Zo.decode(n,n.uint32());continue;case 12:if(i!==98)break;o.runStarted=Jo.decode(n,n.uint32());continue;case 13:if(i!==106)break;o.runFinished=Qo.decode(n,n.uint32());continue;case 14:if(i!==114)break;o.runError=ei.decode(n,n.uint32());continue;case 15:if(i!==122)break;o.stepStarted=ti.decode(n,n.uint32());continue;case 16:if(i!==130)break;o.stepFinished=ni.decode(n,n.uint32());continue;case 17:if(i!==138)break;o.textMessageChunk=ri.decode(n,n.uint32());continue;case 18:if(i!==146)break;o.toolCallChunk=oi.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Vc.fromPartial(t??{})},fromPartial(t){let e=Bc();return e.textMessageStart=t.textMessageStart!==void 0&&t.textMessageStart!==null?Fo.fromPartial(t.textMessageStart):void 0,e.textMessageContent=t.textMessageContent!==void 0&&t.textMessageContent!==null?$o.fromPartial(t.textMessageContent):void 0,e.textMessageEnd=t.textMessageEnd!==void 0&&t.textMessageEnd!==null?Bo.fromPartial(t.textMessageEnd):void 0,e.toolCallStart=t.toolCallStart!==void 0&&t.toolCallStart!==null?Vo.fromPartial(t.toolCallStart):void 0,e.toolCallArgs=t.toolCallArgs!==void 0&&t.toolCallArgs!==null?jo.fromPartial(t.toolCallArgs):void 0,e.toolCallEnd=t.toolCallEnd!==void 0&&t.toolCallEnd!==null?qo.fromPartial(t.toolCallEnd):void 0,e.stateSnapshot=t.stateSnapshot!==void 0&&t.stateSnapshot!==null?Wo.fromPartial(t.stateSnapshot):void 0,e.stateDelta=t.stateDelta!==void 0&&t.stateDelta!==null?Xo.fromPartial(t.stateDelta):void 0,e.messagesSnapshot=t.messagesSnapshot!==void 0&&t.messagesSnapshot!==null?Yo.fromPartial(t.messagesSnapshot):void 0,e.raw=t.raw!==void 0&&t.raw!==null?Ko.fromPartial(t.raw):void 0,e.custom=t.custom!==void 0&&t.custom!==null?Zo.fromPartial(t.custom):void 0,e.runStarted=t.runStarted!==void 0&&t.runStarted!==null?Jo.fromPartial(t.runStarted):void 0,e.runFinished=t.runFinished!==void 0&&t.runFinished!==null?Qo.fromPartial(t.runFinished):void 0,e.runError=t.runError!==void 0&&t.runError!==null?ei.fromPartial(t.runError):void 0,e.stepStarted=t.stepStarted!==void 0&&t.stepStarted!==null?ti.fromPartial(t.stepStarted):void 0,e.stepFinished=t.stepFinished!==void 0&&t.stepFinished!==null?ni.fromPartial(t.stepFinished):void 0,e.textMessageChunk=t.textMessageChunk!==void 0&&t.textMessageChunk!==null?ri.fromPartial(t.textMessageChunk):void 0,e.toolCallChunk=t.toolCallChunk!==void 0&&t.toolCallChunk!==null?oi.fromPartial(t.toolCallChunk):void 0,e}};function hm(t){let e=globalThis.Number(t.toString());if(e>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(e<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return e}var ko=t=>{if(!(!t||typeof t!="object")){if(t.data)return{type:"data",value:t.data.value,mimeType:t.data.mimeType};if(t.url)return{type:"url",value:t.url.value,mimeType:t.url.mimeType}}},fm=t=>{if(!(!t||typeof t!="object")){if(t.text)return{type:"text",text:t.text.text};if(t.image)return{type:"image",source:ko(t.image.source),metadata:t.image.metadata};if(t.audio)return{type:"audio",source:ko(t.audio.source),metadata:t.audio.metadata};if(t.video)return{type:"video",source:ko(t.video.source),metadata:t.video.metadata};if(t.document)return{type:"document",source:ko(t.document.source),metadata:t.document.metadata}}};function jc(t){let e=Vc.decode(t),n=Object.values(e).find(r=>r!==void 0);if(!n)throw new Error("Invalid event");if(n.type=pm[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 i=o.contentParts.map(s=>fm(s)).filter(s=>s!==void 0);i.length>0&&(o.content=i)}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,i=Array.isArray(r.interrupts)?r.interrupts:[];delete r.interrupts,o==="interrupt"?r.outcome={type:"interrupt",interrupts:i}:o==="success"?r.outcome={type:"success"}:delete r.outcome}if(n.type===v.STATE_DELTA)for(let r of n.delta)r.op=dm[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]}),Br.parse(n)}var Js="application/vnd.ag-ui.event+proto";var gm=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Qs=t=>{if(typeof t!="string")throw new TypeError("Invalid argument expected string");let e=t.match(gm);if(!e)throw new Error(`Invalid argument not valid semver ('${t}' received)`);return e.shift(),e},qc=t=>t==="*"||t==="x"||t==="X",Wc=t=>{let e=parseInt(t,10);return isNaN(e)?t:e},vm=(t,e)=>typeof t!=typeof e?[String(t),String(e)]:[t,e],bm=(t,e)=>{if(qc(t)||qc(e))return 0;let[n,r]=vm(Wc(t),Wc(e));return n>r?1:n<r?-1:0},ea=(t,e)=>{for(let n=0;n<Math.max(t.length,e.length);n++){let r=bm(t[n]||"0",e[n]||"0");if(r!==0)return r}return 0};var rr=(t,e)=>{let n=Qs(t),r=Qs(e),o=n.pop(),i=r.pop(),s=ea(n,r);return s!==0?s:o&&i?ea(o.split("."),i.split(".")):o||i?o?-1:1:0};var q=t=>{if(typeof structuredClone=="function")return structuredClone(t);try{return JSON.parse(JSON.stringify(t))}catch{return Array.isArray(t)?[...t]:{...t}}};function Ue(){return yt()}function ra(t){if(Object.freeze(t),typeof t=="object"&&t)for(let e of Object.values(t))typeof e=="object"&&e&&!Object.isFrozen(e)&&ra(e);return t}var Xc=512*1024;function Yc(t,e,n){let r=0,o=[t,e],i=new WeakSet;for(;o.length>0;){let s=o.pop();if(typeof s=="string"){if(r+=s.length,r>n)return!0}else if(typeof s=="object"&&s){if(i.has(s))continue;if(i.add(s),Array.isArray(s))for(let a=0;a<s.length;a++)o.push(s[a]);else{let a=Object.keys(s);for(let l=0;l<a.length;l++){let c=a[l];if(r+=c.length,r>n)return!0;o.push(s[c])}}}}return!1}async function K(t,e,n,r){let o=typeof process<"u"&&process.env!==void 0,i=o&&!!process.env.VITEST_WORKER_ID,s=o&&!!process.env.VITEST_WORKER_ID,a=s&&!Yc(e,n,Xc),l=a?q(e):e,c=a?q(n):n,h=!1,m=!1,y;for(let f of t)try{a&&(ra(l),ra(c));let p=await r(f,l,c);if(p===void 0)continue;let g=!1;if(p.messages!==void 0&&p.messages!==l&&(l=q(p.messages),h=!0,g=!0),p.state!==void 0&&p.state!==c&&(c=q(p.state),m=!0,g=!0),a&&g&&Yc(l,c,Xc)&&(a=!1),y=p.stopPropagation,y===!0)break}catch(p){if(s&&p instanceof TypeError){if(i)throw p;console.error("AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.",p)}else i||console.error("Subscriber error:",p);continue}return{...h?{messages:Object.isFrozen(l)?q(l):l}:{},...m?{state:Object.isFrozen(c)?q(c):c}:{},...y===void 0?{}:{stopPropagation:y}}}function ii(t){if(!t)return{enabled:!1,events:!1,lifecycle:!1,verbose:!1};if(t===!0)return{enabled:!0,events:!0,lifecycle:!0,verbose:!0};let e=t.events??!0,n=t.lifecycle??!0,r=t.verbose??!1;return{enabled:e||n,events:e,lifecycle:n,verbose:r}}function or(t){if(t instanceof oa)return t;if(t===!0)return new oa(ii(!0))}var oa=class{constructor(t){this.config=t}event(t,e,n,r){this.config.events&&(this.config.verbose?console.debug(`[${t}] ${e}`,typeof n=="string"?n:JSON.stringify(n)):console.debug(`[${t}] ${e}`,r??n))}lifecycle(t,e,n){this.config.lifecycle&&(n?console.debug(`[${t}] ${e}`,n):console.debug(`[${t}] ${e}`))}get eventsEnabled(){return this.config.events}get lifecycleEnabled(){return this.config.lifecycle}get enabled(){return this.config.enabled}};function ta(t){return t.enabled?new oa(t):void 0}function ym(t,e,n){if(e){let o=t.find(s=>s.id===e);if(o?.role==="assistant")return o;o&&console.warn(`TOOL_CALL_START: parentMessageId '${e}' matches a '${o.role}' message, not assistant \u2014 falling back to toolCallId`);let i={id:o?n:e,role:"assistant",toolCalls:[]};return t.push(i),i}let r={id:n,role:"assistant",toolCalls:[]};return t.push(r),r}var tu=(t,e,n,r,o)=>{let i=or(o),s=q(n.messages),a=q(t.state),l={},c=m=>{m.messages!==void 0&&(s=m.messages,l.messages=m.messages),m.state!==void 0&&(a=m.state,l.state=m.state)},h=()=>{let m=q(l);return l={},m.messages!==void 0||m.state!==void 0?ue(m):so};return e.pipe(To(async m=>{let y=await K(r,s,a,(f,p,g)=>f.onEvent?.({event:m,agent:n,input:t,messages:p,state:g}));if(c(y),y.stopPropagation===!0?i?.event("APPLY","Event dropped:",m,{type:m.type,reason:"stopPropagation by subscriber"}):i?.event("APPLY","Event applied:",m,{type:m.type,subscribers:r.length}),y.stopPropagation===!0)return h();switch(m.type){case v.TEXT_MESSAGE_START:{let f=await K(r,s,a,(p,g,x)=>p.onTextMessageStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:p,role:g="assistant",name:x}=m;if(!s.find(_=>_.id===p)){let _={id:p,role:g,content:"",...x!==void 0&&{name:x}};s.push(_),c({messages:s})}}return h()}case v.TEXT_MESSAGE_CONTENT:{let{messageId:f,delta:p}=m,g=s.find(_=>_.id===f);if(!g)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${f}'`),h();let x=await K(r,s,a,(_,w,C)=>_.onTextMessageContentEvent?.({event:m,messages:w,state:C,agent:n,input:t,textMessageBuffer:typeof g.content=="string"?g.content:""}));return c(x),x.stopPropagation!==!0&&(g.content=`${typeof g.content=="string"?g.content:""}${p}`,c({messages:s})),h()}case v.TEXT_MESSAGE_END:{let{messageId:f}=m,p=s.find(g=>g.id===f);return p?(c(await K(r,s,a,(g,x,_)=>g.onTextMessageEndEvent?.({event:m,messages:x,state:_,agent:n,input:t,textMessageBuffer:typeof p.content=="string"?p.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:p,messages:s,state:a,agent:n,input:t})})),h()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${f}'`),h())}case v.TOOL_CALL_START:{let f=await K(r,s,a,(p,g,x)=>p.onToolCallStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{toolCallId:p,toolCallName:g,parentMessageId:x}=m,_=ym(s,x,p);_.toolCalls??=[],_.toolCalls.push({id:p,type:"function",function:{name:g,arguments:""}}),c({messages:s})}return h()}case v.TOOL_CALL_ARGS:{let{toolCallId:f,delta:p}=m,g=s.find(w=>w.toolCalls?.some(C=>C.id===f));if(!g)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${f}'`),h();let x=g.toolCalls?.find(w=>w.id===f);if(!x)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${f}'`),h();let _=await K(r,s,a,(w,C,H)=>{let U=x.function.arguments,Y=x.function.name,re={};try{re=So(U)}catch{}return w.onToolCallArgsEvent?.({event:m,messages:C,state:H,agent:n,input:t,toolCallBuffer:U,toolCallName:Y,partialToolCallArgs:re})});return c(_),_.stopPropagation!==!0&&(x.function.arguments+=p,c({messages:s})),h()}case v.TOOL_CALL_END:{let{toolCallId:f}=m,p=s.find(x=>x.toolCalls?.some(_=>_.id===f));if(!p)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${f}'`),h();let g=p.toolCalls?.find(x=>x.id===f);return g?(c(await K(r,s,a,(x,_,w)=>{let C=g.function.arguments,H=g.function.name,U={};try{U=JSON.parse(C)}catch{}return x.onToolCallEndEvent?.({event:m,messages:_,state:w,agent:n,input:t,toolCallName:H,toolCallArgs:U})})),await Promise.all(r.map(x=>{x.onNewToolCall?.({toolCall:g,messages:s,state:a,agent:n,input:t})})),h()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${f}'`),h())}case v.TOOL_CALL_RESULT:{let f=await K(r,s,a,(p,g,x)=>p.onToolCallResultEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:p,toolCallId:g,content:x,role:_}=m,w={id:p,toolCallId:g,role:_||"tool",content:x},C=s.findIndex(H=>H.role==="assistant"&&H.toolCalls?.some(U=>U.id===g));if(C===-1)s.push(w);else{let H=C+1;for(;H<s.length&&s[H].role==="tool";)H++;s.splice(H,0,w)}await Promise.all(r.map(H=>{H.onNewMessage?.({message:w,messages:s,state:a,agent:n,input:t})})),c({messages:s})}return h()}case v.STATE_SNAPSHOT:{let f=await K(r,s,a,(p,g,x)=>p.onStateSnapshotEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{snapshot:p}=m;a=p,c({state:a})}return h()}case v.STATE_DELTA:{let f=await K(r,s,a,(p,g,x)=>p.onStateDeltaEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{delta:p}=m;try{a=Zr.applyPatch(a,p,!0,!1).newDocument,c({state:a})}catch(g){let x=g instanceof Error?g.message:String(g);console.warn(`Failed to apply state patch:
|
|
4
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function Qn(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var Sn=(function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,n,r,o,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=ht(s),l=a.next();!l.done;l=a.next()){var c=l.value;c.remove(this)}}catch(g){e={error:g}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}else s.remove(this);var h=this.initialTeardown;if(B(h))try{h()}catch(g){i=g instanceof no?g.errors:[g]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var y=ht(m),f=y.next();!f.done;f=y.next()){var p=f.value;try{Gl(p)}catch(g){i=i??[],g instanceof no?i=Tn(Tn([],_n(i)),_n(g.errors)):i.push(g)}}}catch(g){r={error:g}}finally{try{f&&!f.done&&(o=y.return)&&o.call(y)}finally{if(r)throw r.error}}}if(i)throw new no(i)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)Gl(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(e)}},t.prototype._hasParent=function(e){var n=this._parentage;return n===e||Array.isArray(n)&&n.includes(e)},t.prototype._addParent=function(e){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(e),n):n?[n,e]:e},t.prototype._removeParent=function(e){var n=this._parentage;n===e?this._parentage=null:Array.isArray(n)&&Qn(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&Qn(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=(function(){var e=new t;return e.closed=!0,e})(),t})();var Ps=Sn.EMPTY;function ro(t){return t instanceof Sn||t&&"closed"in t&&B(t.remove)&&B(t.add)&&B(t.unsubscribe)}function Gl(t){B(t)?t():t.unsubscribe()}var We={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var An={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=An.delegate;return o?.setTimeout?o.setTimeout.apply(o,Tn([t,e],_n(n))):setTimeout.apply(void 0,Tn([t,e],_n(n)))},clearTimeout:function(t){var e=An.delegate;return(e?.clearTimeout||clearTimeout)(t)},delegate:void 0};function oo(t){An.setTimeout(function(){var e=We.onUnhandledError;if(e)e(t);else throw t})}function er(){}var Fl=(function(){return Ds("C",void 0,void 0)})();function $l(t){return Ds("E",void 0,t)}function Bl(t){return Ds("N",t,void 0)}function Ds(t,e,n){return{kind:t,value:e,error:n}}var Kt=null;function kn(t){if(We.useDeprecatedSynchronousErrorHandling){var e=!Kt;if(e&&(Kt={errorThrown:!1,error:null}),t(),e){var n=Kt,r=n.errorThrown,o=n.error;if(Kt=null,r)throw o}}else t()}function Vl(t){We.useDeprecatedSynchronousErrorHandling&&Kt&&(Kt.errorThrown=!0,Kt.error=t)}var tr=(function(t){it(e,t);function e(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,ro(n)&&n.add(r)):r.destination=tm,r}return e.create=function(n,r,o){return new so(n,r,o)},e.prototype.next=function(n){this.isStopped?Hs(Bl(n),this):this._next(n)},e.prototype.error=function(n){this.isStopped?Hs($l(n),this):(this.isStopped=!0,this._error(n))},e.prototype.complete=function(){this.isStopped?Hs(Fl,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(n){this.destination.next(n)},e.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e})(Sn);var Jf=Function.prototype.bind;function Us(t,e){return Jf.call(t,e)}var Qf=(function(){function t(e){this.partialObserver=e}return t.prototype.next=function(e){var n=this.partialObserver;if(n.next)try{n.next(e)}catch(r){io(r)}},t.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(r){io(r)}else io(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){io(n)}},t})(),so=(function(t){it(e,t);function e(n,r,o){var i=t.call(this)||this,s;if(B(n)||!n)s={next:n??void 0,error:r??void 0,complete:o??void 0};else{var a;i&&We.useDeprecatedNextContext?(a=Object.create(n),a.unsubscribe=function(){return i.unsubscribe()},s={next:n.next&&Us(n.next,a),error:n.error&&Us(n.error,a),complete:n.complete&&Us(n.complete,a)}):s=n}return i.destination=new Qf(s),i}return e})(tr);function io(t){We.useDeprecatedSynchronousErrorHandling?Vl(t):oo(t)}function em(t){throw t}function Hs(t,e){var n=We.onStoppedNotification;n&&An.setTimeout(function(){return n(t,e)})}var tm={closed:!0,next:er,error:em,complete:er};var Cn=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function In(t){return t}function ao(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return zs(t)}function zs(t){return t.length===0?In:t.length===1?t[0]:function(n){return t.reduce(function(r,o){return o(r)},n)}}var te=(function(){function t(e){e&&(this._subscribe=e)}return t.prototype.lift=function(e){var n=new t;return n.source=this,n.operator=e,n},t.prototype.subscribe=function(e,n,r){var o=this,i=rm(e)?e:new so(e,n,r);return kn(function(){var s=o,a=s.operator,l=s.source;i.add(a?a.call(i,l):l?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(n){e.error(n)}},t.prototype.forEach=function(e,n){var r=this;return n=jl(n),new n(function(o,i){var s=new so({next:function(a){try{e(a)}catch(l){i(l),s.unsubscribe()}},error:i,complete:o});r.subscribe(s)})},t.prototype._subscribe=function(e){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(e)},t.prototype[Cn]=function(){return this},t.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return zs(e)(this)},t.prototype.toPromise=function(e){var n=this;return e=jl(e),new e(function(r,o){var i;n.subscribe(function(s){return i=s},function(s){return o(s)},function(){return r(i)})})},t.create=function(e){return new t(e)},t})();function jl(t){var e;return(e=t??We.Promise)!==null&&e!==void 0?e:Promise}function nm(t){return t&&B(t.next)&&B(t.error)&&B(t.complete)}function rm(t){return t&&t instanceof tr||nm(t)&&ro(t)}function om(t){return B(t?.lift)}function fe(t){return function(e){if(om(e))return e.lift(function(n){try{return t(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function ge(t,e,n,r,o){return new im(t,e,n,r,o)}var im=(function(t){it(e,t);function e(n,r,o,i,s,a){var l=t.call(this,n)||this;return l.onFinalize=s,l.shouldUnsubscribe=a,l._next=r?function(c){try{r(c)}catch(h){n.error(h)}}:t.prototype._next,l._error=i?function(c){try{i(c)}catch(h){n.error(h)}finally{this.unsubscribe()}}:t.prototype._error,l._complete=o?function(){try{o()}catch(c){n.error(c)}finally{this.unsubscribe()}}:t.prototype._complete,l}return e.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},e})(tr);var ql=wn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var st=(function(t){it(e,t);function e(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return e.prototype.lift=function(n){var r=new Wl(this,this);return r.operator=n,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new ql},e.prototype.next=function(n){var r=this;kn(function(){var o,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=ht(r.currentObservers),a=s.next();!a.done;a=s.next()){var l=a.value;l.next(n)}}catch(c){o={error:c}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}}})},e.prototype.error=function(n){var r=this;kn(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)}})},e.prototype.complete=function(){var n=this;kn(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},e.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},e.prototype._innerSubscribe=function(n){var r=this,o=this,i=o.hasError,s=o.isStopped,a=o.observers;return i||s?Ps:(this.currentObservers=null,a.push(n),new Sn(function(){r.currentObservers=null,Qn(a,n)}))},e.prototype._checkFinalizedStatuses=function(n){var r=this,o=r.hasError,i=r.thrownError,s=r.isStopped;o?n.error(i):s&&n.complete()},e.prototype.asObservable=function(){var n=new te;return n.source=this,n},e.create=function(n,r){return new Wl(n,r)},e})(te);var Wl=(function(t){it(e,t);function e(n,r){var o=t.call(this)||this;return o.destination=n,o.source=r,o}return e.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)},e.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)},e.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)},e.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:Ps},e})(st);var Gs={now:function(){return(Gs.delegate||Date).now()},delegate:void 0};var lo=(function(t){it(e,t);function e(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=Gs);var i=t.call(this)||this;return i._bufferSize=n,i._windowTime=r,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,n),i._windowTime=Math.max(1,r),i}return e.prototype.next=function(n){var r=this,o=r.isStopped,i=r._buffer,s=r._infiniteTimeWindow,a=r._timestampProvider,l=r._windowTime;o||(i.push(n),!s&&i.push(a.now()+l)),this._trimBuffer(),t.prototype.next.call(this,n)},e.prototype._subscribe=function(n){this._throwIfClosed(),this._trimBuffer();for(var r=this._innerSubscribe(n),o=this,i=o._infiniteTimeWindow,s=o._buffer,a=s.slice(),l=0;l<a.length&&!n.closed;l+=i?1:2)n.next(a[l]);return this._checkFinalizedStatuses(n),r},e.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,o=n._timestampProvider,i=n._buffer,s=n._infiniteTimeWindow,a=(s?1:2)*r;if(r<1/0&&a<i.length&&i.splice(0,i.length-a),!s){for(var l=o.now(),c=0,h=1;h<i.length&&i[h]<=l;h+=2)c=h;c&&i.splice(0,c+1)}},e})(st);var co=new te(function(t){return t.complete()});function Xl(t){return t&&B(t.schedule)}function sm(t){return t[t.length-1]}function Yl(t){return Xl(sm(t))?t.pop():void 0}var uo=(function(t){return t&&typeof t.length=="number"&&typeof t!="function"});function po(t){return B(t?.then)}function ho(t){return B(t[Cn])}function fo(t){return Symbol.asyncIterator&&B(t?.[Symbol.asyncIterator])}function mo(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function am(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var go=am();function vo(t){return B(t?.[go])}function bo(t){return Hl(this,arguments,function(){var n,r,o,i;return to(this,function(s){switch(s.label){case 0:n=t.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,Yt(n.read())];case 3:return r=s.sent(),o=r.value,i=r.done,i?[4,Yt(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,Yt(o)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function yo(t){return B(t?.getReader)}function ve(t){if(t instanceof te)return t;if(t!=null){if(ho(t))return lm(t);if(uo(t))return cm(t);if(po(t))return um(t);if(fo(t))return Kl(t);if(vo(t))return dm(t);if(yo(t))return pm(t)}throw mo(t)}function lm(t){return new te(function(e){var n=t[Cn]();if(B(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function cm(t){return new te(function(e){for(var n=0;n<t.length&&!e.closed;n++)e.next(t[n]);e.complete()})}function um(t){return new te(function(e){t.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,oo)})}function dm(t){return new te(function(e){var n,r;try{for(var o=ht(t),i=o.next();!i.done;i=o.next()){var s=i.value;if(e.next(s),e.closed)return}}catch(a){n={error:a}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}e.complete()})}function Kl(t){return new te(function(e){hm(t,e).catch(function(n){return e.error(n)})})}function pm(t){return Kl(bo(t))}function hm(t,e){var n,r,o,i;return Ul(this,void 0,void 0,function(){var s,a;return to(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=zl(t),l.label=1;case 1:return[4,n.next()];case 2:if(r=l.sent(),!!r.done)return[3,4];if(s=r.value,e.next(s),e.closed)return[2];l.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=l.sent(),o={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),r&&!r.done&&(i=n.return)?[4,i.call(n)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function $e(t,e,n,r,o){r===void 0&&(r=0),o===void 0&&(o=!1);var i=e.schedule(function(){n(),o?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(i),!o)return i}function xo(t,e){return e===void 0&&(e=0),fe(function(n,r){n.subscribe(ge(r,function(o){return $e(r,t,function(){return r.next(o)},e)},function(){return $e(r,t,function(){return r.complete()},e)},function(o){return $e(r,t,function(){return r.error(o)},e)}))})}function Eo(t,e){return e===void 0&&(e=0),fe(function(n,r){r.add(t.schedule(function(){return n.subscribe(r)},e))})}function Zl(t,e){return ve(t).pipe(Eo(e),xo(e))}function Jl(t,e){return ve(t).pipe(Eo(e),xo(e))}function Ql(t,e){return new te(function(n){var r=0;return e.schedule(function(){r===t.length?n.complete():(n.next(t[r++]),n.closed||this.schedule())})})}function ec(t,e){return new te(function(n){var r;return $e(n,e,function(){r=t[go](),$e(n,e,function(){var o,i,s;try{o=r.next(),i=o.value,s=o.done}catch(a){n.error(a);return}s?n.complete():n.next(i)},0,!0)}),function(){return B(r?.return)&&r.return()}})}function _o(t,e){if(!t)throw new Error("Iterable cannot be null");return new te(function(n){$e(n,e,function(){var r=t[Symbol.asyncIterator]();$e(n,e,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function tc(t,e){return _o(bo(t),e)}function nc(t,e){if(t!=null){if(ho(t))return Zl(t,e);if(uo(t))return Ql(t,e);if(po(t))return Jl(t,e);if(fo(t))return _o(t,e);if(vo(t))return ec(t,e);if(yo(t))return tc(t,e)}throw mo(t)}function Zt(t,e){return e?nc(t,e):ve(t)}function ue(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Yl(t);return Zt(t,n)}function ne(t,e){var n=B(t)?t:function(){return t},r=function(o){return o.error(n())};return new te(e?function(o){return e.schedule(r,0,o)}:r)}var rc=wn(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}});function To(t,e){var n=typeof e=="object";return new Promise(function(r,o){var i=!1,s;t.subscribe({next:function(a){s=a,i=!0},error:o,complete:function(){i?r(s):n?r(e.defaultValue):o(new rc)}})})}function Jt(t,e){return fe(function(n,r){var o=0;n.subscribe(ge(r,function(i){r.next(t.call(e,i,o++))}))})}function oc(t,e,n,r,o,i,s,a){var l=[],c=0,h=0,m=!1,y=function(){m&&!l.length&&!c&&e.complete()},f=function(g){return c<r?p(g):l.push(g)},p=function(g){i&&e.next(g),c++;var x=!1;ve(n(g,h++)).subscribe(ge(e,function(S){o?.(S),i?f(S):e.next(S)},function(){x=!0},void 0,function(){if(x)try{c--;for(var S=function(){var T=l.shift();s?$e(e,s,function(){return p(T)}):p(T)};l.length&&c<r;)S();y()}catch(T){e.error(T)}}))};return t.subscribe(ge(e,f,function(){m=!0,y()})),function(){a?.()}}function Me(t,e,n){return n===void 0&&(n=1/0),B(e)?Me(function(r,o){return Jt(function(i,s){return e(r,i,o,s)})(ve(t(r,o)))},n):(typeof e=="number"&&(n=e),fe(function(r,o){return oc(r,o,t,n)}))}function Fs(t){return t===void 0&&(t=1/0),Me(In,t)}function wo(t){return new te(function(e){ve(t()).subscribe(e)})}function nr(t){return fe(function(e,n){var r=null,o=!1,i;r=e.subscribe(ge(n,void 0,void 0,function(s){i=ve(t(s,nr(t)(e))),r?(r.unsubscribe(),r=null,i.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,i.subscribe(n))})}function So(t,e){return B(e)?Me(t,e,1):Me(t,1)}function $s(t){return fe(function(e,n){var r=!1;e.subscribe(ge(n,function(o){r=!0,n.next(o)},function(){r||n.next(t),n.complete()}))})}function Qt(t){return fe(function(e,n){try{e.subscribe(n)}finally{n.add(t)}})}function Bs(t,e){return fe(function(n,r){var o=null,i=0,s=!1,a=function(){return s&&!o&&r.complete()};n.subscribe(ge(r,function(l){o?.unsubscribe();var c=0,h=i++;ve(t(l,h)).subscribe(o=ge(r,function(m){return r.next(e?e(l,m,h,c++):m)},function(){o=null,a()}))},function(){s=!0,a()}))})}function Ao(t){return fe(function(e,n){ve(t).subscribe(ge(n,function(){return n.complete()},er)),!n.closed&&e.subscribe(n)})}function Vs(t,e,n){var r=B(t)||e||n?{next:t,error:e,complete:n}:t;return r?fe(function(o,i){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var a=!0;o.subscribe(ge(i,function(l){var c;(c=r.next)===null||c===void 0||c.call(r,l),i.next(l)},function(){var l;a=!1,(l=r.complete)===null||l===void 0||l.call(r),i.complete()},function(l){var c;a=!1,(c=r.error)===null||c===void 0||c.call(r,l),i.error(l)},function(){var l,c;a&&((l=r.unsubscribe)===null||l===void 0||l.call(r)),(c=r.finalize)===null||c===void 0||c.call(r)}))}):In}function ic(t){return` \r
|
|
5
|
+
`.indexOf(t)>=0}function ko(t){for(var e=["topLevel"],n=0,r,o,i,s=function(T){return e.push(T)},a=function(T){return e[e.length-1]=T},l=function(T){r==null&&(r=n,o=e.length,i=T)},c=function(T){T===i&&(r=void 0,o=void 0,i=void 0)},h=function(){return e.pop()},m=function(){return n--},y=function(T){if("0"<=T&&T<="9"){s("number");return}switch(T){case'"':s("string");return;case"-":s("numberNeedsDigit");return;case"t":s("true");return;case"f":s("false");return;case"n":s("null");return;case"[":s("arrayNeedsValue");return;case"{":s("objectNeedsKey");return}},f=t.length;n<f;n++){var p=t[n];switch(e[e.length-1]){case"topLevel":y(p);break;case"string":switch(p){case'"':h();break;case"\\":l("stringEscape"),s("stringEscaped");break}break;case"stringEscaped":p==="u"?s("stringUnicode"):(c("stringEscape"),h());break;case"stringUnicode":n-t.lastIndexOf("u",n)===4&&(c("stringEscape"),h());break;case"number":p==="."?a("numberNeedsDigit"):p==="e"||p==="E"?a("numberNeedsExponent"):(p<"0"||p>"9")&&(m(),h());break;case"numberNeedsDigit":a("number");break;case"numberNeedsExponent":a(p==="+"||p==="-"?"numberNeedsDigit":"number");break;case"true":case"false":case"null":(p<"a"||p>"z")&&(m(),h());break;case"arrayNeedsValue":p==="]"?h():ic(p)||(c("collectionItem"),a("arrayNeedsComma"),y(p));break;case"arrayNeedsComma":p==="]"?h():p===","&&(l("collectionItem"),a("arrayNeedsValue"));break;case"objectNeedsKey":p==="}"?h():p==='"'&&(l("collectionItem"),a("objectNeedsColon"),s("string"));break;case"objectNeedsColon":p===":"&&a("objectNeedsValue");break;case"objectNeedsValue":ic(p)||(c("collectionItem"),a("objectNeedsComma"),y(p));break;case"objectNeedsComma":p==="}"?h():p===","&&(l("collectionItem"),a("objectNeedsKey"));break}}o!=null&&(e.length=o);for(var g=[r!=null?t.slice(0,r):t],x=function(T){return g.push(T.slice(t.length-t.lastIndexOf(T[0])))},S=e.length-1;S>=0;S--)switch(e[S]){case"string":g.push('"');break;case"numberNeedsDigit":case"numberNeedsExponent":g.push("0");break;case"true":x("true");break;case"false":x("false");break;case"null":x("null");break;case"arrayNeedsValue":case"arrayNeedsComma":g.push("]");break;case"objectNeedsKey":case"objectNeedsColon":case"objectNeedsValue":case"objectNeedsComma":g.push("}");break}return g.join("")}function ac(){let t=0,e=0;for(let r=0;r<28;r+=7){let o=this.buf[this.pos++];if(t|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(n&15)<<28,e=(n&112)>>4,(n&128)==0)return this.assertBounds(),[t,e];for(let r=3;r<=31;r+=7){let o=this.buf[this.pos++];if(e|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Io(t,e,n){for(let i=0;i<28;i=i+7){let s=t>>>i,a=!(!(s>>>7)&&e==0),l=(a?s|128:s)&255;if(n.push(l),!a)return}let r=t>>>28&15|(e&7)<<4,o=e>>3!=0;if(n.push((o?r|128:r)&255),!!o){for(let i=3;i<31;i=i+7){let s=e>>>i,a=!!(s>>>7),l=(a?s|128:s)&255;if(n.push(l),!a)return}n.push(e>>>31&1)}}var Co=4294967296;function js(t){let e=t[0]==="-";e&&(t=t.slice(1));let n=1e6,r=0,o=0;function i(s,a){let l=Number(t.slice(s,a));o*=n,r=r*n+l,r>=Co&&(o=o+(r/Co|0),r=r%Co)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),e?cc(r,o):Ws(r,o)}function lc(t,e){let n=Ws(t,e),r=n.hi&2147483648;r&&(n=cc(n.lo,n.hi));let o=qs(n.lo,n.hi);return r?"-"+o:o}function qs(t,e){if({lo:t,hi:e}=fm(t,e),e<=2097151)return String(Co*e+t);let n=t&16777215,r=(t>>>24|e<<8)&16777215,o=e>>16&65535,i=n+r*6777216+o*6710656,s=r+o*8147497,a=o*2,l=1e7;return i>=l&&(s+=Math.floor(i/l),i%=l),s>=l&&(a+=Math.floor(s/l),s%=l),a.toString()+sc(s)+sc(i)}function fm(t,e){return{lo:t>>>0,hi:e>>>0}}function Ws(t,e){return{lo:t|0,hi:e|0}}function cc(t,e){return e=~e,t?t=~t+1:e+=1,Ws(t,e)}var sc=t=>{let e=String(t);return"0000000".slice(e.length)+e};function Xs(t,e){if(t>=0){for(;t>127;)e.push(t&127|128),t=t>>>7;e.push(t)}else{for(let n=0;n<9;n++)e.push(t&127|128),t=t>>7;e.push(1)}}function uc(){let t=this.buf[this.pos++],e=t&127;if((t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<7,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<14,(t&128)==0)return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(t&127)<<21,(t&128)==0)return this.assertBounds(),e;t=this.buf[this.pos++],e|=(t&15)<<28;for(let n=5;(t&128)!==0&&n<10;n++)t=this.buf[this.pos++];if((t&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var Xe=mm();function mm(){let t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(!!globalThis.Deno||!!globalThis.Bun||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let n=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),o=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(s){let a=typeof s=="bigint"?s:BigInt(s);if(a>r||a<n)throw new Error(`invalid int64: ${s}`);return a},uParse(s){let a=typeof s=="bigint"?s:BigInt(s);if(a>i||a<o)throw new Error(`invalid uint64: ${s}`);return a},enc(s){return t.setBigInt64(0,this.parse(s),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(s){return t.setBigInt64(0,this.uParse(s),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec(s,a){return t.setInt32(0,s,!0),t.setInt32(4,a,!0),t.getBigInt64(0,!0)},uDec(s,a){return t.setInt32(0,s,!0),t.setInt32(4,a,!0),t.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(n){return typeof n!="string"&&(n=n.toString()),dc(n),n},uParse(n){return typeof n!="string"&&(n=n.toString()),pc(n),n},enc(n){return typeof n!="string"&&(n=n.toString()),dc(n),js(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),pc(n),js(n)},dec(n,r){return lc(n,r)},uDec(n,r){return qs(n,r)}}}function dc(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function pc(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}var Ys=Symbol.for("@bufbuild/protobuf/text-encoding");function Ks(){if(globalThis[Ys]==null){let t=new globalThis.TextEncoder,e=new globalThis.TextDecoder,n;globalThis[Ys]={encodeUtf8(r){return t.encode(r)},decodeUtf8(r,o){return o?(n===void 0&&(n=new globalThis.TextDecoder("utf-8",{fatal:!0})),n.decode(r)):e.decode(r)},checkUtf8(r){try{return encodeURIComponent(r),!0}catch{return!1}}}}return globalThis[Ys]}var St;(function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"})(St||(St={}));var gm=34028234663852886e22,vm=-34028234663852886e22,bm=4294967295,ym=2147483647,xm=-2147483648,F=class{constructor(e=Ks().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let o=0;o<this.chunks.length;o++)e+=this.chunks[o].length;let n=new Uint8Array(e),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 e=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(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(hc(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Zs(e),Xs(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.encodeUtf8(e);return this.uint32(n.byteLength),this.raw(n)}float(e){Em(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){hc(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){Zs(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return Zs(e),e=(e<<1^e>>31)>>>0,Xs(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),o=Xe.enc(e);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),o=Xe.uEnc(e);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}int64(e){let n=Xe.enc(e);return Io(n.lo,n.hi,this.buf),this}sint64(e){let n=Xe.enc(e),r=n.hi>>31,o=n.lo<<1^r,i=(n.hi<<1|n.lo>>>31)^r;return Io(o,i,this.buf),this}uint64(e){let n=Xe.uEnc(e);return Io(n.lo,n.hi,this.buf),this}},A=class{constructor(e,n=Ks().decodeUtf8){this.decodeUtf8=n,this.varint64=ac,this.uint32=uc,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.pos,n=this.uint32(),r=this.pos-e;if(r>5||r==5&&this.buf[this.pos-1]>15)throw new Error("illegal tag: varint overflows uint32");let o=n>>>3,i=n&7;if(o<=0||i>5)throw new Error("illegal tag: field no "+o+" wire type "+i);return[o,i]}skip(e,n,r=100){let o=this.pos;switch(e){case St.Varint:for(;this.buf[this.pos++]&128;);break;case St.Bit64:this.pos+=4;case St.Bit32:this.pos+=4;break;case St.LengthDelimited:let i=this.uint32();this.pos+=i;break;case St.StartGroup:if(r<=0)throw new Error("maximum recursion depth reached");for(;;){let[s,a]=this.tag();if(a===St.EndGroup){if(n!==void 0&&s!==n)throw new Error("invalid end group tag");break}this.skip(a,s,r-1)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(o,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return Xe.dec(...this.varint64())}uint64(){return Xe.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),r=-(e&1);return e=(e>>>1|(n&1)<<31)^r,n=n>>>1^r,Xe.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==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 Xe.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Xe.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 e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(e){return this.decodeUtf8(this.bytes(),e)}};function Zs(t){if(typeof t=="string")t=Number(t);else if(typeof t!="number")throw new Error("invalid int32: "+typeof t);if(!Number.isInteger(t)||t>ym||t<xm)throw new Error("invalid int32: "+t)}function hc(t){if(typeof t=="string")t=Number(t);else if(typeof t!="number")throw new Error("invalid uint32: "+typeof t);if(!Number.isInteger(t)||t>bm||t<0)throw new Error("invalid uint32: "+t)}function Em(t){if(typeof t=="string"){let e=t;if(t=Number(t),Number.isNaN(t)&&e!=="NaN")throw new Error("invalid float32: "+e)}else if(typeof t!="number")throw new Error("invalid float32: "+typeof t);if(Number.isFinite(t)&&(t>gm||t<vm))throw new Error("invalid float32: "+t)}var _m=(function(t){return t[t.NULL_VALUE=0]="NULL_VALUE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function Js(){return{fields:{}}}var rr={encode(t,e=new F){return Object.entries(t.fields).forEach(([n,r])=>{r!==void 0&&ta.encode({key:n,value:r},e.uint32(10).fork()).join()}),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Js();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:{if(i!==10)break;let s=ta.decode(n,n.uint32());s.value!==void 0&&(o.fields[s.key]=s.value);continue}}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return rr.fromPartial(t??{})},fromPartial(t){let e=Js();return e.fields=Object.entries(t.fields??{}).reduce((n,[r,o])=>(o!==void 0&&(n[r]=o),n),{}),e},wrap(t){let e=Js();if(t!==void 0)for(let n of Object.keys(t))e.fields[n]=t[n];return e},unwrap(t){let e={};if(t.fields)for(let n of Object.keys(t.fields))e[n]=t.fields[n];return e}};function fc(){return{key:"",value:void 0}}var ta={encode(t,e=new F){return t.key!==""&&e.uint32(10).string(t.key),t.value!==void 0&&O.encode(O.wrap(t.value),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=fc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.key=n.string();continue;case 2:if(i!==18)break;o.value=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ta.fromPartial(t??{})},fromPartial(t){let e=fc();return e.key=t.key??"",e.value=t.value??void 0,e}};function Qs(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var O={encode(t,e=new F){return t.nullValue!==void 0&&e.uint32(8).int32(t.nullValue),t.numberValue!==void 0&&e.uint32(17).double(t.numberValue),t.stringValue!==void 0&&e.uint32(26).string(t.stringValue),t.boolValue!==void 0&&e.uint32(32).bool(t.boolValue),t.structValue!==void 0&&rr.encode(rr.wrap(t.structValue),e.uint32(42).fork()).join(),t.listValue!==void 0&&or.encode(or.wrap(t.listValue),e.uint32(50).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Qs();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==8)break;o.nullValue=n.int32();continue;case 2:if(i!==17)break;o.numberValue=n.double();continue;case 3:if(i!==26)break;o.stringValue=n.string();continue;case 4:if(i!==32)break;o.boolValue=n.bool();continue;case 5:if(i!==42)break;o.structValue=rr.unwrap(rr.decode(n,n.uint32()));continue;case 6:if(i!==50)break;o.listValue=or.unwrap(or.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return O.fromPartial(t??{})},fromPartial(t){let e=Qs();return e.nullValue=t.nullValue??void 0,e.numberValue=t.numberValue??void 0,e.stringValue=t.stringValue??void 0,e.boolValue=t.boolValue??void 0,e.structValue=t.structValue??void 0,e.listValue=t.listValue??void 0,e},wrap(t){let e=Qs();if(t===null)e.nullValue=_m.NULL_VALUE;else if(typeof t=="boolean")e.boolValue=t;else if(typeof t=="number")e.numberValue=t;else if(typeof t=="string")e.stringValue=t;else if(globalThis.Array.isArray(t))e.listValue=t;else if(typeof t=="object")e.structValue=t;else if(typeof t<"u")throw new globalThis.Error("Unsupported any value type: "+typeof t);return e},unwrap(t){if(t.stringValue!==void 0)return t.stringValue;if(t?.numberValue!==void 0)return t.numberValue;if(t?.boolValue!==void 0)return t.boolValue;if(t?.structValue!==void 0)return t.structValue;if(t?.listValue!==void 0)return t.listValue;if(t?.nullValue!==void 0)return null}};function ea(){return{values:[]}}var or={encode(t,e=new F){for(let n of t.values)O.encode(O.wrap(n),e.uint32(10).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=ea();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.values.push(O.unwrap(O.decode(n,n.uint32())));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return or.fromPartial(t??{})},fromPartial(t){let e=ea();return e.values=t.values?.map(n=>n)||[],e},wrap(t){let e=ea();return e.values=t??[],e},unwrap(t){return t?.hasOwnProperty("values")&&globalThis.Array.isArray(t.values)?t.values:t}},Tm=(function(t){return t[t.ADD=0]="ADD",t[t.REMOVE=1]="REMOVE",t[t.REPLACE=2]="REPLACE",t[t.MOVE=3]="MOVE",t[t.COPY=4]="COPY",t[t.TEST=5]="TEST",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function mc(){return{op:0,path:"",from:void 0,value:void 0}}var No={encode(t,e=new F){return t.op!==0&&e.uint32(8).int32(t.op),t.path!==""&&e.uint32(18).string(t.path),t.from!==void 0&&e.uint32(26).string(t.from),t.value!==void 0&&O.encode(O.wrap(t.value),e.uint32(34).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=mc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==8)break;o.op=n.int32();continue;case 2:if(i!==18)break;o.path=n.string();continue;case 3:if(i!==26)break;o.from=n.string();continue;case 4:if(i!==34)break;o.value=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return No.fromPartial(t??{})},fromPartial(t){let e=mc();return e.op=t.op??0,e.path=t.path??"",e.from=t.from??void 0,e.value=t.value??void 0,e}};function gc(){return{id:"",type:"",function:void 0}}var Oo={encode(t,e=new F){return t.id!==""&&e.uint32(10).string(t.id),t.type!==""&&e.uint32(18).string(t.type),t.function!==void 0&&Mo.encode(t.function,e.uint32(26).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=gc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=n.string();continue;case 2:if(i!==18)break;o.type=n.string();continue;case 3:if(i!==26)break;o.function=Mo.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Oo.fromPartial(t??{})},fromPartial(t){let e=gc();return e.id=t.id??"",e.type=t.type??"",e.function=t.function!==void 0&&t.function!==null?Mo.fromPartial(t.function):void 0,e}};function vc(){return{name:"",arguments:""}}var Mo={encode(t,e=new F){return t.name!==""&&e.uint32(10).string(t.name),t.arguments!==""&&e.uint32(18).string(t.arguments),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=vc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.name=n.string();continue;case 2:if(i!==18)break;o.arguments=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Mo.fromPartial(t??{})},fromPartial(t){let e=vc();return e.name=t.name??"",e.arguments=t.arguments??"",e}};function bc(){return{value:"",mimeType:""}}var Lo={encode(t,e=new F){return t.value!==""&&e.uint32(10).string(t.value),t.mimeType!==""&&e.uint32(18).string(t.mimeType),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=bc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.value=n.string();continue;case 2:if(i!==18)break;o.mimeType=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Lo.fromPartial(t??{})},fromPartial(t){let e=bc();return e.value=t.value??"",e.mimeType=t.mimeType??"",e}};function yc(){return{value:"",mimeType:void 0}}var Po={encode(t,e=new F){return t.value!==""&&e.uint32(10).string(t.value),t.mimeType!==void 0&&e.uint32(18).string(t.mimeType),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=yc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.value=n.string();continue;case 2:if(i!==18)break;o.mimeType=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Po.fromPartial(t??{})},fromPartial(t){let e=yc();return e.value=t.value??"",e.mimeType=t.mimeType??void 0,e}};function xc(){return{data:void 0,url:void 0}}var De={encode(t,e=new F){return t.data!==void 0&&Lo.encode(t.data,e.uint32(10).fork()).join(),t.url!==void 0&&Po.encode(t.url,e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=xc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.data=Lo.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.url=Po.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return De.fromPartial(t??{})},fromPartial(t){let e=xc();return e.data=t.data!==void 0&&t.data!==null?Lo.fromPartial(t.data):void 0,e.url=t.url!==void 0&&t.url!==null?Po.fromPartial(t.url):void 0,e}};function Ec(){return{text:""}}var Do={encode(t,e=new F){return t.text!==""&&e.uint32(10).string(t.text),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ec();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.text=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Do.fromPartial(t??{})},fromPartial(t){let e=Ec();return e.text=t.text??"",e}};function _c(){return{source:void 0,metadata:void 0}}var Uo={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=_c();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Uo.fromPartial(t??{})},fromPartial(t){let e=_c();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Tc(){return{source:void 0,metadata:void 0}}var Ho={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Tc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ho.fromPartial(t??{})},fromPartial(t){let e=Tc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function wc(){return{source:void 0,metadata:void 0}}var zo={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=wc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return zo.fromPartial(t??{})},fromPartial(t){let e=wc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Sc(){return{source:void 0,metadata:void 0}}var Go={encode(t,e=new F){return t.source!==void 0&&De.encode(t.source,e.uint32(10).fork()).join(),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Sc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=De.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Go.fromPartial(t??{})},fromPartial(t){let e=Sc();return e.source=t.source!==void 0&&t.source!==null?De.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Ac(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var Fo={encode(t,e=new F){return t.text!==void 0&&Do.encode(t.text,e.uint32(10).fork()).join(),t.image!==void 0&&Uo.encode(t.image,e.uint32(18).fork()).join(),t.audio!==void 0&&Ho.encode(t.audio,e.uint32(26).fork()).join(),t.video!==void 0&&zo.encode(t.video,e.uint32(34).fork()).join(),t.document!==void 0&&Go.encode(t.document,e.uint32(42).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ac();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.text=Do.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.image=Uo.decode(n,n.uint32());continue;case 3:if(i!==26)break;o.audio=Ho.decode(n,n.uint32());continue;case 4:if(i!==34)break;o.video=zo.decode(n,n.uint32());continue;case 5:if(i!==42)break;o.document=Go.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Fo.fromPartial(t??{})},fromPartial(t){let e=Ac();return e.text=t.text!==void 0&&t.text!==null?Do.fromPartial(t.text):void 0,e.image=t.image!==void 0&&t.image!==null?Uo.fromPartial(t.image):void 0,e.audio=t.audio!==void 0&&t.audio!==null?Ho.fromPartial(t.audio):void 0,e.video=t.video!==void 0&&t.video!==null?zo.fromPartial(t.video):void 0,e.document=t.document!==void 0&&t.document!==null?Go.fromPartial(t.document):void 0,e}};function kc(){return{id:"",role:"",content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var $o={encode(t,e=new F){t.id!==""&&e.uint32(10).string(t.id),t.role!==""&&e.uint32(18).string(t.role),t.content!==void 0&&e.uint32(26).string(t.content),t.name!==void 0&&e.uint32(34).string(t.name);for(let n of t.toolCalls)Oo.encode(n,e.uint32(42).fork()).join();t.toolCallId!==void 0&&e.uint32(50).string(t.toolCallId),t.error!==void 0&&e.uint32(58).string(t.error);for(let n of t.contentParts)Fo.encode(n,e.uint32(66).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=kc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=n.string();continue;case 2:if(i!==18)break;o.role=n.string();continue;case 3:if(i!==26)break;o.content=n.string();continue;case 4:if(i!==34)break;o.name=n.string();continue;case 5:if(i!==42)break;o.toolCalls.push(Oo.decode(n,n.uint32()));continue;case 6:if(i!==50)break;o.toolCallId=n.string();continue;case 7:if(i!==58)break;o.error=n.string();continue;case 8:if(i!==66)break;o.contentParts.push(Fo.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return $o.fromPartial(t??{})},fromPartial(t){let e=kc();return e.id=t.id??"",e.role=t.role??"",e.content=t.content??void 0,e.name=t.name??void 0,e.toolCalls=t.toolCalls?.map(n=>Oo.fromPartial(n))||[],e.toolCallId=t.toolCallId??void 0,e.error=t.error??void 0,e.contentParts=t.contentParts?.map(n=>Fo.fromPartial(n))||[],e}};function Cc(){return{id:"",reason:"",message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var Bo={encode(t,e=new F){return t.id!==""&&e.uint32(10).string(t.id),t.reason!==""&&e.uint32(18).string(t.reason),t.message!==void 0&&e.uint32(26).string(t.message),t.toolCallId!==void 0&&e.uint32(34).string(t.toolCallId),t.responseSchema!==void 0&&O.encode(O.wrap(t.responseSchema),e.uint32(42).fork()).join(),t.expiresAt!==void 0&&e.uint32(50).string(t.expiresAt),t.metadata!==void 0&&O.encode(O.wrap(t.metadata),e.uint32(58).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Cc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=n.string();continue;case 2:if(i!==18)break;o.reason=n.string();continue;case 3:if(i!==26)break;o.message=n.string();continue;case 4:if(i!==34)break;o.toolCallId=n.string();continue;case 5:if(i!==42)break;o.responseSchema=O.unwrap(O.decode(n,n.uint32()));continue;case 6:if(i!==50)break;o.expiresAt=n.string();continue;case 7:if(i!==58)break;o.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Bo.fromPartial(t??{})},fromPartial(t){let e=Cc();return e.id=t.id??"",e.reason=t.reason??"",e.message=t.message??void 0,e.toolCallId=t.toolCallId??void 0,e.responseSchema=t.responseSchema??void 0,e.expiresAt=t.expiresAt??void 0,e.metadata=t.metadata??void 0,e}},wm=(function(t){return t[t.TEXT_MESSAGE_START=0]="TEXT_MESSAGE_START",t[t.TEXT_MESSAGE_CONTENT=1]="TEXT_MESSAGE_CONTENT",t[t.TEXT_MESSAGE_END=2]="TEXT_MESSAGE_END",t[t.TOOL_CALL_START=3]="TOOL_CALL_START",t[t.TOOL_CALL_ARGS=4]="TOOL_CALL_ARGS",t[t.TOOL_CALL_END=5]="TOOL_CALL_END",t[t.STATE_SNAPSHOT=6]="STATE_SNAPSHOT",t[t.STATE_DELTA=7]="STATE_DELTA",t[t.MESSAGES_SNAPSHOT=8]="MESSAGES_SNAPSHOT",t[t.RAW=9]="RAW",t[t.CUSTOM=10]="CUSTOM",t[t.RUN_STARTED=11]="RUN_STARTED",t[t.RUN_FINISHED=12]="RUN_FINISHED",t[t.RUN_ERROR=13]="RUN_ERROR",t[t.STEP_STARTED=14]="STEP_STARTED",t[t.STEP_FINISHED=15]="STEP_FINISHED",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function Ic(){return{type:0,timestamp:void 0,rawEvent:void 0}}var M={encode(t,e=new F){return t.type!==0&&e.uint32(8).int32(t.type),t.timestamp!==void 0&&e.uint32(16).int64(t.timestamp),t.rawEvent!==void 0&&O.encode(O.wrap(t.rawEvent),e.uint32(26).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Ic();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==8)break;o.type=n.int32();continue;case 2:if(i!==16)break;o.timestamp=Sm(n.int64());continue;case 3:if(i!==26)break;o.rawEvent=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return M.fromPartial(t??{})},fromPartial(t){let e=Ic();return e.type=t.type??0,e.timestamp=t.timestamp??void 0,e.rawEvent=t.rawEvent??void 0,e}};function Rc(){return{baseEvent:void 0,messageId:"",role:void 0,name:void 0}}var Vo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==""&&e.uint32(18).string(t.messageId),t.role!==void 0&&e.uint32(26).string(t.role),t.name!==void 0&&e.uint32(34).string(t.name),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Rc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue;case 3:if(i!==26)break;o.role=n.string();continue;case 4:if(i!==34)break;o.name=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Vo.fromPartial(t??{})},fromPartial(t){let e=Rc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e.role=t.role??void 0,e.name=t.name??void 0,e}};function Nc(){return{baseEvent:void 0,messageId:"",delta:""}}var jo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==""&&e.uint32(18).string(t.messageId),t.delta!==""&&e.uint32(26).string(t.delta),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Nc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue;case 3:if(i!==26)break;o.delta=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return jo.fromPartial(t??{})},fromPartial(t){let e=Nc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e.delta=t.delta??"",e}};function Oc(){return{baseEvent:void 0,messageId:""}}var qo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==""&&e.uint32(18).string(t.messageId),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Oc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return qo.fromPartial(t??{})},fromPartial(t){let e=Oc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e}};function Mc(){return{baseEvent:void 0,toolCallId:"",toolCallName:"",parentMessageId:void 0}}var Wo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==""&&e.uint32(18).string(t.toolCallId),t.toolCallName!==""&&e.uint32(26).string(t.toolCallName),t.parentMessageId!==void 0&&e.uint32(34).string(t.parentMessageId),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Mc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue;case 3:if(i!==26)break;o.toolCallName=n.string();continue;case 4:if(i!==34)break;o.parentMessageId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Wo.fromPartial(t??{})},fromPartial(t){let e=Mc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e.toolCallName=t.toolCallName??"",e.parentMessageId=t.parentMessageId??void 0,e}};function Lc(){return{baseEvent:void 0,toolCallId:"",delta:""}}var Xo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==""&&e.uint32(18).string(t.toolCallId),t.delta!==""&&e.uint32(26).string(t.delta),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Lc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue;case 3:if(i!==26)break;o.delta=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Xo.fromPartial(t??{})},fromPartial(t){let e=Lc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e.delta=t.delta??"",e}};function Pc(){return{baseEvent:void 0,toolCallId:""}}var Yo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==""&&e.uint32(18).string(t.toolCallId),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Pc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Yo.fromPartial(t??{})},fromPartial(t){let e=Pc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e}};function Dc(){return{baseEvent:void 0,snapshot:void 0}}var Ko={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.snapshot!==void 0&&O.encode(O.wrap(t.snapshot),e.uint32(18).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Dc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.snapshot=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ko.fromPartial(t??{})},fromPartial(t){let e=Dc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.snapshot=t.snapshot??void 0,e}};function Uc(){return{baseEvent:void 0,delta:[]}}var Zo={encode(t,e=new F){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.delta)No.encode(n,e.uint32(18).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Uc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.delta.push(No.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Zo.fromPartial(t??{})},fromPartial(t){let e=Uc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.delta=t.delta?.map(n=>No.fromPartial(n))||[],e}};function Hc(){return{baseEvent:void 0,messages:[]}}var Jo={encode(t,e=new F){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.messages)$o.encode(n,e.uint32(18).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Hc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messages.push($o.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Jo.fromPartial(t??{})},fromPartial(t){let e=Hc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messages=t.messages?.map(n=>$o.fromPartial(n))||[],e}};function zc(){return{baseEvent:void 0,event:void 0,source:void 0}}var Qo={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.event!==void 0&&O.encode(O.wrap(t.event),e.uint32(18).fork()).join(),t.source!==void 0&&e.uint32(26).string(t.source),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=zc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.event=O.unwrap(O.decode(n,n.uint32()));continue;case 3:if(i!==26)break;o.source=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Qo.fromPartial(t??{})},fromPartial(t){let e=zc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.event=t.event??void 0,e.source=t.source??void 0,e}};function Gc(){return{baseEvent:void 0,name:"",value:void 0}}var ei={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.name!==""&&e.uint32(18).string(t.name),t.value!==void 0&&O.encode(O.wrap(t.value),e.uint32(26).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Gc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.name=n.string();continue;case 3:if(i!==26)break;o.value=O.unwrap(O.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ei.fromPartial(t??{})},fromPartial(t){let e=Gc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.name=t.name??"",e.value=t.value??void 0,e}};function Fc(){return{baseEvent:void 0,threadId:"",runId:""}}var ti={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.threadId!==""&&e.uint32(18).string(t.threadId),t.runId!==""&&e.uint32(26).string(t.runId),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Fc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.threadId=n.string();continue;case 3:if(i!==26)break;o.runId=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ti.fromPartial(t??{})},fromPartial(t){let e=Fc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.threadId=t.threadId??"",e.runId=t.runId??"",e}};function $c(){return{baseEvent:void 0,threadId:"",runId:"",result:void 0,outcome:"",interrupts:[]}}var ni={encode(t,e=new F){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.threadId!==""&&e.uint32(18).string(t.threadId),t.runId!==""&&e.uint32(26).string(t.runId),t.result!==void 0&&O.encode(O.wrap(t.result),e.uint32(34).fork()).join(),t.outcome!==""&&e.uint32(42).string(t.outcome);for(let n of t.interrupts)Bo.encode(n,e.uint32(50).fork()).join();return e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=$c();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.threadId=n.string();continue;case 3:if(i!==26)break;o.runId=n.string();continue;case 4:if(i!==34)break;o.result=O.unwrap(O.decode(n,n.uint32()));continue;case 5:if(i!==42)break;o.outcome=n.string();continue;case 6:if(i!==50)break;o.interrupts.push(Bo.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ni.fromPartial(t??{})},fromPartial(t){let e=$c();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.threadId=t.threadId??"",e.runId=t.runId??"",e.result=t.result??void 0,e.outcome=t.outcome??"",e.interrupts=t.interrupts?.map(n=>Bo.fromPartial(n))||[],e}};function Bc(){return{baseEvent:void 0,code:void 0,message:""}}var ri={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.code!==void 0&&e.uint32(18).string(t.code),t.message!==""&&e.uint32(26).string(t.message),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Bc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.code=n.string();continue;case 3:if(i!==26)break;o.message=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ri.fromPartial(t??{})},fromPartial(t){let e=Bc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.code=t.code??void 0,e.message=t.message??"",e}};function Vc(){return{baseEvent:void 0,stepName:""}}var oi={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.stepName!==""&&e.uint32(18).string(t.stepName),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Vc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.stepName=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return oi.fromPartial(t??{})},fromPartial(t){let e=Vc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e}};function jc(){return{baseEvent:void 0,stepName:""}}var ii={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.stepName!==""&&e.uint32(18).string(t.stepName),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=jc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.stepName=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ii.fromPartial(t??{})},fromPartial(t){let e=jc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e}};function qc(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var si={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.messageId!==void 0&&e.uint32(18).string(t.messageId),t.role!==void 0&&e.uint32(26).string(t.role),t.delta!==void 0&&e.uint32(34).string(t.delta),t.name!==void 0&&e.uint32(42).string(t.name),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=qc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.messageId=n.string();continue;case 3:if(i!==26)break;o.role=n.string();continue;case 4:if(i!==34)break;o.delta=n.string();continue;case 5:if(i!==42)break;o.name=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return si.fromPartial(t??{})},fromPartial(t){let e=qc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??void 0,e.role=t.role??void 0,e.delta=t.delta??void 0,e.name=t.name??void 0,e}};function Wc(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var ai={encode(t,e=new F){return t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join(),t.toolCallId!==void 0&&e.uint32(18).string(t.toolCallId),t.toolCallName!==void 0&&e.uint32(26).string(t.toolCallName),t.parentMessageId!==void 0&&e.uint32(34).string(t.parentMessageId),t.delta!==void 0&&e.uint32(42).string(t.delta),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Wc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=M.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.toolCallId=n.string();continue;case 3:if(i!==26)break;o.toolCallName=n.string();continue;case 4:if(i!==34)break;o.parentMessageId=n.string();continue;case 5:if(i!==42)break;o.delta=n.string();continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ai.fromPartial(t??{})},fromPartial(t){let e=Wc();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??void 0,e.toolCallName=t.toolCallName??void 0,e.parentMessageId=t.parentMessageId??void 0,e.delta=t.delta??void 0,e}};function Xc(){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 Yc={encode(t,e=new F){return t.textMessageStart!==void 0&&Vo.encode(t.textMessageStart,e.uint32(10).fork()).join(),t.textMessageContent!==void 0&&jo.encode(t.textMessageContent,e.uint32(18).fork()).join(),t.textMessageEnd!==void 0&&qo.encode(t.textMessageEnd,e.uint32(26).fork()).join(),t.toolCallStart!==void 0&&Wo.encode(t.toolCallStart,e.uint32(34).fork()).join(),t.toolCallArgs!==void 0&&Xo.encode(t.toolCallArgs,e.uint32(42).fork()).join(),t.toolCallEnd!==void 0&&Yo.encode(t.toolCallEnd,e.uint32(50).fork()).join(),t.stateSnapshot!==void 0&&Ko.encode(t.stateSnapshot,e.uint32(58).fork()).join(),t.stateDelta!==void 0&&Zo.encode(t.stateDelta,e.uint32(66).fork()).join(),t.messagesSnapshot!==void 0&&Jo.encode(t.messagesSnapshot,e.uint32(74).fork()).join(),t.raw!==void 0&&Qo.encode(t.raw,e.uint32(82).fork()).join(),t.custom!==void 0&&ei.encode(t.custom,e.uint32(90).fork()).join(),t.runStarted!==void 0&&ti.encode(t.runStarted,e.uint32(98).fork()).join(),t.runFinished!==void 0&&ni.encode(t.runFinished,e.uint32(106).fork()).join(),t.runError!==void 0&&ri.encode(t.runError,e.uint32(114).fork()).join(),t.stepStarted!==void 0&&oi.encode(t.stepStarted,e.uint32(122).fork()).join(),t.stepFinished!==void 0&&ii.encode(t.stepFinished,e.uint32(130).fork()).join(),t.textMessageChunk!==void 0&&si.encode(t.textMessageChunk,e.uint32(138).fork()).join(),t.toolCallChunk!==void 0&&ai.encode(t.toolCallChunk,e.uint32(146).fork()).join(),e},decode(t,e){let n=t instanceof A?t:new A(t),r=e===void 0?n.len:n.pos+e,o=Xc();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.textMessageStart=Vo.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.textMessageContent=jo.decode(n,n.uint32());continue;case 3:if(i!==26)break;o.textMessageEnd=qo.decode(n,n.uint32());continue;case 4:if(i!==34)break;o.toolCallStart=Wo.decode(n,n.uint32());continue;case 5:if(i!==42)break;o.toolCallArgs=Xo.decode(n,n.uint32());continue;case 6:if(i!==50)break;o.toolCallEnd=Yo.decode(n,n.uint32());continue;case 7:if(i!==58)break;o.stateSnapshot=Ko.decode(n,n.uint32());continue;case 8:if(i!==66)break;o.stateDelta=Zo.decode(n,n.uint32());continue;case 9:if(i!==74)break;o.messagesSnapshot=Jo.decode(n,n.uint32());continue;case 10:if(i!==82)break;o.raw=Qo.decode(n,n.uint32());continue;case 11:if(i!==90)break;o.custom=ei.decode(n,n.uint32());continue;case 12:if(i!==98)break;o.runStarted=ti.decode(n,n.uint32());continue;case 13:if(i!==106)break;o.runFinished=ni.decode(n,n.uint32());continue;case 14:if(i!==114)break;o.runError=ri.decode(n,n.uint32());continue;case 15:if(i!==122)break;o.stepStarted=oi.decode(n,n.uint32());continue;case 16:if(i!==130)break;o.stepFinished=ii.decode(n,n.uint32());continue;case 17:if(i!==138)break;o.textMessageChunk=si.decode(n,n.uint32());continue;case 18:if(i!==146)break;o.toolCallChunk=ai.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Yc.fromPartial(t??{})},fromPartial(t){let e=Xc();return e.textMessageStart=t.textMessageStart!==void 0&&t.textMessageStart!==null?Vo.fromPartial(t.textMessageStart):void 0,e.textMessageContent=t.textMessageContent!==void 0&&t.textMessageContent!==null?jo.fromPartial(t.textMessageContent):void 0,e.textMessageEnd=t.textMessageEnd!==void 0&&t.textMessageEnd!==null?qo.fromPartial(t.textMessageEnd):void 0,e.toolCallStart=t.toolCallStart!==void 0&&t.toolCallStart!==null?Wo.fromPartial(t.toolCallStart):void 0,e.toolCallArgs=t.toolCallArgs!==void 0&&t.toolCallArgs!==null?Xo.fromPartial(t.toolCallArgs):void 0,e.toolCallEnd=t.toolCallEnd!==void 0&&t.toolCallEnd!==null?Yo.fromPartial(t.toolCallEnd):void 0,e.stateSnapshot=t.stateSnapshot!==void 0&&t.stateSnapshot!==null?Ko.fromPartial(t.stateSnapshot):void 0,e.stateDelta=t.stateDelta!==void 0&&t.stateDelta!==null?Zo.fromPartial(t.stateDelta):void 0,e.messagesSnapshot=t.messagesSnapshot!==void 0&&t.messagesSnapshot!==null?Jo.fromPartial(t.messagesSnapshot):void 0,e.raw=t.raw!==void 0&&t.raw!==null?Qo.fromPartial(t.raw):void 0,e.custom=t.custom!==void 0&&t.custom!==null?ei.fromPartial(t.custom):void 0,e.runStarted=t.runStarted!==void 0&&t.runStarted!==null?ti.fromPartial(t.runStarted):void 0,e.runFinished=t.runFinished!==void 0&&t.runFinished!==null?ni.fromPartial(t.runFinished):void 0,e.runError=t.runError!==void 0&&t.runError!==null?ri.fromPartial(t.runError):void 0,e.stepStarted=t.stepStarted!==void 0&&t.stepStarted!==null?oi.fromPartial(t.stepStarted):void 0,e.stepFinished=t.stepFinished!==void 0&&t.stepFinished!==null?ii.fromPartial(t.stepFinished):void 0,e.textMessageChunk=t.textMessageChunk!==void 0&&t.textMessageChunk!==null?si.fromPartial(t.textMessageChunk):void 0,e.toolCallChunk=t.toolCallChunk!==void 0&&t.toolCallChunk!==null?ai.fromPartial(t.toolCallChunk):void 0,e}};function Sm(t){let e=globalThis.Number(t.toString());if(e>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(e<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return e}var Ro=t=>{if(!(!t||typeof t!="object")){if(t.data)return{type:"data",value:t.data.value,mimeType:t.data.mimeType};if(t.url)return{type:"url",value:t.url.value,mimeType:t.url.mimeType}}},Am=t=>{if(!(!t||typeof t!="object")){if(t.text)return{type:"text",text:t.text.text};if(t.image)return{type:"image",source:Ro(t.image.source),metadata:t.image.metadata};if(t.audio)return{type:"audio",source:Ro(t.audio.source),metadata:t.audio.metadata};if(t.video)return{type:"video",source:Ro(t.video.source),metadata:t.video.metadata};if(t.document)return{type:"document",source:Ro(t.document.source),metadata:t.document.metadata}}};function Kc(t){let e=Yc.decode(t),n=Object.values(e).find(r=>r!==void 0);if(!n)throw new Error("Invalid event");if(n.type=wm[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 i=o.contentParts.map(s=>Am(s)).filter(s=>s!==void 0);i.length>0&&(o.content=i)}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,i=Array.isArray(r.interrupts)?r.interrupts:[];delete r.interrupts,o==="interrupt"?r.outcome={type:"interrupt",interrupts:i}:o==="success"?r.outcome={type:"success"}:delete r.outcome}if(n.type===v.STATE_DELTA)for(let r of n.delta)r.op=Tm[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]}),qr.parse(n)}var na="application/vnd.ag-ui.event+proto";var Cm=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,ra=t=>{if(typeof t!="string")throw new TypeError("Invalid argument expected string");let e=t.match(Cm);if(!e)throw new Error(`Invalid argument not valid semver ('${t}' received)`);return e.shift(),e},Zc=t=>t==="*"||t==="x"||t==="X",Jc=t=>{let e=parseInt(t,10);return isNaN(e)?t:e},Im=(t,e)=>typeof t!=typeof e?[String(t),String(e)]:[t,e],Rm=(t,e)=>{if(Zc(t)||Zc(e))return 0;let[n,r]=Im(Jc(t),Jc(e));return n>r?1:n<r?-1:0},oa=(t,e)=>{for(let n=0;n<Math.max(t.length,e.length);n++){let r=Rm(t[n]||"0",e[n]||"0");if(r!==0)return r}return 0};var ir=(t,e)=>{let n=ra(t),r=ra(e),o=n.pop(),i=r.pop(),s=oa(n,r);return s!==0?s:o&&i?oa(o.split("."),i.split(".")):o||i?o?-1:1:0};var q=t=>{if(typeof structuredClone=="function")return structuredClone(t);try{return JSON.parse(JSON.stringify(t))}catch{return Array.isArray(t)?[...t]:{...t}}};function Ue(){return xt()}function aa(t){if(Object.freeze(t),typeof t=="object"&&t)for(let e of Object.values(t))typeof e=="object"&&e&&!Object.isFrozen(e)&&aa(e);return t}var Qc=512*1024;function eu(t,e,n){let r=0,o=[t,e],i=new WeakSet;for(;o.length>0;){let s=o.pop();if(typeof s=="string"){if(r+=s.length,r>n)return!0}else if(typeof s=="object"&&s){if(i.has(s))continue;if(i.add(s),Array.isArray(s))for(let a=0;a<s.length;a++)o.push(s[a]);else{let a=Object.keys(s);for(let l=0;l<a.length;l++){let c=a[l];if(r+=c.length,r>n)return!0;o.push(s[c])}}}}return!1}async function K(t,e,n,r){let o=typeof process<"u"&&process.env!==void 0,i=o&&!!process.env.VITEST_WORKER_ID,s=o&&!!process.env.VITEST_WORKER_ID,a=s&&!eu(e,n,Qc),l=a?q(e):e,c=a?q(n):n,h=!1,m=!1,y;for(let f of t)try{a&&(aa(l),aa(c));let p=await r(f,l,c);if(p===void 0)continue;let g=!1;if(p.messages!==void 0&&p.messages!==l&&(l=q(p.messages),h=!0,g=!0),p.state!==void 0&&p.state!==c&&(c=q(p.state),m=!0,g=!0),a&&g&&eu(l,c,Qc)&&(a=!1),y=p.stopPropagation,y===!0)break}catch(p){if(s&&p instanceof TypeError){if(i)throw p;console.error("AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.",p)}else i||console.error("Subscriber error:",p);continue}return{...h?{messages:Object.isFrozen(l)?q(l):l}:{},...m?{state:Object.isFrozen(c)?q(c):c}:{},...y===void 0?{}:{stopPropagation:y}}}function li(t){if(!t)return{enabled:!1,events:!1,lifecycle:!1,verbose:!1};if(t===!0)return{enabled:!0,events:!0,lifecycle:!0,verbose:!0};let e=t.events??!0,n=t.lifecycle??!0,r=t.verbose??!1;return{enabled:e||n,events:e,lifecycle:n,verbose:r}}function sr(t){if(t instanceof la)return t;if(t===!0)return new la(li(!0))}var la=class{constructor(t){this.config=t}event(t,e,n,r){this.config.events&&(this.config.verbose?console.debug(`[${t}] ${e}`,typeof n=="string"?n:JSON.stringify(n)):console.debug(`[${t}] ${e}`,r??n))}lifecycle(t,e,n){this.config.lifecycle&&(n?console.debug(`[${t}] ${e}`,n):console.debug(`[${t}] ${e}`))}get eventsEnabled(){return this.config.events}get lifecycleEnabled(){return this.config.lifecycle}get enabled(){return this.config.enabled}};function ia(t){return t.enabled?new la(t):void 0}function Nm(t,e,n){if(e){let o=t.find(s=>s.id===e);if(o?.role==="assistant")return o;o&&console.warn(`TOOL_CALL_START: parentMessageId '${e}' matches a '${o.role}' message, not assistant \u2014 falling back to toolCallId`);let i={id:o?n:e,role:"assistant",toolCalls:[]};return t.push(i),i}let r={id:n,role:"assistant",toolCalls:[]};return t.push(r),r}var su=(t,e,n,r,o)=>{let i=sr(o),s=q(n.messages),a=q(t.state),l={},c=m=>{m.messages!==void 0&&(s=m.messages,l.messages=m.messages),m.state!==void 0&&(a=m.state,l.state=m.state)},h=()=>{let m=q(l);return l={},m.messages!==void 0||m.state!==void 0?ue(m):co};return e.pipe(So(async m=>{let y=await K(r,s,a,(f,p,g)=>f.onEvent?.({event:m,agent:n,input:t,messages:p,state:g}));if(c(y),y.stopPropagation===!0?i?.event("APPLY","Event dropped:",m,{type:m.type,reason:"stopPropagation by subscriber"}):i?.event("APPLY","Event applied:",m,{type:m.type,subscribers:r.length}),y.stopPropagation===!0)return h();switch(m.type){case v.TEXT_MESSAGE_START:{let f=await K(r,s,a,(p,g,x)=>p.onTextMessageStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:p,role:g="assistant",name:x}=m;if(!s.find(S=>S.id===p)){let S={id:p,role:g,content:"",...x!==void 0&&{name:x}};s.push(S),c({messages:s})}}return h()}case v.TEXT_MESSAGE_CONTENT:{let{messageId:f,delta:p}=m,g=s.find(S=>S.id===f);if(!g)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${f}'`),h();let x=await K(r,s,a,(S,T,I)=>S.onTextMessageContentEvent?.({event:m,messages:T,state:I,agent:n,input:t,textMessageBuffer:typeof g.content=="string"?g.content:""}));return c(x),x.stopPropagation!==!0&&(g.content=`${typeof g.content=="string"?g.content:""}${p}`,c({messages:s})),h()}case v.TEXT_MESSAGE_END:{let{messageId:f}=m,p=s.find(g=>g.id===f);return p?(c(await K(r,s,a,(g,x,S)=>g.onTextMessageEndEvent?.({event:m,messages:x,state:S,agent:n,input:t,textMessageBuffer:typeof p.content=="string"?p.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:p,messages:s,state:a,agent:n,input:t})})),h()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${f}'`),h())}case v.TOOL_CALL_START:{let f=await K(r,s,a,(p,g,x)=>p.onToolCallStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{toolCallId:p,toolCallName:g,parentMessageId:x}=m,S=Nm(s,x,p);S.toolCalls??=[],S.toolCalls.push({id:p,type:"function",function:{name:g,arguments:""}}),c({messages:s})}return h()}case v.TOOL_CALL_ARGS:{let{toolCallId:f,delta:p}=m,g=s.find(T=>T.toolCalls?.some(I=>I.id===f));if(!g)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${f}'`),h();let x=g.toolCalls?.find(T=>T.id===f);if(!x)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${f}'`),h();let S=await K(r,s,a,(T,I,H)=>{let U=x.function.arguments,Y=x.function.name,re={};try{re=ko(U)}catch{}return T.onToolCallArgsEvent?.({event:m,messages:I,state:H,agent:n,input:t,toolCallBuffer:U,toolCallName:Y,partialToolCallArgs:re})});return c(S),S.stopPropagation!==!0&&(x.function.arguments+=p,c({messages:s})),h()}case v.TOOL_CALL_END:{let{toolCallId:f}=m,p=s.find(x=>x.toolCalls?.some(S=>S.id===f));if(!p)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${f}'`),h();let g=p.toolCalls?.find(x=>x.id===f);return g?(c(await K(r,s,a,(x,S,T)=>{let I=g.function.arguments,H=g.function.name,U={};try{U=JSON.parse(I)}catch{}return x.onToolCallEndEvent?.({event:m,messages:S,state:T,agent:n,input:t,toolCallName:H,toolCallArgs:U})})),await Promise.all(r.map(x=>{x.onNewToolCall?.({toolCall:g,messages:s,state:a,agent:n,input:t})})),h()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${f}'`),h())}case v.TOOL_CALL_RESULT:{let f=await K(r,s,a,(p,g,x)=>p.onToolCallResultEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:p,toolCallId:g,content:x,role:S}=m,T={id:p,toolCallId:g,role:S||"tool",content:x},I=s.findIndex(H=>H.role==="assistant"&&H.toolCalls?.some(U=>U.id===g));if(I===-1)s.push(T);else{let H=I+1;for(;H<s.length&&s[H].role==="tool";)H++;s.splice(H,0,T)}await Promise.all(r.map(H=>{H.onNewMessage?.({message:T,messages:s,state:a,agent:n,input:t})})),c({messages:s})}return h()}case v.STATE_SNAPSHOT:{let f=await K(r,s,a,(p,g,x)=>p.onStateSnapshotEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{snapshot:p}=m;a=p,c({state:a})}return h()}case v.STATE_DELTA:{let f=await K(r,s,a,(p,g,x)=>p.onStateDeltaEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{delta:p}=m;try{a=eo.applyPatch(a,p,!0,!1).newDocument,c({state:a})}catch(g){let x=g instanceof Error?g.message:String(g);console.warn(`Failed to apply state patch:
|
|
6
6
|
Current state: ${JSON.stringify(a,null,2)}
|
|
7
7
|
Patch operations: ${JSON.stringify(p,null,2)}
|
|
8
|
-
Error: ${x}`)}}return h()}case v.MESSAGES_SNAPSHOT:{let f=await K(r,s,a,(p,g,x)=>p.onMessagesSnapshotEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messages:p}=m,g=new Map(p.map(C=>[C.id,C])),x=p.some(C=>C.role==="reasoning"),_=C=>C.role==="activity"||C.role==="reasoning"&&!x;s=s.filter(C=>_(C)||g.has(C.id)).map(C=>_(C)?C:g.get(C.id));let w=new Set(s.map(C=>C.id));for(let C of p)w.has(C.id)||s.push(C);c({messages:s})}return h()}case v.ACTIVITY_SNAPSHOT:{let f=m,p=s.findIndex(C=>C.id===f.messageId),g=p>=0?s[p]:void 0,x=g?.role==="activity"?g:void 0,_=f.replace??!0,w=await K(r,s,a,(C,H,U)=>C.onActivitySnapshotEvent?.({event:f,messages:H,state:U,agent:n,input:t,activityMessage:x,existingMessage:g}));if(c(w),w.stopPropagation!==!0){let C={id:f.messageId,role:"activity",activityType:f.activityType,content:q(f.content)},H;p===-1?(s.push(C),H=C):x?_&&(s[p]={...x,activityType:f.activityType,content:q(f.content)}):_&&(s[p]=C,H=C),c({messages:s}),H&&await Promise.all(r.map(U=>U.onNewMessage?.({message:H,messages:s,state:a,agent:n,input:t})))}return h()}case v.ACTIVITY_DELTA:{let f=m,p=s.findIndex(w=>w.id===f.messageId);if(p===-1)return h();let g=s[p];if(g.role!=="activity")return console.warn(`ACTIVITY_DELTA: Message '${f.messageId}' is not an activity message`),h();let x=g,_=await K(r,s,a,(w,C,H)=>w.onActivityDeltaEvent?.({event:f,messages:C,state:H,agent:n,input:t,activityMessage:x}));if(c(_),_.stopPropagation!==!0)try{let w=q(x.content??{}),C=Zr.applyPatch(w,f.patch??[],!0,!1).newDocument;s[p]={...x,content:q(C),activityType:f.activityType},c({messages:s})}catch(w){let C=w instanceof Error?w.message:String(w);console.warn(`Failed to apply activity patch for '${f.messageId}': ${C}`)}return h()}case v.RAW:return c(await K(r,s,a,(f,p,g)=>f.onRawEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.CUSTOM:return c(await K(r,s,a,(f,p,g)=>f.onCustomEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.RUN_STARTED:{let f=await K(r,s,a,(p,g,x)=>p.onRunStartedEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let p=m;if(p.input?.messages){for(let g of p.input.messages)s.find(x=>x.id===g.id)||s.push(g);c({messages:s})}}return h()}case v.RUN_FINISHED:{let f=m,p=f.outcome?.type==="interrupt"?{event:f,outcome:"interrupt",interrupts:f.outcome.interrupts}:{event:f,outcome:"success",result:f.result},g=await K(r,s,a,(x,_,w)=>x.onRunFinishedEvent?.({...p,messages:_,state:w,agent:n,input:t}));return c(g),g.stopPropagation!==!0&&(n.pendingInterrupts=p.outcome==="interrupt"?[...p.interrupts]:[]),h()}case v.RUN_ERROR:return c(await K(r,s,a,(f,p,g)=>f.onRunErrorEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.STEP_STARTED:return c(await K(r,s,a,(f,p,g)=>f.onStepStartedEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.STEP_FINISHED:return c(await K(r,s,a,(f,p,g)=>f.onStepFinishedEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();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 h();case v.THINKING_END:return h();case v.THINKING_TEXT_MESSAGE_START:return h();case v.THINKING_TEXT_MESSAGE_CONTENT:return h();case v.THINKING_TEXT_MESSAGE_END:return h();case v.REASONING_START:return c(await K(r,s,a,(f,p,g)=>f.onReasoningStartEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.REASONING_MESSAGE_START:{let f=await K(r,s,a,(p,g,x)=>p.onReasoningMessageStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:p}=m;if(!s.find(g=>g.id===p)){let g={id:p,role:"reasoning",content:""};s.push(g),c({messages:s})}}return h()}case v.REASONING_MESSAGE_CONTENT:{let{messageId:f,delta:p}=m,g=s.find(_=>_.id===f);if(!g)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${f}'`),h();let x=await K(r,s,a,(_,w,C)=>_.onReasoningMessageContentEvent?.({event:m,messages:w,state:C,agent:n,input:t,reasoningMessageBuffer:typeof g.content=="string"?g.content:""}));return c(x),x.stopPropagation!==!0&&(g.content=`${typeof g.content=="string"?g.content:""}${p}`,c({messages:s})),h()}case v.REASONING_MESSAGE_END:{let{messageId:f}=m,p=s.find(g=>g.id===f);return p?(c(await K(r,s,a,(g,x,_)=>g.onReasoningMessageEndEvent?.({event:m,messages:x,state:_,agent:n,input:t,reasoningMessageBuffer:typeof p.content=="string"?p.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:p,messages:s,state:a,agent:n,input:t})})),h()):(console.warn(`REASONING_MESSAGE_END: No message found with ID '${f}'`),h())}case v.REASONING_MESSAGE_CHUNK:throw Error("REASONING_MESSAGE_CHUNK must be transformed before being applied");case v.REASONING_END:return c(await K(r,s,a,(f,p,g)=>f.onReasoningEndEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.REASONING_ENCRYPTED_VALUE:{let{subtype:f,entityId:p,encryptedValue:g}=m,x=await K(r,s,a,(_,w,C)=>_.onReasoningEncryptedValueEvent?.({event:m,messages:w,state:C,agent:n,input:t}));if(c(x),x.stopPropagation!==!0){let _=!1;if(f==="tool-call"){for(let w of s)if(w.role==="assistant"&&w.toolCalls){let C=w.toolCalls.find(H=>H.id===p);if(C){C.encryptedValue=g,_=!0;break}}}else{let w=s.find(C=>C.id===p);w?.role!=="activity"&&w&&(w.encryptedValue=g,_=!0)}_&&(l.messages=s)}return h()}}return m.type,h()}),Us(),r.length>0?Hs({}):m=>m)},na=t=>e=>{let n=or(t),r=new Map,o=new Map,i=!1,s=!1,a=!1,l=new Map,c=!1,h=!1,m=!1,y=()=>{r.clear(),o.clear(),l.clear(),c=!1,h=!1,i=!1,s=!1,m=!0};return e.pipe(Me(f=>{let p=f.type;if(n?.event("VERIFY","Event:",f,{type:f.type}),s)return ne(()=>new ee(`Cannot send event type '${p}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(i&&p!==v.RUN_ERROR&&p!==v.RUN_STARTED)return ne(()=>new ee(`Cannot send event type '${p}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(a){if(p===v.RUN_STARTED){if(m&&!i)return ne(()=>new ee("Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run."));i&&y()}}else if(a=!0,p!==v.RUN_STARTED&&p!==v.RUN_ERROR)return ne(()=>new ee("First event must be 'RUN_STARTED'"));switch(p){case v.TEXT_MESSAGE_START:{let g=f.messageId;return r.has(g)?ne(()=>new ee(`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),ue(f))}case v.TEXT_MESSAGE_CONTENT:{let g=f.messageId;return r.has(g)?ue(f):ne(()=>new ee(`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),ue(f)):ne(()=>new ee(`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)?ne(()=>new ee(`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),ue(f))}case v.TOOL_CALL_ARGS:{let g=f.toolCallId;return o.has(g)?ue(f):ne(()=>new ee(`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),ue(f)):ne(()=>new ee(`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 l.has(g)?ne(()=>new ee(`Step "${g}" is already active for 'STEP_STARTED'`)):(l.set(g,!0),ue(f))}case v.STEP_FINISHED:{let g=f.stepName;return l.has(g)?(l.delete(g),ue(f)):ne(()=>new ee(`Cannot send 'STEP_FINISHED' for step "${g}" that was not started`))}case v.RUN_STARTED:return m=!0,ue(f);case v.RUN_FINISHED:if(l.size>0){let g=Array.from(l.keys()).join(", ");return ne(()=>new ee(`Cannot send 'RUN_FINISHED' while steps are still active: ${g}`))}if(r.size>0){let g=Array.from(r.keys()).join(", ");return ne(()=>new ee(`Cannot send 'RUN_FINISHED' while text messages are still active: ${g}`))}if(o.size>0){let g=Array.from(o.keys()).join(", ");return ne(()=>new ee(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${g}`))}return i=!0,ue(f);case v.RUN_ERROR:return s=!0,ue(f);case v.CUSTOM:return ue(f);case v.THINKING_TEXT_MESSAGE_START:return c?h?ne(()=>new ee("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.")):(h=!0,ue(f)):ne(()=>new ee("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 h?ue(f):ne(()=>new ee("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 h?(h=!1,ue(f)):ne(()=>new ee("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?ne(()=>new ee("Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.")):(c=!0,ue(f));case v.THINKING_END:return c?(c=!1,ue(f)):ne(()=>new ee("Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first."));default:return ue(f)}}))},Qt=(function(t){return t.HEADERS="headers",t.DATA="data",t})({}),xm=t=>Eo(()=>Kt(t())).pipe(Gs(e=>{if(!e.ok){let o=e.headers.get("content-type")||"";return Kt(e.text()).pipe(Me(i=>{let s=i;if(o.includes("application/json"))try{s=JSON.parse(i)}catch{}let a=Error(`HTTP ${e.status}: ${typeof s=="string"?s:JSON.stringify(s)}`);return a.status=e.status,a.payload=s,ne(()=>a)}))}let n={type:Qt.HEADERS,status:e.status,headers:e.headers},r=e.body?.getReader();return r?new te(o=>(o.next(n),(async()=>{try{for(;;){let{done:i,value:s}=await r.read();if(i)break;let a={type:Qt.DATA,data:s};o.next(a)}o.complete()}catch(i){o.error(i)}})(),()=>{r.cancel().catch(i=>{if(i?.name!=="AbortError")throw i})})):ne(()=>Error("Failed to getReader() from response"))})),Em=(t,e)=>{let n=or(e),r=new it,o=new TextDecoder("utf-8",{fatal:!1}),i="";t.subscribe({next:a=>{if(a.type!==Qt.HEADERS&&a.type===Qt.DATA&&a.data){let l=o.decode(a.data,{stream:!0});i+=l;let c=i.split(/\n\n/);i=c.pop()||"";for(let h of c)s(h)}},error:a=>r.error(a),complete:()=>{i&&(i+=o.decode(),s(i)),r.complete()}});function s(a){let l=a.split(`
|
|
8
|
+
Error: ${x}`)}}return h()}case v.MESSAGES_SNAPSHOT:{let f=await K(r,s,a,(p,g,x)=>p.onMessagesSnapshotEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messages:p}=m,g=new Map(p.map(I=>[I.id,I])),x=p.some(I=>I.role==="reasoning"),S=I=>I.role==="activity"||I.role==="reasoning"&&!x;s=s.filter(I=>S(I)||g.has(I.id)).map(I=>S(I)?I:g.get(I.id));let T=new Set(s.map(I=>I.id));for(let I of p)T.has(I.id)||s.push(I);c({messages:s})}return h()}case v.ACTIVITY_SNAPSHOT:{let f=m,p=s.findIndex(I=>I.id===f.messageId),g=p>=0?s[p]:void 0,x=g?.role==="activity"?g:void 0,S=f.replace??!0,T=await K(r,s,a,(I,H,U)=>I.onActivitySnapshotEvent?.({event:f,messages:H,state:U,agent:n,input:t,activityMessage:x,existingMessage:g}));if(c(T),T.stopPropagation!==!0){let I={id:f.messageId,role:"activity",activityType:f.activityType,content:q(f.content)},H;p===-1?(s.push(I),H=I):x?S&&(s[p]={...x,activityType:f.activityType,content:q(f.content)}):S&&(s[p]=I,H=I),c({messages:s}),H&&await Promise.all(r.map(U=>U.onNewMessage?.({message:H,messages:s,state:a,agent:n,input:t})))}return h()}case v.ACTIVITY_DELTA:{let f=m,p=s.findIndex(T=>T.id===f.messageId);if(p===-1)return h();let g=s[p];if(g.role!=="activity")return console.warn(`ACTIVITY_DELTA: Message '${f.messageId}' is not an activity message`),h();let x=g,S=await K(r,s,a,(T,I,H)=>T.onActivityDeltaEvent?.({event:f,messages:I,state:H,agent:n,input:t,activityMessage:x}));if(c(S),S.stopPropagation!==!0)try{let T=q(x.content??{}),I=eo.applyPatch(T,f.patch??[],!0,!1).newDocument;s[p]={...x,content:q(I),activityType:f.activityType},c({messages:s})}catch(T){let I=T instanceof Error?T.message:String(T);console.warn(`Failed to apply activity patch for '${f.messageId}': ${I}`)}return h()}case v.RAW:return c(await K(r,s,a,(f,p,g)=>f.onRawEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.CUSTOM:return c(await K(r,s,a,(f,p,g)=>f.onCustomEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.RUN_STARTED:{let f=await K(r,s,a,(p,g,x)=>p.onRunStartedEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let p=m;if(p.input?.messages){for(let g of p.input.messages)s.find(x=>x.id===g.id)||s.push(g);c({messages:s})}}return h()}case v.RUN_FINISHED:{let f=m,p=f.outcome?.type==="interrupt"?{event:f,outcome:"interrupt",interrupts:f.outcome.interrupts}:{event:f,outcome:"success",result:f.result},g=await K(r,s,a,(x,S,T)=>x.onRunFinishedEvent?.({...p,messages:S,state:T,agent:n,input:t}));return c(g),g.stopPropagation!==!0&&(n.pendingInterrupts=p.outcome==="interrupt"?[...p.interrupts]:[]),h()}case v.RUN_ERROR:return c(await K(r,s,a,(f,p,g)=>f.onRunErrorEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.STEP_STARTED:return c(await K(r,s,a,(f,p,g)=>f.onStepStartedEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.STEP_FINISHED:return c(await K(r,s,a,(f,p,g)=>f.onStepFinishedEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();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 h();case v.THINKING_END:return h();case v.THINKING_TEXT_MESSAGE_START:return h();case v.THINKING_TEXT_MESSAGE_CONTENT:return h();case v.THINKING_TEXT_MESSAGE_END:return h();case v.REASONING_START:return c(await K(r,s,a,(f,p,g)=>f.onReasoningStartEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.REASONING_MESSAGE_START:{let f=await K(r,s,a,(p,g,x)=>p.onReasoningMessageStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:p}=m;if(!s.find(g=>g.id===p)){let g={id:p,role:"reasoning",content:""};s.push(g),c({messages:s})}}return h()}case v.REASONING_MESSAGE_CONTENT:{let{messageId:f,delta:p}=m,g=s.find(S=>S.id===f);if(!g)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${f}'`),h();let x=await K(r,s,a,(S,T,I)=>S.onReasoningMessageContentEvent?.({event:m,messages:T,state:I,agent:n,input:t,reasoningMessageBuffer:typeof g.content=="string"?g.content:""}));return c(x),x.stopPropagation!==!0&&(g.content=`${typeof g.content=="string"?g.content:""}${p}`,c({messages:s})),h()}case v.REASONING_MESSAGE_END:{let{messageId:f}=m,p=s.find(g=>g.id===f);return p?(c(await K(r,s,a,(g,x,S)=>g.onReasoningMessageEndEvent?.({event:m,messages:x,state:S,agent:n,input:t,reasoningMessageBuffer:typeof p.content=="string"?p.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:p,messages:s,state:a,agent:n,input:t})})),h()):(console.warn(`REASONING_MESSAGE_END: No message found with ID '${f}'`),h())}case v.REASONING_MESSAGE_CHUNK:throw Error("REASONING_MESSAGE_CHUNK must be transformed before being applied");case v.REASONING_END:return c(await K(r,s,a,(f,p,g)=>f.onReasoningEndEvent?.({event:m,messages:p,state:g,agent:n,input:t}))),h();case v.REASONING_ENCRYPTED_VALUE:{let{subtype:f,entityId:p,encryptedValue:g}=m,x=await K(r,s,a,(S,T,I)=>S.onReasoningEncryptedValueEvent?.({event:m,messages:T,state:I,agent:n,input:t}));if(c(x),x.stopPropagation!==!0){let S=!1;if(f==="tool-call"){for(let T of s)if(T.role==="assistant"&&T.toolCalls){let I=T.toolCalls.find(H=>H.id===p);if(I){I.encryptedValue=g,S=!0;break}}}else{let T=s.find(I=>I.id===p);T?.role!=="activity"&&T&&(T.encryptedValue=g,S=!0)}S&&(l.messages=s)}return h()}}return m.type,h()}),Fs(),r.length>0?$s({}):m=>m)},sa=t=>e=>{let n=sr(t),r=new Map,o=new Map,i=!1,s=!1,a=!1,l=new Map,c=!1,h=!1,m=!1,y=()=>{r.clear(),o.clear(),l.clear(),c=!1,h=!1,i=!1,s=!1,m=!0};return e.pipe(Me(f=>{let p=f.type;if(n?.event("VERIFY","Event:",f,{type:f.type}),s)return ne(()=>new ee(`Cannot send event type '${p}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(i&&p!==v.RUN_ERROR&&p!==v.RUN_STARTED)return ne(()=>new ee(`Cannot send event type '${p}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(a){if(p===v.RUN_STARTED){if(m&&!i)return ne(()=>new ee("Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run."));i&&y()}}else if(a=!0,p!==v.RUN_STARTED&&p!==v.RUN_ERROR)return ne(()=>new ee("First event must be 'RUN_STARTED'"));switch(p){case v.TEXT_MESSAGE_START:{let g=f.messageId;return r.has(g)?ne(()=>new ee(`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),ue(f))}case v.TEXT_MESSAGE_CONTENT:{let g=f.messageId;return r.has(g)?ue(f):ne(()=>new ee(`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),ue(f)):ne(()=>new ee(`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)?ne(()=>new ee(`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),ue(f))}case v.TOOL_CALL_ARGS:{let g=f.toolCallId;return o.has(g)?ue(f):ne(()=>new ee(`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),ue(f)):ne(()=>new ee(`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 l.has(g)?ne(()=>new ee(`Step "${g}" is already active for 'STEP_STARTED'`)):(l.set(g,!0),ue(f))}case v.STEP_FINISHED:{let g=f.stepName;return l.has(g)?(l.delete(g),ue(f)):ne(()=>new ee(`Cannot send 'STEP_FINISHED' for step "${g}" that was not started`))}case v.RUN_STARTED:return m=!0,ue(f);case v.RUN_FINISHED:if(l.size>0){let g=Array.from(l.keys()).join(", ");return ne(()=>new ee(`Cannot send 'RUN_FINISHED' while steps are still active: ${g}`))}if(r.size>0){let g=Array.from(r.keys()).join(", ");return ne(()=>new ee(`Cannot send 'RUN_FINISHED' while text messages are still active: ${g}`))}if(o.size>0){let g=Array.from(o.keys()).join(", ");return ne(()=>new ee(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${g}`))}return i=!0,ue(f);case v.RUN_ERROR:return s=!0,ue(f);case v.CUSTOM:return ue(f);case v.THINKING_TEXT_MESSAGE_START:return c?h?ne(()=>new ee("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.")):(h=!0,ue(f)):ne(()=>new ee("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 h?ue(f):ne(()=>new ee("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 h?(h=!1,ue(f)):ne(()=>new ee("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?ne(()=>new ee("Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.")):(c=!0,ue(f));case v.THINKING_END:return c?(c=!1,ue(f)):ne(()=>new ee("Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first."));default:return ue(f)}}))},en=(function(t){return t.HEADERS="headers",t.DATA="data",t})({}),Om=t=>wo(()=>Zt(t())).pipe(Bs(e=>{if(!e.ok){let o=e.headers.get("content-type")||"";return Zt(e.text()).pipe(Me(i=>{let s=i;if(o.includes("application/json"))try{s=JSON.parse(i)}catch{}let a=Error(`HTTP ${e.status}: ${typeof s=="string"?s:JSON.stringify(s)}`);return a.status=e.status,a.payload=s,ne(()=>a)}))}let n={type:en.HEADERS,status:e.status,headers:e.headers},r=e.body?.getReader();return r?new te(o=>(o.next(n),(async()=>{try{for(;;){let{done:i,value:s}=await r.read();if(i)break;let a={type:en.DATA,data:s};o.next(a)}o.complete()}catch(i){o.error(i)}})(),()=>{r.cancel().catch(i=>{if(i?.name!=="AbortError")throw i})})):ne(()=>Error("Failed to getReader() from response"))})),Mm=(t,e)=>{let n=sr(e),r=new st,o=new TextDecoder("utf-8",{fatal:!1}),i="";t.subscribe({next:a=>{if(a.type!==en.HEADERS&&a.type===en.DATA&&a.data){let l=o.decode(a.data,{stream:!0});i+=l;let c=i.split(/\n\n/);i=c.pop()||"";for(let h of c)s(h)}},error:a=>r.error(a),complete:()=>{i&&(i+=o.decode(),s(i)),r.complete()}});function s(a){let l=a.split(`
|
|
9
9
|
`),c=[];for(let h of l)h.startsWith("data:")&&c.push(h.slice(5).replace(/^ /,""));if(c.length>0)try{let h=c.join(`
|
|
10
|
-
`),m=JSON.parse(h);n?.event("SSE","Event received:",m,{type:m.type}),r.next(m)}catch(h){r.error(h)}}return r.asObservable()},
|
|
11
|
-
`)},Dm=(t,e,n)=>r=>{let o={},i=!0,s=!0,a="",l=null,c=null,h=[],m={},y=f=>{typeof f=="object"&&f&&("messages"in f&&delete f.messages,o=f)};return r.pipe(Me(f=>{switch(f.type){case v.TEXT_MESSAGE_START:{let p=f;return[{type:Q.enum.TextMessageStart,messageId:p.messageId,role:p.role}]}case v.TEXT_MESSAGE_CONTENT:{let p=f;return[{type:Q.enum.TextMessageContent,messageId:p.messageId,content:p.delta}]}case v.TEXT_MESSAGE_END:{let p=f;return[{type:Q.enum.TextMessageEnd,messageId:p.messageId}]}case v.TOOL_CALL_START:{let p=f;return h.push({id:p.toolCallId,type:"function",function:{name:p.toolCallName,arguments:""}}),s=!0,m[p.toolCallId]=p.toolCallName,[{type:Q.enum.ActionExecutionStart,actionExecutionId:p.toolCallId,actionName:p.toolCallName,parentMessageId:p.parentMessageId}]}case v.TOOL_CALL_ARGS:{let p=f,g=h.find(_=>_.id===p.toolCallId);if(!g)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${p.toolCallId}'`),[];g.function.arguments+=p.delta;let x=!1;if(c){let _=c.find(w=>w.tool==g.function.name);if(_)try{let w=JSON.parse(So(g.function.arguments));_.tool_argument&&_.tool_argument in w?(y({...o,[_.state_key]:w[_.tool_argument]}),x=!0):_.tool_argument||(y({...o,[_.state_key]:w}),x=!0)}catch{}}return[{type:Q.enum.ActionExecutionArgs,actionExecutionId:p.toolCallId,args:p.delta},...x?[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}]:[]]}case v.TOOL_CALL_END:{let p=f;return[{type:Q.enum.ActionExecutionEnd,actionExecutionId:p.toolCallId}]}case v.TOOL_CALL_RESULT:{let p=f;return[{type:Q.enum.ActionExecutionResult,actionExecutionId:p.toolCallId,result:p.content,actionName:m[p.toolCallId]||"unknown"}]}case v.RAW:return[];case v.CUSTOM:{let p=f;switch(p.name){case"Exit":i=!1;break;case"PredictState":c=p.value;break}return[{type:Q.enum.MetaEvent,name:p.name,value:p.value}]}case v.STATE_SNAPSHOT:return y(f.snapshot),[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}];case v.STATE_DELTA:{let p=f,g=Zr.applyPatch(o,p.delta,!0,!1);return g?(y(g.newDocument),[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}]):[]}case v.MESSAGES_SNAPSHOT:return l=f.messages,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify({...o,...l?{messages:l}:{}}),active:!0}];case v.RUN_STARTED:return[];case v.RUN_FINISHED:return l&&(o.messages=l),Object.keys(o).length===0?[]:[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify({...o,...l?{messages:Um(l)}:{}}),active:!1}];case v.RUN_ERROR:{let p=f;return[{type:Q.enum.RunError,message:p.message,code:p.code}]}case v.STEP_STARTED:return a=f.stepName,h=[],c=null,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:!0}];case v.STEP_FINISHED:return h=[],c=null,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:!1}];default:return[]}}))};function Um(t){let e=[];for(let n of t)if(n.role==="assistant"||n.role==="user"||n.role==="system"){let r=Pm(n.content);if(r){let o={id:n.id,role:n.role,content:r};e.push(o)}if(n.role==="assistant"&&n.toolCalls&&n.toolCalls.length>0)for(let o of n.toolCalls){let i={id:o.id,name:o.function.name,arguments:JSON.parse(o.function.arguments),parentMessageId:n.id};e.push(i)}}else if(n.role==="tool"){let r="unknown";for(let i of t)if(i.role==="assistant"&&i.toolCalls?.length){for(let s of i.toolCalls)if(s.id===n.toolCallId){r=s.function.name;break}}let o={id:n.id,result:n.content,actionExecutionId:n.toolCallId,actionName:r};e.push(o)}return e}var si=t=>e=>{let n=or(t),r,o,i,s,a=()=>{if(!r||s!=="text")throw Error("No text message to close");let m={type:v.TEXT_MESSAGE_END,messageId:r.messageId};return s=void 0,r=void 0,n?.event("TRANSFORM","TEXT_MESSAGE_END",m,{messageId:m.messageId}),m},l=()=>{if(!o||s!=="tool")throw Error("No tool call to close");let m={type:v.TOOL_CALL_END,toolCallId:o.toolCallId};return s=void 0,o=void 0,n?.event("TRANSFORM","TOOL_CALL_END",m,{toolCallId:m.toolCallId}),m},c=()=>{if(!i||s!=="reasoning")throw Error("No reasoning message to close");let m={type:v.REASONING_MESSAGE_END,messageId:i.messageId};return s=void 0,i=void 0,n?.event("TRANSFORM","REASONING_MESSAGE_END",m,{messageId:m.messageId}),m},h=()=>s==="text"?[a()]:s==="tool"?[l()]:s==="reasoning"?[c()]:[];return e.pipe(Me(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[...h(),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 y=m,f=[];if((s!=="text"||y.messageId!==void 0&&y.messageId!==r?.messageId)&&f.push(...h()),s!=="text"){if(y.messageId===void 0)throw Error("First TEXT_MESSAGE_CHUNK must have a messageId");r={messageId:y.messageId,name:y.name},s="text";let w={type:v.TEXT_MESSAGE_START,messageId:y.messageId,role:y.role||"assistant",...y.name!==void 0&&{name:y.name}};f.push(w),n?.event("TRANSFORM","TEXT_MESSAGE_START",w,{messageId:y.messageId})}if(y.delta!==void 0){let w={type:v.TEXT_MESSAGE_CONTENT,messageId:r.messageId,delta:y.delta};f.push(w),n?.event("TRANSFORM","TEXT_MESSAGE_CONTENT",w,{messageId:r.messageId})}return f;case v.TOOL_CALL_CHUNK:let p=m,g=[];if((s!=="tool"||p.toolCallId!==void 0&&p.toolCallId!==o?.toolCallId)&&g.push(...h()),s!=="tool"){if(p.toolCallId===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallId");if(p.toolCallName===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallName");o={toolCallId:p.toolCallId,toolCallName:p.toolCallName,parentMessageId:p.parentMessageId},s="tool";let w={type:v.TOOL_CALL_START,toolCallId:p.toolCallId,toolCallName:p.toolCallName,parentMessageId:p.parentMessageId};g.push(w),n?.event("TRANSFORM","TOOL_CALL_START",w,{toolCallId:p.toolCallId,toolCallName:p.toolCallName})}if(p.delta!==void 0){let w={type:v.TOOL_CALL_ARGS,toolCallId:o.toolCallId,delta:p.delta};g.push(w),n?.event("TRANSFORM","TOOL_CALL_ARGS",w,{toolCallId:o.toolCallId})}return g;case v.REASONING_MESSAGE_CHUNK:let x=m,_=[];if((s!=="reasoning"||x.messageId&&x.messageId!==i?.messageId)&&_.push(...h()),s!=="reasoning"){if(x.messageId===void 0)throw Error("First REASONING_MESSAGE_CHUNK must have a messageId");i={messageId:x.messageId},s="reasoning";let w={type:v.REASONING_MESSAGE_START,messageId:x.messageId};_.push(w),n?.event("TRANSFORM","REASONING_MESSAGE_START",w,{messageId:x.messageId})}if(x.delta!==void 0){let w={type:v.REASONING_MESSAGE_CONTENT,messageId:i.messageId,delta:x.delta};_.push(w),n?.event("TRANSFORM","REASONING_MESSAGE_CONTENT",w,{messageId:i.messageId})}return _}return m.type,[]}),Jt(()=>{h()}))};function Hm(t,e=new Date){return t.expiresAt===void 0?!1:new Date(t.expiresAt)<=e}function nu(t,e){let n=new Set(t.map(s=>s.id)),r=new Set(Object.keys(e)),o=[...n].filter(s=>!r.has(s));if(o.length>0)throw Error(`buildResumeArray: missing responses for open interrupts: ${o.join(", ")}`);let i=[...r].filter(s=>!n.has(s));if(i.length>0)throw Error(`buildResumeArray: responses reference unknown interrupt ids: ${i.join(", ")}`);return t.map(s=>{let a=e[s.id];if(a.status==="resolved"){let l={interruptId:s.id,status:"resolved"};return a.payload!==void 0&&(l.payload=a.payload),l}return{interruptId:s.id,status:"cancelled"}})}var ai=class{runNext(t,e){return e.run(t).pipe(si(!1))}runNextWithState(t,e){let n=q(t.messages||[]),r=q(t.state||{}),o=new io;return tu(t,o,e,[]).subscribe(i=>{i.messages!==void 0&&(n=i.messages),i.state!==void 0&&(r=i.state)}),this.runNext(t,e).pipe(To(async i=>(o.next(i),await new Promise(s=>setTimeout(s,0)),{event:i,messages:q(n),state:q(r)})))}},Gm=class extends ai{constructor(t){super(),this.fn=t}run(t,e){return this.fn(t,e)}};function zm(t){let e=t.content;if(Array.isArray(e)){let n=e.filter(r=>typeof r=="object"&&!!r&&"type"in r&&r.type==="text"&&typeof r.text=="string").map(r=>r.text).join("");return{...t,content:n}}return typeof e=="string"?t:{...t,content:""}}var Fm=class extends ai{run(t,e){let{parentRunId:n,...r}=t,o={...r,messages:r.messages.map(zm)};return this.runNext(o,e)}},Kc="THINKING_START",Zc="THINKING_END",Jc="THINKING_TEXT_MESSAGE_START",Qc="THINKING_TEXT_MESSAGE_CONTENT",eu="THINKING_TEXT_MESSAGE_END",$m=class extends ai{constructor(...t){super(...t),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(t,e){typeof process<"u"&&process.env!==void 0&&process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${t} to ${e}. 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(t,e){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(t,e).pipe(Zt(n=>this.transformEvent(n)))}transformEvent(t){switch(t.type){case Kc:{this.currentReasoningId=Ue();let{title:e,...n}=t;return this.warnAboutTransformation(Kc,v.REASONING_START),{...n,type:v.REASONING_START,messageId:this.currentReasoningId}}case Jc:return this.currentMessageId=Ue(),this.warnAboutTransformation(Jc,v.REASONING_MESSAGE_START),{...t,type:v.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:"assistant"};case Qc:{let{delta:e,...n}=t;return this.warnAboutTransformation(Qc,v.REASONING_MESSAGE_CONTENT),{...n,type:v.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??Ue(),delta:e}}case eu:{let e=this.currentMessageId??Ue();return this.warnAboutTransformation(eu,v.REASONING_MESSAGE_END),{...t,type:v.REASONING_MESSAGE_END,messageId:e}}case Zc:{let e=this.currentReasoningId??Ue();return this.warnAboutTransformation(Zc,v.REASONING_END),{...t,type:v.REASONING_END,messageId:e}}default:return t}}};function Bm(t){return t.startsWith("image/")?"image":t.startsWith("audio/")?"audio":t.startsWith("video/")?"video":"document"}function Vm(t){return typeof t=="object"&&!!t&&"type"in t&&t.type==="binary"&&"mimeType"in t&&typeof t.mimeType=="string"}function jm(t){let e=Bm(t.mimeType);return t.data?{type:e,source:{type:"data",value:t.data,mimeType:t.mimeType},...t.filename?{metadata:{filename:t.filename}}:{}}:t.url?{type:e,source:{type:"url",value:t.url,mimeType:t.mimeType},...t.filename?{metadata:{filename:t.filename}}:{}}:t}function qm(t){let e=t.content;if(!Array.isArray(e))return t;let n=e.map(r=>Vm(r)?jm(r):r);return{...t,content:n}}var Wm=class extends ai{run(t,e){let n={...t,messages:t.messages.map(qm)};return this.runNext(n,e)}},Xm="0.0.57",Ym=class{get maxVersion(){return Xm}get debug(){return this._debug}set debug(t){this._debug=ii(t),this._debugLogger=ta(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(t){typeof t=="boolean"?this._debugLogger=t?ta(ii(!0)):void 0:this._debugLogger=t}constructor({agentId:t,description:e,threadId:n,initialMessages:r,initialState:o,debug:i}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.agentId=t,this.description=e??"",this.threadId=n??yt(),this.messages=q(r??[]),this.state=q(o??{}),this._debug=ii(i),this._debugLogger=ta(this._debug),rr(this.maxVersion,"0.0.39")<=0&&this.middlewares.unshift(new Fm),rr(this.maxVersion,"0.0.45")<=0&&this.middlewares.unshift(new $m),rr(this.maxVersion,"0.0.47")<=0&&this.middlewares.unshift(new Wm)}subscribe(t){return this.subscribers.push(t),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(e=>e!==t)}}}use(...t){let e=t.map(n=>typeof n=="function"?new Gm(n):n);return this.middlewares.push(...e),this}async runAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??yt();let n=this.prepareRunAgentInput(t);this.debugLogger?.lifecycle("LIFECYCLE","Run started:",{agentId:this.agentId,threadId:this.threadId});let r,o=new Set(this.messages.map(l=>l.id)),i=[{onRunFinishedEvent:l=>{l.outcome==="success"&&(r=l.result)}},...this.subscribers,e??{}];await this.onInitialize(n,i),this.activeRunDetach$=new it;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await xo(oo(()=>this.middlewares.length===0?this.run(n):this.middlewares.reduceRight((l,c)=>({run:h=>c.run(h,l),get messages(){return l.messages},get state(){return l.state}}),this).run(n),si(this.debugLogger),na(this.debugLogger),l=>l.pipe(wo(this.activeRunDetach$)),l=>this.apply(n,l,i),l=>this.processApplyEvents(n,l,i),er(l=>(this.debugLogger?.lifecycle("LIFECYCLE","Run errored:",{agentId:this.agentId,error:l instanceof Error?l.message:String(l)}),this.isRunning=!1,this.onError(n,l,i))),Jt(()=>{this.debugLogger?.lifecycle("LIFECYCLE","Run finished:",{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(n,i),s?.(),s=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(ue(null)));let a=q(this.messages).filter(l=>!o.has(l.id));return{result:r,newMessages:a}}finally{this.isRunning=!1}}connect(t){throw new Ss}async connectAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??yt();let n=this.prepareRunAgentInput(t),r,o=new Set(this.messages.map(l=>l.id)),i=[{onRunFinishedEvent:l=>{l.outcome==="success"&&(r=l.result)}},...this.subscribers,e??{}];await this.onInitialize(n,i),this.activeRunDetach$=new it;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await xo(oo(()=>Eo(()=>this.connect(n)),si(this.debugLogger),na(this.debugLogger),l=>l.pipe(wo(this.activeRunDetach$)),l=>this.apply(n,l,i),l=>this.processApplyEvents(n,l,i),er(l=>(this.isRunning=!1,l instanceof Ss?so:this.onError(n,l,i))),Jt(()=>{this.isRunning=!1,this.onFinalize(n,i),s?.(),s=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(ue(null)),{defaultValue:void 0});let a=q(this.messages).filter(l=>!o.has(l.id));return{result:r,newMessages:a}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){if(!this.activeRunDetach$)return;let t=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),this.activeRunDetach$?.complete(),await t}apply(t,e,n){return tu(t,e,this,n,this.debugLogger)}processApplyEvents(t,e,n){return e.pipe(zs(r=>{r.messages&&(this.messages=r.messages,n.forEach(o=>{o.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),r.state&&(this.state=r.state,n.forEach(o=>{o.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})}))}))}prepareRunAgentInput(t){let e=q(this.messages).filter(n=>n.role!=="activity");return{threadId:this.threadId,runId:t?.runId||yt(),tools:q(t?.tools??[]),context:q(t?.context??[]),forwardedProps:q(t?.forwardedProps??{}),state:q(this.state),messages:e,...t?.resume===void 0?{}:{resume:q(t.resume)}}}async onInitialize(t,e){if(this.pendingInterrupts.length>0){let r=new Set((t.resume??[]).map(i=>i.interruptId)),o=this.pendingInterrupts.map(i=>i.id).filter(i=>!r.has(i));if(o.length>0)throw new ee(`Thread has ${o.length} pending interrupt(s) not addressed by resume: ${o.join(", ")}`);for(let i of this.pendingInterrupts)if(Hm(i))throw new ee(`Interrupt ${i.id} expired at ${i.expiresAt}`)}let n=await K(e,this.messages,this.state,(r,o,i)=>r.onRunInitialized?.({messages:o,state:i,agent:this,input:t}));(n.messages!==void 0||n.state!==void 0)&&(n.messages&&(this.messages=n.messages,t.messages=n.messages,e.forEach(r=>{r.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),n.state&&(this.state=n.state,t.state=n.state,e.forEach(r=>{r.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})})))}onError(t,e,n){return Kt(K(n,this.messages,this.state,(r,o,i)=>r.onRunFailed?.({error:e,messages:o,state:i,agent:this,input:t}))).pipe(Zt(r=>{let o=r;if((o.messages!==void 0||o.state!==void 0)&&(o.messages!==void 0&&(this.messages=o.messages,n.forEach(i=>{i.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),o.state!==void 0&&(this.state=o.state,n.forEach(i=>{i.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})}))),o.stopPropagation!==!0){let i=String(e);if(!(e.name==="AbortError"||e.message==="Fetch is aborted"||e.message==="signal is aborted without reason"||e.message==="component unmounted"||i==="component unmounted"))throw console.error("Agent execution failed:",e),e}return{}}))}async onFinalize(t,e){let n=await K(e,this.messages,this.state,(r,o,i)=>r.onRunFinalized?.({messages:o,state:i,agent:this,input:t}));(n.messages!==void 0||n.state!==void 0)&&(n.messages!==void 0&&(this.messages=n.messages,e.forEach(r=>{r.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),n.state!==void 0&&(this.state=n.state,e.forEach(r=>{r.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})})))}clone(){let t=Object.create(Object.getPrototypeOf(this));return t.agentId=this.agentId,t.description=this.description,t.threadId=this.threadId,t.messages=q(this.messages),t.state=q(this.state),t._debug=this._debug,t._debugLogger=this._debugLogger,t.isRunning=this.isRunning,t.subscribers=[...this.subscribers],t.middlewares=[...this.middlewares],t.pendingInterrupts=q(this.pendingInterrupts),t}addMessage(t){this.messages.push(t),(async()=>{for(let e of this.subscribers)await e.onNewMessage?.({message:t,messages:this.messages,state:this.state,agent:this});if(t.role==="assistant"&&t.toolCalls)for(let e of t.toolCalls)for(let n of this.subscribers)await n.onNewToolCall?.({toolCall:e,messages:this.messages,state:this.state,agent:this});for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}addMessages(t){this.messages.push(...t),(async()=>{for(let e of t){for(let n of this.subscribers)await n.onNewMessage?.({message:e,messages:this.messages,state:this.state,agent:this});if(e.role==="assistant"&&e.toolCalls)for(let n of e.toolCalls)for(let r of this.subscribers)await r.onNewToolCall?.({toolCall:n,messages:this.messages,state:this.state,agent:this})}for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setMessages(t){this.messages=q(t),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(t){this.state=q(t),(async()=>{for(let e of this.subscribers)await e.onStateChanged?.({messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(t){this.agentId=this.agentId??yt();let e=this.prepareRunAgentInput(t);return(this.middlewares.length===0?this.run(e):this.middlewares.reduceRight((n,r)=>({run:o=>r.run(o,n),get messages(){return n.messages},get state(){return n.state}}),this).run(e)).pipe(si(this.debugLogger),na(this.debugLogger),Dm(this.threadId,e.runId,this.agentId),n=>n.pipe(Zt(r=>(this.debugLogger?.event("LEGACY","Event:",r,{type:r.type}),r))))}},ru=class extends Ym{requestInit(t){return{method:"POST",headers:{...this.headers,"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(t),signal:this.abortController.signal}}runAgent(t,e){return this.abortController=t?.abortController??new AbortController,super.runAgent(t,e)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(t){super(t),this.abortController=new AbortController,this.url=t.url,this.headers=q(t.headers??{}),this.fetch=t.fetch??((e,n)=>fetch(e,n))}run(t){return wm(xm(()=>this.fetch(this.url,this.requestInit(t))),this.debugLogger)}clone(){let t=super.clone();t.url=this.url,t.headers=q(this.headers??{}),t.fetch=this.fetch;let e=new AbortController,n=this.abortController.signal;return n.aborted&&e.abort(n.reason),t.abortController=e,t}};var li=class{element;#n;#e;#t=[];constructor(e){this.#n=e,this.#e=e.strings??ae,this.element=document.createElement("div"),this.element.className="attachment-tray",this.element.setAttribute("part","attachment-tray"),this.element.hidden=!0}add(e){let n={localId:Ue(),file:e,status:Pe.UPLOADING,progress:0,ref:null,error:"",controller:null};this.#t.push(n);let r=this.#s(e);if(r!==null){n.status=Pe.ERROR,n.error=r,this.#o(),this.#n.onChange?.();return}this.#o(),this.#n.onChange?.(),this.#r(n)}readyRefs(){let e=[];for(let n of this.#t)n.ref!==null&&e.push(n.ref);return e}hasPending(){return this.#t.some(e=>e.status===Pe.UPLOADING)}pendingCount(){return this.#t.filter(e=>e.status===Pe.UPLOADING).length}isEmpty(){return this.#t.length===0}clearReady(){this.#t=this.#t.filter(e=>e.status===Pe.UPLOADING),this.#o()}clear(){for(let e of this.#t)e.controller?.abort();this.#t=[],this.#o()}dispose(){for(let e of this.#t)e.controller?.abort()}#s(e){return this.#n.maxBytes>0&&e.size>this.#n.maxBytes?this.#e.tooLarge.replace("{size}",Pr(this.#n.maxBytes)):Km(this.#n.accept,e)?null:this.#e.fileTypeNotAllowed}#r(e){let n=this.#s(e.file);if(n!==null){e.status=Pe.ERROR,e.error=n,this.#o(),this.#n.onChange?.();return}e.status=Pe.UPLOADING,e.progress=0,e.error="";let r=new AbortController;e.controller=r,this.#o(),this.#n.upload(e.file,o=>{e.progress=o,this.#o()},r.signal).then(o=>{e.status=Pe.READY,e.ref=o}).catch(o=>{e.status=Pe.ERROR,e.error=o instanceof Error?o.message:this.#e.uploadFailed}).finally(()=>{e.controller=null,this.#o(),this.#n.onChange?.()})}#a(e){e.controller?.abort(),this.#t=this.#t.filter(n=>n!==e),this.#o(),this.#n.onChange?.()}#o(){this.element.replaceChildren(),this.element.hidden=this.#t.length===0;for(let e of this.#t)this.element.appendChild(this.#i(e))}#i(e){let n=document.createElement("div");n.className=`attachment-chip attachment-chip--${e.status}`,n.setAttribute("part","attachment-chip");let r=document.createElement("span");r.className="attachment-chip-icon",r.setAttribute("part","attachment-chip-icon"),r.textContent=vs(e.file.type),r.setAttribute("aria-hidden","true");let o=document.createElement("span");o.className="attachment-chip-name",o.setAttribute("part","attachment-chip-name"),o.textContent=e.file.name,o.title=e.file.name;let i=document.createElement("span");if(i.className="attachment-chip-size",i.setAttribute("part","attachment-chip-size"),i.textContent=e.status===Pe.ERROR?e.error:Pr(e.file.size),n.append(r,o,i),e.status===Pe.UPLOADING){let a=document.createElement("div");a.className="attachment-chip-bar",a.setAttribute("part","attachment-chip-bar");let l=document.createElement("div");l.className="attachment-chip-bar-fill",l.setAttribute("part","attachment-chip-bar-fill"),l.style.width=`${Math.round(e.progress*100)}%`,a.appendChild(l),n.appendChild(a)}if(e.status===Pe.ERROR){let a=document.createElement("button");a.type="button",a.className="attachment-chip-retry",a.setAttribute("part","attachment-chip-retry"),a.title=this.#e.retry,a.setAttribute("aria-label",this.#e.retryUpload),a.textContent="\u21BB",a.addEventListener("click",()=>this.#r(e)),n.appendChild(a)}let s=document.createElement("button");return s.type="button",s.className="attachment-chip-remove",s.setAttribute("part","attachment-chip-remove"),s.title=this.#e.remove,s.setAttribute("aria-label",this.#e.removeAttachment),s.textContent="\u2715",s.addEventListener("click",()=>this.#a(e)),n.appendChild(s),n}};function Km(t,e){let n=t.split(",").map(i=>i.trim().toLowerCase()).filter(i=>i!=="");if(n.length===0)return!0;let r=e.type.toLowerCase(),o=e.name.toLowerCase();return n.some(i=>i.startsWith(".")?o.endsWith(i):i.endsWith("/*")?r.startsWith(i.slice(0,-1)):r===i)}function ci(t,e=Date.now(),n=ae){if(!Number.isFinite(t))return n.justNow;let r=Math.round((e-t)/1e3);if(r<60)return n.justNow;let o=Math.round(r/60);if(o<60)return n.minutesAgo.replace("{n}",String(o));let i=Math.round(o/60);if(i<24)return n.hoursAgo.replace("{n}",String(i));let s=Math.round(i/24);return s<7?n.daysAgo.replace("{n}",String(s)):n.weeksAgo.replace("{n}",String(Math.round(s/7)))}var ir=class{element;#n;#e;#t;#s=null;#r;#a=[];constructor(e,n=ae){this.#n=e,this.#r=n,this.element=document.createElement("div"),this.element.className="checkpoints",this.element.setAttribute("part","checkpoints"),this.element.setAttribute("role","dialog"),this.element.setAttribute("aria-label",n.checkpoints),this.element.tabIndex=-1,this.element.hidden=!0;let r=document.createElement("div");r.className="checkpoints-header",r.setAttribute("part","checkpoints-header"),this.#t=document.createElement("span"),this.#t.className="checkpoints-title",this.#t.setAttribute("part","checkpoints-title"),this.#t.textContent=n.checkpoints,r.append(this.#t),this.#e=document.createElement("div"),this.#e.className="checkpoints-list",this.#e.setAttribute("part","checkpoints-list"),this.element.append(r,this.#e),this.element.addEventListener("keydown",o=>this.#l(o))}setRuns(e){this.#a=e,this.#c()}setStrings(e){this.#r=e,this.element.setAttribute("aria-label",e.checkpoints),this.#t.textContent=e.checkpoints,this.#c()}open(){this.open_||(this.#s=this.#o(),this.element.hidden=!1,(this.#i()[0]??this.element).focus())}close(){this.open_&&(this.element.hidden=!0,this.#s?.focus(),this.#s=null)}#o(){return this.element.getRootNode().activeElement}#i(){return Array.from(this.element.querySelectorAll("button, [tabindex]")).filter(e=>!e.hidden)}#l(e){if(e.key==="Escape"){e.stopPropagation(),this.close();return}if(e.key!=="Tab")return;let n=this.#i(),r=n[0],o=n[n.length-1],i=this.#o();e.shiftKey&&i===r?(e.preventDefault(),o?.focus()):!e.shiftKey&&i===o&&(e.preventDefault(),r?.focus())}get open_(){return!this.element.hidden}#c(){if(this.#e.replaceChildren(),this.#a.length===0){let e=document.createElement("div");e.className="checkpoints-empty",e.setAttribute("part","checkpoints-empty"),e.textContent=this.#r.noCheckpoints,this.#e.append(e);return}for(let e of this.#a)this.#e.append(this.#d(e))}#d(e){let n=document.createElement("div");n.className="checkpoint-row",n.setAttribute("part","checkpoint-row");let r=document.createElement("span");if(r.className="checkpoint-label",r.setAttribute("part","checkpoint-label"),r.textContent=e.started_at===null?e.run_id:ci(Date.parse(e.started_at),Date.now(),this.#r),r.title=e.run_id,n.append(r),e.parent_run_id!==null){let o=document.createElement("span");o.className="checkpoint-branch",o.setAttribute("part","checkpoint-branch"),o.textContent=this.#r.forkedRun,o.title=e.parent_run_id,n.append(o)}return n.append(this.#u(e.run_id,"resume",this.#r.resumeRun),this.#u(e.run_id,"fork",this.#r.forkRun)),n}#u(e,n,r){let o=document.createElement("button");return o.type="button",o.className=`checkpoint-action checkpoint-${n}`,o.setAttribute("part",`checkpoint-action checkpoint-${n}`),o.textContent=r,o.addEventListener("click",()=>{this.close(),this.#n(e,n)}),o}};function ou(t,e){let n=document.createElement("button");return n.type="button",n.className=`confirm-btn confirm-btn--${t}`,n.setAttribute("part",`confirm-button confirm-${t}`),n.textContent=e,n}function ia(t,e,n={}){let r=n.strings??ae;return new Promise(o=>{let i=document.createElement("div");i.className="confirm",i.setAttribute("part","confirm"),i.setAttribute("data-tool-name",e.toolName),i.setAttribute("role","group"),i.setAttribute("aria-label",r.confirmAction);let s=document.createElement("div");s.className="confirm-body",s.setAttribute("part","confirm-body"),s.textContent=e.message??r.confirmRun.replace("{tool}",e.toolName);let a=document.createElement("pre");a.className="confirm-args",a.setAttribute("part","confirm-args"),a.textContent=JSON.stringify(e.args,null,2),a.hidden=Object.keys(e.args).length===0;let l=document.createElement("div");l.className="confirm-actions",l.setAttribute("part","confirm-actions");let c=ou("cancel",r.cancel),h=ou("confirm",r.confirm),m=!1,y=f=>{m||(m=!0,i.remove(),o(f))};if(c.addEventListener("click",()=>y(!1)),h.addEventListener("click",()=>y(!0)),n.signal?.addEventListener("abort",()=>y(!1),{once:!0}),l.append(c,h),i.append(s,a,l),t.appendChild(i),n.signal?.aborted===!0){y(!1);return}h.focus()})}function sa(t){let e=t.replace(/[._-]+/g," ").trim();return e===""?t:e.charAt(0).toUpperCase()+e.slice(1)}function Zm(t){let e=document.createElement("input");return e.type="text",e.className="question-input",e.setAttribute("part","question-input"),e.placeholder=t,e}function aa(t,e,n={}){let r=n.strings??ae,o=e.options??[],i=o.length>0,s=!i||e.allowCustom===!0;return new Promise(a=>{let l=document.createElement("div");l.className="question",l.setAttribute("part","question"),l.setAttribute("role","group"),l.setAttribute("aria-label",r.askUserAction);let c=document.createElement("div");c.className="question-body",c.setAttribute("part","question-body"),c.textContent=e.question;let h=document.createElement("div");h.className="question-options",h.setAttribute("part","question-options");let m=`q-${o.length}-${e.question.length}`,y=[];for(let U of o){let Y=document.createElement("label");Y.className="question-choice",Y.setAttribute("part","question-choice");let re=document.createElement("input");re.type="radio",re.name=m,re.value=U,re.setAttribute("part","question-radio");let Be=document.createElement("span");Be.setAttribute("part","question-choice-text"),Be.textContent=U,Y.append(re,Be),h.appendChild(Y),y.push(re)}let f=null,p=null;if(s){if(p=Zm(r.answerPlaceholder),i){let U=document.createElement("label");U.className="question-choice",U.setAttribute("part","question-choice"),f=document.createElement("input"),f.type="radio",f.name=m,f.value="",f.setAttribute("part","question-radio");let Y=document.createElement("span");Y.setAttribute("part","question-choice-text"),Y.textContent=r.otherOption,U.append(f,Y),h.appendChild(U),p.disabled=!0}h.appendChild(p)}let g=document.createElement("div");g.className="question-actions",g.setAttribute("part","question-actions");let x=document.createElement("button");x.type="button",x.className="question-btn",x.setAttribute("part","question-button"),x.textContent=r.submit,g.appendChild(x);let _=!1,w=()=>{let U=y.find(Y=>Y.checked);if(U!==void 0)return U.value;if(p!==null&&(f===null||f.checked)){let Y=p.value.trim();return Y===""?null:Y}return null},C=()=>{p!==null&&f!==null&&(p.disabled=!f.checked),x.disabled=w()===null},H=U=>{if(!_){_=!0,x.disabled=!0;for(let Y of y)Y.disabled=!0;f!==null&&(f.disabled=!0),p!==null&&(p.disabled=!0),l.setAttribute("data-resolved",U===""?"cancelled":"answered"),a(U)}};for(let U of[...y,...f!==null?[f]:[]])U.addEventListener("change",C);if(p?.addEventListener("input",C),p?.addEventListener("keydown",U=>{if(U.key==="Enter"){U.preventDefault();let Y=w();Y!==null&&H(Y)}}),x.addEventListener("click",()=>{let U=w();U!==null&&H(U)}),n.signal?.addEventListener("abort",()=>H(""),{once:!0}),l.append(c,h,g),t.appendChild(l),n.signal?.aborted===!0){H("");return}C(),(i?y[0]:p)?.focus()})}function iu(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function Jm(t){if(Array.isArray(t))return t}function Qm(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,o,i,s,a=[],l=!0,c=!1;try{if(i=(n=n.call(t)).next,e!==0)for(;!(l=(r=i.call(n)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(h){c=!0,o=h}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw o}}return a}}function eg(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
12
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tg(t,e){return Jm(t)||Qm(t,e)||ng(t,e)||eg()}function ng(t,e){if(t){if(typeof t=="string")return iu(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?iu(t,e):void 0}}var xu=Object.entries,su=Object.setPrototypeOf,rg=Object.isFrozen,og=Object.getPrototypeOf,ig=Object.getOwnPropertyDescriptor,we=Object.freeze,Se=Object.seal,Nn=Object.create,Eu=typeof Reflect<"u"&&Reflect,ha=Eu.apply,fa=Eu.construct;we||(we=function(e){return e});Se||(Se=function(e){return e});ha||(ha=function(e,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return e.apply(n,o)});fa||(fa=function(e){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 e(...r)});var Cn=me(Array.prototype.forEach),sg=me(Array.prototype.lastIndexOf),au=me(Array.prototype.pop),Rn=me(Array.prototype.push),ag=me(Array.prototype.splice),At=Array.isArray,lr=me(String.prototype.toLowerCase),la=me(String.prototype.toString),lu=me(String.prototype.match),sr=me(String.prototype.replace),cu=me(String.prototype.indexOf),lg=me(String.prototype.trim),cg=me(Number.prototype.toString),ug=me(Boolean.prototype.toString),uu=typeof BigInt>"u"?null:me(BigInt.prototype.toString),du=typeof Symbol>"u"?null:me(Symbol.prototype.toString),ye=me(Object.prototype.hasOwnProperty),ar=me(Object.prototype.toString),be=me(RegExp.prototype.test),en=dg(TypeError);function me(t){return function(e){e instanceof RegExp&&(e.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 ha(t,e,r)}}function dg(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return fa(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:lr;if(su&&su(t,null),!At(e))return t;let r=e.length;for(;r--;){let o=e[r];if(typeof o=="string"){let i=n(o);i!==o&&(rg(e)||(e[r]=i),o=i)}t[o]=!0}return t}function pg(t){for(let e=0;e<t.length;e++)ye(t,e)||(t[e]=null);return t}function Ae(t){let e=Nn(null);for(let r of xu(t)){var n=tg(r,2);let o=n[0],i=n[1];ye(t,o)&&(At(i)?e[o]=pg(i):i&&typeof i=="object"&&i.constructor===Object?e[o]=Ae(i):e[o]=i)}return e}function hg(t){switch(typeof t){case"string":return t;case"number":return cg(t);case"boolean":return ug(t);case"bigint":return uu?uu(t):"0";case"symbol":return du?du(t):"Symbol()";case"undefined":return ar(t);case"function":case"object":{if(t===null)return ar(t);let e=t,n=Xe(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:ar(r)}return ar(t)}default:return ar(t)}}function Xe(t,e){for(;t!==null;){let r=ig(t,e);if(r){if(r.get)return me(r.get);if(typeof r.value=="function")return me(r.value)}t=og(t)}function n(){return null}return n}function fg(t){try{return be(t,""),!0}catch{return!1}}var pu=we(["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"]),ca=we(["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"]),ua=we(["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"]),mg=we(["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"]),da=we(["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"]),gg=we(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),hu=we(["#text"]),fu=we(["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"]),pa=we(["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","dominant-baseline","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-orientation","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"]),mu=we(["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"]),ui=we(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),vg=Se(/{{[\w\W]*|^[\w\W]*}}/g),bg=Se(/<%[\w\W]*|^[\w\W]*%>/g),yg=Se(/\${[\w\W]*/g),xg=Se(/^data-[\-\w.\u00B7-\uFFFF]+$/),Eg=Se(/^aria-[\-\w]+$/),gu=Se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Tg=Se(/^(?:\w+script|data):/i),wg=Se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Sg=Se(/^html$/i),_g=Se(/^[a-z][.\w]*(-[.\w]+)+$/i),vu=Se(/<[/\w!]/g),bu=Se(/<[/\w]/g),Ag=Se(/<\/no(script|embed|frames)/i),kg=Se(/\/>/i),He={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ig=function(){return typeof window>"u"?null:window},Cg=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));let i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},yu=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},_t=function(e,n,r,o){return ye(e,n)&&At(e[n])?W(o.base?Ae(o.base):{},e[n],o.transform):r};function Tu(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ig(),e=S=>Tu(S);if(e.version="3.4.13",e.removed=[],!t||!t.document||t.document.nodeType!==He.document||!t.Element)return e.isSupported=!1,e;let n=t.document,r=n,o=r.currentScript;t.DocumentFragment;let i=t.HTMLTemplateElement,s=t.Node,a=t.Element,l=t.NodeFilter,c=t.NamedNodeMap;c===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let h=t.DOMParser,m=t.trustedTypes,y=a.prototype,f=Xe(y,"cloneNode"),p=Xe(y,"remove"),g=Xe(y,"nextSibling"),x=Xe(y,"childNodes"),_=Xe(y,"parentNode"),w=Xe(y,"shadowRoot"),C=Xe(y,"attributes"),H=s&&s.prototype?Xe(s.prototype,"nodeType"):null,U=s&&s.prototype?Xe(s.prototype,"nodeName"):null,Y=s&&s.prototype?Xe(s.prototype,"ownerDocument"):null;if(typeof i=="function"){let S=n.createElement("template");S.content&&S.content.ownerDocument&&(n=S.content.ownerDocument)}let re,Be="",Si,Ma=!1,Pn=0,La=function(){if(Pn>0)throw en('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},on=function(d){La(),Pn++;try{return re.createHTML(d)}finally{Pn--}},nd=function(d){La(),Pn++;try{return re.createScriptURL(d)}finally{Pn--}},rd=function(){return Ma||(Si=Cg(m,o),Ma=!0),Si},br=n,_i=br.implementation,Pa=br.createNodeIterator,od=br.createDocumentFragment,id=br.getElementsByTagName,sd=r.importNode,oe=yu();e.isSupported=typeof xu=="function"&&typeof _=="function"&&_i&&_i.createHTMLDocument!==void 0;let ad=vg,ld=bg,cd=yg,ud=xg,dd=Eg,pd=Tg,Da=wg,hd=_g,Ua=gu,ie=null,Ai=W({},[...pu,...ca,...ua,...da,...hu]),se=null,ki=W({},[...fu,...pa,...mu,...ui]),de=Object.seal(Nn(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}})),Dn=null,Ha=null,mt=Object.seal(Nn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ga=!0,Ii=!0,za=!1,Fa=!0,gt=!1,vt=!0,It=!1,Ci=!1,yr=null,xr=null,Ri=!1,sn=!1,Er=!1,Tr=!1,$a=!0,Ba=!1,Va="user-content-",Ni=!0,wr=!1,an={},Ze=null,Oi=W({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),ja=null,qa=W({},["audio","video","img","source","image","track"]),Mi=null,Wa=W({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Sr="http://www.w3.org/1998/Math/MathML",_r="http://www.w3.org/2000/svg",Je="http://www.w3.org/1999/xhtml",ln=Je,Li=!1,Pi=null,fd=W({},[Sr,_r,Je],la),Xa=we(["mi","mo","mn","ms","mtext"]),Di=W({},Xa),Ya=we(["annotation-xml"]),Ui=W({},Ya),md=W({},["title","style","font","a","script"]),Un=null,gd=["application/xhtml+xml","text/html"],vd="text/html",le=null,cn=null,bd=n.createElement("form"),Ka=function(d){return d instanceof RegExp||d instanceof Function},Hi=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(cn&&cn===d)return;(!d||typeof d!="object")&&(d={}),d=Ae(d),Un=gd.indexOf(d.PARSER_MEDIA_TYPE)===-1?vd:d.PARSER_MEDIA_TYPE,le=Un==="application/xhtml+xml"?la:lr,ie=_t(d,"ALLOWED_TAGS",Ai,{transform:le}),se=_t(d,"ALLOWED_ATTR",ki,{transform:le}),Pi=_t(d,"ALLOWED_NAMESPACES",fd,{transform:la}),Mi=_t(d,"ADD_URI_SAFE_ATTR",Wa,{transform:le,base:Wa}),ja=_t(d,"ADD_DATA_URI_TAGS",qa,{transform:le,base:qa}),Ze=_t(d,"FORBID_CONTENTS",Oi,{transform:le}),Dn=_t(d,"FORBID_TAGS",Ae({}),{transform:le}),Ha=_t(d,"FORBID_ATTR",Ae({}),{transform:le}),an=ye(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?Ae(d.USE_PROFILES):d.USE_PROFILES:!1,Ga=d.ALLOW_ARIA_ATTR!==!1,Ii=d.ALLOW_DATA_ATTR!==!1,za=d.ALLOW_UNKNOWN_PROTOCOLS||!1,Fa=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,gt=d.SAFE_FOR_TEMPLATES||!1,vt=d.SAFE_FOR_XML!==!1,It=d.WHOLE_DOCUMENT||!1,sn=d.RETURN_DOM||!1,Er=d.RETURN_DOM_FRAGMENT||!1,Tr=d.RETURN_TRUSTED_TYPE||!1,Ri=d.FORCE_BODY||!1,$a=d.SANITIZE_DOM!==!1,Ba=d.SANITIZE_NAMED_PROPS||!1,Ni=d.KEEP_CONTENT!==!1,wr=d.IN_PLACE||!1,Ua=fg(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:gu,ln=typeof d.NAMESPACE=="string"?d.NAMESPACE:Je,Di=ye(d,"MATHML_TEXT_INTEGRATION_POINTS")&&d.MATHML_TEXT_INTEGRATION_POINTS&&typeof d.MATHML_TEXT_INTEGRATION_POINTS=="object"?Ae(d.MATHML_TEXT_INTEGRATION_POINTS):W({},Xa),Ui=ye(d,"HTML_INTEGRATION_POINTS")&&d.HTML_INTEGRATION_POINTS&&typeof d.HTML_INTEGRATION_POINTS=="object"?Ae(d.HTML_INTEGRATION_POINTS):W({},Ya);let b=ye(d,"CUSTOM_ELEMENT_HANDLING")&&d.CUSTOM_ELEMENT_HANDLING&&typeof d.CUSTOM_ELEMENT_HANDLING=="object"?Ae(d.CUSTOM_ELEMENT_HANDLING):Nn(null);if(de=Nn(null),ye(b,"tagNameCheck")&&Ka(b.tagNameCheck)&&(de.tagNameCheck=b.tagNameCheck),ye(b,"attributeNameCheck")&&Ka(b.attributeNameCheck)&&(de.attributeNameCheck=b.attributeNameCheck),ye(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(de.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),Se(de),gt&&(Ii=!1),Er&&(sn=!0),an&&(ie=W({},hu),se=Nn(null),an.html===!0&&(W(ie,pu),W(se,fu)),an.svg===!0&&(W(ie,ca),W(se,pa),W(se,ui)),an.svgFilters===!0&&(W(ie,ua),W(se,pa),W(se,ui)),an.mathMl===!0&&(W(ie,da),W(se,mu),W(se,ui))),mt.tagCheck=null,mt.attributeCheck=null,ye(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?mt.tagCheck=d.ADD_TAGS:At(d.ADD_TAGS)&&(ie===Ai&&(ie=Ae(ie)),W(ie,d.ADD_TAGS,le))),ye(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?mt.attributeCheck=d.ADD_ATTR:At(d.ADD_ATTR)&&(se===ki&&(se=Ae(se)),W(se,d.ADD_ATTR,le))),ye(d,"ADD_URI_SAFE_ATTR")&&At(d.ADD_URI_SAFE_ATTR)&&W(Mi,d.ADD_URI_SAFE_ATTR,le),ye(d,"FORBID_CONTENTS")&&At(d.FORBID_CONTENTS)&&(Ze===Oi&&(Ze=Ae(Ze)),W(Ze,d.FORBID_CONTENTS,le)),ye(d,"ADD_FORBID_CONTENTS")&&At(d.ADD_FORBID_CONTENTS)&&(Ze===Oi&&(Ze=Ae(Ze)),W(Ze,d.ADD_FORBID_CONTENTS,le)),Ni&&(ie["#text"]=!0),It&&W(ie,["html","head","body"]),ie.table&&(W(ie,["tbody"]),delete Dn.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw en('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw en('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let E=re;re=d.TRUSTED_TYPES_POLICY;try{Be=on("")}catch(N){throw re=E,N}}else d.TRUSTED_TYPES_POLICY===null?(re=void 0,Be=""):(re===void 0&&(re=rd()),re&&typeof Be=="string"&&(Be=on("")));we&&we(d),cn=d},Za=W({},[...ca,...ua,...mg]),Ja=W({},[...da,...gg]),yd=function(d,b,E){return b.namespaceURI===Je?d==="svg":b.namespaceURI===Sr?d==="svg"&&(E==="annotation-xml"||Di[E]):!!Za[d]},xd=function(d,b,E){return b.namespaceURI===Je?d==="math":b.namespaceURI===_r?d==="math"&&Ui[E]:!!Ja[d]},Ed=function(d,b,E){return b.namespaceURI===_r&&!Ui[E]||b.namespaceURI===Sr&&!Di[E]?!1:!Ja[d]&&(md[d]||!Za[d])},Td=function(d){let b=_(d);(!b||!b.tagName)&&(b={namespaceURI:ln,tagName:"template"});let E=lr(d.tagName),N=lr(b.tagName);return Pi[d.namespaceURI]?d.namespaceURI===_r?yd(E,b,N):d.namespaceURI===Sr?xd(E,b,N):d.namespaceURI===Je?Ed(E,b,N):!!(Un==="application/xhtml+xml"&&Pi[d.namespaceURI]):!1},bt=function(d){Rn(e.removed,{element:d});try{_(d).removeChild(d)}catch{if(p(d),!_(d))throw en("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Ar=function(d){Hn(d);let b=x(d);if(b){let N=[];Cn(b,L=>{Rn(N,L)}),Cn(N,L=>{try{p(L)}catch{}})}let E=C(d);if(E)for(let N=E.length-1;N>=0;--N){let L=E[N],G=L&&L.name;if(typeof G=="string")try{d.removeAttribute(G)}catch{}}},Ct=function(d,b){try{Rn(e.removed,{attribute:b.getAttributeNode(d),from:b})}catch{Rn(e.removed,{attribute:null,from:b})}if(b.removeAttribute(d),d==="is")if(sn||Er)try{bt(b)}catch{}else try{b.setAttribute(d,"")}catch{}},wd=function(d){let b=C(d);if(b)for(let E=b.length-1;E>=0;--E){let N=b[E],L=N&&N.name;if(!(typeof L!="string"||se[le(L)]))try{d.removeAttribute(L)}catch{}}},Hn=function(d){let b=[d];for(;b.length>0;){let E=b.pop();(H?H(E):E.nodeType)===He.element&&wd(E);let L=x(E);if(L)for(let G=L.length-1;G>=0;--G)b.push(L[G])}},Sd=function(d){if(!vt)return;let b=[d];for(;b.length>0;){let E=b.pop(),N=H?H(E):E.nodeType;if(N===He.processingInstruction||N===He.comment&&be(bu,E.data)){try{p(E)}catch{}continue}if(N===He.element){let G=E,Z=le(U?U(E):E.nodeName);try{G.hasAttribute&&G.hasAttribute("patchsrc")&&G.removeAttribute("patchsrc"),G.hasAttribute&&G.hasAttribute("for")&&Z!=="label"&&Z!=="output"&&G.removeAttribute("for")}catch{}}let L=x(E);if(L)for(let G=L.length-1;G>=0;--G)b.push(L[G])}},Qa=function(d){let b=null,E=null;if(Ri)d="<remove></remove>"+d;else{let G=lu(d,/^[\r\n\t ]+/);E=G&&G[0]}Un==="application/xhtml+xml"&&ln===Je&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");let N=re?on(d):d;if(ln===Je)try{b=new h().parseFromString(N,Un)}catch{}if(!b||!b.documentElement){b=_i.createDocument(ln,"template",null);try{b.documentElement.innerHTML=Li?Be:N}catch{}}let L=b.body||b.documentElement;return d&&E&&L.insertBefore(n.createTextNode(E),L.childNodes[0]||null),ln===Je?id.call(b,It?"html":"body")[0]:It?b.documentElement:L},el=function(d){let b=Y?Y(d):d.ownerDocument;return Pa.call(b||d,d,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},kr=function(d){return d=sr(d,ad," "),d=sr(d,ld," "),d=sr(d,cd," "),d},Gi=function(d){var b;d.normalize();let E=Y?Y(d):d.ownerDocument,N=Pa.call(E||d,d,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),L=N.nextNode();for(;L;)L.data=kr(L.data),L=N.nextNode();let G=(b=d.querySelectorAll)===null||b===void 0?void 0:b.call(d,"template");G&&Cn(G,Z=>{un(Z.content)&&Gi(Z.content)})},Ir=function(d){let b=U?U(d):null;return typeof b!="string"||le(b)!=="form"?!1:typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||d.attributes!==C(d)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==H(d)||d.childNodes!==x(d)},un=function(d){if(!H||typeof d!="object"||d===null)return!1;try{return H(d)===He.documentFragment}catch{return!1}},Gn=function(d){if(!H||typeof d!="object"||d===null)return!1;try{return typeof H(d)=="number"}catch{return!1}};function Qe(S,d,b){S.length!==0&&Cn(S,E=>{E.call(e,d,b,cn)})}let _d=function(d,b){return!!(vt&&d.hasChildNodes()&&!Gn(d.firstElementChild)&&be(vu,d.textContent)&&be(vu,d.innerHTML)||vt&&d.namespaceURI===Je&&b==="style"&&Gn(d.firstElementChild)||d.nodeType===He.processingInstruction||vt&&d.nodeType===He.comment&&be(bu,d.data))},Ad=function(d,b,E){if(!Dn[b]&&ol(b)&&(de.tagNameCheck instanceof RegExp&&be(de.tagNameCheck,b)||de.tagNameCheck instanceof Function&&de.tagNameCheck(b)))return!1;if(Ni&&!Ze[b]){let N=_(d),L=x(d);if(L&&N){let G=L.length;for(let Z=G-1;Z>=0;--Z){let ce=d===E?f(L[Z],!0):L[Z];N.insertBefore(ce,g(d))}}}return bt(d),!0},tl=function(d,b,E,N){return d.length===0?b:b===E||b===N?Ae(b):b},nl=function(d,b){if(Qe(oe.beforeSanitizeElements,d,null),d!==b&&_(d)===null)return wr&&Hn(d),!0;if(Ir(d))return bt(d),!0;let E=le(U?U(d):d.nodeName);if(ie=tl(oe.uponSanitizeElement,ie,Ai,yr),Qe(oe.uponSanitizeElement,d,{tagName:E,allowedTags:ie}),d!==b&&_(d)===null)return wr&&Hn(d),!0;if(_d(d,E))return bt(d),!0;if(Dn[E]||!(mt.tagCheck instanceof Function&&mt.tagCheck(E))&&!ie[E]){let L=Ad(d,E,b);return L===!1&&Qe(oe.afterSanitizeElements,d,null),L}if((H?H(d):d.nodeType)===He.element&&!Td(d)||(E==="noscript"||E==="noembed"||E==="noframes")&&be(Ag,d.innerHTML))return bt(d),!0;if(gt&&d.nodeType===He.text){let L=kr(d.textContent);d.textContent!==L&&(Rn(e.removed,{element:d.cloneNode()}),d.textContent=L)}return Qe(oe.afterSanitizeElements,d,null),!1},rl=function(d,b,E){if(Ha[b]||vt&&b==="patchsrc"||vt&&b==="for"&&d!=="label"&&d!=="output"||$a&&(b==="id"||b==="name")&&(E in n||E in bd))return!1;let N=se[b]||mt.attributeCheck instanceof Function&&mt.attributeCheck(b,d);if(!(Ii&&be(ud,b))){if(!(Ga&&be(dd,b))){if(N){if(!Mi[b]){if(!be(Ua,sr(E,Da,""))){if(!((b==="src"||b==="xlink:href"||b==="href")&&d!=="script"&&cu(E,"data:")===0&&ja[d])){if(!(za&&!be(pd,sr(E,Da,"")))){if(E)return!1}}}}}else if(!(ol(d)&&(de.tagNameCheck instanceof RegExp&&be(de.tagNameCheck,d)||de.tagNameCheck instanceof Function&&de.tagNameCheck(d))&&(de.attributeNameCheck instanceof RegExp&&be(de.attributeNameCheck,b)||de.attributeNameCheck instanceof Function&&de.attributeNameCheck(b,d))||b==="is"&&de.allowCustomizedBuiltInElements&&(de.tagNameCheck instanceof RegExp&&be(de.tagNameCheck,E)||de.tagNameCheck instanceof Function&&de.tagNameCheck(E))))return!1}}return!0},kd=W({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ol=function(d){return!kd[lr(d)]&&be(hd,d)},Id=function(d,b,E,N){if(re&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!E)switch(m.getAttributeType(d,b)){case"TrustedHTML":return on(N);case"TrustedScriptURL":return nd(N)}return N},Cd=function(d,b,E,N){try{E?d.setAttributeNS(E,b,N):d.setAttribute(b,N),Ir(d)?bt(d):au(e.removed)}catch{Ct(b,d)}},il=function(d){Qe(oe.beforeSanitizeAttributes,d,null);let b=d.attributes;if(!b||Ir(d))return;se=tl(oe.uponSanitizeAttribute,se,ki,xr);let E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:se,forceKeepAttr:void 0},N=b.length,L=le(d.nodeName);for(;N--;){let G=b[N],Z=G.name,ce=G.namespaceURI,Ce=G.value,Re=le(Z),Fi=Ce,Ie=Z==="value"?Fi:lg(Fi);if(E.attrName=Re,E.attrValue=Ie,E.keepAttr=!0,E.forceKeepAttr=void 0,Qe(oe.uponSanitizeAttribute,d,E),Ie=E.attrValue,Ba&&(Re==="id"||Re==="name")&&cu(Ie,Va)!==0&&(Ct(Z,d),Ie=Va+Ie),vt&&be(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ie)){Ct(Z,d);continue}if(Re==="attributename"&&lu(Ie,"href")){Ct(Z,d);continue}if(!E.forceKeepAttr){if(!E.keepAttr){Ct(Z,d);continue}if(!Fa&&be(kg,Ie)){Ct(Z,d);continue}if(gt&&(Ie=kr(Ie)),!rl(L,Re,Ie)){Ct(Z,d);continue}Ie=Id(L,Re,ce,Ie),Ie!==Fi&&Cd(d,Z,ce,Ie)}}Qe(oe.afterSanitizeAttributes,d,null)},Cr=function(d){let b=null,E=el(d);for(Qe(oe.beforeSanitizeShadowDOM,d,null);b=E.nextNode();)if(Qe(oe.uponSanitizeShadowNode,b,null),nl(b,d),il(b),un(b.content)&&Cr(b.content),(H?H(b):b.nodeType)===He.element){let L=w(b);un(L)&&(zi(L),Cr(L))}Qe(oe.afterSanitizeShadowDOM,d,null)},zi=function(d){let b=[{node:d,shadow:null}];for(;b.length>0;){let E=b.pop();if(E.shadow){Cr(E.shadow);continue}let N=E.node,G=(H?H(N):N.nodeType)===He.element,Z=x(N);if(Z)for(let ce=Z.length-1;ce>=0;--ce)b.push({node:Z[ce],shadow:null});if(G){let ce=U?U(N):null;if(typeof ce=="string"&&le(ce)==="template"){let Ce=N.content;un(Ce)&&b.push({node:Ce,shadow:null})}}if(G){let ce=w(N);un(ce)&&b.push({node:null,shadow:ce},{node:ce,shadow:null})}}};return e.sanitize=function(S){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,E=null,N=null,L=null;if(Li=!S,Li&&(S="<!-->"),typeof S!="string"&&!Gn(S)&&(S=hg(S),typeof S!="string"))throw en("dirty is not a string, aborting");if(!e.isSupported)return S;Ci?(ie=yr,se=xr):Hi(d),(oe.uponSanitizeElement.length>0||oe.uponSanitizeAttribute.length>0)&&(ie=Ae(ie)),oe.uponSanitizeAttribute.length>0&&(se=Ae(se)),e.removed=[];let G=wr&&typeof S!="string"&&Gn(S);if(G){Sd(S);let Ce=U?U(S):S.nodeName;if(typeof Ce=="string"){let Re=le(Ce);if(!ie[Re]||Dn[Re])throw Ar(S),en("root node is forbidden and cannot be sanitized in-place")}if(Ir(S))throw Ar(S),en("root node is clobbered and cannot be sanitized in-place");try{zi(S)}catch(Re){throw Ar(S),Re}}else if(Gn(S))b=Qa("<!---->"),E=b.ownerDocument.importNode(S,!0),E.nodeType===He.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?b=E:b.appendChild(E),zi(E);else{if(!sn&&!gt&&!It&&S.indexOf("<")===-1)return re&&Tr?on(S):S;if(b=Qa(S),!b)return sn?null:Tr?Be:""}b&&Ri&&bt(b.firstChild);let Z=G?S:b;try{let Ce=el(Z);for(;N=Ce.nextNode();)nl(N,Z),il(N),un(N.content)&&Cr(N.content)}catch(Ce){throw G&&(Ar(S),Cn(e.removed,Re=>{Re.element&&Hn(Re.element)})),Ce}if(G)return Cn(e.removed,Ce=>{Ce.element&&Hn(Ce.element)}),gt&&Gi(S),S;if(sn){if(gt&&Gi(b),Er)for(L=od.call(b.ownerDocument);b.firstChild;)L.appendChild(b.firstChild);else L=b;return(se.shadowroot||se.shadowrootmode)&&(L=sd.call(r,L,!0)),L}let ce=It?b.outerHTML:b.innerHTML;return It&&ie["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&be(Sg,b.ownerDocument.doctype.name)&&(ce="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
13
|
-
`+ce),
|
|
14
|
-
]`).replace("lheading",
|
|
10
|
+
`),m=JSON.parse(h);n?.event("SSE","Event received:",m,{type:m.type}),r.next(m)}catch(h){r.error(h)}}return r.asObservable()},Lm=t=>{let e=new st,n=new Uint8Array;t.subscribe({next:o=>{if(o.type!==en.HEADERS&&o.type===en.DATA&&o.data){let i=new Uint8Array(n.length+o.data.length);i.set(n,0),i.set(o.data,n.length),n=i,r()}},error:o=>e.error(o),complete:()=>{if(n.length>0)try{r()}catch{console.warn("Incomplete or invalid protocol buffer data at stream end")}e.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 i=n.slice(4,o),s=Kc(i);e.next(s),n=n.slice(o)}catch(i){let s=i instanceof Error?i.message:String(i);e.error(Error(`Failed to decode protocol buffer message: ${s}`));return}}}return e.asObservable()},Pm=(t,e)=>{let n=sr(e),r=new st,o=new lo,i=!1;return t.subscribe({next:s=>{if(o.next(s),s.type===en.HEADERS&&!i){i=!0;let a=s.headers.get("content-type");n?.lifecycle("HTTP","Stream format detected:",{contentType:a,parser:a===na?"protobuf":"sse"}),a===na?Lm(o).subscribe({next:l=>r.next(l),error:l=>r.error(l),complete:()=>r.complete()}):Mm(o,n).subscribe({next:l=>{try{let c=qr.parse(l);n?.event("HTTP","Event validated:",c,{type:c.type,valid:!0}),r.next(c)}catch(c){n?.event("HTTP","Event invalid:",{json:l,error:String(c)}),r.error(c)}},error:l=>{if(l?.name==="AbortError"){r.next({type:v.RUN_ERROR,message:l.message||"Request aborted",code:"abort",rawEvent:l}),r.complete();return}return r.error(l)},complete:()=>r.complete()})}else i||r.error(Error("No headers event received before data events"))},error:s=>{o.error(s),r.error(s)},complete:()=>{o.complete()}}),r.asObservable()},Q=u.enum(["TextMessageStart","TextMessageContent","TextMessageEnd","ActionExecutionStart","ActionExecutionArgs","ActionExecutionEnd","ActionExecutionResult","AgentStateMessage","MetaEvent","RunStarted","RunFinished","RunError","NodeStarted","NodeFinished"]),Dm=u.enum(["LangGraphInterruptEvent","PredictState","Exit"]),Um=u.object({type:u.literal(Q.enum.TextMessageStart),messageId:u.string(),parentMessageId:u.string().optional(),role:u.string().optional()}),Hm=u.object({type:u.literal(Q.enum.TextMessageContent),messageId:u.string(),content:u.string()}),zm=u.object({type:u.literal(Q.enum.TextMessageEnd),messageId:u.string()}),Gm=u.object({type:u.literal(Q.enum.ActionExecutionStart),actionExecutionId:u.string(),actionName:u.string(),parentMessageId:u.string().optional()}),Fm=u.object({type:u.literal(Q.enum.ActionExecutionArgs),actionExecutionId:u.string(),args:u.string()}),$m=u.object({type:u.literal(Q.enum.ActionExecutionEnd),actionExecutionId:u.string()}),Bm=u.object({type:u.literal(Q.enum.ActionExecutionResult),actionName:u.string(),actionExecutionId:u.string(),result:u.string()}),Vm=u.object({type:u.literal(Q.enum.AgentStateMessage),threadId:u.string(),agentName:u.string(),nodeName:u.string(),runId:u.string(),active:u.boolean(),role:u.string(),state:u.string(),running:u.boolean()}),jm=u.object({type:u.literal(Q.enum.MetaEvent),name:Dm,value:u.any()}),qm=u.object({type:u.literal(Q.enum.RunError),message:u.string(),code:u.string().optional()});u.discriminatedUnion("type",[Um,Hm,zm,Gm,Fm,$m,Bm,Vm,jm,qm]),u.object({id:u.string(),role:u.string(),content:u.string(),parentMessageId:u.string().optional()}),u.object({id:u.string(),name:u.string(),arguments:u.any(),parentMessageId:u.string().optional()}),u.object({id:u.string(),result:u.any(),actionExecutionId:u.string(),actionName:u.string()});var Wm=t=>{if(typeof t=="string")return t;if(!Array.isArray(t))return;let e=t.filter(n=>n.type==="text").map(n=>n.text).filter(n=>n.length>0);if(e.length!==0)return e.join(`
|
|
11
|
+
`)},Xm=(t,e,n)=>r=>{let o={},i=!0,s=!0,a="",l=null,c=null,h=[],m={},y=f=>{typeof f=="object"&&f&&("messages"in f&&delete f.messages,o=f)};return r.pipe(Me(f=>{switch(f.type){case v.TEXT_MESSAGE_START:{let p=f;return[{type:Q.enum.TextMessageStart,messageId:p.messageId,role:p.role}]}case v.TEXT_MESSAGE_CONTENT:{let p=f;return[{type:Q.enum.TextMessageContent,messageId:p.messageId,content:p.delta}]}case v.TEXT_MESSAGE_END:{let p=f;return[{type:Q.enum.TextMessageEnd,messageId:p.messageId}]}case v.TOOL_CALL_START:{let p=f;return h.push({id:p.toolCallId,type:"function",function:{name:p.toolCallName,arguments:""}}),s=!0,m[p.toolCallId]=p.toolCallName,[{type:Q.enum.ActionExecutionStart,actionExecutionId:p.toolCallId,actionName:p.toolCallName,parentMessageId:p.parentMessageId}]}case v.TOOL_CALL_ARGS:{let p=f,g=h.find(S=>S.id===p.toolCallId);if(!g)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${p.toolCallId}'`),[];g.function.arguments+=p.delta;let x=!1;if(c){let S=c.find(T=>T.tool==g.function.name);if(S)try{let T=JSON.parse(ko(g.function.arguments));S.tool_argument&&S.tool_argument in T?(y({...o,[S.state_key]:T[S.tool_argument]}),x=!0):S.tool_argument||(y({...o,[S.state_key]:T}),x=!0)}catch{}}return[{type:Q.enum.ActionExecutionArgs,actionExecutionId:p.toolCallId,args:p.delta},...x?[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}]:[]]}case v.TOOL_CALL_END:{let p=f;return[{type:Q.enum.ActionExecutionEnd,actionExecutionId:p.toolCallId}]}case v.TOOL_CALL_RESULT:{let p=f;return[{type:Q.enum.ActionExecutionResult,actionExecutionId:p.toolCallId,result:p.content,actionName:m[p.toolCallId]||"unknown"}]}case v.RAW:return[];case v.CUSTOM:{let p=f;switch(p.name){case"Exit":i=!1;break;case"PredictState":c=p.value;break}return[{type:Q.enum.MetaEvent,name:p.name,value:p.value}]}case v.STATE_SNAPSHOT:return y(f.snapshot),[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}];case v.STATE_DELTA:{let p=f,g=eo.applyPatch(o,p.delta,!0,!1);return g?(y(g.newDocument),[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:s}]):[]}case v.MESSAGES_SNAPSHOT:return l=f.messages,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify({...o,...l?{messages:l}:{}}),active:!0}];case v.RUN_STARTED:return[];case v.RUN_FINISHED:return l&&(o.messages=l),Object.keys(o).length===0?[]:[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify({...o,...l?{messages:Ym(l)}:{}}),active:!1}];case v.RUN_ERROR:{let p=f;return[{type:Q.enum.RunError,message:p.message,code:p.code}]}case v.STEP_STARTED:return a=f.stepName,h=[],c=null,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:!0}];case v.STEP_FINISHED:return h=[],c=null,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:!1}];default:return[]}}))};function Ym(t){let e=[];for(let n of t)if(n.role==="assistant"||n.role==="user"||n.role==="system"){let r=Wm(n.content);if(r){let o={id:n.id,role:n.role,content:r};e.push(o)}if(n.role==="assistant"&&n.toolCalls&&n.toolCalls.length>0)for(let o of n.toolCalls){let i={id:o.id,name:o.function.name,arguments:JSON.parse(o.function.arguments),parentMessageId:n.id};e.push(i)}}else if(n.role==="tool"){let r="unknown";for(let i of t)if(i.role==="assistant"&&i.toolCalls?.length){for(let s of i.toolCalls)if(s.id===n.toolCallId){r=s.function.name;break}}let o={id:n.id,result:n.content,actionExecutionId:n.toolCallId,actionName:r};e.push(o)}return e}var ci=t=>e=>{let n=sr(t),r,o,i,s,a=()=>{if(!r||s!=="text")throw Error("No text message to close");let m={type:v.TEXT_MESSAGE_END,messageId:r.messageId};return s=void 0,r=void 0,n?.event("TRANSFORM","TEXT_MESSAGE_END",m,{messageId:m.messageId}),m},l=()=>{if(!o||s!=="tool")throw Error("No tool call to close");let m={type:v.TOOL_CALL_END,toolCallId:o.toolCallId};return s=void 0,o=void 0,n?.event("TRANSFORM","TOOL_CALL_END",m,{toolCallId:m.toolCallId}),m},c=()=>{if(!i||s!=="reasoning")throw Error("No reasoning message to close");let m={type:v.REASONING_MESSAGE_END,messageId:i.messageId};return s=void 0,i=void 0,n?.event("TRANSFORM","REASONING_MESSAGE_END",m,{messageId:m.messageId}),m},h=()=>s==="text"?[a()]:s==="tool"?[l()]:s==="reasoning"?[c()]:[];return e.pipe(Me(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[...h(),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 y=m,f=[];if((s!=="text"||y.messageId!==void 0&&y.messageId!==r?.messageId)&&f.push(...h()),s!=="text"){if(y.messageId===void 0)throw Error("First TEXT_MESSAGE_CHUNK must have a messageId");r={messageId:y.messageId,name:y.name},s="text";let T={type:v.TEXT_MESSAGE_START,messageId:y.messageId,role:y.role||"assistant",...y.name!==void 0&&{name:y.name}};f.push(T),n?.event("TRANSFORM","TEXT_MESSAGE_START",T,{messageId:y.messageId})}if(y.delta!==void 0){let T={type:v.TEXT_MESSAGE_CONTENT,messageId:r.messageId,delta:y.delta};f.push(T),n?.event("TRANSFORM","TEXT_MESSAGE_CONTENT",T,{messageId:r.messageId})}return f;case v.TOOL_CALL_CHUNK:let p=m,g=[];if((s!=="tool"||p.toolCallId!==void 0&&p.toolCallId!==o?.toolCallId)&&g.push(...h()),s!=="tool"){if(p.toolCallId===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallId");if(p.toolCallName===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallName");o={toolCallId:p.toolCallId,toolCallName:p.toolCallName,parentMessageId:p.parentMessageId},s="tool";let T={type:v.TOOL_CALL_START,toolCallId:p.toolCallId,toolCallName:p.toolCallName,parentMessageId:p.parentMessageId};g.push(T),n?.event("TRANSFORM","TOOL_CALL_START",T,{toolCallId:p.toolCallId,toolCallName:p.toolCallName})}if(p.delta!==void 0){let T={type:v.TOOL_CALL_ARGS,toolCallId:o.toolCallId,delta:p.delta};g.push(T),n?.event("TRANSFORM","TOOL_CALL_ARGS",T,{toolCallId:o.toolCallId})}return g;case v.REASONING_MESSAGE_CHUNK:let x=m,S=[];if((s!=="reasoning"||x.messageId&&x.messageId!==i?.messageId)&&S.push(...h()),s!=="reasoning"){if(x.messageId===void 0)throw Error("First REASONING_MESSAGE_CHUNK must have a messageId");i={messageId:x.messageId},s="reasoning";let T={type:v.REASONING_MESSAGE_START,messageId:x.messageId};S.push(T),n?.event("TRANSFORM","REASONING_MESSAGE_START",T,{messageId:x.messageId})}if(x.delta!==void 0){let T={type:v.REASONING_MESSAGE_CONTENT,messageId:i.messageId,delta:x.delta};S.push(T),n?.event("TRANSFORM","REASONING_MESSAGE_CONTENT",T,{messageId:i.messageId})}return S}return m.type,[]}),Qt(()=>{h()}))};function Km(t,e=new Date){return t.expiresAt===void 0?!1:new Date(t.expiresAt)<=e}function au(t,e){let n=new Set(t.map(s=>s.id)),r=new Set(Object.keys(e)),o=[...n].filter(s=>!r.has(s));if(o.length>0)throw Error(`buildResumeArray: missing responses for open interrupts: ${o.join(", ")}`);let i=[...r].filter(s=>!n.has(s));if(i.length>0)throw Error(`buildResumeArray: responses reference unknown interrupt ids: ${i.join(", ")}`);return t.map(s=>{let a=e[s.id];if(a.status==="resolved"){let l={interruptId:s.id,status:"resolved"};return a.payload!==void 0&&(l.payload=a.payload),l}return{interruptId:s.id,status:"cancelled"}})}var ui=class{runNext(t,e){return e.run(t).pipe(ci(!1))}runNextWithState(t,e){let n=q(t.messages||[]),r=q(t.state||{}),o=new lo;return su(t,o,e,[]).subscribe(i=>{i.messages!==void 0&&(n=i.messages),i.state!==void 0&&(r=i.state)}),this.runNext(t,e).pipe(So(async i=>(o.next(i),await new Promise(s=>setTimeout(s,0)),{event:i,messages:q(n),state:q(r)})))}},Zm=class extends ui{constructor(t){super(),this.fn=t}run(t,e){return this.fn(t,e)}};function Jm(t){let e=t.content;if(Array.isArray(e)){let n=e.filter(r=>typeof r=="object"&&!!r&&"type"in r&&r.type==="text"&&typeof r.text=="string").map(r=>r.text).join("");return{...t,content:n}}return typeof e=="string"?t:{...t,content:""}}var Qm=class extends ui{run(t,e){let{parentRunId:n,...r}=t,o={...r,messages:r.messages.map(Jm)};return this.runNext(o,e)}},tu="THINKING_START",nu="THINKING_END",ru="THINKING_TEXT_MESSAGE_START",ou="THINKING_TEXT_MESSAGE_CONTENT",iu="THINKING_TEXT_MESSAGE_END",eg=class extends ui{constructor(...t){super(...t),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(t,e){typeof process<"u"&&process.env!==void 0&&process.env.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${t} to ${e}. 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(t,e){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(t,e).pipe(Jt(n=>this.transformEvent(n)))}transformEvent(t){switch(t.type){case tu:{this.currentReasoningId=Ue();let{title:e,...n}=t;return this.warnAboutTransformation(tu,v.REASONING_START),{...n,type:v.REASONING_START,messageId:this.currentReasoningId}}case ru:return this.currentMessageId=Ue(),this.warnAboutTransformation(ru,v.REASONING_MESSAGE_START),{...t,type:v.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:"assistant"};case ou:{let{delta:e,...n}=t;return this.warnAboutTransformation(ou,v.REASONING_MESSAGE_CONTENT),{...n,type:v.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??Ue(),delta:e}}case iu:{let e=this.currentMessageId??Ue();return this.warnAboutTransformation(iu,v.REASONING_MESSAGE_END),{...t,type:v.REASONING_MESSAGE_END,messageId:e}}case nu:{let e=this.currentReasoningId??Ue();return this.warnAboutTransformation(nu,v.REASONING_END),{...t,type:v.REASONING_END,messageId:e}}default:return t}}};function tg(t){return t.startsWith("image/")?"image":t.startsWith("audio/")?"audio":t.startsWith("video/")?"video":"document"}function ng(t){return typeof t=="object"&&!!t&&"type"in t&&t.type==="binary"&&"mimeType"in t&&typeof t.mimeType=="string"}function rg(t){let e=tg(t.mimeType);return t.data?{type:e,source:{type:"data",value:t.data,mimeType:t.mimeType},...t.filename?{metadata:{filename:t.filename}}:{}}:t.url?{type:e,source:{type:"url",value:t.url,mimeType:t.mimeType},...t.filename?{metadata:{filename:t.filename}}:{}}:t}function og(t){let e=t.content;if(!Array.isArray(e))return t;let n=e.map(r=>ng(r)?rg(r):r);return{...t,content:n}}var ig=class extends ui{run(t,e){let n={...t,messages:t.messages.map(og)};return this.runNext(n,e)}},sg="0.0.57",ag=class{get maxVersion(){return sg}get debug(){return this._debug}set debug(t){this._debug=li(t),this._debugLogger=ia(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(t){typeof t=="boolean"?this._debugLogger=t?ia(li(!0)):void 0:this._debugLogger=t}constructor({agentId:t,description:e,threadId:n,initialMessages:r,initialState:o,debug:i}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.agentId=t,this.description=e??"",this.threadId=n??xt(),this.messages=q(r??[]),this.state=q(o??{}),this._debug=li(i),this._debugLogger=ia(this._debug),ir(this.maxVersion,"0.0.39")<=0&&this.middlewares.unshift(new Qm),ir(this.maxVersion,"0.0.45")<=0&&this.middlewares.unshift(new eg),ir(this.maxVersion,"0.0.47")<=0&&this.middlewares.unshift(new ig)}subscribe(t){return this.subscribers.push(t),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(e=>e!==t)}}}use(...t){let e=t.map(n=>typeof n=="function"?new Zm(n):n);return this.middlewares.push(...e),this}async runAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??xt();let n=this.prepareRunAgentInput(t);this.debugLogger?.lifecycle("LIFECYCLE","Run started:",{agentId:this.agentId,threadId:this.threadId});let r,o=new Set(this.messages.map(l=>l.id)),i=[{onRunFinishedEvent:l=>{l.outcome==="success"&&(r=l.result)}},...this.subscribers,e??{}];await this.onInitialize(n,i),this.activeRunDetach$=new st;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await To(ao(()=>this.middlewares.length===0?this.run(n):this.middlewares.reduceRight((l,c)=>({run:h=>c.run(h,l),get messages(){return l.messages},get state(){return l.state}}),this).run(n),ci(this.debugLogger),sa(this.debugLogger),l=>l.pipe(Ao(this.activeRunDetach$)),l=>this.apply(n,l,i),l=>this.processApplyEvents(n,l,i),nr(l=>(this.debugLogger?.lifecycle("LIFECYCLE","Run errored:",{agentId:this.agentId,error:l instanceof Error?l.message:String(l)}),this.isRunning=!1,this.onError(n,l,i))),Qt(()=>{this.debugLogger?.lifecycle("LIFECYCLE","Run finished:",{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(n,i),s?.(),s=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(ue(null)));let a=q(this.messages).filter(l=>!o.has(l.id));return{result:r,newMessages:a}}finally{this.isRunning=!1}}connect(t){throw new Cs}async connectAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??xt();let n=this.prepareRunAgentInput(t),r,o=new Set(this.messages.map(l=>l.id)),i=[{onRunFinishedEvent:l=>{l.outcome==="success"&&(r=l.result)}},...this.subscribers,e??{}];await this.onInitialize(n,i),this.activeRunDetach$=new st;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await To(ao(()=>wo(()=>this.connect(n)),ci(this.debugLogger),sa(this.debugLogger),l=>l.pipe(Ao(this.activeRunDetach$)),l=>this.apply(n,l,i),l=>this.processApplyEvents(n,l,i),nr(l=>(this.isRunning=!1,l instanceof Cs?co:this.onError(n,l,i))),Qt(()=>{this.isRunning=!1,this.onFinalize(n,i),s?.(),s=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(ue(null)),{defaultValue:void 0});let a=q(this.messages).filter(l=>!o.has(l.id));return{result:r,newMessages:a}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){if(!this.activeRunDetach$)return;let t=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),this.activeRunDetach$?.complete(),await t}apply(t,e,n){return su(t,e,this,n,this.debugLogger)}processApplyEvents(t,e,n){return e.pipe(Vs(r=>{r.messages&&(this.messages=r.messages,n.forEach(o=>{o.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),r.state&&(this.state=r.state,n.forEach(o=>{o.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})}))}))}prepareRunAgentInput(t){let e=q(this.messages).filter(n=>n.role!=="activity");return{threadId:this.threadId,runId:t?.runId||xt(),tools:q(t?.tools??[]),context:q(t?.context??[]),forwardedProps:q(t?.forwardedProps??{}),state:q(this.state),messages:e,...t?.resume===void 0?{}:{resume:q(t.resume)}}}async onInitialize(t,e){if(this.pendingInterrupts.length>0){let r=new Set((t.resume??[]).map(i=>i.interruptId)),o=this.pendingInterrupts.map(i=>i.id).filter(i=>!r.has(i));if(o.length>0)throw new ee(`Thread has ${o.length} pending interrupt(s) not addressed by resume: ${o.join(", ")}`);for(let i of this.pendingInterrupts)if(Km(i))throw new ee(`Interrupt ${i.id} expired at ${i.expiresAt}`)}let n=await K(e,this.messages,this.state,(r,o,i)=>r.onRunInitialized?.({messages:o,state:i,agent:this,input:t}));(n.messages!==void 0||n.state!==void 0)&&(n.messages&&(this.messages=n.messages,t.messages=n.messages,e.forEach(r=>{r.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),n.state&&(this.state=n.state,t.state=n.state,e.forEach(r=>{r.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})})))}onError(t,e,n){return Zt(K(n,this.messages,this.state,(r,o,i)=>r.onRunFailed?.({error:e,messages:o,state:i,agent:this,input:t}))).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(i=>{i.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),o.state!==void 0&&(this.state=o.state,n.forEach(i=>{i.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})}))),o.stopPropagation!==!0){let i=String(e);if(!(e.name==="AbortError"||e.message==="Fetch is aborted"||e.message==="signal is aborted without reason"||e.message==="component unmounted"||i==="component unmounted"))throw console.error("Agent execution failed:",e),e}return{}}))}async onFinalize(t,e){let n=await K(e,this.messages,this.state,(r,o,i)=>r.onRunFinalized?.({messages:o,state:i,agent:this,input:t}));(n.messages!==void 0||n.state!==void 0)&&(n.messages!==void 0&&(this.messages=n.messages,e.forEach(r=>{r.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),n.state!==void 0&&(this.state=n.state,e.forEach(r=>{r.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})})))}clone(){let t=Object.create(Object.getPrototypeOf(this));return t.agentId=this.agentId,t.description=this.description,t.threadId=this.threadId,t.messages=q(this.messages),t.state=q(this.state),t._debug=this._debug,t._debugLogger=this._debugLogger,t.isRunning=this.isRunning,t.subscribers=[...this.subscribers],t.middlewares=[...this.middlewares],t.pendingInterrupts=q(this.pendingInterrupts),t}addMessage(t){this.messages.push(t),(async()=>{for(let e of this.subscribers)await e.onNewMessage?.({message:t,messages:this.messages,state:this.state,agent:this});if(t.role==="assistant"&&t.toolCalls)for(let e of t.toolCalls)for(let n of this.subscribers)await n.onNewToolCall?.({toolCall:e,messages:this.messages,state:this.state,agent:this});for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}addMessages(t){this.messages.push(...t),(async()=>{for(let e of t){for(let n of this.subscribers)await n.onNewMessage?.({message:e,messages:this.messages,state:this.state,agent:this});if(e.role==="assistant"&&e.toolCalls)for(let n of e.toolCalls)for(let r of this.subscribers)await r.onNewToolCall?.({toolCall:n,messages:this.messages,state:this.state,agent:this})}for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setMessages(t){this.messages=q(t),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(t){this.state=q(t),(async()=>{for(let e of this.subscribers)await e.onStateChanged?.({messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(t){this.agentId=this.agentId??xt();let e=this.prepareRunAgentInput(t);return(this.middlewares.length===0?this.run(e):this.middlewares.reduceRight((n,r)=>({run:o=>r.run(o,n),get messages(){return n.messages},get state(){return n.state}}),this).run(e)).pipe(ci(this.debugLogger),sa(this.debugLogger),Xm(this.threadId,e.runId,this.agentId),n=>n.pipe(Jt(r=>(this.debugLogger?.event("LEGACY","Event:",r,{type:r.type}),r))))}},lu=class extends ag{requestInit(t){return{method:"POST",headers:{...this.headers,"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(t),signal:this.abortController.signal}}runAgent(t,e){return this.abortController=t?.abortController??new AbortController,super.runAgent(t,e)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(t){super(t),this.abortController=new AbortController,this.url=t.url,this.headers=q(t.headers??{}),this.fetch=t.fetch??((e,n)=>fetch(e,n))}run(t){return Pm(Om(()=>this.fetch(this.url,this.requestInit(t))),this.debugLogger)}clone(){let t=super.clone();t.url=this.url,t.headers=q(this.headers??{}),t.fetch=this.fetch;let e=new AbortController,n=this.abortController.signal;return n.aborted&&e.abort(n.reason),t.abortController=e,t}};var di=class{element;#n;#e;#t=[];constructor(e){this.#n=e,this.#e=e.strings??ae,this.element=document.createElement("div"),this.element.className="attachment-tray",this.element.setAttribute("part","attachment-tray"),this.element.hidden=!0}add(e){let n={localId:Ue(),file:e,status:Pe.UPLOADING,progress:0,ref:null,error:"",controller:null};this.#t.push(n);let r=this.#s(e);if(r!==null){n.status=Pe.ERROR,n.error=r,this.#i(),this.#n.onChange?.();return}this.#i(),this.#n.onChange?.(),this.#r(n)}readyRefs(){let e=[];for(let n of this.#t)n.ref!==null&&e.push(n.ref);return e}hasPending(){return this.#t.some(e=>e.status===Pe.UPLOADING)}pendingCount(){return this.#t.filter(e=>e.status===Pe.UPLOADING).length}isEmpty(){return this.#t.length===0}clearReady(){this.#t=this.#t.filter(e=>e.status===Pe.UPLOADING),this.#i()}clear(){for(let e of this.#t)e.controller?.abort();this.#t=[],this.#i()}dispose(){for(let e of this.#t)e.controller?.abort()}#s(e){return this.#n.maxBytes>0&&e.size>this.#n.maxBytes?this.#e.tooLarge.replace("{size}",Hr(this.#n.maxBytes)):lg(this.#n.accept,e)?null:this.#e.fileTypeNotAllowed}#r(e){let n=this.#s(e.file);if(n!==null){e.status=Pe.ERROR,e.error=n,this.#i(),this.#n.onChange?.();return}e.status=Pe.UPLOADING,e.progress=0,e.error="";let r=new AbortController;e.controller=r,this.#i(),this.#n.upload(e.file,o=>{e.progress=o,this.#i()},r.signal).then(o=>{e.status=Pe.READY,e.ref=o}).catch(o=>{e.status=Pe.ERROR,e.error=o instanceof Error?o.message:this.#e.uploadFailed}).finally(()=>{e.controller=null,this.#i(),this.#n.onChange?.()})}#a(e){e.controller?.abort(),this.#t=this.#t.filter(n=>n!==e),this.#i(),this.#n.onChange?.()}#i(){this.element.replaceChildren(),this.element.hidden=this.#t.length===0;for(let e of this.#t)this.element.appendChild(this.#o(e))}#o(e){let n=document.createElement("div");n.className=`attachment-chip attachment-chip--${e.status}`,n.setAttribute("part","attachment-chip");let r=document.createElement("span");r.className="attachment-chip-icon",r.setAttribute("part","attachment-chip-icon"),r.textContent=Es(e.file.type),r.setAttribute("aria-hidden","true");let o=document.createElement("span");o.className="attachment-chip-name",o.setAttribute("part","attachment-chip-name"),o.textContent=e.file.name,o.title=e.file.name;let i=document.createElement("span");if(i.className="attachment-chip-size",i.setAttribute("part","attachment-chip-size"),i.textContent=e.status===Pe.ERROR?e.error:Hr(e.file.size),n.append(r,o,i),e.status===Pe.UPLOADING){let a=document.createElement("div");a.className="attachment-chip-bar",a.setAttribute("part","attachment-chip-bar");let l=document.createElement("div");l.className="attachment-chip-bar-fill",l.setAttribute("part","attachment-chip-bar-fill"),l.style.width=`${Math.round(e.progress*100)}%`,a.appendChild(l),n.appendChild(a)}if(e.status===Pe.ERROR){let a=document.createElement("button");a.type="button",a.className="attachment-chip-retry",a.setAttribute("part","attachment-chip-retry"),a.title=this.#e.retry,a.setAttribute("aria-label",this.#e.retryUpload),a.textContent="\u21BB",a.addEventListener("click",()=>this.#r(e)),n.appendChild(a)}let s=document.createElement("button");return s.type="button",s.className="attachment-chip-remove",s.setAttribute("part","attachment-chip-remove"),s.title=this.#e.remove,s.setAttribute("aria-label",this.#e.removeAttachment),s.textContent="\u2715",s.addEventListener("click",()=>this.#a(e)),n.appendChild(s),n}};function lg(t,e){let n=t.split(",").map(i=>i.trim().toLowerCase()).filter(i=>i!=="");if(n.length===0)return!0;let r=e.type.toLowerCase(),o=e.name.toLowerCase();return n.some(i=>i.startsWith(".")?o.endsWith(i):i.endsWith("/*")?r.startsWith(i.slice(0,-1)):r===i)}function pi(t,e=Date.now(),n=ae){if(!Number.isFinite(t))return n.justNow;let r=Math.round((e-t)/1e3);if(r<60)return n.justNow;let o=Math.round(r/60);if(o<60)return n.minutesAgo.replace("{n}",String(o));let i=Math.round(o/60);if(i<24)return n.hoursAgo.replace("{n}",String(i));let s=Math.round(i/24);return s<7?n.daysAgo.replace("{n}",String(s)):n.weeksAgo.replace("{n}",String(Math.round(s/7)))}var ar=class{element;#n;#e;#t;#s=null;#r;#a=[];constructor(e,n=ae){this.#n=e,this.#r=n,this.element=document.createElement("div"),this.element.className="checkpoints",this.element.setAttribute("part","checkpoints"),this.element.setAttribute("role","dialog"),this.element.setAttribute("aria-label",n.checkpoints),this.element.tabIndex=-1,this.element.hidden=!0;let r=document.createElement("div");r.className="checkpoints-header",r.setAttribute("part","checkpoints-header"),this.#t=document.createElement("span"),this.#t.className="checkpoints-title",this.#t.setAttribute("part","checkpoints-title"),this.#t.textContent=n.checkpoints,r.append(this.#t),this.#e=document.createElement("div"),this.#e.className="checkpoints-list",this.#e.setAttribute("part","checkpoints-list"),this.element.append(r,this.#e),this.element.addEventListener("keydown",o=>this.#l(o))}setRuns(e){this.#a=e,this.#c()}setStrings(e){this.#r=e,this.element.setAttribute("aria-label",e.checkpoints),this.#t.textContent=e.checkpoints,this.#c()}open(){this.open_||(this.#s=this.#i(),this.element.hidden=!1,(this.#o()[0]??this.element).focus())}close(){this.open_&&(this.element.hidden=!0,this.#s?.focus(),this.#s=null)}#i(){return this.element.getRootNode().activeElement}#o(){return Array.from(this.element.querySelectorAll("button, [tabindex]")).filter(e=>!e.hidden)}#l(e){if(e.key==="Escape"){e.stopPropagation(),this.close();return}if(e.key!=="Tab")return;let n=this.#o(),r=n[0],o=n[n.length-1],i=this.#i();e.shiftKey&&i===r?(e.preventDefault(),o?.focus()):!e.shiftKey&&i===o&&(e.preventDefault(),r?.focus())}get open_(){return!this.element.hidden}#c(){if(this.#e.replaceChildren(),this.#a.length===0){let e=document.createElement("div");e.className="checkpoints-empty",e.setAttribute("part","checkpoints-empty"),e.textContent=this.#r.noCheckpoints,this.#e.append(e);return}for(let e of this.#a)this.#e.append(this.#d(e))}#d(e){let n=document.createElement("div");n.className="checkpoint-row",n.setAttribute("part","checkpoint-row");let r=document.createElement("span");if(r.className="checkpoint-label",r.setAttribute("part","checkpoint-label"),r.textContent=e.started_at===null?e.run_id:pi(Date.parse(e.started_at),Date.now(),this.#r),r.title=e.run_id,n.append(r),e.parent_run_id!==null){let o=document.createElement("span");o.className="checkpoint-branch",o.setAttribute("part","checkpoint-branch"),o.textContent=this.#r.forkedRun,o.title=e.parent_run_id,n.append(o)}return n.append(this.#u(e.run_id,"resume",this.#r.resumeRun),this.#u(e.run_id,"fork",this.#r.forkRun)),n}#u(e,n,r){let o=document.createElement("button");return o.type="button",o.className=`checkpoint-action checkpoint-${n}`,o.setAttribute("part",`checkpoint-action checkpoint-${n}`),o.textContent=r,o.addEventListener("click",()=>{this.close(),this.#n(e,n)}),o}};function cu(t,e){let n=document.createElement("button");return n.type="button",n.className=`confirm-btn confirm-btn--${t}`,n.setAttribute("part",`confirm-button confirm-${t}`),n.textContent=e,n}function ca(t,e,n={}){let r=n.strings??ae;return new Promise(o=>{let i=document.createElement("div");i.className="confirm",i.setAttribute("part","confirm"),i.setAttribute("data-tool-name",e.toolName),i.setAttribute("role","group"),i.setAttribute("aria-label",r.confirmAction);let s=document.createElement("div");s.className="confirm-body",s.setAttribute("part","confirm-body"),s.textContent=e.message??r.confirmRun.replace("{tool}",e.toolName);let a=document.createElement("pre");a.className="confirm-args",a.setAttribute("part","confirm-args"),a.textContent=JSON.stringify(e.args,null,2),a.hidden=Object.keys(e.args).length===0;let l=document.createElement("div");l.className="confirm-actions",l.setAttribute("part","confirm-actions");let c=cu("cancel",r.cancel),h=cu("confirm",r.confirm),m=!1,y=f=>{m||(m=!0,i.remove(),o(f))};if(c.addEventListener("click",()=>y(!1)),h.addEventListener("click",()=>y(!0)),n.signal?.addEventListener("abort",()=>y(!1),{once:!0}),l.append(c,h),i.append(s,a,l),t.appendChild(i),n.signal?.aborted===!0){y(!1);return}h.focus()})}function ua(t){let e=t.replace(/[._-]+/g," ").trim();return e===""?t:e.charAt(0).toUpperCase()+e.slice(1)}function cg(t){let e=document.createElement("input");return e.type="text",e.className="question-input",e.setAttribute("part","question-input"),e.placeholder=t,e}function da(t,e,n={}){let r=n.strings??ae,o=e.options??[],i=o.length>0,s=!i||e.allowCustom===!0;return new Promise(a=>{let l=document.createElement("div");l.className="question",l.setAttribute("part","question"),l.setAttribute("role","group"),l.setAttribute("aria-label",r.askUserAction);let c=document.createElement("div");c.className="question-body",c.setAttribute("part","question-body"),c.textContent=e.question;let h=document.createElement("div");h.className="question-options",h.setAttribute("part","question-options");let m=`q-${o.length}-${e.question.length}`,y=[];for(let U of o){let Y=document.createElement("label");Y.className="question-choice",Y.setAttribute("part","question-choice");let re=document.createElement("input");re.type="radio",re.name=m,re.value=U,re.setAttribute("part","question-radio");let Ve=document.createElement("span");Ve.setAttribute("part","question-choice-text"),Ve.textContent=U,Y.append(re,Ve),h.appendChild(Y),y.push(re)}let f=null,p=null;if(s){if(p=cg(r.answerPlaceholder),i){let U=document.createElement("label");U.className="question-choice",U.setAttribute("part","question-choice"),f=document.createElement("input"),f.type="radio",f.name=m,f.value="",f.setAttribute("part","question-radio");let Y=document.createElement("span");Y.setAttribute("part","question-choice-text"),Y.textContent=r.otherOption,U.append(f,Y),h.appendChild(U),p.disabled=!0}h.appendChild(p)}let g=document.createElement("div");g.className="question-actions",g.setAttribute("part","question-actions");let x=document.createElement("button");x.type="button",x.className="question-btn",x.setAttribute("part","question-button"),x.textContent=r.submit,g.appendChild(x);let S=!1,T=()=>{let U=y.find(Y=>Y.checked);if(U!==void 0)return U.value;if(p!==null&&(f===null||f.checked)){let Y=p.value.trim();return Y===""?null:Y}return null},I=()=>{p!==null&&f!==null&&(p.disabled=!f.checked),x.disabled=T()===null},H=U=>{if(!S){S=!0,x.disabled=!0;for(let Y of y)Y.disabled=!0;f!==null&&(f.disabled=!0),p!==null&&(p.disabled=!0),l.setAttribute("data-resolved",U===""?"cancelled":"answered"),a(U)}};for(let U of[...y,...f!==null?[f]:[]])U.addEventListener("change",I);if(p?.addEventListener("input",I),p?.addEventListener("keydown",U=>{if(U.key==="Enter"){U.preventDefault();let Y=T();Y!==null&&H(Y)}}),x.addEventListener("click",()=>{let U=T();U!==null&&H(U)}),n.signal?.addEventListener("abort",()=>H(""),{once:!0}),l.append(c,h,g),t.appendChild(l),n.signal?.aborted===!0){H("");return}I(),(i?y[0]:p)?.focus()})}function uu(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function ug(t){if(Array.isArray(t))return t}function dg(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,o,i,s,a=[],l=!0,c=!1;try{if(i=(n=n.call(t)).next,e!==0)for(;!(l=(r=i.call(n)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(h){c=!0,o=h}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw o}}return a}}function pg(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
12
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hg(t,e){return ug(t)||dg(t,e)||fg(t,e)||pg()}function fg(t,e){if(t){if(typeof t=="string")return uu(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?uu(t,e):void 0}}var Su=Object.entries,du=Object.setPrototypeOf,mg=Object.isFrozen,gg=Object.getPrototypeOf,vg=Object.getOwnPropertyDescriptor,Te=Object.freeze,we=Object.seal,On=Object.create,Au=typeof Reflect<"u"&&Reflect,va=Au.apply,ba=Au.construct;Te||(Te=function(e){return e});we||(we=function(e){return e});va||(va=function(e,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return e.apply(n,o)});ba||(ba=function(e){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 e(...r)});var Rn=me(Array.prototype.forEach),bg=me(Array.prototype.lastIndexOf),pu=me(Array.prototype.pop),Nn=me(Array.prototype.push),yg=me(Array.prototype.splice),kt=Array.isArray,ur=me(String.prototype.toLowerCase),pa=me(String.prototype.toString),hu=me(String.prototype.match),lr=me(String.prototype.replace),fu=me(String.prototype.indexOf),xg=me(String.prototype.trim),Eg=me(Number.prototype.toString),_g=me(Boolean.prototype.toString),mu=typeof BigInt>"u"?null:me(BigInt.prototype.toString),gu=typeof Symbol>"u"?null:me(Symbol.prototype.toString),ye=me(Object.prototype.hasOwnProperty),cr=me(Object.prototype.toString),be=me(RegExp.prototype.test),tn=Tg(TypeError);function me(t){return function(e){e instanceof RegExp&&(e.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 va(t,e,r)}}function Tg(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return ba(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ur;if(du&&du(t,null),!kt(e))return t;let r=e.length;for(;r--;){let o=e[r];if(typeof o=="string"){let i=n(o);i!==o&&(mg(e)||(e[r]=i),o=i)}t[o]=!0}return t}function wg(t){for(let e=0;e<t.length;e++)ye(t,e)||(t[e]=null);return t}function Ae(t){let e=On(null);for(let r of Su(t)){var n=hg(r,2);let o=n[0],i=n[1];ye(t,o)&&(kt(i)?e[o]=wg(i):i&&typeof i=="object"&&i.constructor===Object?e[o]=Ae(i):e[o]=i)}return e}function Sg(t){switch(typeof t){case"string":return t;case"number":return Eg(t);case"boolean":return _g(t);case"bigint":return mu?mu(t):"0";case"symbol":return gu?gu(t):"Symbol()";case"undefined":return cr(t);case"function":case"object":{if(t===null)return cr(t);let e=t,n=Ye(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:cr(r)}return cr(t)}default:return cr(t)}}function Ye(t,e){for(;t!==null;){let r=vg(t,e);if(r){if(r.get)return me(r.get);if(typeof r.value=="function")return me(r.value)}t=gg(t)}function n(){return null}return n}function Ag(t){try{return be(t,""),!0}catch{return!1}}var vu=Te(["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"]),ha=Te(["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"]),fa=Te(["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"]),kg=Te(["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"]),ma=Te(["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"]),Cg=Te(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),bu=Te(["#text"]),yu=Te(["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"]),ga=Te(["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","dominant-baseline","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-orientation","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"]),xu=Te(["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"]),hi=Te(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ig=we(/{{[\w\W]*|^[\w\W]*}}/g),Rg=we(/<%[\w\W]*|^[\w\W]*%>/g),Ng=we(/\${[\w\W]*/g),Og=we(/^data-[\-\w.\u00B7-\uFFFF]+$/),Mg=we(/^aria-[\-\w]+$/),Eu=we(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Lg=we(/^(?:\w+script|data):/i),Pg=we(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Dg=we(/^html$/i),Ug=we(/^[a-z][.\w]*(-[.\w]+)+$/i),_u=we(/<[/\w!]/g),Tu=we(/<[/\w]/g),Hg=we(/<\/no(script|embed|frames)/i),zg=we(/\/>/i),He={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Gg=function(){return typeof window>"u"?null:window},Fg=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));let i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},wu=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},At=function(e,n,r,o){return ye(e,n)&&kt(e[n])?W(o.base?Ae(o.base):{},e[n],o.transform):r};function ku(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Gg(),e=w=>ku(w);if(e.version="3.4.13",e.removed=[],!t||!t.document||t.document.nodeType!==He.document||!t.Element)return e.isSupported=!1,e;let n=t.document,r=n,o=r.currentScript;t.DocumentFragment;let i=t.HTMLTemplateElement,s=t.Node,a=t.Element,l=t.NodeFilter,c=t.NamedNodeMap;c===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let h=t.DOMParser,m=t.trustedTypes,y=a.prototype,f=Ye(y,"cloneNode"),p=Ye(y,"remove"),g=Ye(y,"nextSibling"),x=Ye(y,"childNodes"),S=Ye(y,"parentNode"),T=Ye(y,"shadowRoot"),I=Ye(y,"attributes"),H=s&&s.prototype?Ye(s.prototype,"nodeType"):null,U=s&&s.prototype?Ye(s.prototype,"nodeName"):null,Y=s&&s.prototype?Ye(s.prototype,"ownerDocument"):null;if(typeof i=="function"){let w=n.createElement("template");w.content&&w.content.ownerDocument&&(n=w.content.ownerDocument)}let re,Ve="",ki,za=!1,Dn=0,Ga=function(){if(Dn>0)throw tn('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},sn=function(d){Ga(),Dn++;try{return re.createHTML(d)}finally{Dn--}},ad=function(d){Ga(),Dn++;try{return re.createScriptURL(d)}finally{Dn--}},ld=function(){return za||(ki=Fg(m,o),za=!0),ki},xr=n,Ci=xr.implementation,Fa=xr.createNodeIterator,cd=xr.createDocumentFragment,ud=xr.getElementsByTagName,dd=r.importNode,oe=wu();e.isSupported=typeof Su=="function"&&typeof S=="function"&&Ci&&Ci.createHTMLDocument!==void 0;let pd=Ig,hd=Rg,fd=Ng,md=Og,gd=Mg,vd=Lg,$a=Pg,bd=Ug,Ba=Eu,ie=null,Ii=W({},[...vu,...ha,...fa,...ma,...bu]),se=null,Ri=W({},[...yu,...ga,...xu,...hi]),de=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}})),Un=null,Va=null,gt=Object.seal(On(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ja=!0,Ni=!0,qa=!1,Wa=!0,vt=!1,bt=!0,It=!1,Oi=!1,Er=null,_r=null,Mi=!1,an=!1,Tr=!1,wr=!1,Xa=!0,Ya=!1,Ka="user-content-",Li=!0,Sr=!1,ln={},Je=null,Pi=W({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]),Za=null,Ja=W({},["audio","video","img","source","image","track"]),Di=null,Qa=W({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ar="http://www.w3.org/1998/Math/MathML",kr="http://www.w3.org/2000/svg",Qe="http://www.w3.org/1999/xhtml",cn=Qe,Ui=!1,Hi=null,yd=W({},[Ar,kr,Qe],pa),el=Te(["mi","mo","mn","ms","mtext"]),zi=W({},el),tl=Te(["annotation-xml"]),Gi=W({},tl),xd=W({},["title","style","font","a","script"]),Hn=null,Ed=["application/xhtml+xml","text/html"],_d="text/html",le=null,un=null,Td=n.createElement("form"),nl=function(d){return d instanceof RegExp||d instanceof Function},Fi=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(un&&un===d)return;(!d||typeof d!="object")&&(d={}),d=Ae(d),Hn=Ed.indexOf(d.PARSER_MEDIA_TYPE)===-1?_d:d.PARSER_MEDIA_TYPE,le=Hn==="application/xhtml+xml"?pa:ur,ie=At(d,"ALLOWED_TAGS",Ii,{transform:le}),se=At(d,"ALLOWED_ATTR",Ri,{transform:le}),Hi=At(d,"ALLOWED_NAMESPACES",yd,{transform:pa}),Di=At(d,"ADD_URI_SAFE_ATTR",Qa,{transform:le,base:Qa}),Za=At(d,"ADD_DATA_URI_TAGS",Ja,{transform:le,base:Ja}),Je=At(d,"FORBID_CONTENTS",Pi,{transform:le}),Un=At(d,"FORBID_TAGS",Ae({}),{transform:le}),Va=At(d,"FORBID_ATTR",Ae({}),{transform:le}),ln=ye(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?Ae(d.USE_PROFILES):d.USE_PROFILES:!1,ja=d.ALLOW_ARIA_ATTR!==!1,Ni=d.ALLOW_DATA_ATTR!==!1,qa=d.ALLOW_UNKNOWN_PROTOCOLS||!1,Wa=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,vt=d.SAFE_FOR_TEMPLATES||!1,bt=d.SAFE_FOR_XML!==!1,It=d.WHOLE_DOCUMENT||!1,an=d.RETURN_DOM||!1,Tr=d.RETURN_DOM_FRAGMENT||!1,wr=d.RETURN_TRUSTED_TYPE||!1,Mi=d.FORCE_BODY||!1,Xa=d.SANITIZE_DOM!==!1,Ya=d.SANITIZE_NAMED_PROPS||!1,Li=d.KEEP_CONTENT!==!1,Sr=d.IN_PLACE||!1,Ba=Ag(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:Eu,cn=typeof d.NAMESPACE=="string"?d.NAMESPACE:Qe,zi=ye(d,"MATHML_TEXT_INTEGRATION_POINTS")&&d.MATHML_TEXT_INTEGRATION_POINTS&&typeof d.MATHML_TEXT_INTEGRATION_POINTS=="object"?Ae(d.MATHML_TEXT_INTEGRATION_POINTS):W({},el),Gi=ye(d,"HTML_INTEGRATION_POINTS")&&d.HTML_INTEGRATION_POINTS&&typeof d.HTML_INTEGRATION_POINTS=="object"?Ae(d.HTML_INTEGRATION_POINTS):W({},tl);let b=ye(d,"CUSTOM_ELEMENT_HANDLING")&&d.CUSTOM_ELEMENT_HANDLING&&typeof d.CUSTOM_ELEMENT_HANDLING=="object"?Ae(d.CUSTOM_ELEMENT_HANDLING):On(null);if(de=On(null),ye(b,"tagNameCheck")&&nl(b.tagNameCheck)&&(de.tagNameCheck=b.tagNameCheck),ye(b,"attributeNameCheck")&&nl(b.attributeNameCheck)&&(de.attributeNameCheck=b.attributeNameCheck),ye(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(de.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),we(de),vt&&(Ni=!1),Tr&&(an=!0),ln&&(ie=W({},bu),se=On(null),ln.html===!0&&(W(ie,vu),W(se,yu)),ln.svg===!0&&(W(ie,ha),W(se,ga),W(se,hi)),ln.svgFilters===!0&&(W(ie,fa),W(se,ga),W(se,hi)),ln.mathMl===!0&&(W(ie,ma),W(se,xu),W(se,hi))),gt.tagCheck=null,gt.attributeCheck=null,ye(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?gt.tagCheck=d.ADD_TAGS:kt(d.ADD_TAGS)&&(ie===Ii&&(ie=Ae(ie)),W(ie,d.ADD_TAGS,le))),ye(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?gt.attributeCheck=d.ADD_ATTR:kt(d.ADD_ATTR)&&(se===Ri&&(se=Ae(se)),W(se,d.ADD_ATTR,le))),ye(d,"ADD_URI_SAFE_ATTR")&&kt(d.ADD_URI_SAFE_ATTR)&&W(Di,d.ADD_URI_SAFE_ATTR,le),ye(d,"FORBID_CONTENTS")&&kt(d.FORBID_CONTENTS)&&(Je===Pi&&(Je=Ae(Je)),W(Je,d.FORBID_CONTENTS,le)),ye(d,"ADD_FORBID_CONTENTS")&&kt(d.ADD_FORBID_CONTENTS)&&(Je===Pi&&(Je=Ae(Je)),W(Je,d.ADD_FORBID_CONTENTS,le)),Li&&(ie["#text"]=!0),It&&W(ie,["html","head","body"]),ie.table&&(W(ie,["tbody"]),delete Un.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw tn('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw tn('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let E=re;re=d.TRUSTED_TYPES_POLICY;try{Ve=sn("")}catch(N){throw re=E,N}}else d.TRUSTED_TYPES_POLICY===null?(re=void 0,Ve=""):(re===void 0&&(re=ld()),re&&typeof Ve=="string"&&(Ve=sn("")));Te&&Te(d),un=d},rl=W({},[...ha,...fa,...kg]),ol=W({},[...ma,...Cg]),wd=function(d,b,E){return b.namespaceURI===Qe?d==="svg":b.namespaceURI===Ar?d==="svg"&&(E==="annotation-xml"||zi[E]):!!rl[d]},Sd=function(d,b,E){return b.namespaceURI===Qe?d==="math":b.namespaceURI===kr?d==="math"&&Gi[E]:!!ol[d]},Ad=function(d,b,E){return b.namespaceURI===kr&&!Gi[E]||b.namespaceURI===Ar&&!zi[E]?!1:!ol[d]&&(xd[d]||!rl[d])},kd=function(d){let b=S(d);(!b||!b.tagName)&&(b={namespaceURI:cn,tagName:"template"});let E=ur(d.tagName),N=ur(b.tagName);return Hi[d.namespaceURI]?d.namespaceURI===kr?wd(E,b,N):d.namespaceURI===Ar?Sd(E,b,N):d.namespaceURI===Qe?Ad(E,b,N):!!(Hn==="application/xhtml+xml"&&Hi[d.namespaceURI]):!1},yt=function(d){Nn(e.removed,{element:d});try{S(d).removeChild(d)}catch{if(p(d),!S(d))throw tn("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Cr=function(d){zn(d);let b=x(d);if(b){let N=[];Rn(b,L=>{Nn(N,L)}),Rn(N,L=>{try{p(L)}catch{}})}let E=I(d);if(E)for(let N=E.length-1;N>=0;--N){let L=E[N],z=L&&L.name;if(typeof z=="string")try{d.removeAttribute(z)}catch{}}},Rt=function(d,b){try{Nn(e.removed,{attribute:b.getAttributeNode(d),from:b})}catch{Nn(e.removed,{attribute:null,from:b})}if(b.removeAttribute(d),d==="is")if(an||Tr)try{yt(b)}catch{}else try{b.setAttribute(d,"")}catch{}},Cd=function(d){let b=I(d);if(b)for(let E=b.length-1;E>=0;--E){let N=b[E],L=N&&N.name;if(!(typeof L!="string"||se[le(L)]))try{d.removeAttribute(L)}catch{}}},zn=function(d){let b=[d];for(;b.length>0;){let E=b.pop();(H?H(E):E.nodeType)===He.element&&Cd(E);let L=x(E);if(L)for(let z=L.length-1;z>=0;--z)b.push(L[z])}},Id=function(d){if(!bt)return;let b=[d];for(;b.length>0;){let E=b.pop(),N=H?H(E):E.nodeType;if(N===He.processingInstruction||N===He.comment&&be(Tu,E.data)){try{p(E)}catch{}continue}if(N===He.element){let z=E,Z=le(U?U(E):E.nodeName);try{z.hasAttribute&&z.hasAttribute("patchsrc")&&z.removeAttribute("patchsrc"),z.hasAttribute&&z.hasAttribute("for")&&Z!=="label"&&Z!=="output"&&z.removeAttribute("for")}catch{}}let L=x(E);if(L)for(let z=L.length-1;z>=0;--z)b.push(L[z])}},il=function(d){let b=null,E=null;if(Mi)d="<remove></remove>"+d;else{let z=hu(d,/^[\r\n\t ]+/);E=z&&z[0]}Hn==="application/xhtml+xml"&&cn===Qe&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");let N=re?sn(d):d;if(cn===Qe)try{b=new h().parseFromString(N,Hn)}catch{}if(!b||!b.documentElement){b=Ci.createDocument(cn,"template",null);try{b.documentElement.innerHTML=Ui?Ve:N}catch{}}let L=b.body||b.documentElement;return d&&E&&L.insertBefore(n.createTextNode(E),L.childNodes[0]||null),cn===Qe?ud.call(b,It?"html":"body")[0]:It?b.documentElement:L},sl=function(d){let b=Y?Y(d):d.ownerDocument;return Fa.call(b||d,d,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Ir=function(d){return d=lr(d,pd," "),d=lr(d,hd," "),d=lr(d,fd," "),d},$i=function(d){var b;d.normalize();let E=Y?Y(d):d.ownerDocument,N=Fa.call(E||d,d,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),L=N.nextNode();for(;L;)L.data=Ir(L.data),L=N.nextNode();let z=(b=d.querySelectorAll)===null||b===void 0?void 0:b.call(d,"template");z&&Rn(z,Z=>{dn(Z.content)&&$i(Z.content)})},Rr=function(d){let b=U?U(d):null;return typeof b!="string"||le(b)!=="form"?!1:typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||d.attributes!==I(d)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==H(d)||d.childNodes!==x(d)},dn=function(d){if(!H||typeof d!="object"||d===null)return!1;try{return H(d)===He.documentFragment}catch{return!1}},Gn=function(d){if(!H||typeof d!="object"||d===null)return!1;try{return typeof H(d)=="number"}catch{return!1}};function et(w,d,b){w.length!==0&&Rn(w,E=>{E.call(e,d,b,un)})}let Rd=function(d,b){return!!(bt&&d.hasChildNodes()&&!Gn(d.firstElementChild)&&be(_u,d.textContent)&&be(_u,d.innerHTML)||bt&&d.namespaceURI===Qe&&b==="style"&&Gn(d.firstElementChild)||d.nodeType===He.processingInstruction||bt&&d.nodeType===He.comment&&be(Tu,d.data))},Nd=function(d,b,E){if(!Un[b]&&ul(b)&&(de.tagNameCheck instanceof RegExp&&be(de.tagNameCheck,b)||de.tagNameCheck instanceof Function&&de.tagNameCheck(b)))return!1;if(Li&&!Je[b]){let N=S(d),L=x(d);if(L&&N){let z=L.length;for(let Z=z-1;Z>=0;--Z){let ce=d===E?f(L[Z],!0):L[Z];N.insertBefore(ce,g(d))}}}return yt(d),!0},al=function(d,b,E,N){return d.length===0?b:b===E||b===N?Ae(b):b},ll=function(d,b){if(et(oe.beforeSanitizeElements,d,null),d!==b&&S(d)===null)return Sr&&zn(d),!0;if(Rr(d))return yt(d),!0;let E=le(U?U(d):d.nodeName);if(ie=al(oe.uponSanitizeElement,ie,Ii,Er),et(oe.uponSanitizeElement,d,{tagName:E,allowedTags:ie}),d!==b&&S(d)===null)return Sr&&zn(d),!0;if(Rd(d,E))return yt(d),!0;if(Un[E]||!(gt.tagCheck instanceof Function&>.tagCheck(E))&&!ie[E]){let L=Nd(d,E,b);return L===!1&&et(oe.afterSanitizeElements,d,null),L}if((H?H(d):d.nodeType)===He.element&&!kd(d)||(E==="noscript"||E==="noembed"||E==="noframes")&&be(Hg,d.innerHTML))return yt(d),!0;if(vt&&d.nodeType===He.text){let L=Ir(d.textContent);d.textContent!==L&&(Nn(e.removed,{element:d.cloneNode()}),d.textContent=L)}return et(oe.afterSanitizeElements,d,null),!1},cl=function(d,b,E){if(Va[b]||bt&&b==="patchsrc"||bt&&b==="for"&&d!=="label"&&d!=="output"||Xa&&(b==="id"||b==="name")&&(E in n||E in Td))return!1;let N=se[b]||gt.attributeCheck instanceof Function&>.attributeCheck(b,d);if(!(Ni&&be(md,b))){if(!(ja&&be(gd,b))){if(N){if(!Di[b]){if(!be(Ba,lr(E,$a,""))){if(!((b==="src"||b==="xlink:href"||b==="href")&&d!=="script"&&fu(E,"data:")===0&&Za[d])){if(!(qa&&!be(vd,lr(E,$a,"")))){if(E)return!1}}}}}else if(!(ul(d)&&(de.tagNameCheck instanceof RegExp&&be(de.tagNameCheck,d)||de.tagNameCheck instanceof Function&&de.tagNameCheck(d))&&(de.attributeNameCheck instanceof RegExp&&be(de.attributeNameCheck,b)||de.attributeNameCheck instanceof Function&&de.attributeNameCheck(b,d))||b==="is"&&de.allowCustomizedBuiltInElements&&(de.tagNameCheck instanceof RegExp&&be(de.tagNameCheck,E)||de.tagNameCheck instanceof Function&&de.tagNameCheck(E))))return!1}}return!0},Od=W({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ul=function(d){return!Od[ur(d)]&&be(bd,d)},Md=function(d,b,E,N){if(re&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!E)switch(m.getAttributeType(d,b)){case"TrustedHTML":return sn(N);case"TrustedScriptURL":return ad(N)}return N},Ld=function(d,b,E,N){try{E?d.setAttributeNS(E,b,N):d.setAttribute(b,N),Rr(d)?yt(d):pu(e.removed)}catch{Rt(b,d)}},dl=function(d){et(oe.beforeSanitizeAttributes,d,null);let b=d.attributes;if(!b||Rr(d))return;se=al(oe.uponSanitizeAttribute,se,Ri,_r);let E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:se,forceKeepAttr:void 0},N=b.length,L=le(d.nodeName);for(;N--;){let z=b[N],Z=z.name,ce=z.namespaceURI,Ie=z.value,Re=le(Z),Vi=Ie,Ce=Z==="value"?Vi:xg(Vi);if(E.attrName=Re,E.attrValue=Ce,E.keepAttr=!0,E.forceKeepAttr=void 0,et(oe.uponSanitizeAttribute,d,E),Ce=E.attrValue,Ya&&(Re==="id"||Re==="name")&&fu(Ce,Ka)!==0&&(Rt(Z,d),Ce=Ka+Ce),bt&&be(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ce)){Rt(Z,d);continue}if(Re==="attributename"&&hu(Ce,"href")){Rt(Z,d);continue}if(!E.forceKeepAttr){if(!E.keepAttr){Rt(Z,d);continue}if(!Wa&&be(zg,Ce)){Rt(Z,d);continue}if(vt&&(Ce=Ir(Ce)),!cl(L,Re,Ce)){Rt(Z,d);continue}Ce=Md(L,Re,ce,Ce),Ce!==Vi&&Ld(d,Z,ce,Ce)}}et(oe.afterSanitizeAttributes,d,null)},Nr=function(d){let b=null,E=sl(d);for(et(oe.beforeSanitizeShadowDOM,d,null);b=E.nextNode();)if(et(oe.uponSanitizeShadowNode,b,null),ll(b,d),dl(b),dn(b.content)&&Nr(b.content),(H?H(b):b.nodeType)===He.element){let L=T(b);dn(L)&&(Bi(L),Nr(L))}et(oe.afterSanitizeShadowDOM,d,null)},Bi=function(d){let b=[{node:d,shadow:null}];for(;b.length>0;){let E=b.pop();if(E.shadow){Nr(E.shadow);continue}let N=E.node,z=(H?H(N):N.nodeType)===He.element,Z=x(N);if(Z)for(let ce=Z.length-1;ce>=0;--ce)b.push({node:Z[ce],shadow:null});if(z){let ce=U?U(N):null;if(typeof ce=="string"&&le(ce)==="template"){let Ie=N.content;dn(Ie)&&b.push({node:Ie,shadow:null})}}if(z){let ce=T(N);dn(ce)&&b.push({node:null,shadow:ce},{node:ce,shadow:null})}}};return e.sanitize=function(w){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,E=null,N=null,L=null;if(Ui=!w,Ui&&(w="<!-->"),typeof w!="string"&&!Gn(w)&&(w=Sg(w),typeof w!="string"))throw tn("dirty is not a string, aborting");if(!e.isSupported)return w;Oi?(ie=Er,se=_r):Fi(d),(oe.uponSanitizeElement.length>0||oe.uponSanitizeAttribute.length>0)&&(ie=Ae(ie)),oe.uponSanitizeAttribute.length>0&&(se=Ae(se)),e.removed=[];let z=Sr&&typeof w!="string"&&Gn(w);if(z){Id(w);let Ie=U?U(w):w.nodeName;if(typeof Ie=="string"){let Re=le(Ie);if(!ie[Re]||Un[Re])throw Cr(w),tn("root node is forbidden and cannot be sanitized in-place")}if(Rr(w))throw Cr(w),tn("root node is clobbered and cannot be sanitized in-place");try{Bi(w)}catch(Re){throw Cr(w),Re}}else if(Gn(w))b=il("<!---->"),E=b.ownerDocument.importNode(w,!0),E.nodeType===He.element&&E.nodeName==="BODY"||E.nodeName==="HTML"?b=E:b.appendChild(E),Bi(E);else{if(!an&&!vt&&!It&&w.indexOf("<")===-1)return re&&wr?sn(w):w;if(b=il(w),!b)return an?null:wr?Ve:""}b&&Mi&&yt(b.firstChild);let Z=z?w:b;try{let Ie=sl(Z);for(;N=Ie.nextNode();)ll(N,Z),dl(N),dn(N.content)&&Nr(N.content)}catch(Ie){throw z&&(Cr(w),Rn(e.removed,Re=>{Re.element&&zn(Re.element)})),Ie}if(z)return Rn(e.removed,Ie=>{Ie.element&&zn(Ie.element)}),vt&&$i(w),w;if(an){if(vt&&$i(b),Tr)for(L=cd.call(b.ownerDocument);b.firstChild;)L.appendChild(b.firstChild);else L=b;return(se.shadowroot||se.shadowrootmode)&&(L=dd.call(r,L,!0)),L}let ce=It?b.outerHTML:b.innerHTML;return It&&ie["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&be(Dg,b.ownerDocument.doctype.name)&&(ce="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
13
|
+
`+ce),vt&&(ce=Ir(ce)),re&&wr?sn(ce):ce},e.setConfig=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Fi(w),Oi=!0,Er=ie,_r=se},e.clearConfig=function(){un=null,Oi=!1,Er=null,_r=null,re=ki,Ve=""},e.isValidAttribute=function(w,d,b){un||Fi({});let E=le(w),N=le(d);return cl(E,N,b)},e.addHook=function(w,d){typeof d=="function"&&ye(oe,w)&&Nn(oe[w],d)},e.removeHook=function(w,d){if(ye(oe,w)){if(d!==void 0){let b=bg(oe[w],d);return b===-1?void 0:yg(oe[w],b,1)[0]}return pu(oe[w])}},e.removeHooks=function(w){ye(oe,w)&&(oe[w]=[])},e.removeAllHooks=function(){oe=wu()},e}var Cu=ku();function _a(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var on=_a();function Du(t){on=t}var nn={exec:()=>null};function Mn(t){let e=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),o=e[r];return o||(o=t(r),e[r]=o),o}}function j(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(o,i)=>{let s=typeof i=="string"?i:i.source;return s=s.replace(ke.caret,"$1"),n=n.replace(o,s),r},getRegex:()=>new RegExp(n,e)};return r}var $g=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),ke={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:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:Mn(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Mn(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Mn(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:Mn(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:Mn(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Mn(t=>new RegExp(`^ {0,${t}}>`))},Bg=/^(?:[ \t]*(?:\n|$))+/,Vg=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,jg=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,qg=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ta=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Uu=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Hu=j(Uu).replace(/bull/g,Ta).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}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Wg=j(Uu).replace(/bull/g,Ta).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}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),wa=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Xg=/^[^\n]+/,Sa=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Yg=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Sa).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Kg=j(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Ta).getRegex(),bi="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",Aa=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Zg=j("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\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",Aa).replace("tag",bi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),zu=t=>j(wa).replace("hr",hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list",t).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",bi).getRegex(),Jg=zu(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Qg=zu(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),ev=j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Qg).getRegex(),ka={blockquote:ev,code:Vg,def:Yg,fences:jg,heading:qg,hr,html:Zg,lheading:Hu,list:Kg,newline:Bg,paragraph:Jg,table:nn,text:Xg},Iu=j("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",bi).getRegex(),tv={...ka,lheading:Wg,table:Iu,paragraph:j(wa).replace("hr",hr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Iu).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",bi).getRegex()},nv={...ka,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Aa).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:nn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(wa).replace("hr",hr).replace("heading",` *#{1,6} *[^
|
|
14
|
+
]`).replace("lheading",Hu).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},rv=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ov=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Gu=/^( {2,}|\\)\n(?!\s*$)/,iv=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ft=/[\p{P}\p{S}]/u,Ln=/[\s\p{P}\p{S}]/u,fr=/[^\s\p{P}\p{S}]/u,sv=j(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ln).getRegex(),av=/[\p{Pi}\p{Ps}"']/u,Fu=/(?!~)[\p{P}\p{S}]/u,lv=/(?!~)[\s\p{P}\p{S}]/u,cv=/(?:[^\s\p{P}\p{S}]|~)/u,uv=j(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",$g?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),$u=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,dv=j($u,"u").replace(/punct/g,ft).getRegex(),pv=j($u,"u").replace(/punct/g,Fu).getRegex(),hv=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,fv=j(hv,"u").replace(/openQuote/g,av).replace(/punct/g,ft).getRegex(),Bu="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",mv=j(Bu,"gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Ln).replace(/punct/g,ft).getRegex(),gv=j(Bu,"gu").replace(/notPunctSpace/g,cv).replace(/punctSpace/g,lv).replace(/punct/g,Fu).getRegex(),vv="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",bv=j(vv,"gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Ln).replace(/punct/g,ft).getRegex(),yv=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Ln).replace(/punct/g,ft).getRegex(),xv="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",Ev=j(xv,"gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Ln).replace(/punct/g,ft).getRegex(),_v=j(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,ft).getRegex(),Tv="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",wv=j(Tv,"gu").replace(/notPunctSpace/g,fr).replace(/punctSpace/g,Ln).replace(/punct/g,ft).getRegex(),Sv=j(/\\(punct)/,"gu").replace(/punct/g,ft).getRegex(),Av=j(/^<(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(),kv=j(Aa).replace("(?:-->|$)","-->").getRegex(),Cv=j("^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",kv).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),mi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Iv=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",mi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Vu=j(/^!?\[(label)\]\[(ref)\]/).replace("label",mi).replace("ref",Sa).getRegex(),ju=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",Sa).getRegex(),Rv=j("reflink|nolink(?!\\()","g").replace("reflink",Vu).replace("nolink",ju).getRegex(),Ru=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ca={_backpedal:nn,anyPunctuation:Sv,autolink:Av,blockSkip:uv,br:Gu,code:ov,del:nn,delLDelim:nn,delRDelim:nn,emStrongLDelim:dv,emStrongRDelimAst:mv,emStrongRDelimUnd:yv,escape:rv,link:Iv,nolink:ju,punctuation:sv,reflink:Vu,reflinkSearch:Rv,tag:Cv,text:iv,url:nn},Nv={...Ca,emStrongLDelim:fv,emStrongRDelimAst:bv,emStrongRDelimUnd:Ev,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",mi).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",mi).getRegex()},ya={...Ca,emStrongRDelimAst:gv,emStrongLDelim:pv,delLDelim:_v,delRDelim:wv,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ru).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:j(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ru).getRegex()},Ov={...ya,br:j(Gu).replace("{2,}","*").getRegex(),text:j(ya.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},fi={normal:ka,gfm:tv,pedantic:nv},dr={normal:Ca,gfm:ya,breaks:Ov,pedantic:Nv},Mv={"&":"&","<":"<",">":">",'"':""","'":"'"},Nu=t=>Mv[t];function at(t,e){if(e){if(ke.escapeTest.test(t))return t.replace(ke.escapeReplace,Nu)}else if(ke.escapeTestNoEncode.test(t))return t.replace(ke.escapeReplaceNoEncode,Nu);return t}function Ou(t){try{t=encodeURI(t).replace(ke.percentDecode,"%")}catch{return null}return t}function Mu(t,e){let n=t.replace(ke.findPipe,(i,s,a)=>{let l=!1,c=s;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(ke.splitPipe),o=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;o<r.length;o++)r[o]=r[o].trim().replace(ke.slashPipe,"|");return r}function Ct(t,e,n){let r=t.length;if(r===0)return"";let o=0;for(;o<r;){let i=t.charAt(r-o-1);if(i===e&&!n)o++;else if(i!==e&&n)o++;else break}return t.slice(0,r-o)}function Lu(t){let e=t.split(`
|
|
15
15
|
`),n=e.length-1;for(;n>=0&&ke.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`
|
|
16
|
-
`)}function
|
|
16
|
+
`)}function Lv(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function Pv(t,e=0){let n=e,r="";for(let o of t)if(o===" "){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=o,n++;return r}function Pu(t,e,n,r,o){let i=e.href,s=e.title||null,a=t[1].replace(o.other.outputLinkReplace,"$1");r.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:i,title:s,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,l}function Dv(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let o=r[1];return e.split(`
|
|
17
17
|
`).map(i=>{let s=i.match(n.other.beginningSpace);if(s===null)return i;let[a]=s;return a.length>=o.length?i.slice(o.length):i}).join(`
|
|
18
|
-
`)}var
|
|
19
|
-
`),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:
|
|
20
|
-
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=
|
|
18
|
+
`)}var gi=class{options;rules;lexer;constructor(t){this.options=t||on}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=this.options.pedantic?e[0]:Lu(e[0]),r=n.replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:n,codeBlockStyle:"indented",text:r}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=Dv(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=Ct(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Ct(e[0],`
|
|
19
|
+
`),depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Ct(e[0],`
|
|
20
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=Ct(e[0],`
|
|
21
21
|
`).split(`
|
|
22
22
|
`),r="",o="",i=[];for(;n.length>0;){let s=!1,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),s=!0;else if(!s)a.push(n[l]);else break;n=n.slice(l);let c=a.join(`
|
|
23
23
|
`),h=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
@@ -29,19 +29,19 @@ ${h}`:h;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
|
|
|
29
29
|
${p}`,o=o.substring(0,o.length-f.text.length)+x.text;break}else if(y?.type==="list"){let f=y,p=f.raw+`
|
|
30
30
|
`+n.join(`
|
|
31
31
|
`),g=this.list(p);i[i.length-1]=g,r=r.substring(0,r.length-y.raw.length)+g.raw,o=o.substring(0,o.length-f.raw.length)+g.raw,n=p.substring(i.at(-1).raw.length).split(`
|
|
32
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:o}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[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 i=this.rules.other.listItemRegex(n),s=!1;for(;t;){let l=!1,c="",h="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let m=
|
|
32
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:i,text:o}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[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 i=this.rules.other.listItemRegex(n),s=!1;for(;t;){let l=!1,c="",h="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let m=Pv(e[2].split(`
|
|
33
33
|
`,1)[0],e[1].length),y=t.split(`
|
|
34
34
|
`,1)[0],f=!m.trim(),p=0;if(this.options.pedantic?(p=2,h=m.trimStart()):f?p=e[1].length+1:(p=m.search(this.rules.other.nonSpaceChar),p=p>4?1:p,h=m.slice(p),p+=e[1].length),f&&this.rules.other.blankLine.test(y)&&(c+=y+`
|
|
35
|
-
`,t=t.substring(y.length+1),l=!0),!l){let g=this.rules.other.nextBulletRegex(p),x=this.rules.other.hrRegex(p),
|
|
36
|
-
`,1)[0],Y;if(y=U,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),Y=y):Y=y.replace(this.rules.other.tabCharGlobal," "),
|
|
37
|
-
`+Y.slice(p);else{if(f||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||
|
|
35
|
+
`,t=t.substring(y.length+1),l=!0),!l){let g=this.rules.other.nextBulletRegex(p),x=this.rules.other.hrRegex(p),S=this.rules.other.fencesBeginRegex(p),T=this.rules.other.headingBeginRegex(p),I=this.rules.other.htmlBeginRegex(p),H=this.rules.other.blockquoteBeginRegex(p);for(;t;){let U=t.split(`
|
|
36
|
+
`,1)[0],Y;if(y=U,this.options.pedantic?(y=y.replace(this.rules.other.listReplaceNesting," "),Y=y):Y=y.replace(this.rules.other.tabCharGlobal," "),S.test(y)||T.test(y)||I.test(y)||H.test(y)||g.test(y)||x.test(y))break;if(Y.search(this.rules.other.nonSpaceChar)>=p||!y.trim())h+=`
|
|
37
|
+
`+Y.slice(p);else{if(f||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||S.test(m)||T.test(m)||x.test(m))break;h+=`
|
|
38
38
|
`+y}f=!y.trim(),c+=U+`
|
|
39
|
-
`,t=t.substring(U.length+1),m=Y.slice(p)}}o.loose||(s?o.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(s=!0)),o.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,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 l of o.items){this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]);let c=l.tokens[0];if(l.task&&(c?.type==="text"||c?.type==="paragraph")){l.text=l.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 h=this.rules.other.listTaskCheckbox.exec(l.raw);if(h){let m={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};l.checked=m.checked,o.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=m.raw+l.tokens[0].raw,l.tokens[0].text=m.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(m)):l.tokens.unshift({type:"paragraph",raw:m.raw,text:m.raw,tokens:[m]}):l.tokens.unshift(m)}}else l.task&&(l.task=!1);if(!o.loose){let h=l.tokens.filter(y=>y.type==="space"),m=h.length>0&&h.some(y=>this.rules.other.anyLine.test(y.raw));o.loose=m}}if(o.loose)for(let l of o.items){l.loose=!0;for(let c of l.tokens)c.type==="text"&&(c.type="paragraph")}return o}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=
|
|
40
|
-
`),href:r,title:o}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=
|
|
41
|
-
`):[],i={type:"table",raw:
|
|
42
|
-
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let s of r)this.rules.other.tableAlignRight.test(s)?i.align.push("right"):this.rules.other.tableAlignCenter.test(s)?i.align.push("center"):this.rules.other.tableAlignLeft.test(s)?i.align.push("left"):i.align.push(null);for(let s=0;s<n.length;s++)i.header.push({text:n[s],tokens:this.lexer.inline(n[s]),header:!0,align:i.align[s]});for(let s of o)i.rows.push(
|
|
39
|
+
`,t=t.substring(U.length+1),m=Y.slice(p)}}o.loose||(s?o.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(s=!0)),o.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,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 l of o.items){this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]);let c=l.tokens[0];if(l.task&&(c?.type==="text"||c?.type==="paragraph")){l.text=l.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 h=this.rules.other.listTaskCheckbox.exec(l.raw);if(h){let m={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};l.checked=m.checked,o.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=m.raw+l.tokens[0].raw,l.tokens[0].text=m.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(m)):l.tokens.unshift({type:"paragraph",raw:m.raw,text:m.raw,tokens:[m]}):l.tokens.unshift(m)}}else l.task&&(l.task=!1);if(!o.loose){let h=l.tokens.filter(y=>y.type==="space"),m=h.length>0&&h.some(y=>this.rules.other.anyLine.test(y.raw));o.loose=m}}if(o.loose)for(let l of o.items){l.loose=!0;for(let c of l.tokens)c.type==="text"&&(c.type="paragraph")}return o}}html(t){let e=this.rules.block.html.exec(t);if(e){let n=Lu(e[0]);return{type:"html",block:!0,raw:n,pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:n}}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",o=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:Ct(e[0],`
|
|
40
|
+
`),href:r,title:o}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=Mu(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
41
|
+
`):[],i={type:"table",raw:Ct(e[0],`
|
|
42
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let s of r)this.rules.other.tableAlignRight.test(s)?i.align.push("right"):this.rules.other.tableAlignCenter.test(s)?i.align.push("center"):this.rules.other.tableAlignLeft.test(s)?i.align.push("left"):i.align.push(null);for(let s=0;s<n.length;s++)i.header.push({text:n[s],tokens:this.lexer.inline(n[s]),header:!0,align:i.align[s]});for(let s of o)i.rows.push(Mu(s,i.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:!1,align:i.align[l]})));return i}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:Ct(e[0],`
|
|
43
43
|
`),depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
44
|
-
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=
|
|
44
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let i=Ct(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=Lv(e[2],"()");if(i===-2)return;if(i>-1){let s=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,s).trim(),e[3]=""}}let r=e[2],o="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(r);i&&(r=i[1],o=i[3])}else o=e[3]?e[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)),Pu(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:o&&o.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),o=e[r.toLowerCase()];if(!o){let i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return Pu(n,o,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);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,i,s,a=o,l=0,c=r[0][0],h=n===c,m=c==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(m.lastIndex=0,e=e.slice(-1*t.length+o);(r=m.exec(e))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(s=[...i].length,r[3]||r[4]){a+=s;continue}else if(r[5]||r[6]){if(o%3&&!((o+s)%3)){l+=s;continue}if(h)break}if(a-=s,a>0)continue;s=Math.min(s,s+a+l);let y=[...r[0]][0].length,f=t.slice(0,o+r.index+y+s);if(Math.min(o,s)%2){let g=f.slice(1,-1);return{type:"em",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}let p=f.slice(2,-2);return{type:"strong",raw:f,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[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:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let o=[...r[0]].length-1,i,s,a=o,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+o);(r=l.exec(e))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(s=[...i].length,s!==o))continue;if(r[3]||r[4]){a+=s;continue}if(a-=s,a>0)continue;s=Math.min(s,s+a);let c=[...r[0]][0].length,h=t.slice(0,o+r.index+c+s),m=h.slice(o,-o);return{type:"del",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let o;do o=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(o!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},Ke=class xa{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||on,this.options.tokenizer=this.options.tokenizer||new gi,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:ke,block:fi.normal,inline:dr.normal};this.options.pedantic?(n.block=fi.pedantic,n.inline=dr.pedantic):this.options.gfm&&(n.block=fi.gfm,this.options.breaks?n.inline=dr.breaks:n.inline=dr.gfm),this.tokenizer.rules=n}static get rules(){return{block:fi,inline:dr}}static lex(e,n){return new xa(n).lex(e)}static lexInline(e,n){return new xa(n).inlineTokens(e)}lex(e){e=e.replace(ke.carriageReturn,`
|
|
45
45
|
`),this.blockTokens(e,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(e,n=[],r=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(ke.tabCharGlobal," ").replace(ke.spaceLine,""));let o=1/0;for(;e;){if(e.length<o)o=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(a=>(i=a.call({lexer:this},e,n))?(e=e.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let a=n.at(-1);i.raw.length===1&&a!==void 0?a.raw+=`
|
|
46
46
|
`:n.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let a=n.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
47
47
|
`)?"":`
|
|
@@ -55,9 +55,9 @@ ${p}`,o=o.substring(0,o.length-f.text.length)+x.text;break}else if(y?.type==="li
|
|
|
55
55
|
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(i),r=s.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let a=n.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
56
56
|
`)?"":`
|
|
57
57
|
`)+i.raw,a.text+=`
|
|
58
|
-
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links){let a=Object.keys(this.tokens.links);a.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,l=>a.includes(l.slice(l.lastIndexOf("[")+1,-1))?"["+"a".repeat(l.length-2)+"]":l))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),r=r.replace(this.tokenizer.rules.inline.blockSkip,(a,l,c)=>{let h=c?c.length:0;return a.slice(0,h)+"["+"a".repeat(a.length-h-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let o=!1,i="",s=1/0;for(;e;){if(e.length<s)s=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}o||(i=""),o=!1;let a;if(this.options.extensions?.inline?.some(c=>(a=c.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let c=n.at(-1);a.type==="text"&&c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(a=this.tokenizer.emStrong(e,r,i)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.del(e,r,i)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),n.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),n.push(a);continue}let l=e;if(this.options.extensions?.startInline){let c=1/0,h=e.slice(1),m;this.options.extensions.startInline.forEach(y=>{m=y.call({lexer:this},h),typeof m=="number"&&m>=0&&(c=Math.min(c,m))}),c<1/0&&c>=0&&(l=e.substring(0,c+1))}if(a=this.tokenizer.inlineText(l)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(i=a.raw.slice(-1)),o=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},
|
|
59
|
-
`;return r?'<pre><code class="language-'+
|
|
60
|
-
`:"<pre><code>"+(n?o:
|
|
58
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e;if(this.tokens.links){let a=Object.keys(this.tokens.links);a.length>0&&(r=r.replace(this.tokenizer.rules.inline.reflinkSearch,l=>a.includes(l.slice(l.lastIndexOf("[")+1,-1))?"["+"a".repeat(l.length-2)+"]":l))}r=r.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),r=r.replace(this.tokenizer.rules.inline.blockSkip,(a,l,c)=>{let h=c?c.length:0;return a.slice(0,h)+"["+"a".repeat(a.length-h-2)+"]"}),r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let o=!1,i="",s=1/0;for(;e;){if(e.length<s)s=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}o||(i=""),o=!1;let a;if(this.options.extensions?.inline?.some(c=>(a=c.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let c=n.at(-1);a.type==="text"&&c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(a=this.tokenizer.emStrong(e,r,i)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.del(e,r,i)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),n.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),n.push(a);continue}let l=e;if(this.options.extensions?.startInline){let c=1/0,h=e.slice(1),m;this.options.extensions.startInline.forEach(y=>{m=y.call({lexer:this},h),typeof m=="number"&&m>=0&&(c=Math.min(c,m))}),c<1/0&&c>=0&&(l=e.substring(0,c+1))}if(a=this.tokenizer.inlineText(l)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(i=a.raw.slice(-1)),o=!0;let c=n.at(-1);c?.type==="text"?(c.raw+=a.raw,c.text+=a.text):n.push(a);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}infiniteLoopError(e){let n="Infinite loop on byte: "+e;if(this.options.silent)console.error(n);else throw new Error(n)}},vi=class{options;parser;constructor(t){this.options=t||on}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(ke.notSpaceStart)?.[0],o=t.replace(ke.endingNewline,"")+`
|
|
59
|
+
`;return r?'<pre><code class="language-'+at(r)+'">'+(n?o:at(o,!0))+`</code></pre>
|
|
60
|
+
`:"<pre><code>"+(n?o:at(o,!0))+`</code></pre>
|
|
61
61
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
62
62
|
${this.parser.parse(t)}</blockquote>
|
|
63
63
|
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
@@ -73,153 +73,188 @@ ${this.parser.parse(t)}</blockquote>
|
|
|
73
73
|
`}tablerow({text:t}){return`<tr>
|
|
74
74
|
${t}</tr>
|
|
75
75
|
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
76
|
-
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${
|
|
77
|
-
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+
|
|
76
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${at(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),o=Ou(t);if(o===null)return r;t=o;let i='<a href="'+t+'"';return e&&(i+=' title="'+at(e)+'"'),i+=">"+r+"</a>",i}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let o=Ou(t);if(o===null)return at(n);t=o;let i=`<img src="${t}" alt="${at(n)}"`;return e&&(i+=` title="${at(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:at(t.text)}},Ia=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Ze=class Ea{options;renderer;textRenderer;constructor(e){this.options=e||on,this.options.renderer=this.options.renderer||new vi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ia}static parse(e,n){return new Ea(n).parse(e)}static parseInline(e,n){return new Ea(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let o=e[r];if(this.options.extensions?.renderers?.[o.type]){let s=o,a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==!1||!["space","hr","heading","code","table","blockquote","list","checkbox","html","def","paragraph","text"].includes(s.type)){n+=a||"";continue}}let i=o;switch(i.type){case"space":{n+=this.renderer.space(i);break}case"hr":{n+=this.renderer.hr(i);break}case"heading":{n+=this.renderer.heading(i);break}case"code":{n+=this.renderer.code(i);break}case"table":{n+=this.renderer.table(i);break}case"blockquote":{n+=this.renderer.blockquote(i);break}case"list":{n+=this.renderer.list(i);break}case"checkbox":{n+=this.renderer.checkbox(i);break}case"html":{n+=this.renderer.html(i);break}case"def":{n+=this.renderer.def(i);break}case"paragraph":{n+=this.renderer.paragraph(i);break}case"text":{n+=this.renderer.text(i);break}default:{let s='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let o=0;o<e.length;o++){let i=e[o];if(this.options.extensions?.renderers?.[i.type]){let a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==!1||!["escape","html","link","image","checkbox","strong","em","codespan","br","del","text"].includes(i.type)){r+=a||"";continue}}let s=i;switch(s.type){case"escape":{r+=n.text(s);break}case"html":{r+=n.html(s);break}case"link":{r+=n.link(s);break}case"image":{r+=n.image(s);break}case"checkbox":{r+=n.checkbox(s);break}case"strong":{r+=n.strong(s);break}case"em":{r+=n.em(s);break}case"codespan":{r+=n.codespan(s);break}case"br":{r+=n.br(s);break}case"del":{r+=n.del(s);break}case"text":{r+=n.text(s);break}default:{let a='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return r}},pr=class{options;block;constructor(t){this.options=t||on}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?Ke.lex:Ke.lexInline}provideParser(t=this.block){return t?Ze.parse:Ze.parseInline}},Ra=class{defaults=_a();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ze;Renderer=vi;TextRenderer=Ia;Lexer=Ke;Tokenizer=gi;Hooks=pr;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let o=r;for(let i of o.header)n=n.concat(this.walkTokens(i.tokens,e));for(let i of o.rows)for(let s of i)n=n.concat(this.walkTokens(s.tokens,e));break}case"list":{let o=r;n=n.concat(this.walkTokens(o.items,e));break}default:{let o=r;this.defaults.extensions?.childTokens?.[o.type]?this.defaults.extensions.childTokens[o.type].forEach(i=>{let s=o[i].flat(1/0);n=n.concat(this.walkTokens(s,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.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 i=e.renderers[o.name];i?e.renderers[o.name]=function(...s){let a=o.renderer.apply(this,s);return a===!1&&(a=i.apply(this,s)),a}:e.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 i=e[o.level];i?i.unshift(o.tokenizer):e[o.level]=[o.tokenizer],o.start&&(o.level==="block"?e.startBlock?e.startBlock.push(o.start):e.startBlock=[o.start]:o.level==="inline"&&(e.startInline?e.startInline.push(o.start):e.startInline=[o.start]))}"childTokens"in o&&o.childTokens&&(e.childTokens[o.name]=o.childTokens)}),r.extensions=e),n.renderer){let o=this.defaults.renderer||new vi(this.defaults);for(let i in n.renderer){if(!(i in o))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let s=i,a=n.renderer[s],l=o[s];o[s]=(...c)=>{let h=a.apply(o,c);return h===!1&&(h=l.apply(o,c)),h||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new gi(this.defaults);for(let i in n.tokenizer){if(!(i in o))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let s=i,a=n.tokenizer[s],l=o[s];o[s]=(...c)=>{let h=a.apply(o,c);return h===!1&&(h=l.apply(o,c)),h}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new pr;for(let i in n.hooks){if(!(i in o))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let s=i,a=n.hooks[s],l=o[s];pr.passThroughHooks.has(i)?o[s]=c=>{if(this.defaults.async&&pr.passThroughHooksRespectAsync.has(i))return(async()=>{let m=await a.call(o,c);return l.call(o,m)})();let h=a.call(o,c);return l.call(o,h)}:o[s]=(...c)=>{if(this.defaults.async)return(async()=>{let m=await a.apply(o,c);return m===!1&&(m=await l.apply(o,c)),m})();let h=a.apply(o,c);return h===!1&&(h=l.apply(o,c)),h}}r.hooks=o}if(n.walkTokens){let o=this.defaults.walkTokens,i=n.walkTokens;r.walkTokens=function(s){let a=[];return a.push(i.call(this,s)),o&&(a=a.concat(o.call(this,s))),a}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return Ke.lex(t,e??this.defaults)}parser(t,e){return Ze.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},o={...this.defaults,...r},i=this.onError(!!o.silent,!!o.async);if(this.defaults.async===!0&&r.async===!1)return i(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 e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(o.hooks&&(o.hooks.options=o,o.hooks.block=t),o.async)return(async()=>{let s=o.hooks?await o.hooks.preprocess(e):e,a=await(o.hooks?await o.hooks.provideLexer(t):t?Ke.lex:Ke.lexInline)(s,o),l=o.hooks?await o.hooks.processAllTokens(a):a;o.walkTokens&&await Promise.all(this.walkTokens(l,o.walkTokens));let c=await(o.hooks?await o.hooks.provideParser(t):t?Ze.parse:Ze.parseInline)(l,o);return o.hooks?await o.hooks.postprocess(c):c})().catch(i);try{o.hooks&&(e=o.hooks.preprocess(e));let s=(o.hooks?o.hooks.provideLexer(t):t?Ke.lex:Ke.lexInline)(e,o);o.hooks&&(s=o.hooks.processAllTokens(s)),o.walkTokens&&this.walkTokens(s,o.walkTokens);let a=(o.hooks?o.hooks.provideParser(t):t?Ze.parse:Ze.parseInline)(s,o);return o.hooks&&(a=o.hooks.postprocess(a)),a}catch(s){return i(s)}}}onError(t,e){return n=>{if(n.message+=`
|
|
77
|
+
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+at(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},rn=new Ra;function J(t,e){return rn.parse(t,e)}J.options=J.setOptions=function(t){return rn.setOptions(t),J.defaults=rn.defaults,Du(J.defaults),J};J.getDefaults=_a;J.defaults=on;function Uv(...t){return rn.use(...t),J.defaults=rn.defaults,Du(J.defaults),J}J.use=Uv;J.walkTokens=function(t,e){return rn.walkTokens(t,e)};J.parseInline=rn.parseInline;J.Parser=Ze;J.parser=Ze.parse;J.Renderer=vi;J.TextRenderer=Ia;J.Lexer=Ke;J.lexer=Ke.lex;J.Tokenizer=gi;J.Hooks=pr;J.parse=J;var Pw=J.options,Dw=J.setOptions,Uw=J.walkTokens,Hw=J.parseInline;var zw=Ze.parse,Gw=Ke.lex;var Hv=new Ra({gfm:!0,breaks:!0}),qu=["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"],Wu=["href","title","class"],zv=[...qu,"img"],Gv=[...Wu,"src","alt","width","height"];function yi(t,e){let n=e?.allowImages===!0,r=Hv.parse(t,{async:!1}),o=Cu.sanitize(r,{ALLOWED_TAGS:n?zv:qu,ALLOWED_ATTR:n?Gv:Wu}),i=document.createElement("template");i.innerHTML=o;for(let s of i.content.querySelectorAll("a[href]"))s.setAttribute("target","_blank"),s.setAttribute("rel","noopener noreferrer");return i.innerHTML.trim()}function Xu(t){let e=document.createElement("div");e.className="resize-handle",e.setAttribute("part","resize-handle"),e.setAttribute("role","separator"),e.setAttribute("aria-label",t.label),e.tabIndex=0;let n=(r,o,i,s,a)=>{let l=o.x==="right"?i.right-s:s-i.left,c={width:Math.max(280,l)};if(r!=="both")return c;let h=o.y==="bottom"?i.bottom-a:a-i.top;return{...c,height:Math.max(240,h)}};return e.addEventListener("pointerdown",r=>{let o=t.axis();if(o==="none")return;let i=t.anchor(),s=t.rect(),a=c=>{t.apply(n(o,i,s,c.clientX,c.clientY))},l=c=>{window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",l),e.removeAttribute("data-dragging"),t.commit(n(o,i,s,c.clientX,c.clientY))};e.setAttribute("data-dragging","true"),window.addEventListener("pointermove",a),window.addEventListener("pointerup",l),r.preventDefault()}),e.addEventListener("keydown",r=>{let o=t.axis();if(o==="none")return;let i=t.anchor(),s=t.rect(),a=r.shiftKey?64:16,l=i.x==="right"?-1:1,c=s.right-s.left,h=s.bottom-s.top,m=null;if(r.key==="ArrowLeft")m={width:Math.max(280,c-a*l)};else if(r.key==="ArrowRight")m={width:Math.max(280,c+a*l)};else if(o==="both"&&(r.key==="ArrowUp"||r.key==="ArrowDown")){let y=r.key===(i.y==="bottom"?"ArrowUp":"ArrowDown");m={height:Math.max(240,h+(y?a:-a))}}m!==null&&(r.preventDefault(),t.apply(m),t.commit(m))}),e}function Yu(t,e){for(let n of Array.from(t.childNodes))n.nodeType===Node.TEXT_NODE?e.push({node:n,parent:t}):Yu(n,e)}function Ku(t){let e=[];Yu(t,e);let n=0;for(let{node:r,parent:o}of e){let i=document.createDocumentFragment();for(let s of r.data.split(/(\s+)/)){if(s==="")continue;if(/\s/.test(s)){i.appendChild(document.createTextNode(s));continue}let a=document.createElement("span");a.className="word",a.style.setProperty("--ag-ui-word-index",String(n)),a.textContent=s,i.appendChild(a),n+=1}o.replaceChild(i,r)}}function Zu(t,e,n){let r=document.createElement("div");r.className=`run-notice run-notice--${n}`,r.setAttribute("part",`run-notice run-notice-${n}`),r.setAttribute("role","status");let o=document.createElement("span");o.className="run-notice-icon",o.setAttribute("part","run-notice-icon"),o.textContent=t,o.setAttribute("aria-hidden","true");let i=document.createElement("span");return i.className="run-notice-text",i.setAttribute("part","run-notice-text"),i.textContent=e,r.append(o,i),r}var xi=class{chips;palette;#n;#e=[];#t=!1;#s=!1;#r=[];#a=0;constructor(e){this.#n=e,this.chips=document.createElement("div"),this.chips.className="skill-chips",this.chips.setAttribute("part","skill-chips"),this.chips.hidden=!0,this.palette=document.createElement("div"),this.palette.className="skill-palette",this.palette.setAttribute("part","skill-palette"),this.palette.setAttribute("role","listbox"),this.palette.hidden=!0}setSkills(e){this.#e=e,this.#c()}enableChips(e){this.#t=e,this.#c()}enableSlash(e){this.#s=e}isOpen(){return!this.palette.hidden}onInput(e){this.#s&&e.startsWith("/")?this.#i(e.slice(1)):this.close()}onKeydown(e){return this.isOpen()?e.key==="ArrowDown"?(this.#o(1),!0):e.key==="ArrowUp"?(this.#o(-1),!0):e.key==="Escape"?(this.close(),!0):e.key==="Enter"?(this.#r.slice(this.#a,this.#a+1).forEach(n=>{this.#l(n)}),!0):!1:!1}close(){this.palette.hidden=!0,this.palette.replaceChildren()}#i(e){let n=e.trim().toLowerCase(),r=this.#e.filter(o=>o.name.toLowerCase().includes(n)||o.title.toLowerCase().includes(n));if(r.length===0){this.close();return}this.#r=r,this.#a=0,this.#d(),this.palette.hidden=!1}#o(e){let n=this.#r.length;this.#a=(this.#a+e+n)%n,this.#d()}#l(e){this.close(),this.#n(e)}#c(){this.chips.replaceChildren();let e=this.#t?this.#e.filter(n=>n.chip===!0):[];this.chips.hidden=e.length===0;for(let n of e){let r=document.createElement("button");r.type="button",r.className="skill-chip",r.setAttribute("part","skill-chip"),r.textContent=n.title,r.title=`/${n.name}`,r.addEventListener("click",()=>this.#l(n)),this.chips.appendChild(r)}}#d(){this.palette.replaceChildren(),this.#r.forEach((e,n)=>{let r=document.createElement("button");r.type="button",r.className="skill-item",r.setAttribute("part","skill-item"),r.setAttribute("role","option"),r.setAttribute("aria-selected",n===this.#a?"true":"false");let o=document.createElement("span");o.className="skill-item-title",o.setAttribute("part","skill-item-title");let i=document.createElement("code");if(i.className="skill-item-token",i.setAttribute("part","skill-item-token"),i.textContent=`/${e.name}`,o.append(i,document.createTextNode(` ${e.title}`)),r.appendChild(o),e.description!==void 0){let s=document.createElement("span");s.className="skill-item-desc",s.setAttribute("part","skill-item-desc"),s.textContent=e.description,r.appendChild(s)}r.addEventListener("click",()=>this.#l(e)),this.palette.appendChild(r)})}};var Ju=`
|
|
78
|
+
/* \u2500\u2500 Token defaults \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
79
|
+
Every public --ag-ui-* token is read here into a private --_* alias, and
|
|
80
|
+
only the alias is used by the rules below.
|
|
81
|
+
|
|
82
|
+
The indirection is what makes ancestor theming work. Declaring the public
|
|
83
|
+
name on :host would set it *on the host element*, and a value on an element
|
|
84
|
+
always beats one inherited from an ancestor \u2014 so a page that put the tokens
|
|
85
|
+
on a wrapper would see no effect at all, which is the one thing the API is
|
|
86
|
+
documented to support. Reading the public name with the default as a var()
|
|
87
|
+
fallback leaves it undeclared on the element, so an ancestor's value is
|
|
88
|
+
inherited normally while a value aimed at the element still wins over it.
|
|
89
|
+
|
|
90
|
+
Two invariants hold this together:
|
|
91
|
+
1. No rule outside this file's :host blocks may reference a public name
|
|
92
|
+
directly. A public name read outside these blocks resolves to nothing and
|
|
93
|
+
silently drops its declaration rather than erroring, so the miss shows up
|
|
94
|
+
as a missing colour, not a failure.
|
|
95
|
+
2. Every --_* alias in use is declared here. Aliases inherit like any custom
|
|
96
|
+
property, so an undeclared one would pick up a same-named property from
|
|
97
|
+
the host page; declaring it on :host shields the shadow tree from that. */
|
|
78
98
|
:host {
|
|
79
99
|
/* Colors */
|
|
80
|
-
--ag-ui-bg
|
|
81
|
-
--ag-ui-fg
|
|
82
|
-
--ag-ui-accent
|
|
83
|
-
--ag-ui-user-bg
|
|
84
|
-
--ag-ui-user-fg
|
|
85
|
-
--ag-ui-assistant-bg
|
|
86
|
-
--ag-ui-hover
|
|
87
|
-
--
|
|
88
|
-
--
|
|
89
|
-
--ag-ui-tool-fg
|
|
90
|
-
--ag-ui-header-bg
|
|
91
|
-
--ag-ui-header-fg
|
|
92
|
-
--ag-ui-border
|
|
93
|
-
--ag-ui-radius
|
|
100
|
+
--_bg: var(--ag-ui-bg, #ffffff);
|
|
101
|
+
--_fg: var(--ag-ui-fg, #1a1a2e);
|
|
102
|
+
--_accent: var(--ag-ui-accent, #4f46e5);
|
|
103
|
+
--_user-bg: var(--ag-ui-user-bg, #4f46e5);
|
|
104
|
+
--_user-fg: var(--ag-ui-user-fg, #ffffff);
|
|
105
|
+
--_assistant-bg: var(--ag-ui-assistant-bg, #f1f1f6);
|
|
106
|
+
--_hover: var(--ag-ui-hover, #e7e7ee);
|
|
107
|
+
--_input-bg: var(--ag-ui-input-bg, var(--_bg));
|
|
108
|
+
--_tool-bg: var(--ag-ui-tool-bg, var(--_assistant-bg));
|
|
109
|
+
--_tool-fg: var(--ag-ui-tool-fg, var(--_accent));
|
|
110
|
+
--_header-bg: var(--ag-ui-header-bg, var(--_accent));
|
|
111
|
+
--_header-fg: var(--ag-ui-header-fg, #ffffff);
|
|
112
|
+
--_border: var(--ag-ui-border, #e2e2ec);
|
|
113
|
+
--_radius: var(--ag-ui-radius, 12px);
|
|
114
|
+
|
|
115
|
+
/* Body text and raised chrome. Both are referenced by the code-block copy
|
|
116
|
+
button; neither had a default before, so the declarations reading them
|
|
117
|
+
were dropped and the button fell back to the inherited colour over a
|
|
118
|
+
transparent box. The defaults below restate exactly that, so this is a
|
|
119
|
+
rename with no repaint \u2014 see the note on .code-copy. */
|
|
120
|
+
--_text: var(--ag-ui-text, var(--_fg));
|
|
121
|
+
--_surface: var(--ag-ui-surface, transparent);
|
|
94
122
|
|
|
95
123
|
/* Status accents for tool-call cards. */
|
|
96
|
-
--ag-ui-success
|
|
97
|
-
--ag-ui-danger
|
|
98
|
-
--ag-ui-muted
|
|
124
|
+
--_success: var(--ag-ui-success, #15803d);
|
|
125
|
+
--_danger: var(--ag-ui-danger, #b91c1c);
|
|
126
|
+
--_muted: var(--ag-ui-muted, #6b7280);
|
|
99
127
|
|
|
100
128
|
/* Tool-call status icon glyphs (override to re-theme) + spinner speed.
|
|
101
129
|
The pending state is the animated ring; the settled states use these. */
|
|
102
|
-
--ag-ui-tool-icon-done
|
|
103
|
-
--ag-ui-tool-icon-error
|
|
104
|
-
--ag-ui-tool-icon-declined
|
|
105
|
-
--ag-ui-tool-spin-duration
|
|
130
|
+
--_tool-icon-done: var(--ag-ui-tool-icon-done, "\u2713");
|
|
131
|
+
--_tool-icon-error: var(--ag-ui-tool-icon-error, "\u2715");
|
|
132
|
+
--_tool-icon-declined: var(--ag-ui-tool-icon-declined, "\u2298");
|
|
133
|
+
--_tool-spin-duration: var(--ag-ui-tool-spin-duration, 0.7s);
|
|
106
134
|
|
|
107
135
|
/* Answer well (opt-in via data-answer-well) \u2014 boxes a whole assistant turn. */
|
|
108
|
-
--ag-ui-well-bg
|
|
109
|
-
--
|
|
136
|
+
--_well-bg: var(--ag-ui-well-bg, transparent);
|
|
137
|
+
--_well-border: var(--ag-ui-well-border, var(--_border));
|
|
110
138
|
|
|
111
139
|
/* Surface \u2014 set --ag-ui-shadow: none for a flush, embedded panel. */
|
|
112
|
-
--ag-ui-shadow
|
|
113
|
-
--ag-ui-font
|
|
114
|
-
--ag-ui-font-size
|
|
115
|
-
--ag-ui-code-font
|
|
140
|
+
--_shadow: var(--ag-ui-shadow, 0 12px 32px rgba(20, 20, 50, 0.18));
|
|
141
|
+
--_font: var(--ag-ui-font, inherit);
|
|
142
|
+
--_font-size: var(--ag-ui-font-size, 14px);
|
|
143
|
+
--_code-font: var(--ag-ui-code-font, ui-monospace, "SF Mono", Menlo, monospace);
|
|
144
|
+
|
|
145
|
+
/* Header / launcher icon box. */
|
|
146
|
+
--_icon-size: var(--ag-ui-icon-size, 22px);
|
|
147
|
+
--_icon-radius: var(--ag-ui-icon-radius, 4px);
|
|
116
148
|
|
|
117
149
|
/* Spacing \u2014 the density preset overrides these. */
|
|
118
|
-
--ag-ui-space
|
|
119
|
-
--ag-ui-pad
|
|
120
|
-
--ag-ui-msg-pad
|
|
121
|
-
--ag-ui-msg-radius
|
|
150
|
+
--_space: var(--ag-ui-space, 10px);
|
|
151
|
+
--_pad: var(--ag-ui-pad, 16px);
|
|
152
|
+
--_msg-pad: var(--ag-ui-msg-pad, 8px 12px);
|
|
153
|
+
--_msg-radius: var(--ag-ui-msg-radius, 14px);
|
|
122
154
|
|
|
123
155
|
/* Layout \u2014 override from outside to dock the widget anywhere.
|
|
124
156
|
Set --ag-ui-position: static (and place this element in your own
|
|
125
157
|
grid/flex layout) to embed it in the page flow instead of floating. */
|
|
126
|
-
--ag-ui-position
|
|
127
|
-
--ag-ui-z-index
|
|
128
|
-
--ag-ui-width
|
|
129
|
-
--ag-ui-height
|
|
130
|
-
--ag-ui-inset
|
|
131
|
-
--ag-ui-max-width
|
|
132
|
-
--ag-ui-max-height
|
|
158
|
+
--_position: var(--ag-ui-position, fixed);
|
|
159
|
+
--_z-index: var(--ag-ui-z-index, 2147483000);
|
|
160
|
+
--_width: var(--ag-ui-width, 380px);
|
|
161
|
+
--_height: var(--ag-ui-height, 560px);
|
|
162
|
+
--_inset: var(--ag-ui-inset, auto 24px 24px auto);
|
|
163
|
+
--_max-width: var(--ag-ui-max-width, calc(100vw - 48px));
|
|
164
|
+
--_max-height: var(--ag-ui-max-height, calc(100vh - 48px));
|
|
133
165
|
/* Reading-column width for placement="page" (full-bleed, centred content). */
|
|
134
|
-
--ag-ui-content-max-width
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
166
|
+
--_content-max-width: var(--ag-ui-content-max-width, 820px);
|
|
167
|
+
/* Slim rail the sidebar placement collapses to. Only that placement reads
|
|
168
|
+
it, but it is declared here so invariant 2 holds for every alias. */
|
|
169
|
+
--_rail-width: var(--ag-ui-rail-width, 52px);
|
|
170
|
+
|
|
171
|
+
position: var(--_position);
|
|
172
|
+
inset: var(--_inset);
|
|
173
|
+
z-index: var(--_z-index);
|
|
174
|
+
width: var(--_width);
|
|
175
|
+
max-width: var(--_max-width);
|
|
176
|
+
height: var(--_height);
|
|
177
|
+
max-height: var(--_max-height);
|
|
143
178
|
display: flex;
|
|
144
|
-
font-family: var(--
|
|
145
|
-
font-size: var(--
|
|
146
|
-
color: var(--
|
|
179
|
+
font-family: var(--_font);
|
|
180
|
+
font-size: var(--_font-size);
|
|
181
|
+
color: var(--_fg);
|
|
147
182
|
}
|
|
148
183
|
|
|
149
184
|
/* \u2500\u2500 Themes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
150
185
|
Themes only re-set the colour variables; layout/spacing are unaffected.
|
|
151
186
|
theme="auto" follows the OS via prefers-color-scheme. */
|
|
152
187
|
:host([theme="dark"]) {
|
|
153
|
-
--ag-ui-bg
|
|
154
|
-
--ag-ui-fg
|
|
155
|
-
--ag-ui-assistant-bg
|
|
156
|
-
--ag-ui-hover
|
|
157
|
-
--ag-ui-header-bg
|
|
158
|
-
--ag-ui-header-fg
|
|
159
|
-
--ag-ui-border
|
|
160
|
-
--ag-ui-muted
|
|
161
|
-
--ag-ui-shadow
|
|
188
|
+
--_bg: var(--ag-ui-bg, #15151f);
|
|
189
|
+
--_fg: var(--ag-ui-fg, #e8e8f2);
|
|
190
|
+
--_assistant-bg: var(--ag-ui-assistant-bg, #25253a);
|
|
191
|
+
--_hover: var(--ag-ui-hover, #303049);
|
|
192
|
+
--_header-bg: var(--ag-ui-header-bg, #1f1f30);
|
|
193
|
+
--_header-fg: var(--ag-ui-header-fg, #e8e8f2);
|
|
194
|
+
--_border: var(--ag-ui-border, #33334a);
|
|
195
|
+
--_muted: var(--ag-ui-muted, #9aa0b4);
|
|
196
|
+
--_shadow: var(--ag-ui-shadow, 0 12px 32px rgba(0, 0, 0, 0.5));
|
|
162
197
|
}
|
|
163
198
|
|
|
164
199
|
@media (prefers-color-scheme: dark) {
|
|
165
200
|
:host([theme="auto"]) {
|
|
166
|
-
--ag-ui-bg
|
|
167
|
-
--ag-ui-fg
|
|
168
|
-
--ag-ui-assistant-bg
|
|
169
|
-
--ag-ui-hover
|
|
170
|
-
--ag-ui-header-bg
|
|
171
|
-
--ag-ui-header-fg
|
|
172
|
-
--ag-ui-border
|
|
173
|
-
--ag-ui-muted
|
|
174
|
-
--ag-ui-shadow
|
|
201
|
+
--_bg: var(--ag-ui-bg, #15151f);
|
|
202
|
+
--_fg: var(--ag-ui-fg, #e8e8f2);
|
|
203
|
+
--_assistant-bg: var(--ag-ui-assistant-bg, #25253a);
|
|
204
|
+
--_hover: var(--ag-ui-hover, #303049);
|
|
205
|
+
--_header-bg: var(--ag-ui-header-bg, #1f1f30);
|
|
206
|
+
--_header-fg: var(--ag-ui-header-fg, #e8e8f2);
|
|
207
|
+
--_border: var(--ag-ui-border, #33334a);
|
|
208
|
+
--_muted: var(--ag-ui-muted, #9aa0b4);
|
|
209
|
+
--_shadow: var(--ag-ui-shadow, 0 12px 32px rgba(0, 0, 0, 0.5));
|
|
175
210
|
}
|
|
176
211
|
}
|
|
177
212
|
|
|
178
213
|
/* A terminal-flavoured "code" theme: dark, monospace, green accent. */
|
|
179
214
|
:host([theme="code"]) {
|
|
180
|
-
--ag-ui-bg
|
|
181
|
-
--ag-ui-fg
|
|
182
|
-
--ag-ui-accent
|
|
183
|
-
--ag-ui-user-bg
|
|
184
|
-
--ag-ui-assistant-bg
|
|
185
|
-
--ag-ui-hover
|
|
186
|
-
--ag-ui-header-bg
|
|
187
|
-
--ag-ui-header-fg
|
|
188
|
-
--ag-ui-border
|
|
189
|
-
--ag-ui-muted
|
|
190
|
-
--ag-ui-font
|
|
191
|
-
--ag-ui-shadow
|
|
215
|
+
--_bg: var(--ag-ui-bg, #0d1117);
|
|
216
|
+
--_fg: var(--ag-ui-fg, #c9d1d9);
|
|
217
|
+
--_accent: var(--ag-ui-accent, #3fb950);
|
|
218
|
+
--_user-bg: var(--ag-ui-user-bg, #238636);
|
|
219
|
+
--_assistant-bg: var(--ag-ui-assistant-bg, #161b22);
|
|
220
|
+
--_hover: var(--ag-ui-hover, #21262d);
|
|
221
|
+
--_header-bg: var(--ag-ui-header-bg, #010409);
|
|
222
|
+
--_header-fg: var(--ag-ui-header-fg, #c9d1d9);
|
|
223
|
+
--_border: var(--ag-ui-border, #30363d);
|
|
224
|
+
--_muted: var(--ag-ui-muted, #8b949e);
|
|
225
|
+
--_font: var(--ag-ui-font, var(--_code-font));
|
|
226
|
+
--_shadow: var(--ag-ui-shadow, 0 12px 32px rgba(0, 0, 0, 0.6));
|
|
192
227
|
}
|
|
193
228
|
|
|
194
229
|
/* \u2500\u2500 Density \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
195
230
|
:host([density="compact"]) {
|
|
196
|
-
--ag-ui-font-size
|
|
197
|
-
--ag-ui-space
|
|
198
|
-
--ag-ui-pad
|
|
199
|
-
--ag-ui-msg-pad
|
|
200
|
-
--ag-ui-msg-radius
|
|
231
|
+
--_font-size: var(--ag-ui-font-size, 13px);
|
|
232
|
+
--_space: var(--ag-ui-space, 6px);
|
|
233
|
+
--_pad: var(--ag-ui-pad, 10px);
|
|
234
|
+
--_msg-pad: var(--ag-ui-msg-pad, 5px 9px);
|
|
235
|
+
--_msg-radius: var(--ag-ui-msg-radius, 10px);
|
|
201
236
|
}
|
|
202
237
|
|
|
203
238
|
/* \u2500\u2500 Placement presets \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
204
239
|
:host([placement="bottom-left"]) {
|
|
205
|
-
--ag-ui-inset
|
|
240
|
+
--_inset: var(--ag-ui-inset, auto auto 24px 24px);
|
|
206
241
|
}
|
|
207
242
|
|
|
208
243
|
:host([placement="side"]) {
|
|
209
|
-
--ag-ui-inset
|
|
210
|
-
--ag-ui-width
|
|
211
|
-
--ag-ui-height
|
|
212
|
-
--ag-ui-max-height
|
|
213
|
-
--ag-ui-radius
|
|
244
|
+
--_inset: var(--ag-ui-inset, 0 0 0 auto);
|
|
245
|
+
--_width: var(--ag-ui-width, 420px);
|
|
246
|
+
--_height: var(--ag-ui-height, 100vh);
|
|
247
|
+
--_max-height: var(--ag-ui-max-height, 100vh);
|
|
248
|
+
--_radius: var(--ag-ui-radius, 0);
|
|
214
249
|
}
|
|
215
250
|
|
|
216
251
|
:host([placement="full"]) {
|
|
217
|
-
--ag-ui-inset
|
|
218
|
-
--ag-ui-width
|
|
219
|
-
--ag-ui-height
|
|
220
|
-
--ag-ui-max-width
|
|
221
|
-
--ag-ui-max-height
|
|
222
|
-
--ag-ui-radius
|
|
252
|
+
--_inset: var(--ag-ui-inset, 0);
|
|
253
|
+
--_width: var(--ag-ui-width, 100vw);
|
|
254
|
+
--_height: var(--ag-ui-height, 100vh);
|
|
255
|
+
--_max-width: var(--ag-ui-max-width, 100vw);
|
|
256
|
+
--_max-height: var(--ag-ui-max-height, 100vh);
|
|
257
|
+
--_radius: var(--ag-ui-radius, 0);
|
|
223
258
|
}
|
|
224
259
|
|
|
225
260
|
/* Page: full-bleed background with a centred reading column. Unlike
|
|
@@ -228,85 +263,20 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
228
263
|
padding on the scroll area + composer (no per-row wrapper), so user pills
|
|
229
264
|
still right-align and the assistant well spans the column. */
|
|
230
265
|
:host([placement="page"]) {
|
|
231
|
-
--ag-ui-inset
|
|
232
|
-
--ag-ui-width
|
|
233
|
-
--ag-ui-height
|
|
234
|
-
--ag-ui-max-width
|
|
235
|
-
--ag-ui-max-height
|
|
236
|
-
--ag-ui-radius
|
|
266
|
+
--_inset: var(--ag-ui-inset, 0);
|
|
267
|
+
--_width: var(--ag-ui-width, 100vw);
|
|
268
|
+
--_height: var(--ag-ui-height, 100vh);
|
|
269
|
+
--_max-width: var(--ag-ui-max-width, 100vw);
|
|
270
|
+
--_max-height: var(--ag-ui-max-height, 100vh);
|
|
271
|
+
--_radius: var(--ag-ui-radius, 0);
|
|
237
272
|
}
|
|
238
273
|
|
|
239
274
|
:host([placement="page"]) .messages {
|
|
240
|
-
padding-inline: max(var(--
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
:host([placement="page"]) /* Resize handle: a corner grip on a floating panel, an edge grip on a docked
|
|
244
|
-
one. Absent entirely where the placement is full-bleed, since there is
|
|
245
|
-
nothing to drag. */
|
|
246
|
-
.resize-handle {
|
|
247
|
-
position: absolute;
|
|
248
|
-
z-index: 2;
|
|
249
|
-
background: transparent;
|
|
250
|
-
touch-action: none;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.resize-handle:focus-visible {
|
|
254
|
-
outline: 2px solid var(--ag-ui-accent);
|
|
255
|
-
outline-offset: -2px;
|
|
275
|
+
padding-inline: max(var(--_pad), calc((100% - var(--_content-max-width)) / 2));
|
|
256
276
|
}
|
|
257
277
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
and stamps data-resize-anchor with the edges that stay put.
|
|
261
|
-
|
|
262
|
-
Default (bottom-right pinned, the floating case) puts the grip top-left. */
|
|
263
|
-
.resize-handle {
|
|
264
|
-
top: 0;
|
|
265
|
-
left: 0;
|
|
266
|
-
width: 14px;
|
|
267
|
-
height: 14px;
|
|
268
|
-
cursor: nwse-resize;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
:host([data-resize-anchor~="left"]) .resize-handle {
|
|
272
|
-
left: auto;
|
|
273
|
-
right: 0;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
:host([data-resize-anchor~="top"]) .resize-handle {
|
|
277
|
-
top: auto;
|
|
278
|
-
bottom: 0;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/* One axis flipped means the drag runs along the other diagonal. */
|
|
282
|
-
:host([data-resize-anchor="top-right"]) .resize-handle,
|
|
283
|
-
:host([data-resize-anchor="bottom-left"]) .resize-handle {
|
|
284
|
-
cursor: nesw-resize;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/* Docked: the placement owns the height, so only the inner edge is the user's. */
|
|
288
|
-
:host([placement="sidebar"]) .resize-handle,
|
|
289
|
-
:host([placement="side"]) .resize-handle {
|
|
290
|
-
top: 0;
|
|
291
|
-
bottom: auto;
|
|
292
|
-
width: 8px;
|
|
293
|
-
height: 100%;
|
|
294
|
-
cursor: ew-resize;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/* Full-bleed: nothing to drag. */
|
|
298
|
-
:host([placement="full"]) .resize-handle,
|
|
299
|
-
:host([placement="page"]) .resize-handle {
|
|
300
|
-
display: none;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
.resize-handle[data-dragging] {
|
|
304
|
-
background: var(--ag-ui-accent);
|
|
305
|
-
opacity: 0.35;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
.input-row {
|
|
309
|
-
padding-inline: max(12px, calc((100% - var(--ag-ui-content-max-width)) / 2));
|
|
278
|
+
:host([placement="page"]) .input-row {
|
|
279
|
+
padding-inline: max(12px, calc((100% - var(--_content-max-width)) / 2));
|
|
310
280
|
}
|
|
311
281
|
|
|
312
282
|
/* The rows between the message list and the composer (skill chips, the
|
|
@@ -315,12 +285,12 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
315
285
|
margin-based, so each gets its own inline axis nudged by the same gutter. */
|
|
316
286
|
:host([placement="page"]) .skill-chips,
|
|
317
287
|
:host([placement="page"]) .attachment-tray {
|
|
318
|
-
padding-inline: max(12px, calc((100% - var(--
|
|
288
|
+
padding-inline: max(12px, calc((100% - var(--_content-max-width)) / 2));
|
|
319
289
|
}
|
|
320
290
|
|
|
321
291
|
:host([placement="page"]) .skill-palette,
|
|
322
292
|
:host([placement="page"]) .skill-hint {
|
|
323
|
-
margin-inline: max(12px, calc((100% - var(--
|
|
293
|
+
margin-inline: max(12px, calc((100% - var(--_content-max-width)) / 2));
|
|
324
294
|
}
|
|
325
295
|
|
|
326
296
|
/* In the reading column the assistant well uses the full width; the user
|
|
@@ -335,17 +305,16 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
335
305
|
--ag-ui-position: static (and place this element in your own layout) for a
|
|
336
306
|
host-managed push instead. */
|
|
337
307
|
:host([placement="sidebar"]) {
|
|
338
|
-
--ag-ui-inset
|
|
339
|
-
--ag-ui-width
|
|
340
|
-
--ag-ui-height
|
|
341
|
-
--ag-ui-max-height
|
|
342
|
-
--ag-ui-radius
|
|
343
|
-
--ag-ui-rail-width: 52px;
|
|
308
|
+
--_inset: var(--ag-ui-inset, 0 0 0 auto);
|
|
309
|
+
--_width: var(--ag-ui-width, 420px);
|
|
310
|
+
--_height: var(--ag-ui-height, 100vh);
|
|
311
|
+
--_max-height: var(--ag-ui-max-height, 100vh);
|
|
312
|
+
--_radius: var(--ag-ui-radius, 0);
|
|
344
313
|
transition: width 0.28s ease;
|
|
345
314
|
}
|
|
346
315
|
|
|
347
316
|
:host([placement="sidebar"][data-side="left"]) {
|
|
348
|
-
--ag-ui-inset
|
|
317
|
+
--_inset: var(--ag-ui-inset, 0 auto 0 0);
|
|
349
318
|
}
|
|
350
319
|
|
|
351
320
|
:host([placement="sidebar"]) .chat {
|
|
@@ -356,7 +325,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
356
325
|
reveal the rail. Higher specificity than the generic collapse rules, so it
|
|
357
326
|
wins regardless of source order. */
|
|
358
327
|
:host([placement="sidebar"][collapsed]) {
|
|
359
|
-
width: var(--
|
|
328
|
+
width: var(--_rail-width);
|
|
360
329
|
height: 100vh;
|
|
361
330
|
max-height: 100vh;
|
|
362
331
|
bottom: 0;
|
|
@@ -381,9 +350,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
381
350
|
align-items: flex-start;
|
|
382
351
|
justify-content: center;
|
|
383
352
|
padding-top: 16px;
|
|
384
|
-
border: 1px solid var(--
|
|
385
|
-
background: var(--
|
|
386
|
-
color: var(--
|
|
353
|
+
border: 1px solid var(--_border);
|
|
354
|
+
background: var(--_header-bg);
|
|
355
|
+
color: var(--_header-fg);
|
|
387
356
|
cursor: pointer;
|
|
388
357
|
}
|
|
389
358
|
|
|
@@ -397,13 +366,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
397
366
|
/* Embedded: drop the floating chrome and the high z-index stacking context so
|
|
398
367
|
the widget lives in the host's own layout (fixes overlay/z-index clashes). */
|
|
399
368
|
:host([placement="embedded"]) {
|
|
400
|
-
--ag-ui-position
|
|
401
|
-
--ag-ui-width
|
|
402
|
-
--ag-ui-height
|
|
403
|
-
--ag-ui-max-width
|
|
404
|
-
--ag-ui-max-height
|
|
405
|
-
--ag-ui-shadow
|
|
406
|
-
--ag-ui-z-index
|
|
369
|
+
--_position: var(--ag-ui-position, static);
|
|
370
|
+
--_width: var(--ag-ui-width, 100%);
|
|
371
|
+
--_height: var(--ag-ui-height, 100%);
|
|
372
|
+
--_max-width: var(--ag-ui-max-width, 100%);
|
|
373
|
+
--_max-height: var(--ag-ui-max-height, 100%);
|
|
374
|
+
--_shadow: var(--ag-ui-shadow, none);
|
|
375
|
+
--_z-index: var(--ag-ui-z-index, auto);
|
|
407
376
|
}
|
|
408
377
|
|
|
409
378
|
.chat {
|
|
@@ -412,10 +381,10 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
412
381
|
flex-direction: column;
|
|
413
382
|
flex: 1;
|
|
414
383
|
min-height: 0;
|
|
415
|
-
background: var(--
|
|
416
|
-
border: 1px solid var(--
|
|
417
|
-
border-radius: var(--
|
|
418
|
-
box-shadow: var(--
|
|
384
|
+
background: var(--_bg);
|
|
385
|
+
border: 1px solid var(--_border);
|
|
386
|
+
border-radius: var(--_radius);
|
|
387
|
+
box-shadow: var(--_shadow);
|
|
419
388
|
overflow: hidden;
|
|
420
389
|
}
|
|
421
390
|
|
|
@@ -425,9 +394,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
425
394
|
justify-content: space-between;
|
|
426
395
|
gap: 8px;
|
|
427
396
|
padding: 10px 14px;
|
|
428
|
-
border-bottom: 1px solid var(--
|
|
429
|
-
background: var(--
|
|
430
|
-
color: var(--
|
|
397
|
+
border-bottom: 1px solid var(--_border);
|
|
398
|
+
background: var(--_header-bg);
|
|
399
|
+
color: var(--_header-fg);
|
|
431
400
|
}
|
|
432
401
|
|
|
433
402
|
.header-title {
|
|
@@ -446,8 +415,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
446
415
|
align-items: center;
|
|
447
416
|
justify-content: center;
|
|
448
417
|
flex: none;
|
|
449
|
-
width: var(--
|
|
450
|
-
height: var(--
|
|
418
|
+
width: var(--_icon-size);
|
|
419
|
+
height: var(--_icon-size);
|
|
451
420
|
line-height: 1;
|
|
452
421
|
}
|
|
453
422
|
|
|
@@ -455,7 +424,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
455
424
|
width: 100%;
|
|
456
425
|
height: 100%;
|
|
457
426
|
object-fit: contain;
|
|
458
|
-
border-radius: var(--
|
|
427
|
+
border-radius: var(--_icon-radius);
|
|
459
428
|
}
|
|
460
429
|
|
|
461
430
|
.header-controls {
|
|
@@ -507,10 +476,10 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
507
476
|
.messages {
|
|
508
477
|
flex: 1;
|
|
509
478
|
overflow-y: auto;
|
|
510
|
-
padding: var(--
|
|
479
|
+
padding: var(--_pad);
|
|
511
480
|
display: flex;
|
|
512
481
|
flex-direction: column;
|
|
513
|
-
gap: var(--
|
|
482
|
+
gap: var(--_space);
|
|
514
483
|
}
|
|
515
484
|
|
|
516
485
|
/* Empty-state region (slot): centred while it's the only thing in the
|
|
@@ -518,7 +487,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
518
487
|
.empty {
|
|
519
488
|
margin: auto;
|
|
520
489
|
text-align: center;
|
|
521
|
-
color: var(--
|
|
490
|
+
color: var(--_muted);
|
|
522
491
|
}
|
|
523
492
|
|
|
524
493
|
.empty[hidden] {
|
|
@@ -534,22 +503,22 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
534
503
|
.answer {
|
|
535
504
|
display: flex;
|
|
536
505
|
flex-direction: column;
|
|
537
|
-
gap: var(--
|
|
506
|
+
gap: var(--_space);
|
|
538
507
|
align-self: stretch;
|
|
539
508
|
min-width: 0;
|
|
540
509
|
}
|
|
541
510
|
|
|
542
511
|
:host([data-answer-well]) .answer {
|
|
543
|
-
padding: var(--
|
|
544
|
-
background: var(--
|
|
545
|
-
border: 1px solid var(--
|
|
546
|
-
border-radius: var(--
|
|
512
|
+
padding: var(--_pad);
|
|
513
|
+
background: var(--_well-bg);
|
|
514
|
+
border: 1px solid var(--_well-border);
|
|
515
|
+
border-radius: var(--_radius);
|
|
547
516
|
}
|
|
548
517
|
|
|
549
518
|
.message {
|
|
550
519
|
max-width: 80%;
|
|
551
|
-
padding: var(--
|
|
552
|
-
border-radius: var(--
|
|
520
|
+
padding: var(--_msg-pad);
|
|
521
|
+
border-radius: var(--_msg-radius);
|
|
553
522
|
line-height: 1.4;
|
|
554
523
|
white-space: pre-wrap;
|
|
555
524
|
word-break: break-word;
|
|
@@ -587,14 +556,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
587
556
|
|
|
588
557
|
.message--user {
|
|
589
558
|
align-self: flex-end;
|
|
590
|
-
background: var(--
|
|
591
|
-
color: var(--
|
|
559
|
+
background: var(--_user-bg);
|
|
560
|
+
color: var(--_user-fg);
|
|
592
561
|
border-bottom-right-radius: 4px;
|
|
593
562
|
}
|
|
594
563
|
|
|
595
564
|
.message--assistant {
|
|
596
565
|
align-self: flex-start;
|
|
597
|
-
background: var(--
|
|
566
|
+
background: var(--_assistant-bg);
|
|
598
567
|
border-bottom-left-radius: 4px;
|
|
599
568
|
/* Assistant bubbles hold rendered markdown/HTML, so collapse the source
|
|
600
569
|
whitespace the renderer leaves between block tags. */
|
|
@@ -624,7 +593,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
624
593
|
}
|
|
625
594
|
|
|
626
595
|
.message--assistant a {
|
|
627
|
-
color: var(--
|
|
596
|
+
color: var(--_accent);
|
|
628
597
|
text-decoration: underline;
|
|
629
598
|
}
|
|
630
599
|
|
|
@@ -639,8 +608,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
639
608
|
.message--assistant pre {
|
|
640
609
|
padding: 8px 10px;
|
|
641
610
|
overflow: auto;
|
|
642
|
-
background: var(--
|
|
643
|
-
border: 1px solid var(--
|
|
611
|
+
background: var(--_bg);
|
|
612
|
+
border: 1px solid var(--_border);
|
|
644
613
|
border-radius: 6px;
|
|
645
614
|
}
|
|
646
615
|
|
|
@@ -656,6 +625,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
656
625
|
position: relative;
|
|
657
626
|
}
|
|
658
627
|
|
|
628
|
+
/* This button is the only reader of --ag-ui-surface and --ag-ui-text, and
|
|
629
|
+
neither had a default until the alias layer gave them one. Both references
|
|
630
|
+
used to resolve to nothing, dropping the declaration: the background fell
|
|
631
|
+
back to the initial transparent, and the hover/copied colour to the
|
|
632
|
+
inherited body colour. The defaults chosen upstream (transparent, and the
|
|
633
|
+
body foreground) reproduce that, so the rename repaints nothing. A raised
|
|
634
|
+
surface behind the button is a separate design question. */
|
|
659
635
|
.code-copy {
|
|
660
636
|
position: absolute;
|
|
661
637
|
top: 4px;
|
|
@@ -664,9 +640,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
664
640
|
font: inherit;
|
|
665
641
|
font-size: 0.75em;
|
|
666
642
|
line-height: 1.6;
|
|
667
|
-
color: var(--
|
|
668
|
-
background: var(--
|
|
669
|
-
border: 1px solid var(--
|
|
643
|
+
color: var(--_muted);
|
|
644
|
+
background: var(--_surface);
|
|
645
|
+
border: 1px solid var(--_border);
|
|
670
646
|
border-radius: 4px;
|
|
671
647
|
cursor: pointer;
|
|
672
648
|
opacity: 0;
|
|
@@ -681,24 +657,24 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
681
657
|
}
|
|
682
658
|
|
|
683
659
|
.code-copy:hover {
|
|
684
|
-
color: var(--
|
|
685
|
-
background: var(--
|
|
660
|
+
color: var(--_text);
|
|
661
|
+
background: var(--_hover);
|
|
686
662
|
}
|
|
687
663
|
|
|
688
664
|
.code-copy[data-state="copied"] {
|
|
689
665
|
opacity: 1;
|
|
690
|
-
color: var(--
|
|
666
|
+
color: var(--_text);
|
|
691
667
|
}
|
|
692
668
|
|
|
693
669
|
.code-copy[data-state="failed"] {
|
|
694
670
|
opacity: 1;
|
|
695
|
-
color: var(--
|
|
671
|
+
color: var(--_danger, var(--_text));
|
|
696
672
|
}
|
|
697
673
|
|
|
698
674
|
.message--assistant blockquote {
|
|
699
675
|
padding-left: 10px;
|
|
700
|
-
border-left: 3px solid var(--
|
|
701
|
-
color: var(--
|
|
676
|
+
border-left: 3px solid var(--_border);
|
|
677
|
+
color: var(--_muted);
|
|
702
678
|
}
|
|
703
679
|
|
|
704
680
|
/* Markdown tables. table/thead/tbody/tr/th/td are all in
|
|
@@ -719,13 +695,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
719
695
|
.message--assistant th,
|
|
720
696
|
.message--assistant td {
|
|
721
697
|
padding: 6px 10px;
|
|
722
|
-
border: 1px solid var(--
|
|
698
|
+
border: 1px solid var(--_border);
|
|
723
699
|
text-align: left;
|
|
724
700
|
vertical-align: top;
|
|
725
701
|
}
|
|
726
702
|
|
|
727
703
|
.message--assistant th {
|
|
728
|
-
background: var(--
|
|
704
|
+
background: var(--_hover);
|
|
729
705
|
font-weight: 600;
|
|
730
706
|
}
|
|
731
707
|
|
|
@@ -735,7 +711,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
735
711
|
gap: 4px;
|
|
736
712
|
align-items: center;
|
|
737
713
|
padding: 12px 14px;
|
|
738
|
-
background: var(--
|
|
714
|
+
background: var(--_assistant-bg);
|
|
739
715
|
border-radius: 14px;
|
|
740
716
|
border-bottom-left-radius: 4px;
|
|
741
717
|
}
|
|
@@ -744,7 +720,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
744
720
|
width: 6px;
|
|
745
721
|
height: 6px;
|
|
746
722
|
border-radius: 50%;
|
|
747
|
-
background: var(--
|
|
723
|
+
background: var(--_muted);
|
|
748
724
|
animation: ag-ui-pending 1.2s infinite ease-in-out both;
|
|
749
725
|
}
|
|
750
726
|
|
|
@@ -777,7 +753,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
777
753
|
flex-direction: column;
|
|
778
754
|
gap: 4px;
|
|
779
755
|
font-size: 12px;
|
|
780
|
-
color: var(--
|
|
756
|
+
color: var(--_muted);
|
|
781
757
|
}
|
|
782
758
|
|
|
783
759
|
.thoughts-toggle {
|
|
@@ -788,7 +764,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
788
764
|
font: inherit;
|
|
789
765
|
font-size: 12px;
|
|
790
766
|
font-weight: 600;
|
|
791
|
-
color: var(--
|
|
767
|
+
color: var(--_muted);
|
|
792
768
|
cursor: pointer;
|
|
793
769
|
}
|
|
794
770
|
|
|
@@ -813,7 +789,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
813
789
|
.thoughts-body {
|
|
814
790
|
margin: 0;
|
|
815
791
|
padding: 4px 0 4px 10px;
|
|
816
|
-
border-left: 2px solid var(--
|
|
792
|
+
border-left: 2px solid var(--_border);
|
|
817
793
|
max-height: 220px;
|
|
818
794
|
overflow: auto;
|
|
819
795
|
white-space: pre-wrap;
|
|
@@ -842,9 +818,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
842
818
|
font-family: ui-monospace, "SF Mono", Menlo, monospace;
|
|
843
819
|
padding: 8px 10px;
|
|
844
820
|
border-radius: 8px;
|
|
845
|
-
background: var(--
|
|
846
|
-
border: 1px solid var(--
|
|
847
|
-
color: var(--
|
|
821
|
+
background: var(--_tool-bg);
|
|
822
|
+
border: 1px solid var(--_border);
|
|
823
|
+
color: var(--_tool-fg);
|
|
848
824
|
}
|
|
849
825
|
|
|
850
826
|
.tool-call-head {
|
|
@@ -877,10 +853,10 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
877
853
|
|
|
878
854
|
/* Pending: a real spinning ring. Speed is tunable; reduced motion stops it. */
|
|
879
855
|
.tool-call[data-status="pending"] .tool-call-icon {
|
|
880
|
-
border: 2px solid var(--
|
|
856
|
+
border: 2px solid var(--_muted);
|
|
881
857
|
border-top-color: transparent;
|
|
882
858
|
border-radius: 50%;
|
|
883
|
-
animation: ag-ui-tool-spin var(--
|
|
859
|
+
animation: ag-ui-tool-spin var(--_tool-spin-duration) linear infinite;
|
|
884
860
|
}
|
|
885
861
|
|
|
886
862
|
@keyframes ag-ui-tool-spin {
|
|
@@ -889,18 +865,18 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
889
865
|
|
|
890
866
|
/* Settled: a themeable glyph coloured by outcome. */
|
|
891
867
|
.tool-call[data-status="done"] .tool-call-icon::before {
|
|
892
|
-
content: var(--
|
|
893
|
-
color: var(--
|
|
868
|
+
content: var(--_tool-icon-done);
|
|
869
|
+
color: var(--_success);
|
|
894
870
|
}
|
|
895
871
|
|
|
896
872
|
.tool-call[data-status="error"] .tool-call-icon::before {
|
|
897
|
-
content: var(--
|
|
898
|
-
color: var(--
|
|
873
|
+
content: var(--_tool-icon-error);
|
|
874
|
+
color: var(--_danger);
|
|
899
875
|
}
|
|
900
876
|
|
|
901
877
|
.tool-call[data-status="declined"] .tool-call-icon::before {
|
|
902
|
-
content: var(--
|
|
903
|
-
color: var(--
|
|
878
|
+
content: var(--_tool-icon-declined);
|
|
879
|
+
color: var(--_muted);
|
|
904
880
|
}
|
|
905
881
|
|
|
906
882
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -926,19 +902,19 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
926
902
|
font-size: 11px;
|
|
927
903
|
font-weight: 600;
|
|
928
904
|
background: rgba(127, 127, 127, 0.16);
|
|
929
|
-
color: var(--
|
|
905
|
+
color: var(--_muted);
|
|
930
906
|
}
|
|
931
907
|
|
|
932
908
|
.tool-call[data-status="done"] .tool-call-status {
|
|
933
|
-
color: var(--
|
|
909
|
+
color: var(--_success);
|
|
934
910
|
}
|
|
935
911
|
|
|
936
912
|
.tool-call[data-status="error"] .tool-call-status {
|
|
937
|
-
color: var(--
|
|
913
|
+
color: var(--_danger);
|
|
938
914
|
}
|
|
939
915
|
|
|
940
916
|
.tool-call[data-status="declined"] .tool-call-status {
|
|
941
|
-
color: var(--
|
|
917
|
+
color: var(--_muted);
|
|
942
918
|
}
|
|
943
919
|
|
|
944
920
|
.tool-call-body {
|
|
@@ -960,7 +936,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
960
936
|
font-weight: 700;
|
|
961
937
|
letter-spacing: 0.06em;
|
|
962
938
|
text-transform: uppercase;
|
|
963
|
-
color: var(--
|
|
939
|
+
color: var(--_muted);
|
|
964
940
|
}
|
|
965
941
|
|
|
966
942
|
/* The record of a human decision on a gated call. An approved call used to
|
|
@@ -968,7 +944,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
968
944
|
.skill-item-token {
|
|
969
945
|
font-family: ui-monospace, "SF Mono", Menlo, monospace;
|
|
970
946
|
font-size: 0.92em;
|
|
971
|
-
color: var(--
|
|
947
|
+
color: var(--_accent);
|
|
972
948
|
margin-right: 6px;
|
|
973
949
|
}
|
|
974
950
|
|
|
@@ -976,7 +952,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
976
952
|
flex: none;
|
|
977
953
|
font-size: 11px;
|
|
978
954
|
font-style: italic;
|
|
979
|
-
color: var(--
|
|
955
|
+
color: var(--_muted);
|
|
980
956
|
}
|
|
981
957
|
|
|
982
958
|
.tool-call-args,
|
|
@@ -985,12 +961,12 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
985
961
|
padding: 6px 8px;
|
|
986
962
|
max-height: 160px;
|
|
987
963
|
overflow: auto;
|
|
988
|
-
background: var(--
|
|
989
|
-
border: 1px solid var(--
|
|
964
|
+
background: var(--_bg);
|
|
965
|
+
border: 1px solid var(--_border);
|
|
990
966
|
border-radius: 6px;
|
|
991
967
|
white-space: pre-wrap;
|
|
992
968
|
word-break: break-word;
|
|
993
|
-
color: var(--
|
|
969
|
+
color: var(--_fg);
|
|
994
970
|
}
|
|
995
971
|
|
|
996
972
|
/* Display modes are pure visibility over one DOM shape, selected from the host
|
|
@@ -1037,7 +1013,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1037
1013
|
background: none;
|
|
1038
1014
|
font: inherit;
|
|
1039
1015
|
font-weight: 600;
|
|
1040
|
-
color: var(--
|
|
1016
|
+
color: var(--_accent);
|
|
1041
1017
|
cursor: pointer;
|
|
1042
1018
|
}
|
|
1043
1019
|
|
|
@@ -1060,13 +1036,12 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1060
1036
|
}
|
|
1061
1037
|
|
|
1062
1038
|
.resize-handle:focus-visible {
|
|
1063
|
-
outline: 2px solid var(--
|
|
1039
|
+
outline: 2px solid var(--_accent);
|
|
1064
1040
|
outline-offset: -2px;
|
|
1065
1041
|
}
|
|
1066
1042
|
|
|
1067
1043
|
/* The grip sits on the corner opposite the panel's anchor, because a resize
|
|
1068
|
-
measures from whichever edge is not moving.
|
|
1069
|
-
so switching placement moves the grip immediately.
|
|
1044
|
+
measures from whichever edge is not moving.
|
|
1070
1045
|
|
|
1071
1046
|
Default is floating: pinned bottom-right, so the grip is top-left. */
|
|
1072
1047
|
.resize-handle {
|
|
@@ -1077,7 +1052,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1077
1052
|
cursor: nwse-resize;
|
|
1078
1053
|
}
|
|
1079
1054
|
|
|
1080
|
-
/*
|
|
1055
|
+
/* Placement is only the opening guess, and these two rules are all it is good
|
|
1056
|
+
for. Embedded sits in normal flow, pinned top-left, so it grows bottom-right;
|
|
1057
|
+
bottom-left is pinned there, so its free corner is top-right. */
|
|
1081
1058
|
:host([placement="embedded"]) .resize-handle {
|
|
1082
1059
|
top: auto;
|
|
1083
1060
|
left: auto;
|
|
@@ -1086,16 +1063,64 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1086
1063
|
cursor: nwse-resize;
|
|
1087
1064
|
}
|
|
1088
1065
|
|
|
1089
|
-
/* Pinned bottom-left, so the free corner is top-right. */
|
|
1090
1066
|
:host([placement="bottom-left"]) .resize-handle {
|
|
1091
1067
|
left: auto;
|
|
1092
1068
|
right: 0;
|
|
1093
1069
|
cursor: nesw-resize;
|
|
1094
1070
|
}
|
|
1095
1071
|
|
|
1096
|
-
/*
|
|
1072
|
+
/* Then the measurement corrects it. Which edges are held still belongs to the
|
|
1073
|
+
host's layout rather than to placement -- a floating panel a host right-aligns
|
|
1074
|
+
is anchored bottom-left, not bottom-right -- so the element measures the edges
|
|
1075
|
+
that stay put and stamps them here as "<y>-<x>". Equal specificity to the
|
|
1076
|
+
rules above, so source order is what lets the measured value win.
|
|
1077
|
+
|
|
1078
|
+
These must not be written as [data-resize-anchor~="left"]: the stamped value
|
|
1079
|
+
is one hyphenated token, and ~= matches whitespace-separated words, so such a
|
|
1080
|
+
selector cannot ever match. It did not, which left the grip drawn at the
|
|
1081
|
+
corner that moves while the cursor pointed along the right diagonal.
|
|
1082
|
+
|
|
1083
|
+
Each rule also sets both sides of its axis rather than only the side it
|
|
1084
|
+
moves. One that flipped a single way could not undo a placement guess that
|
|
1085
|
+
had flipped the other, which put the grip on the anchored corner for an
|
|
1086
|
+
embedded panel its host right-aligns. */
|
|
1087
|
+
:host([data-resize-anchor$="-left"]) .resize-handle {
|
|
1088
|
+
left: auto;
|
|
1089
|
+
right: 0;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
:host([data-resize-anchor$="-right"]) .resize-handle {
|
|
1093
|
+
left: 0;
|
|
1094
|
+
right: auto;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
:host([data-resize-anchor^="top-"]) .resize-handle {
|
|
1098
|
+
top: auto;
|
|
1099
|
+
bottom: 0;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
:host([data-resize-anchor^="bottom-"]) .resize-handle {
|
|
1103
|
+
top: 0;
|
|
1104
|
+
bottom: auto;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
/* One axis flipped means the drag runs along the other diagonal. */
|
|
1108
|
+
:host([data-resize-anchor="top-left"]) .resize-handle,
|
|
1109
|
+
:host([data-resize-anchor="bottom-right"]) .resize-handle {
|
|
1110
|
+
cursor: nwse-resize;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
:host([data-resize-anchor="top-right"]) .resize-handle,
|
|
1114
|
+
:host([data-resize-anchor="bottom-left"]) .resize-handle {
|
|
1115
|
+
cursor: nesw-resize;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
/* Docked: the placement owns the height, so only the inner edge is the user's --
|
|
1119
|
+
an edge, not a corner, so this outranks the measured anchor by coming after. */
|
|
1097
1120
|
:host([placement="sidebar"]) .resize-handle,
|
|
1098
1121
|
:host([placement="side"]) .resize-handle {
|
|
1122
|
+
top: 0;
|
|
1123
|
+
bottom: auto;
|
|
1099
1124
|
width: 8px;
|
|
1100
1125
|
height: 100%;
|
|
1101
1126
|
cursor: ew-resize;
|
|
@@ -1114,7 +1139,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1114
1139
|
}
|
|
1115
1140
|
|
|
1116
1141
|
.resize-handle[data-dragging] {
|
|
1117
|
-
background: var(--
|
|
1142
|
+
background: var(--_accent);
|
|
1118
1143
|
opacity: 0.35;
|
|
1119
1144
|
}
|
|
1120
1145
|
|
|
@@ -1122,14 +1147,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1122
1147
|
display: flex;
|
|
1123
1148
|
gap: 8px;
|
|
1124
1149
|
padding: 12px;
|
|
1125
|
-
border-top: 1px solid var(--
|
|
1150
|
+
border-top: 1px solid var(--_border);
|
|
1126
1151
|
}
|
|
1127
1152
|
|
|
1128
1153
|
.input {
|
|
1129
1154
|
flex: 1;
|
|
1130
1155
|
resize: none;
|
|
1131
|
-
background: var(--
|
|
1132
|
-
border: 1px solid var(--
|
|
1156
|
+
background: var(--_input-bg);
|
|
1157
|
+
border: 1px solid var(--_border);
|
|
1133
1158
|
border-radius: 8px;
|
|
1134
1159
|
padding: 8px 10px;
|
|
1135
1160
|
font: inherit;
|
|
@@ -1138,14 +1163,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1138
1163
|
}
|
|
1139
1164
|
|
|
1140
1165
|
.input:focus {
|
|
1141
|
-
border-color: var(--
|
|
1166
|
+
border-color: var(--_accent);
|
|
1142
1167
|
}
|
|
1143
1168
|
|
|
1144
1169
|
.send {
|
|
1145
1170
|
border: none;
|
|
1146
1171
|
border-radius: 8px;
|
|
1147
1172
|
padding: 0 16px;
|
|
1148
|
-
background: var(--
|
|
1173
|
+
background: var(--_accent);
|
|
1149
1174
|
color: #ffffff;
|
|
1150
1175
|
font: inherit;
|
|
1151
1176
|
font-weight: 600;
|
|
@@ -1159,23 +1184,23 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1159
1184
|
|
|
1160
1185
|
/* The composer button doubles as the Stop control while a run is in flight. */
|
|
1161
1186
|
.send[data-state="running"] {
|
|
1162
|
-
background: var(--
|
|
1187
|
+
background: var(--_muted);
|
|
1163
1188
|
}
|
|
1164
1189
|
|
|
1165
1190
|
/* \u2500\u2500 File attachments \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
1166
1191
|
/* The \u{1F4CE} picker button sits left of the input; hidden until data-attachments-url. */
|
|
1167
1192
|
.attach-btn {
|
|
1168
|
-
border: 1px solid var(--
|
|
1193
|
+
border: 1px solid var(--_border);
|
|
1169
1194
|
border-radius: 8px;
|
|
1170
1195
|
padding: 0 10px;
|
|
1171
|
-
background: var(--
|
|
1196
|
+
background: var(--_input-bg);
|
|
1172
1197
|
color: inherit;
|
|
1173
1198
|
font: inherit;
|
|
1174
1199
|
cursor: pointer;
|
|
1175
1200
|
}
|
|
1176
1201
|
|
|
1177
1202
|
.attach-btn:hover {
|
|
1178
|
-
border-color: var(--
|
|
1203
|
+
border-color: var(--_accent);
|
|
1179
1204
|
}
|
|
1180
1205
|
|
|
1181
1206
|
.attach-input {
|
|
@@ -1188,17 +1213,17 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1188
1213
|
}
|
|
1189
1214
|
|
|
1190
1215
|
.voice-btn {
|
|
1191
|
-
border: 1px solid var(--
|
|
1216
|
+
border: 1px solid var(--_border);
|
|
1192
1217
|
border-radius: 8px;
|
|
1193
1218
|
padding: 0 10px;
|
|
1194
|
-
background: var(--
|
|
1219
|
+
background: var(--_input-bg);
|
|
1195
1220
|
color: inherit;
|
|
1196
1221
|
font: inherit;
|
|
1197
1222
|
cursor: pointer;
|
|
1198
1223
|
}
|
|
1199
1224
|
|
|
1200
1225
|
.voice-btn:hover {
|
|
1201
|
-
border-color: var(--
|
|
1226
|
+
border-color: var(--_accent);
|
|
1202
1227
|
}
|
|
1203
1228
|
|
|
1204
1229
|
.voice-btn:disabled {
|
|
@@ -1208,8 +1233,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1208
1233
|
|
|
1209
1234
|
/* Recording: a red tint + a gentle pulse so it's clearly "live". */
|
|
1210
1235
|
.voice-btn[data-state="recording"] {
|
|
1211
|
-
border-color: var(--
|
|
1212
|
-
background: var(--
|
|
1236
|
+
border-color: var(--_danger);
|
|
1237
|
+
background: var(--_danger);
|
|
1213
1238
|
color: #ffffff;
|
|
1214
1239
|
animation: ag-ui-voice-pulse 1.2s ease-in-out infinite;
|
|
1215
1240
|
}
|
|
@@ -1252,10 +1277,10 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1252
1277
|
max-width: 100%;
|
|
1253
1278
|
margin: 2px 0;
|
|
1254
1279
|
padding: 3px 10px;
|
|
1255
|
-
border: 1px dashed var(--
|
|
1280
|
+
border: 1px dashed var(--_border);
|
|
1256
1281
|
border-radius: 999px;
|
|
1257
1282
|
background: transparent;
|
|
1258
|
-
color: var(--
|
|
1283
|
+
color: var(--_muted);
|
|
1259
1284
|
font-size: 0.8em;
|
|
1260
1285
|
line-height: 1.4;
|
|
1261
1286
|
}
|
|
@@ -1276,16 +1301,16 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1276
1301
|
gap: 6px;
|
|
1277
1302
|
max-width: 100%;
|
|
1278
1303
|
padding: 4px 8px;
|
|
1279
|
-
border: 1px solid var(--
|
|
1304
|
+
border: 1px solid var(--_border);
|
|
1280
1305
|
border-radius: 999px;
|
|
1281
|
-
background: var(--
|
|
1306
|
+
background: var(--_assistant-bg);
|
|
1282
1307
|
font-size: 0.85em;
|
|
1283
1308
|
position: relative;
|
|
1284
1309
|
}
|
|
1285
1310
|
|
|
1286
1311
|
.attachment-chip--error {
|
|
1287
|
-
border-color: var(--
|
|
1288
|
-
color: var(--
|
|
1312
|
+
border-color: var(--_danger);
|
|
1313
|
+
color: var(--_danger);
|
|
1289
1314
|
}
|
|
1290
1315
|
|
|
1291
1316
|
.attachment-chip-name {
|
|
@@ -1296,12 +1321,12 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1296
1321
|
}
|
|
1297
1322
|
|
|
1298
1323
|
.attachment-chip-size {
|
|
1299
|
-
color: var(--
|
|
1324
|
+
color: var(--_muted);
|
|
1300
1325
|
white-space: nowrap;
|
|
1301
1326
|
}
|
|
1302
1327
|
|
|
1303
1328
|
.attachment-chip--error .attachment-chip-size {
|
|
1304
|
-
color: var(--
|
|
1329
|
+
color: var(--_danger);
|
|
1305
1330
|
}
|
|
1306
1331
|
|
|
1307
1332
|
/* The progress bar fills as the file uploads. */
|
|
@@ -1309,13 +1334,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1309
1334
|
flex-basis: 100%;
|
|
1310
1335
|
height: 3px;
|
|
1311
1336
|
border-radius: 2px;
|
|
1312
|
-
background: var(--
|
|
1337
|
+
background: var(--_border);
|
|
1313
1338
|
overflow: hidden;
|
|
1314
1339
|
}
|
|
1315
1340
|
|
|
1316
1341
|
.attachment-chip-bar-fill {
|
|
1317
1342
|
height: 100%;
|
|
1318
|
-
background: var(--
|
|
1343
|
+
background: var(--_accent);
|
|
1319
1344
|
transition: width 0.15s ease;
|
|
1320
1345
|
}
|
|
1321
1346
|
|
|
@@ -1337,14 +1362,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1337
1362
|
|
|
1338
1363
|
/* A subtle outline while a file is dragged over the shell. */
|
|
1339
1364
|
.chat--dragover {
|
|
1340
|
-
outline: 2px dashed var(--
|
|
1365
|
+
outline: 2px dashed var(--_accent);
|
|
1341
1366
|
outline-offset: -4px;
|
|
1342
1367
|
}
|
|
1343
1368
|
|
|
1344
1369
|
/* Muted "\u23F9 Stopped" line after a cancelled run \u2014 a note, not an error bubble. */
|
|
1345
1370
|
.stopped-note {
|
|
1346
1371
|
align-self: flex-start;
|
|
1347
|
-
color: var(--
|
|
1372
|
+
color: var(--_muted);
|
|
1348
1373
|
font-size: 12px;
|
|
1349
1374
|
padding: 2px 4px;
|
|
1350
1375
|
}
|
|
@@ -1357,14 +1382,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1357
1382
|
flex-direction: column;
|
|
1358
1383
|
gap: 8px;
|
|
1359
1384
|
padding: 12px;
|
|
1360
|
-
background: var(--
|
|
1361
|
-
border: 1px solid var(--
|
|
1385
|
+
background: var(--_bg);
|
|
1386
|
+
border: 1px solid var(--_accent);
|
|
1362
1387
|
border-radius: 10px;
|
|
1363
1388
|
}
|
|
1364
1389
|
|
|
1365
1390
|
.confirm[data-resolved] {
|
|
1366
1391
|
opacity: 0.7;
|
|
1367
|
-
border-color: var(--
|
|
1392
|
+
border-color: var(--_border);
|
|
1368
1393
|
}
|
|
1369
1394
|
|
|
1370
1395
|
.confirm-body {
|
|
@@ -1378,7 +1403,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1378
1403
|
overflow: auto;
|
|
1379
1404
|
font-size: 12px;
|
|
1380
1405
|
font-family: ui-monospace, "SF Mono", Menlo, monospace;
|
|
1381
|
-
background: var(--
|
|
1406
|
+
background: var(--_assistant-bg);
|
|
1382
1407
|
border-radius: 8px;
|
|
1383
1408
|
white-space: pre-wrap;
|
|
1384
1409
|
word-break: break-word;
|
|
@@ -1391,14 +1416,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1391
1416
|
}
|
|
1392
1417
|
|
|
1393
1418
|
.confirm-btn {
|
|
1394
|
-
border: 1px solid var(--
|
|
1419
|
+
border: 1px solid var(--_border);
|
|
1395
1420
|
border-radius: 8px;
|
|
1396
1421
|
padding: 8px 14px;
|
|
1397
1422
|
font: inherit;
|
|
1398
1423
|
font-weight: 600;
|
|
1399
1424
|
cursor: pointer;
|
|
1400
|
-
background: var(--
|
|
1401
|
-
color: var(--
|
|
1425
|
+
background: var(--_bg);
|
|
1426
|
+
color: var(--_fg);
|
|
1402
1427
|
}
|
|
1403
1428
|
|
|
1404
1429
|
.confirm-btn:disabled {
|
|
@@ -1407,8 +1432,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1407
1432
|
}
|
|
1408
1433
|
|
|
1409
1434
|
.confirm-btn--confirm {
|
|
1410
|
-
border-color: var(--
|
|
1411
|
-
background: var(--
|
|
1435
|
+
border-color: var(--_accent);
|
|
1436
|
+
background: var(--_accent);
|
|
1412
1437
|
color: #ffffff;
|
|
1413
1438
|
}
|
|
1414
1439
|
|
|
@@ -1420,14 +1445,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1420
1445
|
flex-direction: column;
|
|
1421
1446
|
gap: 8px;
|
|
1422
1447
|
padding: 12px;
|
|
1423
|
-
background: var(--
|
|
1424
|
-
border: 1px solid var(--
|
|
1448
|
+
background: var(--_bg);
|
|
1449
|
+
border: 1px solid var(--_accent);
|
|
1425
1450
|
border-radius: 10px;
|
|
1426
1451
|
}
|
|
1427
1452
|
|
|
1428
1453
|
.approval[data-resolved] {
|
|
1429
1454
|
opacity: 0.7;
|
|
1430
|
-
border-color: var(--
|
|
1455
|
+
border-color: var(--_border);
|
|
1431
1456
|
}
|
|
1432
1457
|
|
|
1433
1458
|
.approval-body {
|
|
@@ -1441,14 +1466,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1441
1466
|
}
|
|
1442
1467
|
|
|
1443
1468
|
.approval-btn {
|
|
1444
|
-
border: 1px solid var(--
|
|
1469
|
+
border: 1px solid var(--_border);
|
|
1445
1470
|
border-radius: 8px;
|
|
1446
1471
|
padding: 8px 14px;
|
|
1447
1472
|
font: inherit;
|
|
1448
1473
|
font-weight: 600;
|
|
1449
1474
|
cursor: pointer;
|
|
1450
|
-
background: var(--
|
|
1451
|
-
color: var(--
|
|
1475
|
+
background: var(--_bg);
|
|
1476
|
+
color: var(--_fg);
|
|
1452
1477
|
}
|
|
1453
1478
|
|
|
1454
1479
|
.approval-btn:disabled {
|
|
@@ -1457,8 +1482,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1457
1482
|
}
|
|
1458
1483
|
|
|
1459
1484
|
.approval-btn--approve {
|
|
1460
|
-
border-color: var(--
|
|
1461
|
-
background: var(--
|
|
1485
|
+
border-color: var(--_accent);
|
|
1486
|
+
background: var(--_accent);
|
|
1462
1487
|
color: #ffffff;
|
|
1463
1488
|
}
|
|
1464
1489
|
|
|
@@ -1470,14 +1495,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1470
1495
|
flex-direction: column;
|
|
1471
1496
|
gap: 8px;
|
|
1472
1497
|
padding: 12px;
|
|
1473
|
-
background: var(--
|
|
1474
|
-
border: 1px solid var(--
|
|
1498
|
+
background: var(--_bg);
|
|
1499
|
+
border: 1px solid var(--_accent);
|
|
1475
1500
|
border-radius: 10px;
|
|
1476
1501
|
}
|
|
1477
1502
|
|
|
1478
1503
|
.question[data-resolved] {
|
|
1479
1504
|
opacity: 0.7;
|
|
1480
|
-
border-color: var(--
|
|
1505
|
+
border-color: var(--_border);
|
|
1481
1506
|
}
|
|
1482
1507
|
|
|
1483
1508
|
.question-body {
|
|
@@ -1502,9 +1527,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1502
1527
|
width: 100%;
|
|
1503
1528
|
padding: 8px 10px;
|
|
1504
1529
|
font: inherit;
|
|
1505
|
-
color: var(--
|
|
1506
|
-
background: var(--
|
|
1507
|
-
border: 1px solid var(--
|
|
1530
|
+
color: var(--_fg);
|
|
1531
|
+
background: var(--_bg);
|
|
1532
|
+
border: 1px solid var(--_border);
|
|
1508
1533
|
border-radius: 8px;
|
|
1509
1534
|
}
|
|
1510
1535
|
|
|
@@ -1518,13 +1543,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1518
1543
|
}
|
|
1519
1544
|
|
|
1520
1545
|
.question-btn {
|
|
1521
|
-
border: 1px solid var(--
|
|
1546
|
+
border: 1px solid var(--_accent);
|
|
1522
1547
|
border-radius: 8px;
|
|
1523
1548
|
padding: 8px 14px;
|
|
1524
1549
|
font: inherit;
|
|
1525
1550
|
font-weight: 600;
|
|
1526
1551
|
cursor: pointer;
|
|
1527
|
-
background: var(--
|
|
1552
|
+
background: var(--_accent);
|
|
1528
1553
|
color: #ffffff;
|
|
1529
1554
|
}
|
|
1530
1555
|
|
|
@@ -1542,18 +1567,18 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1542
1567
|
}
|
|
1543
1568
|
|
|
1544
1569
|
.skill-chip {
|
|
1545
|
-
border: 1px solid var(--
|
|
1570
|
+
border: 1px solid var(--_border);
|
|
1546
1571
|
border-radius: 999px;
|
|
1547
1572
|
padding: 4px 12px;
|
|
1548
1573
|
font: inherit;
|
|
1549
1574
|
font-size: 0.9em;
|
|
1550
1575
|
cursor: pointer;
|
|
1551
|
-
background: var(--
|
|
1552
|
-
color: var(--
|
|
1576
|
+
background: var(--_assistant-bg);
|
|
1577
|
+
color: var(--_fg);
|
|
1553
1578
|
}
|
|
1554
1579
|
|
|
1555
1580
|
.skill-chip:hover {
|
|
1556
|
-
border-color: var(--
|
|
1581
|
+
border-color: var(--_accent);
|
|
1557
1582
|
}
|
|
1558
1583
|
|
|
1559
1584
|
.skill-palette {
|
|
@@ -1562,8 +1587,8 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1562
1587
|
flex-direction: column;
|
|
1563
1588
|
max-height: 220px;
|
|
1564
1589
|
overflow: auto;
|
|
1565
|
-
background: var(--
|
|
1566
|
-
border: 1px solid var(--
|
|
1590
|
+
background: var(--_bg);
|
|
1591
|
+
border: 1px solid var(--_border);
|
|
1567
1592
|
border-radius: 8px;
|
|
1568
1593
|
box-shadow: 0 8px 24px rgba(20, 20, 50, 0.16);
|
|
1569
1594
|
}
|
|
@@ -1579,11 +1604,11 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1579
1604
|
font: inherit;
|
|
1580
1605
|
text-align: left;
|
|
1581
1606
|
cursor: pointer;
|
|
1582
|
-
color: var(--
|
|
1607
|
+
color: var(--_fg);
|
|
1583
1608
|
}
|
|
1584
1609
|
|
|
1585
1610
|
.skill-item[aria-selected="true"] {
|
|
1586
|
-
background: var(--
|
|
1611
|
+
background: var(--_assistant-bg);
|
|
1587
1612
|
}
|
|
1588
1613
|
|
|
1589
1614
|
.skill-item-title {
|
|
@@ -1592,7 +1617,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1592
1617
|
|
|
1593
1618
|
.skill-item-desc {
|
|
1594
1619
|
font-size: 0.85em;
|
|
1595
|
-
color: var(--
|
|
1620
|
+
color: var(--_muted);
|
|
1596
1621
|
}
|
|
1597
1622
|
|
|
1598
1623
|
/* The hint sits directly above the composer's top border, so a zero bottom
|
|
@@ -1601,7 +1626,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1601
1626
|
margin: 8px 12px;
|
|
1602
1627
|
font-size: 0.85em;
|
|
1603
1628
|
line-height: 1.4;
|
|
1604
|
-
color: var(--
|
|
1629
|
+
color: var(--_danger);
|
|
1605
1630
|
}
|
|
1606
1631
|
|
|
1607
1632
|
/* Chat-history drawer \u2014 a slide-over within the chat panel. */
|
|
@@ -1625,9 +1650,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1625
1650
|
flex-direction: column;
|
|
1626
1651
|
gap: 0.25rem;
|
|
1627
1652
|
padding: 0.5rem;
|
|
1628
|
-
border: 1px solid var(--
|
|
1653
|
+
border: 1px solid var(--_border);
|
|
1629
1654
|
border-radius: 0.5rem;
|
|
1630
|
-
background: var(--
|
|
1655
|
+
background: var(--_assistant-bg);
|
|
1631
1656
|
box-shadow: 0 6px 24px rgb(0 0 0 / 12%);
|
|
1632
1657
|
max-height: 60%;
|
|
1633
1658
|
overflow-y: auto;
|
|
@@ -1658,7 +1683,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1658
1683
|
}
|
|
1659
1684
|
|
|
1660
1685
|
.checkpoint-row:hover {
|
|
1661
|
-
background: var(--
|
|
1686
|
+
background: var(--_hover);
|
|
1662
1687
|
}
|
|
1663
1688
|
|
|
1664
1689
|
.checkpoint-label {
|
|
@@ -1673,7 +1698,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1673
1698
|
font-size: 0.6875rem;
|
|
1674
1699
|
padding: 0 0.375rem;
|
|
1675
1700
|
border-radius: 999px;
|
|
1676
|
-
background: var(--
|
|
1701
|
+
background: var(--_hover);
|
|
1677
1702
|
opacity: 0.8;
|
|
1678
1703
|
}
|
|
1679
1704
|
|
|
@@ -1682,14 +1707,14 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1682
1707
|
font-size: 0.75rem;
|
|
1683
1708
|
cursor: pointer;
|
|
1684
1709
|
padding: 0.125rem 0.5rem;
|
|
1685
|
-
border: 1px solid var(--
|
|
1710
|
+
border: 1px solid var(--_border);
|
|
1686
1711
|
border-radius: 0.375rem;
|
|
1687
1712
|
background: transparent;
|
|
1688
1713
|
color: inherit;
|
|
1689
1714
|
}
|
|
1690
1715
|
|
|
1691
1716
|
.checkpoint-action:hover {
|
|
1692
|
-
background: var(--
|
|
1717
|
+
background: var(--_hover);
|
|
1693
1718
|
}
|
|
1694
1719
|
|
|
1695
1720
|
.drawer-backdrop {
|
|
@@ -1704,9 +1729,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1704
1729
|
flex-direction: column;
|
|
1705
1730
|
width: min(300px, 85%);
|
|
1706
1731
|
height: 100%;
|
|
1707
|
-
background: var(--
|
|
1708
|
-
border-right: 1px solid var(--
|
|
1709
|
-
box-shadow: var(--
|
|
1732
|
+
background: var(--_bg);
|
|
1733
|
+
border-right: 1px solid var(--_border);
|
|
1734
|
+
box-shadow: var(--_shadow);
|
|
1710
1735
|
overflow: hidden;
|
|
1711
1736
|
}
|
|
1712
1737
|
|
|
@@ -1714,9 +1739,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1714
1739
|
display: flex;
|
|
1715
1740
|
align-items: center;
|
|
1716
1741
|
justify-content: space-between;
|
|
1717
|
-
gap: var(--
|
|
1718
|
-
padding: var(--
|
|
1719
|
-
border-bottom: 1px solid var(--
|
|
1742
|
+
gap: var(--_space);
|
|
1743
|
+
padding: var(--_pad);
|
|
1744
|
+
border-bottom: 1px solid var(--_border);
|
|
1720
1745
|
}
|
|
1721
1746
|
|
|
1722
1747
|
.drawer-title {
|
|
@@ -1724,10 +1749,10 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1724
1749
|
}
|
|
1725
1750
|
|
|
1726
1751
|
.drawer-new {
|
|
1727
|
-
border: 1px solid var(--
|
|
1728
|
-
border-radius: var(--
|
|
1729
|
-
background: var(--
|
|
1730
|
-
color: var(--
|
|
1752
|
+
border: 1px solid var(--_border);
|
|
1753
|
+
border-radius: var(--_radius);
|
|
1754
|
+
background: var(--_bg);
|
|
1755
|
+
color: var(--_accent);
|
|
1731
1756
|
padding: 4px 10px;
|
|
1732
1757
|
font: inherit;
|
|
1733
1758
|
font-size: 0.85em;
|
|
@@ -1741,19 +1766,19 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1741
1766
|
}
|
|
1742
1767
|
|
|
1743
1768
|
.drawer-empty {
|
|
1744
|
-
padding: var(--
|
|
1769
|
+
padding: var(--_pad);
|
|
1745
1770
|
font-size: 0.9em;
|
|
1746
|
-
color: var(--
|
|
1771
|
+
color: var(--_muted);
|
|
1747
1772
|
}
|
|
1748
1773
|
|
|
1749
1774
|
.drawer-row {
|
|
1750
1775
|
display: flex;
|
|
1751
1776
|
align-items: stretch;
|
|
1752
|
-
border-bottom: 1px solid var(--
|
|
1777
|
+
border-bottom: 1px solid var(--_border);
|
|
1753
1778
|
}
|
|
1754
1779
|
|
|
1755
1780
|
.drawer-row--active {
|
|
1756
|
-
background: var(--
|
|
1781
|
+
background: var(--_assistant-bg);
|
|
1757
1782
|
}
|
|
1758
1783
|
|
|
1759
1784
|
.drawer-row-select {
|
|
@@ -1780,12 +1805,12 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1780
1805
|
|
|
1781
1806
|
.drawer-row-time {
|
|
1782
1807
|
font-size: 0.72em;
|
|
1783
|
-
color: var(--
|
|
1808
|
+
color: var(--_muted);
|
|
1784
1809
|
}
|
|
1785
1810
|
|
|
1786
1811
|
.drawer-row-preview {
|
|
1787
1812
|
font-size: 0.8em;
|
|
1788
|
-
color: var(--
|
|
1813
|
+
color: var(--_muted);
|
|
1789
1814
|
overflow: hidden;
|
|
1790
1815
|
white-space: nowrap;
|
|
1791
1816
|
text-overflow: ellipsis;
|
|
@@ -1802,7 +1827,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1802
1827
|
.drawer-row-delete {
|
|
1803
1828
|
border: none;
|
|
1804
1829
|
background: none;
|
|
1805
|
-
color: var(--
|
|
1830
|
+
color: var(--_muted);
|
|
1806
1831
|
font-size: 0.9em;
|
|
1807
1832
|
padding: 4px;
|
|
1808
1833
|
cursor: pointer;
|
|
@@ -1813,10 +1838,10 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1813
1838
|
min-width: 0;
|
|
1814
1839
|
margin: 6px 10px;
|
|
1815
1840
|
padding: 4px 8px;
|
|
1816
|
-
border: 1px solid var(--
|
|
1841
|
+
border: 1px solid var(--_accent);
|
|
1817
1842
|
border-radius: 6px;
|
|
1818
|
-
background: var(--
|
|
1819
|
-
color: var(--
|
|
1843
|
+
background: var(--_input-bg);
|
|
1844
|
+
color: var(--_fg);
|
|
1820
1845
|
font: inherit;
|
|
1821
1846
|
}
|
|
1822
1847
|
|
|
@@ -1829,13 +1854,13 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1829
1854
|
}
|
|
1830
1855
|
|
|
1831
1856
|
.drawer-confirm-label {
|
|
1832
|
-
color: var(--
|
|
1857
|
+
color: var(--_danger);
|
|
1833
1858
|
}
|
|
1834
1859
|
|
|
1835
1860
|
.drawer-confirm-yes {
|
|
1836
1861
|
border: none;
|
|
1837
1862
|
border-radius: 6px;
|
|
1838
|
-
background: var(--
|
|
1863
|
+
background: var(--_danger);
|
|
1839
1864
|
color: #ffffff;
|
|
1840
1865
|
padding: 3px 10px;
|
|
1841
1866
|
font: inherit;
|
|
@@ -1843,7 +1868,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1843
1868
|
}
|
|
1844
1869
|
|
|
1845
1870
|
.drawer-confirm-no {
|
|
1846
|
-
border: 1px solid var(--
|
|
1871
|
+
border: 1px solid var(--_border);
|
|
1847
1872
|
border-radius: 6px;
|
|
1848
1873
|
background: none;
|
|
1849
1874
|
color: inherit;
|
|
@@ -1863,9 +1888,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1863
1888
|
border-right: none;
|
|
1864
1889
|
box-shadow: none;
|
|
1865
1890
|
}
|
|
1866
|
-
`;var bi=class{element;#n;#e;#t;#s;#r=!1;constructor(e=ae){this.#s=e,this.element=document.createElement("div"),this.element.className="thoughts",this.element.setAttribute("part","thoughts"),this.element.setAttribute("data-streaming",""),this.#t=document.createElement("button"),this.#t.type="button",this.#t.className="thoughts-toggle",this.#t.setAttribute("part","thoughts-toggle"),this.#t.setAttribute("aria-expanded","true"),this.#n=document.createElement("span"),this.#n.className="thoughts-label",this.#n.setAttribute("part","thoughts-label"),this.#n.textContent=e.thinking,this.#t.append(this.#n),this.#e=document.createElement("pre"),this.#e.className="thoughts-body",this.#e.setAttribute("part","thoughts-body"),this.#t.addEventListener("click",()=>{this.#a(!this.#r)}),this.element.append(this.#t,this.#e)}stream(e){this.#e.textContent=e}collapse(){this.#r||(this.element.removeAttribute("data-streaming"),this.#n.textContent=this.#s.thoughts,this.#a(!0))}#a(e){this.#r=e,this.#e.hidden=e,this.#t.setAttribute("aria-expanded",String(!e))}};var yi=class{element;#n;#e;#t;#s;#r;#a;#o=[];#i="";#l=null;constructor(e,n=ae){this.#n=e,this.#a=n,this.element=document.createElement("div"),this.element.className="drawer",this.element.setAttribute("part","drawer"),this.element.hidden=!0;let r=document.createElement("div");r.className="drawer-backdrop",r.setAttribute("part","drawer-backdrop"),r.addEventListener("click",()=>this.close()),this.#e=document.createElement("div"),this.#e.className="drawer-panel",this.#e.setAttribute("part","drawer-panel"),this.#e.setAttribute("role","dialog"),this.#e.setAttribute("aria-modal","true"),this.#e.setAttribute("aria-label",n.chatHistory),this.#e.addEventListener("keydown",i=>this.#d(i));let o=document.createElement("div");o.className="drawer-header",o.setAttribute("part","drawer-header"),this.#t=document.createElement("span"),this.#t.className="drawer-title",this.#t.setAttribute("part","drawer-title"),this.#t.textContent=n.chats,this.#s=document.createElement("button"),this.#s.type="button",this.#s.className="drawer-new",this.#s.setAttribute("part","drawer-new"),this.#s.textContent=n.newChat,this.#s.addEventListener("click",()=>{this.close(),this.#n.onNew()}),o.append(this.#t,this.#s),this.#r=document.createElement("div"),this.#r.className="drawer-list",this.#r.setAttribute("part","drawer-list"),this.#e.append(o,this.#r),this.element.append(r,this.#e)}setStrings(e){this.#a=e,this.#e.setAttribute("aria-label",e.chatHistory),this.#t.textContent=e.chats,this.#s.textContent=e.newChat,this.#u()}isOpen(){return!this.element.hidden}open(){this.isOpen()||(this.#l=this.#c(),this.element.hidden=!1,this.#s.focus())}close(){this.isOpen()&&(this.element.hidden=!0,this.#l?.focus(),this.#l=null)}toggle(){this.isOpen()?this.close():this.open()}#c(){return this.element.getRootNode().activeElement}#d(e){if(e.key==="Escape"){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;let n=Array.from(this.#e.querySelectorAll("button, input, [tabindex]")).filter(s=>!s.hidden),r=n[0],o=n[n.length-1],i=this.#c();e.shiftKey&&i===r?(e.preventDefault(),o?.focus()):!e.shiftKey&&i===o&&(e.preventDefault(),r?.focus())}setThreads(e,n){this.#o=e,this.#i=n,this.#u()}#u(){if(this.#r.replaceChildren(),this.#o.length===0){let e=document.createElement("div");e.className="drawer-empty",e.setAttribute("part","drawer-empty"),e.textContent=this.#a.noConversations,this.#r.appendChild(e);return}for(let e of this.#o)this.#r.appendChild(this.#f(e))}#f(e){let n=document.createElement("div");n.className="drawer-row",n.setAttribute("part","drawer-row"),e.threadId===this.#i&&n.classList.add("drawer-row--active");let r=document.createElement("button");r.type="button",r.className="drawer-row-select",r.setAttribute("part","drawer-row-select");let o=document.createElement("span");o.className="drawer-row-title",o.setAttribute("part","drawer-row-title"),o.textContent=e.title;let i=document.createElement("span");i.className="drawer-row-time",i.setAttribute("part","drawer-row-time"),i.textContent=ci(e.updatedAt,void 0,this.#a);let s=document.createElement("span");s.className="drawer-row-preview",s.setAttribute("part","drawer-row-preview"),s.textContent=e.preview,r.append(o,i,s),r.addEventListener("click",()=>{this.close(),this.#n.onSelect(e.threadId)});let a=document.createElement("button");a.type="button",a.className="drawer-row-rename",a.setAttribute("part","drawer-row-rename"),a.title=this.#a.rename,a.setAttribute("aria-label",this.#a.renameConversation),a.textContent="\u270E",a.addEventListener("click",()=>this.#h(n,e));let l=document.createElement("button");l.type="button",l.className="drawer-row-delete",l.setAttribute("part","drawer-row-delete"),l.title=this.#a.delete,l.setAttribute("aria-label",this.#a.deleteConversation),l.textContent="\u{1F5D1}",l.addEventListener("click",()=>this.#k(n,e));let c=document.createElement("div");return c.className="drawer-row-actions",c.setAttribute("part","drawer-row-actions"),c.append(a,l),n.append(r,c),n}#h(e,n){let r=document.createElement("input");r.type="text",r.className="drawer-rename-input",r.setAttribute("part","drawer-rename-input"),r.value=n.title;let o=!1,i=()=>{if(o)return;o=!0;let a=r.value.trim();a===""||a===n.title?this.#u():this.#n.onRename(n.threadId,a)},s=()=>{o||(o=!0,this.#u())};r.addEventListener("keydown",a=>{a.key==="Enter"?(a.preventDefault(),i()):a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),s())}),r.addEventListener("blur",()=>i()),e.replaceChildren(r),r.focus(),r.select()}#k(e,n){let r=document.createElement("div");r.className="drawer-confirm",r.setAttribute("part","drawer-confirm");let o=document.createElement("span");o.className="drawer-confirm-label",o.setAttribute("part","drawer-confirm-label"),o.textContent=this.#a.deletePrompt;let i=document.createElement("button");i.type="button",i.className="drawer-confirm-yes",i.setAttribute("part","drawer-confirm-yes"),i.textContent=this.#a.delete,i.addEventListener("click",()=>this.#n.onDelete(n.threadId));let s=document.createElement("button");s.type="button",s.className="drawer-confirm-no",s.setAttribute("part","drawer-confirm-no"),s.textContent=this.#a.cancel,s.addEventListener("click",()=>this.#u()),r.append(o,i,s),e.replaceChildren(r)}};function Xu(t){return{[pe.PENDING]:t.toolRunning,[pe.DONE]:t.toolDone,[pe.ERROR]:t.toolError,[pe.DECLINED]:t.toolDeclined}}function Cv(t){return{[pe.DONE]:t.resultLabel,[pe.ERROR]:t.errorLabel,[pe.DECLINED]:t.declinedLabel}}function Rv(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}var hr=class{element;#n;#e;#t;#s;#r;#a;#o;#i=!1;constructor(e,n,r,o=ae){this.#o=o,this.element=document.createElement("div"),this.element.className="tool-call",this.element.setAttribute("part","tool-card"),this.element.setAttribute("data-tool-name",e),this.element.setAttribute("data-status",pe.PENDING),this.element.setAttribute("data-expanded","false");let i=document.createElement("div");i.className="tool-call-head",i.setAttribute("part","tool-card-head");let s=document.createElement("span");s.className="tool-call-icon",s.setAttribute("part","tool-card-icon"),s.setAttribute("aria-hidden","true");let a=document.createElement("span");a.className="tool-call-name",a.setAttribute("part","tool-card-name"),a.textContent=r??e,this.#n=document.createElement("span"),this.#n.className="tool-call-status",this.#n.setAttribute("part","tool-card-status"),this.#n.textContent=Xu(o)[pe.PENDING],this.#e=document.createElement("span"),this.#e.className="tool-call-decision",this.#e.setAttribute("part","tool-card-decision"),this.#e.hidden=!0,i.append(s,a,this.#n,this.#e);let l=this.#l("args",o.argumentsLabel);l.body.textContent=JSON.stringify(n,null,2),l.root.hidden=Object.keys(n).length===0;let c=this.#l("result",o.resultLabel);this.#s=c.root,this.#r=c.label,this.#a=c.body,c.root.hidden=!0,this.#t=document.createElement("button"),this.#t.type="button",this.#t.className="tool-call-toggle",this.#t.setAttribute("part","tool-card-toggle"),this.#t.setAttribute("aria-expanded","false"),this.#t.textContent=o.details,this.#t.addEventListener("click",()=>this.#d(!this.#c()));let h=document.createElement("div");h.className="tool-call-body",h.setAttribute("part","tool-card-body"),h.append(l.root,c.root),this.element.append(i,this.#t,h)}recordDecision(e){this.element.setAttribute("data-decision",e),this.#e.textContent=e==="approved"?this.#o.decisionApproved:this.#o.decisionDeclined,this.#e.hidden=!1}get settled(){return this.#i}settle(e,n){this.#i||(this.#i=!0,this.element.setAttribute("data-status",e),this.#n.textContent=Xu(this.#o)[e],this.#r.textContent=Cv(this.#o)[e],this.#a.textContent=Rv(n),this.#s.hidden=!1)}#l(e,n){let r=document.createElement("div");r.className=`tool-call-section tool-call-section--${e}`,r.setAttribute("part",`tool-card-section tool-card-${e}-section`);let o=document.createElement("span");o.className="tool-call-section-label",o.setAttribute("part",`tool-card-section-label tool-card-${e}-label`),o.textContent=n;let i=document.createElement("pre");return i.className=`tool-call-${e}`,i.setAttribute("part",`tool-card-${e}`),r.append(o,i),{root:r,label:o,body:i}}#c(){return this.element.getAttribute("data-expanded")==="true"}#d(e){this.element.setAttribute("data-expanded",String(e)),this.#t.setAttribute("aria-expanded",String(e))}};var xi=class{element;#n;#e;#t;#s="idle";#r=null;#a=null;#o=[];#i=!1;constructor(e){this.#n=e.transcribe,this.#e=e.onText,this.#t=e.strings??ae,this.element=document.createElement("button"),this.element.type="button",this.element.className="voice-btn",this.element.setAttribute("part","voice-button"),this.element.textContent="\u{1F3A4}",this.#h("idle"),this.element.addEventListener("click",()=>{this.toggle()})}async toggle(){if(this.#s==="recording"){this.#c();return}this.#s!=="transcribing"&&await this.#l()}async#l(){let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{this.#f(this.#t.transcriptionFailed);return}this.#a=e,this.#o=[];let n=new MediaRecorder(e);n.addEventListener("dataavailable",r=>{this.#o.push(r.data)}),n.addEventListener("stop",()=>{this.#d(n.mimeType)}),this.#r=n,n.start(),this.#h("recording")}#c(){this.#r?.stop()}dispose(){this.#i=!0,this.#r!==null&&this.#r.state!=="inactive"&&this.#r.stop(),this.#r=null,this.#u()}async#d(e){if(this.#i)return;this.#u(),this.#h("transcribing");let n=new Blob(this.#o,{type:e||"audio/webm"});try{let r=await this.#n(n);this.#h("idle"),r!==""&&this.#e(r)}catch(r){this.#f(r instanceof Error?r.message:this.#t.transcriptionFailed)}finally{this.#r=null}}#u(){for(let e of this.#a?.getTracks()??[])e.stop();this.#a=null}#f(e){this.#u(),this.#r=null,this.#h("idle"),this.element.title=e}#h(e){this.#s=e,this.element.dataset.state=e;let n=this.#k(e);this.element.title=n,this.element.setAttribute("aria-label",n),this.element.setAttribute("aria-pressed",String(e==="recording")),this.element.disabled=e==="transcribing"}#k(e){return e==="recording"?this.#t.stopRecording:e==="transcribing"?this.#t.transcribing:this.#t.recordVoice}};var Ei=class extends Error{constructor(e){super(e),this.name="ConnectionLostError"}},Ln=class{#n;#e;#t;#s;#r;#a;#o;#i=new Set;#l;#c=!1;constructor(e){this.#n=e.agent,this.#e=e.handlers,this.#t=e.getTools??(()=>[]),this.#s=e.getContext??(()=>[]),this.#r=e.executeTool??null,this.#a=e.resolveInterrupts??null,this.#o=e.onPersist??(()=>{}),this.#l=e.connectionLostMessage??"Connection lost";let n=e.onStateChanged;n!==void 0&&this.#n.subscribe({onStateChanged:({state:r})=>{n(r)}})}get state(){return this.#n.state}setState(e){this.#n.setState({...e})}get running(){return this.#n.isRunning}get messages(){return this.#n.messages}async send(e,n=[]){let r={id:Ue(),role:"user",content:e};n.length>0&&(r.attachments=n),this.#n.addMessage(r),this.#o(this.#n.messages),await this.#d()}async resume(){await this.#d()}addToolResult(e,n){this.#n.addMessage({id:Ue(),role:"tool",content:n,toolCallId:e}),this.#o(this.#n.messages)}cancel(){this.#c=!0,this.#n.abortRun()}async#d(){this.#c=!1;try{await this.#f(),this.#c&&this.#u()}catch(e){this.#c||Nv(e)?this.#u():this.#e.onError(e instanceof Error?e.message:String(e))}finally{this.#e.onSettled()}}#u(){this.#o(this.#n.messages),this.#e.onCancelled()}async#f(){let e;for(let n=0;n<Yi;n+=1){if(this.#c)return;let r=[],o={terminal:!1,errored:!1,interrupts:[]},i={tools:this.#t(),context:this.#s()};if(e!==void 0&&(i.resume=e),await this.#n.runAgent(i,this.#h(r,o)),e=void 0,this.#o(this.#n.messages),this.#c)return;if(!o.terminal)throw new Ei(this.#l);if(o.errored)return;if(o.interrupts.length>0){if(this.#a===null)return;let a=await this.#a(o.interrupts);if(this.#c)return;e=nu(o.interrupts,a);continue}if(this.#r===null||r.length===0)return;let s=!1;for(let a of r){let l=await this.#r(a);if(l!==null){if(l.halt===!0)return;this.#n.addMessage({id:Ue(),role:"tool",content:l.content,toolCallId:a.id}),this.#o(this.#n.messages),s=!0}}if(!s)return}}#h(e,n){let r=this.#e,o=this.#i;return{onRunInitialized(){r.onRunStart()},onTextMessageStartEvent({event:i}){o.has(i.messageId)&&console.warn(`<ag-ui-chat>: the server reused message id "${i.messageId}", which was already closed. Its content will be appended to that earlier message rather than starting a new one, and the merged result is what gets persisted. Issue a fresh id per message.`)},onTextMessageContentEvent({textMessageBuffer:i}){r.onTextDelta(i)},onTextMessageEndEvent({event:i,textMessageBuffer:s}){o.add(i.messageId),r.onTextEnd(s)},onToolCallEndEvent({event:i,toolCallName:s,toolCallArgs:a}){let l={id:i.toolCallId,name:s,args:a};e.push(l),r.onToolCall(l)},onToolCallResultEvent({event:i}){r.onToolResult(i.toolCallId,i.content)},onActivitySnapshotEvent({event:i}){r.onActivity(i.activityType,i.content)},onReasoningStartEvent(){r.onReasoningStart()},onReasoningMessageContentEvent({reasoningMessageBuffer:i}){r.onReasoningDelta(i)},onReasoningEndEvent(){r.onReasoningEnd()},onRunFinishedEvent(i){n.terminal=!0,i.outcome==="interrupt"&&(n.interrupts=i.interrupts)},onRunErrorEvent({event:i}){n.terminal=!0,n.errored=!0,r.onError(i.message)},onRunFinalized(){n.terminal=!0,r.onRunEnd()}}}};function Nv(t){return t instanceof Error&&t.name==="AbortError"}function ka(t){let e=t.attachments;return Array.isArray(e)?e.filter(Ov):[]}function Ov(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.id=="string"&&typeof e.name=="string"&&typeof e.mime=="string"&&typeof e.size=="number"&&(e.url===void 0||typeof e.url=="string")}var Ia="ag-ui-chat",fr="thread",Ca="threads",Ti="messages:",wi="checkpoint:",Mv=60,Lv=100,Pv="New conversation",ft=class{#n;constructor(e=""){this.#n=e===""?Ia:`${Ia}@${e}`,e!==""&&this.#a()}threadId(){let e=this.#r(fr),n=sessionStorage.getItem(e);if(n!==null)return n;let r=Ue();return sessionStorage.setItem(e,r),r}loadMessages(e){return Promise.resolve(this.#o(this.#r(Ti+e)))}saveMessages(e,n){sessionStorage.setItem(this.#r(Ti+e),JSON.stringify(n)),this.#e(e,n)}loadCheckpoint(e){return this.#o(this.#r(wi+e))}saveCheckpoint(e,n){let r=this.#r(wi+e);if(n===null){sessionStorage.removeItem(r);return}sessionStorage.setItem(r,JSON.stringify(n))}clear(e){sessionStorage.removeItem(this.#r(Ti+e)),sessionStorage.removeItem(this.#r(wi+e)),this.#s(this.#t().filter(n=>n.threadId!==e)),sessionStorage.getItem(this.#r(fr))===e&&sessionStorage.removeItem(this.#r(fr))}listThreads(){let e=this.#t().sort((n,r)=>r.updatedAt-n.updatedAt).map(({threadId:n,title:r,updatedAt:o,preview:i})=>({threadId:n,title:r,updatedAt:o,preview:i}));return Promise.resolve(e)}setActiveThread(e){sessionStorage.setItem(this.#r(fr),e)}renameThread(e,n){let r=this.#t(),o=r.find(i=>i.threadId===e);o!==void 0&&(o.title=n,o.titleCustom=!0,this.#s(r))}#e(e,n){let r=this.#t(),o=r.find(a=>a.threadId===e),i=Uv(n),s=Date.now();o===void 0?r.push({threadId:e,title:Yu(n),titleCustom:!1,preview:i,updatedAt:s}):(o.preview=i,o.updatedAt=s,o.titleCustom||(o.title=Yu(n))),this.#s(r)}#t(){return this.#o(this.#r(Ca))??[]}#s(e){let n=this.#r(Ca);if(e.length===0){sessionStorage.removeItem(n);return}sessionStorage.setItem(n,JSON.stringify(e))}#r(e){return`${this.#n}:${e}`}#a(){let e=`${Ia}:`,n=[];for(let r=0;r<sessionStorage.length;r+=1){let o=sessionStorage.key(r);if(o===null||!o.startsWith(e))continue;let i=o.slice(e.length);Dv(i)&&n.push([o,this.#r(i)])}for(let[r,o]of n){let i=sessionStorage.getItem(r);i!==null&&sessionStorage.getItem(o)===null&&sessionStorage.setItem(o,i),sessionStorage.removeItem(r)}}#o(e){let n=sessionStorage.getItem(e);if(n===null)return null;try{return JSON.parse(n)}catch{return null}}};function Dv(t){return t===fr||t===Ca||t.startsWith(Ti)||t.startsWith(wi)}function Yu(t){for(let e of t)if(e.role==="user"){let n=Ku(e.content);if(n!=="")return Zu(n,Mv)}return Pv}function Uv(t){for(let e of[...t].reverse()){let n=Ku(e.content);if(n!=="")return Zu(n,Lv)}return""}function Ku(t){return typeof t=="string"?t.replace(/\s+/g," ").trim():""}function Zu(t,e){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}\u2026`}function Ra(t){return new ru({url:t.endpoint,headers:t.headers??{},initialState:{...t.initialState??{}},fetch:(e,n)=>{let r=t.getHeaders?.();if(r===void 0)return fetch(e,n);let o=new Headers(n?.headers);for(let[i,s]of Object.entries(r))o.set(i,s);return fetch(e,{...n,headers:o})},...t.threadId!==void 0?{threadId:t.threadId}:{},...t.initialMessages!==void 0?{initialMessages:[...t.initialMessages]}:{}})}var mr=class{#n;#e;#t;#s=new Set;#r=new Map;constructor(e,n=()=>({}),r=new ft){this.#n=e.endsWith("/")?e:`${e}/`,this.#e=n,this.#t=r}threadId(){return this.#t.threadId()}setActiveThread(e){this.#t.setActiveThread(e)}saveMessages(e,n){this.#t.saveMessages(e,n)}loadCheckpoint(e){return this.#t.loadCheckpoint(e)}saveCheckpoint(e,n){this.#t.saveCheckpoint(e,n)}renameThread(e,n){this.#t.renameThread(e,n),this.#r.set(e,n),this.#c(e,"PATCH",{title:n})}clear(e){this.#t.clear(e),this.#s.add(e),this.#c(e,"DELETE")}async listThreads(){let e=await this.#a();return e===null?this.#t.listThreads():e.filter(n=>!this.#s.has(n.thread_id)).map(n=>this.#i(n))}async loadMessages(e){let n=await this.#l(`${this.#n}${encodeURIComponent(e)}/`);if(n===null||!n.ok)return this.#t.loadMessages(e);let r=await this.#o(n);return r===null?this.#t.loadMessages(e):r.messages??null}async#a(){let e=await this.#l(this.#n);if(e===null||!e.ok)return null;let n=await this.#o(e);return n===null?null:n.threads??[]}async#o(e){try{return await e.json()}catch{return null}}#i(e){return{threadId:e.thread_id,title:this.#r.get(e.thread_id)??e.title,updatedAt:e.updated_at===null?Number.NaN:Date.parse(e.updated_at),preview:e.preview}}async#l(e){try{return await fetch(e,{headers:this.#e()})}catch{return null}}async#c(e,n,r){let o=this.#e();try{await fetch(`${this.#n}${encodeURIComponent(e)}/`,{method:n,headers:r===void 0?o:{...o,"content-type":"application/json"},body:r===void 0?null:JSON.stringify(r)})}catch{}}};var gr=class{#n;#e;constructor(e,n=()=>({})){this.#n=e.endsWith("/")?e:`${e}/`,this.#e=n}async list(){try{let e=await fetch(this.#n,{method:"GET",headers:{Accept:"application/json",...this.#e()}});return e.ok?(await e.json()).runs??[]:[]}catch{return[]}}async continuable(){return(await this.list()).filter(e=>e.continuable)}resumeUrl(e){return this.#t("resume",e)}forkUrl(e){return this.#t("fork",e)}#t(e,n){return`${this.#n.slice(0,-5)}${e}/${encodeURIComponent(n)}/`}};async function Na(t,e){let n=new FormData;n.append("audio",t,"recording.webm");let r=await fetch(e.url,{method:"POST",headers:{...e.headers??{}},body:n});if(!r.ok)throw new Error(await Hv(r));let o=await r.json();if(typeof o=="object"&&o!==null&&typeof o.text=="string")return o.text;throw new Error("transcription returned an unreadable response")}async function Hv(t){try{let e=await t.json();if(typeof e.error=="string")return e.error}catch{}return`transcription failed (${t.status})`}function Oa(t,e){return new Promise((n,r)=>{let o=new FormData;o.append("file",t);let i=new XMLHttpRequest;i.open("POST",e.url);for(let[l,c]of Object.entries(e.headers??{}))i.setRequestHeader(l,c);let s=e.onProgress;s!==void 0&&i.upload.addEventListener("progress",l=>{l.lengthComputable&&s(l.total===0?0:l.loaded/l.total)}),i.addEventListener("load",()=>{if(i.status>=200&&i.status<300)try{n(Gv(JSON.parse(i.responseText)))}catch{r(new Error("upload returned an unreadable response"))}else r(new Error(zv(i)))}),i.addEventListener("error",()=>r(new Error("upload failed"))),i.addEventListener("abort",()=>r(new Error("upload cancelled")));let a=e.signal;a!==void 0&&a.addEventListener("abort",()=>i.abort()),i.send(o)})}function Gv(t){if(typeof t!="object"||t===null)throw new Error("not an object");let e=t,n=e.id,r=e.name,o=e.mime,i=e.size,s=e.url;if(typeof n!="string"||typeof r!="string"||typeof o!="string"||typeof i!="number")throw new Error("missing fields");return typeof s=="string"?{id:n,name:r,mime:o,size:i,url:s}:{id:n,name:r,mime:o,size:i}}function zv(t){try{let e=JSON.parse(t.responseText);if(typeof e.error=="string")return e.error}catch{}return`upload failed (${t.status})`}var Fv=["data-attachments-url","data-attachment-accept","data-attachment-max-bytes","data-transcribe-url","data-threads-url","data-tools-url","data-skills-url","data-skills","data-prompt-chips","data-slash-commands","data-theme-toggle","data-strings","data-icon-url"],Ju="ag-ui-chat:collapsed",Qu="ag-ui-chat:size",ed="ag-ui-chat:theme",vr=class extends HTMLElement{agentFactory=Ra;headers={};allowImages=!1;autoConfirm=!1;askUser=!1;askUserRenderer=null;approvalRenderer=null;confirmPredicate=null;getTools=()=>[...this.#le().map(e=>({name:e.name,description:e.description,parameters:e.parameters})),...this.#t.tools()];getContext=()=>[...us(this.getPageMap,this.autoInjectPageMap),...this.#Ve()];routeMap=[];navigate=null;getPageMap=null;autoInjectPageMap=!0;conversationStore=new ft;uploadHandler=null;transcribeHandler=null;navigationResult=()=>({navigated:!0,url:window.location.href});skillContext=()=>({});toolSummaries={};strings={};resolvePageTarget=e=>document.querySelector(e);#n={};#e=ae;#t=new $n;#s=new Map;#r=new Set;#a;#o;#i;#l;#c;#d;#u;#f;#h;#k=null;#y;#v;#b;#H;#S;#_;#I;#m=null;#G;#q=null;#z=!1;#L=[];#C=null;#N={};#P=!1;#W=null;#x=null;#E=null;#X=0;#F=null;#A=null;#R=null;#p="";#O="";#Y=0;#K=[];#ie=[];#se=[];#ae=[];constructor(){super(),this.#a=this.attachShadow({mode:"open"}),this.#o=document.createElement("div"),this.#i=document.createElement("div"),this.#l=document.createElement("textarea"),this.#c=document.createElement("button"),this.#d=document.createElement("span"),this.#y=document.createElement("div"),this.#v=document.createElement("button"),this.#b=document.createElement("input"),this.#H=document.createElement("div"),this.#G=document.createElement("span"),this.#S=document.createElement("button"),this.#_=document.createElement("button"),this.#I=document.createElement("div"),this.#u=new vi(e=>this.#Ke(e)),this.#f=new yi({onSelect:e=>{this.#et(e)},onNew:()=>{this.newChat(),this.#B()},onRename:(e,n)=>{this.conversationStore.renameThread(e,n),this.#B()},onDelete:e=>{this.#tt(e)}}),this.#h=new ir((e,n)=>{this.#Ie(e,n)})}#Z(){let e=this.getAttribute("data-runs-url");return e===null||e===""?null:(this.#k===null&&(this.#k=new gr(e,()=>this.headers)),this.#k)}async#Ie(e,n){let r=this.#Z();if(r===null)return;let o=this.#l.value.trim();if(o==="")return;this.#l.value="";let i=n==="resume"?r.resumeUrl(e):r.forkUrl(e),s=this.agentFactory({endpoint:i,headers:this.headers,getHeaders:()=>this.headers,threadId:this.#p,initialMessages:[]});await new Ln({agent:s,handlers:this.#Se(),getTools:()=>this.getTools(),getContext:()=>this.#ge(),executeTool:l=>this.#Te(l),resolveInterrupts:l=>this.#we(l),connectionLostMessage:this.#e.connectionLost}).send(o)}async#Ce(){let e=this.#Z();this.#h.setRuns(e===null?[]:await e.continuable())}static get observedAttributes(){return["title-text","placement",...Fv]}attributeChangedCallback(e,n,r){if(e==="placement"){requestAnimationFrame(()=>this.#Q());return}if(e==="title-text"){this.#d.textContent=r??this.#e.title;return}n===r||!this.#z||console.warn(`<ag-ui-chat>: "${e}" was changed after the element connected, and is read only while connecting \u2014 this assignment has no effect. Set it before the element enters the DOM (in the markup, or on the element before appending it); frameworks that patch attributes after mount should bind it at creation. To apply a new value now, remove and re-insert the element.`)}registerTool(e){this.#t.register(e)}get sharedState(){return this.#C?.state??this.#N}set sharedState(e){this.#N={...e},this.#C?.setState(this.#N)}registerPageState(e){for(let n of Lr(e))this.#t.register(n)}registerStateHook(e){this.registerPageState(e)}#Re(){return this.routeMap.length===0?[]:ps(()=>this.routeMap,()=>this.navigate)}#Ne(){let e=this.getPageMap;return e===null?[]:[{name:Xi,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:[],[Le]:"Read the page"},handler:()=>e()}]}#Oe(){let e=this.getAttribute("data-page-actions");if(e===null)return[];let n=new Set(e.split(",").map(r=>r.trim()).filter(r=>r!==""));return cs(n,r=>this.resolvePageTarget(r))}#le(){return[...this.#Re(),...this.#Ne(),...this.#Oe(),...this.#Me()]}#Me(){return this.askUser?[{name:"ask_user",description:"Ask the user a question and wait for their answer. Provide `options` for a multiple-choice prompt; set `allow_custom` to also accept a free-text answer.",parameters:{type:"object",properties:{question:{type:"string",description:"The question to ask the user."},options:{type:"array",items:{type:"string"},description:"Preset choices offered as radio buttons."},allow_custom:{type:"boolean",description:"Allow a free-text answer in addition to any options."}},required:["question"]},handler:e=>this.#Le(e)}]:[]}async#Le(e){let r={question:typeof e.question=="string"?e.question:""},o=e.options;Array.isArray(o)&&(r.options=o.filter(a=>typeof a=="string")),e.allow_custom===!0&&(r.allowCustom=!0),this.#x=new AbortController;let i=this.#x.signal;this.#w();let s=this.askUserRenderer!==null?await this.askUserRenderer(r,{signal:i}):await aa(this.#T(),r,{signal:i,strings:this.#e});return this.#x=null,this.#g(),this.#i.scrollTop=this.#i.scrollHeight,s}#ce(e){let n=this.#le().find(r=>r.name===e);return n!==void 0?n:this.#t.has(e)?this.#t.get(e):null}get endpoint(){return this.getAttribute("endpoint")??""}set endpoint(e){this.setAttribute("endpoint",e)}get toolDisplay(){let e=this.getAttribute("data-tool-display");return e===dn.INLINE||e===dn.MINIMAL||e===dn.COMPACT?e:dn.FULL}set toolDisplay(e){this.setAttribute("data-tool-display",e)}connectedCallback(){if(this.#O=this.id!==""?this.id:this.endpoint,this.#ee(this.#he()),requestAnimationFrame(()=>this.#Q()),this.#e=hs({...this.#Pe(),...this.strings}),this.getAttribute("data-theme-toggle")!==null){let e=this.#te(ed);e!==null&&this.setAttribute("theme",e)}this.#at(),this.#f.setStrings(this.#e),this.#h.setStrings(this.#e),this.#te(Ju)==="1"&&this.setAttribute("collapsed",""),this.#ye(),this.#We(),this.#qe(),this.#O!==""&&this.conversationStore instanceof ft&&(this.conversationStore=new ft(this.#O)),this.#je(),this.#De(),this.#He(),this.#p=this.conversationStore.threadId(),this.#me(),this.#z=!0}disconnectedCallback(){this.#z=!1,this.#M(),this.#m?.dispose(),this.#q?.dispose()}#ue(e){let n=this.getAttribute(e);return n!==null&&n!=="false"}#Pe(){let e=this.getAttribute("data-strings");if(e===null)return{};try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#De(){let e=this.getAttribute("data-attachments-url"),n=this.uploadHandler??this.#Ue(e);if(n===null)return;let r=this.getAttribute("data-attachment-accept")??"",o=new li({upload:n,maxBytes:this.#Fe(),accept:r,strings:this.#e,onChange:()=>this.#ct(o)});this.#m=o,this.#H.appendChild(this.#m.element),this.#b.accept=r,this.#v.hidden=!1,this.#Be()}#Ue(e){return e===null?null:(n,r,o)=>Oa(n,{url:e,headers:this.headers,onProgress:r,signal:o})}#He(){let e=this.getAttribute("data-transcribe-url"),n=this.transcribeHandler??this.#Ge(e);n!==null&&(this.#q=new xi({transcribe:n,onText:r=>this.#ze(r),strings:this.#e}),this.#G.appendChild(this.#q.element))}#Ge(e){return e===null?null:n=>Na(n,{url:e,headers:this.headers})}#ze(e){let n=this.#l.value.trim();this.#l.value=n===""?e:`${n} ${e}`,this.#xe(),this.#l.focus()}#Fe(){let e=this.getAttribute("data-attachment-max-bytes");if(e===null)return Ki;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:Ki}#$e(){let e=this.#b.files;if(e!==null)for(let n of Array.from(e))this.#m?.add(n);this.#b.value=""}#Be(){this.#o.addEventListener("dragover",e=>{e.preventDefault(),this.#o.classList.add("chat--dragover")}),this.#o.addEventListener("dragleave",()=>{this.#o.classList.remove("chat--dragover")}),this.#o.addEventListener("drop",e=>{e.preventDefault(),this.#o.classList.remove("chat--dragover");let n=e.dataTransfer?.files;if(n!==void 0)for(let r of Array.from(n))this.#m?.add(r)})}#Ve(){return this.#L.length===0?[]:[{description:"Files the user attached to this message",value:`${this.#L.map(n=>`- ${n.name} (id: ${n.id}, ${n.mime||"unknown type"}, ${n.size} bytes)`).join(`
|
|
1891
|
+
`;var Ei=class{element;#n;#e;#t;#s;#r=!1;constructor(e=ae){this.#s=e,this.element=document.createElement("div"),this.element.className="thoughts",this.element.setAttribute("part","thoughts"),this.element.setAttribute("data-streaming",""),this.#t=document.createElement("button"),this.#t.type="button",this.#t.className="thoughts-toggle",this.#t.setAttribute("part","thoughts-toggle"),this.#t.setAttribute("aria-expanded","true"),this.#n=document.createElement("span"),this.#n.className="thoughts-label",this.#n.setAttribute("part","thoughts-label"),this.#n.textContent=e.thinking,this.#t.append(this.#n),this.#e=document.createElement("pre"),this.#e.className="thoughts-body",this.#e.setAttribute("part","thoughts-body"),this.#t.addEventListener("click",()=>{this.#a(!this.#r)}),this.element.append(this.#t,this.#e)}stream(e){this.#e.textContent=e}collapse(){this.#r||(this.element.removeAttribute("data-streaming"),this.#n.textContent=this.#s.thoughts,this.#a(!0))}#a(e){this.#r=e,this.#e.hidden=e,this.#t.setAttribute("aria-expanded",String(!e))}};var _i=class{element;#n;#e;#t;#s;#r;#a;#i=[];#o="";#l=null;constructor(e,n=ae){this.#n=e,this.#a=n,this.element=document.createElement("div"),this.element.className="drawer",this.element.setAttribute("part","drawer"),this.element.hidden=!0;let r=document.createElement("div");r.className="drawer-backdrop",r.setAttribute("part","drawer-backdrop"),r.addEventListener("click",()=>this.close()),this.#e=document.createElement("div"),this.#e.className="drawer-panel",this.#e.setAttribute("part","drawer-panel"),this.#e.setAttribute("role","dialog"),this.#e.setAttribute("aria-modal","true"),this.#e.setAttribute("aria-label",n.chatHistory),this.#e.addEventListener("keydown",i=>this.#d(i));let o=document.createElement("div");o.className="drawer-header",o.setAttribute("part","drawer-header"),this.#t=document.createElement("span"),this.#t.className="drawer-title",this.#t.setAttribute("part","drawer-title"),this.#t.textContent=n.chats,this.#s=document.createElement("button"),this.#s.type="button",this.#s.className="drawer-new",this.#s.setAttribute("part","drawer-new"),this.#s.textContent=n.newChat,this.#s.addEventListener("click",()=>{this.close(),this.#n.onNew()}),o.append(this.#t,this.#s),this.#r=document.createElement("div"),this.#r.className="drawer-list",this.#r.setAttribute("part","drawer-list"),this.#e.append(o,this.#r),this.element.append(r,this.#e)}setStrings(e){this.#a=e,this.#e.setAttribute("aria-label",e.chatHistory),this.#t.textContent=e.chats,this.#s.textContent=e.newChat,this.#u()}isOpen(){return!this.element.hidden}open(){this.isOpen()||(this.#l=this.#c(),this.element.hidden=!1,this.#s.focus())}close(){this.isOpen()&&(this.element.hidden=!0,this.#l?.focus(),this.#l=null)}toggle(){this.isOpen()?this.close():this.open()}#c(){return this.element.getRootNode().activeElement}#d(e){if(e.key==="Escape"){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;let n=Array.from(this.#e.querySelectorAll("button, input, [tabindex]")).filter(s=>!s.hidden),r=n[0],o=n[n.length-1],i=this.#c();e.shiftKey&&i===r?(e.preventDefault(),o?.focus()):!e.shiftKey&&i===o&&(e.preventDefault(),r?.focus())}setThreads(e,n){this.#i=e,this.#o=n,this.#u()}#u(){if(this.#r.replaceChildren(),this.#i.length===0){let e=document.createElement("div");e.className="drawer-empty",e.setAttribute("part","drawer-empty"),e.textContent=this.#a.noConversations,this.#r.appendChild(e);return}for(let e of this.#i)this.#r.appendChild(this.#f(e))}#f(e){let n=document.createElement("div");n.className="drawer-row",n.setAttribute("part","drawer-row"),e.threadId===this.#o&&n.classList.add("drawer-row--active");let r=document.createElement("button");r.type="button",r.className="drawer-row-select",r.setAttribute("part","drawer-row-select");let o=document.createElement("span");o.className="drawer-row-title",o.setAttribute("part","drawer-row-title"),o.textContent=e.title;let i=document.createElement("span");i.className="drawer-row-time",i.setAttribute("part","drawer-row-time"),i.textContent=pi(e.updatedAt,void 0,this.#a);let s=document.createElement("span");s.className="drawer-row-preview",s.setAttribute("part","drawer-row-preview"),s.textContent=e.preview,r.append(o,i,s),r.addEventListener("click",()=>{this.close(),this.#n.onSelect(e.threadId)});let a=document.createElement("button");a.type="button",a.className="drawer-row-rename",a.setAttribute("part","drawer-row-rename"),a.title=this.#a.rename,a.setAttribute("aria-label",this.#a.renameConversation),a.textContent="\u270E",a.addEventListener("click",()=>this.#h(n,e));let l=document.createElement("button");l.type="button",l.className="drawer-row-delete",l.setAttribute("part","drawer-row-delete"),l.title=this.#a.delete,l.setAttribute("aria-label",this.#a.deleteConversation),l.textContent="\u{1F5D1}",l.addEventListener("click",()=>this.#C(n,e));let c=document.createElement("div");return c.className="drawer-row-actions",c.setAttribute("part","drawer-row-actions"),c.append(a,l),n.append(r,c),n}#h(e,n){let r=document.createElement("input");r.type="text",r.className="drawer-rename-input",r.setAttribute("part","drawer-rename-input"),r.value=n.title;let o=!1,i=()=>{if(o)return;o=!0;let a=r.value.trim();a===""||a===n.title?this.#u():this.#n.onRename(n.threadId,a)},s=()=>{o||(o=!0,this.#u())};r.addEventListener("keydown",a=>{a.key==="Enter"?(a.preventDefault(),i()):a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),s())}),r.addEventListener("blur",()=>i()),e.replaceChildren(r),r.focus(),r.select()}#C(e,n){let r=document.createElement("div");r.className="drawer-confirm",r.setAttribute("part","drawer-confirm");let o=document.createElement("span");o.className="drawer-confirm-label",o.setAttribute("part","drawer-confirm-label"),o.textContent=this.#a.deletePrompt;let i=document.createElement("button");i.type="button",i.className="drawer-confirm-yes",i.setAttribute("part","drawer-confirm-yes"),i.textContent=this.#a.delete,i.addEventListener("click",()=>this.#n.onDelete(n.threadId));let s=document.createElement("button");s.type="button",s.className="drawer-confirm-no",s.setAttribute("part","drawer-confirm-no"),s.textContent=this.#a.cancel,s.addEventListener("click",()=>this.#u()),r.append(o,i,s),e.replaceChildren(r)}};function Qu(t){return{[pe.PENDING]:t.toolRunning,[pe.DONE]:t.toolDone,[pe.ERROR]:t.toolError,[pe.DECLINED]:t.toolDeclined}}function Fv(t){return{[pe.DONE]:t.resultLabel,[pe.ERROR]:t.errorLabel,[pe.DECLINED]:t.declinedLabel}}function $v(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}var mr=class{element;#n;#e;#t;#s;#r;#a;#i;#o=!1;constructor(e,n,r,o=ae){this.#i=o,this.element=document.createElement("div"),this.element.className="tool-call",this.element.setAttribute("part","tool-card"),this.element.setAttribute("data-tool-name",e),this.element.setAttribute("data-status",pe.PENDING),this.element.setAttribute("data-expanded","false");let i=document.createElement("div");i.className="tool-call-head",i.setAttribute("part","tool-card-head");let s=document.createElement("span");s.className="tool-call-icon",s.setAttribute("part","tool-card-icon"),s.setAttribute("aria-hidden","true");let a=document.createElement("span");a.className="tool-call-name",a.setAttribute("part","tool-card-name"),a.textContent=r??e,this.#n=document.createElement("span"),this.#n.className="tool-call-status",this.#n.setAttribute("part","tool-card-status"),this.#n.textContent=Qu(o)[pe.PENDING],this.#e=document.createElement("span"),this.#e.className="tool-call-decision",this.#e.setAttribute("part","tool-card-decision"),this.#e.hidden=!0,i.append(s,a,this.#n,this.#e);let l=this.#l("args",o.argumentsLabel);l.body.textContent=JSON.stringify(n,null,2),l.root.hidden=Object.keys(n).length===0;let c=this.#l("result",o.resultLabel);this.#s=c.root,this.#r=c.label,this.#a=c.body,c.root.hidden=!0,this.#t=document.createElement("button"),this.#t.type="button",this.#t.className="tool-call-toggle",this.#t.setAttribute("part","tool-card-toggle"),this.#t.setAttribute("aria-expanded","false"),this.#t.textContent=o.details,this.#t.addEventListener("click",()=>this.#d(!this.#c()));let h=document.createElement("div");h.className="tool-call-body",h.setAttribute("part","tool-card-body"),h.append(l.root,c.root),this.element.append(i,this.#t,h)}recordDecision(e){this.element.setAttribute("data-decision",e),this.#e.textContent=e==="approved"?this.#i.decisionApproved:this.#i.decisionDeclined,this.#e.hidden=!1}get settled(){return this.#o}settle(e,n){this.#o||(this.#o=!0,this.element.setAttribute("data-status",e),this.#n.textContent=Qu(this.#i)[e],this.#r.textContent=Fv(this.#i)[e],this.#a.textContent=$v(n),this.#s.hidden=!1)}#l(e,n){let r=document.createElement("div");r.className=`tool-call-section tool-call-section--${e}`,r.setAttribute("part",`tool-card-section tool-card-${e}-section`);let o=document.createElement("span");o.className="tool-call-section-label",o.setAttribute("part",`tool-card-section-label tool-card-${e}-label`),o.textContent=n;let i=document.createElement("pre");return i.className=`tool-call-${e}`,i.setAttribute("part",`tool-card-${e}`),r.append(o,i),{root:r,label:o,body:i}}#c(){return this.element.getAttribute("data-expanded")==="true"}#d(e){this.element.setAttribute("data-expanded",String(e)),this.#t.setAttribute("aria-expanded",String(e))}};var Ti=class{element;#n;#e;#t;#s="idle";#r=null;#a=null;#i=[];#o=!1;constructor(e){this.#n=e.transcribe,this.#e=e.onText,this.#t=e.strings??ae,this.element=document.createElement("button"),this.element.type="button",this.element.className="voice-btn",this.element.setAttribute("part","voice-button"),this.element.textContent="\u{1F3A4}",this.#h("idle"),this.element.addEventListener("click",()=>{this.toggle()})}async toggle(){if(this.#s==="recording"){this.#c();return}this.#s!=="transcribing"&&await this.#l()}async#l(){let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{this.#f(this.#t.transcriptionFailed);return}this.#a=e,this.#i=[];let n=new MediaRecorder(e);n.addEventListener("dataavailable",r=>{this.#i.push(r.data)}),n.addEventListener("stop",()=>{this.#d(n.mimeType)}),this.#r=n,n.start(),this.#h("recording")}#c(){this.#r?.stop()}dispose(){this.#o=!0,this.#r!==null&&this.#r.state!=="inactive"&&this.#r.stop(),this.#r=null,this.#u()}async#d(e){if(this.#o)return;this.#u(),this.#h("transcribing");let n=new Blob(this.#i,{type:e||"audio/webm"});try{let r=await this.#n(n);this.#h("idle"),r!==""&&this.#e(r)}catch(r){this.#f(r instanceof Error?r.message:this.#t.transcriptionFailed)}finally{this.#r=null}}#u(){for(let e of this.#a?.getTracks()??[])e.stop();this.#a=null}#f(e){this.#u(),this.#r=null,this.#h("idle"),this.element.title=e}#h(e){this.#s=e,this.element.dataset.state=e;let n=this.#C(e);this.element.title=n,this.element.setAttribute("aria-label",n),this.element.setAttribute("aria-pressed",String(e==="recording")),this.element.disabled=e==="transcribing"}#C(e){return e==="recording"?this.#t.stopRecording:e==="transcribing"?this.#t.transcribing:this.#t.recordVoice}};var wi=class extends Error{constructor(e){super(e),this.name="ConnectionLostError"}},Pn=class{#n;#e;#t;#s;#r;#a;#i;#o=new Set;#l;#c=!1;constructor(e){this.#n=e.agent,this.#e=e.handlers,this.#t=e.getTools??(()=>[]),this.#s=e.getContext??(()=>[]),this.#r=e.executeTool??null,this.#a=e.resolveInterrupts??null,this.#i=e.onPersist??(()=>{}),this.#l=e.connectionLostMessage??"Connection lost";let n=e.onStateChanged;n!==void 0&&this.#n.subscribe({onStateChanged:({state:r})=>{n(r)}})}get state(){return this.#n.state}setState(e){this.#n.setState({...e})}get running(){return this.#n.isRunning}get messages(){return this.#n.messages}async send(e,n=[]){let r={id:Ue(),role:"user",content:e};n.length>0&&(r.attachments=n),this.#n.addMessage(r),this.#i(this.#n.messages),await this.#d()}async resume(){await this.#d()}addToolResult(e,n){this.#n.addMessage({id:Ue(),role:"tool",content:n,toolCallId:e}),this.#i(this.#n.messages)}cancel(){this.#c=!0,this.#n.abortRun()}async#d(){this.#c=!1;try{await this.#f(),this.#c&&this.#u()}catch(e){this.#c||Bv(e)?this.#u():this.#e.onError(e instanceof Error?e.message:String(e))}finally{this.#e.onSettled()}}#u(){this.#i(this.#n.messages),this.#e.onCancelled()}async#f(){let e;for(let n=0;n<Ji;n+=1){if(this.#c)return;let r=[],o={terminal:!1,errored:!1,interrupts:[]},i={tools:this.#t(),context:this.#s()};if(e!==void 0&&(i.resume=e),await this.#n.runAgent(i,this.#h(r,o)),e=void 0,this.#i(this.#n.messages),this.#c)return;if(!o.terminal)throw new wi(this.#l);if(o.errored)return;if(o.interrupts.length>0){if(this.#a===null)return;let a=await this.#a(o.interrupts);if(this.#c)return;e=au(o.interrupts,a);continue}if(this.#r===null||r.length===0)return;let s=!1;for(let a of r){let l=await this.#r(a);if(l!==null){if(l.halt===!0)return;this.#n.addMessage({id:Ue(),role:"tool",content:l.content,toolCallId:a.id}),this.#i(this.#n.messages),s=!0}}if(!s)return}}#h(e,n){let r=this.#e,o=this.#o;return{onRunInitialized(){r.onRunStart()},onTextMessageStartEvent({event:i}){o.has(i.messageId)&&console.warn(`<ag-ui-chat>: the server reused message id "${i.messageId}", which was already closed. Its content will be appended to that earlier message rather than starting a new one, and the merged result is what gets persisted. Issue a fresh id per message.`)},onTextMessageContentEvent({textMessageBuffer:i}){r.onTextDelta(i)},onTextMessageEndEvent({event:i,textMessageBuffer:s}){o.add(i.messageId),r.onTextEnd(s)},onToolCallEndEvent({event:i,toolCallName:s,toolCallArgs:a}){let l={id:i.toolCallId,name:s,args:a};e.push(l),r.onToolCall(l)},onToolCallResultEvent({event:i}){r.onToolResult(i.toolCallId,i.content)},onActivitySnapshotEvent({event:i}){r.onActivity(i.activityType,i.content)},onReasoningStartEvent(){r.onReasoningStart()},onReasoningMessageContentEvent({reasoningMessageBuffer:i}){r.onReasoningDelta(i)},onReasoningEndEvent(){r.onReasoningEnd()},onRunFinishedEvent(i){n.terminal=!0,i.outcome==="interrupt"&&(n.interrupts=i.interrupts)},onRunErrorEvent({event:i}){n.terminal=!0,n.errored=!0,r.onError(i.message)},onRunFinalized(){n.terminal=!0,r.onRunEnd()}}}};function Bv(t){return t instanceof Error&&t.name==="AbortError"}function Na(t){let e=t.attachments;return Array.isArray(e)?e.filter(Vv):[]}function Vv(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.id=="string"&&typeof e.name=="string"&&typeof e.mime=="string"&&typeof e.size=="number"&&(e.url===void 0||typeof e.url=="string")}var Oa="ag-ui-chat",gr="thread",Ma="threads",Si="messages:",Ai="checkpoint:",jv=60,qv=100,Wv="New conversation",mt=class{#n;constructor(e=""){this.#n=e===""?Oa:`${Oa}@${e}`,e!==""&&this.#a()}threadId(){let e=this.#r(gr),n=sessionStorage.getItem(e);if(n!==null)return n;let r=Ue();return sessionStorage.setItem(e,r),r}loadMessages(e){return Promise.resolve(this.#i(this.#r(Si+e)))}saveMessages(e,n){sessionStorage.setItem(this.#r(Si+e),JSON.stringify(n)),this.#e(e,n)}loadCheckpoint(e){return this.#i(this.#r(Ai+e))}saveCheckpoint(e,n){let r=this.#r(Ai+e);if(n===null){sessionStorage.removeItem(r);return}sessionStorage.setItem(r,JSON.stringify(n))}clear(e){sessionStorage.removeItem(this.#r(Si+e)),sessionStorage.removeItem(this.#r(Ai+e)),this.#s(this.#t().filter(n=>n.threadId!==e)),sessionStorage.getItem(this.#r(gr))===e&&sessionStorage.removeItem(this.#r(gr))}listThreads(){let e=this.#t().sort((n,r)=>r.updatedAt-n.updatedAt).map(({threadId:n,title:r,updatedAt:o,preview:i})=>({threadId:n,title:r,updatedAt:o,preview:i}));return Promise.resolve(e)}setActiveThread(e){sessionStorage.setItem(this.#r(gr),e)}renameThread(e,n){let r=this.#t(),o=r.find(i=>i.threadId===e);o!==void 0&&(o.title=n,o.titleCustom=!0,this.#s(r))}#e(e,n){let r=this.#t(),o=r.find(a=>a.threadId===e),i=Yv(n),s=Date.now();o===void 0?r.push({threadId:e,title:ed(n),titleCustom:!1,preview:i,updatedAt:s}):(o.preview=i,o.updatedAt=s,o.titleCustom||(o.title=ed(n))),this.#s(r)}#t(){return this.#i(this.#r(Ma))??[]}#s(e){let n=this.#r(Ma);if(e.length===0){sessionStorage.removeItem(n);return}sessionStorage.setItem(n,JSON.stringify(e))}#r(e){return`${this.#n}:${e}`}#a(){let e=`${Oa}:`,n=[];for(let r=0;r<sessionStorage.length;r+=1){let o=sessionStorage.key(r);if(o===null||!o.startsWith(e))continue;let i=o.slice(e.length);Xv(i)&&n.push([o,this.#r(i)])}for(let[r,o]of n){let i=sessionStorage.getItem(r);i!==null&&sessionStorage.getItem(o)===null&&sessionStorage.setItem(o,i),sessionStorage.removeItem(r)}}#i(e){let n=sessionStorage.getItem(e);if(n===null)return null;try{return JSON.parse(n)}catch{return null}}};function Xv(t){return t===gr||t===Ma||t.startsWith(Si)||t.startsWith(Ai)}function ed(t){for(let e of t)if(e.role==="user"){let n=td(e.content);if(n!=="")return nd(n,jv)}return Wv}function Yv(t){for(let e of[...t].reverse()){let n=td(e.content);if(n!=="")return nd(n,qv)}return""}function td(t){return typeof t=="string"?t.replace(/\s+/g," ").trim():""}function nd(t,e){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}\u2026`}function Be(t,e){return e===void 0?t:{...t,credentials:e}}function La(t){return new lu({url:t.endpoint,headers:t.headers??{},initialState:{...t.initialState??{}},fetch:(e,n)=>{let r=t.getHeaders?.();if(r===void 0)return fetch(e,Be(n,t.credentials));let o=new Headers(n?.headers);for(let[i,s]of Object.entries(r))o.set(i,s);return fetch(e,Be({...n,headers:o},t.credentials))},...t.threadId!==void 0?{threadId:t.threadId}:{},...t.initialMessages!==void 0?{initialMessages:[...t.initialMessages]}:{}})}var vr=class{#n;#e;#t;#s;#r=new Set;#a=new Map;constructor(e,n=()=>({}),r=new mt,o=()=>{}){this.#n=e.endsWith("/")?e:`${e}/`,this.#e=n,this.#t=r,this.#s=o}threadId(){return this.#t.threadId()}setActiveThread(e){this.#t.setActiveThread(e)}saveMessages(e,n){this.#t.saveMessages(e,n)}loadCheckpoint(e){return this.#t.loadCheckpoint(e)}saveCheckpoint(e,n){this.#t.saveCheckpoint(e,n)}renameThread(e,n){this.#t.renameThread(e,n),this.#a.set(e,n),this.#d(e,"PATCH",{title:n})}clear(e){this.#t.clear(e),this.#r.add(e),this.#d(e,"DELETE")}async listThreads(){let e=await this.#i();return e===null?this.#t.listThreads():e.filter(n=>!this.#r.has(n.thread_id)).map(n=>this.#l(n))}async loadMessages(e){let n=await this.#c(`${this.#n}${encodeURIComponent(e)}/`);if(n===null||!n.ok)return this.#t.loadMessages(e);let r=await this.#o(n);return r===null?this.#t.loadMessages(e):r.messages??null}async#i(){let e=await this.#c(this.#n);if(e===null||!e.ok)return null;let n=await this.#o(e);return n===null?null:n.threads??[]}async#o(e){try{return await e.json()}catch{return null}}#l(e){return{threadId:e.thread_id,title:this.#a.get(e.thread_id)??e.title,updatedAt:e.updated_at===null?Number.NaN:Date.parse(e.updated_at),preview:e.preview}}async#c(e){try{return await fetch(e,Be({headers:this.#e()},this.#s()))}catch{return null}}async#d(e,n,r){let o=this.#e();try{await fetch(`${this.#n}${encodeURIComponent(e)}/`,Be({method:n,headers:r===void 0?o:{...o,"content-type":"application/json"},body:r===void 0?null:JSON.stringify(r)},this.#s()))}catch{}}};var br=class{#n;#e;#t;constructor(e,n=()=>({}),r=()=>{}){this.#n=e.endsWith("/")?e:`${e}/`,this.#e=n,this.#t=r}async list(){try{let e=await fetch(this.#n,Be({method:"GET",headers:{Accept:"application/json",...this.#e()}},this.#t()));return e.ok?(await e.json()).runs??[]:[]}catch{return[]}}async continuable(){return(await this.list()).filter(e=>e.continuable)}resumeUrl(e){return this.#s("resume",e)}forkUrl(e){return this.#s("fork",e)}#s(e,n){return`${this.#n.slice(0,-5)}${e}/${encodeURIComponent(n)}/`}};async function Pa(t,e){let n=new FormData;n.append("audio",t,"recording.webm");let r=await fetch(e.url,Be({method:"POST",headers:{...e.headers??{}},body:n},e.credentials));if(!r.ok)throw new Error(await Kv(r));let o=await r.json();if(typeof o=="object"&&o!==null&&typeof o.text=="string")return o.text;throw new Error("transcription returned an unreadable response")}async function Kv(t){try{let e=await t.json();if(typeof e.error=="string")return e.error}catch{}return`transcription failed (${t.status})`}function Da(t,e){return new Promise((n,r)=>{let o=new FormData;o.append("file",t);let i=new XMLHttpRequest;i.open("POST",e.url),i.withCredentials=e.credentials==="include";for(let[l,c]of Object.entries(e.headers??{}))i.setRequestHeader(l,c);let s=e.onProgress;s!==void 0&&i.upload.addEventListener("progress",l=>{l.lengthComputable&&s(l.total===0?0:l.loaded/l.total)}),i.addEventListener("load",()=>{if(i.status>=200&&i.status<300)try{n(Zv(JSON.parse(i.responseText)))}catch{r(new Error("upload returned an unreadable response"))}else r(new Error(Jv(i)))}),i.addEventListener("error",()=>r(new Error("upload failed"))),i.addEventListener("abort",()=>r(new Error("upload cancelled")));let a=e.signal;a!==void 0&&a.addEventListener("abort",()=>i.abort()),i.send(o)})}function Zv(t){if(typeof t!="object"||t===null)throw new Error("not an object");let e=t,n=e.id,r=e.name,o=e.mime,i=e.size,s=e.url;if(typeof n!="string"||typeof r!="string"||typeof o!="string"||typeof i!="number")throw new Error("missing fields");return typeof s=="string"?{id:n,name:r,mime:o,size:i,url:s}:{id:n,name:r,mime:o,size:i}}function Jv(t){try{let e=JSON.parse(t.responseText);if(typeof e.error=="string")return e.error}catch{}return`upload failed (${t.status})`}var Qv=["data-attachments-url","data-attachment-accept","data-attachment-max-bytes","data-transcribe-url","data-threads-url","data-tools-url","data-skills-url","data-skills","data-prompt-chips","data-slash-commands","data-theme-toggle","data-strings","data-icon-url"],Ha=["omit","same-origin","include"];function Ua(t){return Ha.includes(t)}var rd="ag-ui-chat:collapsed",od="ag-ui-chat:size",id="ag-ui-chat:theme",yr=class extends HTMLElement{agentFactory=La;headers={};getHeaders=null;allowImages=!1;autoConfirm=!1;askUser=!1;askUserRenderer=null;approvalRenderer=null;confirmPredicate=null;getTools=()=>[...this.#he().map(e=>({name:e.name,description:e.description,parameters:e.parameters})),...this.#t.tools()];getContext=()=>[...fs(this.getPageMap,this.autoInjectPageMap),...this.#Je()];routeMap=[];navigate=null;getPageMap=null;autoInjectPageMap=!0;conversationStore=new mt;uploadHandler=null;transcribeHandler=null;navigationResult=()=>({navigated:!0,url:window.location.href});skillContext=()=>({});toolSummaries={};strings={};resolvePageTarget=e=>document.querySelector(e);#n={};#e=ae;#t=new Bn;#s=new Map;#r=new Set;#a;#i;#o;#l;#c;#d;#u;#f;#h;#C=null;#y;#v;#b;#G;#w;#S;#I;#m=null;#F;#K=null;#D=!1;#U=[];#R=null;#M={};#H=!1;#Z=null;#x=null;#E=null;#J=0;#$=null;#A=null;#N=null;#p="";#L="";#Q=0;#ee=[];#ue=[];#de=[];#pe=[];constructor(){super(),this.#a=this.attachShadow({mode:"open"}),this.#i=document.createElement("div"),this.#o=document.createElement("div"),this.#l=document.createElement("textarea"),this.#c=document.createElement("button"),this.#d=document.createElement("span"),this.#y=document.createElement("div"),this.#v=document.createElement("button"),this.#b=document.createElement("input"),this.#G=document.createElement("div"),this.#F=document.createElement("span"),this.#w=document.createElement("button"),this.#S=document.createElement("button"),this.#I=document.createElement("div"),this.#u=new xi(e=>this.#nt(e)),this.#f=new _i({onSelect:e=>{this.#st(e)},onNew:()=>{this.newChat(),this.#W()},onRename:(e,n)=>{this.conversationStore.renameThread(e,n),this.#W()},onDelete:e=>{this.#at(e)}}),this.#h=new ar((e,n)=>{this.#Pe(e,n)})}#te(){let e=this.getAttribute("data-runs-url");return e===null||e===""?null:(this.#C===null&&(this.#C=new br(e,()=>this.#k(),()=>this.#B())),this.#C)}async#Pe(e,n){let r=this.#te();if(r===null)return;let o=this.#l.value.trim();if(o==="")return;this.#l.value="";let i=n==="resume"?r.resumeUrl(e):r.forkUrl(e),s=this.agentFactory({endpoint:i,headers:this.#k(),getHeaders:()=>this.#k(),...this.#V(),threadId:this.#p,initialMessages:[]});await new Pn({agent:s,handlers:this.#Ne(),getTools:()=>this.getTools(),getContext:()=>this.#Te(),executeTool:l=>this.#Ie(l),resolveInterrupts:l=>this.#Re(l),connectionLostMessage:this.#e.connectionLost}).send(o)}async#De(){let e=this.#te();this.#h.setRuns(e===null?[]:await e.continuable())}static get observedAttributes(){return["title-text","placement","credentials",...Qv]}attributeChangedCallback(e,n,r){if(e==="credentials"){r!==null&&!Ua(r)&&console.error(`<ag-ui-chat>: credentials="${r}" is not a fetch credentials mode (${Ha.join(" / ")}) \u2014 it is being ignored, so requests use the browser default and cross-origin cookies will not be sent.`);return}if(e==="placement"){this.#ot(),requestAnimationFrame(()=>this.#oe());return}if(e==="title-text"){this.#d.textContent=r??this.#e.title;return}n===r||!this.#D||console.warn(`<ag-ui-chat>: "${e}" was changed after the element connected, and is read only while connecting \u2014 this assignment has no effect. Set it before the element enters the DOM (in the markup, or on the element before appending it); frameworks that patch attributes after mount should bind it at creation. To apply a new value now, remove and re-insert the element.`)}registerTool(e){this.#t.register(e)}get sharedState(){return this.#R?.state??this.#M}set sharedState(e){this.#M={...e},this.#R?.setState(this.#M)}registerPageState(e){for(let n of Ur(e))this.#t.register(n)}registerStateHook(e){this.registerPageState(e)}#Ue(){return this.routeMap.length===0?[]:gs(()=>this.routeMap,()=>this.navigate)}#He(){let e=this.getPageMap;return e===null?[]:[{name:Zi,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:[],[Le]:"Read the page"},handler:()=>e()}]}#ze(){let e=this.getAttribute("data-page-actions");if(e===null)return[];let n=new Set(e.split(",").map(r=>r.trim()).filter(r=>r!==""));return hs(n,r=>this.resolvePageTarget(r))}#he(){return[...this.#Ue(),...this.#He(),...this.#ze(),...this.#Ge()]}#Ge(){return this.askUser?[{name:"ask_user",description:"Ask the user a question and wait for their answer. Provide `options` for a multiple-choice prompt; set `allow_custom` to also accept a free-text answer.",parameters:{type:"object",properties:{question:{type:"string",description:"The question to ask the user."},options:{type:"array",items:{type:"string"},description:"Preset choices offered as radio buttons."},allow_custom:{type:"boolean",description:"Allow a free-text answer in addition to any options."}},required:["question"]},handler:e=>this.#Fe(e)}]:[]}async#Fe(e){let r={question:typeof e.question=="string"?e.question:""},o=e.options;Array.isArray(o)&&(r.options=o.filter(a=>typeof a=="string")),e.allow_custom===!0&&(r.allowCustom=!0),this.#x=new AbortController;let i=this.#x.signal;this.#T();let s=this.askUserRenderer!==null?await this.askUserRenderer(r,{signal:i}):await da(this.#_(),r,{signal:i,strings:this.#e});return this.#x=null,this.#g(),this.#o.scrollTop=this.#o.scrollHeight,s}#fe(e){let n=this.#he().find(r=>r.name===e);return n!==void 0?n:this.#t.has(e)?this.#t.get(e):null}get endpoint(){return this.getAttribute("endpoint")??""}set endpoint(e){this.setAttribute("endpoint",e)}get credentials(){let e=this.getAttribute("credentials");return e!==null&&Ua(e)?e:null}set credentials(e){if(e===null){this.removeAttribute("credentials");return}if(!Ua(e))throw new TypeError(`<ag-ui-chat>: credentials must be one of ${Ha.map(n=>`"${n}"`).join(", ")} (got ${JSON.stringify(e)}).`);this.setAttribute("credentials",e)}#k(){return{...this.headers,...this.getHeaders?.()}}#B(){return this.credentials??void 0}#V(){let e=this.#B();return e===void 0?{}:{credentials:e}}#me(){return Be({headers:this.#k()},this.#B())}get toolDisplay(){let e=this.getAttribute("data-tool-display");return e===pn.INLINE||e===pn.MINIMAL||e===pn.COMPACT?e:pn.FULL}set toolDisplay(e){this.setAttribute("data-tool-display",e)}connectedCallback(){if(this.#L=this.id!==""?this.id:this.endpoint,this.#ie(this.#Ee()),requestAnimationFrame(()=>this.#oe()),this.#e=vs({...this.#Be(),...this.strings}),this.getAttribute("data-theme-toggle")!==null){let e=this.#se(id);e!==null&&this.setAttribute("theme",e)}this.#ht(),this.#f.setStrings(this.#e),this.#h.setStrings(this.#e),this.#se(rd)==="1"&&this.setAttribute("collapsed",""),this.#Ae(),this.#et(),this.#L!==""&&this.conversationStore instanceof mt&&(this.conversationStore=new mt(this.#L)),this.#Qe(),this.#Ve(),this.#qe(),this.#p=this.conversationStore.threadId(),queueMicrotask(()=>this.#$e()),this.#ae(),this.#D=!0}#$e(){this.#D&&(this.#ve(),this.#be())}async reload(){this.#O(),this.#q(),this.#P(!1),await Promise.all([this.#ve(),this.#be(),this.#ae()])}disconnectedCallback(){this.#D=!1,this.#O(),this.#m?.dispose(),this.#K?.dispose()}#ge(e){let n=this.getAttribute(e);return n!==null&&n!=="false"}#Be(){let e=this.getAttribute("data-strings");if(e===null)return{};try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#Ve(){let e=this.getAttribute("data-attachments-url"),n=this.uploadHandler??this.#je(e);if(n===null)return;let r=this.getAttribute("data-attachment-accept")??"",o=new di({upload:n,maxBytes:this.#Ye(),accept:r,strings:this.#e,onChange:()=>this.#mt(o)});this.#m=o,this.#G.appendChild(this.#m.element),this.#b.accept=r,this.#v.hidden=!1,this.#Ze()}#je(e){return e===null?null:(n,r,o)=>Da(n,{url:e,headers:this.#k(),...this.#V(),onProgress:r,signal:o})}#qe(){let e=this.getAttribute("data-transcribe-url"),n=this.transcribeHandler??this.#We(e);n!==null&&(this.#K=new Ti({transcribe:n,onText:r=>this.#Xe(r),strings:this.#e}),this.#F.appendChild(this.#K.element))}#We(e){return e===null?null:n=>Pa(n,{url:e,headers:this.#k(),...this.#V()})}#Xe(e){let n=this.#l.value.trim();this.#l.value=n===""?e:`${n} ${e}`,this.#ke(),this.#l.focus()}#Ye(){let e=this.getAttribute("data-attachment-max-bytes");if(e===null)return Qi;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:Qi}#Ke(){let e=this.#b.files;if(e!==null)for(let n of Array.from(e))this.#m?.add(n);this.#b.value=""}#Ze(){this.#i.addEventListener("dragover",e=>{e.preventDefault(),this.#i.classList.add("chat--dragover")}),this.#i.addEventListener("dragleave",()=>{this.#i.classList.remove("chat--dragover")}),this.#i.addEventListener("drop",e=>{e.preventDefault(),this.#i.classList.remove("chat--dragover");let n=e.dataTransfer?.files;if(n!==void 0)for(let r of Array.from(n))this.#m?.add(r)})}#Je(){return this.#U.length===0?[]:[{description:"Files the user attached to this message",value:`${this.#U.map(n=>`- ${n.name} (id: ${n.id}, ${n.mime||"unknown type"}, ${n.size} bytes)`).join(`
|
|
1867
1892
|
`)}
|
|
1868
|
-
Use the read_attachment tool with an id to read a file's contents.`}]}#je(){let e=this.getAttribute("data-threads-url");e!==null&&(this.conversationStore=new mr(e,()=>this.headers,this.conversationStore))}async#qe(){let e=this.getAttribute("data-tools-url");if(e!==null)try{let n=await fetch(e,{headers:this.headers});this.#n=ds(await n.json())}catch{}}setSkills(e){this.#ae=e,this.#J()}#We(){this.#u.enableChips(this.#ue("data-prompt-chips")),this.#u.enableSlash(this.#ue("data-slash-commands")),this.#se=this.#Xe(),this.#J(),this.#Ye()}#Xe(){let e=this.getAttribute("data-skills");if(e===null)return[];try{return Qi(JSON.parse(e))}catch{return[]}}async#Ye(){let e=this.getAttribute("data-skills-url");if(e!==null)try{let n=await fetch(e,{headers:this.headers});this.#ie=Qi(await n.json()),this.#J()}catch{}}#J(){let e=new Map;for(let n of[...this.#ie,...this.#se,...this.#ae])e.set(n.name,n);this.#u.setSkills([...e.values()])}#Ke(e){if(e.prompt===void 0){this.#y.hidden=!0,this.sendMessage(`/${e.name}`);return}let{text:n,missing:r}=sl(e.prompt,this.skillContext());if(r.length>0){this.#y.textContent=this.#e.skillNeeds.replace("{title}",e.title).replace("{fields}",r.join(", ")),this.#y.hidden=!1,this.#l.value=n,this.#l.focus(),this.#Ze(n);return}if(this.#y.hidden=!0,this.#l.value=n,e.sendImmediately===!1){this.#l.focus();return}this.#re()}#Ze(e){let n=e.indexOf("{");this.#l.setSelectionRange(n,e.indexOf("}",n)+1)}get collapsed(){return this.hasAttribute("collapsed")}set collapsed(e){this.setCollapsed(e)}setCollapsed(e){e?this.setAttribute("collapsed",""):this.removeAttribute("collapsed"),sessionStorage.setItem(this.#$(Ju),e?"1":"0"),this.#ye(),this.dispatchEvent(new CustomEvent(Vi,{detail:{collapsed:e},bubbles:!0,composed:!0}))}toggleCollapsed(){this.setCollapsed(!this.collapsed)}toggleTheme(){let e=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",e),sessionStorage.setItem(this.#$(ed),e),this.#fe()}#Je(){switch(this.getAttribute("placement")){case"full":case"page":return"none";case"sidebar":case"side":return"width";default:return"both"}}#de(){let e=this.getBoundingClientRect(),n=this.style.getPropertyValue("--ag-ui-width"),r=this.style.getPropertyValue("--ag-ui-height");this.#ee({width:e.width+1,height:e.height+1});let o=this.getBoundingClientRect();return this.#pe("--ag-ui-width",n),this.#pe("--ag-ui-height",r),{x:Math.abs(o.left-e.left)<.5?"left":"right",y:Math.abs(o.top-e.top)<.5?"top":"bottom"}}#Q(){if(!this.#z)return;let e=this.#de();this.setAttribute("data-resize-anchor",`${e.y}-${e.x}`)}#pe(e,n){if(n===""){this.style.removeProperty(e);return}this.style.setProperty(e,n)}#ee(e){e.width!==void 0&&this.style.setProperty("--ag-ui-width",`${e.width}px`),e.height!==void 0&&this.style.setProperty("--ag-ui-height",`${e.height}px`)}#Qe(e){let n={...this.#he(),...e};sessionStorage.setItem(this.#$(Qu),JSON.stringify(n))}#he(){let e=this.#te(Qu);if(e===null)return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!==null?n:{}}catch{return{}}}#$(e){return this.#O===""?e:`${e}:${this.#O}`}#te(e){let n=sessionStorage.getItem(this.#$(e));return n!==null||this.#O===""?n:sessionStorage.getItem(e)}#fe(){let e=this.getAttribute("theme")==="dark";this.#S.textContent=e?"\u2600\uFE0F":"\u{1F319}"}newChat(){this.#M(),this.conversationStore.clear(this.#p),this.#ne(),this.#p=this.conversationStore.threadId(),this.#D(!1)}#ne(){this.#C=null,this.#E=null,this.#A=null,this.#R=null,this.#w(),this.#s.clear(),this.#r.clear(),this.#K=[],this.#L=[],this.#m?.clear(),this.#i.replaceChildren(this.#I),this.#g()}async#et(e){e!==this.#p&&(this.#M(),this.#ne(),this.conversationStore.setActiveThread(e),this.#p=e,this.#D(!1),await this.#me())}#tt(e){let n=e===this.#p;n&&this.#M(),this.conversationStore.clear(e),n&&(this.#ne(),this.#p=this.conversationStore.threadId(),this.#D(!1)),this.#B()}async#B(){this.#f.setThreads(await this.conversationStore.listThreads(),this.#p)}async#me(){this.#Y+=1;let e=this.#Y,n=await this.conversationStore.loadMessages(this.#p);if(e!==this.#Y)return;if(n!==null){this.#K=n;for(let o of n)this.#ot(o)}let r=this.conversationStore.loadCheckpoint(this.#p);if(r!==null){await this.#st(r);return}this.#rt(n)}#ge(){return this.#W=window.location.href,this.getContext()}#nt(){return this.#W!==null&&this.#W!==window.location.href}#rt(e){let n=e?.at(-1);n===void 0||n.role!==Ve.USER||this.#j("\u26A0",this.#e.runInterrupted,"interrupted")}#ot(e){let n=typeof e.content=="string"?e.content:"";if(e.role===Ve.USER){let r=ka(e);if(n!==""||r.length>0){let o=this.appendMessage(Ve.USER,n);r.length>0&&o.appendChild(gs(r))}return}if(e.role===Ve.ASSISTANT){n!==""&&this.appendMessage(Ve.ASSISTANT,n).classList.add("message--restored");let r=e.toolCalls;if(r!==void 0)for(let o of r){let i={id:o.id,name:o.function.name,args:this.#it(o.function.arguments)};this.#ke(i)||this.#oe(i)}return}if(e.role==="tool"){let r=this.#s.get(e.toolCallId);r!==void 0&&r.settle(pe.DONE,e.content)}}#it(e){try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#ve(e){this.getAttribute("data-text-animation")==="word"&&ju(e)}async#st(e){this.conversationStore.saveCheckpoint(this.#p,null);let n=this.#Ee();n.addToolResult(e.toolCallId,JSON.stringify(this.navigationResult(e))),await n.resume()}appendMessage(e,n){let r=document.createElement("div");return r.className=`message message--${e}`,r.setAttribute("part",`message message-${e}`),e===Ve.ASSISTANT?(r.innerHTML=gi(n,{allowImages:this.allowImages}),ms(r,this.#e),this.#T().appendChild(r)):(this.#A=null,r.textContent=n,this.#i.appendChild(r)),this.#g(),this.#i.scrollTop=this.#i.scrollHeight,r}#T(){if(this.#A===null){let e=document.createElement("div");e.className="answer",e.setAttribute("part","answer"),this.#A=e,this.#i.appendChild(e),this.#g()}return this.#A}#at(){let e=document.createElement("style");e.textContent=Wu,this.#o.className="chat",this.#o.setAttribute("part","panel");let n=document.createElement("div");n.className="header",n.setAttribute("part","header");let r=this.#d;r.className="header-title",r.setAttribute("part","title"),r.textContent=this.getAttribute("title-text")??this.#e.title,(this.querySelector('[slot="icon"]')!==null||this.getAttribute("data-icon-url")!==null)&&n.append(this.#be("icon","icon",null));let o=document.createElement("slot");o.name="header-actions";let i=document.createElement("div");i.className="header-controls",i.setAttribute("part","header-controls");let s=this.#V("history",this.#e.chatHistory,"\u2630");s.addEventListener("click",()=>{this.#B(),this.#f.open()});let a=this.#V("checkpoints",this.#e.checkpoints,"\u2B6F");a.addEventListener("click",()=>{this.#Ce(),this.#h.open()});let l=this.#V("new",this.#e.newChat,"\u271A");l.addEventListener("click",()=>this.newChat());let c=this.#V("collapse",this.#e.collapse,"\u2014");c.addEventListener("click",()=>this.toggleCollapsed()),this.#Z()!==null?i.append(s,a,l):i.append(s,l),this.getAttribute("data-theme-toggle")!==null&&(this.#S.type="button",this.#S.className="header-btn header-btn--theme",this.#S.setAttribute("part","header-button theme-toggle"),this.#S.title=this.#e.toggleTheme,this.#S.setAttribute("aria-label",this.#e.toggleTheme),this.#S.addEventListener("click",()=>this.toggleTheme()),this.#fe(),i.append(this.#S)),i.append(c),n.append(r,o,i),this.#i.className="messages",this.#i.setAttribute("part","messages"),this.#i.setAttribute("role","log"),this.#i.setAttribute("aria-live","polite"),this.#i.setAttribute("aria-label",this.#e.conversation),this.#I.className="empty",this.#I.setAttribute("part","empty");let h=document.createElement("slot");h.name="empty",this.#I.append(h),this.#i.append(this.#I);let m=document.createElement("div");m.className="input-row",m.setAttribute("part","composer"),this.#l.className="input",this.#l.setAttribute("part","input"),this.#l.setAttribute("aria-label",this.#e.message),this.#l.rows=2,this.#l.placeholder=this.#e.inputPlaceholder,this.#l.addEventListener("keydown",f=>this.#lt(f)),this.#l.addEventListener("input",()=>this.#xe()),this.#c.className="send",this.#c.type="button",this.#c.setAttribute("part","send"),this.#c.textContent=this.#e.send,this.#c.setAttribute("aria-label",this.#e.send),this.#c.dataset.state="idle",this.#c.addEventListener("click",()=>{if(this.#P){this.#M();return}this.#re()}),this.#y.className="skill-hint",this.#y.setAttribute("part","skill-hint"),this.#y.hidden=!0,this.#v.className="attach-btn",this.#v.type="button",this.#v.setAttribute("part","attach-button"),this.#v.textContent="\u{1F4CE}",this.#v.title=this.#e.attachFiles,this.#v.setAttribute("aria-label",this.#e.attachFiles),this.#v.hidden=!0,this.#v.addEventListener("click",()=>this.#b.click()),this.#b.className="attach-input",this.#b.type="file",this.#b.multiple=!0,this.#b.hidden=!0,this.#b.addEventListener("change",()=>this.#$e()),this.#H.className="attachment-slot",this.#G.className="voice-slot";let y=document.createElement("slot");y.name="footer",m.append(this.#v,this.#G,this.#l,this.#c,this.#b),this.#o.append(n,this.#i,this.#u.palette,this.#u.chips,this.#y,this.#H,m,y,this.#f.element,this.#h.element),this.#_.className="rail",this.#_.type="button",this.#_.setAttribute("part","launcher"),this.#_.setAttribute("aria-label",this.#e.expand),this.#_.append(this.#be("launcher","launcher-icon","\u{1F4AC}")),this.#_.addEventListener("click",()=>this.setCollapsed(!1)),this.#o.append(Bu({axis:()=>this.#Je(),anchor:()=>this.#de(),rect:()=>this.getBoundingClientRect(),apply:f=>this.#ee(f),commit:f=>{this.#Qe(f),this.#Q()},label:this.#e.resizePanel})),this.#a.append(e,this.#o,this.#_)}#V(e,n,r){let o=document.createElement("button");o.type="button",o.className=`header-btn header-btn--${e}`,o.setAttribute("part",`header-button ${e}-button`),o.title=n,o.setAttribute("aria-label",n);let i=document.createElement("slot");return i.name=`icon-${e}`,i.append(document.createTextNode(r)),o.append(i),o}#be(e,n,r){let o=document.createElement("span");o.className="icon-holder",o.setAttribute("part",n);let i=document.createElement("slot");i.name=e;let s=this.getAttribute("data-icon-url");if(s!==null){let a=document.createElement("img");a.className="icon-img",a.src=s,a.alt="",i.append(a)}else r!==null&&i.append(document.createTextNode(r));return o.append(i),o}#ye(){this.#_.setAttribute("aria-expanded",String(!this.collapsed))}#g(){this.#I.hidden=this.#i.childElementCount>1}#xe(){this.#u.onInput(this.#l.value),this.#y.hidden=!0}#lt(e){if(this.#u.onKeydown(e)){e.preventDefault();return}if(e.key==="Escape"&&this.#P){e.preventDefault(),this.#M();return}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.#re())}#M(){this.#x?.abort(),this.#C?.cancel()}#D(e){this.#P=e;let n=e?this.#e.stop:this.#e.send;this.#c.textContent=n,this.#c.setAttribute("aria-label",n),this.#c.dataset.state=e?"running":"idle"}async#re(){if(this.#P)return;let e=this.#l.value.trim(),n=this.#m?.readyRefs()??[];e===""&&n.length===0||(this.#l.value="",this.#m?.hasPending()===!0&&this.#j("\u{1F4CE}",this.#e.attachmentsStillUploading.replace("{n}",String(this.#m.pendingCount())),"attachment-pending"),this.#m?.clearReady(),await this.sendMessage(e,n))}async sendMessage(e,n=[]){if(this.#P||e===""&&n.length===0)return;let r=this.appendMessage(Ve.USER,e);n.length>0&&r.appendChild(gs(n)),this.#L=n,this.dispatchEvent(new CustomEvent(Bi,{detail:{content:e,attachments:n},bubbles:!0,composed:!0})),await this.#ut(e,n)}attachFile(e){return this.#m===null?!1:(this.#m.add(e),!0)}#ct(e){this.dispatchEvent(new CustomEvent(qi,{detail:{attachments:e.readyRefs(),pending:e.pendingCount()},bubbles:!0,composed:!0}))}async#ut(e,n){this.endpoint!==""&&await this.#Ee().send(e,n)}#Ee(){if(this.#C===null){let e=this.agentFactory({endpoint:this.endpoint,headers:this.headers,getHeaders:()=>this.headers,threadId:this.#p,initialMessages:this.#K,initialState:this.#N});this.#C=new Ln({agent:e,handlers:this.#Se(),getTools:()=>this.getTools(),getContext:()=>this.#ge(),executeTool:n=>this.#Te(n),resolveInterrupts:n=>this.#we(n),onPersist:n=>this.conversationStore.saveMessages(this.#p,n),onStateChanged:n=>this.#dt(n),connectionLostMessage:this.#e.connectionLost})}return this.#C}#dt(e){this.#N={...e},this.dispatchEvent(new CustomEvent(ji,{detail:{state:this.#N},bubbles:!0,composed:!0}))}async#pt(e,n){return this.autoConfirm?!1:this.confirmPredicate!==null?await this.confirmPredicate(e.name,e.args)===!0:es(n.parameters)}async#Te(e){if(td(e)!==null)return null;let n=this.#oe(e);this.#s.delete(e.id);let r=this.#ce(e.name);if(r===null)return this.#r.has(e.id)||n.settle(pe.DONE,this.#e.noResult),null;if(this.getPageMap!==null&&e.name!==Xi&&!Nr(r.parameters)&&this.#nt()){let i=this.#e.pageMoved;return n.settle(pe.ERROR,i),this.#U(),{content:`Error: ${i}`,error:i}}if(await this.#pt(e,r)){let i={toolName:e.name,args:e.args},s=r.parameters[Wi];typeof s=="string"&&(i.message=s),this.#x=new AbortController;let a=ia(this.#T(),i,{signal:this.#x.signal,strings:this.#e});this.#g(),this.#i.scrollTop=this.#i.scrollHeight;let l=await a;if(this.#x=null,n.recordDecision(l?"approved":"declined"),!l){let c=this.#e.declinedAction;return n.settle(pe.DECLINED,c),this.#U(),{content:c}}}let o=Nr(r.parameters)&&this.navigate===null;o&&this.conversationStore.saveCheckpoint(this.#p,{toolCallId:e.id});try{let i=await r.handler(e.args);if(o)return n.settle(pe.DONE,this.#e.navigating),{content:"",halt:!0};let s=JSON.stringify(i??null);return n.settle(pe.DONE,s),this.#U(),{content:s}}catch(i){o&&this.conversationStore.saveCheckpoint(this.#p,null);let s=i instanceof Error?i.message:String(i);return n.settle(pe.ERROR,s),this.#U(),{content:`Error: ${s}`,error:s}}}async#we(e){let n={};this.#x=new AbortController,this.#w();for(let r of e){let o={};r.message!==void 0&&(o.message=r.message);let i=r.toolCallId!==void 0?this.#s.get(r.toolCallId):void 0,s=i?.element.getAttribute("data-tool-name");s!=null&&(o.toolName=s);let a=this.#x.signal,l=this.approvalRenderer!==null?await this.approvalRenderer(o,{signal:a}):await fs(this.#T(),o,{signal:a,strings:this.#e});this.#g(),this.#i.scrollTop=this.#i.scrollHeight,i?.recordDecision(l?"approved":"declined"),l?n[r.id]={status:"resolved",payload:{approved:!0}}:(n[r.id]={status:"cancelled"},i?.settle(pe.DECLINED,this.#e.declinedAction))}return this.#x=null,n}#Se(){return{onRunStart:()=>{this.#D(!0),this.#T(),this.#U()},onReasoningStart:()=>{this.#w(),this.#_e()},onReasoningDelta:e=>{this.#_e().stream(e)},onReasoningEnd:()=>{},onTextDelta:e=>{this.#w(),this.#R?.collapse(),this.#Ae(e),this.#X+=1},onTextEnd:e=>{let n=this.#Ae(e);this.#X<=1&&this.#ve(n),ms(n,this.#e),this.#E=null},onToolCall:e=>{this.#w(),!this.#ke(e)&&this.#oe(e)},onActivity:(e,n)=>{if(e!==Zi)return;let r=$v(n);r!==null&&this.#j("\u{1F5DC}",this.#e.historyCompacted.replace("{count}",String(r)),"compaction")},onToolResult:(e,n)=>{let r=this.#s.get(e);r!==void 0&&(r.settle(pe.DONE,n),this.#r.add(e))},onRunEnd:()=>{this.#w(),this.#E=null},onError:e=>{this.#w(),this.#ve(this.appendMessage(Ve.ASSISTANT,`\u26A0\uFE0F ${e}`)),this.#E=null},onCancelled:()=>{this.#w(),this.#ht(),this.#E=null},onSettled:()=>{this.#w(),this.#D(!1),this.#E=null,this.#L=[];for(let e of this.#s.values())e.settled||e.settle(pe.DONE,this.#e.noResult);this.#A!==null&&this.#A.childElementCount===0&&(this.#A.remove(),this.#g()),this.#A=null,this.#R=null}}}#ht(){let e=document.createElement("div");e.className="stopped-note",e.setAttribute("part","stopped"),e.setAttribute("role","status"),e.textContent=this.#e.stopped,this.#T().appendChild(e),this.#g(),this.#i.scrollTop=this.#i.scrollHeight}#U(){if(this.#F!==null)return;let e=document.createElement("div");e.className="pending",e.setAttribute("part","pending"),e.setAttribute("role","status"),e.setAttribute("aria-label",this.#e.thinking);for(let n=0;n<3;n+=1){let r=document.createElement("span");r.className="pending-dot",e.appendChild(r)}this.#F=e,this.#T().appendChild(e),this.#g(),this.#i.scrollTop=this.#i.scrollHeight}#w(){this.#F?.remove(),this.#F=null}#_e(){if(this.#R===null){this.#R=new bi(this.#e);let e=this.#T();e.insertBefore(this.#R.element,e.firstChild),this.#g(),this.#i.scrollTop=this.#i.scrollHeight}return this.#R}#Ae(e){return this.#E===null&&(this.#E=this.appendMessage(Ve.ASSISTANT,""),this.#X=0),this.#E.innerHTML=gi(e,{allowImages:this.allowImages}),this.#i.scrollTop=this.#i.scrollHeight,this.#E}#ke(e){let n=td(e);return n===null?!1:(this.#j("\u2728",this.#e.usingSkill.replace("{name}",n),"skill"),!0)}#j(e,n,r){this.#T().appendChild(qu(e,n,r)),this.#g(),this.#i.scrollTop=this.#i.scrollHeight}#oe(e){let n=this.#s.get(e.id);if(n!==void 0)return n;let r=this.#ce(e.name)?.parameters[Le],o=typeof r=="string"?r:this.toolSummaries[e.name]??this.#n[e.name]??sa(e.name),i=new hr(e.name,e.args,o,this.#e);return this.#s.set(e.id,i),this.#T().appendChild(i.element),this.#g(),this.#i.scrollTop=this.#i.scrollHeight,i}};function td(t){if(t.name!==Ji)return null;let e=t.args?.id;return typeof e=="string"&&e!==""?e:null}function $v(t){let e=t?.removed;return typeof e=="number"?e:null}function Bv(){customElements.get(Rr)===void 0&&customElements.define(Rr,vr)}async function Vv(t,e,n={}){at(t),await rs(t,{flashMs:n.flashMs??0}),await ts(t,e,n)}async function jv(t,e={}){at(t),await ns(t,e)}async function qv(t,e={}){at(t),await is(t,e)}async function Wv(t,e,n={}){at(t),await ss(t,e,n)}async function Xv(t,e,n={}){at(t),await as(t,e,n)}function Yv(t,e){t instanceof HTMLInputElement&&t.type==="checkbox"?Bn(t,!!e):Rt(t,String(e)),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}var Kv="0.20.0";export{qi as ATTACHMENT_EVENT,vr as AgUiChat,Ln as AgUiClient,Zi as COMPACTION_ACTIVITY_TYPE,ir as CheckpointMenu,$n as ClientToolRegistry,Ei as ConnectionLostError,ae as DEFAULT_UI_STRINGS,Rr as ELEMENT_TAG,Ji as LOAD_CAPABILITY_TOOL,Yi as MAX_TOOL_ROUNDS,Ve as MESSAGE_ROLE,ls as PAGE_ACTIONS,mr as RemoteConversationStore,gr as RunIndex,ji as STATE_EVENT,Bi as SUBMIT_EVENT,ft as SessionStorageStore,Vi as TOGGLE_EVENT,pe as TOOL_CALL_STATUS,dn as TOOL_DISPLAY,hr as ToolCallCard,Kv as VERSION,Wi as X_CONFIRM_KEY,zn as X_DESTRUCTIVE_KEY,Fn as X_NAVIGATES_KEY,Le as X_SUMMARY_KEY,jv as clickElement,Ra as createHttpAgent,cs as createPageActionTools,us as createPageMapContext,Lr as createPageStateTools,ps as createRouteTools,Fd as createStateHookTools,Bv as defineAgUiChat,Vv as fillField,rs as focusWithFlash,ns as highlightThenClick,es as isDestructive,Nr as isNavigates,hs as mergeUiStrings,ka as messageAttachments,ds as parseToolCatalog,cl as prefersReducedMotion,qv as pressButton,is as pressThenClick,sa as prettifyToolName,gi as renderMarkdown,fs as requestApproval,ia as requestConfirmation,aa as requestQuestion,at as scrollIntoCenterView,Wv as selectControl,ss as selectOption,Yv as setControlValue,Bn as setNativeChecked,Rt as setNativeValue,Xv as toggleCheckbox,as as toggleControl,Na as transcribeAudio,ts as typeInto,Oa as uploadAttachment};
|
|
1893
|
+
Use the read_attachment tool with an id to read a file's contents.`}]}#Qe(){let e=this.getAttribute("data-threads-url");e!==null&&(this.conversationStore=new vr(e,()=>this.#k(),this.conversationStore,()=>this.#B()))}async#ve(){let e=this.getAttribute("data-tools-url");if(e!==null)try{let n=await fetch(e,this.#me());this.#n=ms(await n.json())}catch{}}setSkills(e){this.#pe=e,this.#ne()}#et(){this.#u.enableChips(this.#ge("data-prompt-chips")),this.#u.enableSlash(this.#ge("data-slash-commands")),this.#de=this.#tt(),this.#ne()}#tt(){let e=this.getAttribute("data-skills");if(e===null)return[];try{return ns(JSON.parse(e))}catch{return[]}}async#be(){let e=this.getAttribute("data-skills-url");if(e!==null)try{let n=await fetch(e,this.#me());this.#ue=ns(await n.json()),this.#ne()}catch{}}#ne(){let e=new Map;for(let n of[...this.#ue,...this.#de,...this.#pe])e.set(n.name,n);this.#u.setSkills([...e.values()])}#nt(e){if(e.prompt===void 0){this.#y.hidden=!0,this.sendMessage(`/${e.name}`);return}let{text:n,missing:r}=pl(e.prompt,this.skillContext());if(r.length>0){this.#y.textContent=this.#e.skillNeeds.replace("{title}",e.title).replace("{fields}",r.join(", ")),this.#y.hidden=!1,this.#l.value=n,this.#l.focus(),this.#rt(n);return}if(this.#y.hidden=!0,this.#l.value=n,e.sendImmediately===!1){this.#l.focus();return}this.#le()}#rt(e){let n=e.indexOf("{");this.#l.setSelectionRange(n,e.indexOf("}",n)+1)}get collapsed(){return this.hasAttribute("collapsed")}set collapsed(e){this.setCollapsed(e)}setCollapsed(e){e?this.setAttribute("collapsed",""):this.removeAttribute("collapsed"),sessionStorage.setItem(this.#j(rd),e?"1":"0"),this.#Ae(),this.dispatchEvent(new CustomEvent(Wi,{detail:{collapsed:e},bubbles:!0,composed:!0}))}toggleCollapsed(){this.setCollapsed(!this.collapsed)}toggleTheme(){let e=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",e),sessionStorage.setItem(this.#j(id),e),this.#_e()}#re(){switch(this.getAttribute("placement")){case"full":case"page":return"none";case"sidebar":case"side":return"width";default:return"both"}}#ye(){let e=this.getBoundingClientRect(),n=this.style.getPropertyValue("--ag-ui-width"),r=this.style.getPropertyValue("--ag-ui-height");this.#ie({width:e.width+1,height:e.height+1});let o=this.getBoundingClientRect();return this.#xe("--ag-ui-width",n),this.#xe("--ag-ui-height",r),{x:Math.abs(o.left-e.left)<.5?"left":"right",y:Math.abs(o.top-e.top)<.5?"top":"bottom"}}#oe(){if(!this.#D)return;let e=this.#ye();this.setAttribute("data-resize-anchor",`${e.y}-${e.x}`)}#xe(e,n){if(n===""){this.style.removeProperty(e);return}this.style.setProperty(e,n)}#ie(e){let n=this.#re();n!=="none"&&(e.width!==void 0&&this.style.setProperty("--ag-ui-width",`${e.width}px`),e.height!==void 0&&n==="both"&&this.style.setProperty("--ag-ui-height",`${e.height}px`))}#ot(){let e=this.#re();e!=="both"&&this.style.removeProperty("--ag-ui-height"),e==="none"&&this.style.removeProperty("--ag-ui-width")}#it(e){let n={...this.#Ee(),...e};sessionStorage.setItem(this.#j(od),JSON.stringify(n))}#Ee(){let e=this.#se(od);if(e===null)return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!==null?n:{}}catch{return{}}}#j(e){return this.#L===""?e:`${e}:${this.#L}`}#se(e){let n=sessionStorage.getItem(this.#j(e));return n!==null||this.#L===""?n:sessionStorage.getItem(e)}#_e(){let e=this.getAttribute("theme")==="dark";this.#w.textContent=e?"\u2600\uFE0F":"\u{1F319}"}openThreads(){this.#W(),this.#f.open()}openCheckpoints(){this.#De(),this.#h.open()}newChat(){this.#O(),this.conversationStore.clear(this.#p),this.#q(),this.#p=this.conversationStore.threadId(),this.#P(!1)}#q(){this.#R=null,this.#E=null,this.#A=null,this.#N=null,this.#T(),this.#s.clear(),this.#r.clear(),this.#ee=[],this.#U=[],this.#m?.clear(),this.#o.replaceChildren(this.#I),this.#g()}async#st(e){e!==this.#p&&(this.#O(),this.#q(),this.conversationStore.setActiveThread(e),this.#p=e,this.#P(!1),await this.#ae())}#at(e){let n=e===this.#p;n&&this.#O(),this.conversationStore.clear(e),n&&(this.#q(),this.#p=this.conversationStore.threadId(),this.#P(!1)),this.#W()}async#W(){this.#f.setThreads(await this.conversationStore.listThreads(),this.#p)}async#ae(){this.#Q+=1;let e=this.#Q,n=await this.conversationStore.loadMessages(this.#p);if(e!==this.#Q)return;if(n!==null){this.#ee=n;for(let o of n)this.#ut(o)}let r=this.conversationStore.loadCheckpoint(this.#p);if(r!==null){await this.#pt(r);return}this.#ct(n)}#Te(){return this.#Z=window.location.href,this.getContext()}#lt(){return this.#Z!==null&&this.#Z!==window.location.href}#ct(e){let n=e?.at(-1);n===void 0||n.role!==je.USER||this.#Y("\u26A0",this.#e.runInterrupted,"interrupted")}#ut(e){let n=typeof e.content=="string"?e.content:"";if(e.role===je.USER){let r=Na(e);if(n!==""||r.length>0){let o=this.appendMessage(je.USER,n);r.length>0&&o.appendChild(xs(r))}return}if(e.role===je.ASSISTANT){n!==""&&this.appendMessage(je.ASSISTANT,n).classList.add("message--restored");let r=e.toolCalls;if(r!==void 0)for(let o of r){let i={id:o.id,name:o.function.name,args:this.#dt(o.function.arguments)};this.#Le(i)||this.#ce(i)}return}if(e.role==="tool"){let r=this.#s.get(e.toolCallId);r!==void 0&&r.settle(pe.DONE,e.content)}}#dt(e){try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#we(e){this.getAttribute("data-text-animation")==="word"&&Ku(e)}async#pt(e){this.conversationStore.saveCheckpoint(this.#p,null);let n=this.#Ce();n.addToolResult(e.toolCallId,JSON.stringify(this.navigationResult(e))),await n.resume()}appendMessage(e,n){let r=document.createElement("div");return r.className=`message message--${e}`,r.setAttribute("part",`message message-${e}`),e===je.ASSISTANT?(r.innerHTML=yi(n,{allowImages:this.allowImages}),ys(r,this.#e),this.#_().appendChild(r)):(this.#A=null,r.textContent=n,this.#o.appendChild(r)),this.#g(),this.#o.scrollTop=this.#o.scrollHeight,r}#_(){if(this.#A===null){let e=document.createElement("div");e.className="answer",e.setAttribute("part","answer"),this.#A=e,this.#o.appendChild(e),this.#g()}return this.#A}#ht(){let e=document.createElement("style");e.textContent=Ju,this.#i.className="chat",this.#i.setAttribute("part","panel");let n=document.createElement("div");n.className="header",n.setAttribute("part","header");let r=this.#d;r.className="header-title",r.setAttribute("part","title"),r.textContent=this.getAttribute("title-text")??this.#e.title,(this.querySelector('[slot="icon"]')!==null||this.getAttribute("data-icon-url")!==null)&&n.append(this.#Se("icon","icon",null));let o=document.createElement("slot");o.name="header-actions";let i=document.createElement("div");i.className="header-controls",i.setAttribute("part","header-controls");let s=this.#X("history",this.#e.chatHistory,"\u2630");s.addEventListener("click",()=>this.openThreads());let a=this.#X("checkpoints",this.#e.checkpoints,"\u2B6F");a.addEventListener("click",()=>this.openCheckpoints());let l=this.#X("new",this.#e.newChat,"\u271A");l.addEventListener("click",()=>this.newChat());let c=this.#X("collapse",this.#e.collapse,"\u2014");c.addEventListener("click",()=>this.toggleCollapsed()),this.#te()!==null?i.append(s,a,l):i.append(s,l),this.getAttribute("data-theme-toggle")!==null&&(this.#w.type="button",this.#w.className="header-btn header-btn--theme",this.#w.setAttribute("part","header-button theme-toggle"),this.#w.title=this.#e.toggleTheme,this.#w.setAttribute("aria-label",this.#e.toggleTheme),this.#w.addEventListener("click",()=>this.toggleTheme()),this.#_e(),i.append(this.#w)),i.append(c),n.append(r,o,i),this.#o.className="messages",this.#o.setAttribute("part","messages"),this.#o.setAttribute("role","log"),this.#o.setAttribute("aria-live","polite"),this.#o.setAttribute("aria-label",this.#e.conversation),this.#I.className="empty",this.#I.setAttribute("part","empty");let h=document.createElement("slot");h.name="empty",this.#I.append(h),this.#o.append(this.#I);let m=document.createElement("div");m.className="input-row",m.setAttribute("part","composer"),this.#l.className="input",this.#l.setAttribute("part","input"),this.#l.setAttribute("aria-label",this.#e.message),this.#l.rows=2,this.#l.placeholder=this.#e.inputPlaceholder,this.#l.addEventListener("keydown",f=>this.#ft(f)),this.#l.addEventListener("input",()=>this.#ke()),this.#c.className="send",this.#c.type="button",this.#c.setAttribute("part","send"),this.#c.textContent=this.#e.send,this.#c.setAttribute("aria-label",this.#e.send),this.#c.dataset.state="idle",this.#c.addEventListener("click",()=>{if(this.#H){this.#O();return}this.#le()}),this.#y.className="skill-hint",this.#y.setAttribute("part","skill-hint"),this.#y.hidden=!0,this.#v.className="attach-btn",this.#v.type="button",this.#v.setAttribute("part","attach-button"),this.#v.textContent="\u{1F4CE}",this.#v.title=this.#e.attachFiles,this.#v.setAttribute("aria-label",this.#e.attachFiles),this.#v.hidden=!0,this.#v.addEventListener("click",()=>this.#b.click()),this.#b.className="attach-input",this.#b.type="file",this.#b.multiple=!0,this.#b.hidden=!0,this.#b.addEventListener("change",()=>this.#Ke()),this.#G.className="attachment-slot",this.#F.className="voice-slot";let y=document.createElement("slot");y.name="footer",m.append(this.#v,this.#F,this.#l,this.#c,this.#b),this.#i.append(n,this.#o,this.#u.palette,this.#u.chips,this.#y,this.#G,m,y,this.#f.element,this.#h.element),this.#S.className="rail",this.#S.type="button",this.#S.setAttribute("part","launcher"),this.#S.setAttribute("aria-label",this.#e.expand),this.#S.append(this.#Se("launcher","launcher-icon","\u{1F4AC}")),this.#S.addEventListener("click",()=>this.setCollapsed(!1)),this.#i.append(Xu({axis:()=>this.#re(),anchor:()=>this.#ye(),rect:()=>this.getBoundingClientRect(),apply:f=>this.#ie(f),commit:f=>{this.#it(f),this.#oe()},label:this.#e.resizePanel})),this.#a.append(e,this.#i,this.#S)}#X(e,n,r){let o=document.createElement("button");o.type="button",o.className=`header-btn header-btn--${e}`,o.setAttribute("part",`header-button ${e}-button`),o.title=n,o.setAttribute("aria-label",n);let i=document.createElement("slot");return i.name=`icon-${e}`,i.append(document.createTextNode(r)),o.append(i),o}#Se(e,n,r){let o=document.createElement("span");o.className="icon-holder",o.setAttribute("part",n);let i=document.createElement("slot");i.name=e;let s=this.getAttribute("data-icon-url");if(s!==null){let a=document.createElement("img");a.className="icon-img",a.src=s,a.alt="",i.append(a)}else r!==null&&i.append(document.createTextNode(r));return o.append(i),o}#Ae(){this.#S.setAttribute("aria-expanded",String(!this.collapsed))}#g(){this.#I.hidden=this.#o.childElementCount>1}#ke(){this.#u.onInput(this.#l.value),this.#y.hidden=!0}#ft(e){if(this.#u.onKeydown(e)){e.preventDefault();return}if(e.key==="Escape"&&this.#H){e.preventDefault(),this.#O();return}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.#le())}#O(){this.#x?.abort(),this.#R?.cancel()}#P(e){this.#H=e;let n=e?this.#e.stop:this.#e.send;this.#c.textContent=n,this.#c.setAttribute("aria-label",n),this.#c.dataset.state=e?"running":"idle"}async#le(){if(this.#H)return;let e=this.#l.value.trim(),n=this.#m?.readyRefs()??[];e===""&&n.length===0||(this.#l.value="",this.#m?.hasPending()===!0&&this.#Y("\u{1F4CE}",this.#e.attachmentsStillUploading.replace("{n}",String(this.#m.pendingCount())),"attachment-pending"),this.#m?.clearReady(),await this.sendMessage(e,n))}async sendMessage(e,n=[]){if(this.#H||e===""&&n.length===0)return;let r=this.appendMessage(je.USER,e);n.length>0&&r.appendChild(xs(n)),this.#U=n,this.dispatchEvent(new CustomEvent(qi,{detail:{content:e,attachments:n},bubbles:!0,composed:!0})),await this.#gt(e,n)}attachFile(e){return this.#m===null?!1:(this.#m.add(e),!0)}#mt(e){this.dispatchEvent(new CustomEvent(Yi,{detail:{attachments:e.readyRefs(),pending:e.pendingCount()},bubbles:!0,composed:!0}))}async#gt(e,n){this.endpoint!==""&&await this.#Ce().send(e,n)}#Ce(){if(this.#R===null){let e=this.agentFactory({endpoint:this.endpoint,headers:this.#k(),getHeaders:()=>this.#k(),...this.#V(),threadId:this.#p,initialMessages:this.#ee,initialState:this.#M});this.#R=new Pn({agent:e,handlers:this.#Ne(),getTools:()=>this.getTools(),getContext:()=>this.#Te(),executeTool:n=>this.#Ie(n),resolveInterrupts:n=>this.#Re(n),onPersist:n=>this.conversationStore.saveMessages(this.#p,n),onStateChanged:n=>this.#vt(n),connectionLostMessage:this.#e.connectionLost})}return this.#R}#vt(e){this.#M={...e},this.dispatchEvent(new CustomEvent(Xi,{detail:{state:this.#M},bubbles:!0,composed:!0}))}async#bt(e,n){return this.autoConfirm?!1:this.confirmPredicate!==null?await this.confirmPredicate(e.name,e.args)===!0:rs(n.parameters)}async#Ie(e){if(sd(e)!==null)return null;let n=this.#ce(e);this.#s.delete(e.id);let r=this.#fe(e.name);if(r===null)return this.#r.has(e.id)||n.settle(pe.DONE,this.#e.noResult),null;if(this.getPageMap!==null&&e.name!==Zi&&!Mr(r.parameters)&&this.#lt()){let i=this.#e.pageMoved;return n.settle(pe.ERROR,i),this.#z(),{content:`Error: ${i}`,error:i}}if(await this.#bt(e,r)){let i={toolName:e.name,args:e.args},s=r.parameters[Ki];typeof s=="string"&&(i.message=s),this.#x=new AbortController;let a=ca(this.#_(),i,{signal:this.#x.signal,strings:this.#e});this.#g(),this.#o.scrollTop=this.#o.scrollHeight;let l=await a;if(this.#x=null,n.recordDecision(l?"approved":"declined"),!l){let c=this.#e.declinedAction;return n.settle(pe.DECLINED,c),this.#z(),{content:c}}}let o=Mr(r.parameters)&&this.navigate===null;o&&this.conversationStore.saveCheckpoint(this.#p,{toolCallId:e.id});try{let i=await r.handler(e.args);if(o)return n.settle(pe.DONE,this.#e.navigating),{content:"",halt:!0};let s=JSON.stringify(i??null);return n.settle(pe.DONE,s),this.#z(),{content:s}}catch(i){o&&this.conversationStore.saveCheckpoint(this.#p,null);let s=i instanceof Error?i.message:String(i);return n.settle(pe.ERROR,s),this.#z(),{content:`Error: ${s}`,error:s}}}async#Re(e){let n={};this.#x=new AbortController,this.#T();for(let r of e){let o={};r.message!==void 0&&(o.message=r.message);let i=r.toolCallId!==void 0?this.#s.get(r.toolCallId):void 0,s=i?.element.getAttribute("data-tool-name");s!=null&&(o.toolName=s);let a=this.#x.signal,l=this.approvalRenderer!==null?await this.approvalRenderer(o,{signal:a}):await bs(this.#_(),o,{signal:a,strings:this.#e});this.#g(),this.#o.scrollTop=this.#o.scrollHeight,i?.recordDecision(l?"approved":"declined"),l?n[r.id]={status:"resolved",payload:{approved:!0}}:(n[r.id]={status:"cancelled"},i?.settle(pe.DECLINED,this.#e.declinedAction))}return this.#x=null,n}#Ne(){return{onRunStart:()=>{this.#P(!0),this.#_(),this.#z()},onReasoningStart:()=>{this.#T(),this.#Oe()},onReasoningDelta:e=>{this.#Oe().stream(e)},onReasoningEnd:()=>{},onTextDelta:e=>{this.#T(),this.#N?.collapse(),this.#Me(e),this.#J+=1},onTextEnd:e=>{let n=this.#Me(e);this.#J<=1&&this.#we(n),ys(n,this.#e),this.#E=null},onToolCall:e=>{this.#T(),!this.#Le(e)&&this.#ce(e)},onActivity:(e,n)=>{if(e!==es)return;let r=eb(n);r!==null&&this.#Y("\u{1F5DC}",this.#e.historyCompacted.replace("{count}",String(r)),"compaction")},onToolResult:(e,n)=>{let r=this.#s.get(e);r!==void 0&&(r.settle(pe.DONE,n),this.#r.add(e))},onRunEnd:()=>{this.#T(),this.#E=null},onError:e=>{this.#T(),this.#we(this.appendMessage(je.ASSISTANT,`\u26A0\uFE0F ${e}`)),this.#E=null},onCancelled:()=>{this.#T(),this.#yt(),this.#E=null},onSettled:()=>{this.#T(),this.#P(!1),this.#E=null,this.#U=[];for(let e of this.#s.values())e.settled||e.settle(pe.DONE,this.#e.noResult);this.#A!==null&&this.#A.childElementCount===0&&(this.#A.remove(),this.#g()),this.#A=null,this.#N=null}}}#yt(){let e=document.createElement("div");e.className="stopped-note",e.setAttribute("part","stopped"),e.setAttribute("role","status"),e.textContent=this.#e.stopped,this.#_().appendChild(e),this.#g(),this.#o.scrollTop=this.#o.scrollHeight}#z(){if(this.#$!==null)return;let e=document.createElement("div");e.className="pending",e.setAttribute("part","pending"),e.setAttribute("role","status"),e.setAttribute("aria-label",this.#e.thinking);for(let n=0;n<3;n+=1){let r=document.createElement("span");r.className="pending-dot",e.appendChild(r)}this.#$=e,this.#_().appendChild(e),this.#g(),this.#o.scrollTop=this.#o.scrollHeight}#T(){this.#$?.remove(),this.#$=null}#Oe(){if(this.#N===null){this.#N=new Ei(this.#e);let e=this.#_();e.insertBefore(this.#N.element,e.firstChild),this.#g(),this.#o.scrollTop=this.#o.scrollHeight}return this.#N}#Me(e){return this.#E===null&&(this.#E=this.appendMessage(je.ASSISTANT,""),this.#J=0),this.#E.innerHTML=yi(e,{allowImages:this.allowImages}),this.#o.scrollTop=this.#o.scrollHeight,this.#E}#Le(e){let n=sd(e);return n===null?!1:(this.#Y("\u2728",this.#e.usingSkill.replace("{name}",n),"skill"),!0)}#Y(e,n,r){this.#_().appendChild(Zu(e,n,r)),this.#g(),this.#o.scrollTop=this.#o.scrollHeight}#ce(e){let n=this.#s.get(e.id);if(n!==void 0)return n;let r=this.#fe(e.name)?.parameters[Le],o=typeof r=="string"?r:this.toolSummaries[e.name]??this.#n[e.name]??ua(e.name),i=new mr(e.name,e.args,o,this.#e);return this.#s.set(e.id,i),this.#_().appendChild(i.element),this.#g(),this.#o.scrollTop=this.#o.scrollHeight,i}};function sd(t){if(t.name!==ts)return null;let e=t.args?.id;return typeof e=="string"&&e!==""?e:null}function eb(t){let e=t?.removed;return typeof e=="number"?e:null}function tb(){customElements.get(Or)===void 0&&customElements.define(Or,yr)}async function nb(t,e,n={}){await lt(t),await ls(t,{...n,flashMs:n.flashMs??0}),await ss(t,e,n)}async function rb(t,e={}){await lt(t),await as(t,e)}async function ob(t,e={}){await lt(t),await cs(t,e)}async function ib(t,e,n={}){await lt(t),await us(t,e,n)}async function sb(t,e,n={}){await lt(t),await ds(t,e,n)}function ab(t,e){t instanceof HTMLInputElement&&t.type==="checkbox"?Vn(t,!!e):Nt(t,String(e)),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}var lb="0.21.0";export{Yi as ATTACHMENT_EVENT,yr as AgUiChat,Pn as AgUiClient,es as COMPACTION_ACTIVITY_TYPE,ar as CheckpointMenu,Bn as ClientToolRegistry,wi as ConnectionLostError,ae as DEFAULT_UI_STRINGS,Or as ELEMENT_TAG,ts as LOAD_CAPABILITY_TOOL,Ji as MAX_TOOL_ROUNDS,je as MESSAGE_ROLE,ps as PAGE_ACTIONS,vr as RemoteConversationStore,br as RunIndex,Xi as STATE_EVENT,qi as SUBMIT_EVENT,mt as SessionStorageStore,Wi as TOGGLE_EVENT,pe as TOOL_CALL_STATUS,pn as TOOL_DISPLAY,mr as ToolCallCard,lb as VERSION,Ki as X_CONFIRM_KEY,Fn as X_DESTRUCTIVE_KEY,$n as X_NAVIGATES_KEY,Le as X_SUMMARY_KEY,rb as clickElement,La as createHttpAgent,hs as createPageActionTools,fs as createPageMapContext,Ur as createPageStateTools,gs as createRouteTools,Qd as createStateHookTools,tb as defineAgUiChat,nb as fillField,Xd as flash,ls as focusWithFlash,as as highlightThenClick,rs as isDestructive,Mr as isNavigates,vs as mergeUiStrings,Na as messageAttachments,ms as parseToolCatalog,Pr as prefersReducedMotion,ob as pressButton,cs as pressThenClick,ua as prettifyToolName,yi as renderMarkdown,bs as requestApproval,ca as requestConfirmation,da as requestQuestion,lt as scrollIntoCenterView,ib as selectControl,us as selectOption,ab as setControlValue,Vn as setNativeChecked,Nt as setNativeValue,sb as toggleCheckbox,ds as toggleControl,Pa as transcribeAudio,ss as typeInto,Da as uploadAttachment};
|
|
1869
1894
|
/*! Bundled license information:
|
|
1870
1895
|
|
|
1871
1896
|
fast-json-patch/module/helpers.mjs:
|