page-agent-sdk 4.1.0 → 4.2.1

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;oe(t,i);continue;case w.BEGIN_WHITESPACE:oe(t,i);continue;case w.TEXT:if(t.sawRoot&&!t.closedRoot){for(var a=n-1;i&&i!==`<`&&i!==`&`;)i=se(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)&&A(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(A(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?(D(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)&&A(t,`Inappropriately located doctype declaration`),t.doctype=``,t.sgmlDecl=``):i===`>`?(D(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,D(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=O(t.opt,t.comment),t.comment&&D(t,`oncomment`,t.comment),t.comment=``):(t.comment+=`-`+i,t.state=w.COMMENT);continue;case w.COMMENT_ENDED:i===`>`?t.state=w.TEXT:(A(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&&D(t,`oncdata`,t.cdata),D(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===`>`?(D(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:(ne(t),i===`>`?M(t):i===`/`?t.state=w.OPEN_TAG_SLASH:(y(i)||A(t,`Invalid character in tag name`),t.state=w.ATTRIB));continue;case w.OPEN_TAG_SLASH:i===`>`?(M(t,!0),ie(t)):(A(t,`Forward-slash in opening tag not followed by >`),t.state=w.ATTRIB);continue;case w.ATTRIB:if(y(i))continue;i===`>`?M(t):i===`/`?t.state=w.OPEN_TAG_SLASH:S(h,i)?(t.attribName=i,t.attribValue=``,t.state=w.ATTRIB_NAME):A(t,`Invalid attribute name`);continue;case w.ATTRIB_NAME:i===`=`?t.state=w.ATTRIB_VALUE:i===`>`?(A(t,`Attribute without value`),t.attribValue=t.attribName,re(t),M(t)):y(i)?t.state=w.ATTRIB_NAME_SAW_WHITE:S(g,i)?t.attribName+=i:A(t,`Invalid attribute name`);continue;case w.ATTRIB_NAME_SAW_WHITE:if(i===`=`)t.state=w.ATTRIB_VALUE;else if(y(i))continue;else A(t,`Attribute without value`),t.tag.attributes[t.attribName]=``,t.attribValue=``,D(t,`onattribute`,{name:t.attribName,value:``}),t.attribName=``,i===`>`?M(t):S(h,i)?(t.attribName=i,t.state=w.ATTRIB_NAME):(A(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):(A(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}re(t),t.q=``,t.state=w.ATTRIB_VALUE_CLOSED;continue;case w.ATTRIB_VALUE_CLOSED:y(i)?t.state=w.ATTRIB:i===`>`?M(t):i===`/`?t.state=w.OPEN_TAG_SLASH:S(h,i)?(A(t,`No whitespace between attributes`),t.attribName=i,t.attribValue=``,t.state=w.ATTRIB_NAME):A(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}re(t),i===`>`?M(t):t.state=w.ATTRIB;continue;case w.CLOSE_TAG:if(t.tagName)i===`>`?ie(t):S(g,i)?t.tagName+=i:t.script?(t.script+=`</`+t.tagName,t.tagName=``,t.state=w.SCRIPT):(y(i)||A(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):A(t,`Invalid tagname in closing tag.`):t.tagName=i}continue;case w.CLOSE_TAG_SAW_WHITE:if(y(i))continue;i===`>`?ie(t):A(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=ae(t);t.entity=``,t.state=s,t.write(l)}else t[c]+=ae(t),t.entity=``,t.state=s;else S(t.entity.length?v:_,i)?t.entity+=i:(A(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 kF(e,t){if(e.function===void 0)return;let n;if(t?.partial)try{n=Yx(e.function.arguments??`{}`)}catch{return}else try{n=JSON.parse(e.function.arguments)}catch(t){throw new CF([`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 AF(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 jF(e,t){return{name:e.function?.name,args:e.function?.arguments,id:e.id,error:t,type:`invalid_tool_call`}}var MF=class extends TF{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(gS(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=>kF(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}},NF=class extends MF{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 CF(`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 Dk(this.zodSchema,e);if(t.success)return t.data;throw new CF(`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 PF(e){return Ek(e)?OF.fromZodSchema(e):tM(e)?DF.fromSerializableSchema(e):new EF}function FF(e,t,n){let r=n??NF;return Ek(e)?new r({returnSingle:!0,keyName:t,zodSchema:e}):tM(e)?new r({returnSingle:!0,keyName:t,serializableSchema:e}):new r({returnSingle:!0,keyName:t})}function IF(e,t,n,r){if(!n){let n=e.pipe(t);return r?n.withConfig({runName:r}):n}let i=bF.assign({parsed:(e,n)=>t.invoke(e.raw,n)}),a=bF.assign({parsed:()=>null}),o=i.withFallbacks({fallbacks:[a]}),s=TM.from([{raw:e},o]);return r?s.withConfig({runName:r}):s}var LF=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 RF(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 zF(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 BF(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 VF(e){if(typeof e!=`object`||!e)return!1;let t=e.type;return t===`reasoning`||t===`thinking`}function HF(e){if(e)return{...e,input_tokens:e.input_tokens??0,output_tokens:e.output_tokens??0,total_tokens:e.total_tokens??0}}function UF(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 WF(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:UF(r)}}var GF=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=zF(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=zF(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)}},KF=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)}},qF=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(!VF(r.content)){if(n)return;continue}n=!0;let e=BF(r.content);if(e==null||e.length===0)continue;t+=e,yield t}else if(r.event===`content-block-delta`){let e=zF(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`&&VF(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(!VF(n.content)){if(t)return;continue}t=!0;let e=BF(n.content);e!=null&&e.length>0&&(yield e)}else if(n.event===`content-block-delta`){let e=zF(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`&&VF(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)}},JF=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=HF(t.usage);e&&(yield e)}else if(t.event===`message-start`&&t.usage){let e=HF(t.usage);e&&(yield e)}else if(t.event===`message-finish`&&t.usage){let e=HF(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)}},YF=class{_buffer;constructor(e){this._buffer=new LF,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 GF(this._buffer)}get toolCalls(){return new KF(this._buffer)}get reasoning(){return new qF(this._buffer)}get usage(){return new JF(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=HF(a.usage));break;case`content-block-start`:e[a.index]=a.content;break;case`content-block-delta`:{let t=e[a.index],n=zF(a);t&&n&&(e[a.index]=RF(t,n));break}case`content-block-finish`:e[a.index]=a.content;break;case`usage`:n=HF(a.usage);break;case`message-finish`:i=a.reason,a.usage&&(n=HF(a.usage)),a.responseMetadata&&(r={...r,...a.responseMetadata});break;default:break}let a=e.filter(e=>e!=null).map(WF);return new hS({id:t,content:a,usage_metadata:n,response_metadata:{...r,...i?{finish_reason:i}:{},output_version:`v1`}})}},XF={wav:`audio/wav`,mp3:`audio/mpeg`,flac:`audio/flac`,opus:`audio/opus`,aac:`audio/aac`,pcm16:`audio/pcm`},ZF={png:`image/png`,jpeg:`image/jpeg`,jpg:`image/jpeg`,webp:`image/webp`,gif:`image/gif`};function QF(e){let t=0;for(let n of e.keys())n>=t&&(t=n+1);return t}function $F(e){let t=e.additional_kwargs;return typeof t==`object`&&t?t:{}}function eI(e){let t=$F(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:ZF[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 tI(e){let t=$F(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:XF[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*nI(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};vS.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=iI(e);r.accumulated=rI(r.accumulated,i),yield{event:`content-block-delta`,index:t,delta:i}}}if(vS.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=tI(e);if(u!=null){if(a==null){let e=QF(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 eI(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=QF(n);n.set(i,{type:`image`,accumulated:t}),yield{event:`content-block-start`,index:i,content:t}}if(!c&&vS.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:aI(t.accumulated)};yield{event:`message-finish`,reason:`stop`,...i?{usage:i}:{}}}function rI(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 iI(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 aI(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 oI(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];(Zy(r)||Qy(r))&&e===n&&(e=new n.constructor({...e,content:[...n.content.slice(0,t),eb(r),...n.content.slice(t+1)]}))}t.push(e)}return t}var sI=class e extends _F{lc_namespace=[`langchain`,`chat_models`,this._llmType()];disableStreaming=!1;outputVersion;get callKeys(){return[...super.callKeys,`outputVersion`]}constructor(e){super(e),this.outputVersion=vF(()=>{let t=e.outputVersion??tC(`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*nI(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 YF(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 mO.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(),[oI(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 yF(e.message):yield e.message,f=f?f.concat(e):e,_S(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(lS)),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 mO.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(oI),r.runId,void 0,s,void 0,void 0,r.runName)}let s=n.outputVersion??this.outputVersion,c=[],l=[],u=!!o?.[0].handlers.find(iC),d=!!o?.[0].handlers.find(rC);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 YF({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 Ky(`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:DO(t,i),_S(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 Ky(`Model invocation was aborted.`,e)}if(t===void 0)throw Error(`Received empty response from chat model call.`);s===`v1`&&(t.message=yF(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=yF(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,XO,{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(lS)),s={...a.metadata,...this.getLsParamsWithDefaults(i)},c=this._getInvocationParamsForTracing(i),l=await mO.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(oI),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&&dx(e.message)&&gS(e.message)&&(e.message.usage_metadata={input_tokens:0,output_tokens:0,total_tokens:0},m===`v1`&&(e.message=yF(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,XO,{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(lS)),[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=kk(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`;!Ek(n)&&!tM(n)&&`name`in n&&(s=n.name);let c=Ek(n)||tM(n)?dM(n):n,l=[{type:`function`,function:{name:s,description:i,parameters:c}}];return IF(this.bindTools(l),DM.from(e=>{if(!vS.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 cI(e,t){return typeof e==`string`?{model:e,...t??{}}:e??t}var lI=class extends sI{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??tC(`OPENAI_API_KEY`),this.organization=e?.configuration?.organization??tC(`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(!LM(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&&Ek(e.json_schema.schema)?IP(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=WM({baseURL:this.clientConfig.baseURL}),t={...this.clientConfig,baseURL:e,timeout:this.timeout,maxRetries:0};t.baseURL||delete t.baseURL,t.defaultHeaders=JM(t.defaultHeaders),this.client=new Iy(t)}return{...this.clientConfig,...e}}_convertChatOpenAIToolToCompletionsTool(e,t){return uN(e)?_N(e.metadata.customTool):mF(e)?t?.strict===void 0?e:{...e,function:{...e.function,strict:t.strict}}:tN(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(sN(e)||uN(e))return e;if(cN(e))return e.extras.providerToolDefinition;let t=this._convertChatOpenAIToolToCompletionsTool(e,{strict:n});return QM(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(HM(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=rN(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 Yy(e)}})}get profile(){return RP[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=PP(this.model,t?.method);if(s===`jsonMode`){r=PF(i);let e=dM(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=dM(i),o={name:a??`extract`,description:kk(e),schema:Ek(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}}}),Ek(i)||tM(i)){let e=PF(i);r=DM.from(async t=>`parsed`in t.additional_kwargs?t.additional_kwargs.parsed:e.invoke(t.content))}else r=new EF}else{let e=a??`extract`,o=dM(i),s;Ek(i)||tM(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=FF(i,e)}return IF(n,r,o)}},uI={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=nb({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=tb(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=tb(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=nb({dataUrl:e.url}),n=VM(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=VM(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`)}},dI=({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(kF(e,{returnId:!0}))}catch(t){o.push(jF(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 hS({content:LP(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 Xx(e.content||``,e.role??`unknown`)}},fI=({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 eS({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 vS({content:a,tool_call_chunks:n,additional_kwargs:o,id:t.id,response_metadata:s})}else if(i===`system`)return new rS({content:a,response_metadata:s});else if(i===`developer`)return new rS({content:a,response_metadata:s,additional_kwargs:{__openai_role__:`developer`}});else if(i===`function`)return new Qx({content:a,additional_kwargs:o,name:e.name,response_metadata:s});else if(i===`tool`)return new bx({content:a,additional_kwargs:o,tool_call_id:e.tool_call_id,response_metadata:s});else return new Zx({content:a,role:i,response_metadata:s})},pI=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=aS(()=>{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=VM(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}}}},mI=({message:e,model:t})=>{let n=HM(e);if(n===`system`&&LM(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 hS.isInstance(e)&&e.tool_calls?.length?t.tool_calls=e.tool_calls.map(AF):e.additional_kwargs.tool_calls!=null&&(t.tool_calls=e.additional_kwargs.tool_calls),t}else if(n===`tool`&&yx.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=pI(t);e&&(yield e)}}return{role:`user`,content:Array.from(r(e.contentBlocks))}},hI=({messages:e,model:t})=>e.flatMap(e=>{if(`output_version`in e.response_metadata&&e.response_metadata?.output_version===`v1`)return mI({message:e});let n=HM(e);n===`system`&&LM(t)&&(n=`developer`);let r=typeof e.content==`string`?e.content:e.content.flatMap(e=>Xy(e)?rb(e,uI):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),hS.isInstance(e)&&e.tool_calls?.length?i.tool_calls=e.tool_calls.map(AF):(e.additional_kwargs.tool_calls!=null&&(i.tool_calls=e.additional_kwargs.tool_calls),yx.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*gI(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=bI(t.usage),yield{event:`usage`,usage:l});let e=t.x_groq?.usage;e&&n&&(l=vI(e),yield{event:`usage`,usage:l});let o=t.choices?.[0];if(!o)continue;o.finish_reason!=null&&(u=yI(o.finish_reason),d=xI(t,o));let{delta:s}=o;if(!s)continue;let m=_I(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:aI(t)};yield{event:`message-finish`,reason:u,...l?{usage:l}:{},...d?{responseMetadata:d}:{}}}function _I(e){let t=e.reasoning_content??e.reasoning;return typeof t==`string`&&t.length>0?t:void 0}function vI(e){return{input_tokens:e.prompt_tokens??0,output_tokens:e.completion_tokens??0,total_tokens:e.total_tokens??0}}function yI(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 bI(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 xI(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 SI=class extends lI{constructor(e,t){super(cI(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:oN(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),LM(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=hI({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}:{}},gS(n.message)&&(n.message.usage_metadata=r),n.message=new hS(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=hI({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*gI(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=hI({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 QO({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 QO({message:new vS({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 Yy(e)}})}_convertCompletionsDeltaToBaseMessageChunk(e,t,n){return fI({delta:e,rawResponse:t,includeRawResponse:this.__includeRawResponse,defaultRole:n})}_convertCompletionsMessageToBaseMessage(e,t){return dI({message:e,rawResponse:t,includeRawResponse:this.__includeRawResponse})}},CI=`__openai_function_call_ids__`,wI=`__openai_custom_tool_call_ids__`;function TI(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 EI(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 DI=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}},OI=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(TI),...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(kF(e,{returnId:!0}))}catch(t){let n;typeof t==`object`&&t&&`message`in t&&typeof t.message==`string`&&(n=t.message),r.push(jF(e,n))}o[CI]??={},i.id&&(o[CI][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=fN(i);e?(n.push(e),o[wI]??={},i.id&&i.call_id&&(o[wI][i.call_id]=i.id)):r.push(jF(i,`Malformed custom tool call`))}else if(i.type===`computer_call`){let e=pN(i);e?n.push(e):r.push(jF(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 hS({id:e.id,content:t,tool_calls:n,invalid_tool_calls:r,usage_metadata:DI(e.usage),additional_kwargs:o,response_metadata:a})},kI=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}},AI=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:[TI(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[CI]={[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[wI]={[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=OI(e.response);if(r=DI(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 QO({text:t.map(e=>e.text).join(``),message:new vS({id:s,content:t,tool_call_chunks:i,usage_metadata:r,additional_kwargs:o,response_metadata:a}),generationInfo:n})},jI=e=>{let t=hS.isInstance(e)&&e.response_metadata?.model_provider===`openai`;function*n(){let n=IM(()=>{try{let t=HM(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=IM(()=>{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=zM(e);return{type:`input_file`,file_id:e.fileId,...t?{filename:t}:{}}}if(e.url){let t=zM(e);return{...t?{filename:t}:{},type:`input_file`,file_url:e.url}}if(e.data){let t=VM(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=IM(()=>{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=IM(()=>{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())},MI=({messages:e,zdrEnabled:t,model:n})=>e.flatMap(e=>{let r=e.response_metadata;if(r?.output_version===`v1`)return jI(e);let i=e.additional_kwargs,a=HM(e);if(a===`system`&&LM(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=kI(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:IM(()=>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(EI)}}return e.type===`output_text`||e.type===`refusal`?e:[]})),phase:IM(()=>{if(Array.isArray(s))return s.find(e=>`phase`in e&&typeof e.phase==`string`)?.phase})};n.push(r)}let c=i?.[CI],l=i?.[wI];hS.isInstance(e)&&e.tool_calls?.length?n.push(...e.tool_calls.map(e=>hN(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}:mN(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}),Xy(e)){if(e.type===`file`){let t=zM(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:VM(e)}}return rb(e,uI)}return e.type===`text`?{type:`input_text`,text:e.text}:e.type===`image_url`?{type:`input_image`,image_url:IM(()=>{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:IM(()=>{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*NI(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:aI(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=PI(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=DI(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 PI(e,t){return t===`response.incomplete`?`length`:e===`completed`?`stop`:e===`incomplete`?`length`:`stop`}var FI=class extends lI{constructor(e,t){super(cI(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:lN(e?.tool_choice)?e?.tool_choice:(()=>{let t=oN(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:MI({messages:e,zdrEnabled:this.zdrEnabled??!1,model:this.model}),...r,stream:!1},{signal:t?.signal,...t?.options});return{generations:[{text:n.output_text,message:OI(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:MI({messages:e,zdrEnabled:this.zdrEnabled??!1,model:this.model}),stream:!0},t),i=this.streamUsage??t.streamUsage;yield*NI(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:MI({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=AI(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 Yy(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 Yy(e)}})}_reduceChatOpenAITools(e,t){let n=[];for(let r of e)if(sN(r))r.type===`image_generation`&&t?.stream&&(r.partial_images=1),n.push(r);else if(uN(r)){let e=r.metadata.customTool;n.push({type:`custom`,name:e.name,description:e.description,format:e.format})}else if(mF(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 dN(r)&&n.push(gN(r));return n}},II=class e extends lI{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=cI(e,t);super(n),this.fields=n,this.useResponsesApi=n?.useResponsesApi??!1,this.responses=n?.responses??new FI(n),this.completions=n?.completions??new SI(n)}_useResponsesApi(e){let t=e?.tools?.some(sN),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(dN)||e?.tools?.some(uN);return this.useResponsesApi||t||n||r||UM(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}};Bj(),yN();var LI=class extends gF{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=bO(yO(this.defaultConfig,t));return Wx(e)?(n=e.args,r={...r,toolCall:e}):n=e,this.call(n,r)}async call(e,t,n){let r=Wx(e)?e.args:e,i;if(Ek(this.schema))try{i=await Ok(this.schema,r)}catch(t){let n=`Received tool input did not match expected schema`;throw this.verboseParsingErrors&&(n=`${n}\nDetails: ${t.message}`),Vk(t)&&(n=`${n}\n\n${nt(t)}`),new Kx(n,JSON.stringify(e))}else{let t=lM(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 Kx(n,JSON.stringify(e))}i=r}let a=dO(t),o=mO.configure(a.callbacks,this.callbacks,a.tags||n,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),s;Wx(e)&&(s=e.id),!s&&Gx(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=vM(e)?await xse(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=UI({content:u,artifact:d,toolCallId:s,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(f),f}},RI=class extends LI{schema=Rj({input:Ij().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)}},zI=class extends RI{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=dO(t);return n.runName===void 0&&(n.runName=this.name),super.call(e,n)}_call(e,t,n){return this.func(e,t,n)}},BI=class extends LI{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=dO(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 VI(e,t){let n=Ak(t.schema),r=fM(t.schema);if(!t.schema||n||r)return new zI({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(t,n,r)=>new Promise((i,a)=>{let o=xO(r,{callbacks:n?.getChild()});_O.runWithConfig(SO(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 BI({...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(wO(r.signal))},r.signal.addEventListener(`abort`,o,{once:!0}));let c=xO(r,{callbacks:n?.getChild()});_O.runWithConfig(SO(c),async()=>{try{let n=await e(t,c);if(vM(n)){i(n);return}if(r?.signal?.aborted){s();return}s(),i(n)}catch(e){s(),a(e)}})})})}function HI(e){return typeof e==`object`&&!!e&&`type`in e}function UI(e){let{content:t,artifact:n,toolCallId:r,metadata:i}=e;return r&&!vx(t)?typeof t==`string`||Array.isArray(t)&&t.every(HI)?new yx({status:`success`,content:t,artifact:n,tool_call_id:r,name:e.name,metadata:i}):new yx({status:`success`,content:WI(t),artifact:n,tool_call_id:r,name:e.name,metadata:i}):t}function WI(e){try{return JSON.stringify(e)??``}catch{return`${e}`}}yN(),B({action:jd([B({type:Ud(`screenshot`)}),B({type:Ud(`click`),x:ud(),y:ud(),button:Vd([`left`,`right`,`wheel`,`back`,`forward`]).default(`left`)}),B({type:Ud(`double_click`),x:ud(),y:ud(),button:Vd([`left`,`right`,`wheel`,`back`,`forward`]).default(`left`)}),B({type:Ud(`drag`),path:z(B({x:ud(),y:ud()}))}),B({type:Ud(`keypress`),keys:z(R())}),B({type:Ud(`move`),x:ud(),y:ud()}),B({type:Ud(`scroll`),x:ud(),y:ud(),scroll_x:ud(),scroll_y:ud()}),B({type:Ud(`type`),text:R()}),B({type:Ud(`wait`),duration:ud().optional()})])}),yN(),jd([B({type:Ud(`exec`),command:z(R()),env:Id(R(),R()).optional(),working_directory:R().optional(),timeout_ms:ud().optional(),user:R().optional()})]),yN(),B({commands:z(R()).describe(`Array of shell commands to execute`),timeout_ms:ud().optional().describe(`Optional timeout in milliseconds for the commands`),max_output_length:ud().optional().describe(`Optional maximum number of characters to return from each command`)}),yN(),jd([B({type:Ud(`create_file`),path:R(),diff:R()}),B({type:Ud(`update_file`),path:R(),diff:R()}),B({type:Ud(`delete_file`),path:R()})]);function GI(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 KI(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 II({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 II({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&&GI(n?.body))try{a=await s(),o.set(`Authorization`,`Bearer ${a}`),l=await c()}catch{}return l}}})}var qI=[{pattern:/deepseek-v4/i,caps:{contextWindow:1048576,maxOutputTokens:393216,thinking:!0}},{pattern:/deepseek-reasoner|deepseek-r1/i,caps:{contextWindow:65536,maxOutputTokens:8192,thinking:!0}},{pattern:/deepseek/i,caps:{contextWindow:131072,maxOutputTokens:8192,thinking:!0}},{pattern:/gpt-5/i,caps:{contextWindow:1048576,maxOutputTokens:32768,vision:!0}},{pattern:/gpt-4\.1/i,caps:{contextWindow:1047576,maxOutputTokens:32768,vision:!0}},{pattern:/gpt-4o-mini/i,caps:{contextWindow:131072,maxOutputTokens:16384,vision:!0}},{pattern:/gpt-4o/i,caps:{contextWindow:131072,maxOutputTokens:16384,vision:!0}},{pattern:/gpt-4-turbo|gpt-4-1106|gpt-4-0125/i,caps:{contextWindow:131072,maxOutputTokens:4096,vision:!0}},{pattern:/gpt-3\.5/i,caps:{contextWindow:16385,maxOutputTokens:4096}},{pattern:/claude-(sonnet|opus)-4|claude-4/i,caps:{contextWindow:2e5,maxOutputTokens:64e3,vision:!0,thinking:!0}},{pattern:/claude-3-7-sonnet/i,caps:{contextWindow:2e5,maxOutputTokens:8192,vision:!0,thinking:!0}},{pattern:/claude-3-5-sonnet/i,caps:{contextWindow:2e5,maxOutputTokens:8192,vision:!0}},{pattern:/claude-3-opus/i,caps:{contextWindow:2e5,maxOutputTokens:4096,vision:!0}},{pattern:/claude-3-haiku/i,caps:{contextWindow:2e5,maxOutputTokens:4096,vision:!0}},{pattern:/qwen2\.5-vl|qwen2-vl|qwen-vl|qvq/i,caps:{contextWindow:32768,maxOutputTokens:2048,vision:!0}},{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,thinking:!0}},{pattern:/glm-5/i,caps:{contextWindow:2e5,maxOutputTokens:65536}},{pattern:/glm-4v|glm4v/i,caps:{contextWindow:32768,maxOutputTokens:2048,vision:!0}},{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}}],JI={contextWindow:32768,maxOutputTokens:4096},YI=2e5;function XI(e={}){let t=(()=>{if(!e.model)return;let t=qI.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??JI.contextWindow,maxOutputTokens:e.maxOutputTokens??t?.maxOutputTokens??JI.maxOutputTokens,vision:e.vision??t?.vision??!1,thinking:e.thinking??t?.thinking??!1}}function ZI(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 QI(e){return Math.max(2e3,Math.min(2e4,Math.round(e*.035)))}function $I(e){let t=QI(e);return Math.min(2e5,Math.max(t,Math.round(e*.7)))}function eL(e,t){if(!t)return e;if(t===`simple`){let t=e.extraBody&&`thinking`in e.extraBody;if(!t&&!e.thinking)return e;let{thinking:n,...r}=e,i=r;if(t){let{thinking:t,...n}=e.extraBody;i.extraBody=n}return i}if(e.provider===`anthropic`){if(e.thinking?.type===`enabled`&&e.thinking.budget_tokens)return e;let t=e.thinking?.budget_tokens??Math.min(e.maxTokens??4096,8e3);return{...e,thinking:{type:`enabled`,budget_tokens:t}}}let n=e.extraBody?.thinking??{};return{...e,extraBody:{...e.extraBody??{},thinking:{...n,type:`enabled`}}}}function tL(e,t,n){if(t)return t;if(e.thinkingMode)return e.thinkingMode;if(!(e.extraBody&&`thinking`in e.extraBody||e.thinking))return n||(XI({model:e.model}).thinking?`deep`:void 0)}function nL(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 rL(e){return!e||!e.startsWith(`/`)||typeof location>`u`||!location.origin?e:`${location.origin}${e}`}function iL(e,t={}){return e=eL(e,tL(e,t.thinkingMode,t.thinkingFallback)),new II({apiKey:e.apiKey,model:e.model,temperature:t.temperature??e.temperature,maxTokens:t.maxTokens??e.maxTokens,configuration:{...e.baseUrl?{baseURL:rL(e.baseUrl)}:{},fetch:nL,...e.extraConfig},...e.extraBody?{modelKwargs:e.extraBody}:{}})}async function aL(e,t={}){if(e=eL(e,tL(e,t.thinkingMode,t.thinkingFallback)),(e.provider??`openai`)===`openai`)return iL(e,t);let{ChatAnthropic:n}=await import(`@langchain/anthropic`);return new n({apiKey:e.apiKey,model:e.model,temperature:e.thinking?1:t.temperature??e.temperature,maxTokens:t.maxTokens??e.maxTokens,...e.baseUrl?{anthropicApiUrl:rL(e.baseUrl)}:{},...e.extraConfig?{clientOptions:e.extraConfig}:{},...e.thinking?{thinking:e.thinking}:{},...e.cacheControl?{invocationKwargs:{cache_control:{type:`ephemeral`,...e.cacheControl===!0?{}:{ttl:e.cacheControl}}}}:{}})}function oL(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 sL(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 cL(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`&&lL(e))return e}function lL(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 uL(e){let t=cL(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,l=n.output_token_details,u=n.completion_tokens_details,d=e,f=Number(l?.reasoning??u?.reasoning_tokens??d?.response_metadata?.usage?.completion_tokens_details?.reasoning_tokens??0)||0;return{prompt_tokens:r,completion_tokens:i,total_tokens:a,...s?{cache_read_input_tokens:s}:{},...c?{cache_creation_input_tokens:c}:{},...f?{reasoning_tokens:f}:{}}}function dL(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var fL={},pL=[],mL=()=>{},hL=()=>!1,gL=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),_L=e=>e.startsWith(`onUpdate:`),vL=Object.assign,yL=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},bL=Object.prototype.hasOwnProperty,xL=(e,t)=>bL.call(e,t),SL=Array.isArray,CL=e=>ML(e)===`[object Map]`,wL=e=>ML(e)===`[object Set]`,TL=e=>ML(e)===`[object Date]`,EL=e=>typeof e==`function`,DL=e=>typeof e==`string`,OL=e=>typeof e==`symbol`,kL=e=>typeof e==`object`&&!!e,AL=e=>(kL(e)||EL(e))&&EL(e.then)&&EL(e.catch),jL=Object.prototype.toString,ML=e=>jL.call(e),NL=e=>ML(e).slice(8,-1),PL=e=>ML(e)===`[object Object]`,FL=e=>DL(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,IL=dL(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),LL=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},RL=/-\w/g,zL=LL(e=>e.replace(RL,e=>e.slice(1).toUpperCase())),BL=/\B([A-Z])/g,VL=LL(e=>e.replace(BL,`-$1`).toLowerCase()),HL=LL(e=>e.charAt(0).toUpperCase()+e.slice(1)),UL=LL(e=>e?`on${HL(e)}`:``),WL=(e,t)=>!Object.is(e,t),GL=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},KL=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},qL=e=>{let t=parseFloat(e);return isNaN(t)?e:t},JL=e=>{let t=DL(e)?Number(e):NaN;return isNaN(t)?e:t},YL,XL=()=>YL||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{};function ZL(e){if(SL(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=DL(r)?tR(r):ZL(r);if(i)for(let e in i)t[e]=i[e]}return t}else if(DL(e)||kL(e))return e}var QL=/;(?![^(]*\))/g,$L=/:([^]+)/,eR=/\/\*[^]*?\*\//g;function tR(e){let t={};return e.replace(eR,``).split(QL).forEach(e=>{if(e){let n=e.split($L);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function nR(e){let t=``;if(DL(e))t=e;else if(SL(e))for(let n=0;n<e.length;n++){let r=nR(e[n]);r&&(t+=r+` `)}else if(kL(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}var rR=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,iR=dL(rR);rR+``;function aR(e){return!!e||e===``}function oR(e,t){if(e.length!==t.length)return!1;let n=!0;for(let r=0;n&&r<e.length;r++)n=sR(e[r],t[r]);return n}function sR(e,t){if(e===t)return!0;let n=TL(e),r=TL(t);if(n||r)return n&&r?e.getTime()===t.getTime():!1;if(n=OL(e),r=OL(t),n||r)return e===t;if(n=SL(e),r=SL(t),n||r)return n&&r?oR(e,t):!1;if(n=kL(e),r=kL(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||!sR(e[n],t[n]))return!1}}return String(e)===String(t)}var cR=e=>!!(e&&e.__v_isRef===!0),J=e=>DL(e)?e:e==null?``:SL(e)||kL(e)&&(e.toString===jL||!EL(e.toString))?cR(e)?J(e.value):JSON.stringify(e,lR,2):String(e),lR=(e,t)=>cR(t)?lR(e,t.value):CL(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[uR(t,r)+` =>`]=n,e),{})}:wL(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>uR(e))}:OL(t)?uR(t):kL(t)&&!SL(t)&&!PL(t)?String(t):t,uR=(e,t=``)=>OL(e)?`Symbol(${e.description??t})`:e,dR,wse=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&&dR&&(dR.active?(this.parent=dR,this.index=(dR.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=dR;try{return dR=this,e()}finally{dR=t}}}on(){++this._on===1&&(this.prevScope=dR,dR=this)}off(){if(this._on>0&&--this._on===0){if(dR===this)dR=this.prevScope;else{let e=dR;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 Tse(){return dR}function Ese(e,t=!1){dR&&dR.cleanups.push(e)}var fR,pR=new WeakSet,mR=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,dR&&(dR.active?dR.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,pR.has(this)&&(pR.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||vR(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,AR(this),xR(this);let e=fR,t=ER;fR=this,ER=!0;try{return this.fn()}finally{SR(this),fR=e,ER=t,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)TR(e);this.deps=this.depsTail=void 0,AR(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?pR.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){CR(this)&&this.run()}get dirty(){return CR(this)}},hR=0,gR,_R;function vR(e,t=!1){if(e.flags|=8,t){e.next=_R,_R=e;return}e.next=gR,gR=e}function yR(){hR++}function bR(){if(--hR>0)return;if(_R){let e=_R;for(_R=void 0;e;){let t=e.next;e.next=void 0,e.flags&=-9,e=t}}let e;for(;gR;){let t=gR;for(gR=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 xR(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function SR(e){let t,n=e.depsTail,r=n;for(;r;){let e=r.prevDep;r.version===-1?(r===n&&(n=e),TR(r),Dse(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=e}e.deps=t,e.depsTail=n}function CR(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(wR(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function wR(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===jR)||(e.globalVersion=jR,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!CR(e))))return;e.flags|=2;let t=e.dep,n=fR,r=ER;fR=e,ER=!0;try{xR(e);let n=e.fn(e._value);(t.version===0||WL(n,e._value))&&(e.flags|=128,e._value=n,t.version++)}catch(e){throw t.version++,e}finally{fR=n,ER=r,SR(e),e.flags&=-3}}function TR(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)TR(e,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function Dse(e){let{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}var ER=!0,DR=[];function OR(){DR.push(ER),ER=!1}function kR(){let e=DR.pop();ER=e===void 0||e}function AR(e){let{cleanup:t}=e;if(e.cleanup=void 0,t){let e=fR;fR=void 0;try{t()}finally{fR=e}}}var jR=0,Ose=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}},MR=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(!fR||!ER||fR===this.computed)return;let t=this.activeLink;if(t===void 0||t.sub!==fR)t=this.activeLink=new Ose(fR,this),fR.deps?(t.prevDep=fR.depsTail,fR.depsTail.nextDep=t,fR.depsTail=t):fR.deps=fR.depsTail=t,NR(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=fR.depsTail,t.nextDep=void 0,fR.depsTail.nextDep=t,fR.depsTail=t,fR.deps===t&&(fR.deps=e)}return t}trigger(e){this.version++,jR++,this.notify(e)}notify(e){yR();try{for(let e=this.subs;e;e=e.prevSub)e.sub.notify()&&e.sub.dep.notify()}finally{bR()}}};function NR(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)NR(e)}let n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}var PR=new WeakMap,FR=Symbol(``),IR=Symbol(``),LR=Symbol(``);function RR(e,t,n){if(ER&&fR){let t=PR.get(e);t||PR.set(e,t=new Map);let r=t.get(n);r||(t.set(n,r=new MR),r.map=t,r.key=n),r.track()}}function zR(e,t,n,r,i,a){let o=PR.get(e);if(!o){jR++;return}let s=e=>{e&&e.trigger()};if(yR(),t===`clear`)o.forEach(s);else{let i=SL(e),a=i&&FL(n);if(i&&n===`length`){let e=Number(r);o.forEach((t,n)=>{(n===`length`||n===LR||!OL(n)&&n>=e)&&s(t)})}else switch((n!==void 0||o.has(void 0))&&s(o.get(n)),a&&s(o.get(LR)),t){case`add`:i?a&&s(o.get(`length`)):(s(o.get(FR)),CL(e)&&s(o.get(IR)));break;case`delete`:i||(s(o.get(FR)),CL(e)&&s(o.get(IR)));break;case`set`:CL(e)&&s(o.get(FR));break}}bR()}function BR(e){let t=dz(e);return t===e?t:(RR(t,`iterate`,LR),lz(e)?t:t.map(fz))}function VR(e){return RR(e=dz(e),`iterate`,LR),e}function HR(e,t){return cz(e)?pz(sz(e)?fz(t):t):fz(t)}var kse={__proto__:null,[Symbol.iterator](){return UR(this,Symbol.iterator,e=>HR(this,e))},concat(...e){return BR(this).concat(...e.map(e=>SL(e)?BR(e):e))},entries(){return UR(this,`entries`,e=>(e[1]=HR(this,e[1]),e))},every(e,t){return WR(this,`every`,e,t,void 0,arguments)},filter(e,t){return WR(this,`filter`,e,t,e=>e.map(e=>HR(this,e)),arguments)},find(e,t){return WR(this,`find`,e,t,e=>HR(this,e),arguments)},findIndex(e,t){return WR(this,`findIndex`,e,t,void 0,arguments)},findLast(e,t){return WR(this,`findLast`,e,t,e=>HR(this,e),arguments)},findLastIndex(e,t){return WR(this,`findLastIndex`,e,t,void 0,arguments)},forEach(e,t){return WR(this,`forEach`,e,t,void 0,arguments)},includes(...e){return KR(this,`includes`,e)},indexOf(...e){return KR(this,`indexOf`,e)},join(e){return BR(this).join(e)},lastIndexOf(...e){return KR(this,`lastIndexOf`,e)},map(e,t){return WR(this,`map`,e,t,void 0,arguments)},pop(){return qR(this,`pop`)},push(...e){return qR(this,`push`,e)},reduce(e,...t){return GR(this,`reduce`,e,t)},reduceRight(e,...t){return GR(this,`reduceRight`,e,t)},shift(){return qR(this,`shift`)},some(e,t){return WR(this,`some`,e,t,void 0,arguments)},splice(...e){return qR(this,`splice`,e)},toReversed(){return BR(this).toReversed()},toSorted(e){return BR(this).toSorted(e)},toSpliced(...e){return BR(this).toSpliced(...e)},unshift(...e){return qR(this,`unshift`,e)},values(){return UR(this,`values`,e=>HR(this,e))}};function UR(e,t,n){let r=VR(e),i=r[t]();return r!==e&&!lz(e)&&(i._next=i.next,i.next=()=>{let e=i._next();return e.done||(e.value=n(e.value)),e}),i}var Ase=Array.prototype;function WR(e,t,n,r,i,a){let o=VR(e),s=o!==e&&!lz(e),c=o[t];if(c!==Ase[t]){let t=c.apply(e,a);return s?fz(t):t}let l=n;o!==e&&(s?l=function(t,r){return n.call(this,HR(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 GR(e,t,n,r){let i=VR(e),a=i!==e&&!lz(e),o=n,s=!1;i!==e&&(a?(s=r.length===0,o=function(t,r,i){return s&&(s=!1,t=HR(e,t)),n.call(this,t,HR(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?HR(e,c):c}function KR(e,t,n){let r=dz(e);RR(r,`iterate`,LR);let i=r[t](...n);return(i===-1||i===!1)&&uz(n[0])?(n[0]=dz(n[0]),r[t](...n)):i}function qR(e,t,n=[]){OR(),yR();let r=dz(e)[t].apply(e,n);return bR(),kR(),r}var jse=dL(`__proto__,__v_isRef,__isVue`),JR=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!==`arguments`&&e!==`caller`).map(e=>Symbol[e]).filter(OL));function Mse(e){OL(e)||(e=String(e));let t=dz(this);return RR(t,`has`,e),t.hasOwnProperty(e)}var YR=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?Hse:rz:i?nz:tz).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;let a=SL(e);if(!r){let e;if(a&&(e=kse[t]))return e;if(t===`hasOwnProperty`)return Mse}let o=Reflect.get(e,t,mz(e)?e:n);if((OL(t)?JR.has(t):jse(t))||(r||RR(e,`get`,t),i))return o;if(mz(o)){let e=a&&FL(t)?o:o.value;return r&&kL(e)?az(e):e}return kL(o)?r?az(o):iz(o):o}},XR=class extends YR{constructor(e=!1){super(!1,e)}set(e,t,n,r){let i=e[t],a=SL(e)&&FL(t);if(!this._isShallow){let e=cz(i);if(!lz(n)&&!cz(n)&&(i=dz(i),n=dz(n)),!a&&mz(i)&&!mz(n))return e||(i.value=n),!0}let o=a?Number(t)<e.length:xL(e,t),s=Reflect.set(e,t,n,mz(e)?e:r);return e===dz(r)&&s&&(o?WL(n,i)&&zR(e,`set`,t,n,i):zR(e,`add`,t,n)),s}deleteProperty(e,t){let n=xL(e,t),r=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&zR(e,`delete`,t,void 0,r),i}has(e,t){let n=Reflect.has(e,t);return(!OL(t)||!JR.has(t))&&RR(e,`has`,t),n}ownKeys(e){return RR(e,`iterate`,SL(e)?`length`:FR),Reflect.ownKeys(e)}},Nse=class extends YR{constructor(e=!1){super(!0,e)}set(e,t){return!0}deleteProperty(e,t){return!0}},Pse=new XR,Fse=new Nse,Ise=new XR(!0),ZR=e=>e,QR=e=>Reflect.getPrototypeOf(e);function Lse(e,t,n){return function(...r){let i=this.__v_raw,a=dz(i),o=CL(a),s=e===`entries`||e===Symbol.iterator&&o,c=e===`keys`&&o,l=i[e](...r),u=n?ZR:t?pz:fz;return!t&&RR(a,`iterate`,c?IR:FR),vL(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 $R(e){return function(...t){return e===`delete`?!1:e===`clear`?void 0:this}}function Rse(e,t){let n={get(n){let r=this.__v_raw,i=dz(r),a=dz(n);e||(WL(n,a)&&RR(i,`get`,n),RR(i,`get`,a));let{has:o}=QR(i),s=t?ZR:e?pz:fz;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&&RR(dz(t),`iterate`,FR),t.size},has(t){let n=this.__v_raw,r=dz(n),i=dz(t);return e||(WL(t,i)&&RR(r,`has`,t),RR(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=dz(a),s=t?ZR:e?pz:fz;return!e&&RR(o,`iterate`,FR),a.forEach((e,t)=>n.call(r,s(e),s(t),i))}};return vL(n,e?{add:$R(`add`),set:$R(`set`),delete:$R(`delete`),clear:$R(`clear`)}:{add(e){let n=dz(this),r=QR(n),i=dz(e),a=!t&&!lz(e)&&!cz(e)?i:e;return r.has.call(n,a)||WL(e,a)&&r.has.call(n,e)||WL(i,a)&&r.has.call(n,i)||(n.add(a),zR(n,`add`,a,a)),this},set(e,n){!t&&!lz(n)&&!cz(n)&&(n=dz(n));let r=dz(this),{has:i,get:a}=QR(r),o=i.call(r,e);o||=(e=dz(e),i.call(r,e));let s=a.call(r,e);return r.set(e,n),o?WL(n,s)&&zR(r,`set`,e,n,s):zR(r,`add`,e,n),this},delete(e){let t=dz(this),{has:n,get:r}=QR(t),i=n.call(t,e);i||=(e=dz(e),n.call(t,e));let a=r?r.call(t,e):void 0,o=t.delete(e);return i&&zR(t,`delete`,e,void 0,a),o},clear(){let e=dz(this),t=e.size!==0,n=e.clear();return t&&zR(e,`clear`,void 0,void 0,void 0),n}}),[`keys`,`values`,`entries`,Symbol.iterator].forEach(r=>{n[r]=Lse(r,e,t)}),n}function ez(e,t){let n=Rse(e,t);return(t,r,i)=>r===`__v_isReactive`?!e:r===`__v_isReadonly`?e:r===`__v_raw`?t:Reflect.get(xL(n,r)&&r in t?n:t,r,i)}var zse={get:ez(!1,!1)},Bse={get:ez(!1,!0)},Vse={get:ez(!0,!1)},tz=new WeakMap,nz=new WeakMap,rz=new WeakMap,Hse=new WeakMap;function Use(e){switch(e){case`Object`:case`Array`:return 1;case`Map`:case`Set`:case`WeakMap`:case`WeakSet`:return 2;default:return 0}}function iz(e){return cz(e)?e:oz(e,!1,Pse,zse,tz)}function Wse(e){return oz(e,!1,Ise,Bse,nz)}function az(e){return oz(e,!0,Fse,Vse,rz)}function oz(e,t,n,r,i){if(!kL(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=Use(NL(e));if(o===0)return e;let s=new Proxy(e,o===2?r:n);return i.set(e,s),s}function sz(e){return cz(e)?sz(e.__v_raw):!!(e&&e.__v_isReactive)}function cz(e){return!!(e&&e.__v_isReadonly)}function lz(e){return!!(e&&e.__v_isShallow)}function uz(e){return e?!!e.__v_raw:!1}function dz(e){let t=e&&e.__v_raw;return t?dz(t):e}function Gse(e){return!xL(e,`__v_skip`)&&Object.isExtensible(e)&&KL(e,`__v_skip`,!0),e}var fz=e=>kL(e)?iz(e):e,pz=e=>kL(e)?az(e):e;function mz(e){return e?e.__v_isRef===!0:!1}function hz(e){return _z(e,!1)}function gz(e){return _z(e,!0)}function _z(e,t){return mz(e)?e:new Kse(e,t)}var Kse=class{constructor(e,t){this.dep=new MR,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=t?e:dz(e),this._value=t?e:fz(e),this.__v_isShallow=t}get value(){return this.dep.track(),this._value}set value(e){let t=this._rawValue,n=this.__v_isShallow||lz(e)||cz(e);e=n?e:dz(e),WL(e,t)&&(this._rawValue=e,this._value=n?e:fz(e),this.dep.trigger())}};function vz(e){e.dep&&e.dep.trigger()}function Y(e){return mz(e)?e.value:e}var qse={get:(e,t,n)=>t===`__v_raw`?e:Y(Reflect.get(e,t,n)),set:(e,t,n,r)=>{let i=e[t];return mz(i)&&!mz(n)?(i.value=n,!0):Reflect.set(e,t,n,r)}};function yz(e){return sz(e)?e:new Proxy(e,qse)}var Jse=class{constructor(e,t,n){this.fn=e,this.setter=t,this._value=void 0,this.dep=new MR(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=jR-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!t,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&fR!==this)return vR(this,!0),!0}get value(){let e=this.dep.track();return wR(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}};function Yse(e,t,n=!1){let r,i;return EL(e)?r=e:(r=e.get,i=e.set),new Jse(r,i,n)}var bz={},xz=new WeakMap,Sz=void 0;function Xse(e,t=!1,n=Sz){if(n){let t=xz.get(n);t||xz.set(n,t=[]),t.push(e)}}function Zse(e,t,n=fL){let{immediate:r,deep:i,once:a,scheduler:o,augmentJob:s,call:c}=n,l=e=>i?e:lz(e)||i===!1||i===0?Cz(e,1):Cz(e),u,d,f,p,m=!1,h=!1;if(mz(e)?(d=()=>e.value,m=lz(e)):sz(e)?(d=()=>l(e),m=!0):SL(e)?(h=!0,m=e.some(e=>sz(e)||lz(e)),d=()=>e.map(e=>{if(mz(e))return e.value;if(sz(e))return l(e);if(EL(e))return c?c(e,2):e()})):d=EL(e)?t?c?()=>c(e,2):e:()=>{if(f){OR();try{f()}finally{kR()}}let t=Sz;Sz=u;try{return c?c(e,3,[p]):e(p)}finally{Sz=t}}:mL,t&&i){let e=d,t=i===!0?1/0:i;d=()=>Cz(e(),t)}let g=Tse(),_=()=>{u.stop(),g&&g.active&&yL(g.effects,u)};if(a&&t){let e=t;t=(...t)=>{let n=e(...t);return _(),n}}let v=h?Array(e.length).fill(bz):bz,y=e=>{if(!(!(u.flags&1)||!u.dirty&&!e))if(t){let n=u.run();if(e||i||m||(h?n.some((e,t)=>WL(e,v[t])):WL(n,v))){f&&f();let e=Sz;Sz=u;try{let e=[n,v===bz?void 0:h&&v[0]===bz?[]:v,p];v=n,c?c(t,3,e):t(...e)}finally{Sz=e}}}else u.run()};return s&&s(y),u=new mR(d),u.scheduler=o?()=>o(y,!1):y,p=e=>Xse(e,!1,u),f=u.onStop=()=>{let e=xz.get(u);if(e){if(c)c(e,4);else for(let t of e)t();xz.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 Cz(e,t=1/0,n){if(t<=0||!kL(e)||e.__v_skip||(n||=new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,mz(e))Cz(e.value,t,n);else if(SL(e))for(let r=0;r<e.length;r++)Cz(e[r],t,n);else if(wL(e)||CL(e))e.forEach(e=>{Cz(e,t,n)});else if(PL(e)){for(let r in e)Cz(e[r],t,n);for(let r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&Cz(e[r],t,n)}return e}function wz(e,t,n,r){try{return r?e(...r):e()}catch(e){Ez(e,t,n)}}function Tz(e,t,n,r){if(EL(e)){let i=wz(e,t,n,r);return i&&AL(i)&&i.catch(e=>{Ez(e,t,n)}),i}if(SL(e)){let i=[];for(let a=0;a<e.length;a++)i.push(Tz(e[a],t,n,r));return i}}function Ez(e,t,n,r=!0){let i=t?t.vnode:null,{errorHandler:a,throwUnhandledErrorInProduction:o}=t&&t.appContext.config||fL;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){OR(),wz(a,null,10,[e,i,o]),kR();return}}Qse(e,n,i,r,o)}function Qse(e,t,n,r=!0,i=!1){if(i)throw e;console.error(e)}var Dz=[],Oz=-1,kz=[],Az=null,jz=0,Mz=Promise.resolve(),Nz=null;function Pz(e){let t=Nz||Mz;return e?t.then(this?e.bind(this):e):t}function $se(e){let t=Oz+1,n=Dz.length;for(;t<n;){let r=t+n>>>1,i=Dz[r],a=zz(i);a<e||a===e&&i.flags&2?t=r+1:n=r}return t}function Fz(e){if(!(e.flags&1)){let t=zz(e),n=Dz[Dz.length-1];!n||!(e.flags&2)&&t>=zz(n)?Dz.push(e):Dz.splice($se(t),0,e),e.flags|=1,Iz()}}function Iz(){Nz||=Mz.then(Bz)}function ece(e){SL(e)?kz.push(...e):Az&&e.id===-1?Az.splice(jz+1,0,e):e.flags&1||(kz.push(e),e.flags|=1),Iz()}function Lz(e,t,n=Oz+1){for(;n<Dz.length;n++){let t=Dz[n];if(t&&t.flags&2){if(e&&t.id!==e.uid)continue;Dz.splice(n,1),n--,t.flags&4&&(t.flags&=-2),t(),t.flags&4||(t.flags&=-2)}}}function Rz(e){if(kz.length){let e=[...new Set(kz)].sort((e,t)=>zz(e)-zz(t));if(kz.length=0,Az){Az.push(...e);return}for(Az=e,jz=0;jz<Az.length;jz++){let e=Az[jz];e.flags&4&&(e.flags&=-2),e.flags&8||e(),e.flags&=-2}Az=null,jz=0}}var zz=e=>e.id==null?e.flags&2?-1:1/0:e.id;function Bz(e){try{for(Oz=0;Oz<Dz.length;Oz++){let e=Dz[Oz];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),wz(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;Oz<Dz.length;Oz++){let e=Dz[Oz];e&&(e.flags&=-2)}Oz=-1,Dz.length=0,Rz(e),Nz=null,(Dz.length||kz.length)&&Bz(e)}}var Vz=null,Hz=null;function Uz(e){let t=Vz;return Vz=e,Hz=e&&e.type.__scopeId||null,t}function Wz(e,t=Vz,n){if(!t||e._n)return e;let r=(...n)=>{r._d&&MV(-1);let i=Uz(t),a;try{a=e(...n)}finally{Uz(i),r._d&&MV(1)}return a};return r._n=!0,r._c=!0,r._d=!0,r}function Gz(e,t){if(Vz===null)return e;let n=iH(Vz),r=e.dirs||=[];for(let e=0;e<t.length;e++){let[i,a,o,s=fL]=t[e];i&&(EL(i)&&(i={mounted:i,updated:i}),i.deep&&Cz(a),r.push({dir:i,instance:n,value:a,oldValue:void 0,arg:o,modifiers:s}))}return e}function Kz(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&&(OR(),Tz(c,n,8,[e.el,s,e,t]),kR())}}function qz(e,t){if(KV){let n=KV.provides,r=KV.parent&&KV.parent.provides;r===n&&(n=KV.provides=Object.create(r)),n[e]=t}}function Jz(e,t,n=!1){let r=qV();if(r||$B){let i=$B?$B._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&&EL(t)?t.call(r&&r.proxy):t}}var tce=Symbol.for(`v-scx`),nce=()=>Jz(tce);function Yz(e,t,n){return Xz(e,t,n)}function Xz(e,t,n=fL){let{immediate:r,deep:i,flush:a,once:o}=n,s=vL({},n),c=t&&r||!t&&a!==`post`,l;if($V){if(a===`sync`){let e=nce();l=e.__watcherHandles||=[]}else if(!c){let e=()=>{};return e.stop=mL,e.resume=mL,e.pause=mL,e}}let u=KV;s.call=(e,t,n)=>Tz(e,u,t,n);let d=!1;a===`post`?s.scheduler=e=>{_V(e,u&&u.suspense)}:a!==`sync`&&(d=!0,s.scheduler=(e,t)=>{t?e():Fz(e)}),s.augmentJob=e=>{t&&(e.flags|=4),d&&(e.flags|=2,u&&(e.id=u.uid,e.i=u))};let f=Zse(e,t,s);return $V&&(l?l.push(f):c&&f()),f}function rce(e,t,n){let r=this.proxy,i=DL(e)?e.includes(`.`)?Zz(r,e):()=>r[e]:e.bind(r,r),a;EL(t)?a=t:(a=t.handler,n=t);let o=XV(this),s=Xz(i,a.bind(r),n);return o(),s}function Zz(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 Qz=new WeakMap,$z=Symbol(`_vte`),eB=e=>e.__isTeleport,tB=e=>e&&(e.disabled||e.disabled===``),ice=e=>e&&(e.defer||e.defer===``),nB=e=>typeof SVGElement<`u`&&e instanceof SVGElement,rB=e=>typeof MathMLElement==`function`&&e instanceof MathMLElement,iB=(e,t)=>{let n=e&&e.to;return DL(n)?t?t(n):null:n},ace={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=tB(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=tB(e.props),r=e.target=iB(e.props,m),a=cB(r,e,h,p);r&&(o!==`svg`&&nB(r)?o=`svg`:o!==`mathml`&&rB(r)&&(o=`mathml`),i&&i.isCE&&(i.ce._teleportTargets||(i.ce._teleportTargets=new Set)).add(r),n||(b(e,r,a),sB(e,!1)))},S=e=>{let t=()=>{if(Qz.get(e)===t){if(Qz.delete(e),tB(e.props)){let t=_(e.el)||n;b(e,t,e.anchor),sB(e,!0)}x(e)}};Qz.set(e,t),_V(t,a)};if(e==null){let e=t.el=h(``),i=t.anchor=h(``);if(p(e,n,r),p(i,n,r),ice(t.props)||a&&a.pendingBranch){S(t);return}v&&(b(t,n,i),sB(t,!0)),x()}else{t.el=e.el;let r=t.anchor=e.anchor,u=Qz.get(e);if(u){u.flags|=8,Qz.delete(e),S(t);return}t.targetStart=e.targetStart;let p=t.target=e.target,h=t.targetAnchor=e.targetAnchor,g=tB(e.props),_=g?n:p,b=g?r:h;if(o===`svg`||nB(p)?o=`svg`:(o===`mathml`||rB(p))&&(o=`mathml`),y?(f(e.dynamicChildren,y,_,i,a,o,s),bV(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):aB(t,n,r,l,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){let e=iB(t.props,m);e&&(t.target=e,aB(t,e,null,l,0))}else g&&aB(t,p,h,l,1);sB(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=tB(f),m=a||!p,h=Qz.get(e);if(h&&(h.flags|=8,Qz.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:aB,hydrate:oce};function aB(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),!Qz.has(e)&&(!d||tB(u))&&c&16)for(let e=0;e<l.length;e++)i(l[e],t,n,2);d&&r(s,t,n)}function oce(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=iB(t.props,c),h=tB(t.props);if(m){let c=m._lpa||m.firstChild;t.shapeFlag&16&&(h?(p(e,t),f(m,c),t.targetAnchor||cB(m,t,u,l,s(e)===m?e:null)):(t.anchor=o(e),f(m,c),t.targetAnchor||cB(m,t,u,l),d(c&&o(c),t,m,n,r,i,a))),sB(t,h)}else h&&t.shapeFlag&16&&(p(e,t),t.targetStart=e,t.targetAnchor=o(e));return t.anchor&&o(t.anchor)}var oB=ace;function sB(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 cB(e,t,n,r,i=null){let a=t.targetStart=n(``),o=t.targetAnchor=n(``);return a[$z]=o,e&&(r(a,e,i),r(o,e,i)),o}var lB=Symbol(`_leaveCb`),uB=Symbol(`_enterCb`);function sce(){let e={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return MB(()=>{e.isMounted=!0}),NB(()=>{e.isUnmounting=!0}),e}var dB=[Function,Array],fB={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:dB,onEnter:dB,onAfterEnter:dB,onEnterCancelled:dB,onBeforeLeave:dB,onLeave:dB,onAfterLeave:dB,onLeaveCancelled:dB,onBeforeAppear:dB,onAppear:dB,onAfterAppear:dB,onAppearCancelled:dB},pB=e=>{let t=e.subTree;return t.component?pB(t.component):t},cce={name:`BaseTransition`,props:fB,setup(e,{slots:t}){let n=qV(),r=sce();return()=>{let i=t.default&&bB(t.default(),!0),a=i&&i.length?mB(i):n.subTree?$():void 0;if(!a)return;let o=dz(e),{mode:s}=o;if(r.isLeaving)return _B(a);let c=vB(a);if(!c)return _B(a);let l=gB(c,o,r,n,e=>l=e);c.type!==DV&&yB(c,l);let u=n.subTree&&vB(n.subTree);if(u&&u.type!==DV&&!IV(u,c)&&pB(n).type!==DV){let e=gB(u,o,r,n);if(yB(u,e),s===`out-in`&&c.type!==DV)return r.isLeaving=!0,e.afterLeave=()=>{r.isLeaving=!1,n.job.flags&8||n.update(),delete e.afterLeave,u=void 0},_B(a);s===`in-out`&&c.type!==DV?e.delayLeave=(e,t,n)=>{let i=hB(r,u);i[String(u.key)]=u,e[lB]=()=>{t(),e[lB]=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 mB(e){let t=e[0];if(e.length>1){for(let n of e)if(n.type!==DV){t=n;break}}return t}var lce=cce;function hB(e,t){let{leavingVNodes:n}=e,r=n.get(t.type);return r||(r=Object.create(null),n.set(t.type,r)),r}function gB(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=hB(n,e),S=(e,t)=>{e&&Tz(e,r,9,t)},C=(e,t)=>{let n=t[1];S(e,t),SL(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[lB]&&t[lB](!0);let i=x[b];i&&IV(e,i)&&i.el[lB]&&i.el[lB](),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[uB]=e=>{s||(s=!0,S(e?o:i,[t]),w.delayedLeave&&w.delayedLeave(),t[uB]=void 0)};let c=t[uB].bind(null,!1);r?C(r,[t,c]):c()},leave(t,r){let i=String(e.key);if(t[uB]&&t[uB](!0),n.isUnmounting)return r();S(f,[t]);let a=!1;t[lB]=n=>{a||(a=!0,r(),S(n?h:m,[t]),t[lB]=void 0,x[i]===e&&delete x[i])};let o=t[lB].bind(null,!1);x[i]=e,p?C(p,[t,o]):o()},clone(e){let a=gB(e,t,n,r,i);return i&&i(a),a}};return w}function _B(e){if(OB(e))return e=BV(e),e.children=null,e}function vB(e){if(!OB(e))return eB(e.type)&&e.children?mB(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&&EL(n.default))return n.default()}}function yB(e,t){e.shapeFlag&6&&e.component?(e.transition=t,yB(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 bB(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===TV?(o.patchFlag&128&&i++,r=r.concat(bB(o.children,t,s))):(t||o.type!==DV)&&r.push(s==null?o:BV(o,{key:s}))}if(i>1)for(let e=0;e<r.length;e++)r[e].patchFlag=-2;return r}function xB(e,t){return EL(e)?vL({name:e.name},t,{setup:e}):e}function SB(e){e.ids=[e.ids[0]+e.ids[2]+++`-`,0,0]}function CB(e,t){let n;return!!((n=Object.getOwnPropertyDescriptor(e,t))&&!n.configurable)}var wB=new WeakMap;function TB(e,t,n,r,i=!1){if(SL(e)){e.forEach((e,a)=>TB(e,t&&(SL(t)?t[a]:t),n,r,i));return}if(DB(r)&&!i){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&TB(e,t,n,r.component.subTree);return}let a=r.shapeFlag&4?iH(r.component):r.el,o=i?null:a,{i:s,r:c}=e,l=t&&t.r,u=s.refs===fL?s.refs={}:s.refs,d=s.setupState,f=dz(d),p=d===fL?hL:e=>!CB(u,e)&&xL(f,e),m=(e,t)=>!(t&&CB(u,t));if(l!=null&&l!==c){if(EB(t),DL(l))u[l]=null,p(l)&&(d[l]=null);else if(mz(l)){let e=t;m(l,e.k)&&(l.value=null),e.k&&(u[e.k]=null)}}if(EL(c)){OR();try{wz(c,s,12,[o,u])}finally{kR()}}else{let t=DL(c),r=mz(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)SL(n)&&yL(n,a);else if(SL(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(),wB.delete(e)};t.id=-1,wB.set(e,t),_V(t,n)}else EB(e),s()}}}function EB(e){let t=wB.get(e);t&&(t.flags|=8,wB.delete(e))}XL().requestIdleCallback,XL().cancelIdleCallback;var DB=e=>!!e.type.__asyncLoader,OB=e=>e.type.__isKeepAlive;function uce(e,t){kB(e,`a`,t)}function dce(e,t){kB(e,`da`,t)}function kB(e,t,n=KV){let r=e.__wdc||=()=>{let t=n;for(;t;){if(t.isDeactivated)return;t=t.parent}return e()};if(AB(t,r,n),n){let e=n.parent;for(;e&&e.parent;)OB(e.parent.vnode)&&fce(r,t,n,e),e=e.parent}}function fce(e,t,n,r){let i=AB(t,e,r,!0);PB(()=>{yL(r[t],i)},n)}function AB(e,t,n=KV,r=!1){if(n){let i=n[e]||(n[e]=[]),a=t.__weh||=(...r)=>{OR();let i=XV(n),a=Tz(t,n,e,r);return i(),kR(),a};return r?i.unshift(a):i.push(a),a}}var jB=e=>(t,n=KV)=>{(!$V||e===`sp`)&&AB(e,(...e)=>t(...e),n)},pce=jB(`bm`),MB=jB(`m`),mce=jB(`bu`),hce=jB(`u`),NB=jB(`bum`),PB=jB(`um`),gce=jB(`sp`),_ce=jB(`rtg`),vce=jB(`rtc`);function yce(e,t=KV){AB(`ec`,e,t)}var bce=Symbol.for(`v-ndc`);function FB(e,t,n,r){let i,a=n&&n[r],o=SL(e);if(o||DL(e)){let n=o&&sz(e),r=!1,s=!1;n&&(r=!lz(e),s=cz(e),e=VR(e)),i=Array(e.length);for(let n=0,o=e.length;n<o;n++)i[n]=t(r?s?pz(fz(e[n])):fz(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(kL(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 IB(e,t,n={},r,i){if(Vz.ce||Vz.parent&&DB(Vz.parent)&&Vz.parent.ce){let e=Object.keys(n).length>0;return t!=="default"&&(n.name=t),X(),PV(TV,null,[zV(`slot`,n,r&&r())],e?-2:64)}let a=e[t];a&&a._c&&(a._d=!1),X();let o=a&&LB(a(n)),s=n.key||o&&o.key,c=PV(TV,{key:(s&&!OL(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 LB(e){return e.some(e=>!FV(e)||!(e.type===DV||e.type===TV&&!LB(e.children)))?e:null}var RB=e=>e?QV(e)?iH(e):RB(e.parent):null,zB=vL(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=>RB(e.parent),$root:e=>RB(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>GB(e),$forceUpdate:e=>e.f||=()=>{Fz(e.update)},$nextTick:e=>e.n||=Pz.bind(e.proxy),$watch:e=>rce.bind(e)}),BB=(e,t)=>e!==fL&&!e.__isScriptSetup&&xL(e,t),xce={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(BB(r,t))return o[t]=1,r[t];else if(i!==fL&&xL(i,t))return o[t]=2,i[t];else if(xL(a,t))return o[t]=3,a[t];else if(n!==fL&&xL(n,t))return o[t]=4,n[t];else HB&&(o[t]=0)}let l=zB[t],u,d;if(l)return t===`$attrs`&&RR(e.attrs,`get`,``),l(e);if((u=s.__cssModules)&&(u=u[t]))return u;if(n!==fL&&xL(n,t))return o[t]=4,n[t];if(d=c.config.globalProperties,xL(d,t))return d[t]},set({_:e},t,n){let{data:r,setupState:i,ctx:a}=e;return BB(i,t)?(i[t]=n,!0):r!==fL&&xL(r,t)?(r[t]=n,!0):xL(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!==fL&&s[0]!==`$`&&xL(e,s)||BB(t,s)||xL(a,s)||xL(r,s)||xL(zB,s)||xL(i.config.globalProperties,s)||(c=o.__cssModules)&&c[s])},defineProperty(e,t,n){return n.get==null?xL(n,`value`)&&this.set(e,t,n.value,null):e._.accessCache[t]=0,Reflect.defineProperty(e,t,n)}};function VB(e){return SL(e)?e.reduce((e,t)=>(e[t]=null,e),{}):e}var HB=!0;function Sce(e){let t=GB(e),n=e.proxy,r=e.ctx;HB=!1,t.beforeCreate&&UB(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:E,inheritAttrs:D,components:ee,directives:O,filters:k}=t;if(l&&Cce(l,r,null),o)for(let e in o){let t=o[e];EL(t)&&(r[e]=t.bind(n))}if(i){let t=i.call(n,n);kL(t)&&(e.data=iz(t))}if(HB=!0,a)for(let e in a){let t=a[e],i=aH({get:EL(t)?t.bind(n,n):EL(t.get)?t.get.bind(n,n):mL,set:!EL(t)&&EL(t.set)?t.set.bind(n):mL});Object.defineProperty(r,e,{enumerable:!0,configurable:!0,get:()=>i.value,set:e=>i.value=e})}if(s)for(let e in s)WB(s[e],r,n,e);if(c){let e=EL(c)?c.call(n):c;Reflect.ownKeys(e).forEach(t=>{qz(t,e[t])})}u&&UB(u,e,`c`);function te(e,t){SL(t)?t.forEach(t=>e(t.bind(n))):t&&e(t.bind(n))}if(te(pce,d),te(MB,f),te(mce,p),te(hce,m),te(uce,h),te(dce,g),te(yce,w),te(vce,S),te(_ce,C),te(NB,v),te(PB,b),te(gce,T),SL(E))if(E.length){let t=e.exposed||={};E.forEach(e=>{Object.defineProperty(t,e,{get:()=>n[e],set:t=>n[e]=t,enumerable:!0})})}else e.exposed||={};x&&e.render===mL&&(e.render=x),D!=null&&(e.inheritAttrs=D),ee&&(e.components=ee),O&&(e.directives=O),T&&SB(e)}function Cce(e,t,n=mL){SL(e)&&(e=JB(e));for(let n in e){let r=e[n],i;i=kL(r)?`default`in r?Jz(r.from||n,r.default,!0):Jz(r.from||n):Jz(r),mz(i)?Object.defineProperty(t,n,{enumerable:!0,configurable:!0,get:()=>i.value,set:e=>i.value=e}):t[n]=i}}function UB(e,t,n){Tz(SL(e)?e.map(e=>e.bind(t.proxy)):e.bind(t.proxy),t,n)}function WB(e,t,n,r){let i=r.includes(`.`)?Zz(n,r):()=>n[r];if(DL(e)){let n=t[e];EL(n)&&Yz(i,n)}else if(EL(e))Yz(i,e.bind(n));else if(kL(e))if(SL(e))e.forEach(e=>WB(e,t,n,r));else{let r=EL(e.handler)?e.handler.bind(n):t[e.handler];EL(r)&&Yz(i,r,e)}}function GB(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=>KB(c,e,o,!0)),KB(c,t,o)),kL(t)&&a.set(t,c),c}function KB(e,t,n,r=!1){let{mixins:i,extends:a}=t;a&&KB(e,a,n,!0),i&&i.forEach(t=>KB(e,t,n,!0));for(let i in t)if(!(r&&i===`expose`)){let r=wce[i]||n&&n[i];e[i]=r?r(e[i],t[i]):t[i]}return e}var wce={data:qB,props:ZB,emits:ZB,methods:XB,computed:XB,beforeCreate:YB,created:YB,beforeMount:YB,mounted:YB,beforeUpdate:YB,updated:YB,beforeDestroy:YB,beforeUnmount:YB,destroyed:YB,unmounted:YB,activated:YB,deactivated:YB,errorCaptured:YB,serverPrefetch:YB,components:XB,directives:XB,watch:Ece,provide:qB,inject:Tce};function qB(e,t){return t?e?function(){return vL(EL(e)?e.call(this,this):e,EL(t)?t.call(this,this):t)}:t:e}function Tce(e,t){return XB(JB(e),JB(t))}function JB(e){if(SL(e)){let t={};for(let n=0;n<e.length;n++)t[e[n]]=e[n];return t}return e}function YB(e,t){return e?[...new Set([].concat(e,t))]:t}function XB(e,t){return e?vL(Object.create(null),e,t):t}function ZB(e,t){return e?SL(e)&&SL(t)?[...new Set([...e,...t])]:vL(Object.create(null),VB(e),VB(t??{})):t}function Ece(e,t){if(!e)return t;if(!t)return e;let n=vL(Object.create(null),e);for(let r in t)n[r]=YB(e[r],t[r]);return n}function QB(){return{app:null,config:{isNativeTag:hL,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 Dce=0;function Oce(e,t){return function(n,r=null){EL(n)||(n=vL({},n)),r!=null&&!kL(r)&&(r=null);let i=QB(),a=new WeakSet,o=[],s=!1,c=i.app={_uid:Dce++,_component:n,_props:r,_container:null,_context:i,_instance:null,version:ale,get config(){return i.config},set config(e){},use(e,...t){return a.has(e)||(e&&EL(e.install)?(a.add(e),e.install(c,...t)):EL(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||zV(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,iH(u.component)}},onUnmount(e){o.push(e)},unmount(){s&&(Tz(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=$B;$B=c;try{return e()}finally{$B=t}}};return c}}var $B=null,kce=(e,t)=>t===`modelValue`||t===`model-value`?e.modelModifiers:e[`${t}Modifiers`]||e[`${zL(t)}Modifiers`]||e[`${VL(t)}Modifiers`];function Ace(e,t,...n){if(e.isUnmounted)return;let r=e.vnode.props||fL,i=n,a=t.startsWith(`update:`),o=a&&kce(r,t.slice(7));o&&(o.trim&&(i=n.map(e=>DL(e)?e.trim():e)),o.number&&(i=n.map(qL)));let s,c=r[s=UL(t)]||r[s=UL(zL(t))];!c&&a&&(c=r[s=UL(VL(t))]),c&&Tz(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,Tz(l,e,6,i)}}var jce=new WeakMap;function eV(e,t,n=!1){let r=n?jce:t.emitsCache,i=r.get(e);if(i!==void 0)return i;let a=e.emits,o={},s=!1;if(!EL(e)){let r=e=>{let n=eV(e,t,!0);n&&(s=!0,vL(o,n))};!n&&t.mixins.length&&t.mixins.forEach(r),e.extends&&r(e.extends),e.mixins&&e.mixins.forEach(r)}return!a&&!s?(kL(e)&&r.set(e,null),null):(SL(a)?a.forEach(e=>o[e]=null):vL(o,a),kL(e)&&r.set(e,o),o)}function tV(e,t){return!e||!gL(t)?!1:(t=t.slice(2),t=t===`Once`?t:t.replace(/Once$/,``),xL(e,t[0].toLowerCase()+t.slice(1))||xL(e,VL(t))||xL(e,t))}function nV(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=Uz(e),_,v;try{if(n.shapeFlag&4){let e=i||r,t=e;_=HV(l.call(t,e,u,d,p,f,m)),v=s}else{let e=t;_=HV(e.length>1?e(d,{attrs:s,slots:o,emit:c}):e(d,null)),v=t.props?s:Mce(s)}}catch(t){kV.length=0,Ez(t,e,1),_=zV(DV)}let y=_;if(v&&h!==!1){let e=Object.keys(v),{shapeFlag:t}=y;e.length&&t&7&&(a&&e.some(_L)&&(v=Nce(v,a)),y=BV(y,v,!1,!0))}return n.dirs&&(y=BV(y,null,!1,!0),y.dirs=y.dirs?y.dirs.concat(n.dirs):n.dirs),n.transition&&yB(y,n.transition),_=y,Uz(g),_}var Mce=e=>{let t;for(let n in e)(n===`class`||n===`style`||gL(n))&&((t||={})[n]=e[n]);return t},Nce=(e,t)=>{let n={};for(let r in e)(!_L(r)||!(r.slice(9)in t))&&(n[r]=e[r]);return n};function Pce(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?rV(r,o,l):!!o;if(c&8){let e=t.dynamicProps;for(let t=0;t<e.length;t++){let n=e[t];if(iV(o,r,n)&&!tV(l,n))return!0}}}else return(i||s)&&(!s||!s.$stable)?!0:r===o?!1:r?!o||rV(r,o,l):!!o;return!1}function rV(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(iV(t,e,a)&&!tV(n,a))return!0}return!1}function iV(e,t,n){let r=e[n],i=t[n];return n===`style`&&kL(r)&&kL(i)?!sR(r,i):r!==i}function Fce({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 aV={},oV=()=>Object.create(aV),sV=e=>Object.getPrototypeOf(e)===aV;function Ice(e,t,n,r=!1){let i={},a=oV();e.propsDefaults=Object.create(null),cV(e,t,i,a);for(let t in e.propsOptions[0])t in i||(i[t]=void 0);n?e.props=r?i:Wse(i):e.type.props?e.props=i:e.props=a,e.attrs=a}function Lce(e,t,n,r){let{props:i,attrs:a,vnode:{patchFlag:o}}=e,s=dz(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(tV(e.emitsOptions,o))continue;let u=t[o];if(c)if(xL(a,o))u!==a[o]&&(a[o]=u,l=!0);else{let t=zL(o);i[t]=lV(c,s,t,u,e,!1)}else u!==a[o]&&(a[o]=u,l=!0)}}}else{cV(e,t,i,a)&&(l=!0);let r;for(let a in s)(!t||!xL(t,a)&&((r=VL(a))===a||!xL(t,r)))&&(c?n&&(n[a]!==void 0||n[r]!==void 0)&&(i[a]=lV(c,s,a,void 0,e,!0)):delete i[a]);if(a!==s)for(let e in a)(!t||!xL(t,e))&&(delete a[e],l=!0)}l&&zR(e.attrs,`set`,``)}function cV(e,t,n,r){let[i,a]=e.propsOptions,o=!1,s;if(t)for(let c in t){if(IL(c))continue;let l=t[c],u;i&&xL(i,u=zL(c))?!a||!a.includes(u)?n[u]=l:(s||={})[u]=l:tV(e.emitsOptions,c)||(!(c in r)||l!==r[c])&&(r[c]=l,o=!0)}if(a){let t=dz(n),r=s||fL;for(let o=0;o<a.length;o++){let s=a[o];n[s]=lV(i,t,s,r[s],e,!xL(r,s))}}return o}function lV(e,t,n,r,i,a){let o=e[n];if(o!=null){let e=xL(o,`default`);if(e&&r===void 0){let e=o.default;if(o.type!==Function&&!o.skipFactory&&EL(e)){let{propsDefaults:a}=i;if(n in a)r=a[n];else{let o=XV(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===VL(n))&&(r=!0))}return r}var Rce=new WeakMap;function uV(e,t,n=!1){let r=n?Rce:t.propsCache,i=r.get(e);if(i)return i;let a=e.props,o={},s=[],c=!1;if(!EL(e)){let r=e=>{c=!0;let[n,r]=uV(e,t,!0);vL(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 kL(e)&&r.set(e,pL),pL;if(SL(a))for(let e=0;e<a.length;e++){let t=zL(a[e]);dV(t)&&(o[t]=fL)}else if(a)for(let e in a){let t=zL(e);if(dV(t)){let n=a[e],r=o[t]=SL(n)||EL(n)?{type:n}:vL({},n),i=r.type,c=!1,l=!0;if(SL(i))for(let e=0;e<i.length;++e){let t=i[e],n=EL(t)&&t.name;if(n===`Boolean`){c=!0;break}else n===`String`&&(l=!1)}else c=EL(i)&&i.name===`Boolean`;r[0]=c,r[1]=l,(c||xL(r,`default`))&&s.push(t)}}let l=[o,s];return kL(e)&&r.set(e,l),l}function dV(e){return e[0]!==`$`&&!IL(e)}var fV=e=>e===`_`||e===`_ctx`||e===`$stable`,pV=e=>SL(e)?e.map(HV):[HV(e)],zce=(e,t,n)=>{if(t._n)return t;let r=Wz((...e)=>pV(t(...e)),n);return r._c=!1,r},mV=(e,t,n)=>{let r=e._ctx;for(let n in e){if(fV(n))continue;let i=e[n];if(EL(i))t[n]=zce(n,i,r);else if(i!=null){let e=pV(i);t[n]=()=>e}}},hV=(e,t)=>{let n=pV(t);e.slots.default=()=>n},gV=(e,t,n)=>{for(let r in t)(n||!fV(r))&&(e[r]=t[r])},Bce=(e,t,n)=>{let r=e.slots=oV();if(e.vnode.shapeFlag&32){let e=t._;e?(gV(r,t,n),n&&KL(r,`_`,e,!0)):mV(t,r)}else t&&hV(e,t)},Vce=(e,t,n)=>{let{vnode:r,slots:i}=e,a=!0,o=fL;if(r.shapeFlag&32){let e=t._;e?n&&e===1?a=!1:gV(i,t,n):(a=!t.$stable,mV(t,i)),o=t}else t&&(hV(e,t),o={default:1});if(a)for(let e in i)!fV(e)&&o[e]==null&&delete i[e]},_V=Kce;function Hce(e){return Uce(e)}function Uce(e,t){let n=XL();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=mL,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&&!IV(e,t)&&(r=ue(e),ae(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 EV:g(e,t,n,r);break;case DV:_(e,t,n,r);break;case OV:e??v(t,n,r,o);break;case TV:ee(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?O(e,t,n,r,i,a,o,s,c):(d&64||d&128)&&l.process(e,t,n,r,i,a,o,s,c,N)}u!=null&&i?TB(u,e&&e.ref,a,t||e,!t):u==null&&e&&e.ref!=null&&TB(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,vV(e,c),l,d),_&&Kz(e,null,i,`created`),C(f,e,e.scopeId,l,i),m){for(let e in m)e!==`value`&&!IL(e)&&a(f,e,null,m[e],c,i);`value`in m&&a(f,`value`,null,m.value,c),(p=m.onVnodeBeforeMount)&&GV(p,i,e)}_&&Kz(e,null,i,`beforeMount`);let v=Wce(s,g);v&&g.beforeEnter(f),r(f,t,n),((p=m&&m.onVnodeMounted)||v||_)&&_V(()=>{try{p&&GV(p,i,e),v&&g.enter(f),_&&Kz(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||wV(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?UV(e[l]):HV(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||fL,m=t.props||fL,h;if(n&&yV(n,!1),(h=m.onVnodeBeforeUpdate)&&GV(h,n,t,e),f&&Kz(t,e,n,`beforeUpdate`),n&&yV(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?E(e.dynamicChildren,d,c,n,r,vV(t,i),o):s||j(e,t,c,null,n,r,vV(t,i),o,!1),l>0){if(l&16)D(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&&D(c,p,m,n,i);((h=m.onVnodeUpdated)||f)&&_V(()=>{h&&GV(h,n,t,e),f&&Kz(t,e,n,`updated`)},r)},E=(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===TV||!IV(c,l)||c.shapeFlag&198)?d(c.el):n;h(c,l,u,null,r,i,a,o,!0)}},D=(e,t,n,r,i)=>{if(t!==n){if(t!==fL)for(let o in t)!IL(o)&&!(o in n)&&a(e,o,t[o],null,i,r);for(let o in n){if(IL(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)}},ee=(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?(E(e.dynamicChildren,m,n,a,o,c,l),(t.key!=null||a&&t===a.subTree)&&bV(e,t,!0)):j(e,t,n,f,a,o,c,l,u)},O=(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):k(t,n,r,i,a,o,c):te(e,t,c)},k=(e,t,n,r,i,a,o)=>{let s=e.component=$ce(e,r,i);if(OB(e)&&(s.ctx.renderer=N),ele(s,!1,o),s.asyncDep){if(i&&i.registerDep(s,A,o),!e.el){let r=s.subTree=zV(DV);_(null,r,t,n),e.placeholder=r.el}}else A(s,e,t,n,i,a,o)},te=(e,t,n)=>{let r=t.component=e.component;if(Pce(e,t,n))if(r.asyncDep&&!r.asyncResolved){ne(r,t,n);return}else r.next=t,r.update();else t.el=e.el,r.vnode=t},A=(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=xV(e);if(n){t&&(t.el=c.el,ne(e,t,o)),n.asyncDep.then(()=>{_V(()=>{e.isUnmounted||l()},i)});return}}let u=t,f;yV(e,!1),t?(t.el=c.el,ne(e,t,o)):t=c,n&&GL(n),(f=t.props&&t.props.onVnodeBeforeUpdate)&&GV(f,s,t,c),yV(e,!0);let p=nV(e),m=e.subTree;e.subTree=p,h(m,p,d(m.el),ue(m),e,i,a),t.el=p.el,u===null&&Fce(e,p.el),r&&_V(r,i),(f=t.props&&t.props.onVnodeUpdated)&&_V(()=>GV(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=DB(t);if(yV(e,!1),l&&GL(l),!m&&(o=c&&c.onVnodeBeforeMount)&&GV(o,d,t),yV(e,!0),s&&me){let t=()=>{e.subTree=nV(e),me(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=nV(e);h(null,o,n,r,e,i,a),t.el=o.el}if(u&&_V(u,i),!m&&(o=c&&c.onVnodeMounted)){let e=t;_V(()=>GV(o,d,e),i)}(t.shapeFlag&256||d&&DB(d.vnode)&&d.vnode.shapeFlag&256)&&e.a&&_V(e.a,i),e.isMounted=!0,t=n=r=null}};e.scope.on();let c=e.effect=new mR(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=()=>Fz(u),yV(e,!0),l()},ne=(e,t,n)=>{t.component=e;let r=e.vnode.props;e.vnode=t,e.next=null,Lce(e,t.props,r,n),Vce(e,t.children,n),OR(),Lz(e),kR()},j=(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){M(l,f,n,r,i,a,o,s,c);return}else if(p&256){re(l,f,n,r,i,a,o,s,c);return}}m&8?(d&16&&le(l,i,a),f!==l&&u(n,f)):d&16?m&16?M(l,f,n,r,i,a,o,s,c):le(l,i,a,!0):(d&8&&u(n,``),m&16&&w(f,n,r,i,a,o,s,c))},re=(e,t,n,r,i,a,o,s,c)=>{e||=pL,t||=pL;let l=e.length,u=t.length,d=Math.min(l,u),f;for(f=0;f<d;f++){let r=t[f]=c?UV(t[f]):HV(t[f]);h(e[f],r,n,null,i,a,o,s,c)}l>u?le(e,i,a,!0,!1,d):w(t,n,r,i,a,o,s,c,d)},M=(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?UV(t[l]):HV(t[l]);if(IV(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?UV(t[f]):HV(t[f]);if(IV(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?UV(t[l]):HV(t[l]),n,d,i,a,o,s,c),l++}}else if(l>f)for(;l<=d;)ae(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?UV(t[l]):HV(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){ae(r,i,a,!0);continue}let u;if(r.key!=null)u=g.get(r.key);else for(_=m;_<=f;_++)if(S[_-m]===0&&IV(r,t[_])){u=_;break}u===void 0?ae(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?Gce(S):pL;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||CV(f):r;S[l]===0?h(null,d,n,p,i,a,o,s,c):b&&(_<0||l!==C[_]?ie(d,n,p,2):_--)}}},ie=(e,t,n,a,o=null)=>{let{el:s,type:c,transition:l,children:u,shapeFlag:d}=e;if(d&6){ie(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,N);return}if(c===TV){r(s,t,n);for(let e=0;e<u.length;e++)ie(u[e],t,n,a);r(e.anchor,t,n);return}if(c===OV){y(e,t,n);return}if(a!==2&&d&1&&l)if(a===0)l.persisted&&!s[lB]?r(s,t,n):(l.beforeEnter(s),r(s,t,n),_V(()=>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[lB];s._isLeaving&&s[lB](!0),l.persisted&&!e?u():a(s,()=>{u(),c&&c()})};o?o(s,u,d):d()}else r(s,t,n)},ae=(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&&(OR(),TB(s,null,n,e,!0),kR()),p!=null&&(t.renderCache[p]=void 0),u&256){t.ctx.deactivate(e);return}let h=u&1&&f,g=!DB(e),_;if(g&&(_=o&&o.onVnodeBeforeUnmount)&&GV(_,t,e),u&6)ce(e.component,n,r);else{if(u&128){e.suspense.unmount(n,r);return}h&&Kz(e,null,t,`beforeUnmount`),u&64?e.type.remove(e,t,n,N,r):l&&!l.hasOnce&&(a!==TV||d>0&&d&64)?le(l,t,n,!1,!0):(a===TV&&d&384||!i&&u&16)&&le(c,t,n),r&&oe(e)}let v=m!=null&&p==null;(g&&(_=o&&o.onVnodeUnmounted)||h||v)&&_V(()=>{_&&GV(_,t,e),h&&Kz(e,null,t,`unmounted`),v&&(e.el=null)},n)},oe=e=>{let{type:t,el:n,anchor:r,transition:a}=e;if(t===TV){se(n,r);return}if(t===OV){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()},se=(e,t)=>{let n;for(;e!==t;)n=f(e),i(e),e=n;i(t)},ce=(e,t,n)=>{let{bum:r,scope:i,job:a,subTree:o,um:s,m:c,a:l}=e;SV(c),SV(l),r&&GL(r),i.stop(),a&&(a.flags|=8,ae(o,e,t,n)),s&&_V(s,t),_V(()=>{e.isUnmounted=!0},t)},le=(e,t,n,r=!1,i=!1,a=0)=>{for(let o=a;o<e.length;o++)ae(e[o],t,n,r,i)},ue=e=>{if(e.shapeFlag&6)return ue(e.component.subTree);if(e.shapeFlag&128)return e.suspense.next();let t=f(e.anchor||e.el),n=t&&t[$z];return n?f(n):t},de=!1,fe=(e,t,n)=>{let r;e==null?t._vnode&&(ae(t._vnode,null,null,!0),r=t._vnode.component):h(t._vnode||null,e,t,null,null,null,n),t._vnode=e,de||=(de=!0,Lz(r),Rz(),!1)},N={p:h,um:ae,m:ie,r:oe,mt:k,mc:w,pc:j,pbc:E,n:ue,o:e},pe,me;return t&&([pe,me]=t(N)),{render:fe,hydrate:pe,createApp:Oce(fe,pe)}}function vV({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 yV({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function Wce(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function bV(e,t,n=!1){let r=e.children,i=t.children;if(SL(r)&&SL(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]=UV(i[e]),a.el=t.el),!n&&a.patchFlag!==-2&&bV(t,a)),a.type===EV&&(a.patchFlag===-1&&(a=i[e]=UV(a)),a.el=t.el),a.type===DV&&!a.el&&(a.el=t.el)}}function Gce(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 xV(e){let t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:xV(t)}function SV(e){if(e)for(let t=0;t<e.length;t++)e[t].flags|=8}function CV(e){if(e.placeholder)return e.placeholder;let t=e.component;return t?CV(t.subTree):null}var wV=e=>e.__isSuspense;function Kce(e,t){t&&t.pendingBranch?SL(e)?t.effects.push(...e):t.effects.push(e):ece(e)}var TV=Symbol.for(`v-fgt`),EV=Symbol.for(`v-txt`),DV=Symbol.for(`v-cmt`),OV=Symbol.for(`v-stc`),kV=[],AV=null;function X(e=!1){kV.push(AV=e?null:[])}function qce(){kV.pop(),AV=kV[kV.length-1]||null}var jV=1;function MV(e,t=!1){jV+=e,e<0&&AV&&t&&(AV.hasOnce=!0)}function NV(e){return e.dynamicChildren=jV>0?AV||pL:null,qce(),jV>0&&AV&&AV.push(e),e}function Z(e,t,n,r,i,a){return NV(Q(e,t,n,r,i,a,!0))}function PV(e,t,n,r,i){return NV(zV(e,t,n,r,i,!0))}function FV(e){return e?e.__v_isVNode===!0:!1}function IV(e,t){return e.type===t.type&&e.key===t.key}var LV=({key:e})=>e??null,RV=({ref:e,ref_key:t,ref_for:n})=>(typeof e==`number`&&(e=``+e),e==null?null:DL(e)||mz(e)||EL(e)?{i:Vz,r:e,k:t,f:!!n}:e);function Q(e,t=null,n=null,r=0,i=null,a=e===TV?0:1,o=!1,s=!1){let c={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&LV(t),ref:t&&RV(t),scopeId:Hz,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:Vz};return s?(WV(c,n),a&128&&e.normalize(c)):n&&(c.shapeFlag|=DL(n)?8:16),jV>0&&!o&&AV&&(c.patchFlag>0||a&6)&&c.patchFlag!==32&&AV.push(c),c}var zV=Jce;function Jce(e,t=null,n=null,r=0,i=null,a=!1){if((!e||e===bce)&&(e=DV),FV(e)){let r=BV(e,t,!0);return n&&WV(r,n),jV>0&&!a&&AV&&(r.shapeFlag&6?AV[AV.indexOf(e)]=r:AV.push(r)),r.patchFlag=-2,r}if(ile(e)&&(e=e.__vccOpts),t){t=Yce(t);let{class:e,style:n}=t;e&&!DL(e)&&(t.class=nR(e)),kL(n)&&(uz(n)&&!SL(n)&&(n=vL({},n)),t.style=ZL(n))}let o=DL(e)?1:wV(e)?128:eB(e)?64:kL(e)?4:EL(e)?2:0;return Q(e,t,n,r,i,o,a,!0)}function Yce(e){return e?uz(e)||sV(e)?vL({},e):e:null}function BV(e,t,n=!1,r=!1){let{props:i,ref:a,patchFlag:o,children:s,transition:c}=e,l=t?Xce(i||{},t):i,u={__v_isVNode:!0,__v_skip:!0,type:e.type,props:l,key:l&&LV(l),ref:t&&t.ref?n&&a?SL(a)?a.concat(RV(t)):[a,RV(t)]:RV(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!==TV?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&&BV(e.ssContent),ssFallback:e.ssFallback&&BV(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return c&&r&&yB(u,c.clone(u)),u}function VV(e=` `,t=0){return zV(EV,null,e,t)}function $(e=``,t=!1){return t?(X(),PV(DV,null,e)):zV(DV,null,e)}function HV(e){return e==null||typeof e==`boolean`?zV(DV):SL(e)?zV(TV,null,e.slice()):FV(e)?UV(e):zV(EV,null,String(e))}function UV(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:BV(e)}function WV(e,t){let n=0,{shapeFlag:r}=e;if(t==null)t=null;else if(SL(t))n=16;else if(typeof t==`object`)if(r&65){let n=t.default;n&&(n._c&&(n._d=!1),WV(e,n()),n._c&&(n._d=!0));return}else{n=32;let r=t._;!r&&!sV(t)?t._ctx=Vz:r===3&&Vz&&(Vz.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else if(EL(t)){if(r&65){WV(e,{default:t});return}t={default:t,_ctx:Vz},n=32}else t=String(t),r&64?(n=16,t=[VV(t)]):n=8;e.children=t,e.shapeFlag|=n}function Xce(...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=nR([t.class,r.class]));else if(e===`style`)t.style=ZL([t.style,r.style]);else if(gL(e)){let n=t[e],i=r[e];i&&n!==i&&!(SL(n)&&n.includes(i))?t[e]=n?[].concat(n,i):i:i==null&&n==null&&!_L(e)&&(t[e]=i)}else e!==``&&(t[e]=r[e])}return t}function GV(e,t,n,r=null){Tz(e,t,7,[n,r])}var Zce=QB(),Qce=0;function $ce(e,t,n){let r=e.type,i=(t?t.appContext:e.appContext)||Zce,a={uid:Qce++,vnode:e,type:r,parent:t,appContext:i,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new wse(!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:uV(r,i),emitsOptions:eV(r,i),emit:null,emitted:null,propsDefaults:fL,inheritAttrs:r.inheritAttrs,ctx:fL,data:fL,props:fL,attrs:fL,slots:fL,refs:fL,setupState:fL,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=Ace.bind(null,a),e.ce&&e.ce(a),a}var KV=null,qV=()=>KV||Vz,JV,YV;{let e=XL(),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)}};JV=t(`__VUE_INSTANCE_SETTERS__`,e=>KV=e),YV=t(`__VUE_SSR_SETTERS__`,e=>$V=e)}var XV=e=>{let t=KV;return JV(e),e.scope.on(),()=>{e.scope.off(),JV(t)}},ZV=()=>{KV&&KV.scope.off(),JV(null)};function QV(e){return e.vnode.shapeFlag&4}var $V=!1;function ele(e,t=!1,n=!1){t&&YV(t);let{props:r,children:i}=e.vnode,a=QV(e);Ice(e,r,a,t),Bce(e,i,n||t);let o=a?tle(e,t):void 0;return t&&YV(!1),o}function tle(e,t){let n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,xce);let{setup:r}=n;if(r){OR();let n=e.setupContext=r.length>1?rle(e):null,i=XV(e),a=wz(r,e,0,[e.props,n]),o=AL(a);if(kR(),i(),(o||e.sp)&&!DB(e)&&SB(e),o){if(a.then(ZV,ZV),t)return a.then(n=>{eH(e,n,t)}).catch(t=>{Ez(t,e,0)});e.asyncDep=a}else eH(e,a,t)}else rH(e,t)}function eH(e,t,n){EL(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:kL(t)&&(e.setupState=yz(t)),rH(e,n)}var tH,nH;function rH(e,t,n){let r=e.type;if(!e.render){if(!t&&tH&&!r.render){let t=r.template||GB(e).template;if(t){let{isCustomElement:n,compilerOptions:i}=e.appContext.config,{delimiters:a,compilerOptions:o}=r;r.render=tH(t,vL(vL({isCustomElement:n,delimiters:a},i),o))}}e.render=r.render||mL,nH&&nH(e)}{let t=XV(e);OR();try{Sce(e)}finally{kR(),t()}}}var nle={get(e,t){return RR(e,`get`,``),e[t]}};function rle(e){return{attrs:new Proxy(e.attrs,nle),slots:e.slots,emit:e.emit,expose:t=>{e.exposed=t||{}}}}function iH(e){return e.exposed?e.exposeProxy||=new Proxy(yz(Gse(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in zB)return zB[n](e)},has(e,t){return t in e||t in zB}}):e.proxy}function ile(e){return EL(e)&&`__vccOpts`in e}var aH=(e,t)=>Yse(e,t,$V);function oH(e,t,n){try{MV(-1);let r=arguments.length;return r===2?kL(t)&&!SL(t)?FV(t)?zV(e,null,[t]):zV(e,t):zV(e,null,t):(r>3?n=Array.prototype.slice.call(arguments,2):r===3&&FV(n)&&(n=[n]),zV(e,t,n))}finally{MV(1)}}var ale=`3.5.39`,sH=void 0,cH=typeof window<`u`&&window.trustedTypes;if(cH)try{sH=cH.createPolicy(`vue`,{createHTML:e=>e})}catch{}var lH=sH?e=>sH.createHTML(e):e=>e,ole=`http://www.w3.org/2000/svg`,sle=`http://www.w3.org/1998/Math/MathML`,uH=typeof document<`u`?document:null,dH=uH&&uH.createElement(`template`),cle={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`?uH.createElementNS(ole,e):t===`mathml`?uH.createElementNS(sle,e):n?uH.createElement(e,{is:n}):uH.createElement(e);return e===`select`&&r&&r.multiple!=null&&i.setAttribute(`multiple`,r.multiple),i},createText:e=>uH.createTextNode(e),createComment:e=>uH.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>uH.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{dH.innerHTML=lH(r===`svg`?`<svg>${e}</svg>`:r===`mathml`?`<math>${e}</math>`:e);let i=dH.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]}},fH=`transition`,pH=`animation`,mH=Symbol(`_vtc`),hH={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},lle=vL({},fB,hH),gH=(e=>(e.displayName=`Transition`,e.props=lle,e))((e,{slots:t})=>oH(lce,ule(e),t)),_H=(e,t=[])=>{SL(e)?e.forEach(e=>e(...t)):e&&e(...t)},vH=e=>e?SL(e)?e.some(e=>e.length>1):e.length>1:!1;function ule(e){let t={};for(let n in e)n in hH||(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=dle(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,xH(e,t?u:s),xH(e,t?l:o),n&&n()},E=(e,t)=>{e._isLeaving=!1,xH(e,d),xH(e,p),xH(e,f),t&&t()},D=e=>(t,n)=>{let i=e?C:v,o=()=>T(t,e,n);_H(i,[t,o]),SH(()=>{xH(t,e?c:a),bH(t,e?u:s),vH(i)||CH(t,r,h,o)})};return vL(t,{onBeforeEnter(e){_H(_,[e]),bH(e,a),bH(e,o)},onBeforeAppear(e){_H(S,[e]),bH(e,c),bH(e,l)},onEnter:D(!1),onAppear:D(!0),onLeave(e,t){e._isLeaving=!0;let n=()=>E(e,t);bH(e,d),e._enterCancelled?(bH(e,f),DH(e)):(DH(e),bH(e,f)),SH(()=>{e._isLeaving&&(xH(e,d),bH(e,p),vH(b)||CH(e,r,g,n))}),_H(b,[e,n])},onEnterCancelled(e){T(e,!1,void 0,!0),_H(y,[e])},onAppearCancelled(e){T(e,!0,void 0,!0),_H(w,[e])},onLeaveCancelled(e){E(e),_H(x,[e])}})}function dle(e){if(e==null)return null;if(kL(e))return[yH(e.enter),yH(e.leave)];{let t=yH(e);return[t,t]}}function yH(e){return JL(e)}function bH(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.add(t)),(e[mH]||(e[mH]=new Set)).add(t)}function xH(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.remove(t));let n=e[mH];n&&(n.delete(t),n.size||(e[mH]=void 0))}function SH(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}var fle=0;function CH(e,t,n,r){let i=e._endId=++fle,a=()=>{i===e._endId&&r()};if(n!=null)return setTimeout(a,n);let{type:o,timeout:s,propCount:c}=wH(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 wH(e,t){let n=window.getComputedStyle(e),r=e=>(n[e]||``).split(`, `),i=r(`${fH}Delay`),a=r(`${fH}Duration`),o=TH(i,a),s=r(`${pH}Delay`),c=r(`${pH}Duration`),l=TH(s,c),u=null,d=0,f=0;t===fH?o>0&&(u=fH,d=o,f=a.length):t===pH?l>0&&(u=pH,d=l,f=c.length):(d=Math.max(o,l),u=d>0?o>l?fH:pH:null,f=u?u===fH?a.length:c.length:0);let p=u===fH&&/\b(?:transform|all)(?:,|$)/.test(r(`${fH}Property`).toString());return{type:u,timeout:d,propCount:f,hasTransform:p}}function TH(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map((t,n)=>EH(t)+EH(e[n])))}function EH(e){return e===`auto`?0:Number(e.slice(0,-1).replace(`,`,`.`))*1e3}function DH(e){return(e?e.ownerDocument:document).body.offsetHeight}function OH(e,t,n){let r=e[mH];r&&(t=(t?[t,...r]:[...r]).join(` `)),t==null?e.removeAttribute(`class`):n?e.setAttribute(`class`,t):e.className=t}var kH=Symbol(`_vod`),AH=Symbol(`_vsh`),jH={name:`show`,beforeMount(e,{value:t},{transition:n}){e[kH]=e.style.display===`none`?``:e.style.display,n&&t?n.beforeEnter(e):MH(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),MH(e,!0),r.enter(e)):r.leave(e,()=>{MH(e,!1)}):MH(e,t))},beforeUnmount(e,{value:t}){MH(e,t)}};function MH(e,t){e.style.display=t?e[kH]:`none`,e[AH]=!t}var NH=Symbol(``),PH=/(?:^|;)\s*display\s*:/;function FH(e,t,n){let r=e.style,i=DL(n),a=!1;if(n&&!i){if(t)if(DL(t))for(let e of t.split(`;`)){let t=e.slice(0,e.indexOf(`:`)).trim();n[t]??LH(r,t,``)}else for(let e in t)n[e]??LH(r,e,``);for(let i in n){i===`display`&&(a=!0);let o=n[i];o==null?LH(r,i,``):VH(e,i,!DL(t)&&t?t[i]:void 0,o)||LH(r,i,o)}}else if(i){if(t!==n){let e=r[NH];e&&(n+=`;`+e),r.cssText=n,a=PH.test(n)}}else t&&e.removeAttribute(`style`);kH in e&&(e[kH]=a?r.display:``,e[AH]&&(r.display=`none`))}var IH=/\s*!important$/;function LH(e,t,n){if(SL(n))n.forEach(n=>LH(e,t,n));else if(n??=``,t.startsWith(`--`))e.setProperty(t,n);else{let r=BH(e,t);IH.test(n)?e.setProperty(VL(r),n.replace(IH,``),`important`):e[r]=n}}var RH=[`Webkit`,`Moz`,`ms`],zH={};function BH(e,t){let n=zH[t];if(n)return n;let r=zL(t);if(r!==`filter`&&r in e)return zH[t]=r;r=HL(r);for(let n=0;n<RH.length;n++){let i=RH[n]+r;if(i in e)return zH[t]=i}return t}function VH(e,t,n,r){return e.tagName===`TEXTAREA`&&(t===`width`||t===`height`)&&DL(r)&&n===r}var HH=`http://www.w3.org/1999/xlink`;function UH(e,t,n,r,i,a=iR(t)){r&&t.startsWith(`xlink:`)?n==null?e.removeAttributeNS(HH,t.slice(6,t.length)):e.setAttributeNS(HH,t,n):n==null||a&&!aR(n)?e.removeAttribute(t):e.setAttribute(t,a?``:OL(n)?String(n):n)}function WH(e,t,n,r,i){if(t===`innerHTML`||t===`textContent`){n!=null&&(e[t]=t===`innerHTML`?lH(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=aR(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 GH(e,t,n,r){e.addEventListener(t,n,r)}function KH(e,t,n,r){e.removeEventListener(t,n,r)}var qH=Symbol(`_vei`);function JH(e,t,n,r,i=null){let a=e[qH]||(e[qH]={}),o=a[t];if(r&&o)o.value=r;else{let[n,s]=ZH(t);r?GH(e,n,a[t]=tU(r,i),s):o&&(KH(e,n,o,s),a[t]=void 0)}}var YH=/(Once|Passive|Capture)$/,XH=/^on:?(?:Once|Passive|Capture)$/;function ZH(e){let t,n;for(;(n=e.match(YH))&&!XH.test(e);)t||={},e=e.slice(0,e.length-n[1].length),t[n[1].toLowerCase()]=!0;return[e[2]===`:`?e.slice(3):VL(e.slice(2)),t]}var QH=0,$H=Promise.resolve(),eU=()=>QH||=($H.then(()=>QH=0),Date.now());function tU(e,t){let n=e=>{if(!e._vts)e._vts=Date.now();else if(e._vts<=n.attached)return;let r=n.value;if(SL(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&&Tz(e,t,5,a)}}else Tz(r,t,5,[e])};return n.value=e,n.attached=eU(),n}var nU=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,rU=(e,t,n,r,i,a)=>{let o=i===`svg`;t===`class`?OH(e,r,o):t===`style`?FH(e,n,r):gL(t)?_L(t)||JH(e,t,n,r,a):(t[0]===`.`?(t=t.slice(1),!0):t[0]===`^`?(t=t.slice(1),!1):iU(e,t,r,o))?(WH(e,t,r),!e.tagName.includes(`-`)&&(t===`value`||t===`checked`||t===`selected`)&&UH(e,t,r,o,a,t!==`value`)):e._isVueCE&&(aU(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!DL(r)))?WH(e,zL(t),r,a,t):(t===`true-value`?e._trueValue=r:t===`false-value`&&(e._falseValue=r),UH(e,t,r,o))};function iU(e,t,n,r){if(r)return!!(t===`innerHTML`||t===`textContent`||t in e&&nU(t)&&EL(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 nU(t)&&DL(n)?!1:t in e}function aU(e,t){let n=e._def.props;if(!n)return!1;let r=zL(t);return Array.isArray(n)?n.some(e=>zL(e)===r):Object.keys(n).some(e=>zL(e)===r)}var oU=e=>{let t=e.props[`onUpdate:modelValue`]||!1;return SL(t)?e=>GL(t,e):t};function sU(e){e.target.composing=!0}function cU(e){let t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event(`input`)))}var lU=Symbol(`_assign`);function uU(e,t,n){return t&&(e=e.trim()),n&&(e=qL(e)),e}var dU={created(e,{modifiers:{lazy:t,trim:n,number:r}},i){e[lU]=oU(i);let a=r||i.props&&i.props.type===`number`;GH(e,t?`change`:`input`,t=>{t.target.composing||e[lU](uU(e.value,n,a))}),(n||a)&&GH(e,`change`,()=>{e.value=uU(e.value,n,a)}),t||(GH(e,`compositionstart`,sU),GH(e,`compositionend`,cU),GH(e,`change`,cU))},mounted(e,{value:t}){e.value=t??``},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[lU]=oU(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?qL(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)}},fU=[`ctrl`,`shift`,`alt`,`meta`],pU={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)=>fU.some(n=>e[`${n}Key`]&&!t.includes(n))},mU=(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=pU[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},hU={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},gU=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=VL(n.key);if(t.some(e=>e===r||hU[e]===r))return e(n)}))},_U=vL({patchProp:rU},cle),vU;function yU(){return vU||=Hce(_U)}var bU=((...e)=>{let t=yU().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=SU(e);if(!r)return;let i=t._component;!EL(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,xU(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t});function xU(e){if(e instanceof SVGElement)return`svg`;if(typeof MathMLElement==`function`&&e instanceof MathMLElement)return`mathml`}function SU(e){return DL(e)?document.querySelector(e):e}function CU(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 wU(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 TU(e,t){return CU({code:`SCHEMA_INVALID`,path:e,message:`值不符合 "${e}" 的 schema(${t.length} 处问题)`,hint:`用 read({jsonPath:"${e}"}) 查看当前值,按 describe_data() 查看主数据 schema,修正后重试;改大对象优先用 write 的 patch 增量(只发改动部分)`,details:wU(t)})}function EU(e,t,n){let r=n?.message||String(n),i=typeof t==`string`?t:JSON.stringify(t);return CU({code:`JSON_PARSE`,...e===void 0?{}:{path:e},message:`value 不是合法 JSON:${r}`,hint:`检查引号/逗号/括号是否闭合;字符串值需双引号包裹(如 '"dark"' 表示字符串 dark,数字直接写如 5);预览前 80 字符:${i.slice(0,80)}`})}function DU(e){return e.severity===`recoverable`?`feedback`:e.severity===`fatal`?`abort`:`log`}function OU(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 kU(e,t,n,r){return{severity:e,message:t,code:n,context:r}}var AU=20*1024*1024,jU=1568,MU=.85,NU=class extends Error{code;constructor(e,t){super(t),this.code=e}};function PU(){return`img_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function FU(e){let t=/^data:([^;,]+)(?:;charset=[^;,]+)?;base64,(.*)$/s.exec(e??``);return t?{mimeType:t[1],data:t[2]}:null}function IU(e,t,n){if(e<=0||t<=0)return{width:Math.max(1,Math.round(e)),height:Math.max(1,Math.round(t))};let r=Math.min(1,n/Math.max(e,t));return{width:Math.max(1,Math.round(e*r)),height:Math.max(1,Math.round(t*r))}}function LU(e,t,n=`openai`){let r=[{type:`text`,text:e??``}];for(let e of t)if(e.dataUri)if(n===`anthropic`){let t=FU(e.dataUri);if(!t)continue;r.push({type:`image`,source:{type:`base64`,media_type:t.mimeType,data:t.data}})}else r.push({type:`image_url`,image_url:{url:e.dataUri}});else e.url&&r.push(n===`anthropic`?{type:`image`,source:{type:`url`,url:e.url}}:{type:`image_url`,image_url:{url:e.url}});return r.length>1?r:null}function RU(e,t){let n=(t??[]).filter(e=>e.description);return n.length?`${e}\n\n${n.map((e,t)=>`[图片 ${t+1} 描述]\n${e.description}`).join(`
148
+ `)}`),new Kx(n,JSON.stringify(e))}i=r}let a=dO(t),o=mO.configure(a.callbacks,this.callbacks,a.tags||n,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),s;Wx(e)&&(s=e.id),!s&&Gx(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=vM(e)?await xse(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=UI({content:u,artifact:d,toolCallId:s,name:this.name,metadata:this.metadata});return await c?.handleToolEnd(f),f}},RI=class extends LI{schema=Rj({input:Ij().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)}},zI=class extends RI{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=dO(t);return n.runName===void 0&&(n.runName=this.name),super.call(e,n)}_call(e,t,n){return this.func(e,t,n)}},BI=class extends LI{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=dO(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 VI(e,t){let n=Ak(t.schema),r=fM(t.schema);if(!t.schema||n||r)return new zI({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(t,n,r)=>new Promise((i,a)=>{let o=xO(r,{callbacks:n?.getChild()});_O.runWithConfig(SO(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 BI({...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(wO(r.signal))},r.signal.addEventListener(`abort`,o,{once:!0}));let c=xO(r,{callbacks:n?.getChild()});_O.runWithConfig(SO(c),async()=>{try{let n=await e(t,c);if(vM(n)){i(n);return}if(r?.signal?.aborted){s();return}s(),i(n)}catch(e){s(),a(e)}})})})}function HI(e){return typeof e==`object`&&!!e&&`type`in e}function UI(e){let{content:t,artifact:n,toolCallId:r,metadata:i}=e;return r&&!vx(t)?typeof t==`string`||Array.isArray(t)&&t.every(HI)?new yx({status:`success`,content:t,artifact:n,tool_call_id:r,name:e.name,metadata:i}):new yx({status:`success`,content:WI(t),artifact:n,tool_call_id:r,name:e.name,metadata:i}):t}function WI(e){try{return JSON.stringify(e)??``}catch{return`${e}`}}yN(),B({action:jd([B({type:Ud(`screenshot`)}),B({type:Ud(`click`),x:ud(),y:ud(),button:Vd([`left`,`right`,`wheel`,`back`,`forward`]).default(`left`)}),B({type:Ud(`double_click`),x:ud(),y:ud(),button:Vd([`left`,`right`,`wheel`,`back`,`forward`]).default(`left`)}),B({type:Ud(`drag`),path:z(B({x:ud(),y:ud()}))}),B({type:Ud(`keypress`),keys:z(R())}),B({type:Ud(`move`),x:ud(),y:ud()}),B({type:Ud(`scroll`),x:ud(),y:ud(),scroll_x:ud(),scroll_y:ud()}),B({type:Ud(`type`),text:R()}),B({type:Ud(`wait`),duration:ud().optional()})])}),yN(),jd([B({type:Ud(`exec`),command:z(R()),env:Id(R(),R()).optional(),working_directory:R().optional(),timeout_ms:ud().optional(),user:R().optional()})]),yN(),B({commands:z(R()).describe(`Array of shell commands to execute`),timeout_ms:ud().optional().describe(`Optional timeout in milliseconds for the commands`),max_output_length:ud().optional().describe(`Optional maximum number of characters to return from each command`)}),yN(),jd([B({type:Ud(`create_file`),path:R(),diff:R()}),B({type:Ud(`update_file`),path:R(),diff:R()}),B({type:Ud(`delete_file`),path:R()})]);function GI(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 KI(e){let t=e.model||`deepseek-v4-flash`,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 II({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 II({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&&GI(n?.body))try{a=await s(),o.set(`Authorization`,`Bearer ${a}`),l=await c()}catch{}return l}}})}var qI=[{pattern:/deepseek-v4/i,caps:{contextWindow:1048576,maxOutputTokens:393216,thinking:!0}},{pattern:/deepseek-reasoner|deepseek-r1/i,caps:{contextWindow:65536,maxOutputTokens:8192,thinking:!0}},{pattern:/deepseek/i,caps:{contextWindow:131072,maxOutputTokens:8192,thinking:!0}},{pattern:/gpt-5/i,caps:{contextWindow:1048576,maxOutputTokens:32768,vision:!0}},{pattern:/gpt-4\.1/i,caps:{contextWindow:1047576,maxOutputTokens:32768,vision:!0}},{pattern:/gpt-4o-mini/i,caps:{contextWindow:131072,maxOutputTokens:16384,vision:!0}},{pattern:/gpt-4o/i,caps:{contextWindow:131072,maxOutputTokens:16384,vision:!0}},{pattern:/gpt-4-turbo|gpt-4-1106|gpt-4-0125/i,caps:{contextWindow:131072,maxOutputTokens:4096,vision:!0}},{pattern:/gpt-3\.5/i,caps:{contextWindow:16385,maxOutputTokens:4096}},{pattern:/claude-(sonnet|opus)-4|claude-4/i,caps:{contextWindow:2e5,maxOutputTokens:64e3,vision:!0,thinking:!0}},{pattern:/claude-3-7-sonnet/i,caps:{contextWindow:2e5,maxOutputTokens:8192,vision:!0,thinking:!0}},{pattern:/claude-3-5-sonnet/i,caps:{contextWindow:2e5,maxOutputTokens:8192,vision:!0}},{pattern:/claude-3-opus/i,caps:{contextWindow:2e5,maxOutputTokens:4096,vision:!0}},{pattern:/claude-3-haiku/i,caps:{contextWindow:2e5,maxOutputTokens:4096,vision:!0}},{pattern:/qwen2\.5-vl|qwen2-vl|qwen-vl|qvq/i,caps:{contextWindow:32768,maxOutputTokens:2048,vision:!0}},{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,thinking:!0}},{pattern:/glm-5/i,caps:{contextWindow:2e5,maxOutputTokens:65536}},{pattern:/glm-4v|glm4v/i,caps:{contextWindow:32768,maxOutputTokens:2048,vision:!0}},{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}}],JI={contextWindow:32768,maxOutputTokens:4096},YI=2e5;function XI(e={}){let t=(()=>{if(!e.model)return;let t=qI.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??JI.contextWindow,maxOutputTokens:e.maxOutputTokens??t?.maxOutputTokens??JI.maxOutputTokens,vision:e.vision??t?.vision??!1,thinking:e.thinking??t?.thinking??!1}}function ZI(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 QI(e){return Math.max(2e3,Math.min(2e4,Math.round(e*.035)))}function $I(e){let t=QI(e);return Math.min(2e5,Math.max(t,Math.round(e*.7)))}function eL(e,t){if(!t)return e;if(t===`simple`){let t=e.extraBody&&`thinking`in e.extraBody;if(!t&&!e.thinking)return e;let{thinking:n,...r}=e,i=r;if(t){let{thinking:t,...n}=e.extraBody;i.extraBody=n}return i}if(e.provider===`anthropic`){if(e.thinking?.type===`enabled`&&e.thinking.budget_tokens)return e;let t=e.thinking?.budget_tokens??Math.min(e.maxTokens??4096,8e3);return{...e,thinking:{type:`enabled`,budget_tokens:t}}}let n=e.extraBody?.thinking??{};return{...e,extraBody:{...e.extraBody??{},thinking:{...n,type:`enabled`}}}}function tL(e,t,n){if(t)return t;if(e.thinkingMode)return e.thinkingMode;if(!(e.extraBody&&`thinking`in e.extraBody||e.thinking))return n||(XI({model:e.model}).thinking?`deep`:void 0)}function nL(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 rL(e){return!e||!e.startsWith(`/`)||typeof location>`u`||!location.origin?e:`${location.origin}${e}`}function iL(e,t={}){return e=eL(e,tL(e,t.thinkingMode,t.thinkingFallback)),new II({apiKey:e.apiKey,model:e.model,temperature:t.temperature??e.temperature,maxTokens:t.maxTokens??e.maxTokens,configuration:{...e.baseUrl?{baseURL:rL(e.baseUrl)}:{},fetch:nL,...e.extraConfig},...e.extraBody?{modelKwargs:e.extraBody}:{}})}async function aL(e,t={}){if(e=eL(e,tL(e,t.thinkingMode,t.thinkingFallback)),(e.provider??`openai`)===`openai`)return iL(e,t);let{ChatAnthropic:n}=await import(`@langchain/anthropic`);return new n({apiKey:e.apiKey,model:e.model,temperature:e.thinking?1:t.temperature??e.temperature,maxTokens:t.maxTokens??e.maxTokens,...e.baseUrl?{anthropicApiUrl:rL(e.baseUrl)}:{},...e.extraConfig?{clientOptions:e.extraConfig}:{},...e.thinking?{thinking:e.thinking}:{},...e.cacheControl?{invocationKwargs:{cache_control:{type:`ephemeral`,...e.cacheControl===!0?{}:{ttl:e.cacheControl}}}}:{}})}function oL(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 sL(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 cL(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`&&lL(e))return e}function lL(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 uL(e){let t=cL(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,l=n.output_token_details,u=n.completion_tokens_details,d=e,f=Number(l?.reasoning??u?.reasoning_tokens??d?.response_metadata?.usage?.completion_tokens_details?.reasoning_tokens??0)||0;return{prompt_tokens:r,completion_tokens:i,total_tokens:a,...s?{cache_read_input_tokens:s}:{},...c?{cache_creation_input_tokens:c}:{},...f?{reasoning_tokens:f}:{}}}function dL(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var fL={},pL=[],mL=()=>{},hL=()=>!1,gL=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),_L=e=>e.startsWith(`onUpdate:`),vL=Object.assign,yL=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},bL=Object.prototype.hasOwnProperty,xL=(e,t)=>bL.call(e,t),SL=Array.isArray,CL=e=>ML(e)===`[object Map]`,wL=e=>ML(e)===`[object Set]`,TL=e=>ML(e)===`[object Date]`,EL=e=>typeof e==`function`,DL=e=>typeof e==`string`,OL=e=>typeof e==`symbol`,kL=e=>typeof e==`object`&&!!e,AL=e=>(kL(e)||EL(e))&&EL(e.then)&&EL(e.catch),jL=Object.prototype.toString,ML=e=>jL.call(e),NL=e=>ML(e).slice(8,-1),PL=e=>ML(e)===`[object Object]`,FL=e=>DL(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,IL=dL(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),LL=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},RL=/-\w/g,zL=LL(e=>e.replace(RL,e=>e.slice(1).toUpperCase())),BL=/\B([A-Z])/g,VL=LL(e=>e.replace(BL,`-$1`).toLowerCase()),HL=LL(e=>e.charAt(0).toUpperCase()+e.slice(1)),UL=LL(e=>e?`on${HL(e)}`:``),WL=(e,t)=>!Object.is(e,t),GL=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},KL=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},qL=e=>{let t=parseFloat(e);return isNaN(t)?e:t},JL=e=>{let t=DL(e)?Number(e):NaN;return isNaN(t)?e:t},YL,XL=()=>YL||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{};function ZL(e){if(SL(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=DL(r)?tR(r):ZL(r);if(i)for(let e in i)t[e]=i[e]}return t}else if(DL(e)||kL(e))return e}var QL=/;(?![^(]*\))/g,$L=/:([^]+)/,eR=/\/\*[^]*?\*\//g;function tR(e){let t={};return e.replace(eR,``).split(QL).forEach(e=>{if(e){let n=e.split($L);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function nR(e){let t=``;if(DL(e))t=e;else if(SL(e))for(let n=0;n<e.length;n++){let r=nR(e[n]);r&&(t+=r+` `)}else if(kL(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}var rR=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,iR=dL(rR);rR+``;function aR(e){return!!e||e===``}function oR(e,t){if(e.length!==t.length)return!1;let n=!0;for(let r=0;n&&r<e.length;r++)n=sR(e[r],t[r]);return n}function sR(e,t){if(e===t)return!0;let n=TL(e),r=TL(t);if(n||r)return n&&r?e.getTime()===t.getTime():!1;if(n=OL(e),r=OL(t),n||r)return e===t;if(n=SL(e),r=SL(t),n||r)return n&&r?oR(e,t):!1;if(n=kL(e),r=kL(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||!sR(e[n],t[n]))return!1}}return String(e)===String(t)}var cR=e=>!!(e&&e.__v_isRef===!0),J=e=>DL(e)?e:e==null?``:SL(e)||kL(e)&&(e.toString===jL||!EL(e.toString))?cR(e)?J(e.value):JSON.stringify(e,lR,2):String(e),lR=(e,t)=>cR(t)?lR(e,t.value):CL(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[uR(t,r)+` =>`]=n,e),{})}:wL(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>uR(e))}:OL(t)?uR(t):kL(t)&&!SL(t)&&!PL(t)?String(t):t,uR=(e,t=``)=>OL(e)?`Symbol(${e.description??t})`:e,dR,wse=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&&dR&&(dR.active?(this.parent=dR,this.index=(dR.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=dR;try{return dR=this,e()}finally{dR=t}}}on(){++this._on===1&&(this.prevScope=dR,dR=this)}off(){if(this._on>0&&--this._on===0){if(dR===this)dR=this.prevScope;else{let e=dR;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 Tse(){return dR}function Ese(e,t=!1){dR&&dR.cleanups.push(e)}var fR,pR=new WeakSet,mR=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,dR&&(dR.active?dR.effects.push(this):this.flags&=-2)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,pR.has(this)&&(pR.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||vR(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,AR(this),xR(this);let e=fR,t=ER;fR=this,ER=!0;try{return this.fn()}finally{SR(this),fR=e,ER=t,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)TR(e);this.deps=this.depsTail=void 0,AR(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?pR.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){CR(this)&&this.run()}get dirty(){return CR(this)}},hR=0,gR,_R;function vR(e,t=!1){if(e.flags|=8,t){e.next=_R,_R=e;return}e.next=gR,gR=e}function yR(){hR++}function bR(){if(--hR>0)return;if(_R){let e=_R;for(_R=void 0;e;){let t=e.next;e.next=void 0,e.flags&=-9,e=t}}let e;for(;gR;){let t=gR;for(gR=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 xR(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function SR(e){let t,n=e.depsTail,r=n;for(;r;){let e=r.prevDep;r.version===-1?(r===n&&(n=e),TR(r),Dse(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=e}e.deps=t,e.depsTail=n}function CR(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(wR(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function wR(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===jR)||(e.globalVersion=jR,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!CR(e))))return;e.flags|=2;let t=e.dep,n=fR,r=ER;fR=e,ER=!0;try{xR(e);let n=e.fn(e._value);(t.version===0||WL(n,e._value))&&(e.flags|=128,e._value=n,t.version++)}catch(e){throw t.version++,e}finally{fR=n,ER=r,SR(e),e.flags&=-3}}function TR(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)TR(e,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function Dse(e){let{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}var ER=!0,DR=[];function OR(){DR.push(ER),ER=!1}function kR(){let e=DR.pop();ER=e===void 0||e}function AR(e){let{cleanup:t}=e;if(e.cleanup=void 0,t){let e=fR;fR=void 0;try{t()}finally{fR=e}}}var jR=0,Ose=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}},MR=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(!fR||!ER||fR===this.computed)return;let t=this.activeLink;if(t===void 0||t.sub!==fR)t=this.activeLink=new Ose(fR,this),fR.deps?(t.prevDep=fR.depsTail,fR.depsTail.nextDep=t,fR.depsTail=t):fR.deps=fR.depsTail=t,NR(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=fR.depsTail,t.nextDep=void 0,fR.depsTail.nextDep=t,fR.depsTail=t,fR.deps===t&&(fR.deps=e)}return t}trigger(e){this.version++,jR++,this.notify(e)}notify(e){yR();try{for(let e=this.subs;e;e=e.prevSub)e.sub.notify()&&e.sub.dep.notify()}finally{bR()}}};function NR(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)NR(e)}let n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}var PR=new WeakMap,FR=Symbol(``),IR=Symbol(``),LR=Symbol(``);function RR(e,t,n){if(ER&&fR){let t=PR.get(e);t||PR.set(e,t=new Map);let r=t.get(n);r||(t.set(n,r=new MR),r.map=t,r.key=n),r.track()}}function zR(e,t,n,r,i,a){let o=PR.get(e);if(!o){jR++;return}let s=e=>{e&&e.trigger()};if(yR(),t===`clear`)o.forEach(s);else{let i=SL(e),a=i&&FL(n);if(i&&n===`length`){let e=Number(r);o.forEach((t,n)=>{(n===`length`||n===LR||!OL(n)&&n>=e)&&s(t)})}else switch((n!==void 0||o.has(void 0))&&s(o.get(n)),a&&s(o.get(LR)),t){case`add`:i?a&&s(o.get(`length`)):(s(o.get(FR)),CL(e)&&s(o.get(IR)));break;case`delete`:i||(s(o.get(FR)),CL(e)&&s(o.get(IR)));break;case`set`:CL(e)&&s(o.get(FR));break}}bR()}function BR(e){let t=dz(e);return t===e?t:(RR(t,`iterate`,LR),lz(e)?t:t.map(fz))}function VR(e){return RR(e=dz(e),`iterate`,LR),e}function HR(e,t){return cz(e)?pz(sz(e)?fz(t):t):fz(t)}var kse={__proto__:null,[Symbol.iterator](){return UR(this,Symbol.iterator,e=>HR(this,e))},concat(...e){return BR(this).concat(...e.map(e=>SL(e)?BR(e):e))},entries(){return UR(this,`entries`,e=>(e[1]=HR(this,e[1]),e))},every(e,t){return WR(this,`every`,e,t,void 0,arguments)},filter(e,t){return WR(this,`filter`,e,t,e=>e.map(e=>HR(this,e)),arguments)},find(e,t){return WR(this,`find`,e,t,e=>HR(this,e),arguments)},findIndex(e,t){return WR(this,`findIndex`,e,t,void 0,arguments)},findLast(e,t){return WR(this,`findLast`,e,t,e=>HR(this,e),arguments)},findLastIndex(e,t){return WR(this,`findLastIndex`,e,t,void 0,arguments)},forEach(e,t){return WR(this,`forEach`,e,t,void 0,arguments)},includes(...e){return KR(this,`includes`,e)},indexOf(...e){return KR(this,`indexOf`,e)},join(e){return BR(this).join(e)},lastIndexOf(...e){return KR(this,`lastIndexOf`,e)},map(e,t){return WR(this,`map`,e,t,void 0,arguments)},pop(){return qR(this,`pop`)},push(...e){return qR(this,`push`,e)},reduce(e,...t){return GR(this,`reduce`,e,t)},reduceRight(e,...t){return GR(this,`reduceRight`,e,t)},shift(){return qR(this,`shift`)},some(e,t){return WR(this,`some`,e,t,void 0,arguments)},splice(...e){return qR(this,`splice`,e)},toReversed(){return BR(this).toReversed()},toSorted(e){return BR(this).toSorted(e)},toSpliced(...e){return BR(this).toSpliced(...e)},unshift(...e){return qR(this,`unshift`,e)},values(){return UR(this,`values`,e=>HR(this,e))}};function UR(e,t,n){let r=VR(e),i=r[t]();return r!==e&&!lz(e)&&(i._next=i.next,i.next=()=>{let e=i._next();return e.done||(e.value=n(e.value)),e}),i}var Ase=Array.prototype;function WR(e,t,n,r,i,a){let o=VR(e),s=o!==e&&!lz(e),c=o[t];if(c!==Ase[t]){let t=c.apply(e,a);return s?fz(t):t}let l=n;o!==e&&(s?l=function(t,r){return n.call(this,HR(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 GR(e,t,n,r){let i=VR(e),a=i!==e&&!lz(e),o=n,s=!1;i!==e&&(a?(s=r.length===0,o=function(t,r,i){return s&&(s=!1,t=HR(e,t)),n.call(this,t,HR(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?HR(e,c):c}function KR(e,t,n){let r=dz(e);RR(r,`iterate`,LR);let i=r[t](...n);return(i===-1||i===!1)&&uz(n[0])?(n[0]=dz(n[0]),r[t](...n)):i}function qR(e,t,n=[]){OR(),yR();let r=dz(e)[t].apply(e,n);return bR(),kR(),r}var jse=dL(`__proto__,__v_isRef,__isVue`),JR=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!==`arguments`&&e!==`caller`).map(e=>Symbol[e]).filter(OL));function Mse(e){OL(e)||(e=String(e));let t=dz(this);return RR(t,`has`,e),t.hasOwnProperty(e)}var YR=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?Hse:rz:i?nz:tz).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;let a=SL(e);if(!r){let e;if(a&&(e=kse[t]))return e;if(t===`hasOwnProperty`)return Mse}let o=Reflect.get(e,t,mz(e)?e:n);if((OL(t)?JR.has(t):jse(t))||(r||RR(e,`get`,t),i))return o;if(mz(o)){let e=a&&FL(t)?o:o.value;return r&&kL(e)?az(e):e}return kL(o)?r?az(o):iz(o):o}},XR=class extends YR{constructor(e=!1){super(!1,e)}set(e,t,n,r){let i=e[t],a=SL(e)&&FL(t);if(!this._isShallow){let e=cz(i);if(!lz(n)&&!cz(n)&&(i=dz(i),n=dz(n)),!a&&mz(i)&&!mz(n))return e||(i.value=n),!0}let o=a?Number(t)<e.length:xL(e,t),s=Reflect.set(e,t,n,mz(e)?e:r);return e===dz(r)&&s&&(o?WL(n,i)&&zR(e,`set`,t,n,i):zR(e,`add`,t,n)),s}deleteProperty(e,t){let n=xL(e,t),r=e[t],i=Reflect.deleteProperty(e,t);return i&&n&&zR(e,`delete`,t,void 0,r),i}has(e,t){let n=Reflect.has(e,t);return(!OL(t)||!JR.has(t))&&RR(e,`has`,t),n}ownKeys(e){return RR(e,`iterate`,SL(e)?`length`:FR),Reflect.ownKeys(e)}},Nse=class extends YR{constructor(e=!1){super(!0,e)}set(e,t){return!0}deleteProperty(e,t){return!0}},Pse=new XR,Fse=new Nse,Ise=new XR(!0),ZR=e=>e,QR=e=>Reflect.getPrototypeOf(e);function Lse(e,t,n){return function(...r){let i=this.__v_raw,a=dz(i),o=CL(a),s=e===`entries`||e===Symbol.iterator&&o,c=e===`keys`&&o,l=i[e](...r),u=n?ZR:t?pz:fz;return!t&&RR(a,`iterate`,c?IR:FR),vL(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 $R(e){return function(...t){return e===`delete`?!1:e===`clear`?void 0:this}}function Rse(e,t){let n={get(n){let r=this.__v_raw,i=dz(r),a=dz(n);e||(WL(n,a)&&RR(i,`get`,n),RR(i,`get`,a));let{has:o}=QR(i),s=t?ZR:e?pz:fz;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&&RR(dz(t),`iterate`,FR),t.size},has(t){let n=this.__v_raw,r=dz(n),i=dz(t);return e||(WL(t,i)&&RR(r,`has`,t),RR(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=dz(a),s=t?ZR:e?pz:fz;return!e&&RR(o,`iterate`,FR),a.forEach((e,t)=>n.call(r,s(e),s(t),i))}};return vL(n,e?{add:$R(`add`),set:$R(`set`),delete:$R(`delete`),clear:$R(`clear`)}:{add(e){let n=dz(this),r=QR(n),i=dz(e),a=!t&&!lz(e)&&!cz(e)?i:e;return r.has.call(n,a)||WL(e,a)&&r.has.call(n,e)||WL(i,a)&&r.has.call(n,i)||(n.add(a),zR(n,`add`,a,a)),this},set(e,n){!t&&!lz(n)&&!cz(n)&&(n=dz(n));let r=dz(this),{has:i,get:a}=QR(r),o=i.call(r,e);o||=(e=dz(e),i.call(r,e));let s=a.call(r,e);return r.set(e,n),o?WL(n,s)&&zR(r,`set`,e,n,s):zR(r,`add`,e,n),this},delete(e){let t=dz(this),{has:n,get:r}=QR(t),i=n.call(t,e);i||=(e=dz(e),n.call(t,e));let a=r?r.call(t,e):void 0,o=t.delete(e);return i&&zR(t,`delete`,e,void 0,a),o},clear(){let e=dz(this),t=e.size!==0,n=e.clear();return t&&zR(e,`clear`,void 0,void 0,void 0),n}}),[`keys`,`values`,`entries`,Symbol.iterator].forEach(r=>{n[r]=Lse(r,e,t)}),n}function ez(e,t){let n=Rse(e,t);return(t,r,i)=>r===`__v_isReactive`?!e:r===`__v_isReadonly`?e:r===`__v_raw`?t:Reflect.get(xL(n,r)&&r in t?n:t,r,i)}var zse={get:ez(!1,!1)},Bse={get:ez(!1,!0)},Vse={get:ez(!0,!1)},tz=new WeakMap,nz=new WeakMap,rz=new WeakMap,Hse=new WeakMap;function Use(e){switch(e){case`Object`:case`Array`:return 1;case`Map`:case`Set`:case`WeakMap`:case`WeakSet`:return 2;default:return 0}}function iz(e){return cz(e)?e:oz(e,!1,Pse,zse,tz)}function Wse(e){return oz(e,!1,Ise,Bse,nz)}function az(e){return oz(e,!0,Fse,Vse,rz)}function oz(e,t,n,r,i){if(!kL(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=Use(NL(e));if(o===0)return e;let s=new Proxy(e,o===2?r:n);return i.set(e,s),s}function sz(e){return cz(e)?sz(e.__v_raw):!!(e&&e.__v_isReactive)}function cz(e){return!!(e&&e.__v_isReadonly)}function lz(e){return!!(e&&e.__v_isShallow)}function uz(e){return e?!!e.__v_raw:!1}function dz(e){let t=e&&e.__v_raw;return t?dz(t):e}function Gse(e){return!xL(e,`__v_skip`)&&Object.isExtensible(e)&&KL(e,`__v_skip`,!0),e}var fz=e=>kL(e)?iz(e):e,pz=e=>kL(e)?az(e):e;function mz(e){return e?e.__v_isRef===!0:!1}function hz(e){return _z(e,!1)}function gz(e){return _z(e,!0)}function _z(e,t){return mz(e)?e:new Kse(e,t)}var Kse=class{constructor(e,t){this.dep=new MR,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=t?e:dz(e),this._value=t?e:fz(e),this.__v_isShallow=t}get value(){return this.dep.track(),this._value}set value(e){let t=this._rawValue,n=this.__v_isShallow||lz(e)||cz(e);e=n?e:dz(e),WL(e,t)&&(this._rawValue=e,this._value=n?e:fz(e),this.dep.trigger())}};function vz(e){e.dep&&e.dep.trigger()}function Y(e){return mz(e)?e.value:e}var qse={get:(e,t,n)=>t===`__v_raw`?e:Y(Reflect.get(e,t,n)),set:(e,t,n,r)=>{let i=e[t];return mz(i)&&!mz(n)?(i.value=n,!0):Reflect.set(e,t,n,r)}};function yz(e){return sz(e)?e:new Proxy(e,qse)}var Jse=class{constructor(e,t,n){this.fn=e,this.setter=t,this._value=void 0,this.dep=new MR(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=jR-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!t,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&fR!==this)return vR(this,!0),!0}get value(){let e=this.dep.track();return wR(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}};function Yse(e,t,n=!1){let r,i;return EL(e)?r=e:(r=e.get,i=e.set),new Jse(r,i,n)}var bz={},xz=new WeakMap,Sz=void 0;function Xse(e,t=!1,n=Sz){if(n){let t=xz.get(n);t||xz.set(n,t=[]),t.push(e)}}function Zse(e,t,n=fL){let{immediate:r,deep:i,once:a,scheduler:o,augmentJob:s,call:c}=n,l=e=>i?e:lz(e)||i===!1||i===0?Cz(e,1):Cz(e),u,d,f,p,m=!1,h=!1;if(mz(e)?(d=()=>e.value,m=lz(e)):sz(e)?(d=()=>l(e),m=!0):SL(e)?(h=!0,m=e.some(e=>sz(e)||lz(e)),d=()=>e.map(e=>{if(mz(e))return e.value;if(sz(e))return l(e);if(EL(e))return c?c(e,2):e()})):d=EL(e)?t?c?()=>c(e,2):e:()=>{if(f){OR();try{f()}finally{kR()}}let t=Sz;Sz=u;try{return c?c(e,3,[p]):e(p)}finally{Sz=t}}:mL,t&&i){let e=d,t=i===!0?1/0:i;d=()=>Cz(e(),t)}let g=Tse(),_=()=>{u.stop(),g&&g.active&&yL(g.effects,u)};if(a&&t){let e=t;t=(...t)=>{let n=e(...t);return _(),n}}let v=h?Array(e.length).fill(bz):bz,y=e=>{if(!(!(u.flags&1)||!u.dirty&&!e))if(t){let n=u.run();if(e||i||m||(h?n.some((e,t)=>WL(e,v[t])):WL(n,v))){f&&f();let e=Sz;Sz=u;try{let e=[n,v===bz?void 0:h&&v[0]===bz?[]:v,p];v=n,c?c(t,3,e):t(...e)}finally{Sz=e}}}else u.run()};return s&&s(y),u=new mR(d),u.scheduler=o?()=>o(y,!1):y,p=e=>Xse(e,!1,u),f=u.onStop=()=>{let e=xz.get(u);if(e){if(c)c(e,4);else for(let t of e)t();xz.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 Cz(e,t=1/0,n){if(t<=0||!kL(e)||e.__v_skip||(n||=new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,mz(e))Cz(e.value,t,n);else if(SL(e))for(let r=0;r<e.length;r++)Cz(e[r],t,n);else if(wL(e)||CL(e))e.forEach(e=>{Cz(e,t,n)});else if(PL(e)){for(let r in e)Cz(e[r],t,n);for(let r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&Cz(e[r],t,n)}return e}function wz(e,t,n,r){try{return r?e(...r):e()}catch(e){Ez(e,t,n)}}function Tz(e,t,n,r){if(EL(e)){let i=wz(e,t,n,r);return i&&AL(i)&&i.catch(e=>{Ez(e,t,n)}),i}if(SL(e)){let i=[];for(let a=0;a<e.length;a++)i.push(Tz(e[a],t,n,r));return i}}function Ez(e,t,n,r=!0){let i=t?t.vnode:null,{errorHandler:a,throwUnhandledErrorInProduction:o}=t&&t.appContext.config||fL;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){OR(),wz(a,null,10,[e,i,o]),kR();return}}Qse(e,n,i,r,o)}function Qse(e,t,n,r=!0,i=!1){if(i)throw e;console.error(e)}var Dz=[],Oz=-1,kz=[],Az=null,jz=0,Mz=Promise.resolve(),Nz=null;function Pz(e){let t=Nz||Mz;return e?t.then(this?e.bind(this):e):t}function $se(e){let t=Oz+1,n=Dz.length;for(;t<n;){let r=t+n>>>1,i=Dz[r],a=zz(i);a<e||a===e&&i.flags&2?t=r+1:n=r}return t}function Fz(e){if(!(e.flags&1)){let t=zz(e),n=Dz[Dz.length-1];!n||!(e.flags&2)&&t>=zz(n)?Dz.push(e):Dz.splice($se(t),0,e),e.flags|=1,Iz()}}function Iz(){Nz||=Mz.then(Bz)}function ece(e){SL(e)?kz.push(...e):Az&&e.id===-1?Az.splice(jz+1,0,e):e.flags&1||(kz.push(e),e.flags|=1),Iz()}function Lz(e,t,n=Oz+1){for(;n<Dz.length;n++){let t=Dz[n];if(t&&t.flags&2){if(e&&t.id!==e.uid)continue;Dz.splice(n,1),n--,t.flags&4&&(t.flags&=-2),t(),t.flags&4||(t.flags&=-2)}}}function Rz(e){if(kz.length){let e=[...new Set(kz)].sort((e,t)=>zz(e)-zz(t));if(kz.length=0,Az){Az.push(...e);return}for(Az=e,jz=0;jz<Az.length;jz++){let e=Az[jz];e.flags&4&&(e.flags&=-2),e.flags&8||e(),e.flags&=-2}Az=null,jz=0}}var zz=e=>e.id==null?e.flags&2?-1:1/0:e.id;function Bz(e){try{for(Oz=0;Oz<Dz.length;Oz++){let e=Dz[Oz];e&&!(e.flags&8)&&(e.flags&4&&(e.flags&=-2),wz(e,e.i,e.i?15:14),e.flags&4||(e.flags&=-2))}}finally{for(;Oz<Dz.length;Oz++){let e=Dz[Oz];e&&(e.flags&=-2)}Oz=-1,Dz.length=0,Rz(e),Nz=null,(Dz.length||kz.length)&&Bz(e)}}var Vz=null,Hz=null;function Uz(e){let t=Vz;return Vz=e,Hz=e&&e.type.__scopeId||null,t}function Wz(e,t=Vz,n){if(!t||e._n)return e;let r=(...n)=>{r._d&&MV(-1);let i=Uz(t),a;try{a=e(...n)}finally{Uz(i),r._d&&MV(1)}return a};return r._n=!0,r._c=!0,r._d=!0,r}function Gz(e,t){if(Vz===null)return e;let n=iH(Vz),r=e.dirs||=[];for(let e=0;e<t.length;e++){let[i,a,o,s=fL]=t[e];i&&(EL(i)&&(i={mounted:i,updated:i}),i.deep&&Cz(a),r.push({dir:i,instance:n,value:a,oldValue:void 0,arg:o,modifiers:s}))}return e}function Kz(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&&(OR(),Tz(c,n,8,[e.el,s,e,t]),kR())}}function qz(e,t){if(KV){let n=KV.provides,r=KV.parent&&KV.parent.provides;r===n&&(n=KV.provides=Object.create(r)),n[e]=t}}function Jz(e,t,n=!1){let r=qV();if(r||$B){let i=$B?$B._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&&EL(t)?t.call(r&&r.proxy):t}}var tce=Symbol.for(`v-scx`),nce=()=>Jz(tce);function Yz(e,t,n){return Xz(e,t,n)}function Xz(e,t,n=fL){let{immediate:r,deep:i,flush:a,once:o}=n,s=vL({},n),c=t&&r||!t&&a!==`post`,l;if($V){if(a===`sync`){let e=nce();l=e.__watcherHandles||=[]}else if(!c){let e=()=>{};return e.stop=mL,e.resume=mL,e.pause=mL,e}}let u=KV;s.call=(e,t,n)=>Tz(e,u,t,n);let d=!1;a===`post`?s.scheduler=e=>{_V(e,u&&u.suspense)}:a!==`sync`&&(d=!0,s.scheduler=(e,t)=>{t?e():Fz(e)}),s.augmentJob=e=>{t&&(e.flags|=4),d&&(e.flags|=2,u&&(e.id=u.uid,e.i=u))};let f=Zse(e,t,s);return $V&&(l?l.push(f):c&&f()),f}function rce(e,t,n){let r=this.proxy,i=DL(e)?e.includes(`.`)?Zz(r,e):()=>r[e]:e.bind(r,r),a;EL(t)?a=t:(a=t.handler,n=t);let o=XV(this),s=Xz(i,a.bind(r),n);return o(),s}function Zz(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 Qz=new WeakMap,$z=Symbol(`_vte`),eB=e=>e.__isTeleport,tB=e=>e&&(e.disabled||e.disabled===``),ice=e=>e&&(e.defer||e.defer===``),nB=e=>typeof SVGElement<`u`&&e instanceof SVGElement,rB=e=>typeof MathMLElement==`function`&&e instanceof MathMLElement,iB=(e,t)=>{let n=e&&e.to;return DL(n)?t?t(n):null:n},ace={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=tB(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=tB(e.props),r=e.target=iB(e.props,m),a=cB(r,e,h,p);r&&(o!==`svg`&&nB(r)?o=`svg`:o!==`mathml`&&rB(r)&&(o=`mathml`),i&&i.isCE&&(i.ce._teleportTargets||(i.ce._teleportTargets=new Set)).add(r),n||(b(e,r,a),sB(e,!1)))},S=e=>{let t=()=>{if(Qz.get(e)===t){if(Qz.delete(e),tB(e.props)){let t=_(e.el)||n;b(e,t,e.anchor),sB(e,!0)}x(e)}};Qz.set(e,t),_V(t,a)};if(e==null){let e=t.el=h(``),i=t.anchor=h(``);if(p(e,n,r),p(i,n,r),ice(t.props)||a&&a.pendingBranch){S(t);return}v&&(b(t,n,i),sB(t,!0)),x()}else{t.el=e.el;let r=t.anchor=e.anchor,u=Qz.get(e);if(u){u.flags|=8,Qz.delete(e),S(t);return}t.targetStart=e.targetStart;let p=t.target=e.target,h=t.targetAnchor=e.targetAnchor,g=tB(e.props),_=g?n:p,b=g?r:h;if(o===`svg`||nB(p)?o=`svg`:(o===`mathml`||rB(p))&&(o=`mathml`),y?(f(e.dynamicChildren,y,_,i,a,o,s),bV(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):aB(t,n,r,l,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){let e=iB(t.props,m);e&&(t.target=e,aB(t,e,null,l,0))}else g&&aB(t,p,h,l,1);sB(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=tB(f),m=a||!p,h=Qz.get(e);if(h&&(h.flags|=8,Qz.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:aB,hydrate:oce};function aB(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),!Qz.has(e)&&(!d||tB(u))&&c&16)for(let e=0;e<l.length;e++)i(l[e],t,n,2);d&&r(s,t,n)}function oce(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=iB(t.props,c),h=tB(t.props);if(m){let c=m._lpa||m.firstChild;t.shapeFlag&16&&(h?(p(e,t),f(m,c),t.targetAnchor||cB(m,t,u,l,s(e)===m?e:null)):(t.anchor=o(e),f(m,c),t.targetAnchor||cB(m,t,u,l),d(c&&o(c),t,m,n,r,i,a))),sB(t,h)}else h&&t.shapeFlag&16&&(p(e,t),t.targetStart=e,t.targetAnchor=o(e));return t.anchor&&o(t.anchor)}var oB=ace;function sB(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 cB(e,t,n,r,i=null){let a=t.targetStart=n(``),o=t.targetAnchor=n(``);return a[$z]=o,e&&(r(a,e,i),r(o,e,i)),o}var lB=Symbol(`_leaveCb`),uB=Symbol(`_enterCb`);function sce(){let e={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return MB(()=>{e.isMounted=!0}),NB(()=>{e.isUnmounting=!0}),e}var dB=[Function,Array],fB={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:dB,onEnter:dB,onAfterEnter:dB,onEnterCancelled:dB,onBeforeLeave:dB,onLeave:dB,onAfterLeave:dB,onLeaveCancelled:dB,onBeforeAppear:dB,onAppear:dB,onAfterAppear:dB,onAppearCancelled:dB},pB=e=>{let t=e.subTree;return t.component?pB(t.component):t},cce={name:`BaseTransition`,props:fB,setup(e,{slots:t}){let n=qV(),r=sce();return()=>{let i=t.default&&bB(t.default(),!0),a=i&&i.length?mB(i):n.subTree?$():void 0;if(!a)return;let o=dz(e),{mode:s}=o;if(r.isLeaving)return _B(a);let c=vB(a);if(!c)return _B(a);let l=gB(c,o,r,n,e=>l=e);c.type!==DV&&yB(c,l);let u=n.subTree&&vB(n.subTree);if(u&&u.type!==DV&&!IV(u,c)&&pB(n).type!==DV){let e=gB(u,o,r,n);if(yB(u,e),s===`out-in`&&c.type!==DV)return r.isLeaving=!0,e.afterLeave=()=>{r.isLeaving=!1,n.job.flags&8||n.update(),delete e.afterLeave,u=void 0},_B(a);s===`in-out`&&c.type!==DV?e.delayLeave=(e,t,n)=>{let i=hB(r,u);i[String(u.key)]=u,e[lB]=()=>{t(),e[lB]=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 mB(e){let t=e[0];if(e.length>1){for(let n of e)if(n.type!==DV){t=n;break}}return t}var lce=cce;function hB(e,t){let{leavingVNodes:n}=e,r=n.get(t.type);return r||(r=Object.create(null),n.set(t.type,r)),r}function gB(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=hB(n,e),S=(e,t)=>{e&&Tz(e,r,9,t)},C=(e,t)=>{let n=t[1];S(e,t),SL(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[lB]&&t[lB](!0);let i=x[b];i&&IV(e,i)&&i.el[lB]&&i.el[lB](),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[uB]=e=>{s||(s=!0,S(e?o:i,[t]),w.delayedLeave&&w.delayedLeave(),t[uB]=void 0)};let c=t[uB].bind(null,!1);r?C(r,[t,c]):c()},leave(t,r){let i=String(e.key);if(t[uB]&&t[uB](!0),n.isUnmounting)return r();S(f,[t]);let a=!1;t[lB]=n=>{a||(a=!0,r(),S(n?h:m,[t]),t[lB]=void 0,x[i]===e&&delete x[i])};let o=t[lB].bind(null,!1);x[i]=e,p?C(p,[t,o]):o()},clone(e){let a=gB(e,t,n,r,i);return i&&i(a),a}};return w}function _B(e){if(OB(e))return e=BV(e),e.children=null,e}function vB(e){if(!OB(e))return eB(e.type)&&e.children?mB(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&&EL(n.default))return n.default()}}function yB(e,t){e.shapeFlag&6&&e.component?(e.transition=t,yB(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 bB(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===TV?(o.patchFlag&128&&i++,r=r.concat(bB(o.children,t,s))):(t||o.type!==DV)&&r.push(s==null?o:BV(o,{key:s}))}if(i>1)for(let e=0;e<r.length;e++)r[e].patchFlag=-2;return r}function xB(e,t){return EL(e)?vL({name:e.name},t,{setup:e}):e}function SB(e){e.ids=[e.ids[0]+e.ids[2]+++`-`,0,0]}function CB(e,t){let n;return!!((n=Object.getOwnPropertyDescriptor(e,t))&&!n.configurable)}var wB=new WeakMap;function TB(e,t,n,r,i=!1){if(SL(e)){e.forEach((e,a)=>TB(e,t&&(SL(t)?t[a]:t),n,r,i));return}if(DB(r)&&!i){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&TB(e,t,n,r.component.subTree);return}let a=r.shapeFlag&4?iH(r.component):r.el,o=i?null:a,{i:s,r:c}=e,l=t&&t.r,u=s.refs===fL?s.refs={}:s.refs,d=s.setupState,f=dz(d),p=d===fL?hL:e=>!CB(u,e)&&xL(f,e),m=(e,t)=>!(t&&CB(u,t));if(l!=null&&l!==c){if(EB(t),DL(l))u[l]=null,p(l)&&(d[l]=null);else if(mz(l)){let e=t;m(l,e.k)&&(l.value=null),e.k&&(u[e.k]=null)}}if(EL(c)){OR();try{wz(c,s,12,[o,u])}finally{kR()}}else{let t=DL(c),r=mz(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)SL(n)&&yL(n,a);else if(SL(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(),wB.delete(e)};t.id=-1,wB.set(e,t),_V(t,n)}else EB(e),s()}}}function EB(e){let t=wB.get(e);t&&(t.flags|=8,wB.delete(e))}XL().requestIdleCallback,XL().cancelIdleCallback;var DB=e=>!!e.type.__asyncLoader,OB=e=>e.type.__isKeepAlive;function uce(e,t){kB(e,`a`,t)}function dce(e,t){kB(e,`da`,t)}function kB(e,t,n=KV){let r=e.__wdc||=()=>{let t=n;for(;t;){if(t.isDeactivated)return;t=t.parent}return e()};if(AB(t,r,n),n){let e=n.parent;for(;e&&e.parent;)OB(e.parent.vnode)&&fce(r,t,n,e),e=e.parent}}function fce(e,t,n,r){let i=AB(t,e,r,!0);PB(()=>{yL(r[t],i)},n)}function AB(e,t,n=KV,r=!1){if(n){let i=n[e]||(n[e]=[]),a=t.__weh||=(...r)=>{OR();let i=XV(n),a=Tz(t,n,e,r);return i(),kR(),a};return r?i.unshift(a):i.push(a),a}}var jB=e=>(t,n=KV)=>{(!$V||e===`sp`)&&AB(e,(...e)=>t(...e),n)},pce=jB(`bm`),MB=jB(`m`),mce=jB(`bu`),hce=jB(`u`),NB=jB(`bum`),PB=jB(`um`),gce=jB(`sp`),_ce=jB(`rtg`),vce=jB(`rtc`);function yce(e,t=KV){AB(`ec`,e,t)}var bce=Symbol.for(`v-ndc`);function FB(e,t,n,r){let i,a=n&&n[r],o=SL(e);if(o||DL(e)){let n=o&&sz(e),r=!1,s=!1;n&&(r=!lz(e),s=cz(e),e=VR(e)),i=Array(e.length);for(let n=0,o=e.length;n<o;n++)i[n]=t(r?s?pz(fz(e[n])):fz(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(kL(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 IB(e,t,n={},r,i){if(Vz.ce||Vz.parent&&DB(Vz.parent)&&Vz.parent.ce){let e=Object.keys(n).length>0;return t!=="default"&&(n.name=t),X(),PV(TV,null,[zV(`slot`,n,r&&r())],e?-2:64)}let a=e[t];a&&a._c&&(a._d=!1),X();let o=a&&LB(a(n)),s=n.key||o&&o.key,c=PV(TV,{key:(s&&!OL(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 LB(e){return e.some(e=>!FV(e)||!(e.type===DV||e.type===TV&&!LB(e.children)))?e:null}var RB=e=>e?QV(e)?iH(e):RB(e.parent):null,zB=vL(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=>RB(e.parent),$root:e=>RB(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>GB(e),$forceUpdate:e=>e.f||=()=>{Fz(e.update)},$nextTick:e=>e.n||=Pz.bind(e.proxy),$watch:e=>rce.bind(e)}),BB=(e,t)=>e!==fL&&!e.__isScriptSetup&&xL(e,t),xce={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(BB(r,t))return o[t]=1,r[t];else if(i!==fL&&xL(i,t))return o[t]=2,i[t];else if(xL(a,t))return o[t]=3,a[t];else if(n!==fL&&xL(n,t))return o[t]=4,n[t];else HB&&(o[t]=0)}let l=zB[t],u,d;if(l)return t===`$attrs`&&RR(e.attrs,`get`,``),l(e);if((u=s.__cssModules)&&(u=u[t]))return u;if(n!==fL&&xL(n,t))return o[t]=4,n[t];if(d=c.config.globalProperties,xL(d,t))return d[t]},set({_:e},t,n){let{data:r,setupState:i,ctx:a}=e;return BB(i,t)?(i[t]=n,!0):r!==fL&&xL(r,t)?(r[t]=n,!0):xL(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!==fL&&s[0]!==`$`&&xL(e,s)||BB(t,s)||xL(a,s)||xL(r,s)||xL(zB,s)||xL(i.config.globalProperties,s)||(c=o.__cssModules)&&c[s])},defineProperty(e,t,n){return n.get==null?xL(n,`value`)&&this.set(e,t,n.value,null):e._.accessCache[t]=0,Reflect.defineProperty(e,t,n)}};function VB(e){return SL(e)?e.reduce((e,t)=>(e[t]=null,e),{}):e}var HB=!0;function Sce(e){let t=GB(e),n=e.proxy,r=e.ctx;HB=!1,t.beforeCreate&&UB(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:E,inheritAttrs:D,components:ee,directives:O,filters:k}=t;if(l&&Cce(l,r,null),o)for(let e in o){let t=o[e];EL(t)&&(r[e]=t.bind(n))}if(i){let t=i.call(n,n);kL(t)&&(e.data=iz(t))}if(HB=!0,a)for(let e in a){let t=a[e],i=aH({get:EL(t)?t.bind(n,n):EL(t.get)?t.get.bind(n,n):mL,set:!EL(t)&&EL(t.set)?t.set.bind(n):mL});Object.defineProperty(r,e,{enumerable:!0,configurable:!0,get:()=>i.value,set:e=>i.value=e})}if(s)for(let e in s)WB(s[e],r,n,e);if(c){let e=EL(c)?c.call(n):c;Reflect.ownKeys(e).forEach(t=>{qz(t,e[t])})}u&&UB(u,e,`c`);function te(e,t){SL(t)?t.forEach(t=>e(t.bind(n))):t&&e(t.bind(n))}if(te(pce,d),te(MB,f),te(mce,p),te(hce,m),te(uce,h),te(dce,g),te(yce,w),te(vce,S),te(_ce,C),te(NB,v),te(PB,b),te(gce,T),SL(E))if(E.length){let t=e.exposed||={};E.forEach(e=>{Object.defineProperty(t,e,{get:()=>n[e],set:t=>n[e]=t,enumerable:!0})})}else e.exposed||={};x&&e.render===mL&&(e.render=x),D!=null&&(e.inheritAttrs=D),ee&&(e.components=ee),O&&(e.directives=O),T&&SB(e)}function Cce(e,t,n=mL){SL(e)&&(e=JB(e));for(let n in e){let r=e[n],i;i=kL(r)?`default`in r?Jz(r.from||n,r.default,!0):Jz(r.from||n):Jz(r),mz(i)?Object.defineProperty(t,n,{enumerable:!0,configurable:!0,get:()=>i.value,set:e=>i.value=e}):t[n]=i}}function UB(e,t,n){Tz(SL(e)?e.map(e=>e.bind(t.proxy)):e.bind(t.proxy),t,n)}function WB(e,t,n,r){let i=r.includes(`.`)?Zz(n,r):()=>n[r];if(DL(e)){let n=t[e];EL(n)&&Yz(i,n)}else if(EL(e))Yz(i,e.bind(n));else if(kL(e))if(SL(e))e.forEach(e=>WB(e,t,n,r));else{let r=EL(e.handler)?e.handler.bind(n):t[e.handler];EL(r)&&Yz(i,r,e)}}function GB(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=>KB(c,e,o,!0)),KB(c,t,o)),kL(t)&&a.set(t,c),c}function KB(e,t,n,r=!1){let{mixins:i,extends:a}=t;a&&KB(e,a,n,!0),i&&i.forEach(t=>KB(e,t,n,!0));for(let i in t)if(!(r&&i===`expose`)){let r=wce[i]||n&&n[i];e[i]=r?r(e[i],t[i]):t[i]}return e}var wce={data:qB,props:ZB,emits:ZB,methods:XB,computed:XB,beforeCreate:YB,created:YB,beforeMount:YB,mounted:YB,beforeUpdate:YB,updated:YB,beforeDestroy:YB,beforeUnmount:YB,destroyed:YB,unmounted:YB,activated:YB,deactivated:YB,errorCaptured:YB,serverPrefetch:YB,components:XB,directives:XB,watch:Ece,provide:qB,inject:Tce};function qB(e,t){return t?e?function(){return vL(EL(e)?e.call(this,this):e,EL(t)?t.call(this,this):t)}:t:e}function Tce(e,t){return XB(JB(e),JB(t))}function JB(e){if(SL(e)){let t={};for(let n=0;n<e.length;n++)t[e[n]]=e[n];return t}return e}function YB(e,t){return e?[...new Set([].concat(e,t))]:t}function XB(e,t){return e?vL(Object.create(null),e,t):t}function ZB(e,t){return e?SL(e)&&SL(t)?[...new Set([...e,...t])]:vL(Object.create(null),VB(e),VB(t??{})):t}function Ece(e,t){if(!e)return t;if(!t)return e;let n=vL(Object.create(null),e);for(let r in t)n[r]=YB(e[r],t[r]);return n}function QB(){return{app:null,config:{isNativeTag:hL,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 Dce=0;function Oce(e,t){return function(n,r=null){EL(n)||(n=vL({},n)),r!=null&&!kL(r)&&(r=null);let i=QB(),a=new WeakSet,o=[],s=!1,c=i.app={_uid:Dce++,_component:n,_props:r,_container:null,_context:i,_instance:null,version:ale,get config(){return i.config},set config(e){},use(e,...t){return a.has(e)||(e&&EL(e.install)?(a.add(e),e.install(c,...t)):EL(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||zV(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,iH(u.component)}},onUnmount(e){o.push(e)},unmount(){s&&(Tz(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=$B;$B=c;try{return e()}finally{$B=t}}};return c}}var $B=null,kce=(e,t)=>t===`modelValue`||t===`model-value`?e.modelModifiers:e[`${t}Modifiers`]||e[`${zL(t)}Modifiers`]||e[`${VL(t)}Modifiers`];function Ace(e,t,...n){if(e.isUnmounted)return;let r=e.vnode.props||fL,i=n,a=t.startsWith(`update:`),o=a&&kce(r,t.slice(7));o&&(o.trim&&(i=n.map(e=>DL(e)?e.trim():e)),o.number&&(i=n.map(qL)));let s,c=r[s=UL(t)]||r[s=UL(zL(t))];!c&&a&&(c=r[s=UL(VL(t))]),c&&Tz(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,Tz(l,e,6,i)}}var jce=new WeakMap;function eV(e,t,n=!1){let r=n?jce:t.emitsCache,i=r.get(e);if(i!==void 0)return i;let a=e.emits,o={},s=!1;if(!EL(e)){let r=e=>{let n=eV(e,t,!0);n&&(s=!0,vL(o,n))};!n&&t.mixins.length&&t.mixins.forEach(r),e.extends&&r(e.extends),e.mixins&&e.mixins.forEach(r)}return!a&&!s?(kL(e)&&r.set(e,null),null):(SL(a)?a.forEach(e=>o[e]=null):vL(o,a),kL(e)&&r.set(e,o),o)}function tV(e,t){return!e||!gL(t)?!1:(t=t.slice(2),t=t===`Once`?t:t.replace(/Once$/,``),xL(e,t[0].toLowerCase()+t.slice(1))||xL(e,VL(t))||xL(e,t))}function nV(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=Uz(e),_,v;try{if(n.shapeFlag&4){let e=i||r,t=e;_=HV(l.call(t,e,u,d,p,f,m)),v=s}else{let e=t;_=HV(e.length>1?e(d,{attrs:s,slots:o,emit:c}):e(d,null)),v=t.props?s:Mce(s)}}catch(t){kV.length=0,Ez(t,e,1),_=zV(DV)}let y=_;if(v&&h!==!1){let e=Object.keys(v),{shapeFlag:t}=y;e.length&&t&7&&(a&&e.some(_L)&&(v=Nce(v,a)),y=BV(y,v,!1,!0))}return n.dirs&&(y=BV(y,null,!1,!0),y.dirs=y.dirs?y.dirs.concat(n.dirs):n.dirs),n.transition&&yB(y,n.transition),_=y,Uz(g),_}var Mce=e=>{let t;for(let n in e)(n===`class`||n===`style`||gL(n))&&((t||={})[n]=e[n]);return t},Nce=(e,t)=>{let n={};for(let r in e)(!_L(r)||!(r.slice(9)in t))&&(n[r]=e[r]);return n};function Pce(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?rV(r,o,l):!!o;if(c&8){let e=t.dynamicProps;for(let t=0;t<e.length;t++){let n=e[t];if(iV(o,r,n)&&!tV(l,n))return!0}}}else return(i||s)&&(!s||!s.$stable)?!0:r===o?!1:r?!o||rV(r,o,l):!!o;return!1}function rV(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(iV(t,e,a)&&!tV(n,a))return!0}return!1}function iV(e,t,n){let r=e[n],i=t[n];return n===`style`&&kL(r)&&kL(i)?!sR(r,i):r!==i}function Fce({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 aV={},oV=()=>Object.create(aV),sV=e=>Object.getPrototypeOf(e)===aV;function Ice(e,t,n,r=!1){let i={},a=oV();e.propsDefaults=Object.create(null),cV(e,t,i,a);for(let t in e.propsOptions[0])t in i||(i[t]=void 0);n?e.props=r?i:Wse(i):e.type.props?e.props=i:e.props=a,e.attrs=a}function Lce(e,t,n,r){let{props:i,attrs:a,vnode:{patchFlag:o}}=e,s=dz(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(tV(e.emitsOptions,o))continue;let u=t[o];if(c)if(xL(a,o))u!==a[o]&&(a[o]=u,l=!0);else{let t=zL(o);i[t]=lV(c,s,t,u,e,!1)}else u!==a[o]&&(a[o]=u,l=!0)}}}else{cV(e,t,i,a)&&(l=!0);let r;for(let a in s)(!t||!xL(t,a)&&((r=VL(a))===a||!xL(t,r)))&&(c?n&&(n[a]!==void 0||n[r]!==void 0)&&(i[a]=lV(c,s,a,void 0,e,!0)):delete i[a]);if(a!==s)for(let e in a)(!t||!xL(t,e))&&(delete a[e],l=!0)}l&&zR(e.attrs,`set`,``)}function cV(e,t,n,r){let[i,a]=e.propsOptions,o=!1,s;if(t)for(let c in t){if(IL(c))continue;let l=t[c],u;i&&xL(i,u=zL(c))?!a||!a.includes(u)?n[u]=l:(s||={})[u]=l:tV(e.emitsOptions,c)||(!(c in r)||l!==r[c])&&(r[c]=l,o=!0)}if(a){let t=dz(n),r=s||fL;for(let o=0;o<a.length;o++){let s=a[o];n[s]=lV(i,t,s,r[s],e,!xL(r,s))}}return o}function lV(e,t,n,r,i,a){let o=e[n];if(o!=null){let e=xL(o,`default`);if(e&&r===void 0){let e=o.default;if(o.type!==Function&&!o.skipFactory&&EL(e)){let{propsDefaults:a}=i;if(n in a)r=a[n];else{let o=XV(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===VL(n))&&(r=!0))}return r}var Rce=new WeakMap;function uV(e,t,n=!1){let r=n?Rce:t.propsCache,i=r.get(e);if(i)return i;let a=e.props,o={},s=[],c=!1;if(!EL(e)){let r=e=>{c=!0;let[n,r]=uV(e,t,!0);vL(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 kL(e)&&r.set(e,pL),pL;if(SL(a))for(let e=0;e<a.length;e++){let t=zL(a[e]);dV(t)&&(o[t]=fL)}else if(a)for(let e in a){let t=zL(e);if(dV(t)){let n=a[e],r=o[t]=SL(n)||EL(n)?{type:n}:vL({},n),i=r.type,c=!1,l=!0;if(SL(i))for(let e=0;e<i.length;++e){let t=i[e],n=EL(t)&&t.name;if(n===`Boolean`){c=!0;break}else n===`String`&&(l=!1)}else c=EL(i)&&i.name===`Boolean`;r[0]=c,r[1]=l,(c||xL(r,`default`))&&s.push(t)}}let l=[o,s];return kL(e)&&r.set(e,l),l}function dV(e){return e[0]!==`$`&&!IL(e)}var fV=e=>e===`_`||e===`_ctx`||e===`$stable`,pV=e=>SL(e)?e.map(HV):[HV(e)],zce=(e,t,n)=>{if(t._n)return t;let r=Wz((...e)=>pV(t(...e)),n);return r._c=!1,r},mV=(e,t,n)=>{let r=e._ctx;for(let n in e){if(fV(n))continue;let i=e[n];if(EL(i))t[n]=zce(n,i,r);else if(i!=null){let e=pV(i);t[n]=()=>e}}},hV=(e,t)=>{let n=pV(t);e.slots.default=()=>n},gV=(e,t,n)=>{for(let r in t)(n||!fV(r))&&(e[r]=t[r])},Bce=(e,t,n)=>{let r=e.slots=oV();if(e.vnode.shapeFlag&32){let e=t._;e?(gV(r,t,n),n&&KL(r,`_`,e,!0)):mV(t,r)}else t&&hV(e,t)},Vce=(e,t,n)=>{let{vnode:r,slots:i}=e,a=!0,o=fL;if(r.shapeFlag&32){let e=t._;e?n&&e===1?a=!1:gV(i,t,n):(a=!t.$stable,mV(t,i)),o=t}else t&&(hV(e,t),o={default:1});if(a)for(let e in i)!fV(e)&&o[e]==null&&delete i[e]},_V=Kce;function Hce(e){return Uce(e)}function Uce(e,t){let n=XL();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=mL,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&&!IV(e,t)&&(r=ue(e),ae(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 EV:g(e,t,n,r);break;case DV:_(e,t,n,r);break;case OV:e??v(t,n,r,o);break;case TV:ee(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?O(e,t,n,r,i,a,o,s,c):(d&64||d&128)&&l.process(e,t,n,r,i,a,o,s,c,N)}u!=null&&i?TB(u,e&&e.ref,a,t||e,!t):u==null&&e&&e.ref!=null&&TB(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,vV(e,c),l,d),_&&Kz(e,null,i,`created`),C(f,e,e.scopeId,l,i),m){for(let e in m)e!==`value`&&!IL(e)&&a(f,e,null,m[e],c,i);`value`in m&&a(f,`value`,null,m.value,c),(p=m.onVnodeBeforeMount)&&GV(p,i,e)}_&&Kz(e,null,i,`beforeMount`);let v=Wce(s,g);v&&g.beforeEnter(f),r(f,t,n),((p=m&&m.onVnodeMounted)||v||_)&&_V(()=>{try{p&&GV(p,i,e),v&&g.enter(f),_&&Kz(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||wV(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?UV(e[l]):HV(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||fL,m=t.props||fL,h;if(n&&yV(n,!1),(h=m.onVnodeBeforeUpdate)&&GV(h,n,t,e),f&&Kz(t,e,n,`beforeUpdate`),n&&yV(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?E(e.dynamicChildren,d,c,n,r,vV(t,i),o):s||j(e,t,c,null,n,r,vV(t,i),o,!1),l>0){if(l&16)D(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&&D(c,p,m,n,i);((h=m.onVnodeUpdated)||f)&&_V(()=>{h&&GV(h,n,t,e),f&&Kz(t,e,n,`updated`)},r)},E=(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===TV||!IV(c,l)||c.shapeFlag&198)?d(c.el):n;h(c,l,u,null,r,i,a,o,!0)}},D=(e,t,n,r,i)=>{if(t!==n){if(t!==fL)for(let o in t)!IL(o)&&!(o in n)&&a(e,o,t[o],null,i,r);for(let o in n){if(IL(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)}},ee=(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?(E(e.dynamicChildren,m,n,a,o,c,l),(t.key!=null||a&&t===a.subTree)&&bV(e,t,!0)):j(e,t,n,f,a,o,c,l,u)},O=(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):k(t,n,r,i,a,o,c):te(e,t,c)},k=(e,t,n,r,i,a,o)=>{let s=e.component=$ce(e,r,i);if(OB(e)&&(s.ctx.renderer=N),ele(s,!1,o),s.asyncDep){if(i&&i.registerDep(s,A,o),!e.el){let r=s.subTree=zV(DV);_(null,r,t,n),e.placeholder=r.el}}else A(s,e,t,n,i,a,o)},te=(e,t,n)=>{let r=t.component=e.component;if(Pce(e,t,n))if(r.asyncDep&&!r.asyncResolved){ne(r,t,n);return}else r.next=t,r.update();else t.el=e.el,r.vnode=t},A=(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=xV(e);if(n){t&&(t.el=c.el,ne(e,t,o)),n.asyncDep.then(()=>{_V(()=>{e.isUnmounted||l()},i)});return}}let u=t,f;yV(e,!1),t?(t.el=c.el,ne(e,t,o)):t=c,n&&GL(n),(f=t.props&&t.props.onVnodeBeforeUpdate)&&GV(f,s,t,c),yV(e,!0);let p=nV(e),m=e.subTree;e.subTree=p,h(m,p,d(m.el),ue(m),e,i,a),t.el=p.el,u===null&&Fce(e,p.el),r&&_V(r,i),(f=t.props&&t.props.onVnodeUpdated)&&_V(()=>GV(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=DB(t);if(yV(e,!1),l&&GL(l),!m&&(o=c&&c.onVnodeBeforeMount)&&GV(o,d,t),yV(e,!0),s&&me){let t=()=>{e.subTree=nV(e),me(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=nV(e);h(null,o,n,r,e,i,a),t.el=o.el}if(u&&_V(u,i),!m&&(o=c&&c.onVnodeMounted)){let e=t;_V(()=>GV(o,d,e),i)}(t.shapeFlag&256||d&&DB(d.vnode)&&d.vnode.shapeFlag&256)&&e.a&&_V(e.a,i),e.isMounted=!0,t=n=r=null}};e.scope.on();let c=e.effect=new mR(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=()=>Fz(u),yV(e,!0),l()},ne=(e,t,n)=>{t.component=e;let r=e.vnode.props;e.vnode=t,e.next=null,Lce(e,t.props,r,n),Vce(e,t.children,n),OR(),Lz(e),kR()},j=(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){M(l,f,n,r,i,a,o,s,c);return}else if(p&256){re(l,f,n,r,i,a,o,s,c);return}}m&8?(d&16&&le(l,i,a),f!==l&&u(n,f)):d&16?m&16?M(l,f,n,r,i,a,o,s,c):le(l,i,a,!0):(d&8&&u(n,``),m&16&&w(f,n,r,i,a,o,s,c))},re=(e,t,n,r,i,a,o,s,c)=>{e||=pL,t||=pL;let l=e.length,u=t.length,d=Math.min(l,u),f;for(f=0;f<d;f++){let r=t[f]=c?UV(t[f]):HV(t[f]);h(e[f],r,n,null,i,a,o,s,c)}l>u?le(e,i,a,!0,!1,d):w(t,n,r,i,a,o,s,c,d)},M=(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?UV(t[l]):HV(t[l]);if(IV(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?UV(t[f]):HV(t[f]);if(IV(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?UV(t[l]):HV(t[l]),n,d,i,a,o,s,c),l++}}else if(l>f)for(;l<=d;)ae(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?UV(t[l]):HV(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){ae(r,i,a,!0);continue}let u;if(r.key!=null)u=g.get(r.key);else for(_=m;_<=f;_++)if(S[_-m]===0&&IV(r,t[_])){u=_;break}u===void 0?ae(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?Gce(S):pL;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||CV(f):r;S[l]===0?h(null,d,n,p,i,a,o,s,c):b&&(_<0||l!==C[_]?ie(d,n,p,2):_--)}}},ie=(e,t,n,a,o=null)=>{let{el:s,type:c,transition:l,children:u,shapeFlag:d}=e;if(d&6){ie(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,N);return}if(c===TV){r(s,t,n);for(let e=0;e<u.length;e++)ie(u[e],t,n,a);r(e.anchor,t,n);return}if(c===OV){y(e,t,n);return}if(a!==2&&d&1&&l)if(a===0)l.persisted&&!s[lB]?r(s,t,n):(l.beforeEnter(s),r(s,t,n),_V(()=>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[lB];s._isLeaving&&s[lB](!0),l.persisted&&!e?u():a(s,()=>{u(),c&&c()})};o?o(s,u,d):d()}else r(s,t,n)},ae=(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&&(OR(),TB(s,null,n,e,!0),kR()),p!=null&&(t.renderCache[p]=void 0),u&256){t.ctx.deactivate(e);return}let h=u&1&&f,g=!DB(e),_;if(g&&(_=o&&o.onVnodeBeforeUnmount)&&GV(_,t,e),u&6)ce(e.component,n,r);else{if(u&128){e.suspense.unmount(n,r);return}h&&Kz(e,null,t,`beforeUnmount`),u&64?e.type.remove(e,t,n,N,r):l&&!l.hasOnce&&(a!==TV||d>0&&d&64)?le(l,t,n,!1,!0):(a===TV&&d&384||!i&&u&16)&&le(c,t,n),r&&oe(e)}let v=m!=null&&p==null;(g&&(_=o&&o.onVnodeUnmounted)||h||v)&&_V(()=>{_&&GV(_,t,e),h&&Kz(e,null,t,`unmounted`),v&&(e.el=null)},n)},oe=e=>{let{type:t,el:n,anchor:r,transition:a}=e;if(t===TV){se(n,r);return}if(t===OV){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()},se=(e,t)=>{let n;for(;e!==t;)n=f(e),i(e),e=n;i(t)},ce=(e,t,n)=>{let{bum:r,scope:i,job:a,subTree:o,um:s,m:c,a:l}=e;SV(c),SV(l),r&&GL(r),i.stop(),a&&(a.flags|=8,ae(o,e,t,n)),s&&_V(s,t),_V(()=>{e.isUnmounted=!0},t)},le=(e,t,n,r=!1,i=!1,a=0)=>{for(let o=a;o<e.length;o++)ae(e[o],t,n,r,i)},ue=e=>{if(e.shapeFlag&6)return ue(e.component.subTree);if(e.shapeFlag&128)return e.suspense.next();let t=f(e.anchor||e.el),n=t&&t[$z];return n?f(n):t},de=!1,fe=(e,t,n)=>{let r;e==null?t._vnode&&(ae(t._vnode,null,null,!0),r=t._vnode.component):h(t._vnode||null,e,t,null,null,null,n),t._vnode=e,de||=(de=!0,Lz(r),Rz(),!1)},N={p:h,um:ae,m:ie,r:oe,mt:k,mc:w,pc:j,pbc:E,n:ue,o:e},pe,me;return t&&([pe,me]=t(N)),{render:fe,hydrate:pe,createApp:Oce(fe,pe)}}function vV({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 yV({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function Wce(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function bV(e,t,n=!1){let r=e.children,i=t.children;if(SL(r)&&SL(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]=UV(i[e]),a.el=t.el),!n&&a.patchFlag!==-2&&bV(t,a)),a.type===EV&&(a.patchFlag===-1&&(a=i[e]=UV(a)),a.el=t.el),a.type===DV&&!a.el&&(a.el=t.el)}}function Gce(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 xV(e){let t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:xV(t)}function SV(e){if(e)for(let t=0;t<e.length;t++)e[t].flags|=8}function CV(e){if(e.placeholder)return e.placeholder;let t=e.component;return t?CV(t.subTree):null}var wV=e=>e.__isSuspense;function Kce(e,t){t&&t.pendingBranch?SL(e)?t.effects.push(...e):t.effects.push(e):ece(e)}var TV=Symbol.for(`v-fgt`),EV=Symbol.for(`v-txt`),DV=Symbol.for(`v-cmt`),OV=Symbol.for(`v-stc`),kV=[],AV=null;function X(e=!1){kV.push(AV=e?null:[])}function qce(){kV.pop(),AV=kV[kV.length-1]||null}var jV=1;function MV(e,t=!1){jV+=e,e<0&&AV&&t&&(AV.hasOnce=!0)}function NV(e){return e.dynamicChildren=jV>0?AV||pL:null,qce(),jV>0&&AV&&AV.push(e),e}function Z(e,t,n,r,i,a){return NV(Q(e,t,n,r,i,a,!0))}function PV(e,t,n,r,i){return NV(zV(e,t,n,r,i,!0))}function FV(e){return e?e.__v_isVNode===!0:!1}function IV(e,t){return e.type===t.type&&e.key===t.key}var LV=({key:e})=>e??null,RV=({ref:e,ref_key:t,ref_for:n})=>(typeof e==`number`&&(e=``+e),e==null?null:DL(e)||mz(e)||EL(e)?{i:Vz,r:e,k:t,f:!!n}:e);function Q(e,t=null,n=null,r=0,i=null,a=e===TV?0:1,o=!1,s=!1){let c={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&LV(t),ref:t&&RV(t),scopeId:Hz,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:Vz};return s?(WV(c,n),a&128&&e.normalize(c)):n&&(c.shapeFlag|=DL(n)?8:16),jV>0&&!o&&AV&&(c.patchFlag>0||a&6)&&c.patchFlag!==32&&AV.push(c),c}var zV=Jce;function Jce(e,t=null,n=null,r=0,i=null,a=!1){if((!e||e===bce)&&(e=DV),FV(e)){let r=BV(e,t,!0);return n&&WV(r,n),jV>0&&!a&&AV&&(r.shapeFlag&6?AV[AV.indexOf(e)]=r:AV.push(r)),r.patchFlag=-2,r}if(ile(e)&&(e=e.__vccOpts),t){t=Yce(t);let{class:e,style:n}=t;e&&!DL(e)&&(t.class=nR(e)),kL(n)&&(uz(n)&&!SL(n)&&(n=vL({},n)),t.style=ZL(n))}let o=DL(e)?1:wV(e)?128:eB(e)?64:kL(e)?4:EL(e)?2:0;return Q(e,t,n,r,i,o,a,!0)}function Yce(e){return e?uz(e)||sV(e)?vL({},e):e:null}function BV(e,t,n=!1,r=!1){let{props:i,ref:a,patchFlag:o,children:s,transition:c}=e,l=t?Xce(i||{},t):i,u={__v_isVNode:!0,__v_skip:!0,type:e.type,props:l,key:l&&LV(l),ref:t&&t.ref?n&&a?SL(a)?a.concat(RV(t)):[a,RV(t)]:RV(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!==TV?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&&BV(e.ssContent),ssFallback:e.ssFallback&&BV(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return c&&r&&yB(u,c.clone(u)),u}function VV(e=` `,t=0){return zV(EV,null,e,t)}function $(e=``,t=!1){return t?(X(),PV(DV,null,e)):zV(DV,null,e)}function HV(e){return e==null||typeof e==`boolean`?zV(DV):SL(e)?zV(TV,null,e.slice()):FV(e)?UV(e):zV(EV,null,String(e))}function UV(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:BV(e)}function WV(e,t){let n=0,{shapeFlag:r}=e;if(t==null)t=null;else if(SL(t))n=16;else if(typeof t==`object`)if(r&65){let n=t.default;n&&(n._c&&(n._d=!1),WV(e,n()),n._c&&(n._d=!0));return}else{n=32;let r=t._;!r&&!sV(t)?t._ctx=Vz:r===3&&Vz&&(Vz.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else if(EL(t)){if(r&65){WV(e,{default:t});return}t={default:t,_ctx:Vz},n=32}else t=String(t),r&64?(n=16,t=[VV(t)]):n=8;e.children=t,e.shapeFlag|=n}function Xce(...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=nR([t.class,r.class]));else if(e===`style`)t.style=ZL([t.style,r.style]);else if(gL(e)){let n=t[e],i=r[e];i&&n!==i&&!(SL(n)&&n.includes(i))?t[e]=n?[].concat(n,i):i:i==null&&n==null&&!_L(e)&&(t[e]=i)}else e!==``&&(t[e]=r[e])}return t}function GV(e,t,n,r=null){Tz(e,t,7,[n,r])}var Zce=QB(),Qce=0;function $ce(e,t,n){let r=e.type,i=(t?t.appContext:e.appContext)||Zce,a={uid:Qce++,vnode:e,type:r,parent:t,appContext:i,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new wse(!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:uV(r,i),emitsOptions:eV(r,i),emit:null,emitted:null,propsDefaults:fL,inheritAttrs:r.inheritAttrs,ctx:fL,data:fL,props:fL,attrs:fL,slots:fL,refs:fL,setupState:fL,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=Ace.bind(null,a),e.ce&&e.ce(a),a}var KV=null,qV=()=>KV||Vz,JV,YV;{let e=XL(),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)}};JV=t(`__VUE_INSTANCE_SETTERS__`,e=>KV=e),YV=t(`__VUE_SSR_SETTERS__`,e=>$V=e)}var XV=e=>{let t=KV;return JV(e),e.scope.on(),()=>{e.scope.off(),JV(t)}},ZV=()=>{KV&&KV.scope.off(),JV(null)};function QV(e){return e.vnode.shapeFlag&4}var $V=!1;function ele(e,t=!1,n=!1){t&&YV(t);let{props:r,children:i}=e.vnode,a=QV(e);Ice(e,r,a,t),Bce(e,i,n||t);let o=a?tle(e,t):void 0;return t&&YV(!1),o}function tle(e,t){let n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,xce);let{setup:r}=n;if(r){OR();let n=e.setupContext=r.length>1?rle(e):null,i=XV(e),a=wz(r,e,0,[e.props,n]),o=AL(a);if(kR(),i(),(o||e.sp)&&!DB(e)&&SB(e),o){if(a.then(ZV,ZV),t)return a.then(n=>{eH(e,n,t)}).catch(t=>{Ez(t,e,0)});e.asyncDep=a}else eH(e,a,t)}else rH(e,t)}function eH(e,t,n){EL(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:kL(t)&&(e.setupState=yz(t)),rH(e,n)}var tH,nH;function rH(e,t,n){let r=e.type;if(!e.render){if(!t&&tH&&!r.render){let t=r.template||GB(e).template;if(t){let{isCustomElement:n,compilerOptions:i}=e.appContext.config,{delimiters:a,compilerOptions:o}=r;r.render=tH(t,vL(vL({isCustomElement:n,delimiters:a},i),o))}}e.render=r.render||mL,nH&&nH(e)}{let t=XV(e);OR();try{Sce(e)}finally{kR(),t()}}}var nle={get(e,t){return RR(e,`get`,``),e[t]}};function rle(e){return{attrs:new Proxy(e.attrs,nle),slots:e.slots,emit:e.emit,expose:t=>{e.exposed=t||{}}}}function iH(e){return e.exposed?e.exposeProxy||=new Proxy(yz(Gse(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in zB)return zB[n](e)},has(e,t){return t in e||t in zB}}):e.proxy}function ile(e){return EL(e)&&`__vccOpts`in e}var aH=(e,t)=>Yse(e,t,$V);function oH(e,t,n){try{MV(-1);let r=arguments.length;return r===2?kL(t)&&!SL(t)?FV(t)?zV(e,null,[t]):zV(e,t):zV(e,null,t):(r>3?n=Array.prototype.slice.call(arguments,2):r===3&&FV(n)&&(n=[n]),zV(e,t,n))}finally{MV(1)}}var ale=`3.5.39`,sH=void 0,cH=typeof window<`u`&&window.trustedTypes;if(cH)try{sH=cH.createPolicy(`vue`,{createHTML:e=>e})}catch{}var lH=sH?e=>sH.createHTML(e):e=>e,ole=`http://www.w3.org/2000/svg`,sle=`http://www.w3.org/1998/Math/MathML`,uH=typeof document<`u`?document:null,dH=uH&&uH.createElement(`template`),cle={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`?uH.createElementNS(ole,e):t===`mathml`?uH.createElementNS(sle,e):n?uH.createElement(e,{is:n}):uH.createElement(e);return e===`select`&&r&&r.multiple!=null&&i.setAttribute(`multiple`,r.multiple),i},createText:e=>uH.createTextNode(e),createComment:e=>uH.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>uH.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{dH.innerHTML=lH(r===`svg`?`<svg>${e}</svg>`:r===`mathml`?`<math>${e}</math>`:e);let i=dH.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]}},fH=`transition`,pH=`animation`,mH=Symbol(`_vtc`),hH={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},lle=vL({},fB,hH),gH=(e=>(e.displayName=`Transition`,e.props=lle,e))((e,{slots:t})=>oH(lce,ule(e),t)),_H=(e,t=[])=>{SL(e)?e.forEach(e=>e(...t)):e&&e(...t)},vH=e=>e?SL(e)?e.some(e=>e.length>1):e.length>1:!1;function ule(e){let t={};for(let n in e)n in hH||(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=dle(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,xH(e,t?u:s),xH(e,t?l:o),n&&n()},E=(e,t)=>{e._isLeaving=!1,xH(e,d),xH(e,p),xH(e,f),t&&t()},D=e=>(t,n)=>{let i=e?C:v,o=()=>T(t,e,n);_H(i,[t,o]),SH(()=>{xH(t,e?c:a),bH(t,e?u:s),vH(i)||CH(t,r,h,o)})};return vL(t,{onBeforeEnter(e){_H(_,[e]),bH(e,a),bH(e,o)},onBeforeAppear(e){_H(S,[e]),bH(e,c),bH(e,l)},onEnter:D(!1),onAppear:D(!0),onLeave(e,t){e._isLeaving=!0;let n=()=>E(e,t);bH(e,d),e._enterCancelled?(bH(e,f),DH(e)):(DH(e),bH(e,f)),SH(()=>{e._isLeaving&&(xH(e,d),bH(e,p),vH(b)||CH(e,r,g,n))}),_H(b,[e,n])},onEnterCancelled(e){T(e,!1,void 0,!0),_H(y,[e])},onAppearCancelled(e){T(e,!0,void 0,!0),_H(w,[e])},onLeaveCancelled(e){E(e),_H(x,[e])}})}function dle(e){if(e==null)return null;if(kL(e))return[yH(e.enter),yH(e.leave)];{let t=yH(e);return[t,t]}}function yH(e){return JL(e)}function bH(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.add(t)),(e[mH]||(e[mH]=new Set)).add(t)}function xH(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.remove(t));let n=e[mH];n&&(n.delete(t),n.size||(e[mH]=void 0))}function SH(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}var fle=0;function CH(e,t,n,r){let i=e._endId=++fle,a=()=>{i===e._endId&&r()};if(n!=null)return setTimeout(a,n);let{type:o,timeout:s,propCount:c}=wH(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 wH(e,t){let n=window.getComputedStyle(e),r=e=>(n[e]||``).split(`, `),i=r(`${fH}Delay`),a=r(`${fH}Duration`),o=TH(i,a),s=r(`${pH}Delay`),c=r(`${pH}Duration`),l=TH(s,c),u=null,d=0,f=0;t===fH?o>0&&(u=fH,d=o,f=a.length):t===pH?l>0&&(u=pH,d=l,f=c.length):(d=Math.max(o,l),u=d>0?o>l?fH:pH:null,f=u?u===fH?a.length:c.length:0);let p=u===fH&&/\b(?:transform|all)(?:,|$)/.test(r(`${fH}Property`).toString());return{type:u,timeout:d,propCount:f,hasTransform:p}}function TH(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map((t,n)=>EH(t)+EH(e[n])))}function EH(e){return e===`auto`?0:Number(e.slice(0,-1).replace(`,`,`.`))*1e3}function DH(e){return(e?e.ownerDocument:document).body.offsetHeight}function OH(e,t,n){let r=e[mH];r&&(t=(t?[t,...r]:[...r]).join(` `)),t==null?e.removeAttribute(`class`):n?e.setAttribute(`class`,t):e.className=t}var kH=Symbol(`_vod`),AH=Symbol(`_vsh`),jH={name:`show`,beforeMount(e,{value:t},{transition:n}){e[kH]=e.style.display===`none`?``:e.style.display,n&&t?n.beforeEnter(e):MH(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),MH(e,!0),r.enter(e)):r.leave(e,()=>{MH(e,!1)}):MH(e,t))},beforeUnmount(e,{value:t}){MH(e,t)}};function MH(e,t){e.style.display=t?e[kH]:`none`,e[AH]=!t}var NH=Symbol(``),PH=/(?:^|;)\s*display\s*:/;function FH(e,t,n){let r=e.style,i=DL(n),a=!1;if(n&&!i){if(t)if(DL(t))for(let e of t.split(`;`)){let t=e.slice(0,e.indexOf(`:`)).trim();n[t]??LH(r,t,``)}else for(let e in t)n[e]??LH(r,e,``);for(let i in n){i===`display`&&(a=!0);let o=n[i];o==null?LH(r,i,``):VH(e,i,!DL(t)&&t?t[i]:void 0,o)||LH(r,i,o)}}else if(i){if(t!==n){let e=r[NH];e&&(n+=`;`+e),r.cssText=n,a=PH.test(n)}}else t&&e.removeAttribute(`style`);kH in e&&(e[kH]=a?r.display:``,e[AH]&&(r.display=`none`))}var IH=/\s*!important$/;function LH(e,t,n){if(SL(n))n.forEach(n=>LH(e,t,n));else if(n??=``,t.startsWith(`--`))e.setProperty(t,n);else{let r=BH(e,t);IH.test(n)?e.setProperty(VL(r),n.replace(IH,``),`important`):e[r]=n}}var RH=[`Webkit`,`Moz`,`ms`],zH={};function BH(e,t){let n=zH[t];if(n)return n;let r=zL(t);if(r!==`filter`&&r in e)return zH[t]=r;r=HL(r);for(let n=0;n<RH.length;n++){let i=RH[n]+r;if(i in e)return zH[t]=i}return t}function VH(e,t,n,r){return e.tagName===`TEXTAREA`&&(t===`width`||t===`height`)&&DL(r)&&n===r}var HH=`http://www.w3.org/1999/xlink`;function UH(e,t,n,r,i,a=iR(t)){r&&t.startsWith(`xlink:`)?n==null?e.removeAttributeNS(HH,t.slice(6,t.length)):e.setAttributeNS(HH,t,n):n==null||a&&!aR(n)?e.removeAttribute(t):e.setAttribute(t,a?``:OL(n)?String(n):n)}function WH(e,t,n,r,i){if(t===`innerHTML`||t===`textContent`){n!=null&&(e[t]=t===`innerHTML`?lH(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=aR(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 GH(e,t,n,r){e.addEventListener(t,n,r)}function KH(e,t,n,r){e.removeEventListener(t,n,r)}var qH=Symbol(`_vei`);function JH(e,t,n,r,i=null){let a=e[qH]||(e[qH]={}),o=a[t];if(r&&o)o.value=r;else{let[n,s]=ZH(t);r?GH(e,n,a[t]=tU(r,i),s):o&&(KH(e,n,o,s),a[t]=void 0)}}var YH=/(Once|Passive|Capture)$/,XH=/^on:?(?:Once|Passive|Capture)$/;function ZH(e){let t,n;for(;(n=e.match(YH))&&!XH.test(e);)t||={},e=e.slice(0,e.length-n[1].length),t[n[1].toLowerCase()]=!0;return[e[2]===`:`?e.slice(3):VL(e.slice(2)),t]}var QH=0,$H=Promise.resolve(),eU=()=>QH||=($H.then(()=>QH=0),Date.now());function tU(e,t){let n=e=>{if(!e._vts)e._vts=Date.now();else if(e._vts<=n.attached)return;let r=n.value;if(SL(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&&Tz(e,t,5,a)}}else Tz(r,t,5,[e])};return n.value=e,n.attached=eU(),n}var nU=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,rU=(e,t,n,r,i,a)=>{let o=i===`svg`;t===`class`?OH(e,r,o):t===`style`?FH(e,n,r):gL(t)?_L(t)||JH(e,t,n,r,a):(t[0]===`.`?(t=t.slice(1),!0):t[0]===`^`?(t=t.slice(1),!1):iU(e,t,r,o))?(WH(e,t,r),!e.tagName.includes(`-`)&&(t===`value`||t===`checked`||t===`selected`)&&UH(e,t,r,o,a,t!==`value`)):e._isVueCE&&(aU(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!DL(r)))?WH(e,zL(t),r,a,t):(t===`true-value`?e._trueValue=r:t===`false-value`&&(e._falseValue=r),UH(e,t,r,o))};function iU(e,t,n,r){if(r)return!!(t===`innerHTML`||t===`textContent`||t in e&&nU(t)&&EL(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 nU(t)&&DL(n)?!1:t in e}function aU(e,t){let n=e._def.props;if(!n)return!1;let r=zL(t);return Array.isArray(n)?n.some(e=>zL(e)===r):Object.keys(n).some(e=>zL(e)===r)}var oU=e=>{let t=e.props[`onUpdate:modelValue`]||!1;return SL(t)?e=>GL(t,e):t};function sU(e){e.target.composing=!0}function cU(e){let t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event(`input`)))}var lU=Symbol(`_assign`);function uU(e,t,n){return t&&(e=e.trim()),n&&(e=qL(e)),e}var dU={created(e,{modifiers:{lazy:t,trim:n,number:r}},i){e[lU]=oU(i);let a=r||i.props&&i.props.type===`number`;GH(e,t?`change`:`input`,t=>{t.target.composing||e[lU](uU(e.value,n,a))}),(n||a)&&GH(e,`change`,()=>{e.value=uU(e.value,n,a)}),t||(GH(e,`compositionstart`,sU),GH(e,`compositionend`,cU),GH(e,`change`,cU))},mounted(e,{value:t}){e.value=t??``},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[lU]=oU(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?qL(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)}},fU=[`ctrl`,`shift`,`alt`,`meta`],pU={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)=>fU.some(n=>e[`${n}Key`]&&!t.includes(n))},mU=(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=pU[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},hU={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},gU=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=VL(n.key);if(t.some(e=>e===r||hU[e]===r))return e(n)}))},_U=vL({patchProp:rU},cle),vU;function yU(){return vU||=Hce(_U)}var bU=((...e)=>{let t=yU().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=SU(e);if(!r)return;let i=t._component;!EL(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,xU(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a},t});function xU(e){if(e instanceof SVGElement)return`svg`;if(typeof MathMLElement==`function`&&e instanceof MathMLElement)return`mathml`}function SU(e){return DL(e)?document.querySelector(e):e}function CU(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 wU(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 TU(e,t){return CU({code:`SCHEMA_INVALID`,path:e,message:`值不符合 "${e}" 的 schema(${t.length} 处问题)`,hint:`用 read({jsonPath:"${e}"}) 查看当前值,按 describe_data() 查看主数据 schema,修正后重试;改大对象优先用 write 的 patch 增量(只发改动部分)`,details:wU(t)})}function EU(e,t,n){let r=n?.message||String(n),i=typeof t==`string`?t:JSON.stringify(t);return CU({code:`JSON_PARSE`,...e===void 0?{}:{path:e},message:`value 不是合法 JSON:${r}`,hint:`检查引号/逗号/括号是否闭合;字符串值需双引号包裹(如 '"dark"' 表示字符串 dark,数字直接写如 5);预览前 80 字符:${i.slice(0,80)}`})}function DU(e){return e.severity===`recoverable`?`feedback`:e.severity===`fatal`?`abort`:`log`}function OU(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 kU(e,t,n,r){return{severity:e,message:t,code:n,context:r}}var AU=20*1024*1024,jU=1568,MU=.85,NU=class extends Error{code;constructor(e,t){super(t),this.code=e}};function PU(){return`img_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function FU(e){let t=/^data:([^;,]+)(?:;charset=[^;,]+)?;base64,(.*)$/s.exec(e??``);return t?{mimeType:t[1],data:t[2]}:null}function IU(e,t,n){if(e<=0||t<=0)return{width:Math.max(1,Math.round(e)),height:Math.max(1,Math.round(t))};let r=Math.min(1,n/Math.max(e,t));return{width:Math.max(1,Math.round(e*r)),height:Math.max(1,Math.round(t*r))}}function LU(e,t,n=`openai`){let r=[{type:`text`,text:e??``}];for(let e of t)if(e.dataUri)if(n===`anthropic`){let t=FU(e.dataUri);if(!t)continue;r.push({type:`image`,source:{type:`base64`,media_type:t.mimeType,data:t.data}})}else r.push({type:`image_url`,image_url:{url:e.dataUri}});else e.url&&r.push(n===`anthropic`?{type:`image`,source:{type:`url`,url:e.url}}:{type:`image_url`,image_url:{url:e.url}});return r.length>1?r:null}function RU(e,t){let n=(t??[]).filter(e=>e.description);return n.length?`${e}\n\n${n.map((e,t)=>`[图片 ${t+1} 描述]\n${e.description}`).join(`
149
149
 
150
150
  `)}`:e}function zU(e){return{id:e.id,name:e.name,thumb:e.thumb,vfsRef:e.vfsRef,url:e.url,description:e.description,width:e.width,height:e.height}}function BU(e){return e.map(e=>e.images?.length?{...e,images:e.images.map(zU)}:e)}function VU(e,t){return e.map(e=>{if(!e.images?.length)return e;let n=e.images.map(e=>e.dataUri||e.url?e:{...e,dataUri:t(e.vfsRef??``)||void 0});return{...e,images:n}})}function HU(e,t,n){try{let r=e.getImageData(0,0,t,n).data;for(let e=0;e<n;e+=32)for(let n=0;n<t;n+=32)if(r[(e*t+n)*4+3]<250)return!0;return!1}catch{return!1}}function UU(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(new NU(`IMAGE_DECODE_FAILED`,`图片读取失败`)),r.readAsDataURL(e)})}async function WU(e,t={}){if(e.size>20971520)throw new NU(`IMAGE_TOO_LARGE`,`图片超过 ${Math.round(AU/1024/1024)}MB 上限`);let n=e.type||``;if(n&&!/^image\//i.test(n))throw new NU(`IMAGE_UNSUPPORTED_TYPE`,`不支持的文件类型:${n}`);let r=await GU(e),{width:i,height:a}=IU(r.width,r.height,jU),o=document.createElement(`canvas`);o.width=i,o.height=a;let s=o.getContext(`2d`);s.drawImage(r,0,0,i,a),`close`in r&&typeof r.close==`function`&&r.close();let c=(n===`image/png`||n===`image/gif`||n===`image/webp`)&&HU(s,i,a)?o.toDataURL(`image/png`):o.toDataURL(`image/jpeg`,MU);return{id:PU(),dataUri:c,name:t.name,width:i,height:a,bytes:Math.round(c.length*3/4)}}async function GU(e){if(typeof createImageBitmap==`function`&&e.type!==`image/svg+xml`)try{return await createImageBitmap(e)}catch{}return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new NU(`IMAGE_DECODE_FAILED`,`图片解码失败(损坏或不支持的格式)`)),UU(e).then(e=>{r.src=e},n)})}async function KU(e){let t=await new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new NU(`IMAGE_DECODE_FAILED`,`缩略图生成失败`)),r.src=e}),{width:n,height:r}=IU(t.naturalWidth||96,t.naturalHeight||96,96),i=document.createElement(`canvas`);return i.width=n,i.height=r,i.getContext(`2d`).drawImage(t,0,0,n,r),i.toDataURL(`image/jpeg`,.7)}function qU(e){return e.replace(/^\/+/,``).replace(/\/+/g,`/`)}function JU(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 YU(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}-${JU(e)}.txt`,r=qU(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(`
151
151
  `),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 XU(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 ZU=`__pgWatchdog`,QU=class extends Error{timedOutMs;constructor(e){super(`工具执行超过 ${e}ms 未返回(看门狗超时)`),this.name=`ToolTimeoutError`,this.timedOutMs=e}};function $U(e){for(let t of e)t&&typeof t==`object`&&`name`in t&&(t[ZU]=!0)}function eW(e,t){return t>0&&!!e&&typeof e==`object`&&e.__pgWatchdog===!0}async function tW(e,t){if(!(t>0))return e;let n,r=new Promise((e,r)=>{n=setTimeout(()=>r(new QU(t)),t)});try{return await Promise.race([e,r])}finally{n!==void 0&&clearTimeout(n),e.catch(()=>{})}}function nW(){return{messages:[],todos:[],files:{},skillsMetadata:[],skillsLoaded:[],memory:``,verifyAttempts:0}}function rW(e,t){return t?.aborted?!0:e?.name===`AbortError`}function iW(e,t){if(rW(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 aW(){let e=Error(`Aborted`);return e.name=`AbortError`,e}function oW(e,t){return new Promise((n,r)=>{if(t?.aborted){r(aW());return}let i=()=>{clearTimeout(a),r(aW())},a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n()},e);t?.addEventListener(`abort`,i,{once:!0})})}async function sW(e,t={}){let n=t.maxRetries??2,r=t.baseDelayMs??500,i=0;for(;;)try{return await e()}catch(e){if(rW(e,t.signal)||i>=n||!iW(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 oW(a,t.signal),i++}}var cW=class extends Error{waitedMs;constructor(e){super(`LLM 流停滞:${e}ms 无数据,已中断(可调 streamStallMs 放宽或设 0 关闭)`),this.name=`StreamStalledError`,this.waitedMs=e,this.status=408}},lW=class extends cW{constructor(e){super(e),this.name=`StreamMaxDurationError`,this.message=`LLM 流总时长超限:${e}ms(keepalive 空转黑洞特征:chunk 不断但无实质内容,可调 streamMaxDurationMs 放宽或设 0 关闭)`}},uW=9e4,dW=class extends Error{constructor(){super(`LLM 返回空响应:流正常结束但零内容(网关可能返回了错误体;已自动重试 1 次仍为空),请重发或稍后重试`),this.name=`EmptyLLMResponseError`,this.status=502}},fW=6e5;async function*pW(e,t,n){if(!(t>0)&&!(n>0)){yield*e;return}let r=e[Symbol.asyncIterator](),i=n>0?Date.now()+n:1/0;for(;;){let e=i-Date.now();if(e<=0)throw new lW(n);let a=Math.min(t>0?t:1/0,e),o,s=new Promise((e,r)=>{o=setTimeout(()=>r(Date.now()>=i?new lW(n):new cW(t)),a)}),c=r.next();c.catch(()=>{});let l;try{l=await Promise.race([c,s])}finally{clearTimeout(o)}if(l.done)return;yield l.value}}function mW(e){if(!e||typeof e!=`object`)return!1;try{if(qy.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 hW(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.lc_error_code===`MODEL_UNAVAILABLE`||t.code===`model_not_found`||t.code===`MODEL_UNAVAILABLE`||(t.status===400||t.status===404)&&typeof t.message==`string`&&/is offline|not support for model/i.test(t.message)}var gW=`该模型在当前网关不可用:换模型名后 setLlm 重试,或检查网关/服务方开放的模型面列表`;function _W(e){if(!hW(e))return!1;let t=e;try{t.code=`MODEL_UNAVAILABLE`,typeof t.message==`string`&&!t.message.includes(`该模型在当前网关不可用:换模型名后 setLlm 重试,或检查网关/服务方开放的模型面列表`)&&(t.message=`${t.message}(${gW})`)}catch{}return!0}function vW(e,t,n){if(!e||!n||n.status===`error`||t&&t.dryRun===!0)return!1;let r=`writeCapable`in e?e.writeCapable:void 0;if(!(typeof r==`function`?r(t??{}):r===!0))return!1;let i=String(n.content||``);return!(i.startsWith(`ERROR:`)||i.includes(`未写入`)||i.includes(`无需删除`))}function yW(e){let t=(t,n)=>{try{Object.defineProperty(e,t,{configurable:!1,writable:!1,value:n})}catch{}};if(t(`fetch`,()=>{throw Error(`fetch 已被沙箱禁用`)}),t(`XMLHttpRequest`,function(){throw Error(`XMLHttpRequest 已被沙箱禁用`)}),t(`importScripts`,()=>{throw Error(`importScripts 已被沙箱禁用`)}),t(`WebSocket`,function(){throw Error(`WebSocket 已被沙箱禁用`)}),t(`indexedDB`,void 0),t(`caches`,void 0),t(`Worker`,void 0),t(`SharedWorker`,void 0),t(`EventSource`,void 0),t(`BroadcastChannel`,void 0),e.navigator)try{Object.defineProperty(e.navigator,"sendBeacon",{configurable:!1,writable:!1,value:()=>{throw Error(`sendBeacon 已被沙箱禁用`)}})}catch{}}var bW=`(${yW.toString()})(self);`,xW=[{re:/\bimport\s*\(/,msg:`动态 import() 拉外网模块`},{re:/\bimport\s+[\w'"]/,msg:`import 语句`},{re:/\beval\s*\(/,msg:`eval() 动态执行`},{re:/\bFunction\s*\(/,msg:`Function() 构造`},{re:/new\s+Function\b/,msg:`new Function() 构造`},{re:/\brequire\s*\(/,msg:`require() 拉模块`},{re:/\bconstructor\s*\(/,msg:`沙箱脚本不允许原型链访问`},{re:/\bgetPrototypeOf\b/,msg:`沙箱脚本不允许原型链访问`},{re:/\.prototype\b/,msg:`沙箱脚本不允许原型链访问`},{re:/__proto__/,msg:`沙箱脚本不允许原型链访问`},{re:/\bReflect\b/,msg:`沙箱脚本不允许反射访问`}];function SW(e,t=3e3){return async n=>{for(let{re:t,msg:n}of xW)if(t.test(e))return{ok:!1,error:`沙箱拒绝执行:脚本含禁用模式(${n})`,elapsedMs:0};return new Promise(r=>{let i=Date.now(),a=!1,o=e=>{if(!a){a=!0,clearTimeout(u);try{l.terminate()}catch{}URL.revokeObjectURL(c),r({...e,elapsedMs:Date.now()-i})}},s=bW+`
@@ -172,7 +172,7 @@ self.onmessage = async (e) => {
172
172
  `),`请核实并处理:① 路径写错 → 用 update_todo 修正 evidence 为本次实际写入的 jsonPath;② 实际未完成 → 改回 pending 继续执行,不要谎报完成;③ 工作经委派子 agent 等未走主写路径完成 → 修正 evidence 为如实说明(不含路径样式文字)。`].join(`
173
173
  `)}function FG(e,t){return t?{...e,...t}:e}async function IG(e,t){let n=t;for(let t of e)t.beforeAgent&&(n=FG(n,await t.beforeAgent(n)));return n}function LG(e,t){let n=t.state;for(let r of e)r.beforeModel&&(n=FG(n,r.beforeModel({messages:t.messages,state:n})));return n}function RG(e,t,n){let r=n;for(let n=e.length-1;n>=0;n--){let i=e[n];i.afterModel&&(r=FG(r,i.afterModel(t,r)))}return r}async function zG(e,t){let n=t;for(let t=e.length-1;t>=0;t--){let r=e[t];r.afterAgent&&(n=FG(n,await r.afterAgent(n)))}return n}async function BG(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(`
174
174
 
175
- `):null}function VG(e,t){return e.reduceRight((e,t)=>n=>t.wrapModelCall?t.wrapModelCall(n,e):e(n),t)}function HG(e,t){return e.reduceRight((e,t)=>n=>t.wrapToolCall?t.wrapToolCall(n,e):e(n),t)}function UG(e){return e?/<|tool_calls|>|<||[^>]*tool_call|<||?DSML|<||?tool[_a-z]*|?>|<invoke\s+name=|<\/?tool_call>|<function_call>/i.test(e):!1}function WG(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 GG=/<|tool_calls|>|<||[^>]*tool_call|<||?DSML|<||?tool[_a-z]*|?>/i;function KG(e){return e.replace(/```[\w-]*\n?[\s\S]*?```/g,``)}function qG(e){if(!e||!UG(e))return null;let t=KG(e);if(!GG.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]]=JG(f[2].trim());l.push({id:`dsml_${e}_${Date.now().toString(36)}`,name:r[e].name,args:d})}return l.length?l:null}function JG(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 YG=30,XG=300,ZG=6e3;function QG(e,t){let n=e=>ZI(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 yx))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+=ZI(t)-ZI(n),new yx({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 $G(e,t){return t??Math.max(e*3,30)}function eK(e,t,n){if(t<=0||e<0)return``;let r=t-e;return r<=0?``:r<=2?`⚠️ 轮次预算告急:本轮任务已用 ${e}/${t} 轮工具调用,仅剩 ${r} 轮。立即停止扩展性操作(查询/重读/优化),完成手头最关键的一步写入或委派,然后用纯文本给出诚实结论:哪些已完成、哪些未做(用 update_todo 如实标记),用户可回复「继续」续跑。`:e>=Math.ceil(t*.7)?`⚠️ 轮次预算提醒:本轮任务已用 ${e}/${t} 轮工具调用,剩余 ${r} 轮。${n?`剩余任务多且重时,可并行分段委派(多个 spawn_agent 各带 writablePaths=段前缀,task 写明改动目标与验收),子 agent 过程隔离不占你的轮次与上下文;`:`剩余任务多且重时优先做最关键的部分;`}砍掉非必要的查询与重复读;若预估剩余步骤超出预算,先做最重要的部分并如实标记未完成项,不要等被打断。`:``}var tK=new Set([`write`,`draft_commit`]);function nK(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 rK(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=uW,streamMaxMs:g=fW,toolTimeoutMs:_,maxParallelTools:v=1,maxVerifyAttempts:y=0,roundTokenBudget:b=0,onLog:x,onLlmChange:S,imageContentFormat:C=`openai`,staleReadInvalidation:w=!0,debug:T=!1}=e,E=d??YG;(!Number.isFinite(E)||E<1)&&(console.warn(`[page-agent-sdk] maxToolRounds=${E} 非法(须 ≥1 正整数),已 clamp 到 1(0/负数致主循环 while 不进 → agent 不调 LLM 静默返回兜底文案)`),E=1);let D=XI({model:r,contextWindow:e.contextWindow,maxOutputTokens:e.maxOutputTokens,vision:e.vision}),ee=a??D.maxOutputTokens,O=QI(D.contextWindow),k=$I(D.contextWindow);function te(e){D=e,O=QI(D.contextWindow),k=$I(D.contextWindow)}let A=gz([]),ne=0,j=new Set;function re(e,t){let n={timestamp:Date.now(),type:e,data:t};A.value.push(n),A.value.length>XG&&A.value.splice(0,A.value.length-XG),vz(A),x?.(n),T&&console.log(`%c[Agent] ${e}`,`color:#667eea;font-weight:bold`,t)}let M=e=>{A.value.push(e),A.value.length>XG&&A.value.splice(0,A.value.length-XG),vz(A)},ie=[...u.flatMap(e=>e.tools||[]),...l],ae=e.llm??new II({apiKey:t,model:r,temperature:i,maxTokens:ee,configuration:{...n?{baseURL:rL(n)}:{},fetch:nL,...s},...o?{modelKwargs:o}:{}}),oe=ie.length>0?ae.bindTools?.(ie)??ae:ae,se=()=>{let e=ae;return(typeof e.model==`string`&&e.model?e.model:typeof e.modelName==`string`&&e.modelName?e.modelName:``)||r};function ce(){oe=ie.length>0?ae.bindTools?.(ie)??ae:ae}let le=nW();e.__pgIsSubagent&&(le.__pgIsSubagent=!0);let ue=.25,de=new Set([`mission`,`workingMemory`,`intentGuard`,`resumeNotice`]);function fe(){let e=c||`你是一个智能助手。`,t=[];for(let e of u)if(e.augmentPrompt){let n=e.augmentPrompt(le);n&&t.push({name:e.name,text:n,tokens:ZI(n),pin:de.has(e.name)})}let n=Math.max(2e3,Math.round(D.contextWindow*ue)),r=ZI(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,窗口 ${D.contextWindow} 的 ${ue*100}%),drop 非核心段:${i.join(`, `)}(保 base/mission/workingMemory)`)}return[e,...t.filter(e=>e.text).map(e=>e.text)].join(`
175
+ `):null}function VG(e,t){return e.reduceRight((e,t)=>n=>t.wrapModelCall?t.wrapModelCall(n,e):e(n),t)}function HG(e,t){return e.reduceRight((e,t)=>n=>t.wrapToolCall?t.wrapToolCall(n,e):e(n),t)}function UG(e){return e?/<|tool_calls|>|<||[^>]*tool_call|<||?DSML|<||?tool[_a-z]*|?>|<invoke\s+name=|<\/?tool_call>|<function_call>/i.test(e):!1}function WG(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 GG=/<|tool_calls|>|<||[^>]*tool_call|<||?DSML|<||?tool[_a-z]*|?>/i;function KG(e){return e.replace(/```[\w-]*\n?[\s\S]*?```/g,``)}function qG(e){if(!e||!UG(e))return null;let t=KG(e);if(!GG.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]]=JG(f[2].trim());l.push({id:`dsml_${e}_${Date.now().toString(36)}`,name:r[e].name,args:d})}return l.length?l:null}function JG(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 YG=30,XG=300,ZG=6e3;function QG(e,t){let n=e=>ZI(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 yx))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+=ZI(t)-ZI(n),new yx({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 $G(e,t){return t??Math.max(e*3,30)}function eK(e,t,n){if(t<=0||e<0)return``;let r=t-e;return r<=0?``:r<=2?`⚠️ 轮次预算告急:本轮任务已用 ${e}/${t} 轮工具调用,仅剩 ${r} 轮。立即停止扩展性操作(查询/重读/优化),完成手头最关键的一步写入或委派,然后用纯文本给出诚实结论:哪些已完成、哪些未做(用 update_todo 如实标记),用户可回复「继续」续跑。`:e>=Math.ceil(t*.7)?`⚠️ 轮次预算提醒:本轮任务已用 ${e}/${t} 轮工具调用,剩余 ${r} 轮。${n?`剩余任务多且重时,可并行分段委派(多个 spawn_agent 各带 writablePaths=段前缀,task 写明改动目标与验收),子 agent 过程隔离不占你的轮次与上下文;`:`剩余任务多且重时优先做最关键的部分;`}砍掉非必要的查询与重复读;若预估剩余步骤超出预算,先做最重要的部分并如实标记未完成项,不要等被打断。`:``}var tK=new Set([`write`,`draft_commit`]);function nK(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 rK(e){let{apiKey:t,baseUrl:n,model:r=`deepseek-v4-flash`,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=uW,streamMaxMs:g=fW,toolTimeoutMs:_,maxParallelTools:v=1,maxVerifyAttempts:y=0,roundTokenBudget:b=0,onLog:x,onLlmChange:S,imageContentFormat:C=`openai`,staleReadInvalidation:w=!0,debug:T=!1}=e,E=d??YG;(!Number.isFinite(E)||E<1)&&(console.warn(`[page-agent-sdk] maxToolRounds=${E} 非法(须 ≥1 正整数),已 clamp 到 1(0/负数致主循环 while 不进 → agent 不调 LLM 静默返回兜底文案)`),E=1);let D=XI({model:r,contextWindow:e.contextWindow,maxOutputTokens:e.maxOutputTokens,vision:e.vision}),ee=a??D.maxOutputTokens,O=QI(D.contextWindow),k=$I(D.contextWindow);function te(e){D=e,O=QI(D.contextWindow),k=$I(D.contextWindow)}let A=gz([]),ne=0,j=new Set;function re(e,t){let n={timestamp:Date.now(),type:e,data:t};A.value.push(n),A.value.length>XG&&A.value.splice(0,A.value.length-XG),vz(A),x?.(n),T&&console.log(`%c[Agent] ${e}`,`color:#667eea;font-weight:bold`,t)}let M=e=>{A.value.push(e),A.value.length>XG&&A.value.splice(0,A.value.length-XG),vz(A)},ie=[...u.flatMap(e=>e.tools||[]),...l],ae=e.llm??new II({apiKey:t,model:r,temperature:i,maxTokens:ee,configuration:{...n?{baseURL:rL(n)}:{},fetch:nL,...s},...o?{modelKwargs:o}:{}}),oe=ie.length>0?ae.bindTools?.(ie)??ae:ae,se=()=>{let e=ae;return(typeof e.model==`string`&&e.model?e.model:typeof e.modelName==`string`&&e.modelName?e.modelName:``)||r};function ce(){oe=ie.length>0?ae.bindTools?.(ie)??ae:ae}let le=nW();e.__pgIsSubagent&&(le.__pgIsSubagent=!0);let ue=.25,de=new Set([`mission`,`workingMemory`,`intentGuard`,`resumeNotice`]);function fe(){let e=c||`你是一个智能助手。`,t=[];for(let e of u)if(e.augmentPrompt){let n=e.augmentPrompt(le);n&&t.push({name:e.name,text:n,tokens:ZI(n),pin:de.has(e.name)})}let n=Math.max(2e3,Math.round(D.contextWindow*ue)),r=ZI(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,窗口 ${D.contextWindow} 的 ${ue*100}%),drop 非核心段:${i.join(`, `)}(保 base/mission/workingMemory)`)}return[e,...t.filter(e=>e.text).map(e=>e.text)].join(`
176
176
 
177
177
  `)}function N(e){let t=[new nS(fe())];for(let n of e)if(n.role===`user`){let e=D.vision&&n.images?.length?LU(n.content,n.images,C):null;e?t.push(new $x({content:e})):n.images?.some(e=>e.description)?t.push(new $x(RU(n.content,n.images))):t.push(new $x(n.content))}else n.role===`assistant`?t.push(new hS(n.content)):n.role===`system`&&t.push(new nS(n.content));return t}function pe(e,t){let n=e[0]&&ge(e[0])===`system`?e.slice(1):e.slice(),r=fe();return[new nS(t?`${r}\n\n${t}`:r),...n]}async function me(e,t,n,r){let i=r??oe,a={signal:n,maxRetries:p,baseDelayMs:m,onRetry:({attempt:e,error:t,waitMs:n})=>{let r=t?.message??String(t);re(`error`,{stage:`model_retry`,attempt:e,waitMs:n,error:r}),console.warn(`[Agent] 模型调用失败,第 ${e}/${p} 次重试(等 ${n}ms):${r}`)}},o=new AbortController;n&&(n.aborted?o.abort():n.addEventListener(`abort`,()=>o.abort(),{once:!0}));let s;try{let t;try{s=await sW(()=>{clearTimeout(t);let n=h>0?h:uW,r=i.stream(e.messages,{signal:o.signal});return h>0?Promise.race([r,new Promise((e,r)=>{t=setTimeout(()=>r(new cW(n)),n)})]):r},a)}finally{clearTimeout(t)}}catch(i){if(rW(i,n))return{message:new hS(``),toolCalls:[],content:``,aborted:!0};if(mW(i)&&!e._ctxRetry){e._ctxRetry=!0;let i=e=>ZI(typeof e.content==`string`?e.content:JSON.stringify(e.content)),a=e.messages.reduce((e,t)=>e+i(t),0),o=_e(e.messages,Math.round(D.contextWindow*.3)),s=o.reduce((e,t)=>e+i(t),0);return re(`error`,{stage:`context_overflow_retry`,at:`launch`,beforeTokens:a,afterTokens:s,window:D.contextWindow}),console.warn(`[page-agent-sdk] 上下文超限(启动)→ 激进 trim 重试:${a} → ${s} tokens`),me({...e,messages:o},t,n,r)}throw _W(i)&&re(`error`,{stage:`model_unavailable`,at:`launch`,status:i?.status}),i}if(!s)return{message:new hS(``),toolCalls:[],content:``,aborted:!0};let c=null,l=``;try{for await(let e of pW(s,h,g)){c=c?c.concat(e):e;let n=oL(e);n&&t&&(l+=n,t({type:`text`,delta:n}));let r=sL(e);r&&t&&t({type:`reasoning`,delta:r})}}catch(i){if(i instanceof cW)throw o.abort(),re(`error`,{stage:i instanceof lW?`stream_max_duration`:`stream_stalled`,waitedMs:i.waitedMs,stallMs:h,streamMaxMs:g}),i;if(rW(i,n))return{message:c??new hS(l),toolCalls:[],content:l,aborted:!0};if(mW(i)&&c===null&&l===``&&!e._ctxRetry){e._ctxRetry=!0;let i=e=>ZI(typeof e.content==`string`?e.content:JSON.stringify(e.content)),a=e.messages.reduce((e,t)=>e+i(t),0),o=_e(e.messages,Math.round(D.contextWindow*.3)),s=o.reduce((e,t)=>e+i(t),0);return re(`error`,{stage:`context_overflow_retry`,beforeTokens:a,afterTokens:s,window:D.contextWindow}),console.warn(`[page-agent-sdk] 上下文超限 → 激进 trim 重试:${a} → ${s} tokens(窗口 ${D.contextWindow})`),me({...e,messages:o},t,n,r)}throw _W(i)&&re(`error`,{stage:`model_unavailable`,at:`iterate`,status:i?.status}),i}if(c===null){if(!e._emptyRetry)return e._emptyRetry=!0,re(`error`,{stage:`empty_llm_response_retry`,hint:`流正常结束但零 chunk(网关 200+错误体形态),自动重试 1 次`}),me(e,t,n,r);throw re(`error`,{stage:`empty_llm_response`,retried:!0,hint:`重试后仍零 chunk,抛 EmptyLLMResponseError 显式报错`}),new dW}let u=c;return{message:u,toolCalls:u.tool_calls||[],content:l}}async function he(e){let t=ie.find(t=>t.name===e.name);if(!t){let t=ie.map(e=>e.name).filter(e=>!e.startsWith(`__`));return{content:`工具 "${e.name}" 不存在(当前上下文可用工具:${t.join(`, `)})`,status:`error`}}try{let n={__pgDataScope:``,...e.callConfig??{}},r=eW(t,_??12e4)?_??12e4:0,i;if(r>0)try{i=await tW(Promise.resolve().then(()=>t.invoke(e.args,{configurable:n})),r)}catch(t){if(t instanceof QU)return re(`error`,{stage:`tool_timeout`,name:e.name,timeoutMs:r,hint:`集成方工具超时,看门狗兜底(底层调用无法取消,可能仍在后台执行)`}),{content:`工具执行超时:${e.name} 超过 ${r}ms 未返回,已放弃等待。该工具可能卡住(底层调用无法取消,或仍在后台执行),请勿原样重试;请改用其他方式完成,或向用户如实说明该工具当前不可用。`,status:`error`};throw t}else i=await t.invoke(e.args,{configurable:n});let a=typeof i==`string`?i:JSON.stringify(i),o=ie.some(e=>e.name===`vfs_read`);return a=YU(a,{files:e.state.files,vfsAvailable:!!e.state.files&&o,toolName:e.name,threshold:O,passThroughChars:k}).content,{content:a,status:`done`}}catch(e){return{content:`工具执行出错:${OU(e,`recoverable`).message}`,status:`error`}}}function ge(e){return e instanceof $x?`human`:e instanceof hS?`ai`:e instanceof nS?`system`:e instanceof yx?`tool`:`unknown`}function _e(e,t){return QG(e,t)}function P(e){return!T&&!x?[]:e.map(e=>{let t=ge(e),n={role:t===`human`?`user`:t===`ai`?`assistant`:t},r=typeof e.content==`string`?e.content:JSON.stringify(e.content);r&&(n.content=r.length>ZG?r.slice(0,ZG)+`…(截断 ${r.length-ZG} 字符)`:r);let i=e.tool_calls;Array.isArray(i)&&i.length&&(n.tool_calls=i.map(e=>({id:e.id,type:`function`,function:{name:e.name,arguments:typeof e.args==`string`?e.args:JSON.stringify(e.args)}})));let a=e.tool_call_id;return a&&(n.tool_call_id=a),n})}async function ve(t,n,r){le=nW(),e.__pgIsSubagent&&(le.__pgIsSubagent=!0),le.messages=t,le=await IG(u,le);let i=t;for(let e of u)if(e.compressInput){let t=await e.compressInput(i);i=Array.isArray(t)?t:t.messages,t&&!Array.isArray(t)&&t.stats&&(le={...le,lastCompression:t.stats})}{let e=ZI(c||`你是一个智能助手。`),t=Math.max(2e3,Math.round(D.contextWindow*ue));if(e>t){let r=`[page-agent-sdk] systemPrompt 本身(${e} tokens)超过系统段预算(${t} tokens,窗口 ${D.contextWindow} 的 ${ue*100}%);请缩减 systemPrompt 或换更大窗口模型`;return console.error(r),n({type:`error`,message:r,severity:`fatal`,code:`SYSTEM_PROMPT_OVER_BUDGET`}),n({type:`done`,content:``}),``}}let a=N(i);re(`context`,{model:se(),tools:ie.map(e=>e.name),middleware:u.map(e=>e.name)});let o=VG(u,e=>me(e,n,r)),s=HG(u,he),l={rounds:0,maxToolRounds:E,invokeUsage:{prompt_tokens:0,completion_tokens:0,total_tokens:0},writeFailures:{},budgetHinted:!1};le.loopProgress=l;let d={counts:{},writePaths:[],failures:0},p=DG(),m=new Map((le.todos??[]).map(e=>[e.id,{status:e.status,content:e.content}])),h=new Map,g=0,_=e=>{let t=ie.find(t=>t.name===e);return t&&`writeCapable`in t?typeof t.writeCapable==`function`||t.writeCapable===!0:tK.has(e)},x=0,S=0,C=$G(E,f),T=null,ee=0,O=!1,k=!1;try{for(;(x<E||k)&&S<C&&(S++,!r?.aborted);){if(b>0&&l.invokeUsage.total_tokens>b){let e=`本轮 token 预算(约 ${b})已用尽:任务在 ${x} 轮工具调用后中断,已完成的部分均保留。可继续对话,指定下一步(如「继续完成」/「只改 X」/「提高预算重试」)。`;return re(`error`,{stage:`round_token_budget_exceeded`,used:l.invokeUsage.total_tokens,budget:b,rounds:x}),n({type:`error`,message:e,severity:`observable`,code:`ROUND_TOKEN_BUDGET_EXCEEDED`,context:{used:l.invokeUsage.total_tokens,budget:b}}),n({type:`done`,content:e}),e}n({type:`round_start`,round:S}),le=LG(u,{messages:a,state:le}),a=pe(a,eK(x,E,e.hasSubagent)),a=_e(a,Math.round(D.contextWindow*.6)),re(`llm_request`,{round:x+1,model:se(),tools:ie.map(e=>e.name),messages:P(a)});let t=await o({messages:a,state:le});a.push(t.message);let i=uL(t.message);if(re(`llm_response`,{round:x+1,content:t.content,toolCalls:t.toolCalls,...i?{usage:i}:{}}),i&&(l.invokeUsage.prompt_tokens+=i.prompt_tokens??0,l.invokeUsage.completion_tokens+=i.completion_tokens??0,l.invokeUsage.total_tokens+=i.total_tokens??0),le=RG(u,t,le),t.aborted)return n({type:`done`,content:t.content}),t.content;if(!t.toolCalls.length){{let e=t.message?.response_metadata??t.message?.responseMetadata,n=e?.stop_reason??e?.finish_reason,r=uL(t.message);if((n===`length`||!t.content&&(r?.completion_tokens??0)>=4e3)&&!O){O=!0,k=!0,re(`error`,{stage:`completion_truncated_retry`,completionTokens:r?.completion_tokens,stopReason:n??null,hint:`空输出且 completion 达上限,疑似 max_tokens 截断;回灌分步写入指引`}),a.push(new $x(`⚠️ 你上一轮输出为空(疑似被 max_tokens 截断:单次输出过长,常见于把完整大段代码塞进一次工具调用参数)。请改用分步方式:① 先用工具写入小体积骨架/占位结构,② 再逐步用增量工具调用补充内容;或大幅精简单次输出。不要一次性输出完整大段内容。`));continue}}let e=UG(t.content),r=e?qG(t.content):null;if(r&&r.length){t.toolCalls=r;let e=t.message;e&&(e.tool_calls=r.map(e=>({id:e.id,name:e.name,args:e.args,type:`tool_call`}))),re(`middleware`,{stage:`dsml_parsed`,count:r.length,names:r.map(e=>e.name)})}else{if(e&&ee<2){ee+=1,k=!0,re(`middleware`,{stage:`format_retry`,attempt:ee,content:t.content.slice(0,200)}),a.push(new $x(`⚠️ 你刚才把工具调用写成了文本(伪 XML/标签/DSML 标记,如 <|tool_calls|>、<||DSML||>、<invoke name=...>),未被系统识别为工具调用,因此未执行,页面无变化。请直接用标准 function calling(工具调用)格式重新发起工具调用,不要在回复正文里输出这些标签或 JSON 文本。`));continue}e&&(re(`error`,{stage:`garbled_exhausted`,retries:ee,content:t.content.slice(0,200)}),n({type:`error`,message:`模型连续 2 次输出无法解析的工具调用格式(DSML/伪标签),任务可能未完成。请重试或换模型。`,severity:`observable`,code:`GARBLED_TOOL_CALL_EXHAUSTED`,context:{content:t.content.slice(0,200)}}));let r=MG({state:p,garbled:e,rounds:x,finalContent:t.content,todos:le.todos,isSubagent:!!le.__pgIsSubagent,turnUsage:d,isWriteToolByName:_,messages:a,sessionWritePaths:j,todosStatusAtStart:m});if(r?.kind===`feedback`){k=!0,re(`middleware`,{stage:r.gate.stage,attempt:r.gate.attempt,...r.gate.logData??{},content:t.content.slice(0,160)}),a.push(new $x(r.gate.feedback));continue}if(r?.kind===`observable`&&n({type:`error`,message:r.obs.message,severity:`observable`,code:r.obs.code,context:r.obs.context}),!e&&y>0&&le.verifyAttempts<y){let e=await BG(u,{messages:a,state:le,response:t,log:(e,t)=>re(e,t)});if(e){T=t.content,le.verifyAttempts+=1,a.push(new $x(`⚠️ 验证未通过,请修正:${e}`)),re(`middleware`,{stage:`verify_retry`,attempt:le.verifyAttempts,feedback:e});continue}}k=!1;let i=t.content;if(e){let e=WG(i);i=e?`${e}\n\n(注:此后模型输出了无法解析的工具调用文本,该调用未执行,任务可能未完成。)`:`模型多次输出无法解析的工具调用格式,本次任务可能未完成。请重试或继续指示。`}return n({type:`done`,content:i}),i}}k=!1;let c=t.toolCalls,f=c.map(e=>{let t=e.id||`call_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return{id:t,call:e,ctx:{id:t,name:e.name,args:e.args,state:le,signal:r,emit:n,logSink:M}}});if(c.some(e=>!e.id)){let e=t.message;e?.tool_calls&&(e.tool_calls=e.tool_calls.map((e,t)=>e&&e.id?e:{...e,id:f[t]?.id,type:e?.type??`tool_call`}))}let C=await XU(f,v,async e=>{if(r?.aborted)return;let t=Date.now();n({type:`tool_call`,name:e.call.name,args:e.call.args,id:e.id}),re(`tool_call`,{round:x+1,name:e.call.name,args:e.call.args,id:e.id});let i;try{i=await s(e.ctx)}catch(e){if(rW(e,r))throw e;i={content:`工具执行出错:${OU(e,`recoverable`).message}`,status:`error`}}let a=Date.now()-t;return n({type:`tool_result`,name:e.call.name,result:i.content,status:i.status,durationMs:a,id:e.id}),re(`tool_result`,{round:x+1,name:e.call.name,result:i.content,status:i.status,durationMs:a}),i},r);for(let e=0;e<f.length;e++){let t=C[e];if(!t)continue;let n=e=>e&&typeof e==`object`&&!Array.isArray(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,n(e[t])])):e,r=`${f[e].call.name}|${JSON.stringify(n(f[e].call.args??{}))}`,i=t.status===`error`||typeof t.content==`string`&&t.content.startsWith(`ERROR:`),o=t.content;if(i){let e=(h.get(r)??0)+1;h.set(r,e),e>=2&&(o=`${t.content}\n(提示:同参数已连续失败 ${e} 次,原样重试大概率仍失败;请检查参数/换路径/换方法,或向用户如实说明困难)`)}else h.delete(r);if(f[e].call.name===`read`&&!i){let t=f[e].call.args??{};t.jsonPath&&!t.jsonPaths?.length?(g++,g>=2&&(o=`${o}\n(提示:还需读多个路径时,用 read({jsonPaths:["路径1","路径2",…]}) 一次取回省轮次;多路径单项标错不整批失败)`)):t.jsonPaths?.length&&(g=0)}a.push(new yx({tool_call_id:f[e].id,content:o}))}for(let e=0;e<f.length;e++){let t=C[e];if(!t||!tK.has(f[e].call.name))continue;let n=nK(f[e].call.args);t.status===`error`?l.writeFailures[n]=(l.writeFailures[n]??0)+1:delete l.writeFailures[n]}let te=[];for(let e=0;e<f.length;e++){let t=C[e];if(!t)continue;let n=f[e].call.name;if(d.counts[n]=(d.counts[n]??0)+1,t.status===`error`&&(d.failures+=1),vW(ie.find(e=>e.name===n),f[e].call.args,t)){let t=nK(f[e].call.args);d.writePaths.push(t||`(整体)`),te.push({name:n,args:f[e].call.args,callIndex:e});let r=JW({name:n,args:f[e].call.args,callIndex:e});if(r)for(let e of r.paths)j.add(e)}}if(w&&te.length){let e=XW(a,te,{round:x+1,maxParallelTools:v});e.invalidatedCount>0&&(a=e.messages,ne+=e.invalidatedCount,re(`middleware`,{stage:`stale_read_invalidated`,round:x+1,writtenPaths:te.map(e=>nK(e.args)||`(整体)`),invalidatedCount:e.invalidatedCount}))}if(r?.aborted)break;x++,l.rounds=x}if(r?.aborted)return n({type:`done`,content:``}),``;let t=`\n\n(提示:工具调用次数已达上限(${E} 轮 / ${C} 次迭代),以上为基于已完成操作的阶段性结果,任务可能未完成。回复「继续」或告诉我下一步重点,即可接着做。)`;re(`error`,{stage:`react_call_limit_exceeded`,rounds:x,maxToolRounds:E,iterations:S,maxIterations:C}),n({type:`error`,message:`ReAct 循环达到调用上限(rounds=${x}/${E},iterations=${S}/${C}),已强制收口,可回复「继续」。`,severity:`observable`,code:`REACT_CALL_LIMIT_EXCEEDED`,context:{rounds:x,maxToolRounds:E,iterations:S,maxIterations:C}});let i=NG(le.todos??[],m,j);if(i.length){let e=i.map(e=>({id:e.id,evidence:e.evidence}));re(`middleware`,{stage:`evidence_audit_flagged`,offenders:e}),n({type:`error`,message:`轮次耗尽收口:${i.length} 项已完成任务的 evidence 路径与写入记录不符,最终回复中的完成声明可能不实`,severity:`observable`,code:`AUDIT_EVIDENCE_SUSPECT`,context:{offenders:e}})}if(T!=null){let e=T+t;return n({type:`done`,content:e}),e}let c=a[a.length-1];if(c&&ge(c)===`tool`){let e=a[0]&&ge(a[0])===`system`?a.slice(1):a.slice(),i=[new nS(fe()+`
178
178
 
@@ -189,8 +189,8 @@ self.onmessage = async (e) => {
189
189
  提示:改某组件深层字段前,先 schema_data({jsonPath}) 查完整约束;或 read 子路径见实际值。`}return n}return e?.description||`(用 read 查看实际形状)`}var HK=/(?:改|加|删|生成|查询|分析|创建|修改|配置|实现|检查|对比|整理|转换|设计|搭建|编排|布局|调整|更新)/;function UK(e){return!e||e.trim().length<8||/^(你好|hi|hello|ok|好的|继续|嗯|谢谢|hey|哈喽|收到|明白)/i.test(e.trim())||e.length>2e3?!1:HK.test(e)}function WK(e){for(let t=0;t<e.length;t++){if(e[t].role!==`user`)continue;let n=e[t].content;if(UK(n))return{goal:n.length>200?n.slice(0,200)+`…`:n,sourceMessageIdx:t,capturedAt:Date.now(),explicit:!1}}}function GK(){let e,t=!1;return{name:`mission`,beforeAgent:n=>(!e&&!t&&(e=WK(n.messages)),e?{mission:e}:{}),augmentPrompt:()=>{if(!e)return;let t=[`## 当前主线目标`,e.goal];return e.acceptanceCriteria?.length&&(t.push(`完成标准:`),e.acceptanceCriteria.forEach((e,n)=>t.push(`${n+1}. ${e}`))),t.push(`(每步操作应服务此目标;偏离时回到主线)`),t.join(`
190
190
  `)},setMission:n=>{if(Object.keys(n).length===0){e=void 0,t=!0;return}t=!1,e={goal:n.goal??e?.goal??``,acceptanceCriteria:n.acceptanceCriteria??e?.acceptanceCriteria,sourceMessageIdx:n.sourceMessageIdx??e?.sourceMessageIdx??-1,capturedAt:n.capturedAt??e?.capturedAt??Date.now(),explicit:n.explicit??!0}},getMission:()=>e,reset:()=>{e=void 0,t=!1}}}var KK=/(为什么|为啥|多少|几个|能不能|可不可以|是否|有没有|怎样|咋)/,qK=/(是什么|是啥|怎么用|如何用|有哪些|什么意思|干嘛的|干什么用)/,JK=/(吗|呢)[??]?\s*$/;function YK(e){let t=(e||``).trim();return t?!!(/[??]\s*$/.test(t)||qK.test(t)||KK.test(t)&&JK.test(t)):!1}var XK=[`[本轮消息为咨询] 用户最新消息是提问/咨询,不是操作指令。`,`请先作答:用 read / query / search / list_components / rag 等工具查证后基于事实回答,不要凭空猜测。`,`不要执行生成/修改/删除操作 —— 除非用户在同一条消息里同时明确提出了操作要求(如「顺便把 X 改成 Y」)。`].join(`
191
191
  `);function ZK(e){let t=null;return{name:`intentGuard`,augmentPrompt:n=>{for(let r=n.messages.length-1;r>=0;r--){let i=n.messages[r];if(i.role===`user`)return YK(i.content)?(e&&t!==i.content&&(t=i.content,e(i.content.slice(0,60))),XK):void 0}}}}var QK=[`[本会话从历史记录恢复] 你不在场期间,宿主页面数据可能已发生变化:`,`- 页面刷新可能使数据回退到上次保存的状态(未保存的修改已不存在);用户或宿主也可能改动过数据。`,`- 历史对话与已完成的任务记录不代表当前实际数据。`,`纪律:断言「已生成/已存在/已完成」前,先用 read / list_components 等工具核实当前状态;`,`用户要求重做历史工作(如「重新生成」)时,先核实缺失了哪些部分,再补齐或重做,勿直接回复「已完成/完毕」。`].join(`
192
- `);function $K(e){let t=!1,n=!1;return{name:`resumeNotice`,markResumed:()=>{t=!0,n=!1},reset:()=>{t=!1,n=!1},isPending:()=>t,augmentPrompt:()=>{if(t)return e&&!n&&(n=!0,e()),QK},afterAgent:()=>{t=!1}}}var eq=new Set([`__proto__`,`constructor`,`prototype`]);function tq(e){return e.split(`.`).some(e=>eq.has(e))}function nq(e,t){if(!(!t||typeof t!=`object`||Array.isArray(t)))for(let n of Object.keys(t))eq.has(n)||(e[n]=t[n])}function rq(e,t){if(!t)return e;if(tq(t))return;let n=t.split(`.`),r=e;for(let e of n){if(r==null)return;r=r[e]}return r}function iq(e,t,n){if(!t||tq(t))return;let r=t.split(`.`),i=e;for(let e=0;e<r.length-1;e++){let t=r[e];(i[t]==null||typeof i[t]!=`object`)&&(i[t]={}),i=i[t]}i[r[r.length-1]]=n}function aq(e,t){if(!t||tq(t))return!1;let n=t.split(`.`),r=e;for(let e=0;e<n.length-1;e++){if(r==null)return!1;r=r[n[e]]}let i=n[n.length-1];return r==null||!(i in r)?!1:(Array.isArray(r)&&/^\d+$/.test(i)?r.splice(Number(i),1):delete r[i],!0)}function oq(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch(t){let n=sq(e);throw n?Error(`数据存在循环引用(${n});数据槽/快照不支持环形结构,请检查宿主 bind 或写入值`):t}}function sq(e){let t=new WeakSet,n=(e,r)=>{if(typeof e!=`object`||!e)return;let i=e;if(t.has(i))return r;if(t.add(i),Array.isArray(e))for(let t=0;t<e.length;t++){let i=n(e[t],`${r}[${t}]`);if(i)return i}else for(let t of Object.keys(e)){let i=n(e[t],`${r}.${t}`);if(i)return i}t.delete(i)};return n(e,`$`)}function cq(e){if(typeof e!=`string`)return{parsed:e};let t=e.trim();if(!t)return{parsed:e};let n=t[0]===`{`||t[0]===`[`;try{return{parsed:JSON.parse(t)}}catch(t){return n?{parseError:t}:{parsed:e}}}function lq(e,t){if(typeof e!=`object`||!e)return e;let n=new Set(t);if(Array.isArray(e))return e.map(e=>lq(e,t));let r={};for(let t of Object.keys(e))n.has(t)&&(r[t]=e[t]);return r}function uq(e,t){if(typeof e!=`object`||!e)return e;if(t<=0)return Array.isArray(e)?`[...${e.length}]`:`{...}`;if(Array.isArray(e))return e.map(e=>uq(e,t-1));let n={};for(let r of Object.keys(e))n[r]=uq(e[r],t-1);return n}function dq(e,t=1/0,n){let r=new WeakSet,i;try{i=JSON.stringify(e,(e,t)=>{if(!(n&&e&&n.has(e))){if(typeof t==`function`)return`[Function]`;if(typeof t==`bigint`)return t.toString();if(typeof t==`object`&&t){if(typeof HTMLElement<`u`&&t instanceof HTMLElement)return`[HTMLElement: <${t.tagName.toLowerCase()}>]`;if(typeof Node<`u`&&t instanceof Node)return`[Node: type=${t.nodeType}]`;if(r.has(t))return`[Circular]`;r.add(t)}return t}},0)}catch(e){i=`[无法序列化: ${e?.message||String(e)}]`}return i.length>t&&(i=i.slice(0,t)+`\n…[已截断,原长度 ${i.length}]`),i}function fq(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677)}return n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}function pq(e,t){return fq(dq(e,1/0,t)).toString(36)}function mq(e,t){let n=[],r=e=>{if(Array.isArray(e)){e.forEach(r);return}if(e&&typeof e==`object`)for(let[i,a]of Object.entries(e))t.has(i)&&n.push(`${i}=${dq(a)}`),r(a)};return r(e),n.sort(),fq(n.join(`\0`)).toString(36)}function hq(e,t,n,r){if(t===`set`)return n?(iq(e,n,r),null):`set 操作需要 jsonPath(整体替换请用 write({value}))`;if(t===`remove`)return n?aq(e,n)?null:`remove 路径不存在: ${n}(数组索引越界或字段缺失;请先 read 最新结构确认索引)`:`remove 操作需要 jsonPath`;if(t===`merge`){let t=n?rq(e,n):e;return typeof t!=`object`||!t||Array.isArray(t)?`merge 目标${n?`(${n})`:`(根)`}不是对象`:(nq(t,r),null)}if(t===`move`)return _q(e,n,r);let i=n?rq(e,n):e;return Array.isArray(i)?(Array.isArray(r)?i.push(...r):i.push(r),null):`append 目标${n?`(${n})`:`(根)`}不是数组`}function gq(e,t){let n=t.split(`.`),r=e;for(let e=0;e<n.length-1;e++){if(r==null)return null;r=r[n[e]]}return[r,n[n.length-1]]}function _q(e,t,n){if(!t)return`move 操作需要 jsonPath(源数组元素路径,如 components.2)`;if(typeof n!=`string`||!n)return`move 的 value 必须是目标路径字符串(数组本身=追加,如 "sections.1.children";数组内下标=插入,如 "components.0")`;if(tq(n))return`move 目标路径 "${n}" 含非法段`;let r=gq(e,t);if(!r||!Array.isArray(r[0]))return`move 源的父级不是数组(仅支持数组元素移动,jsonPath 应指向数组下标,如 components.2)`;let i=Number(r[1]);if(!Number.isInteger(i)||i<0||i>=r[0].length)return`move 源下标越界:${t}(父数组长度 ${r[0].length})`;let a=r[0][i];r[0].splice(i,1);let o=rq(e,n);if(Array.isArray(o))return o.push(a),null;if(o===void 0){let t=gq(e,n);if(t&&t[0]!=null&&typeof t[0]==`object`&&!/^\d+$/.test(t[1]))return t[0][t[1]]=[a],null}let s=gq(e,n);if(s&&Array.isArray(s[0])&&/^\d+$/.test(s[1])){let e=Math.min(Number(s[1]),s[0].length);return s[0].splice(e,0,a),null}return`move 目标 "${n}" 不是数组(目标须为数组本身(追加)或数组内某下标(插入))`}function vq(e,t,n,r){if(t===`set`)iq(e,n,r);else if(t===`remove`)aq(e,n);else if(t===`merge`)nq(n?rq(e,n):e,r);else if(t===`move`)_q(e,n,r);else{let t=n?rq(e,n):e;Array.isArray(r)?t.push(...r):t.push(r)}}function yq(e,t){typeof e==`object`&&e&&bq(e,t)}function bq(e,t){if(Array.isArray(e)){e.length=0,Array.isArray(t)&&e.push(...t);return}let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{};for(let t of Object.keys(e))t in n||delete e[t];for(let t of Object.keys(n))e[t]=n[t]}function xq(e,t,n,r=``){let i=[],a=e=>typeof e==`object`&&!!e;if(!a(t))return i;if(Array.isArray(t)){let a=Array.isArray(e)?e:[],o=Array.isArray(n)?n:[],s=new Set(a.map(e=>JSON.stringify(e)));return t.forEach((e,t)=>{s.has(JSON.stringify(e))||i.push(...xq(a[t],e,o[t],r?`${r}.${t}`:String(t)))}),i}let o=t,s=a(n)&&!Array.isArray(n)?n:null,c=a(e)&&!Array.isArray(e)?e:null;for(let e of Object.keys(o)){let t=r?`${r}.${e}`:e;e.startsWith(`__pg`)||(s&&!(e in s)?(!c||!(e in c))&&i.push(t):s&&e in s&&i.push(...xq(c?.[e],o[e],s[e],t)))}return i}function Sq(e,t,n=``){let r=[];if(!(typeof e==`object`&&e)||!(typeof t==`object`&&t)||Array.isArray(e)!==Array.isArray(t))return e!==t&&r.push({path:n||`(root)`,from:e,to:t}),r;if(Array.isArray(e)&&Array.isArray(t)){let i=Math.max(e.length,t.length);for(let a=0;a<i;a++){let i=n?`${n}.${a}`:`${a}`;a>=e.length?r.push({path:i,from:void 0,to:t[a]}):a>=t.length?r.push({path:i,from:e[a],to:void 0}):r.push(...Sq(e[a],t[a],i))}return r}let i=e,a=t,o=new Set([...Object.keys(i),...Object.keys(a)]);for(let e of o){let t=n?`${n}.${e}`:e;e in i?e in a?r.push(...Sq(i[e],a[e],t)):r.push({path:t,from:i[e],to:void 0}):r.push({path:t,from:void 0,to:a[e]})}return r}var Cq=new Set([`write`,`draft_commit`]);function wq(e){let t=e??{},n=new Set;if(typeof t.jsonPath==`string`&&t.jsonPath&&n.add(t.jsonPath),typeof t.path==`string`&&t.path&&n.add(t.path),t.patch&&typeof t.patch.jsonPath==`string`&&t.patch.jsonPath&&n.add(t.patch.jsonPath),Array.isArray(t.patches))for(let e of t.patches)e&&typeof e.jsonPath==`string`&&e.jsonPath&&n.add(e.jsonPath);return[...n]}function Tq(e,t){return e===t||e.startsWith(t+`.`)}function Eq(e,t){if(!t||typeof t!=`object`)return!1;let n=e.lastIndexOf(`.`);if(n<0)return!1;let r=e.slice(0,n),i=e.slice(n+1);if(!/^\d+$/.test(i))return!1;let a=rq(t,r);return Array.isArray(a)&&Number(i)>=a.length}function Dq(e){let t=e.initialFocuses?[...e.initialFocuses]:[],n=()=>e.onChange?.([...t]),r=e.unfocusGuidance??`tool`,i=e=>`若你的意图是修改聚焦组件本身(如给它新增页签/子项),请改写焦点路径的子路径重试${e?`(如 ${e})`:``};`,a=r===`tool`?`需改其他组件请先 remove_focus / clear_focus 或换焦点。${i()}`:r===`ask-user`?`焦点由用户在输入框设定与移除(聚焦 chip ✕);用户要求改其他组件时,提示用户移除聚焦后重试,勿尝试写焦点外(会被拒)。${i()}`:`需改其他组件时,在收口回复中说明需先取消焦点(焦点由主会话管理),勿尝试越界写。${i()}`,o=e=>r===`tool`?`${i(e)}需操作焦点外组件请先 remove_focus / clear_focus 或换焦点后重试。`:r===`ask-user`?`${i(e)}焦点由用户在输入框管理,请提示用户移除输入框中的聚焦 chip 后重试(当前模式无 focus 工具)。`:`${i(e)}请只改焦点子树;需改其他组件时,在收口回复中说明需先取消焦点。`;return{name:`focus`,beforeAgent:()=>t.length?{focuses:[...t],focus:t[0]}:{},augmentPrompt:()=>{if(!t.length)return;let n=[`## 当前精修目标`,t.map(e=>`· ${e.path}${e.label?`(${e.label})`:``}`).join(`
193
- `),`仅操作上述 ${t.length} 个聚焦子树${t.length>1?`之一`:``},用户未指明目标的指令默认作用于聚焦组件(「增加/修改/删除 X」类指令优先理解为对聚焦组件本身的改动 —— 如为其加页签/子项,写焦点路径的子路径;仅用户明确要求新建独立组件时才需解除焦点);不要改动其他组件;${a}`,`read 不带路径时默认只返回聚焦子树;需要全量主数据时显式列顶层键(read({jsonPaths:[...]}) )`],r=e.getSchema();if(r){let e=t.map(e=>{let t=sK(r,e.path);return t?BK(t):null}).filter(e=>!!e);e.length&&n.push(``,`## 焦点子树结构(仅此范围可操作)`,...e)}return n.join(`
192
+ `);function $K(e){let t=!1,n=!1;return{name:`resumeNotice`,markResumed:()=>{t=!0,n=!1},reset:()=>{t=!1,n=!1},isPending:()=>t,augmentPrompt:()=>{if(t)return e&&!n&&(n=!0,e()),QK},afterAgent:()=>{t=!1}}}var eq=new Set([`__proto__`,`constructor`,`prototype`]);function tq(e){return e.split(`.`).some(e=>eq.has(e))}function nq(e,t){if(!(!t||typeof t!=`object`||Array.isArray(t)))for(let n of Object.keys(t))eq.has(n)||(e[n]=t[n])}function rq(e,t){if(!t)return e;if(tq(t))return;let n=t.split(`.`),r=e;for(let e of n){if(r==null)return;r=r[e]}return r}function iq(e,t,n){if(!t||tq(t))return;let r=t.split(`.`),i=e;for(let e=0;e<r.length-1;e++){let t=r[e];(i[t]==null||typeof i[t]!=`object`)&&(i[t]={}),i=i[t]}i[r[r.length-1]]=n}function aq(e,t){if(!t||tq(t))return!1;let n=t.split(`.`),r=e;for(let e=0;e<n.length-1;e++){if(r==null)return!1;r=r[n[e]]}let i=n[n.length-1];return r==null||!(i in r)?!1:(Array.isArray(r)&&/^\d+$/.test(i)?r.splice(Number(i),1):delete r[i],!0)}function oq(e){if(e!==void 0)try{return JSON.parse(JSON.stringify(e))}catch(t){let n=sq(e);throw n?Error(`数据存在循环引用(${n});数据槽/快照不支持环形结构,请检查宿主 bind 或写入值`):t}}function sq(e){let t=new WeakSet,n=(e,r)=>{if(typeof e!=`object`||!e)return;let i=e;if(t.has(i))return r;if(t.add(i),Array.isArray(e))for(let t=0;t<e.length;t++){let i=n(e[t],`${r}[${t}]`);if(i)return i}else for(let t of Object.keys(e)){let i=n(e[t],`${r}.${t}`);if(i)return i}t.delete(i)};return n(e,`$`)}function cq(e){if(typeof e!=`string`)return{parsed:e};let t=e.trim();if(!t)return{parsed:e};let n=t[0]===`{`||t[0]===`[`;try{return{parsed:JSON.parse(t)}}catch(t){return n?{parseError:t}:{parsed:e}}}function lq(e,t){if(typeof e!=`object`||!e)return e;let n=new Set(t);if(Array.isArray(e))return e.map(e=>lq(e,t));let r={};for(let t of Object.keys(e))n.has(t)&&(r[t]=e[t]);return r}function uq(e,t){if(typeof e!=`object`||!e)return e;if(t<=0)return Array.isArray(e)?`[...${e.length}]`:`{...}`;if(Array.isArray(e))return e.map(e=>uq(e,t-1));let n={};for(let r of Object.keys(e))n[r]=uq(e[r],t-1);return n}function dq(e,t=1/0,n){let r=new WeakSet,i;try{i=JSON.stringify(e,(e,t)=>{if(!(n&&e&&n.has(e))){if(typeof t==`function`)return`[Function]`;if(typeof t==`bigint`)return t.toString();if(typeof t==`object`&&t){if(typeof HTMLElement<`u`&&t instanceof HTMLElement)return`[HTMLElement: <${t.tagName.toLowerCase()}>]`;if(typeof Node<`u`&&t instanceof Node)return`[Node: type=${t.nodeType}]`;if(r.has(t))return`[Circular]`;r.add(t)}return t}},0)}catch(e){i=`[无法序列化: ${e?.message||String(e)}]`}return i.length>t&&(i=i.slice(0,t)+`\n…[已截断,原长度 ${i.length}]`),i}function fq(e,t=0){let n=3735928559^t,r=1103547991^t;for(let t=0;t<e.length;t++){let i=e.charCodeAt(t);n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677)}return n=Math.imul(n^n>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),4294967296*(2097151&r)+(n>>>0)}function pq(e,t){return fq(dq(e,1/0,t)).toString(36)}function mq(e,t){let n=[],r=e=>{if(Array.isArray(e)){e.forEach(r);return}if(e&&typeof e==`object`)for(let[i,a]of Object.entries(e))t.has(i)&&n.push(`${i}=${dq(a)}`),r(a)};return r(e),n.sort(),fq(n.join(`\0`)).toString(36)}function hq(e,t,n,r){if(t===`set`)return n?(iq(e,n,r),null):`set 操作需要 jsonPath(整体替换请用 write({value}))`;if(t===`remove`)return n?aq(e,n)?null:`remove 路径不存在: ${n}(数组索引越界或字段缺失;请先 read 最新结构确认索引)`:`remove 操作需要 jsonPath`;if(t===`merge`){let t=n?rq(e,n):e;return typeof t!=`object`||!t||Array.isArray(t)?`merge 目标${n?`(${n})`:`(根)`}不是对象`:(nq(t,r),null)}if(t===`move`)return _q(e,n,r);let i=n?rq(e,n):e;return typeof i==`string`?typeof r==`string`?(iq(e,n,i+r),null):`append 目标(${n})是字符串,value 必须也是字符串(拼接语义)`:Array.isArray(i)?(Array.isArray(r)?i.push(...r):i.push(r),null):`append 目标${n?`(${n})`:`(根)`}不是数组(也不支持非字符串标量拼接)`}function gq(e,t){let n=t.split(`.`),r=e;for(let e=0;e<n.length-1;e++){if(r==null)return null;r=r[n[e]]}return[r,n[n.length-1]]}function _q(e,t,n){if(!t)return`move 操作需要 jsonPath(源数组元素路径,如 components.2)`;if(typeof n!=`string`||!n)return`move 的 value 必须是目标路径字符串(数组本身=追加,如 "sections.1.children";数组内下标=插入,如 "components.0")`;if(tq(n))return`move 目标路径 "${n}" 含非法段`;let r=gq(e,t);if(!r||!Array.isArray(r[0]))return`move 源的父级不是数组(仅支持数组元素移动,jsonPath 应指向数组下标,如 components.2)`;let i=Number(r[1]);if(!Number.isInteger(i)||i<0||i>=r[0].length)return`move 源下标越界:${t}(父数组长度 ${r[0].length})`;let a=r[0][i];r[0].splice(i,1);let o=rq(e,n);if(Array.isArray(o))return o.push(a),null;if(o===void 0){let t=gq(e,n);if(t&&t[0]!=null&&typeof t[0]==`object`&&!/^\d+$/.test(t[1]))return t[0][t[1]]=[a],null}let s=gq(e,n);if(s&&Array.isArray(s[0])&&/^\d+$/.test(s[1])){let e=Math.min(Number(s[1]),s[0].length);return s[0].splice(e,0,a),null}return`move 目标 "${n}" 不是数组(目标须为数组本身(追加)或数组内某下标(插入))`}function vq(e,t,n,r){if(t===`set`)iq(e,n,r);else if(t===`remove`)aq(e,n);else if(t===`merge`)nq(n?rq(e,n):e,r);else if(t===`move`)_q(e,n,r);else{let t=n?rq(e,n):e;Array.isArray(r)?t.push(...r):t.push(r)}}function yq(e,t){typeof e==`object`&&e&&bq(e,t)}function bq(e,t){if(Array.isArray(e)){e.length=0,Array.isArray(t)&&e.push(...t);return}let n=t&&typeof t==`object`&&!Array.isArray(t)?t:{};for(let t of Object.keys(e))t in n||delete e[t];for(let t of Object.keys(n))e[t]=n[t]}function xq(e,t,n,r=``){let i=[],a=e=>typeof e==`object`&&!!e;if(!a(t))return i;if(Array.isArray(t)){let a=Array.isArray(e)?e:[],o=Array.isArray(n)?n:[],s=new Set(a.map(e=>JSON.stringify(e)));return t.forEach((e,t)=>{s.has(JSON.stringify(e))||i.push(...xq(a[t],e,o[t],r?`${r}.${t}`:String(t)))}),i}let o=t,s=a(n)&&!Array.isArray(n)?n:null,c=a(e)&&!Array.isArray(e)?e:null;for(let e of Object.keys(o)){let t=r?`${r}.${e}`:e;e.startsWith(`__pg`)||(s&&!(e in s)?(!c||!(e in c))&&i.push(t):s&&e in s&&i.push(...xq(c?.[e],o[e],s[e],t)))}return i}function Sq(e,t,n=``){let r=[];if(!(typeof e==`object`&&e)||!(typeof t==`object`&&t)||Array.isArray(e)!==Array.isArray(t))return e!==t&&r.push({path:n||`(root)`,from:e,to:t}),r;if(Array.isArray(e)&&Array.isArray(t)){let i=Math.max(e.length,t.length);for(let a=0;a<i;a++){let i=n?`${n}.${a}`:`${a}`;a>=e.length?r.push({path:i,from:void 0,to:t[a]}):a>=t.length?r.push({path:i,from:e[a],to:void 0}):r.push(...Sq(e[a],t[a],i))}return r}let i=e,a=t,o=new Set([...Object.keys(i),...Object.keys(a)]);for(let e of o){let t=n?`${n}.${e}`:e;e in i?e in a?r.push(...Sq(i[e],a[e],t)):r.push({path:t,from:i[e],to:void 0}):r.push({path:t,from:void 0,to:a[e]})}return r}var Cq=new Set([`write`,`draft_commit`]);function wq(e){let t=e??{},n=new Set;if(typeof t.jsonPath==`string`&&t.jsonPath&&n.add(t.jsonPath),typeof t.path==`string`&&t.path&&n.add(t.path),t.patch&&typeof t.patch.jsonPath==`string`&&t.patch.jsonPath&&n.add(t.patch.jsonPath),Array.isArray(t.patches))for(let e of t.patches)e&&typeof e.jsonPath==`string`&&e.jsonPath&&n.add(e.jsonPath);return[...n]}function Tq(e,t){return e===t||e.startsWith(t+`.`)}function Eq(e,t){if(!t||typeof t!=`object`)return!1;let n=e.lastIndexOf(`.`);if(n<0)return!1;let r=e.slice(0,n),i=e.slice(n+1);if(!/^\d+$/.test(i))return!1;let a=rq(t,r);return Array.isArray(a)&&Number(i)>=a.length}function Dq(e){let t=e.initialFocuses?[...e.initialFocuses]:[],n=()=>e.onChange?.([...t]),r=e.unfocusGuidance??`tool`,i=e=>`若你的意图是修改聚焦组件本身(如给它新增页签/子项),请改写焦点路径的子路径重试${e?`(如 ${e})`:``};`,a=r===`tool`?`需改其他组件请先 remove_focus / clear_focus 或换焦点。${i()}`:r===`ask-user`?`焦点由用户在输入框设定与移除(聚焦 chip ✕);用户要求改其他组件时,提示用户移除聚焦后重试,勿尝试写焦点外(会被拒)。${i()}`:`需改其他组件时,在收口回复中说明需先取消焦点(焦点由主会话管理),勿尝试越界写。${i()}`,o=e=>r===`tool`?`${i(e)}需操作焦点外组件请先 remove_focus / clear_focus 或换焦点后重试。`:r===`ask-user`?`${i(e)}焦点由用户在输入框管理,请提示用户移除输入框中的聚焦 chip 后重试(当前模式无 focus 工具)。`:`${i(e)}请只改焦点子树;需改其他组件时,在收口回复中说明需先取消焦点。`;return{name:`focus`,beforeAgent:()=>t.length?{focuses:[...t],focus:t[0]}:{},augmentPrompt:()=>{if(!t.length)return;let n=[`## 当前精修目标`,t.map(e=>`· ${e.path}${e.label?`(${e.label})`:``}`).join(`
193
+ `),`仅操作上述 ${t.length} 个聚焦子树${t.length>1?`之一`:``},用户未指明目标的指令默认作用于聚焦组件(「增加/修改/删除 X」类指令优先理解为对聚焦组件本身的改动 —— 如为其加页签/子项,写焦点路径的子路径;仅用户明确要求新建独立组件时才需解除焦点);不要改动其他组件;${a}`,`用户用指示代词提问(「这是啥/这个/它是干什么的」等)时,所指默认是聚焦目标 —— 先 read 聚焦子树,再围绕聚焦组件回答,勿泛答整页`,`read 不带路径时默认只返回聚焦子树;需要全量主数据时显式列顶层键(read({jsonPaths:[...]}) )`],r=e.getSchema();if(r){let e=t.map(e=>{let t=sK(r,e.path);return t?BK(t):null}).filter(e=>!!e);e.length&&n.push(``,`## 焦点子树结构(仅此范围可操作)`,...e)}return n.join(`
194
194
  `)},wrapToolCall:async(n,r)=>{if(t.length){let i=t.map(e=>e.label?`${e.path}(${e.label})`:e.path).join(`, `),a=t.length===1?`${t[0].path}.props.xxx`:void 0,s=e=>({content:`PATH_DENIED · 聚焦越界:当前聚焦 [${i}],不可操作「${e}」。${o(a)}`,status:`error`});if(n.name===`eval_script`){if(n.args?.mode!==`transform`)return r(n);let i=wq(n.args);if(!i.length)return s(`(整体数据)`);for(let n of i)if(!t.some(e=>Tq(n,e.path))&&!Eq(n,e.getBind?.()))return s(n);return r(n)}if(Cq.has(n.name)){let r=wq(n.args);if(!r.length)return s(`(整体数据)`);for(let n of r)if(!t.some(e=>Tq(n,e.path))&&!Eq(n,e.getBind?.()))return s(n)}if(n.name===`read`){n.callConfig={...n.callConfig??{},__pgFullTextPaths:t.map(e=>e.path)};let e=n.args;if(!e?.jsonPath&&!e?.jsonPaths){let i=t.map(e=>e.path),a=await r({...n,args:{...e,jsonPaths:i}}),o=`【聚焦模式】read 未带路径 → 默认返回聚焦子树(${i.join(`, `)});需要全量主数据时显式列顶层键,如 read({jsonPaths:['<顶层键1>','<顶层键2>']})\n`;return{...a,content:o+a.content}}}}return r(n)},setFocus:e=>{t=e?[e]:[],n()},getFocus:()=>t[0],getFocuses:()=>[...t],addFocus:e=>{let r=t.findIndex(t=>t.path===e.path);r>=0?t[r]=e:t.push(e),n()},removeFocus:e=>{t=t.filter(t=>t.path!==e),n()},clearFocus:()=>{t=[],n()},reset:()=>{t=[],n()}}}Jp();function Oq(e){return e}var kq=/^https?:\/\//i;function Aq(e){return kq.test(e)||e.startsWith(`//`)?`http`:`vfs`}function jq(e){return e.replace(/^vfs:\/\//,``).replace(/^\/+/,``).replace(/\/+/g,`/`)}var Mq=3e4;async function Nq(e){let t=new AbortController,n=setTimeout(()=>t.abort(),Mq);try{return await fetch(e,{signal:t.signal})}finally{clearTimeout(n)}}async function Pq(e,t){if(Aq(e)===`http`)try{let t=await Nq(e);return t.ok?{ok:!0,content:await t.text()}:{ok:!1,error:`HTTP ${t.status} ${t.statusText}(${e})`}}catch(t){if(t?.name===`AbortError`)return{ok:!1,error:`读取超时(${Mq/1e3}s):${e}`};let n=t?.message||String(t);return/Failed to fetch|NetworkError|CORS|blocked/i.test(n)?{ok:!1,error:`CORS 跨域或网络错误(${n});浏览器仅能 GET 同源或已配 CORS 的资源`}:{ok:!1,error:n}}if(!t)return{ok:!1,error:`skill 文档 ${e} 是 vfs 路径,但 vfs 未启用`};let n=t(jq(e));return n==null?{ok:!1,error:`未找到 vfs 文档 ${e}(可用 vfs_ls 查看)`}:{ok:!0,content:n}}function Fq(e){if(e.length)return[`## 可用 Skills(渐进式披露)`,e.map(e=>`- ${e.name}: ${e.description}`).join(`
195
195
  `),`当某 skill 适用时,先调用 load_skill(name) 加载其完整指令,再按指令执行。不要凭记忆猜测 skill 内容。`].join(`
196
196
  `)}function Iq(e){return e.references?.length?`\n\n## 参考文档(按需加载,勿整包请求)\n${e.references.map(e=>`- ${e.name}${e.description?`: ${e.description}`:``}`).join(`
@@ -247,11 +247,11 @@ ${t}`,d++;break;case`id`:l=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.t
247
247
  `)}`:`虚拟工作区为空。`},{name:`vfs_ls`,description:`列出虚拟工作区所有文件。`,schema:B({})}),VI(async({pattern:t})=>{let n;try{n=xde(t)}catch(e){return CU({code:`GLOB_INVALID`,message:`glob 模式无效: ${e.message}`,hint:`* 匹配非斜杠,** 匹配任意;避免未闭合的字符类`,details:{pattern:t}})}let r=Object.keys(e.files).filter(e=>n.test(e));return r.length?`匹配 ${t}:\n${r.map(e=>`- ${e}`).join(`
248
248
  `)}`:`无匹配 ${t} 的文件。`},{name:`vfs_glob`,description:`按 glob 模式匹配虚拟工作区文件名(* 匹配非斜杠,** 匹配任意)。`,schema:B({pattern:R().describe(`glob 模式,如 "**/*.md"`)})}),VI(async({pattern:t,path:n})=>{let r;try{r=new RegExp(t)}catch(e){return CU({code:`REGEX_INVALID`,path:n,message:`正则表达式无效: ${e.message}`,hint:`检查括号/量词是否闭合;若想搜普通字符串可先转义特殊字符`,details:{pattern:t}})}let i=n?[r2(n)]:Object.keys(e.files),a=[];for(let t of i){let n=e.files[t];n&&n.content.split(`
249
249
  `).forEach((e,n)=>{r.test(e)&&a.push(`${t}:${n+1}: ${e}`)})}return a.length?`找到 ${a.length} 处:\n${a.slice(0,50).join(`
250
- `)}`:`未找到匹配 /${t}/ 的内容。`},{name:`vfs_grep`,description:`在虚拟工作区文件内容中正则搜索。`,schema:B({pattern:R().describe(`正则表达式`),path:R().optional().describe(`限定单个文件,不传则搜索全部`)})}),VI(async({path:t,jsonPath:n})=>{let r=r2(t),i=e.files[r];if(!i)return CU({code:`NOT_FOUND`,path:t,message:`未找到文件 "${t}"`,hint:`用 vfs_ls 查看虚拟工作区文件列表`});let a;try{a=JSON.parse(i.content)}catch(e){return CU({code:`VFS_JSON_INVALID`,path:t,message:`文件内容非合法 JSON: ${e.message}`,hint:`vfs_json_read 要求文件内容是合法 JSON;先 vfs_read 查看实际内容,或 vfs_write({jsonString:true}) 重写为合法 JSON`})}if(n){let e=rq(a,n);return e===void 0?CU({code:`VFS_PATH_NOT_FOUND`,path:t,message:`jsonPath "${n}" 不存在`,hint:`不传 jsonPath 整体读查看结构,或核对路径段`}):`${t}#${n} (JSON):\n${JSON.stringify(e)}`}return`${t} (JSON):\n${JSON.stringify(a)}`},{name:`vfs_json_read`,description:`把虚拟工作区文件当 JSON 读取:先 parse 整文件,再按 jsonPath 取子树(省略返整体)。文件非合法 JSON 报 VFS_JSON_INVALID。适合结构化读取 vfs 内大 JSON。`,schema:B({path:R().describe(`文件路径(内容须为合法 JSON)`),jsonPath:R().optional().describe(`点分隔子路径(如 components.0.title);省略读整体`)})}),VI(async({path:t,patches:n})=>{let r=r2(t),i=e.files[r];if(!i)return CU({code:`NOT_FOUND`,path:t,message:`未找到文件 "${t}"`,hint:`用 vfs_ls 查看虚拟工作区文件列表`});let a;try{a=JSON.parse(i.content)}catch(e){return CU({code:`VFS_JSON_INVALID`,path:t,message:`文件内容非合法 JSON: ${e.message}`,hint:`vfs_json_patch 要求文件内容是合法 JSON`})}let o=oq(a),s=[];for(let e of n){let n=hq(o,e.op,e.jsonPath,e.value);if(n)return CU({code:`PATCH_FAILED`,path:t,message:n,hint:`修正 patches 后重试(原文件未改动)`,details:{failedPatch:e}});s.push(e.jsonPath||`(根)`)}let c=JSON.stringify(o);return e.files[r]={content:c,updatedAt:i2()},`已对 ${t} 应用 ${n.length} 个 patch(影响 ${s.length} 处:${s.join(`, `)}),文件现 ${c.length} 字符`},{name:`vfs_json_patch`,description:`在虚拟工作区 JSON 文件内做原子 jsonPath patch(set/remove/merge/append)。先 parse → clone 上应用全部 patches → 任一失败或 JSON 非法则整体不写回(原文件不变)。`,schema:B({path:R().describe(`文件路径(内容须为合法 JSON)`),patches:z(B({op:Vd([`set`,`remove`,`merge`,`append`]).describe(`操作`),jsonPath:R().describe(`点分隔路径(如 components.0.title);merge/append 目标可为根(空串)`),value:Cd().optional().describe(`set/merge/append 的值(remove 不需要)`)})).describe(`按顺序应用的 patch 列表(原子:任一失败整体不写回)`)})}),VI(async({path:t})=>{let n=r2(t);return e.files[n]?(delete e.files[n],`已删除 ${t}`):CU({code:`NOT_FOUND`,path:t,message:`未找到文件 "${t}",无需删除`,hint:`用 vfs_ls 查看虚拟工作区文件列表`})},{name:`vfs_rm`,description:`删除虚拟工作区文件(清理中间产物 / drafts 下草稿,补「只进不出」的闭环)。不存在返回 NOT_FOUND。`,schema:B({path:R().describe(`要删除的文件路径`)})})]}function wde(e){return{name:`vfs`,tools:Cde(e),beforeAgent:()=>({files:e.files})}}var a2=`⟦frozen:`,o2=`⟦res:`,s2=`⟧`;function c2(e){return`${a2}${e}${s2}`}function l2(e){return`${o2}${e}${s2}`}function Tde(e){return typeof e==`string`?e.startsWith(a2)&&e.endsWith(s2)?{type:`frozen`,path:e.slice(8,e.length-1)}:e.startsWith(o2)&&e.endsWith(s2)?{type:`res`,handle:e.slice(5,e.length-1)}:null:null}function u2(e){return String(e??``).trim().replace(/^\.+/,``)}function d2(e){let t=5381;for(let n=0;n<e.length;n++)t=(t*33^e.charCodeAt(n))>>>0;return(t>>>0).toString(16).padStart(8,`0`).slice(0,8)}function f2(e,t){return e===t?!0:e&&t&&typeof e==`object`&&typeof t==`object`?JSON.stringify(e)===JSON.stringify(t):!1}function p2(e,t){let n=u2(e);if(!n)return;let r=t.get(n);if(r)return{spec:r,relation:`exact`,protectedPath:n};let i;for(let[e,r]of t)n!==e&&(n.startsWith(e+`.`)?(!i||e.length>i.protectedPath.length)&&(i={spec:r,protectedPath:e,relation:`descendant`}):e.startsWith(n+`.`)&&(!i||e.length<i.protectedPath.length)&&(i={spec:r,protectedPath:e,relation:`ancestor`}));return i}var Ede=class{vfs;constructor(e){this.vfs=e}key(e){return`resources/${e}.json`}ensure(e,t,n){let r=d2(e),i={path:e,mode:n,value:t,handle:r};return this.vfs.files[this.key(r)]={content:JSON.stringify(i),updatedAt:Date.now()},r}get(e){return this.readEntry(this.key(e))||this.readEntry(this.key(d2(e)))}readEntry(e){let t=this.vfs.files[e];if(t)try{let e=JSON.parse(t.content);return e&&typeof e.path==`string`?e:void 0}catch{return}}update(e,t){let n=this.get(e);this.ensure(e,t,n?.mode??`verbatim`)}delete(e){let t=this.get(e)?.handle??d2(e),n=this.key(t),r=!!this.vfs.files[n];return r&&delete this.vfs.files[n],r}list(){let e=[];for(let[t,n]of Object.entries(this.vfs.files))if(t.startsWith(`resources/`))try{let t=JSON.parse(n.content);t&&typeof t.path==`string`&&e.push({path:t.path,mode:t.mode,handle:t.handle,bytes:n.content.length})}catch{}return e}clear(){for(let e of Object.keys(this.vfs.files))e.startsWith(`resources/`)&&delete this.vfs.files[e]}};function m2(e){let{jp:t,resolved:n,resourcesByPath:r,resourceStore:i}=e;if(!r.size)return n;let a=!1;for(let e of r.keys())if(t===``||e===t||e.startsWith(t+`.`)){a=!0;break}if(!a)return n;let o=oq(n);for(let[e,n]of r){if(t!==``&&e!==t&&!e.startsWith(t+`.`))continue;if(e===t){if(o===void 0)continue;return n.mode===`freeze`?c2(e):i?l2(i.ensure(e,o,`verbatim`)):o}let r=t===``?e:e.slice(t.length+1),a=rq(o,r);a!==void 0&&(n.mode===`freeze`?iq(o,r,c2(e)):i&&iq(o,r,l2(i.ensure(e,a,`verbatim`))))}return o}function Dde(e,t,n,r){if(!r)return{code:`RESOURCE_NOT_FOUND`,message:`句柄 "${e}" 无法展开(资源池未启用)`,hint:`verbatim 保护需启用 vfs(capabilities.vfs 默认开);集成方经 createChatSdk 配 data.resources 时自动提供 vfsStore`};let i=r.get(e);return i?n===void 0?{code:`RESOURCE_NOT_FOUND`,message:`字段 "${t}" 在 bind 中已不存在,无法展开句柄 "${e}"`,hint:`该字段可能已被删除或 restore 到不含此字段的快照;重新 read 确认当前结构`}:f2(i.value,n)?{value:i.value}:(r.update(t,n),{value:n}):n===void 0?{code:`RESOURCE_NOT_FOUND`,message:`句柄 "${e}" 不存在(字段 "${t}" 可能未注册或已被删除)`,hint:`重新 read 该字段触发懒注册`}:{code:`RESOURCE_EVICTED`,message:`字段 "${t}" 的 verbatim 资源已被淘汰(资源池 LRU)`,hint:`重新 read 该字段触发懒注册重建句柄,再写回新句柄 ⟦res:<handle>⟧`}}function h2(e,t){let n=t.getBind();for(let[r,i]of t.resourcesByPath){let a=rq(n,r),o=rq(e,r);if(o===void 0){a!==void 0&&iq(e,r,a);continue}if(i.mode===`freeze`){if(o===c2(r)){iq(e,r,a);continue}if(!f2(o,a))return{ok:!1,code:`FROZEN_FIELD`,path:r,message:`字段 "${r}" 已冻结(freeze 保护),不可修改`,hint:`该字段由系统/集成方维护,LLM 不得改动。如需展示其值用 resource_get({path}) 取真值`}}else{let n=Tde(o);if(n&&n.type===`res`){let i=Dde(n.handle,r,a,t.resourceStore);if(`value`in i){iq(e,r,i.value);continue}return{ok:!1,code:i.code,path:r,message:i.message,hint:i.hint}}if(!f2(o,a))return{ok:!1,code:`VERBATIM_MISMATCH`,path:r,message:`字段 "${r}" 为 verbatim 保护(精确原样保留),写入值与原值不符`,hint:`要改该值请先 resource_update({path, value}) 更新资源池,再写回句柄 ⟦res:<handle>⟧;或写回原值(经 resource_get 取到的值)保持不变`}}}return{ok:!0}}function g2(e,t,n){let r=t===void 0?e.message:`patches[${t}]${n?` @ "${n}"`:``}: ${e.message}`;return CU({code:e.code,path:e.path,message:r,hint:e.hint,...t===void 0?{}:{details:{patchIndex:t,patchJsonPath:n??null}}})}function _2(e){let{value:t,ctx:n}=e;if(!n||!n.resourcesByPath.size)return{ok:!0,value:t};let r=oq(t),i=h2(r,n);return i.ok?{ok:!0,value:r}:{ok:!1,error:g2(i)}}function Ode(e){let{patches:t,clone:n,ctx:r}=e;if(!r||!r.resourcesByPath.size)return{ok:!0};for(let e=0;e<t.length;e++){let n=t[e];if(n.op===`remove`){let t=p2(n.jsonPath||``,r.resourcesByPath);if(t){let r=t.spec.mode===`freeze`?`FROZEN_FIELD`:`VERBATIM_PROTECTED`,i=t.spec.mode===`freeze`?`冻结字段不可删。如需移除请联系集成方调整 data.resources 配置`:`verbatim 字段不可直接删;先 resource_delete({path}) 释放资源保护后再删`;return{ok:!1,error:CU({code:r,path:t.protectedPath,message:`patches[${e}] @ "${n.jsonPath}" 命中受保护字段 "${t.protectedPath}"(${t.spec.mode}),不可删除`,hint:i,details:{patchIndex:e,patchJsonPath:n.jsonPath??``}})}}}}let i=h2(n,r);if(!i.ok){let e=kde(i.path,t);return{ok:!1,error:g2(i,e>=0?e:void 0,e>=0?t[e].jsonPath:void 0)}}return{ok:!0}}function kde(e,t){let n=u2(e);for(let e=0;e<t.length;e++){let r=u2(t[e].jsonPath||``);if(r&&(r===n||n.startsWith(r+`.`)||r.startsWith(n+`.`)))return e}return-1}Jp();function v2(e,t){if(!e)return null;let n=(t?sK(e,t):e)?.shape;return n&&typeof n==`object`?Object.keys(n):null}var y2=e=>e&&e.length?`(可用字段:${e.slice(0,12).join(`, `)}${e.length>12?` …`:``})`:``,b2=e=>/[.[]/.test(e)?e.replace(/[.[][^.[]*$/,``):``;function x2(e){let{schema:t,allowKeys:n,value:r,bindRef:i}=e,a=[];if(n){if(typeof r!=`object`||!r||Array.isArray(r))return{ok:!1,error:TU(``,[{path:[],code:`invalid_type`,message:`整体 set 需为 JSON 对象(当前为 ${Array.isArray(r)?`array`:r===null?`null`:typeof r})`,expected:`object`}]),notices:a};let e=i&&typeof i==`object`&&!Array.isArray(i)?i:{},n=r,o={};for(let r of Object.keys(n)){if(r.startsWith(`__pg`))continue;let i=n[r],s=dK(t,r,i);if(!s.ok){if(s.resolution===`missing`){if(r in e)continue;return{ok:!1,error:CU({code:`SCHEMA_STRIP`,message:`字段 ${r} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试${y2(v2(t,``))}`,path:r,details:{stripped:[r]}}),notices:a}}return{ok:!1,error:TU(r,s.issues??[]),notices:a}}s.resolution===`open`&&a.push(`${r}=开放节点放行`);let c=xq(e[r],i,s.data,r);if(c.length)return{ok:!1,error:CU({code:`SCHEMA_STRIP`,message:`字段 ${c.join(`, `)} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试${y2(v2(t,b2(String(c[0]))))}`,path:c[0],details:{stripped:c}}),notices:a};o[r]=s.data}return fK(t)&&a.push(`根级 refine/superRefine 不再在 write 时执行(走 capabilities.verify)`),{ok:!0,assembly:o,wholeParsed:null,notices:a}}let o=t.safeParse(r);if(!o.success)return{ok:!1,error:TU(``,o.error.issues),notices:a};let s=xq(i,r,o.data);return s.length?{ok:!1,error:CU({code:`SCHEMA_STRIP`,message:`字段 ${s.join(`, `)} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试`,path:s[0],details:{stripped:s}}),notices:a}:{ok:!0,assembly:o.data,wholeParsed:o.data,notices:a}}function S2(e){let{schema:t,bindRef:n,clone:r,patches:i,schemaErrorMode:a=`zod`,appendCaptures:o,moveCaptures:s}=e,c=[],l=t=>{let n=rq(r,t);return n===void 0?e.valueAt?.(t):n},u=(e,t)=>a===`schema_invalid`?CU({code:`SCHEMA_INVALID`,message:`patches 应用后局部校验失败 @ "${e}",未写入`,hint:`确认该路径的值符合 schema;兄弟节点的既有数据不影响本次写入`,details:wU(t)}):TU(e,t),d=e=>CU({code:`SCHEMA_STRIP`,message:`字段 ${e.join(`, `)} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试`,path:e[0],details:{stripped:e}}),f=[];fK(t)&&c.push(`根级 refine/superRefine 不再在 write 时执行(走 capabilities.verify)`);let p=0,m=0;for(let e of i){let i=e.op??`set`,a=e.jsonPath||``;if(i===`remove`){let e=a.lastIndexOf(`.`);if(e>0&&/^\d+$/.test(a.slice(e+1))){let n=a.slice(0,e),i=uK(t,n);if(i.kind===`schemas`){let e=rq(r,n);if(Array.isArray(e))for(let t of i.schemas){let r=pK(t);if(r!==null&&e.length<r)return{ok:!1,error:u(n,[{path:[n],code:`too_small`,message:`删除后数组长度 ${e.length} 低于 schema 最小约束 ${r}`,expected:`>=${r}`}]),writeBacks:[],notices:c}}}}f.push({op:`remove`,jp:a});continue}if(i===`move`){let n=s[m++];if(n&&n.elem!==void 0){let e=n.toPath.lastIndexOf(`.`),r=e>0&&/^\d+$/.test(n.toPath.slice(e+1))?n.toPath.slice(0,e):n.toPath,i=uK(t,r);if(i.kind===`schemas`){let e=mK(i.schemas);if(e.length){let t=[],r=!1;for(let i of e){let e=i.safeParse(n.elem);if(e.success){r=!0;break}t.push(...e.error?.issues??[])}if(!r)return{ok:!1,error:u(n.toPath,t),writeBacks:[],notices:c}}}else i.kind===`open`&&c.push(`${r}=开放节点放行`)}f.push({op:`move`,jp:a,toPath:String(e.value)});continue}if(i===`append`){let e=o[p++]?.elems??[];if(!e.length){f.push({op:`appendElems`,jp:a,elems:[]});continue}let n=uK(t,a);if(n.kind===`missing`)return{ok:!1,error:d([a||`(根)`]),writeBacks:[],notices:c};if(n.kind===`open`){c.push(`${a||`(根)`}=开放节点放行`),f.push({op:`appendElems`,jp:a,elems:e});continue}let r=mK(n.schemas);if(!r.length){c.push(`${a||`(根)`}:目标非 schema 声明数组,元素未校验放行`),f.push({op:`appendElems`,jp:a,elems:e});continue}let i=[];for(let t=0;t<e.length;t++){let n=[],o,s=!1;for(let i of r){let r=i.safeParse(e[t]);if(r.success){s=!0,o=r.data;break}n.push(...r.error?.issues??[])}if(!s)return{ok:!1,error:u(`${a||`(根)`}[新增元素${t}]`,n),writeBacks:[],notices:c};let l=xq(void 0,e[t],o,a?`${a}.${t}`:String(t));if(l.length)return{ok:!1,error:d(l),writeBacks:[],notices:c};i.push(o)}f.push({op:`appendElems`,jp:a,elems:i});continue}if(i===`merge`){let r=e.value;if(typeof r==`string`){let e=cq(r);if(e.parseError)return{ok:!1,error:EU(`patches merge`,r,e.parseError),writeBacks:[],notices:c};r=e.parsed}if(typeof r!=`object`||!r||Array.isArray(r))return{ok:!1,error:CU({code:`PATCH_FAILED`,message:`merge 的 value 需为对象`,hint:`merge 合并对象键;整体替换用 set`}),writeBacks:[],notices:c};let i=[];for(let e of Object.keys(r)){if(e.startsWith(`__pg`)||eq.has(e))continue;let r=a?`${a}.${e}`:e,o=l(r),s=dK(t,r,o);if(!s.ok){if(s.resolution===`missing`){if(rq(n,r)===void 0)return{ok:!1,error:d([r]),writeBacks:[],notices:c};i.push([e,o]);continue}return{ok:!1,error:u(r,s.issues??[]),writeBacks:[],notices:c}}s.resolution===`open`&&c.push(`${r}=开放节点放行`);let f=xq(rq(n,r),o,s.data,r);if(f.length)return{ok:!1,error:d(f),writeBacks:[],notices:c};i.push([e,s.data])}f.push({op:`mergeKeys`,jp:a,entries:i});continue}let h=l(a),g=a.lastIndexOf(`.`);if(g>0&&/^\d+$/.test(a.slice(g+1))){let e=rq(r,a.slice(0,g));if(Array.isArray(e)){for(let t=0;t<e.length;t++)if(!(t in e))return{ok:!1,error:CU({code:`PATCH_FAILED`,message:`set @ "${a}" 越界数组索引产生稀疏空洞(父数组长度 ${e.length})`,hint:`数组索引须连续(≤ 当前长度);追加请用 op:"append"`}),writeBacks:[],notices:c}}}let _=dK(t,a,h);if(!_.ok){if(_.resolution===`missing`){if(rq(n,a)===void 0)return{ok:!1,error:d([a]),writeBacks:[],notices:c};f.push({op:`set`,jp:a,value:h});continue}return{ok:!1,error:u(a,_.issues??[]),writeBacks:[],notices:c}}_.resolution===`open`&&c.push(`${a||`(根)`}=开放节点放行`);let v=xq(rq(n,a),h,_.data,a);if(v.length)return{ok:!1,error:d(v),writeBacks:[],notices:c};f.push({op:`set`,jp:a,value:_.data})}return{ok:!0,writeBacks:f,notices:c}}function C2(e){let{bindRef:t,schema:n,allowKeys:r,snapshots:i,maxSnapshots:a,audit:o,dryRun:s,op:c=`set`,protectedCtx:l,snapshotLabel:u}=e,d=e.value,f=e.internalAfterWrite?oq(t):null,p=T2(d);if(p)return{ok:!1,error:E2(p)};if(l){let e=_2({value:d,ctx:l});if(!e.ok)return{ok:!1,error:e.error};d=e.value}let m=x2({schema:n,allowKeys:r,value:d,bindRef:t});if(!m.ok)return{ok:!1,error:m.error};let h=m.assembly;if(s)return{ok:!0,hash:``,data:h,notices:m.notices};if(typeof t!=`object`||!t)return{ok:!1,error:CU({code:`LEAF_BIND`,message:`主数据 bind 为原始类型(${t===null?`null`:typeof t}),无法就地替换外部持有的值引用`,hint:`主数据 bind 必须为对象/数组;叶子值请用对象包裹(如 {value:"x"})或集成方通过 sdk.setData 替换 bind`})};let g=oq(t),_=i.length?i[i.length-1].id+1:1;for(i.push({id:_,ts:Date.now(),op:c,value:g,...u?{label:u}:{}});i.length>a;)i.shift();return typeof h==`object`&&h&&(m.wholeParsed?bq(t,h):nq(t,h)),o({op:c,value:h,timestamp:Date.now()}),e.onWrite?.(),e.internalAfterWrite?.(t,f),{ok:!0,hash:e.hashFn?e.hashFn():pq(t),data:h,notices:m.notices}}function w2(e){let{bindRef:t,patches:n,schema:r,allowKeys:i,snapshots:a,maxSnapshots:o,markDataDirty:s,schemaErrorMode:c=`zod`,snapshotLabel:l,dryRun:u,protectedCtx:d}=e,f=e.internalAfterWrite?oq(t):null,p=oq(t),m=[],h=[],g=[],_=[],v=(e,t)=>{(e===`set`||e===`merge`)&&_.push({jp:t,val:rq(p,t)})};for(let e=0;e<n.length;e++){let t=n[e],a=t.jsonPath||``;if(tq(a))return{ok:!1,error:CU({code:`PATH_UNSAFE`,message:`patches[${e}] jsonPath "${a}" 含非法段`,hint:`使用正常属性路径,如 components.0.text`})};if(!aK(a,r,i))return{ok:!1,error:CU({code:`PATH_DENIED`,message:`patches[${e}] @ "${a}" 不在 schema 声明字段内`,hint:`仅 schema 声明的 key 可写${y2(v2(r,b2(a)))}`})};let o=t.op??`set`,s;if(o!==`remove`){if(t.value===void 0||t.value===``&&o===`move`)return{ok:!1,error:CU({code:`MISSING_VALUE`,message:`patches[${e}] ${o} 操作需要 value`,hint:`op 为 ${o} 时 value 必填;删除请用 op:'remove'`})};let n=cq(t.value);if(n.parseError)return{ok:!1,error:EU(`patches[${e}]`,t.value,n.parseError)};if(s=n.parsed,o!==`move`){let t=T2(s);if(t)return{ok:!1,error:E2(t,`patches[${e}] @ "${a}"`)}}if(o===`move`&&typeof s==`string`&&!aK(s,r,i))return{ok:!1,error:CU({code:`PATH_DENIED`,message:`patches[${e}] move 目标 "${s}" 不在 schema 声明字段内`,hint:`move 的 value(目标路径)也须在 schema 声明字段内${y2(v2(r,b2(String(s))))}`})}}o===`append`&&h.push({jp:a,elems:Array.isArray(s)?[...s]:[s]}),o===`move`&&g.push({jp:a,toPath:String(s),elem:rq(p,a)});let c=hq(p,o,a,s);if(c)return{ok:!1,error:CU({code:`PATCH_FAILED`,message:`patches[${e}]: ${c}`,hint:`检查 op 与目标类型:merge 需对象,append 需数组`})};v(o,a),m.push({op:o,jp:a,value:s})}if(d){let e=Ode({patches:n,clone:p,ctx:d});if(!e.ok)return{ok:!1,error:e.error}}let y=S2({schema:r,bindRef:t,clone:p,patches:n,schemaErrorMode:c,appendCaptures:h,moveCaptures:g,valueAt:e=>_.find(t=>t.jp===e)?.val});if(!y.ok)return{ok:!1,error:y.error};if(u)return{ok:!0,applied:m,clone:p,notices:y.notices};let b=a.length?a[a.length-1].id+1:1;for(a.push({id:b,ts:Date.now(),op:`edit`,value:f??oq(t),...l?{label:l}:{}});a.length>o;)a.shift();for(let e of y.writeBacks)if(e.op===`remove`)aq(t,e.jp);else if(e.op===`set`)iq(t,e.jp,e.value);else if(e.op===`move`)_q(t,e.jp,e.toPath);else if(e.op===`mergeKeys`){let n=e.jp?rq(t,e.jp):t;if(n&&typeof n==`object`&&!Array.isArray(n))for(let[t,r]of e.entries??[])n[t]=r}else if(e.op===`appendElems`){let n=e.jp?rq(t,e.jp):t;Array.isArray(n)&&e.elems?.length&&n.push(...e.elems)}return e.internalAfterWrite?.(t,f),s?.(),{ok:!0,applied:m,clone:p,notices:y.notices}}function T2(e){let t=/^<[A-Za-z_][\w.-]*\s[\d.]+[KMG]?B>$/,n=e=>{if(typeof e==`string`)return e.includes(`<subtree `)||t.test(e)?e.slice(0,60):null;if(Array.isArray(e)){for(let t of e){let e=n(t);if(e)return e}return null}if(e&&typeof e==`object`)for(let t of Object.values(e)){let e=n(t);if(e)return e}return null};return n(e)}var E2=(e,t)=>CU({code:`PLACEHOLDER_LEAK`,path:t||void 0,message:`写入值包含摘要占位符 "${e}"(read/query 为省上下文返回的体积占位,非真实数据),已拒绝写入`,hint:`占位符子树的真实内容需先窄读获取:read({jsonPath:"<该子树路径>"}) 结果根豁免返回全文;聚焦该区域可用 set_focus。基于真实值重新构造写入内容`});function D2(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}var Ade=3072;function jde(e){return typeof e==`string`?e.length+2:typeof e==`number`||typeof e==`boolean`?8:4}function O2(e,t,n,r,i){if(!t||e==null)return e;let a=new Set(n.map(e=>e.field)),o=r,s=Ade,c=i?.rootExempt??!1,l=i?.rootPath??``,u=i?.fullTextPrefixes??[],d=oq(e),f=i?.onSummarized,p=e=>u.some(t=>t&&(e===t||e.startsWith(t+`.`)||e.startsWith(t+`[`))),m=(e,t)=>{let n=`#`+String(pq(e)).slice(0,8);if(Array.isArray(e))return`<subtree ${D2(t)} children:${e.length} ${n}>`;let r=Object.keys(e),i=r.slice(0,6).join(`,`)+(r.length>6?`,…`:``);return`<subtree ${D2(t)} keys:[${i}] ${n}>`},h=(e,t,n)=>{if(typeof e!=`object`||!e)return{node:e,eff:jde(e)};if(p(t))return{node:e,eff:40};if(Array.isArray(e)){let r=2;for(let n=0;n<e.length;n++){let i=h(e[n],`${t}.${n}`,!1);e[n]=i.node,r+=i.eff}return!(n&&c)&&r>=s?(f?.(t),{node:m(e,r),eff:40}):{node:e,eff:r}}let r=2;for(let n of Object.keys(e)){let i=e[n],s=t?`${t}.${n}`:n;if(typeof i==`string`&&a.has(n)&&i.length>=o&&!p(s))e[n]=`<${n} ${D2(i.length)}>`,f?.(s),r+=e[n].length+n.length+2;else{let t=h(i,s,!1);e[n]=t.node,r+=t.eff+n.length+2}}return!(n&&c)&&r>=s?(f?.(t),{node:m(e,r),eff:40}):{node:e,eff:r}};return h(d,l,!0).node}var k2=0;function Mde(){return k2++,`c_`+Math.random().toString(36).slice(2,8)+k2.toString(36)}function A2(e,t){if(!(!e||typeof e!=`object`))for(let n of t){let t=rq(e,n);if(Array.isArray(t))for(let e of t)e&&typeof e==`object`&&!(`__pgId`in e)&&(e.__pgId=Mde())}}function j2(e){(function e(t){if(Array.isArray(t))t.forEach(e);else if(t&&typeof t==`object`)for(let n of Object.keys(t))n.startsWith(`__pg`)?delete t[n]:e(t[n])})(e)}function M2(e,t={}){let n=t.pgIdPaths??[],r=n.length?(e,t)=>{if(t&&typeof t==`object`)for(let r of n){let n=rq(t,r),i=rq(e,r);if(!Array.isArray(n)||!Array.isArray(i))continue;let a=e=>{if(!e||typeof e!=`object`)return e;let t={...e};return delete t.__pgId,t},o=new Set;for(let e=0;e<i.length;e++){let t=i[e];if(!(!t||typeof t!=`object`||`__pgId`in t))for(let e=0;e<n.length;e++){if(o.has(e))continue;let r=n[e];if(!(!r||typeof r!=`object`||!r.__pgId)&&f2(a(r),a(t))){t.__pgId=r.__pgId,o.add(e);break}}}for(let e=0;e<n.length&&e<i.length;e++){if(o.has(e))continue;let t=n[e]?.__pgId,r=i[e];t&&r&&typeof r==`object`&&!(`__pgId`in r)&&(r.__pgId=t,o.add(e))}}A2(e,n)}:void 0,i=n.length?MK(e.schema,n).schema:e.schema,a=e.bind,o=e.description??`主数据对象`,s=iK(i),c=new Map,l=t.vfsStore?new Ede(t.vfsStore):void 0;function u(e){if(c.clear(),e)for(let t of e){let e=u2(t.path);c.set(e,{path:e,mode:t.mode})}}u(e.resources);let d=c.size?{resourcesByPath:c,resourceStore:l,getBind:()=>a}:void 0,f=[],p=t.maxSnapshots??20,m=new Map,h=``,g=e=>e?.configurable?.__pgDataScope??h,_=e=>{let t=e?.configurable?.__pgFullTextPaths;return Array.isArray(t)?t.map(String):void 0},v=new Set,y=e=>{for(v.add(e);v.size>500;)v.delete(v.values().next().value)},b=e=>m.get(e??h),x=(e,t)=>{let n=t??h;e===void 0?m.delete(n):m.set(n,e)},S=t.conflictWatchFields??[],C=!S.includes(`*`)&&S.length?new Set(S):void 0,w=S.length>0,T=()=>C?mq(a,C):pq(a),E=(t.maxParallelTools??1)>1&&w,D=!1,ee=[];async function O(){if(!E)return{release:()=>{},reacquire:async()=>{}};D?await new Promise(e=>ee.push(e)):D=!0;let e=!0;return{release:()=>{if(!e)return;e=!1;let t=ee.shift();t?t():D=!1},reacquire:async()=>{e||=(D?await new Promise(e=>ee.push(e)):D=!0,!0)}}}(t.maxParallelTools??1)>1&&!w&&console.warn(`[page-agent-sdk] maxParallelTools>1 且未声明 conflictWatchFields:并发写不互锁(后写覆盖前写,既有明文语义);声明 conflictWatchFields 后自动启用写互锁与乐观锁校验`);let k=e=>{let t=T();return x(t,e),t},te=t.largeTextThreshold??200,A=(t.largeTextPaths??[]).map(e=>{let t=e.lastIndexOf(`.`);return t>0?{arrayPath:e.slice(0,t),field:e.slice(t+1)}:null}).filter(e=>e!==null),ne=!0;function j(){ne=!0}let re={get:()=>({schema:i,bind:a,description:o}),set:e=>{i=n.length?MK(e.schema,n).schema:e.schema,a=e.bind,o=e.description??`主数据对象`,s=iK(i),f.length=0,m.clear(),u(e.resources),l?.clear(),j()},update:e=>{a=e,f.length=0,m.clear(),j()},markDataDirty:j,consumeDataDirty:()=>{let e=ne;return ne=!1,e},enterScope:e=>{let t=h;return h=e,()=>{h=t}},exitScope:e=>{m.delete(e)},recomputeBaseline:e=>{m.set(e??``,T())},recomputeAllBaselines:()=>{let e=T();for(let t of m.keys())m.set(t,e)},hasBaselines:()=>m.size>0,getSummarizedPaths:()=>[...v],clearSummarizedPaths:()=>v.clear(),getResourcesSnapshot:()=>{let e=[];for(let[t,n]of c)if(n.mode===`verbatim`){let r=l?.get(t);e.push(r?.handle?{path:t,mode:n.mode,handle:r.handle}:{path:t,mode:n.mode})}else e.push({path:t,mode:n.mode});return e},createResource:l?(e,t)=>{let n=u2(e),r=c.get(n),i=t===void 0?rq(a,n):t;return l.ensure(n,i,r?.mode??`verbatim`)}:void 0,getResource:l?e=>{let t=l.get(e);return t?{path:t.path,mode:t.mode,value:t.value,handle:t.handle}:void 0}:void 0,updateResource:l?(e,t)=>{let n=u2(e);l.update(n,t),iq(a,n,t),j(),x(T(),``)}:void 0,deleteResource:l?e=>l.delete(e):void 0,listResources:l?()=>l.list():void 0},M=e=>{t.onAudit?.(e)};function ie(e,t){let n=oq(a),r=f.length?f[f.length-1].id+1:1;for(f.push({id:r,ts:Date.now(),op:e,label:t,value:n});f.length>p;)f.shift();return r}async function ae(e,n,r,i){if(!n||n===``)return null;let o=T();if(o===n)return null;if(!t.onConflict)return CU({code:`VERSION_CONFLICT`,message:`乐观锁冲突:expectedHash=${n} 但当前 hash=${o}。主数据在你 read 之后已被修改(外部代码/其他 agent/用户手动改)。`,hint:`重新 read 拿最新值与 hash,基于最新值修改后再写入。当前值:${dq(a,400)}`});i?.release();let s=await t.onConflict({op:e,agentValue:r,currentValue:a,currentHash:o,expectedHash:n,snapshotId:0});if(s.action===`keep_external`)return`已保留外部修改(未写入)。当前值:${dq(a,400)} (hash=${o})。请重新 read 拿最新值与 hash 再改。`;if(s.action===`restore`){if(await i?.reacquire(),!f.length)return`无历史快照可回退(本次为首次操作)。当前值:${dq(a,400)} (hash=${o})。请重新 read 再改或选「强制覆盖」。`;let e=f[f.length-1];return yq(a,oq(e.value)),j(),x(T()),`已回退主数据到历史快照 #${e.id}[${e.op}]。当前值:${dq(a,400)} (hash=${T()})。请基于回退后的值重写或停止。`}await i?.reacquire();let c=T();return c===o?(x(T()),null):(M({op:`conflict_recheck`,detail:`裁决基于 ${o} 恢复时 ${c}(ask 窗口新修改落地,overwrite 被拦)`,timestamp:Date.now()}),CU({code:`VERSION_CONFLICT`,message:`裁决恢复点校验失败:裁决基于 hash=${o},恢复时主数据已变为 hash=${c}(裁决等待期间又有新修改落地,裁决者未见过)。`,hint:`重新 read 拿最新值与 hash,基于最新值修改后再写入(单次校验,不再二次挂起)。`}))}let oe=(e,t=!0)=>{e.writeCapable=t},se=VI(async()=>[`说明: ${o}`,`格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误,含具体字段与期望类型)。`].join(`
250
+ `)}`:`未找到匹配 /${t}/ 的内容。`},{name:`vfs_grep`,description:`在虚拟工作区文件内容中正则搜索。`,schema:B({pattern:R().describe(`正则表达式`),path:R().optional().describe(`限定单个文件,不传则搜索全部`)})}),VI(async({path:t,jsonPath:n})=>{let r=r2(t),i=e.files[r];if(!i)return CU({code:`NOT_FOUND`,path:t,message:`未找到文件 "${t}"`,hint:`用 vfs_ls 查看虚拟工作区文件列表`});let a;try{a=JSON.parse(i.content)}catch(e){return CU({code:`VFS_JSON_INVALID`,path:t,message:`文件内容非合法 JSON: ${e.message}`,hint:`vfs_json_read 要求文件内容是合法 JSON;先 vfs_read 查看实际内容,或 vfs_write({jsonString:true}) 重写为合法 JSON`})}if(n){let e=rq(a,n);return e===void 0?CU({code:`VFS_PATH_NOT_FOUND`,path:t,message:`jsonPath "${n}" 不存在`,hint:`不传 jsonPath 整体读查看结构,或核对路径段`}):`${t}#${n} (JSON):\n${JSON.stringify(e)}`}return`${t} (JSON):\n${JSON.stringify(a)}`},{name:`vfs_json_read`,description:`把虚拟工作区文件当 JSON 读取:先 parse 整文件,再按 jsonPath 取子树(省略返整体)。文件非合法 JSON 报 VFS_JSON_INVALID。适合结构化读取 vfs 内大 JSON。`,schema:B({path:R().describe(`文件路径(内容须为合法 JSON)`),jsonPath:R().optional().describe(`点分隔子路径(如 components.0.title);省略读整体`)})}),VI(async({path:t,patches:n})=>{let r=r2(t),i=e.files[r];if(!i)return CU({code:`NOT_FOUND`,path:t,message:`未找到文件 "${t}"`,hint:`用 vfs_ls 查看虚拟工作区文件列表`});let a;try{a=JSON.parse(i.content)}catch(e){return CU({code:`VFS_JSON_INVALID`,path:t,message:`文件内容非合法 JSON: ${e.message}`,hint:`vfs_json_patch 要求文件内容是合法 JSON`})}let o=oq(a),s=[];for(let e of n){let n=hq(o,e.op,e.jsonPath,e.value);if(n)return CU({code:`PATCH_FAILED`,path:t,message:n,hint:`修正 patches 后重试(原文件未改动)`,details:{failedPatch:e}});s.push(e.jsonPath||`(根)`)}let c=JSON.stringify(o);return e.files[r]={content:c,updatedAt:i2()},`已对 ${t} 应用 ${n.length} 个 patch(影响 ${s.length} 处:${s.join(`, `)}),文件现 ${c.length} 字符`},{name:`vfs_json_patch`,description:`在虚拟工作区 JSON 文件内做原子 jsonPath patch(set/remove/merge/append)。先 parse → clone 上应用全部 patches → 任一失败或 JSON 非法则整体不写回(原文件不变)。`,schema:B({path:R().describe(`文件路径(内容须为合法 JSON)`),patches:z(B({op:Vd([`set`,`remove`,`merge`,`append`]).describe(`操作`),jsonPath:R().describe(`点分隔路径(如 components.0.title);merge/append 目标可为根(空串)`),value:Cd().optional().describe(`set/merge/append 的值(remove 不需要)`)})).describe(`按顺序应用的 patch 列表(原子:任一失败整体不写回)`)})}),VI(async({path:t})=>{let n=r2(t);return e.files[n]?(delete e.files[n],`已删除 ${t}`):CU({code:`NOT_FOUND`,path:t,message:`未找到文件 "${t}",无需删除`,hint:`用 vfs_ls 查看虚拟工作区文件列表`})},{name:`vfs_rm`,description:`删除虚拟工作区文件(清理中间产物 / drafts 下草稿,补「只进不出」的闭环)。不存在返回 NOT_FOUND。`,schema:B({path:R().describe(`要删除的文件路径`)})})]}function wde(e){return{name:`vfs`,tools:Cde(e),beforeAgent:()=>({files:e.files})}}var a2=`⟦frozen:`,o2=`⟦res:`,s2=`⟧`;function c2(e){return`${a2}${e}${s2}`}function l2(e){return`${o2}${e}${s2}`}function Tde(e){return typeof e==`string`?e.startsWith(a2)&&e.endsWith(s2)?{type:`frozen`,path:e.slice(8,e.length-1)}:e.startsWith(o2)&&e.endsWith(s2)?{type:`res`,handle:e.slice(5,e.length-1)}:null:null}function u2(e){return String(e??``).trim().replace(/^\.+/,``)}function d2(e){let t=5381;for(let n=0;n<e.length;n++)t=(t*33^e.charCodeAt(n))>>>0;return(t>>>0).toString(16).padStart(8,`0`).slice(0,8)}function f2(e,t){return e===t?!0:e&&t&&typeof e==`object`&&typeof t==`object`?JSON.stringify(e)===JSON.stringify(t):!1}function p2(e,t){let n=u2(e);if(!n)return;let r=t.get(n);if(r)return{spec:r,relation:`exact`,protectedPath:n};let i;for(let[e,r]of t)n!==e&&(n.startsWith(e+`.`)?(!i||e.length>i.protectedPath.length)&&(i={spec:r,protectedPath:e,relation:`descendant`}):e.startsWith(n+`.`)&&(!i||e.length<i.protectedPath.length)&&(i={spec:r,protectedPath:e,relation:`ancestor`}));return i}var Ede=class{vfs;constructor(e){this.vfs=e}key(e){return`resources/${e}.json`}ensure(e,t,n){let r=d2(e),i={path:e,mode:n,value:t,handle:r};return this.vfs.files[this.key(r)]={content:JSON.stringify(i),updatedAt:Date.now()},r}get(e){return this.readEntry(this.key(e))||this.readEntry(this.key(d2(e)))}readEntry(e){let t=this.vfs.files[e];if(t)try{let e=JSON.parse(t.content);return e&&typeof e.path==`string`?e:void 0}catch{return}}update(e,t){let n=this.get(e);this.ensure(e,t,n?.mode??`verbatim`)}delete(e){let t=this.get(e)?.handle??d2(e),n=this.key(t),r=!!this.vfs.files[n];return r&&delete this.vfs.files[n],r}list(){let e=[];for(let[t,n]of Object.entries(this.vfs.files))if(t.startsWith(`resources/`))try{let t=JSON.parse(n.content);t&&typeof t.path==`string`&&e.push({path:t.path,mode:t.mode,handle:t.handle,bytes:n.content.length})}catch{}return e}clear(){for(let e of Object.keys(this.vfs.files))e.startsWith(`resources/`)&&delete this.vfs.files[e]}};function m2(e){let{jp:t,resolved:n,resourcesByPath:r,resourceStore:i}=e;if(!r.size)return n;let a=!1;for(let e of r.keys())if(t===``||e===t||e.startsWith(t+`.`)){a=!0;break}if(!a)return n;let o=oq(n);for(let[e,n]of r){if(t!==``&&e!==t&&!e.startsWith(t+`.`))continue;if(e===t){if(o===void 0)continue;return n.mode===`freeze`?c2(e):i?l2(i.ensure(e,o,`verbatim`)):o}let r=t===``?e:e.slice(t.length+1),a=rq(o,r);a!==void 0&&(n.mode===`freeze`?iq(o,r,c2(e)):i&&iq(o,r,l2(i.ensure(e,a,`verbatim`))))}return o}function Dde(e,t,n,r){if(!r)return{code:`RESOURCE_NOT_FOUND`,message:`句柄 "${e}" 无法展开(资源池未启用)`,hint:`verbatim 保护需启用 vfs(capabilities.vfs 默认开);集成方经 createChatSdk 配 data.resources 时自动提供 vfsStore`};let i=r.get(e);return i?n===void 0?{code:`RESOURCE_NOT_FOUND`,message:`字段 "${t}" 在 bind 中已不存在,无法展开句柄 "${e}"`,hint:`该字段可能已被删除或 restore 到不含此字段的快照;重新 read 确认当前结构`}:f2(i.value,n)?{value:i.value}:(r.update(t,n),{value:n}):n===void 0?{code:`RESOURCE_NOT_FOUND`,message:`句柄 "${e}" 不存在(字段 "${t}" 可能未注册或已被删除)`,hint:`重新 read 该字段触发懒注册`}:{code:`RESOURCE_EVICTED`,message:`字段 "${t}" 的 verbatim 资源已被淘汰(资源池 LRU)`,hint:`重新 read 该字段触发懒注册重建句柄,再写回新句柄 ⟦res:<handle>⟧`}}function h2(e,t,n){let r=t.getBind();for(let[i,a]of t.resourcesByPath){let o=rq(r,i),s=rq(e,i);if(s===void 0){if(o===void 0)continue;let t=i.split(`.`);if(rq(e,t.length>1?t.slice(0,-1).join(`.`):``)!==void 0){iq(e,i,o);continue}if(!(e&&typeof e==`object`&&t[0]in e)){if(n)continue;iq(e,i,o);continue}return{ok:!1,code:a.mode===`freeze`?`FROZEN_FIELD`:`VERBATIM_PROTECTED`,path:i,message:`整体替换会移除受保护字段 "${i}"(${a.mode}),已拒绝`,hint:a.mode===`freeze`?`含冻结字段的容器不可整体清空/替换:保留包含该字段的元素(补齐其必填字段,如 type),或逐个 remove 其余元素;彻底移除该字段需集成方调整 data.resources`:`含 verbatim 字段的容器不可整体清空/替换:保留包含该字段的元素,或先 resource_delete({path}) 释放保护后再整体替换`}}if(a.mode===`freeze`){if(s===c2(i)){iq(e,i,o);continue}if(!f2(s,o))return{ok:!1,code:`FROZEN_FIELD`,path:i,message:`字段 "${i}" 已冻结(freeze 保护),不可修改`,hint:`该字段由系统/集成方维护,LLM 不得改动。如需展示其值用 resource_get({path}) 取真值`}}else{let n=Tde(s);if(n&&n.type===`res`){let r=Dde(n.handle,i,o,t.resourceStore);if(`value`in r){iq(e,i,r.value);continue}return{ok:!1,code:r.code,path:i,message:r.message,hint:r.hint}}if(!f2(s,o))return{ok:!1,code:`VERBATIM_MISMATCH`,path:i,message:`字段 "${i}" 为 verbatim 保护(精确原样保留),写入值与原值不符`,hint:`要改该值请先 resource_update({path, value}) 更新资源池,再写回句柄 ⟦res:<handle>⟧;或写回原值(经 resource_get 取到的值)保持不变`}}}return{ok:!0}}function g2(e,t,n){let r=t===void 0?e.message:`patches[${t}]${n?` @ "${n}"`:``}: ${e.message}`;return CU({code:e.code,path:e.path,message:r,hint:e.hint,...t===void 0?{}:{details:{patchIndex:t,patchJsonPath:n??null}}})}function _2(e){let{value:t,ctx:n,mergeMode:r}=e;if(!n||!n.resourcesByPath.size)return{ok:!0,value:t};let i=oq(t),a=h2(i,n,r);return a.ok?{ok:!0,value:i}:{ok:!1,error:g2(a)}}function Ode(e){let{patches:t,clone:n,ctx:r}=e;if(!r||!r.resourcesByPath.size)return{ok:!0};for(let e=0;e<t.length;e++){let n=t[e];if(n.op===`remove`){let t=p2(n.jsonPath||``,r.resourcesByPath);if(t){let r=t.spec.mode===`freeze`?`FROZEN_FIELD`:`VERBATIM_PROTECTED`,i=t.spec.mode===`freeze`?`冻结字段不可删。如需移除请联系集成方调整 data.resources 配置`:`verbatim 字段不可直接删;先 resource_delete({path}) 释放资源保护后再删`;return{ok:!1,error:CU({code:r,path:t.protectedPath,message:`patches[${e}] @ "${n.jsonPath}" 命中受保护字段 "${t.protectedPath}"(${t.spec.mode}),不可删除`,hint:i,details:{patchIndex:e,patchJsonPath:n.jsonPath??``}})}}}}let i=h2(n,r);if(!i.ok){let e=kde(i.path,t);return{ok:!1,error:g2(i,e>=0?e:void 0,e>=0?t[e].jsonPath:void 0)}}return{ok:!0}}function kde(e,t){let n=u2(e);for(let e=0;e<t.length;e++){let r=u2(t[e].jsonPath||``);if(r&&(r===n||n.startsWith(r+`.`)||r.startsWith(n+`.`)))return e}return-1}Jp();function v2(e,t){if(!e)return null;let n=(t?sK(e,t):e)?.shape;return n&&typeof n==`object`?Object.keys(n):null}var y2=e=>e&&e.length?`(可用字段:${e.slice(0,12).join(`, `)}${e.length>12?` …`:``})`:``,b2=e=>/[.[]/.test(e)?e.replace(/[.[][^.[]*$/,``):``;function x2(e){let{schema:t,allowKeys:n,value:r,bindRef:i}=e,a=[];if(n){if(typeof r!=`object`||!r||Array.isArray(r))return{ok:!1,error:TU(``,[{path:[],code:`invalid_type`,message:`整体 set 需为 JSON 对象(当前为 ${Array.isArray(r)?`array`:r===null?`null`:typeof r})`,expected:`object`}]),notices:a};let e=i&&typeof i==`object`&&!Array.isArray(i)?i:{},n=r,o={};for(let r of Object.keys(n)){if(r.startsWith(`__pg`))continue;let i=n[r],s=dK(t,r,i);if(!s.ok){if(s.resolution===`missing`){if(r in e)continue;return{ok:!1,error:CU({code:`SCHEMA_STRIP`,message:`字段 ${r} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试${y2(v2(t,``))}`,path:r,details:{stripped:[r]}}),notices:a}}return{ok:!1,error:TU(r,s.issues??[]),notices:a}}s.resolution===`open`&&a.push(`${r}=开放节点放行`);let c=xq(e[r],i,s.data,r);if(c.length)return{ok:!1,error:CU({code:`SCHEMA_STRIP`,message:`字段 ${c.join(`, `)} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试${y2(v2(t,b2(String(c[0]))))}`,path:c[0],details:{stripped:c}}),notices:a};o[r]=s.data}return fK(t)&&a.push(`根级 refine/superRefine 不再在 write 时执行(走 capabilities.verify)`),{ok:!0,assembly:o,wholeParsed:null,notices:a}}let o=t.safeParse(r);if(!o.success)return{ok:!1,error:TU(``,o.error.issues),notices:a};let s=xq(i,r,o.data);return s.length?{ok:!1,error:CU({code:`SCHEMA_STRIP`,message:`字段 ${s.join(`, `)} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试`,path:s[0],details:{stripped:s}}),notices:a}:{ok:!0,assembly:o.data,wholeParsed:o.data,notices:a}}function S2(e){let{schema:t,bindRef:n,clone:r,patches:i,schemaErrorMode:a=`zod`,appendCaptures:o,moveCaptures:s}=e,c=[],l=t=>{let n=rq(r,t);return n===void 0?e.valueAt?.(t):n},u=(e,t)=>a===`schema_invalid`?CU({code:`SCHEMA_INVALID`,message:`patches 应用后局部校验失败 @ "${e}",未写入`,hint:`确认该路径的值符合 schema;兄弟节点的既有数据不影响本次写入`,details:wU(t)}):TU(e,t),d=e=>CU({code:`SCHEMA_STRIP`,message:`字段 ${e.join(`, `)} 不在 schema 声明内,写入被拒绝(防静默丢失)`,hint:`该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试`,path:e[0],details:{stripped:e}}),f=[];fK(t)&&c.push(`根级 refine/superRefine 不再在 write 时执行(走 capabilities.verify)`);let p=0,m=0;for(let e of i){let i=e.op??`set`,a=e.jsonPath||``;if(i===`remove`){let e=a.lastIndexOf(`.`);if(e>0&&/^\d+$/.test(a.slice(e+1))){let n=a.slice(0,e),i=uK(t,n);if(i.kind===`schemas`){let e=rq(r,n);if(Array.isArray(e))for(let t of i.schemas){let r=pK(t);if(r!==null&&e.length<r)return{ok:!1,error:u(n,[{path:[n],code:`too_small`,message:`删除后数组长度 ${e.length} 低于 schema 最小约束 ${r}`,expected:`>=${r}`}]),writeBacks:[],notices:c}}}}f.push({op:`remove`,jp:a});continue}if(i===`move`){let n=s[m++];if(n&&n.elem!==void 0){let e=n.toPath.lastIndexOf(`.`),r=e>0&&/^\d+$/.test(n.toPath.slice(e+1))?n.toPath.slice(0,e):n.toPath,i=uK(t,r);if(i.kind===`schemas`){let e=mK(i.schemas);if(e.length){let t=[],r=!1;for(let i of e){let e=i.safeParse(n.elem);if(e.success){r=!0;break}t.push(...e.error?.issues??[])}if(!r)return{ok:!1,error:u(n.toPath,t),writeBacks:[],notices:c}}}else i.kind===`open`&&c.push(`${r}=开放节点放行`)}f.push({op:`move`,jp:a,toPath:String(e.value)});continue}if(i===`append`){let e=o[p++]?.elems??[],r=rq(n,a);if(typeof r==`string`&&typeof e[0]==`string`){let n=e[0],i=uK(t,a);if(i.kind===`missing`)return{ok:!1,error:d([a]),writeBacks:[],notices:c};let o=r+n;if(i.kind!==`open`){let e=i.schemas.map(e=>e.safeParse(o)).find(e=>!e.success);if(e)return{ok:!1,error:u(a,e.error?.issues??[]),writeBacks:[],notices:c}}f.push({op:`appendStr`,jp:a,str:n});continue}if(!e.length){f.push({op:`appendElems`,jp:a,elems:[]});continue}let i=uK(t,a);if(i.kind===`missing`)return{ok:!1,error:d([a||`(根)`]),writeBacks:[],notices:c};if(i.kind===`open`){c.push(`${a||`(根)`}=开放节点放行`),f.push({op:`appendElems`,jp:a,elems:e});continue}let s=mK(i.schemas);if(!s.length){c.push(`${a||`(根)`}:目标非 schema 声明数组,元素未校验放行`),f.push({op:`appendElems`,jp:a,elems:e});continue}let l=[];for(let t=0;t<e.length;t++){let n=[],r,i=!1;for(let a of s){let o=a.safeParse(e[t]);if(o.success){i=!0,r=o.data;break}n.push(...o.error?.issues??[])}if(!i)return{ok:!1,error:u(`${a||`(根)`}[新增元素${t}]`,n),writeBacks:[],notices:c};let o=xq(void 0,e[t],r,a?`${a}.${t}`:String(t));if(o.length)return{ok:!1,error:d(o),writeBacks:[],notices:c};l.push(r)}f.push({op:`appendElems`,jp:a,elems:l});continue}if(i===`merge`){let r=e.value;if(typeof r==`string`){let e=cq(r);if(e.parseError)return{ok:!1,error:EU(`patches merge`,r,e.parseError),writeBacks:[],notices:c};r=e.parsed}if(typeof r!=`object`||!r||Array.isArray(r))return{ok:!1,error:CU({code:`PATCH_FAILED`,message:`merge 的 value 需为对象`,hint:`merge 合并对象键;整体替换用 set`}),writeBacks:[],notices:c};let i=[];for(let e of Object.keys(r)){if(e.startsWith(`__pg`)||eq.has(e))continue;let r=a?`${a}.${e}`:e,o=l(r),s=dK(t,r,o);if(!s.ok){if(s.resolution===`missing`){if(rq(n,r)===void 0)return{ok:!1,error:d([r]),writeBacks:[],notices:c};i.push([e,o]);continue}return{ok:!1,error:u(r,s.issues??[]),writeBacks:[],notices:c}}s.resolution===`open`&&c.push(`${r}=开放节点放行`);let f=xq(rq(n,r),o,s.data,r);if(f.length)return{ok:!1,error:d(f),writeBacks:[],notices:c};i.push([e,s.data])}f.push({op:`mergeKeys`,jp:a,entries:i});continue}let h=l(a),g=a.lastIndexOf(`.`);if(g>0&&/^\d+$/.test(a.slice(g+1))){let e=rq(r,a.slice(0,g));if(Array.isArray(e)){for(let t=0;t<e.length;t++)if(!(t in e))return{ok:!1,error:CU({code:`PATCH_FAILED`,message:`set @ "${a}" 越界数组索引产生稀疏空洞(父数组长度 ${e.length})`,hint:`数组索引须连续(≤ 当前长度);追加请用 op:"append"`}),writeBacks:[],notices:c}}}let _=dK(t,a,h);if(!_.ok){if(_.resolution===`missing`){if(rq(n,a)===void 0)return{ok:!1,error:d([a]),writeBacks:[],notices:c};f.push({op:`set`,jp:a,value:h});continue}return{ok:!1,error:u(a,_.issues??[]),writeBacks:[],notices:c}}_.resolution===`open`&&c.push(`${a||`(根)`}=开放节点放行`);let v=xq(rq(n,a),h,_.data,a);if(v.length)return{ok:!1,error:d(v),writeBacks:[],notices:c};f.push({op:`set`,jp:a,value:_.data})}return{ok:!0,writeBacks:f,notices:c}}function C2(e){let{bindRef:t,schema:n,allowKeys:r,snapshots:i,maxSnapshots:a,audit:o,dryRun:s,op:c=`set`,protectedCtx:l,snapshotLabel:u}=e,d=e.value,f=e.internalAfterWrite?oq(t):null,p=T2(d);if(p)return{ok:!1,error:E2(p)};if(l){let e=_2({value:d,ctx:l,mergeMode:!!r});if(!e.ok)return{ok:!1,error:e.error};d=e.value}let m=x2({schema:n,allowKeys:r,value:d,bindRef:t});if(!m.ok)return{ok:!1,error:m.error};let h=m.assembly;if(s)return{ok:!0,hash:``,data:h,notices:m.notices};if(typeof t!=`object`||!t)return{ok:!1,error:CU({code:`LEAF_BIND`,message:`主数据 bind 为原始类型(${t===null?`null`:typeof t}),无法就地替换外部持有的值引用`,hint:`主数据 bind 必须为对象/数组;叶子值请用对象包裹(如 {value:"x"})或集成方通过 sdk.setData 替换 bind`})};let g=oq(t),_=i.length?i[i.length-1].id+1:1;for(i.push({id:_,ts:Date.now(),op:c,value:g,...u?{label:u}:{}});i.length>a;)i.shift();return typeof h==`object`&&h&&(m.wholeParsed?bq(t,h):nq(t,h)),o({op:c,value:h,timestamp:Date.now()}),e.onWrite?.(),e.internalAfterWrite?.(t,f),{ok:!0,hash:e.hashFn?e.hashFn():pq(t),data:h,notices:m.notices}}function w2(e){let{bindRef:t,patches:n,schema:r,allowKeys:i,snapshots:a,maxSnapshots:o,markDataDirty:s,schemaErrorMode:c=`zod`,snapshotLabel:l,dryRun:u,protectedCtx:d}=e,f=e.internalAfterWrite?oq(t):null,p=oq(t),m=[],h=[],g=[],_=[],v=(e,t)=>{(e===`set`||e===`merge`)&&_.push({jp:t,val:rq(p,t)})};for(let e=0;e<n.length;e++){let t=n[e],a=t.jsonPath||``;if(tq(a))return{ok:!1,error:CU({code:`PATH_UNSAFE`,message:`patches[${e}] jsonPath "${a}" 含非法段`,hint:`使用正常属性路径,如 components.0.text`})};if(!aK(a,r,i))return{ok:!1,error:CU({code:`PATH_DENIED`,message:`patches[${e}] @ "${a}" 不在 schema 声明字段内`,hint:`仅 schema 声明的 key 可写${y2(v2(r,b2(a)))}`})};let o=t.op??`set`,s;if(o!==`remove`){if(t.value===void 0||t.value===``&&o===`move`)return{ok:!1,error:CU({code:`MISSING_VALUE`,message:`patches[${e}] ${o} 操作需要 value`,hint:`op 为 ${o} 时 value 必填;删除请用 op:'remove'`})};let n=cq(t.value);if(n.parseError)return{ok:!1,error:EU(`patches[${e}]`,t.value,n.parseError)};if(s=n.parsed,o!==`move`){let t=T2(s);if(t)return{ok:!1,error:E2(t,`patches[${e}] @ "${a}"`)}}if(o===`move`&&typeof s==`string`&&!aK(s,r,i))return{ok:!1,error:CU({code:`PATH_DENIED`,message:`patches[${e}] move 目标 "${s}" 不在 schema 声明字段内`,hint:`move 的 value(目标路径)也须在 schema 声明字段内${y2(v2(r,b2(String(s))))}`})}}o===`append`&&h.push({jp:a,elems:Array.isArray(s)?[...s]:[s]}),o===`move`&&g.push({jp:a,toPath:String(s),elem:rq(p,a)});let c=hq(p,o,a,s);if(c)return{ok:!1,error:CU({code:`PATCH_FAILED`,message:`patches[${e}]: ${c}`,hint:`检查 op 与目标类型:merge 需对象,append 需数组或字符串`})};v(o,a),m.push({op:o,jp:a,value:s})}if(d){let e=Ode({patches:n,clone:p,ctx:d});if(!e.ok)return{ok:!1,error:e.error}}let y=S2({schema:r,bindRef:t,clone:p,patches:n,schemaErrorMode:c,appendCaptures:h,moveCaptures:g,valueAt:e=>_.find(t=>t.jp===e)?.val});if(!y.ok)return{ok:!1,error:y.error};if(u)return{ok:!0,applied:m,clone:p,notices:y.notices};let b=a.length?a[a.length-1].id+1:1;for(a.push({id:b,ts:Date.now(),op:`edit`,value:f??oq(t),...l?{label:l}:{}});a.length>o;)a.shift();for(let e of y.writeBacks)if(e.op===`remove`)aq(t,e.jp);else if(e.op===`set`)iq(t,e.jp,e.value);else if(e.op===`move`)_q(t,e.jp,e.toPath);else if(e.op===`mergeKeys`){let n=e.jp?rq(t,e.jp):t;if(n&&typeof n==`object`&&!Array.isArray(n))for(let[t,r]of e.entries??[])n[t]=r}else if(e.op===`appendElems`){let n=e.jp?rq(t,e.jp):t;Array.isArray(n)&&e.elems?.length&&n.push(...e.elems)}else if(e.op===`appendStr`){let n=e.jp?rq(t,e.jp):t;typeof n==`string`&&typeof e.str==`string`&&iq(t,e.jp,n+e.str)}return e.internalAfterWrite?.(t,f),s?.(),{ok:!0,applied:m,clone:p,notices:y.notices}}function T2(e){let t=/^<[A-Za-z_][\w.-]*\s[\d.]+[KMG]?B>$/,n=e=>{if(typeof e==`string`)return e.includes(`<subtree `)||t.test(e)?e.slice(0,60):null;if(Array.isArray(e)){for(let t of e){let e=n(t);if(e)return e}return null}if(e&&typeof e==`object`)for(let t of Object.values(e)){let e=n(t);if(e)return e}return null};return n(e)}var E2=(e,t)=>CU({code:`PLACEHOLDER_LEAK`,path:t||void 0,message:`写入值包含摘要占位符 "${e}"(read/query 为省上下文返回的体积占位,非真实数据),已拒绝写入`,hint:`占位符子树的真实内容需先窄读获取:read({jsonPath:"<该子树路径>"}) 结果根豁免返回全文;聚焦该区域可用 set_focus。基于真实值重新构造写入内容`});function D2(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}var Ade=3072;function jde(e){return typeof e==`string`?e.length+2:typeof e==`number`||typeof e==`boolean`?8:4}function O2(e,t,n,r,i){if(!t||e==null)return e;let a=new Set(n.map(e=>e.field)),o=r,s=Ade,c=i?.rootExempt??!1,l=i?.rootPath??``,u=i?.fullTextPrefixes??[],d=oq(e),f=i?.onSummarized,p=e=>u.some(t=>t&&(e===t||e.startsWith(t+`.`)||e.startsWith(t+`[`))),m=(e,t)=>{let n=`#`+String(pq(e)).slice(0,8);if(Array.isArray(e))return`<subtree ${D2(t)} children:${e.length} ${n}>`;let r=Object.keys(e),i=r.slice(0,6).join(`,`)+(r.length>6?`,…`:``);return`<subtree ${D2(t)} keys:[${i}] ${n}>`},h=(e,t,n)=>{if(typeof e!=`object`||!e)return{node:e,eff:jde(e)};if(p(t))return{node:e,eff:40};if(Array.isArray(e)){let r=2;for(let n=0;n<e.length;n++){let i=h(e[n],`${t}.${n}`,!1);e[n]=i.node,r+=i.eff}return!(n&&c)&&r>=s?(f?.(t),{node:m(e,r),eff:40}):{node:e,eff:r}}let r=2;for(let n of Object.keys(e)){let i=e[n],s=t?`${t}.${n}`:n;if(typeof i==`string`&&a.has(n)&&i.length>=o&&!p(s))e[n]=`<${n} ${D2(i.length)}>`,f?.(s),r+=e[n].length+n.length+2;else{let t=h(i,s,!1);e[n]=t.node,r+=t.eff+n.length+2}}return!(n&&c)&&r>=s?(f?.(t),{node:m(e,r),eff:40}):{node:e,eff:r}};return h(d,l,!0).node}var k2=0;function Mde(){return k2++,`c_`+Math.random().toString(36).slice(2,8)+k2.toString(36)}function A2(e,t){if(!(!e||typeof e!=`object`))for(let n of t){let t=rq(e,n);if(Array.isArray(t))for(let e of t)e&&typeof e==`object`&&!(`__pgId`in e)&&(e.__pgId=Mde())}}function j2(e){(function e(t){if(Array.isArray(t))t.forEach(e);else if(t&&typeof t==`object`)for(let n of Object.keys(t))n.startsWith(`__pg`)?delete t[n]:e(t[n])})(e)}function M2(e,t={}){let n=t.pgIdPaths??[],r=n.length?(e,t)=>{if(t&&typeof t==`object`)for(let r of n){let n=rq(t,r),i=rq(e,r);if(!Array.isArray(n)||!Array.isArray(i))continue;let a=e=>{if(!e||typeof e!=`object`)return e;let t={...e};return delete t.__pgId,t},o=new Set;for(let e=0;e<i.length;e++){let t=i[e];if(!(!t||typeof t!=`object`||`__pgId`in t))for(let e=0;e<n.length;e++){if(o.has(e))continue;let r=n[e];if(!(!r||typeof r!=`object`||!r.__pgId)&&f2(a(r),a(t))){t.__pgId=r.__pgId,o.add(e);break}}}for(let e=0;e<n.length&&e<i.length;e++){if(o.has(e))continue;let t=n[e]?.__pgId,r=i[e];t&&r&&typeof r==`object`&&!(`__pgId`in r)&&(r.__pgId=t,o.add(e))}}A2(e,n)}:void 0,i=n.length?MK(e.schema,n).schema:e.schema,a=e.bind,o=e.description??`主数据对象`,s=iK(i),c=new Map,l=t.vfsStore?new Ede(t.vfsStore):void 0;function u(e){if(c.clear(),e)for(let t of e){let e=u2(t.path);c.set(e,{path:e,mode:t.mode})}}u(e.resources);let d=c.size?{resourcesByPath:c,resourceStore:l,getBind:()=>a}:void 0,f=[],p=t.maxSnapshots??20,m=new Map,h=``,g=e=>e?.configurable?.__pgDataScope??h,_=e=>{let t=e?.configurable?.__pgFullTextPaths;return Array.isArray(t)?t.map(String):void 0},v=new Set,y=e=>{for(v.add(e);v.size>500;)v.delete(v.values().next().value)},b=e=>m.get(e??h),x=(e,t)=>{let n=t??h;e===void 0?m.delete(n):m.set(n,e)},S=t.conflictWatchFields??[],C=!S.includes(`*`)&&S.length?new Set(S):void 0,w=S.length>0,T=()=>C?mq(a,C):pq(a),E=(t.maxParallelTools??1)>1&&w,D=!1,ee=[];async function O(){if(!E)return{release:()=>{},reacquire:async()=>{}};D?await new Promise(e=>ee.push(e)):D=!0;let e=!0;return{release:()=>{if(!e)return;e=!1;let t=ee.shift();t?t():D=!1},reacquire:async()=>{e||=(D?await new Promise(e=>ee.push(e)):D=!0,!0)}}}(t.maxParallelTools??1)>1&&!w&&console.warn(`[page-agent-sdk] maxParallelTools>1 且未声明 conflictWatchFields:并发写不互锁(后写覆盖前写,既有明文语义);声明 conflictWatchFields 后自动启用写互锁与乐观锁校验`);let k=e=>{let t=T();return x(t,e),t},te=t.largeTextThreshold??200,A=(t.largeTextPaths??[]).map(e=>{let t=e.lastIndexOf(`.`);return t>0?{arrayPath:e.slice(0,t),field:e.slice(t+1)}:null}).filter(e=>e!==null),ne=!0;function j(){ne=!0}let re={get:()=>({schema:i,bind:a,description:o}),set:e=>{i=n.length?MK(e.schema,n).schema:e.schema,a=e.bind,o=e.description??`主数据对象`,s=iK(i),f.length=0,m.clear(),u(e.resources),l?.clear(),j()},update:e=>{a=e,f.length=0,m.clear(),j()},markDataDirty:j,consumeDataDirty:()=>{let e=ne;return ne=!1,e},enterScope:e=>{let t=h;return h=e,()=>{h=t}},exitScope:e=>{m.delete(e)},recomputeBaseline:e=>{m.set(e??``,T())},recomputeAllBaselines:()=>{let e=T();for(let t of m.keys())m.set(t,e)},hasBaselines:()=>m.size>0,getSummarizedPaths:()=>[...v],clearSummarizedPaths:()=>v.clear(),getResourcesSnapshot:()=>{let e=[];for(let[t,n]of c)if(n.mode===`verbatim`){let r=l?.get(t);e.push(r?.handle?{path:t,mode:n.mode,handle:r.handle}:{path:t,mode:n.mode})}else e.push({path:t,mode:n.mode});return e},createResource:l?(e,t)=>{let n=u2(e),r=c.get(n),i=t===void 0?rq(a,n):t;return l.ensure(n,i,r?.mode??`verbatim`)}:void 0,getResource:l?e=>{let t=l.get(e);return t?{path:t.path,mode:t.mode,value:t.value,handle:t.handle}:void 0}:void 0,updateResource:l?(e,t)=>{let n=u2(e);l.update(n,t),iq(a,n,t),j(),x(T(),``)}:void 0,deleteResource:l?e=>l.delete(e):void 0,listResources:l?()=>l.list():void 0},M=e=>{t.onAudit?.(e)};function ie(e,t){let n=oq(a),r=f.length?f[f.length-1].id+1:1;for(f.push({id:r,ts:Date.now(),op:e,label:t,value:n});f.length>p;)f.shift();return r}async function ae(e,n,r,i){if(!n||n===``)return null;let o=T();if(o===n)return null;if(!t.onConflict)return CU({code:`VERSION_CONFLICT`,message:`乐观锁冲突:expectedHash=${n} 但当前 hash=${o}。主数据在你 read 之后已被修改(外部代码/其他 agent/用户手动改)。`,hint:`重新 read 拿最新值与 hash,基于最新值修改后再写入。当前值:${dq(a,400)}`});i?.release();let s=await t.onConflict({op:e,agentValue:r,currentValue:a,currentHash:o,expectedHash:n,snapshotId:0});if(s.action===`keep_external`)return`已保留外部修改(未写入)。当前值:${dq(a,400)} (hash=${o})。请重新 read 拿最新值与 hash 再改。`;if(s.action===`restore`){if(await i?.reacquire(),!f.length)return`无历史快照可回退(本次为首次操作)。当前值:${dq(a,400)} (hash=${o})。请重新 read 再改或选「强制覆盖」。`;let e=f[f.length-1];return yq(a,oq(e.value)),j(),x(T()),`已回退主数据到历史快照 #${e.id}[${e.op}]。当前值:${dq(a,400)} (hash=${T()})。请基于回退后的值重写或停止。`}await i?.reacquire();let c=T();return c===o?(x(T()),null):(M({op:`conflict_recheck`,detail:`裁决基于 ${o} 恢复时 ${c}(ask 窗口新修改落地,overwrite 被拦)`,timestamp:Date.now()}),CU({code:`VERSION_CONFLICT`,message:`裁决恢复点校验失败:裁决基于 hash=${o},恢复时主数据已变为 hash=${c}(裁决等待期间又有新修改落地,裁决者未见过)。`,hint:`重新 read 拿最新值与 hash,基于最新值修改后再写入(单次校验,不再二次挂起)。`}))}let oe=(e,t=!0)=>{e.writeCapable=t},se=VI(async()=>[`说明: ${o}`,`格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误,含具体字段与期望类型)。`].join(`
251
251
  `),{name:`describe_data`,description:`获取主数据的说明与格式要求。`,schema:B({})}),ce=VI(async({id:e},t)=>{let n=g(t);if(!f.length)return CU({code:`NO_SNAPSHOT`,message:`无快照可回退`,hint:`write 各写意图会自动存快照;或 history_data({list:true}) 查看可用快照`});let r=e===void 0?f[f.length-1]:f.find(t=>t.id===e);if(!r)return CU({code:`SNAPSHOT_NOT_FOUND`,message:`未找到快照 #${e}`,hint:`用 history_data({list:true}) 查看可用快照序号`});let o=i.safeParse(r.value);return o.success?(yq(a,oq(r.value)),j(),M({op:`restore`,detail:`#${r.id}`,timestamp:Date.now()}),x(T(),n),`已回退主数据到快照 #${r.id}[${r.op}]${r.label?`(${r.label})`:``}。`):CU({code:`SNAPSHOT_SCHEMA_INVALID`,message:`快照 #${r.id} 的值不符合当前 schema,无法回退`,hint:`schema 可能已变更;该快照已过期,选其他快照或重新设置`,details:wU(o.error.issues)})},{name:`restore_data`,description:`把主数据回退到某个快照(就地还原,保留响应式)。不传 id 则回退最近一次(快速回退)。可用 history_data({list:true}) 查看快照列表。`,schema:B({id:ud().int().optional().describe(`指定快照序号;不传则回退最近一次`)})});oe(ce);let le=VI(async({id:e,jsonPath:t,list:n})=>{if(n){if(!f.length)return`无快照。set/edit/delete 会自动存快照。`;let e=f.map(e=>{let t=JSON.stringify(e.value??``).length,n=new Date(e.ts).toLocaleTimeString(`zh-CN`,{hour12:!1});return` #${e.id} [${e.op}]${e.label?` "${e.label}"`:``} ${n} 修改前≈${t}字符`});return`主数据快照时间线(共 ${f.length} 条,默认最近一次):\n${e.join(`
252
252
  `)}\n用 history_data({id}) 查看某条快照内容;restore_data({id}) 回退;diff_data({snapshotId}) 对比差异。`}if(!f.length)return CU({code:`NO_SNAPSHOT`,message:`无历史快照可查看`,hint:`set/edit/delete 会自动存快照;或 history_data({list:true}) 查看可用序号`});let r=e===void 0?f[f.length-1]:f.find(t=>t.id===e);if(!r)return CU({code:`SNAPSHOT_NOT_FOUND`,message:`未找到快照 #${e}`,hint:`不传 id 查看最近一次;或 history_data({list:true}) 查看可用序号`});let a=oq(r.value),o=t||``;if(o){if(tq(o))return CU({code:`PATH_UNSAFE`,message:`jsonPath "${o}" 含非法段`,hint:`使用正常属性路径`});if(!aK(o,i,s))return CU({code:`PATH_DENIED`,message:`history_data @ "${o}" 不在 schema 声明字段内`,hint:`仅 schema 声明的 key 可读`});a=rq(a,o);let e=sK(i,o);e&&(a=bK(a,e))}else s&&(a=bK(a,i));return`快照 #${r.id}[${r.op}]${r.label?`(${r.label})`:``}${o?` @ ${o}`:``} = ${dq(a)}`},{name:`history_data`,description:`查看主数据快照(只读不回退当前)。list:true 列时间线;传 id 看某次快照内容(默认最近),jsonPath 可只看子路径。冲突诊断/看上一版用;对比差异用 diff_data;回退用 restore_data。`,schema:B({id:ud().int().optional().describe(`快照序号;不传则最近一次(list:true 时忽略)`),jsonPath:R().optional().describe(`只看快照的某子路径(相对主数据根);不传则整个快照`),list:gd().optional().describe(`true 则列出快照时间线元信息(序号/操作/标签/时间/大小);不传则查看单条快照内容`)})}),ue=VI(async({expr:e,limit:t},n)=>{let r=g(n);if(typeof a!=`object`||!a)return CU({code:`NOT_OBJECT`,message:`主数据不是对象/数组,无法查询(当前为 ${a===void 0?`undefined`:typeof a})`,hint:`query 仅适用于对象/数组;叶子用 read 读`});let o=s?bK(a,i):a,c;try{c=MW(o,e)}catch(t){return CU({code:`JSONPATH_SYNTAX`,message:`JSONPath 解析错误: ${t.message}`,hint:`语法子集:$ .key [n] ["key"] [*] [?(filter)] ..key ..*;filter:@.field op literal,&&/||/();对象根需先点出数组字段再过滤,如 $.components[?(@.x>1)]`,details:{expr:e}})}let l=t??50,u=c.slice(0,l),d=_(n),f=u.map(e=>`{"path":${JSON.stringify(e.path)},"index":${e.index===void 0?`null`:e.index},"value":${dq(O2(e.value,r===``,A,te,{rootExempt:!1,rootPath:String(e.path??``),fullTextPrefixes:d,onSummarized:y}))}}`);return`{"matched":${c.length},"returned":${u.length},"truncated":${c.length>l},"results":[${f.join(`,`)}]}`},{name:`query_data`,description:`用 JSONPath 查询主数据(只读):$ 根/.key/[n]/[*]/[?(==/!=/</<=/>/>=,&&/||)]/..key 递归。返回匹配元素 path/index/value(path 可作 write patch 的 jsonPath);大数组筛选定位用它。`,schema:B({expr:R().describe(`JSONPath 表达式,如 $.components[?(@.type=="card" && @.price<100)] 或 $..title(递归找所有 title)`),limit:ud().int().min(1).max(200).optional().describe(`返回结果上限,默认 50`)})}),de=VI(async({query:e,mode:t,fuzzyThreshold:n,matchKey:r,limit:o})=>{if(a==null)return CU({code:`EMPTY`,message:`主数据为空,无可搜索内容`});try{let c=PW(s?bK(a,i):a,e,{mode:t,fuzzyThreshold:n,matchKey:r,limit:o??50});return dq({matched:c.length,results:c})}catch(t){return CU({code:`REGEX_INVALID`,message:`搜索错误: ${t.message}`,hint:`regex 模式下 query 须为合法正则;改 mode 为 substring/fuzzy 可避免正则语法问题`,details:{query:e}})}},{name:`search_data`,description:`主数据内文本搜索(只读)。mode:substring(默认,不区分大小写)/regex(i 标志)/fuzzy(Levenshtein ≤ fuzzyThreshold)。递归遍历叶子值返回命中 path+value(超 200 字符截断);找名字记不清的元素用它。`,schema:B({query:R().describe(`搜索词(substring/regex/fuzzy 共用)`),mode:Vd([`substring`,`regex`,`fuzzy`]).optional().describe(`匹配模式,默认 substring`),fuzzyThreshold:ud().int().min(0).max(5).optional().describe(`fuzzy 模式最大编辑距离,默认 2`),matchKey:gd().optional().describe(`是否同时匹配 key 名,默认 true`),limit:ud().int().min(1).max(200).optional().describe(`返回上限,默认 50`)})}),fe=VI(async({script:e,mode:t,jsonPath:n},o)=>{let c=g(o);if(e.length>8e3)return CU({code:`SCRIPT_TOO_LARGE`,message:`脚本过长(${e.length} 字符,上限 8000)`,hint:`精简脚本;复杂逻辑可分步(先 query 探查再 transform 改),或拆成多次 eval`});let l=n||``,u;if(l){if(!aK(l,i,s))return CU({code:`PATH_DENIED`,message:`eval_script @ "${l}" 不在 schema 声明字段内`,hint:`仅 schema 声明的 key 可作为子树`});if(u=rq(a,l),s){let e=sK(i,l);e&&(u=bK(u,e))}}else u=s?bK(a,i):a;let m=oq(u),h=await IW(m,e,l&&JSON.stringify(m).length>1e5?8e3:3e3);if(!h.ok){let t=/超时/.test(h.error||``);return CU({code:t?`SCRIPT_TIMEOUT`:`SCRIPT_ERROR`,message:`脚本执行失败: ${h.error}`,hint:t?`脚本可能有死循环或过重计算;加边界检查/分批;transform 返回完整新值勿返回巨大中间结果`:`检查脚本语法与运行时错误;入参为 data(主数据深拷贝),沙箱内禁用 fetch/XHR/WebSocket`,details:{elapsedMs:h.elapsedMs,scriptLen:e.length}})}if(t===`transform`){let e=h.result;if(l){let t=await O();try{let t=w2({bindRef:a,patches:[{op:`set`,jsonPath:l,value:e}],schema:i,allowKeys:s,snapshots:f,maxSnapshots:p,markDataDirty:j,schemaErrorMode:`schema_invalid`,snapshotLabel:`eval_transform_subtree`,internalAfterWrite:r,protectedCtx:d});return t.ok?(M({op:`edit`,detail:`eval_transform_subtree @ ${l}`,timestamp:Date.now()}),x(T(),c),`已通过脚本 transform 子树 @ ${l} 更新(耗时 ${h.elapsedMs}ms)。当前值: ${dq(a,600)}`):t.error}finally{t.release()}}if(e&&typeof e==`object`&&!Array.isArray(e)&&`patches`in e&&Array.isArray(e.patches)){if(typeof a!=`object`||!a)return CU({code:`LEAF_BIND`,message:`主数据 bind 为原始类型(${a===null?`null`:typeof a}),eval transform(patches) 无法就地替换`,hint:`主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind`});let t=await O();try{let t=w2({bindRef:a,patches:e.patches,schema:i,allowKeys:s,snapshots:f,maxSnapshots:p,markDataDirty:j,schemaErrorMode:`schema_invalid`,snapshotLabel:`eval_transform`,internalAfterWrite:r,protectedCtx:d});return t.ok?(M({op:`edit`,detail:`eval_transform(${t.applied.length} patches)`,timestamp:Date.now()}),x(T(),c),`已通过脚本 transform(patches) 更新主数据(${t.applied.length} 个 patch,耗时 ${h.elapsedMs}ms)。当前值: ${dq(a,600)}`):t.error}finally{t.release()}}let t=e,n=T2(t);if(n)return E2(n);if(d){let e=_2({value:t,ctx:d});if(!e.ok)return e.error;t=e.value}if(typeof a!=`object`||!a)return CU({code:`LEAF_BIND`,message:`主数据 bind 为原始类型(${a===null?`null`:typeof a}),eval transform 无法就地替换外部持有的值引用`,hint:`主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind`});let o=await O();try{let e=x2({schema:i,allowKeys:s,value:t,bindRef:a});return e.ok?(ie(`edit`,`eval_transform`),e.wholeParsed?bq(a,e.assembly):e.assembly!==null&&typeof e.assembly==`object`&&nq(a,e.assembly),j(),M({op:`edit`,detail:`eval_transform`,timestamp:Date.now()}),x(T(),c),`已通过脚本 transform 更新主数据(耗时 ${h.elapsedMs}ms)。当前值: ${dq(a,600)}`):CU({code:`SCHEMA_INVALID`,message:`脚本返回值校验失败,未写入(transform 模式要求返回主数据的完整新值或顶层 key 子集)`,hint:`确认脚本 return 了完整新值(非部分);或返回 {patches:[...]} 走增量模式;按 describe_data() 查看格式`,details:(e.error.match(/"details":\s*(\[[^\]]*\])/)?.[1]??``)||e.error})}finally{o.release()}}return dq({ok:!0,result:h.result,elapsedMs:h.elapsedMs})},{name:`eval_script`,description:`在 Worker 沙箱对主数据跑自定义 JS(无 window/fetch,超时 3s)。入参 data(深拷贝),返回值即结果。mode:query 只读回给 LLM(过滤/映射/聚合)/transform 落地(返回完整新值或 {patches:[...]} 增量)。jsonPath 可只对子树执行。`,schema:B({script:R().describe(`JS 脚本体,如 data.filter(c=>c.stock>0).map(c=>c.id);入参名 data;末尾表达式或 return 即返回值`),mode:Vd([`query`,`transform`]).optional().describe(`query=只读返回结果(默认),transform=校验后落地为新值`),jsonPath:R().optional().describe(`子树模式:仅对 jsonPath 指向的子树执行(降低大 JSON 成本);transform 时返回值作为该子树新值`)})});oe(fe,e=>e?.mode===`transform`);let N=VI(async({jsonPath:e,jsonPaths:t,fields:n,depth:r,offset:c,limit:l},u)=>{let f=g(u),p=_(u),m=T();if(t&&t.length){let e=!1,o=t.map(t=>{let o=t||``;if(!aK(o,i,s))return`- ${o||`(根)`}: [PATH_DENIED: 不在 schema 声明字段内]`;e=!0;let c=o?rq(a,o):a;if(!o&&s)c=bK(c,i);else if(s){let e=sK(i,o);e&&(c=bK(c,e))}let l=c;return d&&(l=m2({jp:o,resolved:l,resourcesByPath:d.resourcesByPath,resourceStore:d.resourceStore})),n&&n.length&&(l=lq(l,n)),r!=null&&(l=uq(l,r)),l=O2(l,f===``,A,te,{rootExempt:!0,rootPath:o,fullTextPrefixes:p,onSummarized:y}),l===void 0?`- ${o} = (undefined)`:`- ${o} = ${dq(l)}`});return e&&x(m,f),`多路径读取(共 ${t.length} 项,hash=${m}):\n${o.join(`
253
253
  `)}`}let h=e||``;if(tq(h))return CU({code:`PATH_UNSAFE`,message:`jsonPath "${h}" 含非法段(__proto__/constructor/prototype)`,hint:`使用正常属性路径,如 components.0.text(数组索引数字)`});let v=(e,t)=>v2(i,e)??(t&&typeof t==`object`&&!Array.isArray(t)?Object.keys(t):[]);if(!aK(h,i,s)){let e=/[.[]/.test(h)?h.replace(/[.[][^.[]*$/,``):``,t=v(e,e?rq(a,e):a),n=t.length?`;父级 "${e||`(root)`}" 的可用字段:${t.slice(0,12).join(`, `)}${t.length>12?` …`:``}`:``;return CU({code:`PATH_DENIED`,message:`read @ "${h}" 不在 schema 声明字段内`,hint:`主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它${n}`})}let b=h?rq(a,h):a;if(h&&b===void 0){let e=sK(i,h);if(!(e&&typeof e.isOptional==`function`&&e.isOptional())){let e=/[.[]/.test(h)?h.replace(/[.[][^.[]*$/,``):``,t=e?rq(a,e):a,n=v(e,t),r=Array.isArray(t)?`父级 "${e||`(root)`}" 是 ${t.length} 元数组,有效索引 0-${Math.max(t.length-1,0)};先 read({jsonPath:"${e}"}) 确认现状,追加元素走 write 的 append`:n.length?`父级 "${e||`(root)`}" 的可用字段:${n.slice(0,12).join(`, `)}${n.length>12?` …`:``};先 read({jsonPath:"${e}"}) 确认`:`父级 "${e||`(root)`}" 不存在或不是容器;先 read() 不传 jsonPath 查看顶层字段`;return CU({code:`PATH_NOT_FOUND`,path:h,message:`路径 "${h}" 不存在`,hint:r})}}if(!h&&s)b=bK(b,i);else if(s){let e=sK(i,h);e&&(b=bK(b,e))}let S=b;d&&(S=m2({jp:h,resolved:S,resourcesByPath:d.resourcesByPath,resourceStore:d.resourceStore})),x(m,f),n&&n.length&&(S=lq(S,n)),r!=null&&(S=uq(S,r)),S=O2(S,f===``,A,te,{rootExempt:!0,rootPath:h,fullTextPrefixes:p,onSummarized:y});let C=e?``:`主数据说明: ${o}\n格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误)。字段约束(类型/min/max/enum/必填/默认)见 systemPrompt「可操作数据」段,或用 schema_data({ jsonPath }) 按需查。\n\n`,w=n&&n.length?`(字段裁剪:${n.join(`,`)})`:``,E=r==null?``:`(深度≤${r})`,D=w||E?` ${w}${E}`:``;if((c!==void 0||l!==void 0)&&Array.isArray(S)){let e=S.length,t=Math.max(0,c??0),n=Math.min(200,Math.max(1,l??50)),r=S.slice(t,t+n),i=t+n<e;return`${C}主数据${h?` @ ${h}`:``} 数组分页[offset=${t},limit=${n}]${D} = ${dq(r)} (total=${e}, hasMore=${i}) (hash=${m})`}return S===void 0?`${C}主数据${h?` @ ${h}`:``}${D} = (undefined) (hash=${m})`:`${C}主数据${h?` @ ${h}`:``}${D} = ${dq(S)} (hash=${m})`},{name:`read`,description:`读取主数据(高层入口,合并 describe/get)。不传 jsonPath → 返回主数据说明 + 格式提示(含字段约束);传 jsonPath → 返回该子路径当前值 + hash;传 jsonPaths → 一次读多个不相关子路径(省多轮往返)。hash 用于乐观锁(声明 conflictWatchFields 后 write 自动比对;未声明不自动校验)。fields(字段裁剪)/depth(深度截断)减体积;offset+limit 对数组目标分页(返回切片 + total/hasMore)。`,schema:B({jsonPath:R().optional().describe(`要读的子路径(相对主数据根,如 components.0.text);不传则读整个主数据并返回说明`),jsonPaths:z(R()).optional().describe(`多路径读取:一次读多个不相关子路径(与 jsonPath 互斥,优先于 jsonPath);返回各路径值,非法路径单项标错不整批失败`),fields:z(R()).optional().describe(`字段裁剪:只返回指定字段(对对象/数组元素投影),减少返回体积,如 ["id","title"]`),depth:ud().int().min(0).optional().describe(`嵌套深度限制:0=只根占位,1=根+子,递归到 depth 层后用 {...}/[...] 占位截断,减少深层返回体积`),offset:ud().int().min(0).optional().describe(`数组分页起始偏移(仅当读取目标是数组时生效,默认 0),配合 limit 分页读大数组`),limit:ud().int().min(1).max(200).optional().describe(`数组分页每页条数(默认 50,上限 200;仅数组时生效),返回切片 + total/hasMore`)})}),pe=VI(async({value:e,patch:t,patches:o,del:c,dryRun:l},u)=>{let m=g(u),h=`set`;c?h=`delete`:(o&&o.length||t)&&(h=`edit`);let _=t?.value===void 0?e:t.value,v=await O();try{let e=w?b(m):void 0;if(l&&e!==void 0){let t=T();if(t!==e)return CU({code:`VERSION_CONFLICT`,message:`dryRun 预检发现乐观锁冲突: expectedHash=${e} 当前 hash=${t}(主数据在你 read 后被改)`,hint:`重新 read 拿最新 hash 再预检/写`})}if(h===`delete`){if(!t?.jsonPath)return CU({code:`MISSING_VALUE`,message:`delete 需要 patch.jsonPath 指定要删的子路径(主数据整体不可删,用 write(value) 整体替换)`,hint:`如 patch:{jsonPath:"components.0"}, del:true`});if(tq(t.jsonPath))return CU({code:`PATH_UNSAFE`,message:`jsonPath "${t.jsonPath}" 含非法段`,hint:`使用正常属性路径`});if(!aK(t.jsonPath,i,s))return CU({code:`PATH_DENIED`,message:`write delete @ "${t.jsonPath}" 不在 schema 声明字段内`,hint:`仅 schema 声明的 key 可删`});if(d){let e=p2(t.jsonPath,d.resourcesByPath);if(e)return CU({code:e.spec.mode===`freeze`?`FROZEN_FIELD`:`VERBATIM_PROTECTED`,message:`write delete @ "${t.jsonPath}" 命中受保护字段 "${e.protectedPath}"(${e.spec.mode}),不可删除`,hint:e.spec.mode===`freeze`?`冻结字段不可删`:`verbatim 字段不可直接删;先 resource_delete 释放`})}let n=await ae(`delete`,e,void 0,v);if(n!==null)return n;if(l){let e=oq(a);return aq(e,t.jsonPath)?`dryRun(delete): 将删除 @ ${t.jsonPath}。预览剩余:${dq(e,600)}。未实际写入、未入快照。`:`dryRun(delete): @ ${t.jsonPath} 不存在(无需删除)。未实际写入。`}ie(`delete`);let o=aq(a,t.jsonPath);return j(),M({op:`delete`,detail:t.jsonPath,timestamp:Date.now()}),r&&(r(a,null),j()),x(T(),m),o?`已删除主数据 @ ${t.jsonPath}`:`主数据 @ ${t.jsonPath} 不存在(无需删除)`}if(h===`edit`){if(typeof a!=`object`||!a)return CU({code:`NOT_OBJECT`,message:`edit 仅适用于对象/数组主数据,当前是 ${a===void 0?`undefined`:typeof a}`,hint:`叶子用 write(value) 整体设置`});let n=await ae(`edit`,e,void 0,v);if(n!==null)return n;let c=o&&o.length?o:[{op:t.op??`set`,jsonPath:t.jsonPath||``,value:_}],u=w2({bindRef:a,patches:c,schema:i,allowKeys:s,snapshots:f,maxSnapshots:p,markDataDirty:j,schemaErrorMode:`zod`,dryRun:l,internalAfterWrite:r,protectedCtx:d});if(!u.ok)return u.error;if(l)return`dryRun(edit): ${u.applied.length} 个 patch 预检通过(schema 校验 OK)。预览结果:${dq(u.clone,600)}。未实际写入、未入快照。`;M({op:`edit`,detail:`${u.applied.length} 个 patch${u.applied.length>1?`(批量)`:``}`,value:u.applied.map(e=>`${e.op}@${e.jp}`),timestamp:Date.now()});let h=k(m);return j2(u.clone),`已 write(edit) 主数据(${u.applied.length} 个 patch)。当前值:${dq(u.clone,600)} (新 hash=${h})`}let c=cq(_);if(c.parseError)return EU(``,_,c.parseError);let u=await ae(`set`,e,_,v);if(u!==null)return u;let g=C2({bindRef:a,value:c.parsed,schema:i,allowKeys:s,snapshots:f,maxSnapshots:p,audit:M,dryRun:l,onWrite:j,internalAfterWrite:r,protectedCtx:d,hashFn:T});if(!g.ok)return g.error;if(l)return`dryRun(set): schema 校验通过。预览新值:${dq(g.data,600)}。未实际写入、未入快照。`;let y=g.hash??T();x(y,m);let S=n.length?oq(g.data):g.data;return j2(S),`已 write(set) 主数据 = ${dq(S,600)} (新 hash=${y})${s?`(白名单模式:仅更新 schema 声明字段,未声明字段保留)`:``}`}finally{v.release()}},{name:`write`,description:`写入主数据(高层入口,合并 set/edit/delete + 自动乐观锁 + 自动快照)。四意图:① 整体替换 write({value:整个对象});② 增量 write({patch:{op,jsonPath,value}}) op=set/remove/merge/append/move(move 的 value=目标路径字符串);③ 批量原子 write({patches:[...]})(任一失败整批回滚);④ 删子路径 write({patch:{jsonPath},del:true})。dryRun:true 预检不落盘。写入自动 schema 校验(失败不写,按错误修正重试)+ 自动快照。详细用法见系统提示「能力使用提示」。`,schema:B({value:wd().optional().describe(`JSON 对象(推荐,如 {title:"x"})或 JSON 字符串;set 整体或单个 patch 的 set/merge/append 必填`),patch:B({op:Vd([`set`,`remove`,`merge`,`append`,`move`]).optional().describe(`增量操作:set 设值/remove 删/merge 合并对象/append 追加数组/move 移动数组元素(value=目标路径字符串)。单 patch edit 缺省按 set;del 模式(write({patch:{jsonPath},del:true}))不读 op 可省略`),jsonPath:R().optional().describe(`相对主数据根的点号路径(如 components.0.text);set/remove 必填,merge/append 不填则作用于根`),value:wd().optional().describe(`该 patch 的值(JSON 直传或 JSON 字符串);set/merge/append 必填,remove 不需。与顶层 value 二选一:优先 patch.value,未填则回退顶层 value(向后兼容)。推荐用 patch.value(自带,与 patches 元素一致,无歧义)`)}).optional().describe(`单个增量编辑(自带 value,与 patches 元素一致);传 patch(无 patches)走单 patch edit 语义`),patches:z(B({op:Vd([`set`,`remove`,`merge`,`append`,`move`]),jsonPath:R().optional().describe(`相对主数据根的点号路径;set/remove 必填,merge/append 不填则作用于根`),value:wd().optional().describe(`JSON 值(推荐直传)或 JSON 字符串;set/merge/append 必填,remove 不需`)})).optional().describe(`批量增量编辑:一次原子应用多个 patch(任一失败则整体不写入,clone 试跑全部 + schema 校验通过才落 live)。适合一次改多处,减少多轮往返`),del:gd().optional().describe(`true 则删除 patch.jsonPath 指定的子路径`),dryRun:gd().optional().describe(`预检模式:走完整校验链(schema + 白名单 + patch 应用到 clone)但不落盘、不入快照,返回预览。四意图(value/patch/patches/del)均支持;乐观锁冲突照常检测(返回 VERSION_CONFLICT 不挂起)`)})});oe(pe);let me=VI(async({jsonPath:e})=>{let t=e||``,n=t?sK(i,t):i;return n?`schema${t?` @ ${t}`:``} = ${dq(DK(n))}`:CU({code:`PATH_DENIED`,message:`schema @ "${t}" 不存在`,hint:`jsonPath 需在 schema 声明字段内(用 read() 不传 jsonPath 查看顶层字段)`})},{name:`schema_data`,description:`查看主数据(或子路径)的字段约束:类型/min/max/enum/必填/默认值/嵌套 shape。写前查约束,避免写错重试。不传 jsonPath 查根;传子路径(如 components.0)查该位置约束。`,schema:B({jsonPath:R().optional().describe(`要查约束的子路径;不传查根 schema`)})}),he=VI(async({snapshotId:e,against:t})=>{let n=t!=null,r,o;if(n){let e=t;if(typeof e==`string`){let t=cq(e);t.parseError||(e=t.parsed)}r=e,o=`against`}else{if(!f.length)return CU({code:`NO_SNAPSHOT`,message:`无快照可对比`,hint:`set/edit/delete 自动存快照;或传 against 一段 JSON 值直接对比`});let t=e===void 0?f[f.length-1]:f.find(t=>t.id===e);if(!t)return CU({code:`SNAPSHOT_NOT_FOUND`,message:`未找到快照 #${e}`,hint:`不传 snapshotId 用最近一次;或传 against`});r=t.value,o=`快照 #${t.id}`}let c=s?bK(a,i):a,l=Sq(r,oq(c));return l.length?`差异(当前 vs ${o},共 ${l.length} 处):\n${l.map(e=>` ${e.path}: ${dq(e.from)} → ${dq(e.to)}`).join(`
254
- `)}`:`无差异:当前主数据与 ${o} 完全相同。`},{name:`diff_data`,description:`对比当前主数据与某快照(默认最近)或一段 JSON(against)的差异,返回结构化 {path, from→to} 列表。供 verify 自纠/冲突诊断/操作审计("刚才改了啥")。snapshotId 指定快照;against 传一段 JSON 值(与 snapshotId 互斥,传则忽略快照)。`,schema:B({snapshotId:ud().int().optional().describe(`对比的快照序号;不传则最近一次`),against:wd().optional().describe(`对比的一段 JSON 值(与 snapshotId 互斥;传则忽略快照)`)})}),ge=[];if(t.vfsStore){let e=t.vfsStore,n=e=>`drafts/${e}.json`,o=VI(({draftId:t,chunk:r,mode:i})=>{let a=n(t),o=e.files[a],s=i===`append`&&o,c=s?o.content+r:r;return e.files[a]={content:c,updatedAt:Date.now()},JSON.stringify({draftId:t,bytes:c.length,mode:s?`append`:`start`})},{name:`draft_write`,description:`分块写 JSON 草稿到 drafts 池(单次 write 受 max_tokens 限制装不下时用)。mode:"start" 新建/"append" 追加拼接;返回 {draftId,bytes} 看累计进度。累积完 draft_commit 提交;拼接不合法返回 JSON_INVALID 草稿保留。`,schema:B({draftId:R().describe(`草稿标识(自起,如 "page-gen-1")`),chunk:R().describe(`JSON 片段字符串(分块输出,append 拼接成完整 JSON;如 '{"components":[' / '{"type":"heading",...},' / ']}')`),mode:Vd([`start`,`append`]).optional().describe(`start=新建/覆盖(默认);append=追加 chunk 到已有草稿`)})}),c=VI(async({draftId:t},o)=>{let c=g(o),l=n(t),u=e.files[l];if(!u)return CU({code:`DRAFT_NOT_FOUND`,message:`草稿 "${t}" 不存在`,hint:`先 draft_write({draftId, chunk, mode:"start"}) 新建,再 append 累积分块`});let m;try{m=JSON.parse(u.content)}catch(e){return CU({code:`JSON_INVALID`,message:`草稿 "${t}" 拼接后非合法 JSON: ${e.message}`,hint:`检查 chunk 拼接(逗号/括号/引号是否匹配,首尾是否闭合);草稿保留未删,可继续 draft_write 修正后重 commit`,details:{bytes:u.content.length,preview:u.content.slice(0,200)+(u.content.length>200?`…`:``)}})}let h=await O();try{let n=await ae(`set`,w?b(c):void 0,m,h);if(n!==null)return n;let o=C2({bindRef:a,value:m,schema:i,allowKeys:s,snapshots:f,maxSnapshots:p,audit:M,op:`draft_commit`,onWrite:j,internalAfterWrite:r,protectedCtx:d,hashFn:T});return o.ok?(x(o.hash,c),delete e.files[l],`已 draft_commit 草稿 "${t}" → 主数据 = ${dq(o.data,600)} (新 hash=${o.hash})${s?`(白名单模式:仅更新 schema 声明字段)`:``}。草稿已清理。`):o.error}finally{h.release()}},{name:`draft_commit`,description:`把 draft_write 累积的草稿合并 + JSON.parse + 乐观锁 + schema 校验,原子提交主数据(任一步失败不写,草稿保留可修后重试;成功清草稿 + 自动快照可回退)。仅大 JSON 从零生成用;小改用 write。`,schema:B({draftId:R().describe(`要提交的草稿标识(对应 draft_write 的 draftId)`)})});oe(c),ge.push(o,c)}let _e=[];if(e.resources?.length&&l){let e=VI(async({path:e,handle:t})=>{let n=e;if(!n&&t&&(n=l.get(t)?.path),!n)return CU({code:`RESOURCE_NOT_FOUND`,message:`未提供 path 或有效 handle`,hint:`传 path(受保护字段)或 handle(占位符 ⟦res:handle⟧ 里的句柄)`});let r=u2(n);if(!c.has(r))return CU({code:`RESOURCE_NOT_FOUND`,message:`"${n}" 不是受保护字段`,hint:`resource_get 仅查集成方在 data.resources 声明的路径`});let i=l.get(r);if(i)return dq({path:i.path,mode:i.mode,value:i.value,handle:i.handle});let o=rq(a,r);if(o===void 0)return CU({code:`RESOURCE_NOT_FOUND`,message:`字段 "${n}" 当前无值,无法注册`,hint:`该字段可能在 bind 中不存在;先 read 触发懒注册`});let s=c.get(r),u=l.ensure(r,o,s.mode);return dq({path:r,mode:s.mode,value:o,handle:u})},{name:`resource_get`,description:`取受保护字段(freeze/verbatim)的真实值(占位符背后的精确值)。仅受保护路径(集成方在 data.resources 声明)。read 返回 ⟦frozen:path⟧/⟦res:handle⟧ 占位符,确需真值时用此工具。传 path 或 handle。`,schema:B({path:R().optional().describe(`受保护字段路径(data.resources 声明的)`),handle:R().optional().describe(`占位符 ⟦res:handle⟧ 里的句柄(与 path 二选一)`)})}),t=VI(async({path:e,value:t},n)=>{let r=g(n);if(!e)return CU({code:`MISSING_VALUE`,message:`resource_update 需要 path`,hint:`传要更新的 verbatim 受保护字段路径`});let o=u2(e),s=c.get(o);if(!s)return CU({code:`RESOURCE_NOT_FOUND`,message:`"${e}" 不是受保护字段`,hint:`resource_update 仅改 data.resources 声明的字段`});if(s.mode===`freeze`)return CU({code:`FROZEN_FIELD`,message:`字段 "${e}" 已冻结,resource_update 也不可改`,hint:`冻结字段完全只读`});let u=sK(i,o);if(u){let n=u.safeParse(t);if(!n.success)return CU({code:`SCHEMA_INVALID`,message:`resource_update 值不符合 "${e}" 的类型`,hint:`按字段类型传值`,details:wU(n.error.issues)})}l.update(o,t),iq(a,o,t),x(T(),r),j();let d=l.get(o)?.handle;return`已更新 verbatim 资源 "${e}" = ${dq(t,200)}(handle ${d??`(未知)`} 不变)。后续 write 该字段写回句柄 ⟦res:${d}⟧ 或新值`},{name:`resource_update`,description:`更新 verbatim 受保护字段的真实值(改精确原值,如刷新 token/hash)。仅 verbatim 可改;freeze 拒。更新后同步 bind + 标脏,后续 write 写回句柄即用新值。`,schema:B({path:R().describe(`要更新的 verbatim 受保护字段路径`),value:wd().describe(`新值(需符合字段 schema 类型)`)})});oe(t);let n=VI(async()=>{let e=l.list();return e.length?dq({resources:e}):`当前无已注册的受保护资源(read 受保护路径会懒注册)`},{name:`resource_list`,description:`列出所有已注册的受保护资源(path/mode/handle/bytes)。`,schema:B({})}),r=VI(async({path:e,handle:t})=>{let n=e;return!n&&t&&(n=l.get(t)?.path),n?l.delete(n)?`已释放资源 "${n}"(后续 read 该字段会重新懒注册)`:`资源 "${n}" 不存在(无需释放)`:CU({code:`RESOURCE_NOT_FOUND`,message:`未提供 path 或有效 handle`,hint:`传要释放的受保护字段 path 或 handle`})},{name:`resource_delete`,description:`释放受保护资源(从资源池删除,后续 read 重新懒注册)。用于不再需要保护的字段或释放空间。`,schema:B({path:R().optional().describe(`要释放的受保护字段路径`),handle:R().optional().describe(`占位符句柄(与 path 二选一)`)})});oe(r),_e.push(e,t,n,r)}let P=[se,ce,le,ue,de,fe,N,pe,me,he,...ge,..._e];Object.defineProperty(P,"controller",{value:re,enumerable:!1,configurable:!1,writable:!1});for(let e of P)Object.defineProperty(e,"__dataOpsScoped",{value:!0,enumerable:!1,configurable:!1});return P}var N2=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),Nde=new Set([`script`,`style`]);function P2(e){let t=[],n=e.length;if(!e.trim())return t;let r=[0];for(let t=0;t<n;t++)e[t]===`
254
+ `)}`:`无差异:当前主数据与 ${o} 完全相同。`},{name:`diff_data`,description:`对比当前主数据与某快照(默认最近)或一段 JSON(against)的差异,返回结构化 {path, from→to} 列表。供 verify 自纠/冲突诊断/操作审计("刚才改了啥")。snapshotId 指定快照;against 传一段 JSON 值(与 snapshotId 互斥,传则忽略快照)。`,schema:B({snapshotId:ud().int().optional().describe(`对比的快照序号;不传则最近一次`),against:wd().optional().describe(`对比的一段 JSON 值(与 snapshotId 互斥;传则忽略快照)`)})}),ge=[];if(t.vfsStore){let e=t.vfsStore,n=e=>`drafts/${e}.json`,o=VI(({draftId:t,chunk:r,mode:i})=>{let a=n(t),o=e.files[a],s=i===`append`&&o,c=s?o.content+r:r;return e.files[a]={content:c,updatedAt:Date.now()},JSON.stringify({draftId:t,bytes:c.length,mode:s?`append`:`start`})},{name:`draft_write`,description:`分块写 JSON 草稿到 drafts 池(单次 write 受 max_tokens 限制装不下时用)。mode:"start" 新建/"append" 追加拼接;返回 {draftId,bytes} 看累计进度。累积完 draft_commit 提交;拼接不合法返回 JSON_INVALID 草稿保留。`,schema:B({draftId:R().describe(`草稿标识(自起,如 "page-gen-1")`),chunk:R().describe(`JSON 片段字符串(分块输出,append 拼接成完整 JSON;如 '{"components":[' / '{"type":"heading",...},' / ']}')`),mode:Vd([`start`,`append`]).optional().describe(`start=新建/覆盖(默认);append=追加 chunk 到已有草稿`)})}),c=VI(async({draftId:t},o)=>{let c=g(o),l=n(t),u=e.files[l];if(!u)return CU({code:`DRAFT_NOT_FOUND`,message:`草稿 "${t}" 不存在`,hint:`先 draft_write({draftId, chunk, mode:"start"}) 新建,再 append 累积分块`});let m;try{m=JSON.parse(u.content)}catch(e){return CU({code:`JSON_INVALID`,message:`草稿 "${t}" 拼接后非合法 JSON: ${e.message}`,hint:`检查 chunk 拼接(逗号/括号/引号是否匹配,首尾是否闭合);草稿保留未删,可继续 draft_write 修正后重 commit`,details:{bytes:u.content.length,preview:u.content.slice(0,200)+(u.content.length>200?`…`:``)}})}let h=await O();try{let n=await ae(`set`,w?b(c):void 0,m,h);if(n!==null)return n;let o=C2({bindRef:a,value:m,schema:i,allowKeys:s,snapshots:f,maxSnapshots:p,audit:M,op:`draft_commit`,onWrite:j,internalAfterWrite:r,protectedCtx:d,hashFn:T});return o.ok?(x(o.hash,c),delete e.files[l],`已 draft_commit 草稿 "${t}" → 主数据 = ${dq(o.data,600)} (新 hash=${o.hash})${s?`(白名单模式:仅更新 schema 声明字段)`:``}。草稿已清理。`):o.error}finally{h.release()}},{name:`draft_commit`,description:`把 draft_write 累积的草稿合并 + JSON.parse + 乐观锁 + schema 校验,原子提交主数据(任一步失败不写,草稿保留可修后重试;成功清草稿 + 自动快照可回退)。仅大 JSON 从零生成用;小改用 write。`,schema:B({draftId:R().describe(`要提交的草稿标识(对应 draft_write 的 draftId)`)})});oe(c),ge.push(o,c)}let _e=[];if(e.resources?.length&&l){let e=VI(async({path:e,handle:t})=>{let n=e;if(!n&&t&&(n=l.get(t)?.path),!n)return CU({code:`RESOURCE_NOT_FOUND`,message:`未提供 path 或有效 handle`,hint:`传 path(受保护字段)或 handle(占位符 ⟦res:handle⟧ 里的句柄)`});let r=u2(n);if(!c.has(r))return CU({code:`RESOURCE_NOT_FOUND`,message:`"${n}" 不是受保护字段`,hint:`resource_get 仅查集成方在 data.resources 声明的路径`});let i=l.get(r);if(i)return dq({path:i.path,mode:i.mode,value:i.value,handle:i.handle});let o=rq(a,r);if(o===void 0)return CU({code:`RESOURCE_NOT_FOUND`,message:`字段 "${n}" 当前无值,无法注册`,hint:`该字段可能在 bind 中不存在;先 read 触发懒注册`});let s=c.get(r),u=l.ensure(r,o,s.mode);return dq({path:r,mode:s.mode,value:o,handle:u})},{name:`resource_get`,description:`取受保护字段(freeze/verbatim)的真实值(占位符背后的精确值)。仅受保护路径(集成方在 data.resources 声明)。read 返回 ⟦frozen:path⟧/⟦res:handle⟧ 占位符,确需真值时用此工具。传 path 或 handle。`,schema:B({path:R().optional().describe(`受保护字段路径(data.resources 声明的)`),handle:R().optional().describe(`占位符 ⟦res:handle⟧ 里的句柄(与 path 二选一)`)})}),t=VI(async({path:e,value:t},n)=>{let r=g(n);if(!e)return CU({code:`MISSING_VALUE`,message:`resource_update 需要 path`,hint:`传要更新的 verbatim 受保护字段路径`});let o=u2(e),s=c.get(o);if(!s)return CU({code:`RESOURCE_NOT_FOUND`,message:`"${e}" 不是受保护字段`,hint:`resource_update 仅改 data.resources 声明的字段`});if(s.mode===`freeze`)return CU({code:`FROZEN_FIELD`,message:`字段 "${e}" 已冻结,resource_update 也不可改`,hint:`冻结字段完全只读`});let u=sK(i,o);if(u){let n=u.safeParse(t);if(!n.success)return CU({code:`SCHEMA_INVALID`,message:`resource_update 值不符合 "${e}" 的类型`,hint:`按字段类型传值`,details:wU(n.error.issues)})}l.update(o,t),iq(a,o,t),x(T(),r),j();let d=l.get(o)?.handle;return`已更新 verbatim 资源 "${e}" = ${dq(t,200)}(handle ${d??`(未知)`} 不变)。后续 write 该字段写回句柄 ⟦res:${d}⟧ 或新值`},{name:`resource_update`,description:`更新 verbatim 受保护字段的真实值(改精确原值,如刷新 token/hash)。仅 verbatim 可改;freeze 拒。更新后同步 bind + 标脏,后续 write 写回句柄即用新值。`,schema:B({path:R().describe(`要更新的 verbatim 受保护字段路径`),value:wd().describe(`新值(需符合字段 schema 类型)`)})});oe(t);let n=VI(async()=>{let e=l.list();if(!e.length){let e=[...d.resourcesByPath.entries()].filter(([,e])=>e.mode===`freeze`).map(([e])=>e);return e.length?`资源池为空,但集成方静态配置了 freeze 只读字段:${e.join(`、 `)}(freeze 无句柄、不可释放;resource_delete 仅对 verbatim 生效)`:`当前无已注册的受保护资源(read 受保护路径会懒注册)`}return dq({resources:e})},{name:`resource_list`,description:`列出所有已注册的受保护资源(path/mode/handle/bytes)。`,schema:B({})}),r=VI(async({path:e,handle:t})=>{let n=e;return!n&&t&&(n=l.get(t)?.path),n?l.delete(n)?`已释放资源 "${n}"(后续 read 该字段会重新懒注册)`:d.resourcesByPath.get(n)?.mode===`freeze`?CU({code:`FROZEN_FIELD`,message:`字段 "${n}" 为 freeze 静态保护(不在资源池、无句柄、不可释放)`,hint:`freeze 由集成方在 data.resources 静态配置,只读不可解;含冻结字段的元素无法整体删除,请保留该元素或由集成方调整 data.resources`}):`资源 "${n}" 不存在(无需释放)`:CU({code:`RESOURCE_NOT_FOUND`,message:`未提供 path 或有效 handle`,hint:`传要释放的受保护字段 path 或 handle`})},{name:`resource_delete`,description:`释放受保护资源(从资源池删除,后续 read 重新懒注册)。用于不再需要保护的字段或释放空间。`,schema:B({path:R().optional().describe(`要释放的受保护字段路径`),handle:R().optional().describe(`占位符句柄(与 path 二选一)`)})});oe(r),_e.push(e,t,n,r)}let P=[se,ce,le,ue,de,fe,N,pe,me,he,...ge,..._e];Object.defineProperty(P,"controller",{value:re,enumerable:!1,configurable:!1,writable:!1});for(let e of P)Object.defineProperty(e,"__dataOpsScoped",{value:!0,enumerable:!1,configurable:!1});return P}var N2=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),Nde=new Set([`script`,`style`]);function P2(e){let t=[],n=e.length;if(!e.trim())return t;let r=[0];for(let t=0;t<n;t++)e[t]===`
255
255
  `&&r.push(t+1);let i=e=>{let t=0,n=r.length-1;for(;t<n;){let i=t+n+1>>1;r[i]<=e?t=i:n=i-1}return t+1},a=[],o=0;for(;o<n;){let r=e.indexOf(`<`,o);if(r<0)break;if(e.startsWith(`<!--`,r)){let n=e.indexOf(`-->`,r+4);if(n<0){t.push({line:i(r),code:`UNCLOSED_COMMENT`,message:`注释 <!-- 未闭合(缺 -->)`});break}o=n+3;continue}if(e[r+1]===`!`){let t=e.indexOf(`>`,r);o=t<0?n:t+1;continue}let s=e[r+1]===`/`,c=s?r+2:r+1,l=e[c]??``;if(!/[a-zA-Z]/.test(l)){o=r+1;continue}let u=c,d=``;for(;u<n;){let t=e[u];if(d)t===d&&(d=``);else if(t===`"`||t===`'`)d=t;else if(t===`>`)break;u++}if(u>=n){t.push({line:i(r),code:`UNCLOSED_TAG`,message:`标签 ${e.slice(r,Math.min(r+20,n))} 未写完(缺 >)`});break}let f=e.slice(c,u),p=(f.match(/^[a-zA-Z][a-zA-Z0-9-]*/)??[``])[0].toLowerCase(),m=!s&&/\/\s*$/.test(f);if(o=u+1,p){if(s){let e=a.length-1;if(e>=0&&a[e].name===p)a.pop();else{let e=a.findIndex(e=>e.name===p);if(e>=0){let n=a.splice(e);for(let e of n.slice(1))t.push({line:i(e.idx),code:`UNCLOSED_TAG`,message:`<${e.name}> 未闭合(先遇到 </${p}>)`})}else t.push({line:i(r),code:`STRAY_CLOSE_TAG`,message:`</${p}> 无匹配的开标签`})}continue}if(!(N2.has(p)||m)){if(Nde.has(p)){let n=RegExp(`</${p}\\s*>`,`i`).exec(e.slice(o));if(!n){t.push({line:i(r),code:`UNCLOSED_TAG`,message:`<${p}> 未闭合(缺 </${p}>)`});break}o+=n.index+n[0].length;continue}a.push({name:p,idx:r})}}}for(let e of a)t.push({line:i(e.idx),code:`UNCLOSED_TAG`,message:`<${e.name}> 未闭合`});return t}var F2=`__pgTouched`,I2=`__pgFinalText`,L2=`__pgCodeHashes`,R2=`__pgKeepExternal`,z2=`__pgNotes`,B2=200;function Pde(e){let t=[];for(let n of e.split(`
256
256
  `)){let e=n.match(/^\s*[-*]?\s*\[note\]\s*(.*)$/i);e&&e[1].trim()&&t.push(`[note] `+e[1].trim())}return[...new Set(t)]}function Fde(e,t){let n=Array.isArray(e[z2])?e[z2].filter(e=>typeof e==`string`):[];e[z2]=[...new Set([...n,...t])].map(e=>e.length>B2?e.slice(0,B2)+`…`:e).slice(-5)}function V2(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return(t>>>0).toString(16)}function Ide(e,t){let n=[];return U2(e,t,e=>{typeof e.name==`string`&&e.name&&n.push(e.name)}),n}function H2(e,t){if(!e.startsWith(t))return null;let n=e.slice(t.length),r=n.lastIndexOf(`.`);return(r>0?n.slice(0,r):r===0?``:n)||null}function U2(e,t,n){if(!(!e||typeof e!=`object`))for(let r of t){let t=rq(e,r);if(Array.isArray(t))for(let e=0;e<t.length;e++){let i=t[e];i&&typeof i==`object`&&typeof i.__pgId==`string`&&n(i,r,e)}}}function Lde(e,t,n){let r=new Set;if(!e||typeof e!=`object`)return r;for(let i of t){let t=rq(e,i);if(Array.isArray(t))for(let e=0;e<t.length;e++){let a=t[e];if(!a||typeof a!=`object`)continue;let o=a.__pgId;if(typeof o!=`string`)continue;let s=`${i}.${e}`;for(let e of n)if(e.path===s||e.path.startsWith(s+`.`)){r.add(o);break}}}return r}function Rde(e){let{writablePaths:t,codeVfsPrefix:n,ext:r,codeField:i=`code`,onWarning:a,getController:o,vfsStore:s,craftNotes:c=!0}=e,l=s,u=l.__pgLastCheckout??=new Map,d=l.__pgPendingRetry??=new Set;return{name:`code-asset-checkout-commit`,beforeAgent:e=>{let c=o()?.get?.().bind;c&&A2(c,t);let l=0,f=0,p=new Map;if(U2(c,t,e=>{l++;let t=rq(e,i);if(typeof t==`string`){f++;let i=e.__pgId,a=V2(t);p.set(i,a);let o=`${n}${i}.${r}`,c=s.files[o],l=u.get(i);c&&typeof c.content==`string`&&c.content!==t&&l===a?d.add(o):(s.files[o]={content:t,updatedAt:Date.now()},d.delete(o)),u.set(i,a)}}),l>0&&f===0&&a){let e=``;for(let n of t){let t=rq(c,n);if(Array.isArray(t)&&t.length){e=Object.keys(t[0]??{}).join(`,`);break}}a(`codeField '${i}' 在当前 ${l} 个组件中均未命中 string 值。组件实际字段:[${e}]。若预期有代码组件请核对 codeField 路径;若当前确无代码组件可忽略。`)}return{files:s.files,[F2]:new Set,[I2]:{text:``},[L2]:p,[R2]:[]}},wrapModelCall:async(e,t)=>{let n=await t(e),r=e.state[I2];return r&&!(n.toolCalls&&n.toolCalls.length)&&typeof n.content==`string`&&n.content&&(r.text=n.content),n},augmentPrompt:()=>{let e=o()?.get?.().bind,i=[],a=0;if(U2(e,t,(e,t,o)=>{a++;let l=typeof e.name==`string`&&e.name?e.name:``,u=l?`${l} [${o}]`:`(未命名 [${o}])`,d=`${n}${e.__pgId}.${r}`,f=!!s.files[d];if(i.push(`- ${u} → ${d}${f?``:`(尚未检出,先 vfs_write 创建)`}`),c){let t=Array.isArray(e[z2])?e[z2].filter(e=>typeof e==`string`):[];if(t.length){let e=t[t.length-1];i.push(` 📝 笔记×${t.length}(最近):${e.length>120?e.slice(0,120)+`…`:e}`)}}}),!i.length)return;let l=``;for(let n of t){let t=rq(e,n);if(Array.isArray(t)){l=`\n新建组件追加索引:write({patch:{op:'set',jsonPath:'${n}.${t.length}',value:{...}}})(当前共 ${t.length} 个,勿覆盖已有索引)`;break}}return`## 组件代码文件地图(改组件时按 name 直接改对应 vfs 文件;框架自动 checkout/commit)${c?`
257
257
  📝 笔记 = 前任维护者交接(设计决策/用户反馈/踩坑),改该组件时遵循;收口回复末行必须附一行 [note] 交接笔记(本组件本次的实现要点),框架存进组件转交下任`:``}\n${i.join(`
@@ -306,6 +306,7 @@ ${`- 输出形态:完整、自包含的 HTML 页面(.${r},可独立成页)`}
306
306
  - **机械决定一次定**:写法选择(read 回读 vs 复制、vfs 草稿 vs 直写 data、并行 vs 串行)快速选一个,**不在思考里反复权衡 token 成本**(为之纠结反更费 token)。
307
307
  - **禁止在思考里整段写出完整代码草稿**:CSS/JS/HTML 代码只写进 write / vfs_write / vfs_edit 工具调用(代码只出现一次);思考里只做高层设计(结构 / 字段 / 方案选择),不要先逐行预写一遍代码再在工具里重复一遍 —— 那会让代码 token 翻倍。
308
308
  - **终稿纪律(一次写成)**:动手前要点清单一次定稿(≤10 条:结构 + DOM 分层/z-index + 关键尺寸 + 动画时序),清单齐了**直接在工具调用里写终稿**;① 不先写一版再推翻重写第二版(整段重写 = 代码 token 翻倍,写前多花 30 秒把清单想齐);② 同一几何/层级约束(bottom 定位/遮挡/z-index)**只推演一次**,不重复推导第二遍;③ 写完发现小问题(遮挡/重叠/命名),只改那一处,不重写整段。
309
+ - **大段 code 分块写(超长代码硬约束)**:预计 code 超过 ~8K 字符时,**一次工具调用装不下会被 max_tokens 掐断** —— 必须分块:① 首块用 write 把组件连同 code 第一段写入(如 code 写到 CSS 中段即止);② 后续每段用 write({op:'append', jsonPath:'${n}.N.${t}', value:'下一段文本'}) 逐块尾接(每块 ≤4K 字符);③ 全部拼完再 validate_code。**禁止**在任何一次调用里塞完整超长代码(截断 = 静默失败重来,token 全废)。
309
310
  - **代码字符串不纠结转义**:代码字段(${t})/ content 参数就是普通字符串,直接写完整代码文本(换行、引号照常写),不要纠结「\n」转义、单双引号、字面换行会不会被拒 —— 框架自动序列化,反复权衡纯属浪费 token。
310
311
  - 一次想清楚 → 动手 → 验证 → 收口。**思考是手段不是目的,产出代码才是**。
311
312
  8. **收口格式(必守,最后一行)**:收口回复 = 简短结果总结 + **末行交接笔记** \`[note] <一句话实现要点>\` —— 关键设计决策 / 用户偏好 / 踩坑(如「[note] 液面用 height keyframes 4.2s 循环;装饰仅灯串+光斑 2 类」)。框架只识别末尾 [note] 行存进组件、自动转交下次维护该组件的子 agent;**漏写 = 下任失去交接**(真 LLM 实测漏写率 3/4,务必末行带上)。一行内,只写可复用结论。`}function Zde(e,t){return`# HTML 完整页面生成规范