@artooi/ag-ui-web-component 0.28.0 → 0.30.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 +615 -1
- package/README.md +564 -35
- package/dist/ag-ui-web-component.bundle.js +491 -50
- package/dist/ag-ui-web-component.bundle.js.map +4 -4
- package/dist/constants.d.ts +129 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/ag_ui_chat.d.ts +232 -1
- package/dist/core/ag_ui_chat.d.ts.map +1 -1
- package/dist/core/agui_client.d.ts +56 -1
- package/dist/core/agui_client.d.ts.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2081 -98
- package/dist/index.js.map +4 -4
- package/dist/ui/approval_card.d.ts +18 -0
- package/dist/ui/approval_card.d.ts.map +1 -1
- package/dist/ui/checkpoint_menu.d.ts +10 -0
- package/dist/ui/checkpoint_menu.d.ts.map +1 -1
- package/dist/ui/confirmation_card.d.ts +16 -0
- package/dist/ui/confirmation_card.d.ts.map +1 -1
- package/dist/ui/message_actions.d.ts +56 -0
- package/dist/ui/message_actions.d.ts.map +1 -0
- package/dist/ui/page_quote_offer.d.ts +33 -0
- package/dist/ui/page_quote_offer.d.ts.map +1 -0
- package/dist/ui/quote_selection.d.ts +66 -0
- package/dist/ui/quote_selection.d.ts.map +1 -0
- package/dist/ui/relative_time.d.ts +10 -0
- package/dist/ui/relative_time.d.ts.map +1 -1
- package/dist/ui/stick_to_bottom.d.ts +55 -0
- package/dist/ui/stick_to_bottom.d.ts.map +1 -0
- package/dist/ui/styles.d.ts +1 -1
- package/dist/ui/styles.d.ts.map +1 -1
- package/dist/ui/subagent_panel.d.ts +92 -0
- package/dist/ui/subagent_panel.d.ts.map +1 -0
- package/dist/ui/subagent_update.d.ts +19 -0
- package/dist/ui/subagent_update.d.ts.map +1 -0
- package/dist/ui/suggestion_chips.d.ts +29 -0
- package/dist/ui/suggestion_chips.d.ts.map +1 -0
- package/dist/ui/thread_drawer.d.ts +10 -0
- package/dist/ui/thread_drawer.d.ts.map +1 -1
- package/dist/ui/tool_call_card.d.ts +81 -1
- package/dist/ui/tool_call_card.d.ts.map +1 -1
- package/dist/ui/ui_strings.d.ts +50 -0
- package/dist/ui/ui_strings.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +138 -1
- package/src/core/ag_ui_chat.ts +1081 -73
- package/src/core/agui_client.ts +89 -2
- package/src/index.ts +43 -0
- package/src/ui/approval_card.ts +90 -2
- package/src/ui/checkpoint_menu.ts +22 -5
- package/src/ui/confirmation_card.ts +29 -1
- package/src/ui/message_actions.ts +170 -0
- package/src/ui/page_quote_offer.ts +215 -0
- package/src/ui/quote_selection.ts +345 -0
- package/src/ui/relative_time.ts +11 -0
- package/src/ui/stick_to_bottom.ts +126 -0
- package/src/ui/styles.ts +410 -0
- package/src/ui/subagent_panel.ts +213 -0
- package/src/ui/subagent_update.ts +80 -0
- package/src/ui/suggestion_chips.ts +73 -0
- package/src/ui/thread_drawer.ts +22 -2
- package/src/ui/tool_call_card.ts +138 -3
- package/src/ui/ui_strings.ts +75 -0
- package/src/version.ts +1 -1
|
@@ -1,80 +1,109 @@
|
|
|
1
|
-
var yp=Object.defineProperty;var ls=(t,e)=>{for(var n in e)yp(t,n,{get:e[n],enumerable:!0})};var $r="ag-ui-chat",cs="ag-ui-submit",ds="ag-ui-toggle",us="ag-ui-unread",ps="ag-ui-state",hs="ag-ui-attachments",fs="ag-ui-run-finished",We={USER:"user",ASSISTANT:"assistant"},Xn="x-destructive",Vr="x-confirm",Pe="x-summary",Kn="x-navigates",ms="read_page",gs=10,ee={PENDING:"pending",DEFERRED:"deferred",DONE:"done",ERROR:"error",DECLINED:"declined"},De={UPLOADING:"uploading",READY:"ready",ERROR:"error"},vs=10*1024*1024,vn={INLINE:"inline",MINIMAL:"minimal",COMPACT:"compact",FULL:"full"},bs="compaction",ys="load_capability",Ol='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 19.5V5m-6.5 6.5L12 5l6.5 6.5"/></svg>',Ml='<svg class="glyph glyph--solid" viewBox="0 0 24 24" aria-hidden="true"><rect x="7" y="7" width="10" height="10" rx="2.5"/></svg>',Ll='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M17 8.5V15a5 5 0 0 1-10 0V7a3 3 0 0 1 6 0v7.5a1 1 0 0 1-2 0V8.5"/></svg>',Pl='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4a3 3 0 0 1 3 3v5a3 3 0 0 1-6 0V7a3 3 0 0 1 3-3z"/><path d="M5 11v1a7 7 0 0 0 14 0v-1"/><path d="M12 19v3"/></svg>',Dl='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H9l-5 4z"/></svg>',Ul='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/></svg>',Hl='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><rect x="3.5" y="4.5" width="17" height="15" rx="2.5"/><circle cx="9" cy="10" r="1.5"/><path d="M4.5 17.5 9 13.5l3.5 3 3-2.5 4.5 4"/></svg>',zl='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><rect class="glyph--solid" x="7.5" y="13.5" width="9" height="4.5" rx="1"/></svg>',Gl='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M8.5 13.5h7M8.5 17h4.5"/></svg>',Yn="chart";var xe=[];for(let t=0;t<256;++t)xe.push((t+256).toString(16).slice(1));function Fl(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 xs,xp=new Uint8Array(16);function ws(){if(!xs){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");xs=crypto.getRandomValues.bind(crypto)}return xs(xp)}var wp=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),_s={randomUUID:wp};function _p(t,e,n){if(_s.randomUUID&&!e&&!t)return _s.randomUUID();t=t||{};let r=t.random??t.rng?.()??ws();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 i=0;i<16;++i)e[n+i]=r[i];return e}return Fl(r)}var Et=_p;var d={};ls(d,{BRAND:()=>Xp,DIRTY:()=>Lt,EMPTY_PATH:()=>Ap,INVALID:()=>P,NEVER:()=>Oh,OK:()=>Ae,ParseStatus:()=>we,Schema:()=>$,ZodAny:()=>At,ZodArray:()=>mt,ZodBigInt:()=>Dt,ZodBoolean:()=>Ut,ZodBranded:()=>Jn,ZodCatch:()=>Xt,ZodDate:()=>Ht,ZodDefault:()=>Wt,ZodDiscriminatedUnion:()=>qr,ZodEffects:()=>$e,ZodEnum:()=>jt,ZodError:()=>Oe,ZodFirstPartyTypeKind:()=>D,ZodFunction:()=>Xr,ZodIntersection:()=>$t,ZodIssueCode:()=>_,ZodLazy:()=>Vt,ZodLiteral:()=>Bt,ZodMap:()=>En,ZodNaN:()=>Sn,ZodNativeEnum:()=>qt,ZodNever:()=>Xe,ZodNull:()=>Gt,ZodNullable:()=>st,ZodNumber:()=>Pt,ZodObject:()=>Me,ZodOptional:()=>Ge,ZodParsedType:()=>C,ZodPipeline:()=>Qn,ZodPromise:()=>kt,ZodReadonly:()=>Kt,ZodRecord:()=>Wr,ZodSchema:()=>$,ZodSet:()=>Tn,ZodString:()=>St,ZodSymbol:()=>wn,ZodTransformer:()=>$e,ZodTuple:()=>ot,ZodType:()=>$,ZodUndefined:()=>zt,ZodUnion:()=>Ft,ZodUnknown:()=>ft,ZodVoid:()=>_n,addIssueToContext:()=>k,any:()=>rh,array:()=>ah,bigint:()=>Jp,boolean:()=>Jl,coerce:()=>Nh,custom:()=>Kl,date:()=>Qp,datetimeRegex:()=>Wl,defaultErrorMap:()=>pt,discriminatedUnion:()=>uh,effect:()=>Eh,enum:()=>xh,function:()=>vh,getErrorMap:()=>bn,getParsedType:()=>it,instanceof:()=>Yp,intersection:()=>ph,isAborted:()=>Br,isAsync:()=>yn,isDirty:()=>jr,isValid:()=>Tt,late:()=>Kp,lazy:()=>bh,literal:()=>yh,makeIssue:()=>Zn,map:()=>mh,nan:()=>Zp,nativeEnum:()=>wh,never:()=>oh,null:()=>nh,nullable:()=>Sh,number:()=>Zl,object:()=>lh,objectUtil:()=>Es,oboolean:()=>Rh,onumber:()=>Ih,optional:()=>Th,ostring:()=>Ch,pipeline:()=>kh,preprocess:()=>Ah,promise:()=>_h,quotelessJson:()=>Ep,record:()=>fh,set:()=>gh,setErrorMap:()=>Sp,strictObject:()=>ch,string:()=>Yl,symbol:()=>eh,transformer:()=>Eh,tuple:()=>hh,undefined:()=>th,union:()=>dh,unknown:()=>ih,util:()=>B,void:()=>sh});var B;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{let o={};for(let s of i)o[s]=s;return o},t.getValidEnumValues=i=>{let o=t.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(let a of o)s[a]=i[a];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(o){return i[o]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.push(s);return o},t.find=(i,o)=>{for(let s of i)if(o(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,o=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}t.joinValues=r,t.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(B||(B={}));var Es;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Es||(Es={}));var C=B.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),it=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 _=B.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"]),Ep=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Oe=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(o){return o.message},r={_errors:[]},i=o=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(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 i(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,B.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let i of this.issues)if(i.path.length>0){let o=i.path[0];n[o]=n[o]||[],n[o].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};Oe.create=t=>new Oe(t);var Tp=(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,B.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:n=`Unrecognized key(s) in object: ${B.joinValues(t.keys,", ")}`;break;case _.invalid_union:n="Invalid input";break;case _.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${B.joinValues(t.options)}`;break;case _.invalid_enum_value:n=`Invalid enum value. Expected ${B.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}"`:B.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,B.assertNever(t)}return{message:n}},pt=Tp;var $l=pt;function Sp(t){$l=t}function bn(){return $l}var Zn=t=>{let{data:e,path:n,errorMaps:r,issueData:i}=t,o=[...n,...i.path||[]],s={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let a="",l=r.filter(c=>!!c).slice().reverse();for(let c of l)a=c(s,{data:e,defaultError:a}).message;return{...i,path:o,message:a}},Ap=[];function k(t,e){let n=bn(),r=Zn({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===pt?void 0:pt].filter(i=>!!i)});t.common.issues.push(r)}var we=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 i of n){if(i.status==="aborted")return P;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let i of n){let o=await i.key,s=await i.value;r.push({key:o,value:s})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let i of n){let{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return P;o.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(r[o.value]=s.value)}return{status:e.value,value:r}}},P=Object.freeze({status:"aborted"}),Lt=t=>({status:"dirty",value:t}),Ae=t=>({status:"valid",value:t}),Br=t=>t.status==="aborted",jr=t=>t.status==="dirty",Tt=t=>t.status==="valid",yn=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 Fe=class{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}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}},Vl=(t,e)=>{if(Tt(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 Oe(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:i}=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:i}:{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:i}}var $=class{get description(){return this._def.description}_getType(e){return it(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:it(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new we,ctx:{common:e.parent.common,data:e.data,parsedType:it(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(yn(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:it(e)},i=this._parseSync({data:e,path:r.path,parent:r});return Vl(r,i)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:it(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Tt(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=>Tt(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:it(e)},i=this._parse({data:e,path:r.path,parent:r}),o=await(yn(i)?i:Promise.resolve(i));return Vl(r,o)}refine(e,n){let r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,o)=>{let s=e(i),a=()=>o.addIssue({code:_.custom,...r(i)});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,i)=>e(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(e){return new $e({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 st.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return mt.create(this)}promise(){return kt.create(this,this._def)}or(e){return Ft.create([this,e],this._def)}and(e){return $t.create(this,e,this._def)}transform(e){return new $e({...G(this._def),schema:this,typeName:D.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Wt({...G(this._def),innerType:this,defaultValue:n,typeName:D.ZodDefault})}brand(){return new Jn({typeName:D.ZodBranded,type:this,...G(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Xt({...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 Qn.create(this,e)}readonly(){return Kt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},kp=/^c[^\s-]{8,}$/i,Cp=/^[0-9a-z]+$/,Ip=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Rp=/^[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,Np=/^[a-z0-9_-]{21}$/i,Op=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Mp=/^[-+]?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)?)??$/,Lp=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Pp="^(\\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])$/,Up=/^(?:(?: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]))$/,zp=/^(([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])$/,Gp=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Fp=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,jl="((\\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])))",$p=new RegExp(`^${jl}$`);function ql(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 Vp(t){return new RegExp(`^${ql(t)}$`)}function Wl(t){let e=`${jl}T${ql(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 Bp(t,e){return!!((e==="v4"||!e)&&Dp.test(t)||(e==="v6"||!e)&&Hp.test(t))}function jp(t,e){if(!Op.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,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function qp(t,e){return!!((e==="v4"||!e)&&Up.test(t)||(e==="v6"||!e)&&zp.test(t))}var St=class t extends ${_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==C.string){let o=this._getOrReturnCtx(e);return k(o,{code:_.invalid_type,expected:C.string,received:o.parsedType}),P}let r=new we,i;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),k(i,{code:_.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="max")e.data.length>o.value&&(i=this._getOrReturnCtx(e,i),k(i,{code:_.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if(o.kind==="length"){let s=e.data.length>o.value,a=e.data.length<o.value;(s||a)&&(i=this._getOrReturnCtx(e,i),s?k(i,{code:_.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&k(i,{code:_.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if(o.kind==="email")Lp.test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"email",code:_.invalid_string,message:o.message}),r.dirty());else if(o.kind==="emoji")Ts||(Ts=new RegExp(Pp,"u")),Ts.test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"emoji",code:_.invalid_string,message:o.message}),r.dirty());else if(o.kind==="uuid")Rp.test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"uuid",code:_.invalid_string,message:o.message}),r.dirty());else if(o.kind==="nanoid")Np.test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"nanoid",code:_.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid")kp.test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"cuid",code:_.invalid_string,message:o.message}),r.dirty());else if(o.kind==="cuid2")Cp.test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"cuid2",code:_.invalid_string,message:o.message}),r.dirty());else if(o.kind==="ulid")Ip.test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"ulid",code:_.invalid_string,message:o.message}),r.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),k(i,{validation:"url",code:_.invalid_string,message:o.message}),r.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"regex",code:_.invalid_string,message:o.message}),r.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(e,i),k(i,{code:_.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(i=this._getOrReturnCtx(e,i),k(i,{code:_.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),k(i,{code:_.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty()):o.kind==="datetime"?Wl(o).test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{code:_.invalid_string,validation:"datetime",message:o.message}),r.dirty()):o.kind==="date"?$p.test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{code:_.invalid_string,validation:"date",message:o.message}),r.dirty()):o.kind==="time"?Vp(o).test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{code:_.invalid_string,validation:"time",message:o.message}),r.dirty()):o.kind==="duration"?Mp.test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"duration",code:_.invalid_string,message:o.message}),r.dirty()):o.kind==="ip"?Bp(e.data,o.version)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"ip",code:_.invalid_string,message:o.message}),r.dirty()):o.kind==="jwt"?jp(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"jwt",code:_.invalid_string,message:o.message}),r.dirty()):o.kind==="cidr"?qp(e.data,o.version)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"cidr",code:_.invalid_string,message:o.message}),r.dirty()):o.kind==="base64"?Gp.test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"base64",code:_.invalid_string,message:o.message}),r.dirty()):o.kind==="base64url"?Fp.test(e.data)||(i=this._getOrReturnCtx(e,i),k(i,{validation:"base64url",code:_.invalid_string,message:o.message}),r.dirty()):B.assertNever(o);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),{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}};St.create=t=>new St({checks:[],typeName:D.ZodString,coerce:t?.coerce??!1,...G(t)});function Wp(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=n>r?n:r,o=Number.parseInt(t.toFixed(i).replace(".","")),s=Number.parseInt(e.toFixed(i).replace(".",""));return o%s/10**i}var Pt=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 o=this._getOrReturnCtx(e);return k(o,{code:_.invalid_type,expected:C.number,received:o.parsedType}),P}let r,i=new we;for(let o of this._def.checks)o.kind==="int"?B.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:_.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),k(r,{code:_.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),k(r,{code:_.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?Wp(e.data,o.value)!==0&&(r=this._getOrReturnCtx(e,r),k(r,{code:_.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:_.not_finite,message:o.message}),i.dirty()):B.assertNever(o);return{status:i.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,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:R.toString(i)}]})}_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"&&B.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)}};Pt.create=t=>new Pt({checks:[],typeName:D.ZodNumber,coerce:t?.coerce||!1,...G(t)});var Dt=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,i=new we;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(r=this._getOrReturnCtx(e,r),k(r,{code:_.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(r=this._getOrReturnCtx(e,r),k(r,{code:_.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),k(r,{code:_.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):B.assertNever(o);return{status:i.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,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:R.toString(i)}]})}_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}};Dt.create=t=>new Dt({checks:[],typeName:D.ZodBigInt,coerce:t?.coerce??!1,...G(t)});var Ut=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 Ae(e.data)}};Ut.create=t=>new Ut({typeName:D.ZodBoolean,coerce:t?.coerce||!1,...G(t)});var Ht=class t extends ${_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==C.date){let o=this._getOrReturnCtx(e);return k(o,{code:_.invalid_type,expected:C.date,received:o.parsedType}),P}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return k(o,{code:_.invalid_date}),P}let r=new we,i;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),k(i,{code:_.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(i=this._getOrReturnCtx(e,i),k(i,{code:_.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):B.assertNever(o);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}};Ht.create=t=>new Ht({checks:[],coerce:t?.coerce||!1,typeName:D.ZodDate,...G(t)});var wn=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 Ae(e.data)}};wn.create=t=>new wn({typeName:D.ZodSymbol,...G(t)});var zt=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 Ae(e.data)}};zt.create=t=>new zt({typeName:D.ZodUndefined,...G(t)});var Gt=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 Ae(e.data)}};Gt.create=t=>new Gt({typeName:D.ZodNull,...G(t)});var At=class extends ${constructor(){super(...arguments),this._any=!0}_parse(e){return Ae(e.data)}};At.create=t=>new At({typeName:D.ZodAny,...G(t)});var ft=class extends ${constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ae(e.data)}};ft.create=t=>new ft({typeName:D.ZodUnknown,...G(t)});var Xe=class extends ${_parse(e){let n=this._getOrReturnCtx(e);return k(n,{code:_.invalid_type,expected:C.never,received:n.parsedType}),P}};Xe.create=t=>new Xe({typeName:D.ZodNever,...G(t)});var _n=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 Ae(e.data)}};_n.create=t=>new _n({typeName:D.ZodVoid,...G(t)});var mt=class t extends ${_parse(e){let{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==C.array)return k(n,{code:_.invalid_type,expected:C.array,received:n.parsedType}),P;if(i.exactLength!==null){let s=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(s||a)&&(k(n,{code:s?_.too_big:_.too_small,minimum:a?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(k(n,{code:_.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(k(n,{code:_.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((s,a)=>i.type._parseAsync(new Fe(n,s,n.path,a)))).then(s=>we.mergeArray(r,s));let o=[...n.data].map((s,a)=>i.type._parseSync(new Fe(n,s,n.path,a)));return we.mergeArray(r,o)}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)}};mt.create=(t,e)=>new mt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...G(e)});function xn(t){if(t instanceof Me){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Ge.create(xn(r))}return new Me({...t._def,shape:()=>e})}else return t instanceof mt?new mt({...t._def,type:xn(t.element)}):t instanceof Ge?Ge.create(xn(t.unwrap())):t instanceof st?st.create(xn(t.unwrap())):t instanceof ot?ot.create(t.items.map(e=>xn(e))):t}var Me=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=B.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:i}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof Xe&&this._def.unknownKeys==="strip"))for(let c in i.data)s.includes(c)||a.push(c);let l=[];for(let c of s){let p=o[c],m=i.data[c];l.push({key:{status:"valid",value:c},value:p._parse(new Fe(i,m,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Xe){let c=this._def.unknownKeys;if(c==="passthrough")for(let p of a)l.push({key:{status:"valid",value:p},value:{status:"valid",value:i.data[p]}});else if(c==="strict")a.length>0&&(k(i,{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 p of a){let m=i.data[p];l.push({key:{status:"valid",value:p},value:c._parse(new Fe(i,m,i.path,p)),alwaysSet:p in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let c=[];for(let p of l){let m=await p.key,y=await p.value;c.push({key:m,value:y,alwaysSet:p.alwaysSet})}return c}).then(c=>we.mergeObjectSync(r,c)):we.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 i=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:R.errToObj(e).message??i}:{message:i}}}:{}})}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 B.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 B.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return xn(this)}partial(e){let n={};for(let r of B.objectKeys(this.shape)){let i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of B.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let o=this.shape[r];for(;o instanceof Ge;)o=o._def.innerType;n[r]=o}return new t({...this._def,shape:()=>n})}keyof(){return Xl(B.objectKeys(this.shape))}};Me.create=(t,e)=>new Me({shape:()=>t,unknownKeys:"strip",catchall:Xe.create(),typeName:D.ZodObject,...G(e)});Me.strictCreate=(t,e)=>new Me({shape:()=>t,unknownKeys:"strict",catchall:Xe.create(),typeName:D.ZodObject,...G(e)});Me.lazycreate=(t,e)=>new Me({shape:t,unknownKeys:"strip",catchall:Xe.create(),typeName:D.ZodObject,...G(e)});var Ft=class extends ${_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function i(o){for(let a of o)if(a.result.status==="valid")return a.result;for(let a of o)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(a=>new Oe(a.ctx.common.issues));return k(n,{code:_.invalid_union,unionErrors:s}),P}if(n.common.async)return Promise.all(r.map(async o=>{let s={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:s}),ctx:s}})).then(i);{let o,s=[];for(let l of r){let c={...n,common:{...n.common,issues:[]},parent:null},p=l._parseSync({data:n.data,path:n.path,parent:c});if(p.status==="valid")return p;p.status==="dirty"&&!o&&(o={result:p,ctx:c}),c.common.issues.length&&s.push(c.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(l=>new Oe(l));return k(n,{code:_.invalid_union,unionErrors:a}),P}}get options(){return this._def.options}};Ft.create=(t,e)=>new Ft({options:t,typeName:D.ZodUnion,...G(e)});var ht=t=>t instanceof Vt?ht(t.schema):t instanceof $e?ht(t.innerType()):t instanceof Bt?[t.value]:t instanceof jt?t.options:t instanceof qt?B.objectValues(t.enum):t instanceof Wt?ht(t._def.innerType):t instanceof zt?[void 0]:t instanceof Gt?[null]:t instanceof Ge?[void 0,...ht(t.unwrap())]:t instanceof st?[null,...ht(t.unwrap())]:t instanceof Jn||t instanceof Kt?ht(t.unwrap()):t instanceof Xt?ht(t._def.innerType):[],qr=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,i=n.data[r],o=this.optionsMap.get(i);return o?n.common.async?o._parseAsync({data:n.data,path:n.path,parent:n}):o._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 i=new Map;for(let o of n){let s=ht(o.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(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,o)}}return new t({typeName:D.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:i,...G(r)})}};function Ss(t,e){let n=it(t),r=it(e);if(t===e)return{valid:!0,data:t};if(n===C.object&&r===C.object){let i=B.objectKeys(e),o=B.objectKeys(t).filter(a=>i.indexOf(a)!==-1),s={...t,...e};for(let a of o){let l=Ss(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 i=[];for(let o=0;o<t.length;o++){let s=t[o],a=e[o],l=Ss(s,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===C.date&&r===C.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var $t=class extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=(o,s)=>{if(Br(o)||Br(s))return P;let a=Ss(o.value,s.value);return a.valid?((jr(o)||jr(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(([o,s])=>i(o,s)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};$t.create=(t,e,n)=>new $t({left:t,right:e,typeName:D.ZodIntersection,...G(n)});var ot=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 o=[...r.data].map((s,a)=>{let l=this._def.items[a]||this._def.rest;return l?l._parse(new Fe(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(o).then(s=>we.mergeArray(n,s)):we.mergeArray(n,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};ot.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ot({items:t,typeName:D.ZodTuple,rest:null,...G(e)})};var Wr=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 i=[],o=this._def.keyType,s=this._def.valueType;for(let a in r.data)i.push({key:o._parse(new Fe(r,a,r.path,a)),value:s._parse(new Fe(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?we.mergeObjectAsync(n,i):we.mergeObjectSync(n,i)}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:St.create(),valueType:e,typeName:D.ZodRecord,...G(n)})}},En=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 i=this._def.keyType,o=this._def.valueType,s=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new Fe(r,a,r.path,[c,"key"])),value:o._parse(new Fe(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,p=await l.value;if(c.status==="aborted"||p.status==="aborted")return P;(c.status==="dirty"||p.status==="dirty")&&n.dirty(),a.set(c.value,p.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let l of s){let c=l.key,p=l.value;if(c.status==="aborted"||p.status==="aborted")return P;(c.status==="dirty"||p.status==="dirty")&&n.dirty(),a.set(c.value,p.value)}return{status:n.value,value:a}}}};En.create=(t,e,n)=>new En({valueType:e,keyType:t,typeName:D.ZodMap,...G(n)});var Tn=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 i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(k(r,{code:_.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(k(r,{code:_.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());let o=this._def.valueType;function s(l){let c=new Set;for(let p of l){if(p.status==="aborted")return P;p.status==="dirty"&&n.dirty(),c.add(p.value)}return{status:n.value,value:c}}let a=[...r.data.values()].map((l,c)=>o._parse(new Fe(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)}};Tn.create=(t,e)=>new Tn({valueType:t,minSize:null,maxSize:null,typeName:D.ZodSet,...G(e)});var Xr=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 Zn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,bn(),pt].filter(c=>!!c),issueData:{code:_.invalid_arguments,argumentsError:l}})}function i(a,l){return Zn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,bn(),pt].filter(c=>!!c),issueData:{code:_.invalid_return_type,returnTypeError:l}})}let o={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof kt){let a=this;return Ae(async function(...l){let c=new Oe([]),p=await a._def.args.parseAsync(l,o).catch(f=>{throw c.addIssue(r(l,f)),c}),m=await Reflect.apply(s,this,p);return await a._def.returns._def.type.parseAsync(m,o).catch(f=>{throw c.addIssue(i(m,f)),c})})}else{let a=this;return Ae(function(...l){let c=a._def.args.safeParse(l,o);if(!c.success)throw new Oe([r(l,c.error)]);let p=Reflect.apply(s,this,c.data),m=a._def.returns.safeParse(p,o);if(!m.success)throw new Oe([i(p,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:ot.create(e).rest(ft.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||ot.create([]).rest(ft.create()),returns:n||ft.create(),typeName:D.ZodFunction,...G(r)})}},Vt=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})}};Vt.create=(t,e)=>new Vt({getter:t,typeName:D.ZodLazy,...G(e)});var Bt=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}};Bt.create=(t,e)=>new Bt({value:t,typeName:D.ZodLiteral,...G(e)});function Xl(t,e){return new jt({values:t,typeName:D.ZodEnum,...G(e)})}var jt=class t extends ${_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return k(n,{expected:B.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 Ae(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})}};jt.create=Xl;var qt=class extends ${_parse(e){let n=B.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==C.string&&r.parsedType!==C.number){let i=B.objectValues(n);return k(r,{expected:B.joinValues(i),received:r.parsedType,code:_.invalid_type}),P}if(this._cache||(this._cache=new Set(B.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let i=B.objectValues(n);return k(r,{received:r.data,code:_.invalid_enum_value,options:i}),P}return Ae(e.data)}get enum(){return this._def.values}};qt.create=(t,e)=>new qt({values:t,typeName:D.ZodNativeEnum,...G(e)});var kt=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 Ae(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}};kt.create=(t,e)=>new kt({type:t,typeName:D.ZodPromise,...G(e)});var $e=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),i=this._def.effect||null,o={addIssue:s=>{k(r,s),s.fatal?n.abort():n.dirty()},get path(){return r.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){let s=i.transform(r.data,o);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"?Lt(l.value):n.value==="dirty"?Lt(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"?Lt(a.value):n.value==="dirty"?Lt(a.value):a}}if(i.type==="refinement"){let s=a=>{let l=i.refinement(a,o);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(i.type==="transform")if(r.common.async===!1){let s=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Tt(s))return P;let a=i.transform(s.value,o);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=>Tt(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:n.value,value:a})):P);B.assertNever(i)}};$e.create=(t,e,n)=>new $e({schema:t,typeName:D.ZodEffects,effect:e,...G(n)});$e.createWithPreprocess=(t,e,n)=>new $e({schema:e,effect:{type:"preprocess",transform:t},typeName:D.ZodEffects,...G(n)});var Ge=class extends ${_parse(e){return this._getType(e)===C.undefined?Ae(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ge.create=(t,e)=>new Ge({innerType:t,typeName:D.ZodOptional,...G(e)});var st=class extends ${_parse(e){return this._getType(e)===C.null?Ae(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};st.create=(t,e)=>new st({innerType:t,typeName:D.ZodNullable,...G(e)});var Wt=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}};Wt.create=(t,e)=>new Wt({innerType:t,typeName:D.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...G(e)});var Xt=class extends ${_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return yn(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Oe(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Oe(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Xt.create=(t,e)=>new Xt({innerType:t,typeName:D.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...G(e)});var Sn=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}}};Sn.create=t=>new Sn({typeName:D.ZodNaN,...G(t)});var Xp=Symbol("zod_brand"),Jn=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}},Qn=class t extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?P:o.status==="dirty"?(n.dirty(),Lt(o.value)):this._def.out._parseAsync({data:o.value,path:r.path,parent:r})})();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?P:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:D.ZodPipeline})}},Kt=class extends ${_parse(e){let n=this._def.innerType._parse(e),r=i=>(Tt(i)&&(i.value=Object.freeze(i.value)),i);return yn(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}};Kt.create=(t,e)=>new Kt({innerType:t,typeName:D.ZodReadonly,...G(e)});function Bl(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Kl(t,e={},n){return t?At.create().superRefine((r,i)=>{let o=t(r);if(o instanceof Promise)return o.then(s=>{if(!s){let a=Bl(e,r),l=a.fatal??n??!0;i.addIssue({code:"custom",...a,fatal:l})}});if(!o){let s=Bl(e,r),a=s.fatal??n??!0;i.addIssue({code:"custom",...s,fatal:a})}}):At.create()}var Kp={object:Me.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 Yp=(t,e={message:`Input not instance of ${t.name}`})=>Kl(n=>n instanceof t,e),Yl=St.create,Zl=Pt.create,Zp=Sn.create,Jp=Dt.create,Jl=Ut.create,Qp=Ht.create,eh=wn.create,th=zt.create,nh=Gt.create,rh=At.create,ih=ft.create,oh=Xe.create,sh=_n.create,ah=mt.create,lh=Me.create,ch=Me.strictCreate,dh=Ft.create,uh=qr.create,ph=$t.create,hh=ot.create,fh=Wr.create,mh=En.create,gh=Tn.create,vh=Xr.create,bh=Vt.create,yh=Bt.create,xh=jt.create,wh=qt.create,_h=kt.create,Eh=$e.create,Th=Ge.create,Sh=st.create,Ah=$e.createWithPreprocess,kh=Qn.create,Ch=()=>Yl().optional(),Ih=()=>Zl().optional(),Rh=()=>Jl().optional(),Nh={string:(t=>St.create({...t,coerce:!0})),number:(t=>Pt.create({...t,coerce:!0})),boolean:(t=>Ut.create({...t,coerce:!0})),bigint:(t=>Dt.create({...t,coerce:!0})),date:(t=>Ht.create({...t,coerce:!0}))};var Oh=P;var Mh=d.object({name:d.string(),arguments:d.string()}),Lh=d.object({id:d.string(),type:d.literal("function"),function:Mh,encryptedValue:d.string().optional()}),Kr=d.object({id:d.string(),role:d.string(),content:d.string().optional(),name:d.string().optional(),encryptedValue:d.string().optional()}),Ph=d.object({type:d.literal("text"),text:d.string()}),Dh=d.object({type:d.literal("data"),value:d.string(),mimeType:d.string()}),Uh=d.object({type:d.literal("url"),value:d.string(),mimeType:d.string().optional()}),Yr=d.discriminatedUnion("type",[Dh,Uh]),Hh=d.object({type:d.literal("image"),source:Yr,metadata:d.unknown().optional()}),zh=d.object({type:d.literal("audio"),source:Yr,metadata:d.unknown().optional()}),Gh=d.object({type:d.literal("video"),source:Yr,metadata:d.unknown().optional()}),Fh=d.object({type:d.literal("document"),source:Yr,metadata:d.unknown().optional()});var Ql=d.object({type:d.literal("binary"),mimeType:d.string(),id:d.string().optional(),url:d.string().optional(),data:d.string().optional(),filename:d.string().optional()}),ec=(t,e)=>{!t.id&&!t.url&&!t.data&&e.addIssue({code:d.ZodIssueCode.custom,message:"BinaryInputContent requires at least one of id, url, or data.",path:["id"]})},ex=Ql.superRefine((t,e)=>{ec(t,e)}),$h=d.discriminatedUnion("type",[Ph,Hh,zh,Gh,Fh,Ql]),Vh=$h.superRefine((t,e)=>{t.type==="binary"&&ec(t,e)}),Bh=Kr.extend({role:d.literal("developer"),content:d.string()}),jh=Kr.extend({role:d.literal("system"),content:d.string()}),qh=Kr.extend({role:d.literal("assistant"),content:d.string().optional(),toolCalls:d.array(Lh).optional()}),Wh=Kr.extend({role:d.literal("user"),content:d.union([d.string(),d.array(Vh)])}),Xh=d.object({id:d.string(),content:d.string(),role:d.literal("tool"),toolCallId:d.string(),error:d.string().optional(),encryptedValue:d.string().optional()}),Kh=d.object({id:d.string(),role:d.literal("activity"),activityType:d.string(),content:d.record(d.any())}),Yh=d.object({id:d.string(),role:d.literal("reasoning"),content:d.string(),encryptedValue:d.string().optional()}),tc=d.discriminatedUnion("role",[Bh,jh,qh,Wh,Xh,Kh,Yh]),tx=d.union([d.literal("developer"),d.literal("system"),d.literal("assistant"),d.literal("user"),d.literal("tool"),d.literal("activity"),d.literal("reasoning")]),Zh=d.object({description:d.string(),value:d.string()}),nc=d.object({name:d.string(),description:d.string(),parameters:d.any(),metadata:d.record(d.any()).optional()}),Jh=d.object({id:d.string(),reason:d.string(),message:d.string().optional(),toolCallId:d.string().optional(),responseSchema:d.record(d.any()).optional(),expiresAt:d.string().optional(),metadata:d.record(d.any()).optional()}),Qh=d.object({interruptId:d.string(),status:d.enum(["resolved","cancelled"]),payload:d.any().optional()}),ef=d.object({threadId:d.string(),runId:d.string(),parentRunId:d.string().optional(),state:d.any(),messages:d.array(tc),tools:d.array(nc),context:d.array(Zh),forwardedProps:d.any(),resume:d.array(Qh).optional()}),tf=d.any(),te=class extends Error{constructor(t){super(t)}},As=class extends te{constructor(){super("Connect not implemented. This method is not supported by the current agent.")}},nf=d.object({name:d.string(),description:d.string().optional()}),rf=d.object({name:d.string().optional(),type:d.string().optional(),description:d.string().optional(),version:d.string().optional(),provider:d.string().optional(),documentationUrl:d.string().optional(),metadata:d.record(d.unknown()).optional()}),of=d.object({streaming:d.boolean().optional(),websocket:d.boolean().optional(),httpBinary:d.boolean().optional(),pushNotifications:d.boolean().optional(),resumable:d.boolean().optional()}),sf=d.object({supported:d.boolean().optional(),items:d.array(nc).optional(),parallelCalls:d.boolean().optional(),clientProvided:d.boolean().optional()}),af=d.object({structuredOutput:d.boolean().optional(),supportedMimeTypes:d.array(d.string()).optional()}),lf=d.object({snapshots:d.boolean().optional(),deltas:d.boolean().optional(),memory:d.boolean().optional(),persistentState:d.boolean().optional()}),cf=d.object({supported:d.boolean().optional(),delegation:d.boolean().optional(),handoffs:d.boolean().optional(),subAgents:d.array(nf).optional()}),df=d.object({supported:d.boolean().optional(),streaming:d.boolean().optional(),encrypted:d.boolean().optional()}),uf=d.object({image:d.boolean().optional(),audio:d.boolean().optional(),video:d.boolean().optional(),pdf:d.boolean().optional(),file:d.boolean().optional()}),pf=d.object({image:d.boolean().optional(),audio:d.boolean().optional()}),hf=d.object({input:uf.optional(),output:pf.optional()}),ff=d.object({codeExecution:d.boolean().optional(),sandboxed:d.boolean().optional(),maxIterations:d.number().optional(),maxExecutionTime:d.number().optional()}),mf=d.object({supported:d.boolean().optional(),approvals:d.boolean().optional(),interventions:d.boolean().optional(),feedback:d.boolean().optional(),interrupts:d.boolean().optional(),approveWithEdits:d.boolean().optional()}),nx=d.object({identity:rf.optional(),transport:of.optional(),tools:sf.optional(),output:af.optional(),state:lf.optional(),multiAgent:cf.optional(),reasoning:df.optional(),multimodal:hf.optional(),execution:ff.optional(),humanInTheLoop:mf.optional(),custom:d.record(d.unknown()).optional()}),rc=d.union([d.literal("developer"),d.literal("system"),d.literal("assistant"),d.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=d.object({type:d.nativeEnum(v),timestamp:d.number().optional(),rawEvent:d.any().optional()}).passthrough(),gf=X.extend({type:d.literal(v.TEXT_MESSAGE_START),messageId:d.string(),role:rc.default("assistant"),name:d.string().optional()}),ic=X.extend({type:d.literal(v.TEXT_MESSAGE_CONTENT),messageId:d.string(),delta:d.string()}),vf=X.extend({type:d.literal(v.TEXT_MESSAGE_END),messageId:d.string()}),bf=X.extend({type:d.literal(v.TEXT_MESSAGE_CHUNK),messageId:d.string().optional(),role:rc.optional(),delta:d.string().optional(),name:d.string().optional()}),yf=X.extend({type:d.literal(v.THINKING_TEXT_MESSAGE_START)}),xf=ic.omit({messageId:!0,type:!0}).extend({type:d.literal(v.THINKING_TEXT_MESSAGE_CONTENT)}),wf=X.extend({type:d.literal(v.THINKING_TEXT_MESSAGE_END)}),_f=X.extend({type:d.literal(v.TOOL_CALL_START),toolCallId:d.string(),toolCallName:d.string(),parentMessageId:d.string().optional()}),Ef=X.extend({type:d.literal(v.TOOL_CALL_ARGS),toolCallId:d.string(),delta:d.string()}),Tf=X.extend({type:d.literal(v.TOOL_CALL_END),toolCallId:d.string()}),Sf=X.extend({messageId:d.string(),type:d.literal(v.TOOL_CALL_RESULT),toolCallId:d.string(),content:d.string(),role:d.literal("tool").optional()}),Af=X.extend({type:d.literal(v.TOOL_CALL_CHUNK),toolCallId:d.string().optional(),toolCallName:d.string().optional(),parentMessageId:d.string().optional(),delta:d.string().optional()}),kf=X.extend({type:d.literal(v.THINKING_START),title:d.string().optional()}),Cf=X.extend({type:d.literal(v.THINKING_END)}),If=X.extend({type:d.literal(v.STATE_SNAPSHOT),snapshot:tf}),Rf=X.extend({type:d.literal(v.STATE_DELTA),delta:d.array(d.any())}),Nf=X.extend({type:d.literal(v.MESSAGES_SNAPSHOT),messages:d.array(tc)}),Of=X.extend({type:d.literal(v.ACTIVITY_SNAPSHOT),messageId:d.string(),activityType:d.string(),content:d.record(d.any()),replace:d.boolean().optional().default(!0)}),Mf=X.extend({type:d.literal(v.ACTIVITY_DELTA),messageId:d.string(),activityType:d.string(),patch:d.array(d.any())}),Lf=X.extend({type:d.literal(v.RAW),event:d.any(),source:d.string().optional()}),Pf=X.extend({type:d.literal(v.CUSTOM),name:d.string(),value:d.any()}),Df=X.extend({type:d.literal(v.RUN_STARTED),threadId:d.string(),runId:d.string(),parentRunId:d.string().optional(),input:ef.optional()}),Uf=d.object({type:d.literal("success")}).strict(),Hf=d.object({type:d.literal("interrupt"),interrupts:d.array(Jh).min(1)}).strict(),zf=d.discriminatedUnion("type",[Uf,Hf]),Gf=X.extend({type:d.literal(v.RUN_FINISHED),threadId:d.string(),runId:d.string(),result:d.any().optional(),outcome:zf.nullable().optional().transform(t=>t??void 0)}),Ff=X.extend({type:d.literal(v.RUN_ERROR),message:d.string(),code:d.string().optional()}),$f=X.extend({type:d.literal(v.STEP_STARTED),stepName:d.string()}),Vf=X.extend({type:d.literal(v.STEP_FINISHED),stepName:d.string()}),Bf=d.union([d.literal("tool-call"),d.literal("message")]),jf=X.extend({type:d.literal(v.REASONING_START),messageId:d.string()}),qf=X.extend({type:d.literal(v.REASONING_MESSAGE_START),messageId:d.string(),role:d.literal("reasoning")}),Wf=X.extend({type:d.literal(v.REASONING_MESSAGE_CONTENT),messageId:d.string(),delta:d.string()}),Xf=X.extend({type:d.literal(v.REASONING_MESSAGE_END),messageId:d.string()}),Kf=X.extend({type:d.literal(v.REASONING_MESSAGE_CHUNK),messageId:d.string().optional(),delta:d.string().optional()}),Yf=X.extend({type:d.literal(v.REASONING_END),messageId:d.string()}),Zf=X.extend({type:d.literal(v.REASONING_ENCRYPTED_VALUE),subtype:Bf,entityId:d.string(),encryptedValue:d.string()}),Zr=d.discriminatedUnion("type",[gf,ic,vf,bf,kf,Cf,yf,xf,wf,_f,Ef,Tf,Af,Sf,If,Rf,Nf,Of,Mf,Lf,Pf,Df,Gf,Ff,$f,Vf,jf,qf,Wf,Xf,Kf,Yf,Zf]);var ks={};ls(ks,{JsonPatchError:()=>he,_areEquals:()=>nr,applyOperation:()=>Yt,applyPatch:()=>ii,applyReducer:()=>nm,deepClone:()=>em,getValueByPointer:()=>ni,validate:()=>sc,validator:()=>ri});var Jf=(function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var o in i)i.hasOwnProperty(o)&&(r[o]=i[o])},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)}})(),Qf=Object.prototype.hasOwnProperty;function Qr(t,e){return Qf.call(t,e)}function ei(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 i in t)Qr(t,i)&&r.push(i);return r}function _e(t){switch(typeof t){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t}}function ti(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 at(t){return t.indexOf("/")===-1&&t.indexOf("~")===-1?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function er(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Jr(t){if(t===void 0)return!0;if(t){if(Array.isArray(t)){for(var e=0,n=t.length;e<n;e++)if(Jr(t[e]))return!0}else if(typeof t=="object"){for(var r=ei(t),i=r.length,o=0;o<i;o++)if(Jr(t[r[o]]))return!0}}return!1}function oc(t,e){var n=[t];for(var r in e){var i=typeof e[r]=="object"?JSON.stringify(e[r],null,2):e[r];typeof i<"u"&&n.push(r+": "+i)}return n.join(`
|
|
2
|
-
`)}var tr=(function(t){Jf(e,t);function e(n,r,i,o,s){var a=this.constructor,l=t.call(this,oc(n,{name:r,index:i,operation:o,tree:s}))||this;return l.name=r,l.index=i,l.operation=o,l.tree=s,Object.setPrototypeOf(l,a.prototype),l.message=oc(n,{name:r,index:i,operation:o,tree:s}),l}return e})(Error);var he=tr,em=_e,An={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=ni(n,this.path);r&&(r=_e(r));var i=Yt(n,{op:"remove",path:this.from}).removed;return Yt(n,{op:"add",path:this.path,value:i}),{newDocument:n,removed:r}},copy:function(t,e,n){var r=ni(n,this.from);return Yt(n,{op:"add",path:this.path,value:_e(r)}),{newDocument:n}},test:function(t,e,n){return{newDocument:n,test:nr(t[e],this.value)}},_get:function(t,e,n){return this.value=t[e],{newDocument:n}}},tm={add:function(t,e,n){return ti(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:An.move,copy:An.copy,test:An.test,_get:An._get};function ni(t,e){if(e=="")return t;var n={op:"_get",path:e};return Yt(t,n),n.value}function Yt(t,e,n,r,i,o){if(n===void 0&&(n=!1),r===void 0&&(r=!0),i===void 0&&(i=!0),o===void 0&&(o=0),n&&(typeof n=="function"?n(e,0,t,e.path):ri(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=ni(t,e.from),e.op==="move"&&(s.removed=t),s;if(e.op==="test"){if(s.test=nr(t,e.value),s.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",o,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",o,e,t);return s}}else{r||(t=_e(t));var a=e.path||"",l=a.split("/"),c=t,p=1,m=l.length,y=void 0,f=void 0,h=void 0;for(typeof n=="function"?h=n:h=ri;;){if(f=l[p],f&&f.indexOf("~")!=-1&&(f=er(f)),i&&(f=="__proto__"||f=="prototype"&&p>0&&l[p-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&y===void 0&&(c[f]===void 0?y=l.slice(0,p).join("/"):p==m-1&&(y=e.path),y!==void 0&&h(e,0,t,y)),p++,Array.isArray(c)){if(f==="-")f=c.length;else{if(n&&!ti(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",o,e,t);ti(f)&&(f=~~f)}if(p>=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",o,e,t);var s=tm[e.op].call(e,c,f,t);if(s.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return s}}else if(p>=m){var s=An[e.op].call(e,c,f,t);if(s.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return s}if(c=c[f],n&&p<m&&(!c||typeof c!="object"))throw new he("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",o,e,t)}}}function ii(t,e,n,r,i){if(r===void 0&&(r=!0),i===void 0&&(i=!0),n&&!Array.isArray(e))throw new he("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(t=_e(t));for(var o=new Array(e.length),s=0,a=e.length;s<a;s++)o[s]=Yt(t,e[s],n,!0,i,s),t=o[s].newDocument;return o.newDocument=t,o}function nm(t,e,n){var r=Yt(t,e);if(r.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",n,e,t);return r.newDocument}function ri(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(An[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")&&Jr(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 i=t.path.split("/").length,o=r.split("/").length;if(i!==o+1&&i!==o)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=sc([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 sc(t,e,n){try{if(!Array.isArray(t))throw new he("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)ii(_e(e),_e(t),n||!0);else{n=n||ri;for(var r=0;r<t.length;r++)n(t[r],r,e,void 0)}}catch(i){if(i instanceof he)return i;throw i}}function nr(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),i,o,s;if(n&&r){if(o=t.length,o!=e.length)return!1;for(i=o;i--!==0;)if(!nr(t[i],e[i]))return!1;return!0}if(n!=r)return!1;var a=Object.keys(t);if(o=a.length,o!==Object.keys(e).length)return!1;for(i=o;i--!==0;)if(!e.hasOwnProperty(a[i]))return!1;for(i=o;i--!==0;)if(s=a[i],!nr(t[s],e[s]))return!1;return!0}return t!==t&&e!==e}var Ns={};ls(Ns,{compare:()=>dm,generate:()=>Cs,observe:()=>cm,unobserve:()=>lm});var Is=new WeakMap,rm=(function(){function t(e){this.observers=new Map,this.obj=e}return t})(),im=(function(){function t(e,n){this.callback=e,this.observer=n}return t})();function om(t){return Is.get(t)}function sm(t,e){return t.observers.get(e)}function am(t,e){t.observers.delete(e.callback)}function lm(t,e){e.unobserve()}function cm(t,e){var n=[],r,i=om(t);if(!i)i=new rm(t),Is.set(t,i);else{var o=sm(i,e);r=o&&o.observer}if(r)return r;if(r={},i.value=_e(t),e){r.callback=e,r.next=null;var s=function(){Cs(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(){Cs(r),clearTimeout(r.next),am(i,r),typeof window<"u"&&(window.removeEventListener("mouseup",a),window.removeEventListener("keyup",a),window.removeEventListener("mousedown",a),window.removeEventListener("keydown",a),window.removeEventListener("change",a))},i.observers.set(e,new im(e,r)),r}function Cs(t,e){e===void 0&&(e=!1);var n=Is.get(t.object);Rs(n.value,t.object,t.patches,"",e),t.patches.length&&ii(n.value,t.patches);var r=t.patches;return r.length>0&&(t.patches=[],t.callback&&t.callback(r)),r}function Rs(t,e,n,r,i){if(e!==t){typeof e.toJSON=="function"&&(e=e.toJSON());for(var o=ei(e),s=ei(t),a=!1,l=!1,c=s.length-1;c>=0;c--){var p=s[c],m=t[p];if(Qr(e,p)&&!(e[p]===void 0&&m!==void 0&&Array.isArray(e)===!1)){var y=e[p];typeof m=="object"&&m!=null&&typeof y=="object"&&y!=null&&Array.isArray(m)===Array.isArray(y)?Rs(m,y,n,r+"/"+at(p),i):m!==y&&(a=!0,i&&n.push({op:"test",path:r+"/"+at(p),value:_e(m)}),n.push({op:"replace",path:r+"/"+at(p),value:_e(y)}))}else Array.isArray(t)===Array.isArray(e)?(i&&n.push({op:"test",path:r+"/"+at(p),value:_e(m)}),n.push({op:"remove",path:r+"/"+at(p)}),l=!0):(i&&n.push({op:"test",path:r,value:t}),n.push({op:"replace",path:r,value:e}),a=!0)}if(!(!l&&o.length==s.length))for(var c=0;c<o.length;c++){var p=o[c];!Qr(t,p)&&e[p]!==void 0&&n.push({op:"add",path:r+"/"+at(p),value:_e(e[p])})}}}function dm(t,e,n){n===void 0&&(n=!1);var r=[];return Rs(t,e,r,"",n),r}var oi=Object.assign({},ks,Ns,{JsonPatchError:tr,deepClone:_e,escapePathComponent:at,unescapePathComponent:er});var Os=function(t,e){return Os=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},Os(t,e)};function lt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Os(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function ac(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(p){try{c(r.next(p))}catch(m){s(m)}}function l(p){try{c(r.throw(p))}catch(m){s(m)}}function c(p){p.done?o(p.value):i(p.value).then(a,l)}c((r=r.apply(t,e||[])).next())})}function si(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,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(p){return l([c,p])}}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,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(p){c=[6,p],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function gt(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 kn(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,o=[],s;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)o.push(i.value)}catch(a){s={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(s)throw s.error}}return o}function Cn(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,o;r<i;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}function Zt(t){return this instanceof Zt?(this.v=t,this):new Zt(t)}function lc(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(t,e||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",s),i[Symbol.asyncIterator]=function(){return this},i;function s(f){return function(h){return Promise.resolve(h).then(f,m)}}function a(f,h){r[f]&&(i[f]=function(g){return new Promise(function(x,S){o.push([f,g,x,S])>1||l(f,g)})},h&&(i[f]=h(i[f])))}function l(f,h){try{c(r[f](h))}catch(g){y(o[0][3],g)}}function c(f){f.value instanceof Zt?Promise.resolve(f.value.v).then(p,m):y(o[0][2],f)}function p(f){l("next",f)}function m(f){l("throw",f)}function y(f,h){f(h),o.shift(),o.length&&l(o[0][0],o[0][1])}}function cc(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 gt=="function"?gt(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(o){n[o]=t[o]&&function(s){return new Promise(function(a,l){s=t[o](s),i(a,l,s.done,s.value)})}}function i(o,s,a,l){Promise.resolve(l).then(function(c){o({value:c,done:a})},s)}}function V(t){return typeof t=="function"}function In(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 ai=In(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
3
|
-
`+n.map(function(r,
|
|
4
|
-
`):"",this.name="UnsubscriptionError",this.errors=n}});function rr(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var Rn=(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,i,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=gt(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 p=this.initialTeardown;if(V(p))try{p()}catch(g){o=g instanceof ai?g.errors:[g]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var y=gt(m),f=y.next();!f.done;f=y.next()){var h=f.value;try{dc(h)}catch(g){o=o??[],g instanceof ai?o=Cn(Cn([],kn(o)),kn(g.errors)):o.push(g)}}}catch(g){r={error:g}}finally{try{f&&!f.done&&(i=y.return)&&i.call(y)}finally{if(r)throw r.error}}}if(o)throw new ai(o)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)dc(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)&&rr(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&rr(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=(function(){var e=new t;return e.closed=!0,e})(),t})();var Ms=Rn.EMPTY;function li(t){return t instanceof Rn||t&&"closed"in t&&V(t.remove)&&V(t.add)&&V(t.unsubscribe)}function dc(t){V(t)?t():t.unsubscribe()}var Ke={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Nn={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=Nn.delegate;return i?.setTimeout?i.setTimeout.apply(i,Cn([t,e],kn(n))):setTimeout.apply(void 0,Cn([t,e],kn(n)))},clearTimeout:function(t){var e=Nn.delegate;return(e?.clearTimeout||clearTimeout)(t)},delegate:void 0};function ci(t){Nn.setTimeout(function(){var e=Ke.onUnhandledError;if(e)e(t);else throw t})}function ir(){}var uc=(function(){return Ls("C",void 0,void 0)})();function pc(t){return Ls("E",void 0,t)}function hc(t){return Ls("N",t,void 0)}function Ls(t,e,n){return{kind:t,value:e,error:n}}var Jt=null;function On(t){if(Ke.useDeprecatedSynchronousErrorHandling){var e=!Jt;if(e&&(Jt={errorThrown:!1,error:null}),t(),e){var n=Jt,r=n.errorThrown,i=n.error;if(Jt=null,r)throw i}}else t()}function fc(t){Ke.useDeprecatedSynchronousErrorHandling&&Jt&&(Jt.errorThrown=!0,Jt.error=t)}var or=(function(t){lt(e,t);function e(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,li(n)&&n.add(r)):r.destination=fm,r}return e.create=function(n,r,i){return new ui(n,r,i)},e.prototype.next=function(n){this.isStopped?Ds(hc(n),this):this._next(n)},e.prototype.error=function(n){this.isStopped?Ds(pc(n),this):(this.isStopped=!0,this._error(n))},e.prototype.complete=function(){this.isStopped?Ds(uc,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})(Rn);var um=Function.prototype.bind;function Ps(t,e){return um.call(t,e)}var pm=(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){di(r)}},t.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(r){di(r)}else di(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){di(n)}},t})(),ui=(function(t){lt(e,t);function e(n,r,i){var o=t.call(this)||this,s;if(V(n)||!n)s={next:n??void 0,error:r??void 0,complete:i??void 0};else{var a;o&&Ke.useDeprecatedNextContext?(a=Object.create(n),a.unsubscribe=function(){return o.unsubscribe()},s={next:n.next&&Ps(n.next,a),error:n.error&&Ps(n.error,a),complete:n.complete&&Ps(n.complete,a)}):s=n}return o.destination=new pm(s),o}return e})(or);function di(t){Ke.useDeprecatedSynchronousErrorHandling?fc(t):ci(t)}function hm(t){throw t}function Ds(t,e){var n=Ke.onStoppedNotification;n&&Nn.setTimeout(function(){return n(t,e)})}var fm={closed:!0,next:ir,error:hm,complete:ir};var Mn=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Ln(t){return t}function pi(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Us(t)}function Us(t){return t.length===0?Ln:t.length===1?t[0]:function(n){return t.reduce(function(r,i){return i(r)},n)}}var ne=(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 i=this,o=gm(e)?e:new ui(e,n,r);return On(function(){var s=i,a=s.operator,l=s.source;o.add(a?a.call(o,l):l?i._subscribe(o):i._trySubscribe(o))}),o},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=mc(n),new n(function(i,o){var s=new ui({next:function(a){try{e(a)}catch(l){o(l),s.unsubscribe()}},error:o,complete:i});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[Mn]=function(){return this},t.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return Us(e)(this)},t.prototype.toPromise=function(e){var n=this;return e=mc(e),new e(function(r,i){var o;n.subscribe(function(s){return o=s},function(s){return i(s)},function(){return r(o)})})},t.create=function(e){return new t(e)},t})();function mc(t){var e;return(e=t??Ke.Promise)!==null&&e!==void 0?e:Promise}function mm(t){return t&&V(t.next)&&V(t.error)&&V(t.complete)}function gm(t){return t&&t instanceof or||mm(t)&&li(t)}function vm(t){return V(t?.lift)}function fe(t){return function(e){if(vm(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,i){return new bm(t,e,n,r,i)}var bm=(function(t){lt(e,t);function e(n,r,i,o,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(p){n.error(p)}}:t.prototype._next,l._error=o?function(c){try{o(c)}catch(p){n.error(p)}finally{this.unsubscribe()}}:t.prototype._error,l._complete=i?function(){try{i()}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})(or);var gc=In(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var ct=(function(t){lt(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 vc(this,this);return r.operator=n,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new gc},e.prototype.next=function(n){var r=this;On(function(){var i,o;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=gt(r.currentObservers),a=s.next();!a.done;a=s.next()){var l=a.value;l.next(n)}}catch(c){i={error:c}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}})},e.prototype.error=function(n){var r=this;On(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var i=r.observers;i.length;)i.shift().error(n)}})},e.prototype.complete=function(){var n=this;On(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,i=this,o=i.hasError,s=i.isStopped,a=i.observers;return o||s?Ms:(this.currentObservers=null,a.push(n),new Rn(function(){r.currentObservers=null,rr(a,n)}))},e.prototype._checkFinalizedStatuses=function(n){var r=this,i=r.hasError,o=r.thrownError,s=r.isStopped;i?n.error(o):s&&n.complete()},e.prototype.asObservable=function(){var n=new ne;return n.source=this,n},e.create=function(n,r){return new vc(n,r)},e})(ne);var vc=(function(t){lt(e,t);function e(n,r){var i=t.call(this)||this;return i.destination=n,i.source=r,i}return e.prototype.next=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,n)},e.prototype.error=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.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,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&i!==void 0?i:Ms},e})(ct);var Hs={now:function(){return(Hs.delegate||Date).now()},delegate:void 0};var hi=(function(t){lt(e,t);function e(n,r,i){n===void 0&&(n=1/0),r===void 0&&(r=1/0),i===void 0&&(i=Hs);var o=t.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=i,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return e.prototype.next=function(n){var r=this,i=r.isStopped,o=r._buffer,s=r._infiniteTimeWindow,a=r._timestampProvider,l=r._windowTime;i||(o.push(n),!s&&o.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),i=this,o=i._infiniteTimeWindow,s=i._buffer,a=s.slice(),l=0;l<a.length&&!n.closed;l+=o?1:2)n.next(a[l]);return this._checkFinalizedStatuses(n),r},e.prototype._trimBuffer=function(){var n=this,r=n._bufferSize,i=n._timestampProvider,o=n._buffer,s=n._infiniteTimeWindow,a=(s?1:2)*r;if(r<1/0&&a<o.length&&o.splice(0,o.length-a),!s){for(var l=i.now(),c=0,p=1;p<o.length&&o[p]<=l;p+=2)c=p;c&&o.splice(0,c+1)}},e})(ct);var fi=new ne(function(t){return t.complete()});function bc(t){return t&&V(t.schedule)}function ym(t){return t[t.length-1]}function yc(t){return bc(ym(t))?t.pop():void 0}var mi=(function(t){return t&&typeof t.length=="number"&&typeof t!="function"});function gi(t){return V(t?.then)}function vi(t){return V(t[Mn])}function bi(t){return Symbol.asyncIterator&&V(t?.[Symbol.asyncIterator])}function yi(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 xm(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var xi=xm();function wi(t){return V(t?.[xi])}function _i(t){return lc(this,arguments,function(){var n,r,i,o;return si(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,Zt(n.read())];case 3:return r=s.sent(),i=r.value,o=r.done,o?[4,Zt(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,Zt(i)];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 Ei(t){return V(t?.getReader)}function ve(t){if(t instanceof ne)return t;if(t!=null){if(vi(t))return wm(t);if(mi(t))return _m(t);if(gi(t))return Em(t);if(bi(t))return xc(t);if(wi(t))return Tm(t);if(Ei(t))return Sm(t)}throw yi(t)}function wm(t){return new ne(function(e){var n=t[Mn]();if(V(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function _m(t){return new ne(function(e){for(var n=0;n<t.length&&!e.closed;n++)e.next(t[n]);e.complete()})}function Em(t){return new ne(function(e){t.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,ci)})}function Tm(t){return new ne(function(e){var n,r;try{for(var i=gt(t),o=i.next();!o.done;o=i.next()){var s=o.value;if(e.next(s),e.closed)return}}catch(a){n={error:a}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}e.complete()})}function xc(t){return new ne(function(e){Am(t,e).catch(function(n){return e.error(n)})})}function Sm(t){return xc(_i(t))}function Am(t,e){var n,r,i,o;return ac(this,void 0,void 0,function(){var s,a;return si(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=cc(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(),i={error:a},[3,11];case 6:return l.trys.push([6,,9,10]),r&&!r.done&&(o=n.return)?[4,o.call(n)]:[3,8];case 7:l.sent(),l.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function Ve(t,e,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var o=e.schedule(function(){n(),i?t.add(this.schedule(null,r)):this.unsubscribe()},r);if(t.add(o),!i)return o}function Ti(t,e){return e===void 0&&(e=0),fe(function(n,r){n.subscribe(ge(r,function(i){return Ve(r,t,function(){return r.next(i)},e)},function(){return Ve(r,t,function(){return r.complete()},e)},function(i){return Ve(r,t,function(){return r.error(i)},e)}))})}function Si(t,e){return e===void 0&&(e=0),fe(function(n,r){r.add(t.schedule(function(){return n.subscribe(r)},e))})}function wc(t,e){return ve(t).pipe(Si(e),Ti(e))}function _c(t,e){return ve(t).pipe(Si(e),Ti(e))}function Ec(t,e){return new ne(function(n){var r=0;return e.schedule(function(){r===t.length?n.complete():(n.next(t[r++]),n.closed||this.schedule())})})}function Tc(t,e){return new ne(function(n){var r;return Ve(n,e,function(){r=t[xi](),Ve(n,e,function(){var i,o,s;try{i=r.next(),o=i.value,s=i.done}catch(a){n.error(a);return}s?n.complete():n.next(o)},0,!0)}),function(){return V(r?.return)&&r.return()}})}function Ai(t,e){if(!t)throw new Error("Iterable cannot be null");return new ne(function(n){Ve(n,e,function(){var r=t[Symbol.asyncIterator]();Ve(n,e,function(){r.next().then(function(i){i.done?n.complete():n.next(i.value)})},0,!0)})})}function Sc(t,e){return Ai(_i(t),e)}function Ac(t,e){if(t!=null){if(vi(t))return wc(t,e);if(mi(t))return Ec(t,e);if(gi(t))return _c(t,e);if(bi(t))return Ai(t,e);if(wi(t))return Tc(t,e);if(Ei(t))return Sc(t,e)}throw yi(t)}function Qt(t,e){return e?Ac(t,e):ve(t)}function ue(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=yc(t);return Qt(t,n)}function re(t,e){var n=V(t)?t:function(){return t},r=function(i){return i.error(n())};return new ne(e?function(i){return e.schedule(r,0,i)}:r)}var kc=In(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}});function ki(t,e){var n=typeof e=="object";return new Promise(function(r,i){var o=!1,s;t.subscribe({next:function(a){s=a,o=!0},error:i,complete:function(){o?r(s):n?r(e.defaultValue):i(new kc)}})})}function en(t,e){return fe(function(n,r){var i=0;n.subscribe(ge(r,function(o){r.next(t.call(e,o,i++))}))})}function Cc(t,e,n,r,i,o,s,a){var l=[],c=0,p=0,m=!1,y=function(){m&&!l.length&&!c&&e.complete()},f=function(g){return c<r?h(g):l.push(g)},h=function(g){o&&e.next(g),c++;var x=!1;ve(n(g,p++)).subscribe(ge(e,function(S){i?.(S),o?f(S):e.next(S)},function(){x=!0},void 0,function(){if(x)try{c--;for(var S=function(){var E=l.shift();s?Ve(e,s,function(){return h(E)}):h(E)};l.length&&c<r;)S();y()}catch(E){e.error(E)}}))};return t.subscribe(ge(e,f,function(){m=!0,y()})),function(){a?.()}}function Le(t,e,n){return n===void 0&&(n=1/0),V(e)?Le(function(r,i){return en(function(o,s){return e(r,o,i,s)})(ve(t(r,i)))},n):(typeof e=="number"&&(n=e),fe(function(r,i){return Cc(r,i,t,n)}))}function zs(t){return t===void 0&&(t=1/0),Le(Ln,t)}function Ci(t){return new ne(function(e){ve(t()).subscribe(e)})}function sr(t){return fe(function(e,n){var r=null,i=!1,o;r=e.subscribe(ge(n,void 0,void 0,function(s){o=ve(t(s,sr(t)(e))),r?(r.unsubscribe(),r=null,o.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,o.subscribe(n))})}function Ii(t,e){return V(e)?Le(t,e,1):Le(t,1)}function Gs(t){return fe(function(e,n){var r=!1;e.subscribe(ge(n,function(i){r=!0,n.next(i)},function(){r||n.next(t),n.complete()}))})}function tn(t){return fe(function(e,n){try{e.subscribe(n)}finally{n.add(t)}})}function Fs(t,e){return fe(function(n,r){var i=null,o=0,s=!1,a=function(){return s&&!i&&r.complete()};n.subscribe(ge(r,function(l){i?.unsubscribe();var c=0,p=o++;ve(t(l,p)).subscribe(i=ge(r,function(m){return r.next(e?e(l,m,p,c++):m)},function(){i=null,a()}))},function(){s=!0,a()}))})}function Ri(t){return fe(function(e,n){ve(t).subscribe(ge(n,function(){return n.complete()},ir)),!n.closed&&e.subscribe(n)})}function $s(t,e,n){var r=V(t)||e||n?{next:t,error:e,complete:n}:t;return r?fe(function(i,o){var s;(s=r.subscribe)===null||s===void 0||s.call(r);var a=!0;i.subscribe(ge(o,function(l){var c;(c=r.next)===null||c===void 0||c.call(r,l),o.next(l)},function(){var l;a=!1,(l=r.complete)===null||l===void 0||l.call(r),o.complete()},function(l){var c;a=!1,(c=r.error)===null||c===void 0||c.call(r,l),o.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)}))}):Ln}function Ic(t){return` \r
|
|
5
|
-
`.indexOf(t)>=0}function Ni(t){for(var e=["topLevel"],n=0,r,i,o,s=function(E){return e.push(E)},a=function(E){return e[e.length-1]=E},l=function(E){r==null&&(r=n,i=e.length,o=E)},c=function(E){E===o&&(r=void 0,i=void 0,o=void 0)},p=function(){return e.pop()},m=function(){return n--},y=function(E){if("0"<=E&&E<="9"){s("number");return}switch(E){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 h=t[n];switch(e[e.length-1]){case"topLevel":y(h);break;case"string":switch(h){case'"':p();break;case"\\":l("stringEscape"),s("stringEscaped");break}break;case"stringEscaped":h==="u"?s("stringUnicode"):(c("stringEscape"),p());break;case"stringUnicode":n-t.lastIndexOf("u",n)===4&&(c("stringEscape"),p());break;case"number":h==="."?a("numberNeedsDigit"):h==="e"||h==="E"?a("numberNeedsExponent"):(h<"0"||h>"9")&&(m(),p());break;case"numberNeedsDigit":a("number");break;case"numberNeedsExponent":a(h==="+"||h==="-"?"numberNeedsDigit":"number");break;case"true":case"false":case"null":(h<"a"||h>"z")&&(m(),p());break;case"arrayNeedsValue":h==="]"?p():Ic(h)||(c("collectionItem"),a("arrayNeedsComma"),y(h));break;case"arrayNeedsComma":h==="]"?p():h===","&&(l("collectionItem"),a("arrayNeedsValue"));break;case"objectNeedsKey":h==="}"?p():h==='"'&&(l("collectionItem"),a("objectNeedsColon"),s("string"));break;case"objectNeedsColon":h===":"&&a("objectNeedsValue");break;case"objectNeedsValue":Ic(h)||(c("collectionItem"),a("objectNeedsComma"),y(h));break;case"objectNeedsComma":h==="}"?p():h===","&&(l("collectionItem"),a("objectNeedsKey"));break}}i!=null&&(e.length=i);for(var g=[r!=null?t.slice(0,r):t],x=function(E){return g.push(E.slice(t.length-t.lastIndexOf(E[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 Nc(){let t=0,e=0;for(let r=0;r<28;r+=7){let i=this.buf[this.pos++];if(t|=(i&127)<<r,(i&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 i=this.buf[this.pos++];if(e|=(i&127)<<r,(i&128)==0)return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Mi(t,e,n){for(let o=0;o<28;o=o+7){let s=t>>>o,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,i=e>>3!=0;if(n.push((i?r|128:r)&255),!!i){for(let o=3;o<31;o=o+7){let s=e>>>o,a=!!(s>>>7),l=(a?s|128:s)&255;if(n.push(l),!a)return}n.push(e>>>31&1)}}var Oi=4294967296;function Vs(t){let e=t[0]==="-";e&&(t=t.slice(1));let n=1e6,r=0,i=0;function o(s,a){let l=Number(t.slice(s,a));i*=n,r=r*n+l,r>=Oi&&(i=i+(r/Oi|0),r=r%Oi)}return o(-24,-18),o(-18,-12),o(-12,-6),o(-6),e?Mc(r,i):js(r,i)}function Oc(t,e){let n=js(t,e),r=n.hi&2147483648;r&&(n=Mc(n.lo,n.hi));let i=Bs(n.lo,n.hi);return r?"-"+i:i}function Bs(t,e){if({lo:t,hi:e}=km(t,e),e<=2097151)return String(Oi*e+t);let n=t&16777215,r=(t>>>24|e<<8)&16777215,i=e>>16&65535,o=n+r*6777216+i*6710656,s=r+i*8147497,a=i*2,l=1e7;return o>=l&&(s+=Math.floor(o/l),o%=l),s>=l&&(a+=Math.floor(s/l),s%=l),a.toString()+Rc(s)+Rc(o)}function km(t,e){return{lo:t>>>0,hi:e>>>0}}function js(t,e){return{lo:t|0,hi:e|0}}function Mc(t,e){return e=~e,t?t=~t+1:e+=1,js(t,e)}var Rc=t=>{let e=String(t);return"0000000".slice(e.length)+e};function qs(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 Lc(){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 Ye=Cm();function Cm(){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"),i=BigInt("0"),o=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>o||a<i)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()),Pc(n),n},uParse(n){return typeof n!="string"&&(n=n.toString()),Dc(n),n},enc(n){return typeof n!="string"&&(n=n.toString()),Pc(n),Vs(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),Dc(n),Vs(n)},dec(n,r){return Oc(n,r)},uDec(n,r){return Bs(n,r)}}}function Pc(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function Dc(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}var Ws=Symbol.for("@bufbuild/protobuf/text-encoding");function Xs(){if(globalThis[Ws]==null){let t=new globalThis.TextEncoder,e=new globalThis.TextDecoder,n;globalThis[Ws]={encodeUtf8(r){return t.encode(r)},decodeUtf8(r,i){return i?(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[Ws]}var Ct;(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"})(Ct||(Ct={}));var Im=34028234663852886e22,Rm=-34028234663852886e22,Nm=4294967295,Om=2147483647,Mm=-2147483648,F=class{constructor(e=Xs().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 i=0;i<this.chunks.length;i++)e+=this.chunks[i].length;let n=new Uint8Array(e),r=0;for(let i=0;i<this.chunks.length;i++)n.set(this.chunks[i],r),r+=this.chunks[i].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(Uc(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return Ks(e),qs(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){Lm(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){Uc(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){Ks(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return Ks(e),e=(e<<1^e>>31)>>>0,qs(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),i=Ye.enc(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),i=Ye.uEnc(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(n)}int64(e){let n=Ye.enc(e);return Mi(n.lo,n.hi,this.buf),this}sint64(e){let n=Ye.enc(e),r=n.hi>>31,i=n.lo<<1^r,o=(n.hi<<1|n.lo>>>31)^r;return Mi(i,o,this.buf),this}uint64(e){let n=Ye.uEnc(e);return Mi(n.lo,n.hi,this.buf),this}},A=class{constructor(e,n=Xs().decodeUtf8){this.decodeUtf8=n,this.varint64=Nc,this.uint32=Lc,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 i=n>>>3,o=n&7;if(i<=0||o>5)throw new Error("illegal tag: field no "+i+" wire type "+o);return[i,o]}skip(e,n,r=100){let i=this.pos;switch(e){case Ct.Varint:for(;this.buf[this.pos++]&128;);break;case Ct.Bit64:this.pos+=4;case Ct.Bit32:this.pos+=4;break;case Ct.LengthDelimited:let o=this.uint32();this.pos+=o;break;case Ct.StartGroup:if(r<=0)throw new Error("maximum recursion depth reached");for(;;){let[s,a]=this.tag();if(a===Ct.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(i,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 Ye.dec(...this.varint64())}uint64(){return Ye.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),r=-(e&1);return e=(e>>>1|(n&1)<<31)^r,n=n>>>1^r,Ye.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 Ye.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Ye.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 Ks(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>Om||t<Mm)throw new Error("invalid int32: "+t)}function Uc(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>Nm||t<0)throw new Error("invalid uint32: "+t)}function Lm(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>Im||t<Rm))throw new Error("invalid float32: "+t)}var Pm=(function(t){return t[t.NULL_VALUE=0]="NULL_VALUE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function Ys(){return{fields:{}}}var ar={encode(t,e=new F){return Object.entries(t.fields).forEach(([n,r])=>{r!==void 0&&Qs.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,i=Ys();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:{if(o!==10)break;let s=Qs.decode(n,n.uint32());s.value!==void 0&&(i.fields[s.key]=s.value);continue}}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return ar.fromPartial(t??{})},fromPartial(t){let e=Ys();return e.fields=Object.entries(t.fields??{}).reduce((n,[r,i])=>(i!==void 0&&(n[r]=i),n),{}),e},wrap(t){let e=Ys();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 Hc(){return{key:"",value:void 0}}var Qs={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,i=Hc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.key=n.string();continue;case 2:if(o!==18)break;i.value=O.unwrap(O.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Qs.fromPartial(t??{})},fromPartial(t){let e=Hc();return e.key=t.key??"",e.value=t.value??void 0,e}};function Zs(){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&&ar.encode(ar.wrap(t.structValue),e.uint32(42).fork()).join(),t.listValue!==void 0&&lr.encode(lr.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,i=Zs();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;i.nullValue=n.int32();continue;case 2:if(o!==17)break;i.numberValue=n.double();continue;case 3:if(o!==26)break;i.stringValue=n.string();continue;case 4:if(o!==32)break;i.boolValue=n.bool();continue;case 5:if(o!==42)break;i.structValue=ar.unwrap(ar.decode(n,n.uint32()));continue;case 6:if(o!==50)break;i.listValue=lr.unwrap(lr.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return O.fromPartial(t??{})},fromPartial(t){let e=Zs();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=Zs();if(t===null)e.nullValue=Pm.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 Js(){return{values:[]}}var lr={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,i=Js();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.values.push(O.unwrap(O.decode(n,n.uint32())));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return lr.fromPartial(t??{})},fromPartial(t){let e=Js();return e.values=t.values?.map(n=>n)||[],e},wrap(t){let e=Js();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 zc(){return{op:0,path:"",from:void 0,value:void 0}}var Pi={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,i=zc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;i.op=n.int32();continue;case 2:if(o!==18)break;i.path=n.string();continue;case 3:if(o!==26)break;i.from=n.string();continue;case 4:if(o!==34)break;i.value=O.unwrap(O.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Pi.fromPartial(t??{})},fromPartial(t){let e=zc();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 Di={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&&Ui.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,i=Gc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.id=n.string();continue;case 2:if(o!==18)break;i.type=n.string();continue;case 3:if(o!==26)break;i.function=Ui.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Di.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?Ui.fromPartial(t.function):void 0,e}};function Fc(){return{name:"",arguments:""}}var Ui={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,i=Fc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.name=n.string();continue;case 2:if(o!==18)break;i.arguments=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Ui.fromPartial(t??{})},fromPartial(t){let e=Fc();return e.name=t.name??"",e.arguments=t.arguments??"",e}};function $c(){return{value:"",mimeType:""}}var Hi={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,i=$c();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.value=n.string();continue;case 2:if(o!==18)break;i.mimeType=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Hi.fromPartial(t??{})},fromPartial(t){let e=$c();return e.value=t.value??"",e.mimeType=t.mimeType??"",e}};function Vc(){return{value:"",mimeType:void 0}}var zi={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,i=Vc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.value=n.string();continue;case 2:if(o!==18)break;i.mimeType=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return zi.fromPartial(t??{})},fromPartial(t){let e=Vc();return e.value=t.value??"",e.mimeType=t.mimeType??void 0,e}};function Bc(){return{data:void 0,url:void 0}}var Ue={encode(t,e=new F){return t.data!==void 0&&Hi.encode(t.data,e.uint32(10).fork()).join(),t.url!==void 0&&zi.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,i=Bc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.data=Hi.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.url=zi.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Ue.fromPartial(t??{})},fromPartial(t){let e=Bc();return e.data=t.data!==void 0&&t.data!==null?Hi.fromPartial(t.data):void 0,e.url=t.url!==void 0&&t.url!==null?zi.fromPartial(t.url):void 0,e}};function jc(){return{text:""}}var Gi={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,i=jc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.text=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Gi.fromPartial(t??{})},fromPartial(t){let e=jc();return e.text=t.text??"",e}};function qc(){return{source:void 0,metadata:void 0}}var Fi={encode(t,e=new F){return t.source!==void 0&&Ue.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,i=qc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.source=Ue.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Fi.fromPartial(t??{})},fromPartial(t){let e=qc();return e.source=t.source!==void 0&&t.source!==null?Ue.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Wc(){return{source:void 0,metadata:void 0}}var $i={encode(t,e=new F){return t.source!==void 0&&Ue.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,i=Wc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.source=Ue.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return $i.fromPartial(t??{})},fromPartial(t){let e=Wc();return e.source=t.source!==void 0&&t.source!==null?Ue.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Xc(){return{source:void 0,metadata:void 0}}var Vi={encode(t,e=new F){return t.source!==void 0&&Ue.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,i=Xc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.source=Ue.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Vi.fromPartial(t??{})},fromPartial(t){let e=Xc();return e.source=t.source!==void 0&&t.source!==null?Ue.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Kc(){return{source:void 0,metadata:void 0}}var Bi={encode(t,e=new F){return t.source!==void 0&&Ue.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,i=Kc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.source=Ue.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Bi.fromPartial(t??{})},fromPartial(t){let e=Kc();return e.source=t.source!==void 0&&t.source!==null?Ue.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function Yc(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var ji={encode(t,e=new F){return t.text!==void 0&&Gi.encode(t.text,e.uint32(10).fork()).join(),t.image!==void 0&&Fi.encode(t.image,e.uint32(18).fork()).join(),t.audio!==void 0&&$i.encode(t.audio,e.uint32(26).fork()).join(),t.video!==void 0&&Vi.encode(t.video,e.uint32(34).fork()).join(),t.document!==void 0&&Bi.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,i=Yc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.text=Gi.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.image=Fi.decode(n,n.uint32());continue;case 3:if(o!==26)break;i.audio=$i.decode(n,n.uint32());continue;case 4:if(o!==34)break;i.video=Vi.decode(n,n.uint32());continue;case 5:if(o!==42)break;i.document=Bi.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return ji.fromPartial(t??{})},fromPartial(t){let e=Yc();return e.text=t.text!==void 0&&t.text!==null?Gi.fromPartial(t.text):void 0,e.image=t.image!==void 0&&t.image!==null?Fi.fromPartial(t.image):void 0,e.audio=t.audio!==void 0&&t.audio!==null?$i.fromPartial(t.audio):void 0,e.video=t.video!==void 0&&t.video!==null?Vi.fromPartial(t.video):void 0,e.document=t.document!==void 0&&t.document!==null?Bi.fromPartial(t.document):void 0,e}};function Zc(){return{id:"",role:"",content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var qi={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)Di.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)ji.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,i=Zc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.id=n.string();continue;case 2:if(o!==18)break;i.role=n.string();continue;case 3:if(o!==26)break;i.content=n.string();continue;case 4:if(o!==34)break;i.name=n.string();continue;case 5:if(o!==42)break;i.toolCalls.push(Di.decode(n,n.uint32()));continue;case 6:if(o!==50)break;i.toolCallId=n.string();continue;case 7:if(o!==58)break;i.error=n.string();continue;case 8:if(o!==66)break;i.contentParts.push(ji.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return qi.fromPartial(t??{})},fromPartial(t){let e=Zc();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=>Di.fromPartial(n))||[],e.toolCallId=t.toolCallId??void 0,e.error=t.error??void 0,e.contentParts=t.contentParts?.map(n=>ji.fromPartial(n))||[],e}};function Jc(){return{id:"",reason:"",message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var Wi={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,i=Jc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.id=n.string();continue;case 2:if(o!==18)break;i.reason=n.string();continue;case 3:if(o!==26)break;i.message=n.string();continue;case 4:if(o!==34)break;i.toolCallId=n.string();continue;case 5:if(o!==42)break;i.responseSchema=O.unwrap(O.decode(n,n.uint32()));continue;case 6:if(o!==50)break;i.expiresAt=n.string();continue;case 7:if(o!==58)break;i.metadata=O.unwrap(O.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Wi.fromPartial(t??{})},fromPartial(t){let e=Jc();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}},Um=(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 Qc(){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,i=Qc();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==8)break;i.type=n.int32();continue;case 2:if(o!==16)break;i.timestamp=Hm(n.int64());continue;case 3:if(o!==26)break;i.rawEvent=O.unwrap(O.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return M.fromPartial(t??{})},fromPartial(t){let e=Qc();return e.type=t.type??0,e.timestamp=t.timestamp??void 0,e.rawEvent=t.rawEvent??void 0,e}};function ed(){return{baseEvent:void 0,messageId:"",role:void 0,name:void 0}}var Xi={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,i=ed();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.messageId=n.string();continue;case 3:if(o!==26)break;i.role=n.string();continue;case 4:if(o!==34)break;i.name=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Xi.fromPartial(t??{})},fromPartial(t){let e=ed();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 td(){return{baseEvent:void 0,messageId:"",delta:""}}var Ki={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,i=td();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.messageId=n.string();continue;case 3:if(o!==26)break;i.delta=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Ki.fromPartial(t??{})},fromPartial(t){let e=td();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 nd(){return{baseEvent:void 0,messageId:""}}var Yi={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,i=nd();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.messageId=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Yi.fromPartial(t??{})},fromPartial(t){let e=nd();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e}};function rd(){return{baseEvent:void 0,toolCallId:"",toolCallName:"",parentMessageId:void 0}}var Zi={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,i=rd();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.toolCallId=n.string();continue;case 3:if(o!==26)break;i.toolCallName=n.string();continue;case 4:if(o!==34)break;i.parentMessageId=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Zi.fromPartial(t??{})},fromPartial(t){let e=rd();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 id(){return{baseEvent:void 0,toolCallId:"",delta:""}}var Ji={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,i=id();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.toolCallId=n.string();continue;case 3:if(o!==26)break;i.delta=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Ji.fromPartial(t??{})},fromPartial(t){let e=id();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 od(){return{baseEvent:void 0,toolCallId:""}}var Qi={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,i=od();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.toolCallId=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return Qi.fromPartial(t??{})},fromPartial(t){let e=od();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e}};function sd(){return{baseEvent:void 0,snapshot:void 0}}var eo={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,i=sd();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.snapshot=O.unwrap(O.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return eo.fromPartial(t??{})},fromPartial(t){let e=sd();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.snapshot=t.snapshot??void 0,e}};function ad(){return{baseEvent:void 0,delta:[]}}var to={encode(t,e=new F){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.delta)Pi.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,i=ad();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.delta.push(Pi.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return to.fromPartial(t??{})},fromPartial(t){let e=ad();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.delta=t.delta?.map(n=>Pi.fromPartial(n))||[],e}};function ld(){return{baseEvent:void 0,messages:[]}}var no={encode(t,e=new F){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.messages)qi.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,i=ld();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.messages.push(qi.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return no.fromPartial(t??{})},fromPartial(t){let e=ld();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messages=t.messages?.map(n=>qi.fromPartial(n))||[],e}};function cd(){return{baseEvent:void 0,event:void 0,source:void 0}}var ro={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,i=cd();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.event=O.unwrap(O.decode(n,n.uint32()));continue;case 3:if(o!==26)break;i.source=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return ro.fromPartial(t??{})},fromPartial(t){let e=cd();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 dd(){return{baseEvent:void 0,name:"",value:void 0}}var io={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,i=dd();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.name=n.string();continue;case 3:if(o!==26)break;i.value=O.unwrap(O.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return io.fromPartial(t??{})},fromPartial(t){let e=dd();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 ud(){return{baseEvent:void 0,threadId:"",runId:""}}var oo={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,i=ud();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.threadId=n.string();continue;case 3:if(o!==26)break;i.runId=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return oo.fromPartial(t??{})},fromPartial(t){let e=ud();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 pd(){return{baseEvent:void 0,threadId:"",runId:"",result:void 0,outcome:"",interrupts:[]}}var so={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)Wi.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,i=pd();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.threadId=n.string();continue;case 3:if(o!==26)break;i.runId=n.string();continue;case 4:if(o!==34)break;i.result=O.unwrap(O.decode(n,n.uint32()));continue;case 5:if(o!==42)break;i.outcome=n.string();continue;case 6:if(o!==50)break;i.interrupts.push(Wi.decode(n,n.uint32()));continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return so.fromPartial(t??{})},fromPartial(t){let e=pd();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=>Wi.fromPartial(n))||[],e}};function hd(){return{baseEvent:void 0,code:void 0,message:""}}var ao={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,i=hd();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.code=n.string();continue;case 3:if(o!==26)break;i.message=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return ao.fromPartial(t??{})},fromPartial(t){let e=hd();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 fd(){return{baseEvent:void 0,stepName:""}}var lo={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,i=fd();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.stepName=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return lo.fromPartial(t??{})},fromPartial(t){let e=fd();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e}};function md(){return{baseEvent:void 0,stepName:""}}var co={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,i=md();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.stepName=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return co.fromPartial(t??{})},fromPartial(t){let e=md();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e}};function gd(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var uo={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,i=gd();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.messageId=n.string();continue;case 3:if(o!==26)break;i.role=n.string();continue;case 4:if(o!==34)break;i.delta=n.string();continue;case 5:if(o!==42)break;i.name=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return uo.fromPartial(t??{})},fromPartial(t){let e=gd();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 vd(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var po={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,i=vd();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.baseEvent=M.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.toolCallId=n.string();continue;case 3:if(o!==26)break;i.toolCallName=n.string();continue;case 4:if(o!==34)break;i.parentMessageId=n.string();continue;case 5:if(o!==42)break;i.delta=n.string();continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return po.fromPartial(t??{})},fromPartial(t){let e=vd();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 bd(){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 yd={encode(t,e=new F){return t.textMessageStart!==void 0&&Xi.encode(t.textMessageStart,e.uint32(10).fork()).join(),t.textMessageContent!==void 0&&Ki.encode(t.textMessageContent,e.uint32(18).fork()).join(),t.textMessageEnd!==void 0&&Yi.encode(t.textMessageEnd,e.uint32(26).fork()).join(),t.toolCallStart!==void 0&&Zi.encode(t.toolCallStart,e.uint32(34).fork()).join(),t.toolCallArgs!==void 0&&Ji.encode(t.toolCallArgs,e.uint32(42).fork()).join(),t.toolCallEnd!==void 0&&Qi.encode(t.toolCallEnd,e.uint32(50).fork()).join(),t.stateSnapshot!==void 0&&eo.encode(t.stateSnapshot,e.uint32(58).fork()).join(),t.stateDelta!==void 0&&to.encode(t.stateDelta,e.uint32(66).fork()).join(),t.messagesSnapshot!==void 0&&no.encode(t.messagesSnapshot,e.uint32(74).fork()).join(),t.raw!==void 0&&ro.encode(t.raw,e.uint32(82).fork()).join(),t.custom!==void 0&&io.encode(t.custom,e.uint32(90).fork()).join(),t.runStarted!==void 0&&oo.encode(t.runStarted,e.uint32(98).fork()).join(),t.runFinished!==void 0&&so.encode(t.runFinished,e.uint32(106).fork()).join(),t.runError!==void 0&&ao.encode(t.runError,e.uint32(114).fork()).join(),t.stepStarted!==void 0&&lo.encode(t.stepStarted,e.uint32(122).fork()).join(),t.stepFinished!==void 0&&co.encode(t.stepFinished,e.uint32(130).fork()).join(),t.textMessageChunk!==void 0&&uo.encode(t.textMessageChunk,e.uint32(138).fork()).join(),t.toolCallChunk!==void 0&&po.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,i=bd();for(;n.pos<r;){let o=n.uint32();switch(o>>>3){case 1:if(o!==10)break;i.textMessageStart=Xi.decode(n,n.uint32());continue;case 2:if(o!==18)break;i.textMessageContent=Ki.decode(n,n.uint32());continue;case 3:if(o!==26)break;i.textMessageEnd=Yi.decode(n,n.uint32());continue;case 4:if(o!==34)break;i.toolCallStart=Zi.decode(n,n.uint32());continue;case 5:if(o!==42)break;i.toolCallArgs=Ji.decode(n,n.uint32());continue;case 6:if(o!==50)break;i.toolCallEnd=Qi.decode(n,n.uint32());continue;case 7:if(o!==58)break;i.stateSnapshot=eo.decode(n,n.uint32());continue;case 8:if(o!==66)break;i.stateDelta=to.decode(n,n.uint32());continue;case 9:if(o!==74)break;i.messagesSnapshot=no.decode(n,n.uint32());continue;case 10:if(o!==82)break;i.raw=ro.decode(n,n.uint32());continue;case 11:if(o!==90)break;i.custom=io.decode(n,n.uint32());continue;case 12:if(o!==98)break;i.runStarted=oo.decode(n,n.uint32());continue;case 13:if(o!==106)break;i.runFinished=so.decode(n,n.uint32());continue;case 14:if(o!==114)break;i.runError=ao.decode(n,n.uint32());continue;case 15:if(o!==122)break;i.stepStarted=lo.decode(n,n.uint32());continue;case 16:if(o!==130)break;i.stepFinished=co.decode(n,n.uint32());continue;case 17:if(o!==138)break;i.textMessageChunk=uo.decode(n,n.uint32());continue;case 18:if(o!==146)break;i.toolCallChunk=po.decode(n,n.uint32());continue}if((o&7)===4||o===0)break;n.skip(o&7)}return i},create(t){return yd.fromPartial(t??{})},fromPartial(t){let e=bd();return e.textMessageStart=t.textMessageStart!==void 0&&t.textMessageStart!==null?Xi.fromPartial(t.textMessageStart):void 0,e.textMessageContent=t.textMessageContent!==void 0&&t.textMessageContent!==null?Ki.fromPartial(t.textMessageContent):void 0,e.textMessageEnd=t.textMessageEnd!==void 0&&t.textMessageEnd!==null?Yi.fromPartial(t.textMessageEnd):void 0,e.toolCallStart=t.toolCallStart!==void 0&&t.toolCallStart!==null?Zi.fromPartial(t.toolCallStart):void 0,e.toolCallArgs=t.toolCallArgs!==void 0&&t.toolCallArgs!==null?Ji.fromPartial(t.toolCallArgs):void 0,e.toolCallEnd=t.toolCallEnd!==void 0&&t.toolCallEnd!==null?Qi.fromPartial(t.toolCallEnd):void 0,e.stateSnapshot=t.stateSnapshot!==void 0&&t.stateSnapshot!==null?eo.fromPartial(t.stateSnapshot):void 0,e.stateDelta=t.stateDelta!==void 0&&t.stateDelta!==null?to.fromPartial(t.stateDelta):void 0,e.messagesSnapshot=t.messagesSnapshot!==void 0&&t.messagesSnapshot!==null?no.fromPartial(t.messagesSnapshot):void 0,e.raw=t.raw!==void 0&&t.raw!==null?ro.fromPartial(t.raw):void 0,e.custom=t.custom!==void 0&&t.custom!==null?io.fromPartial(t.custom):void 0,e.runStarted=t.runStarted!==void 0&&t.runStarted!==null?oo.fromPartial(t.runStarted):void 0,e.runFinished=t.runFinished!==void 0&&t.runFinished!==null?so.fromPartial(t.runFinished):void 0,e.runError=t.runError!==void 0&&t.runError!==null?ao.fromPartial(t.runError):void 0,e.stepStarted=t.stepStarted!==void 0&&t.stepStarted!==null?lo.fromPartial(t.stepStarted):void 0,e.stepFinished=t.stepFinished!==void 0&&t.stepFinished!==null?co.fromPartial(t.stepFinished):void 0,e.textMessageChunk=t.textMessageChunk!==void 0&&t.textMessageChunk!==null?uo.fromPartial(t.textMessageChunk):void 0,e.toolCallChunk=t.toolCallChunk!==void 0&&t.toolCallChunk!==null?po.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 Li=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}}},zm=t=>{if(!(!t||typeof t!="object")){if(t.text)return{type:"text",text:t.text.text};if(t.image)return{type:"image",source:Li(t.image.source),metadata:t.image.metadata};if(t.audio)return{type:"audio",source:Li(t.audio.source),metadata:t.audio.metadata};if(t.video)return{type:"video",source:Li(t.video.source),metadata:t.video.metadata};if(t.document)return{type:"document",source:Li(t.document.source),metadata:t.document.metadata}}};function xd(t){let e=yd.decode(t),n=Object.values(e).find(r=>r!==void 0);if(!n)throw new Error("Invalid event");if(n.type=Um[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 i=r;if(i.role==="user"&&Array.isArray(i.contentParts)){let o=i.contentParts.map(s=>zm(s)).filter(s=>s!==void 0);o.length>0&&(i.content=o)}Array.isArray(i.contentParts)&&i.contentParts.length===0&&(i.contentParts=void 0),i.toolCalls?.length===0&&(i.toolCalls=void 0)}if(n.type===v.RUN_FINISHED){let r=n,i=typeof r.outcome=="string"&&r.outcome!==""?r.outcome:void 0,o=Array.isArray(r.interrupts)?r.interrupts:[];delete r.interrupts,i==="interrupt"?r.outcome={type:"interrupt",interrupts:o}:i==="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(i=>{r[i]===void 0&&delete r[i]});return Object.keys(n).forEach(r=>{n[r]===void 0&&delete n[r]}),Zr.parse(n)}var ea="application/vnd.ag-ui.event+proto";var Fm=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,ta=t=>{if(typeof t!="string")throw new TypeError("Invalid argument expected string");let e=t.match(Fm);if(!e)throw new Error(`Invalid argument not valid semver ('${t}' received)`);return e.shift(),e},wd=t=>t==="*"||t==="x"||t==="X",_d=t=>{let e=parseInt(t,10);return isNaN(e)?t:e},$m=(t,e)=>typeof t!=typeof e?[String(t),String(e)]:[t,e],Vm=(t,e)=>{if(wd(t)||wd(e))return 0;let[n,r]=$m(_d(t),_d(e));return n>r?1:n<r?-1:0},na=(t,e)=>{for(let n=0;n<Math.max(t.length,e.length);n++){let r=Vm(t[n]||"0",e[n]||"0");if(r!==0)return r}return 0};var cr=(t,e)=>{let n=ta(t),r=ta(e),i=n.pop(),o=r.pop(),s=na(n,r);return s!==0?s:i&&o?na(i.split("."),o.split(".")):i||o?i?-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 Ee(){return Et()}function oa(t){if(Object.freeze(t),typeof t=="object"&&t)for(let e of Object.values(t))typeof e=="object"&&e&&!Object.isFrozen(e)&&oa(e);return t}var Ed=512*1024;function Td(t,e,n){let r=0,i=[t,e],o=new WeakSet;for(;i.length>0;){let s=i.pop();if(typeof s=="string"){if(r+=s.length,r>n)return!0}else if(typeof s=="object"&&s){if(o.has(s))continue;if(o.add(s),Array.isArray(s))for(let a=0;a<s.length;a++)i.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;i.push(s[c])}}}}return!1}async function Y(t,e,n,r){let i=typeof process<"u"&&process.env!==void 0,o=i&&!!process.env.VITEST_WORKER_ID,s=i&&!!process.env.VITEST_WORKER_ID,a=s&&!Td(e,n,Ed),l=a?q(e):e,c=a?q(n):n,p=!1,m=!1,y;for(let f of t)try{a&&(oa(l),oa(c));let h=await r(f,l,c);if(h===void 0)continue;let g=!1;if(h.messages!==void 0&&h.messages!==l&&(l=q(h.messages),p=!0,g=!0),h.state!==void 0&&h.state!==c&&(c=q(h.state),m=!0,g=!0),a&&g&&Td(l,c,Ed)&&(a=!1),y=h.stopPropagation,y===!0)break}catch(h){if(s&&h instanceof TypeError){if(o)throw h;console.error("AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.",h)}else o||console.error("Subscriber error:",h);continue}return{...p?{messages:Object.isFrozen(l)?q(l):l}:{},...m?{state:Object.isFrozen(c)?q(c):c}:{},...y===void 0?{}:{stopPropagation:y}}}function ho(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 dr(t){if(t instanceof sa)return t;if(t===!0)return new sa(ho(!0))}var sa=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 ra(t){return t.enabled?new sa(t):void 0}function Bm(t,e,n){if(e){let i=t.find(s=>s.id===e);if(i?.role==="assistant")return i;i&&console.warn(`TOOL_CALL_START: parentMessageId '${e}' matches a '${i.role}' message, not assistant \u2014 falling back to toolCallId`);let o={id:i?n:e,role:"assistant",toolCalls:[]};return t.push(o),o}let r={id:n,role:"assistant",toolCalls:[]};return t.push(r),r}var Rd=(t,e,n,r,i)=>{let o=dr(i),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)},p=()=>{let m=q(l);return l={},m.messages!==void 0||m.state!==void 0?ue(m):fi};return e.pipe(Ii(async m=>{let y=await Y(r,s,a,(f,h,g)=>f.onEvent?.({event:m,agent:n,input:t,messages:h,state:g}));if(c(y),y.stopPropagation===!0?o?.event("APPLY","Event dropped:",m,{type:m.type,reason:"stopPropagation by subscriber"}):o?.event("APPLY","Event applied:",m,{type:m.type,subscribers:r.length}),y.stopPropagation===!0)return p();switch(m.type){case v.TEXT_MESSAGE_START:{let f=await Y(r,s,a,(h,g,x)=>h.onTextMessageStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:h,role:g="assistant",name:x}=m;if(!s.find(S=>S.id===h)){let S={id:h,role:g,content:"",...x!==void 0&&{name:x}};s.push(S),c({messages:s})}}return p()}case v.TEXT_MESSAGE_CONTENT:{let{messageId:f,delta:h}=m,g=s.find(S=>S.id===f);if(!g)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${f}'`),p();let x=await Y(r,s,a,(S,E,I)=>S.onTextMessageContentEvent?.({event:m,messages:E,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:""}${h}`,c({messages:s})),p()}case v.TEXT_MESSAGE_END:{let{messageId:f}=m,h=s.find(g=>g.id===f);return h?(c(await Y(r,s,a,(g,x,S)=>g.onTextMessageEndEvent?.({event:m,messages:x,state:S,agent:n,input:t,textMessageBuffer:typeof h.content=="string"?h.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:h,messages:s,state:a,agent:n,input:t})})),p()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${f}'`),p())}case v.TOOL_CALL_START:{let f=await Y(r,s,a,(h,g,x)=>h.onToolCallStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{toolCallId:h,toolCallName:g,parentMessageId:x}=m,S=Bm(s,x,h);S.toolCalls??=[],S.toolCalls.push({id:h,type:"function",function:{name:g,arguments:""}}),c({messages:s})}return p()}case v.TOOL_CALL_ARGS:{let{toolCallId:f,delta:h}=m,g=s.find(E=>E.toolCalls?.some(I=>I.id===f));if(!g)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${f}'`),p();let x=g.toolCalls?.find(E=>E.id===f);if(!x)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${f}'`),p();let S=await Y(r,s,a,(E,I,H)=>{let U=x.function.arguments,K=x.function.name,ie={};try{ie=Ni(U)}catch{}return E.onToolCallArgsEvent?.({event:m,messages:I,state:H,agent:n,input:t,toolCallBuffer:U,toolCallName:K,partialToolCallArgs:ie})});return c(S),S.stopPropagation!==!0&&(x.function.arguments+=h,c({messages:s})),p()}case v.TOOL_CALL_END:{let{toolCallId:f}=m,h=s.find(x=>x.toolCalls?.some(S=>S.id===f));if(!h)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${f}'`),p();let g=h.toolCalls?.find(x=>x.id===f);return g?(c(await Y(r,s,a,(x,S,E)=>{let I=g.function.arguments,H=g.function.name,U={};try{U=JSON.parse(I)}catch{}return x.onToolCallEndEvent?.({event:m,messages:S,state:E,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})})),p()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${f}'`),p())}case v.TOOL_CALL_RESULT:{let f=await Y(r,s,a,(h,g,x)=>h.onToolCallResultEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:h,toolCallId:g,content:x,role:S}=m,E={id:h,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(E);else{let H=I+1;for(;H<s.length&&s[H].role==="tool";)H++;s.splice(H,0,E)}await Promise.all(r.map(H=>{H.onNewMessage?.({message:E,messages:s,state:a,agent:n,input:t})})),c({messages:s})}return p()}case v.STATE_SNAPSHOT:{let f=await Y(r,s,a,(h,g,x)=>h.onStateSnapshotEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{snapshot:h}=m;a=h,c({state:a})}return p()}case v.STATE_DELTA:{let f=await Y(r,s,a,(h,g,x)=>h.onStateDeltaEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{delta:h}=m;try{a=oi.applyPatch(a,h,!0,!1).newDocument,c({state:a})}catch(g){let x=g instanceof Error?g.message:String(g);console.warn(`Failed to apply state patch:
|
|
1
|
+
var Wp=Object.defineProperty;var ms=(t,e)=>{for(var n in e)Wp(t,n,{get:e[n],enumerable:!0})};var qr="ag-ui-chat",gs="ag-ui-submit",vs="ag-ui-toggle",bs="ag-ui-unread",ys="ag-ui-state",xs="ag-ui-attachments",ws="ag-ui-run-finished",Es="ag-ui-custom",_s="ag-ui-invalidate",Ts="ag-ui-feedback",Ss="suggestions",As="ag_ui.invalidate",Zl="ag_ui.subagent",Ql={STARTED:"started",TOOL_CALL:"tool_call",TOOL_RESULT:"tool_result",FINISHED:"finished",FAILED:"failed"},ze={USER:"user",ASSISTANT:"assistant"},Kn="x-destructive",Wr="x-confirm",Pe="x-summary",Zn="x-navigates",ks="read_page",vn=10,bn={COPY:"copy",RETRY:"retry",FEEDBACK:"feedback"},te={PENDING:"pending",DEFERRED:"deferred",DONE:"done",ERROR:"error",DECLINED:"declined"},De={UPLOADING:"uploading",READY:"ready",ERROR:"error"},Cs=10*1024*1024,yn={INLINE:"inline",MINIMAL:"minimal",COMPACT:"compact",FULL:"full"},Is="compaction",Rs="load_capability",Jl='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 19.5V5m-6.5 6.5L12 5l6.5 6.5"/></svg>',ec='<svg class="glyph glyph--solid" viewBox="0 0 24 24" aria-hidden="true"><rect x="7" y="7" width="10" height="10" rx="2.5"/></svg>',tc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M17 8.5V15a5 5 0 0 1-10 0V7a3 3 0 0 1 6 0v7.5a1 1 0 0 1-2 0V8.5"/></svg>',nc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 4a3 3 0 0 1 3 3v5a3 3 0 0 1-6 0V7a3 3 0 0 1 3-3z"/><path d="M5 11v1a7 7 0 0 0 14 0v-1"/><path d="M12 19v3"/></svg>',rc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H9l-5 4z"/></svg>',oc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/></svg>',ic='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><rect x="3.5" y="4.5" width="17" height="15" rx="2.5"/><circle cx="9" cy="10" r="1.5"/><path d="M4.5 17.5 9 13.5l3.5 3 3-2.5 4.5 4"/></svg>',sc='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><rect class="glyph--solid" x="7.5" y="13.5" width="9" height="4.5" rx="1"/></svg>',ac='<svg class="glyph" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"/><path d="M14 3v5h5"/><path d="M8.5 13.5h7M8.5 17h4.5"/></svg>',Xr="chart",lc=150;var xe=[];for(let t=0;t<256;++t)xe.push((t+256).toString(16).slice(1));function cc(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 Ns,Xp=new Uint8Array(16);function Os(){if(!Ns){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Ns=crypto.getRandomValues.bind(crypto)}return Ns(Xp)}var Yp=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ms={randomUUID:Yp};function Kp(t,e,n){if(Ms.randomUUID&&!e&&!t)return Ms.randomUUID();t=t||{};let r=t.random??t.rng?.()??Os();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 cc(r)}var _t=Kp;var d={};ms(d,{BRAND:()=>Eh,DIRTY:()=>Lt,EMPTY_PATH:()=>eh,INVALID:()=>P,NEVER:()=>af,OK:()=>Ae,ParseStatus:()=>we,Schema:()=>$,ZodAny:()=>At,ZodArray:()=>mt,ZodBigInt:()=>Dt,ZodBoolean:()=>Ut,ZodBranded:()=>Jn,ZodCatch:()=>Xt,ZodDate:()=>Ht,ZodDefault:()=>Wt,ZodDiscriminatedUnion:()=>Zr,ZodEffects:()=>Be,ZodEnum:()=>jt,ZodError:()=>Oe,ZodFirstPartyTypeKind:()=>D,ZodFunction:()=>Jr,ZodIntersection:()=>$t,ZodIssueCode:()=>E,ZodLazy:()=>Bt,ZodLiteral:()=>Vt,ZodMap:()=>Sn,ZodNaN:()=>kn,ZodNativeEnum:()=>qt,ZodNever:()=>Xe,ZodNull:()=>zt,ZodNullable:()=>st,ZodNumber:()=>Pt,ZodObject:()=>Me,ZodOptional:()=>Ge,ZodParsedType:()=>C,ZodPipeline:()=>er,ZodPromise:()=>kt,ZodReadonly:()=>Yt,ZodRecord:()=>Qr,ZodSchema:()=>$,ZodSet:()=>An,ZodString:()=>St,ZodSymbol:()=>_n,ZodTransformer:()=>Be,ZodTuple:()=>it,ZodType:()=>$,ZodUndefined:()=>Ft,ZodUnion:()=>Gt,ZodUnknown:()=>ft,ZodVoid:()=>Tn,addIssueToContext:()=>k,any:()=>Nh,array:()=>Ph,bigint:()=>Ah,boolean:()=>xc,coerce:()=>sf,custom:()=>vc,date:()=>kh,datetimeRegex:()=>mc,defaultErrorMap:()=>pt,discriminatedUnion:()=>Fh,effect:()=>Zh,enum:()=>Xh,function:()=>jh,getErrorMap:()=>xn,getParsedType:()=>ot,instanceof:()=>Th,intersection:()=>zh,isAborted:()=>Yr,isAsync:()=>wn,isDirty:()=>Kr,isValid:()=>Tt,late:()=>_h,lazy:()=>qh,literal:()=>Wh,makeIssue:()=>Qn,map:()=>Bh,nan:()=>Sh,nativeEnum:()=>Yh,never:()=>Mh,null:()=>Rh,nullable:()=>Jh,number:()=>yc,object:()=>Dh,objectUtil:()=>Ls,oboolean:()=>of,onumber:()=>rf,optional:()=>Qh,ostring:()=>nf,pipeline:()=>tf,preprocess:()=>ef,promise:()=>Kh,quotelessJson:()=>Zp,record:()=>$h,set:()=>Vh,setErrorMap:()=>Jp,strictObject:()=>Uh,string:()=>bc,symbol:()=>Ch,transformer:()=>Zh,tuple:()=>Gh,undefined:()=>Ih,union:()=>Hh,unknown:()=>Oh,util:()=>V,void:()=>Lh});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 Ls;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Ls||(Ls={}));var C=V.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ot=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 E=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"]),Zp=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Oe=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()}};Oe.create=t=>new Oe(t);var Qp=(t,e)=>{let n;switch(t.code){case E.invalid_type:t.received===C.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case E.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,V.jsonStringifyReplacer)}`;break;case E.unrecognized_keys:n=`Unrecognized key(s) in object: ${V.joinValues(t.keys,", ")}`;break;case E.invalid_union:n="Invalid input";break;case E.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${V.joinValues(t.options)}`;break;case E.invalid_enum_value:n=`Invalid enum value. Expected ${V.joinValues(t.options)}, received '${t.received}'`;break;case E.invalid_arguments:n="Invalid function arguments";break;case E.invalid_return_type:n="Invalid function return type";break;case E.invalid_date:n="Invalid date";break;case E.invalid_string:typeof 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 E.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 E.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 E.custom:n="Invalid input";break;case E.invalid_intersection_types:n="Intersection results could not be merged";break;case E.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case E.not_finite:n="Number must be finite";break;default:n=e.defaultError,V.assertNever(t)}return{message:n}},pt=Qp;var dc=pt;function Jp(t){dc=t}function xn(){return dc}var Qn=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}},eh=[];function k(t,e){let n=xn(),r=Qn({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===pt?void 0:pt].filter(o=>!!o)});t.common.issues.push(r)}var we=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"}),Lt=t=>({status:"dirty",value:t}),Ae=t=>({status:"valid",value:t}),Yr=t=>t.status==="aborted",Kr=t=>t.status==="dirty",Tt=t=>t.status==="valid",wn=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 $e=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}},uc=(t,e)=>{if(Tt(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 Oe(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 ot(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:ot(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new we,ctx:{common:e.parent.common,data:e.data,parsedType:ot(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(wn(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:ot(e)},o=this._parseSync({data:e,path:r.path,parent:r});return uc(r,o)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ot(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Tt(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=>Tt(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:ot(e)},o=this._parse({data:e,path:r.path,parent:r}),i=await(wn(o)?o:Promise.resolve(o));return uc(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:E.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 Be({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 st.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return mt.create(this)}promise(){return kt.create(this,this._def)}or(e){return Gt.create([this,e],this._def)}and(e){return $t.create(this,e,this._def)}transform(e){return new Be({...z(this._def),schema:this,typeName:D.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Wt({...z(this._def),innerType:this,defaultValue:n,typeName:D.ZodDefault})}brand(){return new Jn({typeName:D.ZodBranded,type:this,...z(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Xt({...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 er.create(this,e)}readonly(){return Yt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},th=/^c[^\s-]{8,}$/i,nh=/^[0-9a-z]+$/,rh=/^[0-9A-HJKMNP-TV-Z]{26}$/i,oh=/^[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,ih=/^[a-z0-9_-]{21}$/i,sh=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ah=/^[-+]?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)?)??$/,lh=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ch="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ps,dh=/^(?:(?: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])$/,uh=/^(?:(?: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])$/,ph=/^(([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]))$/,hh=/^(([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])$/,fh=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,mh=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,hc="((\\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])))",gh=new RegExp(`^${hc}$`);function fc(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 vh(t){return new RegExp(`^${fc(t)}$`)}function mc(t){let e=`${hc}T${fc(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 bh(t,e){return!!((e==="v4"||!e)&&dh.test(t)||(e==="v6"||!e)&&ph.test(t))}function yh(t,e){if(!sh.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 xh(t,e){return!!((e==="v4"||!e)&&uh.test(t)||(e==="v6"||!e)&&hh.test(t))}var St=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:E.invalid_type,expected:C.string,received:i.parsedType}),P}let r=new we,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:E.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:E.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:E.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&k(o,{code:E.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")lh.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"email",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Ps||(Ps=new RegExp(ch,"u")),Ps.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"emoji",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")oh.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"uuid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")ih.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"nanoid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")th.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")nh.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid2",code:E.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")rh.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ulid",code:E.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:E.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:E.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:E.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:E.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:E.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?mc(i).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:E.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?gh.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:E.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?vh(i).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:E.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?ah.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"duration",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?bh(e.data,i.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ip",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?yh(e.data,i.alg)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"jwt",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?xh(e.data,i.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cidr",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?fh.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64",code:E.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?mh.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64url",code:E.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:E.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}};St.create=t=>new St({checks:[],typeName:D.ZodString,coerce:t?.coerce??!1,...z(t)});function wh(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 Pt=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:E.invalid_type,expected:C.number,received:i.parsedType}),P}let r,o=new we;for(let i of this._def.checks)i.kind==="int"?V.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:E.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:E.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:E.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),o.dirty()):i.kind==="multipleOf"?wh(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),k(r,{code:E.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:E.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)}};Pt.create=t=>new Pt({checks:[],typeName:D.ZodNumber,coerce:t?.coerce||!1,...z(t)});var Dt=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 we;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:E.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:E.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:E.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:E.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}};Dt.create=t=>new Dt({checks:[],typeName:D.ZodBigInt,coerce:t?.coerce??!1,...z(t)});var Ut=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:E.invalid_type,expected:C.boolean,received:r.parsedType}),P}return Ae(e.data)}};Ut.create=t=>new Ut({typeName:D.ZodBoolean,coerce:t?.coerce||!1,...z(t)});var Ht=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:E.invalid_type,expected:C.date,received:i.parsedType}),P}if(Number.isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return k(i,{code:E.invalid_date}),P}let r=new we,o;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:E.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:E.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}};Ht.create=t=>new Ht({checks:[],coerce:t?.coerce||!1,typeName:D.ZodDate,...z(t)});var _n=class extends ${_parse(e){if(this._getType(e)!==C.symbol){let r=this._getOrReturnCtx(e);return k(r,{code:E.invalid_type,expected:C.symbol,received:r.parsedType}),P}return Ae(e.data)}};_n.create=t=>new _n({typeName:D.ZodSymbol,...z(t)});var Ft=class extends ${_parse(e){if(this._getType(e)!==C.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:E.invalid_type,expected:C.undefined,received:r.parsedType}),P}return Ae(e.data)}};Ft.create=t=>new Ft({typeName:D.ZodUndefined,...z(t)});var zt=class extends ${_parse(e){if(this._getType(e)!==C.null){let r=this._getOrReturnCtx(e);return k(r,{code:E.invalid_type,expected:C.null,received:r.parsedType}),P}return Ae(e.data)}};zt.create=t=>new zt({typeName:D.ZodNull,...z(t)});var At=class extends ${constructor(){super(...arguments),this._any=!0}_parse(e){return Ae(e.data)}};At.create=t=>new At({typeName:D.ZodAny,...z(t)});var ft=class extends ${constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ae(e.data)}};ft.create=t=>new ft({typeName:D.ZodUnknown,...z(t)});var Xe=class extends ${_parse(e){let n=this._getOrReturnCtx(e);return k(n,{code:E.invalid_type,expected:C.never,received:n.parsedType}),P}};Xe.create=t=>new Xe({typeName:D.ZodNever,...z(t)});var Tn=class extends ${_parse(e){if(this._getType(e)!==C.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:E.invalid_type,expected:C.void,received:r.parsedType}),P}return Ae(e.data)}};Tn.create=t=>new Tn({typeName:D.ZodVoid,...z(t)});var mt=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:E.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?E.too_big:E.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:E.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(k(n,{code:E.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((s,a)=>o.type._parseAsync(new $e(n,s,n.path,a)))).then(s=>we.mergeArray(r,s));let i=[...n.data].map((s,a)=>o.type._parseSync(new $e(n,s,n.path,a)));return we.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)}};mt.create=(t,e)=>new mt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...z(e)});function En(t){if(t instanceof Me){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Ge.create(En(r))}return new Me({...t._def,shape:()=>e})}else return t instanceof mt?new mt({...t._def,type:En(t.element)}):t instanceof Ge?Ge.create(En(t.unwrap())):t instanceof st?st.create(En(t.unwrap())):t instanceof it?it.create(t.items.map(e=>En(e))):t}var Me=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:E.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 Xe&&this._def.unknownKeys==="strip"))for(let c in o.data)s.includes(c)||a.push(c);let l=[];for(let c of s){let u=i[c],m=o.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new $e(o,m,o.path,c)),alwaysSet:c in o.data})}if(this._def.catchall instanceof Xe){let c=this._def.unknownKeys;if(c==="passthrough")for(let u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:o.data[u]}});else if(c==="strict")a.length>0&&(k(o,{code:E.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let u of a){let m=o.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new $e(o,m,o.path,u)),alwaysSet:u in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let c=[];for(let u of l){let m=await u.key,y=await u.value;c.push({key:m,value:y,alwaysSet:u.alwaysSet})}return c}).then(c=>we.mergeObjectSync(r,c)):we.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 En(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 gc(V.objectKeys(this.shape))}};Me.create=(t,e)=>new Me({shape:()=>t,unknownKeys:"strip",catchall:Xe.create(),typeName:D.ZodObject,...z(e)});Me.strictCreate=(t,e)=>new Me({shape:()=>t,unknownKeys:"strict",catchall:Xe.create(),typeName:D.ZodObject,...z(e)});Me.lazycreate=(t,e)=>new Me({shape:t,unknownKeys:"strip",catchall:Xe.create(),typeName:D.ZodObject,...z(e)});var Gt=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 Oe(a.ctx.common.issues));return k(n,{code:E.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},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,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 Oe(l));return k(n,{code:E.invalid_union,unionErrors:a}),P}}get options(){return this._def.options}};Gt.create=(t,e)=>new Gt({options:t,typeName:D.ZodUnion,...z(e)});var ht=t=>t instanceof Bt?ht(t.schema):t instanceof Be?ht(t.innerType()):t instanceof Vt?[t.value]:t instanceof jt?t.options:t instanceof qt?V.objectValues(t.enum):t instanceof Wt?ht(t._def.innerType):t instanceof Ft?[void 0]:t instanceof zt?[null]:t instanceof Ge?[void 0,...ht(t.unwrap())]:t instanceof st?[null,...ht(t.unwrap())]:t instanceof Jn||t instanceof Yt?ht(t.unwrap()):t instanceof Xt?ht(t._def.innerType):[],Zr=class t extends ${_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==C.object)return k(n,{code:E.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:E.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=ht(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 Ds(t,e){let n=ot(t),r=ot(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=Ds(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=Ds(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 $t=class extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(i,s)=>{if(Yr(i)||Yr(s))return P;let a=Ds(i.value,s.value);return a.valid?((Kr(i)||Kr(s))&&n.dirty(),{status:n.value,value:a.data}):(k(r,{code:E.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}))}};$t.create=(t,e,n)=>new $t({left:t,right:e,typeName:D.ZodIntersection,...z(n)});var it=class t extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==C.array)return k(r,{code:E.invalid_type,expected:C.array,received:r.parsedType}),P;if(r.data.length<this._def.items.length)return k(r,{code:E.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:E.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 $e(r,s,r.path,a)):null}).filter(s=>!!s);return r.common.async?Promise.all(i).then(s=>we.mergeArray(n,s)):we.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};it.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new it({items:t,typeName:D.ZodTuple,rest:null,...z(e)})};var Qr=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:E.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 $e(r,a,r.path,a)),value:s._parse(new $e(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?we.mergeObjectAsync(n,o):we.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:St.create(),valueType:e,typeName:D.ZodRecord,...z(n)})}},Sn=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:E.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 $e(r,a,r.path,[c,"key"])),value:i._parse(new $e(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,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return P;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let l of s){let c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return P;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}};Sn.create=(t,e,n)=>new Sn({valueType:e,keyType:t,typeName:D.ZodMap,...z(n)});var An=class t extends ${_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==C.set)return k(r,{code:E.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:E.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(k(r,{code:E.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 u of l){if(u.status==="aborted")return P;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}let a=[...r.data.values()].map((l,c)=>i._parse(new $e(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)}};An.create=(t,e)=>new An({valueType:t,minSize:null,maxSize:null,typeName:D.ZodSet,...z(e)});var Jr=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:E.invalid_type,expected:C.function,received:n.parsedType}),P;function r(a,l){return Qn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,xn(),pt].filter(c=>!!c),issueData:{code:E.invalid_arguments,argumentsError:l}})}function o(a,l){return Qn({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,xn(),pt].filter(c=>!!c),issueData:{code:E.invalid_return_type,returnTypeError:l}})}let i={errorMap:n.common.contextualErrorMap},s=n.data;if(this._def.returns instanceof kt){let a=this;return Ae(async function(...l){let c=new Oe([]),u=await a._def.args.parseAsync(l,i).catch(f=>{throw c.addIssue(r(l,f)),c}),m=await Reflect.apply(s,this,u);return await a._def.returns._def.type.parseAsync(m,i).catch(f=>{throw c.addIssue(o(m,f)),c})})}else{let a=this;return Ae(function(...l){let c=a._def.args.safeParse(l,i);if(!c.success)throw new Oe([r(l,c.error)]);let u=Reflect.apply(s,this,c.data),m=a._def.returns.safeParse(u,i);if(!m.success)throw new Oe([o(u,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:it.create(e).rest(ft.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||it.create([]).rest(ft.create()),returns:n||ft.create(),typeName:D.ZodFunction,...z(r)})}},Bt=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})}};Bt.create=(t,e)=>new Bt({getter:t,typeName:D.ZodLazy,...z(e)});var Vt=class extends ${_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return k(n,{received:n.data,code:E.invalid_literal,expected:this._def.value}),P}return{status:"valid",value:e.data}}get value(){return this._def.value}};Vt.create=(t,e)=>new Vt({value:t,typeName:D.ZodLiteral,...z(e)});function gc(t,e){return new jt({values:t,typeName:D.ZodEnum,...z(e)})}var jt=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:E.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:E.invalid_enum_value,options:r}),P}return Ae(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})}};jt.create=gc;var qt=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:E.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:E.invalid_enum_value,options:o}),P}return Ae(e.data)}get enum(){return this._def.values}};qt.create=(t,e)=>new qt({values:t,typeName:D.ZodNativeEnum,...z(e)});var kt=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:E.invalid_type,expected:C.promise,received:n.parsedType}),P;let r=n.parsedType===C.promise?n.data:Promise.resolve(n.data);return Ae(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};kt.create=(t,e)=>new kt({type:t,typeName:D.ZodPromise,...z(e)});var Be=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"?Lt(l.value):n.value==="dirty"?Lt(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"?Lt(a.value):n.value==="dirty"?Lt(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(!Tt(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=>Tt(s)?Promise.resolve(o.transform(s.value,i)).then(a=>({status:n.value,value:a})):P);V.assertNever(o)}};Be.create=(t,e,n)=>new Be({schema:t,typeName:D.ZodEffects,effect:e,...z(n)});Be.createWithPreprocess=(t,e,n)=>new Be({schema:e,effect:{type:"preprocess",transform:t},typeName:D.ZodEffects,...z(n)});var Ge=class extends ${_parse(e){return this._getType(e)===C.undefined?Ae(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 st=class extends ${_parse(e){return this._getType(e)===C.null?Ae(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};st.create=(t,e)=>new st({innerType:t,typeName:D.ZodNullable,...z(e)});var Wt=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}};Wt.create=(t,e)=>new Wt({innerType:t,typeName:D.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...z(e)});var Xt=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 wn(o)?o.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Oe(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Oe(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Xt.create=(t,e)=>new Xt({innerType:t,typeName:D.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...z(e)});var kn=class extends ${_parse(e){if(this._getType(e)!==C.nan){let r=this._getOrReturnCtx(e);return k(r,{code:E.invalid_type,expected:C.nan,received:r.parsedType}),P}return{status:"valid",value:e.data}}};kn.create=t=>new kn({typeName:D.ZodNaN,...z(t)});var Eh=Symbol("zod_brand"),Jn=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}},er=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(),Lt(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})}},Yt=class extends ${_parse(e){let n=this._def.innerType._parse(e),r=o=>(Tt(o)&&(o.value=Object.freeze(o.value)),o);return wn(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};Yt.create=(t,e)=>new Yt({innerType:t,typeName:D.ZodReadonly,...z(e)});function pc(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function vc(t,e={},n){return t?At.create().superRefine((r,o)=>{let i=t(r);if(i instanceof Promise)return i.then(s=>{if(!s){let a=pc(e,r),l=a.fatal??n??!0;o.addIssue({code:"custom",...a,fatal:l})}});if(!i){let s=pc(e,r),a=s.fatal??n??!0;o.addIssue({code:"custom",...s,fatal:a})}}):At.create()}var _h={object:Me.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 Th=(t,e={message:`Input not instance of ${t.name}`})=>vc(n=>n instanceof t,e),bc=St.create,yc=Pt.create,Sh=kn.create,Ah=Dt.create,xc=Ut.create,kh=Ht.create,Ch=_n.create,Ih=Ft.create,Rh=zt.create,Nh=At.create,Oh=ft.create,Mh=Xe.create,Lh=Tn.create,Ph=mt.create,Dh=Me.create,Uh=Me.strictCreate,Hh=Gt.create,Fh=Zr.create,zh=$t.create,Gh=it.create,$h=Qr.create,Bh=Sn.create,Vh=An.create,jh=Jr.create,qh=Bt.create,Wh=Vt.create,Xh=jt.create,Yh=qt.create,Kh=kt.create,Zh=Be.create,Qh=Ge.create,Jh=st.create,ef=Be.createWithPreprocess,tf=er.create,nf=()=>bc().optional(),rf=()=>yc().optional(),of=()=>xc().optional(),sf={string:(t=>St.create({...t,coerce:!0})),number:(t=>Pt.create({...t,coerce:!0})),boolean:(t=>Ut.create({...t,coerce:!0})),bigint:(t=>Dt.create({...t,coerce:!0})),date:(t=>Ht.create({...t,coerce:!0}))};var af=P;var lf=d.object({name:d.string(),arguments:d.string()}),cf=d.object({id:d.string(),type:d.literal("function"),function:lf,encryptedValue:d.string().optional()}),eo=d.object({id:d.string(),role:d.string(),content:d.string().optional(),name:d.string().optional(),encryptedValue:d.string().optional()}),df=d.object({type:d.literal("text"),text:d.string()}),uf=d.object({type:d.literal("data"),value:d.string(),mimeType:d.string()}),pf=d.object({type:d.literal("url"),value:d.string(),mimeType:d.string().optional()}),to=d.discriminatedUnion("type",[uf,pf]),hf=d.object({type:d.literal("image"),source:to,metadata:d.unknown().optional()}),ff=d.object({type:d.literal("audio"),source:to,metadata:d.unknown().optional()}),mf=d.object({type:d.literal("video"),source:to,metadata:d.unknown().optional()}),gf=d.object({type:d.literal("document"),source:to,metadata:d.unknown().optional()});var wc=d.object({type:d.literal("binary"),mimeType:d.string(),id:d.string().optional(),url:d.string().optional(),data:d.string().optional(),filename:d.string().optional()}),Ec=(t,e)=>{!t.id&&!t.url&&!t.data&&e.addIssue({code:d.ZodIssueCode.custom,message:"BinaryInputContent requires at least one of id, url, or data.",path:["id"]})},Kx=wc.superRefine((t,e)=>{Ec(t,e)}),vf=d.discriminatedUnion("type",[df,hf,ff,mf,gf,wc]),bf=vf.superRefine((t,e)=>{t.type==="binary"&&Ec(t,e)}),yf=eo.extend({role:d.literal("developer"),content:d.string()}),xf=eo.extend({role:d.literal("system"),content:d.string()}),wf=eo.extend({role:d.literal("assistant"),content:d.string().optional(),toolCalls:d.array(cf).optional()}),Ef=eo.extend({role:d.literal("user"),content:d.union([d.string(),d.array(bf)])}),_f=d.object({id:d.string(),content:d.string(),role:d.literal("tool"),toolCallId:d.string(),error:d.string().optional(),encryptedValue:d.string().optional()}),Tf=d.object({id:d.string(),role:d.literal("activity"),activityType:d.string(),content:d.record(d.any())}),Sf=d.object({id:d.string(),role:d.literal("reasoning"),content:d.string(),encryptedValue:d.string().optional()}),_c=d.discriminatedUnion("role",[yf,xf,wf,Ef,_f,Tf,Sf]),Zx=d.union([d.literal("developer"),d.literal("system"),d.literal("assistant"),d.literal("user"),d.literal("tool"),d.literal("activity"),d.literal("reasoning")]),Af=d.object({description:d.string(),value:d.string()}),Tc=d.object({name:d.string(),description:d.string(),parameters:d.any(),metadata:d.record(d.any()).optional()}),kf=d.object({id:d.string(),reason:d.string(),message:d.string().optional(),toolCallId:d.string().optional(),responseSchema:d.record(d.any()).optional(),expiresAt:d.string().optional(),metadata:d.record(d.any()).optional()}),Cf=d.object({interruptId:d.string(),status:d.enum(["resolved","cancelled"]),payload:d.any().optional()}),If=d.object({threadId:d.string(),runId:d.string(),parentRunId:d.string().optional(),state:d.any(),messages:d.array(_c),tools:d.array(Tc),context:d.array(Af),forwardedProps:d.any(),resume:d.array(Cf).optional()}),Rf=d.any(),ne=class extends Error{constructor(t){super(t)}},Us=class extends ne{constructor(){super("Connect not implemented. This method is not supported by the current agent.")}},Nf=d.object({name:d.string(),description:d.string().optional()}),Of=d.object({name:d.string().optional(),type:d.string().optional(),description:d.string().optional(),version:d.string().optional(),provider:d.string().optional(),documentationUrl:d.string().optional(),metadata:d.record(d.unknown()).optional()}),Mf=d.object({streaming:d.boolean().optional(),websocket:d.boolean().optional(),httpBinary:d.boolean().optional(),pushNotifications:d.boolean().optional(),resumable:d.boolean().optional()}),Lf=d.object({supported:d.boolean().optional(),items:d.array(Tc).optional(),parallelCalls:d.boolean().optional(),clientProvided:d.boolean().optional()}),Pf=d.object({structuredOutput:d.boolean().optional(),supportedMimeTypes:d.array(d.string()).optional()}),Df=d.object({snapshots:d.boolean().optional(),deltas:d.boolean().optional(),memory:d.boolean().optional(),persistentState:d.boolean().optional()}),Uf=d.object({supported:d.boolean().optional(),delegation:d.boolean().optional(),handoffs:d.boolean().optional(),subAgents:d.array(Nf).optional()}),Hf=d.object({supported:d.boolean().optional(),streaming:d.boolean().optional(),encrypted:d.boolean().optional()}),Ff=d.object({image:d.boolean().optional(),audio:d.boolean().optional(),video:d.boolean().optional(),pdf:d.boolean().optional(),file:d.boolean().optional()}),zf=d.object({image:d.boolean().optional(),audio:d.boolean().optional()}),Gf=d.object({input:Ff.optional(),output:zf.optional()}),$f=d.object({codeExecution:d.boolean().optional(),sandboxed:d.boolean().optional(),maxIterations:d.number().optional(),maxExecutionTime:d.number().optional()}),Bf=d.object({supported:d.boolean().optional(),approvals:d.boolean().optional(),interventions:d.boolean().optional(),feedback:d.boolean().optional(),interrupts:d.boolean().optional(),approveWithEdits:d.boolean().optional()}),Qx=d.object({identity:Of.optional(),transport:Mf.optional(),tools:Lf.optional(),output:Pf.optional(),state:Df.optional(),multiAgent:Uf.optional(),reasoning:Hf.optional(),multimodal:Gf.optional(),execution:$f.optional(),humanInTheLoop:Bf.optional(),custom:d.record(d.unknown()).optional()}),Sc=d.union([d.literal("developer"),d.literal("system"),d.literal("assistant"),d.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=d.object({type:d.nativeEnum(v),timestamp:d.number().optional(),rawEvent:d.any().optional()}).passthrough(),Vf=X.extend({type:d.literal(v.TEXT_MESSAGE_START),messageId:d.string(),role:Sc.default("assistant"),name:d.string().optional()}),Ac=X.extend({type:d.literal(v.TEXT_MESSAGE_CONTENT),messageId:d.string(),delta:d.string()}),jf=X.extend({type:d.literal(v.TEXT_MESSAGE_END),messageId:d.string()}),qf=X.extend({type:d.literal(v.TEXT_MESSAGE_CHUNK),messageId:d.string().optional(),role:Sc.optional(),delta:d.string().optional(),name:d.string().optional()}),Wf=X.extend({type:d.literal(v.THINKING_TEXT_MESSAGE_START)}),Xf=Ac.omit({messageId:!0,type:!0}).extend({type:d.literal(v.THINKING_TEXT_MESSAGE_CONTENT)}),Yf=X.extend({type:d.literal(v.THINKING_TEXT_MESSAGE_END)}),Kf=X.extend({type:d.literal(v.TOOL_CALL_START),toolCallId:d.string(),toolCallName:d.string(),parentMessageId:d.string().optional()}),Zf=X.extend({type:d.literal(v.TOOL_CALL_ARGS),toolCallId:d.string(),delta:d.string()}),Qf=X.extend({type:d.literal(v.TOOL_CALL_END),toolCallId:d.string()}),Jf=X.extend({messageId:d.string(),type:d.literal(v.TOOL_CALL_RESULT),toolCallId:d.string(),content:d.string(),role:d.literal("tool").optional()}),em=X.extend({type:d.literal(v.TOOL_CALL_CHUNK),toolCallId:d.string().optional(),toolCallName:d.string().optional(),parentMessageId:d.string().optional(),delta:d.string().optional()}),tm=X.extend({type:d.literal(v.THINKING_START),title:d.string().optional()}),nm=X.extend({type:d.literal(v.THINKING_END)}),rm=X.extend({type:d.literal(v.STATE_SNAPSHOT),snapshot:Rf}),om=X.extend({type:d.literal(v.STATE_DELTA),delta:d.array(d.any())}),im=X.extend({type:d.literal(v.MESSAGES_SNAPSHOT),messages:d.array(_c)}),sm=X.extend({type:d.literal(v.ACTIVITY_SNAPSHOT),messageId:d.string(),activityType:d.string(),content:d.record(d.any()),replace:d.boolean().optional().default(!0)}),am=X.extend({type:d.literal(v.ACTIVITY_DELTA),messageId:d.string(),activityType:d.string(),patch:d.array(d.any())}),lm=X.extend({type:d.literal(v.RAW),event:d.any(),source:d.string().optional()}),cm=X.extend({type:d.literal(v.CUSTOM),name:d.string(),value:d.any()}),dm=X.extend({type:d.literal(v.RUN_STARTED),threadId:d.string(),runId:d.string(),parentRunId:d.string().optional(),input:If.optional()}),um=d.object({type:d.literal("success")}).strict(),pm=d.object({type:d.literal("interrupt"),interrupts:d.array(kf).min(1)}).strict(),hm=d.discriminatedUnion("type",[um,pm]),fm=X.extend({type:d.literal(v.RUN_FINISHED),threadId:d.string(),runId:d.string(),result:d.any().optional(),outcome:hm.nullable().optional().transform(t=>t??void 0)}),mm=X.extend({type:d.literal(v.RUN_ERROR),message:d.string(),code:d.string().optional()}),gm=X.extend({type:d.literal(v.STEP_STARTED),stepName:d.string()}),vm=X.extend({type:d.literal(v.STEP_FINISHED),stepName:d.string()}),bm=d.union([d.literal("tool-call"),d.literal("message")]),ym=X.extend({type:d.literal(v.REASONING_START),messageId:d.string()}),xm=X.extend({type:d.literal(v.REASONING_MESSAGE_START),messageId:d.string(),role:d.literal("reasoning")}),wm=X.extend({type:d.literal(v.REASONING_MESSAGE_CONTENT),messageId:d.string(),delta:d.string()}),Em=X.extend({type:d.literal(v.REASONING_MESSAGE_END),messageId:d.string()}),_m=X.extend({type:d.literal(v.REASONING_MESSAGE_CHUNK),messageId:d.string().optional(),delta:d.string().optional()}),Tm=X.extend({type:d.literal(v.REASONING_END),messageId:d.string()}),Sm=X.extend({type:d.literal(v.REASONING_ENCRYPTED_VALUE),subtype:bm,entityId:d.string(),encryptedValue:d.string()}),no=d.discriminatedUnion("type",[Vf,Ac,jf,qf,tm,nm,Wf,Xf,Yf,Kf,Zf,Qf,em,Jf,rm,om,im,sm,am,lm,cm,dm,fm,mm,gm,vm,ym,xm,wm,Em,_m,Tm,Sm]);var Hs={};ms(Hs,{JsonPatchError:()=>he,_areEquals:()=>rr,applyOperation:()=>Kt,applyPatch:()=>co,applyReducer:()=>Rm,deepClone:()=>Cm,getValueByPointer:()=>ao,validate:()=>Cc,validator:()=>lo});var Am=(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)}})(),km=Object.prototype.hasOwnProperty;function oo(t,e){return km.call(t,e)}function io(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)oo(t,o)&&r.push(o);return r}function Ee(t){switch(typeof t){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t}}function so(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 at(t){return t.indexOf("/")===-1&&t.indexOf("~")===-1?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function tr(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function ro(t){if(t===void 0)return!0;if(t){if(Array.isArray(t)){for(var e=0,n=t.length;e<n;e++)if(ro(t[e]))return!0}else if(typeof t=="object"){for(var r=io(t),o=r.length,i=0;i<o;i++)if(ro(t[r[i]]))return!0}}return!1}function kc(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 nr=(function(t){Am(e,t);function e(n,r,o,i,s){var a=this.constructor,l=t.call(this,kc(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=kc(n,{name:r,index:o,operation:i,tree:s}),l}return e})(Error);var he=nr,Cm=Ee,Cn={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=ao(n,this.path);r&&(r=Ee(r));var o=Kt(n,{op:"remove",path:this.from}).removed;return Kt(n,{op:"add",path:this.path,value:o}),{newDocument:n,removed:r}},copy:function(t,e,n){var r=ao(n,this.from);return Kt(n,{op:"add",path:this.path,value:Ee(r)}),{newDocument:n}},test:function(t,e,n){return{newDocument:n,test:rr(t[e],this.value)}},_get:function(t,e,n){return this.value=t[e],{newDocument:n}}},Im={add:function(t,e,n){return so(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:Cn.move,copy:Cn.copy,test:Cn.test,_get:Cn._get};function ao(t,e){if(e=="")return t;var n={op:"_get",path:e};return Kt(t,n),n.value}function Kt(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):lo(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=ao(t,e.from),e.op==="move"&&(s.removed=t),s;if(e.op==="test"){if(s.test=rr(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=Ee(t));var a=e.path||"",l=a.split("/"),c=t,u=1,m=l.length,y=void 0,f=void 0,h=void 0;for(typeof n=="function"?h=n:h=lo;;){if(f=l[u],f&&f.indexOf("~")!=-1&&(f=tr(f)),o&&(f=="__proto__"||f=="prototype"&&u>0&&l[u-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,u).join("/"):u==m-1&&(y=e.path),y!==void 0&&h(e,0,t,y)),u++,Array.isArray(c)){if(f==="-")f=c.length;else{if(n&&!so(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);so(f)&&(f=~~f)}if(u>=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=Im[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(u>=m){var s=Cn[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&&u<m&&(!c||typeof c!="object"))throw new he("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",i,e,t)}}}function co(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=Ee(t));for(var i=new Array(e.length),s=0,a=e.length;s<a;s++)i[s]=Kt(t,e[s],n,!0,o,s),t=i[s].newDocument;return i.newDocument=t,i}function Rm(t,e,n){var r=Kt(t,e);if(r.test===!1)throw new he("Test operation failed","TEST_OPERATION_FAILED",n,e,t);return r.newDocument}function lo(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(Cn[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")&&ro(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=Cc([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 Cc(t,e,n){try{if(!Array.isArray(t))throw new he("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)co(Ee(e),Ee(t),n||!0);else{n=n||lo;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 rr(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(!rr(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],!rr(t[s],e[s]))return!1;return!0}return t!==t&&e!==e}var $s={};ms($s,{compare:()=>Hm,generate:()=>Fs,observe:()=>Um,unobserve:()=>Dm});var zs=new WeakMap,Nm=(function(){function t(e){this.observers=new Map,this.obj=e}return t})(),Om=(function(){function t(e,n){this.callback=e,this.observer=n}return t})();function Mm(t){return zs.get(t)}function Lm(t,e){return t.observers.get(e)}function Pm(t,e){t.observers.delete(e.callback)}function Dm(t,e){e.unobserve()}function Um(t,e){var n=[],r,o=Mm(t);if(!o)o=new Nm(t),zs.set(t,o);else{var i=Lm(o,e);r=i&&i.observer}if(r)return r;if(r={},o.value=Ee(t),e){r.callback=e,r.next=null;var s=function(){Fs(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(){Fs(r),clearTimeout(r.next),Pm(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 Om(e,r)),r}function Fs(t,e){e===void 0&&(e=!1);var n=zs.get(t.object);Gs(n.value,t.object,t.patches,"",e),t.patches.length&&co(n.value,t.patches);var r=t.patches;return r.length>0&&(t.patches=[],t.callback&&t.callback(r)),r}function Gs(t,e,n,r,o){if(e!==t){typeof e.toJSON=="function"&&(e=e.toJSON());for(var i=io(e),s=io(t),a=!1,l=!1,c=s.length-1;c>=0;c--){var u=s[c],m=t[u];if(oo(e,u)&&!(e[u]===void 0&&m!==void 0&&Array.isArray(e)===!1)){var y=e[u];typeof m=="object"&&m!=null&&typeof y=="object"&&y!=null&&Array.isArray(m)===Array.isArray(y)?Gs(m,y,n,r+"/"+at(u),o):m!==y&&(a=!0,o&&n.push({op:"test",path:r+"/"+at(u),value:Ee(m)}),n.push({op:"replace",path:r+"/"+at(u),value:Ee(y)}))}else Array.isArray(t)===Array.isArray(e)?(o&&n.push({op:"test",path:r+"/"+at(u),value:Ee(m)}),n.push({op:"remove",path:r+"/"+at(u)}),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 u=i[c];!oo(t,u)&&e[u]!==void 0&&n.push({op:"add",path:r+"/"+at(u),value:Ee(e[u])})}}}function Hm(t,e,n){n===void 0&&(n=!1);var r=[];return Gs(t,e,r,"",n),r}var uo=Object.assign({},Hs,$s,{JsonPatchError:nr,deepClone:Ee,escapePathComponent:at,unescapePathComponent:tr});var Bs=function(t,e){return Bs=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])},Bs(t,e)};function lt(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Bs(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function Ic(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(u){try{c(r.next(u))}catch(m){s(m)}}function l(u){try{c(r.throw(u))}catch(m){s(m)}}function c(u){u.done?i(u.value):o(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})}function po(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(u){return l([c,u])}}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(u){c=[6,u],o=0}finally{r=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function gt(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 In(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 Rn(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 Zt(t){return this instanceof Zt?(this.v=t,this):new Zt(t)}function Rc(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(h){return Promise.resolve(h).then(f,m)}}function a(f,h){r[f]&&(o[f]=function(g){return new Promise(function(x,S){i.push([f,g,x,S])>1||l(f,g)})},h&&(o[f]=h(o[f])))}function l(f,h){try{c(r[f](h))}catch(g){y(i[0][3],g)}}function c(f){f.value instanceof Zt?Promise.resolve(f.value.v).then(u,m):y(i[0][2],f)}function u(f){l("next",f)}function m(f){l("throw",f)}function y(f,h){f(h),i.shift(),i.length&&l(i[0][0],i[0][1])}}function Nc(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 gt=="function"?gt(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 Nn(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 ho=Nn(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
3
|
+
`+n.map(function(r,o){return o+1+") "+r.toString()}).join(`
|
|
4
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function or(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var On=(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=gt(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 u=this.initialTeardown;if(B(u))try{u()}catch(g){i=g instanceof ho?g.errors:[g]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var y=gt(m),f=y.next();!f.done;f=y.next()){var h=f.value;try{Oc(h)}catch(g){i=i??[],g instanceof ho?i=Rn(Rn([],In(i)),In(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 ho(i)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)Oc(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)&&or(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&or(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=(function(){var e=new t;return e.closed=!0,e})(),t})();var Vs=On.EMPTY;function fo(t){return t instanceof On||t&&"closed"in t&&B(t.remove)&&B(t.add)&&B(t.unsubscribe)}function Oc(t){B(t)?t():t.unsubscribe()}var Ye={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var Mn={setTimeout:function(t,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=Mn.delegate;return o?.setTimeout?o.setTimeout.apply(o,Rn([t,e],In(n))):setTimeout.apply(void 0,Rn([t,e],In(n)))},clearTimeout:function(t){var e=Mn.delegate;return(e?.clearTimeout||clearTimeout)(t)},delegate:void 0};function mo(t){Mn.setTimeout(function(){var e=Ye.onUnhandledError;if(e)e(t);else throw t})}function ir(){}var Mc=(function(){return js("C",void 0,void 0)})();function Lc(t){return js("E",void 0,t)}function Pc(t){return js("N",t,void 0)}function js(t,e,n){return{kind:t,value:e,error:n}}var Qt=null;function Ln(t){if(Ye.useDeprecatedSynchronousErrorHandling){var e=!Qt;if(e&&(Qt={errorThrown:!1,error:null}),t(),e){var n=Qt,r=n.errorThrown,o=n.error;if(Qt=null,r)throw o}}else t()}function Dc(t){Ye.useDeprecatedSynchronousErrorHandling&&Qt&&(Qt.errorThrown=!0,Qt.error=t)}var sr=(function(t){lt(e,t);function e(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,fo(n)&&n.add(r)):r.destination=$m,r}return e.create=function(n,r,o){return new vo(n,r,o)},e.prototype.next=function(n){this.isStopped?Ws(Pc(n),this):this._next(n)},e.prototype.error=function(n){this.isStopped?Ws(Lc(n),this):(this.isStopped=!0,this._error(n))},e.prototype.complete=function(){this.isStopped?Ws(Mc,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})(On);var Fm=Function.prototype.bind;function qs(t,e){return Fm.call(t,e)}var zm=(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){go(r)}},t.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(r){go(r)}else go(e)},t.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){go(n)}},t})(),vo=(function(t){lt(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&&Ye.useDeprecatedNextContext?(a=Object.create(n),a.unsubscribe=function(){return i.unsubscribe()},s={next:n.next&&qs(n.next,a),error:n.error&&qs(n.error,a),complete:n.complete&&qs(n.complete,a)}):s=n}return i.destination=new zm(s),i}return e})(sr);function go(t){Ye.useDeprecatedSynchronousErrorHandling?Dc(t):mo(t)}function Gm(t){throw t}function Ws(t,e){var n=Ye.onStoppedNotification;n&&Mn.setTimeout(function(){return n(t,e)})}var $m={closed:!0,next:ir,error:Gm,complete:ir};var Pn=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Dn(t){return t}function bo(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Xs(t)}function Xs(t){return t.length===0?Dn:t.length===1?t[0]:function(n){return t.reduce(function(r,o){return o(r)},n)}}var re=(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=Vm(e)?e:new vo(e,n,r);return Ln(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=Uc(n),new n(function(o,i){var s=new vo({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[Pn]=function(){return this},t.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return Xs(e)(this)},t.prototype.toPromise=function(e){var n=this;return e=Uc(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 Uc(t){var e;return(e=t??Ye.Promise)!==null&&e!==void 0?e:Promise}function Bm(t){return t&&B(t.next)&&B(t.error)&&B(t.complete)}function Vm(t){return t&&t instanceof sr||Bm(t)&&fo(t)}function jm(t){return B(t?.lift)}function fe(t){return function(e){if(jm(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 qm(t,e,n,r,o)}var qm=(function(t){lt(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(u){n.error(u)}}:t.prototype._next,l._error=i?function(c){try{i(c)}catch(u){n.error(u)}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})(sr);var Hc=Nn(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var ct=(function(t){lt(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 Fc(this,this);return r.operator=n,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new Hc},e.prototype.next=function(n){var r=this;Ln(function(){var o,i;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var s=gt(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;Ln(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;Ln(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?Vs:(this.currentObservers=null,a.push(n),new On(function(){r.currentObservers=null,or(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 re;return n.source=this,n},e.create=function(n,r){return new Fc(n,r)},e})(re);var Fc=(function(t){lt(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:Vs},e})(ct);var Ys={now:function(){return(Ys.delegate||Date).now()},delegate:void 0};var yo=(function(t){lt(e,t);function e(n,r,o){n===void 0&&(n=1/0),r===void 0&&(r=1/0),o===void 0&&(o=Ys);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,u=1;u<i.length&&i[u]<=l;u+=2)c=u;c&&i.splice(0,c+1)}},e})(ct);var xo=new re(function(t){return t.complete()});function zc(t){return t&&B(t.schedule)}function Wm(t){return t[t.length-1]}function Gc(t){return zc(Wm(t))?t.pop():void 0}var wo=(function(t){return t&&typeof t.length=="number"&&typeof t!="function"});function Eo(t){return B(t?.then)}function _o(t){return B(t[Pn])}function To(t){return Symbol.asyncIterator&&B(t?.[Symbol.asyncIterator])}function So(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 Xm(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ao=Xm();function ko(t){return B(t?.[Ao])}function Co(t){return Rc(this,arguments,function(){var n,r,o,i;return po(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,Zt(n.read())];case 3:return r=s.sent(),o=r.value,i=r.done,i?[4,Zt(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,Zt(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 Io(t){return B(t?.getReader)}function ve(t){if(t instanceof re)return t;if(t!=null){if(_o(t))return Ym(t);if(wo(t))return Km(t);if(Eo(t))return Zm(t);if(To(t))return $c(t);if(ko(t))return Qm(t);if(Io(t))return Jm(t)}throw So(t)}function Ym(t){return new re(function(e){var n=t[Pn]();if(B(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Km(t){return new re(function(e){for(var n=0;n<t.length&&!e.closed;n++)e.next(t[n]);e.complete()})}function Zm(t){return new re(function(e){t.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,mo)})}function Qm(t){return new re(function(e){var n,r;try{for(var o=gt(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 $c(t){return new re(function(e){eg(t,e).catch(function(n){return e.error(n)})})}function Jm(t){return $c(Co(t))}function eg(t,e){var n,r,o,i;return Ic(this,void 0,void 0,function(){var s,a;return po(this,function(l){switch(l.label){case 0:l.trys.push([0,5,6,11]),n=Nc(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 Ve(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 Ro(t,e){return e===void 0&&(e=0),fe(function(n,r){n.subscribe(ge(r,function(o){return Ve(r,t,function(){return r.next(o)},e)},function(){return Ve(r,t,function(){return r.complete()},e)},function(o){return Ve(r,t,function(){return r.error(o)},e)}))})}function No(t,e){return e===void 0&&(e=0),fe(function(n,r){r.add(t.schedule(function(){return n.subscribe(r)},e))})}function Bc(t,e){return ve(t).pipe(No(e),Ro(e))}function Vc(t,e){return ve(t).pipe(No(e),Ro(e))}function jc(t,e){return new re(function(n){var r=0;return e.schedule(function(){r===t.length?n.complete():(n.next(t[r++]),n.closed||this.schedule())})})}function qc(t,e){return new re(function(n){var r;return Ve(n,e,function(){r=t[Ao](),Ve(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 Oo(t,e){if(!t)throw new Error("Iterable cannot be null");return new re(function(n){Ve(n,e,function(){var r=t[Symbol.asyncIterator]();Ve(n,e,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function Wc(t,e){return Oo(Co(t),e)}function Xc(t,e){if(t!=null){if(_o(t))return Bc(t,e);if(wo(t))return jc(t,e);if(Eo(t))return Vc(t,e);if(To(t))return Oo(t,e);if(ko(t))return qc(t,e);if(Io(t))return Wc(t,e)}throw So(t)}function Jt(t,e){return e?Xc(t,e):ve(t)}function ue(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=Gc(t);return Jt(t,n)}function oe(t,e){var n=B(t)?t:function(){return t},r=function(o){return o.error(n())};return new re(e?function(o){return e.schedule(r,0,o)}:r)}var Yc=Nn(function(t){return function(){t(this),this.name="EmptyError",this.message="no elements in sequence"}});function Mo(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 Yc)}})})}function en(t,e){return fe(function(n,r){var o=0;n.subscribe(ge(r,function(i){r.next(t.call(e,i,o++))}))})}function Kc(t,e,n,r,o,i,s,a){var l=[],c=0,u=0,m=!1,y=function(){m&&!l.length&&!c&&e.complete()},f=function(g){return c<r?h(g):l.push(g)},h=function(g){i&&e.next(g),c++;var x=!1;ve(n(g,u++)).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 _=l.shift();s?Ve(e,s,function(){return h(_)}):h(_)};l.length&&c<r;)S();y()}catch(_){e.error(_)}}))};return t.subscribe(ge(e,f,function(){m=!0,y()})),function(){a?.()}}function Le(t,e,n){return n===void 0&&(n=1/0),B(e)?Le(function(r,o){return en(function(i,s){return e(r,i,o,s)})(ve(t(r,o)))},n):(typeof e=="number"&&(n=e),fe(function(r,o){return Kc(r,o,t,n)}))}function Ks(t){return t===void 0&&(t=1/0),Le(Dn,t)}function Lo(t){return new re(function(e){ve(t()).subscribe(e)})}function ar(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,ar(t)(e))),r?(r.unsubscribe(),r=null,i.subscribe(n)):o=!0})),o&&(r.unsubscribe(),r=null,i.subscribe(n))})}function Po(t,e){return B(e)?Le(t,e,1):Le(t,1)}function Zs(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 tn(t){return fe(function(e,n){try{e.subscribe(n)}finally{n.add(t)}})}function Qs(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,u=i++;ve(t(l,u)).subscribe(o=ge(r,function(m){return r.next(e?e(l,m,u,c++):m)},function(){o=null,a()}))},function(){s=!0,a()}))})}function Do(t){return fe(function(e,n){ve(t).subscribe(ge(n,function(){return n.complete()},ir)),!n.closed&&e.subscribe(n)})}function Js(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)}))}):Dn}function Zc(t){return` \r
|
|
5
|
+
`.indexOf(t)>=0}function Uo(t){for(var e=["topLevel"],n=0,r,o,i,s=function(_){return e.push(_)},a=function(_){return e[e.length-1]=_},l=function(_){r==null&&(r=n,o=e.length,i=_)},c=function(_){_===i&&(r=void 0,o=void 0,i=void 0)},u=function(){return e.pop()},m=function(){return n--},y=function(_){if("0"<=_&&_<="9"){s("number");return}switch(_){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 h=t[n];switch(e[e.length-1]){case"topLevel":y(h);break;case"string":switch(h){case'"':u();break;case"\\":l("stringEscape"),s("stringEscaped");break}break;case"stringEscaped":h==="u"?s("stringUnicode"):(c("stringEscape"),u());break;case"stringUnicode":n-t.lastIndexOf("u",n)===4&&(c("stringEscape"),u());break;case"number":h==="."?a("numberNeedsDigit"):h==="e"||h==="E"?a("numberNeedsExponent"):(h<"0"||h>"9")&&(m(),u());break;case"numberNeedsDigit":a("number");break;case"numberNeedsExponent":a(h==="+"||h==="-"?"numberNeedsDigit":"number");break;case"true":case"false":case"null":(h<"a"||h>"z")&&(m(),u());break;case"arrayNeedsValue":h==="]"?u():Zc(h)||(c("collectionItem"),a("arrayNeedsComma"),y(h));break;case"arrayNeedsComma":h==="]"?u():h===","&&(l("collectionItem"),a("arrayNeedsValue"));break;case"objectNeedsKey":h==="}"?u():h==='"'&&(l("collectionItem"),a("objectNeedsColon"),s("string"));break;case"objectNeedsColon":h===":"&&a("objectNeedsValue");break;case"objectNeedsValue":Zc(h)||(c("collectionItem"),a("objectNeedsComma"),y(h));break;case"objectNeedsComma":h==="}"?u():h===","&&(l("collectionItem"),a("objectNeedsKey"));break}}o!=null&&(e.length=o);for(var g=[r!=null?t.slice(0,r):t],x=function(_){return g.push(_.slice(t.length-t.lastIndexOf(_[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 Jc(){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 Fo(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 Ho=4294967296;function ea(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>=Ho&&(o=o+(r/Ho|0),r=r%Ho)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),e?td(r,o):na(r,o)}function ed(t,e){let n=na(t,e),r=n.hi&2147483648;r&&(n=td(n.lo,n.hi));let o=ta(n.lo,n.hi);return r?"-"+o:o}function ta(t,e){if({lo:t,hi:e}=tg(t,e),e<=2097151)return String(Ho*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()+Qc(s)+Qc(i)}function tg(t,e){return{lo:t>>>0,hi:e>>>0}}function na(t,e){return{lo:t|0,hi:e|0}}function td(t,e){return e=~e,t?t=~t+1:e+=1,na(t,e)}var Qc=t=>{let e=String(t);return"0000000".slice(e.length)+e};function ra(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 nd(){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 Ke=ng();function ng(){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()),rd(n),n},uParse(n){return typeof n!="string"&&(n=n.toString()),od(n),n},enc(n){return typeof n!="string"&&(n=n.toString()),rd(n),ea(n)},uEnc(n){return typeof n!="string"&&(n=n.toString()),od(n),ea(n)},dec(n,r){return ed(n,r)},uDec(n,r){return ta(n,r)}}}function rd(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function od(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}var oa=Symbol.for("@bufbuild/protobuf/text-encoding");function ia(){if(globalThis[oa]==null){let t=new globalThis.TextEncoder,e=new globalThis.TextDecoder,n;globalThis[oa]={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[oa]}var Ct;(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"})(Ct||(Ct={}));var rg=34028234663852886e22,og=-34028234663852886e22,ig=4294967295,sg=2147483647,ag=-2147483648,G=class{constructor(e=ia().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(id(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return sa(e),ra(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){lg(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){id(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){sa(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return sa(e),e=(e<<1^e>>31)>>>0,ra(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),o=Ke.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=Ke.uEnc(e);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}int64(e){let n=Ke.enc(e);return Fo(n.lo,n.hi,this.buf),this}sint64(e){let n=Ke.enc(e),r=n.hi>>31,o=n.lo<<1^r,i=(n.hi<<1|n.lo>>>31)^r;return Fo(o,i,this.buf),this}uint64(e){let n=Ke.uEnc(e);return Fo(n.lo,n.hi,this.buf),this}},A=class{constructor(e,n=ia().decodeUtf8){this.decodeUtf8=n,this.varint64=Jc,this.uint32=nd,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 Ct.Varint:for(;this.buf[this.pos++]&128;);break;case Ct.Bit64:this.pos+=4;case Ct.Bit32:this.pos+=4;break;case Ct.LengthDelimited:let i=this.uint32();this.pos+=i;break;case Ct.StartGroup:if(r<=0)throw new Error("maximum recursion depth reached");for(;;){let[s,a]=this.tag();if(a===Ct.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 Ke.dec(...this.varint64())}uint64(){return Ke.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),r=-(e&1);return e=(e>>>1|(n&1)<<31)^r,n=n>>>1^r,Ke.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 Ke.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Ke.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 sa(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>sg||t<ag)throw new Error("invalid int32: "+t)}function id(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>ig||t<0)throw new Error("invalid uint32: "+t)}function lg(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>rg||t<og))throw new Error("invalid float32: "+t)}var cg=(function(t){return t[t.NULL_VALUE=0]="NULL_VALUE",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED",t})({});function aa(){return{fields:{}}}var lr={encode(t,e=new G){return Object.entries(t.fields).forEach(([n,r])=>{r!==void 0&&da.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=aa();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:{if(i!==10)break;let s=da.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 lr.fromPartial(t??{})},fromPartial(t){let e=aa();return e.fields=Object.entries(t.fields??{}).reduce((n,[r,o])=>(o!==void 0&&(n[r]=o),n),{}),e},wrap(t){let e=aa();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 sd(){return{key:"",value:void 0}}var da={encode(t,e=new G){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=sd();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 da.fromPartial(t??{})},fromPartial(t){let e=sd();return e.key=t.key??"",e.value=t.value??void 0,e}};function la(){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 G){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&&lr.encode(lr.wrap(t.structValue),e.uint32(42).fork()).join(),t.listValue!==void 0&&cr.encode(cr.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=la();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=lr.unwrap(lr.decode(n,n.uint32()));continue;case 6:if(i!==50)break;o.listValue=cr.unwrap(cr.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=la();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=la();if(t===null)e.nullValue=cg.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 ca(){return{values:[]}}var cr={encode(t,e=new G){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=ca();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 cr.fromPartial(t??{})},fromPartial(t){let e=ca();return e.values=t.values?.map(n=>n)||[],e},wrap(t){let e=ca();return e.values=t??[],e},unwrap(t){return t?.hasOwnProperty("values")&&globalThis.Array.isArray(t.values)?t.values:t}},dg=(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 ad(){return{op:0,path:"",from:void 0,value:void 0}}var Go={encode(t,e=new G){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=ad();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 Go.fromPartial(t??{})},fromPartial(t){let e=ad();return e.op=t.op??0,e.path=t.path??"",e.from=t.from??void 0,e.value=t.value??void 0,e}};function ld(){return{id:"",type:"",function:void 0}}var $o={encode(t,e=new G){return t.id!==""&&e.uint32(10).string(t.id),t.type!==""&&e.uint32(18).string(t.type),t.function!==void 0&&Bo.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=ld();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=Bo.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=ld();return e.id=t.id??"",e.type=t.type??"",e.function=t.function!==void 0&&t.function!==null?Bo.fromPartial(t.function):void 0,e}};function cd(){return{name:"",arguments:""}}var Bo={encode(t,e=new G){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=cd();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 Bo.fromPartial(t??{})},fromPartial(t){let e=cd();return e.name=t.name??"",e.arguments=t.arguments??"",e}};function dd(){return{value:"",mimeType:""}}var Vo={encode(t,e=new G){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=dd();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 Vo.fromPartial(t??{})},fromPartial(t){let e=dd();return e.value=t.value??"",e.mimeType=t.mimeType??"",e}};function ud(){return{value:"",mimeType:void 0}}var jo={encode(t,e=new G){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=ud();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 jo.fromPartial(t??{})},fromPartial(t){let e=ud();return e.value=t.value??"",e.mimeType=t.mimeType??void 0,e}};function pd(){return{data:void 0,url:void 0}}var Ue={encode(t,e=new G){return t.data!==void 0&&Vo.encode(t.data,e.uint32(10).fork()).join(),t.url!==void 0&&jo.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=pd();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.data=Vo.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.url=jo.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Ue.fromPartial(t??{})},fromPartial(t){let e=pd();return e.data=t.data!==void 0&&t.data!==null?Vo.fromPartial(t.data):void 0,e.url=t.url!==void 0&&t.url!==null?jo.fromPartial(t.url):void 0,e}};function hd(){return{text:""}}var qo={encode(t,e=new G){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=hd();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 qo.fromPartial(t??{})},fromPartial(t){let e=hd();return e.text=t.text??"",e}};function fd(){return{source:void 0,metadata:void 0}}var Wo={encode(t,e=new G){return t.source!==void 0&&Ue.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=fd();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Ue.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 Wo.fromPartial(t??{})},fromPartial(t){let e=fd();return e.source=t.source!==void 0&&t.source!==null?Ue.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function md(){return{source:void 0,metadata:void 0}}var Xo={encode(t,e=new G){return t.source!==void 0&&Ue.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=md();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Ue.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 Xo.fromPartial(t??{})},fromPartial(t){let e=md();return e.source=t.source!==void 0&&t.source!==null?Ue.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function gd(){return{source:void 0,metadata:void 0}}var Yo={encode(t,e=new G){return t.source!==void 0&&Ue.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=gd();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Ue.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 Yo.fromPartial(t??{})},fromPartial(t){let e=gd();return e.source=t.source!==void 0&&t.source!==null?Ue.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function vd(){return{source:void 0,metadata:void 0}}var Ko={encode(t,e=new G){return t.source!==void 0&&Ue.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=vd();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Ue.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 Ko.fromPartial(t??{})},fromPartial(t){let e=vd();return e.source=t.source!==void 0&&t.source!==null?Ue.fromPartial(t.source):void 0,e.metadata=t.metadata??void 0,e}};function bd(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var Zo={encode(t,e=new G){return t.text!==void 0&&qo.encode(t.text,e.uint32(10).fork()).join(),t.image!==void 0&&Wo.encode(t.image,e.uint32(18).fork()).join(),t.audio!==void 0&&Xo.encode(t.audio,e.uint32(26).fork()).join(),t.video!==void 0&&Yo.encode(t.video,e.uint32(34).fork()).join(),t.document!==void 0&&Ko.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=bd();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.text=qo.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.image=Wo.decode(n,n.uint32());continue;case 3:if(i!==26)break;o.audio=Xo.decode(n,n.uint32());continue;case 4:if(i!==34)break;o.video=Yo.decode(n,n.uint32());continue;case 5:if(i!==42)break;o.document=Ko.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=bd();return e.text=t.text!==void 0&&t.text!==null?qo.fromPartial(t.text):void 0,e.image=t.image!==void 0&&t.image!==null?Wo.fromPartial(t.image):void 0,e.audio=t.audio!==void 0&&t.audio!==null?Xo.fromPartial(t.audio):void 0,e.video=t.video!==void 0&&t.video!==null?Yo.fromPartial(t.video):void 0,e.document=t.document!==void 0&&t.document!==null?Ko.fromPartial(t.document):void 0,e}};function yd(){return{id:"",role:"",content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var Qo={encode(t,e=new G){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)$o.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)Zo.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=yd();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($o.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(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=yd();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=>$o.fromPartial(n))||[],e.toolCallId=t.toolCallId??void 0,e.error=t.error??void 0,e.contentParts=t.contentParts?.map(n=>Zo.fromPartial(n))||[],e}};function xd(){return{id:"",reason:"",message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var Jo={encode(t,e=new G){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=xd();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 Jo.fromPartial(t??{})},fromPartial(t){let e=xd();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}},ug=(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 wd(){return{type:0,timestamp:void 0,rawEvent:void 0}}var M={encode(t,e=new G){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=wd();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=pg(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=wd();return e.type=t.type??0,e.timestamp=t.timestamp??void 0,e.rawEvent=t.rawEvent??void 0,e}};function Ed(){return{baseEvent:void 0,messageId:"",role:void 0,name:void 0}}var ei={encode(t,e=new G){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=Ed();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 ei.fromPartial(t??{})},fromPartial(t){let e=Ed();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 _d(){return{baseEvent:void 0,messageId:"",delta:""}}var ti={encode(t,e=new G){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=_d();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 ti.fromPartial(t??{})},fromPartial(t){let e=_d();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 Td(){return{baseEvent:void 0,messageId:""}}var ni={encode(t,e=new G){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=Td();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 ni.fromPartial(t??{})},fromPartial(t){let e=Td();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messageId=t.messageId??"",e}};function Sd(){return{baseEvent:void 0,toolCallId:"",toolCallName:"",parentMessageId:void 0}}var ri={encode(t,e=new G){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=Sd();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 ri.fromPartial(t??{})},fromPartial(t){let e=Sd();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 Ad(){return{baseEvent:void 0,toolCallId:"",delta:""}}var oi={encode(t,e=new G){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=Ad();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 oi.fromPartial(t??{})},fromPartial(t){let e=Ad();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 kd(){return{baseEvent:void 0,toolCallId:""}}var ii={encode(t,e=new G){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=kd();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 ii.fromPartial(t??{})},fromPartial(t){let e=kd();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.toolCallId=t.toolCallId??"",e}};function Cd(){return{baseEvent:void 0,snapshot:void 0}}var si={encode(t,e=new G){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=Cd();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 si.fromPartial(t??{})},fromPartial(t){let e=Cd();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.snapshot=t.snapshot??void 0,e}};function Id(){return{baseEvent:void 0,delta:[]}}var ai={encode(t,e=new G){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.delta)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=Id();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(Go.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return ai.fromPartial(t??{})},fromPartial(t){let e=Id();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.delta=t.delta?.map(n=>Go.fromPartial(n))||[],e}};function Rd(){return{baseEvent:void 0,messages:[]}}var li={encode(t,e=new G){t.baseEvent!==void 0&&M.encode(t.baseEvent,e.uint32(10).fork()).join();for(let n of t.messages)Qo.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=Rd();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(Qo.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return li.fromPartial(t??{})},fromPartial(t){let e=Rd();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.messages=t.messages?.map(n=>Qo.fromPartial(n))||[],e}};function Nd(){return{baseEvent:void 0,event:void 0,source:void 0}}var ci={encode(t,e=new G){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=Nd();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 ci.fromPartial(t??{})},fromPartial(t){let e=Nd();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 Od(){return{baseEvent:void 0,name:"",value:void 0}}var di={encode(t,e=new G){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=Od();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 di.fromPartial(t??{})},fromPartial(t){let e=Od();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 Md(){return{baseEvent:void 0,threadId:"",runId:""}}var ui={encode(t,e=new G){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=Md();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 ui.fromPartial(t??{})},fromPartial(t){let e=Md();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 Ld(){return{baseEvent:void 0,threadId:"",runId:"",result:void 0,outcome:"",interrupts:[]}}var pi={encode(t,e=new G){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)Jo.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=Ld();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(Jo.decode(n,n.uint32()));continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return pi.fromPartial(t??{})},fromPartial(t){let e=Ld();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=>Jo.fromPartial(n))||[],e}};function Pd(){return{baseEvent:void 0,code:void 0,message:""}}var hi={encode(t,e=new G){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=Pd();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 hi.fromPartial(t??{})},fromPartial(t){let e=Pd();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 Dd(){return{baseEvent:void 0,stepName:""}}var fi={encode(t,e=new G){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=Dd();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 fi.fromPartial(t??{})},fromPartial(t){let e=Dd();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e}};function Ud(){return{baseEvent:void 0,stepName:""}}var mi={encode(t,e=new G){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=Ud();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 mi.fromPartial(t??{})},fromPartial(t){let e=Ud();return e.baseEvent=t.baseEvent!==void 0&&t.baseEvent!==null?M.fromPartial(t.baseEvent):void 0,e.stepName=t.stepName??"",e}};function Hd(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var gi={encode(t,e=new G){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=Hd();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 gi.fromPartial(t??{})},fromPartial(t){let e=Hd();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 Fd(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var vi={encode(t,e=new G){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=Fd();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 vi.fromPartial(t??{})},fromPartial(t){let e=Fd();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 zd(){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 Gd={encode(t,e=new G){return t.textMessageStart!==void 0&&ei.encode(t.textMessageStart,e.uint32(10).fork()).join(),t.textMessageContent!==void 0&&ti.encode(t.textMessageContent,e.uint32(18).fork()).join(),t.textMessageEnd!==void 0&&ni.encode(t.textMessageEnd,e.uint32(26).fork()).join(),t.toolCallStart!==void 0&&ri.encode(t.toolCallStart,e.uint32(34).fork()).join(),t.toolCallArgs!==void 0&&oi.encode(t.toolCallArgs,e.uint32(42).fork()).join(),t.toolCallEnd!==void 0&&ii.encode(t.toolCallEnd,e.uint32(50).fork()).join(),t.stateSnapshot!==void 0&&si.encode(t.stateSnapshot,e.uint32(58).fork()).join(),t.stateDelta!==void 0&&ai.encode(t.stateDelta,e.uint32(66).fork()).join(),t.messagesSnapshot!==void 0&&li.encode(t.messagesSnapshot,e.uint32(74).fork()).join(),t.raw!==void 0&&ci.encode(t.raw,e.uint32(82).fork()).join(),t.custom!==void 0&&di.encode(t.custom,e.uint32(90).fork()).join(),t.runStarted!==void 0&&ui.encode(t.runStarted,e.uint32(98).fork()).join(),t.runFinished!==void 0&&pi.encode(t.runFinished,e.uint32(106).fork()).join(),t.runError!==void 0&&hi.encode(t.runError,e.uint32(114).fork()).join(),t.stepStarted!==void 0&&fi.encode(t.stepStarted,e.uint32(122).fork()).join(),t.stepFinished!==void 0&&mi.encode(t.stepFinished,e.uint32(130).fork()).join(),t.textMessageChunk!==void 0&&gi.encode(t.textMessageChunk,e.uint32(138).fork()).join(),t.toolCallChunk!==void 0&&vi.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=zd();for(;n.pos<r;){let i=n.uint32();switch(i>>>3){case 1:if(i!==10)break;o.textMessageStart=ei.decode(n,n.uint32());continue;case 2:if(i!==18)break;o.textMessageContent=ti.decode(n,n.uint32());continue;case 3:if(i!==26)break;o.textMessageEnd=ni.decode(n,n.uint32());continue;case 4:if(i!==34)break;o.toolCallStart=ri.decode(n,n.uint32());continue;case 5:if(i!==42)break;o.toolCallArgs=oi.decode(n,n.uint32());continue;case 6:if(i!==50)break;o.toolCallEnd=ii.decode(n,n.uint32());continue;case 7:if(i!==58)break;o.stateSnapshot=si.decode(n,n.uint32());continue;case 8:if(i!==66)break;o.stateDelta=ai.decode(n,n.uint32());continue;case 9:if(i!==74)break;o.messagesSnapshot=li.decode(n,n.uint32());continue;case 10:if(i!==82)break;o.raw=ci.decode(n,n.uint32());continue;case 11:if(i!==90)break;o.custom=di.decode(n,n.uint32());continue;case 12:if(i!==98)break;o.runStarted=ui.decode(n,n.uint32());continue;case 13:if(i!==106)break;o.runFinished=pi.decode(n,n.uint32());continue;case 14:if(i!==114)break;o.runError=hi.decode(n,n.uint32());continue;case 15:if(i!==122)break;o.stepStarted=fi.decode(n,n.uint32());continue;case 16:if(i!==130)break;o.stepFinished=mi.decode(n,n.uint32());continue;case 17:if(i!==138)break;o.textMessageChunk=gi.decode(n,n.uint32());continue;case 18:if(i!==146)break;o.toolCallChunk=vi.decode(n,n.uint32());continue}if((i&7)===4||i===0)break;n.skip(i&7)}return o},create(t){return Gd.fromPartial(t??{})},fromPartial(t){let e=zd();return e.textMessageStart=t.textMessageStart!==void 0&&t.textMessageStart!==null?ei.fromPartial(t.textMessageStart):void 0,e.textMessageContent=t.textMessageContent!==void 0&&t.textMessageContent!==null?ti.fromPartial(t.textMessageContent):void 0,e.textMessageEnd=t.textMessageEnd!==void 0&&t.textMessageEnd!==null?ni.fromPartial(t.textMessageEnd):void 0,e.toolCallStart=t.toolCallStart!==void 0&&t.toolCallStart!==null?ri.fromPartial(t.toolCallStart):void 0,e.toolCallArgs=t.toolCallArgs!==void 0&&t.toolCallArgs!==null?oi.fromPartial(t.toolCallArgs):void 0,e.toolCallEnd=t.toolCallEnd!==void 0&&t.toolCallEnd!==null?ii.fromPartial(t.toolCallEnd):void 0,e.stateSnapshot=t.stateSnapshot!==void 0&&t.stateSnapshot!==null?si.fromPartial(t.stateSnapshot):void 0,e.stateDelta=t.stateDelta!==void 0&&t.stateDelta!==null?ai.fromPartial(t.stateDelta):void 0,e.messagesSnapshot=t.messagesSnapshot!==void 0&&t.messagesSnapshot!==null?li.fromPartial(t.messagesSnapshot):void 0,e.raw=t.raw!==void 0&&t.raw!==null?ci.fromPartial(t.raw):void 0,e.custom=t.custom!==void 0&&t.custom!==null?di.fromPartial(t.custom):void 0,e.runStarted=t.runStarted!==void 0&&t.runStarted!==null?ui.fromPartial(t.runStarted):void 0,e.runFinished=t.runFinished!==void 0&&t.runFinished!==null?pi.fromPartial(t.runFinished):void 0,e.runError=t.runError!==void 0&&t.runError!==null?hi.fromPartial(t.runError):void 0,e.stepStarted=t.stepStarted!==void 0&&t.stepStarted!==null?fi.fromPartial(t.stepStarted):void 0,e.stepFinished=t.stepFinished!==void 0&&t.stepFinished!==null?mi.fromPartial(t.stepFinished):void 0,e.textMessageChunk=t.textMessageChunk!==void 0&&t.textMessageChunk!==null?gi.fromPartial(t.textMessageChunk):void 0,e.toolCallChunk=t.toolCallChunk!==void 0&&t.toolCallChunk!==null?vi.fromPartial(t.toolCallChunk):void 0,e}};function pg(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 zo=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}}},hg=t=>{if(!(!t||typeof t!="object")){if(t.text)return{type:"text",text:t.text.text};if(t.image)return{type:"image",source:zo(t.image.source),metadata:t.image.metadata};if(t.audio)return{type:"audio",source:zo(t.audio.source),metadata:t.audio.metadata};if(t.video)return{type:"video",source:zo(t.video.source),metadata:t.video.metadata};if(t.document)return{type:"document",source:zo(t.document.source),metadata:t.document.metadata}}};function $d(t){let e=Gd.decode(t),n=Object.values(e).find(r=>r!==void 0);if(!n)throw new Error("Invalid event");if(n.type=ug[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=>hg(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=dg[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]}),no.parse(n)}var ua="application/vnd.ag-ui.event+proto";var mg=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,pa=t=>{if(typeof t!="string")throw new TypeError("Invalid argument expected string");let e=t.match(mg);if(!e)throw new Error(`Invalid argument not valid semver ('${t}' received)`);return e.shift(),e},Bd=t=>t==="*"||t==="x"||t==="X",Vd=t=>{let e=parseInt(t,10);return isNaN(e)?t:e},gg=(t,e)=>typeof t!=typeof e?[String(t),String(e)]:[t,e],vg=(t,e)=>{if(Bd(t)||Bd(e))return 0;let[n,r]=gg(Vd(t),Vd(e));return n>r?1:n<r?-1:0},ha=(t,e)=>{for(let n=0;n<Math.max(t.length,e.length);n++){let r=vg(t[n]||"0",e[n]||"0");if(r!==0)return r}return 0};var dr=(t,e)=>{let n=pa(t),r=pa(e),o=n.pop(),i=r.pop(),s=ha(n,r);return s!==0?s:o&&i?ha(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 _e(){return _t()}function ga(t){if(Object.freeze(t),typeof t=="object"&&t)for(let e of Object.values(t))typeof e=="object"&&e&&!Object.isFrozen(e)&&ga(e);return t}var jd=512*1024;function qd(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&&!qd(e,n,jd),l=a?q(e):e,c=a?q(n):n,u=!1,m=!1,y;for(let f of t)try{a&&(ga(l),ga(c));let h=await r(f,l,c);if(h===void 0)continue;let g=!1;if(h.messages!==void 0&&h.messages!==l&&(l=q(h.messages),u=!0,g=!0),h.state!==void 0&&h.state!==c&&(c=q(h.state),m=!0,g=!0),a&&g&&qd(l,c,jd)&&(a=!1),y=h.stopPropagation,y===!0)break}catch(h){if(s&&h instanceof TypeError){if(i)throw h;console.error("AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.",h)}else i||console.error("Subscriber error:",h);continue}return{...u?{messages:Object.isFrozen(l)?q(l):l}:{},...m?{state:Object.isFrozen(c)?q(c):c}:{},...y===void 0?{}:{stopPropagation:y}}}function bi(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 ur(t){if(t instanceof va)return t;if(t===!0)return new va(bi(!0))}var va=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 fa(t){return t.enabled?new va(t):void 0}function bg(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 Qd=(t,e,n,r,o)=>{let i=ur(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)},u=()=>{let m=q(l);return l={},m.messages!==void 0||m.state!==void 0?ue(m):xo};return e.pipe(Po(async m=>{let y=await K(r,s,a,(f,h,g)=>f.onEvent?.({event:m,agent:n,input:t,messages:h,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 u();switch(m.type){case v.TEXT_MESSAGE_START:{let f=await K(r,s,a,(h,g,x)=>h.onTextMessageStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:h,role:g="assistant",name:x}=m;if(!s.find(S=>S.id===h)){let S={id:h,role:g,content:"",...x!==void 0&&{name:x}};s.push(S),c({messages:s})}}return u()}case v.TEXT_MESSAGE_CONTENT:{let{messageId:f,delta:h}=m,g=s.find(S=>S.id===f);if(!g)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${f}'`),u();let x=await K(r,s,a,(S,_,I)=>S.onTextMessageContentEvent?.({event:m,messages:_,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:""}${h}`,c({messages:s})),u()}case v.TEXT_MESSAGE_END:{let{messageId:f}=m,h=s.find(g=>g.id===f);return h?(c(await K(r,s,a,(g,x,S)=>g.onTextMessageEndEvent?.({event:m,messages:x,state:S,agent:n,input:t,textMessageBuffer:typeof h.content=="string"?h.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:h,messages:s,state:a,agent:n,input:t})})),u()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${f}'`),u())}case v.TOOL_CALL_START:{let f=await K(r,s,a,(h,g,x)=>h.onToolCallStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{toolCallId:h,toolCallName:g,parentMessageId:x}=m,S=bg(s,x,h);S.toolCalls??=[],S.toolCalls.push({id:h,type:"function",function:{name:g,arguments:""}}),c({messages:s})}return u()}case v.TOOL_CALL_ARGS:{let{toolCallId:f,delta:h}=m,g=s.find(_=>_.toolCalls?.some(I=>I.id===f));if(!g)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${f}'`),u();let x=g.toolCalls?.find(_=>_.id===f);if(!x)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${f}'`),u();let S=await K(r,s,a,(_,I,H)=>{let U=x.function.arguments,Y=x.function.name,ie={};try{ie=Uo(U)}catch{}return _.onToolCallArgsEvent?.({event:m,messages:I,state:H,agent:n,input:t,toolCallBuffer:U,toolCallName:Y,partialToolCallArgs:ie})});return c(S),S.stopPropagation!==!0&&(x.function.arguments+=h,c({messages:s})),u()}case v.TOOL_CALL_END:{let{toolCallId:f}=m,h=s.find(x=>x.toolCalls?.some(S=>S.id===f));if(!h)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${f}'`),u();let g=h.toolCalls?.find(x=>x.id===f);return g?(c(await K(r,s,a,(x,S,_)=>{let I=g.function.arguments,H=g.function.name,U={};try{U=JSON.parse(I)}catch{}return x.onToolCallEndEvent?.({event:m,messages:S,state:_,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})})),u()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${f}'`),u())}case v.TOOL_CALL_RESULT:{let f=await K(r,s,a,(h,g,x)=>h.onToolCallResultEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:h,toolCallId:g,content:x,role:S}=m,_={id:h,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(_);else{let H=I+1;for(;H<s.length&&s[H].role==="tool";)H++;s.splice(H,0,_)}await Promise.all(r.map(H=>{H.onNewMessage?.({message:_,messages:s,state:a,agent:n,input:t})})),c({messages:s})}return u()}case v.STATE_SNAPSHOT:{let f=await K(r,s,a,(h,g,x)=>h.onStateSnapshotEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{snapshot:h}=m;a=h,c({state:a})}return u()}case v.STATE_DELTA:{let f=await K(r,s,a,(h,g,x)=>h.onStateDeltaEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{delta:h}=m;try{a=uo.applyPatch(a,h,!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(h,null,2)}
|
|
8
|
-
Error: ${x}`)}}return p()}case v.MESSAGES_SNAPSHOT:{let f=await Y(r,s,a,(h,g,x)=>h.onMessagesSnapshotEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messages:h}=m,g=new Map(h.map(I=>[I.id,I])),x=h.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 E=new Set(s.map(I=>I.id));for(let I of h)E.has(I.id)||s.push(I);c({messages:s})}return p()}case v.ACTIVITY_SNAPSHOT:{let f=m,h=s.findIndex(I=>I.id===f.messageId),g=h>=0?s[h]:void 0,x=g?.role==="activity"?g:void 0,S=f.replace??!0,E=await Y(r,s,a,(I,H,U)=>I.onActivitySnapshotEvent?.({event:f,messages:H,state:U,agent:n,input:t,activityMessage:x,existingMessage:g}));if(c(E),E.stopPropagation!==!0){let I={id:f.messageId,role:"activity",activityType:f.activityType,content:q(f.content)},H;h===-1?(s.push(I),H=I):x?S&&(s[h]={...x,activityType:f.activityType,content:q(f.content)}):S&&(s[h]=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 p()}case v.ACTIVITY_DELTA:{let f=m,h=s.findIndex(E=>E.id===f.messageId);if(h===-1)return p();let g=s[h];if(g.role!=="activity")return console.warn(`ACTIVITY_DELTA: Message '${f.messageId}' is not an activity message`),p();let x=g,S=await Y(r,s,a,(E,I,H)=>E.onActivityDeltaEvent?.({event:f,messages:I,state:H,agent:n,input:t,activityMessage:x}));if(c(S),S.stopPropagation!==!0)try{let E=q(x.content??{}),I=oi.applyPatch(E,f.patch??[],!0,!1).newDocument;s[h]={...x,content:q(I),activityType:f.activityType},c({messages:s})}catch(E){let I=E instanceof Error?E.message:String(E);console.warn(`Failed to apply activity patch for '${f.messageId}': ${I}`)}return p()}case v.RAW:return c(await Y(r,s,a,(f,h,g)=>f.onRawEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),p();case v.CUSTOM:return c(await Y(r,s,a,(f,h,g)=>f.onCustomEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),p();case v.RUN_STARTED:{let f=await Y(r,s,a,(h,g,x)=>h.onRunStartedEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let h=m;if(h.input?.messages){for(let g of h.input.messages)s.find(x=>x.id===g.id)||s.push(g);c({messages:s})}}return p()}case v.RUN_FINISHED:{let f=m,h=f.outcome?.type==="interrupt"?{event:f,outcome:"interrupt",interrupts:f.outcome.interrupts}:{event:f,outcome:"success",result:f.result},g=await Y(r,s,a,(x,S,E)=>x.onRunFinishedEvent?.({...h,messages:S,state:E,agent:n,input:t}));return c(g),g.stopPropagation!==!0&&(n.pendingInterrupts=h.outcome==="interrupt"?[...h.interrupts]:[]),p()}case v.RUN_ERROR:return c(await Y(r,s,a,(f,h,g)=>f.onRunErrorEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),p();case v.STEP_STARTED:return c(await Y(r,s,a,(f,h,g)=>f.onStepStartedEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),p();case v.STEP_FINISHED:return c(await Y(r,s,a,(f,h,g)=>f.onStepFinishedEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),p();case v.TEXT_MESSAGE_CHUNK:throw Error("TEXT_MESSAGE_CHUNK must be tranformed before being applied");case v.TOOL_CALL_CHUNK:throw Error("TOOL_CALL_CHUNK must be tranformed before being applied");case v.THINKING_START:return p();case v.THINKING_END:return p();case v.THINKING_TEXT_MESSAGE_START:return p();case v.THINKING_TEXT_MESSAGE_CONTENT:return p();case v.THINKING_TEXT_MESSAGE_END:return p();case v.REASONING_START:return c(await Y(r,s,a,(f,h,g)=>f.onReasoningStartEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),p();case v.REASONING_MESSAGE_START:{let f=await Y(r,s,a,(h,g,x)=>h.onReasoningMessageStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:h}=m;if(!s.find(g=>g.id===h)){let g={id:h,role:"reasoning",content:""};s.push(g),c({messages:s})}}return p()}case v.REASONING_MESSAGE_CONTENT:{let{messageId:f,delta:h}=m,g=s.find(S=>S.id===f);if(!g)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${f}'`),p();let x=await Y(r,s,a,(S,E,I)=>S.onReasoningMessageContentEvent?.({event:m,messages:E,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:""}${h}`,c({messages:s})),p()}case v.REASONING_MESSAGE_END:{let{messageId:f}=m,h=s.find(g=>g.id===f);return h?(c(await Y(r,s,a,(g,x,S)=>g.onReasoningMessageEndEvent?.({event:m,messages:x,state:S,agent:n,input:t,reasoningMessageBuffer:typeof h.content=="string"?h.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:h,messages:s,state:a,agent:n,input:t})})),p()):(console.warn(`REASONING_MESSAGE_END: No message found with ID '${f}'`),p())}case v.REASONING_MESSAGE_CHUNK:throw Error("REASONING_MESSAGE_CHUNK must be transformed before being applied");case v.REASONING_END:return c(await Y(r,s,a,(f,h,g)=>f.onReasoningEndEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),p();case v.REASONING_ENCRYPTED_VALUE:{let{subtype:f,entityId:h,encryptedValue:g}=m,x=await Y(r,s,a,(S,E,I)=>S.onReasoningEncryptedValueEvent?.({event:m,messages:E,state:I,agent:n,input:t}));if(c(x),x.stopPropagation!==!0){let S=!1;if(f==="tool-call"){for(let E of s)if(E.role==="assistant"&&E.toolCalls){let I=E.toolCalls.find(H=>H.id===h);if(I){I.encryptedValue=g,S=!0;break}}}else{let E=s.find(I=>I.id===h);E?.role!=="activity"&&E&&(E.encryptedValue=g,S=!0)}S&&(l.messages=s)}return p()}}return m.type,p()}),zs(),r.length>0?Gs({}):m=>m)},ia=t=>e=>{let n=dr(t),r=new Map,i=new Map,o=!1,s=!1,a=!1,l=new Map,c=!1,p=!1,m=!1,y=()=>{r.clear(),i.clear(),l.clear(),c=!1,p=!1,o=!1,s=!1,m=!0};return e.pipe(Le(f=>{let h=f.type;if(n?.event("VERIFY","Event:",f,{type:f.type}),s)return re(()=>new te(`Cannot send event type '${h}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(o&&h!==v.RUN_ERROR&&h!==v.RUN_STARTED)return re(()=>new te(`Cannot send event type '${h}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(a){if(h===v.RUN_STARTED){if(m&&!o)return re(()=>new te("Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run."));o&&y()}}else if(a=!0,h!==v.RUN_STARTED&&h!==v.RUN_ERROR)return re(()=>new te("First event must be 'RUN_STARTED'"));switch(h){case v.TEXT_MESSAGE_START:{let g=f.messageId;return r.has(g)?re(()=>new te(`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):re(()=>new te(`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)):re(()=>new te(`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 i.has(g)?re(()=>new te(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${g}' is already in progress. Complete it with 'TOOL_CALL_END' first.`)):(i.set(g,!0),ue(f))}case v.TOOL_CALL_ARGS:{let g=f.toolCallId;return i.has(g)?ue(f):re(()=>new te(`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 i.has(g)?(i.delete(g),ue(f)):re(()=>new te(`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)?re(()=>new te(`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)):re(()=>new te(`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 re(()=>new te(`Cannot send 'RUN_FINISHED' while steps are still active: ${g}`))}if(r.size>0){let g=Array.from(r.keys()).join(", ");return re(()=>new te(`Cannot send 'RUN_FINISHED' while text messages are still active: ${g}`))}if(i.size>0){let g=Array.from(i.keys()).join(", ");return re(()=>new te(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${g}`))}return o=!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?p?re(()=>new te("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.")):(p=!0,ue(f)):re(()=>new te("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first."));case v.THINKING_TEXT_MESSAGE_CONTENT:return p?ue(f):re(()=>new te("Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first."));case v.THINKING_TEXT_MESSAGE_END:return p?(p=!1,ue(f)):re(()=>new te("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?re(()=>new te("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)):re(()=>new te("Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first."));default:return ue(f)}}))},nn=(function(t){return t.HEADERS="headers",t.DATA="data",t})({}),jm=t=>Ci(()=>Qt(t())).pipe(Fs(e=>{if(!e.ok){let i=e.headers.get("content-type")||"";return Qt(e.text()).pipe(Le(o=>{let s=o;if(i.includes("application/json"))try{s=JSON.parse(o)}catch{}let a=Error(`HTTP ${e.status}: ${typeof s=="string"?s:JSON.stringify(s)}`);return a.status=e.status,a.payload=s,re(()=>a)}))}let n={type:nn.HEADERS,status:e.status,headers:e.headers},r=e.body?.getReader();return r?new ne(i=>(i.next(n),(async()=>{try{for(;;){let{done:o,value:s}=await r.read();if(o)break;let a={type:nn.DATA,data:s};i.next(a)}i.complete()}catch(o){i.error(o)}})(),()=>{r.cancel().catch(o=>{if(o?.name!=="AbortError")throw o})})):re(()=>Error("Failed to getReader() from response"))})),qm=(t,e)=>{let n=dr(e),r=new ct,i=new TextDecoder("utf-8",{fatal:!1}),o="";t.subscribe({next:a=>{if(a.type!==nn.HEADERS&&a.type===nn.DATA&&a.data){let l=i.decode(a.data,{stream:!0});o+=l;let c=o.split(/\n\n/);o=c.pop()||"";for(let p of c)s(p)}},error:a=>r.error(a),complete:()=>{o&&(o+=i.decode(),s(o)),r.complete()}});function s(a){let l=a.split(`
|
|
9
|
-
`),c=[];for(let
|
|
10
|
-
`),m=JSON.parse(
|
|
11
|
-
`)},ag=(t,e,n)=>r=>{let i={},o=!0,s=!0,a="",l=null,c=null,p=[],m={},y=f=>{typeof f=="object"&&f&&("messages"in f&&delete f.messages,i=f)};return r.pipe(Le(f=>{switch(f.type){case v.TEXT_MESSAGE_START:{let h=f;return[{type:Q.enum.TextMessageStart,messageId:h.messageId,role:h.role}]}case v.TEXT_MESSAGE_CONTENT:{let h=f;return[{type:Q.enum.TextMessageContent,messageId:h.messageId,content:h.delta}]}case v.TEXT_MESSAGE_END:{let h=f;return[{type:Q.enum.TextMessageEnd,messageId:h.messageId}]}case v.TOOL_CALL_START:{let h=f;return p.push({id:h.toolCallId,type:"function",function:{name:h.toolCallName,arguments:""}}),s=!0,m[h.toolCallId]=h.toolCallName,[{type:Q.enum.ActionExecutionStart,actionExecutionId:h.toolCallId,actionName:h.toolCallName,parentMessageId:h.parentMessageId}]}case v.TOOL_CALL_ARGS:{let h=f,g=p.find(S=>S.id===h.toolCallId);if(!g)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${h.toolCallId}'`),[];g.function.arguments+=h.delta;let x=!1;if(c){let S=c.find(E=>E.tool==g.function.name);if(S)try{let E=JSON.parse(Ni(g.function.arguments));S.tool_argument&&S.tool_argument in E?(y({...i,[S.state_key]:E[S.tool_argument]}),x=!0):S.tool_argument||(y({...i,[S.state_key]:E}),x=!0)}catch{}}return[{type:Q.enum.ActionExecutionArgs,actionExecutionId:h.toolCallId,args:h.delta},...x?[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:o,role:"assistant",state:JSON.stringify(i),active:s}]:[]]}case v.TOOL_CALL_END:{let h=f;return[{type:Q.enum.ActionExecutionEnd,actionExecutionId:h.toolCallId}]}case v.TOOL_CALL_RESULT:{let h=f;return[{type:Q.enum.ActionExecutionResult,actionExecutionId:h.toolCallId,result:h.content,actionName:m[h.toolCallId]||"unknown"}]}case v.RAW:return[];case v.CUSTOM:{let h=f;switch(h.name){case"Exit":o=!1;break;case"PredictState":c=h.value;break}return[{type:Q.enum.MetaEvent,name:h.name,value:h.value}]}case v.STATE_SNAPSHOT:return y(f.snapshot),[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:o,role:"assistant",state:JSON.stringify(i),active:s}];case v.STATE_DELTA:{let h=f,g=oi.applyPatch(i,h.delta,!0,!1);return g?(y(g.newDocument),[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:o,role:"assistant",state:JSON.stringify(i),active:s}]):[]}case v.MESSAGES_SNAPSHOT:return l=f.messages,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:o,role:"assistant",state:JSON.stringify({...i,...l?{messages:l}:{}}),active:!0}];case v.RUN_STARTED:return[];case v.RUN_FINISHED:return l&&(i.messages=l),Object.keys(i).length===0?[]:[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:o,role:"assistant",state:JSON.stringify({...i,...l?{messages:lg(l)}:{}}),active:!1}];case v.RUN_ERROR:{let h=f;return[{type:Q.enum.RunError,message:h.message,code:h.code}]}case v.STEP_STARTED:return a=f.stepName,p=[],c=null,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:o,role:"assistant",state:JSON.stringify(i),active:!0}];case v.STEP_FINISHED:return p=[],c=null,[{type:Q.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:o,role:"assistant",state:JSON.stringify(i),active:!1}];default:return[]}}))};function lg(t){let e=[];for(let n of t)if(n.role==="assistant"||n.role==="user"||n.role==="system"){let r=sg(n.content);if(r){let i={id:n.id,role:n.role,content:r};e.push(i)}if(n.role==="assistant"&&n.toolCalls&&n.toolCalls.length>0)for(let i of n.toolCalls){let o={id:i.id,name:i.function.name,arguments:JSON.parse(i.function.arguments),parentMessageId:n.id};e.push(o)}}else if(n.role==="tool"){let r="unknown";for(let o of t)if(o.role==="assistant"&&o.toolCalls?.length){for(let s of o.toolCalls)if(s.id===n.toolCallId){r=s.function.name;break}}let i={id:n.id,result:n.content,actionExecutionId:n.toolCallId,actionName:r};e.push(i)}return e}var fo=t=>e=>{let n=dr(t),r,i,o,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(!i||s!=="tool")throw Error("No tool call to close");let m={type:v.TOOL_CALL_END,toolCallId:i.toolCallId};return s=void 0,i=void 0,n?.event("TRANSFORM","TOOL_CALL_END",m,{toolCallId:m.toolCallId}),m},c=()=>{if(!o||s!=="reasoning")throw Error("No reasoning message to close");let m={type:v.REASONING_MESSAGE_END,messageId:o.messageId};return s=void 0,o=void 0,n?.event("TRANSFORM","REASONING_MESSAGE_END",m,{messageId:m.messageId}),m},p=()=>s==="text"?[a()]:s==="tool"?[l()]:s==="reasoning"?[c()]:[];return e.pipe(Le(m=>{switch(m.type){case v.TEXT_MESSAGE_START:case v.TEXT_MESSAGE_CONTENT:case v.TEXT_MESSAGE_END:case v.TOOL_CALL_START:case v.TOOL_CALL_ARGS:case v.TOOL_CALL_END:case v.TOOL_CALL_RESULT:case v.STATE_SNAPSHOT:case v.STATE_DELTA:case v.MESSAGES_SNAPSHOT:case v.CUSTOM:case v.RUN_STARTED:case v.RUN_FINISHED:case v.RUN_ERROR:case v.STEP_STARTED:case v.STEP_FINISHED:case v.THINKING_START:case v.THINKING_END:case v.THINKING_TEXT_MESSAGE_START:case v.THINKING_TEXT_MESSAGE_CONTENT:case v.THINKING_TEXT_MESSAGE_END:case v.REASONING_START:case v.REASONING_MESSAGE_START:case v.REASONING_MESSAGE_CONTENT:case v.REASONING_MESSAGE_END:case v.REASONING_END:return[...p(),m];case v.RAW:case v.ACTIVITY_SNAPSHOT:case v.ACTIVITY_DELTA:case v.REASONING_ENCRYPTED_VALUE:return[m];case v.TEXT_MESSAGE_CHUNK:let y=m,f=[];if((s!=="text"||y.messageId!==void 0&&y.messageId!==r?.messageId)&&f.push(...p()),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 E={type:v.TEXT_MESSAGE_START,messageId:y.messageId,role:y.role||"assistant",...y.name!==void 0&&{name:y.name}};f.push(E),n?.event("TRANSFORM","TEXT_MESSAGE_START",E,{messageId:y.messageId})}if(y.delta!==void 0){let E={type:v.TEXT_MESSAGE_CONTENT,messageId:r.messageId,delta:y.delta};f.push(E),n?.event("TRANSFORM","TEXT_MESSAGE_CONTENT",E,{messageId:r.messageId})}return f;case v.TOOL_CALL_CHUNK:let h=m,g=[];if((s!=="tool"||h.toolCallId!==void 0&&h.toolCallId!==i?.toolCallId)&&g.push(...p()),s!=="tool"){if(h.toolCallId===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallId");if(h.toolCallName===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallName");i={toolCallId:h.toolCallId,toolCallName:h.toolCallName,parentMessageId:h.parentMessageId},s="tool";let E={type:v.TOOL_CALL_START,toolCallId:h.toolCallId,toolCallName:h.toolCallName,parentMessageId:h.parentMessageId};g.push(E),n?.event("TRANSFORM","TOOL_CALL_START",E,{toolCallId:h.toolCallId,toolCallName:h.toolCallName})}if(h.delta!==void 0){let E={type:v.TOOL_CALL_ARGS,toolCallId:i.toolCallId,delta:h.delta};g.push(E),n?.event("TRANSFORM","TOOL_CALL_ARGS",E,{toolCallId:i.toolCallId})}return g;case v.REASONING_MESSAGE_CHUNK:let x=m,S=[];if((s!=="reasoning"||x.messageId&&x.messageId!==o?.messageId)&&S.push(...p()),s!=="reasoning"){if(x.messageId===void 0)throw Error("First REASONING_MESSAGE_CHUNK must have a messageId");o={messageId:x.messageId},s="reasoning";let E={type:v.REASONING_MESSAGE_START,messageId:x.messageId};S.push(E),n?.event("TRANSFORM","REASONING_MESSAGE_START",E,{messageId:x.messageId})}if(x.delta!==void 0){let E={type:v.REASONING_MESSAGE_CONTENT,messageId:o.messageId,delta:x.delta};S.push(E),n?.event("TRANSFORM","REASONING_MESSAGE_CONTENT",E,{messageId:o.messageId})}return S}return m.type,[]}),tn(()=>{p()}))};function cg(t,e=new Date){return t.expiresAt===void 0?!1:new Date(t.expiresAt)<=e}function Nd(t,e){let n=new Set(t.map(s=>s.id)),r=new Set(Object.keys(e)),i=[...n].filter(s=>!r.has(s));if(i.length>0)throw Error(`buildResumeArray: missing responses for open interrupts: ${i.join(", ")}`);let o=[...r].filter(s=>!n.has(s));if(o.length>0)throw Error(`buildResumeArray: responses reference unknown interrupt ids: ${o.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 mo=class{runNext(t,e){return e.run(t).pipe(fo(!1))}runNextWithState(t,e){let n=q(t.messages||[]),r=q(t.state||{}),i=new hi;return Rd(t,i,e,[]).subscribe(o=>{o.messages!==void 0&&(n=o.messages),o.state!==void 0&&(r=o.state)}),this.runNext(t,e).pipe(Ii(async o=>(i.next(o),await new Promise(s=>setTimeout(s,0)),{event:o,messages:q(n),state:q(r)})))}},dg=class extends mo{constructor(t){super(),this.fn=t}run(t,e){return this.fn(t,e)}};function ug(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 pg=class extends mo{run(t,e){let{parentRunId:n,...r}=t,i={...r,messages:r.messages.map(ug)};return this.runNext(i,e)}},Sd="THINKING_START",Ad="THINKING_END",kd="THINKING_TEXT_MESSAGE_START",Cd="THINKING_TEXT_MESSAGE_CONTENT",Id="THINKING_TEXT_MESSAGE_END",hg=class extends mo{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(en(n=>this.transformEvent(n)))}transformEvent(t){switch(t.type){case Sd:{this.currentReasoningId=Ee();let{title:e,...n}=t;return this.warnAboutTransformation(Sd,v.REASONING_START),{...n,type:v.REASONING_START,messageId:this.currentReasoningId}}case kd:return this.currentMessageId=Ee(),this.warnAboutTransformation(kd,v.REASONING_MESSAGE_START),{...t,type:v.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:"assistant"};case Cd:{let{delta:e,...n}=t;return this.warnAboutTransformation(Cd,v.REASONING_MESSAGE_CONTENT),{...n,type:v.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??Ee(),delta:e}}case Id:{let e=this.currentMessageId??Ee();return this.warnAboutTransformation(Id,v.REASONING_MESSAGE_END),{...t,type:v.REASONING_MESSAGE_END,messageId:e}}case Ad:{let e=this.currentReasoningId??Ee();return this.warnAboutTransformation(Ad,v.REASONING_END),{...t,type:v.REASONING_END,messageId:e}}default:return t}}};function fg(t){return t.startsWith("image/")?"image":t.startsWith("audio/")?"audio":t.startsWith("video/")?"video":"document"}function mg(t){return typeof t=="object"&&!!t&&"type"in t&&t.type==="binary"&&"mimeType"in t&&typeof t.mimeType=="string"}function gg(t){let e=fg(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 vg(t){let e=t.content;if(!Array.isArray(e))return t;let n=e.map(r=>mg(r)?gg(r):r);return{...t,content:n}}var bg=class extends mo{run(t,e){let n={...t,messages:t.messages.map(vg)};return this.runNext(n,e)}},yg="0.0.57",xg=class{get maxVersion(){return yg}get debug(){return this._debug}set debug(t){this._debug=ho(t),this._debugLogger=ra(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(t){typeof t=="boolean"?this._debugLogger=t?ra(ho(!0)):void 0:this._debugLogger=t}constructor({agentId:t,description:e,threadId:n,initialMessages:r,initialState:i,debug:o}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.agentId=t,this.description=e??"",this.threadId=n??Et(),this.messages=q(r??[]),this.state=q(i??{}),this._debug=ho(o),this._debugLogger=ra(this._debug),cr(this.maxVersion,"0.0.39")<=0&&this.middlewares.unshift(new pg),cr(this.maxVersion,"0.0.45")<=0&&this.middlewares.unshift(new hg),cr(this.maxVersion,"0.0.47")<=0&&this.middlewares.unshift(new bg)}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 dg(n):n);return this.middlewares.push(...e),this}async runAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??Et();let n=this.prepareRunAgentInput(t);this.debugLogger?.lifecycle("LIFECYCLE","Run started:",{agentId:this.agentId,threadId:this.threadId});let r,i=new Set(this.messages.map(l=>l.id)),o=[{onRunFinishedEvent:l=>{l.outcome==="success"&&(r=l.result)}},...this.subscribers,e??{}];await this.onInitialize(n,o),this.activeRunDetach$=new ct;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await ki(pi(()=>this.middlewares.length===0?this.run(n):this.middlewares.reduceRight((l,c)=>({run:p=>c.run(p,l),get messages(){return l.messages},get state(){return l.state}}),this).run(n),fo(this.debugLogger),ia(this.debugLogger),l=>l.pipe(Ri(this.activeRunDetach$)),l=>this.apply(n,l,o),l=>this.processApplyEvents(n,l,o),sr(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,o))),tn(()=>{this.debugLogger?.lifecycle("LIFECYCLE","Run finished:",{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(n,o),s?.(),s=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(ue(null)));let a=q(this.messages).filter(l=>!i.has(l.id));return{result:r,newMessages:a}}finally{this.isRunning=!1}}connect(t){throw new As}async connectAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??Et();let n=this.prepareRunAgentInput(t),r,i=new Set(this.messages.map(l=>l.id)),o=[{onRunFinishedEvent:l=>{l.outcome==="success"&&(r=l.result)}},...this.subscribers,e??{}];await this.onInitialize(n,o),this.activeRunDetach$=new ct;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await ki(pi(()=>Ci(()=>this.connect(n)),fo(this.debugLogger),ia(this.debugLogger),l=>l.pipe(Ri(this.activeRunDetach$)),l=>this.apply(n,l,o),l=>this.processApplyEvents(n,l,o),sr(l=>(this.isRunning=!1,l instanceof As?fi:this.onError(n,l,o))),tn(()=>{this.isRunning=!1,this.onFinalize(n,o),s?.(),s=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(ue(null)),{defaultValue:void 0});let a=q(this.messages).filter(l=>!i.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 Rd(t,e,this,n,this.debugLogger)}processApplyEvents(t,e,n){return e.pipe($s(r=>{r.messages&&(this.messages=r.messages,n.forEach(i=>{i.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),r.state&&(this.state=r.state,n.forEach(i=>{i.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||Et(),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(o=>o.interruptId)),i=this.pendingInterrupts.map(o=>o.id).filter(o=>!r.has(o));if(i.length>0)throw new te(`Thread has ${i.length} pending interrupt(s) not addressed by resume: ${i.join(", ")}`);for(let o of this.pendingInterrupts)if(cg(o))throw new te(`Interrupt ${o.id} expired at ${o.expiresAt}`)}let n=await Y(e,this.messages,this.state,(r,i,o)=>r.onRunInitialized?.({messages:i,state:o,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 Qt(Y(n,this.messages,this.state,(r,i,o)=>r.onRunFailed?.({error:e,messages:i,state:o,agent:this,input:t}))).pipe(en(r=>{let i=r;if((i.messages!==void 0||i.state!==void 0)&&(i.messages!==void 0&&(this.messages=i.messages,n.forEach(o=>{o.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:t})})),i.state!==void 0&&(this.state=i.state,n.forEach(o=>{o.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:t})}))),i.stopPropagation!==!0){let o=String(e);if(!(e.name==="AbortError"||e.message==="Fetch is aborted"||e.message==="signal is aborted without reason"||e.message==="component unmounted"||o==="component unmounted"))throw console.error("Agent execution failed:",e),e}return{}}))}async onFinalize(t,e){let n=await Y(e,this.messages,this.state,(r,i,o)=>r.onRunFinalized?.({messages:i,state:o,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??Et();let e=this.prepareRunAgentInput(t);return(this.middlewares.length===0?this.run(e):this.middlewares.reduceRight((n,r)=>({run:i=>r.run(i,n),get messages(){return n.messages},get state(){return n.state}}),this).run(e)).pipe(fo(this.debugLogger),ia(this.debugLogger),ag(this.threadId,e.runId,this.agentId),n=>n.pipe(en(r=>(this.debugLogger?.event("LEGACY","Event:",r,{type:r.type}),r))))}},Od=class extends xg{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 Xm(jm(()=>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 wg=/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;function Md(t,e){let n=[];return{text:t.replace(wg,(i,o)=>{let s=e[o];return s==null||s===""?(n.includes(o)||n.push(o),i):String(s)}),missing:n}}function _g(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 aa(t){return Array.isArray(t)?t.filter(_g):[]}var ur=class{#t=new Map;register(e){this.#t.set(e.name,e)}has(e){return this.#t.has(e)}get(e){let n=this.#t.get(e);if(n===void 0)throw new Error(`tool "${e}" is not registered`);return n}tools(){return[...this.#t.values()].map(e=>({name:e.name,description:e.description,parameters:e.parameters}))}};function la(t){return t[Xn]===!0}function go(t){return t[Kn]===!0}function vo(t,e){return Object.getOwnPropertyDescriptor(t,e).set}var Eg=vo(HTMLInputElement.prototype,"value"),Tg=vo(HTMLTextAreaElement.prototype,"value"),Sg=vo(HTMLSelectElement.prototype,"value"),Ag=vo(HTMLInputElement.prototype,"checked");function rn(t,e){t instanceof HTMLTextAreaElement?Tg.call(t,e):t instanceof HTMLSelectElement?Sg.call(t,e):Eg.call(t,e)}function pr(t,e){Ag.call(t,e)}var ca="#4f46e5",kg="rgba(79, 70, 229, 0.4)",Cg="--ag-ui-accent";function hr(t){return new Promise(e=>{setTimeout(e,t)})}function bo(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function da(t){return t<=0||bo()?Promise.resolve():hr(t)}function yo(t,e){let n=window.getComputedStyle(t).getPropertyValue(Cg).trim();return n===""?e:n}function Ld(t){return`0 0 0 3px ${yo(t,kg)}`}async function ua(t,e,n={}){let r=n.charDelayMs??35;rn(t,""),t.dispatchEvent(new Event("input",{bubbles:!0}));for(let i of e)rn(t,t.value+i),t.dispatchEvent(new Event("input",{bubbles:!0})),r>0&&await hr(r);t.dispatchEvent(new Event("change",{bubbles:!0}))}async function pa(t,e={}){let n=e.highlightMs??280,r=t.style.outline,i=t.style.outlineOffset;t.style.outline=`2px solid ${yo(t,ca)}`,t.style.outlineOffset="2px",await hr(n),t.style.outline=r,t.style.outlineOffset=i,t.click()}var Ig=600,Rg=100;function vt(t,e={}){let n=bo();return t.scrollIntoView({block:"center",inline:"nearest",behavior:n?"auto":"smooth"}),n?Promise.resolve():new Promise(r=>{let i,o=()=>{clearTimeout(i),document.removeEventListener("scroll",s,!0),document.removeEventListener("scrollend",o,!0),r()},s=()=>{document.removeEventListener("scroll",s,!0),clearTimeout(i),i=setTimeout(o,e.settleMs??Ig)};i=setTimeout(o,Rg),document.addEventListener("scroll",s,!0),document.addEventListener("scrollend",o,!0)})}var Ng=1200,Og=1/3;async function Pd(t,e,n){(e.focus??n)&&t.focus({preventScroll:!0});let r=e.flashMs??Ng;if(r<=0)return;let i=t.style.outline,o=t.style.outlineOffset,s=t.style.transition,a=e.color??yo(t,ca);t.style.outline=`3px solid ${a}`,t.style.outlineOffset="2px";let l=bo()?0:Math.round(r*Og);await hr(r-l),l>0&&(t.style.transition=`outline-color ${l}ms ease-out`,t.style.outline="3px solid transparent",await hr(l)),t.style.outline=i,t.style.outlineOffset=o,t.style.transition=s}function Mg(t,e={}){return Pd(t,e,!1)}function ha(t,e={}){return Pd(t,e,!0)}async function fa(t,e={}){let n=e.pressMs??140,r=t.style.transform,i=t.style.transition,o=t.style.boxShadow;t.style.transition="transform 80ms ease",t.style.transform="scale(0.96)",t.style.boxShadow=Ld(t),await da(n),t.style.transform=r,t.style.transition=i,t.style.boxShadow=o,t.click()}function Lg(t,e){for(let n of Array.from(t.options))if(n.value===e||n.text===e)return n;return null}async function ma(t,e,n={}){let r=Lg(t,e);if(r===null)throw new Error(`no <option> matching "${e}"`);let i=n.highlightMs??220,o=t.style.outline,s=t.style.outlineOffset;t.style.outline=`2px solid ${yo(t,ca)}`,t.style.outlineOffset="2px",await da(i),rn(t,r.value),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),t.style.outline=o,t.style.outlineOffset=s}async function ga(t,e,n={}){let r=n.flashMs??200,i=t.style.boxShadow;t.style.boxShadow=Ld(t),await da(r),pr(t,e),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),t.style.boxShadow=i}var va={SCROLL:"scroll",DRAG:"drag"};function ba(t,e){let n=[];return t.has(va.SCROLL)&&n.push(Pg(e)),t.has(va.DRAG)&&n.push(Dg(e)),n}function Pg(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"],[Pe]:"Scroll into view"},handler:e=>{let n=String(e.target??"");if(n==="top"||n==="bottom"){let i=n==="top"?0:document.body.scrollHeight;return window.scrollTo({top:i,behavior:"smooth"}),{scrolled:!0,target:n}}let r=t(n);if(r===null)throw new Error(`no element matching "${n}"`);return vt(r),{scrolled:!0,target:n}}}}function Dg(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"],[Pe]:"Drag and drop"},handler:e=>{let n=String(e.from??""),r=String(e.to??""),i=t(n);if(i===null)throw new Error(`no element matching "${n}"`);let o=t(r);if(o===null)throw new Error(`no element matching "${r}"`);return Ug(i,o),{dragged:!0,from:n,to:r}}}}function Ug(t,e){let n=new DataTransfer;fr(t,"dragstart",n),fr(e,"dragenter",n),fr(e,"dragover",n),fr(e,"drop",n),fr(t,"dragend",n)}function fr(t,e,n){let r=new Event(e,{bubbles:!0,cancelable:!0});r.dataTransfer=n,t.dispatchEvent(r)}function ya(t,e){return!e||t===null?[]:[{description:"page_map",value:JSON.stringify(t())}]}function xo(t){let e=[{name:`read_${t.name}`,description:`Read the "${t.name}" state.`,parameters:{type:"object",properties:{},required:[],[Pe]:`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"},[Xn]:!0,[Pe]:`Update ${t.name}`},handler:r=>n(r)}),e}var Hg=xo;function xa(t){let e={};if(!Array.isArray(t))return e;for(let n of t){if(n===null||typeof n!="object")continue;let r=n,i=r.name,o=r.summary,s=r.description;typeof i=="string"&&typeof o=="string"&&(e[i]=typeof s=="string"?{name:i,summary:o,description:s}:{name:i,summary:o})}return e}var Dd=/:([A-Za-z_][A-Za-z0-9_]*)/g;function zg(t){return[...t.matchAll(Dd)].map(e=>e[0].slice(1))}function Gg(t,e,n){let r={...n};return{path:e.replace(Dd,(o,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 Fg(t,e){let n=new URLSearchParams;for(let[i,o]of Object.entries(e))n.set(i,String(o));let r=n.toString();return r===""?t:`${t}?${r}`}function wa(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:[],[Pe]:"List pages"},handler:()=>t().map(n=>({...n,pathParams:zg(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"],[Kn]:!0,[Pe]:"Navigate"},handler:n=>{let r=n.route_id,i=t().find(p=>p.id===r);if(i===void 0)throw new Error(`unknown route "${String(r)}"`);let o=n.params??{},{path:s,leftover:a}=Gg(i.id,i.path,o),l=Fg(s,a),c=e();return c!==null?c(l):window.location.assign(l),{navigated:!0,path:l}}}]}var le={title:"Assistant",chatHistory:"Chat history",newChat:"New chat",collapse:"Collapse",expand:"Expand",expandUnread:"Expand \u2014 {count} unread",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",recordingLimit:"Stopped at the {n}-minute limit \u2014 transcribing what was recorded.",toolRunning:"running\u2026",toolDeferred:"waiting for you",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 _a(t){let e={...le};for(let n of Object.keys(t)){let r=t[n];r!==void 0&&(e[n]=r)}return e}function Ud(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 Ea(t,e,n={}){let r=n.strings??le;return new Promise(i=>{let o=document.createElement("div");o.className="approval",o.setAttribute("part","approval"),e.toolName!==void 0&&o.setAttribute("data-tool-name",e.toolName),o.setAttribute("role","group"),o.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=Ud("deny",r.deny),c=Ud("approve",r.approve),p=!1,m=y=>{p||(p=!0,l.disabled=!0,c.disabled=!0,o.setAttribute("data-resolved",y?"approved":"denied"),i(y))};if(l.addEventListener("click",()=>m(!1)),c.addEventListener("click",()=>m(!0)),n.signal?.addEventListener("abort",()=>m(!1),{once:!0}),a.append(l,c),o.append(s,a),t.appendChild(o),n.signal?.aborted===!0){m(!1);return}c.focus()})}function Ta(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($g(r,e)))}}function $g(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",()=>{Vg(n).then(i=>{Bg(r,i?e.copied:e.copyFailed,e)})}),r}async function Vg(t){let e=navigator.clipboard;if(e===void 0)return!1;try{return await e.writeText(t),!0}catch{return!1}}function Bg(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 Sa(t){let e=document.createElement("div");e.className="attachment-chips",e.setAttribute("part","attachment-chips");for(let n of t)e.appendChild(jg(n));return e}function jg(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.innerHTML=Aa(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 i=document.createElement("span");return i.className="attachment-chip-size",i.setAttribute("part","attachment-chip-size"),i.textContent=wo(t.size),e.append(n,r,i),e}function Aa(t){return t.startsWith("image/")?Hl:t==="application/pdf"?zl:t.startsWith("text/")?Gl:Ul}function wo(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 _o=class{element;#t;#r;#e=[];constructor(e){this.#t=e,this.#r=e.strings??le,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:Ee(),file:e,status:De.UPLOADING,progress:0,ref:null,error:"",controller:null};this.#e.push(n);let r=this.#o(e);if(r!==null){n.status=De.ERROR,n.error=r,this.#s(),this.#t.onChange?.();return}this.#s(),this.#t.onChange?.(),this.#n(n)}readyRefs(){let e=[];for(let n of this.#e)n.ref!==null&&e.push(n.ref);return e}hasPending(){return this.#e.some(e=>e.status===De.UPLOADING)}pendingCount(){return this.#e.filter(e=>e.status===De.UPLOADING).length}isEmpty(){return this.#e.length===0}clearReady(){this.#e=this.#e.filter(e=>e.status===De.UPLOADING),this.#s()}clear(){for(let e of this.#e)e.controller?.abort();this.#e=[],this.#s()}dispose(){for(let e of this.#e)e.controller?.abort()}#o(e){return this.#t.maxBytes>0&&e.size>this.#t.maxBytes?this.#r.tooLarge.replace("{size}",wo(this.#t.maxBytes)):qg(this.#t.accept,e)?null:this.#r.fileTypeNotAllowed}#n(e){let n=this.#o(e.file);if(n!==null){e.status=De.ERROR,e.error=n,this.#s(),this.#t.onChange?.();return}e.status=De.UPLOADING,e.progress=0,e.error="";let r=new AbortController;e.controller=r,this.#s(),this.#t.upload(e.file,i=>{e.progress=i,this.#s()},r.signal).then(i=>{e.status=De.READY,e.ref=i}).catch(i=>{e.status=De.ERROR,e.error=i instanceof Error?i.message:this.#r.uploadFailed}).finally(()=>{e.controller=null,this.#s(),this.#t.onChange?.()})}#i(e){e.controller?.abort(),this.#e=this.#e.filter(n=>n!==e),this.#s(),this.#t.onChange?.()}#s(){this.element.replaceChildren(),this.element.hidden=this.#e.length===0;for(let e of this.#e)this.element.appendChild(this.#c(e))}#c(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.innerHTML=Aa(e.file.type),r.setAttribute("aria-hidden","true");let i=document.createElement("span");i.className="attachment-chip-name",i.setAttribute("part","attachment-chip-name"),i.textContent=e.file.name,i.title=e.file.name;let o=document.createElement("span");if(o.className="attachment-chip-size",o.setAttribute("part","attachment-chip-size"),o.textContent=e.status===De.ERROR?e.error:wo(e.file.size),n.append(r,i,o),e.status===De.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===De.ERROR){let a=document.createElement("button");a.type="button",a.className="attachment-chip-retry",a.setAttribute("part","attachment-chip-retry"),a.title=this.#r.retry,a.setAttribute("aria-label",this.#r.retryUpload),a.textContent="\u21BB",a.addEventListener("click",()=>this.#n(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.#r.remove,s.setAttribute("aria-label",this.#r.removeAttachment),s.textContent="\u2715",s.addEventListener("click",()=>this.#i(e)),n.appendChild(s),n}};function qg(t,e){let n=t.split(",").map(o=>o.trim().toLowerCase()).filter(o=>o!=="");if(n.length===0)return!0;let r=e.type.toLowerCase(),i=e.name.toLowerCase();return n.some(o=>o.startsWith(".")?i.endsWith(o):o.endsWith("/*")?r.startsWith(o.slice(0,-1)):r===o)}var Wg="http://www.w3.org/2000/svg";var He={top:20,right:12,bottom:30,left:44},To=480-He.left-He.right,Eo=220-He.top-He.bottom,Hd=["var(--ag-ui-chart-1, #4f7cff)","var(--ag-ui-chart-2, #21b573)","var(--ag-ui-chart-3, #e0803c)","var(--ag-ui-chart-4, #b563d8)","var(--ag-ui-chart-5, #d84f6e)","var(--ag-ui-chart-6, #3ba7c4)"];function on(t){return Hd[t%Hd.length]}function dt(t,e){let n=document.createElementNS(Wg,t);for(let[r,i]of Object.entries(e))n.setAttribute(r,String(i));return n}function zd(t,e){let n=dt("text",{"font-size":10,fill:"currentColor","fill-opacity":.65,...e});return n.textContent=t,n}function Xg(t){let e=[];return t.labels.forEach((n,r)=>{let i=0;for(let o of t.series)i+=o.points[r]??0,e.push(i)}),e}function Kg(t){let e=t.kind==="stacked"?Xg(t):t.series.flatMap(i=>[...i.points]),n=Math.max(0,...e),r=Math.min(0,...e);return n===r?{min:r,max:n+1}:{min:r,max:n}}function sn(t,e,n){return He.top+Eo-(t-e)/(n-e)*Eo}function ka(t,e){let n=To/e;return He.left+n*t+n/2}function Yg(t,e,n,r){for(let i of[n,r]){let o=sn(i,n,r);t.appendChild(dt("line",{x1:He.left,y1:o,x2:480-He.right,y2:o,stroke:"currentColor","stroke-opacity":i===n?.35:.12})),t.appendChild(zd(String(Math.round(i)),{x:He.left-6,y:o+4,"text-anchor":"end"}))}e.labels.forEach((i,o)=>{t.appendChild(zd(i,{x:ka(o,e.labels.length),y:220-He.bottom+16,"text-anchor":"middle"}))})}function Zg(t,e,n,r){let i=To/e.labels.length,o=i*.7/e.series.length,s=sn(n,n,r);e.series.forEach((a,l)=>{a.points.forEach((c,p)=>{let m=sn(c,n,r);t.appendChild(dt("rect",{x:He.left+i*p+i*.15+o*l,y:m,width:o,height:Math.max(1,s-m),fill:on(l),rx:2}))})})}function Jg(t,e,n,r){let i=To/e.labels.length,o=i*.7,s=e.labels.map(()=>0);e.series.forEach((a,l)=>{a.points.forEach((c,p)=>{let m=s[p]??0,y=m+c;s[p]=y;let f=sn(y,n,r);t.appendChild(dt("rect",{x:He.left+i*p+i*.15,y:f,width:o,height:Math.max(1,sn(m,n,r)-f),fill:on(l)}))})})}function Qg(t,e,n,r){e.series.forEach((i,o)=>{let s=i.points.map((a,l)=>`${ka(l,e.labels.length)},${sn(a,n,r)}`).join(" ");t.appendChild(dt("polyline",{points:s,fill:"none",stroke:on(o),"stroke-width":2,"stroke-linejoin":"round"}))})}function ev(t,e,n,r){e.series.forEach((i,o)=>{i.points.forEach((s,a)=>{t.appendChild(dt("circle",{cx:ka(a,e.labels.length),cy:sn(s,n,r),r:4,fill:on(o),"fill-opacity":.85}))})})}function tv(t,e){let n=e.reduce((a,l)=>a+l,0),r=480/2,i=He.top+Eo/2,o=Math.min(To,Eo)/2;if(n===0){t.appendChild(dt("circle",{cx:r,cy:i,r:o,fill:"none",stroke:"currentColor","stroke-opacity":.3}));return}let s=-Math.PI/2;e.forEach((a,l)=>{let c=a/n*Math.PI*2,p=s+c;if(c>=Math.PI*2)t.appendChild(dt("circle",{cx:r,cy:i,r:o,fill:on(l)}));else{let m=r+o*Math.cos(s),y=i+o*Math.sin(s),f=r+o*Math.cos(p),h=i+o*Math.sin(p),g=c>Math.PI?1:0;t.appendChild(dt("path",{d:`M ${r} ${i} L ${m} ${y} A ${o} ${o} 0 ${g} 1 ${f} ${h} Z`,fill:on(l)}))}s=p})}function nv(t){if(t.length<2)return null;let e=document.createElement("div");return e.className="chart-legend",e.setAttribute("part","chart-legend"),t.forEach((n,r)=>{let i=document.createElement("span");i.className="chart-legend-item";let o=document.createElement("span");o.className="chart-legend-swatch",o.style.background=on(r),i.append(o,document.createTextNode(n)),e.appendChild(i)}),e}function mr(t){if(t.labels.length===0||t.series.length===0)return null;let e=document.createElement("div");if(e.className="chart-block",e.setAttribute("part","chart-block"),t.title!==void 0&&t.title!==""){let i=document.createElement("div");i.className="chart-title",i.setAttribute("part","chart-title"),i.textContent=t.title,e.appendChild(i)}let n=dt("svg",{viewBox:"0 0 480 220",width:"100%",role:"img"});if(n.setAttribute("aria-label",t.title??`${t.kind} chart`),t.kind==="pie"){let i=t.series[0];tv(n,i.points.map(o=>Math.max(0,o)))}else{let{min:i,max:o}=Kg(t);Yg(n,t,i,o),t.kind==="bar"?Zg(n,t,i,o):t.kind==="stacked"?Jg(n,t,i,o):t.kind==="line"?Qg(n,t,i,o):ev(n,t,i,o)}e.appendChild(n);let r=nv(t.kind==="pie"?t.labels:t.series.map(i=>i.label));return r!==null&&e.appendChild(r),e}var rv=["bar","line","pie","scatter","stacked"];function iv(t){return rv.includes(t)?t:"bar"}function ov(t){if(!Array.isArray(t))return null;let e=[];for(let n of t){if(typeof n!="number"||!Number.isFinite(n)||Math.abs(n)>1e15)return null;e.push(n)}return e}function sv(t){if(!Array.isArray(t))return null;for(let e=0;e<t.length;e+=1)if(typeof t[e]!="string")return null;return t}function Pn(t){if(typeof t!="object"||t===null)return null;let e=t,n=sv(e.labels);if(n===null||!Array.isArray(e.series))return null;let r=[];for(let s of e.series){if(typeof s!="object"||s===null)return null;let a=s,l=ov(a.points);if(l===null||l.length!==n.length)return null;r.push({label:typeof a.label=="string"?a.label:"",points:l})}if(r.length===0||r.length*n.length>2e4||n.length>2e3)return null;let i=iv(e.kind),o=e.title;return typeof o=="string"?{kind:i,title:o,labels:n,series:r}:{kind:i,labels:n,series:r}}var So="render_chart";function av(t){let e=Pn(t);return e===null?null:mr(e)}function lv(t){let e=Pn(t);return e!==null&&e.labels.length>0&&e.series.length>0}var cv="chart not rendered: expected labels (strings) and series, each with one finite number per label";function Gd(){return{name:So,description:"Show a chart in the conversation. Supply the data and the page draws it. Every series must have exactly one point per label.",parameters:{type:"object",properties:{kind:{type:"string",enum:["bar","line","pie","scatter","stacked"]},title:{type:"string"},labels:{type:"array",items:{type:"string"}},series:{type:"array",items:{type:"object",properties:{label:{type:"string"},points:{type:"array",items:{type:"number"}}},required:["points"]}}},required:["labels","series"],"x-summary":"Draw a chart"},handler:t=>lv(t)?"chart rendered":cv,render:av}}function Ao(t,e=Date.now(),n=le){if(!Number.isFinite(t))return n.justNow;let r=Math.round((e-t)/1e3);if(r<60)return n.justNow;let i=Math.round(r/60);if(i<60)return n.minutesAgo.replace("{n}",String(i));let o=Math.round(i/60);if(o<24)return n.hoursAgo.replace("{n}",String(o));let s=Math.round(o/24);return s<7?n.daysAgo.replace("{n}",String(s)):n.weeksAgo.replace("{n}",String(Math.round(s/7)))}function Fd(t){return t.preview!==void 0&&t.preview!==null&&t.preview!==""?t.preview:null}function $d(t){return t.replace(/\s+/g," ").trim()}var gr=class{element;#t;#r;#e;#o=null;#n;#i=[];constructor(e,n=le){this.#t=e,this.#n=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.#e=document.createElement("span"),this.#e.className="checkpoints-title",this.#e.setAttribute("part","checkpoints-title"),this.#e.textContent=n.checkpoints,r.append(this.#e),this.#r=document.createElement("div"),this.#r.className="checkpoints-list",this.#r.setAttribute("part","checkpoints-list"),this.element.append(r,this.#r),this.element.addEventListener("keydown",i=>this.#u(i))}setRuns(e){this.#i=e,this.#d()}setStrings(e){this.#n=e,this.element.setAttribute("aria-label",e.checkpoints),this.#e.textContent=e.checkpoints,this.#d()}open(){this.open_||(this.#o=this.#s(),this.element.hidden=!1,(this.#c()[0]??this.element).focus())}close(){this.open_&&(this.element.hidden=!0,this.#o?.focus(),this.#o=null)}#s(){return this.element.getRootNode().activeElement}#c(){return Array.from(this.element.querySelectorAll("button, [tabindex]")).filter(e=>!e.hidden)}#u(e){if(e.key==="Escape"){e.stopPropagation(),this.close();return}if(e.key!=="Tab")return;let n=this.#c(),r=n[0],i=n[n.length-1],o=this.#s();e.shiftKey&&o===r?(e.preventDefault(),i?.focus()):!e.shiftKey&&o===i&&(e.preventDefault(),r?.focus())}get open_(){return!this.element.hidden}#d(){if(this.#r.replaceChildren(),this.#i.length===0){let n=document.createElement("div");n.className="checkpoints-empty",n.setAttribute("part","checkpoints-empty"),n.textContent=this.#n.noCheckpoints,this.#r.append(n);return}let e=this.#h();for(let n of this.#i)this.#r.append(this.#f(n,e))}#h(){let e=new Set,n=new Set;for(let r of this.#i){let i=Fd(r);if(i===null)continue;let o=$d(i);e.has(o)&&n.add(o),e.add(o)}return n}#f(e,n){let r=document.createElement("div");r.className="checkpoint-row",r.setAttribute("part","checkpoint-row");let i=Fd(e),o=e.started_at===null?null:Ao(Date.parse(e.started_at),Date.now(),this.#n),s=document.createElement("span");if(s.className="checkpoint-label",s.setAttribute("part","checkpoint-label"),s.textContent=i??o??e.run_id,r.append(s),i!==null&&o!==null){let l=document.createElement("span");l.className="checkpoint-time",l.setAttribute("part","checkpoint-time"),l.textContent=o,r.append(l)}if((i===null?o!==null:n.has($d(i)))&&e.run_id!==""){let l=document.createElement("span");l.className="checkpoint-id",l.setAttribute("part","checkpoint-id"),l.textContent=e.run_id.slice(0,8),l.title=e.run_id,r.append(l)}if(e.parent_run_id!==null){let l=document.createElement("span");l.className="checkpoint-branch",l.setAttribute("part","checkpoint-branch"),l.textContent=this.#n.forkedRun,l.title=e.parent_run_id,r.append(l)}return r.append(this.#p(e.run_id,"resume",this.#n.resumeRun),this.#p(e.run_id,"fork",this.#n.forkRun)),r}#p(e,n,r){let i=document.createElement("button");return i.type="button",i.className=`checkpoint-action checkpoint-${n}`,i.setAttribute("part",`checkpoint-action checkpoint-${n}`),i.textContent=r,i.addEventListener("click",()=>{this.close(),this.#t(e,n)}),i}};function Vd(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??le;return new Promise(i=>{let o=document.createElement("div");o.className="confirm",o.setAttribute("part","confirm"),o.setAttribute("data-tool-name",e.toolName),o.setAttribute("role","group"),o.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=Vd("cancel",r.cancel),p=Vd("confirm",r.confirm),m=!1,y=f=>{m||(m=!0,o.remove(),i(f))};if(c.addEventListener("click",()=>y(!1)),p.addEventListener("click",()=>y(!0)),n.signal?.addEventListener("abort",()=>y(!1),{once:!0}),l.append(c,p),o.append(s,a,l),t.appendChild(o),n.signal?.aborted===!0){y(!1);return}p.focus()})}function Ia(t){let e=t.replace(/[._-]+/g," ").trim();return e===""?t:e.charAt(0).toUpperCase()+e.slice(1)}function dv(t){let e=document.createElement("input");return e.type="text",e.className="question-input",e.setAttribute("part","question-input"),e.placeholder=t,e}function Ra(t,e,n={}){let r=n.strings??le,i=e.options??[],o=i.length>0,s=!o||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 p=document.createElement("div");p.className="question-options",p.setAttribute("part","question-options");let m=`q-${i.length}-${e.question.length}`,y=[];for(let U of i){let K=document.createElement("label");K.className="question-choice",K.setAttribute("part","question-choice");let ie=document.createElement("input");ie.type="radio",ie.name=m,ie.value=U,ie.setAttribute("part","question-radio");let qe=document.createElement("span");qe.setAttribute("part","question-choice-text"),qe.textContent=U,K.append(ie,qe),p.appendChild(K),y.push(ie)}let f=null,h=null;if(s){if(h=dv(r.answerPlaceholder),o){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 K=document.createElement("span");K.setAttribute("part","question-choice-text"),K.textContent=r.otherOption,U.append(f,K),p.appendChild(U),h.disabled=!0}p.appendChild(h)}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,E=()=>{let U=y.find(K=>K.checked);if(U!==void 0)return U.value;if(h!==null&&(f===null||f.checked)){let K=h.value.trim();return K===""?null:K}return null},I=()=>{h!==null&&f!==null&&(h.disabled=!f.checked),x.disabled=E()===null},H=U=>{if(!S){S=!0,x.disabled=!0;for(let K of y)K.disabled=!0;f!==null&&(f.disabled=!0),h!==null&&(h.disabled=!0),l.setAttribute("data-resolved",U===""?"cancelled":"answered"),a(U)}};for(let U of[...y,...f!==null?[f]:[]])U.addEventListener("change",I);if(h?.addEventListener("input",I),h?.addEventListener("keydown",U=>{if(U.key==="Enter"){U.preventDefault();let K=E();K!==null&&H(K)}}),x.addEventListener("click",()=>{let U=E();U!==null&&H(U)}),n.signal?.addEventListener("abort",()=>H(""),{once:!0}),l.append(c,p,g),t.appendChild(l),n.signal?.aborted===!0){H("");return}I(),(o?y[0]:h)?.focus()})}function Bd(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 uv(t){if(Array.isArray(t))return t}function pv(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,i,o,s,a=[],l=!0,c=!1;try{if(o=(n=n.call(t)).next,e!==0)for(;!(l=(r=o.call(n)).done)&&(a.push(r.value),a.length!==e);l=!0);}catch(p){c=!0,i=p}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}}function hv(){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 fv(t,e){return uv(t)||pv(t,e)||mv(t,e)||hv()}function mv(t,e){if(t){if(typeof t=="string")return Bd(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)?Bd(t,e):void 0}}var ou=Object.entries,jd=Object.setPrototypeOf,gv=Object.isFrozen,vv=Object.getPrototypeOf,bv=Object.getOwnPropertyDescriptor,Te=Object.freeze,Se=Object.seal,Hn=Object.create,su=typeof Reflect<"u"&&Reflect,Da=su.apply,Ua=su.construct;Te||(Te=function(e){return e});Se||(Se=function(e){return e});Da||(Da=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return e.apply(n,i)});Ua||(Ua=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new e(...r)});var Dn=me(Array.prototype.forEach),yv=me(Array.prototype.lastIndexOf),qd=me(Array.prototype.pop),Un=me(Array.prototype.push),xv=me(Array.prototype.splice),Rt=Array.isArray,yr=me(String.prototype.toLowerCase),Na=me(String.prototype.toString),Wd=me(String.prototype.match),vr=me(String.prototype.replace),Xd=me(String.prototype.indexOf),wv=me(String.prototype.trim),_v=me(Number.prototype.toString),Ev=me(Boolean.prototype.toString),Kd=typeof BigInt>"u"?null:me(BigInt.prototype.toString),Yd=typeof Symbol>"u"?null:me(Symbol.prototype.toString),ye=me(Object.prototype.hasOwnProperty),br=me(Object.prototype.toString),be=me(RegExp.prototype.test),an=Tv(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),i=1;i<n;i++)r[i-1]=arguments[i];return Da(t,e,r)}}function Tv(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Ua(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:yr;if(jd&&jd(t,null),!Rt(e))return t;let r=e.length;for(;r--;){let i=e[r];if(typeof i=="string"){let o=n(i);o!==i&&(gv(e)||(e[r]=o),i=o)}t[i]=!0}return t}function Sv(t){for(let e=0;e<t.length;e++)ye(t,e)||(t[e]=null);return t}function ke(t){let e=Hn(null);for(let r of ou(t)){var n=fv(r,2);let i=n[0],o=n[1];ye(t,i)&&(Rt(o)?e[i]=Sv(o):o&&typeof o=="object"&&o.constructor===Object?e[i]=ke(o):e[i]=o)}return e}function Av(t){switch(typeof t){case"string":return t;case"number":return _v(t);case"boolean":return Ev(t);case"bigint":return Kd?Kd(t):"0";case"symbol":return Yd?Yd(t):"Symbol()";case"undefined":return br(t);case"function":case"object":{if(t===null)return br(t);let e=t,n=Ze(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:br(r)}return br(t)}default:return br(t)}}function Ze(t,e){for(;t!==null;){let r=bv(t,e);if(r){if(r.get)return me(r.get);if(typeof r.value=="function")return me(r.value)}t=vv(t)}function n(){return null}return n}function kv(t){try{return be(t,""),!0}catch{return!1}}var Zd=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"]),Oa=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"]),Ma=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"]),Cv=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"]),La=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"]),Iv=Te(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Jd=Te(["#text"]),Qd=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"]),Pa=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"]),eu=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"]),ko=Te(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Rv=Se(/{{[\w\W]*|^[\w\W]*}}/g),Nv=Se(/<%[\w\W]*|^[\w\W]*%>/g),Ov=Se(/\${[\w\W]*/g),Mv=Se(/^data-[\-\w.\u00B7-\uFFFF]+$/),Lv=Se(/^aria-[\-\w]+$/),tu=Se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Pv=Se(/^(?:\w+script|data):/i),Dv=Se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Uv=Se(/^html$/i),Hv=Se(/^[a-z][.\w]*(-[.\w]+)+$/i),nu=Se(/<[/\w!]/g),ru=Se(/<[/\w]/g),zv=Se(/<\/no(script|embed|frames)/i),Gv=Se(/\/>/i),ze={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Fv=function(){return typeof window>"u"?null:window},$v=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null,i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));let o="dompurify"+(r?"#"+r:"");try{return e.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},iu=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},It=function(e,n,r,i){return ye(e,n)&&Rt(e[n])?W(i.base?ke(i.base):{},e[n],i.transform):r};function au(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Fv(),e=T=>au(T);if(e.version="3.4.13",e.removed=[],!t||!t.document||t.document.nodeType!==ze.document||!t.Element)return e.isSupported=!1,e;let n=t.document,r=n,i=r.currentScript;t.DocumentFragment;let o=t.HTMLTemplateElement,s=t.Node,a=t.Element,l=t.NodeFilter,c=t.NamedNodeMap;c===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;let p=t.DOMParser,m=t.trustedTypes,y=a.prototype,f=Ze(y,"cloneNode"),h=Ze(y,"remove"),g=Ze(y,"nextSibling"),x=Ze(y,"childNodes"),S=Ze(y,"parentNode"),E=Ze(y,"shadowRoot"),I=Ze(y,"attributes"),H=s&&s.prototype?Ze(s.prototype,"nodeType"):null,U=s&&s.prototype?Ze(s.prototype,"nodeName"):null,K=s&&s.prototype?Ze(s.prototype,"ownerDocument"):null;if(typeof o=="function"){let T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let ie,qe="",Bo,ol=!1,Vn=0,sl=function(){if(Vn>0)throw an('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.')},un=function(u){sl(),Vn++;try{return ie.createHTML(u)}finally{Vn--}},ju=function(u){sl(),Vn++;try{return ie.createScriptURL(u)}finally{Vn--}},qu=function(){return ol||(Bo=$v(m,i),ol=!0),Bo},Rr=n,jo=Rr.implementation,al=Rr.createNodeIterator,Wu=Rr.createDocumentFragment,Xu=Rr.getElementsByTagName,Ku=r.importNode,oe=iu();e.isSupported=typeof ou=="function"&&typeof S=="function"&&jo&&jo.createHTMLDocument!==void 0;let Yu=Rv,Zu=Nv,Ju=Ov,Qu=Mv,ep=Lv,tp=Pv,ll=Dv,np=Hv,cl=tu,se=null,qo=W({},[...Zd,...Oa,...Ma,...La,...Jd]),ae=null,Wo=W({},[...Qd,...Pa,...eu,...ko]),pe=Object.seal(Hn(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}})),Bn=null,dl=null,yt=Object.seal(Hn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ul=!0,Xo=!0,pl=!1,hl=!0,xt=!1,wt=!0,Ot=!1,Ko=!1,Nr=null,Or=null,Yo=!1,pn=!1,Mr=!1,Lr=!1,fl=!0,ml=!1,gl="user-content-",Zo=!0,Pr=!1,hn={},tt=null,Jo=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"]),vl=null,bl=W({},["audio","video","img","source","image","track"]),Qo=null,yl=W({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Dr="http://www.w3.org/1998/Math/MathML",Ur="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml",fn=nt,es=!1,ts=null,rp=W({},[Dr,Ur,nt],Na),xl=Te(["mi","mo","mn","ms","mtext"]),ns=W({},xl),wl=Te(["annotation-xml"]),rs=W({},wl),ip=W({},["title","style","font","a","script"]),jn=null,op=["application/xhtml+xml","text/html"],sp="text/html",ce=null,mn=null,ap=n.createElement("form"),_l=function(u){return u instanceof RegExp||u instanceof Function},is=function(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(mn&&mn===u)return;(!u||typeof u!="object")&&(u={}),u=ke(u),jn=op.indexOf(u.PARSER_MEDIA_TYPE)===-1?sp:u.PARSER_MEDIA_TYPE,ce=jn==="application/xhtml+xml"?Na:yr,se=It(u,"ALLOWED_TAGS",qo,{transform:ce}),ae=It(u,"ALLOWED_ATTR",Wo,{transform:ce}),ts=It(u,"ALLOWED_NAMESPACES",rp,{transform:Na}),Qo=It(u,"ADD_URI_SAFE_ATTR",yl,{transform:ce,base:yl}),vl=It(u,"ADD_DATA_URI_TAGS",bl,{transform:ce,base:bl}),tt=It(u,"FORBID_CONTENTS",Jo,{transform:ce}),Bn=It(u,"FORBID_TAGS",ke({}),{transform:ce}),dl=It(u,"FORBID_ATTR",ke({}),{transform:ce}),hn=ye(u,"USE_PROFILES")?u.USE_PROFILES&&typeof u.USE_PROFILES=="object"?ke(u.USE_PROFILES):u.USE_PROFILES:!1,ul=u.ALLOW_ARIA_ATTR!==!1,Xo=u.ALLOW_DATA_ATTR!==!1,pl=u.ALLOW_UNKNOWN_PROTOCOLS||!1,hl=u.ALLOW_SELF_CLOSE_IN_ATTR!==!1,xt=u.SAFE_FOR_TEMPLATES||!1,wt=u.SAFE_FOR_XML!==!1,Ot=u.WHOLE_DOCUMENT||!1,pn=u.RETURN_DOM||!1,Mr=u.RETURN_DOM_FRAGMENT||!1,Lr=u.RETURN_TRUSTED_TYPE||!1,Yo=u.FORCE_BODY||!1,fl=u.SANITIZE_DOM!==!1,ml=u.SANITIZE_NAMED_PROPS||!1,Zo=u.KEEP_CONTENT!==!1,Pr=u.IN_PLACE||!1,cl=kv(u.ALLOWED_URI_REGEXP)?u.ALLOWED_URI_REGEXP:tu,fn=typeof u.NAMESPACE=="string"?u.NAMESPACE:nt,ns=ye(u,"MATHML_TEXT_INTEGRATION_POINTS")&&u.MATHML_TEXT_INTEGRATION_POINTS&&typeof u.MATHML_TEXT_INTEGRATION_POINTS=="object"?ke(u.MATHML_TEXT_INTEGRATION_POINTS):W({},xl),rs=ye(u,"HTML_INTEGRATION_POINTS")&&u.HTML_INTEGRATION_POINTS&&typeof u.HTML_INTEGRATION_POINTS=="object"?ke(u.HTML_INTEGRATION_POINTS):W({},wl);let b=ye(u,"CUSTOM_ELEMENT_HANDLING")&&u.CUSTOM_ELEMENT_HANDLING&&typeof u.CUSTOM_ELEMENT_HANDLING=="object"?ke(u.CUSTOM_ELEMENT_HANDLING):Hn(null);if(pe=Hn(null),ye(b,"tagNameCheck")&&_l(b.tagNameCheck)&&(pe.tagNameCheck=b.tagNameCheck),ye(b,"attributeNameCheck")&&_l(b.attributeNameCheck)&&(pe.attributeNameCheck=b.attributeNameCheck),ye(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(pe.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),Se(pe),xt&&(Xo=!1),Mr&&(pn=!0),hn&&(se=W({},Jd),ae=Hn(null),hn.html===!0&&(W(se,Zd),W(ae,Qd)),hn.svg===!0&&(W(se,Oa),W(ae,Pa),W(ae,ko)),hn.svgFilters===!0&&(W(se,Ma),W(ae,Pa),W(ae,ko)),hn.mathMl===!0&&(W(se,La),W(ae,eu),W(ae,ko))),yt.tagCheck=null,yt.attributeCheck=null,ye(u,"ADD_TAGS")&&(typeof u.ADD_TAGS=="function"?yt.tagCheck=u.ADD_TAGS:Rt(u.ADD_TAGS)&&(se===qo&&(se=ke(se)),W(se,u.ADD_TAGS,ce))),ye(u,"ADD_ATTR")&&(typeof u.ADD_ATTR=="function"?yt.attributeCheck=u.ADD_ATTR:Rt(u.ADD_ATTR)&&(ae===Wo&&(ae=ke(ae)),W(ae,u.ADD_ATTR,ce))),ye(u,"ADD_URI_SAFE_ATTR")&&Rt(u.ADD_URI_SAFE_ATTR)&&W(Qo,u.ADD_URI_SAFE_ATTR,ce),ye(u,"FORBID_CONTENTS")&&Rt(u.FORBID_CONTENTS)&&(tt===Jo&&(tt=ke(tt)),W(tt,u.FORBID_CONTENTS,ce)),ye(u,"ADD_FORBID_CONTENTS")&&Rt(u.ADD_FORBID_CONTENTS)&&(tt===Jo&&(tt=ke(tt)),W(tt,u.ADD_FORBID_CONTENTS,ce)),Zo&&(se["#text"]=!0),Ot&&W(se,["html","head","body"]),se.table&&(W(se,["tbody"]),delete Bn.tbody),u.TRUSTED_TYPES_POLICY){if(typeof u.TRUSTED_TYPES_POLICY.createHTML!="function")throw an('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof u.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw an('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let w=ie;ie=u.TRUSTED_TYPES_POLICY;try{qe=un("")}catch(N){throw ie=w,N}}else u.TRUSTED_TYPES_POLICY===null?(ie=void 0,qe=""):(ie===void 0&&(ie=qu()),ie&&typeof qe=="string"&&(qe=un("")));Te&&Te(u),mn=u},El=W({},[...Oa,...Ma,...Cv]),Tl=W({},[...La,...Iv]),lp=function(u,b,w){return b.namespaceURI===nt?u==="svg":b.namespaceURI===Dr?u==="svg"&&(w==="annotation-xml"||ns[w]):!!El[u]},cp=function(u,b,w){return b.namespaceURI===nt?u==="math":b.namespaceURI===Ur?u==="math"&&rs[w]:!!Tl[u]},dp=function(u,b,w){return b.namespaceURI===Ur&&!rs[w]||b.namespaceURI===Dr&&!ns[w]?!1:!Tl[u]&&(ip[u]||!El[u])},up=function(u){let b=S(u);(!b||!b.tagName)&&(b={namespaceURI:fn,tagName:"template"});let w=yr(u.tagName),N=yr(b.tagName);return ts[u.namespaceURI]?u.namespaceURI===Ur?lp(w,b,N):u.namespaceURI===Dr?cp(w,b,N):u.namespaceURI===nt?dp(w,b,N):!!(jn==="application/xhtml+xml"&&ts[u.namespaceURI]):!1},_t=function(u){Un(e.removed,{element:u});try{S(u).removeChild(u)}catch{if(h(u),!S(u))throw an("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Hr=function(u){qn(u);let b=x(u);if(b){let N=[];Dn(b,L=>{Un(N,L)}),Dn(N,L=>{try{h(L)}catch{}})}let w=I(u);if(w)for(let N=w.length-1;N>=0;--N){let L=w[N],z=L&&L.name;if(typeof z=="string")try{u.removeAttribute(z)}catch{}}},Mt=function(u,b){try{Un(e.removed,{attribute:b.getAttributeNode(u),from:b})}catch{Un(e.removed,{attribute:null,from:b})}if(b.removeAttribute(u),u==="is")if(pn||Mr)try{_t(b)}catch{}else try{b.setAttribute(u,"")}catch{}},pp=function(u){let b=I(u);if(b)for(let w=b.length-1;w>=0;--w){let N=b[w],L=N&&N.name;if(!(typeof L!="string"||ae[ce(L)]))try{u.removeAttribute(L)}catch{}}},qn=function(u){let b=[u];for(;b.length>0;){let w=b.pop();(H?H(w):w.nodeType)===ze.element&&pp(w);let L=x(w);if(L)for(let z=L.length-1;z>=0;--z)b.push(L[z])}},hp=function(u){if(!wt)return;let b=[u];for(;b.length>0;){let w=b.pop(),N=H?H(w):w.nodeType;if(N===ze.processingInstruction||N===ze.comment&&be(ru,w.data)){try{h(w)}catch{}continue}if(N===ze.element){let z=w,Z=ce(U?U(w):w.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(w);if(L)for(let z=L.length-1;z>=0;--z)b.push(L[z])}},Sl=function(u){let b=null,w=null;if(Yo)u="<remove></remove>"+u;else{let z=Wd(u,/^[\r\n\t ]+/);w=z&&z[0]}jn==="application/xhtml+xml"&&fn===nt&&(u='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+u+"</body></html>");let N=ie?un(u):u;if(fn===nt)try{b=new p().parseFromString(N,jn)}catch{}if(!b||!b.documentElement){b=jo.createDocument(fn,"template",null);try{b.documentElement.innerHTML=es?qe:N}catch{}}let L=b.body||b.documentElement;return u&&w&&L.insertBefore(n.createTextNode(w),L.childNodes[0]||null),fn===nt?Xu.call(b,Ot?"html":"body")[0]:Ot?b.documentElement:L},Al=function(u){let b=K?K(u):u.ownerDocument;return al.call(b||u,u,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},zr=function(u){return u=vr(u,Yu," "),u=vr(u,Zu," "),u=vr(u,Ju," "),u},os=function(u){var b;u.normalize();let w=K?K(u):u.ownerDocument,N=al.call(w||u,u,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),L=N.nextNode();for(;L;)L.data=zr(L.data),L=N.nextNode();let z=(b=u.querySelectorAll)===null||b===void 0?void 0:b.call(u,"template");z&&Dn(z,Z=>{gn(Z.content)&&os(Z.content)})},Gr=function(u){let b=U?U(u):null;return typeof b!="string"||ce(b)!=="form"?!1:typeof u.nodeName!="string"||typeof u.textContent!="string"||typeof u.removeChild!="function"||u.attributes!==I(u)||typeof u.removeAttribute!="function"||typeof u.setAttribute!="function"||typeof u.namespaceURI!="string"||typeof u.insertBefore!="function"||typeof u.hasChildNodes!="function"||u.nodeType!==H(u)||u.childNodes!==x(u)},gn=function(u){if(!H||typeof u!="object"||u===null)return!1;try{return H(u)===ze.documentFragment}catch{return!1}},Wn=function(u){if(!H||typeof u!="object"||u===null)return!1;try{return typeof H(u)=="number"}catch{return!1}};function rt(T,u,b){T.length!==0&&Dn(T,w=>{w.call(e,u,b,mn)})}let fp=function(u,b){return!!(wt&&u.hasChildNodes()&&!Wn(u.firstElementChild)&&be(nu,u.textContent)&&be(nu,u.innerHTML)||wt&&u.namespaceURI===nt&&b==="style"&&Wn(u.firstElementChild)||u.nodeType===ze.processingInstruction||wt&&u.nodeType===ze.comment&&be(ru,u.data))},mp=function(u,b,w){if(!Bn[b]&&Rl(b)&&(pe.tagNameCheck instanceof RegExp&&be(pe.tagNameCheck,b)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(b)))return!1;if(Zo&&!tt[b]){let N=S(u),L=x(u);if(L&&N){let z=L.length;for(let Z=z-1;Z>=0;--Z){let de=u===w?f(L[Z],!0):L[Z];N.insertBefore(de,g(u))}}}return _t(u),!0},kl=function(u,b,w,N){return u.length===0?b:b===w||b===N?ke(b):b},Cl=function(u,b){if(rt(oe.beforeSanitizeElements,u,null),u!==b&&S(u)===null)return Pr&&qn(u),!0;if(Gr(u))return _t(u),!0;let w=ce(U?U(u):u.nodeName);if(se=kl(oe.uponSanitizeElement,se,qo,Nr),rt(oe.uponSanitizeElement,u,{tagName:w,allowedTags:se}),u!==b&&S(u)===null)return Pr&&qn(u),!0;if(fp(u,w))return _t(u),!0;if(Bn[w]||!(yt.tagCheck instanceof Function&&yt.tagCheck(w))&&!se[w]){let L=mp(u,w,b);return L===!1&&rt(oe.afterSanitizeElements,u,null),L}if((H?H(u):u.nodeType)===ze.element&&!up(u)||(w==="noscript"||w==="noembed"||w==="noframes")&&be(zv,u.innerHTML))return _t(u),!0;if(xt&&u.nodeType===ze.text){let L=zr(u.textContent);u.textContent!==L&&(Un(e.removed,{element:u.cloneNode()}),u.textContent=L)}return rt(oe.afterSanitizeElements,u,null),!1},Il=function(u,b,w){if(dl[b]||wt&&b==="patchsrc"||wt&&b==="for"&&u!=="label"&&u!=="output"||fl&&(b==="id"||b==="name")&&(w in n||w in ap))return!1;let N=ae[b]||yt.attributeCheck instanceof Function&&yt.attributeCheck(b,u);if(!(Xo&&be(Qu,b))){if(!(ul&&be(ep,b))){if(N){if(!Qo[b]){if(!be(cl,vr(w,ll,""))){if(!((b==="src"||b==="xlink:href"||b==="href")&&u!=="script"&&Xd(w,"data:")===0&&vl[u])){if(!(pl&&!be(tp,vr(w,ll,"")))){if(w)return!1}}}}}else if(!(Rl(u)&&(pe.tagNameCheck instanceof RegExp&&be(pe.tagNameCheck,u)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(u))&&(pe.attributeNameCheck instanceof RegExp&&be(pe.attributeNameCheck,b)||pe.attributeNameCheck instanceof Function&&pe.attributeNameCheck(b,u))||b==="is"&&pe.allowCustomizedBuiltInElements&&(pe.tagNameCheck instanceof RegExp&&be(pe.tagNameCheck,w)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(w))))return!1}}return!0},gp=W({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Rl=function(u){return!gp[yr(u)]&&be(np,u)},vp=function(u,b,w,N){if(ie&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!w)switch(m.getAttributeType(u,b)){case"TrustedHTML":return un(N);case"TrustedScriptURL":return ju(N)}return N},bp=function(u,b,w,N){try{w?u.setAttributeNS(w,b,N):u.setAttribute(b,N),Gr(u)?_t(u):qd(e.removed)}catch{Mt(b,u)}},Nl=function(u){rt(oe.beforeSanitizeAttributes,u,null);let b=u.attributes;if(!b||Gr(u))return;ae=kl(oe.uponSanitizeAttribute,ae,Wo,Or);let w={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ae,forceKeepAttr:void 0},N=b.length,L=ce(u.nodeName);for(;N--;){let z=b[N],Z=z.name,de=z.namespaceURI,Re=z.value,Ne=ce(Z),as=Re,Ie=Z==="value"?as:wv(as);if(w.attrName=Ne,w.attrValue=Ie,w.keepAttr=!0,w.forceKeepAttr=void 0,rt(oe.uponSanitizeAttribute,u,w),Ie=w.attrValue,ml&&(Ne==="id"||Ne==="name")&&Xd(Ie,gl)!==0&&(Mt(Z,u),Ie=gl+Ie),wt&&be(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ie)){Mt(Z,u);continue}if(Ne==="attributename"&&Wd(Ie,"href")){Mt(Z,u);continue}if(!w.forceKeepAttr){if(!w.keepAttr){Mt(Z,u);continue}if(!hl&&be(Gv,Ie)){Mt(Z,u);continue}if(xt&&(Ie=zr(Ie)),!Il(L,Ne,Ie)){Mt(Z,u);continue}Ie=vp(L,Ne,de,Ie),Ie!==as&&bp(u,Z,de,Ie)}}rt(oe.afterSanitizeAttributes,u,null)},Fr=function(u){let b=null,w=Al(u);for(rt(oe.beforeSanitizeShadowDOM,u,null);b=w.nextNode();)if(rt(oe.uponSanitizeShadowNode,b,null),Cl(b,u),Nl(b),gn(b.content)&&Fr(b.content),(H?H(b):b.nodeType)===ze.element){let L=E(b);gn(L)&&(ss(L),Fr(L))}rt(oe.afterSanitizeShadowDOM,u,null)},ss=function(u){let b=[{node:u,shadow:null}];for(;b.length>0;){let w=b.pop();if(w.shadow){Fr(w.shadow);continue}let N=w.node,z=(H?H(N):N.nodeType)===ze.element,Z=x(N);if(Z)for(let de=Z.length-1;de>=0;--de)b.push({node:Z[de],shadow:null});if(z){let de=U?U(N):null;if(typeof de=="string"&&ce(de)==="template"){let Re=N.content;gn(Re)&&b.push({node:Re,shadow:null})}}if(z){let de=E(N);gn(de)&&b.push({node:null,shadow:de},{node:de,shadow:null})}}};return e.sanitize=function(T){let u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,w=null,N=null,L=null;if(es=!T,es&&(T="<!-->"),typeof T!="string"&&!Wn(T)&&(T=Av(T),typeof T!="string"))throw an("dirty is not a string, aborting");if(!e.isSupported)return T;Ko?(se=Nr,ae=Or):is(u),(oe.uponSanitizeElement.length>0||oe.uponSanitizeAttribute.length>0)&&(se=ke(se)),oe.uponSanitizeAttribute.length>0&&(ae=ke(ae)),e.removed=[];let z=Pr&&typeof T!="string"&&Wn(T);if(z){hp(T);let Re=U?U(T):T.nodeName;if(typeof Re=="string"){let Ne=ce(Re);if(!se[Ne]||Bn[Ne])throw Hr(T),an("root node is forbidden and cannot be sanitized in-place")}if(Gr(T))throw Hr(T),an("root node is clobbered and cannot be sanitized in-place");try{ss(T)}catch(Ne){throw Hr(T),Ne}}else if(Wn(T))b=Sl("<!---->"),w=b.ownerDocument.importNode(T,!0),w.nodeType===ze.element&&w.nodeName==="BODY"||w.nodeName==="HTML"?b=w:b.appendChild(w),ss(w);else{if(!pn&&!xt&&!Ot&&T.indexOf("<")===-1)return ie&&Lr?un(T):T;if(b=Sl(T),!b)return pn?null:Lr?qe:""}b&&Yo&&_t(b.firstChild);let Z=z?T:b;try{let Re=Al(Z);for(;N=Re.nextNode();)Cl(N,Z),Nl(N),gn(N.content)&&Fr(N.content)}catch(Re){throw z&&(Hr(T),Dn(e.removed,Ne=>{Ne.element&&qn(Ne.element)})),Re}if(z)return Dn(e.removed,Re=>{Re.element&&qn(Re.element)}),xt&&os(T),T;if(pn){if(xt&&os(b),Mr)for(L=Wu.call(b.ownerDocument);b.firstChild;)L.appendChild(b.firstChild);else L=b;return(ae.shadowroot||ae.shadowrootmode)&&(L=Ku.call(r,L,!0)),L}let de=Ot?b.outerHTML:b.innerHTML;return Ot&&se["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&be(Uv,b.ownerDocument.doctype.name)&&(de="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
Error: ${x}`)}}return u()}case v.MESSAGES_SNAPSHOT:{let f=await K(r,s,a,(h,g,x)=>h.onMessagesSnapshotEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messages:h}=m,g=new Map(h.map(I=>[I.id,I])),x=h.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 _=new Set(s.map(I=>I.id));for(let I of h)_.has(I.id)||s.push(I);c({messages:s})}return u()}case v.ACTIVITY_SNAPSHOT:{let f=m,h=s.findIndex(I=>I.id===f.messageId),g=h>=0?s[h]:void 0,x=g?.role==="activity"?g:void 0,S=f.replace??!0,_=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(_),_.stopPropagation!==!0){let I={id:f.messageId,role:"activity",activityType:f.activityType,content:q(f.content)},H;h===-1?(s.push(I),H=I):x?S&&(s[h]={...x,activityType:f.activityType,content:q(f.content)}):S&&(s[h]=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 u()}case v.ACTIVITY_DELTA:{let f=m,h=s.findIndex(_=>_.id===f.messageId);if(h===-1)return u();let g=s[h];if(g.role!=="activity")return console.warn(`ACTIVITY_DELTA: Message '${f.messageId}' is not an activity message`),u();let x=g,S=await K(r,s,a,(_,I,H)=>_.onActivityDeltaEvent?.({event:f,messages:I,state:H,agent:n,input:t,activityMessage:x}));if(c(S),S.stopPropagation!==!0)try{let _=q(x.content??{}),I=uo.applyPatch(_,f.patch??[],!0,!1).newDocument;s[h]={...x,content:q(I),activityType:f.activityType},c({messages:s})}catch(_){let I=_ instanceof Error?_.message:String(_);console.warn(`Failed to apply activity patch for '${f.messageId}': ${I}`)}return u()}case v.RAW:return c(await K(r,s,a,(f,h,g)=>f.onRawEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),u();case v.CUSTOM:return c(await K(r,s,a,(f,h,g)=>f.onCustomEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),u();case v.RUN_STARTED:{let f=await K(r,s,a,(h,g,x)=>h.onRunStartedEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let h=m;if(h.input?.messages){for(let g of h.input.messages)s.find(x=>x.id===g.id)||s.push(g);c({messages:s})}}return u()}case v.RUN_FINISHED:{let f=m,h=f.outcome?.type==="interrupt"?{event:f,outcome:"interrupt",interrupts:f.outcome.interrupts}:{event:f,outcome:"success",result:f.result},g=await K(r,s,a,(x,S,_)=>x.onRunFinishedEvent?.({...h,messages:S,state:_,agent:n,input:t}));return c(g),g.stopPropagation!==!0&&(n.pendingInterrupts=h.outcome==="interrupt"?[...h.interrupts]:[]),u()}case v.RUN_ERROR:return c(await K(r,s,a,(f,h,g)=>f.onRunErrorEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),u();case v.STEP_STARTED:return c(await K(r,s,a,(f,h,g)=>f.onStepStartedEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),u();case v.STEP_FINISHED:return c(await K(r,s,a,(f,h,g)=>f.onStepFinishedEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),u();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 u();case v.THINKING_END:return u();case v.THINKING_TEXT_MESSAGE_START:return u();case v.THINKING_TEXT_MESSAGE_CONTENT:return u();case v.THINKING_TEXT_MESSAGE_END:return u();case v.REASONING_START:return c(await K(r,s,a,(f,h,g)=>f.onReasoningStartEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),u();case v.REASONING_MESSAGE_START:{let f=await K(r,s,a,(h,g,x)=>h.onReasoningMessageStartEvent?.({event:m,messages:g,state:x,agent:n,input:t}));if(c(f),f.stopPropagation!==!0){let{messageId:h}=m;if(!s.find(g=>g.id===h)){let g={id:h,role:"reasoning",content:""};s.push(g),c({messages:s})}}return u()}case v.REASONING_MESSAGE_CONTENT:{let{messageId:f,delta:h}=m,g=s.find(S=>S.id===f);if(!g)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${f}'`),u();let x=await K(r,s,a,(S,_,I)=>S.onReasoningMessageContentEvent?.({event:m,messages:_,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:""}${h}`,c({messages:s})),u()}case v.REASONING_MESSAGE_END:{let{messageId:f}=m,h=s.find(g=>g.id===f);return h?(c(await K(r,s,a,(g,x,S)=>g.onReasoningMessageEndEvent?.({event:m,messages:x,state:S,agent:n,input:t,reasoningMessageBuffer:typeof h.content=="string"?h.content:""}))),await Promise.all(r.map(g=>{g.onNewMessage?.({message:h,messages:s,state:a,agent:n,input:t})})),u()):(console.warn(`REASONING_MESSAGE_END: No message found with ID '${f}'`),u())}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,h,g)=>f.onReasoningEndEvent?.({event:m,messages:h,state:g,agent:n,input:t}))),u();case v.REASONING_ENCRYPTED_VALUE:{let{subtype:f,entityId:h,encryptedValue:g}=m,x=await K(r,s,a,(S,_,I)=>S.onReasoningEncryptedValueEvent?.({event:m,messages:_,state:I,agent:n,input:t}));if(c(x),x.stopPropagation!==!0){let S=!1;if(f==="tool-call"){for(let _ of s)if(_.role==="assistant"&&_.toolCalls){let I=_.toolCalls.find(H=>H.id===h);if(I){I.encryptedValue=g,S=!0;break}}}else{let _=s.find(I=>I.id===h);_?.role!=="activity"&&_&&(_.encryptedValue=g,S=!0)}S&&(l.messages=s)}return u()}}return m.type,u()}),Ks(),r.length>0?Zs({}):m=>m)},ma=t=>e=>{let n=ur(t),r=new Map,o=new Map,i=!1,s=!1,a=!1,l=new Map,c=!1,u=!1,m=!1,y=()=>{r.clear(),o.clear(),l.clear(),c=!1,u=!1,i=!1,s=!1,m=!0};return e.pipe(Le(f=>{let h=f.type;if(n?.event("VERIFY","Event:",f,{type:f.type}),s)return oe(()=>new ne(`Cannot send event type '${h}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(i&&h!==v.RUN_ERROR&&h!==v.RUN_STARTED)return oe(()=>new ne(`Cannot send event type '${h}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(a){if(h===v.RUN_STARTED){if(m&&!i)return oe(()=>new ne("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,h!==v.RUN_STARTED&&h!==v.RUN_ERROR)return oe(()=>new ne("First event must be 'RUN_STARTED'"));switch(h){case v.TEXT_MESSAGE_START:{let g=f.messageId;return r.has(g)?oe(()=>new ne(`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):oe(()=>new ne(`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)):oe(()=>new ne(`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)?oe(()=>new ne(`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):oe(()=>new ne(`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)):oe(()=>new ne(`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)?oe(()=>new ne(`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)):oe(()=>new ne(`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 oe(()=>new ne(`Cannot send 'RUN_FINISHED' while steps are still active: ${g}`))}if(r.size>0){let g=Array.from(r.keys()).join(", ");return oe(()=>new ne(`Cannot send 'RUN_FINISHED' while text messages are still active: ${g}`))}if(o.size>0){let g=Array.from(o.keys()).join(", ");return oe(()=>new ne(`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?u?oe(()=>new ne("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.")):(u=!0,ue(f)):oe(()=>new ne("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 u?ue(f):oe(()=>new ne("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 u?(u=!1,ue(f)):oe(()=>new ne("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?oe(()=>new ne("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)):oe(()=>new ne("Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first."));default:return ue(f)}}))},nn=(function(t){return t.HEADERS="headers",t.DATA="data",t})({}),yg=t=>Lo(()=>Jt(t())).pipe(Qs(e=>{if(!e.ok){let o=e.headers.get("content-type")||"";return Jt(e.text()).pipe(Le(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,oe(()=>a)}))}let n={type:nn.HEADERS,status:e.status,headers:e.headers},r=e.body?.getReader();return r?new re(o=>(o.next(n),(async()=>{try{for(;;){let{done:i,value:s}=await r.read();if(i)break;let a={type:nn.DATA,data:s};o.next(a)}o.complete()}catch(i){o.error(i)}})(),()=>{r.cancel().catch(i=>{if(i?.name!=="AbortError")throw i})})):oe(()=>Error("Failed to getReader() from response"))})),xg=(t,e)=>{let n=ur(e),r=new ct,o=new TextDecoder("utf-8",{fatal:!1}),i="";t.subscribe({next:a=>{if(a.type!==nn.HEADERS&&a.type===nn.DATA&&a.data){let l=o.decode(a.data,{stream:!0});i+=l;let c=i.split(/\n\n/);i=c.pop()||"";for(let u of c)s(u)}},error:a=>r.error(a),complete:()=>{i&&(i+=o.decode(),s(i)),r.complete()}});function s(a){let l=a.split(`
|
|
9
|
+
`),c=[];for(let u of l)u.startsWith("data:")&&c.push(u.slice(5).replace(/^ /,""));if(c.length>0)try{let u=c.join(`
|
|
10
|
+
`),m=JSON.parse(u);n?.event("SSE","Event received:",m,{type:m.type}),r.next(m)}catch(u){r.error(u)}}return r.asObservable()},wg=t=>{let e=new ct,n=new Uint8Array;t.subscribe({next:o=>{if(o.type!==nn.HEADERS&&o.type===nn.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=$d(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()},Eg=(t,e)=>{let n=ur(e),r=new ct,o=new yo,i=!1;return t.subscribe({next:s=>{if(o.next(s),s.type===nn.HEADERS&&!i){i=!0;let a=s.headers.get("content-type");n?.lifecycle("HTTP","Stream format detected:",{contentType:a,parser:a===ua?"protobuf":"sse"}),a===ua?wg(o).subscribe({next:l=>r.next(l),error:l=>r.error(l),complete:()=>r.complete()}):xg(o,n).subscribe({next:l=>{try{let c=no.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()},J=d.enum(["TextMessageStart","TextMessageContent","TextMessageEnd","ActionExecutionStart","ActionExecutionArgs","ActionExecutionEnd","ActionExecutionResult","AgentStateMessage","MetaEvent","RunStarted","RunFinished","RunError","NodeStarted","NodeFinished"]),_g=d.enum(["LangGraphInterruptEvent","PredictState","Exit"]),Tg=d.object({type:d.literal(J.enum.TextMessageStart),messageId:d.string(),parentMessageId:d.string().optional(),role:d.string().optional()}),Sg=d.object({type:d.literal(J.enum.TextMessageContent),messageId:d.string(),content:d.string()}),Ag=d.object({type:d.literal(J.enum.TextMessageEnd),messageId:d.string()}),kg=d.object({type:d.literal(J.enum.ActionExecutionStart),actionExecutionId:d.string(),actionName:d.string(),parentMessageId:d.string().optional()}),Cg=d.object({type:d.literal(J.enum.ActionExecutionArgs),actionExecutionId:d.string(),args:d.string()}),Ig=d.object({type:d.literal(J.enum.ActionExecutionEnd),actionExecutionId:d.string()}),Rg=d.object({type:d.literal(J.enum.ActionExecutionResult),actionName:d.string(),actionExecutionId:d.string(),result:d.string()}),Ng=d.object({type:d.literal(J.enum.AgentStateMessage),threadId:d.string(),agentName:d.string(),nodeName:d.string(),runId:d.string(),active:d.boolean(),role:d.string(),state:d.string(),running:d.boolean()}),Og=d.object({type:d.literal(J.enum.MetaEvent),name:_g,value:d.any()}),Mg=d.object({type:d.literal(J.enum.RunError),message:d.string(),code:d.string().optional()});d.discriminatedUnion("type",[Tg,Sg,Ag,kg,Cg,Ig,Rg,Ng,Og,Mg]),d.object({id:d.string(),role:d.string(),content:d.string(),parentMessageId:d.string().optional()}),d.object({id:d.string(),name:d.string(),arguments:d.any(),parentMessageId:d.string().optional()}),d.object({id:d.string(),result:d.any(),actionExecutionId:d.string(),actionName:d.string()});var Lg=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
|
+
`)},Pg=(t,e,n)=>r=>{let o={},i=!0,s=!0,a="",l=null,c=null,u=[],m={},y=f=>{typeof f=="object"&&f&&("messages"in f&&delete f.messages,o=f)};return r.pipe(Le(f=>{switch(f.type){case v.TEXT_MESSAGE_START:{let h=f;return[{type:J.enum.TextMessageStart,messageId:h.messageId,role:h.role}]}case v.TEXT_MESSAGE_CONTENT:{let h=f;return[{type:J.enum.TextMessageContent,messageId:h.messageId,content:h.delta}]}case v.TEXT_MESSAGE_END:{let h=f;return[{type:J.enum.TextMessageEnd,messageId:h.messageId}]}case v.TOOL_CALL_START:{let h=f;return u.push({id:h.toolCallId,type:"function",function:{name:h.toolCallName,arguments:""}}),s=!0,m[h.toolCallId]=h.toolCallName,[{type:J.enum.ActionExecutionStart,actionExecutionId:h.toolCallId,actionName:h.toolCallName,parentMessageId:h.parentMessageId}]}case v.TOOL_CALL_ARGS:{let h=f,g=u.find(S=>S.id===h.toolCallId);if(!g)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${h.toolCallId}'`),[];g.function.arguments+=h.delta;let x=!1;if(c){let S=c.find(_=>_.tool==g.function.name);if(S)try{let _=JSON.parse(Uo(g.function.arguments));S.tool_argument&&S.tool_argument in _?(y({...o,[S.state_key]:_[S.tool_argument]}),x=!0):S.tool_argument||(y({...o,[S.state_key]:_}),x=!0)}catch{}}return[{type:J.enum.ActionExecutionArgs,actionExecutionId:h.toolCallId,args:h.delta},...x?[{type:J.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 h=f;return[{type:J.enum.ActionExecutionEnd,actionExecutionId:h.toolCallId}]}case v.TOOL_CALL_RESULT:{let h=f;return[{type:J.enum.ActionExecutionResult,actionExecutionId:h.toolCallId,result:h.content,actionName:m[h.toolCallId]||"unknown"}]}case v.RAW:return[];case v.CUSTOM:{let h=f;switch(h.name){case"Exit":i=!1;break;case"PredictState":c=h.value;break}return[{type:J.enum.MetaEvent,name:h.name,value:h.value}]}case v.STATE_SNAPSHOT:return y(f.snapshot),[{type:J.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 h=f,g=uo.applyPatch(o,h.delta,!0,!1);return g?(y(g.newDocument),[{type:J.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:J.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:J.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify({...o,...l?{messages:Dg(l)}:{}}),active:!1}];case v.RUN_ERROR:{let h=f;return[{type:J.enum.RunError,message:h.message,code:h.code}]}case v.STEP_STARTED:return a=f.stepName,u=[],c=null,[{type:J.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 u=[],c=null,[{type:J.enum.AgentStateMessage,threadId:t,agentName:n,nodeName:a,runId:e,running:i,role:"assistant",state:JSON.stringify(o),active:!1}];default:return[]}}))};function Dg(t){let e=[];for(let n of t)if(n.role==="assistant"||n.role==="user"||n.role==="system"){let r=Lg(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 yi=t=>e=>{let n=ur(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},u=()=>s==="text"?[a()]:s==="tool"?[l()]:s==="reasoning"?[c()]:[];return e.pipe(Le(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[...u(),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(...u()),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 _={type:v.TEXT_MESSAGE_START,messageId:y.messageId,role:y.role||"assistant",...y.name!==void 0&&{name:y.name}};f.push(_),n?.event("TRANSFORM","TEXT_MESSAGE_START",_,{messageId:y.messageId})}if(y.delta!==void 0){let _={type:v.TEXT_MESSAGE_CONTENT,messageId:r.messageId,delta:y.delta};f.push(_),n?.event("TRANSFORM","TEXT_MESSAGE_CONTENT",_,{messageId:r.messageId})}return f;case v.TOOL_CALL_CHUNK:let h=m,g=[];if((s!=="tool"||h.toolCallId!==void 0&&h.toolCallId!==o?.toolCallId)&&g.push(...u()),s!=="tool"){if(h.toolCallId===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallId");if(h.toolCallName===void 0)throw Error("First TOOL_CALL_CHUNK must have a toolCallName");o={toolCallId:h.toolCallId,toolCallName:h.toolCallName,parentMessageId:h.parentMessageId},s="tool";let _={type:v.TOOL_CALL_START,toolCallId:h.toolCallId,toolCallName:h.toolCallName,parentMessageId:h.parentMessageId};g.push(_),n?.event("TRANSFORM","TOOL_CALL_START",_,{toolCallId:h.toolCallId,toolCallName:h.toolCallName})}if(h.delta!==void 0){let _={type:v.TOOL_CALL_ARGS,toolCallId:o.toolCallId,delta:h.delta};g.push(_),n?.event("TRANSFORM","TOOL_CALL_ARGS",_,{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(...u()),s!=="reasoning"){if(x.messageId===void 0)throw Error("First REASONING_MESSAGE_CHUNK must have a messageId");i={messageId:x.messageId},s="reasoning";let _={type:v.REASONING_MESSAGE_START,messageId:x.messageId};S.push(_),n?.event("TRANSFORM","REASONING_MESSAGE_START",_,{messageId:x.messageId})}if(x.delta!==void 0){let _={type:v.REASONING_MESSAGE_CONTENT,messageId:i.messageId,delta:x.delta};S.push(_),n?.event("TRANSFORM","REASONING_MESSAGE_CONTENT",_,{messageId:i.messageId})}return S}return m.type,[]}),tn(()=>{u()}))};function Ug(t,e=new Date){return t.expiresAt===void 0?!1:new Date(t.expiresAt)<=e}function Jd(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 xi=class{runNext(t,e){return e.run(t).pipe(yi(!1))}runNextWithState(t,e){let n=q(t.messages||[]),r=q(t.state||{}),o=new yo;return Qd(t,o,e,[]).subscribe(i=>{i.messages!==void 0&&(n=i.messages),i.state!==void 0&&(r=i.state)}),this.runNext(t,e).pipe(Po(async i=>(o.next(i),await new Promise(s=>setTimeout(s,0)),{event:i,messages:q(n),state:q(r)})))}},Hg=class extends xi{constructor(t){super(),this.fn=t}run(t,e){return this.fn(t,e)}};function Fg(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 zg=class extends xi{run(t,e){let{parentRunId:n,...r}=t,o={...r,messages:r.messages.map(Fg)};return this.runNext(o,e)}},Wd="THINKING_START",Xd="THINKING_END",Yd="THINKING_TEXT_MESSAGE_START",Kd="THINKING_TEXT_MESSAGE_CONTENT",Zd="THINKING_TEXT_MESSAGE_END",Gg=class extends xi{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(en(n=>this.transformEvent(n)))}transformEvent(t){switch(t.type){case Wd:{this.currentReasoningId=_e();let{title:e,...n}=t;return this.warnAboutTransformation(Wd,v.REASONING_START),{...n,type:v.REASONING_START,messageId:this.currentReasoningId}}case Yd:return this.currentMessageId=_e(),this.warnAboutTransformation(Yd,v.REASONING_MESSAGE_START),{...t,type:v.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:"assistant"};case Kd:{let{delta:e,...n}=t;return this.warnAboutTransformation(Kd,v.REASONING_MESSAGE_CONTENT),{...n,type:v.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??_e(),delta:e}}case Zd:{let e=this.currentMessageId??_e();return this.warnAboutTransformation(Zd,v.REASONING_MESSAGE_END),{...t,type:v.REASONING_MESSAGE_END,messageId:e}}case Xd:{let e=this.currentReasoningId??_e();return this.warnAboutTransformation(Xd,v.REASONING_END),{...t,type:v.REASONING_END,messageId:e}}default:return t}}};function $g(t){return t.startsWith("image/")?"image":t.startsWith("audio/")?"audio":t.startsWith("video/")?"video":"document"}function Bg(t){return typeof t=="object"&&!!t&&"type"in t&&t.type==="binary"&&"mimeType"in t&&typeof t.mimeType=="string"}function Vg(t){let e=$g(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 jg(t){let e=t.content;if(!Array.isArray(e))return t;let n=e.map(r=>Bg(r)?Vg(r):r);return{...t,content:n}}var qg=class extends xi{run(t,e){let n={...t,messages:t.messages.map(jg)};return this.runNext(n,e)}},Wg="0.0.57",Xg=class{get maxVersion(){return Wg}get debug(){return this._debug}set debug(t){this._debug=bi(t),this._debugLogger=fa(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(t){typeof t=="boolean"?this._debugLogger=t?fa(bi(!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??_t(),this.messages=q(r??[]),this.state=q(o??{}),this._debug=bi(i),this._debugLogger=fa(this._debug),dr(this.maxVersion,"0.0.39")<=0&&this.middlewares.unshift(new zg),dr(this.maxVersion,"0.0.45")<=0&&this.middlewares.unshift(new Gg),dr(this.maxVersion,"0.0.47")<=0&&this.middlewares.unshift(new qg)}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 Hg(n):n);return this.middlewares.push(...e),this}async runAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??_t();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 ct;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await Mo(bo(()=>this.middlewares.length===0?this.run(n):this.middlewares.reduceRight((l,c)=>({run:u=>c.run(u,l),get messages(){return l.messages},get state(){return l.state}}),this).run(n),yi(this.debugLogger),ma(this.debugLogger),l=>l.pipe(Do(this.activeRunDetach$)),l=>this.apply(n,l,i),l=>this.processApplyEvents(n,l,i),ar(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))),tn(()=>{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 Us}async connectAgent(t,e){try{this.isRunning=!0,this.agentId=this.agentId??_t();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 ct;let s;this.activeRunCompletionPromise=new Promise(l=>{s=l}),await Mo(bo(()=>Lo(()=>this.connect(n)),yi(this.debugLogger),ma(this.debugLogger),l=>l.pipe(Do(this.activeRunDetach$)),l=>this.apply(n,l,i),l=>this.processApplyEvents(n,l,i),ar(l=>(this.isRunning=!1,l instanceof Us?xo:this.onError(n,l,i))),tn(()=>{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 Qd(t,e,this,n,this.debugLogger)}processApplyEvents(t,e,n){return e.pipe(Js(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||_t(),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 ne(`Thread has ${o.length} pending interrupt(s) not addressed by resume: ${o.join(", ")}`);for(let i of this.pendingInterrupts)if(Ug(i))throw new ne(`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 Jt(K(n,this.messages,this.state,(r,o,i)=>r.onRunFailed?.({error:e,messages:o,state:i,agent:this,input:t}))).pipe(en(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??_t();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(yi(this.debugLogger),ma(this.debugLogger),Pg(this.threadId,e.runId,this.agentId),n=>n.pipe(en(r=>(this.debugLogger?.event("LEGACY","Event:",r,{type:r.type}),r))))}},eu=class extends Xg{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 Eg(yg(()=>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 Yg=/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g;function tu(t,e){let n=[];return{text:t.replace(Yg,(o,i)=>{let s=e[i];return s==null||s===""?(n.includes(i)||n.push(i),o):String(s)}),missing:n}}function Kg(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 ba(t){return Array.isArray(t)?t.filter(Kg):[]}var pr=class{#t=new Map;register(e){this.#t.set(e.name,e)}has(e){return this.#t.has(e)}get(e){let n=this.#t.get(e);if(n===void 0)throw new Error(`tool "${e}" is not registered`);return n}tools(){return[...this.#t.values()].map(e=>({name:e.name,description:e.description,parameters:e.parameters}))}};function ya(t){return t[Kn]===!0}function wi(t){return t[Zn]===!0}function Ei(t,e){return Object.getOwnPropertyDescriptor(t,e).set}var Zg=Ei(HTMLInputElement.prototype,"value"),Qg=Ei(HTMLTextAreaElement.prototype,"value"),Jg=Ei(HTMLSelectElement.prototype,"value"),ev=Ei(HTMLInputElement.prototype,"checked");function rn(t,e){t instanceof HTMLTextAreaElement?Qg.call(t,e):t instanceof HTMLSelectElement?Jg.call(t,e):Zg.call(t,e)}function hr(t,e){ev.call(t,e)}var xa="#4f46e5",tv="rgba(79, 70, 229, 0.4)",nv="--ag-ui-accent";function fr(t){return new Promise(e=>{setTimeout(e,t)})}function _i(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function wa(t){return t<=0||_i()?Promise.resolve():fr(t)}function Ti(t,e){let n=window.getComputedStyle(t).getPropertyValue(nv).trim();return n===""?e:n}function nu(t){return`0 0 0 3px ${Ti(t,tv)}`}async function Ea(t,e,n={}){let r=n.charDelayMs??35;rn(t,""),t.dispatchEvent(new Event("input",{bubbles:!0}));for(let o of e)rn(t,t.value+o),t.dispatchEvent(new Event("input",{bubbles:!0})),r>0&&await fr(r);t.dispatchEvent(new Event("change",{bubbles:!0}))}async function _a(t,e={}){let n=e.highlightMs??280,r=t.style.outline,o=t.style.outlineOffset;t.style.outline=`2px solid ${Ti(t,xa)}`,t.style.outlineOffset="2px",await fr(n),t.style.outline=r,t.style.outlineOffset=o,t.click()}var rv=600,ov=100;function vt(t,e={}){let n=_i();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??rv)};o=setTimeout(i,ov),document.addEventListener("scroll",s,!0),document.addEventListener("scrollend",i,!0)})}var iv=1200,sv=1/3;async function ru(t,e,n){(e.focus??n)&&t.focus({preventScroll:!0});let r=e.flashMs??iv;if(r<=0)return;let o=t.style.outline,i=t.style.outlineOffset,s=t.style.transition,a=e.color??Ti(t,xa);t.style.outline=`3px solid ${a}`,t.style.outlineOffset="2px";let l=_i()?0:Math.round(r*sv);await fr(r-l),l>0&&(t.style.transition=`outline-color ${l}ms ease-out`,t.style.outline="3px solid transparent",await fr(l)),t.style.outline=o,t.style.outlineOffset=i,t.style.transition=s}function av(t,e={}){return ru(t,e,!1)}function Ta(t,e={}){return ru(t,e,!0)}async function Sa(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=nu(t),await wa(n),t.style.transform=r,t.style.transition=o,t.style.boxShadow=i,t.click()}function lv(t,e){for(let n of Array.from(t.options))if(n.value===e||n.text===e)return n;return null}async function Aa(t,e,n={}){let r=lv(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 ${Ti(t,xa)}`,t.style.outlineOffset="2px",await wa(o),rn(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 ka(t,e,n={}){let r=n.flashMs??200,o=t.style.boxShadow;t.style.boxShadow=nu(t),await wa(r),hr(t,e),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0})),t.style.boxShadow=o}var Ca={SCROLL:"scroll",DRAG:"drag"};function Ia(t,e){let n=[];return t.has(Ca.SCROLL)&&n.push(cv(e)),t.has(Ca.DRAG)&&n.push(dv(e)),n}function cv(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"],[Pe]:"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 vt(r),{scrolled:!0,target:n}}}}function dv(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"],[Pe]:"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 uv(o,i),{dragged:!0,from:n,to:r}}}}function uv(t,e){let n=new DataTransfer;mr(t,"dragstart",n),mr(e,"dragenter",n),mr(e,"dragover",n),mr(e,"drop",n),mr(t,"dragend",n)}function mr(t,e,n){let r=new Event(e,{bubbles:!0,cancelable:!0});r.dataTransfer=n,t.dispatchEvent(r)}function Ra(t,e){return!e||t===null?[]:[{description:"page_map",value:JSON.stringify(t())}]}function Si(t){let e=[{name:`read_${t.name}`,description:`Read the "${t.name}" state.`,parameters:{type:"object",properties:{},required:[],[Pe]:`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"},[Kn]:!0,[Pe]:`Update ${t.name}`},handler:r=>n(r)}),e}var pv=Si;function Na(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,s=r.description;typeof o=="string"&&typeof i=="string"&&(e[o]=typeof s=="string"?{name:o,summary:i,description:s}:{name:o,summary:i})}return e}var ou=/:([A-Za-z_][A-Za-z0-9_]*)/g;function hv(t){return[...t.matchAll(ou)].map(e=>e[0].slice(1))}function fv(t,e,n){let r={...n};return{path:e.replace(ou,(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 mv(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 Oa(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:[],[Pe]:"List pages"},handler:()=>t().map(n=>({...n,pathParams:hv(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"],[Zn]:!0,[Pe]:"Navigate"},handler:n=>{let r=n.route_id,o=t().find(u=>u.id===r);if(o===void 0)throw new Error(`unknown route "${String(r)}"`);let i=n.params??{},{path:s,leftover:a}=fv(o.id,o.path,i),l=mv(s,a),c=e();return c!==null?c(l):window.location.assign(l),{navigated:!0,path:l}}}]}var ee={title:"Assistant",chatHistory:"Chat history",newChat:"New chat",collapse:"Collapse",expand:"Expand",expandUnread:"Expand \u2014 {count} unread",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",jumpToLatest:"Jump to latest",announceResponding:"Assistant is responding",announceAnswerReady:"Assistant answered",announceAwaitingDecision:"{count} action is waiting for your approval",announceStopped:"Response stopped",announceFailed:"The response failed",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",historyReplaced:"The server replaced this conversation's history. Reload to see the updated transcript.",chartUndrawable:"A chart could not be drawn from the data sent, so it was removed.",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",recordingLimit:"Stopped at the {n}-minute limit \u2014 transcribing what was recorded.",toolRunning:"running\u2026",toolDeferred:"waiting for you",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",subAgentWorking:"Working\u2026",subAgentSteps:"Steps the sub-agent took",approvalEditArgs:"Edit the arguments before approving",approvalArgsInvalid:"That is not valid JSON, so nothing was sent.",approvalArgsNotAnObject:"Arguments have to be a JSON object.",suggestions:"Suggested follow-ups",messageActions:"Message actions",quoteSelection:"Quote",copyMessage:"Copy message",retryMessage:"Try again",feedbackUp:"Good answer",feedbackDown:"Poor answer",confirmAction:"Confirm action",confirmAlways:"Always allow",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 Ma(t){let e={...ee};for(let n of Object.keys(t)){let r=t[n];r!==void 0&&(e[n]=r)}return e}function iu(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 La(t,e,n={}){let r=n.strings??ee;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=gv(e,n,r),l=document.createElement("div");l.className="approval-actions",l.setAttribute("part","approval-actions");let c=iu("deny",r.deny),u=iu("approve",r.approve),m=!1,y=f=>{m||(m=!0,c.disabled=!0,u.disabled=!0,i.setAttribute("data-resolved",f?"approved":"denied"),o(f))};if(c.addEventListener("click",()=>y(!1)),u.addEventListener("click",()=>{a!==null&&!a.commit()||y(!0)}),n.signal?.addEventListener("abort",()=>y(!1),{once:!0}),l.append(c,u),i.append(s,...a===null?[]:[a.root],l),t.appendChild(i),n.signal?.aborted===!0){y(!1);return}u.focus()})}function gv(t,e,n){let{onEdit:r}=e;if(r===void 0||t.args===void 0)return null;let o=JSON.stringify(t.args,null,2),i=document.createElement("div");i.className="approval-edit",i.setAttribute("part","approval-edit");let s=document.createElement("textarea");s.className="approval-args",s.setAttribute("part","approval-args"),s.setAttribute("aria-label",n.approvalEditArgs),s.rows=Math.min(10,o.split(`
|
|
12
|
+
`).length),s.value=o;let a=document.createElement("div");return a.className="approval-error",a.setAttribute("part","approval-error"),a.setAttribute("role","alert"),a.hidden=!0,i.append(s,a),{root:i,commit:()=>{if(s.value===o)return!0;let l;try{l=JSON.parse(s.value)}catch{return a.textContent=n.approvalArgsInvalid,a.hidden=!1,s.focus(),!1}return typeof l!="object"||l===null||Array.isArray(l)?(a.textContent=n.approvalArgsNotAnObject,a.hidden=!1,s.focus(),!1):(a.hidden=!0,r(l),!0)}}}function Pa(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(vv(r,e)))}}function vv(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",()=>{bv(n).then(o=>{yv(r,o?e.copied:e.copyFailed,e)})}),r}async function bv(t){let e=navigator.clipboard;if(e===void 0)return!1;try{return await e.writeText(t),!0}catch{return!1}}function yv(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 Da(t){let e=document.createElement("div");e.className="attachment-chips",e.setAttribute("part","attachment-chips");for(let n of t)e.appendChild(xv(n));return e}function xv(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.innerHTML=Ua(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=Ai(t.size),e.append(n,r,o),e}function Ua(t){return t.startsWith("image/")?ic:t==="application/pdf"?sc:t.startsWith("text/")?ac:oc}function Ai(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 ki=class{element;#t;#n;#e=[];constructor(e){this.#t=e,this.#n=e.strings??ee,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:_e(),file:e,status:De.UPLOADING,progress:0,ref:null,error:"",controller:null};this.#e.push(n);let r=this.#s(e);if(r!==null){n.status=De.ERROR,n.error=r,this.#o(),this.#t.onChange?.();return}this.#o(),this.#t.onChange?.(),this.#r(n)}readyRefs(){let e=[];for(let n of this.#e)n.ref!==null&&e.push(n.ref);return e}hasPending(){return this.#e.some(e=>e.status===De.UPLOADING)}pendingCount(){return this.#e.filter(e=>e.status===De.UPLOADING).length}isEmpty(){return this.#e.length===0}clearReady(){this.#e=this.#e.filter(e=>e.status===De.UPLOADING),this.#o()}clear(){for(let e of this.#e)e.controller?.abort();this.#e=[],this.#o()}dispose(){for(let e of this.#e)e.controller?.abort()}#s(e){return this.#t.maxBytes>0&&e.size>this.#t.maxBytes?this.#n.tooLarge.replace("{size}",Ai(this.#t.maxBytes)):wv(this.#t.accept,e)?null:this.#n.fileTypeNotAllowed}#r(e){let n=this.#s(e.file);if(n!==null){e.status=De.ERROR,e.error=n,this.#o(),this.#t.onChange?.();return}e.status=De.UPLOADING,e.progress=0,e.error="";let r=new AbortController;e.controller=r,this.#o(),this.#t.upload(e.file,o=>{e.progress=o,this.#o()},r.signal).then(o=>{e.status=De.READY,e.ref=o}).catch(o=>{e.status=De.ERROR,e.error=o instanceof Error?o.message:this.#n.uploadFailed}).finally(()=>{e.controller=null,this.#o(),this.#t.onChange?.()})}#i(e){e.controller?.abort(),this.#e=this.#e.filter(n=>n!==e),this.#o(),this.#t.onChange?.()}#o(){this.element.replaceChildren(),this.element.hidden=this.#e.length===0;for(let e of this.#e)this.element.appendChild(this.#u(e))}#u(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.innerHTML=Ua(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===De.ERROR?e.error:Ai(e.file.size),n.append(r,o,i),e.status===De.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===De.ERROR){let a=document.createElement("button");a.type="button",a.className="attachment-chip-retry",a.setAttribute("part","attachment-chip-retry"),a.title=this.#n.retry,a.setAttribute("aria-label",this.#n.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.#n.remove,s.setAttribute("aria-label",this.#n.removeAttachment),s.textContent="\u2715",s.addEventListener("click",()=>this.#i(e)),n.appendChild(s),n}};function wv(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)}var Ev="http://www.w3.org/2000/svg";var He={top:20,right:12,bottom:30,left:44},Ii=480-He.left-He.right,Ci=220-He.top-He.bottom,su=["var(--ag-ui-chart-1, #4f7cff)","var(--ag-ui-chart-2, #21b573)","var(--ag-ui-chart-3, #e0803c)","var(--ag-ui-chart-4, #b563d8)","var(--ag-ui-chart-5, #d84f6e)","var(--ag-ui-chart-6, #3ba7c4)"];function on(t){return su[t%su.length]}function dt(t,e){let n=document.createElementNS(Ev,t);for(let[r,o]of Object.entries(e))n.setAttribute(r,String(o));return n}function au(t,e){let n=dt("text",{"font-size":10,fill:"currentColor","fill-opacity":.65,...e});return n.textContent=t,n}function _v(t){let e=[];return t.labels.forEach((n,r)=>{let o=0;for(let i of t.series)o+=i.points[r]??0,e.push(o)}),e}function Tv(t){let e=t.kind==="stacked"?_v(t):t.series.flatMap(o=>[...o.points]),n=Math.max(0,...e),r=Math.min(0,...e);return n===r?{min:r,max:n+1}:{min:r,max:n}}function sn(t,e,n){return He.top+Ci-(t-e)/(n-e)*Ci}function Ha(t,e){let n=Ii/e;return He.left+n*t+n/2}function Sv(t,e,n,r){for(let o of[n,r]){let i=sn(o,n,r);t.appendChild(dt("line",{x1:He.left,y1:i,x2:480-He.right,y2:i,stroke:"currentColor","stroke-opacity":o===n?.35:.12})),t.appendChild(au(String(Math.round(o)),{x:He.left-6,y:i+4,"text-anchor":"end"}))}e.labels.forEach((o,i)=>{t.appendChild(au(o,{x:Ha(i,e.labels.length),y:220-He.bottom+16,"text-anchor":"middle"}))})}function Av(t,e,n,r){let o=Ii/e.labels.length,i=o*.7/e.series.length,s=sn(n,n,r);e.series.forEach((a,l)=>{a.points.forEach((c,u)=>{let m=sn(c,n,r);t.appendChild(dt("rect",{x:He.left+o*u+o*.15+i*l,y:m,width:i,height:Math.max(1,s-m),fill:on(l),rx:2}))})})}function kv(t,e,n,r){let o=Ii/e.labels.length,i=o*.7,s=e.labels.map(()=>0);e.series.forEach((a,l)=>{a.points.forEach((c,u)=>{let m=s[u]??0,y=m+c;s[u]=y;let f=sn(y,n,r);t.appendChild(dt("rect",{x:He.left+o*u+o*.15,y:f,width:i,height:Math.max(1,sn(m,n,r)-f),fill:on(l)}))})})}function Cv(t,e,n,r){e.series.forEach((o,i)=>{let s=o.points.map((a,l)=>`${Ha(l,e.labels.length)},${sn(a,n,r)}`).join(" ");t.appendChild(dt("polyline",{points:s,fill:"none",stroke:on(i),"stroke-width":2,"stroke-linejoin":"round"}))})}function Iv(t,e,n,r){e.series.forEach((o,i)=>{o.points.forEach((s,a)=>{t.appendChild(dt("circle",{cx:Ha(a,e.labels.length),cy:sn(s,n,r),r:4,fill:on(i),"fill-opacity":.85}))})})}function Rv(t,e){let n=e.reduce((a,l)=>a+l,0),r=480/2,o=He.top+Ci/2,i=Math.min(Ii,Ci)/2;if(n===0){t.appendChild(dt("circle",{cx:r,cy:o,r:i,fill:"none",stroke:"currentColor","stroke-opacity":.3}));return}let s=-Math.PI/2;e.forEach((a,l)=>{let c=a/n*Math.PI*2,u=s+c;if(c>=Math.PI*2)t.appendChild(dt("circle",{cx:r,cy:o,r:i,fill:on(l)}));else{let m=r+i*Math.cos(s),y=o+i*Math.sin(s),f=r+i*Math.cos(u),h=o+i*Math.sin(u),g=c>Math.PI?1:0;t.appendChild(dt("path",{d:`M ${r} ${o} L ${m} ${y} A ${i} ${i} 0 ${g} 1 ${f} ${h} Z`,fill:on(l)}))}s=u})}function Nv(t){if(t.length<2)return null;let e=document.createElement("div");return e.className="chart-legend",e.setAttribute("part","chart-legend"),t.forEach((n,r)=>{let o=document.createElement("span");o.className="chart-legend-item";let i=document.createElement("span");i.className="chart-legend-swatch",i.style.background=on(r),o.append(i,document.createTextNode(n)),e.appendChild(o)}),e}function gr(t){if(t.labels.length===0||t.series.length===0)return null;let e=document.createElement("div");if(e.className="chart-block",e.setAttribute("part","chart-block"),t.title!==void 0&&t.title!==""){let o=document.createElement("div");o.className="chart-title",o.setAttribute("part","chart-title"),o.textContent=t.title,e.appendChild(o)}let n=dt("svg",{viewBox:"0 0 480 220",width:"100%",role:"img"});if(n.setAttribute("aria-label",t.title??`${t.kind} chart`),t.kind==="pie"){let o=t.series[0];Rv(n,o.points.map(i=>Math.max(0,i)))}else{let{min:o,max:i}=Tv(t);Sv(n,t,o,i),t.kind==="bar"?Av(n,t,o,i):t.kind==="stacked"?kv(n,t,o,i):t.kind==="line"?Cv(n,t,o,i):Iv(n,t,o,i)}e.appendChild(n);let r=Nv(t.kind==="pie"?t.labels:t.series.map(o=>o.label));return r!==null&&e.appendChild(r),e}var Ov=["bar","line","pie","scatter","stacked"];function Mv(t){return Ov.includes(t)?t:"bar"}function Lv(t){if(!Array.isArray(t))return null;let e=[];for(let n of t){if(typeof n!="number"||!Number.isFinite(n)||Math.abs(n)>1e15)return null;e.push(n)}return e}function Pv(t){if(!Array.isArray(t))return null;for(let e=0;e<t.length;e+=1)if(typeof t[e]!="string")return null;return t}function Un(t){if(typeof t!="object"||t===null)return null;let e=t,n=Pv(e.labels);if(n===null||!Array.isArray(e.series))return null;let r=[];for(let s of e.series){if(typeof s!="object"||s===null)return null;let a=s,l=Lv(a.points);if(l===null||l.length!==n.length)return null;r.push({label:typeof a.label=="string"?a.label:"",points:l})}if(r.length===0||r.length*n.length>2e4||n.length>2e3)return null;let o=Mv(e.kind),i=e.title;return typeof i=="string"?{kind:o,title:i,labels:n,series:r}:{kind:o,labels:n,series:r}}var Ri="render_chart";function Dv(t){let e=Un(t);return e===null?null:gr(e)}function Uv(t){let e=Un(t);return e!==null&&e.labels.length>0&&e.series.length>0}var Hv="chart not rendered: expected labels (strings) and series, each with one finite number per label";function lu(){return{name:Ri,description:"Show a chart in the conversation. Supply the data and the page draws it. Every series must have exactly one point per label.",parameters:{type:"object",properties:{kind:{type:"string",enum:["bar","line","pie","scatter","stacked"]},title:{type:"string"},labels:{type:"array",items:{type:"string"}},series:{type:"array",items:{type:"object",properties:{label:{type:"string"},points:{type:"array",items:{type:"number"}}},required:["points"]}}},required:["labels","series"],"x-summary":"Draw a chart"},handler:t=>Uv(t)?"chart rendered":Hv,render:Dv}}function vr(t,e=Date.now(),n=ee){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)))}function cu(t){return t.preview!==void 0&&t.preview!==null&&t.preview!==""?t.preview:null}function du(t){return t.replace(/\s+/g," ").trim()}var br=class{element;#t;#n;#e;#s=null;#r=null;#i;#o=[];constructor(e,n=ee){this.#t=e,this.#i=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.#e=document.createElement("span"),this.#e.className="checkpoints-title",this.#e.setAttribute("part","checkpoints-title"),this.#e.textContent=n.checkpoints,r.append(this.#e),this.#n=document.createElement("div"),this.#n.className="checkpoints-list",this.#n.setAttribute("part","checkpoints-list"),this.element.append(r,this.#n),this.element.addEventListener("keydown",o=>this.#a(o))}setRuns(e){this.#o=e,this.#p()}setRelativeTimeFormatter(e){this.#r=e}#u(e){return this.#r!==null?this.#r(e):vr(e,Date.now(),this.#i)}setStrings(e){this.#i=e,this.element.setAttribute("aria-label",e.checkpoints),this.#e.textContent=e.checkpoints,this.#p()}open(){this.open_||(this.#s=this.#c(),this.element.hidden=!1,(this.#d()[0]??this.element).focus())}close(){this.open_&&(this.element.hidden=!0,this.#s?.focus(),this.#s=null)}#c(){return this.element.getRootNode().activeElement}#d(){return Array.from(this.element.querySelectorAll("button, [tabindex]")).filter(e=>!e.hidden)}#a(e){if(e.key==="Escape"){e.stopPropagation(),this.close();return}if(e.key!=="Tab")return;let n=this.#d(),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())}get open_(){return!this.element.hidden}#p(){if(this.#n.replaceChildren(),this.#o.length===0){let n=document.createElement("div");n.className="checkpoints-empty",n.setAttribute("part","checkpoints-empty"),n.textContent=this.#i.noCheckpoints,this.#n.append(n);return}let e=this.#v();for(let n of this.#o)this.#n.append(this.#m(n,e))}#v(){let e=new Set,n=new Set;for(let r of this.#o){let o=cu(r);if(o===null)continue;let i=du(o);e.has(i)&&n.add(i),e.add(i)}return n}#m(e,n){let r=document.createElement("div");r.className="checkpoint-row",r.setAttribute("part","checkpoint-row");let o=cu(e),i=e.started_at===null?null:this.#u(Date.parse(e.started_at)),s=document.createElement("span");if(s.className="checkpoint-label",s.setAttribute("part","checkpoint-label"),s.textContent=o??i??e.run_id,r.append(s),o!==null&&i!==null){let l=document.createElement("span");l.className="checkpoint-time",l.setAttribute("part","checkpoint-time"),l.textContent=i,r.append(l)}if((o===null?i!==null:n.has(du(o)))&&e.run_id!==""){let l=document.createElement("span");l.className="checkpoint-id",l.setAttribute("part","checkpoint-id"),l.textContent=e.run_id.slice(0,8),l.title=e.run_id,r.append(l)}if(e.parent_run_id!==null){let l=document.createElement("span");l.className="checkpoint-branch",l.setAttribute("part","checkpoint-branch"),l.textContent=this.#i.forkedRun,l.title=e.parent_run_id,r.append(l)}return r.append(this.#y(e.run_id,"resume",this.#i.resumeRun),this.#y(e.run_id,"fork",this.#i.forkRun)),r}#y(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.#t(e,n)}),o}};function Fa(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 za(t,e,n={}){let r=n.strings??ee;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=Fa("cancel",r.cancel),u=n.onAlwaysAllow===void 0?null:Fa("always",r.confirmAlways.replace("{tool}",e.toolName)),m=Fa("confirm",r.confirm),y=!1,f=h=>{y||(y=!0,i.remove(),o(h))};if(c.addEventListener("click",()=>f(!1)),m.addEventListener("click",()=>f(!0)),u?.addEventListener("click",()=>{n.onAlwaysAllow?.(),f(!0)}),n.signal?.addEventListener("abort",()=>f(!1),{once:!0}),l.append(c,...u===null?[]:[u],m),i.append(s,a,l),t.appendChild(i),n.signal?.aborted===!0){f(!1);return}m.focus()})}function Ga(t,e){if(hu(t)!==null)return;let n=Ni(t,e.strings),r=e.text;r!==void 0&&n.appendChild(Fv(e.strings,r)),e.onFeedback!==void 0&&n.append(uu("up",e.strings.feedbackUp,e.onFeedback),uu("down",e.strings.feedbackDown,e.onFeedback))}function Ni(t,e){let n=hu(t);if(n!==null)return n;let r=document.createElement("div");return r.className="message-actions",r.setAttribute("part","message-actions"),r.setAttribute("role","group"),r.setAttribute("aria-label",e.messageActions),t.after(r),r}function hu(t){let e=t.nextElementSibling;return e?.classList.contains("message-actions")===!0?e:null}function Oi(t,e,n){let r=document.createElement("button");r.type="button",r.className=`message-action message-action--${t}`,r.setAttribute("part",`message-action message-action-${t}`),r.title=e,r.setAttribute("aria-label",e);let o=document.createElement("span");return o.setAttribute("aria-hidden","true"),o.textContent=n,r.appendChild(o),r}function Fv(t,e){let n=Oi("copy",t.copyMessage,"\u2398");return n.addEventListener("click",()=>{navigator.clipboard.writeText(e()).then(()=>pu(n,t.copied,t.copyMessage),()=>pu(n,t.copyFailed,t.copyMessage))}),n}function uu(t,e,n){let r=Oi(t==="up"?"up":"down",e,t==="up"?"\u{1F44D}":"\u{1F44E}");return r.addEventListener("click",()=>{let o=r.getAttribute("aria-pressed")==="true";r.setAttribute("aria-pressed",o?"false":"true"),n(t)}),r.setAttribute("aria-pressed","false"),r}function pu(t,e,n){t.title=e,t.setAttribute("aria-label",e),t.classList.add("message-action--confirmed"),setTimeout(()=>{t.title=n,t.setAttribute("aria-label",n),t.classList.remove("message-action--confirmed")},1500)}var zv=500;function yr(t,e=[],n){for(let r of Zv(e)){if(!t.contains(r.startContainer)||!t.contains(r.endContainer))continue;let o=document.createRange();o.setStart(r.startContainer,r.startOffset),o.setEnd(r.endContainer,r.endOffset);let i=Vv(o).trim();if(i!=="")return{text:i,rect:Kv(o,n)}}return null}function $a(t){let e=Gv(t);return e.length===0?"":`${Bv(e.join(`
|
|
13
|
+
`)).split(`
|
|
14
|
+
`).map(o=>`> ${o}`.trimEnd()).join(`
|
|
15
|
+
`)}
|
|
16
|
+
|
|
17
|
+
`}function Gv(t){let e=t.split(/\r\n?|\n/).map(i=>i.trimEnd()),n=e.filter(i=>i!=="").map($v),r=n.length===0?0:Math.min(...n),o=[];for(let i of e){let s=i.slice(r);s===""&&(o.length===0||o[o.length-1]==="")||o.push(s)}for(;o[o.length-1]==="";)o.pop();return o}function $v(t){return t.length-t.trimStart().length}function Bv(t){return t.length>500?`${t.slice(0,500).trimEnd()}...`:t}function Vv(t){let e="";for(let n of Xv(t)){let r=n.parentElement;if(!Yv(r))continue;let o=n===t.startContainer?t.startOffset:0,i=n===t.endContainer?t.endOffset:n.data.length;e+=jv(n.data.slice(o,i),r)}return e}function jv(t,e){return qv.has(Wv(e))?t:t.replace(/[^\S\n]*\n[^\S\n]*/g,`
|
|
18
|
+
`).replace(/[^\S\n]+/g," ")}var qv=new Set(["pre","pre-wrap","break-spaces"]);function Wv(t){return window.getComputedStyle(t).whiteSpace}function Xv(t){let e=t.commonAncestorContainer;if(e.nodeType===Node.TEXT_NODE)return[e];let n=[],r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let o=r.nextNode();o!==null;o=r.nextNode())t.intersectsNode(o)&&n.push(o);return n}function Yv(t){return typeof t.checkVisibility!="function"?!0:t.checkVisibility({contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0})}function Kv(t,e){let n=[...t.getClientRects()];if(n.length===0)return t.getBoundingClientRect();if(e===void 0)return n[0];let r=n[0],o=fu(r,e);for(let i of n.slice(1)){let s=fu(i,e);s<o&&(o=s,r=i)}return r}function fu(t,e){let n=Math.max(t.left-e.x,0,e.x-t.right),r=Math.max(t.top-e.y,0,e.y-t.bottom);return Math.hypot(n,r)}function Zv(t){let e=window.getSelection();if(e===null)return[];let n=[...Qv(e,t)];return e.rangeCount>0&&n.push(e.getRangeAt(0)),n}function Qv(t,e){let n=t.getComposedRanges;if(n===void 0)return[];try{return n.call(t,{shadowRoots:e})}catch{return n.call(t,...e)}}var Ba=6,Jv=`
|
|
19
|
+
.ag-ui-quote-offer {
|
|
20
|
+
position: fixed;
|
|
21
|
+
z-index: 2147483000;
|
|
22
|
+
transform: translate(-50%, -100%);
|
|
23
|
+
margin: 0;
|
|
24
|
+
padding: 0.25em 0.7em;
|
|
25
|
+
border: 1px solid rgb(0 0 0 / 0.15);
|
|
26
|
+
border-radius: 999px;
|
|
27
|
+
background: Canvas;
|
|
28
|
+
color: CanvasText;
|
|
29
|
+
font: inherit;
|
|
30
|
+
font-size: 0.8rem;
|
|
31
|
+
line-height: 1.6;
|
|
32
|
+
white-space: nowrap;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
box-shadow: 0 2px 10px rgb(0 0 0 / 0.18);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ag-ui-quote-offer[data-below="true"] {
|
|
38
|
+
transform: translate(-50%, 0);
|
|
39
|
+
}
|
|
40
|
+
`;function Va(t){let{within:e,exclude:n,onQuote:r}=t,o=new CSSStyleSheet;o.replaceSync(Jv),document.adoptedStyleSheets=[...document.adoptedStyleSheets,o];let i=document.createElement("button");i.type="button",i.className="ag-ui-quote-offer",i.textContent=t.label,i.hidden=!0,document.body.append(i);let s="",a=()=>{i.hidden=!0,s=""},l=u=>{if(u.composedPath().includes(n)){a();return}if(eb()){a();return}let m=u instanceof MouseEvent?{x:u.clientX,y:u.clientY}:void 0,y=yr(e,[],m);if(y===null){a();return}s=y.text,tb(i,y.rect)},c=u=>{i.contains(u.target)||a()};return e.addEventListener("mouseup",l),e.addEventListener("keyup",l),e.addEventListener("mousedown",c),document.addEventListener("scroll",a,!0),window.addEventListener("resize",a),i.addEventListener("mousedown",u=>{u.preventDefault()}),i.addEventListener("click",()=>{let u=s;window.getSelection()?.removeAllRanges(),a(),r(u)}),{element:i,detach(){e.removeEventListener("mouseup",l),e.removeEventListener("keyup",l),e.removeEventListener("mousedown",c),document.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a),i.remove(),document.adoptedStyleSheets=document.adoptedStyleSheets.filter(u=>u!==o)}}}function eb(){let t=document.activeElement;return t===null?!1:t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable===!0}function tb(t,e){t.hidden=!1;let n=e.top<Ba+t.offsetHeight;t.dataset.below=String(n),t.style.top=`${n?e.bottom+Ba:e.top-Ba}px`;let r=t.offsetWidth/2,o=e.left+e.width/2,i=document.documentElement.clientWidth;t.style.left=`${Math.min(Math.max(o,r),i-r)}px`}function ja(t){let e=t.replace(/[._-]+/g," ").trim();return e===""?t:e.charAt(0).toUpperCase()+e.slice(1)}function nb(t){let e=document.createElement("input");return e.type="text",e.className="question-input",e.setAttribute("part","question-input"),e.placeholder=t,e}function qa(t,e,n={}){let r=n.strings??ee,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 u=document.createElement("div");u.className="question-options",u.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 ie=document.createElement("input");ie.type="radio",ie.name=m,ie.value=U,ie.setAttribute("part","question-radio");let We=document.createElement("span");We.setAttribute("part","question-choice-text"),We.textContent=U,Y.append(ie,We),u.appendChild(Y),y.push(ie)}let f=null,h=null;if(s){if(h=nb(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),u.appendChild(U),h.disabled=!0}u.appendChild(h)}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,_=()=>{let U=y.find(Y=>Y.checked);if(U!==void 0)return U.value;if(h!==null&&(f===null||f.checked)){let Y=h.value.trim();return Y===""?null:Y}return null},I=()=>{h!==null&&f!==null&&(h.disabled=!f.checked),x.disabled=_()===null},H=U=>{if(!S){S=!0,x.disabled=!0;for(let Y of y)Y.disabled=!0;f!==null&&(f.disabled=!0),h!==null&&(h.disabled=!0),l.setAttribute("data-resolved",U===""?"cancelled":"answered"),a(U)}};for(let U of[...y,...f!==null?[f]:[]])U.addEventListener("change",I);if(h?.addEventListener("input",I),h?.addEventListener("keydown",U=>{if(U.key==="Enter"){U.preventDefault();let Y=_();Y!==null&&H(Y)}}),x.addEventListener("click",()=>{let U=_();U!==null&&H(U)}),n.signal?.addEventListener("abort",()=>H(""),{once:!0}),l.append(c,u,g),t.appendChild(l),n.signal?.aborted===!0){H("");return}I(),(i?y[0]:h)?.focus()})}function mu(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 rb(t){if(Array.isArray(t))return t}function ob(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(u){c=!0,o=u}finally{try{if(!l&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw o}}return a}}function ib(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
41
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sb(t,e){return rb(t)||ob(t,e)||ab(t,e)||ib()}function ab(t,e){if(t){if(typeof t=="string")return mu(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)?mu(t,e):void 0}}var Ru=Object.entries,gu=Object.setPrototypeOf,lb=Object.isFrozen,cb=Object.getPrototypeOf,db=Object.getOwnPropertyDescriptor,Te=Object.freeze,Se=Object.seal,zn=Object.create,Nu=typeof Reflect<"u"&&Reflect,Qa=Nu.apply,Ja=Nu.construct;Te||(Te=function(e){return e});Se||(Se=function(e){return e});Qa||(Qa=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)});Ja||(Ja=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 Hn=me(Array.prototype.forEach),ub=me(Array.prototype.lastIndexOf),vu=me(Array.prototype.pop),Fn=me(Array.prototype.push),pb=me(Array.prototype.splice),Rt=Array.isArray,Er=me(String.prototype.toLowerCase),Wa=me(String.prototype.toString),bu=me(String.prototype.match),xr=me(String.prototype.replace),yu=me(String.prototype.indexOf),hb=me(String.prototype.trim),fb=me(Number.prototype.toString),mb=me(Boolean.prototype.toString),xu=typeof BigInt>"u"?null:me(BigInt.prototype.toString),wu=typeof Symbol>"u"?null:me(Symbol.prototype.toString),ye=me(Object.prototype.hasOwnProperty),wr=me(Object.prototype.toString),be=me(RegExp.prototype.test),an=gb(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 Qa(t,e,r)}}function gb(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Ja(t,n)}}function W(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Er;if(gu&&gu(t,null),!Rt(e))return t;let r=e.length;for(;r--;){let o=e[r];if(typeof o=="string"){let i=n(o);i!==o&&(lb(e)||(e[r]=i),o=i)}t[o]=!0}return t}function vb(t){for(let e=0;e<t.length;e++)ye(t,e)||(t[e]=null);return t}function ke(t){let e=zn(null);for(let r of Ru(t)){var n=sb(r,2);let o=n[0],i=n[1];ye(t,o)&&(Rt(i)?e[o]=vb(i):i&&typeof i=="object"&&i.constructor===Object?e[o]=ke(i):e[o]=i)}return e}function bb(t){switch(typeof t){case"string":return t;case"number":return fb(t);case"boolean":return mb(t);case"bigint":return xu?xu(t):"0";case"symbol":return wu?wu(t):"Symbol()";case"undefined":return wr(t);case"function":case"object":{if(t===null)return wr(t);let e=t,n=Ze(e,"toString");if(typeof n=="function"){let r=n(e);return typeof r=="string"?r:wr(r)}return wr(t)}default:return wr(t)}}function Ze(t,e){for(;t!==null;){let r=db(t,e);if(r){if(r.get)return me(r.get);if(typeof r.value=="function")return me(r.value)}t=cb(t)}function n(){return null}return n}function yb(t){try{return be(t,""),!0}catch{return!1}}var Eu=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"]),Xa=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"]),Ya=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"]),xb=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"]),Ka=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"]),wb=Te(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),_u=Te(["#text"]),Tu=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"]),Za=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"]),Su=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"]),Mi=Te(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Eb=Se(/{{[\w\W]*|^[\w\W]*}}/g),_b=Se(/<%[\w\W]*|^[\w\W]*%>/g),Tb=Se(/\${[\w\W]*/g),Sb=Se(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ab=Se(/^aria-[\-\w]+$/),Au=Se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),kb=Se(/^(?:\w+script|data):/i),Cb=Se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ib=Se(/^html$/i),Rb=Se(/^[a-z][.\w]*(-[.\w]+)+$/i),ku=Se(/<[/\w!]/g),Cu=Se(/<[/\w]/g),Nb=Se(/<\/no(script|embed|frames)/i),Ob=Se(/\/>/i),Fe={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Mb=function(){return typeof window>"u"?null:window},Lb=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}},Iu=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},It=function(e,n,r,o){return ye(e,n)&&Rt(e[n])?W(o.base?ke(o.base):{},e[n],o.transform):r};function Ou(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Mb(),e=T=>Ou(T);if(e.version="3.4.13",e.removed=[],!t||!t.document||t.document.nodeType!==Fe.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 u=t.DOMParser,m=t.trustedTypes,y=a.prototype,f=Ze(y,"cloneNode"),h=Ze(y,"remove"),g=Ze(y,"nextSibling"),x=Ze(y,"childNodes"),S=Ze(y,"parentNode"),_=Ze(y,"shadowRoot"),I=Ze(y,"attributes"),H=s&&s.prototype?Ze(s.prototype,"nodeType"):null,U=s&&s.prototype?Ze(s.prototype,"nodeName"):null,Y=s&&s.prototype?Ze(s.prototype,"ownerDocument"):null;if(typeof i=="function"){let T=n.createElement("template");T.content&&T.content.ownerDocument&&(n=T.content.ownerDocument)}let ie,We="",Zi,Tl=!1,jn=0,Sl=function(){if(jn>0)throw an('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.')},un=function(p){Sl(),jn++;try{return ie.createHTML(p)}finally{jn--}},yp=function(p){Sl(),jn++;try{return ie.createScriptURL(p)}finally{jn--}},xp=function(){return Tl||(Zi=Lb(m,o),Tl=!0),Zi},Lr=n,Qi=Lr.implementation,Al=Lr.createNodeIterator,wp=Lr.createDocumentFragment,Ep=Lr.getElementsByTagName,_p=r.importNode,se=Iu();e.isSupported=typeof Ru=="function"&&typeof S=="function"&&Qi&&Qi.createHTMLDocument!==void 0;let Tp=Eb,Sp=_b,Ap=Tb,kp=Sb,Cp=Ab,Ip=kb,kl=Cb,Rp=Rb,Cl=Au,ae=null,Ji=W({},[...Eu,...Xa,...Ya,...Ka,..._u]),le=null,es=W({},[...Tu,...Za,...Su,...Mi]),pe=Object.seal(zn(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}})),qn=null,Il=null,yt=Object.seal(zn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Rl=!0,ts=!0,Nl=!1,Ol=!0,xt=!1,wt=!0,Ot=!1,ns=!1,Pr=null,Dr=null,rs=!1,pn=!1,Ur=!1,Hr=!1,Ml=!0,Ll=!1,Pl="user-content-",os=!0,Fr=!1,hn={},tt=null,is=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"]),Dl=null,Ul=W({},["audio","video","img","source","image","track"]),ss=null,Hl=W({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),zr="http://www.w3.org/1998/Math/MathML",Gr="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml",fn=nt,as=!1,ls=null,Np=W({},[zr,Gr,nt],Wa),Fl=Te(["mi","mo","mn","ms","mtext"]),cs=W({},Fl),zl=Te(["annotation-xml"]),ds=W({},zl),Op=W({},["title","style","font","a","script"]),Wn=null,Mp=["application/xhtml+xml","text/html"],Lp="text/html",ce=null,mn=null,Pp=n.createElement("form"),Gl=function(p){return p instanceof RegExp||p instanceof Function},us=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(mn&&mn===p)return;(!p||typeof p!="object")&&(p={}),p=ke(p),Wn=Mp.indexOf(p.PARSER_MEDIA_TYPE)===-1?Lp:p.PARSER_MEDIA_TYPE,ce=Wn==="application/xhtml+xml"?Wa:Er,ae=It(p,"ALLOWED_TAGS",Ji,{transform:ce}),le=It(p,"ALLOWED_ATTR",es,{transform:ce}),ls=It(p,"ALLOWED_NAMESPACES",Np,{transform:Wa}),ss=It(p,"ADD_URI_SAFE_ATTR",Hl,{transform:ce,base:Hl}),Dl=It(p,"ADD_DATA_URI_TAGS",Ul,{transform:ce,base:Ul}),tt=It(p,"FORBID_CONTENTS",is,{transform:ce}),qn=It(p,"FORBID_TAGS",ke({}),{transform:ce}),Il=It(p,"FORBID_ATTR",ke({}),{transform:ce}),hn=ye(p,"USE_PROFILES")?p.USE_PROFILES&&typeof p.USE_PROFILES=="object"?ke(p.USE_PROFILES):p.USE_PROFILES:!1,Rl=p.ALLOW_ARIA_ATTR!==!1,ts=p.ALLOW_DATA_ATTR!==!1,Nl=p.ALLOW_UNKNOWN_PROTOCOLS||!1,Ol=p.ALLOW_SELF_CLOSE_IN_ATTR!==!1,xt=p.SAFE_FOR_TEMPLATES||!1,wt=p.SAFE_FOR_XML!==!1,Ot=p.WHOLE_DOCUMENT||!1,pn=p.RETURN_DOM||!1,Ur=p.RETURN_DOM_FRAGMENT||!1,Hr=p.RETURN_TRUSTED_TYPE||!1,rs=p.FORCE_BODY||!1,Ml=p.SANITIZE_DOM!==!1,Ll=p.SANITIZE_NAMED_PROPS||!1,os=p.KEEP_CONTENT!==!1,Fr=p.IN_PLACE||!1,Cl=yb(p.ALLOWED_URI_REGEXP)?p.ALLOWED_URI_REGEXP:Au,fn=typeof p.NAMESPACE=="string"?p.NAMESPACE:nt,cs=ye(p,"MATHML_TEXT_INTEGRATION_POINTS")&&p.MATHML_TEXT_INTEGRATION_POINTS&&typeof p.MATHML_TEXT_INTEGRATION_POINTS=="object"?ke(p.MATHML_TEXT_INTEGRATION_POINTS):W({},Fl),ds=ye(p,"HTML_INTEGRATION_POINTS")&&p.HTML_INTEGRATION_POINTS&&typeof p.HTML_INTEGRATION_POINTS=="object"?ke(p.HTML_INTEGRATION_POINTS):W({},zl);let b=ye(p,"CUSTOM_ELEMENT_HANDLING")&&p.CUSTOM_ELEMENT_HANDLING&&typeof p.CUSTOM_ELEMENT_HANDLING=="object"?ke(p.CUSTOM_ELEMENT_HANDLING):zn(null);if(pe=zn(null),ye(b,"tagNameCheck")&&Gl(b.tagNameCheck)&&(pe.tagNameCheck=b.tagNameCheck),ye(b,"attributeNameCheck")&&Gl(b.attributeNameCheck)&&(pe.attributeNameCheck=b.attributeNameCheck),ye(b,"allowCustomizedBuiltInElements")&&typeof b.allowCustomizedBuiltInElements=="boolean"&&(pe.allowCustomizedBuiltInElements=b.allowCustomizedBuiltInElements),Se(pe),xt&&(ts=!1),Ur&&(pn=!0),hn&&(ae=W({},_u),le=zn(null),hn.html===!0&&(W(ae,Eu),W(le,Tu)),hn.svg===!0&&(W(ae,Xa),W(le,Za),W(le,Mi)),hn.svgFilters===!0&&(W(ae,Ya),W(le,Za),W(le,Mi)),hn.mathMl===!0&&(W(ae,Ka),W(le,Su),W(le,Mi))),yt.tagCheck=null,yt.attributeCheck=null,ye(p,"ADD_TAGS")&&(typeof p.ADD_TAGS=="function"?yt.tagCheck=p.ADD_TAGS:Rt(p.ADD_TAGS)&&(ae===Ji&&(ae=ke(ae)),W(ae,p.ADD_TAGS,ce))),ye(p,"ADD_ATTR")&&(typeof p.ADD_ATTR=="function"?yt.attributeCheck=p.ADD_ATTR:Rt(p.ADD_ATTR)&&(le===es&&(le=ke(le)),W(le,p.ADD_ATTR,ce))),ye(p,"ADD_URI_SAFE_ATTR")&&Rt(p.ADD_URI_SAFE_ATTR)&&W(ss,p.ADD_URI_SAFE_ATTR,ce),ye(p,"FORBID_CONTENTS")&&Rt(p.FORBID_CONTENTS)&&(tt===is&&(tt=ke(tt)),W(tt,p.FORBID_CONTENTS,ce)),ye(p,"ADD_FORBID_CONTENTS")&&Rt(p.ADD_FORBID_CONTENTS)&&(tt===is&&(tt=ke(tt)),W(tt,p.ADD_FORBID_CONTENTS,ce)),os&&(ae["#text"]=!0),Ot&&W(ae,["html","head","body"]),ae.table&&(W(ae,["tbody"]),delete qn.tbody),p.TRUSTED_TYPES_POLICY){if(typeof p.TRUSTED_TYPES_POLICY.createHTML!="function")throw an('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof p.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw an('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');let w=ie;ie=p.TRUSTED_TYPES_POLICY;try{We=un("")}catch(N){throw ie=w,N}}else p.TRUSTED_TYPES_POLICY===null?(ie=void 0,We=""):(ie===void 0&&(ie=xp()),ie&&typeof We=="string"&&(We=un("")));Te&&Te(p),mn=p},$l=W({},[...Xa,...Ya,...xb]),Bl=W({},[...Ka,...wb]),Dp=function(p,b,w){return b.namespaceURI===nt?p==="svg":b.namespaceURI===zr?p==="svg"&&(w==="annotation-xml"||cs[w]):!!$l[p]},Up=function(p,b,w){return b.namespaceURI===nt?p==="math":b.namespaceURI===Gr?p==="math"&&ds[w]:!!Bl[p]},Hp=function(p,b,w){return b.namespaceURI===Gr&&!ds[w]||b.namespaceURI===zr&&!cs[w]?!1:!Bl[p]&&(Op[p]||!$l[p])},Fp=function(p){let b=S(p);(!b||!b.tagName)&&(b={namespaceURI:fn,tagName:"template"});let w=Er(p.tagName),N=Er(b.tagName);return ls[p.namespaceURI]?p.namespaceURI===Gr?Dp(w,b,N):p.namespaceURI===zr?Up(w,b,N):p.namespaceURI===nt?Hp(w,b,N):!!(Wn==="application/xhtml+xml"&&ls[p.namespaceURI]):!1},Et=function(p){Fn(e.removed,{element:p});try{S(p).removeChild(p)}catch{if(h(p),!S(p))throw an("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},$r=function(p){Xn(p);let b=x(p);if(b){let N=[];Hn(b,L=>{Fn(N,L)}),Hn(N,L=>{try{h(L)}catch{}})}let w=I(p);if(w)for(let N=w.length-1;N>=0;--N){let L=w[N],F=L&&L.name;if(typeof F=="string")try{p.removeAttribute(F)}catch{}}},Mt=function(p,b){try{Fn(e.removed,{attribute:b.getAttributeNode(p),from:b})}catch{Fn(e.removed,{attribute:null,from:b})}if(b.removeAttribute(p),p==="is")if(pn||Ur)try{Et(b)}catch{}else try{b.setAttribute(p,"")}catch{}},zp=function(p){let b=I(p);if(b)for(let w=b.length-1;w>=0;--w){let N=b[w],L=N&&N.name;if(!(typeof L!="string"||le[ce(L)]))try{p.removeAttribute(L)}catch{}}},Xn=function(p){let b=[p];for(;b.length>0;){let w=b.pop();(H?H(w):w.nodeType)===Fe.element&&zp(w);let L=x(w);if(L)for(let F=L.length-1;F>=0;--F)b.push(L[F])}},Gp=function(p){if(!wt)return;let b=[p];for(;b.length>0;){let w=b.pop(),N=H?H(w):w.nodeType;if(N===Fe.processingInstruction||N===Fe.comment&&be(Cu,w.data)){try{h(w)}catch{}continue}if(N===Fe.element){let F=w,Z=ce(U?U(w):w.nodeName);try{F.hasAttribute&&F.hasAttribute("patchsrc")&&F.removeAttribute("patchsrc"),F.hasAttribute&&F.hasAttribute("for")&&Z!=="label"&&Z!=="output"&&F.removeAttribute("for")}catch{}}let L=x(w);if(L)for(let F=L.length-1;F>=0;--F)b.push(L[F])}},Vl=function(p){let b=null,w=null;if(rs)p="<remove></remove>"+p;else{let F=bu(p,/^[\r\n\t ]+/);w=F&&F[0]}Wn==="application/xhtml+xml"&&fn===nt&&(p='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+p+"</body></html>");let N=ie?un(p):p;if(fn===nt)try{b=new u().parseFromString(N,Wn)}catch{}if(!b||!b.documentElement){b=Qi.createDocument(fn,"template",null);try{b.documentElement.innerHTML=as?We:N}catch{}}let L=b.body||b.documentElement;return p&&w&&L.insertBefore(n.createTextNode(w),L.childNodes[0]||null),fn===nt?Ep.call(b,Ot?"html":"body")[0]:Ot?b.documentElement:L},jl=function(p){let b=Y?Y(p):p.ownerDocument;return Al.call(b||p,p,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Br=function(p){return p=xr(p,Tp," "),p=xr(p,Sp," "),p=xr(p,Ap," "),p},ps=function(p){var b;p.normalize();let w=Y?Y(p):p.ownerDocument,N=Al.call(w||p,p,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null),L=N.nextNode();for(;L;)L.data=Br(L.data),L=N.nextNode();let F=(b=p.querySelectorAll)===null||b===void 0?void 0:b.call(p,"template");F&&Hn(F,Z=>{gn(Z.content)&&ps(Z.content)})},Vr=function(p){let b=U?U(p):null;return typeof b!="string"||ce(b)!=="form"?!1:typeof p.nodeName!="string"||typeof p.textContent!="string"||typeof p.removeChild!="function"||p.attributes!==I(p)||typeof p.removeAttribute!="function"||typeof p.setAttribute!="function"||typeof p.namespaceURI!="string"||typeof p.insertBefore!="function"||typeof p.hasChildNodes!="function"||p.nodeType!==H(p)||p.childNodes!==x(p)},gn=function(p){if(!H||typeof p!="object"||p===null)return!1;try{return H(p)===Fe.documentFragment}catch{return!1}},Yn=function(p){if(!H||typeof p!="object"||p===null)return!1;try{return typeof H(p)=="number"}catch{return!1}};function rt(T,p,b){T.length!==0&&Hn(T,w=>{w.call(e,p,b,mn)})}let $p=function(p,b){return!!(wt&&p.hasChildNodes()&&!Yn(p.firstElementChild)&&be(ku,p.textContent)&&be(ku,p.innerHTML)||wt&&p.namespaceURI===nt&&b==="style"&&Yn(p.firstElementChild)||p.nodeType===Fe.processingInstruction||wt&&p.nodeType===Fe.comment&&be(Cu,p.data))},Bp=function(p,b,w){if(!qn[b]&&Yl(b)&&(pe.tagNameCheck instanceof RegExp&&be(pe.tagNameCheck,b)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(b)))return!1;if(os&&!tt[b]){let N=S(p),L=x(p);if(L&&N){let F=L.length;for(let Z=F-1;Z>=0;--Z){let de=p===w?f(L[Z],!0):L[Z];N.insertBefore(de,g(p))}}}return Et(p),!0},ql=function(p,b,w,N){return p.length===0?b:b===w||b===N?ke(b):b},Wl=function(p,b){if(rt(se.beforeSanitizeElements,p,null),p!==b&&S(p)===null)return Fr&&Xn(p),!0;if(Vr(p))return Et(p),!0;let w=ce(U?U(p):p.nodeName);if(ae=ql(se.uponSanitizeElement,ae,Ji,Pr),rt(se.uponSanitizeElement,p,{tagName:w,allowedTags:ae}),p!==b&&S(p)===null)return Fr&&Xn(p),!0;if($p(p,w))return Et(p),!0;if(qn[w]||!(yt.tagCheck instanceof Function&&yt.tagCheck(w))&&!ae[w]){let L=Bp(p,w,b);return L===!1&&rt(se.afterSanitizeElements,p,null),L}if((H?H(p):p.nodeType)===Fe.element&&!Fp(p)||(w==="noscript"||w==="noembed"||w==="noframes")&&be(Nb,p.innerHTML))return Et(p),!0;if(xt&&p.nodeType===Fe.text){let L=Br(p.textContent);p.textContent!==L&&(Fn(e.removed,{element:p.cloneNode()}),p.textContent=L)}return rt(se.afterSanitizeElements,p,null),!1},Xl=function(p,b,w){if(Il[b]||wt&&b==="patchsrc"||wt&&b==="for"&&p!=="label"&&p!=="output"||Ml&&(b==="id"||b==="name")&&(w in n||w in Pp))return!1;let N=le[b]||yt.attributeCheck instanceof Function&&yt.attributeCheck(b,p);if(!(ts&&be(kp,b))){if(!(Rl&&be(Cp,b))){if(N){if(!ss[b]){if(!be(Cl,xr(w,kl,""))){if(!((b==="src"||b==="xlink:href"||b==="href")&&p!=="script"&&yu(w,"data:")===0&&Dl[p])){if(!(Nl&&!be(Ip,xr(w,kl,"")))){if(w)return!1}}}}}else if(!(Yl(p)&&(pe.tagNameCheck instanceof RegExp&&be(pe.tagNameCheck,p)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(p))&&(pe.attributeNameCheck instanceof RegExp&&be(pe.attributeNameCheck,b)||pe.attributeNameCheck instanceof Function&&pe.attributeNameCheck(b,p))||b==="is"&&pe.allowCustomizedBuiltInElements&&(pe.tagNameCheck instanceof RegExp&&be(pe.tagNameCheck,w)||pe.tagNameCheck instanceof Function&&pe.tagNameCheck(w))))return!1}}return!0},Vp=W({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Yl=function(p){return!Vp[Er(p)]&&be(Rp,p)},jp=function(p,b,w,N){if(ie&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!w)switch(m.getAttributeType(p,b)){case"TrustedHTML":return un(N);case"TrustedScriptURL":return yp(N)}return N},qp=function(p,b,w,N){try{w?p.setAttributeNS(w,b,N):p.setAttribute(b,N),Vr(p)?Et(p):vu(e.removed)}catch{Mt(b,p)}},Kl=function(p){rt(se.beforeSanitizeAttributes,p,null);let b=p.attributes;if(!b||Vr(p))return;le=ql(se.uponSanitizeAttribute,le,es,Dr);let w={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:le,forceKeepAttr:void 0},N=b.length,L=ce(p.nodeName);for(;N--;){let F=b[N],Z=F.name,de=F.namespaceURI,Re=F.value,Ne=ce(Z),fs=Re,Ie=Z==="value"?fs:hb(fs);if(w.attrName=Ne,w.attrValue=Ie,w.keepAttr=!0,w.forceKeepAttr=void 0,rt(se.uponSanitizeAttribute,p,w),Ie=w.attrValue,Ll&&(Ne==="id"||Ne==="name")&&yu(Ie,Pl)!==0&&(Mt(Z,p),Ie=Pl+Ie),wt&&be(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Ie)){Mt(Z,p);continue}if(Ne==="attributename"&&bu(Ie,"href")){Mt(Z,p);continue}if(!w.forceKeepAttr){if(!w.keepAttr){Mt(Z,p);continue}if(!Ol&&be(Ob,Ie)){Mt(Z,p);continue}if(xt&&(Ie=Br(Ie)),!Xl(L,Ne,Ie)){Mt(Z,p);continue}Ie=jp(L,Ne,de,Ie),Ie!==fs&&qp(p,Z,de,Ie)}}rt(se.afterSanitizeAttributes,p,null)},jr=function(p){let b=null,w=jl(p);for(rt(se.beforeSanitizeShadowDOM,p,null);b=w.nextNode();)if(rt(se.uponSanitizeShadowNode,b,null),Wl(b,p),Kl(b),gn(b.content)&&jr(b.content),(H?H(b):b.nodeType)===Fe.element){let L=_(b);gn(L)&&(hs(L),jr(L))}rt(se.afterSanitizeShadowDOM,p,null)},hs=function(p){let b=[{node:p,shadow:null}];for(;b.length>0;){let w=b.pop();if(w.shadow){jr(w.shadow);continue}let N=w.node,F=(H?H(N):N.nodeType)===Fe.element,Z=x(N);if(Z)for(let de=Z.length-1;de>=0;--de)b.push({node:Z[de],shadow:null});if(F){let de=U?U(N):null;if(typeof de=="string"&&ce(de)==="template"){let Re=N.content;gn(Re)&&b.push({node:Re,shadow:null})}}if(F){let de=_(N);gn(de)&&b.push({node:null,shadow:de},{node:de,shadow:null})}}};return e.sanitize=function(T){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},b=null,w=null,N=null,L=null;if(as=!T,as&&(T="<!-->"),typeof T!="string"&&!Yn(T)&&(T=bb(T),typeof T!="string"))throw an("dirty is not a string, aborting");if(!e.isSupported)return T;ns?(ae=Pr,le=Dr):us(p),(se.uponSanitizeElement.length>0||se.uponSanitizeAttribute.length>0)&&(ae=ke(ae)),se.uponSanitizeAttribute.length>0&&(le=ke(le)),e.removed=[];let F=Fr&&typeof T!="string"&&Yn(T);if(F){Gp(T);let Re=U?U(T):T.nodeName;if(typeof Re=="string"){let Ne=ce(Re);if(!ae[Ne]||qn[Ne])throw $r(T),an("root node is forbidden and cannot be sanitized in-place")}if(Vr(T))throw $r(T),an("root node is clobbered and cannot be sanitized in-place");try{hs(T)}catch(Ne){throw $r(T),Ne}}else if(Yn(T))b=Vl("<!---->"),w=b.ownerDocument.importNode(T,!0),w.nodeType===Fe.element&&w.nodeName==="BODY"||w.nodeName==="HTML"?b=w:b.appendChild(w),hs(w);else{if(!pn&&!xt&&!Ot&&T.indexOf("<")===-1)return ie&&Hr?un(T):T;if(b=Vl(T),!b)return pn?null:Hr?We:""}b&&rs&&Et(b.firstChild);let Z=F?T:b;try{let Re=jl(Z);for(;N=Re.nextNode();)Wl(N,Z),Kl(N),gn(N.content)&&jr(N.content)}catch(Re){throw F&&($r(T),Hn(e.removed,Ne=>{Ne.element&&Xn(Ne.element)})),Re}if(F)return Hn(e.removed,Re=>{Re.element&&Xn(Re.element)}),xt&&ps(T),T;if(pn){if(xt&&ps(b),Ur)for(L=wp.call(b.ownerDocument);b.firstChild;)L.appendChild(b.firstChild);else L=b;return(le.shadowroot||le.shadowrootmode)&&(L=_p.call(r,L,!0)),L}let de=Ot?b.outerHTML:b.innerHTML;return Ot&&ae["!doctype"]&&b.ownerDocument&&b.ownerDocument.doctype&&b.ownerDocument.doctype.name&&be(Ib,b.ownerDocument.doctype.name)&&(de="<!DOCTYPE "+b.ownerDocument.doctype.name+`>
|
|
42
|
+
`+de),xt&&(de=Br(de)),ie&&Hr?un(de):de},e.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};us(T),ns=!0,Pr=ae,Dr=le},e.clearConfig=function(){mn=null,ns=!1,Pr=null,Dr=null,ie=Zi,We=""},e.isValidAttribute=function(T,p,b){mn||us({});let w=ce(T),N=ce(p);return Xl(w,N,b)},e.addHook=function(T,p){typeof p=="function"&&ye(se,T)&&Fn(se[T],p)},e.removeHook=function(T,p){if(ye(se,T)){if(p!==void 0){let b=ub(se[T],p);return b===-1?void 0:pb(se[T],b,1)[0]}return vu(se[T])}},e.removeHooks=function(T){ye(se,T)&&(se[T]=[])},e.removeAllHooks=function(){se=Iu()},e}var Mu=Ou();function rl(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var dn=rl();function Gu(t){dn=t}var ln={exec:()=>null};function Gn(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(Ce.caret,"$1"),n=n.replace(o,s),r},getRegex:()=>new RegExp(n,e)};return r}var Pb=((t="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+t)}catch{return!1}})(),Ce={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:Gn(t=>new RegExp(`^ {0,${t}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Gn(t=>new RegExp(`^ {0,${t}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Gn(t=>new RegExp(`^ {0,${t}}(?:\`\`\`|~~~)`)),headingBeginRegex:Gn(t=>new RegExp(`^ {0,${t}}#`)),htmlBeginRegex:Gn(t=>new RegExp(`^ {0,${t}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:Gn(t=>new RegExp(`^ {0,${t}}>`))},Db=/^(?:[ \t]*(?:\n|$))+/,Ub=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Hb=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Sr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Fb=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ol=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,$u=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Bu=j($u).replace(/bull/g,ol).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(),zb=j($u).replace(/bull/g,ol).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(),il=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Gb=/^[^\n]+/,sl=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,$b=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",sl).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Bb=j(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,ol).getRegex(),Hi="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",al=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Vb=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",al).replace("tag",Hi).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Vu=t=>j(il).replace("hr",Sr).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",Hi).getRegex(),jb=Vu(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),qb=Vu(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Wb=j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",qb).getRegex(),ll={blockquote:Wb,code:Ub,def:$b,fences:Hb,heading:Fb,hr:Sr,html:Vb,lheading:Bu,list:Bb,newline:Db,paragraph:jb,table:ln,text:Gb},Lu=j("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Sr).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",Hi).getRegex(),Xb={...ll,lheading:zb,table:Lu,paragraph:j(il).replace("hr",Sr).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Lu).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",Hi).getRegex()},Yb={...ll,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",al).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:ln,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(il).replace("hr",Sr).replace("heading",` *#{1,6} *[^
|
|
43
|
+
]`).replace("lheading",Bu).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Kb=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Zb=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ju=/^( {2,}|\\)\n(?!\s*$)/,Qb=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,bt=/[\p{P}\p{S}]/u,$n=/[\s\p{P}\p{S}]/u,Ar=/[^\s\p{P}\p{S}]/u,Jb=j(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,$n).getRegex(),ey=/[\p{Pi}\p{Ps}"']/u,qu=/(?!~)[\p{P}\p{S}]/u,ty=/(?!~)[\s\p{P}\p{S}]/u,ny=/(?:[^\s\p{P}\p{S}]|~)/u,ry=j(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Pb?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Wu=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,oy=j(Wu,"u").replace(/punct/g,bt).getRegex(),iy=j(Wu,"u").replace(/punct/g,qu).getRegex(),sy=/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,ay=j(sy,"u").replace(/openQuote/g,ey).replace(/punct/g,bt).getRegex(),Xu="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",ly=j(Xu,"gu").replace(/notPunctSpace/g,Ar).replace(/punctSpace/g,$n).replace(/punct/g,bt).getRegex(),cy=j(Xu,"gu").replace(/notPunctSpace/g,ny).replace(/punctSpace/g,ty).replace(/punct/g,qu).getRegex(),dy="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)",uy=j(dy,"gu").replace(/notPunctSpace/g,Ar).replace(/punctSpace/g,$n).replace(/punct/g,bt).getRegex(),py=j("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ar).replace(/punctSpace/g,$n).replace(/punct/g,bt).getRegex(),hy="^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)",fy=j(hy,"gu").replace(/notPunctSpace/g,Ar).replace(/punctSpace/g,$n).replace(/punct/g,bt).getRegex(),my=j(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,bt).getRegex(),gy="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",vy=j(gy,"gu").replace(/notPunctSpace/g,Ar).replace(/punctSpace/g,$n).replace(/punct/g,bt).getRegex(),by=j(/\\(punct)/,"gu").replace(/punct/g,bt).getRegex(),yy=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(),xy=j(al).replace("(?:-->|$)","-->").getRegex(),wy=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",xy).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Pi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Ey=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Pi).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Yu=j(/^!?\[(label)\]\[(ref)\]/).replace("label",Pi).replace("ref",sl).getRegex(),Ku=j(/^!?\[(ref)\](?:\[\])?/).replace("ref",sl).getRegex(),_y=j("reflink|nolink(?!\\()","g").replace("reflink",Yu).replace("nolink",Ku).getRegex(),Pu=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,cl={_backpedal:ln,anyPunctuation:by,autolink:yy,blockSkip:ry,br:ju,code:Zb,del:ln,delLDelim:ln,delRDelim:ln,emStrongLDelim:oy,emStrongRDelimAst:ly,emStrongRDelimUnd:py,escape:Kb,link:Ey,nolink:Ku,punctuation:Jb,reflink:Yu,reflinkSearch:_y,tag:wy,text:Qb,url:ln},Ty={...cl,emStrongLDelim:ay,emStrongRDelimAst:uy,emStrongRDelimUnd:fy,link:j(/^!?\[(label)\]\((.*?)\)/).replace("label",Pi).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Pi).getRegex()},el={...cl,emStrongRDelimAst:cy,emStrongLDelim:iy,delLDelim:my,delRDelim:vy,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Pu).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",Pu).getRegex()},Sy={...el,br:j(ju).replace("{2,}","*").getRegex(),text:j(el.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Li={normal:ll,gfm:Xb,pedantic:Yb},_r={normal:cl,gfm:el,breaks:Sy,pedantic:Ty},Ay={"&":"&","<":"<",">":">",'"':""","'":"'"},Du=t=>Ay[t];function ut(t,e){if(e){if(Ce.escapeTest.test(t))return t.replace(Ce.escapeReplace,Du)}else if(Ce.escapeTestNoEncode.test(t))return t.replace(Ce.escapeReplaceNoEncode,Du);return t}function Uu(t){try{t=encodeURI(t).replace(Ce.percentDecode,"%")}catch{return null}return t}function Hu(t,e){let n=t.replace(Ce.findPipe,(i,s,a)=>{let l=!1,c=s;for(;--c>=0&&a[c]==="\\";)l=!l;return l?"|":" |"}),r=n.split(Ce.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(Ce.slashPipe,"|");return r}function Nt(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 Fu(t){let e=t.split(`
|
|
15
44
|
`),n=e.length-1;for(;n>=0&&Ce.blankLine.test(e[n]);)n--;return e.length-n<=2?t:e.slice(0,n+1).join(`
|
|
16
|
-
`)}function
|
|
17
|
-
`).map(
|
|
18
|
-
`)}var
|
|
45
|
+
`)}function ky(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 Cy(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 zu(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 Iy(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let o=r[1];return e.split(`
|
|
46
|
+
`).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(`
|
|
47
|
+
`)}var Di=class{options;rules;lexer;constructor(t){this.options=t||dn}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]:Fu(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=Iy(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=Nt(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:Nt(e[0],`
|
|
19
48
|
`),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:Nt(e[0],`
|
|
20
49
|
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=Nt(e[0],`
|
|
21
50
|
`).split(`
|
|
22
|
-
`),r="",
|
|
23
|
-
`),
|
|
51
|
+
`),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(`
|
|
52
|
+
`),u=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
24
53
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
25
|
-
${c}`:c,
|
|
26
|
-
${
|
|
54
|
+
${c}`:c,o=o?`${o}
|
|
55
|
+
${u}`:u;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,i,!0),this.lexer.state.top=m,n.length===0)break;let y=i.at(-1);if(y?.type==="code")break;if(y?.type==="blockquote"){let f=y,h=n.join(`
|
|
27
56
|
`),g=f.raw+`
|
|
28
|
-
`+h.replace(this.rules.other.blockquoteSetextReplace2,""),x=this.blockquote(g);
|
|
29
|
-
${h}`,
|
|
57
|
+
`+h.replace(this.rules.other.blockquoteSetextReplace2,""),x=this.blockquote(g);i[i.length-1]=x,r=`${r}
|
|
58
|
+
${h}`,o=o.substring(0,o.length-f.text.length)+x.text;break}else if(y?.type==="list"){let f=y,h=f.raw+`
|
|
30
59
|
`+n.join(`
|
|
31
|
-
`),g=this.list(h);
|
|
32
|
-
`);continue}}return{type:"blockquote",raw:r,tokens:
|
|
60
|
+
`),g=this.list(h);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=h.substring(i.at(-1).raw.length).split(`
|
|
61
|
+
`);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="",u="";if(!(e=i.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let m=Cy(e[2].split(`
|
|
33
62
|
`,1)[0],e[1].length),y=t.split(`
|
|
34
|
-
`,1)[0],f=!m.trim(),h=0;if(this.options.pedantic?(h=2,
|
|
35
|
-
`,t=t.substring(y.length+1),l=!0),!l){let g=this.rules.other.nextBulletRegex(h),x=this.rules.other.hrRegex(h),S=this.rules.other.fencesBeginRegex(h),
|
|
36
|
-
`,1)[0],
|
|
37
|
-
`+
|
|
63
|
+
`,1)[0],f=!m.trim(),h=0;if(this.options.pedantic?(h=2,u=m.trimStart()):f?h=e[1].length+1:(h=m.search(this.rules.other.nonSpaceChar),h=h>4?1:h,u=m.slice(h),h+=e[1].length),f&&this.rules.other.blankLine.test(y)&&(c+=y+`
|
|
64
|
+
`,t=t.substring(y.length+1),l=!0),!l){let g=this.rules.other.nextBulletRegex(h),x=this.rules.other.hrRegex(h),S=this.rules.other.fencesBeginRegex(h),_=this.rules.other.headingBeginRegex(h),I=this.rules.other.htmlBeginRegex(h),H=this.rules.other.blockquoteBeginRegex(h);for(;t;){let U=t.split(`
|
|
65
|
+
`,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)||_.test(y)||I.test(y)||H.test(y)||g.test(y)||x.test(y))break;if(Y.search(this.rules.other.nonSpaceChar)>=h||!y.trim())u+=`
|
|
66
|
+
`+Y.slice(h);else{if(f||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||S.test(m)||_.test(m)||x.test(m))break;u+=`
|
|
38
67
|
`+y}f=!y.trim(),c+=U+`
|
|
39
|
-
`,t=t.substring(U.length+1),m=
|
|
40
|
-
`),href:r,title:
|
|
41
|
-
`):[],
|
|
42
|
-
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let s of r)this.rules.other.tableAlignRight.test(s)?
|
|
68
|
+
`,t=t.substring(U.length+1),m=Y.slice(h)}}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(u),loose:!1,text:u,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 u=this.rules.other.listTaskCheckbox.exec(l.raw);if(u){let m={type:"checkbox",raw:u[0]+" ",checked:u[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 u=l.tokens.filter(y=>y.type==="space"),m=u.length>0&&u.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=Fu(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:Nt(e[0],`
|
|
69
|
+
`),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=Hu(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),o=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
70
|
+
`):[],i={type:"table",raw:Nt(e[0],`
|
|
71
|
+
`),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(Hu(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:Nt(e[0],`
|
|
43
72
|
`),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
|
|
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(Ce.tabCharGlobal," ").replace(Ce.spaceLine,""));let
|
|
46
|
-
`:n.push(
|
|
73
|
+
`?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=Nt(n.slice(0,-1),"\\");if((n.length-i.length)%2===0)return}else{let i=ky(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)),zu(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 zu(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],u=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(u)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 h=f.slice(2,-2);return{type:"strong",raw:f,text:h,tokens:this.lexer.inlineTokens(h)}}}}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,u=t.slice(0,o+r.index+c+s),m=u.slice(o,-o);return{type:"del",raw:u,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}}}},Qe=class tl{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||dn,this.options.tokenizer=this.options.tokenizer||new Di,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:Ce,block:Li.normal,inline:_r.normal};this.options.pedantic?(n.block=Li.pedantic,n.inline=_r.pedantic):this.options.gfm&&(n.block=Li.gfm,this.options.breaks?n.inline=_r.breaks:n.inline=_r.gfm),this.tokenizer.rules=n}static get rules(){return{block:Li,inline:_r}}static lex(e,n){return new tl(n).lex(e)}static lexInline(e,n){return new tl(n).inlineTokens(e)}lex(e){e=e.replace(Ce.carriageReturn,`
|
|
74
|
+
`),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(Ce.tabCharGlobal," ").replace(Ce.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+=`
|
|
75
|
+
`: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
76
|
`)?"":`
|
|
48
|
-
`)+
|
|
49
|
-
`+
|
|
77
|
+
`)+i.raw,a.text+=`
|
|
78
|
+
`+i.text,this.inlineQueue.at(-1).src=a.text):n.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let a=n.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
|
|
50
79
|
`)?"":`
|
|
51
|
-
`)+
|
|
52
|
-
`+
|
|
80
|
+
`)+i.raw,a.text+=`
|
|
81
|
+
`+i.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),n.push(i);continue}let s=e;if(this.options.extensions?.startBlock){let a=1/0,l=e.slice(1),c;this.options.extensions.startBlock.forEach(u=>{c=u.call({lexer:this},l),typeof c=="number"&&c>=0&&(a=Math.min(a,c))}),a<1/0&&a>=0&&(s=e.substring(0,a+1))}if(this.state.top&&(i=this.tokenizer.paragraph(s))){let a=n.at(-1);r&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
|
|
53
82
|
`)?"":`
|
|
54
|
-
`)+
|
|
55
|
-
`+
|
|
83
|
+
`)+i.raw,a.text+=`
|
|
84
|
+
`+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
85
|
`)?"":`
|
|
57
|
-
`)+
|
|
58
|
-
`+
|
|
59
|
-
`;return r?'<pre><code class="language-'+ut(r)+'">'+(n?
|
|
60
|
-
`:"<pre><code>"+(n?
|
|
86
|
+
`)+i.raw,a.text+=`
|
|
87
|
+
`+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 u=c?c.length:0;return a.slice(0,u)+"["+"a".repeat(a.length-u-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,u=e.slice(1),m;this.options.extensions.startInline.forEach(y=>{m=y.call({lexer:this},u),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)}},Ui=class{options;parser;constructor(t){this.options=t||dn}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(Ce.notSpaceStart)?.[0],o=t.replace(Ce.endingNewline,"")+`
|
|
88
|
+
`;return r?'<pre><code class="language-'+ut(r)+'">'+(n?o:ut(o,!0))+`</code></pre>
|
|
89
|
+
`:"<pre><code>"+(n?o:ut(o,!0))+`</code></pre>
|
|
61
90
|
`}blockquote({tokens:t}){return`<blockquote>
|
|
62
91
|
${this.parser.parse(t)}</blockquote>
|
|
63
92
|
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
64
93
|
`}hr(t){return`<hr>
|
|
65
|
-
`}list(t){let e=t.ordered,n=t.start,r="";for(let s=0;s<t.items.length;s++){let a=t.items[s];r+=this.listitem(a)}let
|
|
66
|
-
`+r+"</"+
|
|
94
|
+
`}list(t){let e=t.ordered,n=t.start,r="";for(let s=0;s<t.items.length;s++){let a=t.items[s];r+=this.listitem(a)}let o=e?"ol":"ul",i=e&&n!==1?' start="'+n+'"':"";return"<"+o+i+`>
|
|
95
|
+
`+r+"</"+o+`>
|
|
67
96
|
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
68
97
|
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
69
|
-
`}table(t){let e="",n="";for(let
|
|
98
|
+
`}table(t){let e="",n="";for(let o=0;o<t.header.length;o++)n+=this.tablecell(t.header[o]);e+=this.tablerow({text:n});let r="";for(let o=0;o<t.rows.length;o++){let i=t.rows[o];n="";for(let s=0;s<i.length;s++)n+=this.tablecell(i[s]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
70
99
|
<thead>
|
|
71
100
|
`+e+`</thead>
|
|
72
101
|
`+r+`</table>
|
|
73
102
|
`}tablerow({text:t}){return`<tr>
|
|
74
103
|
${t}</tr>
|
|
75
104
|
`}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>${ut(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),
|
|
77
|
-
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+ut(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},cn=new
|
|
105
|
+
`}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>${ut(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=Uu(t);if(o===null)return r;t=o;let i='<a href="'+t+'"';return e&&(i+=' title="'+ut(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=Uu(t);if(o===null)return ut(n);t=o;let i=`<img src="${t}" alt="${ut(n)}"`;return e&&(i+=` title="${ut(e)}"`),i+=">",i}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:ut(t.text)}},dl=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}},Je=class nl{options;renderer;textRenderer;constructor(e){this.options=e||dn,this.options.renderer=this.options.renderer||new Ui,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new dl}static parse(e,n){return new nl(n).parse(e)}static parseInline(e,n){return new nl(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}},Tr=class{options;block;constructor(t){this.options=t||dn}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?Qe.lex:Qe.lexInline}provideParser(t=this.block){return t?Je.parse:Je.parseInline}},ul=class{defaults=rl();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Je;Renderer=Ui;TextRenderer=dl;Lexer=Qe;Tokenizer=Di;Hooks=Tr;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 Ui(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 u=a.apply(o,c);return u===!1&&(u=l.apply(o,c)),u||""}}r.renderer=o}if(n.tokenizer){let o=this.defaults.tokenizer||new Di(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 u=a.apply(o,c);return u===!1&&(u=l.apply(o,c)),u}}r.tokenizer=o}if(n.hooks){let o=this.defaults.hooks||new Tr;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];Tr.passThroughHooks.has(i)?o[s]=c=>{if(this.defaults.async&&Tr.passThroughHooksRespectAsync.has(i))return(async()=>{let m=await a.call(o,c);return l.call(o,m)})();let u=a.call(o,c);return l.call(o,u)}: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 u=a.apply(o,c);return u===!1&&(u=l.apply(o,c)),u}}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 Qe.lex(t,e??this.defaults)}parser(t,e){return Je.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?Qe.lex:Qe.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?Je.parse:Je.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?Qe.lex:Qe.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?Je.parse:Je.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+=`
|
|
106
|
+
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+ut(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},cn=new ul;function Q(t,e){return cn.parse(t,e)}Q.options=Q.setOptions=function(t){return cn.setOptions(t),Q.defaults=cn.defaults,Gu(Q.defaults),Q};Q.getDefaults=rl;Q.defaults=dn;function Ry(...t){return cn.use(...t),Q.defaults=cn.defaults,Gu(Q.defaults),Q}Q.use=Ry;Q.walkTokens=function(t,e){return cn.walkTokens(t,e)};Q.parseInline=cn.parseInline;Q.Parser=Je;Q.parser=Je.parse;Q.Renderer=Ui;Q.TextRenderer=dl;Q.Lexer=Qe;Q.lexer=Qe.lex;Q.Tokenizer=Di;Q.Hooks=Tr;Q.parse=Q;var X0=Q.options,Y0=Q.setOptions,K0=Q.walkTokens,Z0=Q.parseInline;var Q0=Je.parse,J0=Qe.lex;var Ny=new ul({gfm:!0,breaks:!0}),Zu=["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"],Qu=["href","title","class","target","rel"],Ju={ALLOWED_TAGS:Zu,ALLOWED_ATTR:Qu,ALLOW_DATA_ATTR:!1,ALLOW_ARIA_ATTR:!1},Oy={...Ju,ALLOWED_TAGS:[...Zu,"img"],ALLOWED_ATTR:[...Qu,"src","alt","width","height"]},My=/^language-[A-Za-z0-9_+#.-]+$/,Ly=new Set(["CODE","PRE"]);function Py(t){t.nodeName==="A"&&t.hasAttribute("href")?(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer")):(t.removeAttribute("target"),t.removeAttribute("rel"));let e=t.getAttribute("class");if(e===null)return;let n=Ly.has(t.nodeName)?e.split(/\s+/).filter(r=>My.test(r)):[];if(n.length===0){t.removeAttribute("class");return}t.setAttribute("class",n.join(" "))}var Fi=null;function Dy(){return Fi===null&&(Fi=Mu(),Fi.addHook("afterSanitizeAttributes",Py)),Fi}function zi(t,e){let n=e?.allowImages===!0,r=Ny.parse(t,{async:!1});return Dy().sanitize(r,n?Oy:Ju).trim()}function ep(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=(i,s,a,l,c)=>{let u=s.x==="right"?a.right-l:l-a.left,m={width:Math.max(280,u)};if(i!=="both")return m;let y=s.y==="bottom"?a.bottom-c:c-a.top;return{...m,height:Math.max(240,y)}};e.addEventListener("pointerdown",i=>{let s=t.axis();if(s==="none")return;let a=t.anchor(),l=t.rect(),c=m=>{t.apply(n(s,a,l,m.clientX,m.clientY))},u=m=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),e.removeAttribute("data-dragging"),t.commit(n(s,a,l,m.clientX,m.clientY))};e.setAttribute("data-dragging","true"),window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),i.preventDefault()});let r=null,o=()=>{if(r===null)return;let i=r;r=null,t.commit(i)};return e.addEventListener("keydown",i=>{let s=t.axis();if(s==="none")return;let a=t.anchor(),l=t.rect(),c=i.shiftKey?64:16,u=a.x==="right"?-1:1,m=l.right-l.left,y=l.bottom-l.top,f=null;if(i.key==="ArrowLeft")f={width:Math.max(280,m-c*u)};else if(i.key==="ArrowRight")f={width:Math.max(280,m+c*u)};else if(s==="both"&&(i.key==="ArrowUp"||i.key==="ArrowDown")){let h=i.key===(a.y==="bottom"?"ArrowUp":"ArrowDown");f={height:Math.max(240,y+(h?c:-c))}}f!==null&&(i.preventDefault(),t.apply(f),r=f)}),e.addEventListener("keyup",o),e.addEventListener("blur",o),e}function tp(t,e){for(let n of Array.from(t.childNodes))n.nodeType===Node.TEXT_NODE?e.push({node:n,parent:t}):tp(n,e)}function np(t){let e=[];tp(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 pl(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 Gi=class{chips;palette;#t;#n=[];#e=!1;#s=!1;#r=[];#i=0;constructor(e){this.#t=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.#n=e,this.#d()}enableChips(e){this.#e=e,this.#d()}enableSlash(e){this.#s=e}isOpen(){return!this.palette.hidden}onInput(e){this.#s&&e.startsWith("/")?this.#o(e.slice(1)):this.close()}onKeydown(e){return this.isOpen()?e.key==="ArrowDown"?(this.#u(1),!0):e.key==="ArrowUp"?(this.#u(-1),!0):e.key==="Escape"?(this.close(),!0):e.key==="Enter"?(this.#r.slice(this.#i,this.#i+1).forEach(n=>{this.#c(n)}),!0):!1:!1}close(){this.palette.hidden=!0,this.palette.replaceChildren()}#o(e){let n=e.trim().toLowerCase(),r=this.#n.filter(o=>o.name.toLowerCase().includes(n)||o.title.toLowerCase().includes(n));if(r.length===0){this.close();return}this.#r=r,this.#i=0,this.#a(),this.palette.hidden=!1}#u(e){let n=this.#r.length;this.#i=(this.#i+e+n)%n,this.#a()}#c(e){this.close(),this.#t(e)}#d(){this.chips.replaceChildren();let e=this.#e?this.#n.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.#c(n)),this.chips.appendChild(r)}}#a(){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.#i?"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.#c(e)),this.palette.appendChild(r)})}};function rp({viewport:t,onMissedContent:e}){let n=!0,r=!1,o=()=>t.scrollHeight-t.scrollTop-t.clientHeight<=4,i=u=>{u!==r&&(r=u,e(r))},s=()=>{t.scrollTop=t.scrollHeight},a=()=>{n=o(),n&&i(!1)},l=()=>{if(n){s();return}i(!0)};t.addEventListener("scroll",a,{passive:!0});let c=new ResizeObserver(()=>{n&&s()});return c.observe(t),{follow:l,jump:()=>{n=!0,i(!1),s()},following:()=>n,dispose:()=>{t.removeEventListener("scroll",a),c.disconnect()}}}var op=`
|
|
78
107
|
/* \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
108
|
Every public --ag-ui-* token is read here into a private --_* alias, and
|
|
80
109
|
only the alias is used by the rules below.
|
|
@@ -643,6 +672,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
643
672
|
opacity: 0;
|
|
644
673
|
}
|
|
645
674
|
|
|
675
|
+
:host([collapsed]:is([placement="embedded"], [placement="page"])) .messages-wrap,
|
|
646
676
|
:host([collapsed]:is([placement="embedded"], [placement="page"])) .messages,
|
|
647
677
|
:host([collapsed]:is([placement="embedded"], [placement="page"])) .input-row,
|
|
648
678
|
:host([collapsed]:is([placement="embedded"], [placement="page"])) .skill-chips,
|
|
@@ -651,9 +681,113 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
651
681
|
display: none;
|
|
652
682
|
}
|
|
653
683
|
|
|
684
|
+
/* Jump-to-latest: shown only once the reader has scrolled away *and* missed
|
|
685
|
+
something. Anchored to the panel rather than the list so it does not scroll
|
|
686
|
+
with the content it is offering to scroll to. */
|
|
687
|
+
/* The transcript's own box, and the only one whose foot is the transcript's
|
|
688
|
+
foot. The panel's foot is below the composer, the chips and the footer. */
|
|
689
|
+
.messages-wrap {
|
|
690
|
+
position: relative;
|
|
691
|
+
flex: 1;
|
|
692
|
+
min-height: 0;
|
|
693
|
+
display: flex;
|
|
694
|
+
flex-direction: column;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
.jump-latest {
|
|
698
|
+
position: absolute;
|
|
699
|
+
left: 50%;
|
|
700
|
+
transform: translateX(-50%);
|
|
701
|
+
bottom: var(--_pad);
|
|
702
|
+
z-index: 2;
|
|
703
|
+
display: none;
|
|
704
|
+
align-items: center;
|
|
705
|
+
gap: 0.35em;
|
|
706
|
+
padding: 0.4em 0.9em;
|
|
707
|
+
border: 1px solid var(--_border);
|
|
708
|
+
border-radius: 999px;
|
|
709
|
+
/* A raised surface, not the panel's own background. Reusing --_bg made the
|
|
710
|
+
pill the same colour as everything behind it, leaving a 1px border and a
|
|
711
|
+
shadow to carry the whole affordance -- and a dark-on-dark shadow carries
|
|
712
|
+
nothing. --_hover is the token that already means "lifted off the panel",
|
|
713
|
+
and it separates in both themes without competing with the accent the send
|
|
714
|
+
button owns. */
|
|
715
|
+
background: var(--_hover);
|
|
716
|
+
color: var(--_text);
|
|
717
|
+
font: inherit;
|
|
718
|
+
font-size: 0.85em;
|
|
719
|
+
cursor: pointer;
|
|
720
|
+
box-shadow: 0 2px 10px rgb(0 0 0 / 0.18);
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
.jump-latest[data-missed="true"] {
|
|
724
|
+
display: flex;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
.jump-latest:hover {
|
|
728
|
+
border-color: var(--_accent);
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/* The offer to quote a selection. Positioned in script against the transcript
|
|
732
|
+
box, which is the only ancestor whose top and foot are the transcript's --
|
|
733
|
+
the same reason .jump-latest lives here. The translate is the half the
|
|
734
|
+
script does not do: script sets the point the offer hangs from, CSS decides
|
|
735
|
+
which corner of the offer that point is. */
|
|
736
|
+
.quote-selection {
|
|
737
|
+
position: absolute;
|
|
738
|
+
z-index: 2;
|
|
739
|
+
transform: translate(-50%, -100%);
|
|
740
|
+
padding: 0.25em 0.7em;
|
|
741
|
+
border: 1px solid var(--_border);
|
|
742
|
+
border-radius: 999px;
|
|
743
|
+
background: var(--_hover);
|
|
744
|
+
color: var(--_text);
|
|
745
|
+
font: inherit;
|
|
746
|
+
font-size: 0.8em;
|
|
747
|
+
line-height: 1.6;
|
|
748
|
+
white-space: nowrap;
|
|
749
|
+
cursor: pointer;
|
|
750
|
+
box-shadow: 0 2px 10px rgb(0 0 0 / 0.18);
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/* Flipped under the selection when there was no room above it. Only the
|
|
754
|
+
vertical half of the translate changes: it still hangs from its own centre
|
|
755
|
+
horizontally. */
|
|
756
|
+
.quote-selection[data-below="true"] {
|
|
757
|
+
transform: translate(-50%, 0);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
.quote-selection:hover {
|
|
761
|
+
border-color: var(--_accent);
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/* Screen-reader-only status region. Off-screen rather than display:none or
|
|
765
|
+
visibility:hidden, both of which take the element out of the accessibility
|
|
766
|
+
tree entirely -- a hidden live region announces nothing at all, which is the
|
|
767
|
+
classic way this pattern is written wrong.
|
|
768
|
+
|
|
769
|
+
The 1px box with clip-path, rather than width/height 0, is the shape that
|
|
770
|
+
survives: a zero-sized element is dropped from the tree by some engines. */
|
|
771
|
+
.sr-only {
|
|
772
|
+
position: absolute;
|
|
773
|
+
width: 1px;
|
|
774
|
+
height: 1px;
|
|
775
|
+
margin: -1px;
|
|
776
|
+
padding: 0;
|
|
777
|
+
border: 0;
|
|
778
|
+
overflow: hidden;
|
|
779
|
+
white-space: nowrap;
|
|
780
|
+
clip-path: inset(50%);
|
|
781
|
+
}
|
|
782
|
+
|
|
654
783
|
.messages {
|
|
655
784
|
flex: 1;
|
|
656
785
|
overflow-y: auto;
|
|
786
|
+
/* The browser's own scroll anchoring competes with the scroller for the same
|
|
787
|
+
job and wins unpredictably -- it can hold the view still exactly when we
|
|
788
|
+
want to follow. Turned off so following is decided in one place. Safari
|
|
789
|
+
does not implement it, which is itself a reason not to depend on it. */
|
|
790
|
+
overflow-anchor: none;
|
|
657
791
|
padding: var(--_pad);
|
|
658
792
|
display: flex;
|
|
659
793
|
flex-direction: column;
|
|
@@ -1162,6 +1296,21 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1162
1296
|
color: var(--_fg);
|
|
1163
1297
|
}
|
|
1164
1298
|
|
|
1299
|
+
/* A region a host formatter took over, marked by the card. Preformatted
|
|
1300
|
+
whitespace is what makes the built-in block read as written, and it is the one
|
|
1301
|
+
thing a host cannot want: a table inherits it as mangled cell spacing, and a
|
|
1302
|
+
sentence as line breaks nobody typed.
|
|
1303
|
+
|
|
1304
|
+
Whitespace only. The card's own face, frame, padding and scroll cap stay,
|
|
1305
|
+
because the card is one visual object -- the head row and the status pill are
|
|
1306
|
+
monospaced too -- and a region that dropped the family would be the only part
|
|
1307
|
+
of it wearing a different one. A host that wants that restyles the
|
|
1308
|
+
tool-card-result part, which does not need the formatter at all. */
|
|
1309
|
+
.tool-call-args[data-formatted],
|
|
1310
|
+
.tool-call-result[data-formatted] {
|
|
1311
|
+
white-space: normal;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1165
1314
|
/* Display modes are pure visibility over one DOM shape, selected from the host
|
|
1166
1315
|
attribute rather than a value stamped on the card at build time, so flipping
|
|
1167
1316
|
data-tool-display re-styles cards already on screen. See ToolCallCard.
|
|
@@ -1226,6 +1375,174 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1226
1375
|
display: flex;
|
|
1227
1376
|
}
|
|
1228
1377
|
|
|
1378
|
+
/* A delegated sub-agent's progress, inside the card that delegated. Empty on
|
|
1379
|
+
every card that delegated nothing, so it collapses rather than adding a gap
|
|
1380
|
+
to each one -- the same shape the approval slot uses. */
|
|
1381
|
+
.tool-call-subagent:empty {
|
|
1382
|
+
display: none;
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
.tool-call-subagent {
|
|
1386
|
+
display: flex;
|
|
1387
|
+
flex-direction: column;
|
|
1388
|
+
gap: 4px;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
.subagent {
|
|
1392
|
+
display: flex;
|
|
1393
|
+
flex-direction: column;
|
|
1394
|
+
gap: 4px;
|
|
1395
|
+
min-width: 0;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
/* The collapsed row is the status and the expander at once, which is what keeps
|
|
1399
|
+
a ten-step child one row until somebody opens it. Full width and left-aligned,
|
|
1400
|
+
because it is a line of the card rather than a button on it. */
|
|
1401
|
+
.subagent-row {
|
|
1402
|
+
display: flex;
|
|
1403
|
+
align-items: center;
|
|
1404
|
+
gap: 6px;
|
|
1405
|
+
width: 100%;
|
|
1406
|
+
box-sizing: border-box;
|
|
1407
|
+
padding: 2px 0;
|
|
1408
|
+
border: none;
|
|
1409
|
+
background: none;
|
|
1410
|
+
font: inherit;
|
|
1411
|
+
text-align: left;
|
|
1412
|
+
color: var(--_muted);
|
|
1413
|
+
cursor: pointer;
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
/* Nothing behind the row yet -- a delegation that failed before calling
|
|
1417
|
+
anything. Drop the affordances rather than offer a control that expands onto
|
|
1418
|
+
an empty region, which is the refusal the card's own toggle already makes. */
|
|
1419
|
+
.subagent-row:disabled {
|
|
1420
|
+
cursor: default;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
.subagent-row::after {
|
|
1424
|
+
content: "\u25B8";
|
|
1425
|
+
flex: none;
|
|
1426
|
+
margin-left: auto;
|
|
1427
|
+
color: var(--_accent);
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
.subagent-row[aria-expanded="true"]::after {
|
|
1431
|
+
content: "\u25BE";
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
.subagent-row:disabled::after {
|
|
1435
|
+
display: none;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
/* Empty in the DOM; the glyph is drawn here from the panel's data-phase, so a
|
|
1439
|
+
host re-themes it through the same tool-icon custom properties the card uses. */
|
|
1440
|
+
.subagent-icon {
|
|
1441
|
+
flex: none;
|
|
1442
|
+
box-sizing: border-box;
|
|
1443
|
+
display: inline-flex;
|
|
1444
|
+
align-items: center;
|
|
1445
|
+
justify-content: center;
|
|
1446
|
+
width: 10px;
|
|
1447
|
+
height: 10px;
|
|
1448
|
+
font-size: 10px;
|
|
1449
|
+
line-height: 1;
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
/* Anything that is not a terminal phase is the child still working. Selected by
|
|
1453
|
+
what it is not, so a phase this client has not heard of still spins rather
|
|
1454
|
+
than rendering as a blank. */
|
|
1455
|
+
.subagent[data-phase]:not([data-phase="finished"]):not([data-phase="failed"]) .subagent-icon {
|
|
1456
|
+
border: 2px solid var(--_muted);
|
|
1457
|
+
border-top-color: transparent;
|
|
1458
|
+
border-radius: 50%;
|
|
1459
|
+
animation: ag-ui-tool-spin var(--_tool-spin-duration) linear infinite;
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
.subagent[data-phase="finished"] .subagent-icon::before {
|
|
1463
|
+
content: var(--_tool-icon-done);
|
|
1464
|
+
color: var(--_success);
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
.subagent[data-phase="failed"] .subagent-icon::before {
|
|
1468
|
+
content: var(--_tool-icon-error);
|
|
1469
|
+
color: var(--_danger);
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1473
|
+
.subagent .subagent-icon {
|
|
1474
|
+
animation: none;
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
/* The server's own pre-rendered line. Shrinks and wraps rather than pushing the
|
|
1479
|
+
chevron out of the card, which is what a fixed-width sibling in a flex row
|
|
1480
|
+
does to a panel at sidebar width. */
|
|
1481
|
+
.subagent-status {
|
|
1482
|
+
flex: 1 1 auto;
|
|
1483
|
+
min-width: 0;
|
|
1484
|
+
overflow-wrap: anywhere;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
/* The child's own calls. Indented and ruled, so the nesting is visible without
|
|
1488
|
+
a second card frame around it. */
|
|
1489
|
+
.subagent-steps {
|
|
1490
|
+
display: flex;
|
|
1491
|
+
flex-direction: column;
|
|
1492
|
+
gap: 2px;
|
|
1493
|
+
margin-left: 4px;
|
|
1494
|
+
padding-left: 10px;
|
|
1495
|
+
border-left: 1px solid var(--_border);
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
.subagent-steps[hidden] {
|
|
1499
|
+
display: none;
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
.subagent-step {
|
|
1503
|
+
display: flex;
|
|
1504
|
+
align-items: center;
|
|
1505
|
+
gap: 6px;
|
|
1506
|
+
min-width: 0;
|
|
1507
|
+
color: var(--_muted);
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
.subagent-step-icon {
|
|
1511
|
+
flex: none;
|
|
1512
|
+
box-sizing: border-box;
|
|
1513
|
+
display: inline-flex;
|
|
1514
|
+
align-items: center;
|
|
1515
|
+
justify-content: center;
|
|
1516
|
+
width: 8px;
|
|
1517
|
+
height: 8px;
|
|
1518
|
+
font-size: 9px;
|
|
1519
|
+
line-height: 1;
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
/* No outcome yet: the wire says null while the call is in flight, and the
|
|
1523
|
+
absence of the attribute is how that arrives here. A hollow ring, not a
|
|
1524
|
+
spinner -- several can be on screen at once and the row above already spins. */
|
|
1525
|
+
.subagent-step:not([data-ok]) .subagent-step-icon {
|
|
1526
|
+
border: 1px solid var(--_muted);
|
|
1527
|
+
border-radius: 50%;
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
.subagent-step[data-ok="true"] .subagent-step-icon::before {
|
|
1531
|
+
content: var(--_tool-icon-done);
|
|
1532
|
+
color: var(--_success);
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
.subagent-step[data-ok="false"] .subagent-step-icon::before {
|
|
1536
|
+
content: var(--_tool-icon-error);
|
|
1537
|
+
color: var(--_danger);
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
.subagent-step-name {
|
|
1541
|
+
flex: 1 1 auto;
|
|
1542
|
+
min-width: 0;
|
|
1543
|
+
overflow-wrap: anywhere;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1229
1546
|
.tool-call-toggle {
|
|
1230
1547
|
align-self: flex-start;
|
|
1231
1548
|
border: none;
|
|
@@ -1819,6 +2136,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1819
2136
|
|
|
1820
2137
|
.confirm-actions {
|
|
1821
2138
|
display: flex;
|
|
2139
|
+
flex-wrap: wrap;
|
|
1822
2140
|
gap: 8px;
|
|
1823
2141
|
justify-content: flex-end;
|
|
1824
2142
|
}
|
|
@@ -1845,6 +2163,99 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1845
2163
|
color: #ffffff;
|
|
1846
2164
|
}
|
|
1847
2165
|
|
|
2166
|
+
/* The session waiver. Deliberately the quietest of the three: it is the widest
|
|
2167
|
+
decision on the card, so it should be reachable without being the one the eye
|
|
2168
|
+
lands on when the user means to say yes once. */
|
|
2169
|
+
.confirm-btn--always {
|
|
2170
|
+
font-weight: 500;
|
|
2171
|
+
opacity: 0.85;
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
.confirm-btn--always:hover,
|
|
2175
|
+
.confirm-btn--always:focus-visible {
|
|
2176
|
+
opacity: 1;
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
/* Editable arguments on an approval card. A plain field rather than a code
|
|
2180
|
+
editor: it holds the JSON a card already displays, and the only interaction
|
|
2181
|
+
is correcting a value before letting the call run. */
|
|
2182
|
+
.approval-edit {
|
|
2183
|
+
display: flex;
|
|
2184
|
+
flex-direction: column;
|
|
2185
|
+
gap: 6px;
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
.approval-args {
|
|
2189
|
+
box-sizing: border-box;
|
|
2190
|
+
width: 100%;
|
|
2191
|
+
resize: vertical;
|
|
2192
|
+
border: 1px solid var(--_border);
|
|
2193
|
+
border-radius: 8px;
|
|
2194
|
+
padding: 8px;
|
|
2195
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
2196
|
+
font-size: 0.85em;
|
|
2197
|
+
background: var(--_bg);
|
|
2198
|
+
color: var(--_fg);
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2201
|
+
.approval-args:focus-visible {
|
|
2202
|
+
border-color: var(--_accent);
|
|
2203
|
+
outline: none;
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
.approval-error {
|
|
2207
|
+
font-size: 0.85em;
|
|
2208
|
+
color: var(--_danger);
|
|
2209
|
+
}
|
|
2210
|
+
|
|
2211
|
+
/* Message action row. Sits under a finished assistant bubble.
|
|
2212
|
+
|
|
2213
|
+
The wrap is insurance rather than a fix: these buttons are glyph-only, so at
|
|
2214
|
+
every width tested they fit on one line and removing the wrap changes
|
|
2215
|
+
nothing. It is here because the confirmation row one release earlier did
|
|
2216
|
+
overflow when it gained a third button, off the left edge and outside its own
|
|
2217
|
+
card, and the difference between the two rows is only that this one's labels
|
|
2218
|
+
are icons today. */
|
|
2219
|
+
.message-actions {
|
|
2220
|
+
display: flex;
|
|
2221
|
+
flex-wrap: wrap;
|
|
2222
|
+
gap: 4px;
|
|
2223
|
+
/* Negative, and that is the point. The answer group is a flex column with its
|
|
2224
|
+
own gap, so a positive margin here pushes the row further from the message
|
|
2225
|
+
it acts on than the next card is below it -- the buttons then read as
|
|
2226
|
+
belonging to whatever follows. Pulling back inside the gap is what makes
|
|
2227
|
+
them the message's own. */
|
|
2228
|
+
margin-top: -6px;
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
.message-action {
|
|
2232
|
+
border: none;
|
|
2233
|
+
border-radius: 6px;
|
|
2234
|
+
padding: 2px 6px;
|
|
2235
|
+
font: inherit;
|
|
2236
|
+
line-height: 1.2;
|
|
2237
|
+
cursor: pointer;
|
|
2238
|
+
background: transparent;
|
|
2239
|
+
color: var(--_muted);
|
|
2240
|
+
opacity: 0.75;
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
.message-action:hover,
|
|
2244
|
+
.message-action:focus-visible {
|
|
2245
|
+
opacity: 1;
|
|
2246
|
+
background: var(--_border);
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
.message-action[aria-pressed="true"] {
|
|
2250
|
+
opacity: 1;
|
|
2251
|
+
color: var(--_accent);
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
.message-action--confirmed {
|
|
2255
|
+
opacity: 1;
|
|
2256
|
+
color: var(--_accent);
|
|
2257
|
+
}
|
|
2258
|
+
|
|
1848
2259
|
/* Approval card \u2014 the server-side-tool gate (approve/deny an interrupt). */
|
|
1849
2260
|
.approval {
|
|
1850
2261
|
align-self: stretch;
|
|
@@ -1989,6 +2400,34 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1989
2400
|
border-color: var(--_accent);
|
|
1990
2401
|
}
|
|
1991
2402
|
|
|
2403
|
+
/* Follow-up suggestion chips. Deliberately the skill chips' shape rather than a
|
|
2404
|
+
second chip vocabulary -- both are "a question you could ask", and the only
|
|
2405
|
+
difference is who chose it. Inside the transcript, so they scroll with the
|
|
2406
|
+
answer they follow instead of hovering above the composer. */
|
|
2407
|
+
.suggestions {
|
|
2408
|
+
display: flex;
|
|
2409
|
+
flex-wrap: wrap;
|
|
2410
|
+
gap: 6px;
|
|
2411
|
+
align-self: stretch;
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
.suggestion-chip {
|
|
2415
|
+
border: 1px solid var(--_border);
|
|
2416
|
+
border-radius: 999px;
|
|
2417
|
+
padding: 4px 12px;
|
|
2418
|
+
font: inherit;
|
|
2419
|
+
font-size: 0.9em;
|
|
2420
|
+
text-align: left;
|
|
2421
|
+
cursor: pointer;
|
|
2422
|
+
background: var(--_assistant-bg);
|
|
2423
|
+
color: var(--_fg);
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
.suggestion-chip:hover,
|
|
2427
|
+
.suggestion-chip:focus-visible {
|
|
2428
|
+
border-color: var(--_accent);
|
|
2429
|
+
}
|
|
2430
|
+
|
|
1992
2431
|
.skill-palette {
|
|
1993
2432
|
margin: 8px 12px 0;
|
|
1994
2433
|
display: flex;
|
|
@@ -2401,7 +2840,9 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
2401
2840
|
border-right: none;
|
|
2402
2841
|
box-shadow: none;
|
|
2403
2842
|
}
|
|
2404
|
-
`;var Do=class{element;#t;#r;#e;#o;#n=!1;constructor(e=le){this.#o=e,this.element=document.createElement("div"),this.element.className="thoughts",this.element.setAttribute("part","thoughts"),this.element.setAttribute("data-streaming",""),this.#e=document.createElement("button"),this.#e.type="button",this.#e.className="thoughts-toggle",this.#e.setAttribute("part","thoughts-toggle"),this.#e.setAttribute("aria-expanded","true"),this.#t=document.createElement("span"),this.#t.className="thoughts-label",this.#t.setAttribute("part","thoughts-label"),this.#t.textContent=e.thinking,this.#e.append(this.#t),this.#r=document.createElement("pre"),this.#r.className="thoughts-body",this.#r.setAttribute("part","thoughts-body"),this.#e.addEventListener("click",()=>{this.#i(!this.#n)}),this.element.append(this.#e,this.#r)}stream(e){this.#r.textContent=e}collapse(){this.#n||(this.element.removeAttribute("data-streaming"),this.#t.textContent=this.#o.thoughts,this.#i(!0))}#i(e){this.#n=e,this.#r.hidden=e,this.#e.setAttribute("aria-expanded",String(!e))}};var Uo=class{element;#t;#r;#e;#o;#n;#i;#s=[];#c="";#u=null;constructor(e,n=le){this.#t=e,this.#i=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.#r=document.createElement("div"),this.#r.className="drawer-panel",this.#r.setAttribute("part","drawer-panel"),this.#r.setAttribute("role","dialog"),this.#r.setAttribute("aria-modal","true"),this.#r.setAttribute("aria-label",n.chatHistory),this.#r.addEventListener("keydown",o=>this.#h(o));let i=document.createElement("div");i.className="drawer-header",i.setAttribute("part","drawer-header"),this.#e=document.createElement("span"),this.#e.className="drawer-title",this.#e.setAttribute("part","drawer-title"),this.#e.textContent=n.chats,this.#o=document.createElement("button"),this.#o.type="button",this.#o.className="drawer-new",this.#o.setAttribute("part","drawer-new"),this.#o.textContent=n.newChat,this.#o.addEventListener("click",()=>{this.close(),this.#t.onNew()}),i.append(this.#e,this.#o),this.#n=document.createElement("div"),this.#n.className="drawer-list",this.#n.setAttribute("part","drawer-list"),this.#r.append(i,this.#n),this.element.append(r,this.#r)}setStrings(e){this.#i=e,this.#r.setAttribute("aria-label",e.chatHistory),this.#e.textContent=e.chats,this.#o.textContent=e.newChat,this.#f()}isOpen(){return!this.element.hidden}open(){this.isOpen()||(this.#u=this.#d(),this.element.hidden=!1,this.#o.focus())}close(){this.isOpen()&&(this.element.hidden=!0,this.#u?.focus(),this.#u=null)}toggle(){this.isOpen()?this.close():this.open()}#d(){return this.element.getRootNode().activeElement}#h(e){if(e.key==="Escape"){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;let n=Array.from(this.#r.querySelectorAll("button, input, [tabindex]")).filter(s=>!s.hidden),r=n[0],i=n[n.length-1],o=this.#d();e.shiftKey&&o===r?(e.preventDefault(),i?.focus()):!e.shiftKey&&o===i&&(e.preventDefault(),r?.focus())}setThreads(e,n){this.#s=e,this.#c=n,this.#f()}#f(){if(this.#n.replaceChildren(),this.#s.length===0){let e=document.createElement("div");e.className="drawer-empty",e.setAttribute("part","drawer-empty"),e.textContent=this.#i.noConversations,this.#n.appendChild(e);return}for(let e of this.#s)this.#n.appendChild(this.#p(e))}#p(e){let n=document.createElement("div");n.className="drawer-row",n.setAttribute("part","drawer-row"),e.threadId===this.#c&&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 i=document.createElement("span");i.className="drawer-row-title",i.setAttribute("part","drawer-row-title"),i.textContent=e.title;let o=document.createElement("span");o.className="drawer-row-time",o.setAttribute("part","drawer-row-time"),o.textContent=Ao(e.updatedAt,void 0,this.#i);let s=document.createElement("span");s.className="drawer-row-preview",s.setAttribute("part","drawer-row-preview"),s.textContent=e.preview,r.append(i,o,s),r.addEventListener("click",()=>{this.close(),this.#t.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.#i.rename,a.setAttribute("aria-label",this.#i.renameConversation),a.textContent="\u270E",a.addEventListener("click",()=>this.#a(n,e));let l=document.createElement("button");l.type="button",l.className="drawer-row-delete",l.setAttribute("part","drawer-row-delete"),l.title=this.#i.delete,l.setAttribute("aria-label",this.#i.deleteConversation),l.textContent="\u{1F5D1}",l.addEventListener("click",()=>this.#l(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}#a(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 i=!1,o=()=>{if(i)return;i=!0;let a=r.value.trim();a===""||a===n.title?this.#f():this.#t.onRename(n.threadId,a)},s=()=>{i||(i=!0,this.#f())};r.addEventListener("keydown",a=>{a.key==="Enter"?(a.preventDefault(),o()):a.key==="Escape"&&(a.preventDefault(),a.stopPropagation(),s())}),r.addEventListener("blur",()=>o()),e.replaceChildren(r),r.focus(),r.select()}#l(e,n){let r=document.createElement("div");r.className="drawer-confirm",r.setAttribute("part","drawer-confirm");let i=document.createElement("span");i.className="drawer-confirm-label",i.setAttribute("part","drawer-confirm-label"),i.textContent=this.#i.deletePrompt;let o=document.createElement("button");o.type="button",o.className="drawer-confirm-yes",o.setAttribute("part","drawer-confirm-yes"),o.textContent=this.#i.delete,o.addEventListener("click",()=>this.#t.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.#i.cancel,s.addEventListener("click",()=>this.#f()),r.append(i,o,s),e.replaceChildren(r)}};function Ya(t){return{[ee.PENDING]:t.toolRunning,[ee.DEFERRED]:t.toolDeferred,[ee.DONE]:t.toolDone,[ee.ERROR]:t.toolError,[ee.DECLINED]:t.toolDeclined}}function jb(t){return{[ee.DONE]:t.resultLabel,[ee.ERROR]:t.errorLabel,[ee.DECLINED]:t.declinedLabel}}function qb(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}var Tr=class{element;approvalSlot;#t;#r;#e;#o;#n;#i;#s;#c=!1;constructor(e,n,r,i=le){this.#s=i,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",ee.PENDING),this.element.setAttribute("data-expanded","false");let o=document.createElement("div");o.className="tool-call-head",o.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.#t=document.createElement("span"),this.#t.className="tool-call-status",this.#t.setAttribute("part","tool-card-status"),this.#t.textContent=Ya(i)[ee.PENDING],this.#r=document.createElement("span"),this.#r.className="tool-call-decision",this.#r.setAttribute("part","tool-card-decision"),this.#r.hidden=!0,o.append(s,a,this.#t,this.#r);let l=this.#u("args",i.argumentsLabel);l.body.textContent=JSON.stringify(n,null,2),l.root.hidden=Object.keys(n).length===0;let c=this.#u("result",i.resultLabel);this.#o=c.root,this.#n=c.label,this.#i=c.body,c.root.hidden=!0,this.#e=document.createElement("button"),this.#e.type="button",this.#e.className="tool-call-toggle",this.#e.setAttribute("part","tool-card-toggle"),this.#e.setAttribute("aria-expanded","false"),this.#e.textContent=i.details,this.#e.addEventListener("click",()=>this.#h(!this.#d()));let p=document.createElement("div");p.className="tool-call-body",p.setAttribute("part","tool-card-body"),p.append(l.root,c.root),this.approvalSlot=document.createElement("div"),this.approvalSlot.className="tool-call-approval",this.approvalSlot.setAttribute("part","tool-card-approval"),this.element.append(o,this.#e,p,this.approvalSlot)}mark(e){this.#c||(this.element.setAttribute("data-status",e),this.#t.textContent=Ya(this.#s)[e])}recordDecision(e){this.element.setAttribute("data-decision",e),this.#r.textContent=e==="approved"?this.#s.decisionApproved:this.#s.decisionDeclined,this.#r.hidden=!1}get settled(){return this.#c}settle(e,n){this.#c||(this.#c=!0,this.element.setAttribute("data-status",e),this.#t.textContent=Ya(this.#s)[e],this.#n.textContent=jb(this.#s)[e],this.#i.textContent=qb(n),this.#o.hidden=!1)}#u(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 i=document.createElement("span");i.className="tool-call-section-label",i.setAttribute("part",`tool-card-section-label tool-card-${e}-label`),i.textContent=n;let o=document.createElement("pre");return o.className=`tool-call-${e}`,o.setAttribute("part",`tool-card-${e}`),r.append(i,o),{root:r,label:i,body:o}}#d(){return this.element.getAttribute("data-expanded")==="true"}#h(e){this.element.setAttribute("data-expanded",String(e)),this.#e.setAttribute("aria-expanded",String(e))}};var Lu=12e4,Ho=class{element;#t;#r;#e;#o="idle";#n=null;#i=null;#s=[];#c=null;#u=!1;#d=!1;constructor(e){this.#t=e.transcribe,this.#r=e.onText,this.#e=e.strings??le,this.element=document.createElement("button"),this.element.type="button",this.element.className="voice-btn",this.element.setAttribute("part","voice-button");let n=document.createElement("slot");n.name="icon-voice",n.innerHTML=Pl,this.element.append(n),this.#C("idle"),this.element.addEventListener("click",()=>{this.toggle()})}async toggle(){if(this.#o==="recording"){this.#f();return}this.#o!=="transcribing"&&await this.#h()}async#h(){let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{this.#g(this.#e.transcriptionFailed);return}this.#i=e,this.#s=[],this.#u=!1;let n=new MediaRecorder(e);n.addEventListener("dataavailable",r=>{this.#s.push(r.data)}),n.addEventListener("stop",()=>{this.#a(n.mimeType)}),this.#n=n,n.start(),this.#c=setTimeout(()=>{this.#u=!0,this.#f()},Lu),this.#C("recording")}#f(){this.#p(),this.#n?.stop()}#p(){this.#c!==null&&(clearTimeout(this.#c),this.#c=null)}dispose(){this.#d=!0,this.#p(),this.#n!==null&&this.#n.state!=="inactive"&&this.#n.stop(),this.#n=null,this.#l()}async#a(e){if(this.#d)return;this.#l(),this.#C("transcribing");let n=new Blob(this.#s,{type:e||"audio/webm"});try{let r=await this.#t(n);this.#C("idle"),this.#u&&(this.element.title=this.#e.recordingLimit.replace("{n}",String(Lu/6e4))),r!==""&&this.#r(r)}catch(r){this.#g(r instanceof Error?r.message:this.#e.transcriptionFailed)}finally{this.#n=null}}#l(){for(let e of this.#i?.getTracks()??[])e.stop();this.#i=null}#g(e){this.#l(),this.#n=null,this.#C("idle"),this.element.title=e}#C(e){this.#o=e,this.element.dataset.state=e;let n=this.#T(e);this.element.title=n,this.element.setAttribute("aria-label",n),this.element.setAttribute("aria-pressed",String(e==="recording")),this.element.disabled=e==="transcribing"}#T(e){return e==="recording"?this.#e.stopRecording:e==="transcribing"?this.#e.transcribing:this.#e.recordVoice}};var zo=class extends Error{constructor(e){super(e),this.name="ConnectionLostError"}},Fn=class{#t;#r;#e;#o;#n;#i;#s;#c=new Set;#u;#d=!1;constructor(e){this.#t=e.agent,this.#r=e.handlers,this.#e=e.getTools??(()=>[]),this.#o=e.getContext??(()=>[]),this.#n=e.executeTool??null,this.#i=e.resolveInterrupts??null,this.#s=e.onPersist??(()=>{}),this.#u=e.connectionLostMessage??"Connection lost";let n=e.onStateChanged;n!==void 0&&this.#t.subscribe({onStateChanged:({state:r})=>{n(r)}})}get state(){return this.#t.state}setState(e){this.#t.setState({...e})}get running(){return this.#t.isRunning}get messages(){return this.#t.messages}async send(e,n=[]){let r={id:Ee(),role:"user",content:e};n.length>0&&(r.attachments=n),this.#t.addMessage(r),this.#s(this.#t.messages),await this.#h()}async resume(){await this.#h()}addToolResult(e,n){this.#t.addMessage({id:Ee(),role:"tool",content:n,toolCallId:e}),this.#s(this.#t.messages)}cancel(){this.#d=!0,this.#t.abortRun()}async#h(){this.#d=!1;try{await this.#p(),this.#d&&this.#f()}catch(e){this.#d||Wb(e)?this.#f():this.#r.onError(e instanceof Error?e.message:String(e))}finally{this.#r.onSettled()}}#f(){this.#s(this.#t.messages),this.#r.onCancelled()}async#p(){let e;for(let n=0;n<gs;n+=1){if(this.#d)return;let r=[],i={terminal:!1,errored:!1,interrupts:[]},o={tools:this.#e(),context:this.#o()};if(e!==void 0&&(o.resume=e),await this.#t.runAgent(o,this.#a(r,i)),e=void 0,this.#s(this.#t.messages),this.#d)return;if(!i.terminal)throw new zo(this.#u);if(i.errored)return;if(i.interrupts.length>0){if(this.#i===null)return;let a=await this.#i(i.interrupts);if(this.#d)return;e=Nd(i.interrupts,a);continue}if(this.#n===null||r.length===0)return;let s=!1;for(let a of r){let l=await this.#n(a);if(l!==null){if(l.halt===!0)return;this.#t.addMessage({id:Ee(),role:"tool",content:l.content,toolCallId:a.id}),this.#s(this.#t.messages),s=!0}}if(!s)return}}#a(e,n){let r=this.#r,i=this.#c,o=()=>this.#d,s=new Set;return{onRunInitialized(){r.onRunStart()},onTextMessageStartEvent({event:a}){i.has(a.messageId)&&console.warn(`<ag-ui-chat>: the server reused message id "${a.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:a}){r.onTextDelta(a)},onTextMessageEndEvent({event:a,textMessageBuffer:l}){i.add(a.messageId),r.onTextEnd(l)},onToolCallEndEvent({event:a,toolCallName:l,toolCallArgs:c}){let p={id:a.toolCallId,name:l,args:c};e.push(p),r.onToolCall(p)},onToolCallResultEvent({event:a}){r.onToolResult(a.toolCallId,a.content)},onActivitySnapshotEvent({event:a,messages:l}){if(l.some(p=>p.id===a.messageId&&p.role==="activity")){r.onActivityChanged(a.messageId,a.activityType,a.content);return}r.onActivity(a.activityType,a.content,a.messageId)},onActivityDeltaEvent({event:a}){s.add(a.messageId)},onMessagesChanged({messages:a}){if(s.size!==0){for(let l of s){let c=a.find(p=>p.id===l);c!==void 0&&c.role==="activity"&&r.onActivityChanged(l,c.activityType,c.content)}s.clear()}},onReasoningStartEvent(){r.onReasoningStart()},onReasoningMessageContentEvent({reasoningMessageBuffer:a}){r.onReasoningDelta(a)},onReasoningMessageEndEvent({reasoningMessageBuffer:a}){r.onReasoningDelta(a)},onReasoningEndEvent(){r.onReasoningEnd()},onRunFinishedEvent(a){n.terminal=!0,a.outcome==="interrupt"&&(n.interrupts=a.interrupts)},onRunErrorEvent({event:a}){n.terminal=!0,n.errored=!0,!o()&&r.onError(a.message)},onRunFinalized(){n.terminal=!0,r.onRunEnd()}}}};function Wb(t){return t instanceof Error?t.name==="AbortError"||t instanceof TypeError&&/abort/i.test(t.message):!1}function Za(t){let e=t.attachments;return Array.isArray(e)?e.filter(Xb):[]}function Xb(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 Pu="ag-ui-chat",$n="thread",Ja="threads",Sr="messages:",Fo="checkpoint:",Ar="minted:",Kb=60,Yb=100,Zb="New conversation",Du=!1;function et(t,e){try{sessionStorage.setItem(t,e)}catch{if(Du)return;Du=!0,console.warn("<ag-ui-chat>: the browser refused a sessionStorage write \u2014 the quota is full, or storage is disabled for this context. The conversation continues, but it will not survive a page reload. Deleting a long conversation from the history drawer frees the quota.")}}function Go(t){return t===""?Pu:`${Pu}@${t}`}var Be=class t{#t;constructor(e=""){this.#t=Go(e),e!==""&&t.adopt("",e)}static adopt(e,n){let r=`${Go(e)}:`,i=`${Go(n)}:`;for(let[o,s]of Uu(r)){let a=sessionStorage.getItem(o),l=i+s;a!==null&&sessionStorage.getItem(l)===null&&et(l,a),sessionStorage.removeItem(o)}}static purge(e){for(let[n]of Uu(`${Go(e)}:`))sessionStorage.removeItem(n)}threadId(){return sessionStorage.getItem(this.#n($n))??this.newThread()}newThread(){let e=Ee();return et(this.#n($n),e),et(this.#n(Ar+e),"1"),e}isUnsent(e){return sessionStorage.getItem(this.#n(Ar+e))!==null&&sessionStorage.getItem(this.#n(Sr+e))===null}loadMessages(e){return Promise.resolve(this.#i(this.#n(Sr+e)))}saveMessages(e,n){et(this.#n(Sr+e),JSON.stringify(n)),sessionStorage.removeItem(this.#n(Ar+e)),this.#r(e,n)}loadCheckpoint(e){return this.#i(this.#n(Fo+e))}saveCheckpoint(e,n){let r=this.#n(Fo+e);if(n===null){sessionStorage.removeItem(r);return}et(r,JSON.stringify(n))}clear(e){sessionStorage.removeItem(this.#n(Sr+e)),sessionStorage.removeItem(this.#n(Fo+e)),sessionStorage.removeItem(this.#n(Ar+e)),this.#o(this.#e().filter(n=>n.threadId!==e)),sessionStorage.getItem(this.#n($n))===e&&sessionStorage.removeItem(this.#n($n))}listThreads(){let e=this.#e().sort((n,r)=>r.updatedAt-n.updatedAt).map(({threadId:n,title:r,updatedAt:i,preview:o})=>({threadId:n,title:r,updatedAt:i,preview:o}));return Promise.resolve(e)}setActiveThread(e){et(this.#n($n),e)}renameThread(e,n){let r=this.#e(),i=r.find(o=>o.threadId===e);i!==void 0&&(i.title=n,i.titleCustom=!0,this.#o(r))}#r(e,n){let r=this.#e(),i=r.find(a=>a.threadId===e),o=Qb(n),s=Date.now();i===void 0?r.push({threadId:e,title:Hu(n),titleCustom:!1,preview:o,updatedAt:s}):(i.preview=o,i.updatedAt=s,i.titleCustom||(i.title=Hu(n))),this.#o(r)}#e(){return this.#i(this.#n(Ja))??[]}#o(e){let n=this.#n(Ja);if(e.length===0){sessionStorage.removeItem(n);return}et(n,JSON.stringify(e))}#n(e){return`${this.#t}:${e}`}#i(e){let n=sessionStorage.getItem(e);if(n===null)return null;try{return JSON.parse(n)}catch{return null}}};function Uu(t){let e=[];for(let n=0;n<sessionStorage.length;n+=1){let r=sessionStorage.key(n);if(r===null||!r.startsWith(t))continue;let i=r.slice(t.length);Jb(i)&&e.push([r,i])}return e}function Jb(t){return t===$n||t===Ja||t.startsWith(Sr)||t.startsWith(Fo)||t.startsWith(Ar)}function Hu(t){for(let e of t)if(e.role==="user"){let n=zu(e.content);if(n!=="")return Gu(n,Kb)}return Zb}function Qb(t){for(let e of[...t].reverse()){let n=zu(e.content);if(n!=="")return Gu(n,Yb)}return""}function zu(t){return typeof t=="string"?t.replace(/\s+/g," ").trim():""}function Gu(t,e){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}\u2026`}function je(t,e){return e===void 0?t:{...t,credentials:e}}function $o(t){if(t.newThread!==void 0)return t.newThread();let e=Ee();return t.setActiveThread(e),e}function Vo(t,e,n,r){if(e.length===0)return;let i=new URL(String(t),location.href).origin;i===location.origin||n.includes(i)||r.has(i)||(r.add(i),console.warn(`<ag-ui-chat>: sending host credentials (${e.join(", ")}) to ${i}, which is not this page's origin (${location.origin}). Those headers are the page's own authentication, and whichever server answers the browser's preflight receives them \u2014 so a URL attribute built from a query parameter or from tenant-authored configuration is a channel for the token to leave on. If this destination is deliberate, name it in \`trustedOrigins\` to confirm it and silence this notice. Reported once per origin.`))}function Qa(t){let e=t.headers??{},n=new Set;return new Od({url:t.endpoint,headers:e,initialState:{...t.initialState??{}},fetch:(r,i)=>{let o=t.getHeaders?.(),s=[...new Set([...Object.keys(e),...Object.keys(o??{})])].sort();if(Vo(r,s,t.trustedOrigins??[],n),o===void 0)return fetch(r,je(i,t.credentials));let a=new Headers(i?.headers);for(let[l,c]of Object.entries(o))a.set(l,c);return fetch(r,je({...i,headers:a},t.credentials))},...t.threadId!==void 0?{threadId:t.threadId}:{},...t.initialMessages!==void 0?{initialMessages:[...t.initialMessages]}:{}})}var kr=class{#t;#r;#e;#o;#n;#i=new Set;#s=new Map;constructor(e,n=()=>({}),r=new Be,i=()=>{},o=!0){this.#t=e.endsWith("/")?e:`${e}/`,this.#r=n,this.#e=r,this.#o=i,this.#n=o}threadId(){return this.#e.threadId()}setActiveThread(e){this.#e.setActiveThread(e)}newThread(){return $o(this.#e)}isUnsent(e){return this.#e.isUnsent?.(e)===!0}saveMessages(e,n){this.#e.saveMessages(e,this.#n?n:[])}loadCheckpoint(e){return this.#e.loadCheckpoint(e)}saveCheckpoint(e,n){this.#e.saveCheckpoint(e,n)}renameThread(e,n){this.#e.renameThread(e,n),this.#s.set(e,n),this.#f(e,"PATCH",{title:n})}clear(e){this.#e.clear(e),this.#i.add(e),this.#f(e,"DELETE")}async listThreads(){let e=await this.#c();return e===null?this.#e.listThreads():e.filter(n=>!this.#i.has(n.thread_id)).map(n=>this.#d(n))}async loadMessages(e){if(this.#e.isUnsent?.(e)===!0)return null;let n=await this.#h(`${this.#t}${encodeURIComponent(e)}/`);if(n===null||!n.ok)return this.#e.loadMessages(e);let r=await this.#u(n);return r===null?this.#e.loadMessages(e):r.messages??null}async#c(){let e=await this.#h(this.#t);if(e===null||!e.ok)return null;let n=await this.#u(e);return n===null?null:n.threads??[]}async#u(e){try{return await e.json()}catch{return null}}#d(e){return{threadId:e.thread_id,title:this.#s.get(e.thread_id)??e.title,updatedAt:e.updated_at===null?Number.NaN:Date.parse(e.updated_at),preview:e.preview}}async#h(e){try{return await fetch(e,je({headers:this.#r()},this.#o()))}catch{return null}}async#f(e,n,r){let i=this.#r();try{await fetch(`${this.#t}${encodeURIComponent(e)}/`,je({method:n,headers:r===void 0?i:{...i,"content-type":"application/json"},body:r===void 0?null:JSON.stringify(r)},this.#o()))}catch{}}};var Cr=class{#t;#r;#e;constructor(e,n=()=>({}),r=()=>{}){this.#t=e.endsWith("/")?e:`${e}/`,this.#r=n,this.#e=r}async list(){try{let e=await fetch(this.#t,je({method:"GET",headers:{Accept:"application/json",...this.#r()}},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.#o("resume",e)}forkUrl(e){return this.#o("fork",e)}#o(e,n){return`${this.#t.slice(0,-5)}${e}/${encodeURIComponent(n)}/`}};async function el(t,e){let n=new FormData;n.append("audio",t,"recording.webm");let r=await fetch(e.url,je({method:"POST",headers:{...e.headers??{}},body:n},e.credentials));if(!r.ok)throw new Error(await ey(r));let i=await r.json();if(typeof i=="object"&&i!==null&&typeof i.text=="string")return i.text;throw new Error("transcription returned an unreadable response")}async function ey(t){try{let e=await t.json();if(typeof e.error=="string")return e.error}catch{}return`transcription failed (${t.status})`}function tl(t,e){return new Promise((n,r)=>{let i=new FormData;i.append("file",t);let o=new XMLHttpRequest;o.open("POST",e.url),o.withCredentials=e.credentials==="include";for(let[l,c]of Object.entries(e.headers??{}))o.setRequestHeader(l,c);let s=e.onProgress;s!==void 0&&o.upload.addEventListener("progress",l=>{l.lengthComputable&&s(l.total===0?0:l.loaded/l.total)}),o.addEventListener("load",()=>{if(o.status>=200&&o.status<300)try{n(ty(JSON.parse(o.responseText)))}catch{r(new Error("upload returned an unreadable response"))}else r(new Error(ny(o)))}),o.addEventListener("error",()=>r(new Error("upload failed"))),o.addEventListener("abort",()=>r(new Error("upload cancelled")));let a=e.signal;a!==void 0&&a.addEventListener("abort",()=>o.abort()),o.send(i)})}function ty(t){if(typeof t!="object"||t===null)throw new Error("not an object");let e=t,n=e.id,r=e.name,i=e.mime,o=e.size,s=e.url;if(typeof n!="string"||typeof r!="string"||typeof i!="string"||typeof o!="number")throw new Error("missing fields");return typeof s=="string"?{id:n,name:r,mime:i,size:o,url:s}:{id:n,name:r,mime:i,size:o}}function ny(t){try{let e=JSON.parse(t.responseText);if(typeof e.error=="string")return e.error}catch{}return`upload failed (${t.status})`}var ry=["data-attachments-url","data-attachment-accept","data-attachment-max-bytes","data-transcribe-url","data-threads-url","data-threads-cache","data-tools-url","data-skills-url","data-skills","data-prompt-chips","data-slash-commands","data-theme-toggle","data-strings","data-icon-url"],il=["omit","same-origin","include"];function nl(t){return il.includes(t)}var Fu="ag-ui-chat:collapsed",$u="ag-ui-chat:size",Vu="ag-ui-chat:theme",rl=new Set,Ir=class extends HTMLElement{agentFactory=Qa;headers={};getHeaders=null;trustedOrigins=[];allowImages=!1;autoConfirm=!1;askUser=!1;askUserRenderer=null;approvalRenderer=null;confirmPredicate=null;getTools=()=>[...this.#Pe().map(e=>({name:e.name,description:e.description,parameters:e.parameters})),...this.#n.tools()];getContext=()=>[...ya(this.getPageMap,this.autoInjectPageMap)];routeMap=[];navigate=null;getPageMap=null;autoInjectPageMap=!0;conversationStore=new Be;uploadHandler=null;transcribeHandler=null;navigationResult=()=>({navigated:!0,url:window.location.href});skillContext=()=>({});toolSummaries={};strings={};resolvePageTarget=e=>document.querySelector(e);#t={};#r=new Set;#e=le;#o=new Set;#n=new ur;#i=new Map;#s=!1;#c=new Map;#u=new Map;#d=new Set;#h=[];#f;#p;#a;#l;#g;#C;#T;#H;#b;#ue=null;#S;#x;#w;#Z;#I;#_;#R;#J=0;#M;#y=null;#Q;#pe=null;#z=!1;#L=null;#G={};#B=!1;#he=null;#A=null;#ee=null;#fe=0;#te="";#P=null;#ne=null;#N=null;#D=null;#m="";#F="";#re=null;#me="";#Ne="";#j=null;#ge=0;#ve=[];#Oe=[];#Me=[];#Le=[];constructor(){super(),this.#f=this.attachShadow({mode:"open"}),this.#p=document.createElement("div"),this.#a=document.createElement("div"),this.#l=document.createElement("textarea"),this.#g=document.createElement("button"),this.#C=document.createElement("span"),this.#S=document.createElement("div"),this.#x=document.createElement("button"),this.#w=document.createElement("input"),this.#Z=document.createElement("div"),this.#Q=document.createElement("span"),this.#I=document.createElement("button"),this.#_=document.createElement("button"),this.#R=document.createElement("span"),this.#M=document.createElement("div"),this.#T=new Po(e=>this.#At(e)),this.#H=new Uo({onSelect:e=>{this.#Ot(e)},onNew:()=>{this.newChat(),this.#K()},onRename:(e,n)=>{this.conversationStore.renameThread(e,n),this.#K()},onDelete:e=>{this.#Mt(e)}}),this.#b=new gr((e,n)=>{this.#at(e,n)})}#be(){let e=this.getAttribute("data-runs-url");return e===null||e===""?null:(this.#ue===null&&(this.#ue=new Cr(e,()=>this.#W(e),()=>this.#ie())),this.#ue)}async#at(e,n){let r=this.#be();if(r===null)return;let i=this.#l.value.trim();if(i==="")return;this.#l.value="",this.#Y();let o=n==="resume"?r.resumeUrl(e):r.forkUrl(e),s=this.agentFactory({endpoint:o,headers:this.#q(),getHeaders:()=>this.#q(),trustedOrigins:this.trustedOrigins,...this.#oe(),threadId:this.#m,initialMessages:[]});await new Fn({agent:s,handlers:this.#tt(),getTools:()=>this.#De(),getContext:()=>this.#We(),executeTool:l=>this.#Qe(l),resolveInterrupts:l=>this.#et(l),connectionLostMessage:this.#e.connectionLost}).send(i)}async#lt(){let e=this.#be();this.#b.setRuns(e===null?[]:await e.continuable())}static get observedAttributes(){return["title-text","placement","credentials","user-key",...ry]}attributeChangedCallback(e,n,r){if(e==="credentials"){r!==null&&!nl(r)&&console.error(`<ag-ui-chat>: credentials="${r}" is not a fetch credentials mode (${il.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.#Ct(),requestAnimationFrame(()=>this.#_e());return}if(e==="title-text"){this.#C.textContent=r??this.#e.title;return}if(e==="user-key"){this.#z&&(n??"")!==(r??"")&&this.#Nt(n??"",r??"");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.#n.register(e)}get sharedState(){return this.#L?.state??this.#G}set sharedState(e){this.#G={...e},this.#L?.setState(this.#G)}registerPageState(e){for(let n of xo(e))this.#n.register(n)}registerStateHook(e){this.registerPageState(e)}#ct(){return this.routeMap.length===0?[]:wa(()=>this.routeMap,()=>this.navigate)}#dt(){let e=this.getPageMap;return e===null?[]:[{name:ms,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:[],[Pe]:"Read the page"},handler:()=>e()}]}#ut(){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 ba(n,r=>this.resolvePageTarget(r))}#Pe(){return[...this.#ct(),...this.#dt(),...this.#ut(),...this.#pt()]}#pt(){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.#ht(e)}]:[]}async#ht(e){let r={question:typeof e.question=="string"?e.question:""},i=e.options;Array.isArray(i)&&(r.options=i.filter(a=>typeof a=="string")),e.allow_custom===!0&&(r.allowCustom=!0),this.#A=new AbortController;let o=this.#A.signal;this.#k();let s=this.askUserRenderer!==null?await this.askUserRenderer(r,{signal:o}):await Ra(this.#E(),r,{signal:o,strings:this.#e});return this.#A=null,this.#v(),this.#a.scrollTop=this.#a.scrollHeight,s}#De(){let e=this.getTools();return this.#o=new Set(e.map(n=>n.name)),e}#ye(e){let n=this.#Pe().find(r=>r.name===e);return n!==void 0?n:this.#n.has(e)?this.#n.get(e):null}get endpoint(){return this.getAttribute("endpoint")??""}set endpoint(e){this.setAttribute("endpoint",e)}get userKey(){return this.getAttribute("user-key")??""}set userKey(e){this.setAttribute("user-key",e)}get credentials(){let e=this.getAttribute("credentials");return e!==null&&nl(e)?e:null}set credentials(e){if(e===null){this.removeAttribute("credentials");return}if(!nl(e))throw new TypeError(`<ag-ui-chat>: credentials must be one of ${il.map(n=>`"${n}"`).join(", ")} (got ${JSON.stringify(e)}).`);this.setAttribute("credentials",e)}#q(){return{...this.headers,...this.getHeaders?.()}}#W(e){let n=this.#q();return Vo(e,Object.keys(n),this.trustedOrigins,this.#r),n}#ie(){return this.credentials??void 0}#oe(){let e=this.#ie();return e===void 0?{}:{credentials:e}}#Ue(e){return je({headers:this.#W(e)},this.#ie())}get toolDisplay(){let e=this.getAttribute("data-tool-display");return e===vn.INLINE||e===vn.MINIMAL||e===vn.COMPACT?e:vn.FULL}set toolDisplay(e){this.setAttribute("data-tool-display",e)}connectedCallback(){if(this.#F=this.#Rt(),this.#Ee(this.#Be()),requestAnimationFrame(()=>this.#_e()),this.#e=_a({...this.#mt(),...this.strings}),this.getAttribute("data-theme-toggle")!==null){let e=this.#Se(Vu);e!==null&&this.setAttribute("theme",e)}if(this.#zt(),this.#H.setStrings(this.#e),this.#b.setStrings(this.#e),this.#Se(Fu)==="1"&&this.setAttribute("collapsed",""),this.#Ye(),this.#Tt(),this.conversationStore instanceof Be){let e=this.#Te();this.#j=e===""?this.conversationStore:new Be(e),this.conversationStore=this.#j}this.#ze(),this.#gt(),this.#bt(),this.#m=this.conversationStore.threadId(),queueMicrotask(()=>this.#ft()),this.#ae(),this.#z=!0}#ft(){this.#z&&(this.#Ge(),this.#Fe())}async reload(){this.#O(),this.#X(),this.#U(!1),await Promise.all([this.#Ge(),this.#Fe(),this.#ae()])}disconnectedCallback(){this.#z=!1,this.#re!==null&&(rl.delete(this.#re),this.#re=null),this.#O(),this.#y?.dispose(),this.#pe?.dispose()}#He(e){let n=this.getAttribute(e);return n!==null&&n!=="false"}#mt(){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{}}#gt(){let e=this.getAttribute("data-attachments-url"),n=this.uploadHandler??this.#vt(e);if(n===null)return;let r=this.getAttribute("data-attachment-accept")??"",i=new _o({upload:n,maxBytes:this.#wt(),accept:r,strings:this.#e,onChange:()=>this.#Bt(i)});this.#y=i,this.#Z.appendChild(this.#y.element),this.#w.accept=r,this.#x.hidden=!1,this.#Et()}#vt(e){return e===null?null:(n,r,i)=>tl(n,{url:e,headers:this.#W(e),...this.#oe(),onProgress:r,signal:i})}#bt(){let e=this.getAttribute("data-transcribe-url"),n=this.transcribeHandler??this.#yt(e);n!==null&&(this.#pe=new Ho({transcribe:n,onText:r=>this.#xt(r),strings:this.#e}),this.#Q.appendChild(this.#pe.element))}#yt(e){return e===null?null:n=>el(n,{url:e,headers:this.#W(e),...this.#oe()})}#xt(e){let n=this.#l.value.trim();this.#l.value=n===""?e:`${n} ${e}`,this.#Ze(),this.#l.focus()}#wt(){let e=this.getAttribute("data-attachment-max-bytes");if(e===null)return vs;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:vs}#_t(){let e=this.#w.files;if(e!==null)for(let n of Array.from(e))this.#y?.add(n);this.#w.value=""}#Et(){this.#p.addEventListener("dragover",e=>{e.preventDefault(),this.#p.classList.add("chat--dragover")}),this.#p.addEventListener("dragleave",()=>{this.#p.classList.remove("chat--dragover")}),this.#p.addEventListener("drop",e=>{e.preventDefault(),this.#p.classList.remove("chat--dragover");let n=e.dataTransfer?.files;if(n!==void 0)for(let r of Array.from(n))this.#y?.add(r)})}#ze(){let e=this.getAttribute("data-threads-url");e!==null&&(this.conversationStore=new kr(e,()=>this.#W(e),this.conversationStore,()=>this.#ie(),this.getAttribute("data-threads-cache")!=="false"))}async#Ge(){let e=this.getAttribute("data-tools-url");if(e!==null)try{let n=await fetch(e,this.#Ue(e));this.#t=xa(await n.json())}catch{}}setSkills(e){this.#Le=e,this.#xe()}#Tt(){this.#T.enableChips(this.#He("data-prompt-chips")),this.#T.enableSlash(this.#He("data-slash-commands")),this.#Me=this.#St(),this.#xe()}#St(){let e=this.getAttribute("data-skills");if(e===null)return[];try{return aa(JSON.parse(e))}catch{return[]}}async#Fe(){let e=this.getAttribute("data-skills-url");if(e!==null)try{let n=await fetch(e,this.#Ue(e));this.#Oe=aa(await n.json()),this.#xe()}catch{}}#xe(){let e=new Map;for(let n of[...this.#Oe,...this.#Me,...this.#Le])e.set(n.name,n);this.#T.setSkills([...e.values()])}#At(e){if(e.prompt===void 0){this.#S.hidden=!0,this.sendMessage(`/${e.name}`);return}let{text:n,missing:r}=Md(e.prompt,this.skillContext());if(r.length>0){this.#S.textContent=this.#e.skillNeeds.replace("{title}",e.title).replace("{fields}",r.join(", ")),this.#S.hidden=!1,this.#l.value=n,this.#Y(),this.#l.focus(),this.#kt(n);return}if(this.#S.hidden=!0,this.#l.value=n,this.#Y(),e.sendImmediately===!1){this.#l.focus();return}this.#ke()}#kt(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"),et(this.#se(Fu),e?"1":"0"),this.#ce(0),this.dispatchEvent(new CustomEvent(ds,{detail:{collapsed:e},bubbles:!0,composed:!0}))}get unread(){return this.#J}toggleCollapsed(){this.setCollapsed(!this.collapsed)}toggleTheme(){let e=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",e),et(this.#se(Vu),e),this.#qe()}#we(){switch(this.getAttribute("placement")){case"full":case"page":return"none";case"sidebar":case"side":return"width";default:return"both"}}#$e(){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 i=this.getBoundingClientRect();return this.#Ve("--ag-ui-width",n),this.#Ve("--ag-ui-height",r),{x:Math.abs(i.left-e.left)<.5?"left":"right",y:Math.abs(i.top-e.top)<.5?"top":"bottom"}}#_e(){if(!this.#z)return;let e=this.#$e();this.setAttribute("data-resize-anchor",`${e.y}-${e.x}`)}#Ve(e,n){if(n===""){this.style.removeProperty(e);return}this.style.setProperty(e,n)}#Ee(e){let n=this.#we();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`))}#Ct(){let e=this.#we();e!=="both"&&this.style.removeProperty("--ag-ui-height"),e==="none"&&this.style.removeProperty("--ag-ui-width")}#It(e){let n={...this.#Be(),...e};et(this.#se($u),JSON.stringify(n))}#Be(){let e=this.#Se($u);if(e===null)return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!==null?n:{}}catch{return{}}}#Rt(){let e=this.id!==""?this.id:this.endpoint;return e===""?"":this.#Ne===e?this.#me:rl.has(e)?(this.#Ne=e,this.#me=`${e}~${Ee()}`,console.warn(`<ag-ui-chat>: another element on this page already stores its conversation under "${e}", so this one has been given a throwaway namespace of its own \u2014 the two would otherwise share a thread pointer, a history drawer and every message. Give each <ag-ui-chat> its own id to keep them apart and let this one restore its conversation across reloads.`),this.#me):(rl.add(e),this.#re=e,e)}#Te(e=this.userKey){return e===""?this.#F:`${this.#F}#${e}`}#Nt(e,n){let r=this.#Te(e),i=this.#Te(n);if(e===""){Be.adopt(r,i),this.#je(i);return}Be.purge(r),this.#je(i),this.#O(),this.#X(),this.#U(!1),this.#ce(0),this.#m=this.conversationStore.threadId(),this.#ae(),this.#K()}#je(e){this.#j!==null&&(this.#j=new Be(e),this.conversationStore=this.#j,this.#ze())}#se(e){return this.#F===""?e:`${e}:${this.#F}`}#Se(e){let n=sessionStorage.getItem(this.#se(e));return n!==null||this.#F===""?n:sessionStorage.getItem(e)}#qe(){let e=this.getAttribute("theme")==="dark";this.#I.textContent=e?"\u2600\uFE0F":"\u{1F319}"}openThreads(){this.#b.close(),this.#K(),this.#H.open()}openCheckpoints(){this.#H.close(),this.#lt(),this.#b.open()}closeCheckpoints(){this.#b.close()}toggleCheckpoints(){if(this.#b.open_){this.#b.close();return}this.openCheckpoints()}newChat(){this.#O(),this.conversationStore.isUnsent?.(this.#m)===!0&&this.conversationStore.clear(this.#m),this.#X(),this.#m=$o(this.conversationStore),this.#U(!1),this.#ce(0)}#X(){this.#L=null,this.#V(),this.#N=null,this.#D=null,this.#k(),this.#i.clear(),this.#d.clear(),this.#c.clear(),this.#u.clear(),this.#ve=[],this.#y?.clear(),this.#a.replaceChildren(this.#M),this.#v()}async#Ot(e){e!==this.#m&&(this.#O(),this.#X(),this.conversationStore.setActiveThread(e),this.#m=e,this.#U(!1),await this.#ae())}#Mt(e){let n=e===this.#m;n&&this.#O(),this.conversationStore.clear(e),n&&(this.#X(),this.#m=this.conversationStore.threadId(),this.#U(!1)),this.#K()}async#K(){this.#H.setThreads(await this.conversationStore.listThreads(),this.#m)}async#ae(){this.#ge+=1;let e=this.#ge,n=await this.conversationStore.loadMessages(this.#m);if(e!==this.#ge)return;if(n!==null){this.#ve=n;for(let i of n)this.#Dt(i)}let r=this.conversationStore.loadCheckpoint(this.#m);if(r!==null){await this.#Ht(r);return}this.#Pt(n)}#We(){return this.#he=window.location.href,this.getContext()}#Lt(){return this.#he!==null&&this.#he!==window.location.href}#Pt(e){let n=e?.at(-1);n===void 0||n.role!==We.USER||this.#de("\u26A0",this.#e.runInterrupted,"interrupted")}#Dt(e){let n=typeof e.content=="string"?e.content:"";if(e.role===We.USER){let r=Za(e);if(n!==""||r.length>0){let i=this.appendMessage(We.USER,n);r.length>0&&i.appendChild(Sa(r))}return}if(e.role===We.ASSISTANT){n!==""&&this.appendMessage(We.ASSISTANT,n).classList.add("message--restored");for(let r of oy(e.toolCalls)){let i={id:r.id,name:r.function.name,args:this.#Ut(r.function.arguments)};if(this.#it(i))continue;this.#c.set(i.id,this.#Re(i).element);let o=this.#ye(i.name)?.render;o!==void 0&&this.#ot(o,i)}return}if(e.role==="activity"){let r=e;r.activityType===Yn&&this.#s&&this.#Ie(e.id,r.content);return}if(e.role==="tool"){let r=this.#i.get(e.toolCallId);r!==void 0&&r.settle(ee.DONE,e.content)}}#Ut(e){if(typeof e!="string")return{};try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#Xe(e){this.getAttribute("data-text-animation")==="word"&&Nu(e)}async#Ht(e){this.conversationStore.saveCheckpoint(this.#m,null);let n=this.#Je();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===We.ASSISTANT?(r.innerHTML=Lo(n,{allowImages:this.allowImages}),Ta(r,this.#e),this.#E().appendChild(r)):(this.#N=null,r.textContent=n,this.#a.appendChild(r)),this.#v(),this.#a.scrollTop=this.#a.scrollHeight,r}#E(){if(this.#N===null){let e=document.createElement("div");e.className="answer",e.setAttribute("part","answer"),this.#N=e,this.#a.appendChild(e),this.#v()}return this.#N}#zt(){let e=document.createElement("style");e.textContent=Mu,this.#p.className="chat",this.#p.setAttribute("part","panel");let n=document.createElement("div");n.className="header",n.setAttribute("part","header");let r=this.#C;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.#Ke("icon","icon",null));let i=document.createElement("slot");i.name="header-actions";let o=document.createElement("div");o.className="header-controls",o.setAttribute("part","header-controls");let s=this.#le("history",this.#e.chatHistory,"\u2630");s.addEventListener("click",()=>this.openThreads());let a=this.#le("checkpoints",this.#e.checkpoints,"\u21BA");a.addEventListener("click",()=>this.toggleCheckpoints());let l=this.#le("new",this.#e.newChat,"\u271A");l.addEventListener("click",()=>this.newChat());let c=this.#le("collapse",this.#e.collapse,"\u2014");c.addEventListener("click",()=>this.toggleCollapsed()),this.#be()!==null?o.append(s,a,l):o.append(s,l),this.getAttribute("data-theme-toggle")!==null&&(this.#I.type="button",this.#I.className="header-btn header-btn--theme",this.#I.setAttribute("part","header-button theme-toggle"),this.#I.title=this.#e.toggleTheme,this.#I.setAttribute("aria-label",this.#e.toggleTheme),this.#I.addEventListener("click",()=>this.toggleTheme()),this.#qe(),o.append(this.#I)),o.append(c),n.append(r,i,o),this.#a.className="messages",this.#a.setAttribute("part","messages"),this.#a.setAttribute("role","log"),this.#a.setAttribute("aria-live","polite"),this.#a.setAttribute("aria-label",this.#e.conversation),this.#M.className="empty",this.#M.setAttribute("part","empty");let p=document.createElement("slot");p.name="empty",this.#M.append(p),this.#a.append(this.#M);let m=document.createElement("div");m.className="input-row",m.setAttribute("part","composer");let y=document.createElement("div");y.className="composer",y.setAttribute("part","composer-surface");let f=document.createElement("div");f.className="composer-tools",f.setAttribute("part","composer-tools"),this.#l.className="input",this.#l.setAttribute("part","input"),this.#l.setAttribute("aria-label",this.#e.message),this.#l.rows=1,this.#l.placeholder=this.#e.inputPlaceholder,this.#l.addEventListener("keydown",g=>this.#Vt(g)),this.#l.addEventListener("input",()=>this.#Ze()),this.#g.className="send",this.#g.type="button",this.#g.setAttribute("part","send"),this.#g.append(this.#Ae("icon-send","send-send",Ol),this.#Ae("icon-stop","send-stop",Ml)),this.#g.title=this.#e.send,this.#g.setAttribute("aria-label",this.#e.send),this.#g.dataset.state="idle",this.#g.addEventListener("click",()=>{if(this.#B){this.#O();return}this.#ke()}),this.#S.className="skill-hint",this.#S.setAttribute("part","skill-hint"),this.#S.hidden=!0,this.#x.className="attach-btn",this.#x.type="button",this.#x.setAttribute("part","attach-button"),this.#x.append(this.#Ae("icon-attach","attach-glyph",Ll)),this.#x.title=this.#e.attachFiles,this.#x.setAttribute("aria-label",this.#e.attachFiles),this.#x.hidden=!0,this.#x.addEventListener("click",()=>this.#w.click()),this.#w.className="attach-input",this.#w.type="file",this.#w.multiple=!0,this.#w.hidden=!0,this.#w.addEventListener("change",()=>this.#_t()),this.#Z.className="attachment-slot",this.#Q.className="voice-slot";let h=document.createElement("slot");h.name="footer",f.append(this.#x,this.#Q,this.#g),y.append(this.#l,f),m.append(y,this.#w),this.#p.append(n,this.#a,this.#T.palette,this.#T.chips,this.#S,this.#Z,m,h,this.#H.element,this.#b.element),this.#p.addEventListener("pointerdown",g=>{if(!this.#b.open_)return;let x=g.composedPath();x.includes(this.#b.element)||x.includes(a)||this.#b.close()}),this.#_.className="launcher",this.#_.type="button",this.#_.setAttribute("part","launcher"),this.#_.setAttribute("aria-label",this.#e.expand),this.#R.className="launcher-badge",this.#R.setAttribute("part","launcher-badge"),this.#R.setAttribute("aria-hidden","true"),this.#R.hidden=!0,this.#_.append(this.#Ke("launcher","launcher-icon",Dl,this.#Gt()),this.#R),this.#_.addEventListener("click",()=>this.setCollapsed(!1)),this.#p.append(Iu({axis:()=>this.#we(),anchor:()=>this.#$e(),rect:()=>this.getBoundingClientRect(),apply:g=>this.#Ee(g),commit:g=>{this.#It(g),this.#_e()},label:this.#e.resizePanel})),this.#f.append(e,this.#p,this.#_)}#le(e,n,r){let i=document.createElement("button");i.type="button",i.className=`header-btn header-btn--${e}`,i.setAttribute("part",`header-button ${e}-button`),i.title=n,i.setAttribute("aria-label",n);let o=document.createElement("slot");return o.name=`icon-${e}`,o.append(document.createTextNode(r)),i.append(o),i}#Ae(e,n,r){let i=document.createElement("slot");return i.name=e,i.className=n,i.innerHTML=r,i}#Gt(){return this.getAttribute("data-launcher-icon-url")??this.getAttribute("data-icon-url")}#Ke(e,n,r,i=this.getAttribute("data-icon-url")){let o=document.createElement("span");o.className="icon-holder",o.setAttribute("part",n);let s=document.createElement("slot");if(s.name=e,i!==null){let a=document.createElement("img");a.className="icon-img",a.src=i,a.alt="",s.append(a)}else r!==null&&(s.innerHTML=r);return o.append(s),o}#Ye(){this.#_.setAttribute("aria-expanded",String(!this.collapsed));let e=this.#J;this.#R.textContent=e>9?"9+":String(e),this.#R.hidden=e===0||!this.#Ft();let n=this.#R.hidden?this.#e.expand:this.#e.expandUnread.replace("{count}",String(e));this.#_.setAttribute("aria-label",n),this.#_.title=n}#Ft(){return this.getAttribute("data-unread-badge")!=="false"}#ce(e){this.#J=e,this.#Ye(),this.dispatchEvent(new CustomEvent(us,{detail:{unread:e},bubbles:!0,composed:!0}))}#$t(){this.collapsed&&this.#ce(this.#J+1)}#v(){this.#M.hidden=this.#a.childElementCount>1}#Ze(){this.#T.onInput(this.#l.value),this.#S.hidden=!0,this.#Y()}#Vt(e){if(this.#T.onKeydown(e)){e.preventDefault();return}if(e.key==="Escape"&&this.#B){e.preventDefault(),this.#O();return}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.#ke())}#O(){this.#A?.abort(),this.#L?.cancel()}#U(e){this.#B=e;let n=e?this.#e.stop:this.#e.send;this.#g.title=n,this.#g.setAttribute("aria-label",n),this.#g.dataset.state=e?"running":"idle"}#Y(){this.#l.style.height="auto",this.#l.style.height=`${this.#l.scrollHeight}px`}async#ke(){if(this.#B)return;let e=this.#l.value.trim(),n=this.#y?.readyRefs()??[];e===""&&n.length===0||(this.#l.value="",this.#Y(),this.#y?.hasPending()===!0&&this.#de("\u{1F4CE}",this.#e.attachmentsStillUploading.replace("{n}",String(this.#y.pendingCount())),"attachment-pending"),this.#y?.clearReady(),await this.sendMessage(e,n))}async sendMessage(e,n=[]){if(this.#B||e===""&&n.length===0)return;let r=this.appendMessage(We.USER,e);n.length>0&&r.appendChild(Sa(n)),this.dispatchEvent(new CustomEvent(cs,{detail:{content:e,attachments:n},bubbles:!0,composed:!0})),await this.#jt(e,n)}attachFile(e){return this.#y===null?!1:(this.#y.add(e),!0)}#Bt(e){this.dispatchEvent(new CustomEvent(hs,{detail:{attachments:e.readyRefs(),pending:e.pendingCount()},bubbles:!0,composed:!0}))}async#jt(e,n){this.endpoint!==""&&await this.#Je().send(e,n)}#Je(){if(this.#L===null){let e=this.agentFactory({endpoint:this.endpoint,headers:this.#q(),getHeaders:()=>this.#q(),trustedOrigins:this.trustedOrigins,...this.#oe(),threadId:this.#m,initialMessages:this.#ve,initialState:this.#G});this.#L=new Fn({agent:e,handlers:this.#tt(),getTools:()=>this.#De(),getContext:()=>this.#We(),executeTool:n=>this.#Qe(n),resolveInterrupts:n=>this.#et(n),onPersist:n=>this.conversationStore.saveMessages(this.#m,n),onStateChanged:n=>this.#qt(n),connectionLostMessage:this.#e.connectionLost})}return this.#L}#qt(e){this.#G={...e},this.dispatchEvent(new CustomEvent(ps,{detail:{state:this.#G},bubbles:!0,composed:!0}))}async#Wt(e,n){return this.autoConfirm?!1:this.confirmPredicate!==null?await this.confirmPredicate(e.name,e.args)===!0:la(n.parameters)}async#Qe(e){if(Bu(e)!==null)return null;let n=this.#Re(e);this.#i.delete(e.id),this.#c.set(e.id,n.element);let r=this.#o.has(e.name)?this.#ye(e.name):null;if(r===null)return this.#d.has(e.id)||n.settle(ee.DONE,this.#e.noResult),null;if(this.getPageMap!==null&&e.name!==ms&&!go(r.parameters)&&this.#Lt()){let o=this.#e.pageMoved;return n.settle(ee.ERROR,o),this.#$(),{content:`Error: ${o}`,error:o}}if(await this.#Wt(e,r)){let o={toolName:e.name,args:e.args},s=r.parameters[Vr];typeof s=="string"&&(o.message=s),this.#A=new AbortController;let a=Ca(this.#E(),o,{signal:this.#A.signal,strings:this.#e});this.#v(),this.#a.scrollTop=this.#a.scrollHeight;let l=await a;if(this.#A=null,n.recordDecision(l?"approved":"declined"),!l){let c=this.#e.declinedAction;return n.settle(ee.DECLINED,c),this.#$(),{content:c}}}let i=go(r.parameters)&&this.navigate===null;i&&this.conversationStore.saveCheckpoint(this.#m,{toolCallId:e.id});try{let o=await r.handler(e.args,e.id);if(r.render!==void 0&&this.#ot(r.render,e),i)return n.settle(ee.DONE,this.#e.navigating),{content:"",halt:!0};let s=JSON.stringify(o??null);return n.settle(ee.DONE,s),this.#$(),{content:s}}catch(o){i&&this.conversationStore.saveCheckpoint(this.#m,null);let s=o instanceof Error?o.message:String(o);return n.settle(ee.ERROR,s),this.#$(),{content:`Error: ${s}`,error:s}}}async#et(e){this.#A=new AbortController,this.#k();let n=this.#A.signal,r=await Promise.all(e.map(async o=>{let s=o.toolCallId!==void 0?this.#i.get(o.toolCallId):void 0,a={},l=iy(o)??o.message;l!==void 0&&(a.message=l);let c=s?.element.getAttribute("data-tool-name");c!=null&&(a.toolName=c),s?.mark(ee.DEFERRED);let p=this.approvalRenderer!==null?await this.approvalRenderer(a,{signal:n}):await Ea(s?.approvalSlot??this.#E(),a,{signal:n,strings:this.#e});return s?.recordDecision(p?"approved":"declined"),p?s?.mark(ee.PENDING):s?.settle(ee.DECLINED,this.#e.declinedAction),{id:o.id,approved:p}}));this.#v(),this.#a.scrollTop=this.#a.scrollHeight,this.#A=null;let i={};for(let{id:o,approved:s}of r)i[o]=s?{status:"resolved",payload:{approved:!0}}:{status:"cancelled"};return i}#tt(){return{onRunStart:()=>{this.#U(!0),this.#E(),this.#$()},onReasoningStart:()=>{this.#k(),this.#nt()},onReasoningDelta:e=>{this.#nt().stream(e)},onReasoningEnd:()=>{},onTextDelta:e=>{this.#k(),this.#D?.collapse(),this.#Yt(e),this.#fe+=1},onTextEnd:e=>{let n=this.#Ce(e);this.#fe<=1&&this.#Xe(n),Ta(n,this.#e),this.#V(),this.#$t()},onToolCall:e=>{this.#k(),!this.#it(e)&&(this.#h.push({id:e.id,name:e.name}),this.#Re(e))},onActivity:(e,n,r)=>{if(e===Yn){this.#s&&this.#Ie(r,n);return}if(e!==bs)return;let i=ay(n);i!==null&&this.#de("\u{1F5DC}",this.#e.historyCompacted.replace("{count}",String(i)),"compaction")},onToolResult:(e,n)=>{let r=this.#i.get(e);r!==void 0&&(r.settle(ee.DONE,n),this.#d.add(e),this.#$())},onActivityChanged:(e,n,r)=>{n===Yn&&this.#s&&this.#Ie(e,r)},onRunEnd:()=>{this.#k(),this.#V()},onError:e=>{this.#k(),this.#Xe(this.appendMessage(We.ASSISTANT,`\u26A0\uFE0F ${e}`)),this.#V()},onCancelled:()=>{this.#k(),this.#Kt(),this.#V()},onSettled:()=>{this.#k(),this.#U(!1),this.#V();for(let e of this.#i.values())e.settled||e.settle(ee.DONE,this.#e.noResult);this.#N!==null&&this.#N.childElementCount===0&&(this.#N.remove(),this.#v()),this.#N=null,this.#D=null,this.#Xt()}}}#Xt(){let e=this.#h.map(({id:n,name:r})=>({name:r,side:this.#d.has(n)?"server":"client"}));this.#h=[],this.dispatchEvent(new CustomEvent(fs,{detail:{tools:e},bubbles:!0,composed:!0}))}#Kt(){let e=document.createElement("div");e.className="stopped-note",e.setAttribute("part","stopped"),e.setAttribute("role","status"),e.textContent=this.#e.stopped,this.#E().appendChild(e),this.#v(),this.#a.scrollTop=this.#a.scrollHeight}#$(){if(this.#ne!==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.#ne=e,this.#E().appendChild(e),this.#v(),this.#a.scrollTop=this.#a.scrollHeight}#k(){this.#ne?.remove(),this.#ne=null}#nt(){if(this.#D===null){this.#D=new Do(this.#e);let e=this.#E();e.insertBefore(this.#D.element,e.firstChild),this.#v(),this.#a.scrollTop=this.#a.scrollHeight}return this.#D}#rt(){return this.#ee===null&&(this.#ee=this.appendMessage(We.ASSISTANT,""),this.#fe=0),this.#ee}#Yt(e){this.#te=e,this.#rt(),this.#P===null&&(this.#P=requestAnimationFrame(()=>{this.#P=null,this.#Ce(this.#te)}))}#Ce(e){this.#P!==null&&(cancelAnimationFrame(this.#P),this.#P=null),this.#te=e;let n=this.#rt();return n.innerHTML=Lo(e,{allowImages:this.allowImages}),this.#a.scrollTop=this.#a.scrollHeight,n}#V(){this.#P!==null&&this.#Ce(this.#te),this.#ee=null}#it(e){let n=Bu(e);return n===null?!1:(this.#de("\u2728",this.#e.usingSkill.replace("{name}",n),"skill"),!0)}#de(e,n,r){this.#E().appendChild(Ou(e,n,r)),this.#v(),this.#a.scrollTop=this.#a.scrollHeight}enableCharts(e=["tool","activity"]){let n=!this.#s&&!this.#n.has(So);e.includes("activity")&&(this.#s=!0),e.includes("tool")&&this.registerTool(Gd()),n&&this.isConnected&&this.reload()}#ot(e,n){let r;try{r=e(n.args)}catch(i){console.warn(`ag-ui-chat: render failed for tool ${n.name}`,i);return}r!==null&&(this.#c.get(n.id)?.after(r),this.#st())}#Ie(e,n){let r=Pn(n),i=r===null?null:mr(r);if(i===null){this.#u.get(e)?.remove(),this.#u.delete(e);return}let o=this.#u.get(e);o===void 0?this.#E().appendChild(i):o.replaceWith(i),this.#u.set(e,i),this.#st()}#st(){this.#v(),this.#a.scrollTop=this.#a.scrollHeight}#Re(e){let n=this.#i.get(e.id);if(n!==void 0)return n;let r=this.#ye(e.name)?.parameters[Pe],i=typeof r=="string"?r:this.toolSummaries[e.name]??this.#t[e.name]?.summary??Ia(e.name),o=new Tr(e.name,e.args,i,this.#e);return this.#i.set(e.id,o),this.#E().appendChild(o.element),this.#v(),this.#a.scrollTop=this.#a.scrollHeight,o}};function iy(t){let e=t.metadata?.[Vr];return typeof e=="string"&&e.trim()!==""?e:void 0}function oy(t){return Array.isArray(t)?t.filter(sy):[]}function sy(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.id=="string"&&typeof e.function?.name=="string"}function Bu(t){if(t.name!==ys)return null;let e=t.args?.id;return typeof e=="string"&&e!==""?e:null}function ay(t){let e=t?.removed;return typeof e=="number"?e:null}function ly(){customElements.get($r)===void 0&&customElements.define($r,Ir)}async function cy(t,e,n={}){await vt(t),await ha(t,{...n,flashMs:n.flashMs??0}),await ua(t,e,n)}async function dy(t,e={}){await vt(t),await pa(t,e)}async function uy(t,e={}){await vt(t),await fa(t,e)}async function py(t,e,n={}){await vt(t),await ma(t,e,n)}async function hy(t,e,n={}){await vt(t),await ga(t,e,n)}function fy(t,e){t instanceof HTMLInputElement&&t.type==="checkbox"?pr(t,!!e):rn(t,String(e)),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}var my="0.28.0";export{hs as ATTACHMENT_EVENT,Ir as AgUiChat,Fn as AgUiClient,Yn as CHART_ACTIVITY_TYPE,So as CHART_TOOL_NAME,bs as COMPACTION_ACTIVITY_TYPE,gr as CheckpointMenu,ur as ClientToolRegistry,zo as ConnectionLostError,le as DEFAULT_UI_STRINGS,$r as ELEMENT_TAG,ys as LOAD_CAPABILITY_TOOL,gs as MAX_TOOL_ROUNDS,We as MESSAGE_ROLE,va as PAGE_ACTIONS,fs as RUN_FINISHED_EVENT,kr as RemoteConversationStore,Cr as RunIndex,ps as STATE_EVENT,cs as SUBMIT_EVENT,Be as SessionStorageStore,ds as TOGGLE_EVENT,ee as TOOL_CALL_STATUS,vn as TOOL_DISPLAY,Tr as ToolCallCard,us as UNREAD_EVENT,my as VERSION,Vr as X_CONFIRM_KEY,Xn as X_DESTRUCTIVE_KEY,Kn as X_NAVIGATES_KEY,Pe as X_SUMMARY_KEY,Pn as chartSpecFrom,dy as clickElement,Qa as createHttpAgent,ba as createPageActionTools,ya as createPageMapContext,xo as createPageStateTools,wa as createRouteTools,Hg as createStateHookTools,ly as defineAgUiChat,cy as fillField,Mg as flash,ha as focusWithFlash,pa as highlightThenClick,la as isDestructive,go as isNavigates,_a as mergeUiStrings,Za as messageAttachments,xa as parseToolCatalog,bo as prefersReducedMotion,uy as pressButton,fa as pressThenClick,Ia as prettifyToolName,mr as renderChart,Lo as renderMarkdown,Ea as requestApproval,Ca as requestConfirmation,Ra as requestQuestion,vt as scrollIntoCenterView,py as selectControl,ma as selectOption,fy as setControlValue,pr as setNativeChecked,rn as setNativeValue,hy as toggleCheckbox,ga as toggleControl,el as transcribeAudio,ua as typeInto,tl as uploadAttachment};
|
|
2843
|
+
`;var $i=class{element;#t;#n;#e;#s=new Map;constructor(e=ee){this.element=document.createElement("div"),this.element.className="subagent",this.element.setAttribute("part","subagent"),this.#t=document.createElement("button"),this.#t.type="button",this.#t.className="subagent-row",this.#t.setAttribute("part","subagent-row"),this.#t.setAttribute("aria-expanded","false"),this.#t.disabled=!0;let n=document.createElement("span");n.className="subagent-icon",n.setAttribute("part","subagent-icon"),n.setAttribute("aria-hidden","true"),this.#n=document.createElement("span"),this.#n.className="subagent-status",this.#n.setAttribute("part","subagent-status"),this.#n.textContent=e.subAgentWorking,this.#t.append(n,this.#n),this.#e=document.createElement("div"),this.#e.className="subagent-steps",this.#e.setAttribute("part","subagent-steps"),this.#e.setAttribute("role","list"),this.#e.setAttribute("aria-label",e.subAgentSteps),this.#e.hidden=!0,this.#t.addEventListener("click",()=>{this.#o(this.#t.getAttribute("aria-expanded")!=="true")}),this.element.append(this.#t,this.#e)}report(e){this.element.setAttribute("data-phase",e.phase),e.agent!==null&&this.element.setAttribute("data-agent",e.agent),e.status!==null&&(this.#n.textContent=e.status),e.tool!==null&&this.#r(e.tool)}#r(e){let n=this.#s.get(e.toolCallId)??this.#i(e);if(e.ok===null){n.removeAttribute("data-ok");return}n.setAttribute("data-ok",String(e.ok))}#i(e){let n=document.createElement("div");n.className="subagent-step",n.setAttribute("part","subagent-step"),n.setAttribute("role","listitem"),n.setAttribute("data-tool-call-id",e.toolCallId);let r=document.createElement("span");r.className="subagent-step-icon",r.setAttribute("part","subagent-step-icon"),r.setAttribute("aria-hidden","true");let o=document.createElement("span");return o.className="subagent-step-name",o.setAttribute("part","subagent-step-name"),o.textContent=e.name,n.append(r,o),this.#e.appendChild(n),this.#s.set(e.toolCallId,n),this.#t.disabled=!1,n}#o(e){this.#e.hidden=!e,this.#t.setAttribute("aria-expanded",String(e))}};var Uy=Object.values(Ql);function ip(t){return typeof t!="object"||t===null||Array.isArray(t)?null:t}function kr(t){return typeof t=="string"&&t!==""?t:null}function Hy(t){let e=ip(t);if(e===null)return null;let n=kr(e.toolCallId),r=kr(e.name),o=e.ok;return n===null||r===null||o!==null&&typeof o!="boolean"?null:{toolCallId:n,name:r,ok:o}}function sp(t){let e=ip(t);if(e===null)return null;let n=kr(e.delegationId),r=e.phase;return n===null||typeof r!="string"||!Uy.includes(r)?null:{delegationId:n,phase:r,agent:kr(e.agent),status:kr(e.status),tool:Hy(e.tool)}}var Fy=4,zy=120;function ap(t){if(typeof t!="object"||t===null)return null;let e=t.prompts;if(!Array.isArray(e))return null;let n=e.filter(r=>typeof r=="string").map(r=>r.trim()).filter(r=>r!==""&&r.length<=120).slice(0,4);return n.length===0?null:n}function hl(t,e,n){let r=ap(t);if(r===null)return null;let o=document.createElement("div");o.className="suggestions",o.setAttribute("part","suggestions"),o.setAttribute("role","group"),o.setAttribute("aria-label",e.suggestions);for(let i of r){let s=document.createElement("button");s.type="button",s.className="suggestion-chip",s.setAttribute("part","suggestion-chip"),s.textContent=i,s.addEventListener("click",()=>n(i)),o.appendChild(s)}return o}var Bi=class{element;#t;#n;#e;#s;#r=!1;constructor(e=ee){this.#s=e,this.element=document.createElement("div"),this.element.className="thoughts",this.element.setAttribute("part","thoughts"),this.element.setAttribute("data-streaming",""),this.#e=document.createElement("button"),this.#e.type="button",this.#e.className="thoughts-toggle",this.#e.setAttribute("part","thoughts-toggle"),this.#e.setAttribute("aria-expanded","true"),this.#t=document.createElement("span"),this.#t.className="thoughts-label",this.#t.setAttribute("part","thoughts-label"),this.#t.textContent=e.thinking,this.#e.append(this.#t),this.#n=document.createElement("pre"),this.#n.className="thoughts-body",this.#n.setAttribute("part","thoughts-body"),this.#e.addEventListener("click",()=>{this.#i(!this.#r)}),this.element.append(this.#e,this.#n)}stream(e){this.#n.textContent=e}collapse(){this.#r||(this.element.removeAttribute("data-streaming"),this.#t.textContent=this.#s.thoughts,this.#i(!0))}#i(e){this.#r=e,this.#n.hidden=e,this.#e.setAttribute("aria-expanded",String(!e))}};var Vi=class{element;#t;#n;#e;#s;#r;#i=null;#o;#u=[];#c="";#d=null;constructor(e,n=ee){this.#t=e,this.#o=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.#n=document.createElement("div"),this.#n.className="drawer-panel",this.#n.setAttribute("part","drawer-panel"),this.#n.setAttribute("role","dialog"),this.#n.setAttribute("aria-modal","true"),this.#n.setAttribute("aria-label",n.chatHistory),this.#n.addEventListener("keydown",i=>this.#v(i));let o=document.createElement("div");o.className="drawer-header",o.setAttribute("part","drawer-header"),this.#e=document.createElement("span"),this.#e.className="drawer-title",this.#e.setAttribute("part","drawer-title"),this.#e.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.#t.onNew()}),o.append(this.#e,this.#s),this.#r=document.createElement("div"),this.#r.className="drawer-list",this.#r.setAttribute("part","drawer-list"),this.#n.append(o,this.#r),this.element.append(r,this.#n)}setRelativeTimeFormatter(e){this.#i=e}#a(e){return this.#i!==null?this.#i(e):vr(e,void 0,this.#o)}setStrings(e){this.#o=e,this.#n.setAttribute("aria-label",e.chatHistory),this.#e.textContent=e.chats,this.#s.textContent=e.newChat,this.#m()}isOpen(){return!this.element.hidden}open(){this.isOpen()||(this.#d=this.#p(),this.element.hidden=!1,this.#s.focus())}close(){this.isOpen()&&(this.element.hidden=!0,this.#d?.focus(),this.#d=null)}toggle(){this.isOpen()?this.close():this.open()}#p(){return this.element.getRootNode().activeElement}#v(e){if(e.key==="Escape"){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;let n=Array.from(this.#n.querySelectorAll("button, input, [tabindex]")).filter(s=>!s.hidden),r=n[0],o=n[n.length-1],i=this.#p();e.shiftKey&&i===r?(e.preventDefault(),o?.focus()):!e.shiftKey&&i===o&&(e.preventDefault(),r?.focus())}setThreads(e,n){this.#u=e,this.#c=n,this.#m()}#m(){if(this.#r.replaceChildren(),this.#u.length===0){let e=document.createElement("div");e.className="drawer-empty",e.setAttribute("part","drawer-empty"),e.textContent=this.#o.noConversations,this.#r.appendChild(e);return}for(let e of this.#u)this.#r.appendChild(this.#y(e))}#y(e){let n=document.createElement("div");n.className="drawer-row",n.setAttribute("part","drawer-row"),e.threadId===this.#c&&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=this.#a(e.updatedAt);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.#t.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.#o.rename,a.setAttribute("aria-label",this.#o.renameConversation),a.textContent="\u270E",a.addEventListener("click",()=>this.#U(n,e));let l=document.createElement("button");l.type="button",l.className="drawer-row-delete",l.setAttribute("part","drawer-row-delete"),l.title=this.#o.delete,l.setAttribute("aria-label",this.#o.deleteConversation),l.textContent="\u{1F5D1}",l.addEventListener("click",()=>this.#T(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}#U(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.#m():this.#t.onRename(n.threadId,a)},s=()=>{o||(o=!0,this.#m())};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()}#T(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.#o.deletePrompt;let i=document.createElement("button");i.type="button",i.className="drawer-confirm-yes",i.setAttribute("part","drawer-confirm-yes"),i.textContent=this.#o.delete,i.addEventListener("click",()=>this.#t.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.#o.cancel,s.addEventListener("click",()=>this.#m()),r.append(o,i,s),e.replaceChildren(r)}};function fl(t){return{[te.PENDING]:t.toolRunning,[te.DEFERRED]:t.toolDeferred,[te.DONE]:t.toolDone,[te.ERROR]:t.toolError,[te.DECLINED]:t.toolDeclined}}function Gy(t){return{[te.DONE]:t.resultLabel,[te.ERROR]:t.errorLabel,[te.DECLINED]:t.declinedLabel}}function $y(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}var Cr=class{element;approvalSlot;subagentSlot;#t;#n;#e;#s;#r;#i;#o;args;#u;#c;#d=!1;constructor(e,n,r,o=ee,i={}){this.#o=o,this.args=n,this.#u=e,this.#c=i.formatPayload??null,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",te.PENDING),this.element.setAttribute("data-expanded","false");let s=document.createElement("div");s.className="tool-call-head",s.setAttribute("part","tool-card-head");let a=document.createElement("span");a.className="tool-call-icon",a.setAttribute("part","tool-card-icon"),a.setAttribute("aria-hidden","true");let l=document.createElement("span");l.className="tool-call-name",l.setAttribute("part","tool-card-name"),l.textContent=r??e,this.#t=document.createElement("span"),this.#t.className="tool-call-status",this.#t.setAttribute("part","tool-card-status"),this.#t.textContent=fl(o)[te.PENDING],this.#n=document.createElement("span"),this.#n.className="tool-call-decision",this.#n.setAttribute("part","tool-card-decision"),this.#n.hidden=!0,s.append(a,l,this.#t,this.#n);let c=this.#p("args",o.argumentsLabel);this.#a(c.body,{kind:"arguments",toolName:e,args:n},JSON.stringify(n,null,2)),c.root.hidden=Object.keys(n).length===0;let u=this.#p("result",o.resultLabel);this.#s=u.root,this.#r=u.label,this.#i=u.body,u.root.hidden=!0,this.#e=document.createElement("button"),this.#e.type="button",this.#e.className="tool-call-toggle",this.#e.setAttribute("part","tool-card-toggle"),this.#e.setAttribute("aria-expanded","false"),this.#e.textContent=o.details,this.#e.addEventListener("click",()=>this.#m(!this.#v()));let m=document.createElement("div");m.className="tool-call-body",m.setAttribute("part","tool-card-body"),m.append(c.root,u.root),this.approvalSlot=document.createElement("div"),this.approvalSlot.className="tool-call-approval",this.approvalSlot.setAttribute("part","tool-card-approval"),this.subagentSlot=document.createElement("div"),this.subagentSlot.className="tool-call-subagent",this.subagentSlot.setAttribute("part","tool-card-subagent"),this.element.append(s,this.subagentSlot,this.#e,m,this.approvalSlot)}mark(e){this.#d||(this.element.setAttribute("data-status",e),this.#t.textContent=fl(this.#o)[e])}recordDecision(e){this.element.setAttribute("data-decision",e),this.#n.textContent=e==="approved"?this.#o.decisionApproved:this.#o.decisionDeclined,this.#n.hidden=!1}get settled(){return this.#d}settle(e,n){this.#d||(this.#d=!0,this.element.setAttribute("data-status",e),this.#t.textContent=fl(this.#o)[e],this.#r.textContent=Gy(this.#o)[e],this.#a(this.#i,{kind:"result",toolName:this.#u,status:e,text:n},$y(n)),this.#s.hidden=!1)}#a(e,n,r){let o=this.#c===null?null:this.#c(n);if(o===null){e.textContent=r;return}if(e.setAttribute("data-formatted","true"),typeof o=="string"){e.textContent=o;return}e.replaceChildren(o)}#p(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}}#v(){return this.element.getAttribute("data-expanded")==="true"}#m(e){this.element.setAttribute("data-expanded",String(e)),this.#e.setAttribute("aria-expanded",String(e))}};var lp=12e4,ji=class{element;#t;#n;#e;#s="idle";#r=null;#i=null;#o=[];#u=null;#c=!1;#d=!1;constructor(e){this.#t=e.transcribe,this.#n=e.onText,this.#e=e.strings??ee,this.element=document.createElement("button"),this.element.type="button",this.element.className="voice-btn",this.element.setAttribute("part","voice-button");let n=document.createElement("slot");n.name="icon-voice",n.innerHTML=nc,this.element.append(n),this.#T("idle"),this.element.addEventListener("click",()=>{this.toggle()})}async toggle(){if(this.#s==="recording"){this.#p();return}this.#s!=="transcribing"&&await this.#a()}async#a(){let e;try{e=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{this.#U(this.#e.transcriptionFailed);return}this.#i=e,this.#o=[],this.#c=!1;let n=new MediaRecorder(e);n.addEventListener("dataavailable",r=>{this.#o.push(r.data)}),n.addEventListener("stop",()=>{this.#m(n.mimeType)}),this.#r=n,n.start(),this.#u=setTimeout(()=>{this.#c=!0,this.#p()},lp),this.#T("recording")}#p(){this.#v(),this.#r?.stop()}#v(){this.#u!==null&&(clearTimeout(this.#u),this.#u=null)}dispose(){this.#d=!0,this.#v(),this.#r!==null&&this.#r.state!=="inactive"&&this.#r.stop(),this.#r=null,this.#y()}async#m(e){if(this.#d)return;this.#y(),this.#T("transcribing");let n=new Blob(this.#o,{type:e||"audio/webm"});try{let r=await this.#t(n);this.#T("idle"),this.#c&&(this.element.title=this.#e.recordingLimit.replace("{n}",String(lp/6e4))),r!==""&&this.#n(r)}catch(r){this.#U(r instanceof Error?r.message:this.#e.transcriptionFailed)}finally{this.#r=null}}#y(){for(let e of this.#i?.getTracks()??[])e.stop();this.#i=null}#U(e){this.#y(),this.#r=null,this.#T("idle"),this.element.title=e}#T(e){this.#s=e,this.element.dataset.state=e;let n=this.#M(e);this.element.title=n,this.element.setAttribute("aria-label",n),this.element.setAttribute("aria-pressed",String(e==="recording")),this.element.disabled=e==="transcribing"}#M(e){return e==="recording"?this.#e.stopRecording:e==="transcribing"?this.#e.transcribing:this.#e.recordVoice}};var qi=class extends Error{constructor(e){super(e),this.name="ConnectionLostError"}},Bn=class{#t;#n;#e;#s;#r;#i;#o;#u=new Set;#c;#d;#a=!1;constructor(e){this.#t=e.agent,this.#n=e.handlers,this.#e=e.getTools??(()=>[]),this.#s=e.getContext??(()=>[]),this.#r=e.executeTool??null,this.#i=e.resolveInterrupts??null,this.#o=e.onPersist??(()=>{}),this.#c=e.connectionLostMessage??"Connection lost";let n=e.maxToolRounds??vn;this.#d=n>=1?Math.floor(n):vn;let r=e.onStateChanged;r!==void 0&&this.#t.subscribe({onStateChanged:({state:o})=>{r(o)}})}get state(){return this.#t.state}setState(e){this.#t.setState({...e})}get running(){return this.#t.isRunning}get messages(){return this.#t.messages}async send(e,n=[]){let r={id:_e(),role:"user",content:e};n.length>0&&(r.attachments=n),this.#t.addMessage(r),this.#o(this.#t.messages),await this.#p()}truncateToLastUser(){let e=[...this.#t.messages],n=-1;for(let[o,i]of e.entries())i.role==="user"&&(n=o);if(n===-1)return null;let r=e.slice(0,n+1);return this.#t.setMessages(r),this.#o(this.#t.messages),r}async resume(){await this.#p()}addToolResult(e,n){this.#t.addMessage({id:_e(),role:"tool",content:n,toolCallId:e}),this.#o(this.#t.messages)}cancel(){this.#a=!0,this.#t.abortRun()}async#p(){this.#a=!1;try{await this.#m(),this.#a&&this.#v()}catch(e){this.#a||By(e)?this.#v():this.#n.onError(e instanceof Error?e.message:String(e))}finally{this.#n.onSettled()}}#v(){this.#o(this.#t.messages),this.#n.onCancelled()}async#m(){let e;for(let n=0;n<this.#d;n+=1){if(this.#a)return;let r=[],o={terminal:!1,errored:!1,interrupts:[]},i={tools:this.#e(),context:this.#s()};if(e!==void 0&&(i.resume=e),await this.#t.runAgent(i,this.#y(r,o)),e=void 0,this.#o(this.#t.messages),this.#a)return;if(!o.terminal)throw new qi(this.#c);if(o.errored)return;if(o.interrupts.length>0){if(this.#i===null)return;let a=await this.#i(o.interrupts);if(this.#a)return;e=Jd(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.#t.addMessage({id:_e(),role:"tool",content:l.content,toolCallId:a.id}),this.#o(this.#t.messages),s=!0}}if(!s)return}}#y(e,n){let r=this.#n,o=this.#u,i=()=>this.#a,s=new Set;return{onRunInitialized(){r.onRunStart()},onTextMessageStartEvent({event:a}){o.has(a.messageId)&&console.warn(`<ag-ui-chat>: the server reused message id "${a.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:a}){r.onTextDelta(a)},onTextMessageEndEvent({event:a,textMessageBuffer:l}){o.add(a.messageId),r.onTextEnd(l)},onToolCallEndEvent({event:a,toolCallName:l,toolCallArgs:c}){let u={id:a.toolCallId,name:l,args:c};e.push(u),r.onToolCall(u)},onToolCallResultEvent({event:a}){r.onToolResult(a.toolCallId,a.content)},onActivitySnapshotEvent({event:a,messages:l}){if(l.some(u=>u.id===a.messageId&&u.role==="activity")){r.onActivityChanged(a.messageId,a.activityType,a.content);return}r.onActivity(a.activityType,a.content,a.messageId)},onActivityDeltaEvent({event:a}){s.add(a.messageId)},onCustomEvent({event:a}){r.onCustomEvent(a.name,a.value)},onMessagesSnapshotEvent({event:a}){r.onMessagesSnapshot(a.messages)},onMessagesChanged({messages:a}){if(s.size!==0){for(let l of s){let c=a.find(u=>u.id===l);c!==void 0&&c.role==="activity"&&r.onActivityChanged(l,c.activityType,c.content)}s.clear()}},onReasoningStartEvent(){r.onReasoningStart()},onReasoningMessageContentEvent({reasoningMessageBuffer:a}){r.onReasoningDelta(a)},onReasoningMessageEndEvent({reasoningMessageBuffer:a}){r.onReasoningDelta(a)},onReasoningEndEvent(){r.onReasoningEnd()},onRunFinishedEvent(a){n.terminal=!0,a.outcome==="interrupt"&&(n.interrupts=a.interrupts)},onRunErrorEvent({event:a}){n.terminal=!0,n.errored=!0,!i()&&r.onError(a.message)},onRunFinalized(){n.terminal=!0,r.onRunEnd()}}}};function By(t){return t instanceof Error?t.name==="AbortError"||t instanceof TypeError&&/abort/i.test(t.message):!1}function ml(t){let e=t.attachments;return Array.isArray(e)?e.filter(Vy):[]}function Vy(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 cp="ag-ui-chat",Vn="thread",gl="threads",Ir="messages:",Xi="checkpoint:",Rr="minted:",jy=60,qy=100,Wy="New conversation",dp=!1;function et(t,e){try{sessionStorage.setItem(t,e)}catch{if(dp)return;dp=!0,console.warn("<ag-ui-chat>: the browser refused a sessionStorage write \u2014 the quota is full, or storage is disabled for this context. The conversation continues, but it will not survive a page reload. Deleting a long conversation from the history drawer frees the quota.")}}function Wi(t){return t===""?cp:`${cp}@${t}`}var je=class t{#t;constructor(e=""){this.#t=Wi(e),e!==""&&t.adopt("",e)}static adopt(e,n){let r=`${Wi(e)}:`,o=`${Wi(n)}:`;for(let[i,s]of up(r)){let a=sessionStorage.getItem(i),l=o+s;a!==null&&sessionStorage.getItem(l)===null&&et(l,a),sessionStorage.removeItem(i)}}static purge(e){for(let[n]of up(`${Wi(e)}:`))sessionStorage.removeItem(n)}threadId(){return sessionStorage.getItem(this.#r(Vn))??this.newThread()}newThread(){let e=_e();return et(this.#r(Vn),e),et(this.#r(Rr+e),"1"),e}isUnsent(e){return sessionStorage.getItem(this.#r(Rr+e))!==null&&sessionStorage.getItem(this.#r(Ir+e))===null}loadMessages(e){return Promise.resolve(this.#i(this.#r(Ir+e)))}saveMessages(e,n){et(this.#r(Ir+e),JSON.stringify(n)),sessionStorage.removeItem(this.#r(Rr+e)),this.#n(e,n)}loadCheckpoint(e){return this.#i(this.#r(Xi+e))}saveCheckpoint(e,n){let r=this.#r(Xi+e);if(n===null){sessionStorage.removeItem(r);return}et(r,JSON.stringify(n))}clear(e){sessionStorage.removeItem(this.#r(Ir+e)),sessionStorage.removeItem(this.#r(Xi+e)),sessionStorage.removeItem(this.#r(Rr+e)),this.#s(this.#e().filter(n=>n.threadId!==e)),sessionStorage.getItem(this.#r(Vn))===e&&sessionStorage.removeItem(this.#r(Vn))}listThreads(){let e=this.#e().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){et(this.#r(Vn),e)}renameThread(e,n){let r=this.#e(),o=r.find(i=>i.threadId===e);o!==void 0&&(o.title=n,o.titleCustom=!0,this.#s(r))}#n(e,n){let r=this.#e(),o=r.find(a=>a.threadId===e),i=Yy(n),s=Date.now();o===void 0?r.push({threadId:e,title:pp(n),titleCustom:!1,preview:i,updatedAt:s}):(o.preview=i,o.updatedAt=s,o.titleCustom||(o.title=pp(n))),this.#s(r)}#e(){return this.#i(this.#r(gl))??[]}#s(e){let n=this.#r(gl);if(e.length===0){sessionStorage.removeItem(n);return}et(n,JSON.stringify(e))}#r(e){return`${this.#t}:${e}`}#i(e){let n=sessionStorage.getItem(e);if(n===null)return null;try{return JSON.parse(n)}catch{return null}}};function up(t){let e=[];for(let n=0;n<sessionStorage.length;n+=1){let r=sessionStorage.key(n);if(r===null||!r.startsWith(t))continue;let o=r.slice(t.length);Xy(o)&&e.push([r,o])}return e}function Xy(t){return t===Vn||t===gl||t.startsWith(Ir)||t.startsWith(Xi)||t.startsWith(Rr)}function pp(t){for(let e of t)if(e.role==="user"){let n=hp(e.content);if(n!=="")return fp(n,jy)}return Wy}function Yy(t){for(let e of[...t].reverse()){let n=hp(e.content);if(n!=="")return fp(n,qy)}return""}function hp(t){return typeof t=="string"?t.replace(/\s+/g," ").trim():""}function fp(t,e){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}\u2026`}function qe(t,e){return e===void 0?t:{...t,credentials:e}}function Yi(t){if(t.newThread!==void 0)return t.newThread();let e=_e();return t.setActiveThread(e),e}function Ki(t,e,n,r){if(e.length===0)return;let o=new URL(String(t),location.href).origin;o===location.origin||n.includes(o)||r.has(o)||(r.add(o),console.warn(`<ag-ui-chat>: sending host credentials (${e.join(", ")}) to ${o}, which is not this page's origin (${location.origin}). Those headers are the page's own authentication, and whichever server answers the browser's preflight receives them \u2014 so a URL attribute built from a query parameter or from tenant-authored configuration is a channel for the token to leave on. If this destination is deliberate, name it in \`trustedOrigins\` to confirm it and silence this notice. Reported once per origin.`))}function vl(t){let e=t.headers??{},n=new Set;return new eu({url:t.endpoint,headers:e,initialState:{...t.initialState??{}},fetch:(r,o)=>{let i=t.getHeaders?.(),s=[...new Set([...Object.keys(e),...Object.keys(i??{})])].sort();if(Ki(r,s,t.trustedOrigins??[],n),i===void 0)return fetch(r,qe(o,t.credentials));let a=new Headers(o?.headers);for(let[l,c]of Object.entries(i))a.set(l,c);return fetch(r,qe({...o,headers:a},t.credentials))},...t.threadId!==void 0?{threadId:t.threadId}:{},...t.initialMessages!==void 0?{initialMessages:[...t.initialMessages]}:{}})}var Nr=class{#t;#n;#e;#s;#r;#i=new Set;#o=new Map;constructor(e,n=()=>({}),r=new je,o=()=>{},i=!0){this.#t=e.endsWith("/")?e:`${e}/`,this.#n=n,this.#e=r,this.#s=o,this.#r=i}threadId(){return this.#e.threadId()}setActiveThread(e){this.#e.setActiveThread(e)}newThread(){return Yi(this.#e)}isUnsent(e){return this.#e.isUnsent?.(e)===!0}saveMessages(e,n){this.#e.saveMessages(e,this.#r?n:[])}loadCheckpoint(e){return this.#e.loadCheckpoint(e)}saveCheckpoint(e,n){this.#e.saveCheckpoint(e,n)}renameThread(e,n){this.#e.renameThread(e,n),this.#o.set(e,n),this.#p(e,"PATCH",{title:n})}clear(e){this.#e.clear(e),this.#i.add(e),this.#p(e,"DELETE")}async listThreads(){let e=await this.#u();return e===null?this.#e.listThreads():e.filter(n=>!this.#i.has(n.thread_id)).map(n=>this.#d(n))}async loadMessages(e){if(this.#e.isUnsent?.(e)===!0)return null;let n=await this.#a(`${this.#t}${encodeURIComponent(e)}/`);if(n===null||!n.ok)return this.#e.loadMessages(e);let r=await this.#c(n);return r===null?this.#e.loadMessages(e):r.messages??null}async#u(){let e=await this.#a(this.#t);if(e===null||!e.ok)return null;let n=await this.#c(e);return n===null?null:n.threads??[]}async#c(e){try{return await e.json()}catch{return null}}#d(e){return{threadId:e.thread_id,title:this.#o.get(e.thread_id)??e.title,updatedAt:e.updated_at===null?Number.NaN:Date.parse(e.updated_at),preview:e.preview}}async#a(e){try{return await fetch(e,qe({headers:this.#n()},this.#s()))}catch{return null}}async#p(e,n,r){let o=this.#n();try{await fetch(`${this.#t}${encodeURIComponent(e)}/`,qe({method:n,headers:r===void 0?o:{...o,"content-type":"application/json"},body:r===void 0?null:JSON.stringify(r)},this.#s()))}catch{}}};var Or=class{#t;#n;#e;constructor(e,n=()=>({}),r=()=>{}){this.#t=e.endsWith("/")?e:`${e}/`,this.#n=n,this.#e=r}async list(){try{let e=await fetch(this.#t,qe({method:"GET",headers:{Accept:"application/json",...this.#n()}},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.#s("resume",e)}forkUrl(e){return this.#s("fork",e)}#s(e,n){return`${this.#t.slice(0,-5)}${e}/${encodeURIComponent(n)}/`}};async function bl(t,e){let n=new FormData;n.append("audio",t,"recording.webm");let r=await fetch(e.url,qe({method:"POST",headers:{...e.headers??{}},body:n},e.credentials));if(!r.ok)throw new Error(await Ky(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 Ky(t){try{let e=await t.json();if(typeof e.error=="string")return e.error}catch{}return`transcription failed (${t.status})`}function yl(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(Zy(JSON.parse(i.responseText)))}catch{r(new Error("upload returned an unreadable response"))}else r(new Error(Qy(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 Zy(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 Qy(t){try{let e=JSON.parse(t.responseText);if(typeof e.error=="string")return e.error}catch{}return`upload failed (${t.status})`}var Jy=["data-attachments-url","data-attachment-accept","data-attachment-max-bytes","data-transcribe-url","data-threads-url","data-threads-cache","data-tools-url","data-skills-url","data-skills","data-prompt-chips","data-slash-commands","data-theme-toggle","data-strings","data-icon-url"],_l=["omit","same-origin","include"];function xl(t){return _l.includes(t)}var mp="ag-ui-chat:collapsed",gp="ag-ui-chat:size",vp="ag-ui-chat:theme",wl=6,El=new Set,Mr=class extends HTMLElement{agentFactory=vl;headers={};getHeaders=null;trustedOrigins=[];allowImages=!1;formatRelativeTime=null;autoConfirm=!1;askUser=!1;askUserRenderer=null;approvalRenderer=null;approveWithEdits=!1;confirmPredicate=null;getTools=()=>[...this.#Je().map(e=>({name:e.name,description:e.description,parameters:e.parameters})),...this.#r.tools()];getContext=()=>[...Ra(this.getPageMap,this.autoInjectPageMap)];routeMap=[];navigate=null;getPageMap=null;autoInjectPageMap=!0;conversationStore=new je;uploadHandler=null;transcribeHandler=null;navigationResult=()=>({navigated:!0,url:window.location.href});skillContext=()=>({});toolSummaries={};formatToolPayload=null;strings={};resolvePageTarget=e=>document.querySelector(e);#t={};#n=new Set;#e=ee;#s=new Set;#r=new pr;#i=new Map;#o=new Map;#u=new Map;#c=new Set;#d=new Map;#a=new Map;#p=new Set;#v=[];#m=new Set;#y=null;#U=new Set;#T;#M=document.createElement("div");#z=document.createElement("button");#b=document.createElement("button");#Te="";#Y=null;#ce=document.createElement("div");#g;#G=null;#de=!1;#x;#f;#l;#w;#Se;#H;#$;#E;#Ae=null;#R;#A;#k;#ue;#L;#C;#P;#pe=0;#B;#S=null;#he;#ke=null;#K=!1;#V=null;#Z={};#j=!1;#Ce=null;#N=null;#fe=null;#Ie=0;#me="";#q=null;#ge=null;#D=null;#W=null;#h="";#Q="";#ve=null;#Re="";#Ye="";#ne=null;#Ne=0;#Oe=[];#Ke=[];#Ze=[];#Qe=[];constructor(){super(),this.#T=this.attachShadow({mode:"open"}),this.#x=document.createElement("div"),this.#f=document.createElement("div"),this.#l=document.createElement("textarea"),this.#w=document.createElement("button"),this.#Se=document.createElement("span"),this.#R=document.createElement("div"),this.#A=document.createElement("button"),this.#k=document.createElement("input"),this.#ue=document.createElement("div"),this.#he=document.createElement("span"),this.#L=document.createElement("button"),this.#C=document.createElement("button"),this.#P=document.createElement("span"),this.#B=document.createElement("div"),this.registerActivityRenderer({type:Is,render:e=>{let n=rx(e);return n===null?null:pl("\u{1F5DC}",this.#e.historyCompacted.replace("{count}",String(n)),"compaction")}}),this.registerActivityRenderer({type:Ss,render:e=>hl(e,this.#e,n=>{this.sendMessage(n)})}),this.#H=new Gi(e=>this.#Kt(e)),this.#$=new Vi({onSelect:e=>{this.#nn(e)},onNew:()=>{this.newChat(),this.#se()},onRename:(e,n)=>{this.conversationStore.renameThread(e,n),this.#se()},onDelete:e=>{this.#rn(e)}}),this.#E=new br((e,n)=>{this.#kt(e,n)})}#Me(){let e=this.getAttribute("data-runs-url");return e===null||e===""?null:(this.#Ae===null&&(this.#Ae=new Or(e,()=>this.#oe(e),()=>this.#be())),this.#Ae)}async#kt(e,n){let r=this.#Me();if(r===null)return;let o=this.#l.value.trim();if(o==="")return;this.#l.value="",this.#J();let i=n==="resume"?r.resumeUrl(e):r.forkUrl(e),s=this.agentFactory({endpoint:i,headers:this.#re(),getHeaders:()=>this.#re(),trustedOrigins:this.trustedOrigins,...this.#ye(),threadId:this.#h,initialMessages:[]});await new Bn({agent:s,handlers:this.#wt(),getTools:()=>this.#et(),getContext:()=>this.#ht(),executeTool:l=>this.#yt(l),resolveInterrupts:l=>this.#xt(l),connectionLostMessage:this.#e.connectionLost}).send(o)}async#Ct(){let e=this.#Me();this.#E.setRelativeTimeFormatter(this.formatRelativeTime),this.#E.setRuns(e===null?[]:await e.continuable())}static get observedAttributes(){return["title-text","placement","credentials","user-key",...Jy]}attributeChangedCallback(e,n,r){if(e==="credentials"){r!==null&&!xl(r)&&console.error(`<ag-ui-chat>: credentials="${r}" is not a fetch credentials mode (${_l.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.#Qt(),requestAnimationFrame(()=>this.#He());return}if(e==="title-text"){this.#Se.textContent=r??this.#e.title;return}if(e==="user-key"){this.#K&&(n??"")!==(r??"")&&this.#tn(n??"",r??"");return}n===r||!this.#K||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.#r.register(e)}get sharedState(){return this.#V?.state??this.#Z}set sharedState(e){this.#Z={...e},this.#V?.setState(this.#Z)}registerPageState(e){for(let n of Si(e))this.#r.register(n)}registerStateHook(e){this.registerPageState(e)}#It(){return this.routeMap.length===0?[]:Oa(()=>this.routeMap,()=>this.navigate)}#Rt(){let e=this.getPageMap;return e===null?[]:[{name:ks,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:[],[Pe]:"Read the page"},handler:()=>e()}]}#Nt(){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 Ia(n,r=>this.resolvePageTarget(r))}#Je(){return[...this.#It(),...this.#Rt(),...this.#Nt(),...this.#Ot()]}#Ot(){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.#Mt(e)}]:[]}async#Mt(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.#N=new AbortController;let i=this.#N.signal;this.#O();let s=this.askUserRenderer!==null?await this.askUserRenderer(r,{signal:i}):await qa(this.#I(),r,{signal:i,strings:this.#e});return this.#N=null,this.#_(),this.#g.follow(),s}#et(){let e=this.getTools();return this.#s=new Set(e.map(n=>n.name)),e}#Le(e){let n=this.#Je().find(r=>r.name===e);return n!==void 0?n:this.#r.has(e)?this.#r.get(e):null}get endpoint(){return this.getAttribute("endpoint")??""}set endpoint(e){this.setAttribute("endpoint",e)}get userKey(){return this.getAttribute("user-key")??""}set userKey(e){this.setAttribute("user-key",e)}get credentials(){let e=this.getAttribute("credentials");return e!==null&&xl(e)?e:null}set credentials(e){if(e===null){this.removeAttribute("credentials");return}if(!xl(e))throw new TypeError(`<ag-ui-chat>: credentials must be one of ${_l.map(n=>`"${n}"`).join(", ")} (got ${JSON.stringify(e)}).`);this.setAttribute("credentials",e)}#re(){return{...this.headers,...this.getHeaders?.()}}#oe(e){let n=this.#re();return Ki(e,Object.keys(n),this.trustedOrigins,this.#n),n}#be(){return this.credentials??void 0}#ye(){let e=this.#be();return e===void 0?{}:{credentials:e}}#tt(e){return qe({headers:this.#oe(e)},this.#be())}get toolDisplay(){let e=this.getAttribute("data-tool-display");return e===yn.INLINE||e===yn.MINIMAL||e===yn.COMPACT?e:yn.FULL}set toolDisplay(e){this.setAttribute("data-tool-display",e)}connectedCallback(){if(this.#Q=this.#en(),this.#Fe(this.#ct()),requestAnimationFrame(()=>this.#He()),this.#e=Ma({...this.#Pt(),...this.strings}),this.getAttribute("data-theme-toggle")!==null){let e=this.#Ge(vp);e!==null&&this.setAttribute("theme",e)}if(this.#ln(),this.#$.setStrings(this.#e),this.#E.setStrings(this.#e),this.#Ge(mp)==="1"&&this.setAttribute("collapsed",""),this.#vt(),this.#Xt(),this.conversationStore instanceof je){let e=this.#ze();this.#ne=e===""?this.conversationStore:new je(e),this.conversationStore=this.#ne}this.#ot(),this.#Dt(),this.#Ht(),this.#h=this.conversationStore.threadId(),queueMicrotask(()=>this.#Lt()),this.#we(),this.#K=!0}#Lt(){this.#K&&(this.#it(),this.#st())}async reload(){this.#F(),this.#ie(),this.#X(!1),await Promise.all([this.#it(),this.#st(),this.#we()])}disconnectedCallback(){this.#K=!1,this.#ve!==null&&(El.delete(this.#ve),this.#ve=null),this.#F(),this.#Y?.detach(),this.#Y=null,this.#S?.dispose(),this.#ke?.dispose(),this.#g.dispose(),this.#G!==null&&(clearTimeout(this.#G),this.#G=null)}#nt(e){let n=this.getAttribute(e);return n!==null&&n!=="false"}#Pt(){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{}}#Dt(){let e=this.getAttribute("data-attachments-url"),n=this.uploadHandler??this.#Ut(e);if(n===null)return;let r=this.getAttribute("data-attachment-accept")??"",o=new ki({upload:n,maxBytes:this.#jt(),accept:r,strings:this.#e,onChange:()=>this.#fn(o)});this.#S=o,this.#ue.appendChild(this.#S.element),this.#k.accept=r,this.#A.hidden=!1,this.#Wt()}#Ut(e){return e===null?null:(n,r,o)=>yl(n,{url:e,headers:this.#oe(e),...this.#ye(),onProgress:r,signal:o})}#Ht(){let e=this.getAttribute("data-transcribe-url"),n=this.transcribeHandler??this.#Ft(e);n!==null&&(this.#ke=new ji({transcribe:n,onText:r=>this.#zt(r),strings:this.#e}),this.#he.appendChild(this.#ke.element))}#Ft(e){return e===null?null:n=>bl(n,{url:e,headers:this.#oe(e),...this.#ye()})}#zt(e){let n=this.#l.value.trim();this.#l.value=n===""?e:`${n} ${e}`,this.#bt(),this.#l.focus()}quote(e){let n=$a(e);if(n==="")return;let r=this.#l.value.replace(/\s+$/,"");this.#l.value=r===""?n:`${r}
|
|
2844
|
+
|
|
2845
|
+
${n}`,this.#J(),this.#l.focus();let o=this.#l.value.length;this.#l.setSelectionRange(o,o)}offerQuoteInPage(e=document.body){this.#Y?.detach();let n=Va({within:e,label:this.#e.quoteSelection,exclude:this,onQuote:r=>this.quote(r)});return this.#Y=n,()=>{n.detach(),this.#Y===n&&(this.#Y=null)}}#Gt(){return this.getAttribute("data-quote-selection")!=="false"}#rt(e){if(!this.#Gt())return;let n=e===void 0?void 0:{x:e.clientX,y:e.clientY},r=yr(this.#f,[this.#T],n);if(r===null){this.#Pe();return}this.#Te=r.text,this.#$t(r.rect)}#$t(e){this.#b.hidden=!1;let n=this.#ce.getBoundingClientRect(),r=e.top-n.top,o=r<wl+this.#b.offsetHeight;this.#b.dataset.below=String(o),this.#b.style.top=`${o?e.bottom-n.top+wl:r-wl}px`;let i=this.#b.offsetWidth/2,s=e.left+e.width/2-n.left;this.#b.style.left=`${Math.min(Math.max(s,i),n.width-i)}px`}#Pe(){this.#b.hidden=!0,this.#Te=""}#Bt(){let e=this.getAttribute("data-max-tool-rounds");return e===null?vn:Number.parseInt(e,10)}#Vt(){let e=this.getAttribute("data-message-actions");return e===null?new Set(Object.values(bn)):new Set(e.split(",").map(n=>n.trim()).filter(n=>n!==""))}#jt(){let e=this.getAttribute("data-attachment-max-bytes");if(e===null)return Cs;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:Cs}#qt(){let e=this.#k.files;if(e!==null)for(let n of Array.from(e))this.#S?.add(n);this.#k.value=""}#Wt(){this.#x.addEventListener("dragover",e=>{e.preventDefault(),this.#x.classList.add("chat--dragover")}),this.#x.addEventListener("dragleave",()=>{this.#x.classList.remove("chat--dragover")}),this.#x.addEventListener("drop",e=>{e.preventDefault(),this.#x.classList.remove("chat--dragover");let n=e.dataTransfer?.files;if(n!==void 0)for(let r of Array.from(n))this.#S?.add(r)})}#ot(){let e=this.getAttribute("data-threads-url");e!==null&&(this.conversationStore=new Nr(e,()=>this.#oe(e),this.conversationStore,()=>this.#be(),this.getAttribute("data-threads-cache")!=="false"))}async#it(){let e=this.getAttribute("data-tools-url");if(e!==null)try{let n=await fetch(e,this.#tt(e));this.#t=Na(await n.json())}catch{}}setSkills(e){this.#Qe=e,this.#De()}#Xt(){this.#H.enableChips(this.#nt("data-prompt-chips")),this.#H.enableSlash(this.#nt("data-slash-commands")),this.#Ze=this.#Yt(),this.#De()}#Yt(){let e=this.getAttribute("data-skills");if(e===null)return[];try{return ba(JSON.parse(e))}catch{return[]}}async#st(){let e=this.getAttribute("data-skills-url");if(e!==null)try{let n=await fetch(e,this.#tt(e));this.#Ke=ba(await n.json()),this.#De()}catch{}}#De(){let e=new Map;for(let n of[...this.#Ke,...this.#Ze,...this.#Qe])e.set(n.name,n);this.#H.setSkills([...e.values()])}#Kt(e){if(e.prompt===void 0){this.#R.hidden=!0,this.sendMessage(`/${e.name}`);return}let{text:n,missing:r}=tu(e.prompt,this.skillContext());if(r.length>0){this.#R.textContent=this.#e.skillNeeds.replace("{title}",e.title).replace("{fields}",r.join(", ")),this.#R.hidden=!1,this.#l.value=n,this.#J(),this.#l.focus(),this.#Zt(n);return}if(this.#R.hidden=!0,this.#l.value=n,this.#J(),e.sendImmediately===!1){this.#l.focus();return}this.#Be()}#Zt(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"),et(this.#xe(mp),e?"1":"0"),this.#_e(0),this.dispatchEvent(new CustomEvent(vs,{detail:{collapsed:e},bubbles:!0,composed:!0}))}get unread(){return this.#pe}toggleCollapsed(){this.setCollapsed(!this.collapsed)}toggleTheme(){let e=this.getAttribute("theme")==="dark"?"light":"dark";this.setAttribute("theme",e),et(this.#xe(vp),e),this.#ut()}#Ue(){switch(this.getAttribute("placement")){case"full":case"page":return"none";case"sidebar":case"side":return"width";default:return"both"}}#at(){let e=this.getBoundingClientRect(),n=this.style.getPropertyValue("--ag-ui-width"),r=this.style.getPropertyValue("--ag-ui-height");this.#Fe({width:e.width+1,height:e.height+1});let o=this.getBoundingClientRect();return this.#lt("--ag-ui-width",n),this.#lt("--ag-ui-height",r),{x:Math.abs(o.left-e.left)<.5?"left":"right",y:Math.abs(o.top-e.top)<.5?"top":"bottom"}}#He(){if(!this.#K)return;let e=this.#at();this.setAttribute("data-resize-anchor",`${e.y}-${e.x}`)}#lt(e,n){if(n===""){this.style.removeProperty(e);return}this.style.setProperty(e,n)}#Fe(e){let n=this.#Ue();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`))}#Qt(){let e=this.#Ue();e!=="both"&&this.style.removeProperty("--ag-ui-height"),e==="none"&&this.style.removeProperty("--ag-ui-width")}#Jt(e){let n={...this.#ct(),...e};et(this.#xe(gp),JSON.stringify(n))}#ct(){let e=this.#Ge(gp);if(e===null)return{};try{let n=JSON.parse(e);return typeof n=="object"&&n!==null?n:{}}catch{return{}}}#en(){let e=this.id!==""?this.id:this.endpoint;return e===""?"":this.#Ye===e?this.#Re:El.has(e)?(this.#Ye=e,this.#Re=`${e}~${_e()}`,console.warn(`<ag-ui-chat>: another element on this page already stores its conversation under "${e}", so this one has been given a throwaway namespace of its own \u2014 the two would otherwise share a thread pointer, a history drawer and every message. Give each <ag-ui-chat> its own id to keep them apart and let this one restore its conversation across reloads.`),this.#Re):(El.add(e),this.#ve=e,e)}#ze(e=this.userKey){return e===""?this.#Q:`${this.#Q}#${e}`}#tn(e,n){let r=this.#ze(e),o=this.#ze(n);if(e===""){je.adopt(r,o),this.#dt(o);return}je.purge(r),this.#dt(o),this.#F(),this.#ie(),this.#X(!1),this.#_e(0),this.#h=this.conversationStore.threadId(),this.#we(),this.#se()}#dt(e){this.#ne!==null&&(this.#ne=new je(e),this.conversationStore=this.#ne,this.#ot())}#xe(e){return this.#Q===""?e:`${e}:${this.#Q}`}#Ge(e){let n=sessionStorage.getItem(this.#xe(e));return n!==null||this.#Q===""?n:sessionStorage.getItem(e)}#ut(){let e=this.getAttribute("theme")==="dark";this.#L.textContent=e?"\u2600\uFE0F":"\u{1F319}"}openThreads(){this.#E.close(),this.#se(),this.#$.open()}openCheckpoints(){this.#$.close(),this.#Ct(),this.#E.open()}closeCheckpoints(){this.#E.close()}toggleCheckpoints(){if(this.#E.open_){this.#E.close();return}this.openCheckpoints()}newChat(){this.#F(),this.conversationStore.isUnsent?.(this.#h)===!0&&this.conversationStore.clear(this.#h),this.#ie(),this.#h=Yi(this.conversationStore),this.#X(!1),this.#_e(0)}#ie(){this.#V=null,this.#pt(),this.#Oe=[]}#pt(){this.#te(),this.#D=null,this.#W=null,this.#O(),this.#i.clear(),this.#o.clear(),this.#p.clear(),this.#d.clear(),this.#a.clear(),this.#y=null,this.#S?.clear(),this.#f.replaceChildren(this.#B),this.#_()}async retryLastTurn(){if(this.#j)return!1;let e=this.#Ve(),n=e.truncateToLastUser();if(n===null)return!1;this.#pt();for(let r of n)this.#ft(r);return await e.resume(),!0}async#nn(e){e!==this.#h&&(this.#F(),this.#ie(),this.conversationStore.setActiveThread(e),this.#h=e,this.#X(!1),await this.#we())}#rn(e){let n=e===this.#h;n&&this.#F(),this.conversationStore.clear(e),n&&(this.#ie(),this.#h=this.conversationStore.threadId(),this.#X(!1)),this.#se()}async#se(){this.#$.setRelativeTimeFormatter(this.formatRelativeTime),this.#$.setThreads(await this.conversationStore.listThreads(),this.#h)}async#we(){this.#Ne+=1;let e=this.#Ne,n=await this.conversationStore.loadMessages(this.#h);if(e!==this.#Ne)return;if(n!==null){this.#Oe=n;for(let o of n)this.#ft(o)}let r=this.conversationStore.loadCheckpoint(this.#h);if(r!==null){await this.#an(r);return}this.#in(n)}#ht(){return this.#Ce=window.location.href,this.getContext()}#on(){return this.#Ce!==null&&this.#Ce!==window.location.href}#in(e){let n=e?.at(-1);n===void 0||n.role!==ze.USER||this.#le("\u26A0",this.#e.runInterrupted,"interrupted")}#ft(e){let n=typeof e.content=="string"?e.content:"";if(e.role===ze.USER){let r=ml(e);if(n!==""||r.length>0){let o=this.appendMessage(ze.USER,n);r.length>0&&o.appendChild(Da(r))}return}if(e.role===ze.ASSISTANT){if(n!==""){let r=this.appendMessage(ze.ASSISTANT,n);r.classList.add("message--restored"),this.#je(r)}for(let r of tx(e.toolCalls)){let o={id:r.id,name:r.function.name,args:this.#sn(r.function.arguments)};if(this.#Tt(o))continue;this.#d.set(o.id,this.#Xe(o).element);let i=this.#Le(o.name)?.render;i!==void 0&&this.#St(i,o)}return}if(e.role==="activity"){let r=e;typeof r.activityType=="string"&&this.#We(e.id,r.activityType,r.content);return}if(e.role==="tool"){let r=this.#i.get(e.toolCallId);r!==void 0&&r.settle(te.DONE,e.content)}}#sn(e){if(typeof e!="string")return{};try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#mt(e){this.getAttribute("data-text-animation")==="word"&&np(e)}async#an(e){this.conversationStore.saveCheckpoint(this.#h,null);let n=this.#Ve();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===ze.ASSISTANT?(r.innerHTML=zi(n,{allowImages:this.allowImages}),Pa(r,this.#e),this.#I().appendChild(r)):(this.#D=null,r.textContent=n,this.#f.appendChild(r)),this.#_(),e===ze.USER?this.#g.jump():this.#g.follow(),r}#I(){if(this.#D===null){let e=document.createElement("div");e.className="answer",e.setAttribute("part","answer"),this.#D=e,this.#f.appendChild(e),this.#_()}return this.#D}#ln(){this.#x.className="chat",this.#x.setAttribute("part","panel");let e=document.createElement("div");e.className="header",e.setAttribute("part","header");let n=this.#Se;n.className="header-title",n.setAttribute("part","title"),n.textContent=this.getAttribute("title-text")??this.#e.title,(this.querySelector('[slot="icon"]')!==null||this.getAttribute("data-icon-url")!==null)&&e.append(this.#gt("icon","icon",null));let r=document.createElement("slot");r.name="header-actions";let o=document.createElement("div");o.className="header-controls",o.setAttribute("part","header-controls");let i=this.#Ee("history",this.#e.chatHistory,"\u2630");i.addEventListener("click",()=>this.openThreads());let s=this.#Ee("checkpoints",this.#e.checkpoints,"\u21BA");s.addEventListener("click",()=>this.toggleCheckpoints());let a=this.#Ee("new",this.#e.newChat,"\u271A");a.addEventListener("click",()=>this.newChat());let l=this.#Ee("collapse",this.#e.collapse,"\u2014");l.addEventListener("click",()=>this.toggleCollapsed()),this.#Me()!==null?o.append(i,s,a):o.append(i,a),this.getAttribute("data-theme-toggle")!==null&&(this.#L.type="button",this.#L.className="header-btn header-btn--theme",this.#L.setAttribute("part","header-button theme-toggle"),this.#L.title=this.#e.toggleTheme,this.#L.setAttribute("aria-label",this.#e.toggleTheme),this.#L.addEventListener("click",()=>this.toggleTheme()),this.#ut(),o.append(this.#L)),o.append(l),e.append(n,r,o),this.#f.className="messages",this.#f.setAttribute("part","messages"),this.#f.setAttribute("role","log"),this.#f.setAttribute("aria-live","off"),this.#f.setAttribute("aria-label",this.#e.conversation),this.#z.className="jump-latest",this.#z.type="button",this.#z.setAttribute("part","jump-latest"),this.#z.textContent=this.#e.jumpToLatest,this.#z.addEventListener("click",()=>{this.#g.jump()}),this.#b.className="quote-selection",this.#b.type="button",this.#b.setAttribute("part","quote-selection"),this.#b.textContent=this.#e.quoteSelection,this.#b.hidden=!0,this.#b.addEventListener("mousedown",h=>{h.preventDefault()}),this.#b.addEventListener("click",()=>{this.quote(this.#Te),window.getSelection()?.removeAllRanges(),this.#Pe()}),this.#f.addEventListener("mouseup",h=>this.#rt(h)),this.#f.addEventListener("keyup",()=>this.#rt()),this.#f.addEventListener("mousedown",()=>this.#Pe()),this.#g=rp({viewport:this.#f,onMissedContent:h=>{this.#z.dataset.missed=String(h)}}),this.#M.className="sr-only",this.#M.setAttribute("role","status"),this.#M.setAttribute("aria-live","polite"),this.#M.setAttribute("aria-atomic","true"),this.#B.className="empty",this.#B.setAttribute("part","empty");let c=document.createElement("slot");c.name="empty",this.#B.append(c),this.#f.append(this.#B);let u=document.createElement("div");u.className="input-row",u.setAttribute("part","composer");let m=document.createElement("div");m.className="composer",m.setAttribute("part","composer-surface");let y=document.createElement("div");y.className="composer-tools",y.setAttribute("part","composer-tools"),this.#l.className="input",this.#l.setAttribute("part","input"),this.#l.setAttribute("aria-label",this.#e.message),this.#l.rows=1,this.#l.placeholder=this.#e.inputPlaceholder,this.#l.addEventListener("keydown",h=>this.#hn(h)),this.#l.addEventListener("input",()=>this.#bt()),this.#w.className="send",this.#w.type="button",this.#w.setAttribute("part","send"),this.#w.append(this.#$e("icon-send","send-send",Jl),this.#$e("icon-stop","send-stop",ec)),this.#w.title=this.#e.send,this.#w.setAttribute("aria-label",this.#e.send),this.#w.dataset.state="idle",this.#w.addEventListener("click",()=>{if(this.#j){this.#F();return}this.#Be()}),this.#R.className="skill-hint",this.#R.setAttribute("part","skill-hint"),this.#R.hidden=!0,this.#A.className="attach-btn",this.#A.type="button",this.#A.setAttribute("part","attach-button"),this.#A.append(this.#$e("icon-attach","attach-glyph",tc)),this.#A.title=this.#e.attachFiles,this.#A.setAttribute("aria-label",this.#e.attachFiles),this.#A.hidden=!0,this.#A.addEventListener("click",()=>this.#k.click()),this.#k.className="attach-input",this.#k.type="file",this.#k.multiple=!0,this.#k.hidden=!0,this.#k.addEventListener("change",()=>this.#qt()),this.#ue.className="attachment-slot",this.#he.className="voice-slot";let f=document.createElement("slot");f.name="footer",y.append(this.#A,this.#he,this.#w),m.append(this.#l,y),u.append(m,this.#k),this.#ce.className="messages-wrap",this.#ce.append(this.#f,this.#z,this.#b),this.#x.append(e,this.#ce,this.#H.palette,this.#H.chips,this.#R,this.#ue,u,f,this.#$.element,this.#E.element),this.#x.addEventListener("pointerdown",h=>{if(!this.#E.open_)return;let g=h.composedPath();g.includes(this.#E.element)||g.includes(s)||this.#E.close()}),this.#C.className="launcher",this.#C.type="button",this.#C.setAttribute("part","launcher"),this.#C.setAttribute("aria-label",this.#e.expand),this.#P.className="launcher-badge",this.#P.setAttribute("part","launcher-badge"),this.#P.setAttribute("aria-hidden","true"),this.#P.hidden=!0,this.#C.append(this.#gt("launcher","launcher-icon",rc,this.#dn()),this.#P),this.#C.addEventListener("click",()=>this.setCollapsed(!1)),this.#x.append(ep({axis:()=>this.#Ue(),anchor:()=>this.#at(),rect:()=>this.getBoundingClientRect(),apply:h=>this.#Fe(h),commit:h=>{this.#Jt(h),this.#He()},label:this.#e.resizePanel})),this.#cn(),this.#T.append(this.#M,this.#x,this.#C)}#ae(e){this.#G!==null&&clearTimeout(this.#G),this.#M.textContent=e,this.#G=setTimeout(()=>{this.#G=null,this.#M.textContent=""},lc)}#cn(){let e=new CSSStyleSheet;e.replaceSync(op),this.#T.adoptedStyleSheets=[e]}#Ee(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}#$e(e,n,r){let o=document.createElement("slot");return o.name=e,o.className=n,o.innerHTML=r,o}#dn(){return this.getAttribute("data-launcher-icon-url")??this.getAttribute("data-icon-url")}#gt(e,n,r,o=this.getAttribute("data-icon-url")){let i=document.createElement("span");i.className="icon-holder",i.setAttribute("part",n);let s=document.createElement("slot");if(s.name=e,o!==null){let a=document.createElement("img");a.className="icon-img",a.src=o,a.alt="",s.append(a)}else r!==null&&(s.innerHTML=r);return i.append(s),i}#vt(){this.#C.setAttribute("aria-expanded",String(!this.collapsed));let e=this.#pe;this.#P.textContent=e>9?"9+":String(e),this.#P.hidden=e===0||!this.#un();let n=this.#P.hidden?this.#e.expand:this.#e.expandUnread.replace("{count}",String(e));this.#C.setAttribute("aria-label",n),this.#C.title=n}#un(){return this.getAttribute("data-unread-badge")!=="false"}#_e(e){this.#pe=e,this.#vt(),this.dispatchEvent(new CustomEvent(bs,{detail:{unread:e},bubbles:!0,composed:!0}))}#pn(){this.collapsed&&this.#_e(this.#pe+1)}#_(){this.#B.hidden=this.#f.childElementCount>1}#bt(){this.#H.onInput(this.#l.value),this.#R.hidden=!0,this.#J()}#hn(e){if(this.#H.onKeydown(e)){e.preventDefault();return}if(e.key==="Escape"&&this.#j){e.preventDefault(),this.#F();return}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.#Be())}#F(){this.#N?.abort(),this.#V?.cancel()}#X(e){this.#j=e;let n=e?this.#e.stop:this.#e.send;this.#w.title=n,this.#w.setAttribute("aria-label",n),this.#w.dataset.state=e?"running":"idle"}#J(){this.#l.style.height="auto",this.#l.style.height=`${this.#l.scrollHeight}px`}async#Be(){if(this.#j)return;let e=this.#l.value.trim(),n=this.#S?.readyRefs()??[];e===""&&n.length===0||(this.#l.value="",this.#J(),this.#S?.hasPending()===!0&&this.#le("\u{1F4CE}",this.#e.attachmentsStillUploading.replace("{n}",String(this.#S.pendingCount())),"attachment-pending"),this.#S?.clearReady(),await this.sendMessage(e,n))}async sendMessage(e,n=[]){if(this.#j||e===""&&n.length===0)return;let r=this.appendMessage(ze.USER,e);n.length>0&&r.appendChild(Da(n)),this.dispatchEvent(new CustomEvent(gs,{detail:{content:e,attachments:n},bubbles:!0,composed:!0})),await this.#mn(e,n)}attachFile(e){return this.#S===null?!1:(this.#S.add(e),!0)}#fn(e){this.dispatchEvent(new CustomEvent(xs,{detail:{attachments:e.readyRefs(),pending:e.pendingCount()},bubbles:!0,composed:!0}))}async#mn(e,n){this.endpoint!==""&&await this.#Ve().send(e,n)}#Ve(){if(this.#V===null){let e=this.agentFactory({endpoint:this.endpoint,headers:this.#re(),getHeaders:()=>this.#re(),trustedOrigins:this.trustedOrigins,...this.#ye(),threadId:this.#h,initialMessages:this.#Oe,initialState:this.#Z});this.#V=new Bn({agent:e,handlers:this.#wt(),getTools:()=>this.#et(),getContext:()=>this.#ht(),executeTool:n=>this.#yt(n),resolveInterrupts:n=>this.#xt(n),onPersist:n=>this.conversationStore.saveMessages(this.#h,n),onStateChanged:n=>this.#gn(n),connectionLostMessage:this.#e.connectionLost,maxToolRounds:this.#Bt()})}return this.#V}#gn(e){this.#Z={...e},this.dispatchEvent(new CustomEvent(ys,{detail:{state:this.#Z},bubbles:!0,composed:!0}))}#je(e,n={}){let r=this.#Vt(),o=r.has(bn.COPY),i=n.rateable!==!1&&r.has(bn.FEEDBACK);(o||i)&&Ga(e,{strings:this.#e,...o?{text:()=>e.textContent}:{},...i?{onFeedback:s=>{this.dispatchEvent(new CustomEvent(Ts,{detail:{content:e.textContent,rating:s},bubbles:!0,composed:!0}))}}:{}}),r.has(bn.RETRY)&&this.#vn(Ni(e,this.#e))}#vn(e){this.#y?.querySelector(".message-action--retry")?.remove();let n=Oi("retry",this.#e.retryMessage,"\u21BB");n.addEventListener("click",()=>{this.retryLastTurn()}),e.prepend(n),this.#y=e}async#bn(e,n){return this.autoConfirm?null:this.confirmPredicate!==null?await this.confirmPredicate(e.name,e.args)===!0?"predicate":null:this.#m.has(e.name)?null:ya(n.parameters)?"destructive":null}async#yt(e){if(bp(e)!==null)return null;let n=this.#Xe(e);this.#i.delete(e.id),this.#d.set(e.id,n.element);let r=this.#s.has(e.name)?this.#Le(e.name):null;if(r===null)return this.#p.has(e.id)||n.settle(te.DONE,this.#e.noResult),null;if(this.getPageMap!==null&&e.name!==ks&&!wi(r.parameters)&&this.#on()){let s=this.#e.pageMoved;return n.settle(te.ERROR,s),this.#ee(),{content:`Error: ${s}`,error:s}}let o=await this.#bn(e,r);if(o!==null){let s={toolName:e.name,args:e.args},a=r.parameters[Wr];typeof a=="string"&&(s.message=a),this.#N=new AbortController;let l=za(this.#I(),s,{signal:this.#N.signal,strings:this.#e,...o==="destructive"?{onAlwaysAllow:()=>this.#m.add(e.name)}:{}});this.#_(),this.#g.follow();let c=await l;if(this.#N=null,n.recordDecision(c?"approved":"declined"),!c){let u=this.#e.declinedAction;return n.settle(te.DECLINED,u),this.#ee(),{content:u}}}let i=wi(r.parameters)&&this.navigate===null;i&&this.conversationStore.saveCheckpoint(this.#h,{toolCallId:e.id});try{let s=await r.handler(e.args,e.id);if(r.render!==void 0&&this.#St(r.render,e),i)return n.settle(te.DONE,this.#e.navigating),{content:"",halt:!0};let a=JSON.stringify(s??null);return n.settle(te.DONE,a),this.#ee(),{content:a}}catch(s){i&&this.conversationStore.saveCheckpoint(this.#h,null);let a=s instanceof Error?s.message:String(s);return n.settle(te.ERROR,a),this.#ee(),{content:`Error: ${a}`,error:a}}}async#xt(e){this.#N=new AbortController,this.#ae(this.#e.announceAwaitingDecision.replace("{count}",String(e.length))),this.#O();let n=this.#N.signal,r=await Promise.all(e.map(async i=>{let s=i.toolCallId!==void 0?this.#i.get(i.toolCallId):void 0,a={},l=ex(i)??i.message;l!==void 0&&(a.message=l);let c=s?.element.getAttribute("data-tool-name");c!=null&&(a.toolName=c);let u,m=this.approveWithEdits&&s!==void 0;m&&(a.args=s.args),s?.mark(te.DEFERRED);let y=this.approvalRenderer!==null?await this.approvalRenderer(a,{signal:n}):await La(s?.approvalSlot??this.#I(),a,{signal:n,strings:this.#e,...m?{onEdit:f=>{u=f}}:{}});return s?.recordDecision(y?"approved":"declined"),y?s?.mark(te.PENDING):s?.settle(te.DECLINED,this.#e.declinedAction),{id:i.id,approved:y,editedArgs:u}}));this.#_(),this.#g.follow(),this.#N=null;let o={};for(let{id:i,approved:s,editedArgs:a}of r)o[i]=s?{status:"resolved",payload:a===void 0?{approved:!0}:{approved:!0,editedArgs:a}}:{status:"cancelled"};return o}#wt(){return{onRunStart:()=>{this.#j||(this.#de=!1,this.#ae(this.#e.announceResponding)),this.#X(!0),this.#I(),this.#ee()},onReasoningStart:()=>{this.#O(),this.#Et()},onReasoningDelta:e=>{this.#Et().stream(e)},onReasoningEnd:()=>{},onTextDelta:e=>{this.#O(),this.#W?.collapse(),this.#_n(e),this.#Ie+=1},onTextEnd:e=>{let n=this.#qe(e);this.#Ie<=1&&this.#mt(n),Pa(n,this.#e),this.#je(n),this.#te(),this.#pn()},onToolCall:e=>{this.#O(),!this.#Tt(e)&&(this.#v.push({id:e.id,name:e.name}),this.#Xe(e))},onActivity:(e,n,r)=>{this.#We(r,e,n)},onCustomEvent:(e,n)=>{if(e===As){this.#xn(n);return}if(e===Zl){this.#wn(n);return}this.dispatchEvent(new CustomEvent(Es,{detail:{name:e,value:n},bubbles:!0,composed:!0}))},onMessagesSnapshot:()=>{this.#le("\u{1F504}",this.#e.historyReplaced,"history-replaced")},onToolResult:(e,n)=>{let r=this.#i.get(e);r!==void 0&&(r.settle(te.DONE,n),this.#p.add(e),this.#ee())},onActivityChanged:(e,n,r)=>{this.#We(e,n,r)},onRunEnd:()=>{this.#O(),this.#te()},onError:e=>{this.#de=!0,this.#ae(this.#e.announceFailed),this.#O();let n=this.appendMessage(ze.ASSISTANT,`\u26A0\uFE0F ${e}`);n.classList.add("message--failed"),this.#je(n,{rateable:!1}),this.#mt(n),this.#te()},onCancelled:()=>{this.#de=!0,this.#ae(this.#e.announceStopped),this.#O(),this.#En(),this.#te()},onSettled:()=>{this.#de||this.#ae(this.#e.announceAnswerReady),this.#O(),this.#X(!1),this.#te();for(let e of this.#i.values())e.settled||e.settle(te.DONE,this.#e.noResult);this.#D!==null&&this.#D.childElementCount===0&&(this.#D.remove(),this.#_()),this.#D=null,this.#W=null,this.#yn()}}}#yn(){let e=this.#v.map(({id:r,name:o})=>({name:o,side:this.#p.has(r)?"server":"client"}));this.#v=[];let n=[...this.#U];this.#U=new Set,this.dispatchEvent(new CustomEvent(ws,{detail:{tools:e,invalidated:n},bubbles:!0,composed:!0}))}#xn(e){let n=e??{},r=Array.isArray(n.keys)?n.keys.filter(o=>typeof o=="string"):[];if(r.length!==0){for(let o of r)this.#U.add(o);this.dispatchEvent(new CustomEvent(_s,{detail:{keys:r,reason:typeof n.reason=="string"?n.reason:null},bubbles:!0,composed:!0}))}}#wn(e){let n=sp(e);if(n===null)return;let r=this.#i.get(n.delegationId);if(r===void 0)return;let o=this.#o.get(n.delegationId);o===void 0&&(o=new $i(this.#e),this.#o.set(n.delegationId,o),r.subagentSlot.appendChild(o.element)),o.report(n),this.#g.follow()}#En(){let e=document.createElement("div");e.className="stopped-note",e.setAttribute("part","stopped"),e.setAttribute("role","status"),e.textContent=this.#e.stopped,this.#I().appendChild(e),this.#_(),this.#g.follow()}#ee(){if(this.#ge!==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.#ge=e,this.#I().appendChild(e),this.#_(),this.#g.follow()}#O(){this.#ge?.remove(),this.#ge=null}#Et(){if(this.#W===null){this.#W=new Bi(this.#e);let e=this.#I();e.insertBefore(this.#W.element,e.firstChild),this.#_(),this.#g.follow()}return this.#W}#_t(){return this.#fe===null&&(this.#fe=this.appendMessage(ze.ASSISTANT,""),this.#Ie=0),this.#fe}#_n(e){this.#me=e,this.#_t(),this.#q===null&&(this.#q=requestAnimationFrame(()=>{this.#q=null,this.#qe(this.#me)}))}#qe(e){this.#q!==null&&(cancelAnimationFrame(this.#q),this.#q=null),this.#me=e;let n=this.#_t();return n.innerHTML=zi(e,{allowImages:this.allowImages}),this.#g.follow(),n}#te(){this.#q!==null&&this.#qe(this.#me),this.#fe=null}#Tt(e){let n=bp(e);return n===null?!1:(this.#le("\u2728",this.#e.usingSkill.replace("{name}",n),"skill"),!0)}#le(e,n,r){this.#I().appendChild(pl(e,n,r)),this.#_(),this.#g.follow()}enableCharts(e=["tool","activity"]){let n=!this.#u.has(Xr)&&!this.#r.has(Ri);e.includes("activity")&&this.registerActivityRenderer({type:Xr,render:r=>{let o=Un(r);return o===null?null:gr(o)},removedNotice:this.#e.chartUndrawable}),e.includes("tool")&&this.registerTool(lu()),n&&this.isConnected&&this.reload()}#St(e,n){let r;try{r=e(n.args)}catch(o){console.warn(`ag-ui-chat: render failed for tool ${n.name}`,o);return}r!==null&&(this.#d.get(n.id)?.after(r),this.#At())}registerActivityRenderer(e){this.#u.set(e.type,e),this.#c.delete(e.type)}get unhandledActivityTypes(){return[...this.#c]}#We(e,n,r){let o=this.#u.get(n);if(o===void 0){this.#c.add(n);return}let i;try{i=o.render(r)}catch(a){console.warn(`ag-ui-chat: render failed for activity ${n}`,a),i=null}if(i===null){this.#Tn(e,n,o.removedNotice,r);return}let s=this.#a.get(e);s===void 0?this.#I().appendChild(i):s.replaceWith(i),this.#a.set(e,i),this.#At()}#Tn(e,n,r,o){let i=this.#a.has(e);this.#a.get(e)?.remove(),this.#a.delete(e),console.warn(`ag-ui-chat: activity ${e} (${n}) was not drawable and has been removed. A chart's points must each be a finite JSON number; a numeric column serialised as a string (a Decimal, typically) is rejected rather than coerced.`,o),i&&r!==void 0&&this.#le("\u{1F4C9}",r,"chart-undrawable")}#At(){this.#_(),this.#g.follow()}#Xe(e){let n=this.#i.get(e.id);if(n!==void 0)return n;let r=this.#Le(e.name)?.parameters[Pe],o=typeof r=="string"?r:this.toolSummaries[e.name]??this.#t[e.name]?.summary??ja(e.name),i=new Cr(e.name,e.args,o,this.#e,{formatPayload:s=>this.formatToolPayload?.(s)??null});return this.#i.set(e.id,i),this.#I().appendChild(i.element),this.#_(),this.#g.follow(),i}};function ex(t){let e=t.metadata?.[Wr];return typeof e=="string"&&e.trim()!==""?e:void 0}function tx(t){return Array.isArray(t)?t.filter(nx):[]}function nx(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.id=="string"&&typeof e.function?.name=="string"}function bp(t){if(t.name!==Rs)return null;let e=t.args?.id;return typeof e=="string"&&e!==""?e:null}function rx(t){let e=t?.removed;return typeof e=="number"?e:null}function ox(){customElements.get(qr)===void 0&&customElements.define(qr,Mr)}async function ix(t,e,n={}){await vt(t),await Ta(t,{...n,flashMs:n.flashMs??0}),await Ea(t,e,n)}async function sx(t,e={}){await vt(t),await _a(t,e)}async function ax(t,e={}){await vt(t),await Sa(t,e)}async function lx(t,e,n={}){await vt(t),await Aa(t,e,n)}async function cx(t,e,n={}){await vt(t),await ka(t,e,n)}function dx(t,e){t instanceof HTMLInputElement&&t.type==="checkbox"?hr(t,!!e):rn(t,String(e)),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}var ux="0.30.0";export{xs as ATTACHMENT_EVENT,Mr as AgUiChat,Bn as AgUiClient,Xr as CHART_ACTIVITY_TYPE,Ri as CHART_TOOL_NAME,Is as COMPACTION_ACTIVITY_TYPE,Es as CUSTOM_AGENT_EVENT,br as CheckpointMenu,pr as ClientToolRegistry,qi as ConnectionLostError,ee as DEFAULT_UI_STRINGS,qr as ELEMENT_TAG,Ts as FEEDBACK_EVENT,As as INVALIDATE_CUSTOM_NAME,_s as INVALIDATE_EVENT,Rs as LOAD_CAPABILITY_TOOL,zv as MAX_QUOTE_CHARS,Fy as MAX_SUGGESTIONS,zy as MAX_SUGGESTION_CHARS,vn as MAX_TOOL_ROUNDS,bn as MESSAGE_ACTIONS,ze as MESSAGE_ROLE,Ca as PAGE_ACTIONS,ws as RUN_FINISHED_EVENT,Nr as RemoteConversationStore,Or as RunIndex,ys as STATE_EVENT,gs as SUBMIT_EVENT,Ss as SUGGESTIONS_ACTIVITY_TYPE,je as SessionStorageStore,vs as TOGGLE_EVENT,te as TOOL_CALL_STATUS,yn as TOOL_DISPLAY,Cr as ToolCallCard,bs as UNREAD_EVENT,ux as VERSION,Wr as X_CONFIRM_KEY,Kn as X_DESTRUCTIVE_KEY,Zn as X_NAVIGATES_KEY,Pe as X_SUMMARY_KEY,$a as asQuote,Ga as attachMessageActions,Va as attachQuoteOffer,Un as chartSpecFrom,sx as clickElement,vl as createHttpAgent,Ia as createPageActionTools,Ra as createPageMapContext,Si as createPageStateTools,Oa as createRouteTools,pv as createStateHookTools,ox as defineAgUiChat,ix as fillField,av as flash,Ta as focusWithFlash,_a as highlightThenClick,ya as isDestructive,wi as isNavigates,Ma as mergeUiStrings,Ni as messageActionBar,ml as messageAttachments,Na as parseToolCatalog,_i as prefersReducedMotion,ax as pressButton,Sa as pressThenClick,ja as prettifyToolName,yr as quotableSelection,vr as relativeTime,gr as renderChart,zi as renderMarkdown,hl as renderSuggestionChips,La as requestApproval,za as requestConfirmation,qa as requestQuestion,vt as scrollIntoCenterView,lx as selectControl,Aa as selectOption,dx as setControlValue,hr as setNativeChecked,rn as setNativeValue,ap as suggestionPrompts,cx as toggleCheckbox,ka as toggleControl,bl as transcribeAudio,Ea as typeInto,yl as uploadAttachment};
|
|
2405
2846
|
/*! Bundled license information:
|
|
2406
2847
|
|
|
2407
2848
|
fast-json-patch/module/helpers.mjs:
|