page-agent-sdk 3.18.0 → 3.19.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.
@@ -145,7 +145,7 @@ Actual: `+e.attribValue);else{var i=e.tag,a=e.tags[e.tags.length-1]||e;i.ns===a.
145
145
  `?(t.line++,t.column=0):t.column++),t.state){case w.BEGIN:if(t.state=w.BEGIN_WHITESPACE,i===``)continue;ce(t,i);continue;case w.BEGIN_WHITESPACE:ce(t,i);continue;case w.TEXT:if(t.sawRoot&&!t.closedRoot){for(var a=n-1;i&&i!==`<`&&i!==`&`;)i=le(e,n++),i&&t.trackPosition&&(t.position++,i===`
146
146
  `?(t.line++,t.column=0):t.column++);t.textNode+=e.substring(a,n-1)}i===`<`&&!(t.sawRoot&&t.closedRoot&&!t.strict)?(t.state=w.OPEN_WAKA,t.startTagPosition=t.position):(!y(i)&&(!t.sawRoot||t.closedRoot)&&O(t,`Text data outside of root node.`),i===`&`?t.state=w.TEXT_ENTITY:t.textNode+=i);continue;case w.SCRIPT:i===`<`?t.state=w.SCRIPT_ENDING:t.script+=i;continue;case w.SCRIPT_ENDING:i===`/`?t.state=w.CLOSE_TAG:(t.script+=`<`+i,t.state=w.SCRIPT);continue;case w.OPEN_WAKA:if(i===`!`)t.state=w.SGML_DECL,t.sgmlDecl=``;else if(!y(i))if(S(h,i))t.state=w.OPEN_TAG,t.tagName=i;else if(i===`/`)t.state=w.CLOSE_TAG,t.tagName=``;else if(i===`?`)t.state=w.PROC_INST,t.procInstName=t.procInstBody=``;else{if(O(t,`Unencoded <`),t.startTagPosition+1<t.position){var o=t.position-t.startTagPosition;i=Array(o).join(` `)+i}t.textNode+=`<`+i,t.state=w.TEXT}continue;case w.SGML_DECL:(t.sgmlDecl+i).toUpperCase()===u?(E(t,`onopencdata`),t.state=w.CDATA,t.sgmlDecl=``,t.cdata=``):t.sgmlDecl+i===`--`?(t.state=w.COMMENT,t.comment=``,t.sgmlDecl=``):(t.sgmlDecl+i).toUpperCase()===d?(t.state=w.DOCTYPE,(t.doctype||t.sawRoot)&&O(t,`Inappropriately located doctype declaration`),t.doctype=``,t.sgmlDecl=``):i===`>`?(E(t,`onsgmldeclaration`,t.sgmlDecl),t.sgmlDecl=``,t.state=w.TEXT):(b(i)&&(t.state=w.SGML_DECL_QUOTED),t.sgmlDecl+=i);continue;case w.SGML_DECL_QUOTED:i===t.q&&(t.state=w.SGML_DECL,t.q=``),t.sgmlDecl+=i;continue;case w.DOCTYPE:i===`>`?(t.state=w.TEXT,E(t,`ondoctype`,t.doctype),t.doctype=!0):(t.doctype+=i,i===`[`?t.state=w.DOCTYPE_DTD:b(i)&&(t.state=w.DOCTYPE_QUOTED,t.q=i));continue;case w.DOCTYPE_QUOTED:t.doctype+=i,i===t.q&&(t.q=``,t.state=w.DOCTYPE);continue;case w.DOCTYPE_DTD:t.doctype+=i,i===`]`?t.state=w.DOCTYPE:b(i)&&(t.state=w.DOCTYPE_DTD_QUOTED,t.q=i);continue;case w.DOCTYPE_DTD_QUOTED:t.doctype+=i,i===t.q&&(t.state=w.DOCTYPE_DTD,t.q=``);continue;case w.COMMENT:i===`-`?t.state=w.COMMENT_ENDING:t.comment+=i;continue;case w.COMMENT_ENDING:i===`-`?(t.state=w.COMMENT_ENDED,t.comment=ne(t.opt,t.comment),t.comment&&E(t,`oncomment`,t.comment),t.comment=``):(t.comment+=`-`+i,t.state=w.COMMENT);continue;case w.COMMENT_ENDED:i===`>`?t.state=w.TEXT:(O(t,`Malformed comment`),t.comment+=`--`+i,t.state=w.COMMENT);continue;case w.CDATA:i===`]`?t.state=w.CDATA_ENDING:t.cdata+=i;continue;case w.CDATA_ENDING:i===`]`?t.state=w.CDATA_ENDING_2:(t.cdata+=`]`+i,t.state=w.CDATA);continue;case w.CDATA_ENDING_2:i===`>`?(t.cdata&&E(t,`oncdata`,t.cdata),E(t,`onclosecdata`),t.cdata=``,t.state=w.TEXT):i===`]`?t.cdata+=`]`:(t.cdata+=`]]`+i,t.state=w.CDATA);continue;case w.PROC_INST:i===`?`?t.state=w.PROC_INST_ENDING:y(i)?t.state=w.PROC_INST_BODY:t.procInstName+=i;continue;case w.PROC_INST_BODY:if(!t.procInstBody&&y(i))continue;i===`?`?t.state=w.PROC_INST_ENDING:t.procInstBody+=i;continue;case w.PROC_INST_ENDING:i===`>`?(E(t,`onprocessinginstruction`,{name:t.procInstName,body:t.procInstBody}),t.procInstName=t.procInstBody=``,t.state=w.TEXT):(t.procInstBody+=`?`+i,t.state=w.PROC_INST_BODY);continue;case w.OPEN_TAG:S(g,i)?t.tagName+=i:(ie(t),i===`>`?k(t):i===`/`?t.state=w.OPEN_TAG_SLASH:(y(i)||O(t,`Invalid character in tag name`),t.state=w.ATTRIB));continue;case w.OPEN_TAG_SLASH:i===`>`?(k(t,!0),se(t)):(O(t,`Forward-slash in opening tag not followed by >`),t.state=w.ATTRIB);continue;case w.ATTRIB:if(y(i))continue;i===`>`?k(t):i===`/`?t.state=w.OPEN_TAG_SLASH:S(h,i)?(t.attribName=i,t.attribValue=``,t.state=w.ATTRIB_NAME):O(t,`Invalid attribute name`);continue;case w.ATTRIB_NAME:i===`=`?t.state=w.ATTRIB_VALUE:i===`>`?(O(t,`Attribute without value`),t.attribValue=t.attribName,oe(t),k(t)):y(i)?t.state=w.ATTRIB_NAME_SAW_WHITE:S(g,i)?t.attribName+=i:O(t,`Invalid attribute name`);continue;case w.ATTRIB_NAME_SAW_WHITE:if(i===`=`)t.state=w.ATTRIB_VALUE;else if(y(i))continue;else O(t,`Attribute without value`),t.tag.attributes[t.attribName]=``,t.attribValue=``,E(t,`onattribute`,{name:t.attribName,value:``}),t.attribName=``,i===`>`?k(t):S(h,i)?(t.attribName=i,t.state=w.ATTRIB_NAME):(O(t,`Invalid attribute name`),t.state=w.ATTRIB);continue;case w.ATTRIB_VALUE:if(y(i))continue;b(i)?(t.q=i,t.state=w.ATTRIB_VALUE_QUOTED):(O(t,`Unquoted attribute value`),t.state=w.ATTRIB_VALUE_UNQUOTED,t.attribValue=i);continue;case w.ATTRIB_VALUE_QUOTED:if(i!==t.q){i===`&`?t.state=w.ATTRIB_VALUE_ENTITY_Q:t.attribValue+=i;continue}oe(t),t.q=``,t.state=w.ATTRIB_VALUE_CLOSED;continue;case w.ATTRIB_VALUE_CLOSED:y(i)?t.state=w.ATTRIB:i===`>`?k(t):i===`/`?t.state=w.OPEN_TAG_SLASH:S(h,i)?(O(t,`No whitespace between attributes`),t.attribName=i,t.attribValue=``,t.state=w.ATTRIB_NAME):O(t,`Invalid attribute name`);continue;case w.ATTRIB_VALUE_UNQUOTED:if(!x(i)){i===`&`?t.state=w.ATTRIB_VALUE_ENTITY_U:t.attribValue+=i;continue}oe(t),i===`>`?k(t):t.state=w.ATTRIB;continue;case w.CLOSE_TAG:if(t.tagName)i===`>`?se(t):S(g,i)?t.tagName+=i:t.script?(t.script+=`</`+t.tagName,t.tagName=``,t.state=w.SCRIPT):(y(i)||O(t,`Invalid tagname in closing tag`),t.state=w.CLOSE_TAG_SAW_WHITE);else{if(y(i))continue;C(h,i)?t.script?(t.script+=`</`+i,t.state=w.SCRIPT):O(t,`Invalid tagname in closing tag.`):t.tagName=i}continue;case w.CLOSE_TAG_SAW_WHITE:if(y(i))continue;i===`>`?se(t):O(t,`Invalid characters in closing tag`);continue;case w.TEXT_ENTITY:case w.ATTRIB_VALUE_ENTITY_Q:case w.ATTRIB_VALUE_ENTITY_U:var s,c;switch(t.state){case w.TEXT_ENTITY:s=w.TEXT,c=`textNode`;break;case w.ATTRIB_VALUE_ENTITY_Q:s=w.ATTRIB_VALUE_QUOTED,c=`attribValue`;break;case w.ATTRIB_VALUE_ENTITY_U:s=w.ATTRIB_VALUE_UNQUOTED,c=`attribValue`;break}if(i===`;`)if(t.opt.unparsedEntities){var l=A(t);t.entity=``,t.state=s,t.write(l)}else t[c]+=A(t),t.entity=``,t.state=s;else S(t.entity.length?v:_,i)?t.entity+=i:(O(t,`Invalid character in entity name`),t[c]+=`&`+t.entity+i,t.entity=``,t.state=s);continue;default:throw Error(t,`Unknown state: `+t.state)}return t.position>=t.bufferCheckPosition&&r(t),t}return String.fromCodePoint||(function(){var e=String.fromCharCode,t=Math.floor,n=function(){var n=16384,r=[],i,a,o=-1,s=arguments.length;if(!s)return``;for(var c=``;++o<s;){var l=Number(arguments[o]);if(!isFinite(l)||l<0||l>1114111||t(l)!==l)throw RangeError(`Invalid code point: `+l);l<=65535?r.push(l):(l-=65536,i=(l>>10)+55296,a=l%1024+56320,r.push(i,a)),(o+1===s||r.length>n)&&(c+=e.apply(null,r),r.length=0)}return c};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:n,configurable:!0,writable:!0}):String.fromCodePoint=n})(),e})();function hz(e,t){if(e.function===void 0)return;let n;if(t?.partial)try{n=YS(e.function.arguments??`{}`)}catch{return}else try{n=JSON.parse(e.function.arguments)}catch(t){throw new lz([`Function "${e.function.name}" arguments:`,``,e.function.arguments,``,`are not valid JSON.`,`Error: ${t.message}`].join(`
147
147
  `))}let r={name:e.function.name,args:n,type:`tool_call`};return t?.returnId&&(r.id=e.id),r}function gz(e){if(e.id===void 0)throw Error(`All OpenAI tool calls must have an "id" field.`);return{id:e.id,type:`function`,function:{name:e.name,arguments:JSON.stringify(e.args)}}}function _z(e,t){return{name:e.function?.name,args:e.function?.arguments,id:e.id,error:t,type:`invalid_tool_call`}}var vz=class extends dz{static lc_name(){return`JsonOutputToolsParser`}returnId=!1;lc_namespace=[`langchain`,`output_parsers`,`openai_tools`];lc_serializable=!0;constructor(e){super(e),this.returnId=e?.returnId??this.returnId}_diff(){throw Error(`Not supported.`)}async parse(){throw Error(`Not implemented.`)}async parseResult(e){return await this.parsePartialResult(e,!1)}async parsePartialResult(e,t=!0){let n=e[0].message,r;if(gC(n)&&n.tool_calls?.length?r=n.tool_calls.map(e=>{let{id:t,...n}=e;return this.returnId?{id:t,...n}:n}):n.additional_kwargs.tool_calls!==void 0&&(r=JSON.parse(JSON.stringify(n.additional_kwargs.tool_calls)).map(e=>hz(e,{returnId:this.returnId,partial:t}))),!r)return[];let i=[];for(let e of r)if(e!==void 0){let t={type:e.name,args:e.args,id:e.id};i.push(t)}return i}},yz=class extends vz{static lc_name(){return`JsonOutputKeyToolsParser`}lc_namespace=[`langchain`,`output_parsers`,`openai_tools`];lc_serializable=!0;returnId=!1;keyName;returnSingle=!1;zodSchema;serializableSchema;constructor(e){super(e),this.keyName=e.keyName,this.returnSingle=e.returnSingle??this.returnSingle,`zodSchema`in e&&(this.zodSchema=e.zodSchema),`serializableSchema`in e&&(this.serializableSchema=e.serializableSchema)}async _validateResult(e){if(this.serializableSchema!==void 0){let t=await this.serializableSchema[`~standard`].validate(e);if(t.issues)throw new lz(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(t.issues)}`,JSON.stringify(e,null,2));return t.value}if(this.zodSchema===void 0)return e;let t=await wre(this.zodSchema,e);if(t.success)return t.data;throw new lz(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(t.error?.issues)}`,JSON.stringify(e,null,2))}async parsePartialResult(e){let t=(await super.parsePartialResult(e)).filter(e=>e.type===this.keyName),n=t;if(t.length)return this.returnId||(n=t.map(e=>e.args)),this.returnSingle?n[0]:n}async parseResult(e){let t=(await super.parsePartialResult(e,!1)).filter(e=>e.type===this.keyName),n=t;if(t.length)return this.returnId||(n=t.map(e=>e.args)),this.returnSingle?this._validateResult(n[0]):await Promise.all(n.map(e=>this._validateResult(e)))}};function bz(e){return nM(e)?mz.fromZodSchema(e):aF(e)?pz.fromSerializableSchema(e):new fz}function xz(e,t,n){let r=n??yz;return nM(e)?new r({returnSingle:!0,keyName:t,zodSchema:e}):aF(e)?new r({returnSingle:!0,keyName:t,serializableSchema:e}):new r({returnSingle:!0,keyName:t})}function Sz(e,t,n,r){if(!n){let n=e.pipe(t);return r?n.withConfig({runName:r}):n}let i=oz.assign({parsed:(e,n)=>t.invoke(e.raw,n)}),a=oz.assign({parsed:()=>null}),o=i.withFallbacks({fallbacks:[a]}),s=lI.from([{raw:e},o]);return r?s.withConfig({runName:r}):s}var Cz=class{events=[];finished=!1;waiters=[];error=null;push(e){this.events.push(e);let t=this.waiters.splice(0);for(let e of t)e()}finish(){this.finished=!0;let e=this.waiters.splice(0);for(let t of e)t()}setError(e){this.error=e,this.finished=!0;let t=this.waiters.splice(0);for(let e of t)e()}async*iterate(){if(this.finished){if(this.error)throw this.error;yield*this.events;return}let e=0;for(;;){for(;e<this.events.length;)yield this.events[e],e++;if(this.finished){if(this.error)throw this.error;return}await new Promise(t=>{if(e<this.events.length||this.finished){t();return}this.waiters.push(t)})}}};function wz(e,t){switch(t.type){case`text-delta`:return e.type===`text`?{...e,text:(e.text??``)+t.text}:e;case`reasoning-delta`:return e.type===`thinking`?{...e,thinking:(e.thinking??``)+t.reasoning}:e.type===`reasoning`?{...e,reasoning:(e.reasoning??``)+t.reasoning}:e;case`data-delta`:return{...e,data:(e.data??``)+t.data};case`block-delta`:return{...e,...t.fields};default:throw Error(`Unknown delta type: ${JSON.stringify(t)}`)}}function Tz(e){if(e.event!==`content-block-delta`)return;if(`delta`in e&&e.delta)return e.delta;let t=e.content;if(typeof t!=`object`||!t)return;let n=t;if(n.type===`text`&&typeof n.text==`string`)return{type:`text-delta`,text:n.text};if(n.type===`reasoning`&&typeof n.reasoning==`string`)return{type:`reasoning-delta`,reasoning:n.reasoning};if(n.type===`thinking`&&typeof n.thinking==`string`)return{type:`reasoning-delta`,reasoning:n.thinking};if(typeof n.data==`string`)return{type:`data-delta`,data:n.data,encoding:`base64`};if(typeof n.type==`string`)return{type:`block-delta`,fields:{...n,type:n.type}}}function Ez(e){if(typeof e!=`object`||!e)return;let t=e;if(t.type===`reasoning`&&typeof t.reasoning==`string`)return t.reasoning;if(t.type===`thinking`&&typeof t.thinking==`string`)return t.thinking}function Dz(e){if(typeof e!=`object`||!e)return!1;let t=e.type;return t===`reasoning`||t===`thinking`}function Oz(e){if(e)return{...e,input_tokens:e.input_tokens??0,output_tokens:e.output_tokens??0,total_tokens:e.total_tokens??0}}function kz(e){if(typeof e==`object`&&e&&!Array.isArray(e))return e;if(typeof e!=`string`||e.length===0)return{};try{let t=JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)?t:{}}catch{return{}}}function Az(e){let t=e;if(e.type===`tool_call`||e.type!==`tool_call_chunk`&&e.type!==`tool_use`&&e.type!==`input_json_delta`)return e;let n=typeof t.name==`string`?t.name:void 0;if(n==null)return e;let r=t.args??t.input;return{...t,type:`tool_call`,name:n,args:kz(r)}}var jz=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t=``;for await(let n of e.iterate()){let e=Tz(n);e?.type===`text-delta`&&(t+=e.text,yield t)}}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let t of e.iterate()){let e=Tz(t);e?.type===`text-delta`&&(yield e.text)}}return t()}then(e,t){return(async()=>{let e=``;for await(let t of this)e+=t;return e})().then(e,t)}},Mz=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t=[];for await(let n of e.iterate())n.event===`content-block-finish`&&n.content.type===`tool_call`&&(t.push(n.content),yield[...t])}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let t of e.iterate())t.event===`content-block-finish`&&t.content.type===`tool_call`&&(yield t.content)}return t()}then(e,t){return(async()=>{let e=[];for await(let t of this)e.push(t);return e})().then(e,t)}},Nz=class{_buffer;constructor(e){this._buffer=e}get full(){let e=this._buffer;return{async*[Symbol.asyncIterator](){let t=``,n=!1;for await(let r of e.iterate())if(r.event===`content-block-start`){if(!Dz(r.content)){if(n)return;continue}n=!0;let e=Ez(r.content);if(e==null||e.length===0)continue;t+=e,yield t}else if(r.event===`content-block-delta`){let e=Tz(r);if(e?.type!==`reasoning-delta`)continue;n=!0;let i=e.reasoning;if(i==null||i.length===0)continue;t+=i,yield t}else if(r.event===`content-block-finish`&&Dz(r.content))return;else if(r.event===`message-finish`)return}}}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){let t=!1;for await(let n of e.iterate())if(n.event===`content-block-start`){if(!Dz(n.content)){if(t)return;continue}t=!0;let e=Ez(n.content);e!=null&&e.length>0&&(yield e)}else if(n.event===`content-block-delta`){let e=Tz(n);if(e?.type!==`reasoning-delta`)continue;t=!0;let r=e.reasoning;r!=null&&r.length>0&&(yield r)}else if(n.event===`content-block-finish`&&Dz(n.content))return;else if(n.event===`message-finish`)return}return t()}then(e,t){return(async()=>{let e=``;for await(let t of this)e+=t;return e})().then(e,t)}},Pz=class{_buffer;constructor(e){this._buffer=e}[Symbol.asyncIterator](){let e=this._buffer;async function*t(){for await(let t of e.iterate())if(t.event===`usage`){let e=Oz(t.usage);e&&(yield e)}else if(t.event===`message-start`&&t.usage){let e=Oz(t.usage);e&&(yield e)}else if(t.event===`message-finish`&&t.usage){let e=Oz(t.usage);e&&(yield e)}}return t()}then(e,t){return(async()=>{let e;for await(let t of this)e=t;return e})().then(e,t)}},Fz=class{_buffer;constructor(e){this._buffer=new Cz,this._consume(e)}async _consume(e){try{for await(let t of e)this._buffer.push(t);this._buffer.finish()}catch(e){this._buffer.setError(e instanceof Error?e:Error(String(e)))}}[Symbol.asyncIterator](){return this._buffer.iterate()}get text(){return new jz(this._buffer)}get toolCalls(){return new Mz(this._buffer)}get reasoning(){return new Nz(this._buffer)}get usage(){return new Pz(this._buffer)}get output(){return this._assembleMessage()}then(e,t){return this._assembleMessage().then(e,t)}async _assembleMessage(){let e=[],t,n,r={},i;for await(let a of this._buffer.iterate())switch(a.event){case`message-start`:t=a.id??t,a.usage&&(n=Oz(a.usage));break;case`content-block-start`:e[a.index]=a.content;break;case`content-block-delta`:{let t=e[a.index],n=Tz(a);t&&n&&(e[a.index]=wz(t,n));break}case`content-block-finish`:e[a.index]=a.content;break;case`usage`:n=Oz(a.usage);break;case`message-finish`:i=a.reason,a.usage&&(n=Oz(a.usage)),a.responseMetadata&&(r={...r,...a.responseMetadata});break;default:break}let a=e.filter(e=>e!=null).map(Az);return new hC({id:t,content:a,usage_metadata:n,response_metadata:{...r,...i?{finish_reason:i}:{},output_version:`v1`}})}},Iz={wav:`audio/wav`,mp3:`audio/mpeg`,flac:`audio/flac`,opus:`audio/opus`,aac:`audio/aac`,pcm16:`audio/pcm`},Lz={png:`image/png`,jpeg:`image/jpeg`,jpg:`image/jpeg`,webp:`image/webp`,gif:`image/gif`};function Rz(e){let t=0;for(let n of e.keys())n>=t&&(t=n+1);return t}function zz(e){let t=e.additional_kwargs;return typeof t==`object`&&t?t:{}}function Bz(e){let t=zz(e).tool_outputs;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e;if(t.type!==`image_generation_call`)continue;let r=typeof t.result==`string`?t.result:void 0,i=typeof t.url==`string`?t.url:void 0;if(r==null&&i==null)continue;let a=typeof t.output_format==`string`?t.output_format.toLowerCase():void 0,o=(a==null?void 0:Lz[a])??`image/png`;n.push({type:`image`,...typeof t.id==`string`?{id:t.id}:{},...i==null?{}:{url:i},...r==null?{}:{data:r},mimeType:o})}return n}function Vz(e){let t=zz(e).audio;if(typeof t!=`object`||!t)return;let n=t,r=typeof n.data==`string`?n.data:void 0,i=typeof n.url==`string`?n.url:void 0,a=typeof n.transcript==`string`?n.transcript:void 0;if(r==null&&i==null&&a==null)return;let o=typeof n.mime_type==`string`?n.mime_type:typeof n.mimeType==`string`?n.mimeType:void 0,s=typeof n.format==`string`?n.format.toLowerCase():void 0,c=o??(s==null?void 0:Iz[s])??(r==null?`audio/pcm`:`audio/wav`);return{...typeof n.id==`string`?{id:n.id}:{},...r==null?{}:{data:r},...i==null?{}:{url:i},...a==null?{}:{transcript:a},mimeType:c}}async function*Hz(e,t){let n=new Map,r=!1,i,a,o=new Set;for await(let s of e){t?.signal?.throwIfAborted();let e=s.message,c=!1;if(!r){r=!0;let t={event:`message-start`,id:e.id??void 0};vC.isInstance(e)&&e.usage_metadata&&(t.usage=e.usage_metadata,i={...e.usage_metadata},c=!0),yield t}let l=e.content;if(typeof l==`string`){if(l!==``){if(!n.has(0)){let e={type:`text`,text:``};n.set(0,{type:`text`,accumulated:e}),yield{event:`content-block-start`,index:0,content:e}}let e=n.get(0);e.accumulated={...e.accumulated,text:(e.accumulated.text??``)+l},yield{event:`content-block-delta`,index:0,delta:{type:`text-delta`,text:l}}}}else if(Array.isArray(l))for(let e of l){let t=typeof e.index==`number`?e.index:n.size;if(!n.has(t))n.set(t,{type:e.type,accumulated:{...e}}),yield{event:`content-block-start`,index:t,content:{...e}};else{let r=n.get(t),i=Wz(e);r.accumulated=Uz(r.accumulated,i),yield{event:`content-block-delta`,index:t,delta:i}}}if(vC.isInstance(e)&&e.tool_call_chunks&&e.tool_call_chunks.length>0)for(let t of e.tool_call_chunks){let e=typeof t.index==`number`?t.index:n.size;if(!n.has(e)){let r={type:`tool_call_chunk`,id:t.id,name:t.name,args:``,index:e};n.set(e,{type:`tool_call_chunk`,accumulated:r}),yield{event:`content-block-start`,index:e,content:r}}let r=n.get(e).accumulated;t.id!=null&&(r.id=t.id),t.name!=null&&(r.name=t.name),r.args=(r.args??``)+(t.args??``),yield{event:`content-block-delta`,index:e,delta:{type:`block-delta`,fields:{type:`tool_call_chunk`,...`id`in r&&r.id!=null?{id:r.id}:{},...`name`in r&&r.name!=null?{name:r.name}:{},args:r.args}}}}let u=Vz(e);if(u!=null){if(a==null){let e=Rz(n);a={index:e,id:u.id,mimeType:u.mimeType,transcript:``};let t={type:`audio`,...u.id==null?{}:{id:u.id},...u.url==null?{}:{url:u.url},data:``,mimeType:u.mimeType};n.set(e,{type:`audio`,accumulated:t}),yield{event:`content-block-start`,index:e,content:t}}let e=n.get(a.index);if(e!=null){let t=e.accumulated;u.id!=null&&a.id==null&&(a.id=u.id,t.id=u.id),u.transcript!=null&&(a.transcript+=u.transcript,t.transcript=a.transcript,yield{event:`content-block-delta`,index:a.index,delta:{type:`block-delta`,fields:{type:`audio`,transcript:a.transcript}}}),u.data!=null&&u.data.length>0&&(t.data=(t.data??``)+u.data,yield{event:`content-block-delta`,index:a.index,delta:{type:`data-delta`,data:u.data,encoding:`base64`}})}}for(let t of Bz(e)){let e=t,r=e.id??e.url??(e.data==null?void 0:`${e.data.length}:${e.data.slice(0,32)}`);if(r!=null&&o.has(r))continue;r!=null&&o.add(r);let i=Rz(n);n.set(i,{type:`image`,accumulated:t}),yield{event:`content-block-start`,index:i,content:t}}if(!c&&vC.isInstance(e)&&e.usage_metadata){let t=e.usage_metadata;i=i?{input_tokens:i.input_tokens+t.input_tokens,output_tokens:i.output_tokens+t.output_tokens,total_tokens:i.total_tokens+t.total_tokens}:{...t},yield{event:`usage`,usage:{...i}}}}for(let[e,t]of n)yield{event:`content-block-finish`,index:e,content:Gz(t.accumulated)};yield{event:`message-finish`,reason:`stop`,...i?{usage:i}:{}}}function Uz(e,t){switch(t.type){case`text-delta`:return e.type===`text`?{...e,text:(e.text??``)+t.text}:e;case`reasoning-delta`:return e.type===`thinking`?{...e,thinking:(e.thinking??``)+t.reasoning}:e.type===`reasoning`?{...e,reasoning:(e.reasoning??``)+t.reasoning}:e;case`data-delta`:return{...e,data:(e.data??``)+t.data};case`block-delta`:return{...e,...t.fields};default:throw Error(`Unknown delta type: ${JSON.stringify(t)}`)}}function Wz(e){if(e.type===`text`)return{type:`text-delta`,text:e.text};if(e.type===`reasoning`)return{type:`reasoning-delta`,reasoning:e.reasoning};if(e.type===`thinking`&&typeof e.thinking==`string`)return{type:`reasoning-delta`,reasoning:e.thinking};if(typeof e.data==`string`)return{type:`data-delta`,data:e.data,encoding:`base64`};if(typeof e.type==`string`)return{type:`block-delta`,fields:{...e}};throw Error(`Unsupported content block delta: ${JSON.stringify(e)}`)}function Gz(e){if(e.type===`tool_call_chunk`){let t=e,n;try{n=JSON.parse(t.args??`{}`)}catch{return{type:`invalid_tool_call`,id:t.id,name:t.name,args:t.args,error:`Failed to parse tool call arguments as JSON`}}return{type:`tool_call`,id:t.id,name:t.name,args:n}}return e}function Kz(e){let t=[];for(let n of e){let e=n;if(Array.isArray(n.content))for(let t=0;t<n.content.length;t++){let r=n.content[t];(Zb(r)||Qb(r))&&e===n&&(e=new n.constructor({...e,content:[...n.content.slice(0,t),ex(r),...n.content.slice(t+1)]}))}t.push(e)}return t}var qz=class e extends rz{lc_namespace=[`langchain`,`chat_models`,this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,`outputVersion`]}constructor(e){super(e),this.outputVersion=iz(()=>{let t=e.outputVersion??tw(`LC_OUTPUT_VERSION`);return t&&[`v0`,`v1`].includes(t)?t:`v0`})}_separateRunnableConfigFromCallOptionsCompat(e){let[t,n]=super._separateRunnableConfigFromCallOptions(e);return n.signal=t.signal,[t,n]}async invoke(t,n){let r=e._convertInputToPromptValue(t);return(await this.generatePrompt([r],n,n?.callbacks)).generations[0][0].message}async*_streamResponseChunks(e,t,n){throw Error(`Not implemented.`)}async*_streamChatModelEvents(e,t,n){yield*Hz(this._streamResponseChunks(e,t,n),{signal:t.signal})}streamEvents(t,n,r){if(n?.version===`v1`||n?.version===`v2`)return super.streamEvents(t,n,r);let i=e._convertInputToPromptValue(t).toChatMessages(),[,a]=this._separateRunnableConfigFromCallOptionsCompat(n);return new Fz(this._streamChatModelEvents(i,a))}streamV2(e,t){return this.streamEvents(e,t)}async*_streamIterator(t,n){if(this._streamResponseChunks===e.prototype._streamResponseChunks||this.disableStreaming)yield this.invoke(t,n);else{let r=e._convertInputToPromptValue(t).toChatMessages(),[i,a]=this._separateRunnableConfigFromCallOptionsCompat(n),o={...i.metadata,...this.getLsParamsWithDefaults(a)},s=this._getInvocationParamsForTracing(a),c=await JA.configure(i.callbacks,this.callbacks,i.tags,this.tags,o,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(s)}),l={options:this._getCallOptionsForTracing(a,s),invocation_params:s,batch_size:1},u=a.outputVersion??this.outputVersion,d=await c?.handleChatModelStart(this.toJSON(),[Kz(r)],i.runId,void 0,l,void 0,void 0,i.runName),f,p;try{for await(let e of this._streamResponseChunks(r,a,d?.[0])){if(a.signal?.throwIfAborted(),e.message.id==null){let t=d?.at(0)?.runId;t!=null&&e.message._updateId(`run-${t}`)}e.message.response_metadata={...e.generationInfo,...e.message.response_metadata},u===`v1`?yield az(e.message):yield e.message,f=f?f.concat(e):e,_C(e.message)&&e.message.usage_metadata!==void 0&&(p={tokenUsage:{promptTokens:e.message.usage_metadata.input_tokens,completionTokens:e.message.usage_metadata.output_tokens,totalTokens:e.message.usage_metadata.total_tokens}})}a.signal?.throwIfAborted()}catch(e){throw await Promise.all((d??[]).map(t=>t?.handleLLMError(e))),e}await Promise.all((d??[]).map(e=>e?.handleLLMEnd({generations:[[f]],llmOutput:p})))}}getLsParams(e){let t=this.getName().startsWith(`Chat`)?this.getName().replace(`Chat`,``):this.getName();return{ls_model_type:`chat`,ls_stop:e.stop,ls_provider:t}}getLsParamsWithDefaults(e){return{...this.getLsParams(e),ls_integration:`langchain_chat_model`}}async _generateUncached(t,n,r,i){let a=t.map(e=>e.map(lC)),o;if(i!==void 0&&i.length===a.length)o=i;else{let e={...r.metadata,...this.getLsParamsWithDefaults(n)},t=this._getInvocationParamsForTracing(n),i=await JA.configure(r.callbacks,this.callbacks,r.tags,this.tags,e,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(t)}),s={options:this._getCallOptionsForTracing(n,t),invocation_params:t,batch_size:1};o=await i?.handleChatModelStart(this.toJSON(),a.map(Kz),r.runId,void 0,s,void 0,void 0,r.runName)}let s=n.outputVersion??this.outputVersion,c=[],l=[],u=!!o?.[0].handlers.find(iw),d=!!o?.[0].handlers.find(rw);if(u&&!this.disableStreaming&&a.length===1&&(this._streamChatModelEvents!==e.prototype._streamChatModelEvents||this._streamResponseChunks!==e.prototype._streamResponseChunks))try{let e=!1,t=o?.[0],r=this._streamChatModelEvents(a[0],n),i=await new Fz({async*[Symbol.asyncIterator](){for await(let i of r){n.signal?.throwIfAborted(),e=!0;let r=i.event===`message-start`&&i.id==null&&t?.runId!=null?{...i,id:`run-${t.runId}`}:i;await t?.handleChatModelStreamEvent(r),yield r}}});if(n.signal?.throwIfAborted(),!e)throw Error(`Received empty response from chat model call.`);if(i.id==null){let e=o?.at(0)?.runId;e!=null&&i._updateId(`run-${e}`)}let s={text:i.text,message:i};c.push([s]);let l=i.usage_metadata===void 0?void 0:{tokenUsage:{promptTokens:i.usage_metadata.input_tokens,completionTokens:i.usage_metadata.output_tokens,totalTokens:i.usage_metadata.total_tokens}};await o?.[0].handleLLMEnd({generations:c,llmOutput:l})}catch(e){throw await o?.[0].handleLLMError(e),e}else if(d&&!this.disableStreaming&&a.length===1&&this._streamResponseChunks!==e.prototype._streamResponseChunks)try{let e=await this._streamResponseChunks(a[0],n,o?.[0]),t,r;for await(let i of e){if(n.signal?.aborted){let e=t?.message;throw new Kb(`Model invocation was aborted.`,e)}if(i.message.id==null){let e=o?.at(0)?.runId;e!=null&&i.message._updateId(`run-${e}`)}t=t===void 0?i:dj(t,i),_C(i.message)&&i.message.usage_metadata!==void 0&&(r={tokenUsage:{promptTokens:i.message.usage_metadata.input_tokens,completionTokens:i.message.usage_metadata.output_tokens,totalTokens:i.message.usage_metadata.total_tokens}})}if(n.signal?.aborted){let e=t?.message;throw new Kb(`Model invocation was aborted.`,e)}if(t===void 0)throw Error(`Received empty response from chat model call.`);s===`v1`&&(t.message=az(t.message)),c.push([t]),await o?.[0].handleLLMEnd({generations:c,llmOutput:r})}catch(e){throw await o?.[0].handleLLMError(e),e}else{let e=await Promise.allSettled(a.map(async(e,t)=>{let r=await this._generate(e,{...n,promptIndex:t},o?.[t]);if(s===`v1`)for(let e of r.generations)e.message=az(e.message);return r}));await Promise.all(e.map(async(e,t)=>{if(e.status===`fulfilled`){let n=e.value;for(let e of n.generations){if(e.message.id==null){let t=o?.at(0)?.runId;t!=null&&e.message._updateId(`run-${t}`)}e.message.response_metadata={...e.generationInfo,...e.message.response_metadata}}return n.generations.length===1&&(n.generations[0].message.response_metadata={...n.llmOutput,...n.generations[0].message.response_metadata}),c[t]=n.generations,l[t]=n.llmOutput,o?.[t]?.handleLLMEnd({generations:[n.generations],llmOutput:n.llmOutput})}else return await o?.[t]?.handleLLMError(e.reason),Promise.reject(e.reason)}))}let f={generations:c,llmOutput:l.length?this._combineLLMOutput?.(...l):void 0};return Object.defineProperty(f,Rj,{value:o?{runIds:o?.map(e=>e.runId)}:void 0,configurable:!0}),f}async _generateCached({messages:t,cache:n,llmStringKey:r,parsedOptions:i,handledOptions:a}){let o=t.map(e=>e.map(lC)),s={...a.metadata,...this.getLsParamsWithDefaults(i)},c=this._getInvocationParamsForTracing(i),l=await JA.configure(a.callbacks,this.callbacks,a.tags,this.tags,s,this.metadata,{verbose:this.verbose,tracerInheritableMetadata:this._filterInvocationParamsForTracing(c)}),u={options:this._getCallOptionsForTracing(i,c),invocation_params:c,batch_size:1},d=await l?.handleChatModelStart(this.toJSON(),o.map(Kz),a.runId,void 0,u,void 0,void 0,a.runName),f=[],p=(await Promise.allSettled(o.map(async(t,i)=>{let a=e._convertInputToPromptValue(t).toString(),o=await n.lookup(a,r);return o??f.push(i),o}))).map((e,t)=>({result:e,runManager:d?.[t]})).filter(({result:e})=>e.status===`fulfilled`&&e.value!=null||e.status===`rejected`),m=i.outputVersion??this.outputVersion,h=[];await Promise.all(p.map(async({result:e,runManager:t},n)=>{if(e.status===`fulfilled`){let r=e.value;return h[n]=r.map(e=>(`message`in e&&dS(e.message)&&gC(e.message)&&(e.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},m===`v1`&&(e.message=az(e.message))),e.generationInfo={...e.generationInfo,tokenUsage:{}},e)),r.length&&await t?.handleLLMNewToken(r[0].text),t?.handleLLMEnd({generations:[r]},void 0,void 0,void 0,{cached:!0})}else return await t?.handleLLMError(e.reason,void 0,void 0,void 0,{cached:!0}),Promise.reject(e.reason)}));let g={generations:h,missingPromptIndices:f,startedRunManagers:d};return Object.defineProperty(g,Rj,{value:d?{runIds:d?.map(e=>e.runId)}:void 0,configurable:!0}),g}async generate(t,n,r){let i;i=Array.isArray(n)?{stop:n}:n;let a=t.map(e=>e.map(lC)),[o,s]=this._separateRunnableConfigFromCallOptionsCompat(i);if(o.callbacks=o.callbacks??r,!this.cache)return this._generateUncached(a,s,o);let{cache:c}=this,l=this._getSerializedCacheKeyParametersForCall(s),{generations:u,missingPromptIndices:d,startedRunManagers:f}=await this._generateCached({messages:a,cache:c,llmStringKey:l,parsedOptions:s,handledOptions:o}),p={};if(d.length>0){let t=await this._generateUncached(d.map(e=>a[e]),s,o,f===void 0?void 0:d.map(e=>f?.[e]));await Promise.all(t.generations.map(async(t,n)=>{let r=d[n];u[r]=t;let i=e._convertInputToPromptValue(a[r]).toString();return c.update(i,l,t)})),p=t.llmOutput??{}}return{generations:u,llmOutput:p}}_getInvocationParamsForTracing(e){return this.invocationParams(e)}_getCallOptionsForTracing(e,t){return e}invocationParams(e){return{}}_modelType(){return`base_chat_model`}async generatePrompt(e,t,n){let r=e.map(e=>e.toChatMessages());return this.generate(r,t,n)}withStructuredOutput(e,t){if(typeof this.bindTools!=`function`)throw Error(`Chat model must implement ".bindTools()" to use withStructuredOutput.`);if(t?.strict)throw Error(`"strict" mode is not supported for this model by default.`);let n=e,r=t?.name,i=iM(n)??`A function available to call.`,a=t?.method,o=t?.includeRaw;if(a===`jsonMode`)throw Error(`Base withStructuredOutput implementation only supports "functionCalling" as a method.`);let s=r??`extract`;!nM(n)&&!aF(n)&&`name`in n&&(s=n.name);let c=nM(n)||aF(n)?WF(n):n,l=[{type:`function`,function:{name:s,description:i,parameters:c}}];return Sz(this.bindTools(l),pI.from(e=>{if(!vC.isInstance(e))throw Error(`Input is not an AIMessageChunk.`);if(!e.tool_calls||e.tool_calls.length===0)throw Error(`No tool calls found in the response.`);let t=e.tool_calls.find(e=>e.name===s);if(!t)throw Error(`No tool call found with name ${s}.`);return t.args}),o,o?`StructuredOutputRunnable`:`StructuredOutput`)}};function Jz(e,t){return typeof e==`string`?{model:e,...t??{}}:e??t}var Yz=class extends qz{temperature;topP;frequencyPenalty;presencePenalty;n;logitBias;model=`gpt-3.5-turbo`;modelKwargs;stop;stopSequences;user;timeout;streaming=!1;streamUsage=!0;maxTokens;logprobs;topLogprobs;apiKey;organization;__includeRawResponse;client;clientConfig;supportsStrictToolCalling;audio;modalities;reasoning;zdrEnabled;service_tier;promptCacheKey;promptCacheRetention;verbosity;defaultOptions;_llmType(){return`openai`}static lc_name(){return`ChatOpenAI`}get callKeys(){return[...super.callKeys,`options`,`function_call`,`functions`,`tools`,`tool_choice`,`promptIndex`,`response_format`,`seed`,`reasoning`,`reasoning_effort`,`service_tier`]}lc_serializable=!0;get lc_secrets(){return{apiKey:`OPENAI_API_KEY`,organization:`OPENAI_ORGANIZATION`}}get lc_aliases(){return{apiKey:`openai_api_key`,modelName:`model`}}get lc_serializable_keys(){return`configuration.logprobs.topLogprobs.prefixMessages.supportsStrictToolCalling.modalities.audio.temperature.maxTokens.topP.frequencyPenalty.presencePenalty.n.logitBias.user.streaming.streamUsage.model.modelName.modelKwargs.stop.stopSequences.timeout.apiKey.cache.maxConcurrency.maxRetries.verbose.callbacks.tags.metadata.disableStreaming.zdrEnabled.reasoning.promptCacheKey.promptCacheRetention.verbosity`.split(`.`)}getLsParams(e){let t=this.invocationParams(e);return{ls_provider:`openai`,ls_model_name:this.model,ls_model_type:`chat`,ls_temperature:t.temperature??void 0,ls_max_tokens:t.max_tokens??void 0,ls_stop:e.stop}}_identifyingParams(){return{model_name:this.model,...this.invocationParams(),...this.clientConfig}}identifyingParams(){return this._identifyingParams()}constructor(e){super(e??{});let t=typeof e?.configuration?.apiKey==`string`||typeof e?.configuration?.apiKey==`function`?e?.configuration?.apiKey:void 0;this.apiKey=e?.apiKey??t??tw(`OPENAI_API_KEY`),this.organization=e?.configuration?.organization??tw(`OPENAI_ORGANIZATION`),this.model=e?.model??e?.modelName??this.model,this.modelKwargs=e?.modelKwargs??{},this.timeout=e?.timeout,this.temperature=e?.temperature??this.temperature,this.topP=e?.topP??this.topP,this.frequencyPenalty=e?.frequencyPenalty??this.frequencyPenalty,this.presencePenalty=e?.presencePenalty??this.presencePenalty,this.logprobs=e?.logprobs,this.topLogprobs=e?.topLogprobs,this.n=e?.n??this.n,this.logitBias=e?.logitBias,this.stop=e?.stopSequences??e?.stop,this.stopSequences=this.stop,this.user=e?.user,this.__includeRawResponse=e?.__includeRawResponse,this.audio=e?.audio,this.modalities=e?.modalities,this.reasoning=e?.reasoning,this.maxTokens=e?.maxCompletionTokens??e?.maxTokens,this.promptCacheKey=e?.promptCacheKey??this.promptCacheKey,this.promptCacheRetention=e?.promptCacheRetention??this.promptCacheRetention,this.verbosity=e?.verbosity??this.verbosity,this.disableStreaming=e?.disableStreaming===!0,this.streaming=e?.streaming===!0,this.disableStreaming&&(this.streaming=!1),e?.streaming===!1&&(this.disableStreaming=!0),this.streamUsage=e?.streamUsage??this.streamUsage,this.disableStreaming&&(this.streamUsage=!1),this.clientConfig={apiKey:this.apiKey,organization:this.organization,dangerouslyAllowBrowser:!0,...e?.configuration},e?.supportsStrictToolCalling!==void 0&&(this.supportsStrictToolCalling=e.supportsStrictToolCalling),e?.service_tier!==void 0&&(this.service_tier=e.service_tier),this.zdrEnabled=e?.zdrEnabled??!1,this._addVersion(`@langchain/openai`,`1.5.5`)}_getReasoningParams(e){if(!CI(this.model))return;let t;return this.reasoning!==void 0&&(t={...t,...this.reasoning}),e?.reasoning!==void 0&&(t={...t,...e.reasoning}),e?.reasoningEffort!==void 0&&t?.effort===void 0&&(t={...t,effort:e.reasoningEffort}),t}_getResponseFormat(e){return e&&e.type===`json_schema`&&e.json_schema.schema&&nM(e.json_schema.schema)?SR(e.json_schema.schema,e.json_schema.name,{description:e.json_schema.description}):e}_combineCallOptions(e){return{...this.defaultOptions,...e??{}}}_getClientOptions(e){if(!this.client){let e=AI({baseURL:this.clientConfig.baseURL}),t={...this.clientConfig,baseURL:e,timeout:this.timeout,maxRetries:0};t.baseURL||delete t.baseURL,t.defaultHeaders=PI(t.defaultHeaders),this.client=new Ib(t)}return{...this.clientConfig,...e}}_convertChatOpenAIToolToCompletionsTool(e,t){return XI(e)?rL(e.metadata.customTool):ez(e)?t?.strict===void 0?e:{...e,function:{...e.function,strict:t.strict}}:VI(e,t)}bindTools(e,t){let n;return t?.strict===void 0?this.supportsStrictToolCalling!==void 0&&(n=this.supportsStrictToolCalling):n=t.strict,this.withConfig({tools:e.map(e=>{if(qI(e)||XI(e))return e;if(JI(e))return e.extras.providerToolDefinition;let t=this._convertChatOpenAIToolToCompletionsTool(e,{strict:n});return RI(e)&&e.extras?.defer_loading===!0?{...t,defer_loading:!0}:t}),...t})}async stream(e,t){return super.stream(e,this._combineCallOptions(t))}async invoke(e,t){return super.invoke(e,this._combineCallOptions(t))}_combineLLMOutput(...e){return e.reduce((e,t)=>(t&&t.tokenUsage&&(e.tokenUsage.completionTokens+=t.tokenUsage.completionTokens??0,e.tokenUsage.promptTokens+=t.tokenUsage.promptTokens??0,e.tokenUsage.totalTokens+=t.tokenUsage.totalTokens??0),e),{tokenUsage:{completionTokens:0,promptTokens:0,totalTokens:0}})}async getNumTokensFromMessages(e){let t=0,n=0,r=0;this.model===`gpt-3.5-turbo-0301`?(n=4,r=-1):(n=3,r=1);let i=await Promise.all(e.map(async e=>{let[i,a]=await Promise.all([this.getNumTokens(e.content),this.getNumTokens(OI(e))]),o=e.name===void 0?0:r+await this.getNumTokens(e.name),s=i+n+a+o,c=e;if(c._getType()===`function`&&(s-=2),c.additional_kwargs?.function_call&&(s+=3),c?.additional_kwargs.function_call?.name&&(s+=await this.getNumTokens(c.additional_kwargs.function_call?.name)),c.additional_kwargs.function_call?.arguments)try{s+=await this.getNumTokens(JSON.stringify(JSON.parse(c.additional_kwargs.function_call?.arguments)))}catch(e){console.error(`Error parsing function arguments`,e,JSON.stringify(c.additional_kwargs.function_call)),s+=await this.getNumTokens(c.additional_kwargs.function_call?.arguments)}return t+=s,s}));return t+=3,{totalCount:t,countPerMessage:i}}async _getNumTokensFromGenerations(e){return(await Promise.all(e.map(async e=>e.message.additional_kwargs?.function_call?(await this.getNumTokensFromMessages([e.message])).countPerMessage[0]:await this.getNumTokens(e.message.content)))).reduce((e,t)=>e+t,0)}async _getEstimatedTokenCountFromPrompt(e,t,n){let r=(await this.getNumTokensFromMessages(e)).totalCount;if(t&&n!==`auto`){let e=UI(t);r+=await this.getNumTokens(e),r+=9}return t&&e.find(e=>e._getType()===`system`)&&(r-=4),n===`none`?r+=1:typeof n==`object`&&(r+=await this.getNumTokens(n.name)+4),r}async moderateContent(e,t){let n=this._getClientOptions(t?.options),r={input:e,model:t?.model??`omni-moderation-latest`};return this.caller.call(async()=>{try{return await this.client.moderations.create(r,n)}catch(e){throw Yb(e)}})}get profile(){return wR[this.model]??{}}_getStructuredOutputMethod(e){let t={...e};if(!this.model.startsWith(`gpt-3`)&&!this.model.startsWith(`gpt-4-`)&&this.model!==`gpt-4`){if(t?.method===void 0)return`jsonSchema`}else t.method===`jsonSchema`&&console.warn(`[WARNING]: JSON Schema is not supported for model "${this.model}". Falling back to tool calling.`);return t.method}withStructuredOutput(e,t){let n,r,{schema:i,name:a,includeRaw:o}={...t,schema:e};if(t?.strict!==void 0&&t.method===`jsonMode`)throw Error("Argument `strict` is only supported for `method` = 'function_calling'");let s=bR(this.model,t?.method);if(s===`jsonMode`){r=bz(i);let e=WF(i);n=this.withConfig({outputVersion:`v0`,response_format:{type:`json_object`},ls_structured_output_format:{kwargs:{method:`json_mode`},schema:{title:a??`extract`,...e}}})}else if(s===`jsonSchema`){let e=WF(i),o={name:a??`extract`,description:iM(e),schema:nM(i)?i:e,strict:t?.strict};if(n=this.withConfig({outputVersion:`v0`,response_format:{type:`json_schema`,json_schema:o},ls_structured_output_format:{kwargs:{method:`json_schema`},schema:{title:o.name,description:o.description,...e}}}),nM(i)||aF(i)){let e=bz(i);r=pI.from(async t=>`parsed`in t.additional_kwargs?t.additional_kwargs.parsed:e.invoke(t.content))}else r=new fz}else{let e=a??`extract`,o=WF(i),s;nM(i)||aF(i)?s={name:e,description:o.description,parameters:o}:typeof i.name==`string`&&typeof i.parameters==`object`&&i.parameters!=null?(s=i,e=i.name):(e=i.title??e,s={name:e,description:i.description??``,parameters:i}),n=this.withConfig({outputVersion:`v0`,tools:[{type:`function`,function:s}],tool_choice:{type:`function`,function:{name:e}},ls_structured_output_format:{kwargs:{method:`function_calling`},schema:{title:e,...o}},...t?.strict===void 0?{}:{strict:t.strict}}),r=xz(i,e)}return Sz(n,r,o)}},Xz={providerName:`ChatOpenAI`,fromStandardTextBlock(e){return{type:`text`,text:e.text}},fromStandardImageBlock(e){if(e.source_type===`url`)return{type:`image_url`,image_url:{url:e.url,...e.metadata?.detail?{detail:e.metadata.detail}:{}}};if(e.source_type===`base64`)return{type:`image_url`,image_url:{url:`data:${e.mime_type??``};base64,${e.data}`,...e.metadata?.detail?{detail:e.metadata.detail}:{}}};throw Error(`Image content blocks with source_type ${e.source_type} are not supported for ChatOpenAI`)},fromStandardAudioBlock(e){if(e.source_type===`url`){let t=nx({dataUrl:e.url});if(!t)throw Error(`URL audio blocks with source_type ${e.source_type} must be formatted as a data URL for ChatOpenAI`);let n=t.mime_type||e.mime_type||``,r;try{r=tx(n)}catch{throw Error(`Audio blocks with source_type ${e.source_type} must have mime type of audio/wav or audio/mp3`)}if(r.type!==`audio`||r.subtype!==`wav`&&r.subtype!==`mp3`)throw Error(`Audio blocks with source_type ${e.source_type} must have mime type of audio/wav or audio/mp3`);return{type:`input_audio`,input_audio:{format:r.subtype,data:t.data}}}if(e.source_type===`base64`){let t;try{t=tx(e.mime_type??``)}catch{throw Error(`Audio blocks with source_type ${e.source_type} must have mime type of audio/wav or audio/mp3`)}if(t.type!==`audio`||t.subtype!==`wav`&&t.subtype!==`mp3`)throw Error(`Audio blocks with source_type ${e.source_type} must have mime type of audio/wav or audio/mp3`);return{type:`input_audio`,input_audio:{format:t.subtype,data:e.data}}}throw Error(`Audio content blocks with source_type ${e.source_type} are not supported for ChatOpenAI`)},fromStandardFileBlock(e){if(e.source_type===`url`){let t=nx({dataUrl:e.url}),n=DI(e);if(!t)throw Error(`URL file blocks with source_type ${e.source_type} must be formatted as a data URL for ChatOpenAI`);return{type:`file`,file:{file_data:e.url,filename:n}}}if(e.source_type===`base64`){let t=DI(e);return{type:`file`,file:{file_data:`data:${e.mime_type??``};base64,${e.data}`,filename:t}}}if(e.source_type===`id`)return{type:`file`,file:{file_id:e.id}};throw Error(`File content blocks with source_type ${e.source_type} are not supported for ChatOpenAI`)}},Zz=({message:e,rawResponse:t,includeRawResponse:n})=>{let r=e.tool_calls,i=e.reasoning_content;switch(e.role){case`assistant`:{let a=[],o=[];for(let e of r??[])try{a.push(hz(e,{returnId:!0}))}catch(t){o.push(_z(e,t.message))}let s={function_call:e.function_call,tool_calls:r};n!==void 0&&(s.__raw_response=t),i!==void 0&&(s.reasoning_content=i);let c={model_provider:`openai`,model_name:t.model,...t.system_fingerprint?{usage:{...t.usage},system_fingerprint:t.system_fingerprint}:{}};return e.audio&&(s.audio=e.audio),new hC({content:CR(e.content||``,t.choices?.[0]?.message),tool_calls:a,invalid_tool_calls:o,additional_kwargs:s,response_metadata:c,id:t.id})}default:return new XS(e.content||``,e.role??`unknown`)}},Qz=({delta:e,rawResponse:t,includeRawResponse:n,defaultRole:r})=>{let i=e.role??r,a=e.content??``,o;o=e.function_call?{function_call:e.function_call}:e.tool_calls?{tool_calls:e.tool_calls}:{},n&&(o.__raw_response=t),e.reasoning_content!==void 0&&(o.reasoning_content=e.reasoning_content),e.audio&&(o.audio={...e.audio,index:t.choices[0].index});let s={model_provider:`openai`,usage:{...t.usage}};if(i===`user`)return new eC({content:a,response_metadata:s});if(i===`assistant`){let n=[];if(Array.isArray(e.tool_calls))for(let t of e.tool_calls)n.push({name:t.function?.name,args:t.function?.arguments,id:t.id,index:t.index,type:`tool_call_chunk`});return new vC({content:a,tool_call_chunks:n,additional_kwargs:o,id:t.id,response_metadata:s})}else if(i===`system`)return new rC({content:a,response_metadata:s});else if(i===`developer`)return new rC({content:a,response_metadata:s,additional_kwargs:{__openai_role__:`developer`}});else if(i===`function`)return new QS({content:a,additional_kwargs:o,name:e.name,response_metadata:s});else if(i===`tool`)return new bS({content:a,additional_kwargs:o,tool_call_id:e.tool_call_id,response_metadata:s});else return new ZS({content:a,role:i,response_metadata:s})},$z=e=>{if(e.type===`image`){if(e.url)return{type:`image_url`,image_url:{url:e.url}};if(e.data)return{type:`image_url`,image_url:{url:`data:${e.mimeType};base64,${e.data}`}}}if(e.type===`audio`&&e.data){let t=aC(()=>{let[,t]=e.mimeType.split(`/`);return t===`wav`||t===`mp3`?t:`wav`});return{type:`input_audio`,input_audio:{data:e.data.toString(),format:t}}}if(e.type===`file`){if(e.data){let t=DI(e);return{type:`file`,file:{file_data:`data:${e.mimeType};base64,${e.data}`,filename:t}}}if(e.fileId)return{type:`file`,file:{file_id:e.fileId}}}},eB=({message:e,model:t})=>{let n=OI(e);if(n===`system`&&CI(t)&&(n=`developer`),n===`developer`)return{role:`developer`,content:e.contentBlocks.filter(e=>e.type===`text`)};if(n===`system`)return{role:`system`,content:e.contentBlocks.filter(e=>e.type===`text`)};if(n===`assistant`){let t={role:`assistant`,content:e.contentBlocks.filter(e=>e.type===`text`)};return hC.isInstance(e)&&e.tool_calls?.length?t.tool_calls=e.tool_calls.map(gz):e.additional_kwargs.tool_calls!=null&&(t.tool_calls=e.additional_kwargs.tool_calls),t}else if(n===`tool`&&yS.isInstance(e))return{role:`tool`,tool_call_id:e.tool_call_id,content:e.contentBlocks.filter(e=>e.type===`text`)};else if(n===`function`)return{role:`function`,name:e.name??``,content:e.contentBlocks.filter(e=>e.type===`text`).join(``)};function*r(e){for(let t of e){t.type===`text`&&(yield{type:`text`,text:t.text});let e=$z(t);e&&(yield e)}}return{role:`user`,content:Array.from(r(e.contentBlocks))}},tB=({messages:e,model:t})=>e.flatMap(e=>{if(`output_version`in e.response_metadata&&e.response_metadata?.output_version===`v1`)return eB({message:e});let n=OI(e);n===`system`&&CI(t)&&(n=`developer`);let r=typeof e.content==`string`?e.content:e.content.flatMap(e=>Xb(e)?rx(e,Xz):typeof e==`object`&&e&&`type`in e&&(e.type===`tool_use`||e.type===`tool_call`||e.type===`reasoning`||e.type===`reasoning_content`||e.type===`thinking`)?[]:e),i={role:n,content:r};return e.name!=null&&(i.name=e.name),e.additional_kwargs.function_call!=null&&(i.function_call=e.additional_kwargs.function_call),hC.isInstance(e)&&e.tool_calls?.length?i.tool_calls=e.tool_calls.map(gz):(e.additional_kwargs.tool_calls!=null&&(i.tool_calls=e.additional_kwargs.tool_calls),yS.isInstance(e)&&e.tool_call_id!=null&&(i.tool_call_id=e.tool_call_id)),e.additional_kwargs.audio&&typeof e.additional_kwargs.audio==`object`&&`id`in e.additional_kwargs.audio?[i,{role:`assistant`,audio:{id:e.additional_kwargs.audio.id}}]:i});async function*nB(e,t={}){let n=t.streamUsage??!0,r=t.provider??`openai`,i=t.mapChunk,a=new Map,o=new Map,s=0,c=!1,l,u,d,f=!1,p=(e,t)=>{let n=o.get(e);if(n!==void 0)return{index:n,isNew:!1};let r=s++;return o.set(e,r),a.set(r,{...t}),{index:r,isNew:!0}};for await(let t of e){i&&(t=i(t)),c||(c=!0,yield{event:`message-start`,id:t.id}),!f&&(t.model||t.service_tier)&&(f=!0,yield{event:`provider`,provider:r,name:`stream_metadata`,payload:{model:t.model,service_tier:t.service_tier}}),t.usage&&n&&(l=oB(t.usage),yield{event:`usage`,usage:l});let e=t.x_groq?.usage;e&&n&&(l=iB(e),yield{event:`usage`,usage:l});let o=t.choices?.[0];if(!o)continue;o.finish_reason!=null&&(u=aB(o.finish_reason),d=sB(t,o));let{delta:s}=o;if(!s)continue;let m=rB(s);if(m){let{index:e,isNew:t}=p(`reasoning`,{type:`reasoning`,reasoning:``});t&&(yield{event:`content-block-start`,index:e,content:{type:`reasoning`,reasoning:``}});let n=a.get(e);n.reasoning=(n.reasoning??``)+m,yield{event:`content-block-delta`,index:e,delta:{type:`reasoning-delta`,reasoning:m}}}if(s.content){let{index:e,isNew:t}=p(`text`,{type:`text`,text:``});t&&(yield{event:`content-block-start`,index:e,content:{type:`text`,text:``}});let n=a.get(e);n.text=(n.text??``)+s.content,yield{event:`content-block-delta`,index:e,delta:{type:`text-delta`,text:s.content}}}if(Array.isArray(s.tool_calls))for(let e of s.tool_calls){let t=e.index??0,{index:n,isNew:r}=p(`tool:${t}`,{type:`tool_call_chunk`,id:e.id,name:e.function?.name,args:``,index:t});r&&(yield{event:`content-block-start`,index:n,content:{type:`tool_call_chunk`,id:e.id,name:e.function?.name,args:``,index:t}});let i=a.get(n);e.id!=null&&(i.id=e.id),e.function?.name!=null&&(i.name=e.function.name);let o=e.function?.arguments??``;i.args=(i.args??``)+o,yield{event:`content-block-delta`,index:n,delta:{type:`block-delta`,fields:{type:`tool_call_chunk`,...i.id==null?{}:{id:i.id},...i.name==null?{}:{name:i.name},args:i.args}}}}if(s.audio){let{index:e,isNew:t}=p(`audio`,{type:`audio`,id:s.audio.id,data:``,mimeType:`audio/pcm`,transcript:s.audio.transcript??``});t&&(yield{event:`content-block-start`,index:e,content:{type:`audio`,id:s.audio.id,data:``,mimeType:`audio/pcm`,transcript:s.audio.transcript??``}});let n=a.get(e);s.audio.transcript&&(n.transcript=(n.transcript??``)+s.audio.transcript,yield{event:`content-block-delta`,index:e,delta:{type:`block-delta`,fields:{type:`audio`,transcript:n.transcript}}}),s.audio.data&&(n.data=(n.data??``)+s.audio.data,yield{event:`content-block-delta`,index:e,delta:{type:`data-delta`,data:s.audio.data,encoding:`base64`}})}s.function_call&&(yield{event:`provider`,provider:r,name:`function_call`,payload:s.function_call}),o.logprobs&&(yield{event:`provider`,provider:r,name:`logprobs`,payload:o.logprobs})}for(let[e,t]of a)yield{event:`content-block-finish`,index:e,content:Gz(t)};yield{event:`message-finish`,reason:u,...l?{usage:l}:{},...d?{responseMetadata:d}:{}}}function rB(e){let t=e.reasoning_content??e.reasoning;return typeof t==`string`&&t.length>0?t:void 0}function iB(e){return{input_tokens:e.prompt_tokens??0,output_tokens:e.completion_tokens??0,total_tokens:e.total_tokens??0}}function aB(e){switch(e){case`stop`:return`stop`;case`length`:case`max_tokens`:return`length`;case`tool_calls`:case`function_call`:return`tool_use`;case`content_filter`:return`content_filter`;default:return`stop`}}function oB(e){let t={...e.prompt_tokens_details?.audio_tokens!=null&&{audio:e.prompt_tokens_details.audio_tokens},...e.prompt_tokens_details?.cached_tokens!=null&&{cache_read:e.prompt_tokens_details.cached_tokens}},n={...e.completion_tokens_details?.audio_tokens!=null&&{audio:e.completion_tokens_details.audio_tokens},...e.completion_tokens_details?.reasoning_tokens!=null&&{reasoning:e.completion_tokens_details.reasoning_tokens}};return{input_tokens:e.prompt_tokens??0,output_tokens:e.completion_tokens??0,total_tokens:e.total_tokens??0,...Object.keys(t).length>0&&{input_token_details:t},...Object.keys(n).length>0&&{output_token_details:n}}}function sB(e,t){return{model_provider:`openai`,model_name:e.model,system_fingerprint:e.system_fingerprint,service_tier:e.service_tier,finish_reason:t.finish_reason,...e.usage?{usage:e.usage}:{}}}var cB=class extends Yz{constructor(e,t){super(Jz(e,t))}invocationParams(e,t){let n;e?.strict===void 0?this.supportsStrictToolCalling!==void 0&&(n=this.supportsStrictToolCalling):n=e.strict,!(this.streaming||t?.streaming)&&e?.response_format?.type===`json_schema`&&n!==!1&&(n=!0);let r={};e?.stream_options===void 0?this.streamUsage&&(this.streaming||t?.streaming)&&(r={stream_options:{include_usage:!0}}):r={stream_options:e.stream_options};let i={model:this.model,temperature:this.temperature,top_p:this.topP,frequency_penalty:this.frequencyPenalty,presence_penalty:this.presencePenalty,logprobs:this.logprobs,top_logprobs:this.topLogprobs,n:this.n,logit_bias:this.logitBias,stop:e?.stop??this.stopSequences,user:this.user,stream:this.streaming,functions:e?.functions,function_call:e?.function_call,tools:e?.tools?.length?e.tools.map(e=>this._convertChatOpenAIToolToCompletionsTool(e,{strict:n})):void 0,tool_choice:KI(e?.tool_choice),response_format:this._getResponseFormat(e?.response_format),seed:e?.seed,...r,parallel_tool_calls:e?.parallel_tool_calls,...this.audio||e?.audio?{audio:this.audio||e?.audio}:{},...this.modalities||e?.modalities?{modalities:this.modalities||e?.modalities}:{},...this.modelKwargs,prompt_cache_key:e?.promptCacheKey??this.promptCacheKey,prompt_cache_retention:e?.promptCacheRetention??this.promptCacheRetention,verbosity:e?.verbosity??this.verbosity};e?.prediction!==void 0&&(i.prediction=e.prediction),this.service_tier!==void 0&&(i.service_tier=this.service_tier),e?.service_tier!==void 0&&(i.service_tier=e.service_tier);let a=this._getReasoningParams(e);return a!==void 0&&a.effort!==void 0&&(i.reasoning_effort=a.effort),CI(i.model)?i.max_completion_tokens=this.maxTokens===-1?void 0:this.maxTokens:i.max_tokens=this.maxTokens===-1?void 0:this.maxTokens,i}async _generate(e,t,n){t.signal?.throwIfAborted();let r={},i=this.invocationParams(t),a=tB({messages:e,model:this.model});if(i.stream){let i=this._streamResponseChunks(e,t,n),a={};for await(let e of i){e.message.response_metadata={...e.generationInfo,...e.message.response_metadata};let t=e.generationInfo?.completion??0;a[t]===void 0?a[t]=e:a[t]=a[t].concat(e)}let o=Object.entries(a).sort(([e],[t])=>parseInt(e,10)-parseInt(t,10)).map(([e,t])=>t),{functions:s,function_call:c}=this.invocationParams(t),l=await this._getEstimatedTokenCountFromPrompt(e,s,c),u=await this._getNumTokensFromGenerations(o);return r.input_tokens=l,r.output_tokens=u,r.total_tokens=l+u,{generations:o,llmOutput:{estimatedTokenUsage:{promptTokens:r.input_tokens,completionTokens:r.output_tokens,totalTokens:r.total_tokens}}}}else{let e=await this.completionWithRetry({...i,stream:!1,messages:a},{signal:t?.signal,...t?.options}),{completion_tokens:n,prompt_tokens:o,total_tokens:s,prompt_tokens_details:c,completion_tokens_details:l}=e?.usage??{};n&&(r.output_tokens=(r.output_tokens??0)+n),o&&(r.input_tokens=(r.input_tokens??0)+o),s&&(r.total_tokens=(r.total_tokens??0)+s),(c?.audio_tokens!==null||c?.cached_tokens!==null)&&(r.input_token_details={...c?.audio_tokens!==null&&{audio:c?.audio_tokens},...c?.cached_tokens!==null&&{cache_read:c?.cached_tokens}}),(l?.audio_tokens!==null||l?.reasoning_tokens!==null)&&(r.output_token_details={...l?.audio_tokens!==null&&{audio:l?.audio_tokens},...l?.reasoning_tokens!==null&&{reasoning:l?.reasoning_tokens}});let u=[];for(let t of e?.choices??[]){let n={text:t.message?.content??``,message:this._convertCompletionsMessageToBaseMessage(t.message??{role:`assistant`},e)};n.generationInfo={...t.finish_reason?{finish_reason:t.finish_reason}:{},...t.logprobs?{logprobs:t.logprobs}:{}},gC(n.message)&&(n.message.usage_metadata=r),n.message=new hC(Object.fromEntries(Object.entries(n.message).filter(([e])=>!e.startsWith(`lc_`)))),u.push(n)}return{generations:u,llmOutput:{tokenUsage:{promptTokens:r.input_tokens,completionTokens:r.output_tokens,totalTokens:r.total_tokens}}}}}async*_streamChatModelEvents(e,t,n){let r=tB({messages:e,model:this.model}),i={...this.invocationParams(t,{streaming:!0}),messages:r,stream:!0},a=await this.completionWithRetry(i,t),o=this.streamUsage??t.streamUsage;yield*nB(async function*(e,t){for await(let n of e){if(t?.aborted)return;yield n}}(a,t.signal),{streamUsage:o??!0,provider:this.streamEventProvider})}get streamEventProvider(){return`openai`}async*_streamResponseChunks(e,t,n){let r=tB({messages:e,model:this.model}),i={...this.invocationParams(t,{streaming:!0}),messages:r,stream:!0},a,o=await this.completionWithRetry(i,t),s;for await(let e of o){if(t.signal?.aborted)return;let r=e?.choices?.[0];if(e.usage&&(s=e.usage),!r)continue;let{delta:i}=r;if(!i)continue;let o=this._convertCompletionsDeltaToBaseMessageChunk(i,e,a);a=i.role??a;let c={prompt:t.promptIndex??0,completion:r.index??0};if(typeof o.content!=`string`){console.log(`[WARNING]: Received non-string content from OpenAI. This is currently not supported.`);continue}let l={...c};r.finish_reason!=null&&(l.finish_reason=r.finish_reason,l.system_fingerprint=e.system_fingerprint,l.model_name=e.model,l.service_tier=e.service_tier),this.logprobs&&(l.logprobs=r.logprobs);let u=new Bj({message:o,text:o.content,generationInfo:l});yield u,await n?.handleLLMNewToken(u.text??``,c,void 0,void 0,void 0,{chunk:u})}if(s){let e={...s.prompt_tokens_details?.audio_tokens!==null&&{audio:s.prompt_tokens_details?.audio_tokens},...s.prompt_tokens_details?.cached_tokens!==null&&{cache_read:s.prompt_tokens_details?.cached_tokens}},t={...s.completion_tokens_details?.audio_tokens!==null&&{audio:s.completion_tokens_details?.audio_tokens},...s.completion_tokens_details?.reasoning_tokens!==null&&{reasoning:s.completion_tokens_details?.reasoning_tokens}},r=new Bj({message:new vC({content:``,response_metadata:{usage:{...s}},usage_metadata:{input_tokens:s.prompt_tokens,output_tokens:s.completion_tokens,total_tokens:s.total_tokens,...Object.keys(e).length>0&&{input_token_details:e},...Object.keys(t).length>0&&{output_token_details:t}}}),text:``});yield r,await n?.handleLLMNewToken(r.text??``,{prompt:0,completion:0},void 0,void 0,void 0,{chunk:r})}if(t.signal?.aborted)throw Error(`AbortError`)}async completionWithRetry(e,t){let n=this._getClientOptions(t),r=e.response_format&&e.response_format.type===`json_schema`;return this.caller.call(async()=>{try{return r&&!e.stream?await this.client.chat.completions.parse(e,n):await this.client.chat.completions.create(e,n)}catch(e){throw Yb(e)}})}_convertCompletionsDeltaToBaseMessageChunk(e,t,n){return Qz({delta:e,rawResponse:t,includeRawResponse:this.__includeRawResponse,defaultRole:n})}_convertCompletionsMessageToBaseMessage(e,t){return Zz({message:e,rawResponse:t,includeRawResponse:this.__includeRawResponse})}},lB=`__openai_function_call_ids__`,uB=`__openai_custom_tool_call_ids__`;function dB(e){return e.type===`url_citation`?{type:`citation`,source:`url_citation`,url:e.url,title:e.title,startIndex:e.start_index,endIndex:e.end_index}:e.type===`file_citation`?{type:`citation`,source:`file_citation`,title:e.filename,startIndex:e.index,file_id:e.file_id}:e.type===`container_file_citation`?{type:`citation`,source:`container_file_citation`,title:e.filename,startIndex:e.start_index,endIndex:e.end_index,file_id:e.file_id,container_id:e.container_id}:e.type===`file_path`?{type:`citation`,source:`file_path`,startIndex:e.index,file_id:e.file_id}:{type:`non_standard`,value:e}}function zre(e){if(e.type===`url_citation`||e.type===`file_citation`||e.type===`container_file_citation`||e.type===`file_path`)return e;if(e.type===`citation`){let t=e;if(t.source===`url_citation`)return{type:`url_citation`,url:t.url??``,title:t.title??``,start_index:t.startIndex??0,end_index:t.endIndex??0};if(t.source===`file_citation`)return{type:`file_citation`,file_id:t.file_id??``,filename:t.title??``,index:t.startIndex??0};if(t.source===`container_file_citation`)return{type:`container_file_citation`,file_id:t.file_id??``,filename:t.title??``,container_id:t.container_id??``,start_index:t.startIndex??0,end_index:t.endIndex??0};if(t.source===`file_path`)return{type:`file_path`,file_id:t.file_id??``,index:t.startIndex??0}}return e.type===`non_standard`?e.value:e}var fB=e=>{let t={...e?.input_tokens_details?.cached_tokens!=null&&{cache_read:e?.input_tokens_details?.cached_tokens}},n={...e?.output_tokens_details?.reasoning_tokens!=null&&{reasoning:e?.output_tokens_details?.reasoning_tokens}};return{input_tokens:e?.input_tokens??0,output_tokens:e?.output_tokens??0,total_tokens:e?.total_tokens??0,input_token_details:t,output_token_details:n}},pB=e=>{if(e.error){let t=Error(e.error.message);throw t.name=e.error.code,t}let t=[],n=[],r=[],i=e.output.map(e=>{if(e.type===`function_call`&&`parsed_arguments`in e){let t={...e};return delete t.parsed_arguments,t}return e}),a={model_provider:`openai`,model:e.model,created_at:e.created_at,id:e.id,incomplete_details:e.incomplete_details,metadata:e.metadata,object:e.object,output:i,status:e.status,user:e.user,service_tier:e.service_tier,model_name:e.model},o={};for(let i of e.output)if(i.type===`message`)t.push(...i.content.flatMap(e=>e.type===`output_text`?(`parsed`in e&&e.parsed!=null&&(o.parsed=e.parsed),{type:`text`,text:e.text,annotations:e.annotations.map(dB),...i.phase===null?{}:{phase:i.phase}}):e.type===`refusal`?(o.refusal=e.refusal,[]):e));else if(i.type===`function_call`){let e={function:{name:i.name,arguments:i.arguments},id:i.call_id};try{n.push(hz(e,{returnId:!0}))}catch(t){let n;typeof t==`object`&&t&&`message`in t&&typeof t.message==`string`&&(n=t.message),r.push(_z(e,n))}o[lB]??={},i.id&&(o[lB][i.call_id]=i.id)}else if(i.type===`reasoning`){o.reasoning=i;let e=i.summary?.map(e=>e.text).filter(Boolean).join(``);e&&t.push({type:`reasoning`,reasoning:e})}else if(i.type===`custom_tool_call`){let e=QI(i);e?(n.push(e),o[uB]??={},i.id&&i.call_id&&(o[uB][i.call_id]=i.id)):r.push(_z(i,`Malformed custom tool call`))}else if(i.type===`computer_call`){let e=$I(i);e?n.push(e):r.push(_z(i,`Malformed computer call`))}else i.type===`image_generation_call`?(i.result&&t.push({type:`image`,mimeType:`image/png`,data:i.result,id:i.id,metadata:{status:i.status}}),o.tool_outputs??=[],o.tool_outputs.push(i)):(o.tool_outputs??=[],o.tool_outputs.push(i));return new hC({id:e.id,content:t,tool_calls:n,invalid_tool_calls:r,usage_metadata:fB(e.usage),additional_kwargs:o,response_metadata:a})},Bre=e=>{let t=(e.summary.length>1?e.summary.reduce((e,t)=>{let n=e[e.length-1];return n.index===t.index?n.text+=t.text:e.push(t),e},[{...e.summary[0]}]):e.summary).map(e=>Object.fromEntries(Object.entries(e).filter(([e])=>e!==`index`)));return{...e,summary:t}},Vre=e=>{let t=[],n={},r,i=[],a={model_provider:`openai`},o={},s;if(e.type===`response.output_text.delta`)t.push({type:`text`,text:e.delta,index:e.content_index});else if(e.type===`response.output_text.annotation.added`)t.push({type:`text`,text:``,annotations:[dB(e.annotation)],index:e.content_index});else if(e.type===`response.output_item.added`&&e.item.type===`message`){let n=`phase`in e.item?e.item.phase:void 0;n&&t.push({type:`text`,text:``,phase:n,index:0})}else if(e.type===`response.output_item.added`&&e.item.type===`function_call`)i.push({type:`tool_call_chunk`,name:e.item.name,args:e.item.arguments,id:e.item.call_id,index:e.output_index}),o[lB]={[e.item.call_id]:e.item.id};else if(e.type===`response.output_item.added`&&e.item.type===`custom_tool_call`)i.push({type:`tool_call_chunk`,isCustomTool:!0,name:e.item.name,args:e.item.input,id:e.item.call_id,index:e.output_index}),o[uB]={[e.item.call_id]:e.item.id};else if(e.type===`response.output_item.done`&&e.item.type===`computer_call`)i.push({type:`tool_call_chunk`,name:`computer_use`,args:JSON.stringify({action:e.item.action}),id:e.item.call_id,index:e.output_index}),o.tool_outputs=[e.item];else if(e.type===`response.output_item.done`&&e.item.type===`image_generation_call`)e.item.result&&t.push({type:`image`,mimeType:`image/png`,data:e.item.result,id:e.item.id,metadata:{status:e.item.status}}),o.tool_outputs=[e.item];else if(e.type===`response.output_item.done`&&[`web_search_call`,`file_search_call`,`code_interpreter_call`,`shell_call`,`local_shell_call`,`mcp_call`,`mcp_list_tools`,`mcp_approval_request`,`custom_tool_call`,`tool_search_call`,`tool_search_output`].includes(e.item.type))o.tool_outputs=[e.item];else if(e.type===`response.created`)s=e.response.id,a.id=e.response.id,a.model_name=e.response.model,a.model=e.response.model;else if(e.type===`response.completed`||e.type===`response.incomplete`){s=e.response.id;let t=pB(e.response);if(r=fB(e.response.usage),e.response.text?.format?.type===`json_schema`&&t.text)try{o.parsed??=JSON.parse(t.text)}catch{}for(let[n,r]of Object.entries(e.response))n!==`id`&&(n===`output`?a[n]=t.response_metadata.output:a[n]=r)}else if(e.type===`response.function_call_arguments.delta`||e.type===`response.custom_tool_call_input.delta`)i.push({type:`tool_call_chunk`,args:e.delta,index:e.output_index,...e.type===`response.custom_tool_call_input.delta`?{isCustomTool:!0}:{}});else if(e.type===`response.web_search_call.in_progress`||e.type===`response.web_search_call.searching`||e.type===`response.web_search_call.completed`||e.type===`response.file_search_call.in_progress`||e.type===`response.file_search_call.searching`||e.type===`response.file_search_call.completed`||e.type===`response.image_generation_call.in_progress`||e.type===`response.image_generation_call.generating`||e.type===`response.image_generation_call.completed`){let[,t,r]=e.type.match(/^response\.(.*)\.([^.]+)$/)??[``,``,``];n={tool_outputs:{id:e.item_id,type:t,status:r}}}else if(e.type===`response.refusal.done`)o.refusal=e.refusal;else if(e.type===`response.output_item.added`&&`item`in e&&e.item.type===`reasoning`){let n=e.item.summary?e.item.summary.map((e,t)=>({...e,index:t})):void 0;o.reasoning={id:e.item.id,type:e.item.type,...n?{summary:n}:{}};let r=e.item.summary?.map(e=>e.text).filter(Boolean).join(``);r&&t.push({type:`reasoning`,reasoning:r})}else if(e.type===`response.reasoning_summary_part.added`)o.reasoning={type:`reasoning`,summary:[{...e.part,index:e.summary_index}]},e.part.text&&t.push({type:`reasoning`,reasoning:e.part.text,index:e.summary_index});else if(e.type===`response.reasoning_summary_text.delta`)o.reasoning={type:`reasoning`,summary:[{text:e.delta,type:`summary_text`,index:e.summary_index}]},e.delta&&t.push({type:`reasoning`,reasoning:e.delta,index:e.summary_index});else if(e.type===`response.image_generation_call.partial_image`)return null;else return null;return new Bj({text:t.map(e=>e.text).join(``),message:new vC({id:s,content:t,tool_call_chunks:i,usage_metadata:r,additional_kwargs:o,response_metadata:a}),generationInfo:n})},Hre=e=>{let t=hC.isInstance(e)&&e.response_metadata?.model_provider===`openai`;function*n(){let n=SI(()=>{try{let t=OI(e);return t===`system`||t===`developer`||t===`assistant`||t===`user`?t:`assistant`}catch{return`assistant`}}),r=e=>n===`assistant`?{type:`output_text`,text:e,annotations:[]}:{type:`input_text`,text:e},i,a=new Set,o=new Set,s=new Map,c=new Map;function*l(){if(!i)return;let e=i.content;(typeof e==`string`&&e.length>0||Array.isArray(e)&&e.length>0)&&(yield i),i=void 0}let u=(e,t)=>{i||={type:`message`,role:n,content:[],...t?{phase:t}:{}},typeof i.content==`string`?i.content=i.content.length>0?[r(i.content),...e]:[...e]:i.content.push(...e)},d=e=>{if(typeof e==`string`)return e;try{return JSON.stringify(e??{})}catch{return`{}`}},f=e=>{let t=SI(()=>{let t=e.metadata?.detail;return t===`low`||t===`high`||t===`auto`?t:`auto`});if(e.fileId)return{type:`input_image`,detail:t,file_id:e.fileId};if(e.url)return{type:`input_image`,detail:t,image_url:e.url};if(e.data){let n=typeof e.data==`string`?e.data:Buffer.from(e.data).toString(`base64`);return{type:`input_image`,detail:t,image_url:`data:${e.mimeType??`image/png`};base64,${n}`}}},p=e=>{if(e.fileId){let t=TI(e);return{type:`input_file`,file_id:e.fileId,...t?{filename:t}:{}}}if(e.url){let t=TI(e);return{...t?{filename:t}:{},type:`input_file`,file_url:e.url}}if(e.data){let t=DI(e),n=typeof e.data==`string`?e.data:Buffer.from(e.data).toString(`base64`);return{type:`input_file`,file_data:`data:${e.mimeType??`application/octet-stream`};base64,${n}`,filename:t}}},m=e=>{let t=SI(()=>{if(Array.isArray(e.summary)){let t=e.summary?.map(e=>e?.text).filter(e=>typeof e==`string`)??[];if(t.length>0)return t}return e.reasoning?[e.reasoning]:[]}),n=t.length>0?t.map(e=>({type:`summary_text`,text:e})):[{type:`summary_text`,text:``}];return{type:`reasoning`,...e.id?{id:e.id}:{},summary:n}},h=e=>({type:`function_call`,name:e.name??``,call_id:e.id??``,arguments:d(e.args)}),g=e=>{let t=d(e.output),n=e.status===`success`?`completed`:e.status===`error`?`incomplete`:void 0;return{type:`function_call_output`,call_id:e.toolCallId??``,output:t,...n?{status:n}:{}}};for(let n of e.contentBlocks)if(n.type===`text`){let e=SI(()=>{if(`extras`in n&&typeof n.extras==`object`&&n.extras!==null&&`phase`in n.extras)return n.extras.phase});u([r(n.text)],e)}else if(n.type!==`invalid_tool_call`){if(n.type===`reasoning`)yield*l(),yield m(n);else if(n.type===`tool_call`){yield*l();let e=n.id??``;e&&(a.add(e),s.delete(e)),yield h(n)}else if(n.type===`tool_call_chunk`){if(n.id){let e=s.get(n.id)??{name:n.name,args:[]};n.name&&(e.name=n.name),n.args&&e.args.push(n.args),s.set(n.id,e)}}else if(n.type===`server_tool_call`){yield*l();let e=n.id??``;e&&(o.add(e),c.delete(e)),yield h(n)}else if(n.type===`server_tool_call_chunk`){if(n.id){let e=c.get(n.id)??{name:n.name,args:[]};n.name&&(e.name=n.name),n.args&&e.args.push(n.args),c.set(n.id,e)}}else if(n.type===`server_tool_call_result`)yield*l(),yield g(n);else if(n.type!==`audio`)if(n.type===`file`){let e=p(n);e&&u([e])}else if(n.type===`image`){let e=f(n);e&&u([e])}else if(n.type===`video`){let e=p(n);e&&u([e])}else n.type===`text-plain`?n.text&&u([r(n.text)]):n.type===`non_standard`&&t&&(yield*l(),yield n.value)}yield*l();for(let[e,t]of s){if(!e||a.has(e))continue;let n=t.args.join(``);!t.name&&!n||(yield{type:`function_call`,call_id:e,name:t.name??``,arguments:n})}for(let[e,t]of c){if(!e||o.has(e))continue;let n=t.args.join(``);!t.name&&!n||(yield{type:`function_call`,call_id:e,name:t.name??``,arguments:n})}}return Array.from(n())},mB=({messages:e,zdrEnabled:t,model:n})=>e.flatMap(e=>{let r=e.response_metadata;if(r?.output_version===`v1`)return Hre(e);let i=e.additional_kwargs,a=OI(e);if(a===`system`&&CI(n)&&(a=`developer`),a===`function`)throw Error(`Function messages are not supported in Responses API`);if(a===`tool`){let t=e;if(i?.type===`computer_call_output`)return{type:`computer_call_output`,output:(()=>{if(typeof t.content==`string`)return{type:`input_image`,image_url:t.content};if(Array.isArray(t.content)){let e=t.content.find(e=>e.type===`input_image`);if(e)return e;let n=t.content.find(e=>e.type===`computer_screenshot`);if(n)return n;let r=t.content.find(e=>e.type===`image_url`);if(r)return{type:`input_image`,image_url:typeof r.image_url==`string`?r.image_url:r.image_url.url}}throw Error(`Invalid computer call output`)})(),call_id:t.tool_call_id};if(t.additional_kwargs?.customTool)return{type:`custom_tool_call_output`,call_id:t.tool_call_id,output:t.content};let n=Array.isArray(t.content)&&t.content.every(e=>typeof e==`object`&&!!e&&`type`in e&&(e.type===`input_file`||e.type===`input_image`||e.type===`input_text`));return{type:`function_call_output`,call_id:t.tool_call_id,id:t.id?.startsWith(`fc_`)?t.id:void 0,output:n||typeof t.content==`string`?t.content:JSON.stringify(t.content)}}if(a===`assistant`){if(!t&&r?.output!=null&&Array.isArray(r?.output)&&r?.output.length>0&&r?.output.every(e=>`type`in e))return r?.output;let n=[],a=i?.reasoning,o=!!a?.encrypted_content;if(a&&(!t||o)){let e=Bre(a);n.push(e)}let{content:s}=e;if(i?.refusal&&(typeof s==`string`&&(s=[{type:`output_text`,text:s,annotations:[]}]),s=[...s,{type:`refusal`,refusal:i.refusal}]),typeof s==`string`||s.length>0){let r={type:`message`,role:`assistant`,...e.id&&!t&&e.id.startsWith(`msg_`)?{id:e.id}:{},content:SI(()=>typeof s==`string`?s:s.flatMap(e=>{if(e.type===`text`){let t=e;return{type:`output_text`,text:t.text,annotations:(t.annotations??[]).map(zre)}}return e.type===`output_text`||e.type===`refusal`?e:[]})),phase:SI(()=>{if(Array.isArray(s))return s.find(e=>`phase`in e&&typeof e.phase==`string`)?.phase})};n.push(r)}let c=i?.[lB],l=i?.[uB];hC.isInstance(e)&&e.tool_calls?.length?n.push(...e.tool_calls.map(e=>tL(e,l)?{type:`custom_tool_call`,id:`call_id`in e&&typeof e.call_id==`string`?e.call_id:l?.[e.id??``]??``,call_id:e.id??``,input:e.args.input,name:e.name}:eL(e)?{type:`computer_call`,id:e.call_id,call_id:e.id??``,action:e.args.action}:{type:`function_call`,name:e.name,arguments:JSON.stringify(e.args),call_id:e.id,...t?{}:{id:c?.[e.id]}})):i?.tool_calls&&n.push(...i.tool_calls.map(e=>({type:`function_call`,name:e.function.name,call_id:e.id,arguments:e.function.arguments,...t?{}:{id:c?.[e.id]}})));let u=r?.output?.length?r?.output:i.tool_outputs,d=[`computer_call`,`mcp_call`,`code_interpreter_call`,`image_generation_call`,`shell_call`,`local_shell_call`];if(u!=null){let e=u?.filter(e=>d.includes(e.type));e.length>0&&n.push(...e)}return n}if(a===`user`||a===`system`||a===`developer`){if(typeof e.content==`string`)return{type:`message`,role:a,content:e.content};let t=[],n=e.content.flatMap(e=>{if(e.type===`mcp_approval_response`&&t.push({type:`mcp_approval_response`,approval_request_id:e.approval_request_id,approve:e.approve}),Xb(e)){if(e.type===`file`){let t=TI(e);if(e.source_type===`url`)return{type:`input_file`,file_url:e.url,...t?{filename:t}:{}};if(e.source_type===`id`)return{type:`input_file`,file_id:e.id,...t?{filename:t}:{}};if(e.source_type===`base64`)return{type:`input_file`,file_data:`data:${e.mime_type??``};base64,${e.data}`,filename:DI(e)}}return rx(e,Xz)}return e.type===`text`?{type:`input_text`,text:e.text}:e.type===`image_url`?{type:`input_image`,image_url:SI(()=>{if(typeof e.image_url==`string`)return e.image_url;if(typeof e.image_url==`object`&&e.image_url!==null&&`url`in e.image_url)return e.image_url.url}),detail:SI(()=>{if(typeof e.image_url==`string`)return`auto`;if(typeof e.image_url==`object`&&e.image_url!==null&&`detail`in e.image_url)return e.image_url.detail})}:e.type===`input_text`||e.type===`input_image`||e.type===`input_file`?e:[]});return n.length>0&&t.push({type:`message`,role:a,content:n}),t}return console.warn(`Unsupported role found when converting to OpenAI Responses API: ${a}`),[]});async function*Ure(e,t={}){let n=t.streamUsage??!0,r=t.provider??`openai`,i=new Map,a=new Map,o=0,s=!1,c,l,u,d,f=new Set,p=(e,t)=>{let n=a.get(e);if(n!==void 0)return{index:n,isNew:!1};let r=o++;return a.set(e,r),i.set(r,{...t}),{index:r,isNew:!0}},m=function*(){s||(s=!0,yield{event:`message-start`,id:c})},h=function*(e){if(f.has(e))return;let t=i.get(e);t&&(f.add(e),yield{event:`content-block-finish`,index:e,content:Gz(t)})};for await(let t of e){if(t.type===`response.created`){c=t.response.id,yield*m(),yield{event:`provider`,provider:r,name:`response.created`,payload:{model:t.response.model,id:t.response.id}};continue}if(t.type===`response.output_text.delta`){yield*m();let{index:e,isNew:n}=p(`text:${t.output_index}:${t.content_index}`,{type:`text`,text:``});n&&(yield{event:`content-block-start`,index:e,content:{type:`text`,text:``}});let r=i.get(e);r.text=(r.text??``)+t.delta,yield{event:`content-block-delta`,index:e,delta:{type:`text-delta`,text:t.delta}};continue}if(t.type===`response.reasoning_summary_text.delta`){yield*m();let{index:e,isNew:n}=p(`reasoning:${t.output_index}:${t.summary_index}`,{type:`reasoning`,reasoning:``});n&&(yield{event:`content-block-start`,index:e,content:{type:`reasoning`,reasoning:``}});let r=i.get(e);r.reasoning=(r.reasoning??``)+t.delta,yield{event:`content-block-delta`,index:e,delta:{type:`reasoning-delta`,reasoning:t.delta}};continue}if(t.type===`response.output_item.added`&&(t.item.type===`function_call`||t.item.type===`custom_tool_call`)){yield*m();let e=`tool:${t.output_index}`,n=t.item.type===`custom_tool_call`,r=t.item.type===`function_call`?t.item.arguments??``:t.item.input??``,{index:a,isNew:o}=p(e,{type:`tool_call_chunk`,id:t.item.call_id,name:t.item.name,args:r,index:t.output_index,...n?{isCustomTool:!0}:{}});if(o&&(yield{event:`content-block-start`,index:a,content:{type:`tool_call_chunk`,id:t.item.call_id,name:t.item.name,args:r,index:t.output_index}}),r){let e=i.get(a);yield{event:`content-block-delta`,index:a,delta:{type:`block-delta`,fields:{type:`tool_call_chunk`,...e.id==null?{}:{id:e.id},...e.name==null?{}:{name:e.name},args:e.args}}}}continue}if(t.type===`response.function_call_arguments.delta`||t.type===`response.custom_tool_call_input.delta`){yield*m();let{index:e,isNew:n}=p(`tool:${t.output_index}`,{type:`tool_call_chunk`,args:``,index:t.output_index,...t.type===`response.custom_tool_call_input.delta`?{isCustomTool:!0}:{}});n&&(yield{event:`content-block-start`,index:e,content:{type:`tool_call_chunk`,args:``,index:t.output_index}});let r=i.get(e);r.args=(r.args??``)+t.delta,yield{event:`content-block-delta`,index:e,delta:{type:`block-delta`,fields:{type:`tool_call_chunk`,...r.id==null?{}:{id:r.id},...r.name==null?{}:{name:r.name},args:r.args}}};continue}if(t.type===`response.output_item.done`&&(t.item.type===`function_call`||t.item.type===`custom_tool_call`)){yield*m();let e=`tool:${t.output_index}`,n=t.item.type===`function_call`?t.item.arguments??``:t.item.input??``,{index:r,isNew:a}=p(e,{type:`tool_call_chunk`,id:t.item.call_id,name:t.item.name,args:n,index:t.output_index});if(a)yield{event:`content-block-start`,index:r,content:{type:`tool_call_chunk`,id:t.item.call_id,name:t.item.name,args:n,index:t.output_index}};else{let e=i.get(r);e.args=n,e.id=t.item.call_id,e.name=t.item.name}yield*h(r);continue}if(t.type===`response.completed`||t.type===`response.incomplete`){yield*m(),c=t.response.id,u=Wre(t.response.status,t.type),d={model_provider:r,id:t.response.id,model:t.response.model,status:t.response.status},n&&t.response.usage&&(l=fB(t.response.usage),yield{event:`usage`,usage:l});continue}t.type!==`response.image_generation_call.partial_image`&&(yield*m(),yield{event:`provider`,provider:r,name:t.type,payload:t})}s||(yield{event:`message-start`});for(let[e]of i)f.has(e)||(yield*h(e));yield{event:`message-finish`,reason:u,...l?{usage:l}:{},...d?{responseMetadata:d}:{}}}function Wre(e,t){return t===`response.incomplete`?`length`:e===`completed`?`stop`:e===`incomplete`?`length`:`stop`}var Gre=class extends Yz{constructor(e,t){super(Jz(e,t))}invocationParams(e){let t;e?.strict!==void 0&&(t=e.strict),t===void 0&&this.supportsStrictToolCalling!==void 0&&(t=this.supportsStrictToolCalling);let n={model:this.model,temperature:this.temperature,top_p:this.topP,user:this.user,service_tier:this.service_tier,stream:this.streaming,previous_response_id:e?.previous_response_id,truncation:e?.truncation,include:e?.include,tools:e?.tools?.length?this._reduceChatOpenAITools(e.tools,{stream:this.streaming,strict:t}):void 0,tool_choice:YI(e?.tool_choice)?e?.tool_choice:(()=>{let t=KI(e?.tool_choice);if(typeof t==`object`&&`type`in t){if(t.type===`function`)return{type:`function`,name:t.function.name};if(t.type===`allowed_tools`)return{type:`allowed_tools`,mode:t.allowed_tools.mode,tools:t.allowed_tools.tools};if(t.type===`custom`)return{type:`custom`,name:t.custom.name}}})(),text:(()=>{if(e?.text)return e.text;let t=this._getResponseFormat(e?.response_format);return t?.type===`json_schema`?t.json_schema.schema==null?void 0:{format:{type:`json_schema`,schema:t.json_schema.schema,description:t.json_schema.description,name:t.json_schema.name,strict:t.json_schema.strict},verbosity:e?.verbosity}:{format:t,verbosity:e?.verbosity}})(),parallel_tool_calls:e?.parallel_tool_calls,max_output_tokens:this.maxTokens===-1?void 0:this.maxTokens,prompt_cache_key:e?.promptCacheKey??this.promptCacheKey,prompt_cache_retention:e?.promptCacheRetention??this.promptCacheRetention,...this.zdrEnabled?{store:!1}:{},...this.modelKwargs},r=this._getReasoningParams(e);return r!==void 0&&(n.reasoning=r),n}async _generate(e,t,n){t.signal?.throwIfAborted();let r=this.invocationParams(t);if(r.stream){let r=this._streamResponseChunks(e,t,n),i;for await(let e of r)e.message.response_metadata={...e.generationInfo,...e.message.response_metadata},i=i?.concat(e)??e;return{generations:i?[i]:[],llmOutput:{estimatedTokenUsage:i?.message?.usage_metadata}}}else{let n=await this.completionWithRetry({input:mB({messages:e,zdrEnabled:this.zdrEnabled??!1,model:this.model}),...r,stream:!1},{signal:t?.signal,...t?.options});return{generations:[{text:n.output_text,message:pB(n)}],llmOutput:{id:n.id,estimatedTokenUsage:n.usage?{promptTokens:n.usage.input_tokens,completionTokens:n.usage.output_tokens,totalTokens:n.usage.total_tokens}:void 0}}}}async*_streamChatModelEvents(e,t,n){let r=await this.completionWithRetry({...this.invocationParams(t),input:mB({messages:e,zdrEnabled:this.zdrEnabled??!1,model:this.model}),stream:!0},t),i=this.streamUsage??t.streamUsage;yield*Ure(async function*(e,t){for await(let n of e){if(t?.aborted)return;yield n}}(r,t.signal),{streamUsage:i??!0,provider:this.streamEventProvider})}get streamEventProvider(){return`openai`}async*_streamResponseChunks(e,t,n){let r=await this.completionWithRetry({...this.invocationParams(t),input:mB({messages:e,zdrEnabled:this.zdrEnabled??!1,model:this.model}),stream:!0},t);try{for await(let e of r){if(t.signal?.aborted)return;let r=Vre(e);r!=null&&(yield r,await n?.handleLLMNewToken(r.text||``,{prompt:t.promptIndex??0,completion:0},void 0,void 0,void 0,{chunk:r}))}}catch(e){throw Yb(e)}}async completionWithRetry(e,t){return this.caller.call(async()=>{let n=this._getClientOptions(t);try{return e.text?.format?.type===`json_schema`&&!e.stream?await this.client.responses.parse(e,n):await this.client.responses.create(e,n)}catch(e){throw Yb(e)}})}_reduceChatOpenAITools(e,t){let n=[];for(let r of e)if(qI(r))r.type===`image_generation`&&t?.stream&&(r.partial_images=1),n.push(r);else if(XI(r)){let e=r.metadata.customTool;n.push({type:`custom`,name:e.name,description:e.description,format:e.format})}else if(ez(r)){let e={};for(let[t,n]of Object.entries(r))t!==`type`&&t!==`function`&&(e[t]=n);n.push({type:`function`,name:r.function.name,parameters:r.function.parameters,description:r.function.description,strict:t?.strict??null,...e})}else ZI(r)&&n.push(nL(r));return n}},hB=class e extends Yz{useResponsesApi=!1;responses;completions;get lc_serializable_keys(){return[...super.lc_serializable_keys,`useResponsesApi`]}get callKeys(){return[...super.callKeys,`useResponsesApi`]}fields;constructor(e,t){let n=Jz(e,t);super(n),this.fields=n,this.useResponsesApi=n?.useResponsesApi??!1,this.responses=n?.responses??new Gre(n),this.completions=n?.completions??new cB(n)}_useResponsesApi(e){let t=e?.tools?.some(qI),n=e?.previous_response_id!=null||e?.text!=null||e?.truncation!=null||e?.include!=null||e?.reasoning?.summary!=null||this.reasoning?.summary!=null,r=e?.tools?.some(ZI)||e?.tools?.some(XI);return this.useResponsesApi||t||n||r||kI(this.model)}getLsParams(e){let t=this._combineCallOptions(e);return this._useResponsesApi(e)?this.responses.getLsParams(t):this.completions.getLsParams(t)}invocationParams(e){let t=this._combineCallOptions(e);return this._useResponsesApi(e)?this.responses.invocationParams(t):this.completions.invocationParams(t)}async _generate(e,t,n){return this._useResponsesApi(t)?this.responses._generate(e,t,n):this.completions._generate(e,t,n)}async*_streamChatModelEvents(e,t,n){if(this._useResponsesApi(t)){yield*this.responses._streamChatModelEvents(e,this._combineCallOptions(t),n);return}yield*this.completions._streamChatModelEvents(e,this._combineCallOptions(t),n)}async*_streamResponseChunks(e,t,n){if(this._useResponsesApi(t)){yield*this.responses._streamResponseChunks(e,this._combineCallOptions(t),n);return}yield*this.completions._streamResponseChunks(e,this._combineCallOptions(t),n)}withConfig(t){let n=new e(this.fields);return n.defaultOptions={...this.defaultOptions,...t},n}};cP(),aL();var gB=class extends nz{extras;returnDirect=!1;verboseParsingErrors=!1;get lc_namespace(){return[`langchain`,`tools`]}responseFormat=`content`;defaultConfig;constructor(e){super(e??{}),this.verboseParsingErrors=e?.verboseParsingErrors??this.verboseParsingErrors,this.responseFormat=e?.responseFormat??this.responseFormat,this.defaultConfig=e?.defaultConfig??this.defaultConfig,this.metadata=e?.metadata??this.metadata,this.extras=e?.extras??this.extras}async invoke(e,t){let n,r=ij(rj(this.defaultConfig,t));return WS(e)?(n=e.args,r={...r,toolCall:e}):n=e,this.call(n,r)}async call(e,t,n){let r=WS(e)?e.args:e,i;if(nM(this.schema))try{i=await rM(this.schema,r)}catch(t){let n=`Received tool input did not match expected schema`;throw this.verboseParsingErrors&&(n=`${n}\nDetails: ${t.message}`),jre(t)&&(n=`${n}\n\n${at(t)}`),new KS(n,JSON.stringify(e))}else{let t=HF(r,this.schema);if(!t.valid){let n=`Received tool input did not match expected schema`;throw this.verboseParsingErrors&&(n=`${n}\nDetails: ${t.errors.map(e=>`${e.keywordLocation}: ${e.error}`).join(`
148
- `)}`),new KS(n,JSON.stringify(e))}i=r}let a=VA(t),o=JA.configure(a.callbacks,this.callbacks,a.tags||n,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),s;WS(e)&&(s=e.id),!s&&GS(a)&&(s=a.toolCall.id);let c=await o?.handleToolStart(this.toJSON(),typeof e==`string`?e:JSON.stringify(e),a.runId,void 0,void 0,void 0,a.runName,s);delete a.runId;let l;try{let e=await this._call(i,c,a);l=tI(e)?await nI(e,async e=>{try{await c?.handleToolEvent(e)}catch(e){await c?.handleToolError(e)}}):e}catch(e){throw await c?.handleToolError(e),e}let u,d;if(this.responseFormat===`content_and_artifact`)if(Array.isArray(l)&&l.length===2)[u,d]=l;else throw Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.\nResult: ${JSON.stringify(l)}`);else u=l;let f=Xre({content:u,artifact:d,toolCallId:s,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(f),f}},Kre=class extends gB{schema=aP({input:rP().optional()}).transform(e=>e.input);constructor(e){super(e)}call(e,t){let n=typeof e==`string`||e==null?{input:e}:e;return super.call(n,t)}},qre=class extends Kre{static lc_name(){return`DynamicTool`}name;description;func;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect}async call(e,t){let n=VA(t);return n.runName===void 0&&(n.runName=this.name),super.call(e,n)}_call(e,t,n){return this.func(e,t,n)}},Jre=class extends gB{static lc_name(){return`DynamicStructuredTool`}description;func;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect,this.schema=e.schema}async call(e,t,n){let r=VA(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r,n)}_call(e,t,n){return this.func(e,t,n)}};function _B(e,t){let n=aM(t.schema),r=GF(t.schema);if(!t.schema||n||r)return new qre({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(t,n,r)=>new Promise((i,a)=>{let o=aj(r,{callbacks:n?.getChild()});QA.runWithConfig(oj(o),async()=>{try{i(e(t,o))}catch(e){a(e)}})})});let i=t.schema,a=t.description??t.schema.description??`${t.name} tool`;return new Jre({...t,description:a,schema:i,func:async(t,n,r)=>new Promise((i,a)=>{let o,s=()=>{r?.signal&&o&&r.signal.removeEventListener(`abort`,o)};r?.signal&&(o=()=>{s(),a(cj(r.signal))},r.signal.addEventListener(`abort`,o,{once:!0}));let c=aj(r,{callbacks:n?.getChild()});QA.runWithConfig(oj(c),async()=>{try{let n=await e(t,c);if(tI(n)){i(n);return}if(r?.signal?.aborted){s();return}s(),i(n)}catch(e){s(),a(e)}})})})}function Yre(e){return typeof e==`object`&&!!e&&`type`in e}function Xre(e){let{content:t,artifact:n,toolCallId:r,metadata:i}=e;return r&&!vS(t)?typeof t==`string`||Array.isArray(t)&&t.every(Yre)?new yS({status:`success`,content:t,artifact:n,tool_call_id:r,name:e.name,metadata:i}):new yS({status:`success`,content:Zre(t),artifact:n,tool_call_id:r,name:e.name,metadata:i}):t}function Zre(e){try{return JSON.stringify(e)??``}catch{return`${e}`}}aL(),L({action:cf([L({type:bf(`screenshot`)}),L({type:bf(`click`),x:Bd(),y:Bd(),button:vf([`left`,`right`,`wheel`,`back`,`forward`]).default(`left`)}),L({type:bf(`double_click`),x:Bd(),y:Bd(),button:vf([`left`,`right`,`wheel`,`back`,`forward`]).default(`left`)}),L({type:bf(`drag`),path:I(L({x:Bd(),y:Bd()}))}),L({type:bf(`keypress`),keys:I(F())}),L({type:bf(`move`),x:Bd(),y:Bd()}),L({type:bf(`scroll`),x:Bd(),y:Bd(),scroll_x:Bd(),scroll_y:Bd()}),L({type:bf(`type`),text:F()}),L({type:bf(`wait`),duration:Bd().optional()})])}),aL(),cf([L({type:bf(`exec`),command:I(F()),env:pf(F(),F()).optional(),working_directory:F().optional(),timeout_ms:Bd().optional(),user:F().optional()})]),aL(),L({commands:I(F()).describe(`Array of shell commands to execute`),timeout_ms:Bd().optional().describe(`Optional timeout in milliseconds for the commands`),max_output_length:Bd().optional().describe(`Optional maximum number of characters to return from each command`)}),aL(),cf([L({type:bf(`create_file`),path:F(),diff:F()}),L({type:bf(`update_file`),path:F(),diff:F()}),L({type:bf(`delete_file`),path:F()})]);function Qre(e){return!!(e==null||typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof Blob<`u`&&e instanceof Blob||e instanceof URLSearchParams||e instanceof FormData)}function $re(e){let t=e.model||`gpt-3.5-turbo`,n=e.temperature,r=e.maxTokens,i=e.baseUrl;if(e.mode===`direct`){let a=!1;try{a=typeof location<`u`&&location.protocol===`https:`&&![`localhost`,`127.0.0.1`,`0.0.0.0`].includes(location.hostname)}catch{}if(a){if(e.throwOnDirectInProduction)throw Error(`[page-agent-sdk][proxyLlm] direct 模式在生产环境(https + 非本地)会泄露 apiKey(进 bundle),建议改用 proxy 模式(throwOnDirectInProduction 已启用强安全闸;若确需生产直连,设为 false 显式承认风险)`);console.warn(`[page-agent-sdk][proxyLlm] direct 模式在生产环境(https + 非本地)会泄露 apiKey(进 bundle),建议改用 proxy 模式`)}if(!e.apiKey)throw Error(`[page-agent-sdk][proxyLlm] direct 模式需提供 apiKey(开发环境用真实 key)`);return new hB({apiKey:e.apiKey,model:t,temperature:n,maxTokens:r,configuration:i?{baseURL:i}:void 0})}i||console.warn(`[page-agent-sdk][proxyLlm] proxy 模式未配 baseUrl,将打到页面 origin(通常不是预期);请传代理地址如 '/api/llm'`);let a=e.userToken||`proxy`,o=null;function s(){return e.refreshToken?(o||=e.refreshToken().finally(()=>{o=null}),o):Promise.resolve(a)}return new hB({apiKey:a,model:t,temperature:n,maxTokens:r,configuration:{baseURL:i||`/`,fetch:async(t,n)=>{let r,i;typeof t==`string`?(r=t,i=n?.headers):t instanceof URL?(r=t.toString(),i=n?.headers):(r=t.url,i=n?.headers??t.headers);let o=new Headers(i);if(o.set(`Authorization`,`Bearer ${a}`),e.headers)for(let[t,n]of Object.entries(e.headers))o.set(t,n);let c=()=>fetch(r,{...n,headers:o}),l=await c();if(l.status===401&&e.refreshToken&&Qre(n?.body))try{a=await s(),o.set(`Authorization`,`Bearer ${a}`),l=await c()}catch{}return l}}})}function vB(e,t){if(t?.headers){let e=new Headers(t.headers),n=!1;for(let t of[...e.keys()])t.toLowerCase().startsWith(`x-stainless`)&&(e.delete(t),n=!0);n&&(t={...t,headers:e})}return fetch(e,t)}function yB(e){return!e||!e.startsWith(`/`)||typeof location>`u`||!location.origin?e:`${location.origin}${e}`}function bB(e,t={}){return new hB({apiKey:e.apiKey,model:e.model,temperature:t.temperature??e.temperature,maxTokens:t.maxTokens??e.maxTokens,configuration:{...e.baseUrl?{baseURL:yB(e.baseUrl)}:{},fetch:vB,...e.extraConfig},...e.extraBody?{modelKwargs:e.extraBody}:{}})}async function xB(e,t={}){if((e.provider??`openai`)===`openai`)return bB(e,t);let{ChatAnthropic:n}=await import(`@langchain/anthropic`);return new n({apiKey:e.apiKey,model:e.model,temperature:t.temperature??e.temperature,maxTokens:t.maxTokens??e.maxTokens,...e.baseUrl?{anthropicApiUrl:yB(e.baseUrl)}:{},...e.extraConfig?{clientOptions:e.extraConfig}:{}})}function SB(e){let t=e.content;return typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:e?.type===`text`&&typeof e.text==`string`?e.text:``).join(``):``}function CB(e){let t=e.additional_kwargs||{},n=t.reasoning_content||t.reasoning||``;return!n&&Array.isArray(e.content)&&(n=e.content.map(e=>e?.type===`thinking`?e.thinking??``:e?.type===`thinking_delta`?e.delta??e.thinking??``:``).join(``)),n}function wB(e){let t=e,n=[t?.additional_kwargs?.usage,t?.usage_metadata,t?.response_metadata?.usage,t?.response_metadata?.token_usage,t?.response_metadata?.tokenUsage];for(let e of n)if(e&&typeof e==`object`&&eie(e))return e}function eie(e){return[`prompt_tokens`,`completion_tokens`,`total_tokens`,`promptTokens`,`completionTokens`,`totalTokens`,`input_tokens`,`output_tokens`,`inputTokens`,`outputTokens`].some(t=>typeof e[t]==`number`&&e[t]>0)}function TB(e){let t=wB(e);if(!t||typeof t!=`object`)return null;let n=t,r=Number(n.prompt_tokens??n.promptTokens??n.input_tokens??n.inputTokens??0)||0,i=Number(n.completion_tokens??n.completionTokens??n.output_tokens??n.outputTokens??0)||0,a=Number(n.total_tokens??n.totalTokens??r+i)||0;return!r&&!i&&!a?null:{prompt_tokens:r,completion_tokens:i,total_tokens:a}}function EB(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var DB={},OB=[],kB=()=>{},AB=()=>!1,jB=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),MB=e=>e.startsWith(`onUpdate:`),NB=Object.assign,PB=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},tie=Object.prototype.hasOwnProperty,FB=(e,t)=>tie.call(e,t),IB=Array.isArray,LB=e=>KB(e)===`[object Map]`,RB=e=>KB(e)===`[object Set]`,zB=e=>KB(e)===`[object Date]`,BB=e=>typeof e==`function`,VB=e=>typeof e==`string`,HB=e=>typeof e==`symbol`,UB=e=>typeof e==`object`&&!!e,WB=e=>(UB(e)||BB(e))&&BB(e.then)&&BB(e.catch),GB=Object.prototype.toString,KB=e=>GB.call(e),nie=e=>KB(e).slice(8,-1),qB=e=>KB(e)===`[object Object]`,JB=e=>VB(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,YB=EB(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),XB=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},rie=/-\w/g,ZB=XB(e=>e.replace(rie,e=>e.slice(1).toUpperCase())),iie=/\B([A-Z])/g,QB=XB(e=>e.replace(iie,`-$1`).toLowerCase()),$B=XB(e=>e.charAt(0).toUpperCase()+e.slice(1)),eV=XB(e=>e?`on${$B(e)}`:``),tV=(e,t)=>!Object.is(e,t),nV=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},rV=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},iV=e=>{let t=parseFloat(e);return isNaN(t)?e:t},aie=e=>{let t=VB(e)?Number(e):NaN;return isNaN(t)?e:t},oie,aV=()=>oie||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{};function oV(e){if(IB(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=VB(r)?uie(r):oV(r);if(i)for(let e in i)t[e]=i[e]}return t}else if(VB(e)||UB(e))return e}var sie=/;(?![^(]*\))/g,cie=/:([^]+)/,lie=/\/\*[^]*?\*\//g;function uie(e){let t={};return e.replace(lie,``).split(sie).forEach(e=>{if(e){let n=e.split(cie);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function sV(e){let t=``;if(VB(e))t=e;else if(IB(e))for(let n=0;n<e.length;n++){let r=sV(e[n]);r&&(t+=r+` `)}else if(UB(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}var cV=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,die=EB(cV);cV+``;function lV(e){return!!e||e===``}function fie(e,t){if(e.length!==t.length)return!1;let n=!0;for(let r=0;n&&r<e.length;r++)n=uV(e[r],t[r]);return n}function uV(e,t){if(e===t)return!0;let n=zB(e),r=zB(t);if(n||r)return n&&r?e.getTime()===t.getTime():!1;if(n=HB(e),r=HB(t),n||r)return e===t;if(n=IB(e),r=IB(t),n||r)return n&&r?fie(e,t):!1;if(n=UB(e),r=UB(t),n||r){if(!n||!r||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e){let r=e.hasOwnProperty(n),i=t.hasOwnProperty(n);if(r&&!i||!r&&i||!uV(e[n],t[n]))return!1}}return String(e)===String(t)}var dV=e=>!!(e&&e.__v_isRef===!0),q=e=>VB(e)?e:e==null?``:IB(e)||UB(e)&&(e.toString===GB||!BB(e.toString))?dV(e)?q(e.value):JSON.stringify(e,fV,2):String(e),fV=(e,t)=>dV(t)?fV(e,t.value):LB(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[pV(t,r)+` =>`]=n,e),{})}:RB(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>pV(e))}:HB(t)?pV(t):UB(t)&&!IB(t)&&!qB(t)?String(t):t,pV=(e,t=``)=>HB(e)?`Symbol(${e.description??t})`:e,mV,pie=class{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!e&&mV&&(mV.active?(this.parent=mV,this.index=(mV.scopes||=[]).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].pause();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].resume();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].resume()}}run(e){if(this._active){let t=mV;try{return mV=this,e()}finally{mV=t}}}on(){++this._on===1&&(this.prevScope=mV,mV=this)}off(){if(this._on>0&&--this._on===0){if(mV===this)mV=this.prevScope;else{let e=mV;for(;e;){if(e.prevScope===this){e.prevScope=this.prevScope;break}e=e.prevScope}}this.prevScope=void 0}}stop(e){if(this._active){this._active=!1;let t,n;for(t=0,n=this.effects.length;t<n;t++)this.effects[t].stop();for(this.effects.length=0,t=0,n=this.cleanups.length;t<n;t++)this.cleanups[t]();if(this.cleanups.length=0,this.scopes){for(t=0,n=this.scopes.length;t<n;t++)this.scopes[t].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){let e=this.parent.scopes.pop();e&&e!==this&&(this.parent.scopes[this.index]=e,e.index=this.index)}this.parent=void 0}}};function mie(){return mV}function hie(e,t=!1){mV&&mV.cleanups.push(e)}var hV,gV=new WeakSet,_V=class{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,mV&&(mV.active?mV.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,gV.has(this)&&(gV.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||xV(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,NV(this),wV(this);let e=hV,t=kV;hV=this,kV=!0;try{return this.fn()}finally{TV(this),hV=e,kV=t,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)OV(e);this.deps=this.depsTail=void 0,NV(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?gV.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){EV(this)&&this.run()}get dirty(){return EV(this)}},vV=0,yV,bV;function xV(e,t=!1){if(e.flags|=8,t){e.next=bV,bV=e;return}e.next=yV,yV=e}function SV(){vV++}function CV(){if(--vV>0)return;if(bV){let e=bV;for(bV=void 0;e;){let t=e.next;e.next=void 0,e.flags&=-9,e=t}}let e;for(;yV;){let t=yV;for(yV=void 0;t;){let n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(t){e||=t}t=n}}if(e)throw e}function wV(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function TV(e){let t,n=e.depsTail,r=n;for(;r;){let e=r.prevDep;r.version===-1?(r===n&&(n=e),OV(r),gie(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=e}e.deps=t,e.depsTail=n}function EV(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(DV(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function DV(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===PV)||(e.globalVersion=PV,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!EV(e))))return;e.flags|=2;let t=e.dep,n=hV,r=kV;hV=e,kV=!0;try{wV(e);let n=e.fn(e._value);(t.version===0||tV(n,e._value))&&(e.flags|=128,e._value=n,t.version++)}catch(e){throw t.version++,e}finally{hV=n,kV=r,TV(e),e.flags&=-3}}function OV(e,t=!1){let{dep:n,prevSub:r,nextSub:i}=e;if(r&&(r.nextSub=i,e.prevSub=void 0),i&&(i.prevSub=r,e.nextSub=void 0),n.subs===e&&(n.subs=r,!r&&n.computed)){n.computed.flags&=-5;for(let e=n.computed.deps;e;e=e.nextDep)OV(e,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function gie(e){let{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}var kV=!0,AV=[];function jV(){AV.push(kV),kV=!1}function MV(){let e=AV.pop();kV=e===void 0||e}function NV(e){let{cleanup:t}=e;if(e.cleanup=void 0,t){let e=hV;hV=void 0;try{t()}finally{hV=e}}}var PV=0,_ie=class{constructor(e,t){this.sub=e,this.dep=t,this.version=t.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}},FV=class{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!hV||!kV||hV===this.computed)return;let t=this.activeLink;if(t===void 0||t.sub!==hV)t=this.activeLink=new _ie(hV,this),hV.deps?(t.prevDep=hV.depsTail,hV.depsTail.nextDep=t,hV.depsTail=t):hV.deps=hV.depsTail=t,IV(t);else if(t.version===-1&&(t.version=this.version,t.nextDep)){let e=t.nextDep;e.prevDep=t.prevDep,t.prevDep&&(t.prevDep.nextDep=e),t.prevDep=hV.depsTail,t.nextDep=void 0,hV.depsTail.nextDep=t,hV.depsTail=t,hV.deps===t&&(hV.deps=e)}return t}trigger(e){this.version++,PV++,this.notify(e)}notify(e){SV();try{for(let e=this.subs;e;e=e.prevSub)e.sub.notify()&&e.sub.dep.notify()}finally{CV()}}};function IV(e){if(e.dep.sc++,e.sub.flags&4){let t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let e=t.deps;e;e=e.nextDep)IV(e)}let n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}var LV=new WeakMap,RV=Symbol(``),zV=Symbol(``),BV=Symbol(``);function VV(e,t,n){if(kV&&hV){let t=LV.get(e);t||LV.set(e,t=new Map);let r=t.get(n);r||(t.set(n,r=new FV),r.map=t,r.key=n),r.track()}}function HV(e,t,n,r,i,a){let o=LV.get(e);if(!o){PV++;return}let s=e=>{e&&e.trigger()};if(SV(),t===`clear`)o.forEach(s);else{let i=IB(e),a=i&&JB(n);if(i&&n===`length`){let e=Number(r);o.forEach((t,n)=>{(n===`length`||n===BV||!HB(n)&&n>=e)&&s(t)})}else switch((n!==void 0||o.has(void 0))&&s(o.get(n)),a&&s(o.get(BV)),t){case`add`:i?a&&s(o.get(`length`)):(s(o.get(RV)),LB(e)&&s(o.get(zV)));break;case`delete`:i||(s(o.get(RV)),LB(e)&&s(o.get(zV)));break;case`set`:LB(e)&&s(o.get(RV));break}}CV()}function UV(e){let t=mH(e);return t===e?t:(VV(t,`iterate`,BV),fH(e)?t:t.map(hH))}function WV(e){return VV(e=mH(e),`iterate`,BV),e}function GV(e,t){return dH(e)?gH(uH(e)?hH(t):t):hH(t)}var vie={__proto__:null,[Symbol.iterator](){return KV(this,Symbol.iterator,e=>GV(this,e))},concat(...e){return UV(this).concat(...e.map(e=>IB(e)?UV(e):e))},entries(){return KV(this,`entries`,e=>(e[1]=GV(this,e[1]),e))},every(e,t){return qV(this,`every`,e,t,void 0,arguments)},filter(e,t){return qV(this,`filter`,e,t,e=>e.map(e=>GV(this,e)),arguments)},find(e,t){return qV(this,`find`,e,t,e=>GV(this,e),arguments)},findIndex(e,t){return qV(this,`findIndex`,e,t,void 0,arguments)},findLast(e,t){return qV(this,`findLast`,e,t,e=>GV(this,e),arguments)},findLastIndex(e,t){return qV(this,`findLastIndex`,e,t,void 0,arguments)},forEach(e,t){return qV(this,`forEach`,e,t,void 0,arguments)},includes(...e){return YV(this,`includes`,e)},indexOf(...e){return YV(this,`indexOf`,e)},join(e){return UV(this).join(e)},lastIndexOf(...e){return YV(this,`lastIndexOf`,e)},map(e,t){return qV(this,`map`,e,t,void 0,arguments)},pop(){return XV(this,`pop`)},push(...e){return XV(this,`push`,e)},reduce(e,...t){return JV(this,`reduce`,e,t)},reduceRight(e,...t){return JV(this,`reduceRight`,e,t)},shift(){return XV(this,`shift`)},some(e,t){return qV(this,`some`,e,t,void 0,arguments)},splice(...e){return XV(this,`splice`,e)},toReversed(){return UV(this).toReversed()},toSorted(e){return UV(this).toSorted(e)},toSpliced(...e){return UV(this).toSpliced(...e)},unshift(...e){return XV(this,`unshift`,e)},values(){return KV(this,`values`,e=>GV(this,e))}};function KV(e,t,n){let r=WV(e),i=r[t]();return r!==e&&!fH(e)&&(i._next=i.next,i.next=()=>{let e=i._next();return e.done||(e.value=n(e.value)),e}),i}var yie=Array.prototype;function qV(e,t,n,r,i,a){let o=WV(e),s=o!==e&&!fH(e),c=o[t];if(c!==yie[t]){let t=c.apply(e,a);return s?hH(t):t}let l=n;o!==e&&(s?l=function(t,r){return n.call(this,GV(e,t),r,e)}:n.length>2&&(l=function(t,r){return n.call(this,t,r,e)}));let u=c.call(o,l,r);return s&&i?i(u):u}function JV(e,t,n,r){let i=WV(e),a=i!==e&&!fH(e),o=n,s=!1;i!==e&&(a?(s=r.length===0,o=function(t,r,i){return s&&(s=!1,t=GV(e,t)),n.call(this,t,GV(e,r),i,e)}):n.length>3&&(o=function(t,r,i){return n.call(this,t,r,i,e)}));let c=i[t](o,...r);return s?GV(e,c):c}function YV(e,t,n){let r=mH(e);VV(r,`iterate`,BV);let i=r[t](...n);return(i===-1||i===!1)&&pH(n[0])?(n[0]=mH(n[0]),r[t](...n)):i}function XV(e,t,n=[]){jV(),SV();let r=mH(e)[t].apply(e,n);return CV(),MV(),r}var bie=EB(`__proto__,__v_isRef,__isVue`),ZV=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!==`arguments`&&e!==`caller`).map(e=>Symbol[e]).filter(HB));function xie(e){HB(e)||(e=String(e));let t=mH(this);return VV(t,`has`,e),t.hasOwnProperty(e)}var QV=class{constructor(e=!1,t=!1){this._isReadonly=e,this._isShallow=t}get(e,t,n){if(t===`__v_skip`)return e.__v_skip;let r=this._isReadonly,i=this._isShallow;if(t===`__v_isReactive`)return!r;if(t===`__v_isReadonly`)return r;if(t===`__v_isShallow`)return i;if(t===`__v_raw`)return n===(r?i?jie:oH:i?aH:iH).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;let a=IB(e);if(!r){let e;if(a&&(e=vie[t]))return e;if(t===`hasOwnProperty`)return xie}let o=Reflect.get(e,t,_H(e)?e:n);if((HB(t)?ZV.has(t):bie(t))||(r||VV(e,`get`,t),i))return o;if(_H(o)){let e=a&&JB(t)?o:o.value;return r&&UB(e)?cH(e):e}return UB(o)?r?cH(o):sH(o):o}},$V=class extends QV{constructor(e=!1){super(!1,e)}set(e,t,n,r){let i=e[t],a=IB(e)&&JB(t);if(!this._isShallow){let e=dH(i);if(!fH(n)&&!dH(n)&&(i=mH(i),n=mH(n)),!a&&_H(i)&&!_H(n))return e||(i.value=n),!0}let o=a?Number(t)<e.length:FB(e,t),s=Reflect.set(e,t,n,_H(e)?e:r);return e===mH(r)&&s&&(o?tV(n,i)&&HV(e,`set`,t,n,i):HV(e,`add`,t,n)),s}deleteProperty(e,t){let n=FB(e,t),r=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&HV(e,`delete`,t,void 0,r),i}has(e,t){let n=Reflect.has(e,t);return(!HB(t)||!ZV.has(t))&&VV(e,`has`,t),n}ownKeys(e){return VV(e,`iterate`,IB(e)?`length`:RV),Reflect.ownKeys(e)}},Sie=class extends QV{constructor(e=!1){super(!0,e)}set(e,t){return!0}deleteProperty(e,t){return!0}},Cie=new $V,wie=new Sie,Tie=new $V(!0),eH=e=>e,tH=e=>Reflect.getPrototypeOf(e);function Eie(e,t,n){return function(...r){let i=this.__v_raw,a=mH(i),o=LB(a),s=e===`entries`||e===Symbol.iterator&&o,c=e===`keys`&&o,l=i[e](...r),u=n?eH:t?gH:hH;return!t&&VV(a,`iterate`,c?zV:RV),NB(Object.create(l),{next(){let{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:s?[u(e[0]),u(e[1])]:u(e),done:t}}})}}function nH(e){return function(...t){return e===`delete`?!1:e===`clear`?void 0:this}}function Die(e,t){let n={get(n){let r=this.__v_raw,i=mH(r),a=mH(n);e||(tV(n,a)&&VV(i,`get`,n),VV(i,`get`,a));let{has:o}=tH(i),s=t?eH:e?gH:hH;if(o.call(i,n))return s(r.get(n));if(o.call(i,a))return s(r.get(a));r!==i&&r.get(n)},get size(){let t=this.__v_raw;return!e&&VV(mH(t),`iterate`,RV),t.size},has(t){let n=this.__v_raw,r=mH(n),i=mH(t);return e||(tV(t,i)&&VV(r,`has`,t),VV(r,`has`,i)),t===i?n.has(t):n.has(t)||n.has(i)},forEach(n,r){let i=this,a=i.__v_raw,o=mH(a),s=t?eH:e?gH:hH;return!e&&VV(o,`iterate`,RV),a.forEach((e,t)=>n.call(r,s(e),s(t),i))}};return NB(n,e?{add:nH(`add`),set:nH(`set`),delete:nH(`delete`),clear:nH(`clear`)}:{add(e){let n=mH(this),r=tH(n),i=mH(e),a=!t&&!fH(e)&&!dH(e)?i:e;return r.has.call(n,a)||tV(e,a)&&r.has.call(n,e)||tV(i,a)&&r.has.call(n,i)||(n.add(a),HV(n,`add`,a,a)),this},set(e,n){!t&&!fH(n)&&!dH(n)&&(n=mH(n));let r=mH(this),{has:i,get:a}=tH(r),o=i.call(r,e);o||=(e=mH(e),i.call(r,e));let s=a.call(r,e);return r.set(e,n),o?tV(n,s)&&HV(r,`set`,e,n,s):HV(r,`add`,e,n),this},delete(e){let t=mH(this),{has:n,get:r}=tH(t),i=n.call(t,e);i||=(e=mH(e),n.call(t,e));let a=r?r.call(t,e):void 0,o=t.delete(e);return i&&HV(t,`delete`,e,void 0,a),o},clear(){let e=mH(this),t=e.size!==0,n=e.clear();return t&&HV(e,`clear`,void 0,void 0,void 0),n}}),[`keys`,`values`,`entries`,Symbol.iterator].forEach(r=>{n[r]=Eie(r,e,t)}),n}function rH(e,t){let n=Die(e,t);return(t,r,i)=>r===`__v_isReactive`?!e:r===`__v_isReadonly`?e:r===`__v_raw`?t:Reflect.get(FB(n,r)&&r in t?n:t,r,i)}var Oie={get:rH(!1,!1)},kie={get:rH(!1,!0)},Aie={get:rH(!0,!1)},iH=new WeakMap,aH=new WeakMap,oH=new WeakMap,jie=new WeakMap;function Mie(e){switch(e){case`Object`:case`Array`:return 1;case`Map`:case`Set`:case`WeakMap`:case`WeakSet`:return 2;default:return 0}}function sH(e){return dH(e)?e:lH(e,!1,Cie,Oie,iH)}function Nie(e){return lH(e,!1,Tie,kie,aH)}function cH(e){return lH(e,!0,wie,Aie,oH)}function lH(e,t,n,r,i){if(!UB(e)||e.__v_raw&&!(t&&e.__v_isReactive)||e.__v_skip||!Object.isExtensible(e))return e;let a=i.get(e);if(a)return a;let o=Mie(nie(e));if(o===0)return e;let s=new Proxy(e,o===2?r:n);return i.set(e,s),s}function uH(e){return dH(e)?uH(e.__v_raw):!!(e&&e.__v_isReactive)}function dH(e){return!!(e&&e.__v_isReadonly)}function fH(e){return!!(e&&e.__v_isShallow)}function pH(e){return e?!!e.__v_raw:!1}function mH(e){let t=e&&e.__v_raw;return t?mH(t):e}function Pie(e){return!FB(e,`__v_skip`)&&Object.isExtensible(e)&&rV(e,`__v_skip`,!0),e}var hH=e=>UB(e)?sH(e):e,gH=e=>UB(e)?cH(e):e;function _H(e){return e?e.__v_isRef===!0:!1}function vH(e){return bH(e,!1)}function yH(e){return bH(e,!0)}function bH(e,t){return _H(e)?e:new Fie(e,t)}var Fie=class{constructor(e,t){this.dep=new FV,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=t?e:mH(e),this._value=t?e:hH(e),this.__v_isShallow=t}get value(){return this.dep.track(),this._value}set value(e){let t=this._rawValue,n=this.__v_isShallow||fH(e)||dH(e);e=n?e:mH(e),tV(e,t)&&(this._rawValue=e,this._value=n?e:hH(e),this.dep.trigger())}};function xH(e){e.dep&&e.dep.trigger()}function J(e){return _H(e)?e.value:e}var Iie={get:(e,t,n)=>t===`__v_raw`?e:J(Reflect.get(e,t,n)),set:(e,t,n,r)=>{let i=e[t];return _H(i)&&!_H(n)?(i.value=n,!0):Reflect.set(e,t,n,r)}};function SH(e){return uH(e)?e:new Proxy(e,Iie)}var Lie=class{constructor(e,t,n){this.fn=e,this.setter=t,this._value=void 0,this.dep=new FV(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=PV-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!t,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&hV!==this)return xV(this,!0),!0}get value(){let e=this.dep.track();return DV(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}};function Rie(e,t,n=!1){let r,i;return BB(e)?r=e:(r=e.get,i=e.set),new Lie(r,i,n)}var CH={},wH=new WeakMap,TH=void 0;function zie(e,t=!1,n=TH){if(n){let t=wH.get(n);t||wH.set(n,t=[]),t.push(e)}}function EH(e,t,n=DB){let{immediate:r,deep:i,once:a,scheduler:o,augmentJob:s,call:c}=n,l=e=>i?e:fH(e)||i===!1||i===0?DH(e,1):DH(e),u,d,f,p,m=!1,h=!1;if(_H(e)?(d=()=>e.value,m=fH(e)):uH(e)?(d=()=>l(e),m=!0):IB(e)?(h=!0,m=e.some(e=>uH(e)||fH(e)),d=()=>e.map(e=>{if(_H(e))return e.value;if(uH(e))return l(e);if(BB(e))return c?c(e,2):e()})):d=BB(e)?t?c?()=>c(e,2):e:()=>{if(f){jV();try{f()}finally{MV()}}let t=TH;TH=u;try{return c?c(e,3,[p]):e(p)}finally{TH=t}}:kB,t&&i){let e=d,t=i===!0?1/0:i;d=()=>DH(e(),t)}let g=mie(),_=()=>{u.stop(),g&&g.active&&PB(g.effects,u)};if(a&&t){let e=t;t=(...t)=>{let n=e(...t);return _(),n}}let v=h?Array(e.length).fill(CH):CH,y=e=>{if(!(!(u.flags&1)||!u.dirty&&!e))if(t){let n=u.run();if(e||i||m||(h?n.some((e,t)=>tV(e,v[t])):tV(n,v))){f&&f();let e=TH;TH=u;try{let e=[n,v===CH?void 0:h&&v[0]===CH?[]:v,p];v=n,c?c(t,3,e):t(...e)}finally{TH=e}}}else u.run()};return s&&s(y),u=new _V(d),u.scheduler=o?()=>o(y,!1):y,p=e=>zie(e,!1,u),f=u.onStop=()=>{let e=wH.get(u);if(e){if(c)c(e,4);else for(let t of e)t();wH.delete(u)}},t?r?y(!0):v=u.run():o?o(y.bind(null,!0),!0):u.run(),_.pause=u.pause.bind(u),_.resume=u.resume.bind(u),_.stop=_,_}function DH(e,t=1/0,n){if(t<=0||!UB(e)||e.__v_skip||(n||=new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,_H(e))DH(e.value,t,n);else if(IB(e))for(let r=0;r<e.length;r++)DH(e[r],t,n);else if(RB(e)||LB(e))e.forEach(e=>{DH(e,t,n)});else if(qB(e)){for(let r in e)DH(e[r],t,n);for(let r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&DH(e[r],t,n)}return e}function OH(e,t,n,r){try{return r?e(...r):e()}catch(e){AH(e,t,n)}}function kH(e,t,n,r){if(BB(e)){let i=OH(e,t,n,r);return i&&WB(i)&&i.catch(e=>{AH(e,t,n)}),i}if(IB(e)){let i=[];for(let a=0;a<e.length;a++)i.push(kH(e[a],t,n,r));return i}}function AH(e,t,n,r=!0){let i=t?t.vnode:null,{errorHandler:a,throwUnhandledErrorInProduction:o}=t&&t.appContext.config||DB;if(t){let r=t.parent,i=t.proxy,o=`https://vuejs.org/error-reference/#runtime-${n}`;for(;r;){let t=r.ec;if(t){for(let n=0;n<t.length;n++)if(t[n](e,i,o)===!1)return}r=r.parent}if(a){jV(),OH(a,null,10,[e,i,o]),MV();return}}jH(e,n,i,r,o)}function jH(e,t,n,r=!0,i=!1){if(i)throw e;console.error(e)}var MH=[],NH=-1,PH=[],FH=null,IH=0,LH=Promise.resolve(),RH=null;function zH(e){let t=RH||LH;return e?t.then(this?e.bind(this):e):t}function BH(e){let t=NH+1,n=MH.length;for(;t<n;){let r=t+n>>>1,i=MH[r],a=KH(i);a<e||a===e&&i.flags&2?t=r+1:n=r}return t}function VH(e){if(!(e.flags&1)){let t=KH(e),n=MH[MH.length-1];!n||!(e.flags&2)&&t>=KH(n)?MH.push(e):MH.splice(BH(t),0,e),e.flags|=1,HH()}}function HH(){RH||=LH.then(qH)}function UH(e){IB(e)?PH.push(...e):FH&&e.id===-1?FH.splice(IH+1,0,e):e.flags&1||(PH.push(e),e.flags|=1),HH()}function WH(e,t,n=NH+1){for(;n<MH.length;n++){let t=MH[n];if(t&&t.flags&2){if(e&&t.id!==e.uid)continue;MH.splice(n,1),n--,t.flags&4&&(t.flags&=-2),t(),t.flags&4||(t.flags&=-2)}}}function GH(e){if(PH.length){let e=[...new Set(PH)].sort((e,t)=>KH(e)-KH(t));if(PH.length=0,FH){FH.push(...e);return}for(FH=e,IH=0;IH<FH.length;IH++){let e=FH[IH];e.flags&4&&(e.flags&=-2),e.flags&8||e(),e.flags&=-2}FH=null,IH=0}}var KH=e=>e.id==null?e.flags&2?-1:1/0:e.id;function qH(e){try{for(NH=0;NH<MH.length;NH++){let e=MH[NH];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),OH(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;NH<MH.length;NH++){let e=MH[NH];e&&(e.flags&=-2)}NH=-1,MH.length=0,GH(e),RH=null,(MH.length||PH.length)&&qH(e)}}var JH=null,YH=null;function XH(e){let t=JH;return JH=e,YH=e&&e.type.__scopeId||null,t}function ZH(e,t=JH,n){if(!t||e._n)return e;let r=(...n)=>{r._d&&MG(-1);let i=XH(t),a;try{a=e(...n)}finally{XH(i),r._d&&MG(1)}return a};return r._n=!0,r._c=!0,r._d=!0,r}function QH(e,t){if(JH===null)return e;let n=mK(JH),r=e.dirs||=[];for(let e=0;e<t.length;e++){let[i,a,o,s=DB]=t[e];i&&(BB(i)&&(i={mounted:i,updated:i}),i.deep&&DH(a),r.push({dir:i,instance:n,value:a,oldValue:void 0,arg:o,modifiers:s}))}return e}function $H(e,t,n,r){let i=e.dirs,a=t&&t.dirs;for(let o=0;o<i.length;o++){let s=i[o];a&&(s.oldValue=a[o].value);let c=s.dir[r];c&&(jV(),kH(c,n,8,[e.el,s,e,t]),MV())}}function eU(e,t){if(QG){let n=QG.provides,r=QG.parent&&QG.parent.provides;r===n&&(n=QG.provides=Object.create(r)),n[e]=t}}function tU(e,t,n=!1){let r=$G();if(r||PW){let i=PW?PW._context.provides:r?r.parent==null||r.ce?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides:void 0;if(i&&e in i)return i[e];if(arguments.length>1)return n&&BB(t)?t.call(r&&r.proxy):t}}var nU=Symbol.for(`v-scx`),rU=()=>tU(nU);function iU(e,t,n){return aU(e,t,n)}function aU(e,t,n=DB){let{immediate:r,deep:i,flush:a,once:o}=n,s=NB({},n),c=t&&r||!t&&a!==`post`,l;if(aK){if(a===`sync`){let e=rU();l=e.__watcherHandles||=[]}else if(!c){let e=()=>{};return e.stop=kB,e.resume=kB,e.pause=kB,e}}let u=QG;s.call=(e,t,n)=>kH(e,u,t,n);let d=!1;a===`post`?s.scheduler=e=>{dG(e,u&&u.suspense)}:a!==`sync`&&(d=!0,s.scheduler=(e,t)=>{t?e():VH(e)}),s.augmentJob=e=>{t&&(e.flags|=4),d&&(e.flags|=2,u&&(e.id=u.uid,e.i=u))};let f=EH(e,t,s);return aK&&(l?l.push(f):c&&f()),f}function oU(e,t,n){let r=this.proxy,i=VB(e)?e.includes(`.`)?sU(r,e):()=>r[e]:e.bind(r,r),a;BB(t)?a=t:(a=t.handler,n=t);let o=nK(this),s=aU(i,a.bind(r),n);return o(),s}function sU(e,t){let n=t.split(`.`);return()=>{let t=e;for(let e=0;e<n.length&&t;e++)t=t[n[e]];return t}}var cU=new WeakMap,lU=Symbol(`_vte`),uU=e=>e.__isTeleport,dU=e=>e&&(e.disabled||e.disabled===``),fU=e=>e&&(e.defer||e.defer===``),pU=e=>typeof SVGElement<`u`&&e instanceof SVGElement,mU=e=>typeof MathMLElement==`function`&&e instanceof MathMLElement,hU=(e,t)=>{let n=e&&e.to;return VB(n)?t?t(n):null:n},gU={name:`Teleport`,__isTeleport:!0,process(e,t,n,r,i,a,o,s,c,l){let{mc:u,pc:d,pbc:f,o:{insert:p,querySelector:m,createText:h,createComment:g,parentNode:_}}=l,v=dU(t.props),{dynamicChildren:y}=t,b=(e,t,n)=>{e.shapeFlag&16&&u(e.children,t,n,i,a,o,s,c)},x=(e=t)=>{let n=dU(e.props),r=e.target=hU(e.props,m),a=xU(r,e,h,p);r&&(o!==`svg`&&pU(r)?o=`svg`:o!==`mathml`&&mU(r)&&(o=`mathml`),i&&i.isCE&&(i.ce._teleportTargets||(i.ce._teleportTargets=new Set)).add(r),n||(b(e,r,a),bU(e,!1)))},S=e=>{let t=()=>{if(cU.get(e)===t){if(cU.delete(e),dU(e.props)){let t=_(e.el)||n;b(e,t,e.anchor),bU(e,!0)}x(e)}};cU.set(e,t),dG(t,a)};if(e==null){let e=t.el=h(``),i=t.anchor=h(``);if(p(e,n,r),p(i,n,r),fU(t.props)||a&&a.pendingBranch){S(t);return}v&&(b(t,n,i),bU(t,!0)),x()}else{t.el=e.el;let r=t.anchor=e.anchor,u=cU.get(e);if(u){u.flags|=8,cU.delete(e),S(t);return}t.targetStart=e.targetStart;let p=t.target=e.target,h=t.targetAnchor=e.targetAnchor,g=dU(e.props),_=g?n:p,b=g?r:h;if(o===`svg`||pU(p)?o=`svg`:(o===`mathml`||mU(p))&&(o=`mathml`),y?(f(e.dynamicChildren,y,_,i,a,o,s),_G(e,t,!0)):c||d(e,t,_,b,i,a,o,s,!1),v)g?t.props&&e.props&&t.props.to!==e.props.to&&(t.props.to=e.props.to):_U(t,n,r,l,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){let e=hU(t.props,m);e&&(t.target=e,_U(t,e,null,l,0))}else g&&_U(t,p,h,l,1);bU(t,v)}},remove(e,t,n,{um:r,o:{remove:i}},a){let{shapeFlag:o,children:s,anchor:c,targetStart:l,targetAnchor:u,target:d,props:f}=e,p=dU(f),m=a||!p,h=cU.get(e);if(h&&(h.flags|=8,cU.delete(e)),d&&(i(l),i(u)),a&&i(c),!h&&(p||d)&&o&16)for(let e=0;e<s.length;e++){let i=s[e];r(i,t,n,m,!!i.dynamicChildren)}},move:_U,hydrate:vU};function _U(e,t,n,{o:{insert:r},m:i},a=2){a===0&&r(e.targetAnchor,t,n);let{el:o,anchor:s,shapeFlag:c,children:l,props:u}=e,d=a===2;if(d&&r(o,t,n),!cU.has(e)&&(!d||dU(u))&&c&16)for(let e=0;e<l.length;e++)i(l[e],t,n,2);d&&r(s,t,n)}function vU(e,t,n,r,i,a,{o:{nextSibling:o,parentNode:s,querySelector:c,insert:l,createText:u}},d){function f(e,n){let r=n;for(;r;){if(r&&r.nodeType===8){if(r.data===`teleport start anchor`)t.targetStart=r;else if(r.data===`teleport anchor`){t.targetAnchor=r,e._lpa=t.targetAnchor&&o(t.targetAnchor);break}}r=o(r)}}function p(e,t){t.anchor=d(o(e),t,s(e),n,r,i,a)}let m=t.target=hU(t.props,c),h=dU(t.props);if(m){let c=m._lpa||m.firstChild;t.shapeFlag&16&&(h?(p(e,t),f(m,c),t.targetAnchor||xU(m,t,u,l,s(e)===m?e:null)):(t.anchor=o(e),f(m,c),t.targetAnchor||xU(m,t,u,l),d(c&&o(c),t,m,n,r,i,a))),bU(t,h)}else h&&t.shapeFlag&16&&(p(e,t),t.targetStart=e,t.targetAnchor=o(e));return t.anchor&&o(t.anchor)}var yU=gU;function bU(e,t){let n=e.ctx;if(n&&n.ut){let r,i;for(t?(r=e.el,i=e.anchor):(r=e.targetStart,i=e.targetAnchor);r&&r!==i;)r.nodeType===1&&r.setAttribute(`data-v-owner`,n.uid),r=r.nextSibling;n.ut()}}function xU(e,t,n,r,i=null){let a=t.targetStart=n(``),o=t.targetAnchor=n(``);return a[lU]=o,e&&(r(a,e,i),r(o,e,i)),o}var SU=Symbol(`_leaveCb`),CU=Symbol(`_enterCb`);function wU(){let e={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return QU(()=>{e.isMounted=!0}),tW(()=>{e.isUnmounting=!0}),e}var TU=[Function,Array],EU={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:TU,onEnter:TU,onAfterEnter:TU,onEnterCancelled:TU,onBeforeLeave:TU,onLeave:TU,onAfterLeave:TU,onLeaveCancelled:TU,onBeforeAppear:TU,onAppear:TU,onAfterAppear:TU,onAppearCancelled:TU},DU=e=>{let t=e.subTree;return t.component?DU(t.component):t},OU={name:`BaseTransition`,props:EU,setup(e,{slots:t}){let n=$G(),r=wU();return()=>{let i=t.default&&IU(t.default(),!0),a=i&&i.length?kU(i):n.subTree?Q():void 0;if(!a)return;let o=mH(e),{mode:s}=o;if(r.isLeaving)return NU(a);let c=PU(a);if(!c)return NU(a);let l=MU(c,o,r,n,e=>l=e);c.type!==EG&&FU(c,l);let u=n.subTree&&PU(n.subTree);if(u&&u.type!==EG&&!IG(u,c)&&DU(n).type!==EG){let e=MU(u,o,r,n);if(FU(u,e),s===`out-in`&&c.type!==EG)return r.isLeaving=!0,e.afterLeave=()=>{r.isLeaving=!1,n.job.flags&8||n.update(),delete e.afterLeave,u=void 0},NU(a);s===`in-out`&&c.type!==EG?e.delayLeave=(e,t,n)=>{let i=jU(r,u);i[String(u.key)]=u,e[SU]=()=>{t(),e[SU]=void 0,delete l.delayedLeave,u=void 0},l.delayedLeave=()=>{n(),delete l.delayedLeave,u=void 0}}:u=void 0}else u&&=void 0;return a}}};function kU(e){let t=e[0];if(e.length>1){for(let n of e)if(n.type!==EG){t=n;break}}return t}var AU=OU;function jU(e,t){let{leavingVNodes:n}=e,r=n.get(t.type);return r||(r=Object.create(null),n.set(t.type,r)),r}function MU(e,t,n,r,i){let{appear:a,mode:o,persisted:s=!1,onBeforeEnter:c,onEnter:l,onAfterEnter:u,onEnterCancelled:d,onBeforeLeave:f,onLeave:p,onAfterLeave:m,onLeaveCancelled:h,onBeforeAppear:g,onAppear:_,onAfterAppear:v,onAppearCancelled:y}=t,b=String(e.key),x=jU(n,e),S=(e,t)=>{e&&kH(e,r,9,t)},C=(e,t)=>{let n=t[1];S(e,t),IB(e)?e.every(e=>e.length<=1)&&n():e.length<=1&&n()},w={mode:o,persisted:s,beforeEnter(t){let r=c;if(!n.isMounted)if(a)r=g||c;else return;t[SU]&&t[SU](!0);let i=x[b];i&&IG(e,i)&&i.el[SU]&&i.el[SU](),S(r,[t])},enter(t){if(x[b]===e)return;let r=l,i=u,o=d;if(!n.isMounted)if(a)r=_||l,i=v||u,o=y||d;else return;let s=!1;t[CU]=e=>{s||(s=!0,S(e?o:i,[t]),w.delayedLeave&&w.delayedLeave(),t[CU]=void 0)};let c=t[CU].bind(null,!1);r?C(r,[t,c]):c()},leave(t,r){let i=String(e.key);if(t[CU]&&t[CU](!0),n.isUnmounting)return r();S(f,[t]);let a=!1;t[SU]=n=>{a||(a=!0,r(),S(n?h:m,[t]),t[SU]=void 0,x[i]===e&&delete x[i])};let o=t[SU].bind(null,!1);x[i]=e,p?C(p,[t,o]):o()},clone(e){let a=MU(e,t,n,r,i);return i&&i(a),a}};return w}function NU(e){if(WU(e))return e=HG(e),e.children=null,e}function PU(e){if(!WU(e))return uU(e.type)&&e.children?kU(e.children):e;if(e.component)return e.component.subTree;let{shapeFlag:t,children:n}=e;if(n){if(t&16)return n[0];if(t&32&&BB(n.default))return n.default()}}function FU(e,t){e.shapeFlag&6&&e.component?(e.transition=t,FU(e.component.subTree,t)):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function IU(e,t=!1,n){let r=[],i=0;for(let a=0;a<e.length;a++){let o=e[a],s=n==null?o.key:String(n)+String(o.key==null?a:o.key);o.type===wG?(o.patchFlag&128&&i++,r=r.concat(IU(o.children,t,s))):(t||o.type!==EG)&&r.push(s==null?o:HG(o,{key:s}))}if(i>1)for(let e=0;e<r.length;e++)r[e].patchFlag=-2;return r}function LU(e,t){return BB(e)?NB({name:e.name},t,{setup:e}):e}function RU(e){e.ids=[e.ids[0]+e.ids[2]+++`-`,0,0]}function zU(e,t){let n;return!!((n=Object.getOwnPropertyDescriptor(e,t))&&!n.configurable)}var BU=new WeakMap;function VU(e,t,n,r,i=!1){if(IB(e)){e.forEach((e,a)=>VU(e,t&&(IB(t)?t[a]:t),n,r,i));return}if(UU(r)&&!i){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&VU(e,t,n,r.component.subTree);return}let a=r.shapeFlag&4?mK(r.component):r.el,o=i?null:a,{i:s,r:c}=e,l=t&&t.r,u=s.refs===DB?s.refs={}:s.refs,d=s.setupState,f=mH(d),p=d===DB?AB:e=>!zU(u,e)&&FB(f,e),m=(e,t)=>!(t&&zU(u,t));if(l!=null&&l!==c){if(HU(t),VB(l))u[l]=null,p(l)&&(d[l]=null);else if(_H(l)){let e=t;m(l,e.k)&&(l.value=null),e.k&&(u[e.k]=null)}}if(BB(c)){jV();try{OH(c,s,12,[o,u])}finally{MV()}}else{let t=VB(c),r=_H(c);if(t||r){let s=()=>{if(e.f){let n=t?p(c)?d[c]:u[c]:m(c)||!e.k?c.value:u[e.k];if(i)IB(n)&&PB(n,a);else if(IB(n))n.includes(a)||n.push(a);else if(t)u[c]=[a],p(c)&&(d[c]=u[c]);else{let t=[a];m(c,e.k)&&(c.value=t),e.k&&(u[e.k]=t)}}else t?(u[c]=o,p(c)&&(d[c]=o)):r&&(m(c,e.k)&&(c.value=o),e.k&&(u[e.k]=o))};if(o){let t=()=>{s(),BU.delete(e)};t.id=-1,BU.set(e,t),dG(t,n)}else HU(e),s()}}}function HU(e){let t=BU.get(e);t&&(t.flags|=8,BU.delete(e))}aV().requestIdleCallback,aV().cancelIdleCallback;var UU=e=>!!e.type.__asyncLoader,WU=e=>e.type.__isKeepAlive;function GU(e,t){qU(e,`a`,t)}function KU(e,t){qU(e,`da`,t)}function qU(e,t,n=QG){let r=e.__wdc||=()=>{let t=n;for(;t;){if(t.isDeactivated)return;t=t.parent}return e()};if(YU(t,r,n),n){let e=n.parent;for(;e&&e.parent;)WU(e.parent.vnode)&&JU(r,t,n,e),e=e.parent}}function JU(e,t,n,r){let i=YU(t,e,r,!0);nW(()=>{PB(r[t],i)},n)}function YU(e,t,n=QG,r=!1){if(n){let i=n[e]||(n[e]=[]),a=t.__weh||=(...r)=>{jV();let i=nK(n),a=kH(t,n,e,r);return i(),MV(),a};return r?i.unshift(a):i.push(a),a}}var XU=e=>(t,n=QG)=>{(!aK||e===`sp`)&&YU(e,(...e)=>t(...e),n)},ZU=XU(`bm`),QU=XU(`m`),$U=XU(`bu`),eW=XU(`u`),tW=XU(`bum`),nW=XU(`um`),rW=XU(`sp`),iW=XU(`rtg`),aW=XU(`rtc`);function oW(e,t=QG){YU(`ec`,e,t)}var sW=Symbol.for(`v-ndc`);function cW(e,t,n,r){let i,a=n&&n[r],o=IB(e);if(o||VB(e)){let n=o&&uH(e),r=!1,s=!1;n&&(r=!fH(e),s=dH(e),e=WV(e)),i=Array(e.length);for(let n=0,o=e.length;n<o;n++)i[n]=t(r?s?gH(hH(e[n])):hH(e[n]):e[n],n,void 0,a&&a[n])}else if(typeof e==`number`){i=Array(e);for(let n=0;n<e;n++)i[n]=t(n+1,n,void 0,a&&a[n])}else if(UB(e))if(e[Symbol.iterator])i=Array.from(e,(e,n)=>t(e,n,void 0,a&&a[n]));else{let n=Object.keys(e);i=Array(n.length);for(let r=0,o=n.length;r<o;r++){let o=n[r];i[r]=t(e[o],o,r,a&&a[r])}}else i=[];return n&&(n[r]=i),i}function lW(e,t,n={},r,i){if(JH.ce||JH.parent&&UU(JH.parent)&&JH.parent.ce){let e=Object.keys(n).length>0;return t!=="default"&&(n.name=t),Y(),PG(wG,null,[zG(`slot`,n,r&&r())],e?-2:64)}let a=e[t];a&&a._c&&(a._d=!1),Y();let o=a&&uW(a(n)),s=n.key||o&&o.key,c=PG(wG,{key:(s&&!HB(s)?s:`_${t}`)+(!o&&r?`_fb`:``)},o||(r?r():[]),o&&e._===1?64:-2);return!i&&c.scopeId&&(c.slotScopeIds=[c.scopeId+`-s`]),a&&a._c&&(a._d=!0),c}function uW(e){return e.some(e=>!FG(e)||!(e.type===EG||e.type===wG&&!uW(e.children)))?e:null}var dW=e=>e?iK(e)?mK(e):dW(e.parent):null,fW=NB(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>dW(e.parent),$root:e=>dW(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>xW(e),$forceUpdate:e=>e.f||=()=>{VH(e.update)},$nextTick:e=>e.n||=zH.bind(e.proxy),$watch:e=>oU.bind(e)}),pW=(e,t)=>e!==DB&&!e.__isScriptSetup&&FB(e,t),mW={get({_:e},t){if(t===`__v_skip`)return!0;let{ctx:n,setupState:r,data:i,props:a,accessCache:o,type:s,appContext:c}=e;if(t[0]!==`$`){let e=o[t];if(e!==void 0)switch(e){case 1:return r[t];case 2:return i[t];case 4:return n[t];case 3:return a[t]}else if(pW(r,t))return o[t]=1,r[t];else if(i!==DB&&FB(i,t))return o[t]=2,i[t];else if(FB(a,t))return o[t]=3,a[t];else if(n!==DB&&FB(n,t))return o[t]=4,n[t];else gW&&(o[t]=0)}let l=fW[t],u,d;if(l)return t===`$attrs`&&VV(e.attrs,`get`,``),l(e);if((u=s.__cssModules)&&(u=u[t]))return u;if(n!==DB&&FB(n,t))return o[t]=4,n[t];if(d=c.config.globalProperties,FB(d,t))return d[t]},set({_:e},t,n){let{data:r,setupState:i,ctx:a}=e;return pW(i,t)?(i[t]=n,!0):r!==DB&&FB(r,t)?(r[t]=n,!0):FB(e.props,t)||t[0]===`$`&&t.slice(1)in e?!1:(a[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:r,appContext:i,props:a,type:o}},s){let c;return!!(n[s]||e!==DB&&s[0]!==`$`&&FB(e,s)||pW(t,s)||FB(a,s)||FB(r,s)||FB(fW,s)||FB(i.config.globalProperties,s)||(c=o.__cssModules)&&c[s])},defineProperty(e,t,n){return n.get==null?FB(n,`value`)&&this.set(e,t,n.value,null):e._.accessCache[t]=0,Reflect.defineProperty(e,t,n)}};function hW(e){return IB(e)?e.reduce((e,t)=>(e[t]=null,e),{}):e}var gW=!0;function _W(e){let t=xW(e),n=e.proxy,r=e.ctx;gW=!1,t.beforeCreate&&yW(t.beforeCreate,e,`bc`);let{data:i,computed:a,methods:o,watch:s,provide:c,inject:l,created:u,beforeMount:d,mounted:f,beforeUpdate:p,updated:m,activated:h,deactivated:g,beforeDestroy:_,beforeUnmount:v,destroyed:y,unmounted:b,render:x,renderTracked:S,renderTriggered:C,errorCaptured:w,serverPrefetch:T,expose:ee,inheritAttrs:E,components:te,directives:ne,filters:D}=t;if(l&&vW(l,r,null),o)for(let e in o){let t=o[e];BB(t)&&(r[e]=t.bind(n))}if(i){let t=i.call(n,n);UB(t)&&(e.data=sH(t))}if(gW=!0,a)for(let e in a){let t=a[e],i=gK({get:BB(t)?t.bind(n,n):BB(t.get)?t.get.bind(n,n):kB,set:!BB(t)&&BB(t.set)?t.set.bind(n):kB});Object.defineProperty(r,e,{enumerable:!0,configurable:!0,get:()=>i.value,set:e=>i.value=e})}if(s)for(let e in s)bW(s[e],r,n,e);if(c){let e=BB(c)?c.call(n):c;Reflect.ownKeys(e).forEach(t=>{eU(t,e[t])})}u&&yW(u,e,`c`);function re(e,t){IB(t)?t.forEach(t=>e(t.bind(n))):t&&e(t.bind(n))}if(re(ZU,d),re(QU,f),re($U,p),re(eW,m),re(GU,h),re(KU,g),re(oW,w),re(aW,S),re(iW,C),re(tW,v),re(nW,b),re(rW,T),IB(ee))if(ee.length){let t=e.exposed||={};ee.forEach(e=>{Object.defineProperty(t,e,{get:()=>n[e],set:t=>n[e]=t,enumerable:!0})})}else e.exposed||={};x&&e.render===kB&&(e.render=x),E!=null&&(e.inheritAttrs=E),te&&(e.components=te),ne&&(e.directives=ne),T&&RU(e)}function vW(e,t,n=kB){IB(e)&&(e=EW(e));for(let n in e){let r=e[n],i;i=UB(r)?`default`in r?tU(r.from||n,r.default,!0):tU(r.from||n):tU(r),_H(i)?Object.defineProperty(t,n,{enumerable:!0,configurable:!0,get:()=>i.value,set:e=>i.value=e}):t[n]=i}}function yW(e,t,n){kH(IB(e)?e.map(e=>e.bind(t.proxy)):e.bind(t.proxy),t,n)}function bW(e,t,n,r){let i=r.includes(`.`)?sU(n,r):()=>n[r];if(VB(e)){let n=t[e];BB(n)&&iU(i,n)}else if(BB(e))iU(i,e.bind(n));else if(UB(e))if(IB(e))e.forEach(e=>bW(e,t,n,r));else{let r=BB(e.handler)?e.handler.bind(n):t[e.handler];BB(r)&&iU(i,r,e)}}function xW(e){let t=e.type,{mixins:n,extends:r}=t,{mixins:i,optionsCache:a,config:{optionMergeStrategies:o}}=e.appContext,s=a.get(t),c;return s?c=s:!i.length&&!n&&!r?c=t:(c={},i.length&&i.forEach(e=>SW(c,e,o,!0)),SW(c,t,o)),UB(t)&&a.set(t,c),c}function SW(e,t,n,r=!1){let{mixins:i,extends:a}=t;a&&SW(e,a,n,!0),i&&i.forEach(t=>SW(e,t,n,!0));for(let i in t)if(!(r&&i===`expose`)){let r=CW[i]||n&&n[i];e[i]=r?r(e[i],t[i]):t[i]}return e}var CW={data:wW,props:kW,emits:kW,methods:OW,computed:OW,beforeCreate:DW,created:DW,beforeMount:DW,mounted:DW,beforeUpdate:DW,updated:DW,beforeDestroy:DW,beforeUnmount:DW,destroyed:DW,unmounted:DW,activated:DW,deactivated:DW,errorCaptured:DW,serverPrefetch:DW,components:OW,directives:OW,watch:AW,provide:wW,inject:TW};function wW(e,t){return t?e?function(){return NB(BB(e)?e.call(this,this):e,BB(t)?t.call(this,this):t)}:t:e}function TW(e,t){return OW(EW(e),EW(t))}function EW(e){if(IB(e)){let t={};for(let n=0;n<e.length;n++)t[e[n]]=e[n];return t}return e}function DW(e,t){return e?[...new Set([].concat(e,t))]:t}function OW(e,t){return e?NB(Object.create(null),e,t):t}function kW(e,t){return e?IB(e)&&IB(t)?[...new Set([...e,...t])]:NB(Object.create(null),hW(e),hW(t??{})):t}function AW(e,t){if(!e)return t;if(!t)return e;let n=NB(Object.create(null),e);for(let r in t)n[r]=DW(e[r],t[r]);return n}function jW(){return{app:null,config:{isNativeTag:AB,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}var MW=0;function NW(e,t){return function(n,r=null){BB(n)||(n=NB({},n)),r!=null&&!UB(r)&&(r=null);let i=jW(),a=new WeakSet,o=[],s=!1,c=i.app={_uid:MW++,_component:n,_props:r,_container:null,_context:i,_instance:null,version:vK,get config(){return i.config},set config(e){},use(e,...t){return a.has(e)||(e&&BB(e.install)?(a.add(e),e.install(c,...t)):BB(e)&&(a.add(e),e(c,...t))),c},mixin(e){return i.mixins.includes(e)||i.mixins.push(e),c},component(e,t){return t?(i.components[e]=t,c):i.components[e]},directive(e,t){return t?(i.directives[e]=t,c):i.directives[e]},mount(a,o,l){if(!s){let u=c._ceVNode||zG(n,r);return u.appContext=i,l===!0?l=`svg`:l===!1&&(l=void 0),o&&t?t(u,a):e(u,a,l),s=!0,c._container=a,a.__vue_app__=c,mK(u.component)}},onUnmount(e){o.push(e)},unmount(){s&&(kH(o,c._instance,16),e(null,c._container),delete c._container.__vue_app__)},provide(e,t){return i.provides[e]=t,c},runWithContext(e){let t=PW;PW=c;try{return e()}finally{PW=t}}};return c}}var PW=null,FW=(e,t)=>t===`modelValue`||t===`model-value`?e.modelModifiers:e[`${t}Modifiers`]||e[`${ZB(t)}Modifiers`]||e[`${QB(t)}Modifiers`];function IW(e,t,...n){if(e.isUnmounted)return;let r=e.vnode.props||DB,i=n,a=t.startsWith(`update:`),o=a&&FW(r,t.slice(7));o&&(o.trim&&(i=n.map(e=>VB(e)?e.trim():e)),o.number&&(i=n.map(iV)));let s,c=r[s=eV(t)]||r[s=eV(ZB(t))];!c&&a&&(c=r[s=eV(QB(t))]),c&&kH(c,e,6,i);let l=r[s+`Once`];if(l){if(!e.emitted)e.emitted={};else if(e.emitted[s])return;e.emitted[s]=!0,kH(l,e,6,i)}}var LW=new WeakMap;function RW(e,t,n=!1){let r=n?LW:t.emitsCache,i=r.get(e);if(i!==void 0)return i;let a=e.emits,o={},s=!1;if(!BB(e)){let r=e=>{let n=RW(e,t,!0);n&&(s=!0,NB(o,n))};!n&&t.mixins.length&&t.mixins.forEach(r),e.extends&&r(e.extends),e.mixins&&e.mixins.forEach(r)}return!a&&!s?(UB(e)&&r.set(e,null),null):(IB(a)?a.forEach(e=>o[e]=null):NB(o,a),UB(e)&&r.set(e,o),o)}function zW(e,t){return!e||!jB(t)?!1:(t=t.slice(2),t=t===`Once`?t:t.replace(/Once$/,``),FB(e,t[0].toLowerCase()+t.slice(1))||FB(e,QB(t))||FB(e,t))}function BW(e){let{type:t,vnode:n,proxy:r,withProxy:i,propsOptions:[a],slots:o,attrs:s,emit:c,render:l,renderCache:u,props:d,data:f,setupState:p,ctx:m,inheritAttrs:h}=e,g=XH(e),_,v;try{if(n.shapeFlag&4){let e=i||r,t=e;_=WG(l.call(t,e,u,d,p,f,m)),v=s}else{let e=t;_=WG(e.length>1?e(d,{attrs:s,slots:o,emit:c}):e(d,null)),v=t.props?s:VW(s)}}catch(t){OG.length=0,AH(t,e,1),_=zG(EG)}let y=_;if(v&&h!==!1){let e=Object.keys(v),{shapeFlag:t}=y;e.length&&t&7&&(a&&e.some(MB)&&(v=HW(v,a)),y=HG(y,v,!1,!0))}return n.dirs&&(y=HG(y,null,!1,!0),y.dirs=y.dirs?y.dirs.concat(n.dirs):n.dirs),n.transition&&FU(y,n.transition),_=y,XH(g),_}var VW=e=>{let t;for(let n in e)(n===`class`||n===`style`||jB(n))&&((t||={})[n]=e[n]);return t},HW=(e,t)=>{let n={};for(let r in e)(!MB(r)||!(r.slice(9)in t))&&(n[r]=e[r]);return n};function UW(e,t,n){let{props:r,children:i,component:a}=e,{props:o,children:s,patchFlag:c}=t,l=a.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&c>=0){if(c&1024)return!0;if(c&16)return r?WW(r,o,l):!!o;if(c&8){let e=t.dynamicProps;for(let t=0;t<e.length;t++){let n=e[t];if(GW(o,r,n)&&!zW(l,n))return!0}}}else return(i||s)&&(!s||!s.$stable)?!0:r===o?!1:r?!o||WW(r,o,l):!!o;return!1}function WW(e,t,n){let r=Object.keys(t);if(r.length!==Object.keys(e).length)return!0;for(let i=0;i<r.length;i++){let a=r[i];if(GW(t,e,a)&&!zW(n,a))return!0}return!1}function GW(e,t,n){let r=e[n],i=t[n];return n===`style`&&UB(r)&&UB(i)?!uV(r,i):r!==i}function KW({vnode:e,parent:t,suspense:n},r){for(;t;){let n=t.subTree;if(n.suspense&&n.suspense.activeBranch===e&&(n.suspense.vnode.el=n.el=r,e=n),n===e)(e=t.vnode).el=r,t=t.parent;else break}n&&n.activeBranch===e&&(n.vnode.el=r)}var qW={},JW=()=>Object.create(qW),YW=e=>Object.getPrototypeOf(e)===qW;function XW(e,t,n,r=!1){let i={},a=JW();e.propsDefaults=Object.create(null),QW(e,t,i,a);for(let t in e.propsOptions[0])t in i||(i[t]=void 0);n?e.props=r?i:Nie(i):e.type.props?e.props=i:e.props=a,e.attrs=a}function ZW(e,t,n,r){let{props:i,attrs:a,vnode:{patchFlag:o}}=e,s=mH(i),[c]=e.propsOptions,l=!1;if((r||o>0)&&!(o&16)){if(o&8){let n=e.vnode.dynamicProps;for(let r=0;r<n.length;r++){let o=n[r];if(zW(e.emitsOptions,o))continue;let u=t[o];if(c)if(FB(a,o))u!==a[o]&&(a[o]=u,l=!0);else{let t=ZB(o);i[t]=$W(c,s,t,u,e,!1)}else u!==a[o]&&(a[o]=u,l=!0)}}}else{QW(e,t,i,a)&&(l=!0);let r;for(let a in s)(!t||!FB(t,a)&&((r=QB(a))===a||!FB(t,r)))&&(c?n&&(n[a]!==void 0||n[r]!==void 0)&&(i[a]=$W(c,s,a,void 0,e,!0)):delete i[a]);if(a!==s)for(let e in a)(!t||!FB(t,e))&&(delete a[e],l=!0)}l&&HV(e.attrs,`set`,``)}function QW(e,t,n,r){let[i,a]=e.propsOptions,o=!1,s;if(t)for(let c in t){if(YB(c))continue;let l=t[c],u;i&&FB(i,u=ZB(c))?!a||!a.includes(u)?n[u]=l:(s||={})[u]=l:zW(e.emitsOptions,c)||(!(c in r)||l!==r[c])&&(r[c]=l,o=!0)}if(a){let t=mH(n),r=s||DB;for(let o=0;o<a.length;o++){let s=a[o];n[s]=$W(i,t,s,r[s],e,!FB(r,s))}}return o}function $W(e,t,n,r,i,a){let o=e[n];if(o!=null){let e=FB(o,`default`);if(e&&r===void 0){let e=o.default;if(o.type!==Function&&!o.skipFactory&&BB(e)){let{propsDefaults:a}=i;if(n in a)r=a[n];else{let o=nK(i);r=a[n]=e.call(null,t),o()}}else r=e;i.ce&&i.ce._setProp(n,r)}o[0]&&(a&&!e?r=!1:o[1]&&(r===``||r===QB(n))&&(r=!0))}return r}var eG=new WeakMap;function tG(e,t,n=!1){let r=n?eG:t.propsCache,i=r.get(e);if(i)return i;let a=e.props,o={},s=[],c=!1;if(!BB(e)){let r=e=>{c=!0;let[n,r]=tG(e,t,!0);NB(o,n),r&&s.push(...r)};!n&&t.mixins.length&&t.mixins.forEach(r),e.extends&&r(e.extends),e.mixins&&e.mixins.forEach(r)}if(!a&&!c)return UB(e)&&r.set(e,OB),OB;if(IB(a))for(let e=0;e<a.length;e++){let t=ZB(a[e]);nG(t)&&(o[t]=DB)}else if(a)for(let e in a){let t=ZB(e);if(nG(t)){let n=a[e],r=o[t]=IB(n)||BB(n)?{type:n}:NB({},n),i=r.type,c=!1,l=!0;if(IB(i))for(let e=0;e<i.length;++e){let t=i[e],n=BB(t)&&t.name;if(n===`Boolean`){c=!0;break}else n===`String`&&(l=!1)}else c=BB(i)&&i.name===`Boolean`;r[0]=c,r[1]=l,(c||FB(r,`default`))&&s.push(t)}}let l=[o,s];return UB(e)&&r.set(e,l),l}function nG(e){return e[0]!==`$`&&!YB(e)}var rG=e=>e===`_`||e===`_ctx`||e===`$stable`,iG=e=>IB(e)?e.map(WG):[WG(e)],aG=(e,t,n)=>{if(t._n)return t;let r=ZH((...e)=>iG(t(...e)),n);return r._c=!1,r},oG=(e,t,n)=>{let r=e._ctx;for(let n in e){if(rG(n))continue;let i=e[n];if(BB(i))t[n]=aG(n,i,r);else if(i!=null){let e=iG(i);t[n]=()=>e}}},sG=(e,t)=>{let n=iG(t);e.slots.default=()=>n},cG=(e,t,n)=>{for(let r in t)(n||!rG(r))&&(e[r]=t[r])},lG=(e,t,n)=>{let r=e.slots=JW();if(e.vnode.shapeFlag&32){let e=t._;e?(cG(r,t,n),n&&rV(r,`_`,e,!0)):oG(t,r)}else t&&sG(e,t)},uG=(e,t,n)=>{let{vnode:r,slots:i}=e,a=!0,o=DB;if(r.shapeFlag&32){let e=t._;e?n&&e===1?a=!1:cG(i,t,n):(a=!t.$stable,oG(t,i)),o=t}else t&&(sG(e,t),o={default:1});if(a)for(let e in i)!rG(e)&&o[e]==null&&delete i[e]},dG=CG;function fG(e){return pG(e)}function pG(e,t){let n=aV();n.__VUE__=!0;let{insert:r,remove:i,patchProp:a,createElement:o,createText:s,createComment:c,setText:l,setElementText:u,parentNode:d,nextSibling:f,setScopeId:p=kB,insertStaticContent:m}=e,h=(e,t,n,r=null,i=null,a=null,o=void 0,s=null,c=!!t.dynamicChildren)=>{if(e===t)return;e&&!IG(e,t)&&(r=fe(e),A(e,i,a,!0),e=null),t.patchFlag===-2&&(c=!1,t.dynamicChildren=null);let{type:l,ref:u,shapeFlag:d}=t;switch(l){case TG:g(e,t,n,r);break;case EG:_(e,t,n,r);break;case DG:e??v(t,n,r,o);break;case wG:te(e,t,n,r,i,a,o,s,c);break;default:d&1?x(e,t,n,r,i,a,o,s,c):d&6?ne(e,t,n,r,i,a,o,s,c):(d&64||d&128)&&l.process(e,t,n,r,i,a,o,s,c,he)}u!=null&&i?VU(u,e&&e.ref,a,t||e,!t):u==null&&e&&e.ref!=null&&VU(e.ref,null,a,e,!0)},g=(e,t,n,i)=>{if(e==null)r(t.el=s(t.children),n,i);else{let n=t.el=e.el;t.children!==e.children&&l(n,t.children)}},_=(e,t,n,i)=>{e==null?r(t.el=c(t.children||``),n,i):t.el=e.el},v=(e,t,n,r)=>{[e.el,e.anchor]=m(e.children,t,n,r,e.el,e.anchor)},y=({el:e,anchor:t},n,i)=>{let a;for(;e&&e!==t;)a=f(e),r(e,n,i),e=a;r(t,n,i)},b=({el:e,anchor:t})=>{let n;for(;e&&e!==t;)n=f(e),i(e),e=n;i(t)},x=(e,t,n,r,i,a,o,s,c)=>{if(t.type===`svg`?o=`svg`:t.type===`math`&&(o=`mathml`),e==null)S(t,n,r,i,a,o,s,c);else{let n=e.el&&e.el._isVueCE?e.el:null;try{n&&n._beginPatch(),T(e,t,i,a,o,s,c)}finally{n&&n._endPatch()}}},S=(e,t,n,i,s,c,l,d)=>{let f,p,{props:m,shapeFlag:h,transition:g,dirs:_}=e;if(f=e.el=o(e.type,c,m&&m.is,m),h&8?u(f,e.children):h&16&&w(e.children,f,null,i,s,mG(e,c),l,d),_&&$H(e,null,i,`created`),C(f,e,e.scopeId,l,i),m){for(let e in m)e!==`value`&&!YB(e)&&a(f,e,null,m[e],c,i);`value`in m&&a(f,`value`,null,m.value,c),(p=m.onVnodeBeforeMount)&&JG(p,i,e)}_&&$H(e,null,i,`beforeMount`);let v=gG(s,g);v&&g.beforeEnter(f),r(f,t,n),((p=m&&m.onVnodeMounted)||v||_)&&dG(()=>{try{p&&JG(p,i,e),v&&g.enter(f),_&&$H(e,null,i,`mounted`)}finally{}},s)},C=(e,t,n,r,i)=>{if(n&&p(e,n),r)for(let t=0;t<r.length;t++)p(e,r[t]);if(i){let n=i.subTree;if(t===n||SG(n.type)&&(n.ssContent===t||n.ssFallback===t)){let t=i.vnode;C(e,t,t.scopeId,t.slotScopeIds,i.parent)}}},w=(e,t,n,r,i,a,o,s,c=0)=>{for(let l=c;l<e.length;l++){let c=e[l]=s?GG(e[l]):WG(e[l]);h(null,c,t,n,r,i,a,o,s)}},T=(e,t,n,r,i,o,s)=>{let c=t.el=e.el,{patchFlag:l,dynamicChildren:d,dirs:f}=t;l|=e.patchFlag&16;let p=e.props||DB,m=t.props||DB,h;if(n&&hG(n,!1),(h=m.onVnodeBeforeUpdate)&&JG(h,n,t,e),f&&$H(t,e,n,`beforeUpdate`),n&&hG(n,!0),d&&(!e.dynamicChildren||e.dynamicChildren.length!==d.length)&&(l=0,s=!1,d=null),(p.innerHTML&&m.innerHTML==null||p.textContent&&m.textContent==null)&&u(c,``),d?ee(e.dynamicChildren,d,c,n,r,mG(t,i),o):s||ae(e,t,c,null,n,r,mG(t,i),o,!1),l>0){if(l&16)E(c,p,m,n,i);else if(l&2&&p.class!==m.class&&a(c,`class`,null,m.class,i),l&4&&a(c,`style`,p.style,m.style,i),l&8){let e=t.dynamicProps;for(let t=0;t<e.length;t++){let r=e[t],o=p[r],s=m[r];(s!==o||r===`value`)&&a(c,r,o,s,i,n)}}l&1&&e.children!==t.children&&u(c,t.children)}else!s&&d==null&&E(c,p,m,n,i);((h=m.onVnodeUpdated)||f)&&dG(()=>{h&&JG(h,n,t,e),f&&$H(t,e,n,`updated`)},r)},ee=(e,t,n,r,i,a,o)=>{for(let s=0;s<t.length;s++){let c=e[s],l=t[s],u=c.el&&(c.type===wG||!IG(c,l)||c.shapeFlag&198)?d(c.el):n;h(c,l,u,null,r,i,a,o,!0)}},E=(e,t,n,r,i)=>{if(t!==n){if(t!==DB)for(let o in t)!YB(o)&&!(o in n)&&a(e,o,t[o],null,i,r);for(let o in n){if(YB(o))continue;let s=n[o],c=t[o];s!==c&&o!==`value`&&a(e,o,c,s,i,r)}`value`in n&&a(e,`value`,t.value,n.value,i)}},te=(e,t,n,i,a,o,c,l,u)=>{let d=t.el=e?e.el:s(``),f=t.anchor=e?e.anchor:s(``),{patchFlag:p,dynamicChildren:m,slotScopeIds:h}=t;h&&(l=l?l.concat(h):h),e==null?(r(d,n,i),r(f,n,i),w(t.children||[],n,f,a,o,c,l,u)):p>0&&p&64&&m&&e.dynamicChildren&&e.dynamicChildren.length===m.length?(ee(e.dynamicChildren,m,n,a,o,c,l),(t.key!=null||a&&t===a.subTree)&&_G(e,t,!0)):ae(e,t,n,f,a,o,c,l,u)},ne=(e,t,n,r,i,a,o,s,c)=>{t.slotScopeIds=s,e==null?t.shapeFlag&512?i.ctx.activate(t,n,r,o,c):D(t,n,r,i,a,o,c):re(e,t,c)},D=(e,t,n,r,i,a,o)=>{let s=e.component=ZG(e,r,i);if(WU(e)&&(s.ctx.renderer=he),oK(s,!1,o),s.asyncDep){if(i&&i.registerDep(s,O,o),!e.el){let r=s.subTree=zG(EG);_(null,r,t,n),e.placeholder=r.el}}else O(s,e,t,n,i,a,o)},re=(e,t,n)=>{let r=t.component=e.component;if(UW(e,t,n))if(r.asyncDep&&!r.asyncResolved){ie(r,t,n);return}else r.next=t,r.update();else t.el=e.el,r.vnode=t},O=(e,t,n,r,i,a,o)=>{let s=()=>{if(e.isMounted){let{next:t,bu:n,u:r,parent:s,vnode:c}=e;{let n=yG(e);if(n){t&&(t.el=c.el,ie(e,t,o)),n.asyncDep.then(()=>{dG(()=>{e.isUnmounted||l()},i)});return}}let u=t,f;hG(e,!1),t?(t.el=c.el,ie(e,t,o)):t=c,n&&nV(n),(f=t.props&&t.props.onVnodeBeforeUpdate)&&JG(f,s,t,c),hG(e,!0);let p=BW(e),m=e.subTree;e.subTree=p,h(m,p,d(m.el),fe(m),e,i,a),t.el=p.el,u===null&&KW(e,p.el),r&&dG(r,i),(f=t.props&&t.props.onVnodeUpdated)&&dG(()=>JG(f,s,t,c),i)}else{let o,{el:s,props:c}=t,{bm:l,m:u,parent:d,root:f,type:p}=e,m=UU(t);if(hG(e,!1),l&&nV(l),!m&&(o=c&&c.onVnodeBeforeMount)&&JG(o,d,t),hG(e,!0),s&&_e){let t=()=>{e.subTree=BW(e),_e(s,e.subTree,e,i,null)};m&&p.__asyncHydrate?p.__asyncHydrate(s,e,t):t()}else{f.ce&&f.ce._hasShadowRoot()&&f.ce._injectChildStyle(p,e.parent?e.parent.type:void 0);let o=e.subTree=BW(e);h(null,o,n,r,e,i,a),t.el=o.el}if(u&&dG(u,i),!m&&(o=c&&c.onVnodeMounted)){let e=t;dG(()=>JG(o,d,e),i)}(t.shapeFlag&256||d&&UU(d.vnode)&&d.vnode.shapeFlag&256)&&e.a&&dG(e.a,i),e.isMounted=!0,t=n=r=null}};e.scope.on();let c=e.effect=new _V(s);e.scope.off();let l=e.update=c.run.bind(c),u=e.job=c.runIfDirty.bind(c);u.i=e,u.id=e.uid,c.scheduler=()=>VH(u),hG(e,!0),l()},ie=(e,t,n)=>{t.component=e;let r=e.vnode.props;e.vnode=t,e.next=null,ZW(e,t.props,r,n),uG(e,t.children,n),jV(),WH(e),MV()},ae=(e,t,n,r,i,a,o,s,c=!1)=>{let l=e&&e.children,d=e?e.shapeFlag:0,f=t.children,{patchFlag:p,shapeFlag:m}=t;if(p>0){if(p&128){k(l,f,n,r,i,a,o,s,c);return}else if(p&256){oe(l,f,n,r,i,a,o,s,c);return}}m&8?(d&16&&de(l,i,a),f!==l&&u(n,f)):d&16?m&16?k(l,f,n,r,i,a,o,s,c):de(l,i,a,!0):(d&8&&u(n,``),m&16&&w(f,n,r,i,a,o,s,c))},oe=(e,t,n,r,i,a,o,s,c)=>{e||=OB,t||=OB;let l=e.length,u=t.length,d=Math.min(l,u),f;for(f=0;f<d;f++){let r=t[f]=c?GG(t[f]):WG(t[f]);h(e[f],r,n,null,i,a,o,s,c)}l>u?de(e,i,a,!0,!1,d):w(t,n,r,i,a,o,s,c,d)},k=(e,t,n,r,i,a,o,s,c)=>{let l=0,u=t.length,d=e.length-1,f=u-1;for(;l<=d&&l<=f;){let r=e[l],u=t[l]=c?GG(t[l]):WG(t[l]);if(IG(r,u))h(r,u,n,null,i,a,o,s,c);else break;l++}for(;l<=d&&l<=f;){let r=e[d],l=t[f]=c?GG(t[f]):WG(t[f]);if(IG(r,l))h(r,l,n,null,i,a,o,s,c);else break;d--,f--}if(l>d){if(l<=f){let e=f+1,d=e<u?t[e].el:r;for(;l<=f;)h(null,t[l]=c?GG(t[l]):WG(t[l]),n,d,i,a,o,s,c),l++}}else if(l>f)for(;l<=d;)A(e[l],i,a,!0),l++;else{let p=l,m=l,g=new Map;for(l=m;l<=f;l++){let e=t[l]=c?GG(t[l]):WG(t[l]);e.key!=null&&g.set(e.key,l)}let _,v=0,y=f-m+1,b=!1,x=0,S=Array(y);for(l=0;l<y;l++)S[l]=0;for(l=p;l<=d;l++){let r=e[l];if(v>=y){A(r,i,a,!0);continue}let u;if(r.key!=null)u=g.get(r.key);else for(_=m;_<=f;_++)if(S[_-m]===0&&IG(r,t[_])){u=_;break}u===void 0?A(r,i,a,!0):(S[u-m]=l+1,u>=x?x=u:b=!0,h(r,t[u],n,null,i,a,o,s,c),v++)}let C=b?vG(S):OB;for(_=C.length-1,l=y-1;l>=0;l--){let e=m+l,d=t[e],f=t[e+1],p=e+1<u?f.el||xG(f):r;S[l]===0?h(null,d,n,p,i,a,o,s,c):b&&(_<0||l!==C[_]?se(d,n,p,2):_--)}}},se=(e,t,n,a,o=null)=>{let{el:s,type:c,transition:l,children:u,shapeFlag:d}=e;if(d&6){se(e.component.subTree,t,n,a);return}if(d&128){e.suspense.move(t,n,a);return}if(d&64){c.move(e,t,n,he);return}if(c===wG){r(s,t,n);for(let e=0;e<u.length;e++)se(u[e],t,n,a);r(e.anchor,t,n);return}if(c===DG){y(e,t,n);return}if(a!==2&&d&1&&l)if(a===0)l.persisted&&!s[SU]?r(s,t,n):(l.beforeEnter(s),r(s,t,n),dG(()=>l.enter(s),o));else{let{leave:a,delayLeave:o,afterLeave:c}=l,u=()=>{e.ctx.isUnmounted?i(s):r(s,t,n)},d=()=>{let e=s._isLeaving||!!s[SU];s._isLeaving&&s[SU](!0),l.persisted&&!e?u():a(s,()=>{u(),c&&c()})};o?o(s,u,d):d()}else r(s,t,n)},A=(e,t,n,r=!1,i=!1)=>{let{type:a,props:o,ref:s,children:c,dynamicChildren:l,shapeFlag:u,patchFlag:d,dirs:f,cacheIndex:p,memo:m}=e;if(d===-2&&(i=!1),s!=null&&(jV(),VU(s,null,n,e,!0),MV()),p!=null&&(t.renderCache[p]=void 0),u&256){t.ctx.deactivate(e);return}let h=u&1&&f,g=!UU(e),_;if(g&&(_=o&&o.onVnodeBeforeUnmount)&&JG(_,t,e),u&6)ue(e.component,n,r);else{if(u&128){e.suspense.unmount(n,r);return}h&&$H(e,null,t,`beforeUnmount`),u&64?e.type.remove(e,t,n,he,r):l&&!l.hasOnce&&(a!==wG||d>0&&d&64)?de(l,t,n,!1,!0):(a===wG&&d&384||!i&&u&16)&&de(c,t,n),r&&ce(e)}let v=m!=null&&p==null;(g&&(_=o&&o.onVnodeUnmounted)||h||v)&&dG(()=>{_&&JG(_,t,e),h&&$H(e,null,t,`unmounted`),v&&(e.el=null)},n)},ce=e=>{let{type:t,el:n,anchor:r,transition:a}=e;if(t===wG){le(n,r);return}if(t===DG){b(e);return}let o=()=>{i(n),a&&!a.persisted&&a.afterLeave&&a.afterLeave()};if(e.shapeFlag&1&&a&&!a.persisted){let{leave:t,delayLeave:r}=a,i=()=>t(n,o);r?r(e.el,o,i):i()}else o()},le=(e,t)=>{let n;for(;e!==t;)n=f(e),i(e),e=n;i(t)},ue=(e,t,n)=>{let{bum:r,scope:i,job:a,subTree:o,um:s,m:c,a:l}=e;bG(c),bG(l),r&&nV(r),i.stop(),a&&(a.flags|=8,A(o,e,t,n)),s&&dG(s,t),dG(()=>{e.isUnmounted=!0},t)},de=(e,t,n,r=!1,i=!1,a=0)=>{for(let o=a;o<e.length;o++)A(e[o],t,n,r,i)},fe=e=>{if(e.shapeFlag&6)return fe(e.component.subTree);if(e.shapeFlag&128)return e.suspense.next();let t=f(e.anchor||e.el),n=t&&t[lU];return n?f(n):t},pe=!1,me=(e,t,n)=>{let r;e==null?t._vnode&&(A(t._vnode,null,null,!0),r=t._vnode.component):h(t._vnode||null,e,t,null,null,null,n),t._vnode=e,pe||=(pe=!0,WH(r),GH(),!1)},he={p:h,um:A,m:se,r:ce,mt:D,mc:w,pc:ae,pbc:ee,n:fe,o:e},ge,_e;return t&&([ge,_e]=t(he)),{render:me,hydrate:ge,createApp:NW(me,ge)}}function mG({type:e,props:t},n){return n===`svg`&&e===`foreignObject`||n===`mathml`&&e===`annotation-xml`&&t&&t.encoding&&t.encoding.includes(`html`)?void 0:n}function hG({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function gG(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function _G(e,t,n=!1){let r=e.children,i=t.children;if(IB(r)&&IB(i))for(let e=0;e<r.length;e++){let t=r[e],a=i[e];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=i[e]=GG(i[e]),a.el=t.el),!n&&a.patchFlag!==-2&&_G(t,a)),a.type===TG&&(a.patchFlag===-1&&(a=i[e]=GG(a)),a.el=t.el),a.type===EG&&!a.el&&(a.el=t.el)}}function vG(e){let t=e.slice(),n=[0],r,i,a,o,s,c=e.length;for(r=0;r<c;r++){let c=e[r];if(c!==0){if(i=n[n.length-1],e[i]<c){t[r]=i,n.push(r);continue}for(a=0,o=n.length-1;a<o;)s=a+o>>1,e[n[s]]<c?a=s+1:o=s;c<e[n[a]]&&(a>0&&(t[r]=n[a-1]),n[a]=r)}}for(a=n.length,o=n[a-1];a-->0;)n[a]=o,o=t[o];return n}function yG(e){let t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:yG(t)}function bG(e){if(e)for(let t=0;t<e.length;t++)e[t].flags|=8}function xG(e){if(e.placeholder)return e.placeholder;let t=e.component;return t?xG(t.subTree):null}var SG=e=>e.__isSuspense;function CG(e,t){t&&t.pendingBranch?IB(e)?t.effects.push(...e):t.effects.push(e):UH(e)}var wG=Symbol.for(`v-fgt`),TG=Symbol.for(`v-txt`),EG=Symbol.for(`v-cmt`),DG=Symbol.for(`v-stc`),OG=[],kG=null;function Y(e=!1){OG.push(kG=e?null:[])}function AG(){OG.pop(),kG=OG[OG.length-1]||null}var jG=1;function MG(e,t=!1){jG+=e,e<0&&kG&&t&&(kG.hasOnce=!0)}function NG(e){return e.dynamicChildren=jG>0?kG||OB:null,AG(),jG>0&&kG&&kG.push(e),e}function X(e,t,n,r,i,a){return NG(Z(e,t,n,r,i,a,!0))}function PG(e,t,n,r,i){return NG(zG(e,t,n,r,i,!0))}function FG(e){return e?e.__v_isVNode===!0:!1}function IG(e,t){return e.type===t.type&&e.key===t.key}var LG=({key:e})=>e??null,RG=({ref:e,ref_key:t,ref_for:n})=>(typeof e==`number`&&(e=``+e),e==null?null:VB(e)||_H(e)||BB(e)?{i:JH,r:e,k:t,f:!!n}:e);function Z(e,t=null,n=null,r=0,i=null,a=e===wG?0:1,o=!1,s=!1){let c={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&LG(t),ref:t&&RG(t),scopeId:YH,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:a,patchFlag:r,dynamicProps:i,dynamicChildren:null,appContext:null,ctx:JH};return s?(KG(c,n),a&128&&e.normalize(c)):n&&(c.shapeFlag|=VB(n)?8:16),jG>0&&!o&&kG&&(c.patchFlag>0||a&6)&&c.patchFlag!==32&&kG.push(c),c}var zG=BG;function BG(e,t=null,n=null,r=0,i=null,a=!1){if((!e||e===sW)&&(e=EG),FG(e)){let r=HG(e,t,!0);return n&&KG(r,n),jG>0&&!a&&kG&&(r.shapeFlag&6?kG[kG.indexOf(e)]=r:kG.push(r)),r.patchFlag=-2,r}if(hK(e)&&(e=e.__vccOpts),t){t=VG(t);let{class:e,style:n}=t;e&&!VB(e)&&(t.class=sV(e)),UB(n)&&(pH(n)&&!IB(n)&&(n=NB({},n)),t.style=oV(n))}let o=VB(e)?1:SG(e)?128:uU(e)?64:UB(e)?4:BB(e)?2:0;return Z(e,t,n,r,i,o,a,!0)}function VG(e){return e?pH(e)||YW(e)?NB({},e):e:null}function HG(e,t,n=!1,r=!1){let{props:i,ref:a,patchFlag:o,children:s,transition:c}=e,l=t?qG(i||{},t):i,u={__v_isVNode:!0,__v_skip:!0,type:e.type,props:l,key:l&&LG(l),ref:t&&t.ref?n&&a?IB(a)?a.concat(RG(t)):[a,RG(t)]:RG(t):a,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:s,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==wG?o===-1?16:o|16:o,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:c,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&HG(e.ssContent),ssFallback:e.ssFallback&&HG(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return c&&r&&FU(u,c.clone(u)),u}function UG(e=` `,t=0){return zG(TG,null,e,t)}function Q(e=``,t=!1){return t?(Y(),PG(EG,null,e)):zG(EG,null,e)}function WG(e){return e==null||typeof e==`boolean`?zG(EG):IB(e)?zG(wG,null,e.slice()):FG(e)?GG(e):zG(TG,null,String(e))}function GG(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:HG(e)}function KG(e,t){let n=0,{shapeFlag:r}=e;if(t==null)t=null;else if(IB(t))n=16;else if(typeof t==`object`)if(r&65){let n=t.default;n&&(n._c&&(n._d=!1),KG(e,n()),n._c&&(n._d=!0));return}else{n=32;let r=t._;!r&&!YW(t)?t._ctx=JH:r===3&&JH&&(JH.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else if(BB(t)){if(r&65){KG(e,{default:t});return}t={default:t,_ctx:JH},n=32}else t=String(t),r&64?(n=16,t=[UG(t)]):n=8;e.children=t,e.shapeFlag|=n}function qG(...e){let t={};for(let n=0;n<e.length;n++){let r=e[n];for(let e in r)if(e===`class`)t.class!==r.class&&(t.class=sV([t.class,r.class]));else if(e===`style`)t.style=oV([t.style,r.style]);else if(jB(e)){let n=t[e],i=r[e];i&&n!==i&&!(IB(n)&&n.includes(i))?t[e]=n?[].concat(n,i):i:i==null&&n==null&&!MB(e)&&(t[e]=i)}else e!==``&&(t[e]=r[e])}return t}function JG(e,t,n,r=null){kH(e,t,7,[n,r])}var YG=jW(),XG=0;function ZG(e,t,n){let r=e.type,i=(t?t.appContext:e.appContext)||YG,a={uid:XG++,vnode:e,type:r,parent:t,appContext:i,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new pie(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:t?t.provides:Object.create(i.provides),ids:t?t.ids:[``,0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:tG(r,i),emitsOptions:RW(r,i),emit:null,emitted:null,propsDefaults:DB,inheritAttrs:r.inheritAttrs,ctx:DB,data:DB,props:DB,attrs:DB,slots:DB,refs:DB,setupState:DB,setupContext:null,suspense:n,suspenseId:n?n.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return a.ctx={_:a},a.root=t?t.root:a,a.emit=IW.bind(null,a),e.ce&&e.ce(a),a}var QG=null,$G=()=>QG||JH,eK,tK;{let e=aV(),t=(t,n)=>{let r;return(r=e[t])||(r=e[t]=[]),r.push(n),e=>{r.length>1?r.forEach(t=>t(e)):r[0](e)}};eK=t(`__VUE_INSTANCE_SETTERS__`,e=>QG=e),tK=t(`__VUE_SSR_SETTERS__`,e=>aK=e)}var nK=e=>{let t=QG;return eK(e),e.scope.on(),()=>{e.scope.off(),eK(t)}},rK=()=>{QG&&QG.scope.off(),eK(null)};function iK(e){return e.vnode.shapeFlag&4}var aK=!1;function oK(e,t=!1,n=!1){t&&tK(t);let{props:r,children:i}=e.vnode,a=iK(e);XW(e,r,a,t),lG(e,i,n||t);let o=a?sK(e,t):void 0;return t&&tK(!1),o}function sK(e,t){let n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,mW);let{setup:r}=n;if(r){jV();let n=e.setupContext=r.length>1?pK(e):null,i=nK(e),a=OH(r,e,0,[e.props,n]),o=WB(a);if(MV(),i(),(o||e.sp)&&!UU(e)&&RU(e),o){if(a.then(rK,rK),t)return a.then(n=>{cK(e,n,t)}).catch(t=>{AH(t,e,0)});e.asyncDep=a}else cK(e,a,t)}else dK(e,t)}function cK(e,t,n){BB(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:UB(t)&&(e.setupState=SH(t)),dK(e,n)}var lK,uK;function dK(e,t,n){let r=e.type;if(!e.render){if(!t&&lK&&!r.render){let t=r.template||xW(e).template;if(t){let{isCustomElement:n,compilerOptions:i}=e.appContext.config,{delimiters:a,compilerOptions:o}=r;r.render=lK(t,NB(NB({isCustomElement:n,delimiters:a},i),o))}}e.render=r.render||kB,uK&&uK(e)}{let t=nK(e);jV();try{_W(e)}finally{MV(),t()}}}var fK={get(e,t){return VV(e,`get`,``),e[t]}};function pK(e){return{attrs:new Proxy(e.attrs,fK),slots:e.slots,emit:e.emit,expose:t=>{e.exposed=t||{}}}}function mK(e){return e.exposed?e.exposeProxy||=new Proxy(SH(Pie(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in fW)return fW[n](e)},has(e,t){return t in e||t in fW}}):e.proxy}function hK(e){return BB(e)&&`__vccOpts`in e}var gK=(e,t)=>Rie(e,t,aK);function _K(e,t,n){try{MG(-1);let r=arguments.length;return r===2?UB(t)&&!IB(t)?FG(t)?zG(e,null,[t]):zG(e,t):zG(e,null,t):(r>3?n=Array.prototype.slice.call(arguments,2):r===3&&FG(n)&&(n=[n]),zG(e,t,n))}finally{MG(1)}}var vK=`3.5.39`,yK=void 0,bK=typeof window<`u`&&window.trustedTypes;if(bK)try{yK=bK.createPolicy(`vue`,{createHTML:e=>e})}catch{}var xK=yK?e=>yK.createHTML(e):e=>e,SK=`http://www.w3.org/2000/svg`,CK=`http://www.w3.org/1998/Math/MathML`,wK=typeof document<`u`?document:null,TK=wK&&wK.createElement(`template`),EK={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{let t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{let i=t===`svg`?wK.createElementNS(SK,e):t===`mathml`?wK.createElementNS(CK,e):n?wK.createElement(e,{is:n}):wK.createElement(e);return e===`select`&&r&&r.multiple!=null&&i.setAttribute(`multiple`,r.multiple),i},createText:e=>wK.createTextNode(e),createComment:e=>wK.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>wK.querySelector(e),setScopeId(e,t){e.setAttribute(t,``)},insertStaticContent(e,t,n,r,i,a){let o=n?n.previousSibling:t.lastChild;if(i&&(i===a||i.nextSibling))for(;t.insertBefore(i.cloneNode(!0),n),!(i===a||!(i=i.nextSibling)););else{TK.innerHTML=xK(r===`svg`?`<svg>${e}</svg>`:r===`mathml`?`<math>${e}</math>`:e);let i=TK.content;if(r===`svg`||r===`mathml`){let e=i.firstChild;for(;e.firstChild;)i.appendChild(e.firstChild);i.removeChild(e)}t.insertBefore(i,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},DK=`transition`,OK=`animation`,kK=Symbol(`_vtc`),AK={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},jK=NB({},EU,AK),MK=(e=>(e.displayName=`Transition`,e.props=jK,e))((e,{slots:t})=>_K(AU,FK(e),t)),NK=(e,t=[])=>{IB(e)?e.forEach(e=>e(...t)):e&&e(...t)},PK=e=>e?IB(e)?e.some(e=>e.length>1):e.length>1:!1;function FK(e){let t={};for(let n in e)n in AK||(t[n]=e[n]);if(e.css===!1)return t;let{name:n=`v`,type:r,duration:i,enterFromClass:a=`${n}-enter-from`,enterActiveClass:o=`${n}-enter-active`,enterToClass:s=`${n}-enter-to`,appearFromClass:c=a,appearActiveClass:l=o,appearToClass:u=s,leaveFromClass:d=`${n}-leave-from`,leaveActiveClass:f=`${n}-leave-active`,leaveToClass:p=`${n}-leave-to`}=e,m=IK(i),h=m&&m[0],g=m&&m[1],{onBeforeEnter:_,onEnter:v,onEnterCancelled:y,onLeave:b,onLeaveCancelled:x,onBeforeAppear:S=_,onAppear:C=v,onAppearCancelled:w=y}=t,T=(e,t,n,r)=>{e._enterCancelled=r,zK(e,t?u:s),zK(e,t?l:o),n&&n()},ee=(e,t)=>{e._isLeaving=!1,zK(e,d),zK(e,p),zK(e,f),t&&t()},E=e=>(t,n)=>{let i=e?C:v,o=()=>T(t,e,n);NK(i,[t,o]),BK(()=>{zK(t,e?c:a),RK(t,e?u:s),PK(i)||HK(t,r,h,o)})};return NB(t,{onBeforeEnter(e){NK(_,[e]),RK(e,a),RK(e,o)},onBeforeAppear(e){NK(S,[e]),RK(e,c),RK(e,l)},onEnter:E(!1),onAppear:E(!0),onLeave(e,t){e._isLeaving=!0;let n=()=>ee(e,t);RK(e,d),e._enterCancelled?(RK(e,f),KK(e)):(KK(e),RK(e,f)),BK(()=>{e._isLeaving&&(zK(e,d),RK(e,p),PK(b)||HK(e,r,g,n))}),NK(b,[e,n])},onEnterCancelled(e){T(e,!1,void 0,!0),NK(y,[e])},onAppearCancelled(e){T(e,!0,void 0,!0),NK(w,[e])},onLeaveCancelled(e){ee(e),NK(x,[e])}})}function IK(e){if(e==null)return null;if(UB(e))return[LK(e.enter),LK(e.leave)];{let t=LK(e);return[t,t]}}function LK(e){return aie(e)}function RK(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.add(t)),(e[kK]||(e[kK]=new Set)).add(t)}function zK(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.remove(t));let n=e[kK];n&&(n.delete(t),n.size||(e[kK]=void 0))}function BK(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}var VK=0;function HK(e,t,n,r){let i=e._endId=++VK,a=()=>{i===e._endId&&r()};if(n!=null)return setTimeout(a,n);let{type:o,timeout:s,propCount:c}=UK(e,t);if(!o)return r();let l=o+`end`,u=0,d=()=>{e.removeEventListener(l,f),a()},f=t=>{t.target===e&&++u>=c&&d()};setTimeout(()=>{u<c&&d()},s+1),e.addEventListener(l,f)}function UK(e,t){let n=window.getComputedStyle(e),r=e=>(n[e]||``).split(`, `),i=r(`${DK}Delay`),a=r(`${DK}Duration`),o=WK(i,a),s=r(`${OK}Delay`),c=r(`${OK}Duration`),l=WK(s,c),u=null,d=0,f=0;t===DK?o>0&&(u=DK,d=o,f=a.length):t===OK?l>0&&(u=OK,d=l,f=c.length):(d=Math.max(o,l),u=d>0?o>l?DK:OK:null,f=u?u===DK?a.length:c.length:0);let p=u===DK&&/\b(?:transform|all)(?:,|$)/.test(r(`${DK}Property`).toString());return{type:u,timeout:d,propCount:f,hasTransform:p}}function WK(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map((t,n)=>GK(t)+GK(e[n])))}function GK(e){return e===`auto`?0:Number(e.slice(0,-1).replace(`,`,`.`))*1e3}function KK(e){return(e?e.ownerDocument:document).body.offsetHeight}function qK(e,t,n){let r=e[kK];r&&(t=(t?[t,...r]:[...r]).join(` `)),t==null?e.removeAttribute(`class`):n?e.setAttribute(`class`,t):e.className=t}var JK=Symbol(`_vod`),YK=Symbol(`_vsh`),XK={name:`show`,beforeMount(e,{value:t},{transition:n}){e[JK]=e.style.display===`none`?``:e.style.display,n&&t?n.beforeEnter(e):ZK(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:r}){!t!=!n&&(r?t?(r.beforeEnter(e),ZK(e,!0),r.enter(e)):r.leave(e,()=>{ZK(e,!1)}):ZK(e,t))},beforeUnmount(e,{value:t}){ZK(e,t)}};function ZK(e,t){e.style.display=t?e[JK]:`none`,e[YK]=!t}var QK=Symbol(``),$K=/(?:^|;)\s*display\s*:/;function eq(e,t,n){let r=e.style,i=VB(n),a=!1;if(n&&!i){if(t)if(VB(t))for(let e of t.split(`;`)){let t=e.slice(0,e.indexOf(`:`)).trim();n[t]??nq(r,t,``)}else for(let e in t)n[e]??nq(r,e,``);for(let i in n){i===`display`&&(a=!0);let o=n[i];o==null?nq(r,i,``):oq(e,i,!VB(t)&&t?t[i]:void 0,o)||nq(r,i,o)}}else if(i){if(t!==n){let e=r[QK];e&&(n+=`;`+e),r.cssText=n,a=$K.test(n)}}else t&&e.removeAttribute(`style`);JK in e&&(e[JK]=a?r.display:``,e[YK]&&(r.display=`none`))}var tq=/\s*!important$/;function nq(e,t,n){if(IB(n))n.forEach(n=>nq(e,t,n));else if(n??=``,t.startsWith(`--`))e.setProperty(t,n);else{let r=aq(e,t);tq.test(n)?e.setProperty(QB(r),n.replace(tq,``),`important`):e[r]=n}}var rq=[`Webkit`,`Moz`,`ms`],iq={};function aq(e,t){let n=iq[t];if(n)return n;let r=ZB(t);if(r!==`filter`&&r in e)return iq[t]=r;r=$B(r);for(let n=0;n<rq.length;n++){let i=rq[n]+r;if(i in e)return iq[t]=i}return t}function oq(e,t,n,r){return e.tagName===`TEXTAREA`&&(t===`width`||t===`height`)&&VB(r)&&n===r}var sq=`http://www.w3.org/1999/xlink`;function cq(e,t,n,r,i,a=die(t)){r&&t.startsWith(`xlink:`)?n==null?e.removeAttributeNS(sq,t.slice(6,t.length)):e.setAttributeNS(sq,t,n):n==null||a&&!lV(n)?e.removeAttribute(t):e.setAttribute(t,a?``:HB(n)?String(n):n)}function lq(e,t,n,r,i){if(t===`innerHTML`||t===`textContent`){n!=null&&(e[t]=t===`innerHTML`?xK(n):n);return}let a=e.tagName;if(t===`value`&&a!==`PROGRESS`&&!a.includes(`-`)){let r=a===`OPTION`?e.getAttribute(`value`)||``:e.value,i=n==null?e.type===`checkbox`?`on`:``:String(n);(r!==i||!(`_value`in e))&&(e.value=i),n??e.removeAttribute(t),e._value=n;return}let o=!1;if(n===``||n==null){let r=typeof e[t];r===`boolean`?n=lV(n):n==null&&r===`string`?(n=``,o=!0):r===`number`&&(n=0,o=!0)}try{e[t]=n}catch{}o&&e.removeAttribute(i||t)}function uq(e,t,n,r){e.addEventListener(t,n,r)}function dq(e,t,n,r){e.removeEventListener(t,n,r)}var fq=Symbol(`_vei`);function pq(e,t,n,r,i=null){let a=e[fq]||(e[fq]={}),o=a[t];if(r&&o)o.value=r;else{let[n,s]=gq(t);r?uq(e,n,a[t]=bq(r,i),s):o&&(dq(e,n,o,s),a[t]=void 0)}}var mq=/(Once|Passive|Capture)$/,hq=/^on:?(?:Once|Passive|Capture)$/;function gq(e){let t,n;for(;(n=e.match(mq))&&!hq.test(e);)t||={},e=e.slice(0,e.length-n[1].length),t[n[1].toLowerCase()]=!0;return[e[2]===`:`?e.slice(3):QB(e.slice(2)),t]}var _q=0,vq=Promise.resolve(),yq=()=>_q||=(vq.then(()=>_q=0),Date.now());function bq(e,t){let n=e=>{if(!e._vts)e._vts=Date.now();else if(e._vts<=n.attached)return;let r=n.value;if(IB(r)){let n=e.stopImmediatePropagation;e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0};let i=r.slice(),a=[e];for(let n=0;n<i.length&&!e._stopped;n++){let e=i[n];e&&kH(e,t,5,a)}}else kH(r,t,5,[e])};return n.value=e,n.attached=yq(),n}var xq=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,Sq=(e,t,n,r,i,a)=>{let o=i===`svg`;t===`class`?qK(e,r,o):t===`style`?eq(e,n,r):jB(t)?MB(t)||pq(e,t,n,r,a):(t[0]===`.`?(t=t.slice(1),!0):t[0]===`^`?(t=t.slice(1),!1):Cq(e,t,r,o))?(lq(e,t,r),!e.tagName.includes(`-`)&&(t===`value`||t===`checked`||t===`selected`)&&cq(e,t,r,o,a,t!==`value`)):e._isVueCE&&(wq(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!VB(r)))?lq(e,ZB(t),r,a,t):(t===`true-value`?e._trueValue=r:t===`false-value`&&(e._falseValue=r),cq(e,t,r,o))};function Cq(e,t,n,r){if(r)return!!(t===`innerHTML`||t===`textContent`||t in e&&xq(t)&&BB(n));if(t===`spellcheck`||t===`draggable`||t===`translate`||t===`autocorrect`||t===`sandbox`&&e.tagName===`IFRAME`||t===`form`||t===`list`&&e.tagName===`INPUT`||t===`type`&&e.tagName===`TEXTAREA`)return!1;if(t===`width`||t===`height`){let t=e.tagName;if(t===`IMG`||t===`VIDEO`||t===`CANVAS`||t===`SOURCE`)return!1}return xq(t)&&VB(n)?!1:t in e}function wq(e,t){let n=e._def.props;if(!n)return!1;let r=ZB(t);return Array.isArray(n)?n.some(e=>ZB(e)===r):Object.keys(n).some(e=>ZB(e)===r)}var Tq=e=>{let t=e.props[`onUpdate:modelValue`]||!1;return IB(t)?e=>nV(t,e):t};function Eq(e){e.target.composing=!0}function Dq(e){let t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event(`input`)))}var Oq=Symbol(`_assign`);function kq(e,t,n){return t&&(e=e.trim()),n&&(e=iV(e)),e}var Aq={created(e,{modifiers:{lazy:t,trim:n,number:r}},i){e[Oq]=Tq(i);let a=r||i.props&&i.props.type===`number`;uq(e,t?`change`:`input`,t=>{t.target.composing||e[Oq](kq(e.value,n,a))}),(n||a)&&uq(e,`change`,()=>{e.value=kq(e.value,n,a)}),t||(uq(e,`compositionstart`,Eq),uq(e,`compositionend`,Dq),uq(e,`change`,Dq))},mounted(e,{value:t}){e.value=t??``},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Oq]=Tq(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?iV(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},jq=[`ctrl`,`shift`,`alt`,`meta`],Mq={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>jq.some(n=>e[`${n}Key`]&&!t.includes(n))},Nq=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=Mq[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},Pq={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},Fq=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=QB(n.key);if(t.some(e=>e===r||Pq[e]===r))return e(n)}))},Iq=NB({patchProp:Sq},EK),Lq;function Rq(){return Lq||=fG(Iq)}var zq=((...e)=>{let t=Rq().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Vq(e);if(!r)return;let i=t._component;!BB(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,Bq(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t});function Bq(e){if(e instanceof SVGElement)return`svg`;if(typeof MathMLElement==`function`&&e instanceof MathMLElement)return`mathml`}function Vq(e){return VB(e)?document.querySelector(e):e}function $(e){let t={error:e.code,message:e.message};return e.path!==void 0&&(t.path=e.path),e.hint&&(t.hint=e.hint),e.details!==void 0&&(t.details=e.details),`ERROR: ${JSON.stringify(t)}`}function Hq(e){return e.slice(0,10).map(e=>{let t=e,n={path:(Array.isArray(t.path)?t.path.join(`.`):String(t.path??``))||`(root)`,message:t.message};return t.expected!==void 0&&(n.expected=t.expected),t.received!==void 0&&(n.received=t.received),t.code!==void 0&&(n.code=t.code),n})}function Uq(e,t){return $({code:`SCHEMA_INVALID`,path:e,message:`值不符合 "${e}" 的 schema(${t.length} 处问题)`,hint:`用 read({jsonPath:"${e}"}) 查看当前值,按 describe_data() 查看主数据 schema,修正后重试;改大对象优先用 write 的 patch 增量(只发改动部分)`,details:Hq(t)})}function Wq(e,t,n){let r=n?.message||String(n),i=typeof t==`string`?t:JSON.stringify(t);return $({code:`JSON_PARSE`,...e===void 0?{}:{path:e},message:`value 不是合法 JSON:${r}`,hint:`检查引号/逗号/括号是否闭合;字符串值需双引号包裹(如 '"dark"' 表示字符串 dark,数字直接写如 5);预览前 80 字符:${i.slice(0,80)}`})}function Gq(e){return e.severity===`recoverable`?`feedback`:e.severity===`fatal`?`abort`:`log`}function Kq(e,t=`fatal`){return e&&typeof e==`object`&&`severity`in e&&typeof e.severity==`string`&&`message`in e?e:{severity:t,message:e instanceof Error?e.message:String(e),context:e}}function qq(e,t,n,r){return{severity:e,message:t,code:n,context:r}}function Jq(e){return e.replace(/^\/+/,``).replace(/\/+/g,`/`)}function Yq(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return(t>>>0).toString(36)}function Xq(e,t){let n=t.threshold??6e3;if(e.length<=n)return{content:e};if(t.vfsAvailable&&t.files){let n=`large_results/${t.toolName}-${Yq(e)}.txt`,r=Jq(n);t.files[r]={content:e,updatedAt:Date.now()};let i=e.slice(0,1e3),a=e.length,o=a>1e4?`结果较大(共 ${a} 字符),建议分页读取:vfs_read({ path: "${n}", offset: 0, limit: 100 }) 起步,按需 offset += 100 续读,或 vfs_grep({ pattern, path: "${n}" }) 局部检索`:void 0;return{offloaded:!0,content:[i,`…[结果过大(共 ${a} 字符),已转存到虚拟工作区:${n}]`,`需要完整或局部数据时:用 vfs_read({ path: "${n}", offset, limit }) 分页回读,或 vfs_grep({ pattern, path: "${n}" }) 局部检索。`,...o?[o]:[]].join(`
148
+ `)}`),new KS(n,JSON.stringify(e))}i=r}let a=VA(t),o=JA.configure(a.callbacks,this.callbacks,a.tags||n,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),s;WS(e)&&(s=e.id),!s&&GS(a)&&(s=a.toolCall.id);let c=await o?.handleToolStart(this.toJSON(),typeof e==`string`?e:JSON.stringify(e),a.runId,void 0,void 0,void 0,a.runName,s);delete a.runId;let l;try{let e=await this._call(i,c,a);l=tI(e)?await nI(e,async e=>{try{await c?.handleToolEvent(e)}catch(e){await c?.handleToolError(e)}}):e}catch(e){throw await c?.handleToolError(e),e}let u,d;if(this.responseFormat===`content_and_artifact`)if(Array.isArray(l)&&l.length===2)[u,d]=l;else throw Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.\nResult: ${JSON.stringify(l)}`);else u=l;let f=Xre({content:u,artifact:d,toolCallId:s,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(f),f}},Kre=class extends gB{schema=aP({input:rP().optional()}).transform(e=>e.input);constructor(e){super(e)}call(e,t){let n=typeof e==`string`||e==null?{input:e}:e;return super.call(n,t)}},qre=class extends Kre{static lc_name(){return`DynamicTool`}name;description;func;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect}async call(e,t){let n=VA(t);return n.runName===void 0&&(n.runName=this.name),super.call(e,n)}_call(e,t,n){return this.func(e,t,n)}},Jre=class extends gB{static lc_name(){return`DynamicStructuredTool`}description;func;schema;constructor(e){super(e),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect,this.schema=e.schema}async call(e,t,n){let r=VA(t);return r.runName===void 0&&(r.runName=this.name),super.call(e,r,n)}_call(e,t,n){return this.func(e,t,n)}};function _B(e,t){let n=aM(t.schema),r=GF(t.schema);if(!t.schema||n||r)return new qre({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(t,n,r)=>new Promise((i,a)=>{let o=aj(r,{callbacks:n?.getChild()});QA.runWithConfig(oj(o),async()=>{try{i(e(t,o))}catch(e){a(e)}})})});let i=t.schema,a=t.description??t.schema.description??`${t.name} tool`;return new Jre({...t,description:a,schema:i,func:async(t,n,r)=>new Promise((i,a)=>{let o,s=()=>{r?.signal&&o&&r.signal.removeEventListener(`abort`,o)};r?.signal&&(o=()=>{s(),a(cj(r.signal))},r.signal.addEventListener(`abort`,o,{once:!0}));let c=aj(r,{callbacks:n?.getChild()});QA.runWithConfig(oj(c),async()=>{try{let n=await e(t,c);if(tI(n)){i(n);return}if(r?.signal?.aborted){s();return}s(),i(n)}catch(e){s(),a(e)}})})})}function Yre(e){return typeof e==`object`&&!!e&&`type`in e}function Xre(e){let{content:t,artifact:n,toolCallId:r,metadata:i}=e;return r&&!vS(t)?typeof t==`string`||Array.isArray(t)&&t.every(Yre)?new yS({status:`success`,content:t,artifact:n,tool_call_id:r,name:e.name,metadata:i}):new yS({status:`success`,content:Zre(t),artifact:n,tool_call_id:r,name:e.name,metadata:i}):t}function Zre(e){try{return JSON.stringify(e)??``}catch{return`${e}`}}aL(),L({action:cf([L({type:bf(`screenshot`)}),L({type:bf(`click`),x:Bd(),y:Bd(),button:vf([`left`,`right`,`wheel`,`back`,`forward`]).default(`left`)}),L({type:bf(`double_click`),x:Bd(),y:Bd(),button:vf([`left`,`right`,`wheel`,`back`,`forward`]).default(`left`)}),L({type:bf(`drag`),path:I(L({x:Bd(),y:Bd()}))}),L({type:bf(`keypress`),keys:I(F())}),L({type:bf(`move`),x:Bd(),y:Bd()}),L({type:bf(`scroll`),x:Bd(),y:Bd(),scroll_x:Bd(),scroll_y:Bd()}),L({type:bf(`type`),text:F()}),L({type:bf(`wait`),duration:Bd().optional()})])}),aL(),cf([L({type:bf(`exec`),command:I(F()),env:pf(F(),F()).optional(),working_directory:F().optional(),timeout_ms:Bd().optional(),user:F().optional()})]),aL(),L({commands:I(F()).describe(`Array of shell commands to execute`),timeout_ms:Bd().optional().describe(`Optional timeout in milliseconds for the commands`),max_output_length:Bd().optional().describe(`Optional maximum number of characters to return from each command`)}),aL(),cf([L({type:bf(`create_file`),path:F(),diff:F()}),L({type:bf(`update_file`),path:F(),diff:F()}),L({type:bf(`delete_file`),path:F()})]);function Qre(e){return!!(e==null||typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)||typeof Blob<`u`&&e instanceof Blob||e instanceof URLSearchParams||e instanceof FormData)}function $re(e){let t=e.model||`gpt-3.5-turbo`,n=e.temperature,r=e.maxTokens,i=e.baseUrl;if(e.mode===`direct`){let a=!1;try{a=typeof location<`u`&&location.protocol===`https:`&&![`localhost`,`127.0.0.1`,`0.0.0.0`].includes(location.hostname)}catch{}if(a){if(e.throwOnDirectInProduction)throw Error(`[page-agent-sdk][proxyLlm] direct 模式在生产环境(https + 非本地)会泄露 apiKey(进 bundle),建议改用 proxy 模式(throwOnDirectInProduction 已启用强安全闸;若确需生产直连,设为 false 显式承认风险)`);console.warn(`[page-agent-sdk][proxyLlm] direct 模式在生产环境(https + 非本地)会泄露 apiKey(进 bundle),建议改用 proxy 模式`)}if(!e.apiKey)throw Error(`[page-agent-sdk][proxyLlm] direct 模式需提供 apiKey(开发环境用真实 key)`);return new hB({apiKey:e.apiKey,model:t,temperature:n,maxTokens:r,configuration:i?{baseURL:i}:void 0})}i||console.warn(`[page-agent-sdk][proxyLlm] proxy 模式未配 baseUrl,将打到页面 origin(通常不是预期);请传代理地址如 '/api/llm'`);let a=e.userToken||`proxy`,o=null;function s(){return e.refreshToken?(o||=e.refreshToken().finally(()=>{o=null}),o):Promise.resolve(a)}return new hB({apiKey:a,model:t,temperature:n,maxTokens:r,configuration:{baseURL:i||`/`,fetch:async(t,n)=>{let r,i;typeof t==`string`?(r=t,i=n?.headers):t instanceof URL?(r=t.toString(),i=n?.headers):(r=t.url,i=n?.headers??t.headers);let o=new Headers(i);if(o.set(`Authorization`,`Bearer ${a}`),e.headers)for(let[t,n]of Object.entries(e.headers))o.set(t,n);let c=()=>fetch(r,{...n,headers:o}),l=await c();if(l.status===401&&e.refreshToken&&Qre(n?.body))try{a=await s(),o.set(`Authorization`,`Bearer ${a}`),l=await c()}catch{}return l}}})}function vB(e,t){if(t?.headers){let e=new Headers(t.headers),n=!1;for(let t of[...e.keys()])t.toLowerCase().startsWith(`x-stainless`)&&(e.delete(t),n=!0);n&&(t={...t,headers:e})}return fetch(e,t)}function yB(e){return!e||!e.startsWith(`/`)||typeof location>`u`||!location.origin?e:`${location.origin}${e}`}function bB(e,t={}){return new hB({apiKey:e.apiKey,model:e.model,temperature:t.temperature??e.temperature,maxTokens:t.maxTokens??e.maxTokens,configuration:{...e.baseUrl?{baseURL:yB(e.baseUrl)}:{},fetch:vB,...e.extraConfig},...e.extraBody?{modelKwargs:e.extraBody}:{}})}async function xB(e,t={}){if((e.provider??`openai`)===`openai`)return bB(e,t);let{ChatAnthropic:n}=await import(`@langchain/anthropic`);return new n({apiKey:e.apiKey,model:e.model,temperature:t.temperature??e.temperature,maxTokens:t.maxTokens??e.maxTokens,...e.baseUrl?{anthropicApiUrl:yB(e.baseUrl)}:{},...e.extraConfig?{clientOptions:e.extraConfig}:{},...e.cacheControl?{invocationKwargs:{cache_control:{type:`ephemeral`,...e.cacheControl===!0?{}:{ttl:e.cacheControl}}}}:{}})}function SB(e){let t=e.content;return typeof t==`string`?t:Array.isArray(t)?t.map(e=>typeof e==`string`?e:e?.type===`text`&&typeof e.text==`string`?e.text:``).join(``):``}function CB(e){let t=e.additional_kwargs||{},n=t.reasoning_content||t.reasoning||``;return!n&&Array.isArray(e.content)&&(n=e.content.map(e=>e?.type===`thinking`?e.thinking??``:e?.type===`thinking_delta`?e.delta??e.thinking??``:``).join(``)),n}function wB(e){let t=e,n=[t?.additional_kwargs?.usage,t?.usage_metadata,t?.response_metadata?.usage,t?.response_metadata?.token_usage,t?.response_metadata?.tokenUsage];for(let e of n)if(e&&typeof e==`object`&&eie(e))return e}function eie(e){return[`prompt_tokens`,`completion_tokens`,`total_tokens`,`promptTokens`,`completionTokens`,`totalTokens`,`input_tokens`,`output_tokens`,`inputTokens`,`outputTokens`].some(t=>typeof e[t]==`number`&&e[t]>0)}function TB(e){let t=wB(e);if(!t||typeof t!=`object`)return null;let n=t,r=Number(n.prompt_tokens??n.promptTokens??n.input_tokens??n.inputTokens??0)||0,i=Number(n.completion_tokens??n.completionTokens??n.output_tokens??n.outputTokens??0)||0,a=Number(n.total_tokens??n.totalTokens??r+i)||0;if(!r&&!i&&!a)return null;let o=n.input_token_details,s=Number(n.cache_read_input_tokens??n.cacheReadInputTokens??o?.cache_read??0)||0,c=Number(n.cache_creation_input_tokens??n.cacheCreationInputTokens??o?.cache_creation??0)||0;return{prompt_tokens:r,completion_tokens:i,total_tokens:a,...s?{cache_read_input_tokens:s}:{},...c?{cache_creation_input_tokens:c}:{}}}function EB(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var DB={},OB=[],kB=()=>{},AB=()=>!1,jB=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),MB=e=>e.startsWith(`onUpdate:`),NB=Object.assign,PB=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},tie=Object.prototype.hasOwnProperty,FB=(e,t)=>tie.call(e,t),IB=Array.isArray,LB=e=>KB(e)===`[object Map]`,RB=e=>KB(e)===`[object Set]`,zB=e=>KB(e)===`[object Date]`,BB=e=>typeof e==`function`,VB=e=>typeof e==`string`,HB=e=>typeof e==`symbol`,UB=e=>typeof e==`object`&&!!e,WB=e=>(UB(e)||BB(e))&&BB(e.then)&&BB(e.catch),GB=Object.prototype.toString,KB=e=>GB.call(e),nie=e=>KB(e).slice(8,-1),qB=e=>KB(e)===`[object Object]`,JB=e=>VB(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,YB=EB(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),XB=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},rie=/-\w/g,ZB=XB(e=>e.replace(rie,e=>e.slice(1).toUpperCase())),iie=/\B([A-Z])/g,QB=XB(e=>e.replace(iie,`-$1`).toLowerCase()),$B=XB(e=>e.charAt(0).toUpperCase()+e.slice(1)),eV=XB(e=>e?`on${$B(e)}`:``),tV=(e,t)=>!Object.is(e,t),nV=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},rV=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},iV=e=>{let t=parseFloat(e);return isNaN(t)?e:t},aie=e=>{let t=VB(e)?Number(e):NaN;return isNaN(t)?e:t},oie,aV=()=>oie||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{};function oV(e){if(IB(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=VB(r)?uie(r):oV(r);if(i)for(let e in i)t[e]=i[e]}return t}else if(VB(e)||UB(e))return e}var sie=/;(?![^(]*\))/g,cie=/:([^]+)/,lie=/\/\*[^]*?\*\//g;function uie(e){let t={};return e.replace(lie,``).split(sie).forEach(e=>{if(e){let n=e.split(cie);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function sV(e){let t=``;if(VB(e))t=e;else if(IB(e))for(let n=0;n<e.length;n++){let r=sV(e[n]);r&&(t+=r+` `)}else if(UB(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}var cV=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,die=EB(cV);cV+``;function lV(e){return!!e||e===``}function fie(e,t){if(e.length!==t.length)return!1;let n=!0;for(let r=0;n&&r<e.length;r++)n=uV(e[r],t[r]);return n}function uV(e,t){if(e===t)return!0;let n=zB(e),r=zB(t);if(n||r)return n&&r?e.getTime()===t.getTime():!1;if(n=HB(e),r=HB(t),n||r)return e===t;if(n=IB(e),r=IB(t),n||r)return n&&r?fie(e,t):!1;if(n=UB(e),r=UB(t),n||r){if(!n||!r||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e){let r=e.hasOwnProperty(n),i=t.hasOwnProperty(n);if(r&&!i||!r&&i||!uV(e[n],t[n]))return!1}}return String(e)===String(t)}var dV=e=>!!(e&&e.__v_isRef===!0),q=e=>VB(e)?e:e==null?``:IB(e)||UB(e)&&(e.toString===GB||!BB(e.toString))?dV(e)?q(e.value):JSON.stringify(e,fV,2):String(e),fV=(e,t)=>dV(t)?fV(e,t.value):LB(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[pV(t,r)+` =>`]=n,e),{})}:RB(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>pV(e))}:HB(t)?pV(t):UB(t)&&!IB(t)&&!qB(t)?String(t):t,pV=(e,t=``)=>HB(e)?`Symbol(${e.description??t})`:e,mV,pie=class{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this._warnOnRun=!0,this.__v_skip=!0,!e&&mV&&(mV.active?(this.parent=mV,this.index=(mV.scopes||=[]).push(this)-1):(this._active=!1,this._warnOnRun=!1))}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].pause();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].resume();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].resume()}}run(e){if(this._active){let t=mV;try{return mV=this,e()}finally{mV=t}}}on(){++this._on===1&&(this.prevScope=mV,mV=this)}off(){if(this._on>0&&--this._on===0){if(mV===this)mV=this.prevScope;else{let e=mV;for(;e;){if(e.prevScope===this){e.prevScope=this.prevScope;break}e=e.prevScope}}this.prevScope=void 0}}stop(e){if(this._active){this._active=!1;let t,n;for(t=0,n=this.effects.length;t<n;t++)this.effects[t].stop();for(this.effects.length=0,t=0,n=this.cleanups.length;t<n;t++)this.cleanups[t]();if(this.cleanups.length=0,this.scopes){for(t=0,n=this.scopes.length;t<n;t++)this.scopes[t].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){let e=this.parent.scopes.pop();e&&e!==this&&(this.parent.scopes[this.index]=e,e.index=this.index)}this.parent=void 0}}};function mie(){return mV}function hie(e,t=!1){mV&&mV.cleanups.push(e)}var hV,gV=new WeakSet,_V=class{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,mV&&(mV.active?mV.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,gV.has(this)&&(gV.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||xV(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,NV(this),wV(this);let e=hV,t=kV;hV=this,kV=!0;try{return this.fn()}finally{TV(this),hV=e,kV=t,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)OV(e);this.deps=this.depsTail=void 0,NV(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?gV.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){EV(this)&&this.run()}get dirty(){return EV(this)}},vV=0,yV,bV;function xV(e,t=!1){if(e.flags|=8,t){e.next=bV,bV=e;return}e.next=yV,yV=e}function SV(){vV++}function CV(){if(--vV>0)return;if(bV){let e=bV;for(bV=void 0;e;){let t=e.next;e.next=void 0,e.flags&=-9,e=t}}let e;for(;yV;){let t=yV;for(yV=void 0;t;){let n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(t){e||=t}t=n}}if(e)throw e}function wV(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function TV(e){let t,n=e.depsTail,r=n;for(;r;){let e=r.prevDep;r.version===-1?(r===n&&(n=e),OV(r),gie(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=e}e.deps=t,e.depsTail=n}function EV(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(DV(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function DV(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===PV)||(e.globalVersion=PV,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!EV(e))))return;e.flags|=2;let t=e.dep,n=hV,r=kV;hV=e,kV=!0;try{wV(e);let n=e.fn(e._value);(t.version===0||tV(n,e._value))&&(e.flags|=128,e._value=n,t.version++)}catch(e){throw t.version++,e}finally{hV=n,kV=r,TV(e),e.flags&=-3}}function OV(e,t=!1){let{dep:n,prevSub:r,nextSub:i}=e;if(r&&(r.nextSub=i,e.prevSub=void 0),i&&(i.prevSub=r,e.nextSub=void 0),n.subs===e&&(n.subs=r,!r&&n.computed)){n.computed.flags&=-5;for(let e=n.computed.deps;e;e=e.nextDep)OV(e,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function gie(e){let{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}var kV=!0,AV=[];function jV(){AV.push(kV),kV=!1}function MV(){let e=AV.pop();kV=e===void 0||e}function NV(e){let{cleanup:t}=e;if(e.cleanup=void 0,t){let e=hV;hV=void 0;try{t()}finally{hV=e}}}var PV=0,_ie=class{constructor(e,t){this.sub=e,this.dep=t,this.version=t.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}},FV=class{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!hV||!kV||hV===this.computed)return;let t=this.activeLink;if(t===void 0||t.sub!==hV)t=this.activeLink=new _ie(hV,this),hV.deps?(t.prevDep=hV.depsTail,hV.depsTail.nextDep=t,hV.depsTail=t):hV.deps=hV.depsTail=t,IV(t);else if(t.version===-1&&(t.version=this.version,t.nextDep)){let e=t.nextDep;e.prevDep=t.prevDep,t.prevDep&&(t.prevDep.nextDep=e),t.prevDep=hV.depsTail,t.nextDep=void 0,hV.depsTail.nextDep=t,hV.depsTail=t,hV.deps===t&&(hV.deps=e)}return t}trigger(e){this.version++,PV++,this.notify(e)}notify(e){SV();try{for(let e=this.subs;e;e=e.prevSub)e.sub.notify()&&e.sub.dep.notify()}finally{CV()}}};function IV(e){if(e.dep.sc++,e.sub.flags&4){let t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let e=t.deps;e;e=e.nextDep)IV(e)}let n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}var LV=new WeakMap,RV=Symbol(``),zV=Symbol(``),BV=Symbol(``);function VV(e,t,n){if(kV&&hV){let t=LV.get(e);t||LV.set(e,t=new Map);let r=t.get(n);r||(t.set(n,r=new FV),r.map=t,r.key=n),r.track()}}function HV(e,t,n,r,i,a){let o=LV.get(e);if(!o){PV++;return}let s=e=>{e&&e.trigger()};if(SV(),t===`clear`)o.forEach(s);else{let i=IB(e),a=i&&JB(n);if(i&&n===`length`){let e=Number(r);o.forEach((t,n)=>{(n===`length`||n===BV||!HB(n)&&n>=e)&&s(t)})}else switch((n!==void 0||o.has(void 0))&&s(o.get(n)),a&&s(o.get(BV)),t){case`add`:i?a&&s(o.get(`length`)):(s(o.get(RV)),LB(e)&&s(o.get(zV)));break;case`delete`:i||(s(o.get(RV)),LB(e)&&s(o.get(zV)));break;case`set`:LB(e)&&s(o.get(RV));break}}CV()}function UV(e){let t=mH(e);return t===e?t:(VV(t,`iterate`,BV),fH(e)?t:t.map(hH))}function WV(e){return VV(e=mH(e),`iterate`,BV),e}function GV(e,t){return dH(e)?gH(uH(e)?hH(t):t):hH(t)}var vie={__proto__:null,[Symbol.iterator](){return KV(this,Symbol.iterator,e=>GV(this,e))},concat(...e){return UV(this).concat(...e.map(e=>IB(e)?UV(e):e))},entries(){return KV(this,`entries`,e=>(e[1]=GV(this,e[1]),e))},every(e,t){return qV(this,`every`,e,t,void 0,arguments)},filter(e,t){return qV(this,`filter`,e,t,e=>e.map(e=>GV(this,e)),arguments)},find(e,t){return qV(this,`find`,e,t,e=>GV(this,e),arguments)},findIndex(e,t){return qV(this,`findIndex`,e,t,void 0,arguments)},findLast(e,t){return qV(this,`findLast`,e,t,e=>GV(this,e),arguments)},findLastIndex(e,t){return qV(this,`findLastIndex`,e,t,void 0,arguments)},forEach(e,t){return qV(this,`forEach`,e,t,void 0,arguments)},includes(...e){return YV(this,`includes`,e)},indexOf(...e){return YV(this,`indexOf`,e)},join(e){return UV(this).join(e)},lastIndexOf(...e){return YV(this,`lastIndexOf`,e)},map(e,t){return qV(this,`map`,e,t,void 0,arguments)},pop(){return XV(this,`pop`)},push(...e){return XV(this,`push`,e)},reduce(e,...t){return JV(this,`reduce`,e,t)},reduceRight(e,...t){return JV(this,`reduceRight`,e,t)},shift(){return XV(this,`shift`)},some(e,t){return qV(this,`some`,e,t,void 0,arguments)},splice(...e){return XV(this,`splice`,e)},toReversed(){return UV(this).toReversed()},toSorted(e){return UV(this).toSorted(e)},toSpliced(...e){return UV(this).toSpliced(...e)},unshift(...e){return XV(this,`unshift`,e)},values(){return KV(this,`values`,e=>GV(this,e))}};function KV(e,t,n){let r=WV(e),i=r[t]();return r!==e&&!fH(e)&&(i._next=i.next,i.next=()=>{let e=i._next();return e.done||(e.value=n(e.value)),e}),i}var yie=Array.prototype;function qV(e,t,n,r,i,a){let o=WV(e),s=o!==e&&!fH(e),c=o[t];if(c!==yie[t]){let t=c.apply(e,a);return s?hH(t):t}let l=n;o!==e&&(s?l=function(t,r){return n.call(this,GV(e,t),r,e)}:n.length>2&&(l=function(t,r){return n.call(this,t,r,e)}));let u=c.call(o,l,r);return s&&i?i(u):u}function JV(e,t,n,r){let i=WV(e),a=i!==e&&!fH(e),o=n,s=!1;i!==e&&(a?(s=r.length===0,o=function(t,r,i){return s&&(s=!1,t=GV(e,t)),n.call(this,t,GV(e,r),i,e)}):n.length>3&&(o=function(t,r,i){return n.call(this,t,r,i,e)}));let c=i[t](o,...r);return s?GV(e,c):c}function YV(e,t,n){let r=mH(e);VV(r,`iterate`,BV);let i=r[t](...n);return(i===-1||i===!1)&&pH(n[0])?(n[0]=mH(n[0]),r[t](...n)):i}function XV(e,t,n=[]){jV(),SV();let r=mH(e)[t].apply(e,n);return CV(),MV(),r}var bie=EB(`__proto__,__v_isRef,__isVue`),ZV=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!==`arguments`&&e!==`caller`).map(e=>Symbol[e]).filter(HB));function xie(e){HB(e)||(e=String(e));let t=mH(this);return VV(t,`has`,e),t.hasOwnProperty(e)}var QV=class{constructor(e=!1,t=!1){this._isReadonly=e,this._isShallow=t}get(e,t,n){if(t===`__v_skip`)return e.__v_skip;let r=this._isReadonly,i=this._isShallow;if(t===`__v_isReactive`)return!r;if(t===`__v_isReadonly`)return r;if(t===`__v_isShallow`)return i;if(t===`__v_raw`)return n===(r?i?jie:oH:i?aH:iH).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;let a=IB(e);if(!r){let e;if(a&&(e=vie[t]))return e;if(t===`hasOwnProperty`)return xie}let o=Reflect.get(e,t,_H(e)?e:n);if((HB(t)?ZV.has(t):bie(t))||(r||VV(e,`get`,t),i))return o;if(_H(o)){let e=a&&JB(t)?o:o.value;return r&&UB(e)?cH(e):e}return UB(o)?r?cH(o):sH(o):o}},$V=class extends QV{constructor(e=!1){super(!1,e)}set(e,t,n,r){let i=e[t],a=IB(e)&&JB(t);if(!this._isShallow){let e=dH(i);if(!fH(n)&&!dH(n)&&(i=mH(i),n=mH(n)),!a&&_H(i)&&!_H(n))return e||(i.value=n),!0}let o=a?Number(t)<e.length:FB(e,t),s=Reflect.set(e,t,n,_H(e)?e:r);return e===mH(r)&&s&&(o?tV(n,i)&&HV(e,`set`,t,n,i):HV(e,`add`,t,n)),s}deleteProperty(e,t){let n=FB(e,t),r=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&HV(e,`delete`,t,void 0,r),i}has(e,t){let n=Reflect.has(e,t);return(!HB(t)||!ZV.has(t))&&VV(e,`has`,t),n}ownKeys(e){return VV(e,`iterate`,IB(e)?`length`:RV),Reflect.ownKeys(e)}},Sie=class extends QV{constructor(e=!1){super(!0,e)}set(e,t){return!0}deleteProperty(e,t){return!0}},Cie=new $V,wie=new Sie,Tie=new $V(!0),eH=e=>e,tH=e=>Reflect.getPrototypeOf(e);function Eie(e,t,n){return function(...r){let i=this.__v_raw,a=mH(i),o=LB(a),s=e===`entries`||e===Symbol.iterator&&o,c=e===`keys`&&o,l=i[e](...r),u=n?eH:t?gH:hH;return!t&&VV(a,`iterate`,c?zV:RV),NB(Object.create(l),{next(){let{value:e,done:t}=l.next();return t?{value:e,done:t}:{value:s?[u(e[0]),u(e[1])]:u(e),done:t}}})}}function nH(e){return function(...t){return e===`delete`?!1:e===`clear`?void 0:this}}function Die(e,t){let n={get(n){let r=this.__v_raw,i=mH(r),a=mH(n);e||(tV(n,a)&&VV(i,`get`,n),VV(i,`get`,a));let{has:o}=tH(i),s=t?eH:e?gH:hH;if(o.call(i,n))return s(r.get(n));if(o.call(i,a))return s(r.get(a));r!==i&&r.get(n)},get size(){let t=this.__v_raw;return!e&&VV(mH(t),`iterate`,RV),t.size},has(t){let n=this.__v_raw,r=mH(n),i=mH(t);return e||(tV(t,i)&&VV(r,`has`,t),VV(r,`has`,i)),t===i?n.has(t):n.has(t)||n.has(i)},forEach(n,r){let i=this,a=i.__v_raw,o=mH(a),s=t?eH:e?gH:hH;return!e&&VV(o,`iterate`,RV),a.forEach((e,t)=>n.call(r,s(e),s(t),i))}};return NB(n,e?{add:nH(`add`),set:nH(`set`),delete:nH(`delete`),clear:nH(`clear`)}:{add(e){let n=mH(this),r=tH(n),i=mH(e),a=!t&&!fH(e)&&!dH(e)?i:e;return r.has.call(n,a)||tV(e,a)&&r.has.call(n,e)||tV(i,a)&&r.has.call(n,i)||(n.add(a),HV(n,`add`,a,a)),this},set(e,n){!t&&!fH(n)&&!dH(n)&&(n=mH(n));let r=mH(this),{has:i,get:a}=tH(r),o=i.call(r,e);o||=(e=mH(e),i.call(r,e));let s=a.call(r,e);return r.set(e,n),o?tV(n,s)&&HV(r,`set`,e,n,s):HV(r,`add`,e,n),this},delete(e){let t=mH(this),{has:n,get:r}=tH(t),i=n.call(t,e);i||=(e=mH(e),n.call(t,e));let a=r?r.call(t,e):void 0,o=t.delete(e);return i&&HV(t,`delete`,e,void 0,a),o},clear(){let e=mH(this),t=e.size!==0,n=e.clear();return t&&HV(e,`clear`,void 0,void 0,void 0),n}}),[`keys`,`values`,`entries`,Symbol.iterator].forEach(r=>{n[r]=Eie(r,e,t)}),n}function rH(e,t){let n=Die(e,t);return(t,r,i)=>r===`__v_isReactive`?!e:r===`__v_isReadonly`?e:r===`__v_raw`?t:Reflect.get(FB(n,r)&&r in t?n:t,r,i)}var Oie={get:rH(!1,!1)},kie={get:rH(!1,!0)},Aie={get:rH(!0,!1)},iH=new WeakMap,aH=new WeakMap,oH=new WeakMap,jie=new WeakMap;function Mie(e){switch(e){case`Object`:case`Array`:return 1;case`Map`:case`Set`:case`WeakMap`:case`WeakSet`:return 2;default:return 0}}function sH(e){return dH(e)?e:lH(e,!1,Cie,Oie,iH)}function Nie(e){return lH(e,!1,Tie,kie,aH)}function cH(e){return lH(e,!0,wie,Aie,oH)}function lH(e,t,n,r,i){if(!UB(e)||e.__v_raw&&!(t&&e.__v_isReactive)||e.__v_skip||!Object.isExtensible(e))return e;let a=i.get(e);if(a)return a;let o=Mie(nie(e));if(o===0)return e;let s=new Proxy(e,o===2?r:n);return i.set(e,s),s}function uH(e){return dH(e)?uH(e.__v_raw):!!(e&&e.__v_isReactive)}function dH(e){return!!(e&&e.__v_isReadonly)}function fH(e){return!!(e&&e.__v_isShallow)}function pH(e){return e?!!e.__v_raw:!1}function mH(e){let t=e&&e.__v_raw;return t?mH(t):e}function Pie(e){return!FB(e,`__v_skip`)&&Object.isExtensible(e)&&rV(e,`__v_skip`,!0),e}var hH=e=>UB(e)?sH(e):e,gH=e=>UB(e)?cH(e):e;function _H(e){return e?e.__v_isRef===!0:!1}function vH(e){return bH(e,!1)}function yH(e){return bH(e,!0)}function bH(e,t){return _H(e)?e:new Fie(e,t)}var Fie=class{constructor(e,t){this.dep=new FV,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=t?e:mH(e),this._value=t?e:hH(e),this.__v_isShallow=t}get value(){return this.dep.track(),this._value}set value(e){let t=this._rawValue,n=this.__v_isShallow||fH(e)||dH(e);e=n?e:mH(e),tV(e,t)&&(this._rawValue=e,this._value=n?e:hH(e),this.dep.trigger())}};function xH(e){e.dep&&e.dep.trigger()}function J(e){return _H(e)?e.value:e}var Iie={get:(e,t,n)=>t===`__v_raw`?e:J(Reflect.get(e,t,n)),set:(e,t,n,r)=>{let i=e[t];return _H(i)&&!_H(n)?(i.value=n,!0):Reflect.set(e,t,n,r)}};function SH(e){return uH(e)?e:new Proxy(e,Iie)}var Lie=class{constructor(e,t,n){this.fn=e,this.setter=t,this._value=void 0,this.dep=new FV(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=PV-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!t,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&hV!==this)return xV(this,!0),!0}get value(){let e=this.dep.track();return DV(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}};function Rie(e,t,n=!1){let r,i;return BB(e)?r=e:(r=e.get,i=e.set),new Lie(r,i,n)}var CH={},wH=new WeakMap,TH=void 0;function zie(e,t=!1,n=TH){if(n){let t=wH.get(n);t||wH.set(n,t=[]),t.push(e)}}function EH(e,t,n=DB){let{immediate:r,deep:i,once:a,scheduler:o,augmentJob:s,call:c}=n,l=e=>i?e:fH(e)||i===!1||i===0?DH(e,1):DH(e),u,d,f,p,m=!1,h=!1;if(_H(e)?(d=()=>e.value,m=fH(e)):uH(e)?(d=()=>l(e),m=!0):IB(e)?(h=!0,m=e.some(e=>uH(e)||fH(e)),d=()=>e.map(e=>{if(_H(e))return e.value;if(uH(e))return l(e);if(BB(e))return c?c(e,2):e()})):d=BB(e)?t?c?()=>c(e,2):e:()=>{if(f){jV();try{f()}finally{MV()}}let t=TH;TH=u;try{return c?c(e,3,[p]):e(p)}finally{TH=t}}:kB,t&&i){let e=d,t=i===!0?1/0:i;d=()=>DH(e(),t)}let g=mie(),_=()=>{u.stop(),g&&g.active&&PB(g.effects,u)};if(a&&t){let e=t;t=(...t)=>{let n=e(...t);return _(),n}}let v=h?Array(e.length).fill(CH):CH,y=e=>{if(!(!(u.flags&1)||!u.dirty&&!e))if(t){let n=u.run();if(e||i||m||(h?n.some((e,t)=>tV(e,v[t])):tV(n,v))){f&&f();let e=TH;TH=u;try{let e=[n,v===CH?void 0:h&&v[0]===CH?[]:v,p];v=n,c?c(t,3,e):t(...e)}finally{TH=e}}}else u.run()};return s&&s(y),u=new _V(d),u.scheduler=o?()=>o(y,!1):y,p=e=>zie(e,!1,u),f=u.onStop=()=>{let e=wH.get(u);if(e){if(c)c(e,4);else for(let t of e)t();wH.delete(u)}},t?r?y(!0):v=u.run():o?o(y.bind(null,!0),!0):u.run(),_.pause=u.pause.bind(u),_.resume=u.resume.bind(u),_.stop=_,_}function DH(e,t=1/0,n){if(t<=0||!UB(e)||e.__v_skip||(n||=new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,_H(e))DH(e.value,t,n);else if(IB(e))for(let r=0;r<e.length;r++)DH(e[r],t,n);else if(RB(e)||LB(e))e.forEach(e=>{DH(e,t,n)});else if(qB(e)){for(let r in e)DH(e[r],t,n);for(let r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&DH(e[r],t,n)}return e}function OH(e,t,n,r){try{return r?e(...r):e()}catch(e){AH(e,t,n)}}function kH(e,t,n,r){if(BB(e)){let i=OH(e,t,n,r);return i&&WB(i)&&i.catch(e=>{AH(e,t,n)}),i}if(IB(e)){let i=[];for(let a=0;a<e.length;a++)i.push(kH(e[a],t,n,r));return i}}function AH(e,t,n,r=!0){let i=t?t.vnode:null,{errorHandler:a,throwUnhandledErrorInProduction:o}=t&&t.appContext.config||DB;if(t){let r=t.parent,i=t.proxy,o=`https://vuejs.org/error-reference/#runtime-${n}`;for(;r;){let t=r.ec;if(t){for(let n=0;n<t.length;n++)if(t[n](e,i,o)===!1)return}r=r.parent}if(a){jV(),OH(a,null,10,[e,i,o]),MV();return}}jH(e,n,i,r,o)}function jH(e,t,n,r=!0,i=!1){if(i)throw e;console.error(e)}var MH=[],NH=-1,PH=[],FH=null,IH=0,LH=Promise.resolve(),RH=null;function zH(e){let t=RH||LH;return e?t.then(this?e.bind(this):e):t}function BH(e){let t=NH+1,n=MH.length;for(;t<n;){let r=t+n>>>1,i=MH[r],a=KH(i);a<e||a===e&&i.flags&2?t=r+1:n=r}return t}function VH(e){if(!(e.flags&1)){let t=KH(e),n=MH[MH.length-1];!n||!(e.flags&2)&&t>=KH(n)?MH.push(e):MH.splice(BH(t),0,e),e.flags|=1,HH()}}function HH(){RH||=LH.then(qH)}function UH(e){IB(e)?PH.push(...e):FH&&e.id===-1?FH.splice(IH+1,0,e):e.flags&1||(PH.push(e),e.flags|=1),HH()}function WH(e,t,n=NH+1){for(;n<MH.length;n++){let t=MH[n];if(t&&t.flags&2){if(e&&t.id!==e.uid)continue;MH.splice(n,1),n--,t.flags&4&&(t.flags&=-2),t(),t.flags&4||(t.flags&=-2)}}}function GH(e){if(PH.length){let e=[...new Set(PH)].sort((e,t)=>KH(e)-KH(t));if(PH.length=0,FH){FH.push(...e);return}for(FH=e,IH=0;IH<FH.length;IH++){let e=FH[IH];e.flags&4&&(e.flags&=-2),e.flags&8||e(),e.flags&=-2}FH=null,IH=0}}var KH=e=>e.id==null?e.flags&2?-1:1/0:e.id;function qH(e){try{for(NH=0;NH<MH.length;NH++){let e=MH[NH];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),OH(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;NH<MH.length;NH++){let e=MH[NH];e&&(e.flags&=-2)}NH=-1,MH.length=0,GH(e),RH=null,(MH.length||PH.length)&&qH(e)}}var JH=null,YH=null;function XH(e){let t=JH;return JH=e,YH=e&&e.type.__scopeId||null,t}function ZH(e,t=JH,n){if(!t||e._n)return e;let r=(...n)=>{r._d&&MG(-1);let i=XH(t),a;try{a=e(...n)}finally{XH(i),r._d&&MG(1)}return a};return r._n=!0,r._c=!0,r._d=!0,r}function QH(e,t){if(JH===null)return e;let n=mK(JH),r=e.dirs||=[];for(let e=0;e<t.length;e++){let[i,a,o,s=DB]=t[e];i&&(BB(i)&&(i={mounted:i,updated:i}),i.deep&&DH(a),r.push({dir:i,instance:n,value:a,oldValue:void 0,arg:o,modifiers:s}))}return e}function $H(e,t,n,r){let i=e.dirs,a=t&&t.dirs;for(let o=0;o<i.length;o++){let s=i[o];a&&(s.oldValue=a[o].value);let c=s.dir[r];c&&(jV(),kH(c,n,8,[e.el,s,e,t]),MV())}}function eU(e,t){if(QG){let n=QG.provides,r=QG.parent&&QG.parent.provides;r===n&&(n=QG.provides=Object.create(r)),n[e]=t}}function tU(e,t,n=!1){let r=$G();if(r||PW){let i=PW?PW._context.provides:r?r.parent==null||r.ce?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides:void 0;if(i&&e in i)return i[e];if(arguments.length>1)return n&&BB(t)?t.call(r&&r.proxy):t}}var nU=Symbol.for(`v-scx`),rU=()=>tU(nU);function iU(e,t,n){return aU(e,t,n)}function aU(e,t,n=DB){let{immediate:r,deep:i,flush:a,once:o}=n,s=NB({},n),c=t&&r||!t&&a!==`post`,l;if(aK){if(a===`sync`){let e=rU();l=e.__watcherHandles||=[]}else if(!c){let e=()=>{};return e.stop=kB,e.resume=kB,e.pause=kB,e}}let u=QG;s.call=(e,t,n)=>kH(e,u,t,n);let d=!1;a===`post`?s.scheduler=e=>{dG(e,u&&u.suspense)}:a!==`sync`&&(d=!0,s.scheduler=(e,t)=>{t?e():VH(e)}),s.augmentJob=e=>{t&&(e.flags|=4),d&&(e.flags|=2,u&&(e.id=u.uid,e.i=u))};let f=EH(e,t,s);return aK&&(l?l.push(f):c&&f()),f}function oU(e,t,n){let r=this.proxy,i=VB(e)?e.includes(`.`)?sU(r,e):()=>r[e]:e.bind(r,r),a;BB(t)?a=t:(a=t.handler,n=t);let o=nK(this),s=aU(i,a.bind(r),n);return o(),s}function sU(e,t){let n=t.split(`.`);return()=>{let t=e;for(let e=0;e<n.length&&t;e++)t=t[n[e]];return t}}var cU=new WeakMap,lU=Symbol(`_vte`),uU=e=>e.__isTeleport,dU=e=>e&&(e.disabled||e.disabled===``),fU=e=>e&&(e.defer||e.defer===``),pU=e=>typeof SVGElement<`u`&&e instanceof SVGElement,mU=e=>typeof MathMLElement==`function`&&e instanceof MathMLElement,hU=(e,t)=>{let n=e&&e.to;return VB(n)?t?t(n):null:n},gU={name:`Teleport`,__isTeleport:!0,process(e,t,n,r,i,a,o,s,c,l){let{mc:u,pc:d,pbc:f,o:{insert:p,querySelector:m,createText:h,createComment:g,parentNode:_}}=l,v=dU(t.props),{dynamicChildren:y}=t,b=(e,t,n)=>{e.shapeFlag&16&&u(e.children,t,n,i,a,o,s,c)},x=(e=t)=>{let n=dU(e.props),r=e.target=hU(e.props,m),a=xU(r,e,h,p);r&&(o!==`svg`&&pU(r)?o=`svg`:o!==`mathml`&&mU(r)&&(o=`mathml`),i&&i.isCE&&(i.ce._teleportTargets||(i.ce._teleportTargets=new Set)).add(r),n||(b(e,r,a),bU(e,!1)))},S=e=>{let t=()=>{if(cU.get(e)===t){if(cU.delete(e),dU(e.props)){let t=_(e.el)||n;b(e,t,e.anchor),bU(e,!0)}x(e)}};cU.set(e,t),dG(t,a)};if(e==null){let e=t.el=h(``),i=t.anchor=h(``);if(p(e,n,r),p(i,n,r),fU(t.props)||a&&a.pendingBranch){S(t);return}v&&(b(t,n,i),bU(t,!0)),x()}else{t.el=e.el;let r=t.anchor=e.anchor,u=cU.get(e);if(u){u.flags|=8,cU.delete(e),S(t);return}t.targetStart=e.targetStart;let p=t.target=e.target,h=t.targetAnchor=e.targetAnchor,g=dU(e.props),_=g?n:p,b=g?r:h;if(o===`svg`||pU(p)?o=`svg`:(o===`mathml`||mU(p))&&(o=`mathml`),y?(f(e.dynamicChildren,y,_,i,a,o,s),_G(e,t,!0)):c||d(e,t,_,b,i,a,o,s,!1),v)g?t.props&&e.props&&t.props.to!==e.props.to&&(t.props.to=e.props.to):_U(t,n,r,l,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){let e=hU(t.props,m);e&&(t.target=e,_U(t,e,null,l,0))}else g&&_U(t,p,h,l,1);bU(t,v)}},remove(e,t,n,{um:r,o:{remove:i}},a){let{shapeFlag:o,children:s,anchor:c,targetStart:l,targetAnchor:u,target:d,props:f}=e,p=dU(f),m=a||!p,h=cU.get(e);if(h&&(h.flags|=8,cU.delete(e)),d&&(i(l),i(u)),a&&i(c),!h&&(p||d)&&o&16)for(let e=0;e<s.length;e++){let i=s[e];r(i,t,n,m,!!i.dynamicChildren)}},move:_U,hydrate:vU};function _U(e,t,n,{o:{insert:r},m:i},a=2){a===0&&r(e.targetAnchor,t,n);let{el:o,anchor:s,shapeFlag:c,children:l,props:u}=e,d=a===2;if(d&&r(o,t,n),!cU.has(e)&&(!d||dU(u))&&c&16)for(let e=0;e<l.length;e++)i(l[e],t,n,2);d&&r(s,t,n)}function vU(e,t,n,r,i,a,{o:{nextSibling:o,parentNode:s,querySelector:c,insert:l,createText:u}},d){function f(e,n){let r=n;for(;r;){if(r&&r.nodeType===8){if(r.data===`teleport start anchor`)t.targetStart=r;else if(r.data===`teleport anchor`){t.targetAnchor=r,e._lpa=t.targetAnchor&&o(t.targetAnchor);break}}r=o(r)}}function p(e,t){t.anchor=d(o(e),t,s(e),n,r,i,a)}let m=t.target=hU(t.props,c),h=dU(t.props);if(m){let c=m._lpa||m.firstChild;t.shapeFlag&16&&(h?(p(e,t),f(m,c),t.targetAnchor||xU(m,t,u,l,s(e)===m?e:null)):(t.anchor=o(e),f(m,c),t.targetAnchor||xU(m,t,u,l),d(c&&o(c),t,m,n,r,i,a))),bU(t,h)}else h&&t.shapeFlag&16&&(p(e,t),t.targetStart=e,t.targetAnchor=o(e));return t.anchor&&o(t.anchor)}var yU=gU;function bU(e,t){let n=e.ctx;if(n&&n.ut){let r,i;for(t?(r=e.el,i=e.anchor):(r=e.targetStart,i=e.targetAnchor);r&&r!==i;)r.nodeType===1&&r.setAttribute(`data-v-owner`,n.uid),r=r.nextSibling;n.ut()}}function xU(e,t,n,r,i=null){let a=t.targetStart=n(``),o=t.targetAnchor=n(``);return a[lU]=o,e&&(r(a,e,i),r(o,e,i)),o}var SU=Symbol(`_leaveCb`),CU=Symbol(`_enterCb`);function wU(){let e={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return QU(()=>{e.isMounted=!0}),tW(()=>{e.isUnmounting=!0}),e}var TU=[Function,Array],EU={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:TU,onEnter:TU,onAfterEnter:TU,onEnterCancelled:TU,onBeforeLeave:TU,onLeave:TU,onAfterLeave:TU,onLeaveCancelled:TU,onBeforeAppear:TU,onAppear:TU,onAfterAppear:TU,onAppearCancelled:TU},DU=e=>{let t=e.subTree;return t.component?DU(t.component):t},OU={name:`BaseTransition`,props:EU,setup(e,{slots:t}){let n=$G(),r=wU();return()=>{let i=t.default&&IU(t.default(),!0),a=i&&i.length?kU(i):n.subTree?Q():void 0;if(!a)return;let o=mH(e),{mode:s}=o;if(r.isLeaving)return NU(a);let c=PU(a);if(!c)return NU(a);let l=MU(c,o,r,n,e=>l=e);c.type!==EG&&FU(c,l);let u=n.subTree&&PU(n.subTree);if(u&&u.type!==EG&&!IG(u,c)&&DU(n).type!==EG){let e=MU(u,o,r,n);if(FU(u,e),s===`out-in`&&c.type!==EG)return r.isLeaving=!0,e.afterLeave=()=>{r.isLeaving=!1,n.job.flags&8||n.update(),delete e.afterLeave,u=void 0},NU(a);s===`in-out`&&c.type!==EG?e.delayLeave=(e,t,n)=>{let i=jU(r,u);i[String(u.key)]=u,e[SU]=()=>{t(),e[SU]=void 0,delete l.delayedLeave,u=void 0},l.delayedLeave=()=>{n(),delete l.delayedLeave,u=void 0}}:u=void 0}else u&&=void 0;return a}}};function kU(e){let t=e[0];if(e.length>1){for(let n of e)if(n.type!==EG){t=n;break}}return t}var AU=OU;function jU(e,t){let{leavingVNodes:n}=e,r=n.get(t.type);return r||(r=Object.create(null),n.set(t.type,r)),r}function MU(e,t,n,r,i){let{appear:a,mode:o,persisted:s=!1,onBeforeEnter:c,onEnter:l,onAfterEnter:u,onEnterCancelled:d,onBeforeLeave:f,onLeave:p,onAfterLeave:m,onLeaveCancelled:h,onBeforeAppear:g,onAppear:_,onAfterAppear:v,onAppearCancelled:y}=t,b=String(e.key),x=jU(n,e),S=(e,t)=>{e&&kH(e,r,9,t)},C=(e,t)=>{let n=t[1];S(e,t),IB(e)?e.every(e=>e.length<=1)&&n():e.length<=1&&n()},w={mode:o,persisted:s,beforeEnter(t){let r=c;if(!n.isMounted)if(a)r=g||c;else return;t[SU]&&t[SU](!0);let i=x[b];i&&IG(e,i)&&i.el[SU]&&i.el[SU](),S(r,[t])},enter(t){if(x[b]===e)return;let r=l,i=u,o=d;if(!n.isMounted)if(a)r=_||l,i=v||u,o=y||d;else return;let s=!1;t[CU]=e=>{s||(s=!0,S(e?o:i,[t]),w.delayedLeave&&w.delayedLeave(),t[CU]=void 0)};let c=t[CU].bind(null,!1);r?C(r,[t,c]):c()},leave(t,r){let i=String(e.key);if(t[CU]&&t[CU](!0),n.isUnmounting)return r();S(f,[t]);let a=!1;t[SU]=n=>{a||(a=!0,r(),S(n?h:m,[t]),t[SU]=void 0,x[i]===e&&delete x[i])};let o=t[SU].bind(null,!1);x[i]=e,p?C(p,[t,o]):o()},clone(e){let a=MU(e,t,n,r,i);return i&&i(a),a}};return w}function NU(e){if(WU(e))return e=HG(e),e.children=null,e}function PU(e){if(!WU(e))return uU(e.type)&&e.children?kU(e.children):e;if(e.component)return e.component.subTree;let{shapeFlag:t,children:n}=e;if(n){if(t&16)return n[0];if(t&32&&BB(n.default))return n.default()}}function FU(e,t){e.shapeFlag&6&&e.component?(e.transition=t,FU(e.component.subTree,t)):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function IU(e,t=!1,n){let r=[],i=0;for(let a=0;a<e.length;a++){let o=e[a],s=n==null?o.key:String(n)+String(o.key==null?a:o.key);o.type===wG?(o.patchFlag&128&&i++,r=r.concat(IU(o.children,t,s))):(t||o.type!==EG)&&r.push(s==null?o:HG(o,{key:s}))}if(i>1)for(let e=0;e<r.length;e++)r[e].patchFlag=-2;return r}function LU(e,t){return BB(e)?NB({name:e.name},t,{setup:e}):e}function RU(e){e.ids=[e.ids[0]+e.ids[2]+++`-`,0,0]}function zU(e,t){let n;return!!((n=Object.getOwnPropertyDescriptor(e,t))&&!n.configurable)}var BU=new WeakMap;function VU(e,t,n,r,i=!1){if(IB(e)){e.forEach((e,a)=>VU(e,t&&(IB(t)?t[a]:t),n,r,i));return}if(UU(r)&&!i){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&VU(e,t,n,r.component.subTree);return}let a=r.shapeFlag&4?mK(r.component):r.el,o=i?null:a,{i:s,r:c}=e,l=t&&t.r,u=s.refs===DB?s.refs={}:s.refs,d=s.setupState,f=mH(d),p=d===DB?AB:e=>!zU(u,e)&&FB(f,e),m=(e,t)=>!(t&&zU(u,t));if(l!=null&&l!==c){if(HU(t),VB(l))u[l]=null,p(l)&&(d[l]=null);else if(_H(l)){let e=t;m(l,e.k)&&(l.value=null),e.k&&(u[e.k]=null)}}if(BB(c)){jV();try{OH(c,s,12,[o,u])}finally{MV()}}else{let t=VB(c),r=_H(c);if(t||r){let s=()=>{if(e.f){let n=t?p(c)?d[c]:u[c]:m(c)||!e.k?c.value:u[e.k];if(i)IB(n)&&PB(n,a);else if(IB(n))n.includes(a)||n.push(a);else if(t)u[c]=[a],p(c)&&(d[c]=u[c]);else{let t=[a];m(c,e.k)&&(c.value=t),e.k&&(u[e.k]=t)}}else t?(u[c]=o,p(c)&&(d[c]=o)):r&&(m(c,e.k)&&(c.value=o),e.k&&(u[e.k]=o))};if(o){let t=()=>{s(),BU.delete(e)};t.id=-1,BU.set(e,t),dG(t,n)}else HU(e),s()}}}function HU(e){let t=BU.get(e);t&&(t.flags|=8,BU.delete(e))}aV().requestIdleCallback,aV().cancelIdleCallback;var UU=e=>!!e.type.__asyncLoader,WU=e=>e.type.__isKeepAlive;function GU(e,t){qU(e,`a`,t)}function KU(e,t){qU(e,`da`,t)}function qU(e,t,n=QG){let r=e.__wdc||=()=>{let t=n;for(;t;){if(t.isDeactivated)return;t=t.parent}return e()};if(YU(t,r,n),n){let e=n.parent;for(;e&&e.parent;)WU(e.parent.vnode)&&JU(r,t,n,e),e=e.parent}}function JU(e,t,n,r){let i=YU(t,e,r,!0);nW(()=>{PB(r[t],i)},n)}function YU(e,t,n=QG,r=!1){if(n){let i=n[e]||(n[e]=[]),a=t.__weh||=(...r)=>{jV();let i=nK(n),a=kH(t,n,e,r);return i(),MV(),a};return r?i.unshift(a):i.push(a),a}}var XU=e=>(t,n=QG)=>{(!aK||e===`sp`)&&YU(e,(...e)=>t(...e),n)},ZU=XU(`bm`),QU=XU(`m`),$U=XU(`bu`),eW=XU(`u`),tW=XU(`bum`),nW=XU(`um`),rW=XU(`sp`),iW=XU(`rtg`),aW=XU(`rtc`);function oW(e,t=QG){YU(`ec`,e,t)}var sW=Symbol.for(`v-ndc`);function cW(e,t,n,r){let i,a=n&&n[r],o=IB(e);if(o||VB(e)){let n=o&&uH(e),r=!1,s=!1;n&&(r=!fH(e),s=dH(e),e=WV(e)),i=Array(e.length);for(let n=0,o=e.length;n<o;n++)i[n]=t(r?s?gH(hH(e[n])):hH(e[n]):e[n],n,void 0,a&&a[n])}else if(typeof e==`number`){i=Array(e);for(let n=0;n<e;n++)i[n]=t(n+1,n,void 0,a&&a[n])}else if(UB(e))if(e[Symbol.iterator])i=Array.from(e,(e,n)=>t(e,n,void 0,a&&a[n]));else{let n=Object.keys(e);i=Array(n.length);for(let r=0,o=n.length;r<o;r++){let o=n[r];i[r]=t(e[o],o,r,a&&a[r])}}else i=[];return n&&(n[r]=i),i}function lW(e,t,n={},r,i){if(JH.ce||JH.parent&&UU(JH.parent)&&JH.parent.ce){let e=Object.keys(n).length>0;return t!=="default"&&(n.name=t),Y(),PG(wG,null,[zG(`slot`,n,r&&r())],e?-2:64)}let a=e[t];a&&a._c&&(a._d=!1),Y();let o=a&&uW(a(n)),s=n.key||o&&o.key,c=PG(wG,{key:(s&&!HB(s)?s:`_${t}`)+(!o&&r?`_fb`:``)},o||(r?r():[]),o&&e._===1?64:-2);return!i&&c.scopeId&&(c.slotScopeIds=[c.scopeId+`-s`]),a&&a._c&&(a._d=!0),c}function uW(e){return e.some(e=>!FG(e)||!(e.type===EG||e.type===wG&&!uW(e.children)))?e:null}var dW=e=>e?iK(e)?mK(e):dW(e.parent):null,fW=NB(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>dW(e.parent),$root:e=>dW(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>xW(e),$forceUpdate:e=>e.f||=()=>{VH(e.update)},$nextTick:e=>e.n||=zH.bind(e.proxy),$watch:e=>oU.bind(e)}),pW=(e,t)=>e!==DB&&!e.__isScriptSetup&&FB(e,t),mW={get({_:e},t){if(t===`__v_skip`)return!0;let{ctx:n,setupState:r,data:i,props:a,accessCache:o,type:s,appContext:c}=e;if(t[0]!==`$`){let e=o[t];if(e!==void 0)switch(e){case 1:return r[t];case 2:return i[t];case 4:return n[t];case 3:return a[t]}else if(pW(r,t))return o[t]=1,r[t];else if(i!==DB&&FB(i,t))return o[t]=2,i[t];else if(FB(a,t))return o[t]=3,a[t];else if(n!==DB&&FB(n,t))return o[t]=4,n[t];else gW&&(o[t]=0)}let l=fW[t],u,d;if(l)return t===`$attrs`&&VV(e.attrs,`get`,``),l(e);if((u=s.__cssModules)&&(u=u[t]))return u;if(n!==DB&&FB(n,t))return o[t]=4,n[t];if(d=c.config.globalProperties,FB(d,t))return d[t]},set({_:e},t,n){let{data:r,setupState:i,ctx:a}=e;return pW(i,t)?(i[t]=n,!0):r!==DB&&FB(r,t)?(r[t]=n,!0):FB(e.props,t)||t[0]===`$`&&t.slice(1)in e?!1:(a[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:r,appContext:i,props:a,type:o}},s){let c;return!!(n[s]||e!==DB&&s[0]!==`$`&&FB(e,s)||pW(t,s)||FB(a,s)||FB(r,s)||FB(fW,s)||FB(i.config.globalProperties,s)||(c=o.__cssModules)&&c[s])},defineProperty(e,t,n){return n.get==null?FB(n,`value`)&&this.set(e,t,n.value,null):e._.accessCache[t]=0,Reflect.defineProperty(e,t,n)}};function hW(e){return IB(e)?e.reduce((e,t)=>(e[t]=null,e),{}):e}var gW=!0;function _W(e){let t=xW(e),n=e.proxy,r=e.ctx;gW=!1,t.beforeCreate&&yW(t.beforeCreate,e,`bc`);let{data:i,computed:a,methods:o,watch:s,provide:c,inject:l,created:u,beforeMount:d,mounted:f,beforeUpdate:p,updated:m,activated:h,deactivated:g,beforeDestroy:_,beforeUnmount:v,destroyed:y,unmounted:b,render:x,renderTracked:S,renderTriggered:C,errorCaptured:w,serverPrefetch:T,expose:ee,inheritAttrs:E,components:te,directives:ne,filters:D}=t;if(l&&vW(l,r,null),o)for(let e in o){let t=o[e];BB(t)&&(r[e]=t.bind(n))}if(i){let t=i.call(n,n);UB(t)&&(e.data=sH(t))}if(gW=!0,a)for(let e in a){let t=a[e],i=gK({get:BB(t)?t.bind(n,n):BB(t.get)?t.get.bind(n,n):kB,set:!BB(t)&&BB(t.set)?t.set.bind(n):kB});Object.defineProperty(r,e,{enumerable:!0,configurable:!0,get:()=>i.value,set:e=>i.value=e})}if(s)for(let e in s)bW(s[e],r,n,e);if(c){let e=BB(c)?c.call(n):c;Reflect.ownKeys(e).forEach(t=>{eU(t,e[t])})}u&&yW(u,e,`c`);function re(e,t){IB(t)?t.forEach(t=>e(t.bind(n))):t&&e(t.bind(n))}if(re(ZU,d),re(QU,f),re($U,p),re(eW,m),re(GU,h),re(KU,g),re(oW,w),re(aW,S),re(iW,C),re(tW,v),re(nW,b),re(rW,T),IB(ee))if(ee.length){let t=e.exposed||={};ee.forEach(e=>{Object.defineProperty(t,e,{get:()=>n[e],set:t=>n[e]=t,enumerable:!0})})}else e.exposed||={};x&&e.render===kB&&(e.render=x),E!=null&&(e.inheritAttrs=E),te&&(e.components=te),ne&&(e.directives=ne),T&&RU(e)}function vW(e,t,n=kB){IB(e)&&(e=EW(e));for(let n in e){let r=e[n],i;i=UB(r)?`default`in r?tU(r.from||n,r.default,!0):tU(r.from||n):tU(r),_H(i)?Object.defineProperty(t,n,{enumerable:!0,configurable:!0,get:()=>i.value,set:e=>i.value=e}):t[n]=i}}function yW(e,t,n){kH(IB(e)?e.map(e=>e.bind(t.proxy)):e.bind(t.proxy),t,n)}function bW(e,t,n,r){let i=r.includes(`.`)?sU(n,r):()=>n[r];if(VB(e)){let n=t[e];BB(n)&&iU(i,n)}else if(BB(e))iU(i,e.bind(n));else if(UB(e))if(IB(e))e.forEach(e=>bW(e,t,n,r));else{let r=BB(e.handler)?e.handler.bind(n):t[e.handler];BB(r)&&iU(i,r,e)}}function xW(e){let t=e.type,{mixins:n,extends:r}=t,{mixins:i,optionsCache:a,config:{optionMergeStrategies:o}}=e.appContext,s=a.get(t),c;return s?c=s:!i.length&&!n&&!r?c=t:(c={},i.length&&i.forEach(e=>SW(c,e,o,!0)),SW(c,t,o)),UB(t)&&a.set(t,c),c}function SW(e,t,n,r=!1){let{mixins:i,extends:a}=t;a&&SW(e,a,n,!0),i&&i.forEach(t=>SW(e,t,n,!0));for(let i in t)if(!(r&&i===`expose`)){let r=CW[i]||n&&n[i];e[i]=r?r(e[i],t[i]):t[i]}return e}var CW={data:wW,props:kW,emits:kW,methods:OW,computed:OW,beforeCreate:DW,created:DW,beforeMount:DW,mounted:DW,beforeUpdate:DW,updated:DW,beforeDestroy:DW,beforeUnmount:DW,destroyed:DW,unmounted:DW,activated:DW,deactivated:DW,errorCaptured:DW,serverPrefetch:DW,components:OW,directives:OW,watch:AW,provide:wW,inject:TW};function wW(e,t){return t?e?function(){return NB(BB(e)?e.call(this,this):e,BB(t)?t.call(this,this):t)}:t:e}function TW(e,t){return OW(EW(e),EW(t))}function EW(e){if(IB(e)){let t={};for(let n=0;n<e.length;n++)t[e[n]]=e[n];return t}return e}function DW(e,t){return e?[...new Set([].concat(e,t))]:t}function OW(e,t){return e?NB(Object.create(null),e,t):t}function kW(e,t){return e?IB(e)&&IB(t)?[...new Set([...e,...t])]:NB(Object.create(null),hW(e),hW(t??{})):t}function AW(e,t){if(!e)return t;if(!t)return e;let n=NB(Object.create(null),e);for(let r in t)n[r]=DW(e[r],t[r]);return n}function jW(){return{app:null,config:{isNativeTag:AB,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}var MW=0;function NW(e,t){return function(n,r=null){BB(n)||(n=NB({},n)),r!=null&&!UB(r)&&(r=null);let i=jW(),a=new WeakSet,o=[],s=!1,c=i.app={_uid:MW++,_component:n,_props:r,_container:null,_context:i,_instance:null,version:vK,get config(){return i.config},set config(e){},use(e,...t){return a.has(e)||(e&&BB(e.install)?(a.add(e),e.install(c,...t)):BB(e)&&(a.add(e),e(c,...t))),c},mixin(e){return i.mixins.includes(e)||i.mixins.push(e),c},component(e,t){return t?(i.components[e]=t,c):i.components[e]},directive(e,t){return t?(i.directives[e]=t,c):i.directives[e]},mount(a,o,l){if(!s){let u=c._ceVNode||zG(n,r);return u.appContext=i,l===!0?l=`svg`:l===!1&&(l=void 0),o&&t?t(u,a):e(u,a,l),s=!0,c._container=a,a.__vue_app__=c,mK(u.component)}},onUnmount(e){o.push(e)},unmount(){s&&(kH(o,c._instance,16),e(null,c._container),delete c._container.__vue_app__)},provide(e,t){return i.provides[e]=t,c},runWithContext(e){let t=PW;PW=c;try{return e()}finally{PW=t}}};return c}}var PW=null,FW=(e,t)=>t===`modelValue`||t===`model-value`?e.modelModifiers:e[`${t}Modifiers`]||e[`${ZB(t)}Modifiers`]||e[`${QB(t)}Modifiers`];function IW(e,t,...n){if(e.isUnmounted)return;let r=e.vnode.props||DB,i=n,a=t.startsWith(`update:`),o=a&&FW(r,t.slice(7));o&&(o.trim&&(i=n.map(e=>VB(e)?e.trim():e)),o.number&&(i=n.map(iV)));let s,c=r[s=eV(t)]||r[s=eV(ZB(t))];!c&&a&&(c=r[s=eV(QB(t))]),c&&kH(c,e,6,i);let l=r[s+`Once`];if(l){if(!e.emitted)e.emitted={};else if(e.emitted[s])return;e.emitted[s]=!0,kH(l,e,6,i)}}var LW=new WeakMap;function RW(e,t,n=!1){let r=n?LW:t.emitsCache,i=r.get(e);if(i!==void 0)return i;let a=e.emits,o={},s=!1;if(!BB(e)){let r=e=>{let n=RW(e,t,!0);n&&(s=!0,NB(o,n))};!n&&t.mixins.length&&t.mixins.forEach(r),e.extends&&r(e.extends),e.mixins&&e.mixins.forEach(r)}return!a&&!s?(UB(e)&&r.set(e,null),null):(IB(a)?a.forEach(e=>o[e]=null):NB(o,a),UB(e)&&r.set(e,o),o)}function zW(e,t){return!e||!jB(t)?!1:(t=t.slice(2),t=t===`Once`?t:t.replace(/Once$/,``),FB(e,t[0].toLowerCase()+t.slice(1))||FB(e,QB(t))||FB(e,t))}function BW(e){let{type:t,vnode:n,proxy:r,withProxy:i,propsOptions:[a],slots:o,attrs:s,emit:c,render:l,renderCache:u,props:d,data:f,setupState:p,ctx:m,inheritAttrs:h}=e,g=XH(e),_,v;try{if(n.shapeFlag&4){let e=i||r,t=e;_=WG(l.call(t,e,u,d,p,f,m)),v=s}else{let e=t;_=WG(e.length>1?e(d,{attrs:s,slots:o,emit:c}):e(d,null)),v=t.props?s:VW(s)}}catch(t){OG.length=0,AH(t,e,1),_=zG(EG)}let y=_;if(v&&h!==!1){let e=Object.keys(v),{shapeFlag:t}=y;e.length&&t&7&&(a&&e.some(MB)&&(v=HW(v,a)),y=HG(y,v,!1,!0))}return n.dirs&&(y=HG(y,null,!1,!0),y.dirs=y.dirs?y.dirs.concat(n.dirs):n.dirs),n.transition&&FU(y,n.transition),_=y,XH(g),_}var VW=e=>{let t;for(let n in e)(n===`class`||n===`style`||jB(n))&&((t||={})[n]=e[n]);return t},HW=(e,t)=>{let n={};for(let r in e)(!MB(r)||!(r.slice(9)in t))&&(n[r]=e[r]);return n};function UW(e,t,n){let{props:r,children:i,component:a}=e,{props:o,children:s,patchFlag:c}=t,l=a.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&c>=0){if(c&1024)return!0;if(c&16)return r?WW(r,o,l):!!o;if(c&8){let e=t.dynamicProps;for(let t=0;t<e.length;t++){let n=e[t];if(GW(o,r,n)&&!zW(l,n))return!0}}}else return(i||s)&&(!s||!s.$stable)?!0:r===o?!1:r?!o||WW(r,o,l):!!o;return!1}function WW(e,t,n){let r=Object.keys(t);if(r.length!==Object.keys(e).length)return!0;for(let i=0;i<r.length;i++){let a=r[i];if(GW(t,e,a)&&!zW(n,a))return!0}return!1}function GW(e,t,n){let r=e[n],i=t[n];return n===`style`&&UB(r)&&UB(i)?!uV(r,i):r!==i}function KW({vnode:e,parent:t,suspense:n},r){for(;t;){let n=t.subTree;if(n.suspense&&n.suspense.activeBranch===e&&(n.suspense.vnode.el=n.el=r,e=n),n===e)(e=t.vnode).el=r,t=t.parent;else break}n&&n.activeBranch===e&&(n.vnode.el=r)}var qW={},JW=()=>Object.create(qW),YW=e=>Object.getPrototypeOf(e)===qW;function XW(e,t,n,r=!1){let i={},a=JW();e.propsDefaults=Object.create(null),QW(e,t,i,a);for(let t in e.propsOptions[0])t in i||(i[t]=void 0);n?e.props=r?i:Nie(i):e.type.props?e.props=i:e.props=a,e.attrs=a}function ZW(e,t,n,r){let{props:i,attrs:a,vnode:{patchFlag:o}}=e,s=mH(i),[c]=e.propsOptions,l=!1;if((r||o>0)&&!(o&16)){if(o&8){let n=e.vnode.dynamicProps;for(let r=0;r<n.length;r++){let o=n[r];if(zW(e.emitsOptions,o))continue;let u=t[o];if(c)if(FB(a,o))u!==a[o]&&(a[o]=u,l=!0);else{let t=ZB(o);i[t]=$W(c,s,t,u,e,!1)}else u!==a[o]&&(a[o]=u,l=!0)}}}else{QW(e,t,i,a)&&(l=!0);let r;for(let a in s)(!t||!FB(t,a)&&((r=QB(a))===a||!FB(t,r)))&&(c?n&&(n[a]!==void 0||n[r]!==void 0)&&(i[a]=$W(c,s,a,void 0,e,!0)):delete i[a]);if(a!==s)for(let e in a)(!t||!FB(t,e))&&(delete a[e],l=!0)}l&&HV(e.attrs,`set`,``)}function QW(e,t,n,r){let[i,a]=e.propsOptions,o=!1,s;if(t)for(let c in t){if(YB(c))continue;let l=t[c],u;i&&FB(i,u=ZB(c))?!a||!a.includes(u)?n[u]=l:(s||={})[u]=l:zW(e.emitsOptions,c)||(!(c in r)||l!==r[c])&&(r[c]=l,o=!0)}if(a){let t=mH(n),r=s||DB;for(let o=0;o<a.length;o++){let s=a[o];n[s]=$W(i,t,s,r[s],e,!FB(r,s))}}return o}function $W(e,t,n,r,i,a){let o=e[n];if(o!=null){let e=FB(o,`default`);if(e&&r===void 0){let e=o.default;if(o.type!==Function&&!o.skipFactory&&BB(e)){let{propsDefaults:a}=i;if(n in a)r=a[n];else{let o=nK(i);r=a[n]=e.call(null,t),o()}}else r=e;i.ce&&i.ce._setProp(n,r)}o[0]&&(a&&!e?r=!1:o[1]&&(r===``||r===QB(n))&&(r=!0))}return r}var eG=new WeakMap;function tG(e,t,n=!1){let r=n?eG:t.propsCache,i=r.get(e);if(i)return i;let a=e.props,o={},s=[],c=!1;if(!BB(e)){let r=e=>{c=!0;let[n,r]=tG(e,t,!0);NB(o,n),r&&s.push(...r)};!n&&t.mixins.length&&t.mixins.forEach(r),e.extends&&r(e.extends),e.mixins&&e.mixins.forEach(r)}if(!a&&!c)return UB(e)&&r.set(e,OB),OB;if(IB(a))for(let e=0;e<a.length;e++){let t=ZB(a[e]);nG(t)&&(o[t]=DB)}else if(a)for(let e in a){let t=ZB(e);if(nG(t)){let n=a[e],r=o[t]=IB(n)||BB(n)?{type:n}:NB({},n),i=r.type,c=!1,l=!0;if(IB(i))for(let e=0;e<i.length;++e){let t=i[e],n=BB(t)&&t.name;if(n===`Boolean`){c=!0;break}else n===`String`&&(l=!1)}else c=BB(i)&&i.name===`Boolean`;r[0]=c,r[1]=l,(c||FB(r,`default`))&&s.push(t)}}let l=[o,s];return UB(e)&&r.set(e,l),l}function nG(e){return e[0]!==`$`&&!YB(e)}var rG=e=>e===`_`||e===`_ctx`||e===`$stable`,iG=e=>IB(e)?e.map(WG):[WG(e)],aG=(e,t,n)=>{if(t._n)return t;let r=ZH((...e)=>iG(t(...e)),n);return r._c=!1,r},oG=(e,t,n)=>{let r=e._ctx;for(let n in e){if(rG(n))continue;let i=e[n];if(BB(i))t[n]=aG(n,i,r);else if(i!=null){let e=iG(i);t[n]=()=>e}}},sG=(e,t)=>{let n=iG(t);e.slots.default=()=>n},cG=(e,t,n)=>{for(let r in t)(n||!rG(r))&&(e[r]=t[r])},lG=(e,t,n)=>{let r=e.slots=JW();if(e.vnode.shapeFlag&32){let e=t._;e?(cG(r,t,n),n&&rV(r,`_`,e,!0)):oG(t,r)}else t&&sG(e,t)},uG=(e,t,n)=>{let{vnode:r,slots:i}=e,a=!0,o=DB;if(r.shapeFlag&32){let e=t._;e?n&&e===1?a=!1:cG(i,t,n):(a=!t.$stable,oG(t,i)),o=t}else t&&(sG(e,t),o={default:1});if(a)for(let e in i)!rG(e)&&o[e]==null&&delete i[e]},dG=CG;function fG(e){return pG(e)}function pG(e,t){let n=aV();n.__VUE__=!0;let{insert:r,remove:i,patchProp:a,createElement:o,createText:s,createComment:c,setText:l,setElementText:u,parentNode:d,nextSibling:f,setScopeId:p=kB,insertStaticContent:m}=e,h=(e,t,n,r=null,i=null,a=null,o=void 0,s=null,c=!!t.dynamicChildren)=>{if(e===t)return;e&&!IG(e,t)&&(r=fe(e),A(e,i,a,!0),e=null),t.patchFlag===-2&&(c=!1,t.dynamicChildren=null);let{type:l,ref:u,shapeFlag:d}=t;switch(l){case TG:g(e,t,n,r);break;case EG:_(e,t,n,r);break;case DG:e??v(t,n,r,o);break;case wG:te(e,t,n,r,i,a,o,s,c);break;default:d&1?x(e,t,n,r,i,a,o,s,c):d&6?ne(e,t,n,r,i,a,o,s,c):(d&64||d&128)&&l.process(e,t,n,r,i,a,o,s,c,he)}u!=null&&i?VU(u,e&&e.ref,a,t||e,!t):u==null&&e&&e.ref!=null&&VU(e.ref,null,a,e,!0)},g=(e,t,n,i)=>{if(e==null)r(t.el=s(t.children),n,i);else{let n=t.el=e.el;t.children!==e.children&&l(n,t.children)}},_=(e,t,n,i)=>{e==null?r(t.el=c(t.children||``),n,i):t.el=e.el},v=(e,t,n,r)=>{[e.el,e.anchor]=m(e.children,t,n,r,e.el,e.anchor)},y=({el:e,anchor:t},n,i)=>{let a;for(;e&&e!==t;)a=f(e),r(e,n,i),e=a;r(t,n,i)},b=({el:e,anchor:t})=>{let n;for(;e&&e!==t;)n=f(e),i(e),e=n;i(t)},x=(e,t,n,r,i,a,o,s,c)=>{if(t.type===`svg`?o=`svg`:t.type===`math`&&(o=`mathml`),e==null)S(t,n,r,i,a,o,s,c);else{let n=e.el&&e.el._isVueCE?e.el:null;try{n&&n._beginPatch(),T(e,t,i,a,o,s,c)}finally{n&&n._endPatch()}}},S=(e,t,n,i,s,c,l,d)=>{let f,p,{props:m,shapeFlag:h,transition:g,dirs:_}=e;if(f=e.el=o(e.type,c,m&&m.is,m),h&8?u(f,e.children):h&16&&w(e.children,f,null,i,s,mG(e,c),l,d),_&&$H(e,null,i,`created`),C(f,e,e.scopeId,l,i),m){for(let e in m)e!==`value`&&!YB(e)&&a(f,e,null,m[e],c,i);`value`in m&&a(f,`value`,null,m.value,c),(p=m.onVnodeBeforeMount)&&JG(p,i,e)}_&&$H(e,null,i,`beforeMount`);let v=gG(s,g);v&&g.beforeEnter(f),r(f,t,n),((p=m&&m.onVnodeMounted)||v||_)&&dG(()=>{try{p&&JG(p,i,e),v&&g.enter(f),_&&$H(e,null,i,`mounted`)}finally{}},s)},C=(e,t,n,r,i)=>{if(n&&p(e,n),r)for(let t=0;t<r.length;t++)p(e,r[t]);if(i){let n=i.subTree;if(t===n||SG(n.type)&&(n.ssContent===t||n.ssFallback===t)){let t=i.vnode;C(e,t,t.scopeId,t.slotScopeIds,i.parent)}}},w=(e,t,n,r,i,a,o,s,c=0)=>{for(let l=c;l<e.length;l++){let c=e[l]=s?GG(e[l]):WG(e[l]);h(null,c,t,n,r,i,a,o,s)}},T=(e,t,n,r,i,o,s)=>{let c=t.el=e.el,{patchFlag:l,dynamicChildren:d,dirs:f}=t;l|=e.patchFlag&16;let p=e.props||DB,m=t.props||DB,h;if(n&&hG(n,!1),(h=m.onVnodeBeforeUpdate)&&JG(h,n,t,e),f&&$H(t,e,n,`beforeUpdate`),n&&hG(n,!0),d&&(!e.dynamicChildren||e.dynamicChildren.length!==d.length)&&(l=0,s=!1,d=null),(p.innerHTML&&m.innerHTML==null||p.textContent&&m.textContent==null)&&u(c,``),d?ee(e.dynamicChildren,d,c,n,r,mG(t,i),o):s||ae(e,t,c,null,n,r,mG(t,i),o,!1),l>0){if(l&16)E(c,p,m,n,i);else if(l&2&&p.class!==m.class&&a(c,`class`,null,m.class,i),l&4&&a(c,`style`,p.style,m.style,i),l&8){let e=t.dynamicProps;for(let t=0;t<e.length;t++){let r=e[t],o=p[r],s=m[r];(s!==o||r===`value`)&&a(c,r,o,s,i,n)}}l&1&&e.children!==t.children&&u(c,t.children)}else!s&&d==null&&E(c,p,m,n,i);((h=m.onVnodeUpdated)||f)&&dG(()=>{h&&JG(h,n,t,e),f&&$H(t,e,n,`updated`)},r)},ee=(e,t,n,r,i,a,o)=>{for(let s=0;s<t.length;s++){let c=e[s],l=t[s],u=c.el&&(c.type===wG||!IG(c,l)||c.shapeFlag&198)?d(c.el):n;h(c,l,u,null,r,i,a,o,!0)}},E=(e,t,n,r,i)=>{if(t!==n){if(t!==DB)for(let o in t)!YB(o)&&!(o in n)&&a(e,o,t[o],null,i,r);for(let o in n){if(YB(o))continue;let s=n[o],c=t[o];s!==c&&o!==`value`&&a(e,o,c,s,i,r)}`value`in n&&a(e,`value`,t.value,n.value,i)}},te=(e,t,n,i,a,o,c,l,u)=>{let d=t.el=e?e.el:s(``),f=t.anchor=e?e.anchor:s(``),{patchFlag:p,dynamicChildren:m,slotScopeIds:h}=t;h&&(l=l?l.concat(h):h),e==null?(r(d,n,i),r(f,n,i),w(t.children||[],n,f,a,o,c,l,u)):p>0&&p&64&&m&&e.dynamicChildren&&e.dynamicChildren.length===m.length?(ee(e.dynamicChildren,m,n,a,o,c,l),(t.key!=null||a&&t===a.subTree)&&_G(e,t,!0)):ae(e,t,n,f,a,o,c,l,u)},ne=(e,t,n,r,i,a,o,s,c)=>{t.slotScopeIds=s,e==null?t.shapeFlag&512?i.ctx.activate(t,n,r,o,c):D(t,n,r,i,a,o,c):re(e,t,c)},D=(e,t,n,r,i,a,o)=>{let s=e.component=ZG(e,r,i);if(WU(e)&&(s.ctx.renderer=he),oK(s,!1,o),s.asyncDep){if(i&&i.registerDep(s,O,o),!e.el){let r=s.subTree=zG(EG);_(null,r,t,n),e.placeholder=r.el}}else O(s,e,t,n,i,a,o)},re=(e,t,n)=>{let r=t.component=e.component;if(UW(e,t,n))if(r.asyncDep&&!r.asyncResolved){ie(r,t,n);return}else r.next=t,r.update();else t.el=e.el,r.vnode=t},O=(e,t,n,r,i,a,o)=>{let s=()=>{if(e.isMounted){let{next:t,bu:n,u:r,parent:s,vnode:c}=e;{let n=yG(e);if(n){t&&(t.el=c.el,ie(e,t,o)),n.asyncDep.then(()=>{dG(()=>{e.isUnmounted||l()},i)});return}}let u=t,f;hG(e,!1),t?(t.el=c.el,ie(e,t,o)):t=c,n&&nV(n),(f=t.props&&t.props.onVnodeBeforeUpdate)&&JG(f,s,t,c),hG(e,!0);let p=BW(e),m=e.subTree;e.subTree=p,h(m,p,d(m.el),fe(m),e,i,a),t.el=p.el,u===null&&KW(e,p.el),r&&dG(r,i),(f=t.props&&t.props.onVnodeUpdated)&&dG(()=>JG(f,s,t,c),i)}else{let o,{el:s,props:c}=t,{bm:l,m:u,parent:d,root:f,type:p}=e,m=UU(t);if(hG(e,!1),l&&nV(l),!m&&(o=c&&c.onVnodeBeforeMount)&&JG(o,d,t),hG(e,!0),s&&_e){let t=()=>{e.subTree=BW(e),_e(s,e.subTree,e,i,null)};m&&p.__asyncHydrate?p.__asyncHydrate(s,e,t):t()}else{f.ce&&f.ce._hasShadowRoot()&&f.ce._injectChildStyle(p,e.parent?e.parent.type:void 0);let o=e.subTree=BW(e);h(null,o,n,r,e,i,a),t.el=o.el}if(u&&dG(u,i),!m&&(o=c&&c.onVnodeMounted)){let e=t;dG(()=>JG(o,d,e),i)}(t.shapeFlag&256||d&&UU(d.vnode)&&d.vnode.shapeFlag&256)&&e.a&&dG(e.a,i),e.isMounted=!0,t=n=r=null}};e.scope.on();let c=e.effect=new _V(s);e.scope.off();let l=e.update=c.run.bind(c),u=e.job=c.runIfDirty.bind(c);u.i=e,u.id=e.uid,c.scheduler=()=>VH(u),hG(e,!0),l()},ie=(e,t,n)=>{t.component=e;let r=e.vnode.props;e.vnode=t,e.next=null,ZW(e,t.props,r,n),uG(e,t.children,n),jV(),WH(e),MV()},ae=(e,t,n,r,i,a,o,s,c=!1)=>{let l=e&&e.children,d=e?e.shapeFlag:0,f=t.children,{patchFlag:p,shapeFlag:m}=t;if(p>0){if(p&128){k(l,f,n,r,i,a,o,s,c);return}else if(p&256){oe(l,f,n,r,i,a,o,s,c);return}}m&8?(d&16&&de(l,i,a),f!==l&&u(n,f)):d&16?m&16?k(l,f,n,r,i,a,o,s,c):de(l,i,a,!0):(d&8&&u(n,``),m&16&&w(f,n,r,i,a,o,s,c))},oe=(e,t,n,r,i,a,o,s,c)=>{e||=OB,t||=OB;let l=e.length,u=t.length,d=Math.min(l,u),f;for(f=0;f<d;f++){let r=t[f]=c?GG(t[f]):WG(t[f]);h(e[f],r,n,null,i,a,o,s,c)}l>u?de(e,i,a,!0,!1,d):w(t,n,r,i,a,o,s,c,d)},k=(e,t,n,r,i,a,o,s,c)=>{let l=0,u=t.length,d=e.length-1,f=u-1;for(;l<=d&&l<=f;){let r=e[l],u=t[l]=c?GG(t[l]):WG(t[l]);if(IG(r,u))h(r,u,n,null,i,a,o,s,c);else break;l++}for(;l<=d&&l<=f;){let r=e[d],l=t[f]=c?GG(t[f]):WG(t[f]);if(IG(r,l))h(r,l,n,null,i,a,o,s,c);else break;d--,f--}if(l>d){if(l<=f){let e=f+1,d=e<u?t[e].el:r;for(;l<=f;)h(null,t[l]=c?GG(t[l]):WG(t[l]),n,d,i,a,o,s,c),l++}}else if(l>f)for(;l<=d;)A(e[l],i,a,!0),l++;else{let p=l,m=l,g=new Map;for(l=m;l<=f;l++){let e=t[l]=c?GG(t[l]):WG(t[l]);e.key!=null&&g.set(e.key,l)}let _,v=0,y=f-m+1,b=!1,x=0,S=Array(y);for(l=0;l<y;l++)S[l]=0;for(l=p;l<=d;l++){let r=e[l];if(v>=y){A(r,i,a,!0);continue}let u;if(r.key!=null)u=g.get(r.key);else for(_=m;_<=f;_++)if(S[_-m]===0&&IG(r,t[_])){u=_;break}u===void 0?A(r,i,a,!0):(S[u-m]=l+1,u>=x?x=u:b=!0,h(r,t[u],n,null,i,a,o,s,c),v++)}let C=b?vG(S):OB;for(_=C.length-1,l=y-1;l>=0;l--){let e=m+l,d=t[e],f=t[e+1],p=e+1<u?f.el||xG(f):r;S[l]===0?h(null,d,n,p,i,a,o,s,c):b&&(_<0||l!==C[_]?se(d,n,p,2):_--)}}},se=(e,t,n,a,o=null)=>{let{el:s,type:c,transition:l,children:u,shapeFlag:d}=e;if(d&6){se(e.component.subTree,t,n,a);return}if(d&128){e.suspense.move(t,n,a);return}if(d&64){c.move(e,t,n,he);return}if(c===wG){r(s,t,n);for(let e=0;e<u.length;e++)se(u[e],t,n,a);r(e.anchor,t,n);return}if(c===DG){y(e,t,n);return}if(a!==2&&d&1&&l)if(a===0)l.persisted&&!s[SU]?r(s,t,n):(l.beforeEnter(s),r(s,t,n),dG(()=>l.enter(s),o));else{let{leave:a,delayLeave:o,afterLeave:c}=l,u=()=>{e.ctx.isUnmounted?i(s):r(s,t,n)},d=()=>{let e=s._isLeaving||!!s[SU];s._isLeaving&&s[SU](!0),l.persisted&&!e?u():a(s,()=>{u(),c&&c()})};o?o(s,u,d):d()}else r(s,t,n)},A=(e,t,n,r=!1,i=!1)=>{let{type:a,props:o,ref:s,children:c,dynamicChildren:l,shapeFlag:u,patchFlag:d,dirs:f,cacheIndex:p,memo:m}=e;if(d===-2&&(i=!1),s!=null&&(jV(),VU(s,null,n,e,!0),MV()),p!=null&&(t.renderCache[p]=void 0),u&256){t.ctx.deactivate(e);return}let h=u&1&&f,g=!UU(e),_;if(g&&(_=o&&o.onVnodeBeforeUnmount)&&JG(_,t,e),u&6)ue(e.component,n,r);else{if(u&128){e.suspense.unmount(n,r);return}h&&$H(e,null,t,`beforeUnmount`),u&64?e.type.remove(e,t,n,he,r):l&&!l.hasOnce&&(a!==wG||d>0&&d&64)?de(l,t,n,!1,!0):(a===wG&&d&384||!i&&u&16)&&de(c,t,n),r&&ce(e)}let v=m!=null&&p==null;(g&&(_=o&&o.onVnodeUnmounted)||h||v)&&dG(()=>{_&&JG(_,t,e),h&&$H(e,null,t,`unmounted`),v&&(e.el=null)},n)},ce=e=>{let{type:t,el:n,anchor:r,transition:a}=e;if(t===wG){le(n,r);return}if(t===DG){b(e);return}let o=()=>{i(n),a&&!a.persisted&&a.afterLeave&&a.afterLeave()};if(e.shapeFlag&1&&a&&!a.persisted){let{leave:t,delayLeave:r}=a,i=()=>t(n,o);r?r(e.el,o,i):i()}else o()},le=(e,t)=>{let n;for(;e!==t;)n=f(e),i(e),e=n;i(t)},ue=(e,t,n)=>{let{bum:r,scope:i,job:a,subTree:o,um:s,m:c,a:l}=e;bG(c),bG(l),r&&nV(r),i.stop(),a&&(a.flags|=8,A(o,e,t,n)),s&&dG(s,t),dG(()=>{e.isUnmounted=!0},t)},de=(e,t,n,r=!1,i=!1,a=0)=>{for(let o=a;o<e.length;o++)A(e[o],t,n,r,i)},fe=e=>{if(e.shapeFlag&6)return fe(e.component.subTree);if(e.shapeFlag&128)return e.suspense.next();let t=f(e.anchor||e.el),n=t&&t[lU];return n?f(n):t},pe=!1,me=(e,t,n)=>{let r;e==null?t._vnode&&(A(t._vnode,null,null,!0),r=t._vnode.component):h(t._vnode||null,e,t,null,null,null,n),t._vnode=e,pe||=(pe=!0,WH(r),GH(),!1)},he={p:h,um:A,m:se,r:ce,mt:D,mc:w,pc:ae,pbc:ee,n:fe,o:e},ge,_e;return t&&([ge,_e]=t(he)),{render:me,hydrate:ge,createApp:NW(me,ge)}}function mG({type:e,props:t},n){return n===`svg`&&e===`foreignObject`||n===`mathml`&&e===`annotation-xml`&&t&&t.encoding&&t.encoding.includes(`html`)?void 0:n}function hG({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function gG(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function _G(e,t,n=!1){let r=e.children,i=t.children;if(IB(r)&&IB(i))for(let e=0;e<r.length;e++){let t=r[e],a=i[e];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=i[e]=GG(i[e]),a.el=t.el),!n&&a.patchFlag!==-2&&_G(t,a)),a.type===TG&&(a.patchFlag===-1&&(a=i[e]=GG(a)),a.el=t.el),a.type===EG&&!a.el&&(a.el=t.el)}}function vG(e){let t=e.slice(),n=[0],r,i,a,o,s,c=e.length;for(r=0;r<c;r++){let c=e[r];if(c!==0){if(i=n[n.length-1],e[i]<c){t[r]=i,n.push(r);continue}for(a=0,o=n.length-1;a<o;)s=a+o>>1,e[n[s]]<c?a=s+1:o=s;c<e[n[a]]&&(a>0&&(t[r]=n[a-1]),n[a]=r)}}for(a=n.length,o=n[a-1];a-->0;)n[a]=o,o=t[o];return n}function yG(e){let t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:yG(t)}function bG(e){if(e)for(let t=0;t<e.length;t++)e[t].flags|=8}function xG(e){if(e.placeholder)return e.placeholder;let t=e.component;return t?xG(t.subTree):null}var SG=e=>e.__isSuspense;function CG(e,t){t&&t.pendingBranch?IB(e)?t.effects.push(...e):t.effects.push(e):UH(e)}var wG=Symbol.for(`v-fgt`),TG=Symbol.for(`v-txt`),EG=Symbol.for(`v-cmt`),DG=Symbol.for(`v-stc`),OG=[],kG=null;function Y(e=!1){OG.push(kG=e?null:[])}function AG(){OG.pop(),kG=OG[OG.length-1]||null}var jG=1;function MG(e,t=!1){jG+=e,e<0&&kG&&t&&(kG.hasOnce=!0)}function NG(e){return e.dynamicChildren=jG>0?kG||OB:null,AG(),jG>0&&kG&&kG.push(e),e}function X(e,t,n,r,i,a){return NG(Z(e,t,n,r,i,a,!0))}function PG(e,t,n,r,i){return NG(zG(e,t,n,r,i,!0))}function FG(e){return e?e.__v_isVNode===!0:!1}function IG(e,t){return e.type===t.type&&e.key===t.key}var LG=({key:e})=>e??null,RG=({ref:e,ref_key:t,ref_for:n})=>(typeof e==`number`&&(e=``+e),e==null?null:VB(e)||_H(e)||BB(e)?{i:JH,r:e,k:t,f:!!n}:e);function Z(e,t=null,n=null,r=0,i=null,a=e===wG?0:1,o=!1,s=!1){let c={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&LG(t),ref:t&&RG(t),scopeId:YH,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:a,patchFlag:r,dynamicProps:i,dynamicChildren:null,appContext:null,ctx:JH};return s?(KG(c,n),a&128&&e.normalize(c)):n&&(c.shapeFlag|=VB(n)?8:16),jG>0&&!o&&kG&&(c.patchFlag>0||a&6)&&c.patchFlag!==32&&kG.push(c),c}var zG=BG;function BG(e,t=null,n=null,r=0,i=null,a=!1){if((!e||e===sW)&&(e=EG),FG(e)){let r=HG(e,t,!0);return n&&KG(r,n),jG>0&&!a&&kG&&(r.shapeFlag&6?kG[kG.indexOf(e)]=r:kG.push(r)),r.patchFlag=-2,r}if(hK(e)&&(e=e.__vccOpts),t){t=VG(t);let{class:e,style:n}=t;e&&!VB(e)&&(t.class=sV(e)),UB(n)&&(pH(n)&&!IB(n)&&(n=NB({},n)),t.style=oV(n))}let o=VB(e)?1:SG(e)?128:uU(e)?64:UB(e)?4:BB(e)?2:0;return Z(e,t,n,r,i,o,a,!0)}function VG(e){return e?pH(e)||YW(e)?NB({},e):e:null}function HG(e,t,n=!1,r=!1){let{props:i,ref:a,patchFlag:o,children:s,transition:c}=e,l=t?qG(i||{},t):i,u={__v_isVNode:!0,__v_skip:!0,type:e.type,props:l,key:l&&LG(l),ref:t&&t.ref?n&&a?IB(a)?a.concat(RG(t)):[a,RG(t)]:RG(t):a,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:s,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==wG?o===-1?16:o|16:o,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:c,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&HG(e.ssContent),ssFallback:e.ssFallback&&HG(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return c&&r&&FU(u,c.clone(u)),u}function UG(e=` `,t=0){return zG(TG,null,e,t)}function Q(e=``,t=!1){return t?(Y(),PG(EG,null,e)):zG(EG,null,e)}function WG(e){return e==null||typeof e==`boolean`?zG(EG):IB(e)?zG(wG,null,e.slice()):FG(e)?GG(e):zG(TG,null,String(e))}function GG(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:HG(e)}function KG(e,t){let n=0,{shapeFlag:r}=e;if(t==null)t=null;else if(IB(t))n=16;else if(typeof t==`object`)if(r&65){let n=t.default;n&&(n._c&&(n._d=!1),KG(e,n()),n._c&&(n._d=!0));return}else{n=32;let r=t._;!r&&!YW(t)?t._ctx=JH:r===3&&JH&&(JH.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else if(BB(t)){if(r&65){KG(e,{default:t});return}t={default:t,_ctx:JH},n=32}else t=String(t),r&64?(n=16,t=[UG(t)]):n=8;e.children=t,e.shapeFlag|=n}function qG(...e){let t={};for(let n=0;n<e.length;n++){let r=e[n];for(let e in r)if(e===`class`)t.class!==r.class&&(t.class=sV([t.class,r.class]));else if(e===`style`)t.style=oV([t.style,r.style]);else if(jB(e)){let n=t[e],i=r[e];i&&n!==i&&!(IB(n)&&n.includes(i))?t[e]=n?[].concat(n,i):i:i==null&&n==null&&!MB(e)&&(t[e]=i)}else e!==``&&(t[e]=r[e])}return t}function JG(e,t,n,r=null){kH(e,t,7,[n,r])}var YG=jW(),XG=0;function ZG(e,t,n){let r=e.type,i=(t?t.appContext:e.appContext)||YG,a={uid:XG++,vnode:e,type:r,parent:t,appContext:i,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new pie(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:t?t.provides:Object.create(i.provides),ids:t?t.ids:[``,0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:tG(r,i),emitsOptions:RW(r,i),emit:null,emitted:null,propsDefaults:DB,inheritAttrs:r.inheritAttrs,ctx:DB,data:DB,props:DB,attrs:DB,slots:DB,refs:DB,setupState:DB,setupContext:null,suspense:n,suspenseId:n?n.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return a.ctx={_:a},a.root=t?t.root:a,a.emit=IW.bind(null,a),e.ce&&e.ce(a),a}var QG=null,$G=()=>QG||JH,eK,tK;{let e=aV(),t=(t,n)=>{let r;return(r=e[t])||(r=e[t]=[]),r.push(n),e=>{r.length>1?r.forEach(t=>t(e)):r[0](e)}};eK=t(`__VUE_INSTANCE_SETTERS__`,e=>QG=e),tK=t(`__VUE_SSR_SETTERS__`,e=>aK=e)}var nK=e=>{let t=QG;return eK(e),e.scope.on(),()=>{e.scope.off(),eK(t)}},rK=()=>{QG&&QG.scope.off(),eK(null)};function iK(e){return e.vnode.shapeFlag&4}var aK=!1;function oK(e,t=!1,n=!1){t&&tK(t);let{props:r,children:i}=e.vnode,a=iK(e);XW(e,r,a,t),lG(e,i,n||t);let o=a?sK(e,t):void 0;return t&&tK(!1),o}function sK(e,t){let n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,mW);let{setup:r}=n;if(r){jV();let n=e.setupContext=r.length>1?pK(e):null,i=nK(e),a=OH(r,e,0,[e.props,n]),o=WB(a);if(MV(),i(),(o||e.sp)&&!UU(e)&&RU(e),o){if(a.then(rK,rK),t)return a.then(n=>{cK(e,n,t)}).catch(t=>{AH(t,e,0)});e.asyncDep=a}else cK(e,a,t)}else dK(e,t)}function cK(e,t,n){BB(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:UB(t)&&(e.setupState=SH(t)),dK(e,n)}var lK,uK;function dK(e,t,n){let r=e.type;if(!e.render){if(!t&&lK&&!r.render){let t=r.template||xW(e).template;if(t){let{isCustomElement:n,compilerOptions:i}=e.appContext.config,{delimiters:a,compilerOptions:o}=r;r.render=lK(t,NB(NB({isCustomElement:n,delimiters:a},i),o))}}e.render=r.render||kB,uK&&uK(e)}{let t=nK(e);jV();try{_W(e)}finally{MV(),t()}}}var fK={get(e,t){return VV(e,`get`,``),e[t]}};function pK(e){return{attrs:new Proxy(e.attrs,fK),slots:e.slots,emit:e.emit,expose:t=>{e.exposed=t||{}}}}function mK(e){return e.exposed?e.exposeProxy||=new Proxy(SH(Pie(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in fW)return fW[n](e)},has(e,t){return t in e||t in fW}}):e.proxy}function hK(e){return BB(e)&&`__vccOpts`in e}var gK=(e,t)=>Rie(e,t,aK);function _K(e,t,n){try{MG(-1);let r=arguments.length;return r===2?UB(t)&&!IB(t)?FG(t)?zG(e,null,[t]):zG(e,t):zG(e,null,t):(r>3?n=Array.prototype.slice.call(arguments,2):r===3&&FG(n)&&(n=[n]),zG(e,t,n))}finally{MG(1)}}var vK=`3.5.39`,yK=void 0,bK=typeof window<`u`&&window.trustedTypes;if(bK)try{yK=bK.createPolicy(`vue`,{createHTML:e=>e})}catch{}var xK=yK?e=>yK.createHTML(e):e=>e,SK=`http://www.w3.org/2000/svg`,CK=`http://www.w3.org/1998/Math/MathML`,wK=typeof document<`u`?document:null,TK=wK&&wK.createElement(`template`),EK={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{let t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{let i=t===`svg`?wK.createElementNS(SK,e):t===`mathml`?wK.createElementNS(CK,e):n?wK.createElement(e,{is:n}):wK.createElement(e);return e===`select`&&r&&r.multiple!=null&&i.setAttribute(`multiple`,r.multiple),i},createText:e=>wK.createTextNode(e),createComment:e=>wK.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>wK.querySelector(e),setScopeId(e,t){e.setAttribute(t,``)},insertStaticContent(e,t,n,r,i,a){let o=n?n.previousSibling:t.lastChild;if(i&&(i===a||i.nextSibling))for(;t.insertBefore(i.cloneNode(!0),n),!(i===a||!(i=i.nextSibling)););else{TK.innerHTML=xK(r===`svg`?`<svg>${e}</svg>`:r===`mathml`?`<math>${e}</math>`:e);let i=TK.content;if(r===`svg`||r===`mathml`){let e=i.firstChild;for(;e.firstChild;)i.appendChild(e.firstChild);i.removeChild(e)}t.insertBefore(i,n)}return[o?o.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},DK=`transition`,OK=`animation`,kK=Symbol(`_vtc`),AK={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},jK=NB({},EU,AK),MK=(e=>(e.displayName=`Transition`,e.props=jK,e))((e,{slots:t})=>_K(AU,FK(e),t)),NK=(e,t=[])=>{IB(e)?e.forEach(e=>e(...t)):e&&e(...t)},PK=e=>e?IB(e)?e.some(e=>e.length>1):e.length>1:!1;function FK(e){let t={};for(let n in e)n in AK||(t[n]=e[n]);if(e.css===!1)return t;let{name:n=`v`,type:r,duration:i,enterFromClass:a=`${n}-enter-from`,enterActiveClass:o=`${n}-enter-active`,enterToClass:s=`${n}-enter-to`,appearFromClass:c=a,appearActiveClass:l=o,appearToClass:u=s,leaveFromClass:d=`${n}-leave-from`,leaveActiveClass:f=`${n}-leave-active`,leaveToClass:p=`${n}-leave-to`}=e,m=IK(i),h=m&&m[0],g=m&&m[1],{onBeforeEnter:_,onEnter:v,onEnterCancelled:y,onLeave:b,onLeaveCancelled:x,onBeforeAppear:S=_,onAppear:C=v,onAppearCancelled:w=y}=t,T=(e,t,n,r)=>{e._enterCancelled=r,zK(e,t?u:s),zK(e,t?l:o),n&&n()},ee=(e,t)=>{e._isLeaving=!1,zK(e,d),zK(e,p),zK(e,f),t&&t()},E=e=>(t,n)=>{let i=e?C:v,o=()=>T(t,e,n);NK(i,[t,o]),BK(()=>{zK(t,e?c:a),RK(t,e?u:s),PK(i)||HK(t,r,h,o)})};return NB(t,{onBeforeEnter(e){NK(_,[e]),RK(e,a),RK(e,o)},onBeforeAppear(e){NK(S,[e]),RK(e,c),RK(e,l)},onEnter:E(!1),onAppear:E(!0),onLeave(e,t){e._isLeaving=!0;let n=()=>ee(e,t);RK(e,d),e._enterCancelled?(RK(e,f),KK(e)):(KK(e),RK(e,f)),BK(()=>{e._isLeaving&&(zK(e,d),RK(e,p),PK(b)||HK(e,r,g,n))}),NK(b,[e,n])},onEnterCancelled(e){T(e,!1,void 0,!0),NK(y,[e])},onAppearCancelled(e){T(e,!0,void 0,!0),NK(w,[e])},onLeaveCancelled(e){ee(e),NK(x,[e])}})}function IK(e){if(e==null)return null;if(UB(e))return[LK(e.enter),LK(e.leave)];{let t=LK(e);return[t,t]}}function LK(e){return aie(e)}function RK(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.add(t)),(e[kK]||(e[kK]=new Set)).add(t)}function zK(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.remove(t));let n=e[kK];n&&(n.delete(t),n.size||(e[kK]=void 0))}function BK(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}var VK=0;function HK(e,t,n,r){let i=e._endId=++VK,a=()=>{i===e._endId&&r()};if(n!=null)return setTimeout(a,n);let{type:o,timeout:s,propCount:c}=UK(e,t);if(!o)return r();let l=o+`end`,u=0,d=()=>{e.removeEventListener(l,f),a()},f=t=>{t.target===e&&++u>=c&&d()};setTimeout(()=>{u<c&&d()},s+1),e.addEventListener(l,f)}function UK(e,t){let n=window.getComputedStyle(e),r=e=>(n[e]||``).split(`, `),i=r(`${DK}Delay`),a=r(`${DK}Duration`),o=WK(i,a),s=r(`${OK}Delay`),c=r(`${OK}Duration`),l=WK(s,c),u=null,d=0,f=0;t===DK?o>0&&(u=DK,d=o,f=a.length):t===OK?l>0&&(u=OK,d=l,f=c.length):(d=Math.max(o,l),u=d>0?o>l?DK:OK:null,f=u?u===DK?a.length:c.length:0);let p=u===DK&&/\b(?:transform|all)(?:,|$)/.test(r(`${DK}Property`).toString());return{type:u,timeout:d,propCount:f,hasTransform:p}}function WK(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map((t,n)=>GK(t)+GK(e[n])))}function GK(e){return e===`auto`?0:Number(e.slice(0,-1).replace(`,`,`.`))*1e3}function KK(e){return(e?e.ownerDocument:document).body.offsetHeight}function qK(e,t,n){let r=e[kK];r&&(t=(t?[t,...r]:[...r]).join(` `)),t==null?e.removeAttribute(`class`):n?e.setAttribute(`class`,t):e.className=t}var JK=Symbol(`_vod`),YK=Symbol(`_vsh`),XK={name:`show`,beforeMount(e,{value:t},{transition:n}){e[JK]=e.style.display===`none`?``:e.style.display,n&&t?n.beforeEnter(e):ZK(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:r}){!t!=!n&&(r?t?(r.beforeEnter(e),ZK(e,!0),r.enter(e)):r.leave(e,()=>{ZK(e,!1)}):ZK(e,t))},beforeUnmount(e,{value:t}){ZK(e,t)}};function ZK(e,t){e.style.display=t?e[JK]:`none`,e[YK]=!t}var QK=Symbol(``),$K=/(?:^|;)\s*display\s*:/;function eq(e,t,n){let r=e.style,i=VB(n),a=!1;if(n&&!i){if(t)if(VB(t))for(let e of t.split(`;`)){let t=e.slice(0,e.indexOf(`:`)).trim();n[t]??nq(r,t,``)}else for(let e in t)n[e]??nq(r,e,``);for(let i in n){i===`display`&&(a=!0);let o=n[i];o==null?nq(r,i,``):oq(e,i,!VB(t)&&t?t[i]:void 0,o)||nq(r,i,o)}}else if(i){if(t!==n){let e=r[QK];e&&(n+=`;`+e),r.cssText=n,a=$K.test(n)}}else t&&e.removeAttribute(`style`);JK in e&&(e[JK]=a?r.display:``,e[YK]&&(r.display=`none`))}var tq=/\s*!important$/;function nq(e,t,n){if(IB(n))n.forEach(n=>nq(e,t,n));else if(n??=``,t.startsWith(`--`))e.setProperty(t,n);else{let r=aq(e,t);tq.test(n)?e.setProperty(QB(r),n.replace(tq,``),`important`):e[r]=n}}var rq=[`Webkit`,`Moz`,`ms`],iq={};function aq(e,t){let n=iq[t];if(n)return n;let r=ZB(t);if(r!==`filter`&&r in e)return iq[t]=r;r=$B(r);for(let n=0;n<rq.length;n++){let i=rq[n]+r;if(i in e)return iq[t]=i}return t}function oq(e,t,n,r){return e.tagName===`TEXTAREA`&&(t===`width`||t===`height`)&&VB(r)&&n===r}var sq=`http://www.w3.org/1999/xlink`;function cq(e,t,n,r,i,a=die(t)){r&&t.startsWith(`xlink:`)?n==null?e.removeAttributeNS(sq,t.slice(6,t.length)):e.setAttributeNS(sq,t,n):n==null||a&&!lV(n)?e.removeAttribute(t):e.setAttribute(t,a?``:HB(n)?String(n):n)}function lq(e,t,n,r,i){if(t===`innerHTML`||t===`textContent`){n!=null&&(e[t]=t===`innerHTML`?xK(n):n);return}let a=e.tagName;if(t===`value`&&a!==`PROGRESS`&&!a.includes(`-`)){let r=a===`OPTION`?e.getAttribute(`value`)||``:e.value,i=n==null?e.type===`checkbox`?`on`:``:String(n);(r!==i||!(`_value`in e))&&(e.value=i),n??e.removeAttribute(t),e._value=n;return}let o=!1;if(n===``||n==null){let r=typeof e[t];r===`boolean`?n=lV(n):n==null&&r===`string`?(n=``,o=!0):r===`number`&&(n=0,o=!0)}try{e[t]=n}catch{}o&&e.removeAttribute(i||t)}function uq(e,t,n,r){e.addEventListener(t,n,r)}function dq(e,t,n,r){e.removeEventListener(t,n,r)}var fq=Symbol(`_vei`);function pq(e,t,n,r,i=null){let a=e[fq]||(e[fq]={}),o=a[t];if(r&&o)o.value=r;else{let[n,s]=gq(t);r?uq(e,n,a[t]=bq(r,i),s):o&&(dq(e,n,o,s),a[t]=void 0)}}var mq=/(Once|Passive|Capture)$/,hq=/^on:?(?:Once|Passive|Capture)$/;function gq(e){let t,n;for(;(n=e.match(mq))&&!hq.test(e);)t||={},e=e.slice(0,e.length-n[1].length),t[n[1].toLowerCase()]=!0;return[e[2]===`:`?e.slice(3):QB(e.slice(2)),t]}var _q=0,vq=Promise.resolve(),yq=()=>_q||=(vq.then(()=>_q=0),Date.now());function bq(e,t){let n=e=>{if(!e._vts)e._vts=Date.now();else if(e._vts<=n.attached)return;let r=n.value;if(IB(r)){let n=e.stopImmediatePropagation;e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0};let i=r.slice(),a=[e];for(let n=0;n<i.length&&!e._stopped;n++){let e=i[n];e&&kH(e,t,5,a)}}else kH(r,t,5,[e])};return n.value=e,n.attached=yq(),n}var xq=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,Sq=(e,t,n,r,i,a)=>{let o=i===`svg`;t===`class`?qK(e,r,o):t===`style`?eq(e,n,r):jB(t)?MB(t)||pq(e,t,n,r,a):(t[0]===`.`?(t=t.slice(1),!0):t[0]===`^`?(t=t.slice(1),!1):Cq(e,t,r,o))?(lq(e,t,r),!e.tagName.includes(`-`)&&(t===`value`||t===`checked`||t===`selected`)&&cq(e,t,r,o,a,t!==`value`)):e._isVueCE&&(wq(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!VB(r)))?lq(e,ZB(t),r,a,t):(t===`true-value`?e._trueValue=r:t===`false-value`&&(e._falseValue=r),cq(e,t,r,o))};function Cq(e,t,n,r){if(r)return!!(t===`innerHTML`||t===`textContent`||t in e&&xq(t)&&BB(n));if(t===`spellcheck`||t===`draggable`||t===`translate`||t===`autocorrect`||t===`sandbox`&&e.tagName===`IFRAME`||t===`form`||t===`list`&&e.tagName===`INPUT`||t===`type`&&e.tagName===`TEXTAREA`)return!1;if(t===`width`||t===`height`){let t=e.tagName;if(t===`IMG`||t===`VIDEO`||t===`CANVAS`||t===`SOURCE`)return!1}return xq(t)&&VB(n)?!1:t in e}function wq(e,t){let n=e._def.props;if(!n)return!1;let r=ZB(t);return Array.isArray(n)?n.some(e=>ZB(e)===r):Object.keys(n).some(e=>ZB(e)===r)}var Tq=e=>{let t=e.props[`onUpdate:modelValue`]||!1;return IB(t)?e=>nV(t,e):t};function Eq(e){e.target.composing=!0}function Dq(e){let t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event(`input`)))}var Oq=Symbol(`_assign`);function kq(e,t,n){return t&&(e=e.trim()),n&&(e=iV(e)),e}var Aq={created(e,{modifiers:{lazy:t,trim:n,number:r}},i){e[Oq]=Tq(i);let a=r||i.props&&i.props.type===`number`;uq(e,t?`change`:`input`,t=>{t.target.composing||e[Oq](kq(e.value,n,a))}),(n||a)&&uq(e,`change`,()=>{e.value=kq(e.value,n,a)}),t||(uq(e,`compositionstart`,Eq),uq(e,`compositionend`,Dq),uq(e,`change`,Dq))},mounted(e,{value:t}){e.value=t??``},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Oq]=Tq(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?iV(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},jq=[`ctrl`,`shift`,`alt`,`meta`],Mq={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>jq.some(n=>e[`${n}Key`]&&!t.includes(n))},Nq=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=Mq[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},Pq={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},Fq=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=QB(n.key);if(t.some(e=>e===r||Pq[e]===r))return e(n)}))},Iq=NB({patchProp:Sq},EK),Lq;function Rq(){return Lq||=fG(Iq)}var zq=((...e)=>{let t=Rq().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Vq(e);if(!r)return;let i=t._component;!BB(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,Bq(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t});function Bq(e){if(e instanceof SVGElement)return`svg`;if(typeof MathMLElement==`function`&&e instanceof MathMLElement)return`mathml`}function Vq(e){return VB(e)?document.querySelector(e):e}function $(e){let t={error:e.code,message:e.message};return e.path!==void 0&&(t.path=e.path),e.hint&&(t.hint=e.hint),e.details!==void 0&&(t.details=e.details),`ERROR: ${JSON.stringify(t)}`}function Hq(e){return e.slice(0,10).map(e=>{let t=e,n={path:(Array.isArray(t.path)?t.path.join(`.`):String(t.path??``))||`(root)`,message:t.message};return t.expected!==void 0&&(n.expected=t.expected),t.received!==void 0&&(n.received=t.received),t.code!==void 0&&(n.code=t.code),n})}function Uq(e,t){return $({code:`SCHEMA_INVALID`,path:e,message:`值不符合 "${e}" 的 schema(${t.length} 处问题)`,hint:`用 read({jsonPath:"${e}"}) 查看当前值,按 describe_data() 查看主数据 schema,修正后重试;改大对象优先用 write 的 patch 增量(只发改动部分)`,details:Hq(t)})}function Wq(e,t,n){let r=n?.message||String(n),i=typeof t==`string`?t:JSON.stringify(t);return $({code:`JSON_PARSE`,...e===void 0?{}:{path:e},message:`value 不是合法 JSON:${r}`,hint:`检查引号/逗号/括号是否闭合;字符串值需双引号包裹(如 '"dark"' 表示字符串 dark,数字直接写如 5);预览前 80 字符:${i.slice(0,80)}`})}function Gq(e){return e.severity===`recoverable`?`feedback`:e.severity===`fatal`?`abort`:`log`}function Kq(e,t=`fatal`){return e&&typeof e==`object`&&`severity`in e&&typeof e.severity==`string`&&`message`in e?e:{severity:t,message:e instanceof Error?e.message:String(e),context:e}}function qq(e,t,n,r){return{severity:e,message:t,code:n,context:r}}function Jq(e){return e.replace(/^\/+/,``).replace(/\/+/g,`/`)}function Yq(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return(t>>>0).toString(36)}function Xq(e,t){let n=t.threshold??6e3;if(e.length<=n)return{content:e};if(t.vfsAvailable&&t.files){let n=`large_results/${t.toolName}-${Yq(e)}.txt`,r=Jq(n);t.files[r]={content:e,updatedAt:Date.now()};let i=e.slice(0,1e3),a=e.length,o=a>1e4?`结果较大(共 ${a} 字符),建议分页读取:vfs_read({ path: "${n}", offset: 0, limit: 100 }) 起步,按需 offset += 100 续读,或 vfs_grep({ pattern, path: "${n}" }) 局部检索`:void 0;return{offloaded:!0,content:[i,`…[结果过大(共 ${a} 字符),已转存到虚拟工作区:${n}]`,`需要完整或局部数据时:用 vfs_read({ path: "${n}", offset, limit }) 分页回读,或 vfs_grep({ pattern, path: "${n}" }) 局部检索。`,...o?[o]:[]].join(`
149
149
  `),path:n,totalChars:a,preview:i,suggestedReadPlan:o}}let r=t.passThroughChars??n;return e.length<=r?{content:e}:{offloaded:!1,content:e.slice(0,r)+`\n…[结果过大(共 ${e.length} 字符),vfs 未启用无法外存,已截断,仅显示前 ${r} 字符。建议开启 vfs(capabilities.vfs 默认开启)以完整外存可回读]`,totalChars:e.length}}async function Zq(e,t,n,r){let i=Array(e.length),a=Math.max(1,t);if(a===1){for(let t=0;t<e.length&&!r?.aborted;t++)i[t]=await n(e[t],t);return i}let o=0,s=Array.from({length:Math.min(a,e.length)},async()=>{for(;o<e.length;){if(r?.aborted)return;let t=o++;i[t]=await n(e[t],t)}});return await Promise.all(s),i}var Qq=[{pattern:/deepseek-v4/i,caps:{contextWindow:1048576,maxOutputTokens:393216}},{pattern:/deepseek-reasoner|deepseek-r1/i,caps:{contextWindow:65536,maxOutputTokens:8192}},{pattern:/deepseek/i,caps:{contextWindow:131072,maxOutputTokens:8192}},{pattern:/gpt-4\.1/i,caps:{contextWindow:1047576,maxOutputTokens:32768}},{pattern:/gpt-4o-mini/i,caps:{contextWindow:131072,maxOutputTokens:16384}},{pattern:/gpt-4o/i,caps:{contextWindow:131072,maxOutputTokens:16384}},{pattern:/gpt-4-turbo|gpt-4-1106|gpt-4-0125/i,caps:{contextWindow:131072,maxOutputTokens:4096}},{pattern:/gpt-3\.5/i,caps:{contextWindow:16385,maxOutputTokens:4096}},{pattern:/claude-3-7-sonnet/i,caps:{contextWindow:2e5,maxOutputTokens:8192}},{pattern:/claude-3-5-sonnet/i,caps:{contextWindow:2e5,maxOutputTokens:8192}},{pattern:/claude-3-opus/i,caps:{contextWindow:2e5,maxOutputTokens:4096}},{pattern:/claude-3-haiku/i,caps:{contextWindow:2e5,maxOutputTokens:4096}},{pattern:/qwen-max|qwen-plus/i,caps:{contextWindow:32768,maxOutputTokens:8192}},{pattern:/qwen2\.5-1m|qwen-1m/i,caps:{contextWindow:1048576,maxOutputTokens:8192}},{pattern:/qwen2\.5/i,caps:{contextWindow:32768,maxOutputTokens:8192}},{pattern:/glm-5\.2/i,caps:{contextWindow:1048576,maxOutputTokens:65536}},{pattern:/glm-5/i,caps:{contextWindow:2e5,maxOutputTokens:65536}},{pattern:/glm-4\.[6-9]/i,caps:{contextWindow:131072,maxOutputTokens:131072}},{pattern:/glm-4\.5/i,caps:{contextWindow:131072,maxOutputTokens:98304}},{pattern:/glm-4|glm4/i,caps:{contextWindow:131072,maxOutputTokens:4096}},{pattern:/kimi-k3/i,caps:{contextWindow:1048576,maxOutputTokens:65536}},{pattern:/kimi-k2|kimi|moonshot/i,caps:{contextWindow:262144,maxOutputTokens:32768}},{pattern:/yi-34b|yi-large/i,caps:{contextWindow:32768,maxOutputTokens:4096}}],$q={contextWindow:32768,maxOutputTokens:4096},eJ=2e5;function tJ(e={}){let t=(()=>{if(!e.model)return;let t=Qq.map(t=>{let n=t.pattern.exec(e.model);return n?{caps:t.caps,matchedLen:n[0].length}:null}).filter(e=>e!==null);if(t.length)return t.sort((e,t)=>t.matchedLen-e.matchedLen),t[0].caps})();return{contextWindow:e.contextWindow??t?.contextWindow??$q.contextWindow,maxOutputTokens:e.maxOutputTokens??t?.maxOutputTokens??$q.maxOutputTokens}}function nJ(e){if(!e)return 0;let t=(e.match(/[\u4e00-\u9fff]/g)||[]).length,n=e.length-t;return Math.ceil(t*1.5+n*.25)}function rJ(e){return Math.max(2e3,Math.min(2e4,Math.round(e*.035)))}function iJ(e){let t=rJ(e);return Math.min(2e5,Math.max(t,Math.round(e*.7)))}function aJ(e){if(!e.length)return{rounds:0,totalDurationMs:0,avgRoundMs:0,toolCalls:0,toolFailures:0,toolSuccessRate:1,modelCalls:0,retries:0,compressions:0};let t=e.filter(e=>e.type===`round`).length,n=e.filter(e=>e.type===`model`),r=e.filter(e=>e.type===`tool`),i=e.filter(e=>e.type===`compression`),a=r.filter(e=>e.status===`error`).length,o=Math.min(...e.map(e=>e.startTs)),s=Math.max(...e.map(e=>e.endTs??e.startTs))-o,c=n.filter(e=>e.attributes.retry).length,l=0,u=0;for(let e of n){let t=e.attributes.usage;t&&(l+=t.prompt_tokens??0,u+=t.completion_tokens??0)}return{rounds:t,totalDurationMs:s,avgRoundMs:t?Math.round(s/t):0,toolCalls:r.length,toolFailures:a,toolSuccessRate:r.length?(r.length-a)/r.length:1,modelCalls:n.length,retries:c,compressions:i.length,totalTokens:l||u?{prompt:l,completion:u,total:l+u}:void 0}}function oJ(){return{messages:[],todos:[],files:{},skillsMetadata:[],skillsLoaded:[],memory:``,verifyAttempts:0}}function sJ(e,t){return t?.aborted?!0:e?.name===`AbortError`}function cJ(e,t){if(sJ(e,t))return!1;let n=e;return n?n.name===`TimeoutError`||n.status===void 0||n.status===429||n.lc_error_code===`MODEL_RATE_LIMIT`||n.status>=500:!1}function lJ(){let e=Error(`Aborted`);return e.name=`AbortError`,e}function uJ(e,t){return new Promise((n,r)=>{if(t?.aborted){r(lJ());return}let i=()=>{clearTimeout(a),r(lJ())},a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n()},e);t?.addEventListener(`abort`,i,{once:!0})})}async function dJ(e,t={}){let n=t.maxRetries??2,r=t.baseDelayMs??500,i=0;for(;;)try{return await e()}catch(e){if(sJ(e,t.signal)||i>=n||!cJ(e,t.signal))throw e;let a=r*2**i+Math.floor(Math.random()*r*.5);t.onRetry?.({attempt:i+1,error:e,waitMs:a}),await uJ(a,t.signal),i++}}var fJ=class extends Error{waitedMs;constructor(e){super(`LLM 流停滞:${e}ms 无数据,已中断(可调 streamStallMs 放宽或设 0 关闭)`),this.name=`StreamStalledError`,this.waitedMs=e,this.status=408}},pJ=9e4;async function*mJ(e,t){if(!(t>0)){yield*e;return}let n=e[Symbol.asyncIterator]();for(;;){let e,r=new Promise((n,r)=>{e=setTimeout(()=>r(new fJ(t)),t)}),i=n.next();i.catch(()=>{});let a;try{a=await Promise.race([i,r])}finally{clearTimeout(e)}if(a.done)return;yield a.value}}function hJ(e){if(!e||typeof e!=`object`)return!1;try{if(qb.isInstance(e))return!0}catch{}let t=e;return t.lc_error_code===`CONTEXT_OVERFLOW`||t.code===`context_length_exceeded`||t.status===400&&typeof t.message==`string`&&/context_length_exceeded|prompt is too long|maximum context length|exceeds the context window/i.test(t.message)}function gJ(e,t){return t?{...e,...t}:e}async function _J(e,t){let n=t;for(let t of e)t.beforeAgent&&(n=gJ(n,await t.beforeAgent(n)));return n}function vJ(e,t){let n=t.state;for(let r of e)r.beforeModel&&(n=gJ(n,r.beforeModel({messages:t.messages,state:n})));return n}function yJ(e,t,n){let r=n;for(let n=e.length-1;n>=0;n--){let i=e[n];i.afterModel&&(r=gJ(r,i.afterModel(t,r)))}return r}async function bJ(e,t){let n=t;for(let t=e.length-1;t>=0;t--){let r=e[t];r.afterAgent&&(n=gJ(n,await r.afterAgent(n)))}return n}async function xJ(e,t){let n=[];for(let r of e){if(!r.beforeReturn)continue;let e=await r.beforeReturn(t);e&&n.push(e)}return n.length?n.join(`
150
150
 
151
151
  `):null}function SJ(e,t){return e.reduceRight((e,t)=>n=>t.wrapModelCall?t.wrapModelCall(n,e):e(n),t)}function CJ(e,t){return e.reduceRight((e,t)=>n=>t.wrapToolCall?t.wrapToolCall(n,e):e(n),t)}function wJ(e){return e?/<|tool_calls|>|<||[^>]*tool_call|<||?DSML|<||?tool[_a-z]*|?>|<invoke\s+name=|<\/?tool_call>|<function_call>/i.test(e):!1}function TJ(e){if(!e)return``;let t=e.search(/<|tool_calls|>|<||[^>]*tool_call|<||?DSML|<||?tool[_a-z]*|?>|<function_call>|<invoke\s+name=/i);return(t>=0?e.slice(0,t):e).trim()}var EJ=/(我先|让我先|我先看|先看看|先了解|先加载|先查阅|稍后|接下来我|我将先|等我|查完.{0,12}再|看完.{0,12}再|了解.{0,8}再)/,DJ=/(已完成|已生成|已修改|已创建|已添加|已删除|已更新|已调整|已处理|已委派|已配置|已切换|成功|完成[。!?]|搞定了|做好了)/;function OJ(e){if(!e)return!1;let t=e.trim();return t.length>160||DJ.test(t)?!1:EJ.test(t)}var kJ=/<|tool_calls|>|<||[^>]*tool_call|<||?DSML|<||?tool[_a-z]*|?>/i;function AJ(e){return e.replace(/```[\w-]*\n?[\s\S]*?```/g,``)}function jJ(e){if(!e||!wJ(e))return null;let t=AJ(e);if(!kJ.test(t))return null;t=t.replace(/<|(?!|)[^|<>]*?|>/g,``);let n=/<(?:||?DSML||?)?\s*invoke\s+name=["']([^"']+)["'][^>]*>/gi,r=[],i;for(;(i=n.exec(t))!==null;)r.push({name:i[1],tagStart:i.index,after:n.lastIndex});if(!r.length)return null;let a=/<\/?\s*(?:||?DSML||?)?\/?\s*invoke\s*>/i,o=/<(?:||?DSML||?)?\s*parameter\s+name=["']([^"']+)["'][^>]*>([\s\S]*?)<\/?\s*(?:||?DSML||?)?\/?\s*parameter\s*>/gi,s=/<(?:||?DSML||?)?\s*parameter\s+name=["'][^"']+["'][^>]*>/gi,c=/<\/?\s*(?:||?DSML||?)?\/?\s*parameter\s*>/gi,l=[];for(let e=0;e<r.length;e++){let n=e+1<r.length?r[e+1].tagStart:t.length,i=t.slice(r[e].after,n),u=i.match(a);if(u&&u.index!==void 0&&(i=i.slice(0,u.index)),(i.match(s)||[]).length>(i.match(c)||[]).length)continue;let d={};o.lastIndex=0;let f;for(;(f=o.exec(i))!==null;)d[f[1]]=MJ(f[2].trim());l.push({id:`dsml_${e}_${Date.now().toString(36)}`,name:r[e].name,args:d})}return l.length?l:null}function MJ(e){if(e===`true`)return!0;if(e===`false`)return!1;if(e===`null`)return null;try{return JSON.parse(e)}catch{return e}}var NJ=10,PJ=300,FJ=6e3;function IJ(e,t){let n=e=>nJ(typeof e.content==`string`?e.content:JSON.stringify(e.content)),r=e.reduce((e,t)=>e+n(t),0);if(r<=t)return e;let i=0,a=r-t,o=Math.max(100,Math.min(400,Math.round(t/500))),s=e.map(e=>{if(i>=a||!(e instanceof yS))return e;let t=typeof e.content==`string`?e.content:JSON.stringify(e.content);if(t.length<=400)return e;let n=`…[已自动压缩 ${t.length} 字符,保留首 ${o}]\n`+t.slice(0,o);return i+=nJ(t)-nJ(n),new yS({tool_call_id:e.tool_call_id,content:n})}),c=s.reduce((e,t)=>e+n(t),0);return c>t&&console.warn(`[page-agent-sdk] trim 后仍超窗口:${c} > ${t} tokens(系统段/历史超预算,见 Phase 5/P3)`),s}function LJ(e,t){return t??Math.max(e*3,30)}var RJ=new Set([`write`,`set_data`,`edit_data`,`delete_data`,`draft_commit`]);function zJ(e){if(!e||typeof e!=`object`)return``;let t=e;if(typeof t.jsonPath==`string`)return t.jsonPath;let n=t.patch;if(n&&typeof n.jsonPath==`string`)return n.jsonPath;let r=t.patches;return Array.isArray(r)&&r.length&&r[0]&&typeof r[0].jsonPath==`string`?r[0].jsonPath:``}function BJ(e){let{apiKey:t,baseUrl:n,model:r=`gpt-3.5-turbo`,temperature:i=.7,maxTokens:a,extraBody:o,extraConfig:s,systemPrompt:c,tools:l=[],middleware:u=[],maxToolRounds:d,maxIterations:f,maxRetries:p=2,retryDelayMs:m=500,stallMs:h=pJ,maxParallelTools:g=1,maxVerifyAttempts:_=0,roundTokenBudget:v=0,onLog:y,onSpan:b,onTrace:x,onLlmChange:S,debug:C=!1}=e,w=d??NJ;(!Number.isFinite(w)||w<1)&&(console.warn(`[page-agent-sdk] maxToolRounds=${w} 非法(须 ≥1 正整数),已 clamp 到 1(0/负数致主循环 while 不进 → agent 不调 LLM 静默返回兜底文案)`),w=1),g>1&&console.warn(`[page-agent-sdk] maxParallelTools=${g}:并发工具下 dataOps 写工具不互锁(同轮并发两写都在 await handleConflict 让出前取旧基线 → 均通过乐观锁 → 后写覆盖前写,无 VERSION_CONFLICT 回灌);如需精确乐观锁保持 maxParallelTools=1 或写时显式传 expectedHash`);let T=tJ({model:r,contextWindow:e.contextWindow,maxOutputTokens:e.maxOutputTokens}),ee=a??T.maxOutputTokens,E=rJ(T.contextWindow),te=iJ(T.contextWindow);function ne(e){T=e,E=rJ(T.contextWindow),te=iJ(T.contextWindow)}let D=yH([]);function re(e,t){let n={timestamp:Date.now(),type:e,data:t};D.value.push(n),D.value.length>PJ&&D.value.splice(0,D.value.length-PJ),xH(D),y?.(n),C&&console.log(`%c[Agent] ${e}`,`color:#667eea;font-weight:bold`,t)}let O=e=>{D.value.push(e),D.value.length>PJ&&D.value.splice(0,D.value.length-PJ),xH(D)},ie=yH([]),ae=0,oe=!!b||!!x;function k(e,t,n,r={}){if(!oe)return null;let i={id:`span-${++ae}`,parentId:e,name:n,type:t,startTs:Date.now(),status:`ok`,attributes:r};return ie.value.push(i),ie.value.length>PJ&&ie.value.splice(0,ie.value.length-PJ),xH(ie),i}function se(e,t=`ok`,n){!e||!oe||(e.endTs=Date.now(),e.durationMs=e.endTs-e.startTs,e.status=t,n&&Object.assign(e.attributes,n),xH(ie),b?.(e))}let A=[...u.flatMap(e=>e.tools||[]),...l],ce=e.llm??new hB({apiKey:t,model:r,temperature:i,maxTokens:ee,configuration:{...n?{baseURL:yB(n)}:{},fetch:vB,...s},...o?{modelKwargs:o}:{}}),le=A.length>0?ce.bindTools?.(A)??ce:ce;function ue(){le=A.length>0?ce.bindTools?.(A)??ce:ce}let de=oJ(),fe=.25,pe=new Set([`mission`,`workingMemory`]);function me(){let e=c||`你是一个智能助手。`,t=[];for(let e of u)if(e.augmentPrompt){let n=e.augmentPrompt(de);n&&t.push({name:e.name,text:n,tokens:nJ(n),pin:pe.has(e.name)})}let n=Math.max(2e3,Math.round(T.contextWindow*fe)),r=nJ(e)+t.reduce((e,t)=>e+t.tokens,0);if(r>n){let e=r,i=[];for(let e of t.filter(e=>!e.pin).sort((e,t)=>t.tokens-e.tokens)){if(r<=n)break;i.push(`${e.name}(${e.tokens})`),r-=e.tokens,e.text=``}i.length&&console.warn(`[page-agent-sdk] 系统段超预算(${e} > ${n} tokens,窗口 ${T.contextWindow} 的 ${fe*100}%),drop 非核心段:${i.join(`, `)}(保 base/mission/workingMemory)`)}return[e,...t.filter(e=>e.text).map(e=>e.text)].join(`
@@ -334,7 +334,7 @@ ${`- 输出形态:完整、自包含的 HTML 页面(.${r},可独立成页)`}
334
334
  `)}catch(t){let r=t?.message||String(t);return n.signal.aborted?`获取失败:请求超时(${u5}ms,${e})。`:/Failed to fetch|NetworkError|CORS|blocked/i.test(r)?`获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。`:`获取失败:${r}`}finally{clearTimeout(r)}},{name:`fetch_document`,description:`以 GET 请求抓取文档/网页/接口文本。仅支持同源或已配置 CORS 的 URL;跨域会被浏览器拦截。大结果自动外存到虚拟工作区,可用 vfs_read / vfs_grep 回读。`,schema:L({url:F().describe(`要抓取的 URL(同源或已配 CORS)`),as:vf([`text`,`markdown`]).optional().describe(`返回格式标签,默认 text`)})})];xm();var Poe=[`id`,`class`,`href`,`src`,`alt`,`title`,`style`,`role`,`aria-label`,`name`,`type`],Foe=/^(value|srcdoc|formaction|on\w+)$/i,Ioe=/token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session/i;function f5(e,t){if(!e)return null;let{depth:n,attrs:r,includeText:i=!0}=t,a=r!==void 0,o=r??Poe,s=e=>{let t={};for(let n of Array.from(e.attributes))(a?o.includes(n.name):o.includes(n.name)||n.name.startsWith(`data-`))&&(Foe.test(n.name)||Ioe.test(n.name)||(t[n.name]=n.value));return t},c=(e,t)=>{let n={tag:e.tagName.toLowerCase(),attrs:s(e)};if(i){let t=Array.from(e.childNodes).filter(e=>e.nodeType===3).map(e=>e.textContent||``).join(``).trim();t&&(n.text=t)}let r=Array.from(e.children);return t>0?r.length&&(n.children=r.map(e=>c(e,t-1))):r.length&&(n.childCount=r.length),n};return c(e,n)}var p5=_B(({selector:e,depth:t,attrs:n,includeText:r})=>{let i=e?document.querySelector(e):document.body;if(!i)return`未找到匹配元素:selector="${e}"`;let a=f5(i,{depth:t??3,attrs:n,includeText:r??!0});return a?JSON.stringify(a,null,2):`selector="${e}" 未匹配到元素`},{name:`get_dom`,description:`读渲染后 DOM 结构(tag/attrs/text/children)。检查渲染效果/验证修改是否生效用;depth 控制深度(默认 3),attrs 限定返回属性。只读,大结果自动外存 vfs。`,schema:L({selector:F().optional().describe(`CSS 选择器(默认 body,读整个页面)`),depth:Bd().int().min(0).max(10).optional().describe(`遍历深度(默认 3;0 只读根节点)`),attrs:I(F()).optional().describe(`属性白名单(传了 = 严格白名单;不传 = 默认常用 + data-*)`),includeText:Kd().optional().describe(`是否包含直接文本(默认 true)`)})}),m5=[p5];xm();function Loe(e){let t=e;return typeof t.tagName==`string`||typeof t.nodeType==`number`&&typeof t.nodeName==`string`}function h5(e,t=3,n=2e3,r,i){if(e==null)return e;if(typeof e==`string`)return e.length>n?e.slice(0,n)+`…(已截断)`:e;if(typeof e==`number`||typeof e==`boolean`)return e;if(typeof e==`function`)return`[Function: ${e.name||`anonymous`}]`;if(typeof e==`symbol`)return e.toString();if(typeof e==`bigint`)return`${e.toString()}n`;if(typeof e!=`object`)return String(e);let a=e;if(Loe(a)){let e=a;return e.tagName?`[Element: <${e.tagName.toLowerCase()}>]`:`[Node: ${e.nodeName}]`}if(r?.has(a))return`[Circular]`;let o=r??new WeakSet;if(o.add(a),Array.isArray(e)){let r=e.slice(0,100).map(e=>h5(e,t-1,n,o,i));return e.length>100&&r.push(`…(共 ${e.length} 项,已截断)`),r}if(t<0)return`(对象,已截断)`;let s={},c=Object.keys(a);for(let e=0;e<c.length;e++){let r=c[e];if(e>=50){s[`…`]=`(共 ${c.length} 键,已截断)`;break}try{let e=a[r];i?.test(r)?s[r]=`[REDACTED]`:s[r]=h5(e,t-1,n,o,i)}catch{s[r]=`(getter 抛错)`}}return s}function g5(e){let t=e??(typeof window<`u`?window:{}),n=t.navigator,r=t.location,i=t.document;return{location:{href:r?.href,origin:r?.origin,protocol:r?.protocol,host:r?.host,hostname:r?.hostname,pathname:r?.pathname,search:r?.search},navigator:{userAgent:n?.userAgent,language:n?.language,languages:n?.languages,platform:n?.platform,onLine:n?.onLine},viewport:{innerWidth:t.innerWidth,innerHeight:t.innerHeight,devicePixelRatio:t.devicePixelRatio,scrollX:t.scrollX,scrollY:t.scrollY},document:i?{title:i.title,readyState:i.readyState,characterSet:i.characterSet}:`(无 document)`}}var Roe=/^(localStorage|sessionStorage|cookie|document|frames|frameElement|opener|parent|top|self|window|globalThis|closed|history|navigation|trustedTypes|origin|crossOriginIsolated)$/,_5=/token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session|ticket/i,v5=_B(({key:e})=>{if(e){if(Roe.test(e)||_5.test(e))return JSON.stringify({key:e,denied:!0,reason:`安全:该 key 在 denylist(localStorage/sessionStorage/cookie/document 或敏感命名 token/secret/key/auth),不读取防泄漏`},null,2);let t=(typeof window<`u`?window:{})[e];return JSON.stringify({key:e,exists:t!==void 0,type:typeof t,value:h5(t,3,2e3,void 0,_5)},null,2)}return JSON.stringify(g5(),null,2)},{name:`inspect_env`,description:`读宿主页面环境信息(排查调试)。不传参返回摘要(URL/origin、浏览器/语言、viewport、title/readyState);传 key 读指定 window 属性值(如 key:"appConfig")。只读,大结果自动外存 vfs。`,schema:L({key:F().optional().describe(`要读取的 window 属性名(如 "appConfig"/"__DEBUG__");不传 = 返回环境摘要`)})}),y5=[v5];function zoe(e,t,n){let r=0;return{name:`budget`,beforeAgent:()=>{r=Date.now()},wrapModelCall:async(i,a)=>{let{tokenBudget:o,timeBudgetMs:s}=t,c=o!=null&&(e.total_tokens??0)>o,l=s!=null&&Date.now()-r>s;return c||l?(n({type:`error`,severity:`observable`,code:`BUDGET_EXCEEDED`,message:`资源预算超限:${c?`token 超限(累计 ${e.total_tokens??0} > 上限 ${o})`:`时间超限(${Date.now()-r}ms > 上限 ${s}ms)`},agent 已停止(未完成部分可用 restoreLastCheckpoint 回退)。`}),{message:new hC({content:``}),content:``,toolCalls:[],aborted:!0}):a(i)}}}xm();var b5=/^[a-zA-Z][a-zA-Z0-9_]*$/;function x5(e){let t=[];for(let[n,r]of Object.entries(e)){if(!b5.test(n)){console.warn(`[page-agent-sdk][actions] 动作名 "${n}" 非法(须匹配 ${b5}),已跳过`);continue}let e=r.description||`宿主动作 ${n}`;t.push(_B(async e=>{try{let t=await r.run(e||{});return t===void 0?`动作 ${n} 执行完成。`:typeof t==`string`?t:JSON.stringify(t)}catch(e){let t=e?.message||String(e);return`动作 ${n} 执行失败:${t}`}},{name:n,description:e,schema:r.params??L({})}))}return t}function S5(e){let t={};for(let[n,r]of Object.entries(e))b5.test(n)&&(t[n]={description:r.description,hasParams:!!r.params});return t}var Boe=d5,Voe=m5;function Hoe(e,t){return l5(e,t)}function C5(e,t,n,r,i){let a=N8(e);return[...a.dataOps?t:[],...a.fetch?n:[],...a.domInspect&&r?r:[],...a.inspectEnv&&i?i:[]]}function Uoe(e){let t=new Map,n=[];for(let r of e)for(let e of r.tools){let i=t.get(e.name);i&&n.push({name:e.name,winner:r.label,loser:i.label}),t.set(e.name,{tool:e,label:r.label})}return{tools:[...t.values()].map(e=>e.tool),collisions:n}}var w5=.7;function T5(e,t,n=`simple`,r,i){let a=N8(e),o=n!==`advanced`,s=n===`minimal`;return{name:`usageHints`,augmentPrompt:n=>{let r=[];if(a.planning&&(r.push(`【自适应规划】按任务复杂度决定是否先规划,不要对简单任务过度编排:`),r.push(` · 简单/明确任务(改单字段、调样式、查值)→ 直接 read/write 执行,不必 write_todos。`),r.push(` · 复杂任务(多步、大改、有歧义、不可逆)→ 先 write_todos 拆解,首个任务标 in_progress,逐项推进。`),r.push(` · 执行中发现步骤要改/补/细分 → 用 update_todo({id, content?, status?}) 按 id 增量改单项,不必重传整个清单。`),e?.humanConfirm?r.push(` · 规划出多步方案若需用户拍板 → 先 request_human_confirmation 给方案选项,确认后再执行。`):r.push(` · 规划出多步方案若需用户拍板 → 以文字列出方案选项等用户回复,勿自行拍板。`),r.push(` · 规划阶段有轮次预算(maxPlanRevisions,默认 5):勿反复调研/改计划而不执行,规划充分后即开始 write 落地。`)),t&&(o?(r.push(`读写主数据用 read/write(高层入口,自动乐观锁 + 自动快照)。read({jsonPath}) 读子路径当前值(返回含 hash,write 时自动比对,无需手动传);read() 不传读整个主数据 + 说明。write 改值两姿势:① 改单个字段/子路径用 write({patch:{op:"set", jsonPath:"路径.字段", value:新值}})——patch.value 就是该字段的新值(类型匹配:string 直传字符串、number 传数字、对象传对象),不要包成 {字段:值} 对象(字段名已在 jsonPath);也兼容 write({value:新值, patch:{op,jsonPath}}) 顶层 value(向后兼容,但优先 patch.value,避免与整体 set 的 value 混淆);② 替换整个对象用 write({value:{整个新对象}})。op:set 设值 / remove 删 / merge 合并对象 / append 追加数组 / move 移动数组元素(value=目标路径字符串:数组本身=追加到末尾、数组内下标=插到该位置;同数组即重排如组件调序,目标下标按移除源后解释,一步完成免双 set 交换);批量多改动 write({patches:[{op,jsonPath,value},...]});删子路径 write({patch:{jsonPath:"路径"}, del:true})。写入自动经 schema 校验(失败不写,按错误提示改值类型/形状后重试)+ 自动存快照`+(s?`。`:`(出错可用 restore_data 回退)。`)),r.push(`修改大对象/数组优先用 write 的 patch 增量(只发改动部分),避免整体重传被 max_tokens 截断致 JSON 不完整。`),r.push(`读大数组(read 返回 hasMore=true)用 read({jsonPath,offset,limit}) 分页(offset+=limit 续读,默认 limit=50);一次读多个不相关子路径用 read({jsonPaths:[...]}) 省轮次;复杂 patches 改动先 write({patches,dryRun:true}) 预检(走完整校验不落盘)。`),r.push(`read/describe 返回按 schema 投影:仅 schema 声明的字段可见(未声明字段自动隐藏,防误操作);要操作某字段需集成方在 schema 声明。`),s||(r.push(`查任意路径完整约束或对比快照差异需切 advanced 工具模式(schema_data/diff_data,当前未装载勿调用);查历史快照值(只读不改当前)用 history_data({id?,jsonPath?})。`),r.push(`在大数组里按条件筛选用 query_data(JSONPath,如 $.components[?(@.type=="card" && @.price<100)]),返回匹配元素 path/index;定位后用 write patch 改。找名字记不清的元素用 search_data(substring/regex/fuzzy)。批量过滤/映射/聚合/重写大数组用 eval_script(沙箱脚本,mode=query 只读/transform 落地)。`))):(r.push(`改主数据前先 get_data({jsonPath}) 读其当前真实值与 hash(返回末尾 hash=xxx),基于真实值改,不要凭记忆。写入(set/edit/delete)时回传 expectedHash=该 hash 启用乐观锁——若主数据在你 get 之后被外部代码/其他 agent/用户手动改过,会触发冲突:集成方若开启人工介入,工具会挂起等用户决定(保留外部/强制覆盖/回退),你应等待工具返回后按结果继续(保留外部→重新 get 再改;强制覆盖→已写入,继续;回退→已回退到历史快照,基于回退值重写);未开启人工介入时返回 VERSION_CONFLICT 不写入,重新 get 拿最新值与 hash 再改。`),r.push(`不确定主数据字段结构时用 describe_data 查看说明。`),r.push(`修改大对象/数组优先用 edit_data 增量 patch(只发改动部分),避免 set_data 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。`),r.push(`修改主数据出错时可用 restore_data 回退最近一次。`),r.push(`在大数组里按条件筛选元素用 query_data(JSONPath,如 $.components[?(@.type=="card" && @.price<100)]),返回匹配元素的 path/index;定位后再 edit_data 改。`),r.push(`找名字记不清的元素用 search_data(支持 substring/regex/fuzzy 模糊搜索)。`),r.push(`需要过滤/映射/聚合/批量重写大数组时用 eval_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。`),r.push(`读大数组用 read({jsonPath,offset,limit}) 分页(返回 hasMore=true 时 offset+=limit 续读);一次读多个不相关子路径用 read({jsonPaths});复杂改动先 write({...,dryRun:true}) 预检不落盘。`),r.push(`对比当前与历史快照(或一段 JSON against)的差异用 diff_data({snapshotId?,against?})(返回结构化 path→from/to,verify 自纠/操作审计/"刚才改了啥");只读查历史快照值用 history_data({id?,jsonPath?})。`))),a.subagent&&r.push(`独立子任务可 spawn_agent 委派(过程隔离,不占主上下文):默认只读,需要子 agent 写数据时传 writablePaths(路径前缀白名单,越界 PATH_OUT_OF_SCOPE)。多个独立子任务可 spawn_agents 并行委派(各子互不通信,结论由你汇总;并行委派不可授写权限,写操作由你收尾执行)。`),a.inspectEnv&&r.push(`排查页面环境(当前 URL/浏览器/视口/集成方调试变量)用 inspect_env——不传参返回环境摘要(location/navigator/viewport/document),传 key 读特定 window 属性(如 inspect_env({key:"appConfig"}) 读 window.appConfig)。改完数据看渲染、定位"为何没生效"时用它(只读,不改数据)。`),a.domInspect&&r.push(`改完数据想确认渲染是否生效(或定位元素/辅助 UI 设计问答)用 get_dom({selector?,depth?}) 读渲染后 DOM(结构化返回 tag/attrs/text/children,depth 控制深度防爆炸,只读)。配合宿主 actions(save_draft/publish 等)形成"改数据→get_dom 看渲染→触发动作"闭环。`),a.draftWrite&&!o&&(r.push(`生成超大 JSON(如 50+ 组件页面,单次 write 受 max_tokens 限制装不下)用 draft_write 分块构建 → draft_commit 原子提交:draft_write({draftId, chunk, mode}) mode:"start" 新建/"append" 追加(拼 JSON 片段到 drafts 池);累积完 draft_commit({draftId}) 合并 + schema 校验 + 写主数据(失败草稿保留可修后重试,成功自动清草稿)。小改仍用 write patch,只在大 JSON 从零生成时用 draft。`),r.push(`⚠️ 大 JSON 分块构建是典型多轮工具调用(draft_write×N + draft_commit + read 确认 + 调研 read/query),默认 maxToolRounds=10 可能触顶被 while 截断导致草稿写不完;目标组件数大时集成方应在 createChatSdk 配 maxToolRounds ≥ 20(或按 N+5 估算)。draft_commit 提交同样走乐观锁(改前 read 拿 hash,bind 被改过会触发冲突介入,不静默覆盖)。`)),a.todoDeps&&r.push(`复杂任务可用 todos 层级依赖:write_todos 时给 todo 传 parentId(父任务 id,表达层级)+ deps(依赖的 todo id 数组,必须先完成)。有依赖的任务,deps 全 completed 后再标 in_progress;完成时 update_todo({id, status:"completed", evidence:"完成证据"}) 记证据。无依赖关系的任务不传 parentId/deps(扁平)。`),a.focus&&!o&&(r.push(`【上下文聚焦】判断任务范围,用 set_focus/add_focus/remove_focus/clear_focus 自动收敛工作范围:`),r.push(` · 局部任务(只改某一组件/区域,如「调导航栏」「改 components.3 样式」)→ 先 read 定位 jsonPath,再 set_focus({path:"该子树路径"}) 聚焦;聚焦后每轮只看该子树结构,写其他位置会被 PATH_DENIED 拒绝。`),r.push(` · 多个相关组件(如「同时改导航栏和页脚」)→ set_focus 聚焦首个后用 add_focus({path}) 追加其余;聚焦后可写任一焦点子树,越界仍被拒;移除单个用 remove_focus({path})。`),r.push(` · 全局任务(多处/整体结构,如「重排所有组件」「换主题」)→ 不要聚焦,保持全量视野直接写。`),r.push(` · 完成局部精修、要转向其他区域或做整体改动 → 调 clear_focus 退出聚焦(清空全部焦点),恢复全部读写权限。`),r.push(` · set_focus/add_focus 的 path 必须在 schema 内(类型校验);不确定路径先 read/describe_data 查。`)),e?.subagents?.length){let t=e.subagents.filter(e=>(e.temperature??0)>=w5||/规划|创意|设计|方案|brainstorm|plan/i.test(e.description)),n=e.subagents.filter(e=>(e.temperature??0)<w5&&/反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));r.push(`【规划-反思-执行·路由】按任务性质选模式,不要对简单任务过度编排:`),t.length&&(r.push(` · 创作/设计/开放性需求(如"设计主题风格""换个感觉")→ 先调 ${t.map(e=>`use_`+e.id).join(`/`)} 出 2-3 套方案(高温创意),`),r.push(e?.humanConfirm?` 不要自己拍板;拿到方案后,若需用户拍板用 request_human_confirmation 弹选项。`:` 不要自己拍板;拿到方案后以文字列出选项等用户回复(humanConfirm 未开,勿调不存在工具)。`)),n.length&&r.push(` · 严谨/易错/校验类 → 可先调 ${n.map(e=>`use_`+e.id).join(`/`)} 反思挑刺(低温审查),据反馈修订。`),r.push(o?` · 方案定稿后,由你(主 agent)用 write 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。`:` · 方案定稿后,由你(主 agent)用 edit_data 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。`),r.push(` · 简单/明确任务(如"标题改红色")直接执行,不必走规划-反思。`)}e?.humanConfirm&&(r.push(`【人工确认·必读】以下情形必须先调 request_human_confirmation 征询用户、拿到答复后再继续,不要自行拍板:`),r.push(` 1) 用户让你「给方案/列选项/我来选/挑一个」时:把每个方案作为一个 option,调 request_human_confirmation(question=简述, options=[方案A,方案B,...], recommendation=你推荐的)。不要只回文字罗列方案让用户自己回复——要用工具把选项做成可点选按钮。`),r.push(` 2) 需求有歧义/不确定时:调工具问清楚(options 不传则用户答同意或拒绝)。`),r.push(` 3) 即将执行高风险不可逆操作(删除/覆盖/批量改动)前:调工具确认。`),r.push(` 4) 规划出多步方案需用户确认时:把整个方案(或关键分步)作为 option 调 request_human_confirmation,确认后再执行。`),r.push(`用户在选项里选了哪个,就按那个方案继续;选「拒绝」则停止并询问如何调整。`));let c=n?.loopProgress;if(c){let e=c.invokeUsage.prompt_tokens||c.invokeUsage.total_tokens,t=i?.promptSoftCap??1/0,n=c.maxToolRounds>0&&c.rounds>=Math.ceil(c.maxToolRounds*.7),a=t!==1/0&&e>=t*.5;!c.budgetHinted&&(n||a)&&(c.rounds>0||e>0)&&(c.budgetHinted=!0,r.push(`⏳ 预算提示:本任务已用 ${c.rounds}/${c.maxToolRounds} 工具轮、累计约 ${Math.max(1,Math.round(e/1e3))}K prompt tokens。若已接近目标请收敛并给出总结;尚未接近请向用户汇报进度与剩余计划,勿默默继续。`));let o=Object.entries(c.writeFailures).filter(([,e])=>e>=2);if(o.length){let e=o.map(([e,t])=>`${e||`(整体)`}×${t}`).join(`、`);r.push(`⚠️ 以下路径已连续写失败:${e}。连续失败常意味着方向错了——先 read 重新核对实际值/类型,或 restore_data 回退后再改;若确需继续,换思路而非原样重试。`)}}return r.length&&r.unshift(`调用工具务必用标准 function calling(工具调用)格式发起,不要在回复正文里输出伪 XML/标签(如 deepseek 的 tool_calls 标签、invoke、function_call、tool_call 等)或 JSON 文本——那不会被识别为工具调用,会被当普通文字,工具不执行。`),r.length?`## 能力使用提示
335
335
  `+r.join(`
336
336
  `):void 0}}}function Woe(e){let t=e.toolsExposed===!1?`读到 ⟦frozen:path⟧/⟦res:handle⟧ 占位符 = 精确值在冻结区/资源池(不入消息流);resource_get/resource_update 为 advanced 工具,当前模式未装载,勿尝试调用;freeze 字段不可写(撞 FROZEN_FIELD 即放弃);verbatim 字段保持原值,勿在当前模式下尝试改写(直接写新值会 VERBATIM_MISMATCH);撞 RESOURCE_EVICTED/RESOURCE_NOT_FOUND 重新 read 懒注册。`:`读到 ⟦frozen:path⟧/⟦res:handle⟧ 占位符 = 精确值在冻结区/资源池(不入消息流);需真值用 resource_get({path});freeze 字段不可写(撞 FROZEN_FIELD 即放弃);verbatim 直接写新值会 VERBATIM_MISMATCH,先 resource_update 再写回句柄;撞 RESOURCE_EVICTED/RESOURCE_NOT_FOUND 重新 read 懒注册。`;return{name:`resourcesPin`,augmentPrompt:()=>{let n=e.getResourcesSnapshot();if(!n.length)return;let r=[`## 受保护资源(跨压缩保留 · 精确值保护)`];for(let e of n)e.mode===`freeze`?r.push(`- ${e.path} (freeze 已冻结,不可改)`):r.push(`- ${e.path} (verbatim 原样保留)${e.handle?` ⟦res:${e.handle}⟧`:``}`);return r.push(t),r.join(`
337
- `)}}}var E5=`v:1::skill-store`,Goe=`chat-sdk`;function D5(e,t,n){return`${E5}::${e}::${t}::${n}`}function O5(e,t){return`${E5}::${e}::${t}::`}function k5(e={}){let t=e.dbName??Goe,n=e.backend??`indexed`,r=e.id??``,i,a,o=new Promise(e=>{a=e});return(async()=>{try{if(n===`indexed`){if(typeof indexedDB>`u`)throw Error(`indexedDB 不可用`);i=await E8(t),a(!0)}else if(n===`session`){if(typeof sessionStorage>`u`)throw Error(`sessionStorage 不可用`);i=D8(sessionStorage),a(!0)}else if(n===`local`){if(typeof localStorage>`u`)throw Error(`localStorage 不可用`);i=D8(localStorage),a(!0)}else i=T8(),a(!1)}catch{i=T8(),a(!1)}})(),{ready:o,async list(){let e=[];return await i.scan(O5(t,r),(t,n)=>{e.push(n)}),e},async get(e){return await i.get(D5(t,r,e))},async put(e){try{await i.set(D5(t,r,e.name),e)}catch(e){b8(e)&&(i=T8())}},async remove(e){let n=D5(t,r,e);return await i.get(n)==null?!1:(await i.del(n),!0)},async clear(){await i.clearPrefix(O5(t,r))},dispose(){}}}var A5=/large_results\/[^\s"'`),]+\.txt/g;function j5(e){let t=new Set,n=e=>{if(typeof e!=`string`||!e)return;let n;for(A5.lastIndex=0;(n=A5.exec(e))!==null;)t.add(n[0])};for(let t of e)if(n(t.content),t.steps)for(let e of t.steps)n(e.result);return t}function Koe(e,t){let n=[];for(let r of Object.keys(e))r.startsWith(`large_results/`)&&!t.has(r)&&n.push(r);return n}function M5(){let e=Promise.resolve();return function(t){let n=e.then(t,t);return e=n.then(()=>void 0,()=>void 0),n}}xm();var qoe=30,N5=new Map;function Joe(e,t){return e===`set_data`?`set`:e===`edit_data`?`edit`:e===`delete_data`?`delete`:e===`restore_data`?`restore`:e===`write`?t?.del?`delete`:t?.patch?`edit`:`set`:null}function Yoe(e){return e===`spawn_agent`||e===`spawn_agents`||e.startsWith(`use_`)}function Xoe(e,t,n,r){let i=0;return{name:`sdk-events`,wrapToolCall:async(t,r)=>{let i=await r(t),a=Joe(t.name,t.args);return a?e({type:`data_change`,operation:a,value:n()?.bind}):i.status===`done`&&Yoe(t.name)&&e({type:`data_change`,operation:`edit`,value:n()?.bind}),i},afterModel:t=>{let n=TB(t.message);n&&(r.prompt_tokens=(r.prompt_tokens??0)+(n.prompt_tokens??0),r.completion_tokens=(r.completion_tokens??0)+(n.completion_tokens??0),r.total_tokens=(r.total_tokens??0)+(n.total_tokens??0),i++,e({type:`usage`,round:i,usage:n,cumulative:{prompt_tokens:r.prompt_tokens,completion_tokens:r.completion_tokens,total_tokens:r.total_tokens}}))},afterAgent:async()=>{e({type:`message_update`,count:t.length})}}}function P5(e,t,n,r,i){if(!n)return i&&console.warn(`[page-agent-sdk][focus] capabilities.focus 关闭,${t} 忽略`),{ok:!1,error:`capabilities.focus 关闭`};if(!e||!e.path)return i&&console.warn(`[page-agent-sdk][focus] ${t} 拒绝:path 必填且非空`),{ok:!1,error:`path 必填且非空`};let a=r();return a?WJ(a,e.path)?{ok:!0}:(i&&console.warn(`[page-agent-sdk][focus] ${t} 拒绝:path "${e.path}" 不在 schema 内(getSchemaAtPath 返 null;数组组件须 z.array(...) 包裹,裸 discriminatedUnion/Union 会降级)`),{ok:!1,error:`path "${e.path}" 不在 schema 内`}):(i&&console.warn(`[page-agent-sdk][focus] ${t} 拒绝:当前无主数据 schema`),{ok:!1,error:`当前无主数据 schema,无法聚焦`})}function Zoe(e,t){let n={prompt_tokens:0,completion_tokens:0,total_tokens:0},r=h8(()=>mt),i=vH(0),a=A8(e.storage);e.debug&&a&&a.onEvent(e=>console.log(`[page-agent-sdk][storage]`,e));let{modelCaps:o,summaryLlmInvoke:s,titleLlmInvoke:c,compressDecisionInvoke:l}=m8(e),u=o;if(e.debug&&console.log(`[page-agent-sdk][modelCaps]`,u),u.contextWindow<2e5)throw Error(`[page-agent-sdk] 模型上下文窗口 ${u.contextWindow} 小于最小支持 ${eJ}(需 ≥200K 窗口模型,如 GLM-5.2/Claude/Kimi/Qwen-1M/DeepSeek-v4)`);let d=I8(e,u.contextWindow),f=d.enableLLMSummary!==!1,p=(e.contextOptions&&e.contextOptions.preserveLastToolResults)??moe[e.contextPreset??`auto`],m=new Set(p),h=e.llm;e.debug&&!s&&console.warn(`[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要`);let g=sH([]),_=V6(e.vfs?.initialFiles,{persist:a?{save:e=>{P.sessionId&&a&&a.save(t,P.sessionId,{vfs:e})}}:void 0,maxBytes:e.vfs?.maxBytes,poolBytes:e.vfs?.poolBytes}),v=xY([],{maxPlanRevisions:e.maxPlanRevisions}),y=TY(),b=ZY({getSchema:()=>_e()?.schema,getBind:()=>_e()?.bind,unfocusGuidance:e.toolMode===`advanced`?`tool`:`ask-user`,onChange:e=>mt({type:`focus_change`,focuses:e})}),x=eX(),S=bX(e.memory||``);typeof e.memory==`function`&&S.refresh();let C={current:null},w=e.data?{...e.data,description:e.data.description??`主数据对象`}:void 0,T=!(e.subagents??[]).some(e=>e._codeAsset)&&N8(e.capabilities).subagent,ee=e.subagents;T&&w?.schema&&YJ(w.schema).length&&(ee=[...e.subagents??[],o8()],console.info(`[page-agent-sdk] 检测到 schema 含代码组件数组(如 components[].code),已自动装配 HTML 代码子 agent(委派编排 + vfs 工作副本 + 格式校验 + 增量 commit)。需定制(codeField/formatCheck/craftNotes 等)请显式传 createHtmlSubagent(...)`));let E=(ee??[]).filter(e=>!!e._codeAsset),te=new Set;for(let e of E){if(e._codeAsset.writablePaths.length)continue;let t=YJ(w?.schema,e._codeAsset.codeField);t.length?(e._codeAsset.writablePaths=t,Array.isArray(e.writablePaths)&&(e.writablePaths=t),e._rebuildCodeAssetPaths?.(t[0]),console.info(`[page-agent-sdk][createHtmlSubagent] 未传 writablePaths,已从 schema 推断: [${t.map(e=>`'${e}'`).join(`, `)}]`)):(console.warn(`[page-agent-sdk][createHtmlSubagent] 未能从 schema 推断 writablePaths(开放 schema(z.any()/z.record())/嵌套容器(如 sections[].children[])/点路径 codeField(如 props.html_code)不支持自动推断),已跳过该 html 子 agent(整体不受影响);如确需代码资产机制(vfs + 格式校验 + 增量 commit),请显式传 writablePaths(代码组件 data 区,如 ['components'])`),te.add(e))}let ne=te.size?E.filter(e=>!te.has(e)):E,D=te.size?(ee??[]).filter(e=>!te.has(e)):ee,re=ne.length>0,O=ne.flatMap(e=>e._codeAsset.writablePaths),ie=ne.flatMap(e=>e._codeAsset.writablePaths.map(t=>`${t}.${e._codeAsset.codeField}`)),ae=e.checkpoint,oe=ae!==void 0&&ae!==!1,k=oe?RX({getData:()=>_e()?.bind,consumeDataDirty:()=>he?.consumeDataDirty?.()??!0,slotPaths:w?[``]:[],vfsStore:_,todosMw:v,getTodos:()=>C.current?.getState?.()?.todos??[],messages:g,maxCheckpoints:ae&&typeof ae==`object`?ae.maxCheckpoints:void 0}):null,se=!ae||typeof ae!=`object`||ae.auto!==!1,A=N8(e.capabilities),ce=A.dataOps,le=A.draftWrite,ue=A.tracing,de=A.automation,fe=R6(e);if(re){let e=ne.map(e=>e._codeAsset.orchestratorPrompt).filter(Boolean).join(`
337
+ `)}}}var E5=`v:1::skill-store`,Goe=`chat-sdk`;function D5(e,t,n){return`${E5}::${e}::${t}::${n}`}function O5(e,t){return`${E5}::${e}::${t}::`}function k5(e={}){let t=e.dbName??Goe,n=e.backend??`indexed`,r=e.id??``,i,a,o=new Promise(e=>{a=e});return(async()=>{try{if(n===`indexed`){if(typeof indexedDB>`u`)throw Error(`indexedDB 不可用`);i=await E8(t),a(!0)}else if(n===`session`){if(typeof sessionStorage>`u`)throw Error(`sessionStorage 不可用`);i=D8(sessionStorage),a(!0)}else if(n===`local`){if(typeof localStorage>`u`)throw Error(`localStorage 不可用`);i=D8(localStorage),a(!0)}else i=T8(),a(!1)}catch{i=T8(),a(!1)}})(),{ready:o,async list(){let e=[];return await i.scan(O5(t,r),(t,n)=>{e.push(n)}),e},async get(e){return await i.get(D5(t,r,e))},async put(e){try{await i.set(D5(t,r,e.name),e)}catch(e){b8(e)&&(i=T8())}},async remove(e){let n=D5(t,r,e);return await i.get(n)==null?!1:(await i.del(n),!0)},async clear(){await i.clearPrefix(O5(t,r))},dispose(){}}}var A5=/large_results\/[^\s"'`),]+\.txt/g;function j5(e){let t=new Set,n=e=>{if(typeof e!=`string`||!e)return;let n;for(A5.lastIndex=0;(n=A5.exec(e))!==null;)t.add(n[0])};for(let t of e)if(n(t.content),t.steps)for(let e of t.steps)n(e.result);return t}function Koe(e,t){let n=[];for(let r of Object.keys(e))r.startsWith(`large_results/`)&&!t.has(r)&&n.push(r);return n}function M5(){let e=Promise.resolve();return function(t){let n=e.then(t,t);return e=n.then(()=>void 0,()=>void 0),n}}xm();var qoe=30,N5=new Map;function Joe(e,t){return e===`set_data`?`set`:e===`edit_data`?`edit`:e===`delete_data`?`delete`:e===`restore_data`?`restore`:e===`write`?t?.del?`delete`:t?.patch?`edit`:`set`:null}function Yoe(e){return e===`spawn_agent`||e===`spawn_agents`||e.startsWith(`use_`)}function Xoe(e,t,n,r){let i=0;return{name:`sdk-events`,wrapToolCall:async(t,r)=>{let i=await r(t),a=Joe(t.name,t.args);return a?e({type:`data_change`,operation:a,value:n()?.bind}):i.status===`done`&&Yoe(t.name)&&e({type:`data_change`,operation:`edit`,value:n()?.bind}),i},afterModel:t=>{let n=TB(t.message);n&&(r.prompt_tokens=(r.prompt_tokens??0)+(n.prompt_tokens??0),r.completion_tokens=(r.completion_tokens??0)+(n.completion_tokens??0),r.total_tokens=(r.total_tokens??0)+(n.total_tokens??0),i++,e({type:`usage`,round:i,usage:n,cumulative:{prompt_tokens:r.prompt_tokens,completion_tokens:r.completion_tokens,total_tokens:r.total_tokens}}))},afterAgent:async()=>{e({type:`message_update`,count:t.length})}}}function P5(e,t,n,r,i){if(!n)return i&&console.warn(`[page-agent-sdk][focus] capabilities.focus 关闭,${t} 忽略`),{ok:!1,error:`capabilities.focus 关闭`};if(!e||!e.path)return i&&console.warn(`[page-agent-sdk][focus] ${t} 拒绝:path 必填且非空`),{ok:!1,error:`path 必填且非空`};let a=r();return a?WJ(a,e.path)?{ok:!0}:(i&&console.warn(`[page-agent-sdk][focus] ${t} 拒绝:path "${e.path}" 不在 schema 内(getSchemaAtPath 返 null;数组组件须 z.array(...) 包裹,裸 discriminatedUnion/Union 会降级)`),{ok:!1,error:`path "${e.path}" 不在 schema 内`}):(i&&console.warn(`[page-agent-sdk][focus] ${t} 拒绝:当前无主数据 schema`),{ok:!1,error:`当前无主数据 schema,无法聚焦`})}function Zoe(e,t){let n={prompt_tokens:0,completion_tokens:0,total_tokens:0},r=h8(()=>mt),i=vH(0),a=A8(e.storage);e.debug&&a&&a.onEvent(e=>console.log(`[page-agent-sdk][storage]`,e));let{modelCaps:o,summaryLlmInvoke:s,titleLlmInvoke:c,compressDecisionInvoke:l}=m8(e),u=o;if(e.debug&&console.log(`[page-agent-sdk][modelCaps]`,u),u.contextWindow<2e5)throw Error(`[page-agent-sdk] 模型上下文窗口 ${u.contextWindow} 小于最小支持 ${eJ}(需 ≥200K 窗口模型,如 GLM-5.2/Claude/Kimi/Qwen-1M/DeepSeek-v4)`);let d=I8(e,u.contextWindow),f=d.enableLLMSummary!==!1,p=(e.contextOptions&&e.contextOptions.preserveLastToolResults)??moe[e.contextPreset??`auto`],m=new Set(p),h=e.llm;e.debug&&!s&&console.warn(`[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要`);let g=sH([]),_=V6(e.vfs?.initialFiles,{persist:a?{save:e=>{Ht({vfs:e})}}:void 0,maxBytes:e.vfs?.maxBytes,poolBytes:e.vfs?.poolBytes}),v=xY([],{maxPlanRevisions:e.maxPlanRevisions}),y=TY(),b=ZY({getSchema:()=>_e()?.schema,getBind:()=>_e()?.bind,unfocusGuidance:e.toolMode===`advanced`?`tool`:`ask-user`,onChange:e=>mt({type:`focus_change`,focuses:e})}),x=eX(),S=bX(e.memory||``);typeof e.memory==`function`&&S.refresh();let C={current:null},w=e.data?{...e.data,description:e.data.description??`主数据对象`}:void 0,T=!(e.subagents??[]).some(e=>e._codeAsset)&&N8(e.capabilities).subagent,ee=e.subagents;T&&w?.schema&&YJ(w.schema).length&&(ee=[...e.subagents??[],o8()],console.info(`[page-agent-sdk] 检测到 schema 含代码组件数组(如 components[].code),已自动装配 HTML 代码子 agent(委派编排 + vfs 工作副本 + 格式校验 + 增量 commit)。需定制(codeField/formatCheck/craftNotes 等)请显式传 createHtmlSubagent(...)`));let E=(ee??[]).filter(e=>!!e._codeAsset),te=new Set;for(let e of E){if(e._codeAsset.writablePaths.length)continue;let t=YJ(w?.schema,e._codeAsset.codeField);t.length?(e._codeAsset.writablePaths=t,Array.isArray(e.writablePaths)&&(e.writablePaths=t),e._rebuildCodeAssetPaths?.(t[0]),console.info(`[page-agent-sdk][createHtmlSubagent] 未传 writablePaths,已从 schema 推断: [${t.map(e=>`'${e}'`).join(`, `)}]`)):(console.warn(`[page-agent-sdk][createHtmlSubagent] 未能从 schema 推断 writablePaths(开放 schema(z.any()/z.record())/嵌套容器(如 sections[].children[])/点路径 codeField(如 props.html_code)不支持自动推断),已跳过该 html 子 agent(整体不受影响);如确需代码资产机制(vfs + 格式校验 + 增量 commit),请显式传 writablePaths(代码组件 data 区,如 ['components'])`),te.add(e))}let ne=te.size?E.filter(e=>!te.has(e)):E,D=te.size?(ee??[]).filter(e=>!te.has(e)):ee,re=ne.length>0,O=ne.flatMap(e=>e._codeAsset.writablePaths),ie=ne.flatMap(e=>e._codeAsset.writablePaths.map(t=>`${t}.${e._codeAsset.codeField}`)),ae=e.checkpoint,oe=ae!==void 0&&ae!==!1,k=oe?RX({getData:()=>_e()?.bind,consumeDataDirty:()=>he?.consumeDataDirty?.()??!0,slotPaths:w?[``]:[],vfsStore:_,todosMw:v,getTodos:()=>C.current?.getState?.()?.todos??[],messages:g,maxCheckpoints:ae&&typeof ae==`object`?ae.maxCheckpoints:void 0}):null,se=!ae||typeof ae!=`object`||ae.auto!==!1,A=N8(e.capabilities),ce=A.dataOps,le=A.draftWrite,ue=A.tracing,de=A.automation,fe=R6(e);if(re){let e=ne.map(e=>e._codeAsset.orchestratorPrompt).filter(Boolean).join(`
338
338
 
339
339
  `);e&&(fe+=`
340
340
 
@@ -342,7 +342,7 @@ ${`- 输出形态:完整、自包含的 HTML 页面(.${r},可独立成页)`}
342
342
 
343
343
  `+fY.htmlDirectWriteFallback,console.warn(`[page-agent-sdk] 检测到 schema 含 code 字段但未注册 html 子 agent:已自动注入「主 agent 自己写 HTML」编排(code 作普通字段直接 write,无 vfs 工作副本 / 无格式校验门禁)。如需代码资产机制(vfs + 格式校验 + 增量 commit + 主上下文 code 摘要),注册 createHtmlSubagent;若确为降级意图可忽略。`));let pe=ce&&w?l5(w,{onAudit:e.onAudit??(e.debug?e=>console.log(`[page-agent-sdk][data audit]`,e):void 0),maxSnapshots:e.maxSnapshots,onConflict:r.set,autoLock:e.autoLock,interceptors:e.interceptors,vfsStore:le||w?.resources?.length?_:void 0,...O.length?{pgIdPaths:O}:{},...ie.length?{largeTextPaths:ie}:{}}):[],me=ce?r5(pe,e.toolMode):[],he=ce&&w?pe.controller??null:null,ge=ce&&w?.resources?.length&&he?.getResourcesSnapshot?Woe({getResourcesSnapshot:()=>he?.getResourcesSnapshot?.()??[],toolsExposed:e.toolMode===`advanced`}):void 0,_e=()=>he?.get()??w,ve=new Map,ye=C5(A,me,d5,m5,y5);ye.forEach(e=>ve.set(e.name,`builtin`));let be=[...e.tools||[]];be.forEach(e=>ve.set(e.name,`user`));let j=x5(e.actions??{});j.forEach(e=>ve.set(e.name,`action`));let xe=[],M=!1,Se=e.humanConfirm!==!1&&(!e.approval||e.approval.humanConfirmTool!==!1),N=Se?AX():null;N&&ve.set(OX,`builtin`);let Ce=oe&&k?[_B(async()=>{let e=k.list();return e.length?k.restore()?`已回退到最近一次正常状态(checkpoint #${e[e.length-1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。`:`回退失败:无可用 checkpoint。`:`无可用 checkpoint,无法回退。`},{name:`restore_last_checkpoint`,description:`回退到最近一次正常状态(整体还原对话历史 + 主数据 + vfs + todos)。当本轮操作出错、页面被改坏、或走偏时调用,回到本轮起点重新来过。不传参数即回退最近一次。`,schema:L({}).optional()}),_B(async()=>{let e=k.list();return e.length?`可用 checkpoint:
344
344
  `+e.map(e=>`#${e.id} [${e.label??`auto`}] 消息数=${e.messageCount} 时间=${new Date(e.timestamp).toLocaleTimeString()}`).join(`
345
- `):`无可用 checkpoint。`},{name:`list_checkpoints`,description:`列出可用会话 checkpoint(回退点)。`,schema:L({}).optional()})]:[];Ce.forEach(e=>ve.set(e.name,`builtin`));let we=A.focus,Te=_B(async({path:e,label:t})=>{let n=_e()?.schema;return n?WJ(n,e)?(b.setFocus({path:e,...t?{label:t}:{}}),`已聚焦到 ${e}${t?`(${t})`:``}。后续仅可写该子树(越界被拒),每轮只看到该组件结构。完成精修后调 clear_focus 退出。`):`PATH_DENIED · 聚焦失败:path "${e}" 不在 schema 内。请先用 read 查看可操作路径再聚焦。`:`聚焦失败:当前无主数据 schema,无法聚焦。`},{name:`set_focus`,description:`聚焦到指定组件子树(如 components.3)精修,替换全部已有焦点(非累积;要保留已有焦点追加用 add_focus)。聚焦后:仅可写该子树(越界 PATH_DENIED)+ 每轮只看到该组件结构。多组件页面精修其中一个时用,避免改到别处。先 read 定位 path 再聚焦;完成调 clear_focus。`,schema:L({path:F().describe(`要聚焦的组件 jsonPath,如 components.3`),label:F().optional().describe(`人类可读标签,如「导航栏」`)})}),Ee=_B(async()=>(b.clearFocus(),`已清除聚焦,恢复全量可操作范围(可读写所有组件)。`),{name:`clear_focus`,description:`清除当前聚焦,退出精修模式,恢复对全部组件的读写权限。`,schema:L({}).optional()}),De=_B(async({path:e,label:t})=>{let n=_e()?.schema;if(!n)return`聚焦失败:当前无主数据 schema,无法聚焦。`;if(!WJ(n,e))return`PATH_DENIED · 聚焦失败:path "${e}" 不在 schema 内。请先用 read 查看可操作路径再聚焦。`;b.addFocus({path:e,...t?{label:t}:{}});let r=b.getFocuses();return`已聚焦 ${e}${t?`(${t})`:``}(当前共 ${r.length} 个焦点:${r.map(e=>e.path).join(`, `)})。后续仅可写这些子树之一(越界被拒)。`},{name:`add_focus`,description:`追加聚焦一个组件子树(multi-focus,可同时聚焦多个相关组件)。校验 path 在 schema 内。聚焦后仅可写已聚焦的子树之一(越界 PATH_DENIED)。与 set_focus(替换全部)不同:本工具累积追加,不清除已有焦点。`,schema:L({path:F().describe(`要追加聚焦的组件 jsonPath,如 components.3`),label:F().optional().describe(`人类可读标签`)})}),Oe=_B(async({path:e})=>{let t=b.getFocuses().length;b.removeFocus(e);let n=b.getFocuses();return n.length===t?`path "${e}" 不在当前焦点列表中(当前:${n.map(e=>e.path).join(`, `)||`无`})。`:n.length?`已移除焦点 ${e}(剩余 ${n.length} 个:${n.map(e=>e.path).join(`, `)})。`:`已移除焦点 ${e},聚焦已清空,恢复全量操作范围。`},{name:`remove_focus`,description:`移除单个聚焦焦点(by path),保留其他焦点。移除最后一个等价退出精修。全部退出用 clear_focus。`,schema:L({path:F().describe(`要移除的焦点 jsonPath`)})}),ke=we&&e.toolMode===`advanced`?[Te,Ee,De,Oe]:[];ke.forEach(e=>ve.set(e.name,`builtin`));let Ae=[],je=new Map,Me=Ne();function Ne(){let{tools:e,collisions:t}=Uoe([{label:`builtin`,tools:ye},{label:`user`,tools:be},{label:`action`,tools:j},{label:`humanConfirm`,tools:N?[N]:[]},{label:`checkpoint`,tools:Ce},{label:`focus`,tools:ke},{label:`mcp`,tools:xe},{label:`skill`,tools:Ae}]);return t.length&&console.warn(`[page-agent-sdk] 工具重名,后注册覆盖先注册:`,t.map(e=>`${e.name}(${e.loser}→${e.winner})`).join(`, `)),e}let Pe=A.planning,Fe=A.missionAnchor,Ie=A.workingMemory,Le=A.skills,Re=A.vfs||re;if(Re)for(let e of Aae)ve.set(e,`builtin`);if(Pe)for(let e of v.tools??[])ve.set(e.name,`builtin`);let ze=A.summarization,Be=A.agentCompression&&!!l;e.debug&&A.agentCompression&&!l&&console.warn(`[page-agent-sdk][agentCompression] agentCompression 开启但 summaryLlm 不可用(或缺 apiKey / 模型不支持工具),压缩决策不启用,回退静态压缩`);let Ve=A.memory,He=A.subagent,Ue=He?cZ():void 0,We=e.verify?.maxAttempts??2,Ge=!!(e.verify?.check||e.verify?.maxAttempts||e.verify?.adversarial),Ke=e.capabilities?.verify===!1,qe=(A.verify||Ge&&!Ke)&&e.verify?.enabled!==!1&&We>0,Je=A.contextInspector;Ge&&!qe&&e.verify?.enabled!==!1&&console.warn(`[page-agent-sdk][verify] 检测到 verify 配置(check/maxAttempts/adversarial)但未装载(capabilities.verify:false 显式关闭 或 maxAttempts≤0)`);let Ye=e.subagent,Xe=Ye?.allowedTools??[],Ze=e.permissions?.length?EX(e.permissions):void 0,Qe=e.approval&&(e.approval.tools!==void 0||e.approval.confirm)?DX(e.approval):void 0,$e=[...Ze?[Ze]:[],...Qe?[Qe]:[]],et=!He||Ye?.enabled===!1?void 0:wZ({llm:Ye?.llm??e.llm,allTools:()=>P.agent?.allTools??Me,allowedTools:Xe.length?Xe:void 0,systemPrompt:Ye?.systemPrompt,temperature:Ye?.temperature,maxTokens:Ye?.maxTokens,skills:Ye?.skills,maxDepth:Ye?.maxDepth,maxParallel:Ye?.maxParallel,debug:e.debug,getFocuses:()=>b.getFocuses(),getSchema:()=>_e()?.schema??null,tracker:Ue,guardMiddleware:$e.length?$e:void 0,getVfsFiles:Re?()=>_.files:void 0,enterDataScope:he?.enterScope?e=>he.enterScope(e):void 0,exitDataScope:he?.exitScope?e=>he.exitScope(e):void 0,onUsage:e=>{n.prompt_tokens=(n.prompt_tokens??0)+(e.prompt_tokens??0),n.completion_tokens=(n.completion_tokens??0)+(e.completion_tokens??0),n.total_tokens=(n.total_tokens??0)+(e.total_tokens??0)},timeoutMs:Ye?.timeoutMs}),tt=D?.map(e=>{if(!e._codeAsset)return e;let t=e._codeAsset,n=Rae({writablePaths:t.writablePaths,codeVfsPrefix:t.codeVfsPrefix,ext:t.ext,codeField:t.codeField,craftNotes:t.craftNotes,onWarning:e=>console.warn(`[page-agent-sdk][code-asset] ${e}`),getController:()=>he,vfsStore:_}),r=[...e.middleware??[],n];for(let e of r)e&&typeof e==`object`&&typeof e._setGetController==`function`&&e._setGetController(()=>he);return{...e,middleware:r}}),nt=re&&He?zae():void 0,rt=nt?Gae({getBind:()=>_e()?.bind,writablePaths:O,getLocked:()=>nt.locked(),tools:Me}):void 0,it=He&&tt!==void 0?DZ(tt,{llm:e.llm,allTools:()=>P.agent?.allTools??Me,debug:e.debug,getFocuses:()=>b.getFocuses(),getSchema:()=>_e()?.schema??null,getBind:()=>_e()?.bind,tracker:Ue,guardMiddleware:$e.length?$e:void 0,getVfsFiles:Re?()=>_.files:void 0,enterDataScope:he?.enterScope?e=>he.enterScope(e):void 0,exitDataScope:he?.exitScope?e=>he.exitScope(e):void 0,onUsage:e=>{n.prompt_tokens=(n.prompt_tokens??0)+(e.prompt_tokens??0),n.completion_tokens=(n.completion_tokens??0)+(e.completion_tokens??0),n.total_tokens=(n.total_tokens??0)+(e.total_tokens??0)},timeoutMs:e.subagent?.timeoutMs,...nt?{componentLock:nt,resolveComponents:e=>Bae(e,Iae(_e()?.bind,O))}:{}}):void 0,at=it?it.controller:null,ot=[`get_data`,`describe_data`,`read`,`fetch_document`],st=Me.filter(e=>ot.includes(e.name)),ct=qe?OZ({check:e.verify.check??PZ({schemas:()=>_e()?{"":_e().schema}:{},root:()=>_e()?.bind}),adversarial:e.verify?.adversarial?{llm:e.llm,tools:st}:void 0}):void 0,lt=Je?JZ({contextWindow:u.contextWindow,thresholdRatio:I8(e,u.contextWindow).summaryThresholdRatio}):void 0,ut=T5({...A,humanConfirm:Se,subagents:D?.map(e=>({id:e.id,description:e.description,temperature:e.temperature}))},ce&&!!w,e.toolMode,!!w?.resources?.length,{promptSoftCap:rZ(u.contextWindow,d.promptSoftCapTokens)}),dt=w?{name:`dataHint`,augmentPrompt:()=>L6(_e(),e.schemaHint)||void 0}:null,ft=e.augmentSystem?{name:`augmentSystem`,augmentPrompt:t=>{try{return e.augmentSystem({state:t,data:_e()})}catch(t){e.debug&&console.log(`[page-agent-sdk][augmentSystem] 回调抛错,降级跳过:`,t.message);return}}}:null,pt=P8(e.onEvent),mt=pt.emit,ht,gt=[],_t=e=>({name:e.name,description:e.description,content:typeof e.getContent==`function`?e.getContent():``}),vt=e=>({name:e.name,description:e.description,getContent:()=>e.content}),yt=e.skillStorage===!1?null:k5({...typeof e.skillStorage==`object`?e.skillStorage:{},id:e.skillStorage&&typeof e.skillStorage==`object`&&e.skillStorage.id?e.skillStorage.id:`agent::${t}`}),bt=()=>{let t=ht?ht.controller:null;if(t){let n=(e.skills||[]).filter(e=>!gt.some(t=>t.name===e.name));t.set([...n,...gt])}P.infoTick.value++},xt=async()=>{if(yt)try{let t=await yt.list();if(t.length){gt=t.map(vt);let n=ht?ht.controller:null;if(n){let t=(e.skills||[]).filter(e=>!gt.some(t=>t.name===e.name));n.set([...t,...gt])}P.infoTick.value++}}catch{}},St=ze?sZ({...d,llmInvoke:s,getRegisteredData:()=>_e()?[{description:_e().description??`主数据对象`}]:[],preserveLastToolResults:p,...Be?{decideInvoke:l,getSnapshot:()=>lt?.getSnapshot()}:{}}):void 0,Ct=goe([...dt?[dt]:[],ut,...Fe?[y]:[],...Pe?[v]:[],...Le?[ht=yX(e.skills||[],{readVfs:Re?e=>_.files[e]?.content:void 0,hostScriptEnabled:A.skillHostScript,onToolsReady:(e,t)=>{for(let n of t){let t=Ae.findIndex(e=>e.name===n.name);t>=0&&Ae.splice(t,1),Ae.push(n),je.set(n.name,e),ve.set(n.name,`skill:${e}`)}Me=Ne(),P.agent&&P.agent.setTools(Me),P.infoTick.value++}})]:[],...Re?[Mae(_)]:[],...St?[St]:[],...Ie?[x]:[],...we?[b]:[],...ge?[ge]:[],...Ve?[S]:[],...Ze?[Ze]:[],...oe&&se&&k?[zX(k)]:[],...Se?[jX()]:[],...Qe?[Qe]:[],...ct?[ct]:[],...et?[et]:[],...it?[it]:[],...rt?[rt]:[],...ft?[ft]:[],...lt?[lt]:[],...e.middleware||[],...de?[zoe(n,{tokenBudget:e.tokenBudget,timeBudgetMs:e.timeBudgetMs},mt)]:[],Xoe(mt,g,_e,n)]),wt=e.maxMemoryRounds??qoe,Tt=e.approval?.timeoutMs,Et=Tt===void 0||Tt===0?3e4:!Number.isFinite(Tt)||Tt<0?0:Tt;function Dt(e){if(Et)return t=>{if(t.type!==`approval_request`)return;let n=Date.now(),r=t.toolName;setTimeout(()=>{e?.aborted||(t.resolve(!1),mt({type:`error`,message:`确认请求(${r})${Math.round((Date.now()-n)/1e3)}s 无响应已自动拒绝 —— send/batch 路径无 UI 响应方;可传 approval.timeoutMs 调整(Infinity = 无限等)`,severity:`observable`,code:`APPROVAL_AUTO_REJECTED`,context:{toolName:r,waitedMs:Date.now()-n}}))},Et)}}function Ot(e){let t=Dt(e);return e=>{t?.(e),e.type===`error`&&mt(e)}}let kt=vH([]);async function At(){a&&(kt.value=(await a.listSessions(t)).sort((e,t)=>t.lastAccessed-e.lastAccessed))}let jt=M5(),Mt=new Set;function Nt(e){let t=new AbortController;return e&&(e.aborted?t.abort():e.addEventListener(`abort`,()=>t.abort(),{once:!0})),Mt.add(t),{controller:t,untrack:()=>Mt.delete(t)}}function Pt(){for(let e of Mt)e.abort();Mt.clear()}let P={agentId:t,store:a,messages:g,vfsStore:_,listeners:pt.listeners,todosMw:v,memoryMw:S,missionMw:y,workingMemoryMw:x,focusMw:b,agent:null,initDone:Promise.resolve(),sessionId:``,refCount:0,mcpClosers:[],mcpServers:[],checkpoint:k,dataOpsController:he,skillsController:ht?ht.controller:null,infoTick:i,pendingConflict:r.pendingConflict,sessions:kt,refreshSessions:At,liveData:_e,usage:n,emit:mt,runSerial:jt,trackActive:Nt,abortAllActive:Pt,unloadSkillTools(e){if(e){let t=Ae.length;if(Ae=Ae.filter(t=>je.get(t.name)===e?(ve.delete(t.name),je.delete(t.name),!1):!0),Ae.length===t)return}else{if(!Ae.length)return;for(let e of Ae)ve.delete(e.name),je.delete(e.name);Ae=[]}Me=Ne(),P.agent&&P.agent.setTools(Me)},applySnapshot(t){if(t.messages?.length&&g.push(...t.messages),t.vfs&&_.hydrate&&_.hydrate(t.vfs),t.todos?.length&&v.reset(t.todos),t.memory&&!e.memory&&S.reset(t.memory),t.checkpoints?.length&&k&&k.importStack(t.checkpoints),t.usage&&Object.assign(n,t.usage),t.mission&&Fe&&y.setMission(t.mission),t.workingMemory&&Ie&&x.restore(t.workingMemory),we){let n=t.focus,r=n?Array.isArray(n)?n:[n]:[];if(r.length){let t=_e()?.schema,n=t?r.filter(e=>WJ(t,e.path)):[];if(n.length&&(b.setFocus(null),n.forEach(e=>b.addFocus(e))),e.debug&&n.length<r.length){let e=r.filter(e=>!n.includes(e)).map(e=>e.path);console.warn(`[page-agent-sdk][focus] 恢复的焦点部分 path 已失效(schema 变化/无 schema),剔除:`,e)}}}Rt()},addSkill(e){let t=gt.findIndex(t=>t.name===e.name);t>=0?gt[t]=e:gt.push(e),bt(),yt&&yt.put(_t(e))},removeSkill(e){let t=gt.findIndex(t=>t.name===e);return t<0?!1:(gt.splice(t,1),bt(),yt&&yt.remove(e),!0)},listUserSkills(){return gt.map(e=>e.name)},getUserSkill(e){let t=gt.find(t=>t.name===e);if(t)return{name:t.name,description:t.description,content:typeof t.getContent==`function`?t.getContent():``}},afterRound(){zt(),Ht()},async send(e,t){await P.initDone,t??={},t?.mission&&Fe&&y.setMission(t.mission);let n=e;if(t.interceptors?.input)try{let r=t.interceptors.input(e);typeof r==`string`&&(n=r)}catch{}let r=de?t.maxAutoRetries??1:0,i=0,o=!1,s=Ot(t.signal);for(;;){o||=(g.push({role:`user`,content:n,timestamp:Date.now()}),!0);try{let e=await P.agent.invoke(g,t.signal,s);if(t.interceptors?.output)try{let n=t.interceptors.output(e);typeof n==`string`&&(e=n)}catch{}return g.push({role:`assistant`,content:e,timestamp:Date.now()}),P.afterRound(),a&&await a.flush(),e}catch(e){if(sJ(e,t.signal))throw e;let n=Kq(e,`fatal`);if(i<r&&k?.canRestore()){i+=1,k.restore(),o=!0,mt({type:`error`,message:`致命错误自动恢复(${i}/${r}):${n.message},已回退 checkpoint 重试`,severity:`observable`,code:`AUTO_RECOVER_RETRY`,context:{attempt:i,cause:n.code??n.message.slice(0,120)}});continue}throw mt({type:`error`,message:n.message,severity:n.severity,...n.code?{code:n.code}:{},...n.context===void 0?{}:{context:n.context}}),e}}},async batch(e,t,n){if(await P.initDone,!e.length)return[];let r=[],i=Ot(n);for(let o=0;o<e.length;o++){if(n?.aborted){for(let t=o;t<e.length;t++)r.push({index:t,task:e[t],error:`aborted(外部中止)`,ok:!1});break}let s=e[o];k&&k.save(`batch:${o}`);let c=g.length;try{g.push({role:`user`,content:s,timestamp:Date.now()});let c=await P.agent.invoke(g,n,i);g.push({role:`assistant`,content:c,timestamp:Date.now()}),P.afterRound(),a&&await a.flush(),r.push({index:o,task:s,reply:c,ok:!0}),t?.({done:o+1,total:e.length,task:s,ok:!0})}catch(i){if(g.length>c&&g.splice(c),sJ(i,n)){r.push({index:o,task:s,error:`aborted(外部中止)`,ok:!1});for(let t=o+1;t<e.length;t++)r.push({index:t,task:e[t],error:`aborted(外部中止)`,ok:!1});break}let a=Kq(i,`fatal`);mt({type:`error`,message:`批量任务 ${o+1}/${e.length} 失败:${a.message}`,severity:`observable`,code:`BATCH_TASK_FAILED`,context:{index:o,task:s.slice(0,100)}}),r.push({index:o,task:s,error:a.message,ok:!1}),t?.({done:o+1,total:e.length,task:s,ok:!1})}}return r},async switchSession(n){if(await P.initDone,!a)throw Error(`page-agent-sdk: storage 未开启,无法切换会话(请传 storage 选项)`);if(r.resolve(`keep_external`),P.sessionId&&a){if(Fe){let e=y.getMission();e&&a.save(t,P.sessionId,{mission:e})}if(Ie){let e=x.getWorkingMemory();e&&a.save(t,P.sessionId,{workingMemory:e})}if(we){let e=b.getFocuses();a.save(t,P.sessionId,{focus:e.length?e:null})}}_.flush?.(),await a.flush();let i=n??``,o;return i?(o=await a.load(t,i),o||await a.createSession(t,e.session?.title,i)):i=await a.createSession(t,e.session?.title),P.sessionId=i,g.splice(0,g.length),_.clear?.(),v.reset([]),e.memory||S.reset(``),y.reset(),x.reset(),b.reset(),k&&k.importStack([]),P.agent.debugLogs.value=[],o||=await a.load(t,i),o&&(P.applySnapshot(o),mt({type:`session_restored`,sessionId:i,rounds:o.messages?.length??0})),e.memory&&a.save(t,P.sessionId,{memory:S.get()||(typeof e.memory==`string`?e.memory:``)}),At(),Bt=void 0,Vt=!1,P.infoTick.value++,i},resetSession:()=>{Pt(),r.resolve(`keep_external`),P.sessionId=g8(),g.splice(0,g.length),_.clear?.(),v.reset([]),e.memory||S.reset(``),y.reset(),x.reset(),b.reset(),k&&k.importStack([]),P.agent&&(P.agent.debugLogs.value=[]),a&&a.createSession(P.agentId,e.session?.title,P.sessionId),mt({type:`session_restored`,sessionId:P.sessionId,rounds:0}),P.infoTick.value++,At(),Bt=void 0,Vt=!1},stream:(e,t,n)=>{if(!P.agent)throw Error(`page-agent-sdk: agent 尚未初始化完成,请先 await mount()`);_?.setProtectedRefs?.(j5(e));let i=e=>{t?.(e),mt(e),e.type===`subagent`&&(e.kind===`tool_call`||e.kind===`tool_result`)&&P.infoTick.value++};if(n){let e=()=>r.resolve(`keep_external`);n.aborted?e():n.addEventListener(`abort`,e,{once:!0})}let{controller:a,untrack:o}=Nt(n);return P.agent.stream(e,i,a.signal).finally(o)},release(){if(P.refCount--,P.refCount<=0){Pt(),M=!0,a&&(_.flush?.(),a.flush(),a.dispose()),yt&&yt.dispose();let e=P.mcpClosers.splice(0);e.length&&Promise.allSettled(e.map(e=>e())),N5.delete(t)}},resolveConflict:r.resolve,setTools(e){be.length=0,e.forEach(e=>{be.push(e),ve.set(e.name,`user`)}),Me=Ne(),P.agent&&P.agent.setTools(Me),P.infoTick.value++},addTool(e){Me.some(t=>t.name===e.name)&&console.warn(`[page-agent-sdk] 工具 "${e.name}" 已存在,新工具覆盖(后注册覆盖先注册)`);for(let t=be.length-1;t>=0;t--)be[t].name===e.name&&be.splice(t,1);be.push(e),ve.set(e.name,`user`),Me=Ne(),P.agent&&P.agent.setTools(Me),P.infoTick.value++},removeTool(e){let t=be.findIndex(t=>t.name===e);return t<0?!1:(be.splice(t,1),ve.delete(e),Me=Ne(),P.agent&&P.agent.setTools(Me),P.infoTick.value++,!0)},setLlm(t){let n;if(u8(t))n=t;else{let e=t;if((e.provider??`openai`)===`anthropic`)throw Error(`[page-agent-sdk][setLlm] 切换到 Anthropic 需传 BaseChatModel 实例(动态 import 无法同步);请先 const { ChatAnthropic } = await import("@langchain/anthropic") 构造实例后传入`);n=bB(e)}typeof n.bindTools!=`function`&&e.debug&&console.warn(`[page-agent-sdk][setLlm] 新模型不支持 bindTools(tool calling 会失效)`),h=t;let r=u8(t)?void 0:t;if(u=tJ({model:r?.model??t.model??t.modelName,contextWindow:e.contextWindow??r?.contextWindow,maxOutputTokens:e.maxOutputTokens??r?.maxOutputTokens}),u.contextWindow<2e5)throw Error(`[page-agent-sdk][setLlm] 新模型上下文窗口 ${u.contextWindow} 小于最小支持 ${eJ}(需 ≥200K 窗口模型)`);P.agent&&(P.agent.setLlm(n),P.agent.setModelCaps?.(u)),St?.setContextWindow?.(u.contextWindow),lt?.setContextWindow?.(u.contextWindow),P.infoTick.value++,e.debug&&console.log(`[page-agent-sdk][setLlm] 重解析 modelCaps + 回灌:`,u)},setMemory(e){S.reset(e),typeof e==`function`&&S.refresh(),P.infoTick.value++},refreshMemory(){return S.refresh()},setSubagents(t){if(!at){e.debug&&console.warn(`[page-agent-sdk][setSubagents] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略`);return}at.set(t),P.infoTick.value++},addSubagent(t){if(!at){e.debug&&console.warn(`[page-agent-sdk][addSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略`);return}at.add(t),P.infoTick.value++},removeSubagent(t){if(!at)return e.debug&&console.warn(`[page-agent-sdk][removeSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略`),!1;let n=at.remove(t);return n&&P.infoTick.value++,n},getActiveSubagents(){return Ue?.getActive()??[]},get subagentHistory(){return Ue?.getHistory()??[]},getInfo(){return{id:t,sessionId:P.sessionId,model:u8(h)?h.model??h.modelName:h.model,systemPrompt:P.agent?.getEffectiveSystemPrompt?.()??fe+L6(_e(),e.schemaHint),tools:(P.agent?.allTools??Me).map(e=>({name:e.name,description:e.description,schema:e.schema,source:ve.get(e.name)||`user`})),skills:(ht?ht.controller.get():e.skills??[]).map(e=>({name:e.name,description:e.description})),data:_e()?{description:_e().description,schema:_e().schema}:void 0,contextPreset:e.contextPreset??`auto`,compression:{contextWindow:u.contextWindow,summaryThresholdRatio:d.summaryThresholdRatio??.5,promptSoftCap:rZ(u.contextWindow,d.promptSoftCapTokens)},memory:S.get(),middleware:Ct.map(e=>e.name),todos:(P.agent?.getState?.()?.todos??[]).map(e=>({id:e.id,content:e.content,status:e.status,...e.parentId===void 0?{}:{parentId:e.parentId},...e.deps===void 0?{}:{deps:e.deps},...e.criteria===void 0?{}:{criteria:e.criteria},...e.evidence===void 0?{}:{evidence:e.evidence}})),planPhase:v.getPlanPhase(),mission:Fe?y.getMission():void 0,workingMemory:Ie?x.getWorkingMemory():void 0,focus:we?b.getFocus():void 0,focuses:we?b.getFocuses():[],trace:ue&&P.agent?.spans?{spans:P.agent.spans.value,metrics:aJ(P.agent.spans.value)}:void 0,actions:S5(e.actions??{}),subagent:{enabled:!!et,maxDepth:e.subagent?.maxDepth??1,maxParallel:e.subagent?.maxParallel??4,allowedTools:e.subagent?.allowedTools??[],subagents:at?.get()??[],active:Ue?.getActive()??[],history:Ue?.getHistory()??[],lockedComponents:nt?.locked()??{}},verify:{enabled:!!ct,maxAttempts:qe?We:0,adversarial:qe&&!!e.verify?.adversarial},context:(()=>{let e=lt?.getSnapshot();if(e){let t=P.agent?.getState?.()?.lastCompression;t&&(e.compression=t)}return e})(),mcp:{servers:P.mcpServers},lastCompression:P.agent?.getState?.()?.lastCompression,checkpoints:k?{enabled:!0,auto:se,list:k.list()}:void 0}},getMission(){return Fe?y.getMission():void 0},setMission(t){if(!Fe){e.debug&&console.warn(`[page-agent-sdk][mission] capabilities.missionAnchor 关闭,setMission 忽略`);return}y.setMission(t),P.infoTick.value++},getFocus(){return we?b.getFocus():void 0},getFocuses(){return we?b.getFocuses():[]},setFocus(t){let n=P5(t,`setFocus`,we,()=>_e()?.schema,e.debug);return n.ok?(b.setFocus(t),P.infoTick.value++,{ok:!0}):n},addFocus(t){let n=P5(t,`addFocus`,we,()=>_e()?.schema,e.debug);return n.ok?b.getFocuses().length>=8?(e.debug&&console.warn(`[page-agent-sdk][focus] addFocus 拒绝:焦点数已达上限 8(augmentPrompt 注入每焦点子树 schema,过多致 system prompt 超预算)`),{ok:!1,error:`焦点数上限 8(避免 system prompt 撑爆)`}):(b.addFocus(t),P.infoTick.value++,{ok:!0}):n},removeFocus(e){we&&(b.removeFocus(e),P.infoTick.value++)},clearFocus(){we&&(b.clearFocus(),P.infoTick.value++)}};async function Ft(){if(!a)return;await a.ready;let n=e.session||{};if(n.id){P.sessionId=n.id;let e=await a.load(t,P.sessionId);e?(P.applySnapshot(e),mt({type:`session_restored`,sessionId:P.sessionId,rounds:e.messages?.length??0})):await a.createSession(t,n.title,P.sessionId)}else if(n.autoResume!==!1){let r=await a.listSessions(t);if(e.debug&&console.log(`[page-agent-sdk][restore] listSessions`,t,r.length,r.map(e=>e.sessionId)),r.length){P.sessionId=r[0].sessionId;let n=await a.load(t,P.sessionId);n?(P.applySnapshot(n),mt({type:`session_restored`,sessionId:P.sessionId,rounds:n.messages?.length??0}),e.debug&&console.log(`[page-agent-sdk][restore] 恢复会话`,P.sessionId,`${n.messages?.length??0} msgs`)):e.debug&&console.log(`[page-agent-sdk][restore] 会话 meta 存在但快照为空`,P.sessionId)}else P.sessionId=await a.createSession(t,n.title),e.debug&&console.log(`[page-agent-sdk][restore] 新建会话(无历史)`,P.sessionId)}else P.sessionId=await a.createSession(t,n.title);e.memory&&a.save(t,P.sessionId,{memory:S.get()||(typeof e.memory==`string`?e.memory:``)}),At()}async function It(){await xt()}function Lt(e){let t={};for(let n of j5(e)){let e=_.files[n];e&&(t[n]=e.content)}return t}function Rt(){let e=Koe(_.files,j5(g));for(let t of e)delete _.files[t]}function zt(){let e=JX(g,wt);if(!e.trimmed)return;let{older:t,summary:n}=e;if(mt({type:`context_trimmed`,dropped:t.map(e=>({round:e.round,user:e.userMsg.content,assistant:e.assistantMsgs.map(e=>e.content),steps:e.assistantMsgs.flatMap(e=>e.steps??[])})),vfsResults:Lt(t.flatMap(e=>[e.userMsg,...e.assistantMsgs])),summary:n.content,reason:`max_memory_rounds`}),g.splice(e.deleteFrom,e.deleteCount,n),Rt(),f&&s){let n=e.summary,{prevSeg:r}=e;(async()=>{try{let e=await s($X(t,m)),i=g.indexOf(n);if(i<0)return;g[i].content=qX(t,r,e),Ht()}catch{}})()}}let Bt,Vt=!1;function Ht(){if(!P.sessionId||!a)return;let r=JSON.parse(JSON.stringify(g));a.save(t,P.sessionId,{messages:r});let i=P.agent?.getState?.()?.todos??[];if(a.save(t,P.sessionId,{todos:i}),Fe){let e=y.getMission();e&&a.save(t,P.sessionId,{mission:e})}if(Ie){let e=x.getWorkingMemory();e&&a.save(t,P.sessionId,{workingMemory:e})}if(we){let e=b.getFocuses();a.save(t,P.sessionId,{focus:e.length?e:null})}de&&k&&(a.save(t,P.sessionId,{checkpoints:k.exportStack()}),a.save(t,P.sessionId,{usage:n}));let o=l8(g);o&&o!==Bt&&(Bt=o,a.updateTitle(t,P.sessionId,o)),e.autoTitle!==!1&&c&&!Vt&&g.some(e=>e.role===`user`)&&g.some(e=>e.role===`assistant`)&&(Vt=!0,(async()=>{let e=await c(g);e&&(await a.updateTitle(t,P.sessionId,e),await At())})()),e.debug&&console.log(`[page-agent-sdk][persist] save`,P.sessionId,`${g.length} msgs`)}return P.initDone=(async()=>{await Ft(),await It(),e.mcp?.length&&(async()=>{let t=await Promise.allSettled(e.mcp.map(e=>F6(e))),n=t.flatMap(e=>e.status===`fulfilled`?[e.value.close]:[]);if(M){Promise.allSettled(n.map(e=>e()));return}P.mcpClosers=n,P.mcpServers=[];let r=new Set;for(let e of Me){let t=ve.get(e.name);t&&!t.startsWith(`mcp:`)&&r.add(e.name)}t.forEach((t,n)=>{let i=e.mcp[n],a=i.name??i.url;t.status===`fulfilled`?(P.mcpServers.push({name:a,url:i.url,toolCount:t.value.tools.length}),t.value.tools.forEach(e=>{if(r.has(e.name)){console.warn(`[page-agent-sdk][mcp] 工具 "${e.name}" 与内置工具重名,已拒绝注入(安全保留字保护)`);return}ve.set(e.name,`mcp:${a}`),xe.push(e)})):console.warn(`[page-agent-sdk][mcp] server ${a} 连接失败:`,t.reason)}),xe.length&&(Me=Ne(),P.agent&&P.agent.setTools(Me),P.infoTick.value++),e.debug&&console.log(`[page-agent-sdk][mcp] 注入 ${xe.length} 个工具,${P.mcpServers.length} 个 server`)})();let t=u8(e.llm)?e.llm:await xB(e.llm);P.agent=BJ({llm:t,systemPrompt:fe,tools:Me,middleware:Ct,maxToolRounds:e.maxToolRounds,maxRetries:e.maxRetries,stallMs:e.streamStallMs??9e4,maxParallelTools:e.maxParallelTools,contextWindow:u.contextWindow,maxOutputTokens:u.maxOutputTokens,maxVerifyAttempts:qe?We:0,roundTokenBudget:e.roundTokenBudget??0,onLlmChange:e=>{h=e},onTrace:ue?(e,t)=>{try{mt({type:`trace`,spans:e,metrics:t})}catch{}}:void 0,debug:e.debug}),C.current=P.agent,it&&it.setReconfigureHook&&it.setReconfigureHook(()=>{P.agent&&P.agent.setTools(Ne())})})(),P}function Qoe(e,t){let n=e.id??g8();e.id||console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${n}"。刷新后持久化数据无法恢复,请传稳定 id。`);let r=e.streaming??!0,i=e.ui??`default`,a,o=e.shareContext?N5.get(n):void 0;o?a=o:(a=Zoe(e,n),e.shareContext&&N5.set(n,a)),a.refCount++;let s=null,c=j8(e),l=null,u=null;async function d(n){if(await a.initDone,s){s.show();return}let o=n===void 0?e.container:n,d=()=>{a.store&&(l=()=>{a.vfsStore.flush?.(),a.store.flush()},u=()=>{document.visibilityState===`hidden`&&a.store.flush()},typeof window<`u`&&window.addEventListener(`pagehide`,l),typeof document<`u`&&document.addEventListener(`visibilitychange`,u))};if(i===!1||!t){i!==!1&&console.warn(`[page-agent-sdk/headless] 未含 UI 组件,ui 渲染降级 headless;如需 UI 请 import page-agent-sdk 主包`),d();return}let m=typeof o==`string`?document.querySelector(o):o;if(!m)throw Error(`createChatSdk: 挂载点未找到(${o})`);s=t({el:m,core:a,dialogCfg:c,streaming:r,runSerial:a.runSerial,hide:p,unmount:f,onDialogUnmounted:()=>{s=null,a.release()}}),c.drawer===!0&&c.drawerHidden===!0&&s.hide(),d()}function f(){a.abortAllActive(),a.resolveConflict(`keep_external`),l&&typeof window<`u`&&window.removeEventListener(`pagehide`,l),u&&typeof document<`u`&&document.removeEventListener(`visibilitychange`,u),l=null,u=null,s?s.unmount():a.release()}function p(){s?.hide()}function m(){s?.show()}return{mount:d,unmount:f,hide:p,show:m,send:(e,t)=>a.runSerial(async()=>{let{controller:n,untrack:r}=a.trackActive(t?.signal);try{return await a.send(e,{...t,signal:n.signal})}finally{r()}}),batch:(e,t,n)=>a.runSerial(async()=>{let{controller:r,untrack:i}=a.trackActive(n);try{return await a.batch(e,t,r.signal)}finally{i()}}),switchSession:(...e)=>a.runSerial(async()=>(a.abortAllActive(),a.switchSession(...e))),resetSession:()=>a.resetSession(),sessions:a.sessions,async listSessions(){return a.store?a.store.listSessions(n):[]},async deleteSession(e){if(a.store){if(e===a.sessionId){console.warn(`[page-agent-sdk] deleteSession 忽略:不能删除当前会话,请先 switchSession 切到其他会话`);return}await a.store.deleteSession(n,e),await a.refreshSessions()}},get sessionId(){return a.sessionId},stream:(e,t,n)=>a.stream(e,t,n),afterRound:a.afterRound,get debugLogs(){return a.agent.debugLogs},infoTick:a.infoTick,inspect:a.getInfo,inspectContext:()=>a.getInfo().context,getMission:a.getMission,setMission:a.setMission,getFocus:a.getFocus,getFocuses:a.getFocuses,setFocus:a.setFocus,addFocus:a.addFocus,removeFocus:a.removeFocus,clearFocus:a.clearFocus,messages:a.messages,restoreLastCheckpoint:()=>a.checkpoint?.restore()??!1,listCheckpoints:()=>a.checkpoint?.list()??[],hook:e=>(a.listeners.add(e),()=>a.listeners.delete(e)),setData:e=>{if(!a.dataOpsController){console.warn(`[page-agent-sdk] setData 忽略:dataOps 已关闭(capabilities.dataOps:false)`);return}a.dataOpsController.set(e),a.infoTick.value++},getData:()=>a.liveData(),setSkills:e=>{let t=a.skillsController;if(!t){console.warn(`[page-agent-sdk] setSkills 忽略:skills 已关闭(capabilities.skills:false)`);return}t.set(e),a.unloadSkillTools?.(),a.infoTick.value++},addSkill:e=>{if(!a.skillsController){console.warn(`[page-agent-sdk] addSkill 忽略:skills 已关闭(capabilities.skills:false)`);return}a.addSkill(e),a.unloadSkillTools?.(e.name)},removeSkill:e=>{if(!a.skillsController)return console.warn(`[page-agent-sdk] removeSkill 忽略:skills 已关闭(capabilities.skills:false)`),!1;let t=a.removeSkill(e);return t&&a.unloadSkillTools?.(e),t},listUserSkills:()=>a.listUserSkills(),getUserSkill:e=>a.getUserSkill(e),invalidateSkillCache:e=>{let t=a.skillsController;if(!t){console.warn(`[page-agent-sdk] invalidateSkillCache 忽略:skills 已关闭(capabilities.skills:false)`);return}t.invalidateCache(e),a.unloadSkillTools?.(e)},exportData:()=>{let e=a.liveData()?.bind;return e==null?null:JSON.parse(JSON.stringify(e))},importData:(e,t)=>{let n=a.liveData();if(!n||!a.dataOpsController)return{ok:!1,error:`dataOps 未开启或无主数据`};let r=n.bind;if(typeof r!=`object`||!r)return{ok:!1,error:`主数据 bind 非对象,无法就地还原(集成方应用对象包裹)`};if(t?.validate!==!1){let t=n.schema.safeParse(e);if(!t.success)return{ok:!1,error:`schema 校验失败:`+(t.error?.message??`未知错误`)}}return FX(r,e),a.dataOpsController?.markDataDirty?.(),t?.emit!==!1&&a.emit({type:`data_change`,operation:`set`,value:r}),{ok:!0}},vfsWrite:(e,t)=>{let n=typeof t==`string`?t:JSON.stringify(t);a.vfsStore.files[G6(e)]={content:n,updatedAt:Date.now()}},vfsRead:e=>a.vfsStore.files[G6(e)]?.content,createResource:(e,t)=>{let n=a.dataOpsController;if(!n?.createResource)throw Error(`[page-agent-sdk] createResource 不可用:需配 data.resources + vfsStore(capabilities.vfs 默认开)`);return n.createResource(e,t)},getResource:e=>a.dataOpsController?.getResource?.(e),updateResource:(e,t)=>{let n=a.dataOpsController;if(!n?.updateResource)throw Error(`[page-agent-sdk] updateResource 不可用:需配 data.resources + vfsStore`);n.updateResource(e,t)},deleteResource:e=>a.dataOpsController?.deleteResource?.(e)??!1,listResources:()=>a.dataOpsController?.listResources?.()??[],releaseResources:e=>{let t=a.dataOpsController;if(!(!t?.listResources||!t.deleteResource))if(e&&e.length)for(let n of e)t.deleteResource(n);else for(let e of t.listResources())t.deleteResource(e.path)},usage:a.usage,pendingConflict:a.pendingConflict,resolveConflict:e=>a.resolveConflict(e),setTools:e=>a.setTools(e),addTool:e=>a.addTool(e),removeTool:e=>a.removeTool(e),setLlm:e=>a.setLlm(e),setMemory:e=>a.setMemory(e),refreshMemory:()=>a.refreshMemory(),setSubagents:e=>a.setSubagents(e),addSubagent:e=>a.addSubagent(e),removeSubagent:e=>a.removeSubagent(e),getActiveSubagents:()=>a.getActiveSubagents(),get subagentHistory(){return a.subagentHistory}}}var $oe=4e3;function F5(e={}){let{fetchResponse:t,fetchStream:n,onPersist:r,onClear:i,onQueuedCleared:a}=e,o=sH({messages:e.messages??[],loading:!1,error:null}),s=vH(null),c=vH(!0),l=null,u=vH([]),d=vH(null);function f(){}function p(e){let t=s.value;e.deltaY<0?c.value=!1:t&&(c.value=t.scrollHeight-t.scrollTop-t.clientHeight<64)}function m(){s.value&&requestAnimationFrame(()=>{let e=s.value;!e||!c.value||(e.scrollTop=e.scrollHeight)})}function h(e,t,n){o.messages.push({role:e,content:t,timestamp:Date.now(),...n&&n.length?{focuses:n}:{}}),c.value=!0,m()}async function g(e){if(c.value=!0,n){let t=sH({role:`assistant`,content:``,timestamp:Date.now(),reasoning:``,steps:[]}),r=!1;o.messages.push(t);try{await n(o.messages.slice(0,-1),e=>{switch(e.type){case`round_start`:e.round>1&&(t.content||t.reasoning)&&(r=!0);break;case`reasoning`:r&&=(t.reasoning+=`
345
+ `):`无可用 checkpoint。`},{name:`list_checkpoints`,description:`列出可用会话 checkpoint(回退点)。`,schema:L({}).optional()})]:[];Ce.forEach(e=>ve.set(e.name,`builtin`));let we=A.focus,Te=_B(async({path:e,label:t})=>{let n=_e()?.schema;return n?WJ(n,e)?(b.setFocus({path:e,...t?{label:t}:{}}),`已聚焦到 ${e}${t?`(${t})`:``}。后续仅可写该子树(越界被拒),每轮只看到该组件结构。完成精修后调 clear_focus 退出。`):`PATH_DENIED · 聚焦失败:path "${e}" 不在 schema 内。请先用 read 查看可操作路径再聚焦。`:`聚焦失败:当前无主数据 schema,无法聚焦。`},{name:`set_focus`,description:`聚焦到指定组件子树(如 components.3)精修,替换全部已有焦点(非累积;要保留已有焦点追加用 add_focus)。聚焦后:仅可写该子树(越界 PATH_DENIED)+ 每轮只看到该组件结构。多组件页面精修其中一个时用,避免改到别处。先 read 定位 path 再聚焦;完成调 clear_focus。`,schema:L({path:F().describe(`要聚焦的组件 jsonPath,如 components.3`),label:F().optional().describe(`人类可读标签,如「导航栏」`)})}),Ee=_B(async()=>(b.clearFocus(),`已清除聚焦,恢复全量可操作范围(可读写所有组件)。`),{name:`clear_focus`,description:`清除当前聚焦,退出精修模式,恢复对全部组件的读写权限。`,schema:L({}).optional()}),De=_B(async({path:e,label:t})=>{let n=_e()?.schema;if(!n)return`聚焦失败:当前无主数据 schema,无法聚焦。`;if(!WJ(n,e))return`PATH_DENIED · 聚焦失败:path "${e}" 不在 schema 内。请先用 read 查看可操作路径再聚焦。`;b.addFocus({path:e,...t?{label:t}:{}});let r=b.getFocuses();return`已聚焦 ${e}${t?`(${t})`:``}(当前共 ${r.length} 个焦点:${r.map(e=>e.path).join(`, `)})。后续仅可写这些子树之一(越界被拒)。`},{name:`add_focus`,description:`追加聚焦一个组件子树(multi-focus,可同时聚焦多个相关组件)。校验 path 在 schema 内。聚焦后仅可写已聚焦的子树之一(越界 PATH_DENIED)。与 set_focus(替换全部)不同:本工具累积追加,不清除已有焦点。`,schema:L({path:F().describe(`要追加聚焦的组件 jsonPath,如 components.3`),label:F().optional().describe(`人类可读标签`)})}),Oe=_B(async({path:e})=>{let t=b.getFocuses().length;b.removeFocus(e);let n=b.getFocuses();return n.length===t?`path "${e}" 不在当前焦点列表中(当前:${n.map(e=>e.path).join(`, `)||`无`})。`:n.length?`已移除焦点 ${e}(剩余 ${n.length} 个:${n.map(e=>e.path).join(`, `)})。`:`已移除焦点 ${e},聚焦已清空,恢复全量操作范围。`},{name:`remove_focus`,description:`移除单个聚焦焦点(by path),保留其他焦点。移除最后一个等价退出精修。全部退出用 clear_focus。`,schema:L({path:F().describe(`要移除的焦点 jsonPath`)})}),ke=we&&e.toolMode===`advanced`?[Te,Ee,De,Oe]:[];ke.forEach(e=>ve.set(e.name,`builtin`));let Ae=[],je=new Map,Me=Ne();function Ne(){let{tools:e,collisions:t}=Uoe([{label:`builtin`,tools:ye},{label:`user`,tools:be},{label:`action`,tools:j},{label:`humanConfirm`,tools:N?[N]:[]},{label:`checkpoint`,tools:Ce},{label:`focus`,tools:ke},{label:`mcp`,tools:xe},{label:`skill`,tools:Ae}]);return t.length&&console.warn(`[page-agent-sdk] 工具重名,后注册覆盖先注册:`,t.map(e=>`${e.name}(${e.loser}→${e.winner})`).join(`, `)),e}let Pe=A.planning,Fe=A.missionAnchor,Ie=A.workingMemory,Le=A.skills,Re=A.vfs||re;if(Re)for(let e of Aae)ve.set(e,`builtin`);if(Pe)for(let e of v.tools??[])ve.set(e.name,`builtin`);let ze=A.summarization,Be=A.agentCompression&&!!l;e.debug&&A.agentCompression&&!l&&console.warn(`[page-agent-sdk][agentCompression] agentCompression 开启但 summaryLlm 不可用(或缺 apiKey / 模型不支持工具),压缩决策不启用,回退静态压缩`);let Ve=A.memory,He=A.subagent,Ue=He?cZ():void 0,We=e.verify?.maxAttempts??2,Ge=!!(e.verify?.check||e.verify?.maxAttempts||e.verify?.adversarial),Ke=e.capabilities?.verify===!1,qe=(A.verify||Ge&&!Ke)&&e.verify?.enabled!==!1&&We>0,Je=A.contextInspector;Ge&&!qe&&e.verify?.enabled!==!1&&console.warn(`[page-agent-sdk][verify] 检测到 verify 配置(check/maxAttempts/adversarial)但未装载(capabilities.verify:false 显式关闭 或 maxAttempts≤0)`);let Ye=e.subagent,Xe=Ye?.allowedTools??[],Ze=e.permissions?.length?EX(e.permissions):void 0,Qe=e.approval&&(e.approval.tools!==void 0||e.approval.confirm)?DX(e.approval):void 0,$e=[...Ze?[Ze]:[],...Qe?[Qe]:[]],et=!He||Ye?.enabled===!1?void 0:wZ({llm:Ye?.llm??e.llm,allTools:()=>P.agent?.allTools??Me,allowedTools:Xe.length?Xe:void 0,systemPrompt:Ye?.systemPrompt,temperature:Ye?.temperature,maxTokens:Ye?.maxTokens,skills:Ye?.skills,maxDepth:Ye?.maxDepth,maxParallel:Ye?.maxParallel,debug:e.debug,getFocuses:()=>b.getFocuses(),getSchema:()=>_e()?.schema??null,tracker:Ue,guardMiddleware:$e.length?$e:void 0,getVfsFiles:Re?()=>_.files:void 0,enterDataScope:he?.enterScope?e=>he.enterScope(e):void 0,exitDataScope:he?.exitScope?e=>he.exitScope(e):void 0,onUsage:e=>{n.prompt_tokens=(n.prompt_tokens??0)+(e.prompt_tokens??0),n.completion_tokens=(n.completion_tokens??0)+(e.completion_tokens??0),n.total_tokens=(n.total_tokens??0)+(e.total_tokens??0)},timeoutMs:Ye?.timeoutMs}),tt=D?.map(e=>{if(!e._codeAsset)return e;let t=e._codeAsset,n=Rae({writablePaths:t.writablePaths,codeVfsPrefix:t.codeVfsPrefix,ext:t.ext,codeField:t.codeField,craftNotes:t.craftNotes,onWarning:e=>console.warn(`[page-agent-sdk][code-asset] ${e}`),getController:()=>he,vfsStore:_}),r=[...e.middleware??[],n];for(let e of r)e&&typeof e==`object`&&typeof e._setGetController==`function`&&e._setGetController(()=>he);return{...e,middleware:r}}),nt=re&&He?zae():void 0,rt=nt?Gae({getBind:()=>_e()?.bind,writablePaths:O,getLocked:()=>nt.locked(),tools:Me}):void 0,it=He&&tt!==void 0?DZ(tt,{llm:e.llm,allTools:()=>P.agent?.allTools??Me,debug:e.debug,getFocuses:()=>b.getFocuses(),getSchema:()=>_e()?.schema??null,getBind:()=>_e()?.bind,tracker:Ue,guardMiddleware:$e.length?$e:void 0,getVfsFiles:Re?()=>_.files:void 0,enterDataScope:he?.enterScope?e=>he.enterScope(e):void 0,exitDataScope:he?.exitScope?e=>he.exitScope(e):void 0,onUsage:e=>{n.prompt_tokens=(n.prompt_tokens??0)+(e.prompt_tokens??0),n.completion_tokens=(n.completion_tokens??0)+(e.completion_tokens??0),n.total_tokens=(n.total_tokens??0)+(e.total_tokens??0)},timeoutMs:e.subagent?.timeoutMs,...nt?{componentLock:nt,resolveComponents:e=>Bae(e,Iae(_e()?.bind,O))}:{}}):void 0,at=it?it.controller:null,ot=[`get_data`,`describe_data`,`read`,`fetch_document`],st=Me.filter(e=>ot.includes(e.name)),ct=qe?OZ({check:e.verify.check??PZ({schemas:()=>_e()?{"":_e().schema}:{},root:()=>_e()?.bind}),adversarial:e.verify?.adversarial?{llm:e.llm,tools:st}:void 0}):void 0,lt=Je?JZ({contextWindow:u.contextWindow,thresholdRatio:I8(e,u.contextWindow).summaryThresholdRatio}):void 0,ut=T5({...A,humanConfirm:Se,subagents:D?.map(e=>({id:e.id,description:e.description,temperature:e.temperature}))},ce&&!!w,e.toolMode,!!w?.resources?.length,{promptSoftCap:rZ(u.contextWindow,d.promptSoftCapTokens)}),dt=w?{name:`dataHint`,augmentPrompt:()=>L6(_e(),e.schemaHint)||void 0}:null,ft=e.augmentSystem?{name:`augmentSystem`,augmentPrompt:t=>{try{return e.augmentSystem({state:t,data:_e()})}catch(t){e.debug&&console.log(`[page-agent-sdk][augmentSystem] 回调抛错,降级跳过:`,t.message);return}}}:null,pt=P8(e.onEvent),mt=pt.emit,ht,gt=[],_t=e=>({name:e.name,description:e.description,content:typeof e.getContent==`function`?e.getContent():``}),vt=e=>({name:e.name,description:e.description,getContent:()=>e.content}),yt=e.skillStorage===!1?null:k5({...typeof e.skillStorage==`object`?e.skillStorage:{},id:e.skillStorage&&typeof e.skillStorage==`object`&&e.skillStorage.id?e.skillStorage.id:`agent::${t}`}),bt=()=>{let t=ht?ht.controller:null;if(t){let n=(e.skills||[]).filter(e=>!gt.some(t=>t.name===e.name));t.set([...n,...gt])}P.infoTick.value++},xt=async()=>{if(yt)try{let t=await yt.list();if(t.length){gt=t.map(vt);let n=ht?ht.controller:null;if(n){let t=(e.skills||[]).filter(e=>!gt.some(t=>t.name===e.name));n.set([...t,...gt])}P.infoTick.value++}}catch{}},St=ze?sZ({...d,llmInvoke:s,getRegisteredData:()=>_e()?[{description:_e().description??`主数据对象`}]:[],preserveLastToolResults:p,...Be?{decideInvoke:l,getSnapshot:()=>lt?.getSnapshot()}:{}}):void 0,Ct=goe([...dt?[dt]:[],ut,...Fe?[y]:[],...Pe?[v]:[],...Le?[ht=yX(e.skills||[],{readVfs:Re?e=>_.files[e]?.content:void 0,hostScriptEnabled:A.skillHostScript,onToolsReady:(e,t)=>{for(let n of t){let t=Ae.findIndex(e=>e.name===n.name);t>=0&&Ae.splice(t,1),Ae.push(n),je.set(n.name,e),ve.set(n.name,`skill:${e}`)}Me=Ne(),P.agent&&P.agent.setTools(Me),P.infoTick.value++}})]:[],...Re?[Mae(_)]:[],...St?[St]:[],...Ie?[x]:[],...we?[b]:[],...ge?[ge]:[],...Ve?[S]:[],...Ze?[Ze]:[],...oe&&se&&k?[zX(k)]:[],...Se?[jX()]:[],...Qe?[Qe]:[],...ct?[ct]:[],...et?[et]:[],...it?[it]:[],...rt?[rt]:[],...ft?[ft]:[],...lt?[lt]:[],...e.middleware||[],...de?[zoe(n,{tokenBudget:e.tokenBudget,timeBudgetMs:e.timeBudgetMs},mt)]:[],Xoe(mt,g,_e,n)]),wt=e.maxMemoryRounds??qoe,Tt=e.approval?.timeoutMs,Et=Tt===void 0||Tt===0?3e4:!Number.isFinite(Tt)||Tt<0?0:Tt;function Dt(e){if(Et)return t=>{if(t.type!==`approval_request`)return;let n=Date.now(),r=t.toolName;setTimeout(()=>{e?.aborted||(t.resolve(!1),mt({type:`error`,message:`确认请求(${r})${Math.round((Date.now()-n)/1e3)}s 无响应已自动拒绝 —— send/batch 路径无 UI 响应方;可传 approval.timeoutMs 调整(Infinity = 无限等)`,severity:`observable`,code:`APPROVAL_AUTO_REJECTED`,context:{toolName:r,waitedMs:Date.now()-n}}))},Et)}}function Ot(e){let t=Dt(e);return e=>{t?.(e),e.type===`error`&&mt(e)}}let kt=vH([]);async function At(){if(a)try{kt.value=(await a.listSessions(t)).sort((e,t)=>t.lastAccessed-e.lastAccessed)}catch(t){e.debug&&console.warn(`[page-agent-sdk][persist] refreshSessions 失败(已吞):`,t)}}let jt=M5(),Mt=new Set;function Nt(e){let t=new AbortController;return e&&(e.aborted?t.abort():e.addEventListener(`abort`,()=>t.abort(),{once:!0})),Mt.add(t),{controller:t,untrack:()=>Mt.delete(t)}}function Pt(){for(let e of Mt)e.abort();Mt.clear()}let P={agentId:t,store:a,messages:g,vfsStore:_,listeners:pt.listeners,todosMw:v,memoryMw:S,missionMw:y,workingMemoryMw:x,focusMw:b,agent:null,initDone:Promise.resolve(),sessionId:``,refCount:0,mcpClosers:[],mcpServers:[],checkpoint:k,dataOpsController:he,skillsController:ht?ht.controller:null,infoTick:i,pendingConflict:r.pendingConflict,sessions:kt,refreshSessions:At,liveData:_e,usage:n,emit:mt,runSerial:jt,trackActive:Nt,abortAllActive:Pt,unloadSkillTools(e){if(e){let t=Ae.length;if(Ae=Ae.filter(t=>je.get(t.name)===e?(ve.delete(t.name),je.delete(t.name),!1):!0),Ae.length===t)return}else{if(!Ae.length)return;for(let e of Ae)ve.delete(e.name),je.delete(e.name);Ae=[]}Me=Ne(),P.agent&&P.agent.setTools(Me)},applySnapshot(t){if(t.messages?.length&&g.push(...t.messages),t.vfs&&_.hydrate&&_.hydrate(t.vfs),t.todos?.length&&v.reset(t.todos),t.memory&&!e.memory&&S.reset(t.memory),t.checkpoints?.length&&k&&k.importStack(t.checkpoints),t.usage&&Object.assign(n,t.usage),t.mission&&Fe&&y.setMission(t.mission),t.workingMemory&&Ie&&x.restore(t.workingMemory),we){let n=t.focus,r=n?Array.isArray(n)?n:[n]:[];if(r.length){let t=_e()?.schema,n=t?r.filter(e=>WJ(t,e.path)):[];if(n.length&&(b.setFocus(null),n.forEach(e=>b.addFocus(e))),e.debug&&n.length<r.length){let e=r.filter(e=>!n.includes(e)).map(e=>e.path);console.warn(`[page-agent-sdk][focus] 恢复的焦点部分 path 已失效(schema 变化/无 schema),剔除:`,e)}}}Rt()},addSkill(e){let t=gt.findIndex(t=>t.name===e.name);t>=0?gt[t]=e:gt.push(e),bt(),yt&&yt.put(_t(e))},removeSkill(e){let t=gt.findIndex(t=>t.name===e);return t<0?!1:(gt.splice(t,1),bt(),yt&&yt.remove(e),!0)},listUserSkills(){return gt.map(e=>e.name)},getUserSkill(e){let t=gt.find(t=>t.name===e);if(t)return{name:t.name,description:t.description,content:typeof t.getContent==`function`?t.getContent():``}},afterRound(){zt(),Wt()},async send(e,t){await P.initDone,t??={},t?.mission&&Fe&&y.setMission(t.mission);let n=e;if(t.interceptors?.input)try{let r=t.interceptors.input(e);typeof r==`string`&&(n=r)}catch{}let r=de?t.maxAutoRetries??1:0,i=0,o=!1,s=Ot(t.signal);for(;;){o||=(g.push({role:`user`,content:n,timestamp:Date.now()}),!0);try{let e=await P.agent.invoke(g,t.signal,s);if(t.interceptors?.output)try{let n=t.interceptors.output(e);typeof n==`string`&&(e=n)}catch{}return g.push({role:`assistant`,content:e,timestamp:Date.now()}),P.afterRound(),a&&await a.flush(),e}catch(e){if(sJ(e,t.signal))throw e;let n=Kq(e,`fatal`);if(i<r&&k?.canRestore()){i+=1,k.restore(),o=!0,mt({type:`error`,message:`致命错误自动恢复(${i}/${r}):${n.message},已回退 checkpoint 重试`,severity:`observable`,code:`AUTO_RECOVER_RETRY`,context:{attempt:i,cause:n.code??n.message.slice(0,120)}});continue}throw mt({type:`error`,message:n.message,severity:n.severity,...n.code?{code:n.code}:{},...n.context===void 0?{}:{context:n.context}}),e}}},async batch(e,t,n){if(await P.initDone,!e.length)return[];let r=[],i=Ot(n);for(let o=0;o<e.length;o++){if(n?.aborted){for(let t=o;t<e.length;t++)r.push({index:t,task:e[t],error:`aborted(外部中止)`,ok:!1});break}let s=e[o];k&&k.save(`batch:${o}`);let c=g.length;try{g.push({role:`user`,content:s,timestamp:Date.now()});let c=await P.agent.invoke(g,n,i);g.push({role:`assistant`,content:c,timestamp:Date.now()}),P.afterRound(),a&&await a.flush(),r.push({index:o,task:s,reply:c,ok:!0}),t?.({done:o+1,total:e.length,task:s,ok:!0})}catch(i){if(g.length>c&&g.splice(c),sJ(i,n)){r.push({index:o,task:s,error:`aborted(外部中止)`,ok:!1});for(let t=o+1;t<e.length;t++)r.push({index:t,task:e[t],error:`aborted(外部中止)`,ok:!1});break}let a=Kq(i,`fatal`);mt({type:`error`,message:`批量任务 ${o+1}/${e.length} 失败:${a.message}`,severity:`observable`,code:`BATCH_TASK_FAILED`,context:{index:o,task:s.slice(0,100)}}),r.push({index:o,task:s,error:a.message,ok:!1}),t?.({done:o+1,total:e.length,task:s,ok:!1})}}return r},async switchSession(n){if(await P.initDone,!a)throw Error(`page-agent-sdk: storage 未开启,无法切换会话(请传 storage 选项)`);if(r.resolve(`keep_external`),P.sessionId&&a){if(Fe){let e=y.getMission();e&&Ht({mission:e})}if(Ie){let e=x.getWorkingMemory();e&&Ht({workingMemory:e})}if(we){let e=b.getFocuses();Ht({focus:e.length?e:null})}}_.flush?.(),await a.flush();let i=n??``,o;return i?(o=await a.load(t,i),o||await a.createSession(t,e.session?.title,i)):i=await a.createSession(t,e.session?.title),P.sessionId=i,g.splice(0,g.length),_.clear?.(),v.reset([]),e.memory||S.reset(``),y.reset(),x.reset(),b.reset(),k&&k.importStack([]),P.agent.debugLogs.value=[],o||=await a.load(t,i),o&&(P.applySnapshot(o),mt({type:`session_restored`,sessionId:i,rounds:o.messages?.length??0})),e.memory&&Ht({memory:S.get()||(typeof e.memory==`string`?e.memory:``)}),At(),Bt=void 0,Vt=!1,P.infoTick.value++,i},resetSession:()=>{Pt(),r.resolve(`keep_external`),P.sessionId=g8(),g.splice(0,g.length),_.clear?.(),v.reset([]),e.memory||S.reset(``),y.reset(),x.reset(),b.reset(),k&&k.importStack([]),P.agent&&(P.agent.debugLogs.value=[]),a&&a.createSession(P.agentId,e.session?.title,P.sessionId).catch(t=>{e.debug&&console.warn(`[page-agent-sdk][persist] createSession 失败(已吞):`,t)}),mt({type:`session_restored`,sessionId:P.sessionId,rounds:0}),P.infoTick.value++,At(),Bt=void 0,Vt=!1},stream:(e,t,n)=>{if(!P.agent)throw Error(`page-agent-sdk: agent 尚未初始化完成,请先 await mount()`);_?.setProtectedRefs?.(j5(e));let i=e=>{t?.(e),mt(e),e.type===`subagent`&&(e.kind===`tool_call`||e.kind===`tool_result`)&&P.infoTick.value++};if(n){let e=()=>r.resolve(`keep_external`);n.aborted?e():n.addEventListener(`abort`,e,{once:!0})}let{controller:a,untrack:o}=Nt(n);return P.agent.stream(e,i,a.signal).finally(o)},release(){if(P.refCount--,P.refCount<=0){Pt(),M=!0,a&&(_.flush?.(),a.flush(),a.dispose()),yt&&yt.dispose();let e=P.mcpClosers.splice(0);e.length&&Promise.allSettled(e.map(e=>e())),N5.delete(t)}},resolveConflict:r.resolve,setTools(e){be.length=0,e.forEach(e=>{be.push(e),ve.set(e.name,`user`)}),Me=Ne(),P.agent&&P.agent.setTools(Me),P.infoTick.value++},addTool(e){Me.some(t=>t.name===e.name)&&console.warn(`[page-agent-sdk] 工具 "${e.name}" 已存在,新工具覆盖(后注册覆盖先注册)`);for(let t=be.length-1;t>=0;t--)be[t].name===e.name&&be.splice(t,1);be.push(e),ve.set(e.name,`user`),Me=Ne(),P.agent&&P.agent.setTools(Me),P.infoTick.value++},removeTool(e){let t=be.findIndex(t=>t.name===e);return t<0?!1:(be.splice(t,1),ve.delete(e),Me=Ne(),P.agent&&P.agent.setTools(Me),P.infoTick.value++,!0)},setLlm(t){let n;if(u8(t))n=t;else{let e=t;if((e.provider??`openai`)===`anthropic`)throw Error(`[page-agent-sdk][setLlm] 切换到 Anthropic 需传 BaseChatModel 实例(动态 import 无法同步);请先 const { ChatAnthropic } = await import("@langchain/anthropic") 构造实例后传入`);n=bB(e)}typeof n.bindTools!=`function`&&e.debug&&console.warn(`[page-agent-sdk][setLlm] 新模型不支持 bindTools(tool calling 会失效)`),h=t;let r=u8(t)?void 0:t;if(u=tJ({model:r?.model??t.model??t.modelName,contextWindow:e.contextWindow??r?.contextWindow,maxOutputTokens:e.maxOutputTokens??r?.maxOutputTokens}),u.contextWindow<2e5)throw Error(`[page-agent-sdk][setLlm] 新模型上下文窗口 ${u.contextWindow} 小于最小支持 ${eJ}(需 ≥200K 窗口模型)`);P.agent&&(P.agent.setLlm(n),P.agent.setModelCaps?.(u)),St?.setContextWindow?.(u.contextWindow),lt?.setContextWindow?.(u.contextWindow),P.infoTick.value++,e.debug&&console.log(`[page-agent-sdk][setLlm] 重解析 modelCaps + 回灌:`,u)},setMemory(e){S.reset(e),typeof e==`function`&&S.refresh(),P.infoTick.value++},refreshMemory(){return S.refresh()},setSubagents(t){if(!at){e.debug&&console.warn(`[page-agent-sdk][setSubagents] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略`);return}at.set(t),P.infoTick.value++},addSubagent(t){if(!at){e.debug&&console.warn(`[page-agent-sdk][addSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略`);return}at.add(t),P.infoTick.value++},removeSubagent(t){if(!at)return e.debug&&console.warn(`[page-agent-sdk][removeSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略`),!1;let n=at.remove(t);return n&&P.infoTick.value++,n},getActiveSubagents(){return Ue?.getActive()??[]},get subagentHistory(){return Ue?.getHistory()??[]},getInfo(){return{id:t,sessionId:P.sessionId,model:u8(h)?h.model??h.modelName:h.model,systemPrompt:P.agent?.getEffectiveSystemPrompt?.()??fe+L6(_e(),e.schemaHint),tools:(P.agent?.allTools??Me).map(e=>({name:e.name,description:e.description,schema:e.schema,source:ve.get(e.name)||`user`})),skills:(ht?ht.controller.get():e.skills??[]).map(e=>({name:e.name,description:e.description})),data:_e()?{description:_e().description,schema:_e().schema}:void 0,contextPreset:e.contextPreset??`auto`,compression:{contextWindow:u.contextWindow,summaryThresholdRatio:d.summaryThresholdRatio??.5,promptSoftCap:rZ(u.contextWindow,d.promptSoftCapTokens)},memory:S.get(),middleware:Ct.map(e=>e.name),todos:(P.agent?.getState?.()?.todos??[]).map(e=>({id:e.id,content:e.content,status:e.status,...e.parentId===void 0?{}:{parentId:e.parentId},...e.deps===void 0?{}:{deps:e.deps},...e.criteria===void 0?{}:{criteria:e.criteria},...e.evidence===void 0?{}:{evidence:e.evidence}})),planPhase:v.getPlanPhase(),mission:Fe?y.getMission():void 0,workingMemory:Ie?x.getWorkingMemory():void 0,focus:we?b.getFocus():void 0,focuses:we?b.getFocuses():[],trace:ue&&P.agent?.spans?{spans:P.agent.spans.value,metrics:aJ(P.agent.spans.value)}:void 0,actions:S5(e.actions??{}),subagent:{enabled:!!et,maxDepth:e.subagent?.maxDepth??1,maxParallel:e.subagent?.maxParallel??4,allowedTools:e.subagent?.allowedTools??[],subagents:at?.get()??[],active:Ue?.getActive()??[],history:Ue?.getHistory()??[],lockedComponents:nt?.locked()??{}},verify:{enabled:!!ct,maxAttempts:qe?We:0,adversarial:qe&&!!e.verify?.adversarial},context:(()=>{let e=lt?.getSnapshot();if(e){let t=P.agent?.getState?.()?.lastCompression;t&&(e.compression=t)}return e})(),mcp:{servers:P.mcpServers},lastCompression:P.agent?.getState?.()?.lastCompression,checkpoints:k?{enabled:!0,auto:se,list:k.list()}:void 0}},getMission(){return Fe?y.getMission():void 0},setMission(t){if(!Fe){e.debug&&console.warn(`[page-agent-sdk][mission] capabilities.missionAnchor 关闭,setMission 忽略`);return}y.setMission(t),P.infoTick.value++},getFocus(){return we?b.getFocus():void 0},getFocuses(){return we?b.getFocuses():[]},setFocus(t){let n=P5(t,`setFocus`,we,()=>_e()?.schema,e.debug);return n.ok?(b.setFocus(t),P.infoTick.value++,{ok:!0}):n},addFocus(t){let n=P5(t,`addFocus`,we,()=>_e()?.schema,e.debug);return n.ok?b.getFocuses().length>=8?(e.debug&&console.warn(`[page-agent-sdk][focus] addFocus 拒绝:焦点数已达上限 8(augmentPrompt 注入每焦点子树 schema,过多致 system prompt 超预算)`),{ok:!1,error:`焦点数上限 8(避免 system prompt 撑爆)`}):(b.addFocus(t),P.infoTick.value++,{ok:!0}):n},removeFocus(e){we&&(b.removeFocus(e),P.infoTick.value++)},clearFocus(){we&&(b.clearFocus(),P.infoTick.value++)}};async function Ft(){if(!a)return;await a.ready;let n=e.session||{};if(n.id){P.sessionId=n.id;let e=await a.load(t,P.sessionId);e?(P.applySnapshot(e),mt({type:`session_restored`,sessionId:P.sessionId,rounds:e.messages?.length??0})):await a.createSession(t,n.title,P.sessionId)}else if(n.autoResume!==!1){let r=await a.listSessions(t);if(e.debug&&console.log(`[page-agent-sdk][restore] listSessions`,t,r.length,r.map(e=>e.sessionId)),r.length){P.sessionId=r[0].sessionId;let n=await a.load(t,P.sessionId);n?(P.applySnapshot(n),mt({type:`session_restored`,sessionId:P.sessionId,rounds:n.messages?.length??0}),e.debug&&console.log(`[page-agent-sdk][restore] 恢复会话`,P.sessionId,`${n.messages?.length??0} msgs`)):e.debug&&console.log(`[page-agent-sdk][restore] 会话 meta 存在但快照为空`,P.sessionId)}else P.sessionId=await a.createSession(t,n.title),e.debug&&console.log(`[page-agent-sdk][restore] 新建会话(无历史)`,P.sessionId)}else P.sessionId=await a.createSession(t,n.title);e.memory&&Ht({memory:S.get()||(typeof e.memory==`string`?e.memory:``)}),At()}async function It(){await xt()}function Lt(e){let t={};for(let n of j5(e)){let e=_.files[n];e&&(t[n]=e.content)}return t}function Rt(){let e=Koe(_.files,j5(g));for(let t of e)delete _.files[t]}function zt(){let e=JX(g,wt);if(!e.trimmed)return;let{older:t,summary:n}=e;if(mt({type:`context_trimmed`,dropped:t.map(e=>({round:e.round,user:e.userMsg.content,assistant:e.assistantMsgs.map(e=>e.content),steps:e.assistantMsgs.flatMap(e=>e.steps??[])})),vfsResults:Lt(t.flatMap(e=>[e.userMsg,...e.assistantMsgs])),summary:n.content,reason:`max_memory_rounds`}),g.splice(e.deleteFrom,e.deleteCount,n),Rt(),f&&s){let n=e.summary,{prevSeg:r}=e;(async()=>{try{let e=await s($X(t,m)),i=g.indexOf(n);if(i<0)return;g[i].content=qX(t,r,e),Wt()}catch{}})()}}let Bt,Vt=!1;function Ht(n){!P.sessionId||!a||a.save(t,P.sessionId,n).catch(t=>{e.debug&&console.warn(`[page-agent-sdk][persist] save 失败(已吞):`,t)})}function Ut(n,r){a&&a.updateTitle(t,n,r).catch(t=>{e.debug&&console.warn(`[page-agent-sdk][persist] updateTitle 失败(已吞):`,t)})}function Wt(){if(!P.sessionId||!a)return;if(Ht({messages:JSON.parse(JSON.stringify(g))}),Ht({todos:P.agent?.getState?.()?.todos??[]}),Fe){let e=y.getMission();e&&Ht({mission:e})}if(Ie){let e=x.getWorkingMemory();e&&Ht({workingMemory:e})}if(we){let e=b.getFocuses();Ht({focus:e.length?e:null})}de&&k&&(Ht({checkpoints:k.exportStack()}),Ht({usage:n}));let t=l8(g);if(t&&t!==Bt&&(Bt=t,Ut(P.sessionId,t)),e.autoTitle!==!1&&c&&!Vt&&g.some(e=>e.role===`user`)&&g.some(e=>e.role===`assistant`)){Vt=!0;let e=P.sessionId;(async()=>{try{let t=await c(g);t&&P.refCount>0&&P.sessionId===e&&(Ut(e,t),await At())}catch{}})()}e.debug&&console.log(`[page-agent-sdk][persist] save`,P.sessionId,`${g.length} msgs`)}return P.initDone=(async()=>{await Ft(),await It(),e.mcp?.length&&(async()=>{let t=await Promise.allSettled(e.mcp.map(e=>F6(e))),n=t.flatMap(e=>e.status===`fulfilled`?[e.value.close]:[]);if(M){Promise.allSettled(n.map(e=>e()));return}P.mcpClosers=n,P.mcpServers=[];let r=new Set;for(let e of Me){let t=ve.get(e.name);t&&!t.startsWith(`mcp:`)&&r.add(e.name)}t.forEach((t,n)=>{let i=e.mcp[n],a=i.name??i.url;t.status===`fulfilled`?(P.mcpServers.push({name:a,url:i.url,toolCount:t.value.tools.length}),t.value.tools.forEach(e=>{if(r.has(e.name)){console.warn(`[page-agent-sdk][mcp] 工具 "${e.name}" 与内置工具重名,已拒绝注入(安全保留字保护)`);return}ve.set(e.name,`mcp:${a}`),xe.push(e)})):console.warn(`[page-agent-sdk][mcp] server ${a} 连接失败:`,t.reason)}),xe.length&&(Me=Ne(),P.agent&&P.agent.setTools(Me),P.infoTick.value++),e.debug&&console.log(`[page-agent-sdk][mcp] 注入 ${xe.length} 个工具,${P.mcpServers.length} 个 server`)})();let t=u8(e.llm)?e.llm:await xB(e.llm);P.agent=BJ({llm:t,systemPrompt:fe,tools:Me,middleware:Ct,maxToolRounds:e.maxToolRounds,maxRetries:e.maxRetries,stallMs:e.streamStallMs??9e4,maxParallelTools:e.maxParallelTools,contextWindow:u.contextWindow,maxOutputTokens:u.maxOutputTokens,maxVerifyAttempts:qe?We:0,roundTokenBudget:e.roundTokenBudget??0,onLlmChange:e=>{h=e},onTrace:ue?(e,t)=>{try{mt({type:`trace`,spans:e,metrics:t})}catch{}}:void 0,debug:e.debug}),C.current=P.agent,it&&it.setReconfigureHook&&it.setReconfigureHook(()=>{P.agent&&P.agent.setTools(Ne())})})(),P}function Qoe(e,t){let n=e.id??g8();e.id||console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${n}"。刷新后持久化数据无法恢复,请传稳定 id。`);let r=e.streaming??!0,i=e.ui??`default`,a,o=e.shareContext?N5.get(n):void 0;o?a=o:(a=Zoe(e,n),e.shareContext&&N5.set(n,a)),a.refCount++;let s=null,c=j8(e),l=null,u=null;async function d(n){if(await a.initDone,s){s.show();return}let o=n===void 0?e.container:n,d=()=>{a.store&&(l=()=>{a.vfsStore.flush?.(),a.store.flush()},u=()=>{document.visibilityState===`hidden`&&a.store.flush()},typeof window<`u`&&window.addEventListener(`pagehide`,l),typeof document<`u`&&document.addEventListener(`visibilitychange`,u))};if(i===!1||!t){i!==!1&&console.warn(`[page-agent-sdk/headless] 未含 UI 组件,ui 渲染降级 headless;如需 UI 请 import page-agent-sdk 主包`),d();return}let m=typeof o==`string`?document.querySelector(o):o;if(!m)throw Error(`createChatSdk: 挂载点未找到(${o})`);s=t({el:m,core:a,dialogCfg:c,streaming:r,runSerial:a.runSerial,hide:p,unmount:f,onDialogUnmounted:()=>{s=null,a.release()}}),c.drawer===!0&&c.drawerHidden===!0&&s.hide(),d()}function f(){a.abortAllActive(),a.resolveConflict(`keep_external`),l&&typeof window<`u`&&window.removeEventListener(`pagehide`,l),u&&typeof document<`u`&&document.removeEventListener(`visibilitychange`,u),l=null,u=null,s?s.unmount():a.release()}function p(){s?.hide()}function m(){s?.show()}return{mount:d,unmount:f,hide:p,show:m,send:(e,t)=>a.runSerial(async()=>{let{controller:n,untrack:r}=a.trackActive(t?.signal);try{return await a.send(e,{...t,signal:n.signal})}finally{r()}}),batch:(e,t,n)=>a.runSerial(async()=>{let{controller:r,untrack:i}=a.trackActive(n);try{return await a.batch(e,t,r.signal)}finally{i()}}),switchSession:(...e)=>a.runSerial(async()=>(a.abortAllActive(),a.switchSession(...e))),resetSession:()=>a.resetSession(),sessions:a.sessions,async listSessions(){return a.store?a.store.listSessions(n):[]},async deleteSession(e){if(a.store){if(e===a.sessionId){console.warn(`[page-agent-sdk] deleteSession 忽略:不能删除当前会话,请先 switchSession 切到其他会话`);return}await a.store.deleteSession(n,e),await a.refreshSessions()}},get sessionId(){return a.sessionId},stream:(e,t,n)=>a.stream(e,t,n),afterRound:a.afterRound,get debugLogs(){return a.agent.debugLogs},infoTick:a.infoTick,inspect:a.getInfo,inspectContext:()=>a.getInfo().context,getMission:a.getMission,setMission:a.setMission,getFocus:a.getFocus,getFocuses:a.getFocuses,setFocus:a.setFocus,addFocus:a.addFocus,removeFocus:a.removeFocus,clearFocus:a.clearFocus,messages:a.messages,restoreLastCheckpoint:()=>a.checkpoint?.restore()??!1,listCheckpoints:()=>a.checkpoint?.list()??[],hook:e=>(a.listeners.add(e),()=>a.listeners.delete(e)),setData:e=>{if(!a.dataOpsController){console.warn(`[page-agent-sdk] setData 忽略:dataOps 已关闭(capabilities.dataOps:false)`);return}a.dataOpsController.set(e),a.infoTick.value++},getData:()=>a.liveData(),setSkills:e=>{let t=a.skillsController;if(!t){console.warn(`[page-agent-sdk] setSkills 忽略:skills 已关闭(capabilities.skills:false)`);return}t.set(e),a.unloadSkillTools?.(),a.infoTick.value++},addSkill:e=>{if(!a.skillsController){console.warn(`[page-agent-sdk] addSkill 忽略:skills 已关闭(capabilities.skills:false)`);return}a.addSkill(e),a.unloadSkillTools?.(e.name)},removeSkill:e=>{if(!a.skillsController)return console.warn(`[page-agent-sdk] removeSkill 忽略:skills 已关闭(capabilities.skills:false)`),!1;let t=a.removeSkill(e);return t&&a.unloadSkillTools?.(e),t},listUserSkills:()=>a.listUserSkills(),getUserSkill:e=>a.getUserSkill(e),invalidateSkillCache:e=>{let t=a.skillsController;if(!t){console.warn(`[page-agent-sdk] invalidateSkillCache 忽略:skills 已关闭(capabilities.skills:false)`);return}t.invalidateCache(e),a.unloadSkillTools?.(e)},exportData:()=>{let e=a.liveData()?.bind;return e==null?null:JSON.parse(JSON.stringify(e))},importData:(e,t)=>{let n=a.liveData();if(!n||!a.dataOpsController)return{ok:!1,error:`dataOps 未开启或无主数据`};let r=n.bind;if(typeof r!=`object`||!r)return{ok:!1,error:`主数据 bind 非对象,无法就地还原(集成方应用对象包裹)`};if(t?.validate!==!1){let t=n.schema.safeParse(e);if(!t.success)return{ok:!1,error:`schema 校验失败:`+(t.error?.message??`未知错误`)}}return FX(r,e),a.dataOpsController?.markDataDirty?.(),t?.emit!==!1&&a.emit({type:`data_change`,operation:`set`,value:r}),{ok:!0}},vfsWrite:(e,t)=>{let n=typeof t==`string`?t:JSON.stringify(t);a.vfsStore.files[G6(e)]={content:n,updatedAt:Date.now()}},vfsRead:e=>a.vfsStore.files[G6(e)]?.content,createResource:(e,t)=>{let n=a.dataOpsController;if(!n?.createResource)throw Error(`[page-agent-sdk] createResource 不可用:需配 data.resources + vfsStore(capabilities.vfs 默认开)`);return n.createResource(e,t)},getResource:e=>a.dataOpsController?.getResource?.(e),updateResource:(e,t)=>{let n=a.dataOpsController;if(!n?.updateResource)throw Error(`[page-agent-sdk] updateResource 不可用:需配 data.resources + vfsStore`);n.updateResource(e,t)},deleteResource:e=>a.dataOpsController?.deleteResource?.(e)??!1,listResources:()=>a.dataOpsController?.listResources?.()??[],releaseResources:e=>{let t=a.dataOpsController;if(!(!t?.listResources||!t.deleteResource))if(e&&e.length)for(let n of e)t.deleteResource(n);else for(let e of t.listResources())t.deleteResource(e.path)},usage:a.usage,pendingConflict:a.pendingConflict,resolveConflict:e=>a.resolveConflict(e),setTools:e=>a.setTools(e),addTool:e=>a.addTool(e),removeTool:e=>a.removeTool(e),setLlm:e=>a.setLlm(e),setMemory:e=>a.setMemory(e),refreshMemory:()=>a.refreshMemory(),setSubagents:e=>a.setSubagents(e),addSubagent:e=>a.addSubagent(e),removeSubagent:e=>a.removeSubagent(e),getActiveSubagents:()=>a.getActiveSubagents(),get subagentHistory(){return a.subagentHistory}}}var $oe=4e3;function F5(e={}){let{fetchResponse:t,fetchStream:n,onPersist:r,onClear:i,onQueuedCleared:a}=e,o=sH({messages:e.messages??[],loading:!1,error:null}),s=vH(null),c=vH(!0),l=null,u=vH([]),d=vH(null);function f(){}function p(e){let t=s.value;e.deltaY<0?c.value=!1:t&&(c.value=t.scrollHeight-t.scrollTop-t.clientHeight<64)}function m(){s.value&&requestAnimationFrame(()=>{let e=s.value;!e||!c.value||(e.scrollTop=e.scrollHeight)})}function h(e,t,n){o.messages.push({role:e,content:t,timestamp:Date.now(),...n&&n.length?{focuses:n}:{}}),c.value=!0,m()}async function g(e){if(c.value=!0,n){let t=sH({role:`assistant`,content:``,timestamp:Date.now(),reasoning:``,steps:[]}),r=!1;o.messages.push(t);try{await n(o.messages.slice(0,-1),e=>{switch(e.type){case`round_start`:e.round>1&&(t.content||t.reasoning)&&(r=!0);break;case`reasoning`:r&&=(t.reasoning+=`
346
346
  `,!1),t.reasoning=(t.reasoning+e.delta).slice(-4e3);break;case`text`:r&&=(t.content+=`
347
347
  `,!1),t.content+=e.delta;break;case`tool_call`:t.steps.push({name:e.name,args:e.args,status:`running`});break;case`tool_result`:for(let n=t.steps.length-1;n>=0;n--)if(t.steps[n].name===e.name&&t.steps[n].status===`running`){t.steps[n].result=e.result,t.steps[n].status=e.status,t.steps[n].durationMs=e.durationMs;let r=t.steps[n].subReason;r&&r.length>80&&(t.steps[n].subReason=r.slice(0,80)+`…`);break}break;case`subagent`:{let n=t.steps[t.steps.length-1];if(!n)break;if(e.kind===`reasoning`){let t=e.delta||``;n.subReasonFull=(n.subReasonFull||``)+t;let r=(n.subReason||``)+t;n.subReason=r.length>$oe?r.slice(-4e3):r;break}n.children||=[];let r=e.label?`[${e.label}] ${e.name}`:e.name;if(e.kind===`tool_call`)n.children.push({name:r,args:e.args,status:`running`});else for(let t=n.children.length-1;t>=0;t--)if(n.children[t].status===`running`&&n.children[t].name===r){n.children[t].result=e.result,n.children[t].status=e.status||`done`;break}break}case`approval_request`:d.value={toolName:e.toolName,args:e.args,resolve:e.resolve};break}m()},e)}catch(n){if(sJ(n,e)||(o.error=n.message||`请求失败,请重试`),!t.content&&!t.reasoning){let e=o.messages.indexOf(t);e>=0&&o.messages.splice(e,1)}}finally{await v()}return}try{h(`assistant`,await(t||S)(o.messages,e))}catch(t){sJ(t,e)||(o.error=t.message||`请求失败,请重试`)}finally{await v()}}function _(e){let t=e=>{if(e?.length)for(let n of e)n.status===`running`&&(n.status=`error`,n.result||=`(本轮已结束,该步骤未收到结果 —— 子 agent 中断/异常)`),n.children?.length&&t(n.children)};for(let n=e.length-1;n>=0;n--)if(e[n].role===`assistant`){t(e[n].steps);break}}async function v(){_(o.messages);try{await r?.(o.messages)}catch{}o.loading=!1,l=null;let e=u.value.shift();e!==void 0&&(h(`user`,e),o.loading=!0,o.error=null,l=new AbortController,await g(l.signal))}function y(e){u.value.splice(e,1)}async function b(e,t){if(e.trim()){if(o.loading){u.value.push(e.trim());return}h(`user`,e.trim(),t),o.loading=!0,o.error=null,l=new AbortController,await g(l.signal)}}async function x(){if(o.loading)return;let e=o.messages;for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`){e.splice(t);break}e.some(e=>e.role===`user`)&&(o.loading=!0,o.error=null,l=new AbortController,await g(l.signal))}async function S(e){return await new Promise(e=>setTimeout(e,800+Math.random()*1200)),`收到你的消息:"${e.filter(e=>e.role===`user`).pop()?.content}"。这是一个模拟回复,请接入实际的 AI API。`}function C(){i?.(),o.messages.splice(0,o.messages.length),o.error=null}function w(){u.value.length&&a?.([...u.value]),u.value=[],l?.abort()}function T(){u.value=[],l?.abort(),l=null,o.loading=!1,o.error=null,d.value=null}function ee(e){let t=d.value;t&&(d.value=null,t.resolve(e))}async function E(){if(!o.error)return;let e=o.messages,t=-1;for(let n=e.length-1;n>=0;n--)if(e[n].role===`user`){t=n;break}if(t<0)return;let n=e[t].content;e.splice(t),o.error=null,await b(n)}return{state:o,scrollContainer:s,pendingApproval:d,queuedTasks:u,sendMessage:b,removeQueuedTask:y,clearMessages:C,stop:w,reset:T,retry:E,regenerate:x,resolveApproval:ee,onScroll:f,onWheel:p}}async function I5(e){try{let t=globalThis.navigator?.clipboard;if(t&&typeof t.writeText==`function`)return await t.writeText(e),!0}catch{}try{let t=globalThis.document;if(!t||!t.body)return!1;let n=t.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,``),n.style.position=`fixed`,n.style.top=`0`,n.style.left=`0`,n.style.opacity=`0`,t.body.appendChild(n),n.select();let r=t.execCommand(`copy`);return t.body.removeChild(n),r}catch{return!1}}var L5={header:`🤖`,subagent:`🤖`,subagentProgress:`🧬`,empty:`💬`,focus:`🎯`,queued:`📋`,queuedEdit:`✏️`,recommend:`💡`,conflict:`⚠️`};function R5(e){let t={...L5};if(!e)return t;let n=Object.keys(L5);for(let r of n){let n=e[r];typeof n==`string`&&(t[r]=n)}return e.assistantAvatar&&(t.assistantAvatar=e.assistantAvatar),e.userAvatar&&(t.userAvatar=e.userAvatar),t}var z5=Symbol(`chatContext`);function B5(e={}){let t=F5({fetchResponse:e.fetchResponse,fetchStream:e.fetchStream,messages:e.messages,onPersist:e.onPersist,onClear:e.onClear,onQueuedCleared:e.onQueuedCleared}),{state:n,sendMessage:r,removeQueuedTask:i,queuedTasks:a}=t,o=vH(``),s=vH(!0),c=()=>{s.value=!s.value},l=vH(!1),u=()=>{l.value=!0},d=()=>{l.value=!1},f=vH(!1),p=()=>{f.value=!0},m=()=>{f.value=!1},h=vH({}),g=e=>h.value[e]===!0,_=e=>{h.value[e]=!g(e)},v=vH(!1),y=e=>{I5(e).then(e=>{e&&(v.value=!0,setTimeout(()=>{v.value=!1},1500))})},b=gK(()=>{let t=e.getInfo?.();return{mcp:t?.mcp?.servers?.length??0,tools:t?.tools?.length??0}}),x=gK(()=>(n.messages.length,typeof e.canUndo==`function`&&!!e.canUndo())),S=()=>{e.onUndo?.()&&(n.error=null)},C=e=>new Date(e).toLocaleTimeString(`zh-CN`,{hour:`2-digit`,minute:`2-digit`}),w=()=>{o.value.trim()&&(r(o.value,te.value),o.value=``)},T=e=>{e.isComposing||e.keyCode===229||e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),w())},ee=e=>{o.value=a.value[e]||``,i(e)},E=e=>{let t=n.messages,r=t[e];if(!r||r.role!==`assistant`)return!1;let i=`reasoning`in r?r.reasoning:void 0;return n.loading&&e===t.length-1&&!r.content&&!i},te=gK(()=>(e.infoTick?.value,e.getFocuses?.()??[]));return{chat:t,inputText:o,isExpanded:s,toggleCollapse:c,debugVisible:l,openDebug:u,closeDebug:d,skillVisible:f,openSkill:p,closeSkill:m,reasoningExpanded:h,isReasoningExpanded:g,toggleReasoning:_,copiedMsg:v,copyMessage:y,summary:b,canUndo:x,undo:S,formatTime:C,send:w,keydown:T,editQueued:ee,isPendingAssistant:E,focuses:te,addFocus:t=>e.onAddFocus?e.onAddFocus(t):{ok:!1,error:`focus 未启用`},removeFocus:t=>{e.onRemoveFocus?.(t)},clearFocus:()=>{e.onClearFocus?.()},focusChipClick:t=>{e.onFocusChipClick?.(t)},icons:R5(e.icons)}}function V5(){let e=tU(z5);if(!e)throw Error(`useChatContext 必须在 provide(chatContextKey) 的组件子树内调用`);return e}function H5(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ese(e){if(Array.isArray(e))return e}function tse(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function nse(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
348
348
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rse(e,t){return ese(e)||tse(e,t)||ise(e,t)||nse()}function ise(e,t){if(e){if(typeof e==`string`)return H5(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?H5(e,t):void 0}}var U5=Object.entries,W5=Object.setPrototypeOf,ase=Object.isFrozen,ose=Object.getPrototypeOf,sse=Object.getOwnPropertyDescriptor,G5=Object.freeze,K5=Object.seal,q5=Object.create,J5=typeof Reflect<`u`&&Reflect,Y5=J5.apply,X5=J5.construct;G5||=function(e){return e},K5||=function(e){return e},Y5||=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return e.apply(t,r)},X5||=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)};var Z5=f7(Array.prototype.forEach),cse=f7(Array.prototype.lastIndexOf),Q5=f7(Array.prototype.pop),$5=f7(Array.prototype.push),lse=f7(Array.prototype.splice),e7=Array.isArray,t7=f7(String.prototype.toLowerCase),n7=f7(String.prototype.toString),r7=f7(String.prototype.match),i7=f7(String.prototype.replace),a7=f7(String.prototype.indexOf),use=f7(String.prototype.trim),dse=f7(Number.prototype.toString),fse=f7(Boolean.prototype.toString),o7=typeof BigInt>`u`?null:f7(BigInt.prototype.toString),s7=typeof Symbol>`u`?null:f7(Symbol.prototype.toString),c7=f7(Object.prototype.hasOwnProperty),l7=f7(Object.prototype.toString),u7=f7(RegExp.prototype.test),d7=pse(TypeError);function f7(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return Y5(e,t,r)}}function pse(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return X5(e,n)}}function p7(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t7;if(W5&&W5(e,null),!e7(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ase(t)||(t[r]=e),i=e)}e[i]=!0}return e}function mse(e){for(let t=0;t<e.length;t++)c7(e,t)||(e[t]=null);return e}function m7(e){let t=q5(null);for(let r of U5(e)){var n=rse(r,2);let i=n[0],a=n[1];c7(e,i)&&(e7(a)?t[i]=mse(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=m7(a):t[i]=a)}return t}function hse(e){switch(typeof e){case`string`:return e;case`number`:return dse(e);case`boolean`:return fse(e);case`bigint`:return o7?o7(e):`0`;case`symbol`:return s7?s7(e):`Symbol()`;case`undefined`:return l7(e);case`function`:case`object`:{if(e===null)return l7(e);let t=e,n=h7(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:l7(e)}return l7(e)}default:return l7(e)}}function h7(e,t){for(;e!==null;){let n=sse(e,t);if(n){if(n.get)return f7(n.get);if(typeof n.value==`function`)return f7(n.value)}e=ose(e)}function n(){return null}return n}function gse(e){try{return u7(e,``),!0}catch{return!1}}var g7=G5(`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`.split(`.`)),_7=G5(`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`.split(`.`)),v7=G5([`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`]),_se=G5([`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`]),y7=G5(`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`.split(`.`)),vse=G5([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),b7=G5([`#text`]),x7=G5(`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`.split(`.`)),S7=G5(`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`.split(`.`)),C7=G5(`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`.split(`.`)),w7=G5([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),yse=K5(/{{[\w\W]*|^[\w\W]*}}/g),bse=K5(/<%[\w\W]*|^[\w\W]*%>/g),xse=K5(/\${[\w\W]*/g),Sse=K5(/^data-[\-\w.\u00B7-\uFFFF]+$/),Cse=K5(/^aria-[\-\w]+$/),T7=K5(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),wse=K5(/^(?:\w+script|data):/i),Tse=K5(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ese=K5(/^html$/i),Dse=K5(/^[a-z][.\w]*(-[.\w]+)+$/i),E7=K5(/<[/\w!]/g),D7=K5(/<[/\w]/g),Ose=K5(/<\/no(script|embed|frames)/i),kse=K5(/\/>/i),O7={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ase=function(){return typeof window>`u`?null:window},jse=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},k7=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},A7=function(e,t,n,r){return c7(e,t)&&e7(e[t])?p7(r.base?m7(r.base):{},e[t],r.transform):n};function j7(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ase(),t=e=>j7(e);if(t.version=`3.4.13`,t.removed=[],!e||!e.document||e.document.nodeType!==O7.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=h7(d,`cloneNode`),p=h7(d,`remove`),m=h7(d,`nextSibling`),h=h7(d,`childNodes`),g=h7(d,`parentNode`),_=h7(d,`shadowRoot`),v=h7(d,`attributes`),y=o&&o.prototype?h7(o.prototype,`nodeType`):null,b=o&&o.prototype?h7(o.prototype,`nodeName`):null,x=o&&o.prototype?h7(o.prototype,`ownerDocument`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let S,C=``,w,T=!1,ee=0,E=function(){if(ee>0)throw d7(`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.`)},te=function(e){E(),ee++;try{return S.createHTML(e)}finally{ee--}},ne=function(e){E(),ee++;try{return S.createScriptURL(e)}finally{ee--}},D=function(){return T||=(w=jse(u,i),!0),w},re=n,O=re.implementation,ie=re.createNodeIterator,ae=re.createDocumentFragment,oe=re.getElementsByTagName,k=r.importNode,se=k7();t.isSupported=typeof U5==`function`&&typeof g==`function`&&O&&O.createHTMLDocument!==void 0;let A=yse,ce=bse,le=xse,ue=Sse,de=Cse,fe=wse,pe=Tse,me=Dse,he=T7,ge=null,_e=p7({},[...g7,..._7,...v7,...y7,...b7]),ve=null,ye=p7({},[...x7,...S7,...C7,...w7]),be=Object.seal(q5(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}})),j=null,xe=null,M=Object.seal(q5(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Se=!0,N=!0,Ce=!1,we=!0,Te=!1,Ee=!0,De=!1,Oe=!1,ke=null,Ae=null,je=!1,Me=!1,Ne=!1,Pe=!1,Fe=!0,Ie=!1,Le=`user-content-`,Re=!0,ze=!1,Be={},Ve=null,He=p7({},`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`.split(`.`)),Ue=null,We=p7({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ge=null,Ke=p7({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),qe=`http://www.w3.org/1998/Math/MathML`,Je=`http://www.w3.org/2000/svg`,Ye=`http://www.w3.org/1999/xhtml`,Xe=Ye,Ze=!1,Qe=null,$e=p7({},[qe,Je,Ye],n7),et=G5([`mi`,`mo`,`mn`,`ms`,`mtext`]),tt=p7({},et),nt=G5([`annotation-xml`]),rt=p7({},nt),it=p7({},[`title`,`style`,`font`,`a`,`script`]),at=null,ot=[`application/xhtml+xml`,`text/html`],st=null,ct=null,lt=n.createElement(`form`),ut=function(e){return e instanceof RegExp||e instanceof Function},dt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ct&&ct===e)return;(!e||typeof e!=`object`)&&(e={}),e=m7(e),at=ot.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,st=at===`application/xhtml+xml`?n7:t7,ge=A7(e,`ALLOWED_TAGS`,_e,{transform:st}),ve=A7(e,`ALLOWED_ATTR`,ye,{transform:st}),Qe=A7(e,`ALLOWED_NAMESPACES`,$e,{transform:n7}),Ge=A7(e,`ADD_URI_SAFE_ATTR`,Ke,{transform:st,base:Ke}),Ue=A7(e,`ADD_DATA_URI_TAGS`,We,{transform:st,base:We}),Ve=A7(e,`FORBID_CONTENTS`,He,{transform:st}),j=A7(e,`FORBID_TAGS`,m7({}),{transform:st}),xe=A7(e,`FORBID_ATTR`,m7({}),{transform:st}),Be=c7(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?m7(e.USE_PROFILES):e.USE_PROFILES:!1,Se=e.ALLOW_ARIA_ATTR!==!1,N=e.ALLOW_DATA_ATTR!==!1,Ce=e.ALLOW_UNKNOWN_PROTOCOLS||!1,we=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Te=e.SAFE_FOR_TEMPLATES||!1,Ee=e.SAFE_FOR_XML!==!1,De=e.WHOLE_DOCUMENT||!1,Me=e.RETURN_DOM||!1,Ne=e.RETURN_DOM_FRAGMENT||!1,Pe=e.RETURN_TRUSTED_TYPE||!1,je=e.FORCE_BODY||!1,Fe=e.SANITIZE_DOM!==!1,Ie=e.SANITIZE_NAMED_PROPS||!1,Re=e.KEEP_CONTENT!==!1,ze=e.IN_PLACE||!1,he=gse(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:T7,Xe=typeof e.NAMESPACE==`string`?e.NAMESPACE:Ye,tt=c7(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?m7(e.MATHML_TEXT_INTEGRATION_POINTS):p7({},et),rt=c7(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?m7(e.HTML_INTEGRATION_POINTS):p7({},nt);let t=c7(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?m7(e.CUSTOM_ELEMENT_HANDLING):q5(null);if(be=q5(null),c7(t,`tagNameCheck`)&&ut(t.tagNameCheck)&&(be.tagNameCheck=t.tagNameCheck),c7(t,`attributeNameCheck`)&&ut(t.attributeNameCheck)&&(be.attributeNameCheck=t.attributeNameCheck),c7(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(be.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),K5(be),Te&&(N=!1),Ne&&(Me=!0),Be&&(ge=p7({},b7),ve=q5(null),Be.html===!0&&(p7(ge,g7),p7(ve,x7)),Be.svg===!0&&(p7(ge,_7),p7(ve,S7),p7(ve,w7)),Be.svgFilters===!0&&(p7(ge,v7),p7(ve,S7),p7(ve,w7)),Be.mathMl===!0&&(p7(ge,y7),p7(ve,C7),p7(ve,w7))),M.tagCheck=null,M.attributeCheck=null,c7(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?M.tagCheck=e.ADD_TAGS:e7(e.ADD_TAGS)&&(ge===_e&&(ge=m7(ge)),p7(ge,e.ADD_TAGS,st))),c7(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?M.attributeCheck=e.ADD_ATTR:e7(e.ADD_ATTR)&&(ve===ye&&(ve=m7(ve)),p7(ve,e.ADD_ATTR,st))),c7(e,`ADD_URI_SAFE_ATTR`)&&e7(e.ADD_URI_SAFE_ATTR)&&p7(Ge,e.ADD_URI_SAFE_ATTR,st),c7(e,`FORBID_CONTENTS`)&&e7(e.FORBID_CONTENTS)&&(Ve===He&&(Ve=m7(Ve)),p7(Ve,e.FORBID_CONTENTS,st)),c7(e,`ADD_FORBID_CONTENTS`)&&e7(e.ADD_FORBID_CONTENTS)&&(Ve===He&&(Ve=m7(Ve)),p7(Ve,e.ADD_FORBID_CONTENTS,st)),Re&&(ge[`#text`]=!0),De&&p7(ge,[`html`,`head`,`body`]),ge.table&&(p7(ge,[`tbody`]),delete j.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw d7(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw d7(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=S;S=e.TRUSTED_TYPES_POLICY;try{C=te(``)}catch(e){throw S=t,e}}else e.TRUSTED_TYPES_POLICY===null?(S=void 0,C=``):(S===void 0&&(S=D()),S&&typeof C==`string`&&(C=te(``)));G5&&G5(e),ct=e},ft=p7({},[..._7,...v7,..._se]),pt=p7({},[...y7,...vse]),mt=function(e,t,n){return t.namespaceURI===Ye?e===`svg`:t.namespaceURI===qe?e===`svg`&&(n===`annotation-xml`||tt[n]):!!ft[e]},ht=function(e,t,n){return t.namespaceURI===Ye?e===`math`:t.namespaceURI===Je?e===`math`&&rt[n]:!!pt[e]},gt=function(e,t,n){return t.namespaceURI===Je&&!rt[n]||t.namespaceURI===qe&&!tt[n]?!1:!pt[e]&&(it[e]||!ft[e])},_t=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:Xe,tagName:`template`});let n=t7(e.tagName),r=t7(t.tagName);return Qe[e.namespaceURI]?e.namespaceURI===Je?mt(n,t,r):e.namespaceURI===qe?ht(n,t,r):e.namespaceURI===Ye?gt(n,t,r):!!(at===`application/xhtml+xml`&&Qe[e.namespaceURI]):!1},vt=function(e){$5(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw d7(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},yt=function(e){St(e);let t=h(e);if(t){let e=[];Z5(t,t=>{$5(e,t)}),Z5(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},bt=function(e,n){try{$5(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{$5(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Me||Ne)try{vt(n)}catch{}else try{n.setAttribute(e,``)}catch{}},xt=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||ve[st(i)]))try{e.removeAttribute(i)}catch{}}},St=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===O7.element&&xt(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Ct=function(e){if(!Ee)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=y?y(e):e.nodeType;if(n===O7.processingInstruction||n===O7.comment&&u7(D7,e.data)){try{p(e)}catch{}continue}if(n===O7.element){let t=e,n=st(b?b(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&n!==`label`&&n!==`output`&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},wt=function(e){let t=null,r=null;if(je)e=`<remove></remove>`+e;else{let t=r7(e,/^[\r\n\t ]+/);r=t&&t[0]}at===`application/xhtml+xml`&&Xe===Ye&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=S?te(e):e;if(Xe===Ye)try{t=new l().parseFromString(i,at)}catch{}if(!t||!t.documentElement){t=O.createDocument(Xe,`template`,null);try{t.documentElement.innerHTML=Ze?C:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Xe===Ye?oe.call(t,De?`html`:`body`)[0]:De?t.documentElement:a},Tt=function(e){let t=x?x(e):e.ownerDocument;return ie.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Et=function(e){return e=i7(e,A,` `),e=i7(e,ce,` `),e=i7(e,le,` `),e},Dt=function(e){e.normalize();let t=x?x(e):e.ownerDocument,n=ie.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=Et(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&Z5(i,e=>{kt(e.content)&&Dt(e.content)})},Ot=function(e){let t=b?b(e):null;return typeof t!=`string`||st(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},kt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===O7.documentFragment}catch{return!1}},At=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function jt(e,n,r){e.length!==0&&Z5(e,e=>{e.call(t,n,r,ct)})}let Mt=function(e,t){return!!(Ee&&e.hasChildNodes()&&!At(e.firstElementChild)&&u7(E7,e.textContent)&&u7(E7,e.innerHTML)||Ee&&e.namespaceURI===Ye&&t===`style`&&At(e.firstElementChild)||e.nodeType===O7.processingInstruction||Ee&&e.nodeType===O7.comment&&u7(D7,e.data))},Nt=function(e,t,n){if(!j[t]&&Lt(t)&&(be.tagNameCheck instanceof RegExp&&u7(be.tagNameCheck,t)||be.tagNameCheck instanceof Function&&be.tagNameCheck(t)))return!1;if(Re&&!Ve[t]){let t=g(e),r=h(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,m(e))}}}return vt(e),!0},Pt=function(e,t,n,r){return e.length===0?t:t===n||t===r?m7(t):t},P=function(e,n){if(jt(se.beforeSanitizeElements,e,null),e!==n&&g(e)===null)return ze&&St(e),!0;if(Ot(e))return vt(e),!0;let r=st(b?b(e):e.nodeName);if(ge=Pt(se.uponSanitizeElement,ge,_e,ke),jt(se.uponSanitizeElement,e,{tagName:r,allowedTags:ge}),e!==n&&g(e)===null)return ze&&St(e),!0;if(Mt(e,r))return vt(e),!0;if(j[r]||!(M.tagCheck instanceof Function&&M.tagCheck(r))&&!ge[r]){let t=Nt(e,r,n);return t===!1&&jt(se.afterSanitizeElements,e,null),t}if((y?y(e):e.nodeType)===O7.element&&!_t(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&u7(Ose,e.innerHTML))return vt(e),!0;if(Te&&e.nodeType===O7.text){let n=Et(e.textContent);e.textContent!==n&&($5(t.removed,{element:e.cloneNode()}),e.textContent=n)}return jt(se.afterSanitizeElements,e,null),!1},Ft=function(e,t,r){if(xe[t]||Ee&&t===`patchsrc`||Ee&&t===`for`&&e!==`label`&&e!==`output`||Fe&&(t===`id`||t===`name`)&&(r in n||r in lt))return!1;let i=ve[t]||M.attributeCheck instanceof Function&&M.attributeCheck(t,e);if(!(N&&u7(ue,t))&&!(Se&&u7(de,t))){if(!i){if(!(Lt(e)&&(be.tagNameCheck instanceof RegExp&&u7(be.tagNameCheck,e)||be.tagNameCheck instanceof Function&&be.tagNameCheck(e))&&(be.attributeNameCheck instanceof RegExp&&u7(be.attributeNameCheck,t)||be.attributeNameCheck instanceof Function&&be.attributeNameCheck(t,e))||t===`is`&&be.allowCustomizedBuiltInElements&&(be.tagNameCheck instanceof RegExp&&u7(be.tagNameCheck,r)||be.tagNameCheck instanceof Function&&be.tagNameCheck(r))))return!1}else if(!Ge[t]&&!u7(he,i7(r,pe,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&a7(r,`data:`)===0&&Ue[e])&&!(Ce&&!u7(fe,i7(r,pe,``)))&&r)return!1}return!0},It=p7({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Lt=function(e){return!It[t7(e)]&&u7(me,e)},Rt=function(e,t,n,r){if(S&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return te(r);case`TrustedScriptURL`:return ne(r)}return r},zt=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),Ot(e)?vt(e):Q5(t.removed)}catch{bt(n,e)}},Bt=function(e){jt(se.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||Ot(e))return;ve=Pt(se.uponSanitizeAttribute,ve,ye,Ae);let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:ve,forceKeepAttr:void 0},r=t.length,i=st(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=st(o),u=c,d=o===`value`?u:use(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,jt(se.uponSanitizeAttribute,e,n),d=n.attrValue,Ie&&(l===`id`||l===`name`)&&a7(d,Le)!==0&&(bt(o,e),d=Le+d),Ee&&u7(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){bt(o,e);continue}if(l===`attributename`&&r7(d,`href`)){bt(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){bt(o,e);continue}if(!we&&u7(kse,d)){bt(o,e);continue}if(Te&&(d=Et(d)),!Ft(i,l,d)){bt(o,e);continue}d=Rt(i,l,s,d),d!==u&&zt(e,o,s,d)}}jt(se.afterSanitizeAttributes,e,null)},Vt=function(e){let t=null,n=Tt(e);for(jt(se.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(jt(se.uponSanitizeShadowNode,t,null),P(t,e),Bt(t),kt(t.content)&&Vt(t.content),(y?y(t):t.nodeType)===O7.element){let e=_(t);kt(e)&&(Ht(e),Vt(e))}jt(se.afterSanitizeShadowDOM,e,null)},Ht=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Vt(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===O7.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&st(e)===`template`){let e=n.content;kt(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);kt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Ze=!e,Ze&&(e=`<!-->`),typeof e!=`string`&&!At(e)&&(e=hse(e),typeof e!=`string`))throw d7(`dirty is not a string, aborting`);if(!t.isSupported)return e;Oe?(ge=ke,ve=Ae):dt(n),(se.uponSanitizeElement.length>0||se.uponSanitizeAttribute.length>0)&&(ge=m7(ge)),se.uponSanitizeAttribute.length>0&&(ve=m7(ve)),t.removed=[];let c=ze&&typeof e!=`string`&&At(e);if(c){Ct(e);let t=b?b(e):e.nodeName;if(typeof t==`string`){let n=st(t);if(!ge[n]||j[n])throw yt(e),d7(`root node is forbidden and cannot be sanitized in-place`)}if(Ot(e))throw yt(e),d7(`root node is clobbered and cannot be sanitized in-place`);try{Ht(e)}catch(t){throw yt(e),t}}else if(At(e))i=wt(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===O7.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Ht(a);else{if(!Me&&!Te&&!De&&e.indexOf(`<`)===-1)return S&&Pe?te(e):e;if(i=wt(e),!i)return Me?null:Pe?C:``}i&&je&&vt(i.firstChild);let l=c?e:i;try{let e=Tt(l);for(;o=e.nextNode();)P(o,l),Bt(o),kt(o.content)&&Vt(o.content)}catch(n){throw c&&(yt(e),Z5(t.removed,e=>{e.element&&St(e.element)})),n}if(c)return Z5(t.removed,e=>{e.element&&St(e.element)}),Te&&Dt(e),e;if(Me){if(Te&&Dt(i),Ne)for(s=ae.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(ve.shadowroot||ve.shadowrootmode)&&(s=k.call(r,s,!0)),s}let u=De?i.outerHTML:i.innerHTML;return De&&ge[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&u7(Ese,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>