@copilotkit/vue 2.0.0-rc.15 → 2.0.0-rc.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PARITY.md +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/use-render-activity-message-ChWFrgM2.cjs +92 -0
- package/dist/use-render-activity-message-ChWFrgM2.cjs.map +1 -0
- package/dist/{use-render-activity-message-a4iLQujA.js → use-render-activity-message-ccbbC4rz.js} +5478 -5760
- package/dist/use-render-activity-message-ccbbC4rz.js.map +1 -0
- package/dist/v2/components/chat/CopilotChat.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotChatView.vue.d.ts +1 -1
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts +7 -2
- package/dist/v2/components/chat/CopilotPopup.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts +4 -2
- package/dist/v2/components/chat/CopilotPopupView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts +4 -2
- package/dist/v2/components/chat/CopilotPopupViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts +7 -2
- package/dist/v2/components/chat/CopilotSidebar.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts +4 -2
- package/dist/v2/components/chat/CopilotSidebarView.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts +4 -2
- package/dist/v2/components/chat/CopilotSidebarViewInternal.vue.d.ts.map +1 -1
- package/dist/v2/components/chat/forwarded-slots.d.ts +12 -0
- package/dist/v2/components/chat/forwarded-slots.d.ts.map +1 -0
- package/dist/v2/components/chat/index.d.ts +16 -12
- package/dist/v2/components/chat/index.d.ts.map +1 -1
- package/dist/v2/components/chat/types.d.ts +7 -1
- package/dist/v2/components/chat/types.d.ts.map +1 -1
- package/dist/v2/index.cjs +1 -1
- package/dist/v2/index.mjs +1 -1
- package/package.json +8 -8
- package/src/v2/components/chat/CopilotPopup.vue +23 -25
- package/src/v2/components/chat/CopilotPopupView.vue +10 -39
- package/src/v2/components/chat/CopilotPopupViewInternal.vue +14 -34
- package/src/v2/components/chat/CopilotSidebar.vue +23 -25
- package/src/v2/components/chat/CopilotSidebarView.vue +10 -39
- package/src/v2/components/chat/CopilotSidebarViewInternal.vue +14 -34
- package/src/v2/components/chat/__tests__/CopilotPopup.test.ts +90 -1
- package/src/v2/components/chat/__tests__/CopilotSidebar.test.ts +90 -1
- package/src/v2/components/chat/forwarded-slots.ts +17 -0
- package/src/v2/components/chat/types.ts +8 -0
- package/dist/use-render-activity-message-_mkY3bPT.cjs +0 -92
- package/dist/use-render-activity-message-_mkY3bPT.cjs.map +0 -1
- package/dist/use-render-activity-message-a4iLQujA.js.map +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";var Sc=Object.create;var Ba=Object.defineProperty;var wc=Object.getOwnPropertyDescriptor;var Cc=Object.getOwnPropertyNames;var Tc=Object.getPrototypeOf,Ec=Object.prototype.hasOwnProperty;var Ic=(e,n,o,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Cc(n))!Ec.call(e,r)&&r!==o&&Ba(e,r,{get:()=>n[r],enumerable:!(a=wc(n,r))||a.enumerable});return e};var co=(e,n,o)=>(o=e!=null?Sc(Tc(e)):{},Ic(n||!e||!e.__esModule?Ba(o,"default",{value:e,enumerable:!0}):o,e));const t=require("vue"),Q=require("@copilotkit/shared"),x=require("@copilotkit/core"),_c=require("zod"),qn=require("@a2ui/web_core/v0_9"),Io=require("@copilotkit/a2ui-renderer/catalog-schema"),Da=require("@copilotkit/mcp-apps-renderer/activity"),Fe=require("@a2ui/web_core/v0_9/basic_catalog"),zn=require("@ag-ui/client"),Nr=require("@ag-ui/core"),Ac=require("@copilotkit/core/styles");function Mr(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const a=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,a.get?a:{enumerable:!0,get:()=>e[o]})}}return n.default=e,Object.freeze(n)}const $c=Mr(t),de=Mr(_c);let ve=(function(e){return e.TEXT_MESSAGE_START="TEXT_MESSAGE_START",e.TEXT_MESSAGE_CONTENT="TEXT_MESSAGE_CONTENT",e.TEXT_MESSAGE_END="TEXT_MESSAGE_END",e.TEXT_MESSAGE_CHUNK="TEXT_MESSAGE_CHUNK",e.TOOL_CALL_START="TOOL_CALL_START",e.TOOL_CALL_ARGS="TOOL_CALL_ARGS",e.TOOL_CALL_END="TOOL_CALL_END",e.TOOL_CALL_CHUNK="TOOL_CALL_CHUNK",e.TOOL_CALL_RESULT="TOOL_CALL_RESULT",e.STATE_SNAPSHOT="STATE_SNAPSHOT",e.STATE_DELTA="STATE_DELTA",e.MESSAGES_SNAPSHOT="MESSAGES_SNAPSHOT",e.ACTIVITY_SNAPSHOT="ACTIVITY_SNAPSHOT",e.ACTIVITY_DELTA="ACTIVITY_DELTA",e.RAW="RAW",e.CUSTOM="CUSTOM",e.RUN_STARTED="RUN_STARTED",e.RUN_FINISHED="RUN_FINISHED",e.RUN_ERROR="RUN_ERROR",e.STEP_STARTED="STEP_STARTED",e.STEP_FINISHED="STEP_FINISHED",e.REASONING_START="REASONING_START",e.REASONING_MESSAGE_START="REASONING_MESSAGE_START",e.REASONING_MESSAGE_CONTENT="REASONING_MESSAGE_CONTENT",e.REASONING_MESSAGE_END="REASONING_MESSAGE_END",e.REASONING_MESSAGE_CHUNK="REASONING_MESSAGE_CHUNK",e.REASONING_END="REASONING_END",e.REASONING_ENCRYPTED_VALUE="REASONING_ENCRYPTED_VALUE",e.SUBAGENT_STARTED="SUBAGENT_STARTED",e.SUBAGENT_FINISHED="SUBAGENT_FINISHED",e.SUBAGENT_ERROR="SUBAGENT_ERROR",e})({});function _o(e){const n=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,r])=>n.indexOf(+a)===-1).map(([a,r])=>r)}function Fa(e,n="|"){return e.map(o=>Lr(o)).join(n)}function Ao(e,n){return typeof n=="bigint"?n.toString():n}class Rc{constructor(n){this._getter=n,this._value=void 0}get value(){const n=this._getter;return n!==void 0&&(this._value=n(),this._getter=void 0),this._value}}function Jn(e){return new Rc(e)}function xc(e){return e==null}function Go(e){const n=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(n,o)}function Oc(e,n){const o=e/n,a=Math.round(o),r=4*Number.EPSILON*Math.max(Math.abs(o),1);return Math.abs(o-a)<r?0:o-a}function Nt(e,n,o){Object.defineProperty(e,n,{value:o,writable:!0,enumerable:!0,configurable:!0})}function qo(e){const n=Object.getOwnPropertyDescriptor(e,"shape");return n?.get?n.get.raw:n?.value}function kt(e){return qo(e._zod.def)??e._zod.def.shape}function Br(e,n,o){Object.defineProperty(e,n,{get(){const a=o();return Nt(this,n,a),a},enumerable:!0,configurable:!0})}function Dr(e,n,o){n in e?Nt(e,n,o):e[n]=o}function Ut(e,n,o,a){const r=kt(n);for(const s of o){const i=Object.getOwnPropertyDescriptor(r,s);i.enumerable&&(i.get?Br(e,s,()=>{const l=n._zod.def.shape[s];return a?a(l,s):l}):Dr(e,s,a?a(i.value,s):i.value))}}function Nc(e,n){for(const o of Reflect.ownKeys(n)){const a=Object.getOwnPropertyDescriptor(n,o);a.enumerable&&(a.get?Br(e,o,()=>n[o]):Dr(e,o,a.value))}}function at(...e){const n={};for(const o of e){const a=Object.getOwnPropertyDescriptors(o);Object.assign(n,a)}return Object.defineProperties({},n)}function Mc(e){return JSON.stringify(e)}function Bc(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Fr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function fn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Dc=Jn(()=>{if(pt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function mn(e){if(fn(e)===!1)return!1;const n=e.constructor;if(n===void 0||typeof n!="function")return!0;const o=n.prototype;return!(fn(o)===!1||Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)}function Pr(e){return mn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Fc=new Set(["string","number","symbol"]);function Gt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Mt(e,n,o){const a=new e._zod.constr(n??e._zod.def);return(!n||o?.parent)&&(a._zod.parent=e),a}function te(e){const n=e;if(!n)return{};if(typeof n=="string")return{error:()=>n};if(n?.message!==void 0){if(n?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");n.error=n.message}return delete n.message,typeof n.error=="string"?{...n,error:()=>n.error}:n}function Lr(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Pc(e){return Object.keys(e).filter(n=>e[n]._zod.optin!==void 0&&e[n]._zod.optout==="optional")}const Vr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Lc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Vc(e,n){const o=e._zod.def,a=o.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s={};return Ut(s,e,Yn(e,n)),Mt(e,at(o,{shape:s,checks:[]}))}function Yn(e,n){const o=kt(e),a=[];for(const r of Reflect.ownKeys(n)){if(!Object.getOwnPropertyDescriptor(o,r)?.enumerable)throw new Error(`Unrecognized key: "${String(r)}"`);n[r]&&a.push(r)}return a}function zc(e,n){const o=e._zod.def,a=o.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=new Set(Yn(e,n)),i={};return Ut(i,e,Reflect.ownKeys(kt(e)).filter(l=>!s.has(l))),Mt(e,at(o,{shape:i,checks:[]}))}function Uc(e,n){if(!mn(n))throw new Error("Invalid input to extend: expected a plain object");const o=e._zod.def.checks;if(o&&o.length>0){const r=kt(e);for(const s of Reflect.ownKeys(n))if(Object.getOwnPropertyDescriptor(r,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Mt(e,at(e._zod.def,{shape:zr(e,n)}))}function zr(e,n){const o={};return Ut(o,e,Reflect.ownKeys(kt(e))),Nc(o,n),o}function jc(e,n){if(!mn(n))throw new Error("Invalid input to safeExtend: expected a plain object");return Mt(e,at(e._zod.def,{shape:zr(e,n)}))}function Zc(e,n){if(!n?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const o={};Ut(o,e,Reflect.ownKeys(kt(e))),Ut(o,n,Reflect.ownKeys(kt(n)));const a=at(e._zod.def,{shape:o,get catchall(){return n._zod.def.catchall},checks:n._zod.def.checks??[]});return Mt(e,a)}function Pa(e,n,o,a="partial"){const s=n._zod.def.checks;if(s&&s.length>0)throw new Error(`.${a}() cannot be used on object schemas containing refinements`);const l=o?new Set(Yn(n,o)):void 0,c={};return Ut(c,n,Reflect.ownKeys(kt(n)),e&&((u,d)=>l&&!l.has(d)?u:new e({type:"optional",innerType:u}))),Mt(n,at(n._zod.def,{shape:c,checks:[]}))}function Wc(e,n,o){const a=o?new Set(Yn(n,o)):void 0,r={};return Ut(r,n,Reflect.ownKeys(kt(n)),(s,i)=>a&&!a.has(i)?s:new e({type:"nonoptional",innerType:s})),Mt(n,at(n._zod.def,{shape:r}))}function yt(e,n=0){if(e.aborted===!0)return!0;for(let o=n;o<e.issues.length;o++)if(e.issues[o]?.continue!==!0)return!0;return!1}function Hc(e,n=0){if(e.aborted===!0)return!0;for(let o=n;o<e.issues.length;o++)if(e.issues[o]?.continue===!1)return!0;return!1}function Ur(e,n){return n.map(o=>{var a;return(a=o).path??(a.path=[]),o.path.unshift(e),o})}function an(e){return typeof e=="string"?e:e?.message}function La(e){const n=[];for(const o of e??[]){const a=o._zod.def;if(!/_(length|size)$|_equals$/.test(a.check))break;const r=a.maximum??a.length??a.size;r>=0&&n.push([r,o])}return n}function $o(e,n,o){var a;for(let r=n;r<e.length;r++)(a=e[r]).schema??(a.schema=o)}function Xt(e,n,o){var a;const r=e.inst?._zod?.traits;r?.has("$ZodType")&&(r.has("$ZodCheck")?(a=e).schema??(a.schema=e.inst):e.schema=e.inst);const s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:an(e.inst?._zod.def?.error?.(e))??an(s?.(e))??an(n?.error?.(e))??an(o.customError?.(e))??an(o.localeError?.(e))??"Invalid input",l={};for(const c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(l[c]=e[c]);return l.path??(l.path=[]),l.message=i,n?.reportInput&&(l.input=e.input),l}const Kc=/[\uD800-\uDBFF]/;function Jo(e){const n=e.length;if(!Kc.test(e))return n;let o=n;for(let a=0;a<n-1;a++)(e.charCodeAt(a)&64512)===55296&&(e.charCodeAt(a+1)&64512)===56320&&(o--,a++);return o}function Yo(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Gc(e){const n=typeof e;switch(n){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const o=e;if(o&&Object.getPrototypeOf(o)!==Object.prototype&&"constructor"in o&&o.constructor)return o.constructor.name}}return n}function hn(...e){const[n,o,a]=e;return typeof n=="string"?{message:n,code:"custom",input:o,inst:a}:{...n}}function qc(e,n){for(const o in n){const a=Object.getOwnPropertyDescriptor(n,o);a.get?Object.defineProperty(e,o,{...a,enumerable:!1}):Jc(e,o,a.value)}}function xt(e,n,o,a=!0){return Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:a,value:o}),o}function jr(e,n,o){return xt(e,n,o,!1)}function Zr(e,n){for(const o in e){const a=e[o];Object.defineProperty(n,o,{configurable:!0,enumerable:!0,get(){return xt(this,o,a(this))},set(r){xt(this,o,r)}})}return n}function Jc(e,n,o){Object.defineProperty(e,n,{configurable:!0,get(){return this==null?o:xt(this,n,o.bind(this))},set(a){xt(this,n,a)}})}function Yc(e,n){const o=Object.getPrototypeOf(e);return n in o?void 0:o}let uo,$t=!1;const Xc={configurable:!0,get(){$t=!0}};function be(e,n,o){const a=Object.getPrototypeOf(e._zod);if(n in a&&uo!==e._zod){uo=void 0;return}uo=e._zod,Object.defineProperty(a,n,{configurable:!0,get(){Object.defineProperty(this,n,Xc);const r=$t;$t=!1;try{const s=o(this);return $t?delete this[n]:Object.defineProperty(this,n,{configurable:!0,writable:!0,value:s}),$t=$t||r,s}catch(s){throw delete this[n],$t=$t||r,s}},set(r){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:r})}})}function Qc(e,n,o,a){const r=Yc(e,n);r&&Object.defineProperty(r,n,{configurable:!0,get(){const s={configurable:!0,writable:!0,enumerable:a,value:void 0};return Object.defineProperty(this,n,s),s.value=o(this),Object.defineProperty(this,n,s),s.value},set(s){Object.defineProperty(this,n,{configurable:!0,writable:!0,enumerable:a,value:s})}})}const eu="~constantCatch";function tu(e){const n=()=>e;return n[eu]=!0,n}var Va;const po={value:void 0,enumerable:!1};let za="captureStackTrace"in Error?Error:null;function nu(e){const n=za;if(n){const o=n.stackTraceLimit;if(typeof o=="number"){try{n.stackTraceLimit=0}catch{return za=null,new e}try{return new e}finally{n.stackTraceLimit=o}}}return new e}function R(e,n,o,a){const r={};function s(h){this.def=h,this.constr=p,this.traits=new Set}s.prototype=r;const i=o,l=i&&new WeakSet;function c(h,f){if(h._zod){if(h._zod.traits.has(e))return}else{po.value=new s(f);try{Object.defineProperty(h,"_zod",po)}finally{po.value=void 0}}if(h._zod.traits.add(e),n(h,f),l){const g=Object.getPrototypeOf(h),v=h._zod.constr.prototype;let y=g;for(;y&&y!==v;)y=Object.getPrototypeOf(y);const k=y??g;l.has(k)||(l.add(k),qc(k,i))}const m=p.prototype;for(const g in m)Object.prototype.hasOwnProperty.call(m,g)&&(g in h||(h[g]=m[g].bind(h)))}const u=a?.Parent??Object;class d extends u{}Object.defineProperty(d,"name",{value:e});function p(h){const f=a?.Parent?nu(d):this;c(f,h);const m=f._zod.deferred;if(m){for(const v of m)v();f._zod.deferred=void 0}const g=globalThis.__zod_globalConfig?.postProcessor;return g&&g(f),f}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:h=>a?.Parent&&h instanceof a.Parent?!0:h?._zod?.traits?.has(e)}),Object.defineProperty(p,"name",{value:e}),p}class zt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Wr extends Error{constructor(n){super(`Encountered unidirectional transform during encode: ${n}`),this.name="ZodEncodeError"}}(Va=globalThis).__zod_globalConfig??(Va.__zod_globalConfig={});const pt=globalThis.__zod_globalConfig;function Bt(e){return e&&Object.assign(pt,e),pt}function ou(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Ao,2)),e.message}function au(e){this._zod.message=e}const ru={get:ou,set:au,enumerable:!0,configurable:!0},fo={value:void 0,enumerable:!1},Ua=new WeakSet([Object.prototype,Error.prototype]),su=(e,n)=>{e.name="$ZodError",fo.value=n,Object.defineProperty(e,"issues",fo),fo.value=void 0,Object.defineProperty(e,"message",ru);const o=Object.getPrototypeOf(e);Ua.has(o)||(Ua.add(o),Object.defineProperty(o,"toString",{configurable:!0,enumerable:!1,get(){const a=()=>this.message;return Object.defineProperty(this,"toString",{value:a,configurable:!0,writable:!0}),a},set(a){Object.defineProperty(this,"toString",{value:a,configurable:!0,writable:!0})}}))},iu=R("$ZodError",su);function lu(e,n,o){return Object.prototype.hasOwnProperty.call(e,n)||(n==="__proto__"?Object.defineProperty(e,n,{value:o(),writable:!0,enumerable:!0,configurable:!0}):e[n]=o()),e[n]}function cu(e,n=o=>o.message){const o={},a=[];for(const r of e.issues)r.path.length>0?lu(o,r.path[0],()=>[]).push(n(r)):a.push(n(r));return{formErrors:a,fieldErrors:o}}function uu(e,n=o=>o.message){const o={_errors:[]},a=(r,s=[])=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(l=>a({issues:l},[...s,...i.path]));else if(i.code==="invalid_key")a({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")a({issues:i.issues},[...s,...i.path]);else{const l=[...s,...i.path];if(l.length===0)o._errors.push(n(i));else{let c=o,u=0;for(;u<l.length;){const d=l[u],p=u===l.length-1;if(d==="_errors"){p&&c._errors.push(n(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,d)||Object.defineProperty(c,d,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const h=c[d];p&&h._errors.push(n(i)),c=h,u++}}}};return a(e),o}function Xn(e,n){return{callee:n?.callee??e,Err:n?.Err}}const Xo=e=>{const n=(o,a,r,s)=>{const i=r?{...r,async:!1}:{async:!1},l=o._zod.run({value:a,issues:[]},i);if(l instanceof Promise)throw new zt;if(l.issues.length){const c=new(s?.Err??e)(l.issues.map(u=>Xt(u,i,Bt())));throw Fr(c,s?.callee??n),c}return l.value};return n},Qo=e=>{const n=async(o,a,r,s)=>{const i=r?{...r,async:!0}:{async:!0};let l=o._zod.run({value:a,issues:[]},i);if(l instanceof Promise&&(l=await l),l.issues.length){const c=new(s?.Err??e)(l.issues.map(u=>Xt(u,i,Bt())));throw Fr(c,s?.callee??n),c}return l.value};return n},ea=e=>(n,o,a)=>{const r=a?{...a,async:!1}:{async:!1},s=n._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw new zt;return s.issues.length?Hr(e,s.issues,r):{success:!0,data:s.value}};function Hr(e,n,o){let a;return{success:!1,get error(){return a||(a=new e(n.map(r=>Xt(r,o,Bt()))),n=void 0,o=void 0),a},set error(r){a=r,n=void 0,o=void 0}}}const ta=e=>async(n,o,a)=>{const r=a?{...a,async:!0}:{async:!0};let s=n._zod.run({value:o,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?Hr(e,s.issues,r):{success:!0,data:s.value}},du=Symbol.for("zod.compile.invalid"),pu=Symbol.for("zod.compile.fallback"),fu=((e,n,o)=>{const a=e._zod.bag.validator;if(a!==void 0){if(a(n)!==du)return!0;if(a.definite===!0&&o===void 0)return!1}return mu(e,n,o)});function mu(e,n,o){const a=o?{...o,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun;let s;if(r?(a[pu]=!0,s=r({value:n,issues:[]},a)):s=e._zod.run({value:n,issues:[]},a),s instanceof Promise)throw new zt;return s.issues.length===0}const hu=async(e,n,o)=>{const a=o?{...o,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let r=e._zod.run({value:n,issues:[]},a);return r instanceof Promise&&(r=await r),r.issues.length===0},gu=e=>{const n=Xo(e),o=(a,r,s,i)=>{const l=s?{...s,direction:"backward"}:{direction:"backward"};return n(a,r,l,Xn(o,i))};return o},vu=e=>{const n=Xo(e),o=(a,r,s,i)=>n(a,r,s,Xn(o,i));return o},bu=e=>{const n=Qo(e),o=async(a,r,s,i)=>{const l=s?{...s,direction:"backward"}:{direction:"backward"};return await n(a,r,l,Xn(o,i))};return o},yu=e=>{const n=Qo(e),o=async(a,r,s,i)=>await n(a,r,s,Xn(o,i));return o},ku=e=>(n,o,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return ea(e)(n,o,r)},Su=e=>(n,o,a)=>ea(e)(n,o,a),wu=e=>async(n,o,a)=>{const r=a?{...a,direction:"backward"}:{direction:"backward"};return ta(e)(n,o,r)},Cu=e=>async(n,o,a)=>ta(e)(n,o,a),Tu=/^[cC][0-9a-z]{6,}$/,Eu=/^[0-9a-z]+$/,Iu=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,_u=/^[0-9a-vA-V]{20}$/,Au=/^[A-Za-z0-9]{27}$/,$u=/^[a-zA-Z0-9_-]{21}$/;function Ru(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const xu=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ou=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ja=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Nu=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Mu="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Bu(){return new RegExp(Mu,"u")}const Du=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Fu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Pu=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Lu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Vu=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,zu=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Uu=/^https?$/,ju=/^\+[1-9]\d{6,14}$/,Kr="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function Zu(e){return new RegExp(`^${e}$`)}const Wu=Zu(Kr);function Ro(e){const n="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${n}`:e.precision===0?`${n}:[0-5]\\d`:`${n}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${n}:[0-5]\\d(?:\\.\\d+)?`:`${n}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Hu(e){return new RegExp(`^${Ro(e)}$`)}function Ku(e){const n=["Z"];e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${Ro({precision:e.precision,seconds:!0})}(?:${n.join("|")})`,a=e.local?`${o}|${Ro({precision:e.precision})}`:o;return new RegExp(`^${Kr}T(?:${a})$`)}const Gu=/^[\s\S]{0,}$/,qu=/^-?\d+(?:\.\d+)?$/,Ju=/^(?:true|false)$/i,Yu=/^[^A-Z]*$/,Xu=/^[^a-z]*$/,nt=R("$ZodCheck",(e,n)=>{var o;e._zod??(e._zod={}),e._zod.def=n,(o=e._zod).onattach??(o.onattach=[])}),na=e=>{const n=e.value;return!xc(n)&&n.length!==void 0},Un={number:"number",bigint:"bigint",object:"date"},Gr=R("$ZodCheckLessThan",(e,n)=>{nt.init(e,n);const o=Un[typeof n.value];e._zod.check=a=>{(n.inclusive?a.value<=n.value:a.value<n.value)||a.issues.push({origin:Un[typeof a.value]??o,code:"too_big",maximum:typeof n.value=="object"?n.value.getTime():n.value,input:a.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}}),qr=R("$ZodCheckGreaterThan",(e,n)=>{nt.init(e,n);const o=Un[typeof n.value];e._zod.check=a=>{(n.inclusive?a.value>=n.value:a.value>n.value)||a.issues.push({origin:Un[typeof a.value]??o,code:"too_small",minimum:typeof n.value=="object"?n.value.getTime():n.value,input:a.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}}),Qu=R("$ZodCheckMultipleOf",(e,n)=>{nt.init(e,n),e._zod.check=o=>{if(typeof o.value!=typeof n.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof o.value=="bigint"?n.value!==BigInt(0)&&o.value%n.value===BigInt(0):Oc(o.value,n.value)===0)||o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:n.value,input:o.value,inst:e,continue:!n.abort})}}),ed=R("$ZodCheckNumberFormat",(e,n)=>{nt.init(e,n),n.format=n.format||"float64";const o=n.format?.includes("int"),a=o?"int":"number",[r,s]=Vr[n.format];e._zod.check=i=>{const l=i.value;if(o){if(!Number.isInteger(l)){i.issues.push({expected:a,format:n.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?i.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!n.abort}):i.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!n.abort});return}}l<r&&i.issues.push({origin:"number",input:l,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!n.abort}),l>s&&i.issues.push({origin:"number",input:l,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!n.abort})}}),td=R("$ZodCheckMaxLength",(e,n)=>{var o;nt.init(e,n),(o=e._zod.def).when??(o.when=na),e._zod.check=a=>{const r=a.value,s=r.length;if((typeof r=="string"&&s>n.maximum?Jo(r):s)<=n.maximum)return;const l=Yo(r);a.issues.push({origin:l,code:"too_big",maximum:n.maximum,inclusive:!0,input:r,inst:e,continue:!n.abort})}}),nd=R("$ZodCheckMinLength",(e,n)=>{var o;nt.init(e,n),(o=e._zod.def).when??(o.when=na),e._zod.check=a=>{const r=a.value,s=r.length;if((typeof r=="string"&&s>=n.minimum&&s<n.minimum*2?Jo(r):s)>=n.minimum)return;const l=Yo(r);a.issues.push({origin:l,code:"too_small",minimum:n.minimum,inclusive:!0,input:r,inst:e,continue:!n.abort})}}),od=R("$ZodCheckLengthEquals",(e,n)=>{var o;nt.init(e,n),(o=e._zod.def).when??(o.when=na),e._zod.check=a=>{const r=a.value,s=r.length,i=typeof r=="string"&&s>=n.length&&s<=n.length*2?Jo(r):s;if(i===n.length)return;const l=Yo(r),c=i>n.length;a.issues.push({origin:l,...c?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!n.abort})}}),Qn=R("$ZodCheckStringFormat",(e,n)=>{var o,a;nt.init(e,n),n.pattern?(o=e._zod).check??(o.check=r=>{n.pattern.lastIndex=0,!n.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:n.format,input:r.value,...n.pattern?{pattern:n.pattern.toString()}:{},inst:e,continue:!n.abort})}):(a=e._zod).check??(a.check=()=>{})}),ad=R("$ZodCheckRegex",(e,n)=>{Qn.init(e,n),e._zod.check=o=>{n.pattern.lastIndex=0,!n.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:n.pattern.toString(),inst:e,continue:!n.abort})}}),rd=R("$ZodCheckLowerCase",(e,n)=>{n.pattern??(n.pattern=Yu),Qn.init(e,n)}),sd=R("$ZodCheckUpperCase",(e,n)=>{n.pattern??(n.pattern=Xu),Qn.init(e,n)}),id=R("$ZodCheckIncludes",(e,n)=>{nt.init(e,n);const o=Gt(n.includes),a=new RegExp(typeof n.position=="number"?`^.{${n.position},}${o}`:o);n.pattern=a,e._zod.check=r=>{r.value.includes(n.includes,n.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:n.includes,input:r.value,inst:e,continue:!n.abort})}}),ld=R("$ZodCheckStartsWith",(e,n)=>{nt.init(e,n);const o=new RegExp(`^${Gt(n.prefix)}.*`);n.pattern??(n.pattern=o),e._zod.check=a=>{a.value.startsWith(n.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:n.prefix,input:a.value,inst:e,continue:!n.abort})}}),cd=R("$ZodCheckEndsWith",(e,n)=>{nt.init(e,n);const o=new RegExp(`.*${Gt(n.suffix)}$`);n.pattern??(n.pattern=o),e._zod.check=a=>{a.value.endsWith(n.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:n.suffix,input:a.value,inst:e,continue:!n.abort})}}),ud=R("$ZodCheckOverwrite",(e,n)=>{nt.init(e,n),e._zod.check=o=>{o.value=n.tx(o.value)}});class dd{constructor(n=[],o={}){this.content=[],this.indent=0,this.args=n,this.closed=o}indented(n){this.indent+=1;try{n(this)}finally{this.indent-=1}}write(n){if(typeof n=="function"){n(this,{execution:"sync"}),n(this,{execution:"async"});return}const a=n.split(`
|
|
2
|
+
`).filter(i=>i),r=Math.min(...a.map(i=>i.length-i.trimStart().length)),s=a.map(i=>i.slice(r)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const n=Function,o=this?.content??[""];return new n(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
3
|
+
${o.join(`
|
|
4
|
+
`)}
|
|
5
|
+
};`)(...Object.values(this.closed))}}const pd={major:4,minor:6,patch:7},_e=R("$ZodType",(e,n)=>{var o;e??(e={}),e._zod.def=n,e._zod.bag=e._zod.bag||{},e._zod.version=pd;const a=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...a??[]]:a?.length?[...a]:[];for(const s of r)for(const i of s._zod.onattach)i(e);if(r.length===0)(o=e._zod).deferred??(o.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const s=(l,c,u)=>{if(l.memo)return l;let d=yt(l),p;for(const h of c){if(h._zod.def.when){if(Hc(l)||!h._zod.def.when(l))continue}else if(d)continue;const f=l.issues.length,m=h._zod.check(l);if(m instanceof Promise&&u?.async===!1)throw new zt;if(p||m instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await m,l.issues.length!==f&&($o(l.issues,f,e),d||(d=yt(l,f)))});else{if(l.issues.length===f)continue;$o(l.issues,f,e),d||(d=yt(l,f))}}return p?p.then(()=>l):l},i=(l,c,u)=>{if(yt(l))return l.aborted=!0,l;const d=s(c,r,u);if(d instanceof Promise){if(u.async===!1)throw new zt;return d.then(p=>e._zod.parse(p,u))}return e._zod.parse(d,u)};e._zod.run=(l,c)=>{if(c.skipChecks)return e._zod.parse(l,c);if(c.direction==="backward"){const d=e._zod.parse({value:l.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(p=>i(p,l,c)):i(d,l,c)}const u=e._zod.parse(l,c);if(u instanceof Promise){if(c.async===!1)throw new zt;return u.then(d=>s(d,r,c))}return s(u,r,c)}}},{get"~standard"(){return jr(this,"~standard",Yr(this))},set"~standard"(e){xt(this,"~standard",e)}}),Jr=(e,n)=>e.issues.length?{issues:e.issues.map(o=>Xt(o,n,Bt()))}:{value:e.value};async function fd(e,n){const o={async:!0};return Jr(await e._zod.run({value:n,issues:[]},o),o)}function Yr(e){return{validate:n=>{const o={async:!1};try{const a=e._zod.run({value:n,issues:[]},o);if(!(a instanceof Promise))return Jr(a,o)}catch{}return fd(e,n)},vendor:"zod",version:1}}const oa=R("$ZodString",(e,n)=>{_e.init(e,n),e._zod.pattern=n.pattern??Gu,e._zod.parse=(o,a)=>{if(n.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),Ce=R("$ZodStringFormat",(e,n)=>{Qn.init(e,n),oa.init(e,n)}),md=R("$ZodGUID",(e,n)=>{n.pattern??(n.pattern=Ou),Ce.init(e,n)}),hd=R("$ZodUUID",(e,n)=>{if(n.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[n.version];if(a===void 0)throw new Error(`Invalid UUID version: "${n.version}"`);n.pattern??(n.pattern=ja(a))}else n.pattern??(n.pattern=ja());Ce.init(e,n)}),gd=R("$ZodEmail",(e,n)=>{n.pattern??(n.pattern=Nu),Ce.init(e,n)}),Xr=1,jn=2;function Qr(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function vd(e,n){return!("normalize"in n)&&!("hostname"in n)&&!("protocol"in n)?Qr(e)||jn:bd(e,n)}function bd(e,n){if(!n.normalize&&n.protocol?.source===Uu.source&&!/^https?:\/\//i.test(e))return Xr;try{if(typeof URL<"u"){const o=URL;if(typeof o.parse=="function")return o.parse(e)??jn}return new URL(e)}catch{return jn}}const yd=/[\t\n\r]/g;function Za(e){return e.replace(yd,"")}function kd(e,n){return n.lastIndex=0,n.test(e.hostname)}function Sd(e,n){return n.lastIndex=0,n.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const wd=R("$ZodURL",(e,n)=>{Ce.init(e,n),e._zod.check=o=>{try{const a=o.value.trim(),r=vd(a,n);if(r===Xr){o.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:o.value,inst:e,continue:!n.abort});return}if(r===jn){o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:e,continue:!n.abort});return}if(r===!0){o.value=Za(a);return}n.hostname&&!kd(r,n.hostname)&&o.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:n.hostname.source,input:o.value,inst:e,continue:!n.abort}),n.protocol&&!Sd(r,n.protocol)&&o.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:n.protocol.source,input:o.value,inst:e,continue:!n.abort}),o.value=n.normalize?r.href:Za(a);return}catch{o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:e,continue:!n.abort})}}}),Cd=R("$ZodEmoji",(e,n)=>{n.pattern??(n.pattern=Bu()),Ce.init(e,n)}),Td=R("$ZodNanoID",(e,n)=>{if(n.length!==void 0&&(!Number.isInteger(n.length)||n.length<1))throw new Error(`Invalid nanoid length: ${n.length}`);n.pattern??(n.pattern=n.length===void 0?$u:Ru(n.length)),Ce.init(e,n)}),Ed=R("$ZodCUID",(e,n)=>{n.pattern??(n.pattern=Tu),Ce.init(e,n)}),Id=R("$ZodCUID2",(e,n)=>{n.pattern??(n.pattern=Eu),Ce.init(e,n)}),_d=R("$ZodULID",(e,n)=>{n.pattern??(n.pattern=Iu),Ce.init(e,n)}),Ad=R("$ZodXID",(e,n)=>{n.pattern??(n.pattern=_u),Ce.init(e,n)}),$d=R("$ZodKSUID",(e,n)=>{n.pattern??(n.pattern=Au),Ce.init(e,n)}),Rd=R("$ZodISODateTime",(e,n)=>{n.pattern??(n.pattern=Ku(n)),Ce.init(e,n)}),xd=R("$ZodISODate",(e,n)=>{n.pattern??(n.pattern=Wu),Ce.init(e,n)}),Od=R("$ZodISOTime",(e,n)=>{n.pattern??(n.pattern=Hu(n)),Ce.init(e,n)}),Nd=R("$ZodISODuration",(e,n)=>{n.pattern??(n.pattern=xu),Ce.init(e,n)}),Md=R("$ZodIPv4",(e,n)=>{n.pattern??(n.pattern=Du),Ce.init(e,n)}),Bd=/^[0-9a-fA-F:.]+$/;function es(e){return Bd.test(e)?Qr(`http://[${e}]`):!1}const Dd=R("$ZodIPv6",(e,n)=>{n.pattern??(n.pattern=Fu),Ce.init(e,n),e._zod.check=o=>{es(o.value)||o.issues.push({code:"invalid_format",format:"ipv6",input:o.value,inst:e,continue:!n.abort})}}),Fd=R("$ZodCIDRv4",(e,n)=>{n.pattern??(n.pattern=Pu),Ce.init(e,n)});function Pd(e){const n=e.split("/");if(n.length!==2)return!1;const[o,a]=n;if(!a)return!1;const r=Number(a);return`${r}`!==a||r<0||r>128?!1:es(o)}const Ld=R("$ZodCIDRv6",(e,n)=>{n.pattern??(n.pattern=Lu),Ce.init(e,n),e._zod.check=o=>{Pd(o.value)||o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:e,continue:!n.abort})}});function ts(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ns=/^[0-9a-zA-Z+/]*={0,2}$/,Vd=R("$ZodBase64",(e,n)=>{n.pattern??(n.pattern=ns),Ce.init(e,n),e._zod.check=o=>{ts(o.value)||o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!n.abort})}}),aa=/^[A-Za-z0-9_-]*$/;function zd(e){if(!aa.test(e))return!1;const n=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),o=n.padEnd(Math.ceil(n.length/4)*4,"=");return ts(o)}const Ud=R("$ZodBase64URL",(e,n)=>{n.pattern??(n.pattern=aa),Ce.init(e,n),e._zod.check=o=>{zd(o.value)||o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!n.abort})}}),jd=R("$ZodE164",(e,n)=>{n.pattern??(n.pattern=ju),Ce.init(e,n)});function Zd(e,n=null){try{const o=e.split(".");if(o.length!==3)return!1;const[a]=o;if(!a)return!1;const r=JSON.parse(atob(a));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||n&&(!("alg"in r)||r.alg!==n))}catch{return!1}}const Wd=R("$ZodJWT",(e,n)=>{Ce.init(e,n),e._zod.check=o=>{Zd(o.value,n.alg)||o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!n.abort})}}),os=R("$ZodNumber",(e,n)=>{_e.init(e,n),e._zod.pattern=qu,e._zod.parse=(o,a)=>{if(n.coerce)try{o.value=Number(o.value)}catch{}const r=o.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return o;const s=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:String(r):void 0;return o.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...s?{received:s}:{}}),o}}),Hd=R("$ZodNumberFormat",(e,n)=>{ed.init(e,n),os.init(e,n)}),Kd=R("$ZodBoolean",(e,n)=>{_e.init(e,n),e._zod.pattern=Ju,e._zod.parse=(o,a)=>{if(n.coerce)try{o.value=!!o.value}catch{}const r=o.value;return typeof r=="boolean"||o.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),o}}),Gd=R("$ZodAny",(e,n)=>{_e.init(e,n),e._zod.parse=o=>o}),qd=R("$ZodUnknown",(e,n)=>{_e.init(e,n),e._zod.parse=o=>o}),Jd=R("$ZodNever",(e,n)=>{_e.init(e,n),e._zod.parse=(o,a)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)});function Yd(e,n){const o=La(e._zod.def.checks);if(!o.length)return;const a=Math.min(...o.map(s=>s[0])),r=e._zod.parse;e._zod.parse=(s,i)=>{const l=n(s.value);if(l>a&&!i?.skipChecks&&i?.direction!=="backward"){for(const[c,u]of La(e._zod.def.checks))if(l>c&&u._zod.def.when(s)){const d=s.issues.length;return u._zod.check(s),s.issues[d].continue=!1,$o(s.issues,d,e),s}}return r(s,i)}}const Xd=e=>Array.isArray(e)?e.length:-1;function Wa(e,n,o){e.issues.length&&n.issues.push(...Ur(o,e.issues)),n.value[o]=e.value}const Qd=R("$ZodArray",(e,n)=>{_e.init(e,n);const o=pt.memoizer;o?.attach(e),e._zod.parse=(a,r)=>{const s=a.value;if(!Array.isArray(s))return a.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),a;a.value=o?o.alloc(e,a,Array(s.length),r):Array(s.length);const i=[],l=r?.abortEarly;for(let c=0;c<s.length;c++){const u=s[c],d=n.element._zod.run({value:u,issues:[]},r);if(d instanceof Promise)i.push(d.then(p=>Wa(p,a,c)));else if(Wa(d,a,c),l&&d.issues.length!==0&&yt(d))break}return i.length?Promise.all(i).then(()=>a):a},Yd(e,Xd)});function Zn(e,n,o,a,r,s){const i=o in a,l=s==="optional";if(!(!i&&l&&r==="optional")){if(e.issues.length){if(r!==void 0&&l&&!i)return;n.issues.push(...Ur(o,e.issues))}if(!i&&r===void 0){e.issues.length||n.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[o]});return}e.value===void 0?(i||r==="defaulted"&&!l)&&(n.value[o]=void 0):n.value[o]=e.value}}const ep=[];function as(e){const n=Object.keys(e.shape),o=Object.getOwnPropertySymbols(e.shape),a=o.length?o:ep,r=a.length?[...n,...a]:n;for(const i of r)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);const s=Pc(e.shape);return{...e,allKeys:r,symbolKeys:a,keySet:new Set(n),numKeys:n.length,optionalKeys:new Set(s)}}function rs(e,n,o,a,r,s,i){const l=[],c=r.keySet,u=r.catchall._zod,d=u.def.type,p=u.optin,h=u.optout;let f=0;for(const m in n){if(i&&o.issues.length!==f){if(yt(o,f))break;f=o.issues.length}if(c.has(m))continue;if(m==="__proto__"){d==="never"&&l.push(m);continue}if(d==="never"){l.push(m);continue}const g=u.run({value:n[m],issues:[]},a);g instanceof Promise?e.push(g.then(v=>Zn(v,o,m,n,p,h))):Zn(g,o,m,n,p,h)}return l.length&&o.issues.push({code:"unrecognized_keys",keys:l,input:n,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>o):o}const tp=R("$ZodObject",(e,n)=>{_e.init(e,n);const o=Object.getOwnPropertyDescriptor(n,"shape"),a=o?.get?o.get.raw:n.shape??{};if(a){const u=()=>{const d={...a};return Object.defineProperty(n,"shape",{value:d}),u.raw=d,d};u.raw=a,Object.defineProperty(n,"shape",{get:u})}const r=Jn(()=>as(n));be(e,"propValues",u=>{const d=u.def.shape,p={};for(const h in d){const f=d[h]._zod;if(f.values){Object.prototype.hasOwnProperty.call(p,h)||Nt(p,h,new Set);for(const m of f.values)p[h].add(m);f.optin!==void 0&&p[h].add(void 0)}}return p});const s=fn,i=n.catchall;let l;const c=pt.memoizer;c?.attach(e),e._zod.parse=(u,d)=>{l??(l=r.value);const p=u.value;if(!s(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value=c?c.alloc(e,u,{},d):{};const h=[],f=l.shape,m=d?.abortEarly;let g=u.issues.length;for(const v of l.allKeys){if(m&&u.issues.length!==g){if(yt(u,g))break;g=u.issues.length}if(v==="__proto__")continue;const y=f[v],k=y._zod.optin,b=y._zod.optout,w=y._zod.run({value:p[v],issues:[]},d);w instanceof Promise?h.push(w.then(S=>Zn(S,u,v,p,k,b))):Zn(w,u,v,p,k,b)}return i?rs(h,p,u,d,r.value,e,m===!0):h.length?Promise.all(h).then(()=>u):u}}),np=R("$ZodObjectJIT",(e,n)=>{tp.init(e,n);const o=e._zod.parse,a=Jn(()=>as(n)),r=pt.memoizer,s=f=>{const m=a.value,g=m.symbolKeys,v=new dd(["payload","ctx"],{shape:f,inst:e,memo:r,syms:g}),y=S=>`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`,k=(S,C)=>`
|
|
6
|
+
let ${S}_ab = false;
|
|
7
|
+
for (let i = 0; i < ${S}.issues.length; i++) {
|
|
8
|
+
const iss = ${S}.issues[i];
|
|
9
|
+
iss.path = iss.path ? [${C}, ...iss.path] : [${C}];
|
|
10
|
+
payload.issues.push(iss);
|
|
11
|
+
if (iss.continue !== true) ${S}_ab = true;
|
|
12
|
+
}
|
|
13
|
+
if (${S}_ab && ctx && ctx.abortEarly) {
|
|
14
|
+
payload.value = newResult;
|
|
15
|
+
return payload;
|
|
16
|
+
}`;v.write("const input = payload.value;");const b=Object.create(null);let w=0;for(const S of m.allKeys)b[S]=`key_${w++}`;v.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const S of m.allKeys){if(S==="__proto__")continue;const C=b[S],A=typeof S=="symbol"?`syms[${g.indexOf(S)}]`:Mc(S),E=`${A} in input`,L=f[S],z=L?._zod?.optin,O=z!==void 0,N=L?._zod?.optout==="optional";if(v.write(`const ${C} = ${y(A)};`),O&&N){const K=z==="optional"?`${C}_present`:`${C}.value !== undefined || ${C}_present`;v.write(`
|
|
17
|
+
const ${C}_present = ${E};
|
|
18
|
+
if (!${C}.issues.length || ${C}_present) {
|
|
19
|
+
if (${C}.issues.length) {${k(C,A)}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (${K}) {
|
|
23
|
+
newResult[${A}] = ${C}.value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
`)}else O?(v.write(`
|
|
28
|
+
if (${C}.issues.length) {${k(C,A)}
|
|
29
|
+
}
|
|
30
|
+
`),z==="defaulted"?v.write(`newResult[${A}] = ${C}.value;`):v.write(`
|
|
31
|
+
if (${C}.value !== undefined || ${E}) {
|
|
32
|
+
newResult[${A}] = ${C}.value;
|
|
33
|
+
}
|
|
34
|
+
`)):v.write(`
|
|
35
|
+
const ${C}_present = ${E};
|
|
36
|
+
if (${C}.issues.length) {${k(C,A)}
|
|
37
|
+
}
|
|
38
|
+
if (!${C}_present && !${C}.issues.length) {
|
|
39
|
+
payload.issues.push({
|
|
40
|
+
code: "invalid_type",
|
|
41
|
+
expected: "nonoptional",
|
|
42
|
+
input: undefined,
|
|
43
|
+
path: [${A}]
|
|
44
|
+
});
|
|
45
|
+
if (ctx && ctx.abortEarly) {
|
|
46
|
+
payload.value = newResult;
|
|
47
|
+
return payload;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (${C}_present) {
|
|
52
|
+
newResult[${A}] = ${C}.value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
`)}return v.write("payload.value = newResult;"),v.write("return payload;"),v.compile()};let i;const l=fn,c=!pt.jitless,d=c&&Dc.value,p=n.catchall;let h;e._zod.parse=(f,m)=>{h??(h=a.value);const g=f.value;return l(g)?c&&d&&m?.async===!1&&m.jitless!==!0?(i||(i=s(n.shape)),f=i(f,m),p?rs([],g,f,m,h,e,m?.abortEarly===!0):f):o(f,m):(f.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),f)}});function Ha(e,n,o,a){for(const s of e)if(s.issues.length===0)return n.value=s.value,n;const r=e.filter(s=>!yt(s));return r.length===1?(n.value=r[0].value,r[0]):(n.issues.push({code:"invalid_union",input:n.value,inst:o,errors:e.map(s=>s.issues.map(i=>Xt(i,a,Bt())))}),n)}const ss=R("$ZodUnion",(e,n)=>{_e.init(e,n),be(e,"optin",a=>a.def.options.some(r=>r._zod.optin==="defaulted")?"defaulted":a.def.options.some(r=>r._zod.optin!==void 0)?"optional":void 0),be(e,"optout",a=>a.def.options.some(r=>r._zod.optout==="optional")?"optional":void 0),be(e,"values",a=>{if(a.def.options.every(r=>r._zod.values))return new Set(a.def.options.flatMap(r=>Array.from(r._zod.values)))}),be(e,"pattern",a=>{if(a.def.options.every(r=>r._zod.pattern)){const r=a.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${r.map(s=>Go(s.source)).join("|")})$`)}});const o=n.options.length===1?n.options[0]._zod.run:null;e._zod.parse=(a,r)=>{if(o)return o(a,r);let s=!1;const i=[];for(const l of n.options){const c=l._zod.run({value:a.value,issues:[]},r);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(l=>Ha(l,a,e,r)):Ha(i,a,e,r)}});function op(e){const n=new Map;for(const o of e.options){const a=o._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(const r of a)if(n.has(r)){if(r!==void 0)throw new Error(`Duplicate discriminator value "${String(r)}"`);n.set(r,null)}else n.set(r,o)}return n}const ap=R("$ZodDiscriminatedUnion",(e,n)=>{n.inclusive=!1,ss.init(e,n);const o=e._zod.parse;be(e,"propValues",r=>{const s={};let i=0;for(const l of r.def.options){const c=l._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${r.def.options.indexOf(l)}"`);c[r.def.discriminator]?.has(void 0)&&i++;for(const[u,d]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||Nt(s,u,new Set);for(const p of d)s[u].add(p)}}return!r.def.unionFallback&&i>1&&s[r.def.discriminator]?.delete(void 0),s}),n.options.forEach((r,s)=>{const i=qo(r._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,n.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});const a=Jn(()=>op(n));e._zod.parse=(r,s)=>{const i=r.value;if(!fn(i))return r.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),r;const l=i?.[n.discriminator],c=a.value.get(l);return c&&(l!==void 0||s.direction!=="backward")?c._zod.run(r,s):n.unionFallback||s.direction==="backward"?o(r,s):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:n.discriminator,options:Array.from(a.value.keys()).filter(u=>a.value.get(u)!==null),input:i,path:[n.discriminator],inst:e}),r)}}),rp=R("$ZodIntersection",(e,n)=>{_e.init(e,n),e._zod.parse=(o,a)=>{const r=o.value,s=n.left._zod.run({value:r,issues:[]},a),i=n.right._zod.run({value:r,issues:[]},a);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Ka(o,c,u)):Ka(o,s,i)}});function xo(e,n){if(e===n)return{valid:!0,data:e};if(e instanceof Date&&n instanceof Date&&+e==+n)return{valid:!0,data:e};if(mn(e)&&mn(n)){const o=Object.keys(n),a=Object.keys(e).filter(s=>o.indexOf(s)!==-1),r={...e,...n};Object.prototype.hasOwnProperty.call(r,"__proto__")&&delete r.__proto__;for(const s of a){if(s==="__proto__")continue;const i=xo(e[s],n[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};r[s]=i.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return{valid:!1,mergeErrorPath:[]};const o=[];for(let a=0;a<e.length;a++){const r=e[a],s=n[a],i=xo(r,s);if(!i.valid)return{valid:!1,mergeErrorPath:[a,...i.mergeErrorPath]};o.push(i.data)}return{valid:!0,data:o}}return{valid:!1,mergeErrorPath:[]}}function Ka(e,n,o){const a=new Map;let r;const s=new Map,i=(u,d)=>{let p;if(u.code==="unrecognized_keys"&&!u.path?.length)r??(r=u),p=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){const h=String(u.path[0]);s.has(h)||s.set(h,u),p=[h]}else return!1;for(const h of p)a.has(h)||a.set(h,{}),a.get(h)[d]=!0;return!0};for(const u of n.issues)i(u,"l")||e.issues.push(u);for(const u of o.issues)i(u,"r")||e.issues.push(u);const l=[...a].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(l.length){const u=r?l.filter(d=>r.keys.includes(d)):[];u.length&&e.issues.push({...r,keys:u});for(const d of l)!u.includes(d)&&s.has(d)&&e.issues.push(s.get(d))}const c=xo(n.value,o.value);if(!c.valid){if(yt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const sp=R("$ZodEnum",(e,n)=>{_e.init(e,n);const o=_o(n.entries),a=new Set(o);e._zod.values=a,be(e,"pattern",r=>{const s=_o(r.def.entries).filter(i=>Fc.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>Gt(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,s)=>{const i=r.value;return a.has(i)||r.issues.push({code:"invalid_value",values:o,input:i,inst:e}),r}}),ip=R("$ZodLiteral",(e,n)=>{_e.init(e,n);const o=new Set(n.values);e._zod.values=o,be(e,"pattern",a=>{const r=a.def.values;return new RegExp(r.length?`^(${r.map(s=>typeof s=="string"?Gt(s):s?Gt(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(a,r)=>{const s=a.value;return o.has(s)||a.issues.push({code:"invalid_value",values:n.values,input:s,inst:e}),a}}),lp=R("$ZodTransform",(e,n)=>{_e.init(e,n),e._zod.optin="optional",pt.memoizer?.guard(e),e._zod.parse=(o,a)=>{if(a.direction==="backward")throw new Wr(e.constructor.name);const r=n.transform(o.value,o);if(a.async)return(r instanceof Promise?r:Promise.resolve(r)).then(i=>(o.value=i,o));if(r instanceof Promise)throw new zt;return o.value=r,o}});function Ga(e,n){return e.value=n.issues.length?void 0:n.value,e}const is=R("$ZodOptional",(e,n)=>{_e.init(e,n),be(e,"optin",o=>o.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",be(e,"values",o=>{const a=o.def.innerType._zod.values;return a?new Set([...a,void 0]):void 0}),be(e,"pattern",o=>{const a=o.def.innerType._zod.pattern;return a?new RegExp(`^(${Go(a.source)})?$`):void 0}),e._zod.parse=(o,a)=>{if(o.value===void 0){if(n.innerType._zod.optin!=="defaulted")return o;const r=n.innerType._zod.run({value:o.value,issues:[]},a);return r instanceof Promise?r.then(s=>Ga(o,s)):Ga(o,r)}return n.innerType._zod.run(o,a)}}),cp=R("$ZodExactOptional",(e,n)=>{is.init(e,n),be(e,"values",o=>o.def.innerType._zod.values),be(e,"pattern",o=>o.def.innerType._zod.pattern),e._zod.parse=(o,a)=>n.innerType._zod.run(o,a)}),up=R("$ZodNullable",(e,n)=>{_e.init(e,n),be(e,"optin",o=>o.def.innerType._zod.optin),be(e,"optout",o=>o.def.innerType._zod.optout),be(e,"pattern",o=>{const a=o.def.innerType._zod.pattern;return a?new RegExp(`^(${Go(a.source)}|null)$`):void 0}),be(e,"values",o=>o.def.innerType._zod.values?new Set([...o.def.innerType._zod.values,null]):void 0),e._zod.parse=(o,a)=>o.value===null?o:n.innerType._zod.run(o,a)}),dp=R("$ZodDefault",(e,n)=>{_e.init(e,n),e._zod.optin="defaulted",be(e,"values",o=>o.def.innerType._zod.values),e._zod.parse=(o,a)=>{if(a.direction==="backward")return n.innerType._zod.run(o,a);if(o.value===void 0)return o.value=n.defaultValue,o;const r=n.innerType._zod.run(o,a);return r instanceof Promise?r.then(s=>qa(s,n)):qa(r,n)}});function qa(e,n){return e.value===void 0&&(e.value=n.defaultValue),e}const pp=R("$ZodPrefault",(e,n)=>{_e.init(e,n),e._zod.optin="defaulted",be(e,"values",o=>o.def.innerType._zod.values),e._zod.parse=(o,a)=>(a.direction==="backward"||o.value===void 0&&(o.value=n.defaultValue),n.innerType._zod.run(o,a))}),fp=R("$ZodNonOptional",(e,n)=>{_e.init(e,n),be(e,"values",o=>{const a=o.def.innerType._zod.values;return a?new Set([...a].filter(r=>r!==void 0)):void 0}),e._zod.parse=(o,a)=>{const r=n.innerType._zod.run(o,a);return r instanceof Promise?r.then(s=>Ja(s,e)):Ja(r,e)}});function Ja(e,n){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:n}),e}function Ya(e,n,o,a){return n.issues.length?(e.value=o.catchValue({...n,value:e.value,error:{issues:n.issues.map(r=>Xt(r,a,Bt()))},input:e.value}),e):(e.value=n.value,n.memo&&(e.memo=!0),e)}const mp=R("$ZodCatch",(e,n)=>{_e.init(e,n),be(e,"optin",o=>o.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),be(e,"optout",o=>o.def.innerType._zod.optout),be(e,"values",o=>o.def.innerType._zod.values),e._zod.parse=(o,a)=>{if(a.direction==="backward")return n.innerType._zod.run(o,a);const r=n.innerType._zod.run({value:o.value,issues:[]},a);return r instanceof Promise?r.then(s=>Ya(o,s,n,a)):Ya(o,r,n,a)}}),hp=R("$ZodPipe",(e,n)=>{_e.init(e,n),be(e,"values",o=>o.def.in._zod.values),be(e,"optin",o=>o.def.in._zod.optin),be(e,"optout",o=>o.def.out._zod.optout),be(e,"propValues",o=>o.def.in._zod.propValues),e._zod.parse=(o,a)=>{if(a.direction==="backward"){const s=n.out._zod.run(o,a);return s instanceof Promise?s.then(i=>En(i,n.in,a)):En(s,n.in,a)}const r=n.in._zod.run(o,a);return r instanceof Promise?r.then(s=>En(s,n.out,a)):En(r,n.out,a)}});function En(e,n,o){return e.issues.some(a=>a.code!=="unrecognized_keys")?(e.aborted=!0,e):n._zod.run({value:e.value,issues:e.issues},o)}const gp=R("$ZodReadonly",(e,n)=>{_e.init(e,n),be(e,"propValues",o=>o.def.innerType._zod.propValues),be(e,"values",o=>o.def.innerType._zod.values),be(e,"optin",o=>o.def.innerType?._zod?.optin),be(e,"optout",o=>o.def.innerType?._zod?.optout),e._zod.parse=(o,a)=>{if(a.direction==="backward")return n.innerType._zod.run(o,a);const r=n.innerType._zod.run(o,a);return r instanceof Promise?r.then(Xa):Xa(r)}});function Xa(e){return e.memo||(e.value=Object.freeze(e.value)),e}const vp=R("$ZodCustom",(e,n)=>{nt.init(e,n),_e.init(e,n),e._zod.parse=(o,a)=>o,e._zod.check=o=>{const a=o.value,r=n.fn(a);if(r instanceof Promise)return r.then(s=>Qa(s,o,a,e));Qa(r,o,a,e)}});function Qa(e,n,o,a){if(!e){const r={code:"custom",input:o,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(r.params=a._zod.def.params),n.issues.push(hn(r))}}class bp extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Oo="~memo",er=[];function ls(e){return e!==null&&typeof e=="object"}function mo(e){return e.map(n=>n.path?{...n,path:n.path.slice()}:{...n})}const cs=new WeakMap,ln=0,Dn=1,un=2;function Fn(e,n,o){const a=cs.get(e);if(a!==void 0)return a?un:ln;if(n.has(e))return un;n.add(e);let r=ln;const s=d=>{if(r!==un&&d?._zod){const p=Fn(d,n);p>r&&(r=p)}},i=(d,p)=>{let h=ln;for(const f of Reflect.ownKeys(d)){const m=Object.getOwnPropertyDescriptor(d,f);if(!m.enumerable)continue;const g=m.get?Dn:m.value?._zod?Fn(m.value,n):ln;g>h&&(h=g)}return h},l=d=>{d>r&&(r=d)},c=e._zod.def;switch(c.type){case"object":{const d=qo(c);l(d?i(d):Dn),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(const d of c.items)s(d);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(const d of c.options)s(d);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{const d=c._cachedInner??void 0;l(d?Fn(d,n):Dn);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const d in c){const p=Object.getOwnPropertyDescriptor(c,d);if(!p||p.get)continue;const h=p.value;if(!(!h||typeof h!="object")){if(h._zod)s(h);else if(Array.isArray(h))for(const f of h)s(f)}}}return n.delete(e),yp(e,r)}function yp(e,n){return n!==Dn&&cs.set(e,n===un),n}function kp(e,n){let o=e.buckets.get(n);return o||(o=new WeakMap,e.buckets.set(n,o)),o}let In;const _n=[],Sp={alloc(e,n,o){const a=In;if(!a)return o;In=void 0;const r={value:o,issues:null};return a.set(n.value,r),_n.push(r),o},guard(e){var n;(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred.push(()=>{const o=e._zod.parse,a=(r,s)=>{if(s.direction!=="backward"&&Cp(s,r.value))throw new bp;return o(r,s)};e._zod.parse=a,e._zod.run===o&&(e._zod.run=a)})},attach(e){var n;let o,a=!1,r,s;(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred.push(()=>{const i=e._zod.parse,l=(c,u)=>{if(o===void 0){const y=Fn(e,new Set);if(y===ln)return e._zod.parse=i,e._zod.run===l&&(e._zod.run=i),i(c,u);y===un||a?o=!0:a=!0}const d=c.value;if(!ls(d))return i(c,u);let p=u[Oo];p||(p={buckets:new WeakMap,backEdges:void 0},u[Oo]=p);let h;r===u?h=s:(h=kp(p,e),r=u,s=h);const f=h.get(d);if(f)return c.value=f.value,f.issues?f.issues.length&&c.issues.push(...mo(f.issues)):(c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(f.value)),c;In=h;const m=_n.length,g=i(c,u);In=void 0;const v=_n.length>m?_n.pop():void 0;return g instanceof Promise?g.then(y=>(v&&(v.issues=y.issues.length?mo(y.issues):er),y)):(v&&(v.issues=g.issues.length?mo(g.issues):er),g)};e._zod.parse=l,e._zod.run===i&&(e._zod.run=l)})}};function wp(){return Sp}function Cp(e,n){const o=e[Oo]?.backEdges;return o!==void 0&&ls(n)&&o.has(n)}const Tp=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function n(s){return e[s]??null}const o={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},a={nan:"NaN"};function r(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):a[s]??s}return s=>{switch(s.code){case"invalid_type":{const i=r(s.expected),l=Gc(s.input),c=r(l,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${Lr(s.values[0])}`:`Invalid option: expected one of ${Fa(s.values,"|")}`;case"too_big":{const i=s.exact?"exactly ":s.inclusive?"<=":"<",l=n(s.origin);return l?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${l.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{const i=s.exact?"exactly ":s.inclusive?">=":">",l=n(s.origin);return l?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${l.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{const i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${o[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${Fa(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(l=>`'${l}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Ep(){return{localeError:Tp()}}var tr;class Ip{constructor(){this._map=new WeakMap,this._idmap=new Map}add(n,...o){const a=o[0];return this._map.set(n,a),a&&typeof a=="object"&&"id"in a&&this._idmap.set(a.id,n),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(n){const o=this._map.get(n);return o&&typeof o=="object"&&"id"in o&&this._idmap.delete(o.id),this._map.delete(n),this}get(n){const o=n._zod.parent;if(o){const a={...this.get(o)??{}};delete a.id;const r={...a,...this._map.get(n)};return Object.keys(r).length?r:void 0}return this._map.get(n)}has(n){return this._map.has(n)}}function _p(){return new Ip}(tr=globalThis).__zod_globalRegistry??(tr.__zod_globalRegistry=_p());const cn=globalThis.__zod_globalRegistry;function Ap(e){return e.checks&&(e.checks=[...e.checks]),e}function $p(e,n){return new e(Ap({type:"string",...te(n)}))}function Rp(e,n){return new e({type:"string",format:"email",check:"string_format",abort:!1,...te(n)})}function xp(e,n){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...te(n)})}function Op(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...te(n)})}function Np(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...te(n)})}function Mp(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...te(n)})}function Bp(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...te(n)})}function Dp(e,n){return new e({type:"string",format:"url",check:"string_format",abort:!1,...te(n)})}function Fp(e,n){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...te(n)})}function Pp(e,n){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...te(n)})}function Lp(e,n){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...te(n)})}function Vp(e,n){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...te(n)})}function zp(e,n){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...te(n)})}function Up(e,n){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...te(n)})}function jp(e,n){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...te(n)})}function Zp(e,n){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...te(n)})}function Wp(e,n){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...te(n)})}function Hp(e,n){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...te(n)})}function Kp(e,n){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...te(n)})}function Gp(e,n){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...te(n)})}function qp(e,n){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...te(n)})}function Jp(e,n){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...te(n)})}function Yp(e,n){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...te(n)})}function Xp(e,n){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...te(n)})}function Qp(e,n){return new e({type:"string",format:"date",check:"string_format",...te(n)})}function ef(e,n){return new e({type:"string",format:"time",check:"string_format",precision:null,...te(n)})}function tf(e,n){return new e({type:"string",format:"duration",check:"string_format",...te(n)})}function nf(e,n){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...te(n)})}function of(e,n){return new e({type:"boolean",...te(n)})}function af(e){return new e({type:"any"})}function rf(e){return new e({type:"unknown"})}function sf(e,n){return new e({type:"never",...te(n)})}function nr(e,n){return new Gr({check:"less_than",...te(n),value:e,inclusive:!1})}function ho(e,n){return new Gr({check:"less_than",...te(n),value:e,inclusive:!0})}function or(e,n){return new qr({check:"greater_than",...te(n),value:e,inclusive:!1})}function go(e,n){return new qr({check:"greater_than",...te(n),value:e,inclusive:!0})}function ar(e,n){return new Qu({check:"multiple_of",...te(n),value:e})}function us(e,n){return new td({check:"max_length",...te(n),maximum:e})}function Wn(e,n){return new nd({check:"min_length",...te(n),minimum:e})}function ds(e,n){return new od({check:"length_equals",...te(n),length:e})}function lf(e,n){return new ad({check:"string_format",format:"regex",...te(n),pattern:e})}function cf(e){return new rd({check:"string_format",format:"lowercase",...te(e)})}function uf(e){return new sd({check:"string_format",format:"uppercase",...te(e)})}function df(e,n){return new id({check:"string_format",format:"includes",...te(n),includes:e})}function pf(e,n){return new ld({check:"string_format",format:"starts_with",...te(n),prefix:e})}function ff(e,n){return new cd({check:"string_format",format:"ends_with",...te(n),suffix:e})}function Qt(e){return new ud({check:"overwrite",tx:e})}function mf(e){return Qt(n=>n.normalize(e))}function hf(){return Qt(e=>e.trim())}function gf(){return Qt(e=>e.toLowerCase())}function vf(){return Qt(e=>e.toUpperCase())}function bf(){return Qt(e=>Bc(e))}function yf(e,n,o){return new e({type:"array",element:n,...te(o)})}function kf(e,n,o){const a=te(o);return a.abort??(a.abort=!0),new e({type:"custom",check:"custom",fn:n,...a})}function Sf(e,n,o){return new e({type:"custom",check:"custom",fn:n,...te(o)})}function wf(e,n){const o=Cf(a=>(a.addIssue=r=>{if(typeof r=="string")a.issues.push(hn(r,a.value,o._zod.def));else{const s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=a.value),s.inst??(s.inst=o),s.continue??(s.continue=!o._zod.def.abort),a.issues.push(hn(s))}},e(a.value,a)),n);return o}function Cf(e,n){const o=new nt({check:"custom",...te(n)});return o._zod.check=e,o}function dn(e,...n){for(const o of n)for(const a of Reflect.ownKeys(o))Object.prototype.propertyIsEnumerable.call(o,a)&&Nt(e,a,o[a]);return e}function ps(e){let n=e?.target??"draft-2020-12";return n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??cn,target:n,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Ot(e,n,o,a,r){const s=typeof n.unrepresentable=="function"?n.unrepresentable({zodSchema:e,path:a.path,message:r}):n.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(r);return Object.assign(o,s),!0}function Ze(e,n,o={path:[],schemaPath:[]}){var a;const r=e._zod.def,s=n.seen.get(e);if(s)return s.count++,o.schemaPath.includes(e)&&(s.cycle=o.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:o.path};n.seen.set(e,i),n.sharedDefsExtractedFor=void 0,n.sharedEmitDoneFor=void 0;const l=e._zod.toJSONSchema?.();if(l)i.schema=l;else{const d={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(n,i.schema,d);else{const h=i.schema,f=n.processors[r.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,n,h,d)}const p=e._zod.parent;p&&(i.ref||(i.ref=p),Ze(p,n,d),n.seen.get(p).isParent=!0)}const c=n.metadataRegistry.get(e);return c&&dn(i.schema,c),n.io==="input"&&Xe(e)&&(delete i.schema.examples,delete i.schema.default),n.io==="input"&&"_prefault"in i.schema&&((a=i.schema).default??(a.default=i.schema._prefault)),delete i.schema._prefault,n.seen.get(e).schema}function rr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function fs(e,n){const o=e.seen.get(n);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const a=new Map;for(const i of e.seen.entries()){const l=e.metadataRegistry.get(i[0])?.id;if(l){const c=a.get(l);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${l}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(l,i[0])}}const r=i=>{const l=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const p=e.external.registry.get(i[0])?.id,h=e.external.uri??(m=>m);if(p)return{ref:h(p)};const f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${h("__shared")}#/${l}/${rr(f)}`}}const c="#",u=`${c}/${l}/`;if(i[1]===o&&!i[1].schema.id)return{ref:c};const d=i[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+rr(d)}},s=i=>{if(i[1].schema.$ref)return;const l=i[1],{ref:c,defId:u}=r(i);l.def={...l.schema},u&&(l.defId=u);const d=l.schema;for(const p in d)delete d[p];d.$ref=c};if(e.cycles==="throw")for(const i of e.seen.entries()){const l=i[1];if(l.cycle)throw new Error(`Cycle detected: #/${l.cycle?.join("/")}/<root>
|
|
56
|
+
|
|
57
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const l=i[1];if(n===i[0]){s(i);continue}if(e.external){const u=e.external.registry.get(i[0])?.id;if(n!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(l.cycle){s(i);continue}l.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function ms(e){const n=e.anyOf;if(!Array.isArray(n)||n.length===0||e.type!==void 0)return;const o=[];for(const a of n){if(!a||typeof a!="object")return;ms(a);const r=Object.keys(a);if(r.length!==1||r[0]!=="type")return;const s=a.type;for(const i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;o.includes(i)||o.push(i)}}delete e.anyOf,e.type=o.length===1?o[0]:o}const hs=new Set(["type","properties","required","additionalProperties"]),sr=["oneOf","anyOf"];function ir(e){const n=e.additionalProperties;return n===void 0||n===!1||typeof n!="object"||n===null?null:Object.keys(n).length?n:null}function No(e){const n=[];for(const s of e){if(typeof s!="object"||s.type!=="object")return null;for(const i in s)if(!hs.has(i))return null;n.push(s)}const o={},a=new Set;for(const s of n){for(const i in s.properties){if(Object.prototype.hasOwnProperty.call(o,i))continue;const l=[];for(const u of n){const d=u.properties?.[i]??ir(u);d!=null&&(l.some(p=>JSON.stringify(p)===JSON.stringify(d))||l.push(d))}const c=l.length===1?l[0]:No(l)??{allOf:l};Nt(o,i,c)}for(const i of s.required??[])a.add(i)}const r={type:"object",properties:o};if(a.size&&(r.required=[...a]),n.every(s=>s.additionalProperties===!1))r.additionalProperties=!1;else{const s=[];for(const i of n){const l=ir(i);l&&!s.some(c=>JSON.stringify(c)===JSON.stringify(l))&&s.push(l)}s.length===1?r.additionalProperties=s[0]:s.length>1&&(r.additionalProperties={allOf:s})}return r}function Tf(e){const n=e.allOf;if(!Array.isArray(n)||n.length<2)return;for(const r of hs)if(r in e)return;const o=n.filter(r=>sr.some(s=>Array.isArray(r[s])));let a=null;if(!o.length)a=No(n);else{const r=o[0],s=sr.find(c=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;const i=n.filter(c=>c!==r),l=r[s].map(c=>No([...i,c]));if(l.some(c=>!c))return;a={[s]:l}}a&&(delete e.allOf,dn(e,a))}function gs(e,n){const o=e.seen.get(n);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=l=>{const c=e.seen.get(l);if(c.ref===null)return;const u=c.def??c.schema,d={...u},p=c.ref;if(c.ref=null,p){a(p);const f=e.seen.get(p),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):dn(u,m),dn(u,d),l._zod.parent===p)for(const v in u)v==="$ref"||v==="allOf"||v in d||delete u[v];if(m.$ref&&f.def)for(const v in u)v==="$ref"||v==="allOf"||v in f.def&&JSON.stringify(u[v])===JSON.stringify(f.def[v])&&delete u[v]}const h=l._zod.parent;if(h&&h!==p){a(h);const f=e.seen.get(h);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(const m in u)m==="$ref"||m==="allOf"||m in f.def&&JSON.stringify(u[m])===JSON.stringify(f.def[m])&&delete u[m]}e.override({zodSchema:l,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const l of[...e.seen.entries()].reverse())a(l[0]);if(e.target!=="openapi-3.0")for(const l of e.seen.entries())ms(l[1].def??l[1].schema);for(const l of e.deferred)l();if(e.intersections.length){const l=new Map;for(const c of e.seen.values())for(const u of[c.schema,c.def]){const d=u?.allOf;if(!Array.isArray(d))continue;const p=l.get(d);p?p.push(u):l.set(d,[u])}for(const c of e.intersections)for(const u of l.get(c)??[])Tf(u)}}const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const l=e.external.registry.get(n)?.id;if(!l)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(l)}dn(r,o.defId?o.schema:o.def??o.schema);const s=e.metadataRegistry.get(n)?.id;s!==void 0&&r.id===s&&delete r.id;const i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const l of e.seen.entries()){const c=l[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Nt(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{const l=JSON.parse(JSON.stringify(r));return Object.defineProperty(l,"~standard",{value:{...n["~standard"],jsonSchema:{input:Hn(n,"input",e.processors),output:Hn(n,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function Xe(e,n){const o=n??{seen:new Set};if(o.seen.has(e))return!1;o.seen.add(e);const a=e._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return Xe(a.element,o);if(a.type==="set")return Xe(a.valueType,o);if(a.type==="lazy")return Xe(a.getter(),o);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault"||a.type==="catch")return Xe(a.innerType,o);if(a.type==="intersection")return Xe(a.left,o)||Xe(a.right,o);if(a.type==="record"||a.type==="map")return Xe(a.keyType,o)||Xe(a.valueType,o);if(a.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Xe(a.in,o)||Xe(a.out,o);if(a.type==="object"){for(const r in a.shape)if(Xe(a.shape[r],o))return!0;return!1}if(a.type==="union"){for(const r of a.options)if(Xe(r,o))return!0;return!1}if(a.type==="tuple"){for(const r of a.items)if(Xe(r,o))return!0;return!!(a.rest&&Xe(a.rest,o))}return!1}const Ef=(e,n={})=>o=>{const a=ps({...o,processors:n});return Ze(e,a),fs(a,e),gs(a,e)},Hn=(e,n,o={})=>a=>{const{libraryOptions:r,target:s}=a??{},i=ps({...r??{},target:s,io:n,processors:o});return Ze(e,i),fs(i,e),gs(i,e)},qt=(e,n,o)=>{(e[n]===void 0||o>e[n])&&(e[n]=o)},Jt=(e,n,o)=>{(e[n]===void 0||o<e[n])&&(e[n]=o)},lr=(e,n)=>{qt(e,"minimum",n),Jt(e,"maximum",n)},vs=(e,n)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(n)||e.multipleOf.push(n)},bs=(e,n)=>{e.patterns??(e.patterns=new Set),e.patterns.add(n)},ys=(e,n)=>{e.mime=e.mime?e.mime.filter(o=>n.includes(o)):[...n]},ks=(e,n)=>{e.format=n,n.includes("int")&&(e.isInt=!0)},cr=(e,n)=>qt(e,"minimum",n.minimum),ur=(e,n)=>Jt(e,"maximum",n.maximum),dr=e=>(n,o)=>{ks(n,o.format);const[a,r]=e[o.format];qt(n,"minimum",a),Jt(n,"maximum",r)},If={greater_than:(e,n)=>qt(e,n.inclusive?"minimum":"exclusiveMinimum",n.value),less_than:(e,n)=>Jt(e,n.inclusive?"maximum":"exclusiveMaximum",n.value),multiple_of:(e,n)=>vs(e,n.value),number_format:dr(Vr),bigint_format:dr(Lc),min_length:cr,max_length:ur,length_equals:(e,n)=>lr(e,n.length),min_size:cr,max_size:ur,size_equals:(e,n)=>lr(e,n.size),string_format:(e,n)=>{ks(e,n.format),n.pattern&&bs(e,n.pattern),(n.format==="base64"||n.format==="base64url")&&(e.contentEncoding=n.format),(n.local||n.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,n)=>ys(e,n.mime)};function ut(e){const n={},o=e._zod.def,a=e._zod.traits.has("$ZodCheck")?[e,...o.checks??[]]:o.checks??[];for(const s of a)If[s._zod.def.check]?.(n,s._zod.def);const r=e._zod.bag;r.minimum!==void 0&&qt(n,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&qt(n,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&Jt(n,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&Jt(n,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&vs(n,r.multipleOf),r.format!==void 0&&(n.format??(n.format=r.format),r.format.includes("int")&&(n.isInt=!0)),r.mime&&ys(n,r.mime);for(const s of r.patterns??[])bs(n,s);return n}const _f={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Af=new Map([[ns,Vu],[aa,zu]]),$f=e=>Af.get(e)??e,Rf=(e,n,o,a)=>{const r=o;r.type="string";const{minimum:s,maximum:i,format:l,patterns:c,contentEncoding:u,laxFormat:d}=ut(e);if(typeof s=="number"&&(r.minLength=s),typeof i=="number"&&(r.maxLength=i),l&&(r.format=_f[l]??l,r.format===""&&delete r.format,(l==="time"||d)&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){const p=[...c].map($f);p.length===1?r.pattern=p[0].source:p.length>1&&(r.allOf=[...p.map(h=>({...n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},xf=(e,n,o,a)=>{const r=o,{minimum:s,maximum:i,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:u,isInt:d}=ut(e);r.type=d?"integer":"number";const p=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),h=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),f=n.target==="draft-04"||n.target==="openapi-3.0";if(p?f?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:typeof s=="number"&&(r.minimum=s),h?f?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:typeof i=="number"&&(r.maximum=i),l){const m=new Set;for(const y of l)Number.isFinite(y)&&y!==0?m.add(Math.abs(y)):Ot(e,n,r,a,`A multipleOf divisor of ${y} cannot be represented in JSON Schema`);const[g,...v]=m;g!==void 0&&(r.multipleOf=g),v.length&&(r.allOf=[...r.allOf??[],...v.map(y=>({multipleOf:y}))])}},Of=(e,n,o,a)=>{o.type="boolean"},Nf=(e,n,o,a)=>{o.not={}},Mf=(e,n,o,a)=>{},Bf=(e,n,o,a)=>{},Df=(e,n,o,a)=>{const r=e._zod.def,s=_o(r.entries);if(s.length===0){o.not={};return}s.every(i=>typeof i=="number")&&(o.type="number"),s.every(i=>typeof i=="string")&&(o.type="string"),o.enum=s},Ff=(e,n,o,a)=>{const r=e._zod.def;if(r.values.length===0){o.not={};return}const s=[];for(const i of r.values)if(i===void 0){if(Ot(e,n,o,a,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Ot(e,n,o,a,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){const i=s[0];o.type=i===null?"null":typeof i,n.target==="draft-04"||n.target==="openapi-3.0"?o.enum=[i]:o.const=i}else s.every(i=>typeof i=="number")&&(o.type="number"),s.every(i=>typeof i=="string")&&(o.type="string"),s.every(i=>typeof i=="boolean")&&(o.type="boolean"),s.every(i=>i===null)&&(o.type="null"),o.enum=s},Pf=(e,n,o,a)=>{Ot(e,n,o,a,"Custom types cannot be represented in JSON Schema")},Lf=(e,n,o,a)=>{Ot(e,n,o,a,"Transforms cannot be represented in JSON Schema")},Vf=(e,n,o,a)=>{const r=o,s=e._zod.def,{minimum:i,maximum:l}=ut(e);typeof i=="number"&&(r.minItems=i),typeof l=="number"&&(r.maxItems=l),r.type="array",r.items=Ze(s.element,n,{...a,path:[...a.path,"items"]})};function Mo(e){const n=e._zod.def;return n.type==="pipe"&&n.in._zod.traits.has("$ZodTransform")?Mo(n.out):n.type==="catch"?Mo(n.innerType):e._zod.optin}const zf=(e,n,o,a)=>{const r=o,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Ot(e,n,r,a,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(const u in i)Nt(r.properties,u,Ze(i[u],n,{...a,path:[...a.path,"properties",u]}));const c=[];for(const u of Object.keys(i)){const d=s.shape[u];(n.io==="input"?Mo(d)===void 0:d._zod.optout===void 0)&&c.push(u)}c.length>0&&(r.required=c),s.catchall?._zod.def.type==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=Ze(s.catchall,n,{...a,path:[...a.path,"additionalProperties"]})):n.io==="output"&&(r.additionalProperties=!1)},Uf=(e,n,o,a)=>{const r=e._zod.def,s=r.inclusive===!1,i=r.options.map((l,c)=>Ze(l,n,{...a,path:[...a.path,s?"oneOf":"anyOf",c]}));s?o.oneOf=i:o.anyOf=i},jf=(e,n,o,a)=>{const r=e._zod.def,s=Ze(r.left,n,{...a,path:[...a.path,"allOf",0]}),i=Ze(r.right,n,{...a,path:[...a.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(s)?s.allOf:[s],...l(i)?i.allOf:[i]];o.allOf=c,n.intersections.push(c)},Zf=(e,n,o,a)=>{const r=e._zod.def,s=Ze(r.innerType,n,a),i=n.seen.get(e);n.target==="openapi-3.0"?(i.ref=r.innerType,o.nullable=!0):o.anyOf=[s,{type:"null"}]},Wf=(e,n,o,a)=>{const r=e._zod.def;Ze(r.innerType,n,a);const s=n.seen.get(e);s.ref=r.innerType},ra=Symbol();function Ss(e,n,o,a,r){let s=!1;const i=JSON.stringify(e,(l,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(Ot(n,o,a,r,"BigInt defaults cannot be represented in JSON Schema"),ra):JSON.parse(i)}const Hf=(e,n,o,a)=>{const r=e._zod.def;Ze(r.innerType,n,a);const s=n.seen.get(e);s.ref=r.innerType;const i=Ss(r.defaultValue,e,n,o,a);i!==ra&&(o.default=i)},Kf=(e,n,o,a)=>{const r=e._zod.def;Ze(r.innerType,n,a);const s=n.seen.get(e);if(s.ref=r.innerType,n.io!=="input")return;const i=Ss(r.defaultValue,e,n,o,a);i!==ra&&(o._prefault=i)},Gf=(e,n,o,a)=>{const r=e._zod.def;Ze(r.innerType,n,a);const s=n.seen.get(e);s.ref=r.innerType;let i;try{i=r.catchValue(void 0)}catch{Ot(e,n,o,a,"Dynamic catch values are not supported in JSON Schema");return}o.default=i},qf=(e,n,o,a)=>{const r=e._zod.def,s=r.in._zod.traits.has("$ZodTransform"),i=n.io==="input"?s?r.out:r.in:r.out;Ze(i,n,a);const l=n.seen.get(e);l.ref=i},Jf=(e,n,o,a)=>{const r=e._zod.def;Ze(r.innerType,n,a);const s=n.seen.get(e);s.ref=r.innerType,o.readOnly=!0},ws=(e,n,o,a)=>{const r=e._zod.def;Ze(r.innerType,n,a);const s=n.seen.get(e);s.ref=r.innerType},pr=new WeakSet([Object.prototype,Error.prototype]);function An(e,n,o){Object.defineProperty(e,n,{configurable:!0,enumerable:!1,get(){const a=o(this);return Object.defineProperty(this,n,{value:a,configurable:!0,writable:!0}),a},set(a){Object.defineProperty(this,n,{value:a,configurable:!0,writable:!0})}})}const Yf=(e,n)=>{iu.init(e,n),e.name="ZodError";const o=Object.getPrototypeOf(e);pr.has(o)||(pr.add(o),An(o,"format",a=>r=>uu(a,r)),An(o,"flatten",a=>r=>cu(a,r)),An(o,"addIssue",a=>r=>{a.issues.push(r),a.message=JSON.stringify(a.issues,Ao,2)}),An(o,"addIssues",a=>r=>{a.issues.push(...r),a.message=JSON.stringify(a.issues,Ao,2)}),Object.defineProperty(o,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},it=R("ZodError",Yf,void 0,{Parent:Error}),Xf=Xo(it),Qf=Qo(it),em=ea(it),tm=ta(it),nm=gu(it),om=vu(it),am=bu(it),rm=yu(it),sm=ku(it),im=Su(it),lm=wu(it),cm=Cu(it);function um(){pt.localeError||Bt(Ep())}function sa(){pt.memoizer||Bt({memoizer:wp()})}const Ae=R("ZodType",(e,n)=>(um(),_e.init(e,n),e.def=n,e.type=n.type,e),{check(...e){const n=this.def;return this.clone(at(n,{checks:[...n.checks??[],...e.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,n){return Mt(this,e,n)},brand(){return this},register(e,n){return e.add(this,n),this},refine(e,n){return this.check(ih(e,n))},superRefine(e,n){return this.check(lh(e,n))},overwrite(e){return this.check(Qt(e))},optional(){return fr(this)},exactOptional(){return qm(this)},nullable(){return mr(this)},nullish(){return fr(mr(this))},nonoptional(e){return th(this,e)},array(){return De(this)},or(e){return eo([this,e])},and(e){return Wm(this,e)},transform(e){return hr(this,Gm(e))},default(e){return Xm(this,e)},prefault(e){return eh(this,e)},catch(e){return oh(this,e)},pipe(e){return hr(this,e)},readonly(){return sh(this)},describe(e){const n=this.clone();return cn.add(n,{description:e}),n},meta(...e){if(e.length===0)return cn.get(this);const n=this.clone();return cn.add(n,e[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...n){return n.length===0?e(this):e(this,...n)},get"~standard"(){return jr(this,"~standard",{...Yr(this),jsonSchema:{input:Hn(this,"input"),output:Hn(this,"output")}})},set"~standard"(e){xt(this,"~standard",e)},parse:function e(n,o){return Xf(this,n,o,{callee:e})},parseAsync:async function e(n,o){return await Qf(this,n,o,{callee:e})},safeParse(e,n){return em(this,e,n)},async safeParseAsync(e,n){return tm(this,e,n)},get spa(){return this?.safeParseAsync},set spa(e){xt(this,"spa",e)},validate(e,n){return fu(this,e,n)},validateAsync(e,n){return hu(this,e,n)},encode:function e(n,o){return nm(this,n,o,{callee:e})},decode:function e(n,o){return om(this,n,o,{callee:e})},encodeAsync:async function e(n,o){return await am(this,n,o,{callee:e})},decodeAsync:async function e(n,o){return await rm(this,n,o,{callee:e})},safeEncode(e,n){return sm(this,e,n)},safeDecode(e,n){return im(this,e,n)},async safeEncodeAsync(e,n){return lm(this,e,n)},async safeDecodeAsync(e,n){return cm(this,e,n)},toJSONSchema(e){return Ef(this,{})(e)},get description(){return cn.get(this)?.description},get _def(){return this._zod.def}}),Cs=R("_ZodString",(e,n)=>{oa.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Rf(e,o,a)},Zr({format:e=>ut(e).format??null,minLength:e=>ut(e).minimum??null,maxLength:e=>ut(e).maximum??null},{regex(...e){return this.check(lf(...e))},includes(...e){return this.check(df(...e))},startsWith(...e){return this.check(pf(...e))},endsWith(...e){return this.check(ff(...e))},min(...e){return this.check(Wn(...e))},max(...e){return this.check(us(...e))},length(...e){return this.check(ds(...e))},nonempty(...e){return this.check(Wn(1,...e))},lowercase(e){return this.check(cf(e))},uppercase(e){return this.check(uf(e))},trim(){return this.check(hf())},normalize(...e){return this.check(mf(...e))},toLowerCase(){return this.check(gf())},toUpperCase(){return this.check(vf())},slugify(){return this.check(bf())}})),dm=R("ZodString",(e,n)=>{oa.init(e,n),Cs.init(e,n)},{email(e){return this.check(Rp(gm,e))},url(e){return this.check(Dp(bm,e))},jwt(e){return this.check(Yp(Nm,e))},emoji(e){return this.check(Fp(ym,e))},guid(e){return this.check(xp(vm,e))},uuid(e){return this.check(Op($n,e))},uuidv4(e){return this.check(Np($n,e))},uuidv6(e){return this.check(Mp($n,e))},uuidv7(e){return this.check(Bp($n,e))},nanoid(e){return this.check(Pp(km,e))},cuid(e){return this.check(Lp(Sm,e))},cuid2(e){return this.check(Vp(wm,e))},ulid(e){return this.check(zp(Cm,e))},base64(e){return this.check(Gp(Rm,e))},base64url(e){return this.check(qp(xm,e))},xid(e){return this.check(Up(Tm,e))},ksuid(e){return this.check(jp(Em,e))},ipv4(e){return this.check(Zp(Im,e))},ipv6(e){return this.check(Wp(_m,e))},cidrv4(e){return this.check(Hp(Am,e))},cidrv6(e){return this.check(Kp($m,e))},e164(e){return this.check(Jp(Om,e))},datetime(e){return this.check(Xp(pm,e))},date(e){return this.check(Qp(fm,e))},time(e){return this.check(ef(mm,e))},duration(e){return this.check(tf(hm,e))}});function _(e){return $p(dm,e)}const $e=R("ZodStringFormat",(e,n)=>{Ce.init(e,n),Cs.init(e,n)}),pm=R("ZodISODateTime",(e,n)=>{Rd.init(e,n),$e.init(e,n)}),fm=R("ZodISODate",(e,n)=>{xd.init(e,n),$e.init(e,n)}),mm=R("ZodISOTime",(e,n)=>{Od.init(e,n),$e.init(e,n)}),hm=R("ZodISODuration",(e,n)=>{Nd.init(e,n),$e.init(e,n)}),gm=R("ZodEmail",(e,n)=>{gd.init(e,n),$e.init(e,n)}),vm=R("ZodGUID",(e,n)=>{md.init(e,n),$e.init(e,n)}),$n=R("ZodUUID",(e,n)=>{hd.init(e,n),$e.init(e,n)}),bm=R("ZodURL",(e,n)=>{wd.init(e,n),$e.init(e,n)}),ym=R("ZodEmoji",(e,n)=>{Cd.init(e,n),$e.init(e,n)}),km=R("ZodNanoID",(e,n)=>{Td.init(e,n),$e.init(e,n)}),Sm=R("ZodCUID",(e,n)=>{Ed.init(e,n),$e.init(e,n)}),wm=R("ZodCUID2",(e,n)=>{Id.init(e,n),$e.init(e,n)}),Cm=R("ZodULID",(e,n)=>{_d.init(e,n),$e.init(e,n)}),Tm=R("ZodXID",(e,n)=>{Ad.init(e,n),$e.init(e,n)}),Em=R("ZodKSUID",(e,n)=>{$d.init(e,n),$e.init(e,n)}),Im=R("ZodIPv4",(e,n)=>{Md.init(e,n),$e.init(e,n)}),_m=R("ZodIPv6",(e,n)=>{Dd.init(e,n),$e.init(e,n)}),Am=R("ZodCIDRv4",(e,n)=>{Fd.init(e,n),$e.init(e,n)}),$m=R("ZodCIDRv6",(e,n)=>{Ld.init(e,n),$e.init(e,n)}),Rm=R("ZodBase64",(e,n)=>{Vd.init(e,n),$e.init(e,n)}),xm=R("ZodBase64URL",(e,n)=>{Ud.init(e,n),$e.init(e,n)}),Om=R("ZodE164",(e,n)=>{jd.init(e,n),$e.init(e,n)}),Nm=R("ZodJWT",(e,n)=>{Wd.init(e,n),$e.init(e,n)}),Mm=R("ZodNumber",(e,n)=>{os.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>xf(e,o,a,r),e.isFinite=!0},Zr({minValue:e=>{const{minimum:n,exclusiveMinimum:o}=ut(e);return Math.max(n??Number.NEGATIVE_INFINITY,o??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:n,exclusiveMaximum:o}=ut(e);return Math.min(n??Number.POSITIVE_INFINITY,o??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:n,multipleOf:o}=ut(e);return!!n||!!o?.some(Number.isSafeInteger)},format:e=>ut(e).format??null},{gt(e,n){return this.check(or(e,n))},gte(e,n){return this.check(go(e,n))},min(e,n){return this.check(go(e,n))},lt(e,n){return this.check(nr(e,n))},lte(e,n){return this.check(ho(e,n))},max(e,n){return this.check(ho(e,n))},int(e){return this.check(ue(e))},safe(e){return this.check(ue(e))},positive(e){return this.check(or(0,e))},nonnegative(e){return this.check(go(0,e))},negative(e){return this.check(nr(0,e))},nonpositive(e){return this.check(ho(0,e))},multipleOf(e,n){return this.check(ar(e,n))},step(e,n){return this.check(ar(e,n))},finite(){return this}})),Bm=R("ZodNumberFormat",(e,n)=>{Hd.init(e,n),Mm.init(e,n)});function ue(e){return nf(Bm,e)}const Dm=R("ZodBoolean",(e,n)=>{Kd.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Of(e,o,a)});function ge(e){return of(Dm,e)}const Fm=R("ZodAny",(e,n)=>{Gd.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Mf()});function re(){return af(Fm)}const Pm=R("ZodUnknown",(e,n)=>{qd.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Bf()});function Bo(){return rf(Pm)}const Lm=R("ZodNever",(e,n)=>{Jd.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Nf(e,o,a)});function Vm(e){return sf(Lm,e)}const zm=R("ZodArray",(e,n)=>{sa(),Qd.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Vf(e,o,a,r),e.element=n.element},{min(e,n){return this.check(Wn(e,n))},nonempty(e){return this.check(Wn(1,e))},max(e,n){return this.check(us(e,n))},length(e,n){return this.check(ds(e,n))},unwrap(){return this.element}});function De(e,n){return yf(zm,e,n)}const Um=R("ZodObject",(e,n)=>{sa(),np.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>zf(e,o,a,r),Qc(e,"shape",o=>o._zod.def.shape,!1)},{keyof(){return en(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(at(this._zod.def,{catchall:e}))},passthrough(){return this.clone(at(this._zod.def,{catchall:Bo()}))},loose(){return this.clone(at(this._zod.def,{catchall:Bo()}))},strict(){return this.clone(at(this._zod.def,{catchall:Vm()}))},strip(){return this.clone(at(this._zod.def,{catchall:void 0}))},extend(e){return Uc(this,e)},safeExtend(e){return jc(this,e)},merge(e){return Zc(this,e)},pick(e){return Vc(this,e)},omit(e){return zc(this,e)},partial(...e){return Pa(Es,this,e[0])},exactPartial(...e){return Pa(Is,this,e[0],"exactPartial")},required(...e){return Wc(_s,this,e[0])}});function U(e,n){return new Um({type:"object",shape:e,catchall:Bo(),...te(n)})}const Ts=R("ZodUnion",(e,n)=>{ss.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Uf(e,o,a,r),e.options=n.options});function eo(e,n){return new Ts({type:"union",options:e,...te(n)})}const jm=R("ZodDiscriminatedUnion",(e,n)=>{Ts.init(e,n),ap.init(e,n)});function Wt(e,n,o){return new jm({type:"union",options:n,discriminator:e,...te(o)})}const Zm=R("ZodIntersection",(e,n)=>{rp.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>jf(e,o,a,r)});function Wm(e,n){return new Zm({type:"intersection",left:e,right:n})}const Do=R("ZodEnum",(e,n)=>{sp.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(a,r,s)=>Df(e,a,r),e.enum=n.entries,e.options=[...e._zod.values];const o=new Set(Object.keys(n.entries));e.extract=(a,r)=>{const s={};for(const i of a)if(o.has(i))s[i]=n.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Do({...n,checks:[],...te(r),entries:s})},e.exclude=(a,r)=>{const s={...n.entries};for(const i of a)if(o.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Do({...n,checks:[],...te(r),entries:s})}});function en(e,n){const o=Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e;return new Do({type:"enum",entries:o,...te(n)})}const Hm=R("ZodLiteral",(e,n)=>{ip.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Ff(e,o,a,r),e.values=new Set(n.values),Object.defineProperty(e,"value",{get(){if(n.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return n.values[0]}})});function X(e,n){return new Hm({type:"literal",values:Array.isArray(e)?e:[e],...te(n)})}const Km=R("ZodTransform",(e,n)=>{sa(),lp.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Lf(e,o,a,r),e._zod.parse=(o,a)=>{if(a.direction==="backward")throw new Wr(e.constructor.name);o.addIssue=s=>{if(typeof s=="string")o.issues.push(hn(s,o.value,n));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=o.value),i.inst??(i.inst=e),o.issues.push(hn(i))}};const r=n.transform(o.value,o);return r instanceof Promise?r.then(s=>(o.value=s,o)):(o.value=r,o)}});function Gm(e){return new Km({type:"transform",transform:e})}const Es=R("ZodOptional",(e,n)=>{is.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>ws(e,o,a,r),e.unwrap=()=>e._zod.def.innerType});function fr(e){return new Es({type:"optional",innerType:e})}const Is=R("ZodExactOptional",(e,n)=>{cp.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>ws(e,o,a,r),e.unwrap=()=>e._zod.def.innerType});function qm(e){return new Is({type:"optional",innerType:e})}const Jm=R("ZodNullable",(e,n)=>{up.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Zf(e,o,a,r),e.unwrap=()=>e._zod.def.innerType});function mr(e){return new Jm({type:"nullable",innerType:e})}const Ym=R("ZodDefault",(e,n)=>{dp.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Hf(e,o,a,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Xm(e,n){return new Ym({type:"default",innerType:e,get defaultValue(){return typeof n=="function"?n():Pr(n)}})}const Qm=R("ZodPrefault",(e,n)=>{pp.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Kf(e,o,a,r),e.unwrap=()=>e._zod.def.innerType});function eh(e,n){return new Qm({type:"prefault",innerType:e,get defaultValue(){return typeof n=="function"?n():Pr(n)}})}const _s=R("ZodNonOptional",(e,n)=>{fp.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Wf(e,o,a,r),e.unwrap=()=>e._zod.def.innerType});function th(e,n){return new _s({type:"nonoptional",innerType:e,...te(n)})}const nh=R("ZodCatch",(e,n)=>{mp.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Gf(e,o,a,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function oh(e,n){return new nh({type:"catch",innerType:e,catchValue:typeof n=="function"?n:tu(n)})}const ah=R("ZodPipe",(e,n)=>{hp.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>qf(e,o,a,r),e.in=n.in,e.out=n.out});function hr(e,n){return new ah({type:"pipe",in:e,out:n})}const rh=R("ZodReadonly",(e,n)=>{gp.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Jf(e,o,a,r),e.unwrap=()=>e._zod.def.innerType});function sh(e){return new rh({type:"readonly",innerType:e})}const As=R("ZodCustom",(e,n)=>{vp.init(e,n),Ae.init(e,n),e._zod.processJSONSchema=(o,a,r)=>Pf(e,o,a,r)});function bn(e,n){return kf(As,e??(()=>!0),n)}function ih(e,n={}){return Sf(As,e,n)}function lh(e,n){return wf(e,n)}const $s=en(ve),se=bn(e=>typeof e=="object"&&e!==null&&!Array.isArray(e)),me=_(),ia=en(["developer","system","assistant","user"]),Rs=U({type:X(ve.TEXT_MESSAGE_START),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),messageId:_(),role:ia.optional(),name:_().optional()}),xs=U({type:X(ve.TEXT_MESSAGE_CONTENT),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),messageId:_(),delta:_()}),Os=U({type:X(ve.TEXT_MESSAGE_END),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),messageId:_()}),Ns=U({type:X(ve.TEXT_MESSAGE_CHUNK),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),messageId:_().optional(),role:ia.optional(),delta:_().optional(),name:_().optional()}),Ms=U({type:X(ve.TOOL_CALL_START),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),toolCallId:_(),toolCallName:_(),parentMessageId:_().optional()}),Bs=U({type:X(ve.TOOL_CALL_ARGS),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),toolCallId:_(),delta:_()}),Ds=U({type:X(ve.TOOL_CALL_END),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),toolCallId:_()}),Fs=U({type:X(ve.TOOL_CALL_CHUNK),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),toolCallId:_().optional(),toolCallName:_().optional(),parentMessageId:_().optional(),delta:_().optional()}),Ps=U({type:X("text"),id:_().optional(),text:_(),metadata:re().refine(e=>e!==null).optional()}),Ls=U({type:X("data"),value:_(),mimeType:_()}),Vs=U({type:X("url"),value:_(),mimeType:_().optional()}),zs=U({type:X("file"),value:_(),provider:_().optional(),mimeType:_().optional()}),yn=Wt("type",[Ls,Vs,zs]),Us=U({type:X("image"),id:_().optional(),source:yn,metadata:re().refine(e=>e!==null).optional()}),js=U({type:X("audio"),id:_().optional(),source:yn,metadata:re().refine(e=>e!==null).optional()}),Zs=U({type:X("video"),id:_().optional(),source:yn,metadata:re().refine(e=>e!==null).optional()}),Ws=U({type:X("document"),id:_().optional(),source:yn,metadata:re().refine(e=>e!==null).optional()}),to=Wt("type",[Ps,Us,js,Zs,Ws]),Hs=U({type:X(ve.TOOL_CALL_RESULT),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),messageId:_(),toolCallId:_(),content:eo([_(),De(to)]),role:X("tool").optional()}),la=re(),Ks=U({type:X(ve.STATE_SNAPSHOT),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),snapshot:la.refine(e=>e!==void 0)}),St=_().regex(new RegExp("^(/([^/~]|~[01])*)*$")),Gs=U({op:X("add"),path:St,value:re().refine(e=>e!==void 0)}).meta({specOpen:!0}),qs=U({op:X("remove"),path:St}).meta({specOpen:!0}),Js=U({op:X("replace"),path:St,value:re().refine(e=>e!==void 0)}).meta({specOpen:!0}),Ys=U({op:X("move"),from:St,path:St}).meta({specOpen:!0}),Xs=U({op:X("copy"),from:St,path:St}).meta({specOpen:!0}),Qs=U({op:X("test"),path:St,value:re().refine(e=>e!==void 0)}).meta({specOpen:!0}),ei=Wt("op",[Gs,qs,Js,Ys,Xs,Qs]),ca=De(ei),ti=U({type:X(ve.STATE_DELTA),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),delta:ca}),ni=U({subagentRunId:me.optional(),id:_(),role:X("developer"),name:_().optional(),encryptedValue:_().optional(),metadata:se.optional(),content:_()}),oi=U({subagentRunId:me.optional(),id:_(),role:X("system"),name:_().optional(),encryptedValue:_().optional(),metadata:se.optional(),content:_()}),ai=U({name:_(),arguments:_()}),ri=U({id:_(),type:X("function"),function:ai,encryptedValue:_().optional(),metadata:se.optional()}),si=U({subagentRunId:me.optional(),id:_(),role:X("assistant"),name:_().optional(),encryptedValue:_().optional(),metadata:se.optional(),content:_().optional(),toolCalls:De(ri).optional()}),ii=U({subagentRunId:me.optional(),id:_(),role:X("user"),name:_().optional(),encryptedValue:_().optional(),metadata:se.optional(),content:eo([_(),De(to)])}),li=U({subagentRunId:me.optional(),id:_(),role:X("tool"),content:eo([_(),De(to)]),toolCallId:_(),error:_().optional(),encryptedValue:_().optional(),metadata:se.optional()}),ci=U({subagentRunId:me.optional(),id:_(),role:X("activity"),activityType:_(),content:bn(e=>typeof e=="object"&&e!==null&&!Array.isArray(e)),metadata:se.optional()}),ui=U({subagentRunId:me.optional(),id:_(),role:X("reasoning"),content:_(),encryptedValue:_().optional(),metadata:se.optional()}),ua=Wt("role",[ni,oi,si,ii,li,ci,ui]),di=U({type:X(ve.MESSAGES_SNAPSHOT),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),messages:De(ua)}),pi=U({type:X(ve.ACTIVITY_SNAPSHOT),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),messageId:_(),activityType:_(),content:bn(e=>typeof e=="object"&&e!==null&&!Array.isArray(e)),replace:ge().optional()}),fi=U({type:X(ve.ACTIVITY_DELTA),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),messageId:_(),activityType:_(),patch:ca}),mi=U({type:X(ve.RAW),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),event:re().refine(e=>e!==void 0),source:_().optional()}),hi=U({type:X(ve.CUSTOM),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),name:_(),value:re().refine(e=>e!==void 0)}),da=U({name:_(),description:_(),parameters:re().refine(e=>e!==null).optional(),metadata:se.optional()}),gi=U({description:_(),value:_()}),vi=U({interruptId:_(),status:en(["resolved","cancelled"]),payload:re().refine(e=>e!==null).optional(),metadata:se.optional()}),bi=U({threadId:_(),runId:_(),protocolVersion:_().optional(),parentRunId:_().optional(),state:la.refine(e=>e!==null).nullable().transform(e=>e??void 0).optional(),messages:De(ua),tools:De(da).default(()=>[]),context:De(gi).default(()=>[]),forwardedProps:re().refine(e=>e!==null).optional(),resume:De(vi).optional()}),yi=U({type:X(ve.RUN_STARTED),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),threadId:_(),runId:_(),protocolVersion:_().optional(),parentRunId:_().optional(),input:bi.optional()}),ki=U({type:X("success"),pendingToolCallIds:De(_()).optional()}),Si=U({subagentRunId:me.optional(),id:_(),reason:_(),message:_().optional(),toolCallId:_().optional(),responseSchema:bn(e=>typeof e=="object"&&e!==null&&!Array.isArray(e)).optional(),expiresAt:_().optional(),metadata:se.optional()}),wi=U({type:X("interrupt"),interrupts:De(Si).min(1)}),Ci=U({type:X("cancelled")}),Ti=Wt("type",[ki,wi,Ci]),pa=U({provider:_().optional(),model:_().optional(),inputTokens:ue().min(0).max(9007199254740991).optional(),outputTokens:ue().min(0).max(9007199254740991).optional(),totalTokens:ue().min(0).max(9007199254740991).optional(),reasoningTokens:ue().min(0).max(9007199254740991).optional(),cachedInputTokens:ue().min(0).max(9007199254740991).optional(),cacheWriteInputTokens:ue().min(0).max(9007199254740991).optional()}),Ei=U({type:X(ve.RUN_FINISHED),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),threadId:_(),runId:_(),result:re().refine(e=>e!==null).optional(),outcome:Ti.optional(),usage:De(pa).optional()}),Ii=U({type:X(ve.RUN_ERROR),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),message:_(),code:_().optional(),usage:De(pa).optional()}),_i=U({type:X(ve.STEP_STARTED),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),stepName:_()}),Ai=U({type:X(ve.STEP_FINISHED),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),stepName:_()}),$i=U({type:X(ve.REASONING_START),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),messageId:_()}),Ri=U({type:X(ve.REASONING_MESSAGE_START),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),messageId:_(),role:X("reasoning")}),xi=U({type:X(ve.REASONING_MESSAGE_CONTENT),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),messageId:_(),delta:_()}),Oi=U({type:X(ve.REASONING_MESSAGE_END),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),messageId:_()}),Ni=U({type:X(ve.REASONING_MESSAGE_CHUNK),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),messageId:_().optional(),delta:_().optional()}),Mi=U({type:X(ve.REASONING_END),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),messageId:_()}),Bi=en(["tool-call","message"]),Di=U({type:X(ve.REASONING_ENCRYPTED_VALUE),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me.optional(),subtype:Bi,entityId:_(),encryptedValue:_()}),Fi=U({type:X(ve.SUBAGENT_STARTED),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me,name:_(),description:_().optional(),parentSubagentRunId:me.optional(),parentToolCallId:_().optional(),parentMessageId:_().optional()}),Pi=U({type:X("success")}),Li=U({type:X("suspended"),interruptIds:De(_()).optional()}),Vi=Wt("type",[Pi,Li]),zi=U({type:X(ve.SUBAGENT_FINISHED),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me,result:re().refine(e=>e!==null).optional(),outcome:Vi.optional()}),Ui=U({type:X(ve.SUBAGENT_ERROR),timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional(),subagentRunId:me,message:_(),code:_().optional()}),ch=Wt("type",[Rs,xs,Os,Ns,Ms,Bs,Ds,Fs,Hs,Ks,ti,di,pi,fi,mi,hi,yi,Ei,Ii,_i,Ai,$i,Ri,xi,Oi,Ni,Mi,Di,Fi,zi,Ui]),uh=en(["developer","system","assistant","user","tool","activity","reasoning"]),ji=U({name:_(),description:_().optional()}),Zi=U({name:_().optional(),type:_().optional(),description:_().optional(),version:_().optional(),provider:_().optional(),documentationUrl:_().optional(),metadata:se.optional()}),Wi=U({streaming:ge().optional(),websocket:ge().optional(),httpBinary:ge().optional(),pushNotifications:ge().optional(),resumable:ge().optional()}),Hi=U({supported:ge().optional(),items:De(da).optional(),parallelCalls:ge().optional(),clientProvided:ge().optional()}),Ki=U({structuredOutput:ge().optional(),supportedMimeTypes:De(_()).optional()}),Gi=U({snapshots:ge().optional(),deltas:ge().optional(),memory:ge().optional(),persistentState:ge().optional()}),qi=U({supported:ge().optional(),delegation:ge().optional(),handoffs:ge().optional(),subagents:De(ji).optional()}),Ji=U({supported:ge().optional(),streaming:ge().optional(),encrypted:ge().optional()}),Yi=U({image:ge().optional(),audio:ge().optional(),video:ge().optional(),pdf:ge().optional(),file:ge().optional()}),Xi=U({image:ge().optional(),audio:ge().optional()}),Qi=U({input:Yi.optional(),output:Xi.optional()}),el=U({codeExecution:ge().optional(),sandboxed:ge().optional(),maxIterations:ue().min(0).max(9007199254740991).optional(),maxExecutionTime:ue().min(0).max(9007199254740991).optional()}),tl=U({supported:ge().optional(),approvals:ge().optional(),interventions:ge().optional(),feedback:ge().optional(),interrupts:ge().optional(),approveWithEdits:ge().optional()}),dh=U({identity:Zi.optional(),transport:Wi.optional(),tools:Hi.optional(),output:Ki.optional(),state:Gi.optional(),multiAgent:qi.optional(),reasoning:Ji.optional(),multimodal:Qi.optional(),execution:el.optional(),humanInTheLoop:tl.optional(),custom:bn(e=>typeof e=="object"&&e!==null&&!Array.isArray(e)).optional()}),ph=U({subagentRunId:me.optional()}),fh=U({type:$s,timestamp:ue().min(-9007199254740991).max(9007199254740991).optional(),rawEvent:re().refine(e=>e!==null).optional(),metadata:se.optional()}),mh=U({subagentRunId:me.optional(),id:_(),role:_(),name:_().optional(),encryptedValue:_().optional(),metadata:se.optional()}),hh=se.optional(),gh="2.0.0-rc.17",nl=t.defineComponent({inheritAttrs:!1,__name:"CopilotKitInspector",props:{core:{},openRequest:{}},setup(e){const n=e,o=t.useAttrs(),a=t.shallowRef(null),r=t.shallowRef(null);let s=!0,i=null;const l={created(c){i?.(c,n.core??null),r.value=c,n.openRequest&&c.openInspector?.("message_toolbar",n.openRequest)}};return t.onMounted(()=>{import("@copilotkit/web-inspector").then(c=>{s&&(c.defineWebInspector?.(),i=(u,d)=>c.configureWebInspectorElement(u,d,{development:process.env.NODE_ENV==="development",framework:"vue",sdkVersion:gh}),a.value=c.WEB_INSPECTOR_TAG)}).catch(c=>{console.error("Failed to load CopilotKit inspector:",c)})}),t.onUnmounted(()=>{s=!1,r.value=null}),t.watch(()=>n.core,c=>{r.value&&(r.value.core=c??null)}),t.watch(()=>n.openRequest,c=>{c&&r.value?.openInspector?.("message_toolbar",c)}),(c,u)=>a.value?t.withDirectives((t.openBlock(),t.createBlock(t.resolveDynamicComponent(a.value),t.normalizeProps(t.mergeProps({key:0},t.unref(o))),null,16)),[[l]]):t.createCommentVNode("",!0)}}),fa=Symbol("CopilotKit"),Fo=Symbol("CopilotChatConfiguration"),ol=Symbol("SandboxFunctions"),al=Symbol("CopilotKitInspector"),rl=Symbol("CopilotStyleOptions");function Ve(){const e=t.inject(fa);if(!e)throw new Error("useCopilotKit must be used within CopilotKitProvider");return e}const Po=t.defineComponent({name:"MCPAppsActivityRenderer",props:{activityType:{type:String,required:!0},content:{type:Object,required:!0},message:{type:Object,required:!0},agent:{type:Object,required:!1,default:void 0},allowSameOriginFallback:{type:Boolean,required:!1,default:!1}},setup(e){const{copilotkit:n}=Ve(),o=t.ref(null),a=t.ref(null),r=t.ref(null),s=t.ref(!0),i=t.ref({}),l=t.shallowRef(null),c=t.shallowRef(null),u=t.shallowRef(null),d=t.computed(()=>e.message?.id);t.watch([o,()=>e.agent,()=>n.value,d,()=>e.content.resourceUri,()=>e.content.serverHash,()=>e.content.serverId,()=>e.allowSameOriginFallback],([h,f],m,g)=>{if(!f){a.value=new Error("No agent available to fetch resource"),s.value=!1;return}if(!h)return;let v=!0;s.value=!0,a.value=null,r.value=null,i.value={},u.value=null;const y=document.createElement("iframe");y.style.width="100%",y.style.height="100px",y.style.border="none",y.style.backgroundColor="transparent",y.style.display="block",h.appendChild(y),l.value=y,g(()=>{v=!1,c.value?.teardown(),c.value=null,y.remove(),l.value===y&&(l.value=null)}),(async()=>{try{const b=await import("@copilotkit/mcp-apps-renderer").catch(S=>{throw new Error("MCP Apps require '@copilotkit/mcp-apps-renderer' and its '@modelcontextprotocol/ext-apps' dependency. Reinstall your dependencies if this package is missing.",{cause:S})});if(!v)return;const w=b.bindMcpApp({iframe:y,getContent:()=>e.content,getAgent:()=>e.agent,host:n.value,messageId:d.value,options:{allowSameOriginFallback:e.allowSameOriginFallback},hooks:{onResource:S=>{v&&(u.value=S,s.value=!1)},onSizeChanged:S=>{v&&(i.value=S)},onContentError:S=>{v&&(r.value=S)},onError:S=>{v&&(a.value=S,s.value=!1)}}});c.value=w,w.syncContent(e.content)}catch(b){console.error("[MCPAppsRenderer] Setup error:",b),v&&(a.value=b instanceof Error?b:new Error(String(b)),s.value=!1)}})()},{immediate:!0,flush:"post"}),t.watch(i,h=>{const f=l.value;f&&(h.width!==void 0&&(f.style.minWidth=`min(${h.width}px, 100%)`,f.style.width="100%"),h.height!==void 0&&(f.style.height=`${h.height}px`))},{deep:!0}),t.watch([()=>e.content.toolInput,()=>e.content.result],()=>{c.value?.syncContent(e.content)},{deep:!0});const p=t.computed(()=>u.value?._meta?.ui?.prefersBorder!==!0?{}:{borderRadius:"8px",backgroundColor:"#f9f9f9",border:"1px solid #e0e0e0"});return()=>t.h("div",{ref:o,style:{width:"100%",height:i.value.height!==void 0?`${i.value.height}px`:"auto",minHeight:"100px",overflow:"hidden",position:"relative",...p.value}},[s.value?t.h("div",{style:{padding:"1rem",color:"#666"}},"Loading..."):null,a.value||r.value?t.h("div",{style:{color:"red",padding:"1rem"}},`Error: ${(a.value??r.value).message}`):null])}}),vh="a2ui-surface",bh=de.object({operations:de.array(de.record(de.string(),de.unknown()))});function Lo(e){return e.surfaceId??e.beginRendering?.surfaceId??e.surfaceUpdate?.surfaceId??e.dataModelUpdate?.surfaceId??e.deleteSurface?.surfaceId??e.createSurface?.surfaceId??e.updateComponents?.surfaceId??e.updateDataModel?.surfaceId??"default"}class sl extends x.CopilotKitCore{_renderToolCalls=[];_hookRenderToolCalls=new Map;_cachedMergedRenderToolCalls=null;_renderCustomMessages=[];_renderActivityMessages=[];_interruptState=null;constructor(n){super({...n,ɵwaitForFrameworkUpdates:()=>t.nextTick()}),this._renderToolCalls=n.renderToolCalls??[],this._renderCustomMessages=n.renderCustomMessages??[],this._renderActivityMessages=n.renderActivityMessages??[]}get renderCustomMessages(){return this._renderCustomMessages}get renderActivityMessages(){return this._renderActivityMessages}setRenderActivityMessages(n){this._renderActivityMessages=[...n]}setRenderCustomMessages(n){this._renderCustomMessages=[...n],this.notifySubscribers(o=>{o.onRenderCustomMessagesChanged?.({copilotkit:this,renderCustomMessages:[...this.renderCustomMessages]})},"Subscriber onRenderCustomMessagesChanged error:")}get propRenderToolCalls(){return this._renderToolCalls}get renderToolCalls(){if(this._hookRenderToolCalls.size===0)return this._renderToolCalls;if(this._cachedMergedRenderToolCalls)return this._cachedMergedRenderToolCalls;const n=new Map;for(const o of this._renderToolCalls)n.set(`${o.agentId??""}:${o.name}`,o);for(const[o,a]of this._hookRenderToolCalls)n.set(o,a);return this._cachedMergedRenderToolCalls=Array.from(n.values()),this._cachedMergedRenderToolCalls}get interruptState(){return this._interruptState}setRenderToolCalls(n){this._renderToolCalls=[...n],this._cachedMergedRenderToolCalls=null,this._notifyRenderToolCallsChanged()}addHookRenderToolCall(n){const o=`${n.agentId??""}:${n.name}`;this._hookRenderToolCalls.set(o,n),this._cachedMergedRenderToolCalls=null,this._notifyRenderToolCallsChanged()}removeHookRenderToolCall(n,o){const a=`${o??""}:${n}`;this._hookRenderToolCalls.delete(a)&&(this._cachedMergedRenderToolCalls=null,this._notifyRenderToolCallsChanged())}_notifyRenderToolCallsChanged(){this.notifySubscribers(n=>{const o=n;o.onRenderToolCallsChanged&&o.onRenderToolCallsChanged({copilotkit:this,renderToolCalls:[...this.renderToolCalls]})},"Subscriber onRenderToolCallsChanged error:")}setInterruptState(n){this._interruptState=n,this.notifySubscribers(o=>{o.onInterruptStateChanged?.({copilotkit:this,interruptState:this._interruptState})},"Subscriber onInterruptStateChanged error:")}subscribe(n){return super.subscribe(n)}}const yh={status:de.enum(["building","retrying","failed"]).optional(),attempt:de.number().optional(),maxAttempts:de.number().optional(),progressTokens:de.number().optional(),error:de.string().optional(),errors:de.array(de.any()).optional(),attempts:de.array(de.any()).optional(),debugExposure:de.enum(["hidden","collapsed","verbose"]).optional()};function kh(e,n){return e?.debugExposure??n}const il=e=>typeof e?.progressTokens=="number"?e.progressTokens:void 0,At=()=>t.h("div",{style:{width:"7px",height:"7px",borderRadius:"50%",backgroundColor:"#d4d4d8",flexShrink:0}}),vo=()=>t.h("div",{style:{width:"12px"}}),qe=(e,n,o,a,r,s)=>t.h("div",{style:{width:`${e}px`,height:`${n}px`,borderRadius:"9999px",backgroundColor:o,...a!==void 0?{animation:`cpk-a2ui-fade 2.4s ease-in-out ${a}s infinite`}:{},...r!==void 0?{opacity:r}:{},...s?{transition:s}:{}}}),Lt=(e,n,o)=>t.h("div",{style:{display:"flex",alignItems:"center",gap:"6px",opacity:e?1:0,transition:`opacity 0.4s ${n}s`}},o);function Vo(e,n,o){const a=n==null?3:n<50?0:n<200?1:n<400?2:3;return t.h("div",{style:{margin:"12px 0",maxWidth:"320px"}},[t.h("div",{style:{position:"relative",overflow:"hidden",borderRadius:"12px",border:"1px solid rgba(228,228,231,0.8)",backgroundColor:"#fff",boxShadow:"0 1px 2px rgba(0,0,0,0.04)",padding:"16px 18px 14px"}},[t.h("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px"}},[t.h("div",{style:{display:"flex",gap:"4px"}},[At(),At(),At()]),qe(64,6,"#e4e4e7",void 0,a>=1?1:.4,"opacity 0.5s")]),t.h("div",{style:{display:"grid",gap:"7px"}},[Lt(a>=0,0,[qe(36,7,"rgba(147,197,253,0.7)",0),qe(80,7,"rgba(219,234,254,0.8)",.2)]),Lt(a>=0,.1,[vo(),At(),qe(100,7,"rgba(24,24,27,0.2)",.3)]),Lt(a>=1,.15,[vo(),qe(48,7,"rgba(24,24,27,0.15)",.1),qe(40,7,"rgba(153,246,228,0.6)",.5),qe(56,7,"rgba(147,197,253,0.6)",.3)]),Lt(a>=1,.2,[vo(),At(),qe(60,7,"rgba(24,24,27,0.15)",.4)]),Lt(a>=2,.25,[qe(40,7,"rgba(153,246,228,0.5)",.2),At(),qe(48,7,"rgba(24,24,27,0.15)",.6),qe(64,7,"rgba(147,197,253,0.5)",.1)]),Lt(a>=2,.3,[qe(36,7,"rgba(147,197,253,0.6)",.5),qe(36,7,"rgba(24,24,27,0.12)",.7)]),Lt(a>=3,.35,[At(),qe(44,7,"rgba(24,24,27,0.18)",.3),At(),qe(56,7,"rgba(153,246,228,0.5)",.8),qe(48,7,"rgba(147,197,253,0.5)",.4)])]),t.h("div",{style:{pointerEvents:"none",position:"absolute",inset:"0",background:"linear-gradient(105deg, transparent 0%, transparent 40%, rgba(255,255,255,0.6) 50%, transparent 60%, transparent 100%)",backgroundSize:"250% 100%",animation:"cpk-a2ui-sweep 3s ease-in-out infinite"}})]),t.h("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",marginTop:"8px"}},[t.h("span",{style:{fontSize:"12px",color:"#a1a1aa",letterSpacing:"0.025em"}},e),...typeof n=="number"&&n>0?[t.h("span",{style:{fontSize:"11px",color:"#d4d4d8",fontVariantNumeric:"tabular-nums"}},`~${n.toLocaleString()} tokens`)]:[]]),...o??[],t.h("style",`
|
|
58
|
+
@keyframes cpk-a2ui-fade {
|
|
59
|
+
0%, 100% { opacity: 1; }
|
|
60
|
+
50% { opacity: 0.5; }
|
|
61
|
+
}
|
|
62
|
+
@keyframes cpk-a2ui-sweep {
|
|
63
|
+
0% { background-position: 250% 0; }
|
|
64
|
+
100% { background-position: -250% 0; }
|
|
65
|
+
}
|
|
66
|
+
`)])}function ll(e,n,o){return t.h("details",{open:n,class:"cpk-a2ui-debug-details"},[t.h("summary",{class:"cpk-a2ui-debug-details-summary"},e),t.h("pre",{class:"cpk-a2ui-debug-details-payload",style:{fontSize:"11px"}},JSON.stringify(o,null,2))])}const Sh=t.defineComponent({name:"A2UIBuildingState",props:{content:{type:null,default:void 0}},setup(e){return()=>Vo("Building interface",il(e.content))}}),wh=t.defineComponent({name:"A2UIRetryingState",props:{content:{type:null,default:void 0},showAfterMs:{type:Number,required:!0},showAfterAttempts:{type:Number,required:!0},debugExposure:{type:String,required:!0}},setup(e){const n=()=>typeof e.content?.attempt=="number"?e.content.attempt:void 0,o=()=>{const s=n();return s!==void 0&&s>=e.showAfterAttempts},a=t.ref(o());let r;return t.watch([o,()=>e.showAfterMs],([s,i])=>{if(clearTimeout(r),s){a.value=!0;return}r=setTimeout(()=>{a.value=!0},i)},{immediate:!0}),t.onBeforeUnmount(()=>clearTimeout(r)),()=>{const s=il(e.content);if(!a.value)return Vo("Building interface",s);const i=n(),l=typeof e.content?.maxAttempts=="number"?e.content.maxAttempts:void 0,c=i!==void 0&&l!==void 0?`Retrying generation… (${i}/${l} attempts)`:"Retrying generation…",u=Array.isArray(e.content?.errors)?e.content.errors:[];return Vo(c,s,e.debugExposure!=="hidden"&&u.length>0?[ll("validation issues",e.debugExposure==="verbose",{attempt:e.content?.attempt,errors:u})]:[])}}}),Ch=t.defineComponent({name:"A2UIRecoveryFailure",props:{content:{type:null,default:void 0},debugExposure:{type:String,required:!0}},setup(e){return()=>t.h("div",{class:"cpk-a2ui-recovery-failure"},[t.h("div",{class:"cpk-a2ui-recovery-failure-title"},"Couldn't generate the UI"),t.h("div",{class:"cpk-a2ui-recovery-failure-description"},"Something went wrong rendering this. You can keep chatting and try again."),e.debugExposure!=="hidden"?ll("developer details",e.debugExposure==="verbose",{error:e.content?.error,attempts:e.content?.attempts}):null])}}),gr="a2ui_operations",Th=de.object({a2ui_operations:de.array(de.any()).optional(),...yh}).loose();function cl(e){const n=e.recovery?.showAfterMs??2e3,o=e.recovery?.showAfterAttempts??2,a=e.recovery?.debugExposure??"collapsed",r=s=>{const i=kh(s,a);return s?.status==="failed"?t.h(Ch,{content:s,debugExposure:i}):s?.status==="retrying"?t.h(wh,{content:s,showAfterMs:n,showAfterAttempts:o,debugExposure:i}):e.loadingComponent?t.h(e.loadingComponent):t.h(Sh,{content:s})};return{activityType:"a2ui-surface",content:Th,render:t.defineComponent({name:"A2UIMessageRendererHost",props:{activityType:{type:String,required:!0},content:{type:Object,required:!0},message:{type:Object,required:!0},agent:{type:Object,required:!1,default:void 0}},setup(s){const i=t.computed(()=>Array.isArray(s.content?.[gr])?s.content[gr]:[]);return()=>i.value.length===0?r(s.content):t.h(Tl,{activityType:"a2ui-surface",content:{operations:i.value},message:s.message,agent:s.agent,theme:e.theme,catalog:e.catalog})}})}}function Kn(e){const n=e.args??Q.ɵanySchema;return{name:e.name,args:n,render:e.render,...e.agentId?{agentId:e.agentId}:{},...e.group?{group:!0}:{}}}const bo="render_a2ui";function Eh(e,n){t.watch([()=>e.value,n],([o,a],r,s)=>{if(!a)return;const i=Kn({name:bo,args:de.any(),render:()=>null}),l=o.propRenderToolCalls;o.setRenderToolCalls([...l.filter(c=>c.name!==bo),i]),s(()=>{const c=o.propRenderToolCalls;o.setRenderToolCalls(c.filter(u=>u.name!==bo))})},{immediate:!0})}function ze(e,n,o){const a=t.defineComponent({name:`A2UI_${e.name}`,props:{context:{type:Object,required:!0},buildChild:{type:Function,required:!0}},setup(r){const s=t.ref({});let i=null;const l=o?o():void 0;function c(u){i&&i.dispose(),i=new qn.GenericBinder(u,e.schema),s.value=i.snapshot,i.subscribe(d=>{s.value=d})}return c(r.context),t.watch(()=>r.context,u=>{c(u)}),t.onUnmounted(()=>{i&&(i.dispose(),i=null)}),()=>n({props:s.value,buildChild:r.buildChild,context:r.context,state:l})}});return{name:e.name,schema:e.schema,render:a}}const ft="8px",Ih="16px",jt="1px solid var(--a2ui-color-border, #ccc)",no="8px",ul=e=>{switch(e){case"center":return"center";case"end":return"flex-end";case"spaceAround":return"space-around";case"spaceBetween":return"space-between";case"spaceEvenly":return"space-evenly";case"start":return"flex-start";case"stretch":return"stretch";default:return"flex-start"}},ma=e=>{switch(e){case"start":return"flex-start";case"center":return"center";case"end":return"flex-end";case"stretch":return"stretch";default:return"stretch"}},kn=()=>({margin:ft,boxSizing:"border-box"}),_h=()=>({margin:ft,padding:Ih,border:jt,borderRadius:no,boxSizing:"border-box"});function ha(e,n){return Array.isArray(e)?e.map(o=>{if(o&&typeof o=="object"&&"id"in o){const a=o;return n(a.id,a.basePath)}return typeof o=="string"?n(o):null}).filter(o=>o!==null):[]}let Ah=0;function oo(){return`a2ui-vue-${++Ah}`}const $h=ze(Fe.TextApi,({props:e})=>{const n=e.text??"",o={...kn(),display:"inline-block"};switch(e.variant){case"h1":return t.h("h1",{style:o},n);case"h2":return t.h("h2",{style:o},n);case"h3":return t.h("h3",{style:o},n);case"h4":return t.h("h4",{style:o},n);case"h5":return t.h("h5",{style:o},n);case"caption":return t.h("small",{style:{...o,color:"var(--a2ui-color-muted, #666)",textAlign:"left"}},n);default:return t.h("span",{style:o},n)}}),Rh=ze(Fe.ImageApi,({props:e})=>{const n=a=>a==="scaleDown"?"scale-down":a||"fill",o={...kn(),objectFit:n(e.fit),width:"100%",height:"auto",display:"block"};return e.variant==="icon"?(o.width="24px",o.height="24px"):e.variant==="avatar"?(o.width="40px",o.height="40px",o.borderRadius="50%"):e.variant==="smallFeature"?o.maxWidth="100px":e.variant==="largeFeature"?o.maxHeight="400px":e.variant==="header"&&(o.height="200px",o.objectFit="cover"),t.h("img",{src:e.url,alt:e.description||"",style:o})}),xh=ze(Fe.IconApi,({props:e})=>{const n=typeof e.name=="string"?e.name:e.name?.path,o={...kn(),fontSize:"24px",width:"24px",height:"24px",display:"inline-flex",alignItems:"center",justifyContent:"center"};return t.h("span",{class:"material-symbols-outlined",style:o},n)}),Oh=ze(Fe.VideoApi,({props:e})=>{const n={...kn(),width:"100%",aspectRatio:"16/9"};return t.h("video",{src:e.url,controls:!0,style:n})}),Nh=ze(Fe.AudioPlayerApi,({props:e})=>{const n={...kn(),width:"100%"};return t.h("div",{style:{display:"flex",flexDirection:"column",gap:"4px",width:"100%"}},[e.description?t.h("span",{style:{fontSize:"12px",color:"var(--a2ui-color-muted, #666)"}},e.description):null,t.h("audio",{src:e.url,controls:!0,style:n})])}),Mh=ze(Fe.RowApi,({props:e,buildChild:n})=>t.h("div",{style:{display:"flex",flexDirection:"row",justifyContent:ul(e.justify),alignItems:ma(e.align),width:"100%",margin:"0",padding:"0"}},ha(e.children,n))),Bh=ze(Fe.ColumnApi,({props:e,buildChild:n})=>t.h("div",{style:{display:"flex",flexDirection:"column",justifyContent:ul(e.justify),alignItems:ma(e.align),width:"100%",margin:"0",padding:"0"}},ha(e.children,n))),Dh=ze(Fe.ListApi,({props:e,buildChild:n})=>{const o=e.direction==="horizontal",a={display:"flex",flexDirection:o?"row":"column",alignItems:ma(e.align),overflowX:o?"auto":"hidden",overflowY:o?"hidden":"auto",width:"100%",margin:"0",padding:"0"};return t.h("div",{style:a},ha(e.children,n))}),Fh=ze(Fe.CardApi,({props:e,buildChild:n})=>{const o={..._h(),backgroundColor:"var(--a2ui-color-surface, #fff)",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",width:"100%"};return t.h("div",{style:o},[e.child?n(e.child):null])}),Ph=ze(Fe.TabsApi,({props:e,buildChild:n,state:o})=>{const a=e.tabs||[];return t.h("div",{style:{display:"flex",flexDirection:"column",width:"100%",margin:ft}},[t.h("div",{style:{display:"flex",borderBottom:jt,marginBottom:"8px"}},a.map((r,s)=>{const i=typeof r.title=="string"?r.title:String(r.title??"");return t.h("button",{key:s,onClick:()=>{o.selectedIndex.value=s},style:{padding:"8px 16px",border:"none",background:"none",borderBottom:o.selectedIndex.value===s?"2px solid var(--a2ui-primary-color, #007bff)":"none",fontWeight:o.selectedIndex.value===s?"bold":"normal",cursor:"pointer",color:o.selectedIndex.value===s?"var(--a2ui-primary-color, #007bff)":"inherit"}},i)})),t.h("div",{style:{flex:"1"}},[a[o.selectedIndex.value]?.child?n(a[o.selectedIndex.value].child):null])])},()=>({selectedIndex:t.ref(0)})),Lh=ze(Fe.DividerApi,({props:e})=>{const n=e.axis==="vertical",o={margin:ft,border:"none",backgroundColor:"var(--a2ui-color-border, #ccc)"};return n?(o.width="1px",o.height="100%"):(o.width="100%",o.height="1px"),t.h("div",{style:o})}),Vh=ze(Fe.ModalApi,({props:e,buildChild:n,state:o})=>t.h("div",{},[t.h("div",{onClick:()=>{o.isOpen.value=!0},style:{display:"inline-block"}},[e.trigger?n(e.trigger):null]),o.isOpen.value?t.h("div",{style:{position:"fixed",top:"0",left:"0",right:"0",bottom:"0",backgroundColor:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:"1000"},onClick:()=>{o.isOpen.value=!1}},[t.h("div",{style:{backgroundColor:"var(--a2ui-color-surface, #fff)",padding:"24px",borderRadius:"8px",maxWidth:"90%",maxHeight:"90%",overflow:"auto",display:"flex",flexDirection:"column"},onClick:a=>a.stopPropagation()},[t.h("div",{style:{display:"flex",justifyContent:"flex-end"}},[t.h("button",{onClick:()=>{o.isOpen.value=!1},style:{border:"none",background:"none",fontSize:"20px",cursor:"pointer",padding:"4px"}},"×")]),t.h("div",{style:{flex:"1"}},[e.content?n(e.content):null])])]):null]),()=>({isOpen:t.ref(!1)})),zh=ze(Fe.ButtonApi,({props:e,buildChild:n})=>{const o={margin:ft,padding:"8px 16px",cursor:"pointer",border:e.variant==="borderless"?"none":jt,backgroundColor:e.variant==="primary"?"var(--a2ui-primary-color, #007bff)":e.variant==="borderless"?"transparent":"var(--a2ui-color-surface, #fff)",color:e.variant==="primary"?"#fff":"inherit",borderRadius:"4px",display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"};return t.h("button",{style:o,onClick:e.action,disabled:e.isValid===!1},[e.child?n(e.child):null])}),Uh=ze(Fe.TextFieldApi,({props:e,state:n})=>{const o=n.id,a=e.variant==="longText",r=e.variant==="number"?"number":e.variant==="obscured"?"password":"text",s={padding:"8px",width:"100%",border:e.validationErrors&&e.validationErrors.length>0?"1px solid var(--a2ui-color-error, red)":jt,borderRadius:no,boxSizing:"border-box"},i=e.validationErrors&&e.validationErrors.length>0;return t.h("div",{style:{display:"flex",flexDirection:"column",gap:"4px",width:"100%",margin:ft}},[e.label?t.h("label",{for:o,style:{fontSize:"14px",fontWeight:"bold"}},e.label):null,a?t.h("textarea",{id:o,style:s,value:e.value||"",onInput:l=>e.setValue(l.target.value)}):t.h("input",{id:o,type:r,style:s,value:e.value||"",onInput:l=>e.setValue(l.target.value)}),i?t.h("span",{style:{fontSize:"12px",color:"var(--a2ui-color-error, red)"}},e.validationErrors[0]):null])},()=>({id:oo()})),jh=ze(Fe.CheckBoxApi,({props:e,state:n})=>{const o=n.id,a=e.validationErrors&&e.validationErrors.length>0;return t.h("div",{style:{display:"flex",flexDirection:"column",margin:ft}},[t.h("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},[t.h("input",{id:o,type:"checkbox",checked:!!e.value,onChange:r=>e.setValue(r.target.checked),style:{cursor:"pointer",outline:a?"1px solid var(--a2ui-color-error, red)":"none"}}),e.label?t.h("label",{for:o,style:{cursor:"pointer",color:a?"var(--a2ui-color-error, red)":"inherit"}},e.label):null]),a?t.h("span",{style:{fontSize:"12px",color:"var(--a2ui-color-error, red)",marginTop:"4px"}},e.validationErrors?.[0]):null])},()=>({id:oo()})),Zh=ze(Fe.ChoicePickerApi,({props:e,context:n,state:o})=>{const a=Array.isArray(e.value)?e.value:[],r=e.variant==="mutuallyExclusive",s=l=>{if(r)e.setValue([l]);else{const c=a.includes(l)?a.filter(u=>u!==l):[...a,l];e.setValue(c)}},i=(e.options||[]).filter(l=>!e.filterable||o.filter.value===""||String(typeof l.label=="string"?l.label:"").toLowerCase().includes(o.filter.value.toLowerCase()));return t.h("div",{style:{display:"flex",flexDirection:"column",gap:"8px",margin:ft,width:"100%"}},[e.label?t.h("strong",{style:{fontSize:"14px"}},e.label):null,e.filterable?t.h("input",{type:"text",placeholder:"Filter options...",value:o.filter.value,onInput:l=>{o.filter.value=l.target.value},style:{padding:"4px 8px",border:jt,borderRadius:no}}):null,t.h("div",{style:{display:"flex",flexDirection:e.displayStyle==="chips"?"row":"column",flexWrap:e.displayStyle==="chips"?"wrap":"nowrap",gap:"8px"}},i.map((l,c)=>{const u=a.includes(l.value),d=typeof l.label=="string"?l.label:String(l.label??l.value);return e.displayStyle==="chips"?t.h("button",{key:c,onClick:()=>s(l.value),style:{padding:"4px 12px",borderRadius:"16px",border:u?"1px solid var(--a2ui-primary-color, #007bff)":jt,backgroundColor:u?"var(--a2ui-primary-color, #007bff)":"var(--a2ui-color-surface, #fff)",color:u?"#fff":"inherit",cursor:"pointer",fontSize:"12px"}},d):t.h("label",{key:c,style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"}},[t.h("input",{type:r?"radio":"checkbox",checked:u,onChange:()=>s(l.value),name:r?`choice-${n.componentModel.id}`:void 0}),t.h("span",{style:{fontSize:"14px"}},d)])}))])},()=>({filter:t.ref("")})),Wh=ze(Fe.SliderApi,({props:e,state:n})=>{const o=n.id;return t.h("div",{style:{display:"flex",flexDirection:"column",gap:"4px",margin:ft,width:"100%"}},[t.h("div",{style:{display:"flex",justifyContent:"space-between"}},[e.label?t.h("label",{for:o,style:{fontSize:"14px",fontWeight:"bold"}},e.label):null,t.h("span",{style:{fontSize:"12px",color:"var(--a2ui-color-muted, #666)"}},String(e.value))]),t.h("input",{id:o,type:"range",min:e.min??0,max:e.max,value:e.value??0,onInput:a=>e.setValue(Number(a.target.value)),style:{width:"100%",cursor:"pointer"}})])},()=>({id:oo()})),Hh=ze(Fe.DateTimeInputApi,({props:e,state:n})=>{const o=n.id;let a="datetime-local";e.enableDate&&!e.enableTime&&(a="date"),!e.enableDate&&e.enableTime&&(a="time");const r={padding:"8px",width:"100%",border:jt,borderRadius:no,boxSizing:"border-box"};return t.h("div",{style:{display:"flex",flexDirection:"column",gap:"4px",width:"100%",margin:ft}},[e.label?t.h("label",{for:o,style:{fontSize:"14px",fontWeight:"bold"}},e.label):null,t.h("input",{id:o,type:a,style:r,value:e.value||"",onInput:s=>e.setValue(s.target.value),min:typeof e.min=="string"?e.min:void 0,max:typeof e.max=="string"?e.max:void 0})])},()=>({id:oo()})),Kh=[$h,Rh,xh,Oh,Nh,Mh,Bh,Dh,Fh,Ph,Lh,Vh,zh,Uh,jh,Zh,Wh,Hh],ao=new qn.Catalog("https://a2ui.org/specification/v0_9/basic_catalog.json",Kh,Fe.BASIC_FUNCTIONS);function Gh(e,n){return Io.buildCatalogContextValue(e??ao,n)}function qh(e,n){const o=t.computed(()=>Gh(n.catalog(),{includeSchema:n.includeSchema()}));t.watch([()=>e.value,n.enabled,o],([r,s,i],l,c)=>{if(!s)return;const u=r.a2uiAgents,d=r.addContext({description:"A2UI catalog capabilities: available catalog IDs and custom component definitions the client can render.",value:i,...u?{agentIds:u}:{}});c(()=>r.removeContext(d))},{immediate:!0});const a=t.computed(()=>n.includeSchema()?JSON.stringify(Io.extractCatalogComponentSchemas(n.catalog()??ao)):null);t.watch([()=>e.value,n.enabled,a],([r,s,i],l,c)=>{if(!s||!i)return;const u=r.a2uiAgents,d=u?{agentIds:u}:{},p=[];p.push(r.addContext({description:Io.A2UI_SCHEMA_CONTEXT_DESCRIPTION,value:i,...d})),p.push(r.addContext({description:"A2UI generation guidelines — protocol rules, tool arguments, path rules, data model format, and form/two-way-binding instructions.",value:Q.A2UI_DEFAULT_GENERATION_GUIDELINES,...d})),p.push(r.addContext({description:"A2UI design guidelines — visual design rules, component hierarchy tips, and action handler patterns.",value:Q.A2UI_DEFAULT_DESIGN_GUIDELINES,...d})),c(()=>{for(const h of p)r.removeContext(h)})},{immediate:!0})}function dl(){const e=t.inject(ol,t.computed(()=>[]));return t.computed(()=>e.value)}const pl=x.OPEN_GENERATIVE_UI_ACTIVITY_TYPE,fl=de.object({initialHeight:de.number().optional(),generating:de.boolean().optional(),css:de.string().optional(),cssComplete:de.boolean().optional(),html:de.array(de.string()).optional(),htmlComplete:de.boolean().optional(),jsFunctions:de.string().optional(),jsFunctionsComplete:de.boolean().optional(),jsExpressions:de.array(de.string()).optional(),jsExpressionsComplete:de.boolean().optional()}),ml=de.object({initialHeight:de.number().optional(),placeholderMessages:de.array(de.string()).optional(),css:de.string().optional(),html:de.string().optional(),jsFunctions:de.string().optional(),jsExpressions:de.array(de.string()).optional()}),hl=t.defineComponent({name:"OpenGenerativeUIRenderer",props:{content:{type:Object,required:!0}},setup(e){const n=dl(),o=t.ref(null),a=new x.ɵOpenGenerativeUIController;a.setContent(e.content);const r=t.shallowRef(a.getState()),s=a.subscribe(()=>{r.value=a.getState()});return t.watch(()=>e.content,i=>a.setContent(i)),t.watch(n,i=>a.setSandboxFunctions(i),{immediate:!0}),t.onMounted(()=>a.setHost(o.value)),t.onBeforeUnmount(()=>{s(),a.destroy()}),()=>{const{phase:i,generating:l,height:c}=r.value,u=i!=="placeholder";return t.h("div",{ref:o,"data-testid":"open-generative-ui-renderer",style:{position:"relative",width:"100%",height:`${c}px`,borderRadius:"8px",backgroundColor:u?"transparent":"#f5f5f5",border:u?"none":"1px solid #e0e0e0",overflow:"hidden",display:u?"block":"flex",alignItems:u?void 0:"center",justifyContent:u?void 0:"center"}},[u?null:t.h("div",{"data-testid":"open-generative-ui-placeholder"},[t.h("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",style:{animation:"ck-spin 1s linear infinite"}},[t.h("circle",{cx:"12",cy:"12",r:"10",stroke:"#e0e0e0","stroke-width":"3"}),t.h("path",{d:"M12 2a10 10 0 0 1 10 10",stroke:"#999","stroke-width":"3","stroke-linecap":"round"})]),t.h("style","@keyframes ck-spin { to { transform: rotate(360deg) } }")]),l?t.h("div",{"data-testid":"open-generative-ui-progress-overlay",style:{position:"absolute",inset:0,backgroundColor:"rgba(255,255,255,0.45)"}}):null])}}}),gl=t.defineComponent({name:"OpenGenerativeUIActivityRenderer",props:{activityType:{type:String,required:!0},content:{type:Object,required:!0},message:{type:Object,required:!0},agent:{type:Object,required:!1,default:void 0}},setup(e){return()=>t.h(hl,{content:e.content})}}),vl=t.defineComponent({name:"OpenGenerativeUIToolRenderer",props:{name:{type:String,required:!0},args:{type:Object,required:!0},status:{type:String,required:!0},result:{type:String,required:!1}},setup(e){const n=t.ref(0);return t.watch(()=>e.args.placeholderMessages,(o,a,r)=>{if(!o?.length||e.status===x.ToolCallStatus.Complete)return;n.value=Math.max(o.length-1,0);const s=window.setInterval(()=>{n.value=(n.value+1)%Math.max(o.length,1)},5e3);r(()=>window.clearInterval(s))},{immediate:!0}),()=>{if(e.status===x.ToolCallStatus.Complete)return null;const o=e.args.placeholderMessages;if(!o?.length)return null;const a=o[n.value]??o[0];return t.h("div",{style:{padding:"8px 12px",color:"#999",fontSize:"14px"},"data-testid":"open-generative-ui-tool-placeholder"},a)}}}),ga=Symbol("copilotkit-markdown-renderer");function bl(){return t.inject(ga,void 0)}function yl(e){if(typeof e=="function")return!0;if(e&&typeof e=="object"){const n=e;return"setup"in n||"render"in n||"__vccOpts"in n||"__name"in n}return!1}const va=Symbol("LicenseContext");function kl(){return t.ref(Q.createLicenseContextValue(null))}function Re(){const e=t.inject(Fo,void 0);return t.computed(()=>e?.value??null)}function mt(){const e=Re();return t.computed(()=>e.value?.labels??x.CopilotChatDefaultLabels)}const Jh={style:{display:"flex",gap:"8px",alignItems:"center"}},Yh=["href"],Xh=52,vr="--copilotkit-license-banner-offset",Qh=t.defineComponent({__name:"LicenseWarningBanner",props:{type:{},featureName:{default:void 0},expiryDate:{default:void 0},graceRemaining:{default:void 0},onDismiss:{type:Function,default:void 0}},setup(e){const n=e,o=mt();function a(c){if(c===void 0)return o.value.licenseExpiringText;const u=c===1?o.value.licenseExpiringInDaysOne:o.value.licenseExpiringInDaysOther;return x.ɵformatLabel(u,{days:c})}const r=t.computed(()=>{const c=o.value;switch(n.type){case"no_license":return{severity:"info",message:c.licensePoweredByText,actionLabel:c.licenseGetLicenseLabel,actionUrl:"https://copilotkit.ai/pricing"};case"feature_unlicensed":return{severity:"warning",message:x.ɵformatLabel(c.licenseFeatureUnlicensedText,{feature:n.featureName??""}),actionLabel:c.licenseGetLicenseLabel,actionUrl:"https://copilotkit.ai/pricing"};case"expiring":return{severity:"warning",message:a(n.graceRemaining),actionLabel:c.licenseRenewLabel,actionUrl:"https://dashboard.operations.copilotkit.ai"};case"expired":return{severity:"critical",message:n.expiryDate?x.ɵformatLabel(c.licenseExpiredOnDateText,{date:n.expiryDate}):c.licenseExpiredText,actionLabel:c.licenseRenewNowLabel,actionUrl:"https://copilotkit.ai/pricing"};case"invalid":return{severity:"critical",message:c.licenseInvalidText,actionLabel:c.licenseGetLicenseLabel,actionUrl:"https://copilotkit.ai/pricing"};default:return null}}),s={position:"fixed",bottom:"8px",left:"50%",transform:"translateX(-50%)",zIndex:99999,display:"inline-flex",alignItems:"center",gap:"12px",whiteSpace:"nowrap",padding:"8px 16px",fontSize:"13px",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif",borderRadius:"6px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)"},i=t.computed(()=>{switch(r.value?.severity){case"warning":return{backgroundColor:"#fffbeb",border:"1px solid #fbbf24",color:"#92400e"};case"critical":return{backgroundColor:"#fef2f2",border:"1px solid #fca5a5",color:"#991b1b"};default:return{backgroundColor:"#eff6ff",border:"1px solid #93c5fd",color:"#1e40af"}}}),l=t.computed(()=>({...s,...i.value}));return t.onMounted(()=>{typeof document>"u"||document.documentElement.style.setProperty(vr,`${Xh}px`)}),t.onBeforeUnmount(()=>{typeof document>"u"||document.documentElement.style.removeProperty(vr)}),(c,u)=>r.value?(t.openBlock(),t.createElementBlock("div",{key:0,style:t.normalizeStyle(l.value),"data-testid":"copilot-license-banner"},[t.createElementVNode("span",null,t.toDisplayString(r.value.message),1),t.createElementVNode("div",Jh,[t.createElementVNode("a",{href:r.value.actionUrl,target:"_blank",rel:"noopener noreferrer",style:{fontWeight:600,textDecoration:"underline",color:"inherit"}},t.toDisplayString(r.value.actionLabel),9,Yh),n.onDismiss?(t.openBlock(),t.createElementBlock("button",{key:0,style:{background:"none",border:"none",cursor:"pointer",color:"inherit",fontSize:"16px"},onClick:u[0]||(u[0]=(...d)=>n.onDismiss&&n.onDismiss(...d))}," × ")):t.createCommentVNode("",!0)])],4)):t.createCommentVNode("",!0)}}),eg="X-CopilotCloud-Public-Api-Key",tg="https://api.cloud.copilotkit.ai/copilotkit/v1",ng="frontendTools must be a stable array. If you want to dynamically add or remove tools, use `useFrontendTool` instead.",og="humanInTheLoop must be a stable array. If you want to dynamically add or remove human-in-the-loop tools, use `useHumanInTheLoop` instead.",ag="renderCustomMessages must be a stable array.",rg="renderActivityMessages must be a stable array.",sg="openGenerativeUI.sandboxFunctions must be a stable array.",br="Human-in-the-loop interaction aborted",ig=t.defineComponent({__name:"CopilotKitProvider",props:{runtimeUrl:{},headers:{type:[Object,Function],default:()=>({})},credentials:{},nonce:{default:void 0},injectStyles:{type:Boolean,default:!0},messageFilter:{},defaultThrottleMs:{},publicApiKey:{},publicLicenseKey:{},licenseToken:{},properties:{default:()=>({})},useSingleEndpoint:{type:Boolean,default:void 0},agents__unsafe_dev_only:{default:()=>({})},selfManagedAgents:{default:()=>({})},renderToolCalls:{},renderActivityMessages:{default:()=>[]},renderCustomMessages:{default:()=>[]},frontendTools:{default:()=>[]},humanInTheLoop:{default:()=>[]},openGenerativeUI:{default:void 0},enableInspector:{type:Boolean,default:void 0},onError:{},a2ui:{default:void 0},mcpApps:{default:void 0},markdownRenderer:{},debug:{type:[Boolean,Object]},learning:{type:[Boolean,Object],default:void 0}},setup(e){const n={},o=(W,{attrs:ce})=>t.h(Po,{...ce,allowSameOriginFallback:!0}),a=e;t.provide(rl,t.computed(()=>({nonce:a.nonce,inject:a.injectStyles})));const r=t.ref(!1);function s(){r.value=Q.shouldEnableInspector({enableInspector:a.enableInspector,isBrowser:!0,isDevelopment:process.env.NODE_ENV==="development"})}t.onMounted(s),t.watch(()=>a.enableInspector,s);const i=t.ref(null),l=t.computed(()=>r.value);function c(W){i.value={...W}}t.provide(al,{isInspectorEnabled:l,openInspector:c});const u=a.frontendTools,d=a.humanInTheLoop,p=a.renderCustomMessages,h=a.renderActivityMessages,f=a.openGenerativeUI?.sandboxFunctions,m=W=>[...t.toRaw(W??[])].map(ce=>t.toRaw(ce));t.watch(()=>a.frontendTools,W=>{W!==u&&console.error(ng)}),t.watch(()=>a.humanInTheLoop,W=>{W!==d&&console.error(og)}),t.watch(()=>a.renderCustomMessages,W=>{W!==p&&console.error(ag)}),t.watch(()=>a.renderActivityMessages,W=>{W!==h&&console.error(rg)}),t.watch(()=>a.openGenerativeUI?.sandboxFunctions,W=>{W!==f&&console.error(sg)});const g=t.computed(()=>a.publicApiKey??a.publicLicenseKey),v=t.computed(()=>({...a.agents__unsafe_dev_only,...a.selfManagedAgents})),y=t.computed(()=>Object.keys(v.value).length>0),k=t.computed(()=>typeof a.headers=="function"),b=(()=>typeof a.headers=="function"?a.headers():a.headers),w=t.computed(()=>x.ɵwithHeaderDefaults(k.value?b:a.headers,g.value?{[eg]:g.value}:{})),S=t.computed(()=>a.runtimeUrl??(g.value?tg:void 0));t.watch([S,g,y],([W,ce,pe])=>{if(W||ce||pe)return;const Je="Missing required prop: 'runtimeUrl' or 'publicApiKey' or 'publicLicenseKey'";if(process.env.NODE_ENV==="production")throw new Error(Je);console.warn(Je)},{immediate:!0});const C=new Map,A=W=>{const ce=C.get(W);if(ce)return ce.detachAbort?.(),C.delete(W),ce},E=t.computed(()=>{const W=[],ce=[];for(const pe of m(a.humanInTheLoop))if(W.push({type:"human-in-the-loop",name:pe.name,description:pe.description,parameters:pe.parameters,followUp:pe.followUp,...pe.agentId&&{agentId:pe.agentId},handler:async(Je,He)=>{const we=He?.signal,Me=He?.toolCall?.id??pe.name;return new Promise((Oe,Ke)=>{if(we?.aborted){Ke(new Error(br));return}const Ge={resolve:Oe};if(C.set(Me,Ge),we){const gt=()=>{C.delete(Me),Ke(new Error(br))};we.addEventListener("abort",gt,{once:!0}),Ge.detachAbort=()=>{we.removeEventListener("abort",gt)}}})}}),pe.render){const Je=pe.render,He=we=>{const Me=we.toolCallId??pe.name;return t.h(Je,{...we,name:pe.name==="*"?we.name:pe.name,description:pe.description||"",agentId:pe.agentId,respond:we.status===x.ToolCallStatus.Executing?async Oe=>{A(Me)?.resolve(Oe)}:void 0})};ce.push({name:pe.name,args:pe.parameters??Q.ɵanySchema,render:He,...pe.agentId&&{agentId:pe.agentId}})}return{tools:W,renderToolCalls:ce}}),L=t.computed(()=>{const W=[];for(const ce of m(a.frontendTools))W.push(ce);for(const ce of ie.value)W.push(ce);return W.push(...E.value.tools),W}),z=t.computed(()=>{const W=[...m(a.renderToolCalls)];for(const ce of[...m(a.frontendTools),...ie.value])if(ce.render){const pe=ce.parameters??(ce.name==="*"?Q.ɵanySchema:void 0);pe&&W.push({name:ce.name,args:pe,render:ce.render})}return W.push(...E.value.renderToolCalls),W}),O=t.computed(()=>a.renderCustomMessages??[]),N=t.ref(!1),K=t.ref(!1),ae=t.ref(void 0),H=t.ref(void 0),M=t.ref(!1),I=t.computed(()=>K.value||!!a.openGenerativeUI),B=t.computed(()=>!!a.a2ui?.catalog),F=t.computed(()=>N.value||B.value),V=t.computed(()=>B.value?{...a.properties,a2uiCatalogAvailable:!0}:a.properties),oe=t.computed(()=>m(a.openGenerativeUI?.sandboxFunctions)),ie=t.computed(()=>I.value?[{name:x.GENERATE_SANDBOXED_UI_TOOL_NAME,description:Q.GENERATE_SANDBOXED_UI_DESCRIPTION,parameters:ml,handler:async()=>"UI generated",reconnectBehavior:"resume-pending",followUp:!0,render:vl}]:[]),Te=t.computed(()=>{const W=[{activityType:Da.MCPAppsActivityType,content:Da.MCPAppsActivityContentSchema,render:a.mcpApps?.allowSameOriginFallback?o:Po}];return I.value&&W.push({activityType:pl,content:fl,render:gl}),F.value&&W.unshift(cl({theme:a.a2ui?.theme??n,catalog:a.a2ui?.catalog,loadingComponent:a.a2ui?.loadingComponent,recovery:a.a2ui?.recovery})),W}),Ee=t.computed(()=>[...m(a.renderActivityMessages),...Te.value]),Ie=W=>{a.defaultThrottleMs!==void 0&&(!Number.isFinite(a.defaultThrottleMs)||a.defaultThrottleMs<0)&&console.error(`CopilotKitProvider: defaultThrottleMs must be a non-negative finite number, got ${a.defaultThrottleMs}. useAgent hooks without an explicit throttleMs will fall back to unthrottled.`),W.setDefaultThrottleMs(a.defaultThrottleMs)};function Ne(W){if(W===!0)return{};if(W===!1||W===void 0)return;const{autoStart:ce,...pe}=W;return pe}const D=t.computed(()=>Ne(a.learning)),$=()=>{const W=new sl({runtimeUrl:S.value,runtimeTransport:a.useSingleEndpoint===!0?"single":a.useSingleEndpoint===!1?"rest":"auto",headers:w.value,credentials:a.credentials,messageFilter:a.messageFilter,properties:V.value,agents__unsafe_dev_only:v.value,tools:L.value,renderToolCalls:z.value,renderActivityMessages:Ee.value,renderCustomMessages:O.value,debug:a.debug,learning:D.value});return Ie(W),W},P=t.shallowRef($()),Y=t.ref(!1),q=t.ref(new Set);t.watch(P,(W,ce,pe)=>{const Je=W.subscribe({onToolExecutionStart:({toolCallId:Ge})=>{q.value=new Set(q.value).add(Ge)},onToolExecutionEnd:({toolCallId:Ge})=>{setTimeout(()=>{const gt=new Set(q.value);gt.delete(Ge),q.value=gt,t.triggerRef(P)},0)}}),He=W.subscribe({onRenderToolCallsChanged:()=>{t.triggerRef(P)}}),we=W.subscribe({onRenderCustomMessagesChanged:()=>{t.triggerRef(P)}}),Me=W.subscribe({onRuntimeConnectionStatusChanged:()=>{N.value=W.a2uiEnabled,K.value=W.openGenerativeUIEnabled,ae.value=W.licenseStatus,H.value=W.runtimeEntitlements,M.value=W.runtimeEntitlementRetryPending,t.triggerRef(P)}}),Oe=W.subscribe({onError:Ge=>{a.onError?.({error:Ge.error,code:Ge.code,context:Ge.context})}}),Ke=W.subscribe({onHeadersChanged:()=>{t.triggerRef(P)}});pe(()=>{Je.unsubscribe(),He.unsubscribe(),we.unsubscribe(),Me.unsubscribe(),Oe.unsubscribe(),Ke.unsubscribe()})},{immediate:!0}),t.watch([L],([W])=>{Y.value&&P.value.setTools(W)}),t.watch([z],([W])=>{Y.value&&P.value.setRenderToolCalls(W)}),t.watch([O],([W])=>{Y.value&&(P.value.setRenderCustomMessages(W),t.triggerRef(P))}),t.watch([Ee],([W])=>{Y.value&&(P.value.setRenderActivityMessages(W),t.triggerRef(P))});let ne=w.value;function Qe(){P.value.setRuntimeUrl(S.value),P.value.setRuntimeTransport(a.useSingleEndpoint===!0?"single":a.useSingleEndpoint===!1?"rest":"auto"),w.value!==ne&&(ne=w.value,P.value.setHeaders(w.value)),P.value.setCredentials(a.credentials),P.value.setMessageFilter(a.messageFilter),P.value.setProperties(V.value),P.value.setAgents__unsafe_dev_only(v.value),P.value.setDebug(a.debug),Ie(P.value)}t.watch([()=>S.value,()=>w.value,()=>a.credentials,()=>a.messageFilter,()=>V.value,()=>v.value,()=>a.useSingleEndpoint,()=>a.debug],()=>{Y.value&&Qe()}),t.watch(()=>a.defaultThrottleMs,()=>{Y.value&&(Ie(P.value),t.triggerRef(P))}),t.onMounted(()=>{Qe(),N.value=P.value.a2uiEnabled,K.value=P.value.openGenerativeUIEnabled,ae.value=P.value.licenseStatus,H.value=P.value.runtimeEntitlements,M.value=P.value.runtimeEntitlementRetryPending,Y.value=!0,We()});const et=t.computed(()=>D.value!==void 0),Z=t.computed(()=>et.value&&(typeof a.learning!="object"||a.learning.autoStart!==!1)),ye=t.computed(()=>Z.value?D.value?.trajectoryId:void 0),Pe=t.computed(()=>Z.value&&ye.value===void 0);function We(){let W=D.value?.learningContainerIds;t.watch([D,Z],([ce,pe])=>{P.value.setLearningConfig(ce),W=ce?.learningContainerIds,ce?.sink===void 0&&!pe&&ce?.learningContainerIds!==void 0&&console.warn("[CopilotKit] learningContainerIds is supported only with a custom sink. Authenticated Trajectory capture ignores it; assign Learning Spaces on the server with getTrajectoryLearningContainerIds on CopilotKitIntelligence, and remove learningContainerIds from the capture options.")},{immediate:!0}),t.watch(()=>!Z.value&&D.value?.trajectoryId!==void 0,ce=>{ce&&console.warn("[CopilotKit] learning.trajectoryId is ignored when autoStart is false; pass the ID to startTrajectory() instead.")},{immediate:!0}),t.watch([et,Pe,ye],([ce,pe,Je],He,we)=>{if(!ce)return;let Me=!1;const Oe=P.value,Ke=pe?Q.randomUUID():Je;Ke!==void 0&&Oe.startTrajectory({trajectoryId:Ke,learningContainerIds:W}).catch(()=>{Me||console.warn("[CopilotKit] Failed to start interaction capture.")}),we(()=>{Me=!0,Oe.stopTrajectory()})},{immediate:!0})}const Ct=t.computed(()=>a.a2ui?.theme),rt=t.computed(()=>a.a2ui?.catalog),Tt=t.computed(()=>a.a2ui?.loadingComponent),Dt=t.computed(()=>a.a2ui?.includeSchema??!0);Eh(P,()=>F.value),qh(P,{enabled:()=>F.value,catalog:()=>a.a2ui?.catalog,includeSchema:()=>a.a2ui?.includeSchema??!0});const Ue=t.ref([]);t.watch([I,oe,()=>a.openGenerativeUI?.designSkill],([W,ce,pe],Je,He)=>{if(!W)return;const we=[];if(we.push(P.value.addContext({description:"Design guidelines for the generateSandboxedUi tool. Follow these when building UI.",value:pe??x.DEFAULT_OPEN_GENERATIVE_UI_DESIGN_SKILL})),ce.length>0){const Me=JSON.stringify(ce.map(Oe=>({name:Oe.name,description:Oe.description,parameters:Q.schemaToJsonSchema(Oe.parameters)})));we.push(P.value.addContext({description:"Sandbox functions available in generated sandboxed UI code. Call via Websandbox.connection.remote.<functionName>(args).",value:Me}))}Ue.value=we,He(()=>{for(const Me of we)P.value.removeContext(Me)})},{immediate:!0}),t.provide(fa,{copilotkit:P,executingToolCallIds:q,a2uiTheme:Ct,a2uiCatalog:rt,a2uiLoadingComponent:Tt,a2uiIncludeSchema:Dt}),t.provide(ol,oe),t.provide(ga,a.markdownRenderer);const Et=t.computed(()=>x.ɵresolveLicenseState({status:ae.value,entitlements:H.value,retryPending:M.value,publicKey:g.value})),Ft=t.computed(()=>Et.value.context);t.provide(va,Ft);const ht=t.computed(()=>Et.value.bannerType);return t.onUnmounted(()=>{P.value.dispose()}),(W,ce)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.renderSlot(W.$slots,"default"),r.value?(t.openBlock(),t.createBlock(nl,{key:0,core:P.value,"open-request":i.value},null,8,["core","open-request"])):t.createCommentVNode("",!0),ht.value?(t.openBlock(),t.createBlock(Qh,{key:1,type:ht.value},null,8,["type"])):t.createCommentVNode("",!0)],64))}});function lg(e,n){const o=Object.keys(e),a=Object.keys(n);if(o.length!==a.length)return!1;for(const r of o)if(e[r]!==n[r])return!1;return!0}function yr(e){return e!==null&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"}function Sl(e){const n=t.shallowRef(t.toValue(e));return t.watch(()=>t.toValue(e),o=>{const a=n.value;a!==o&&(yr(a)&&yr(o)&&lg(a,o)||(n.value=o))},{immediate:!0}),n}const wl="(max-width: 767px)";function kr(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(wl).matches}const ro=t.defineComponent({__name:"CopilotChatConfigurationProvider",props:{labels:{},agentId:{},threadId:{},hasExplicitThreadId:{type:Boolean,default:void 0},isModalDefaultOpen:{type:Boolean,default:void 0}},setup(e){const n=e,o=t.inject(Fo,null),a=t.computed(()=>o?.value??null),r=t.computed(()=>n.threadId!==void 0&&n.hasExplicitThreadId!==!1),s=t.ref(null),i=Sl(t.computed(()=>n.labels)),l=t.computed(()=>({...x.CopilotChatDefaultLabels,...a.value?.labels,...i.value})),c=t.computed(()=>n.agentId??a.value?.agentId??Q.DEFAULT_AGENT_ID),u=Q.randomUUID(),d=t.computed(()=>r.value?n.threadId:s.value?s.value.threadId:n.threadId?n.threadId:a.value?.threadId?a.value.threadId:u),p=t.inject(fa,null);let h=null;t.onMounted(()=>{t.watch(()=>[p?.copilotkit.value,c.value],([M,I],B,F)=>{if(!M)return;const V=M.registerOpenThread({agentId:I,threadId:d.value});h=V,F(()=>{V.unregister(),h=null})},{immediate:!0}),t.watch(d,M=>h?.update(M))});const f=t.computed(()=>r.value?!0:(s.value?s.value.explicit:n.hasExplicitThreadId!==void 0?n.hasExplicitThreadId:!!n.threadId)||!!a.value?.hasExplicitThreadId),m=t.computed(()=>n.isModalDefaultOpen!==void 0),g=t.computed(()=>n.isModalDefaultOpen??!0),v=t.ref(a.value?.isModalOpen??g.value);function y(M){v.value=M}const k=t.computed(()=>m.value?v.value:a.value?.isModalOpen),b=t.computed(()=>m.value?y:a.value?.setModalOpen);function w(M,I){if(r.value){console.warn("[CopilotKit] Ignoring setActiveThreadId(): threadId is controlled via the `threadId` prop on CopilotChatConfigurationProvider.");return}s.value={threadId:M,explicit:I?.explicit??!0}}function S(){if(r.value){console.warn("[CopilotKit] Ignoring startNewThread(): threadId is controlled via the `threadId` prop on CopilotChatConfigurationProvider.");return}s.value={threadId:Q.randomUUID(),explicit:!1}}const C=t.ref(!1),A=t.ref(0);function E(M){C.value=M,M&&kr()&&b.value?.(!1)}function L(){return A.value+=1,()=>{A.value=Math.max(0,A.value-1)}}const z=t.computed(()=>a.value?a.value.drawerOpen:C.value),O=t.computed(()=>a.value?a.value.setDrawerOpen:E),N=t.computed(()=>a.value?a.value.drawerRegistered:A.value>0),K=t.computed(()=>a.value?a.value.registerDrawer:L),ae=t.computed(()=>{const M=b.value;if(M)return I=>{I&&kr()&&O.value?.(!1),M(I)}}),H=t.computed(()=>({labels:l.value,agentId:c.value,threadId:d.value,hasExplicitThreadId:f.value,isModalOpen:k.value,setModalOpen:ae.value,drawerOpen:z.value,setDrawerOpen:O.value,drawerRegistered:N.value,registerDrawer:K.value,setActiveThreadId:w,startNewThread:S}));return t.provide(Fo,H),(M,I)=>t.renderSlot(M.$slots,"default")}});function Sn(){const e=t.inject(va,kl(),!0);return t.computed(()=>e.value)}const Cl=t.defineComponent({name:"A2UIDeferredChild",props:{surface:{type:Object,required:!0},id:{type:String,required:!0},basePath:{type:String,required:!0}},setup(e){const n=t.ref(0),o=e.surface.componentsModel.onCreated.subscribe(s=>{s.id===e.id&&n.value++}),a=e.surface.componentsModel.onDeleted.subscribe(s=>{s===e.id&&n.value++});t.onUnmounted(()=>{o.unsubscribe(),a.unsubscribe()});function r(s,i){const l=i||e.basePath;return t.h(Cl,{key:`${s}-${l}`,surface:e.surface,id:s,basePath:l})}return()=>{n.value;const s=e.surface.componentsModel.get(e.id);if(!s)return t.h("div",{style:{padding:"12px 16px",borderRadius:"8px",background:"linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%)",backgroundSize:"200% 100%",animation:"a2ui-shimmer 1.5s ease-in-out infinite",minHeight:"2rem"},innerHTML:"<style>@keyframes a2ui-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }</style>"});const i=e.surface.catalog.components.get(s.type);if(!i)return t.h("div",{style:{color:"red"}},`Unknown component: ${s.type}`);const l=new qn.ComponentContext(e.surface,e.id,e.basePath);return t.h(i.render,{context:l,buildChild:r})}}}),cg=t.defineComponent({name:"A2uiSurface",props:{surface:{type:Object,required:!0}},setup(e){return()=>t.h(Cl,{surface:e.surface,id:"root",basePath:"/"})}}),ug=["data-activity-type","data-message-id"],dg={key:0,class:"cpk-a2ui-message-error"},pg={key:1,class:"cpk-a2ui-message-surfaces","data-testid":"a2ui-activity-renderer"},fg=["data-surface-id"],mg={class:"a2ui-surface cpk-a2ui-message-surface"},Sr="default",Tl=t.defineComponent({__name:"A2UISurfaceActivityRenderer",props:{activityType:{},content:{},message:{},agent:{},theme:{},catalog:{}},setup(e){const n=e,{copilotkit:o}=Ve(),a=t.shallowRef(null),r=t.ref(0),s=t.ref(null);let i="";function l(){if(!a.value){const h=n.catalog??ao;a.value=new qn.MessageProcessor([h],f=>{c(f)})}return a.value}async function c(h){if(n.agent)try{o.value.setProperties({...o.value.properties,a2uiAction:h}),await o.value.runAgent({agent:n.agent})}finally{const{a2uiAction:f,...m}=o.value.properties??{};o.value.setProperties(m)}}function u(h){if(!h?.length)return;const f=JSON.stringify(h);if(f===i)return;i=f;const m=l();try{const g=new Map;for(const v of h){const y=Lo(v)??Sr;g.has(y)||g.set(y,[]),g.get(y).push(v)}for(const[v,y]of g){const b=m.model.getSurface(v)?y.filter(w=>!w?.createSurface):y;m.processMessages(b)}s.value=null}catch(g){console.warn("[A2UI Vue] processMessages error:",g),s.value=g instanceof Error?g.message:String(g)}r.value++}t.watch(()=>[n.content.operations,n.theme,n.catalog,n.agent],()=>{u(n.content.operations)},{deep:!0,immediate:!0}),t.onBeforeUnmount(()=>{a.value=null,i=""});const d=t.computed(()=>(n.content.operations??[]).length>0),p=t.computed(()=>{if(r.value,!a.value)return[];const h=[],f=new Map;for(const m of n.content.operations??[]){const g=Lo(m)??Sr;f.has(g)||f.set(g,[]),f.get(g).push(m)}for(const[m]of f){const g=a.value.model.getSurface(m);g&&h.push({surfaceId:m,surface:g})}return h});return(h,f)=>d.value?(t.openBlock(),t.createElementBlock("div",{key:0,"data-copilotkit":"","data-activity-type":e.activityType,"data-message-id":e.message.id},[s.value?(t.openBlock(),t.createElementBlock("div",dg," A2UI render error: "+t.toDisplayString(s.value),1)):(t.openBlock(),t.createElementBlock("div",pg,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(p.value,m=>(t.openBlock(),t.createElementBlock("div",{key:m.surfaceId,class:"cpk-a2ui-message-surface-host","data-surface-id":m.surfaceId},[t.createElementVNode("div",mg,[t.createVNode(t.unref(cg),{surface:m.surface},null,8,["surface"])])],8,fg))),128))]))],8,ug)):t.createCommentVNode("",!0)}}),yo={segmenter:!0,enableTables:!0,enableAutolinks:!0};function hg(e){return{segmenter:e?.segmenter??yo.segmenter,enableTables:e?.enableTables??yo.enableTables,enableAutolinks:e?.enableAutolinks??yo.enableAutolinks}}function gg(e,n){const o=(n?"\r":"")+e,a=o.endsWith("\r");return{text:(a?o.slice(0,-1):o).replace(/\r\n?/g,`
|
|
67
|
+
`),pendingCarriageReturn:a}}function vg(e){const n=[];let o=0;for(let a=0;a<e.length;a+=1)e[a]===`
|
|
68
|
+
`&&(n.push({text:e.slice(o,a),start:o,end:a+1,hasNewline:!0}),o=a+1);return(o<e.length||e.length===0)&&n.push({text:e.slice(o),start:o,end:e.length,hasNewline:!1}),n}function bg(e){const n=e.lastIndexOf(`
|
|
69
|
+
`);return n<0?e:e.slice(n+1)}function yg(e,n){let o=1,a=1;for(let r=0;r<n;r+=1)e[r]===`
|
|
70
|
+
`?(o+=1,a=1):a+=1;return{line:o,column:a}}function Yt(e){return/^\s*$/.test(e)}function ba(e){return/^\s{0,3}\[\^([^\]\s]+)\]:\s*(.*)$/.test(e)}function El(e,n,o){return n||o||ba(e)?!1:/^\s{0,3}\[\^[^\]\s]*$/.test(e)||/^\s{0,3}\[\^[^\]\s]+\]$/.test(e)}function Il(e){const n=e.trimStart(),o=/^(`{3,})(.*)$/.exec(n);if(o)return{marker:"```",length:o[1].length,info:o[2].trim()};const a=/^(~{3,})(.*)$/.exec(n);return a?{marker:"~~~",length:a[1].length,info:a[2].trim()}:null}function kg(e,n,o){return(n==="```"?/^\s*`{3,}\s*$/:/^\s*~{3,}\s*$/).test(e)?e.trim().length>=o:!1}function _l(e){const n=/^\s{0,3}(#{1,6})[ \t]+(.+?)\s*#*\s*$/.exec(e);return n?{level:n[1].length,text:n[2],contentOffset:e.indexOf(n[2])}:null}function Sg(e){return/^\s{0,3}(=+|-+)\s*$/.test(e)}function Al(e){return/^\s{0,3}((\*\s*){3,}|(-\s*){3,}|(_\s*){3,})$/.test(e)}function pn(e){const n=/^(\s{0,3})([-+*])(\s+)(.*)$/.exec(e);if(n){const a=n[1].length,r=a+n[2].length+n[3].length;return{ordered:!1,start:1,content:n[4],indent:a,contentIndent:r}}const o=/^(\s{0,3})(\d{1,9})([.)])(\s+)(.*)$/.exec(e);if(o){const a=o[1].length,r=a+(o[2].length+o[3].length)+o[4].length;return{ordered:!0,start:Number(o[2]),content:o[5],indent:a,contentIndent:r}}return null}function ya(e){return/^\s{0,3}>\s?/.test(e)}function $l(e,n){return Rl(e.text)&&wg(n.text)}function Rl(e){return e.includes("|")&&/\S/.test(e.replace(/\|/g,""))}function wg(e){const n=Pn(e);return n.length===0?!1:n.every(o=>/^:?-{3,}:?$/.test(o.trim()))}function Pn(e){const n=e.trim(),o=n.startsWith("|")?n.slice(1):n;return(o.endsWith("|")?o.slice(0,-1):o).split("|").map(a=>a.trim())}function Cg(e){return e.map(n=>{const o=n.trim(),a=o.startsWith(":"),r=o.endsWith(":");return a&&r?"center":a?"left":r?"right":"none"})}function xl(e,n,o){const a=e[n].text;return!!Il(a)||!!_l(a)||Al(a)||!!pn(a)||ya(a)||o&&n+1<e.length&&$l(e[n],e[n+1])}function Tg(e){return/[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/.test(e)}function Gn(e,n,o,a){let r=0;for(let s=n;s<e.length;s+=1){const i=e[s];if(i==="\\"){s+=1;continue}if(i===o){r+=1;continue}if(i===a&&(r-=1,r===0))return s}return-1}function Ol(e){const n=e.trim();if(n.startsWith("<")){const s=n.indexOf(">");if(s>0){const i=n.slice(1,s),l=wr(n.slice(s+1).trim());return l?{url:i,title:l}:{url:i}}}const o=n.search(/\s/);if(o<0)return{url:n};const a=n.slice(0,o),r=wr(n.slice(o).trim());return r?{url:a,title:r}:{url:a}}function wr(e){if(e&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")||e.startsWith("(")&&e.endsWith(")")))return e.slice(1,-1)}function Eg(e){return/^(https?:\/\/|www\.)\S+$/.test(e)}function ko(e){return/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/.test(e)}function Ig(e){let n=e.length;for(;n>0&&/[.,;:!?]/.test(e[n-1]);)n-=1;let o=e.slice(0,n);if(o.endsWith(")")){const a=(o.match(/\(/g)??[]).length;(o.match(/\)/g)??[]).length>a&&(o=o.slice(0,-1))}return o}function _g(e){const n={},o=[],a=e.split(`
|
|
71
|
+
`);let r=0;for(const s of a){const i=/^\s{0,3}\[\^([^\]\s]+)\]:\s*(.*)$/.exec(s);if(!i){r+=s.length+1;continue}const l=i[1];if(n[l]){o.push({code:"invalid_citation_definition",at:r}),r+=s.length+1;continue}const c=$g(i[2].trim());n[l]={id:l,text:c.text,...c.url?{url:c.url}:{}},r+=s.length+1}return{citations:{order:[],numbers:{},definitions:n},warnings:o}}function Ag(e,n){const o=e.numbers[n];if(typeof o=="number")return{citations:e,number:o};const a=e.order.length+1;return{citations:{...e,order:[...e.order,n],numbers:{...e.numbers,[n]:a}},number:a}}function $g(e){if(!e)return{text:""};const n=/(?:\s|^)(https?:\/\/\S+|www\.\S+)$/.exec(e);return n?{text:e.slice(0,n.index).trimEnd(),url:n[1]}:{text:e}}function Rg(e,n,o){if(o.segmenter===!1)return{segments:[],hasWarnedSegmenterUnavailable:o.hasWarnedSegmenterUnavailable};const a=typeof Intl>"u"?void 0:Intl.Segmenter;if(!a)return o.hasWarnedSegmenterUnavailable?{segments:[],hasWarnedSegmenterUnavailable:!0}:{segments:[],warning:{code:"segmenter_unavailable",at:n},hasWarnedSegmenterUnavailable:!0};const r=o.segmenter===!0?"word":o.segmenter.granularity??"word",s=new a(o.segmenter===!0?void 0:o.segmenter.locale,{granularity:r}),i=[];for(const l of s.segment(e)){const c=l.segment,u=n+l.index;i.push({text:c,start:u,end:u+c.length,kind:r,isWhitespace:/^\s+$/.test(c)})}return{segments:xg(i),hasWarnedSegmenterUnavailable:o.hasWarnedSegmenterUnavailable}}function xg(e){const n=e.reduce((r,s)=>{const i=r[r.length-1];return i&&!i.isWhitespace&&Og(s.text)?(r[r.length-1]={...i,text:`${i.text}${s.text}`,end:s.end},r):[...r,s]},[]),o=[];let a=0;for(;a<n.length;){const r=n[a],s=a+1<n.length?n[a+1]:null;if(s&&!s.isWhitespace&&Ng(r.text)){o.push({...s,text:`${r.text}${s.text}`,start:r.start}),a+=2;continue}o.push(r),a+=1}return o}function Og(e){return Nl(e,Mg)}function Ng(e){return Nl(e,Bg)}function Nl(e,n){return e.length>0&&[...e].every(o=>n.has(o))}const Mg=new Set(["]",",",".","!","?",";",":","%",")","}",">",'"',"'","、","。",",",".","!","?",":",";","%",")","]","}","〉","》","」","』","】","〕","〗"]),Bg=new Set(["(","{","[",'"',"'","〈","《","「","『","【","〔","〖","(","[","{"]);function wt(e,n,o,a){const r=[];let s=0,i="",l=-1,c=a.citations,u=a.warnings,d=a.hasWarnedSegmenterUnavailable;const p=()=>{if(i.length===0||l<0)return;const f=zg(r,i,l,o,a.options.segmenter,d);u=f.warnings.length>0?[...u,...f.warnings]:u,d=f.hasWarnedSegmenterUnavailable,i="",l=-1},h=(f,m)=>{f.length!==0&&(i.length===0&&(l=m),i+=f)};for(;s<e.length;){const f=e[s];if(f===`
|
|
72
|
+
`){const C=Dg(e,s-1,"\\")%2===1,A=s>1&&e.slice(s-2,s)===" ",E=C||A;C&&i.endsWith("\\")&&(i=i.slice(0,-1)),p(),r.push({path:`${o}.${r.length}`,type:E?"hard-break":"soft-break",range:{start:n+s,end:n+s+1},closed:!0,props:{},children:[]}),s+=1;continue}if(f==="\\"&&s+1<e.length&&Tg(e[s+1])){h(e[s+1],n+s),s+=2;continue}const m=Ug(e,s,n,o,c,r.length,a.isComplete);if(m){p(),r.push(m.node),s=m.next,c=m.citations;continue}const g=jg(e,s,n,o,r.length);if(g){p(),r.push(g.node),s=g.next;continue}const v=Zg(e,s,n,o,r.length,a,c,u,d);if(v){p(),r.push(v.node),s=v.next,c=v.citations,u=v.warnings,d=v.hasWarnedSegmenterUnavailable;continue}const y=Wg(e,s,n,o,a.options.enableAutolinks,r.length);if(y){p(),r.push(y.node),s=y.next;continue}const k=Hg(e,s,n,o,r.length);if(k){p(),r.push(k.node),s=k.next;continue}const b=rn(e,s,"**","strong",n,o,r.length,a,c,u,d)??rn(e,s,"__","strong",n,o,r.length,a,c,u,d);if(b){p(),r.push(b.node),s=b.next,c=b.citations,u=b.warnings,d=b.hasWarnedSegmenterUnavailable;continue}const w=rn(e,s,"~~","strikethrough",n,o,r.length,a,c,u,d);if(w){p(),r.push(w.node),s=w.next,c=w.citations,u=w.warnings,d=w.hasWarnedSegmenterUnavailable;continue}const S=rn(e,s,"*","em",n,o,r.length,a,c,u,d)??rn(e,s,"_","em",n,o,r.length,a,c,u,d);if(S){p(),r.push(S.node),s=S.next,c=S.citations,u=S.warnings,d=S.hasWarnedSegmenterUnavailable;continue}h(e[s],n+s),s+=1}return p(),{value:Fg(r),citations:c,warnings:u,hasWarnedSegmenterUnavailable:d}}function Dg(e,n,o){let a=0,r=n;for(;r>=0&&e[r]===o;)a+=1,r-=1;return a}function Fg(e){let n=!1;const o=e.map((a,r)=>{if(a.type!=="text")return a;const s=a.props.segments;if(!Array.isArray(s)||s.length===0)return a;const i=s,l=i[0];if(!l)return a;const c=r>0?e[r-1]:null,u=Lg(l.text)&&Pg(c);if(u===(l.noBreakBefore===!0))return a;const d=[u?{...l,noBreakBefore:!0}:{...l,noBreakBefore:void 0},...i.slice(1)];return n=!0,{...a,props:{...a.props,segments:d}}});return n?o:e}function Pg(e){if(!e||e.type==="soft-break"||e.type==="hard-break")return!1;if(e.type==="text"){const n=String(e.props.text??"");if(!n||/\s$/u.test(n))return!1}return!0}function Lg(e){if(!e)return!1;const[n]=[...e];return n!=null&&Vg.has(n)}const Vg=new Set(["]",",",".","!","?",";",":","%",")","}",">",'"',"'","、","。",",",".","!","?",":",";","%",")","]","}","〉","》","」","』","】","〕","〗"]);function zg(e,n,o,a,r,s){if(!n)return{warnings:[],hasWarnedSegmenterUnavailable:s};const i=Rg(n,o,{segmenter:r,hasWarnedSegmenterUnavailable:s});return e.push({path:`${a}.${e.length}`,type:"text",range:{start:o,end:o+n.length},closed:!0,props:{text:n,segments:i.segments},children:[]}),{warnings:i.warning?[i.warning]:[],hasWarnedSegmenterUnavailable:i.hasWarnedSegmenterUnavailable}}function Ug(e,n,o,a,r,s,i){if(!e.startsWith("[^",n))return null;const l=e.indexOf("]",n+2);if(l>=0){const d=e.slice(n+2,l).trim();if(!d)return null;const p=Ag(r,d);return{node:{path:`${a}.${s}`,type:"citation",range:{start:o+n,end:o+l+1},closed:!0,props:{idRef:d,number:p.number},children:[]},next:l+1,citations:p.citations}}if(i)return null;const c=e.slice(n);if(!/^\[\^[^\]\s]+$/u.test(c))return null;const u=c.slice(2);return{node:{path:`${a}.${s}`,type:"citation",range:{start:o+n,end:o+e.length},closed:!1,props:{idRef:u},children:[]},next:e.length,citations:r}}function jg(e,n,o,a,r){if(!e.startsWith("![",n))return null;const s=Gn(e,n+1,"[","]");if(s<0||e[s+1]!=="(")return null;const i=Gn(e,s+1,"(",")");if(i<0)return null;const l=e.slice(n+2,s),c=Ol(e.slice(s+2,i));return{node:{path:`${a}.${r}`,type:"image",range:{start:o+n,end:o+i+1},closed:!0,props:{url:c.url,alt:l,...c.title?{title:c.title}:{}},children:[]},next:i+1}}function Zg(e,n,o,a,r,s,i,l,c){if(e[n]!=="["||e.startsWith("[^",n))return null;const u=Gn(e,n,"[","]");if(u<0||e[u+1]!=="(")return null;const d=Gn(e,u+1,"(",")");if(d<0)return null;const p=e.slice(n+1,u),h=Ol(e.slice(u+2,d)),f=wt(p,o+n+1,`${a}.${r}`,{...s,citations:i,warnings:l,hasWarnedSegmenterUnavailable:c});return{node:{path:`${a}.${r}`,type:"link",range:{start:o+n,end:o+d+1},closed:!0,props:{url:h.url,...h.title?{title:h.title}:{}},children:f.value},next:d+1,citations:f.citations,warnings:f.warnings,hasWarnedSegmenterUnavailable:f.hasWarnedSegmenterUnavailable}}function Wg(e,n,o,a,r,s){if(!r)return null;if(e[n]==="<"){const u=e.indexOf(">",n+1);if(u>n+1){const d=e.slice(n+1,u).trim();if(Eg(d)||ko(d)){const p=ko(d)?`mailto:${d}`:d;return{node:{path:`${a}.${s}`,type:"autolink",range:{start:o+n,end:o+u+1},closed:!0,props:{url:p,text:d},children:[]},next:u+1}}}}if(!(n===0||/\s|[([{"'`]/.test(e[n-1])))return null;const i=/^(https?:\/\/\S+|www\.\S+|[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,})/.exec(e.slice(n));if(!i)return null;const l=Ig(i[1]);if(!l)return null;const c=ko(l)?`mailto:${l}`:l.startsWith("www.")?`https://${l}`:l;return{node:{path:`${a}.${s}`,type:"autolink",range:{start:o+n,end:o+n+l.length},closed:!0,props:{url:c,text:l},children:[]},next:n+l.length}}function Hg(e,n,o,a,r){if(e[n]!=="`")return null;let s=1;for(;e[n+s]==="`";)s+=1;const i="`".repeat(s),l=e.indexOf(i,n+s);return l<0?{node:{path:`${a}.${r}`,type:"inline-code",range:{start:o+n,end:o+e.length},closed:!1,props:{text:e.slice(n+s)},children:[]},next:e.length}:{node:{path:`${a}.${r}`,type:"inline-code",range:{start:o+n,end:o+l+s},closed:!0,props:{text:e.slice(n+s,l)},children:[]},next:l+s}}function rn(e,n,o,a,r,s,i,l,c,u,d){if(!e.startsWith(o,n))return null;const p=e.indexOf(o,n+o.length);if(p<0){const f=wt(e.slice(n+o.length),r+n+o.length,`${s}.${i}`,{...l,citations:c,warnings:u,hasWarnedSegmenterUnavailable:d});return{node:{path:`${s}.${i}`,type:a,range:{start:r+n,end:r+e.length},closed:!1,props:{},children:f.value},next:e.length,citations:f.citations,warnings:f.warnings,hasWarnedSegmenterUnavailable:f.hasWarnedSegmenterUnavailable}}const h=wt(e.slice(n+o.length,p),r+n+o.length,`${s}.${i}`,{...l,citations:c,warnings:u,hasWarnedSegmenterUnavailable:d});return{node:{path:`${s}.${i}`,type:a,range:{start:r+n,end:r+p+o.length},closed:!0,props:{},children:h.value},next:p+o.length,citations:h.citations,warnings:h.warnings,hasWarnedSegmenterUnavailable:h.hasWarnedSegmenterUnavailable}}function Ml(e,n,o,a,r,s){let i={path:a,type:"document",range:{start:n<o?e[n].start:0,end:n<o?e[o-1].end:0},closed:!1,props:{},children:[]},l=n,c=r.citations,u=r.warnings,d=r.hasWarnedSegmenterUnavailable;for(;l<o;){const p=e[l],h=ba(p.text),f=El(p.text,p.hasNewline,r.isComplete);if(Yt(p.text)||h||f){l+=1;continue}const m=Il(p.text);if(m){const b=`${a}.${i.children.length}`,w=Kg(e,l,o,b,r,m);i.children=[...i.children,w.node],l=w.next;continue}if(ya(p.text)){const b=`${a}.${i.children.length}`,w=Gg(e,l,o,b,{...r,citations:c,warnings:u,hasWarnedSegmenterUnavailable:d});i.children=[...i.children,w.value],l=w.next,c=w.citations,u=w.warnings,d=w.hasWarnedSegmenterUnavailable;continue}const g=pn(p.text);if(g){const b=`${a}.${i.children.length}`,w=qg(e,l,o,b,{...r,citations:c,warnings:u,hasWarnedSegmenterUnavailable:d},g.ordered);i.children=[...i.children,w.value],l=w.next,c=w.citations,u=w.warnings,d=w.hasWarnedSegmenterUnavailable;continue}const v=_l(p.text);if(v){const b=`${a}.${i.children.length}`,w=wt(v.text,p.start+v.contentOffset,b,{...r,citations:c,warnings:u,hasWarnedSegmenterUnavailable:d});i.children=[...i.children,{path:b,type:"heading",range:{start:p.start,end:p.end},closed:r.isComplete||p.hasNewline,props:{level:v.level},children:w.value}],c=w.citations,u=w.warnings,d=w.hasWarnedSegmenterUnavailable,l+=1;continue}if(l+1<o&&Sg(e[l+1].text)&&!Yt(p.text)){const b=`${a}.${i.children.length}`,w=e[l+1].text.trim().startsWith("=")?1:2,S=wt(p.text,p.start,b,{...r,citations:c,warnings:u,hasWarnedSegmenterUnavailable:d});i.children=[...i.children,{path:b,type:"heading",range:{start:p.start,end:e[l+1].end},closed:r.isComplete||e[l+1].hasNewline,props:{level:w},children:S.value}],c=S.citations,u=S.warnings,d=S.hasWarnedSegmenterUnavailable,l+=2;continue}if(Al(p.text)){i.children=[...i.children,{path:`${a}.${i.children.length}`,type:"thematic-break",range:{start:p.start,end:p.end},closed:!0,props:{},children:[]}],l+=1;continue}if(r.options.enableTables&&l+1<o&&$l(e[l],e[l+1])){const b=`${a}.${i.children.length}`,w=Jg(e,l,o,b,{...r,citations:c,warnings:u,hasWarnedSegmenterUnavailable:d});i.children=[...i.children,w.value],l=w.next,c=w.citations,u=w.warnings,d=w.hasWarnedSegmenterUnavailable;continue}const y=`${a}.${i.children.length}`,k=Yg(e,l,o,y,{...r,citations:c,warnings:u,hasWarnedSegmenterUnavailable:d});i.children=[...i.children,k.value],l=k.next,c=k.citations,u=k.warnings,d=k.hasWarnedSegmenterUnavailable}return i={...i,closed:!s||r.isComplete||o>n&&e[o-1].hasNewline&&i.children.every(p=>p.closed)},{value:i,citations:c,warnings:u,hasWarnedSegmenterUnavailable:d}}function Kg(e,n,o,a,r,s){let i=n+1,l=-1;for(;i<o;){if(kg(e[i].text,s.marker,s.length)){l=i;break}i+=1}const c=l>=0?l:o-1,u=e.slice(n+1,l>=0?l:o).map(p=>p.text).join(`
|
|
73
|
+
`),d=l>=0||r.isComplete;return{node:{path:a,type:"code-block",range:{start:e[n].start,end:e[c].end},closed:d,props:{fence:s.marker,...s.info?{info:s.info.split(/\s+/)[0]}:{},...s.info.includes(" ")?{meta:s.info.slice(s.info.indexOf(" ")+1)}:{},text:u},children:[]},next:l>=0?l+1:o}}function Gg(e,n,o,a,r){const s=[];let i=n;for(;i<o;){const u=e[i];if(Yt(u.text)&&s.length>0){s.push(u),i+=1;continue}if(ya(u.text)||!Yt(u.text)&&s.length>0&&!xl(e,i,r.options.enableTables)){s.push(u),i+=1;continue}break}const l=s.map(u=>{const d=/^(\s{0,3}>\s?)/.exec(u.text),p=d?.[1].length??0,h=d?u.text.slice(p):u.text,f=u.start+p;return{text:h,start:f,end:f+h.length,hasNewline:u.hasNewline}}),c=Ml(l,0,l.length,a,r,!1);return{value:{path:a,type:"blockquote",range:{start:s[0].start,end:s[s.length-1].end},closed:r.isComplete||s[s.length-1].hasNewline,props:{},children:c.value.children},next:i,citations:c.citations,warnings:c.warnings,hasWarnedSegmenterUnavailable:c.hasWarnedSegmenterUnavailable}}function qg(e,n,o,a,r,s){const i=[];let l=n,c=!1,u=null,d=r.citations,p=r.warnings,h=r.hasWarnedSegmenterUnavailable;for(;l<o;){const f=pn(e[l].text);if(!f||f.ordered!==s)break;s&&u===null&&(u=f.start);const m=[{...e[l],text:f.content}],g=f.contentIndent;l+=1;let v=!1;for(;l<o;){const S=e[l];if(pn(S.text))break;if(Yt(S.text)){if(v=!0,m.push(S),l+=1,l<o&&pn(e[l].text)){c=!0;break}continue}if((/^\s*/.exec(S.text)?.[0].length??0)<g)break;const C=S.text.slice(g);m.push({...S,text:C}),l+=1}const y=m.map(S=>S.text).join(`
|
|
74
|
+
`).trimEnd(),k=`${a}.${i.length}`,b=wt(y,m[0].start,`${k}.0`,{...r,citations:d,warnings:p,hasWarnedSegmenterUnavailable:h}),w={path:`${k}.0`,type:"paragraph",range:{start:m[0].start,end:m[m.length-1].end},closed:r.isComplete||m[m.length-1].hasNewline,props:{},children:b.value};i.push({path:k,type:"list-item",range:{start:m[0].start,end:m[m.length-1].end},closed:r.isComplete||m[m.length-1].hasNewline,props:{},children:[w]}),d=b.citations,p=b.warnings,h=b.hasWarnedSegmenterUnavailable,v&&(c=!0)}return{value:{path:a,type:"list",range:{start:e[n].start,end:e[Math.max(n,l-1)].end},closed:r.isComplete||e[Math.max(n,l-1)].hasNewline,props:{ordered:s,start:s?u??1:null,tight:!c},children:i},next:l,citations:d,warnings:p,hasWarnedSegmenterUnavailable:h}}function Jg(e,n,o,a,r){const s=Pn(e[n].text),i=Cg(Pn(e[n+1].text)),l=[];let c=n+2;for(;c<o&&Rl(e[c].text);)l.push(Pn(e[c].text)),c+=1;let u=r.citations,d=r.warnings,p=r.hasWarnedSegmenterUnavailable;const h=[];for(let g=0;g<s.length;g+=1){const v=wt(s[g],e[n].start,`${a}.0.${g}`,{...r,citations:u,warnings:d,hasWarnedSegmenterUnavailable:p});h.push({path:`${a}.0.${g}`,type:"table-cell",range:{start:e[n].start,end:e[n].end},closed:!0,props:{},children:v.value}),u=v.citations,d=v.warnings,p=v.hasWarnedSegmenterUnavailable}const f={path:`${a}.0`,type:"table-row",range:{start:e[n].start,end:e[n].end},closed:!0,props:{isHeader:!0},children:h},m=[];for(let g=0;g<l.length;g+=1){const v=l[g],y=[];for(let k=0;k<v.length;k+=1){const b=wt(v[k],e[n+2+g].start,`${a}.${g+1}.${k}`,{...r,citations:u,warnings:d,hasWarnedSegmenterUnavailable:p});y.push({path:`${a}.${g+1}.${k}`,type:"table-cell",range:{start:e[n+2+g].start,end:e[n+2+g].end},closed:!0,props:{},children:b.value}),u=b.citations,d=b.warnings,p=b.hasWarnedSegmenterUnavailable}m.push({path:`${a}.${g+1}`,type:"table-row",range:{start:e[n+2+g].start,end:e[n+2+g].end},closed:!0,props:{isHeader:!1},children:y})}return{value:{path:a,type:"table",range:{start:e[n].start,end:e[c-1].end},closed:r.isComplete||e[c-1].hasNewline,props:{align:i},children:[f,...m]},next:c,citations:u,warnings:d,hasWarnedSegmenterUnavailable:p}}function Yg(e,n,o,a,r){const s=[];let i=n;for(;i<o&&!(Yt(e[i].text)||s.length>0&&xl(e,i,r.options.enableTables)||ba(e[i].text)||El(e[i].text,e[i].hasNewline,r.isComplete));)s.push(e[i]),i+=1;const l=wt(s.map(c=>c.text).join(`
|
|
75
|
+
`),s[0].start,a,r);return{value:{path:a,type:"paragraph",range:{start:s[0].start,end:s[s.length-1].end},closed:r.isComplete||s[s.length-1].hasNewline,props:{},children:l.value},next:i,citations:l.citations,warnings:l.warnings,hasWarnedSegmenterUnavailable:l.hasWarnedSegmenterUnavailable}}function Xg(e){const n=[];function o(a,r){const s=a.children.map((i,l)=>`${a.path}.${l}`);n.push({kind:"upsert-node",path:a.path,parentPath:r,type:a.type,range:a.range,closed:a.closed,props:a.props,childPaths:s});for(let i=0;i<a.children.length;i+=1){const l=a.children[i];o({...l,path:`${a.path}.${i}`},a.path)}}return o(e,null),n}function Qg(e){const n=new Map(e.previousNodes.map(d=>[d.id,d])),o=e.ops.filter(d=>d.kind==="upsert-node"),a={};let r=e.nextId;for(const d of o){const p=e.previousPathToId[d.path]??r++;a[d.path]=p}const s=new Map;for(const d of o){const p=a[d.path],h=ev(d,p,d.parentPath?a[d.parentPath]:null,d.childPaths.map(g=>a[g])),f=n.get(p),m=f?.type==="text"&&h.type==="text"?nv(f,h):h;s.set(p,f&&tv(f,m)?f:m)}const i=o[0]?.path;if(!i)throw new Error("StreamingMarkdown op stream did not include a root node");const l=e.ops.find(d=>d.kind==="set-warnings")?.warnings??[],c=e.ops.find(d=>d.kind==="set-citations")?.citations??{order:[],numbers:{},definitions:{}},u=e.ops.find(d=>d.kind==="set-segmenter-warning-state")?.hasWarnedSegmenterUnavailable??!1;return{nodes:Array.from(s.values()).sort((d,p)=>d.id-p.id),rootId:a[i],nextId:r,pathToId:a,warnings:l,citations:c,hasWarnedSegmenterUnavailable:u}}function ev(e,n,o,a){const r={id:n,type:e.type,parentId:o,closed:e.closed,range:e.range};switch(e.type){case"document":return{...r,type:"document",children:a};case"paragraph":return{...r,type:"paragraph",children:a};case"heading":return{...r,type:"heading",level:e.props.level,children:a};case"blockquote":return{...r,type:"blockquote",children:a};case"list":return{...r,type:"list",ordered:e.props.ordered,start:e.props.start,tight:e.props.tight,children:a};case"list-item":return{...r,type:"list-item",children:a};case"code-block":return{...r,type:"code-block",fence:e.props.fence,info:e.props.info,meta:e.props.meta,text:e.props.text};case"table":return{...r,type:"table",align:e.props.align,children:a};case"table-row":return{...r,type:"table-row",isHeader:e.props.isHeader,children:a};case"table-cell":return{...r,type:"table-cell",children:a};case"thematic-break":return{...r,type:"thematic-break"};case"text":return{...r,type:"text",text:e.props.text,segments:e.props.segments};case"em":return{...r,type:"em",children:a};case"strong":return{...r,type:"strong",children:a};case"strikethrough":return{...r,type:"strikethrough",children:a};case"inline-code":return{...r,type:"inline-code",text:e.props.text};case"soft-break":return{...r,type:"soft-break"};case"hard-break":return{...r,type:"hard-break"};case"link":return{...r,type:"link",url:e.props.url,title:e.props.title,children:a};case"image":return{...r,type:"image",url:e.props.url,title:e.props.title,alt:e.props.alt};case"autolink":return{...r,type:"autolink",url:e.props.url,text:e.props.text};default:return{...r,type:"citation",idRef:e.props.idRef,number:e.props.number}}}function tv(e,n){return JSON.stringify(e)===JSON.stringify(n)}function nv(e,n){if(n.segments.length===0||e.segments.length===0)return n;const o=av(e.segments);let a=!1;const r=n.segments.map(s=>{const i=Bl(s),l=o.get(i);if(!l?.length)return s;const[c,...u]=l;return u.length?o.set(i,u):o.delete(i),a=!0,c});return ov(e.segments,r)?{...n,segments:e.segments}:a?{...n,segments:r}:n}function ov(e,n){return e.length!==n.length?!1:e.every((o,a)=>o===n[a])}function Bl(e){return`${e.start}:${e.end}:${e.text}:${e.kind}:${String(e.isWhitespace)}:${String(e.noBreakBefore===!0)}`}function av(e){const n=new Map;for(const o of e){const a=Bl(o),r=n.get(a)??[];n.set(a,[...r,o])}return n}function rv(e){return{nextId:2,nodes:[{id:1,type:"document",parentId:null,closed:!1,range:{start:0,end:0},children:[]}],rootId:1,stack:[1],mode:"block",warnings:[],citations:{order:[],numbers:{},definitions:{}},lineBuffer:"",isComplete:!1,index:0,line:1,column:1,options:hg(e),source:"",pathToId:{0:1},pendingCarriageReturn:!1,hasWarnedSegmenterUnavailable:!1}}function sv(e,n){const o=gg(n,e.pendingCarriageReturn);return Dl(e,{source:e.source+o.text,isComplete:!1,pendingCarriageReturn:o.pendingCarriageReturn})}function iv(e){return e.isComplete?e:Dl(e,{source:e.source+(e.pendingCarriageReturn?`
|
|
76
|
+
`:""),isComplete:!0,pendingCarriageReturn:!1})}function Dl(e,n){const o=_g(n.source),a={options:e.options,warnings:o.warnings,citations:o.citations,isComplete:n.isComplete,hasWarnedSegmenterUnavailable:e.hasWarnedSegmenterUnavailable},r=vg(n.source),s=Ml(r,0,r.length,"0",a,!0),i=[{kind:"set-warnings",warnings:s.warnings},{kind:"set-citations",citations:s.citations},{kind:"set-segmenter-warning-state",hasWarnedSegmenterUnavailable:s.hasWarnedSegmenterUnavailable},...Xg(s.value)],l=Qg({previousNodes:e.nodes,previousPathToId:e.pathToId,nextId:e.nextId,ops:i}),c=bg(n.source),{line:u,column:d}=yg(n.source,n.source.length);return{...e,nextId:l.nextId,nodes:l.nodes,rootId:l.rootId,stack:lv(l.nodes,l.rootId),mode:cv(l.nodes,l.rootId),warnings:l.warnings,citations:l.citations,lineBuffer:c,isComplete:n.isComplete,index:n.source.length,line:u,column:d,source:n.source,pathToId:l.pathToId,pendingCarriageReturn:n.pendingCarriageReturn,hasWarnedSegmenterUnavailable:l.hasWarnedSegmenterUnavailable}}function lv(e,n){const o=new Map(e.map(s=>[s.id,s])),a=[];let r=n;for(;r!=null;){const s=o.get(r);if(!s||s.closed||(a.push(r),!("children"in s)||s.children.length===0))break;const i=s.children[s.children.length-1];r=typeof i=="number"?i:null}return a}function cv(e,n){if(n==null)return"block";const o=e.find(r=>r.id===n);if(!o||!("children"in o)||o.children.length===0)return"block";const a=e.find(r=>r.id===o.children[o.children.length-1]);return!a||a.closed?"block":a.type==="paragraph"?"paragraph":a.type==="heading"?"heading":a.type==="blockquote"?"blockquote":a.type==="list-item"?"list-item":a.type==="code-block"?"code-fence":a.type==="table"?"table":"block"}let Cr=!1;const uv="https://docs.copilotkit.ai/migrate/markdown-renderer#migrate-with-your-ai-assistant",dv=/(^|\n)[ \t]*(```|~~~)[ \t]*[A-Za-z][\w+#-]*/,pv=/\$\$[\s\S]+?\$\$/,fv=/\\\[[\s\S]+?\\\]/;function mv(){return typeof process<"u"&&process.env!=null&&process.env.NODE_ENV==="production"}function hv(e){if(Cr||!e||mv())return;const n=pv.test(e)||fv.test(e),o=dv.test(e);if(!n&&!o)return;Cr=!0;const[a,r]=n?["math","math typesetting"]:["a syntax-highlighted code block","syntax highlighting"];console.warn(`[CopilotKit] The built-in markdown renderer rendered ${a} without ${r}. It supports GFM, tables, autolinks, and citations, but not math, syntax highlighting, or diagrams. To restore those, plug in a custom markdownRenderer (e.g. react-markdown or streamdown) — or paste the migration prompt into your AI assistant: ${uv}`)}const gv=/^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i,vv=/^(https?:|data:image\/(?!svg)|\/|\.\/|\.\.\/)/i;function Tr(e){if(e)return gv.test(e.trim())?e:void 0}function bv(e){if(e)return vv.test(e.trim())?e:void 0}const So={segmenter:!0,enableTables:!0,enableAutolinks:!0};function yv(e){return{segmenter:e?.segmenter??So.segmenter,enableTables:e?.enableTables??So.enableTables,enableAutolinks:e?.enableAutolinks??So.enableAutolinks}}function kv(e,n,o){const a=rv(n),r=e.length>0?sv(a,e):a;return o?iv(r):r}function Sv(e){return e.text.length===0?[]:e.segments.length===0?[t.h("span",{class:"cpk-streaming-markdown-segment"},e.text)]:e.segments.map(n=>t.h("span",{class:"cpk-streaming-markdown-segment","data-streaming-markdown-segment-kind":n.kind,"data-streaming-markdown-whitespace":String(n.isWhitespace)},n.noBreakBefore?`${n.text}`:n.text))}function ot(e,n,o){return e.map(a=>{const r=n.get(a);return r?zo(r,n,o):null})}function zo(e,n,o){function a(r,s){const i=o?.[r];return i?i(e,s):s}switch(e.type){case"document":return t.h("span",{style:"display:contents"},ot(e.children,n,o));case"paragraph":return a("paragraph",t.h("p",{"data-streaming-markdown-node":"paragraph","data-node-open":String(!e.closed)},ot(e.children,n,o)));case"heading":return a("heading",t.h(`h${e.level}`,{"data-streaming-markdown-node":"heading","data-node-open":String(!e.closed)},ot(e.children,n,o)));case"blockquote":return a("blockquote",t.h("blockquote",{"data-streaming-markdown-node":"blockquote","data-node-open":String(!e.closed)},ot(e.children,n,o)));case"list":{const r=e.ordered?"ol":"ul",s={"data-streaming-markdown-node":"list","data-node-open":String(!e.closed),"data-list-tight":String(e.tight)};return e.ordered&&e.start!=null&&(s.start=e.start),a("list",t.h(r,s,ot(e.children,n,o)))}case"list-item":return a("listItem",t.h("li",{"data-streaming-markdown-node":"list-item","data-node-open":String(!e.closed)},ot(e.children,n,o)));case"code-block":return a("codeBlock",t.h("pre",{"data-streaming-markdown-node":"code-block","data-node-open":String(!e.closed)},[t.h("code",{"data-code-info":e.info??void 0},e.text)]));case"table":return a("table",t.h("table",{"data-streaming-markdown-node":"table","data-node-open":String(!e.closed)},[t.h("tbody",ot(e.children,n,o))]));case"table-row":return a("tableRow",t.h("tr",{"data-streaming-markdown-node":"table-row","data-node-open":String(!e.closed)},ot(e.children,n,o)));case"table-cell":{const r=e.parentId!=null?n.get(e.parentId):void 0;return a("tableCell",t.h(r?.type==="table-row"&&r.isHeader?"th":"td",{"data-streaming-markdown-node":"table-cell","data-node-open":String(!e.closed)},ot(e.children,n,o)))}case"thematic-break":return a("thematicBreak",t.h("hr",{"data-streaming-markdown-node":"thematic-break","data-node-open":String(!e.closed)}));case"text":return t.h("span",{style:"display:contents"},Sv(e));case"em":return a("em",t.h("em",{"data-streaming-markdown-node":"em","data-node-open":String(!e.closed)},ot(e.children,n,o)));case"strong":return a("strong",t.h("strong",{"data-streaming-markdown-node":"strong","data-node-open":String(!e.closed)},ot(e.children,n,o)));case"strikethrough":return a("strikethrough",t.h("del",{"data-streaming-markdown-node":"strikethrough","data-node-open":String(!e.closed)},ot(e.children,n,o)));case"inline-code":return a("inlineCode",t.h("code",{"data-streaming-markdown-node":"inline-code","data-node-open":String(!e.closed)},e.text));case"soft-break":return`
|
|
77
|
+
`;case"hard-break":return a("hardBreak",t.h("br",{"data-streaming-markdown-node":"hard-break","data-node-open":String(!e.closed)}));case"link":{const r=Tr(e.url),s={"data-streaming-markdown-node":"link","data-node-open":String(!e.closed),target:"_blank",rel:"noopener noreferrer"};return r!=null&&(s.href=r),e.title&&(s.title=e.title),a("link",t.h("a",s,ot(e.children,n,o)))}case"image":{const r=bv(e.url),s={"data-streaming-markdown-node":"image","data-node-open":String(!e.closed),alt:e.alt};return r!=null&&(s.src=r),e.title&&(s.title=e.title),a("image",t.h("img",s))}case"autolink":{const r=Tr(e.url),s={"data-streaming-markdown-node":"autolink","data-node-open":String(!e.closed),target:"_blank",rel:"noopener noreferrer"};return r!=null&&(s.href=r),a("autolink",t.h("a",s,e.text))}case"citation":return a("citation",t.h("sup",{"data-streaming-markdown-node":"citation","data-node-open":String(!e.closed),class:"cpk-streaming-markdown-citation"},[t.h("span",{role:"doc-noteref",class:"cpk-streaming-markdown-citation-label"},String(e.number??e.idRef))]));default:return null}}const wv=t.defineComponent({name:"StreamingMarkdownRenderer",props:{content:{type:String,required:!0},isComplete:{type:Boolean,default:!1},options:{type:Object,default:void 0},class:{type:String,default:void 0},caret:{type:Boolean,default:!1},nodeRenderers:{type:Object,default:void 0}},setup(e){const n=t.computed(()=>{const a=yv(e.options);return kv(e.content??"",a,e.isComplete)}),o=t.computed(()=>{const a=new Map;for(const r of n.value.nodes)a.set(r.id,r);return a});return()=>{const a=n.value,r=o.value,s=a.rootId!=null?r.get(a.rootId):void 0,i=e.nodeRenderers,l=e.class?`cpk-streaming-markdown-root ${e.class}`:"cpk-streaming-markdown-root";if(!s)return t.h("div",{class:l,"data-streaming-markdown-root":!0});const c=s.type==="document"?s.children.map(u=>{const d=r.get(u);return d?zo(d,r,i):null}):[zo(s,r,i)];return e.caret&&!a.isComplete&&c.push(t.h("span",{"aria-hidden":!0,class:"cpk-streaming-markdown-caret","data-streaming-markdown-caret":!0,style:{display:"inline-block",width:"0.48em",height:"0.48em",marginInlineStart:"0.08em",verticalAlign:"-0.08em",borderRadius:"999px",backgroundColor:"currentColor",opacity:"0.55"}})),t.h("div",{class:l,"data-streaming-markdown-root":!0},c)}}}),ka=t.defineComponent({__name:"StreamingMarkdownDefault",props:{content:{},isStreaming:{type:Boolean,default:!1},nodeRenderers:{},caret:{type:Boolean},options:{},class:{}},setup(e){const n=e,o=t.computed(()=>n.options),a=(s,i)=>s.type!=="code-block"?i:t.h("pre",{"data-streaming-markdown-node":"code-block","data-node-open":String(!s.closed),class:"cpk-markdown-code-block"},[t.h("code",{"data-code-info":s.info??void 0},s.text)]),r=t.computed(()=>({codeBlock:a,...n.nodeRenderers}));return t.watchEffect(()=>hv(n.content)),(s,i)=>(t.openBlock(),t.createBlock(t.unref(wv),{content:n.content,"is-complete":!n.isStreaming,"node-renderers":r.value,caret:n.caret??n.isStreaming,options:o.value,class:t.normalizeClass(n.class)},null,8,["content","is-complete","node-renderers","caret","options","class"]))}});function Cv(e){return Object.keys(e).some(n=>n.startsWith("aria-")||n==="role"||n==="title")}const Fl={size:{type:[Number,String],default:24},color:{type:String,default:"currentColor"},strokeWidth:{type:[Number,String],default:2}},Tv=t.defineComponent({name:"CopilotIcon",props:{name:{type:String,required:!0},...Fl},setup(e,{attrs:n,slots:o}){return()=>{const a=x.ɵcopilotIcons[e.name],r=o.default?.()??[],s=r.length===0&&!Cv(n);return t.h("svg",{...x.ɵcopilotIconSvgAttributes,width:e.size,height:e.size,stroke:e.color,"stroke-width":e.strokeWidth,class:["lucide",`lucide-${a.name}`],"aria-hidden":s?"true":void 0},[...a.nodes.map(i=>t.h(i.tag,i.attributes)),...r])}}});function xe(e){return t.defineComponent({name:`Icon${e}`,props:Fl,setup(n,{slots:o}){return()=>t.h(Tv,{name:e,...n},o)}})}const Pl=xe("ArrowUp"),so=xe("Check"),Ev=xe("ChevronDown"),Iv=xe("ChevronLeft"),tn=xe("ChevronRight"),_v=xe("Circle"),Ll=xe("Copy"),Av=xe("Edit"),$v=xe("EyeOff"),Sa=xe("Loader2"),Rv=xe("MessageCircle"),xv=xe("Mic"),Ov=xe("PanelLeftOpen"),Nv=xe("Play"),Mv=xe("Plus"),Bv=xe("RefreshCw"),Dv=xe("Square"),Fv=xe("ThumbsDown"),Pv=xe("ThumbsUp"),Lv=xe("Upload"),Vv=xe("Volume2"),zv=xe("Wrench"),wn=xe("X");function wa(e,n){return e.find(o=>o.role==="tool"&&o.toolCallId===n)}function Uv(e){return`tool-call-${e}`}function jv(e,n,o){const a=wa(n,e.id),r=Q.partialJSONParse(e.function.arguments);if(a)return{name:e.function.name,args:r,status:x.ToolCallStatus.Complete,result:Nr.contentToText(a.content),toolCall:e,toolMessage:a};const s=o.has(e.id);return{name:e.function.name,args:r,status:s?x.ToolCallStatus.Executing:x.ToolCallStatus.InProgress,result:void 0,toolCall:e,toolMessage:void 0}}function Zv(e,n,o){const a=wa(n,e.id),r=Q.partialJSONParse(e.function.arguments);return a?{name:e.function.name,toolCallId:e.id,args:r,status:x.ToolCallStatus.Complete,result:Nr.contentToText(a.content)}:o.has(e.id)?{name:e.function.name,toolCallId:e.id,args:r,status:x.ToolCallStatus.Executing,result:void 0}:{name:e.function.name,toolCallId:e.id,args:r&&typeof r=="object"?r:{},status:x.ToolCallStatus.InProgress,result:void 0}}function Wv(e,n,o,a,r=Q.DEFAULT_AGENT_ID){return[e.id,e.function.name,e.function.arguments,wa(n,e.id)?.content,o.has(e.id),x.ɵresolveToolCallRenderer(a,e.function.name,r)?.render]}function Hv(e){const n=t.ref(!1);return t.watch(e,(o,a,r)=>{n.value=o.ɵlearningConfigured,r(o.ɵsubscribeToLearningConfigured(()=>{n.value=o.ɵlearningConfigured}))},{immediate:!0}),n}const Kv=t.defineComponent({name:"ToolCallCaptureScope",props:{toolCallId:{type:String,required:!0},enabled:{type:Boolean,required:!0}},setup(e,{slots:n}){return()=>e.enabled?t.h("div",{"data-tool-call-id":e.toolCallId,style:{display:"contents"}},n.default?.()):n.default?.()}}),wo=t.defineComponent({__name:"CopilotChatToolCallItem",props:{toolCall:{},messages:{default:()=>[]}},setup(e){const n=e,{copilotkit:o,executingToolCallIds:a}=Ve(),r=Re(),s=Hv(o);function i(){return jv(n.toolCall,n.messages,a.value)}function l(){return Zv(n.toolCall,n.messages,a.value)}function c(){const d=r.value?.agentId??Q.DEFAULT_AGENT_ID;return x.ɵresolveToolCallRenderer(o.value.renderToolCalls,n.toolCall.function.name,d)}function u(){const d=r.value?.agentId??Q.DEFAULT_AGENT_ID;return Wv(n.toolCall,n.messages,a.value,o.value.renderToolCalls,d)}return(d,p)=>(t.openBlock(),t.createBlock(t.unref(Kv),{"tool-call-id":e.toolCall.id,enabled:t.unref(s)},{default:t.withCtx(()=>[t.renderSlot(d.$slots,t.unref(Uv)(e.toolCall.function.name),t.normalizeProps(t.guardReactiveProps(i())),()=>[t.renderSlot(d.$slots,"tool-call",t.normalizeProps(t.guardReactiveProps(i())),()=>[c()?t.withMemo(u(),()=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(c()?.render),t.normalizeProps(t.mergeProps({key:0},l())),null,16)),p,0):t.createCommentVNode("",!0)])])]),_:3},8,["tool-call-id","enabled"]))}});let Gv=0;function dt(e="cpk"){const n=$c.useId,o=n?.();return o?`${e}-${o}`:`${e}-${++Gv}`}const Ca=Symbol("CopilotChatToolCallDisplay"),Ta=Symbol("CopilotChatToolCallGroup");function Uo(e,n){switch(n){case"running":return e.toolCallStatusRunningLabel;case"done":return e.toolCallStatusDoneLabel;case"failed":return e.toolCallStatusFailedLabel;case"stopped":return e.toolCallStatusStoppedLabel}}const Zt=t.defineComponent({name:"CopilotChatCollapsible",props:{open:{type:Boolean,required:!0},id:{type:String,default:void 0}},setup(e,{slots:n}){const o=t.ref(null),a=()=>o.value?.toggleAttribute("inert",!e.open);return t.onMounted(a),t.watch(()=>e.open,a,{flush:"post"}),()=>t.h("div",{ref:o,id:e.id,class:"cpk-collapsible",style:{gridTemplateRows:e.open?"1fr":"0fr"}},[t.h("div",{class:"cpk-collapsible-content"},n.default?.())])}}),jo=t.defineComponent({name:"ToolCallStatusIcon",props:{status:{type:String,required:!0}},setup(e){return()=>t.h({running:Sa,done:so,failed:wn,stopped:_v}[e.status],{"aria-hidden":"true",class:["cpk-tool-call-status-icon",e.status==="running"&&"cpk-tool-call-status-icon-running",e.status==="failed"&&"cpk-tool-call-status-icon-failed"]})}}),Rn=t.defineComponent({name:"ToolCallChevron",props:{open:{type:Boolean,required:!0}},setup(e){return()=>t.h(tn,{"aria-hidden":"true",class:["cpk-tool-call-chevron",e.open&&"cpk-tool-call-chevron-open"]})}}),xn=t.defineComponent({name:"ToolCallFailedCount",props:{calls:{type:Array,required:!0}},setup(e){const n=mt();return()=>{const o=x.ɵcountFailedToolCalls(e.calls);return o?t.h("span",{class:"cpk-tool-call-failed-count"},x.ɵformatLabel(n.value.toolCallFailedCountLabel,{count:o})):null}}});function Er(e,n){return t.h("div",[t.h("div",{class:"cpk-tool-call-payload-label"},e),t.h("pre",{class:"cpk-tool-call-payload-code"},x.ɵstringifyToolCallPayload(n))])}const qv=t.defineComponent({name:"ToolCallRow",props:{name:{type:String,required:!0},parameters:{type:null,default:void 0},result:{type:null,default:void 0},status:{type:String,required:!0},appearance:{type:String,required:!0}},setup(e){const n=t.ref(!1),o=dt("cpk-tool-call-row"),a=mt();return()=>{const r=x.ɵgetArgumentPreview(e.parameters);return t.h("div",{"data-copilotkit":"",class:["cpk-tool-call-row",`cpk-tool-call-row-${e.appearance}`]},[t.h("button",{type:"button","aria-expanded":n.value?"true":"false","aria-controls":o,onClick:()=>{n.value=!n.value},class:"cpk-tool-call-row-button"},[t.h(jo,{status:e.status}),t.h("span",{"data-testid":"copilot-tool-render-name",class:["cpk-tool-call-row-name",e.status==="running"&&"cpk-shimmer"]},e.name),r?t.h("span",{class:"cpk-tool-call-row-preview"},r):null,t.h("span",{"data-testid":"copilot-tool-render-status",class:"cpk-tool-call-row-status"},Uo(a.value,e.status)),t.h(tn,{"aria-hidden":"true",class:["cpk-tool-call-chevron",n.value&&"cpk-tool-call-chevron-open","cpk-tool-call-row-chevron"]})]),t.h(Zt,{open:n.value,id:o},()=>[t.h("div",{class:"cpk-tool-call-payloads cpk-tool-call-row-payloads"},[Er(a.value.toolCallArgumentsLabel,e.parameters??{}),e.result!==void 0?Er(a.value.toolCallResultLabel,e.result):null])])])}}}),Jv=["data-appearance","data-state"],Yv=["data-appearance","data-state"],Xv=["aria-expanded","aria-controls"],Qv={class:"cpk-tool-call-group-running cpk-shimmer"},eb={key:0,class:"cpk-tool-call-group-preview"},tb={class:"cpk-tool-call-group-line-summary"},nb={class:"cpk-tool-call-group-line-names"},ob={class:"cpk-tool-call-group-line-body"},ab=["data-appearance","data-state"],rb={class:"cpk-tool-call-group-stack-pile"},sb=["aria-expanded","aria-controls"],ib={class:"cpk-tool-call-group-stack-collapse"},lb={key:0,class:"cpk-tool-call-group-stack-preview"},cb={class:"cpk-tool-call-group-stack-status"},ub={class:"cpk-tool-call-group-stack-meta"},db={class:"cpk-tool-call-group-stack-count"},pb={"aria-live":"polite",class:"cpk-tool-call-group-stack-live"},fb=["id"],mb=["data-appearance","data-state"],hb=["aria-expanded","aria-controls"],gb={class:"cpk-tool-call-group-running cpk-shimmer"},vb={key:0,class:"cpk-tool-call-group-preview"},bb={class:"cpk-tool-call-group-card-summary"},yb={class:"cpk-tool-call-group-card-names"},kb={class:"cpk-tool-call-group-card-meta"},Sb={key:1,class:"cpk-tool-call-group-card-status"},Co="cpk-tool-call-group-stack-layer",Vl=t.defineComponent({__name:"CopilotChatToolCallGroup",props:{calls:{},appearance:{default:"card"},isActive:{type:Boolean,default:!1}},setup(e){const n=e,o=mt(),a=t.ref(!1),r=dt("cpk-tool-call-group"),s=()=>{a.value=!a.value},i=t.computed(()=>n.calls[n.calls.length-1]),l=t.computed(()=>n.isActive?n.calls.find(S=>!S.toolMessage)??i.value:void 0),c=t.computed(()=>l.value?x.ɵgetToolCallPreview(l.value):void 0),u=t.computed(()=>n.calls.filter(S=>S.toolMessage).length),d=t.computed(()=>n.calls.map(S=>x.ɵgetToolCallRowStatus(S,n.isActive))),p=t.computed(()=>new Set(n.calls.filter((S,C)=>d.value[C]==="failed").map(S=>S.toolCall.id))),h=t.computed(()=>l.value?"running":p.value.size>0?"failed":d.value.includes("stopped")?"stopped":"done"),f=t.computed(()=>n.appearance==="line"&&n.calls.length===1&&!l.value);t.provide(Ta,t.computed(()=>({appearance:n.appearance,failedIds:p.value,active:n.isActive})));const m=t.computed(()=>a.value?0:Math.min(n.calls.length-1,2)),g=t.computed(()=>i.value?x.ɵgetToolCallRowStatus(i.value,n.isActive):"done"),v=t.computed(()=>i.value?x.ɵgetToolCallPreview(i.value):void 0),y=t.computed(()=>l.value?x.ɵformatLabel(o.value.toolCallRunningLabel,{name:l.value.toolCall.function.name}):""),k=t.computed(()=>x.ɵformatCountLabel(n.calls.length,{one:o.value.toolCallUsedToolsOne,other:o.value.toolCallUsedToolsOther})),b=t.computed(()=>x.ɵformatToolNames(n.calls)),w=t.computed(()=>Uo(o.value,g.value));return(S,C)=>i.value&&f.value?(t.openBlock(),t.createElementBlock("div",{key:0,"data-copilotkit":"","data-testid":"copilot-tool-call-group","data-appearance":e.appearance,"data-state":h.value,class:"cpk-tool-call-group cpk-tool-call-group-line cpk-tool-call-group-single"},[t.renderSlot(S.$slots,"call",{call:i.value})],8,Jv)):i.value&&e.appearance==="line"?(t.openBlock(),t.createElementBlock("div",{key:1,"data-copilotkit":"","data-testid":"copilot-tool-call-group","data-appearance":e.appearance,"data-state":h.value,class:"cpk-tool-call-group cpk-tool-call-group-line"},[t.createElementVNode("button",{type:"button","aria-expanded":a.value?"true":"false","aria-controls":t.unref(r),class:"cpk-tool-call-group-line-toggle",onClick:s},[l.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("span",Qv,t.toDisplayString(y.value),1),c.value?(t.openBlock(),t.createElementBlock("span",eb,t.toDisplayString(c.value),1)):t.createCommentVNode("",!0)],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createElementVNode("span",tb,t.toDisplayString(k.value),1),t.createElementVNode("span",nb,t.toDisplayString(b.value),1),t.createVNode(t.unref(xn),{calls:e.calls},null,8,["calls"])],64)),t.createVNode(t.unref(Rn),{open:a.value},null,8,["open"])],8,Xv),t.createVNode(t.unref(Zt),{id:t.unref(r),open:a.value},{default:t.withCtx(()=>[t.createElementVNode("div",ob,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.calls,A=>t.renderSlot(S.$slots,"call",{key:A.toolCall.id,call:A})),128))])]),_:3},8,["id","open"])],8,Yv)):i.value&&e.appearance==="stack"?(t.openBlock(),t.createElementBlock("div",{key:2,"data-copilotkit":"","data-testid":"copilot-tool-call-group","data-appearance":e.appearance,"data-state":h.value,class:"cpk-tool-call-group cpk-tool-call-group-stack",style:t.normalizeStyle({paddingBottom:`${m.value*6}px`})},[t.createElementVNode("div",rb,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(m.value,A=>(t.openBlock(),t.createElementBlock("div",{key:A,"aria-hidden":"true",class:t.normalizeClass([Co,"cpk-tool-call-group-stack-behind"]),style:t.normalizeStyle({transform:`translateY(${A*6}px) scaleX(${1-A*.045})`,zIndex:-A,opacity:1-A*.28})},null,6))),128)),t.createElementVNode("button",{type:"button","aria-expanded":a.value?"true":"false","aria-controls":a.value?t.unref(r):void 0,class:t.normalizeClass(["cpk-tool-call-group-stack-toggle",a.value?"cpk-tool-call-group-stack-toggle-open":[Co,"cpk-tool-call-group-stack-toggle-closed"]]),onClick:s},[a.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createTextVNode(t.toDisplayString(t.unref(x.ɵformatCountLabel)(e.calls.length,{one:t.unref(o).toolCallToolCallCountOne,other:t.unref(o).toolCallToolCallCountOther}))+" ",1),t.createVNode(t.unref(xn),{calls:e.calls},null,8,["calls"]),t.createElementVNode("span",ib,[t.createTextVNode(t.toDisplayString(t.unref(o).toolCallCollapseLabel)+" ",1),t.createVNode(t.unref(Rn),{open:!0,class:"cpk-tool-call-group-stack-collapse-icon"})])],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[(t.openBlock(),t.createElementBlock("span",{key:i.value.toolCall.id,class:"cpk-tool-call-group-stack-latest"},[t.createVNode(t.unref(jo),{status:g.value},null,8,["status"]),t.createElementVNode("span",{class:t.normalizeClass(["cpk-tool-call-group-stack-name",g.value==="running"&&"cpk-shimmer"])},t.toDisplayString(i.value.toolCall.function.name),3),v.value?(t.openBlock(),t.createElementBlock("span",lb,t.toDisplayString(v.value),1)):t.createCommentVNode("",!0),t.createElementVNode("span",cb,t.toDisplayString(w.value),1)])),t.createElementVNode("span",ub,[t.createVNode(t.unref(xn),{calls:e.calls},null,8,["calls"]),t.createElementVNode("span",db,t.toDisplayString(t.unref(x.ɵformatCountLabel)(e.calls.length,{one:t.unref(o).toolCallCallCountOne,other:t.unref(o).toolCallCallCountOther})),1),t.createVNode(t.unref(Rn),{open:!1,class:"cpk-tool-call-group-stack-expand-icon"})])],64))],10,sb),t.createElementVNode("span",pb,t.toDisplayString(a.value?"":`${i.value.toolCall.function.name}: ${w.value}`),1)]),a.value?(t.openBlock(),t.createElementBlock("div",{key:0,id:t.unref(r),class:"cpk-tool-call-group-stack-items"},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.calls,(A,E)=>(t.openBlock(),t.createElementBlock("div",{key:A.toolCall.id,class:t.normalizeClass([Co,"cpk-tool-call-group-stack-item"]),style:t.normalizeStyle({animationDelay:`${E*30}ms`})},[t.renderSlot(S.$slots,"call",{call:A})],6))),128))],8,fb)):t.createCommentVNode("",!0)],12,ab)):i.value?(t.openBlock(),t.createElementBlock("div",{key:3,"data-copilotkit":"","data-testid":"copilot-tool-call-group","data-appearance":e.appearance,"data-state":h.value,class:"cpk-tool-call-group cpk-tool-call-group-card"},[t.createElementVNode("button",{type:"button","aria-expanded":a.value?"true":"false","aria-controls":t.unref(r),class:"cpk-tool-call-group-card-toggle",onClick:s},[t.createVNode(t.unref(jo),{status:h.value},null,8,["status"]),l.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("span",gb,t.toDisplayString(y.value),1),c.value?(t.openBlock(),t.createElementBlock("span",vb,t.toDisplayString(c.value),1)):t.createCommentVNode("",!0)],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createElementVNode("span",bb,t.toDisplayString(k.value),1),t.createElementVNode("span",yb,t.toDisplayString(b.value),1)],64)),t.createElementVNode("span",kb,[h.value==="failed"?(t.openBlock(),t.createBlock(t.unref(xn),{key:0,calls:e.calls},null,8,["calls"])):(t.openBlock(),t.createElementBlock("span",Sb,t.toDisplayString(h.value!=="running"?t.unref(Uo)(t.unref(o),h.value):u.value>0?t.unref(x.ɵformatLabel)(t.unref(o).toolCallDoneCountLabel,{count:u.value}):""),1)),t.createVNode(t.unref(Rn),{open:a.value},null,8,["open"])])],8,hb),t.createVNode(t.unref(Zt),{id:t.unref(r),open:a.value},{default:t.withCtx(()=>[t.createElementVNode("div",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.calls,A=>t.renderSlot(S.$slots,"call",{key:A.toolCall.id,call:A})),128))])]),_:3},8,["id","open"])],8,mb)):t.createCommentVNode("",!0)}}),wb={class:"cpk-tool-calls-view-turn-rows"},zl=t.defineComponent({__name:"CopilotChatToolCallsView",props:{message:{},messages:{default:()=>[]},display:{default:void 0}},setup(e){const n=e,o={grouped:"card",line:"line",stacked:"stack"},a=t.useSlots(),{copilotkit:r}=Ve(),s=t.inject(Ca,null);function i(){return Object.keys(a).filter(m=>m==="tool-call"||m.startsWith("tool-call-"))}const l=t.computed(()=>n.display??s?.value.display??"grouped"),c=t.computed(()=>{if(l.value==="separate")return;const m=s?.value.layouts.get(n.message.id);if(m)return m;const g=x.ɵgetToolCallRendererNames(r.value.renderToolCalls,{slotNames:i()});return x.ɵgetToolCallLayouts([n.message],n.messages,g).get(n.message.id)}),u=m=>m&&(s?s.value.isRunning:!0),d=t.computed(()=>o[l.value]??"card"),p=t.computed(()=>s?.value.workOpen.get(n.message.id)),h=t.defineComponent({props:{calls:{type:Array,required:!0},active:{type:Boolean,required:!0}},setup(m,{slots:g}){return t.provide(Ta,t.computed(()=>({appearance:"line",failedIds:new Set(m.calls.filter(v=>v.toolMessage?.error).map(v=>v.toolCall.id)),active:m.active}))),()=>g.default?.()}});function f(m){const g={};for(const v of i())g[v]=a[v];return t.h(wo,{key:m.toolCall.id,toolCall:m.toolCall,messages:n.messages},g)}return(m,g)=>c.value?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(c.value.segments,v=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:v.id},[v.kind==="call"?(t.openBlock(),t.createBlock(wo,{key:0,"tool-call":v.call.toolCall,messages:e.messages},t.createSlots({_:2},[t.renderList(i(),y=>({name:y,fn:t.withCtx(k=>[t.renderSlot(m.$slots,y,t.mergeProps({ref_for:!0},k??{}))])}))]),1032,["tool-call","messages"])):l.value==="turn"?(t.openBlock(),t.createBlock(t.unref(Zt),{key:1,open:p.value??!0,class:"cpk-tool-calls-view-turn"},{default:t.withCtx(()=>[t.createElementVNode("div",wb,[t.createVNode(t.unref(h),{calls:v.calls,active:u(v.trailing)},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(v.calls,y=>(t.openBlock(),t.createBlock(t.resolveDynamicComponent(f(y)),{key:y.toolCall.id}))),128))]),_:2},1032,["calls","active"])])]),_:2},1032,["open"])):t.renderSlot(m.$slots,"tool-calls-group",{key:2,calls:v.calls,appearance:d.value,isActive:u(v.trailing),renderCall:f},()=>[t.createVNode(Vl,{calls:v.calls,appearance:d.value,"is-active":u(v.trailing)},{call:t.withCtx(({call:y})=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(f(y))))]),_:1},8,["calls","appearance","is-active"])])],64))),128)):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:0},t.renderList(e.message.toolCalls??[],v=>(t.openBlock(),t.createBlock(wo,{key:v.id,"tool-call":v,messages:e.messages},t.createSlots({_:2},[t.renderList(i(),y=>({name:y,fn:t.withCtx(k=>[t.renderSlot(m.$slots,y,t.mergeProps({ref_for:!0},k??{}))])}))]),1032,["tool-call","messages"]))),128))}}),Ul=(e,{slots:n})=>e.open===void 0?n.default?.():t.h(Zt,{open:e.open},n);Ul.props=["open"];const Cb=t.defineComponent({name:"CopilotChatWorkText",props:{messageId:{type:String,required:!0}},setup(e,{slots:n}){const o=t.inject(Ca,null);return()=>{if(o?.value.display!=="turn")return n.default?.();const a=o.value.workTextOpen.get(e.messageId);return t.h(Zt,{open:a??!0,class:"cpk-assistant-message-work-text"},()=>[t.h("div",{class:"cpk-assistant-message-work-text-content","data-work-text":a===void 0?"reply":"narration"},n.default?.())])}}}),jl={top:"bottom",bottom:"top",left:"right",right:"left"},On=(e,n,o)=>Math.min(Math.max(e,n),Math.max(n,o));function Tb(e,n,o,a={}){const{side:r="bottom",align:s="center",sideOffset:i=0,alignOffset:l=0,collisionPadding:c=0,arrowSize:u=0}=a,d=i+u,p=S=>({top:e.top,bottom:o.height-e.bottom,left:e.left,right:o.width-e.right})[S]-d-c,h=S=>S==="top"||S==="bottom"?n.height:n.width;let f=r;const m=jl[r];p(f)<h(f)&&p(m)>=h(m)&&p(m)>p(f)&&(f=m);const g=f==="top"||f==="bottom";let v,y;g?(y=f==="top"?e.top-n.height-d:e.bottom+d,v=s==="start"?e.left+l:s==="end"?e.right-n.width-l:e.left+e.width/2-n.width/2,v=On(v,c,o.width-n.width-c)):(v=f==="left"?e.left-n.width-d:e.right+d,y=s==="start"?e.top+l:s==="end"?e.bottom-n.height-l:e.top+e.height/2-n.height/2,y=On(y,c,o.height-n.height-c));const k=g?On(e.left+e.width/2-v,0,n.width):void 0,b=g?void 0:On(e.top+e.height/2-y,0,n.height),w=g?`${k}px ${f==="top"?`${n.height+u}px`:`${-u}px`}`:`${f==="left"?`${n.width+u}px`:`${-u}px`} ${b}px`;return{x:v,y,side:f,align:s,availableWidth:g?o.width-2*c:Math.max(0,p(f)),availableHeight:g?Math.max(0,p(f)):o.height-2*c,arrowX:k,arrowY:b,transformOrigin:w}}function Eb(e){const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView;if(!o)return!1;let a=0,r=0,s=o.innerHeight,i=o.innerWidth;for(let l=e.parentElement;l;l=l.parentElement){const{overflowX:c,overflowY:u}=o.getComputedStyle(l);if(c==="visible"&&u==="visible")continue;const d=l.getBoundingClientRect();a=Math.max(a,d.top),r=Math.max(r,d.left),s=Math.min(s,d.bottom),i=Math.min(i,d.right)}return n.bottom<a||n.top>s||n.right<r||n.left>i}function Ea(e,n,o,a){const r=t.ref(null),s=t.ref(!1);let i;const l=()=>{const d=e.value,p=n.value;if(!d||!p)return;const h=p.ownerDocument.defaultView;if(!h)return;const f=a();r.value=Tb(d.getBoundingClientRect(),{width:p.offsetWidth,height:p.offsetHeight},{width:h.innerWidth,height:h.innerHeight},f),s.value=!!f.hideWhenDetached&&(!d.isConnected||Eb(d))},c=()=>{i?.(),i=void 0};return t.watch([o,e,n],([d,p,h])=>{if(c(),!d||!p||!h){d||(r.value=null);return}l();const f=h.ownerDocument.defaultView;if(!f)return;let m=0;const g=()=>{m||(m=f.requestAnimationFrame(()=>{m=0,l()}))};f.addEventListener("scroll",g,{capture:!0,passive:!0}),f.addEventListener("resize",g);const v=typeof ResizeObserver>"u"?void 0:new ResizeObserver(g);v?.observe(p),v?.observe(h),i=()=>{m&&f.cancelAnimationFrame(m),f.removeEventListener("scroll",g,{capture:!0}),f.removeEventListener("resize",g),v?.disconnect()}},{flush:"post",immediate:!0}),t.onBeforeUnmount(c),{placement:r,referenceHidden:s,update:l,wrapperStyle:d=>{const p=r.value;return{position:"fixed",left:"0px",top:"0px",minWidth:"max-content",zIndex:d??50,transform:p?`translate(${Math.round(p.x)}px, ${Math.round(p.y)}px)`:"translate(0, -200%)",visibility:s.value?"hidden":void 0,pointerEvents:s.value?"none":void 0}}}}function Ib(e){if(!e)return{position:"absolute",visibility:"hidden"};const{side:n,arrowX:o,arrowY:a}=e;return{position:"absolute",left:o!==void 0?`${o}px`:void 0,top:a!==void 0?`${a}px`:void 0,[jl[n]]:"0px",transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[n],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[n],marginLeft:o!==void 0?"-5px":void 0}}function Ia(e,n){const o=t.ref(e.value);let a;const r=()=>{a?.(),a=void 0};return t.watch(e,async s=>{if(r(),s){o.value=!0;return}if(await t.nextTick(),e.value)return;const i=n.value,l=i?.ownerDocument.defaultView,c=i&&l?.getComputedStyle(i).animationName;if(!i||!l||!c||c==="none"){o.value=!1;return}const u=()=>{r(),e.value||(o.value=!1)},d=l.setTimeout(u,400);i.addEventListener("animationend",u,{once:!0}),a=()=>{l.clearTimeout(d),i.removeEventListener("animationend",u)}}),t.onBeforeUnmount(r),o}const _b=["id","data-state","data-side","data-align"],Ab={class:"cpk-tooltip-arrow",width:"10",height:"5",viewBox:"0 0 30 10",preserveAspectRatio:"none","aria-hidden":"true",style:{display:"block"}},$b=10,Rb=100,Rt=t.defineComponent({__name:"CopilotTooltip",props:{content:{default:void 0},side:{default:"top"},align:{default:"center"},sideOffset:{default:0},delayDuration:{default:0},suppressed:{type:Boolean,default:!1},contentClass:{default:void 0}},setup(e){const n=e,o=dt("cpk-tooltip"),a=t.ref(!1),r=t.computed(()=>a.value&&!n.suppressed),s=t.ref(null),i=t.ref(null),l=t.ref(null),c=Ia(r,l),{placement:u,wrapperStyle:d}=Ea(s,i,r,()=>({side:n.side,align:n.align,sideOffset:n.sideOffset,arrowSize:$b}));let p,h,f=!1,m=!1;const g=()=>{clearTimeout(p),clearTimeout(h),p=void 0,h=void 0},v=()=>{g(),n.suppressed||(a.value=!0)},y=()=>{g(),a.value=!1};t.watch(()=>n.suppressed,N=>{N&&y()});const k=N=>{N.pointerType!=="touch"&&(s.value=N.currentTarget,clearTimeout(h),h=void 0,!(m||f)&&(m=!0,n.delayDuration>0?p=setTimeout(v,n.delayDuration):v()))},b=()=>{clearTimeout(p),p=void 0,clearTimeout(h),h=setTimeout(y,Rb)},w=N=>{if(N.pointerType==="touch")return;m=!1;const K=N.relatedTarget;K instanceof Node&&l.value?.contains(K)||b()},S=()=>{f=!1},C=()=>{f=!0,document.addEventListener("pointerup",S,{once:!0}),y()},A=N=>{s.value=N.currentTarget,f||v()},E=t.computed(()=>({"data-state":r.value?"delayed-open":"closed","aria-describedby":r.value?o:void 0,onPointermove:k,onPointerleave:w,onPointerdown:C,onFocus:A,onBlur:y,onClick:y})),L=N=>{N.key==="Escape"&&y()},z=N=>{const K=N.target;K instanceof Node&&K.contains(s.value)&&y()};t.watch(r,N=>{typeof document>"u"||(N?(document.addEventListener("keydown",L),window.addEventListener("scroll",z,{capture:!0})):(document.removeEventListener("keydown",L),window.removeEventListener("scroll",z,{capture:!0})))},{immediate:!0}),t.onBeforeUnmount(()=>{g(),!(typeof document>"u")&&(document.removeEventListener("keydown",L),document.removeEventListener("pointerup",S),window.removeEventListener("scroll",z,{capture:!0}))});const O=t.computed(()=>({"--radix-tooltip-content-transform-origin":u.value?.transformOrigin??"center"}));return(N,K)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.renderSlot(N.$slots,"default",{triggerProps:E.value,open:r.value}),(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.unref(c)?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"wrapper",ref:i,"data-radix-popper-content-wrapper":"",style:t.normalizeStyle(t.unref(d)())},[t.createElementVNode("div",{id:t.unref(o),ref_key:"contentElement",ref:l,"data-copilotkit":"","data-slot":"tooltip-content",role:"tooltip",class:t.normalizeClass(["cpk-tooltip",e.contentClass]),"data-state":r.value?"delayed-open":"closed","data-side":t.unref(u)?.side??e.side,"data-align":t.unref(u)?.align??e.align,style:t.normalizeStyle(O.value),onPointerenter:g,onPointerleave:b},[t.renderSlot(N.$slots,"content",{},()=>[t.createElementVNode("p",null,t.toDisplayString(e.content),1)]),t.createElementVNode("span",{style:t.normalizeStyle(t.unref(Ib)(t.unref(u)))},[(t.openBlock(),t.createElementBlock("svg",Ab,[...K[0]||(K[0]=[t.createElementVNode("polygon",{points:"0,0 30,0 15,10"},null,-1)])]))],4)],46,_b)],4)):t.createCommentVNode("",!0)]))],64))}}),xb=["aria-label"],Ob="cpk-button cpk-button-assistant-message-toolbar cpk-button-size-default",sn=t.defineComponent({inheritAttrs:!1,__name:"CopilotChatAssistantToolbarButton",props:{label:{}},setup(e){const n=t.useAttrs(),o=t.computed(()=>n["aria-expanded"]===!0||n["aria-expanded"]==="true");return(a,r)=>(t.openBlock(),t.createBlock(Rt,{content:e.label,side:"bottom",suppressed:o.value},t.createSlots({default:t.withCtx(({triggerProps:s})=>[t.createElementVNode("button",t.mergeProps({type:"button",class:Ob,"aria-label":e.label},t.mergeProps(s,a.$attrs)),[t.renderSlot(a.$slots,"default")],16,xb)]),_:2},[a.$slots.tooltip?{name:"content",fn:t.withCtx(()=>[t.renderSlot(a.$slots,"tooltip")]),key:"0"}:void 0]),1032,["content","suppressed"]))}}),Nb="message.feedback",Zl=1e3,Mb=500,Zo=new Map,Ln=new Map,Wl=(e,n)=>JSON.stringify([e,n]),Hl=(e,n,o)=>JSON.stringify([e,n,o]),Kl=(e,n)=>{const o=Array.from(e);return o.length>n?o.slice(0,n).join(""):e},Bb=e=>{if(typeof e!="string")return;const n=Kl(e.trim(),Zl);return n===""?void 0:n};function Db(e,n,o){return Zo.get(Hl(e,n,o))}function Fb(e,n,o){const a=Wl(e,n);let r=Ln.get(a);return r===void 0&&(r=new Set,Ln.set(a,r)),r.add(o),()=>{r.delete(o),r.size===0&&Ln.delete(a)}}function Pb(e){const{copilotkit:n,agentId:o,threadId:a,message:r}=e,s=Bb(e.feedback?.comment),i=e.feedback&&{rating:e.feedback.rating,...s?{comment:s}:{}},l=Hl(o,a,r.id);i?Zo.set(l,i):Zo.delete(l);for(const u of Ln.get(Wl(o,a))??[])u();const c=n.getRunIdForMessage(o,a,r.id);n.emitTrajectoryEvent(Nb,{feedbackId:`${a}:${r.id}`,threadId:a,messageId:r.id,agentId:o,...c?{runId:c}:{},rating:i?.rating??null,...i?.comment?{comment:i.comment}:{},...n.ɵlearningCapturesAgentText?{response:Kl(r.content??"",Mb)}:{}})}const Lb=["id","data-state","data-side","data-align"],Vb=t.defineComponent({inheritAttrs:!1,__name:"CopilotPopover",props:{open:{type:Boolean},anchor:{},side:{default:"bottom"},align:{default:"start"},sideOffset:{default:6},collisionPadding:{default:0},hideWhenDetached:{type:Boolean,default:!1}},emits:["escape-key-down","interact-outside","dismiss"],setup(e,{expose:n,emit:o}){const a=e,r=o,s=dt("cpk-popover"),i=t.ref(null),l=t.ref(null),c=t.toRef(a,"open"),u=t.toRef(a,"anchor"),d=Ia(c,l),{placement:p,wrapperStyle:h}=Ea(u,i,c,()=>({side:a.side,align:a.align,sideOffset:a.sideOffset,collisionPadding:a.collisionPadding,hideWhenDetached:a.hideWhenDetached})),f=k=>k instanceof Node&&!!l.value?.contains(k),m=k=>{k.key==="Escape"&&(r("escape-key-down",k),k.defaultPrevented||r("dismiss"))},g=k=>{f(k.target)||(r("interact-outside",k),k.defaultPrevented||r("dismiss"))},v=k=>{typeof document>"u"||(k?(document.addEventListener("keydown",m,{capture:!0}),document.addEventListener("pointerdown",g,{capture:!0}),document.addEventListener("focusin",g,{capture:!0})):(document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("focusin",g,{capture:!0})))};t.watch(c,k=>v(k),{immediate:!0}),t.onBeforeUnmount(()=>v(!1));const y=t.computed(()=>({"--radix-popover-content-transform-origin":p.value?.transformOrigin??"center","--radix-popover-content-available-height":p.value?`${p.value.availableHeight}px`:void 0}));return n({content:l}),(k,b)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.unref(d)?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"wrapper",ref:i,"data-radix-popper-content-wrapper":"",style:t.normalizeStyle(t.unref(h)())},[t.createElementVNode("div",t.mergeProps({id:t.unref(s),ref_key:"content",ref:l,role:"dialog",tabindex:"-1","data-copilotkit":"","data-copilotkit-popover":"","data-slot":"popover-content",class:"cpk-popover","data-state":c.value?"open":"closed","data-side":t.unref(p)?.side??e.side,"data-align":t.unref(p)?.align??e.align,style:y.value},k.$attrs),[t.renderSlot(k.$slots,"default")],16,Lb)],4)):t.createCommentVNode("",!0)]))}}),zb=["value","maxlength","placeholder","aria-label"],Ub=["aria-label","title"],jb=t.defineComponent({__name:"CopilotChatFeedbackCommentPopover",props:{comment:{},savedComment:{},rating:{},anchor:{},messageId:{}},setup(e){const n=e,o=Re(),a=t.computed(()=>o.value?.labels??x.CopilotChatDefaultLabels),r=t.ref(null),s=()=>r.value?.content??null,i=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","[tabindex]"].map(S=>`${S}:not([tabindex="-1"])`).join(", ");function l(S,C){const A=Array.from(S.ownerDocument.querySelectorAll(i)).filter(L=>L===S||!C?.contains(L)&&!L.closest("[hidden], [inert]")),E=A.indexOf(S);return E===-1?null:A[E+1]??null}const c=()=>s()?.contains(document.activeElement)??!1,u=S=>(S instanceof Element?S.closest("[data-copilotkit-rating]"):null)?.closest("[data-message-id]")?.getAttribute("data-message-id")===n.messageId,d=()=>{const S=n.comment.input.value;S&&n.comment.takeFocusRequest()&&S.focus()};t.watch(()=>[n.comment.focusRequest.value,n.comment.open.value],async()=>{await t.nextTick(),d()},{flush:"post",immediate:!0});const p=S=>{n.comment.input.value=S instanceof HTMLInputElement?S:null},h=t.computed(()=>n.comment.draft.value.trim()!==n.savedComment);function f(S){const C=c();C&&S.stopPropagation(),S.preventDefault(),n.comment.close({save:!1}),C&&n.comment.returnFocus(n.anchor)}function m(S){u(S.target)&&S.preventDefault()}function g(S){if(S.key!=="Tab")return;const C=Array.from(s()?.querySelectorAll(i)??[]),A=S.shiftKey?document.activeElement===C[0]:document.activeElement===C[C.length-1],E=n.anchor;if(!A||!E?.isConnected)return;S.preventDefault();const L=S.shiftKey?E:l(E,s())??E;n.comment.close(),L===E?n.comment.returnFocus(L):L.focus()}function v(){n.comment.close(),n.comment.returnFocus(n.anchor)}function y(S){n.comment.setEditing(S)}function k(S){S&&(s()?.contains(S)||u(S))||n.comment.leave()}function b(S){const C=S.currentTarget,A=S.relatedTarget instanceof Element?S.relatedTarget:null;C.contains(A)||typeof document<"u"&&!document.hasFocus()||(y(!1),k(A))}const w=t.computed(()=>({value:n.comment.draft.value,savedComment:n.savedComment,inputRef:p,onChange:S=>{n.comment.draft.value=S},onSubmit:v,onEditingChange:y,onLeave:k}));return(S,C)=>(t.openBlock(),t.createBlock(Vb,{ref_key:"popover",ref:r,open:e.comment.open.value,anchor:e.anchor,side:"bottom","collision-padding":8,"hide-when-detached":"","aria-label":a.value.assistantMessageFeedbackCommentPlaceholder,"data-copilotkit-ignore":"",class:"cpk-assistant-message-feedback-popover",onDismiss:C[2]||(C[2]=A=>e.comment.close()),onEscapeKeyDown:f,onInteractOutside:m,onKeydown:g,onPointerenter:C[3]||(C[3]=A=>e.comment.enter("pointer")),onPointerleave:C[4]||(C[4]=A=>e.comment.leave("pointer"))},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList([e.rating],A=>t.renderSlot(S.$slots,"feedback-comment",t.mergeProps({key:A,ref_for:!0},w.value),()=>[t.createElementVNode("form",{"data-testid":"copilot-feedback-comment",class:"cpk-assistant-message-feedback-comment",onSubmit:t.withModifiers(v,["prevent"]),onFocusin:C[1]||(C[1]=E=>y(!0)),onFocusout:b},[t.createElementVNode("input",{ref_for:!0,ref:p,value:e.comment.draft.value,maxlength:t.unref(Zl),placeholder:a.value.assistantMessageFeedbackCommentPlaceholder,"aria-label":a.value.assistantMessageFeedbackCommentPlaceholder,class:"cpk-assistant-message-feedback-comment-input",onInput:C[0]||(C[0]=E=>e.comment.draft.value=E.target.value)},null,40,zb),h.value?(t.openBlock(),t.createElementBlock("button",{key:0,type:"submit",class:"cpk-button cpk-button-assistant-message-toolbar cpk-button-size-default","aria-label":a.value.assistantMessageFeedbackCommentSubmitLabel,title:a.value.assistantMessageFeedbackCommentSubmitLabel},[t.createVNode(t.unref(Pl),{class:"cpk-assistant-message-feedback-comment-submit-icon"})],8,Ub)):t.createCommentVNode("",!0)],32)])),128))]),_:3},8,["open","anchor","aria-label"]))}}),Zb=["id","data-cpk-menu","data-slot","aria-labelledby","data-state","data-side","data-align"],Wb={key:0,role:"separator","aria-orientation":"horizontal","data-slot":"dropdown-menu-separator",class:"cpk-dropdown-menu-separator"},Hb=["id","aria-expanded","aria-controls","data-state","data-highlighted","onFocus","onPointermove","onPointerleave","onClick"],Kb=["data-highlighted","onFocus","onPointermove","onPointerleave","onClick"],Gb=100,qb=300,Jb=1e3,Gl=t.defineComponent({name:"CopilotDropdownMenuContent",inheritAttrs:!1,__name:"CopilotDropdownMenuContent",props:{open:{type:Boolean},anchor:{},items:{},menuId:{},id:{default:void 0},labelledBy:{default:void 0},side:{default:"bottom"},align:{default:"start"},sideOffset:{default:4},initialFocus:{default:"content"},sub:{type:Boolean,default:!1}},emits:["select","dismiss","close-sub","pointer-enter","pointer-leave"],setup(e,{emit:n}){const o=e,a=n,r=dt("cpk-menu"),s=t.computed(()=>o.id??r),i=t.ref(null),l=t.ref(null),c=t.ref([]),u=t.toRef(o,"open"),d=t.toRef(o,"anchor"),p=Ia(u,l),h=t.ref(null),f=t.ref("none"),m=t.ref(null),{placement:g,wrapperStyle:v}=Ea(d,i,u,()=>({side:o.side,align:o.align,sideOffset:o.sideOffset})),y=D=>D!=="-"&&Array.isArray(D.items)&&D.items.length>0,k=(D,$)=>{c.value[D]=$ instanceof HTMLElement?$:null},b=()=>o.items.flatMap((D,$)=>D!=="-"&&c.value[$]?[$]:[]),w=D=>{D!==void 0&&c.value[D]?.focus()},S=()=>{const D=document.activeElement,$=c.value.findIndex(P=>P===D);return $===-1?null:$};t.watch([u,l],async([D,$])=>{if(!D||!$){D||(h.value=null);return}await t.nextTick();const P=b();o.initialFocus==="first"?w(P[0]):o.initialFocus==="last"?w(P.at(-1)):o.initialFocus==="content"&&$.focus()},{flush:"post"});let C,A=0;const E=()=>{clearTimeout(C),C=void 0},L=(D,$)=>{E(),f.value=$,h.value=D},z=()=>{E(),h.value=null},O=D=>{z(),w(D)};let N="",K;const ae=D=>{const $=o.items[D];return $&&$!=="-"?$.label.trim().toLowerCase():""},H=D=>{clearTimeout(K),N+=D.toLowerCase(),K=setTimeout(()=>{N=""},Jb);const $=b(),P=S(),Y=P===null?-1:$.indexOf(P),q=N.split("").every(Z=>Z===N[0]),ne=q?N[0]:N,Qe=Math.max(0,Y+(q?1:0)),et=[...$.slice(Qe),...$.slice(0,Qe)];w(et.find(Z=>ae(Z).startsWith(ne)))},M=(D,$)=>{const P=o.items[D];if(!(!P||P==="-")){if(y(P)){L(D,$);return}a("select",P)}},I=D=>{const $=b(),P=S(),Y=P===null?-1:$.indexOf(P),q=P===null?void 0:o.items[P];switch(D.key){case"ArrowDown":D.preventDefault(),w($[Math.min(Y+1,$.length-1)]);return;case"ArrowUp":D.preventDefault(),w(Y===-1?$.at(-1):$[Math.max(Y-1,0)]);return;case"Home":case"PageUp":D.preventDefault(),w($[0]);return;case"End":case"PageDown":D.preventDefault(),w($.at(-1));return;case"Enter":case" ":if(P===null)return;if(D.key===" "&&N){D.preventDefault(),H(" ");return}D.preventDefault(),M(P,"first");return;case"ArrowRight":P!==null&&q&&y(q)&&(D.preventDefault(),L(P,"first"));return;case"ArrowLeft":o.sub&&(D.preventDefault(),a("close-sub"));return;case"Escape":D.preventDefault(),D.stopPropagation(),a("dismiss","escape");return;case"Tab":D.preventDefault(),a("dismiss","tab");return}D.key.length===1&&!D.ctrlKey&&!D.metaKey&&!D.altKey&&H(D.key)},B=(D,$)=>{if($.pointerType!=="mouse"&&$.pointerType!=="pen"||Date.now()<A&&h.value!==D)return;A=0;const P=c.value[D];P&&document.activeElement!==P&&P.focus();const Y=o.items[D];Y&&y(Y)?h.value!==D&&C===void 0&&(C=setTimeout(()=>L(D,"none"),Gb)):h.value!==null&&z()},F=(D,$)=>{if($.pointerType!=="mouse"&&$.pointerType!=="pen")return;const P=o.items[D];if(P&&y(P)&&(E(),h.value===D)){A=Date.now()+qb;return}Date.now()<A||document.activeElement===c.value[D]&&l.value?.focus()},V=D=>{M(D,"none")},oe=()=>{A=0},ie=D=>D instanceof Element&&(D.closest(`[data-cpk-menu="${o.menuId}"]`)!==null||(o.anchor?.contains(D)??!1)),Te=D=>{ie(D.target)||a("dismiss","outside")},Ee=D=>{if(o.sub||typeof document>"u")return;const $=D?"addEventListener":"removeEventListener";document[$]("pointerdown",Te,{capture:!0}),document[$]("focusin",Te,{capture:!0})};t.watch(u,D=>Ee(D),{immediate:!0}),t.onBeforeUnmount(()=>{Ee(!1),E(),clearTimeout(K)});const Ie=t.computed(()=>({outline:"none","--radix-dropdown-menu-content-transform-origin":g.value?.transformOrigin??"center","--radix-dropdown-menu-content-available-height":g.value?`${g.value.availableHeight}px`:void 0})),Ne=D=>`${s.value}-sub-${D}`;return(D,$)=>{const P=t.resolveComponent("CopilotDropdownMenuContent",!0);return t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.unref(p)?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"wrapper",ref:i,"data-radix-popper-content-wrapper":"",style:t.normalizeStyle(t.unref(v)())},[t.createElementVNode("div",t.mergeProps({id:s.value,ref_key:"content",ref:l,"data-copilotkit":"","data-cpk-menu":e.menuId,"data-slot":e.sub?"dropdown-menu-sub-content":"dropdown-menu-content",class:e.sub?"cpk-dropdown-menu-sub-content":"cpk-dropdown-menu-content",role:"menu","aria-orientation":"vertical","aria-labelledby":e.labelledBy,tabindex:"-1","data-state":u.value?"open":"closed","data-side":t.unref(g)?.side??e.side,"data-align":t.unref(g)?.align??e.align,style:Ie.value},D.$attrs,{onKeydown:I,onPointerenter:$[4]||($[4]=Y=>a("pointer-enter")),onPointerleave:$[5]||($[5]=Y=>a("pointer-leave"))}),[t.renderSlot(D.$slots,"header"),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.items,(Y,q)=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:q},[Y==="-"?(t.openBlock(),t.createElementBlock("div",Wb)):y(Y)?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createElementVNode("div",{id:`${Ne(q)}-trigger`,ref_for:!0,ref:ne=>k(q,ne),role:"menuitem",tabindex:"-1","aria-haspopup":"menu","aria-expanded":h.value===q,"aria-controls":h.value===q?Ne(q):void 0,"data-slot":"dropdown-menu-sub-trigger",class:"cpk-dropdown-menu-sub-trigger","data-state":h.value===q?"open":"closed","data-highlighted":m.value===q?"":void 0,onFocus:ne=>m.value=q,onBlur:$[0]||($[0]=ne=>m.value=null),onPointermove:ne=>B(q,ne),onPointerleave:ne=>F(q,ne),onClick:ne=>V(q)},[t.createTextVNode(t.toDisplayString(Y.label)+" ",1),t.createVNode(t.unref(tn),{class:"cpk-dropdown-menu-sub-trigger-icon","aria-hidden":"true"})],40,Hb),t.createVNode(P,{id:Ne(q),open:u.value&&h.value===q,anchor:c.value[q]??null,items:Y.items,"menu-id":e.menuId,"labelled-by":`${Ne(q)}-trigger`,side:"right",align:"start","side-offset":0,"initial-focus":f.value,sub:"",onSelect:$[1]||($[1]=ne=>a("select",ne)),onDismiss:$[2]||($[2]=ne=>a("dismiss",ne)),onCloseSub:ne=>O(q),onPointerEnter:oe},null,8,["id","open","anchor","items","menu-id","labelled-by","initial-focus","onCloseSub"])],64)):(t.openBlock(),t.createElementBlock("div",{key:2,ref_for:!0,ref:ne=>k(q,ne),role:"menuitem",tabindex:"-1","data-slot":"dropdown-menu-item","data-variant":"default",class:t.normalizeClass(["cpk-dropdown-menu-item",Y.class]),"data-highlighted":m.value===q?"":void 0,onFocus:ne=>m.value=q,onBlur:$[3]||($[3]=ne=>m.value=null),onPointermove:ne=>B(q,ne),onPointerleave:ne=>F(q,ne),onClick:ne=>V(q)},[t.renderSlot(D.$slots,"item",{item:Y},()=>[t.createTextVNode(t.toDisplayString(Y.label),1)])],42,Kb))],64))),128))],16,Zb)],4)):t.createCommentVNode("",!0)])}}});let Wo=!1;const Ho=new Set;function Yb(){const e=t.ref(Wo),n=()=>{e.value=Wo};return Ho.add(n),t.onBeforeUnmount(()=>Ho.delete(n)),t.readonly(e)}function Xb(){Wo=!0,Ho.forEach(e=>e())}const Qb=["id","disabled","aria-label","aria-expanded","aria-controls","data-state"],ey={"data-slot":"dropdown-menu-label",class:"cpk-dropdown-menu-label cpk-inspector-button-menu-header"},ty={class:"cpk-inspector-button-menu-title"},ny={key:0,"aria-hidden":"true",class:"cpk-inspector-button-kite-icon cpk-inspector-button-menu-item-icon",viewBox:"4.57 3.36 17.8 17.8",fill:"none"},oy=["fill"],ay=["fill"],ry=["fill"],sy=["fill"],iy=["id"],ly=["id"],cy=["id"],uy=["id"],dy={class:"cpk-inspector-button-menu-item-label"},py={class:"cpk-inspector-button-menu-item-description"},fy=t.defineComponent({inheritAttrs:!1,__name:"CopilotChatInspectorButton",props:{title:{},disabled:{type:Boolean}},emits:["click"],setup(e,{emit:n}){const o=e,a=n,r=Re(),s=t.computed(()=>r.value?.labels??x.CopilotChatDefaultLabels),i=dt("cpk-inspector-menu"),l=dt("cpk-inspector-button"),c=dt("cpk-inspector-kite"),u=t.shallowRef(null),d=t.ref(!1),p=t.ref(!1),h=t.ref("none");let f=null,m=!1;const g=()=>{f!==null&&clearTimeout(f),f=null};t.onBeforeUnmount(g);const v=O=>{g(),O&&(p.value=!!u.value?.closest(".dark")),d.value=O},y=()=>{g(),f=setTimeout(()=>{m&&(d.value=!1)},180)},k=t.computed(()=>[{label:o.title||s.value.assistantMessageToolbarInspectorLabel,action:()=>a("click"),class:"cpk-inspector-button-menu-item cpk-inspector-button-inspect-item"},{label:s.value.assistantMessageToolbarInspectorHideLabel,action:Xb,class:"cpk-inspector-button-menu-item cpk-inspector-button-hide-item"}]),b=O=>O===k.value[0];function w(O){o.disabled||O.pointerType==="touch"||(m=!0,h.value="none",v(!0))}function S(){v(!1),a("click")}function C(O){m=!1,O.key==="Enter"||O.key===" "?(O.preventDefault(),S()):O.key==="ArrowDown"&&(O.preventDefault(),h.value="first",d.value?(d.value=!1,queueMicrotask(()=>v(!0))):v(!0))}function A(O){const N=!m;v(!1),O.action?.(),N&&!b(O)&&u.value?.focus()}function E(O){const N=!m&&O!=="outside";v(!1),N&&u.value?.focus()}const L=t.computed(()=>`${s.value.assistantMessageToolbarInspectorTitle} (${s.value.assistantMessageToolbarInspectorLocalOnlyLabel.toLowerCase()})`),z=O=>b(O)?s.value.assistantMessageToolbarInspectorDescription:s.value.assistantMessageToolbarInspectorHideDescription;return(O,N)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createElementVNode("button",t.mergeProps({id:t.unref(l),ref_key:"trigger",ref:u},O.$attrs,{type:"button",disabled:e.disabled,"data-testid":"copilot-inspector-button",class:"cpk-button cpk-button-assistant-message-toolbar cpk-button-size-icon cpk-inspector-button","aria-label":L.value,"aria-haspopup":"menu","aria-expanded":d.value,"aria-controls":d.value?t.unref(i):void 0,"data-state":d.value?"open":"closed",onPointerenter:w,onPointerleave:y,onPointerdown:N[0]||(N[0]=t.withModifiers(()=>{},["prevent"])),onClick:S,onKeydown:C}),[t.createVNode(t.unref(zv),{"aria-hidden":"true",class:"cpk-inspector-button-icon","data-testid":"copilot-inspector-icon"})],16,Qb),t.createVNode(Gl,{id:t.unref(i),open:d.value,anchor:u.value,items:k.value,"menu-id":t.unref(i),"labelled-by":t.unref(l),side:"top",align:"start","side-offset":6,"initial-focus":h.value,class:t.normalizeClass(["cpk-inspector-button-menu",{dark:p.value}]),onSelect:A,onDismiss:E,onPointerEnter:g,onPointerLeave:y,onKeydown:N[1]||(N[1]=K=>t.isRef(m)?m.value=!1:m=!1)},{header:t.withCtx(()=>[t.createElementVNode("div",ey,[t.createElementVNode("span",ty,t.toDisplayString(s.value.assistantMessageToolbarInspectorTitle),1),t.createVNode(Rt,{content:s.value.assistantMessageToolbarInspectorLocalOnlyDescription,side:"top","side-offset":6,"delay-duration":1e3,"content-class":p.value?"cpk-inspector-button-local-tooltip dark":"cpk-inspector-button-local-tooltip"},{default:t.withCtx(({triggerProps:K})=>[t.createElementVNode("span",t.mergeProps({tabindex:"0",class:"cpk-inspector-button-local-badge"},K),t.toDisplayString(s.value.assistantMessageToolbarInspectorLocalOnlyLabel),17)]),content:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(s.value.assistantMessageToolbarInspectorLocalOnlyDescription),1)]),_:1},8,["content","content-class"])]),N[2]||(N[2]=t.createElementVNode("div",{role:"separator","aria-orientation":"horizontal","data-slot":"dropdown-menu-separator",class:"cpk-dropdown-menu-separator"},null,-1))]),item:t.withCtx(({item:K})=>[b(K)?(t.openBlock(),t.createElementBlock("svg",ny,[t.createElementVNode("path",{d:"M6.36084 10.9855C8.34277 8.393 9.98843 5.82939 10.6204 3.75914C10.6382 3.70281 10.7043 3.67888 10.7534 3.7114C12.9536 5.16894 16.9635 6.12833 20.5086 6.15085C20.5703 6.15124 20.6124 6.2114 20.5895 6.26829C19.4109 9.25938 17.9705 14.6189 17.9148 20.7392C17.9148 20.8301 17.7873 20.8627 17.7419 20.7837C15.7236 17.2522 9.26021 12.2898 6.39414 11.1186C6.34112 11.0968 6.32556 11.0313 6.36084 10.9855Z",fill:`url(#${t.unref(c)}-paint0_linear)`},null,8,oy),t.createElementVNode("path",{d:"M13.0475 9.39974C9.95016 10.3806 7.11935 10.9259 6.44331 11.0498C6.40027 11.0577 6.39115 11.1172 6.43152 11.134C9.3203 12.3347 15.7516 17.2826 17.7511 20.7998C17.7551 20.8075 17.7647 20.8103 17.7728 20.8068C17.7809 20.803 17.7853 20.793 17.7819 20.7844L13.0475 9.39974Z",fill:`url(#${t.unref(c)}-paint1_linear)`},null,8,ay),t.createElementVNode("path",{d:"M10.762 3.705C13.4137 5.15161 16.4787 5.80132 20.545 6.14367C20.5703 6.14585 20.5787 6.18008 20.5557 6.19197C20.0359 6.45923 17.0574 7.97512 14.8455 8.78701C14.2524 9.00453 13.6564 9.20632 13.0692 9.39249C13.0562 9.39656 13.0419 9.39015 13.0369 9.37774L10.7005 3.75979C10.6849 3.72196 10.7257 3.68538 10.762 3.705Z",fill:`url(#${t.unref(c)}-paint2_linear)`},null,8,ry),N[7]||(N[7]=t.createElementVNode("path",{d:"M10.7145 3.79041L17.8305 20.7659",stroke:"#513C9F","stroke-width":"0.17284","stroke-linecap":"round"},null,-1)),N[8]||(N[8]=t.createElementVNode("path",{d:"M6.44531 11.0476C6.44531 11.0476 10.375 10.3422 14.0686 9.06804C17.7623 7.7939 20.5122 6.23373 20.5122 6.23373",stroke:"#513C9F","stroke-width":"0.17284","stroke-linecap":"round"},null,-1)),N[9]||(N[9]=t.createElementVNode("path",{d:"M11.6914 5.93518L9.05534 14.7068M9.05534 14.7068H15.3203M9.05534 14.7068L0.15625 26.3646",stroke:"#ABABAB","stroke-width":"0.302474","stroke-linecap":"round"},null,-1)),t.createElementVNode("path",{d:"M6.02539 23.9646L4.85806 24.1287C5.46272 25.7287 6.70381 26.4276 8.18528 26.4276C11.8147 26.4276 10.707 22.3227 12.8103 22.3227C14.3358 22.3227 13.7155 25.6498 16.9992 25.6498C19.0029 25.6498 19.2028 23.631 18.8607 22.7625C18.8589 22.7572 18.8568 22.7524 18.8538 22.7476L18.3166 21.9253C18.2817 21.8706 18.1968 21.8912 18.1907 21.9562L18.0908 22.9529C18.0838 23.0222 18.0857 23.0913 18.0936 23.1605C18.1764 23.8491 18.2291 25.5202 16.9992 25.5202C15.7015 25.5202 15.3895 22.2362 12.8103 22.2362C9.78393 22.2362 10.1726 26.298 8.31487 26.298C7.08938 26.298 6.15447 24.9153 6.02539 23.9646Z",fill:`url(#${t.unref(c)}-paint3_linear)`},null,8,sy),t.createElementVNode("defs",null,[t.createElementVNode("linearGradient",{id:`${t.unref(c)}-paint0_linear`,x1:"15.5372",y1:"5.0278",x2:"12.0802",y2:"14.534",gradientUnits:"userSpaceOnUse"},[...N[3]||(N[3]=[t.createElementVNode("stop",{"stop-color":"#6430AB"},null,-1),t.createElementVNode("stop",{offset:"1","stop-color":"#AA89D8"},null,-1)])],8,iy),t.createElementVNode("linearGradient",{id:`${t.unref(c)}-paint1_linear`,x1:"12.8583",y1:"10.3858",x2:"8.40764",y2:"18.9846",gradientUnits:"userSpaceOnUse"},[...N[4]||(N[4]=[t.createElementVNode("stop",{"stop-color":"#005DBB"},null,-1),t.createElementVNode("stop",{offset:"1","stop-color":"#3D92E8"},null,-1)])],8,ly),t.createElementVNode("linearGradient",{id:`${t.unref(c)}-paint2_linear`,x1:"14.8452",y1:"5.02774",x2:"13.5047",y2:"9.21911",gradientUnits:"userSpaceOnUse"},[...N[5]||(N[5]=[t.createElementVNode("stop",{"stop-color":"#1B70C4"},null,-1),t.createElementVNode("stop",{offset:"1","stop-color":"#54A4F2"},null,-1)])],8,cy),t.createElementVNode("linearGradient",{id:`${t.unref(c)}-paint3_linear`,x1:"4.85806",y1:"24.2455",x2:"18.9963",y2:"24.2455",gradientUnits:"userSpaceOnUse"},[...N[6]||(N[6]=[t.createElementVNode("stop",{"stop-color":"#4497EA"},null,-1),t.createElementVNode("stop",{offset:"0.254755","stop-color":"#1463B2"},null,-1),t.createElementVNode("stop",{offset:"0.498725","stop-color":"#0A437D"},null,-1),t.createElementVNode("stop",{offset:"0.666667","stop-color":"#2476C8"},null,-1),t.createElementVNode("stop",{offset:"0.972542","stop-color":"#0C549A"},null,-1)])],8,uy)])])):(t.openBlock(),t.createBlock(t.unref($v),{key:1,"aria-hidden":"true",class:"cpk-inspector-button-menu-item-icon"})),t.createElementVNode("span",null,[t.createElementVNode("span",dy,t.toDisplayString(K.label),1),t.createElementVNode("span",py,t.toDisplayString(z(K)),1)])]),_:1},8,["id","open","anchor","items","menu-id","labelled-by","initial-focus","class"])],64))}}),ql=Symbol("CopilotMessageFeedbackScope"),Vn=new WeakSet,my=e=>{if(Vn.has(e))return;Vn.add(e);const n=e.ɵsubscribeToLearningConfigured(()=>{e.ɵlearningConfigured||(Vn.delete(e),n())})};function hy(e){const n=t.ref(!1),o=t.ref(!1);return t.watch(e,(a,r,s)=>{const i=()=>{n.value=a.ɵlearningConfigured,o.value=a.trajectoryId!==null,o.value&&my(a)};i();const l=a.ɵsubscribeToLearningConfigured(i),c=a.subscribe({onTrajectoryChanged:i});s(()=>{l(),c.unsubscribe()})},{immediate:!0}),t.computed(()=>n.value&&(o.value||Vn.has(e.value)))}function gy(e){const n=t.inject(ql,t.ref(null)),o=t.ref(0);return t.watch(n,(a,r,s)=>{a&&s(Fb(a.agentId,a.threadId,()=>{o.value++}))},{immediate:!0}),t.computed(()=>{const a=n.value;if(!a)return null;o.value;const r=e.value,s=Db(a.agentId,a.threadId,r.id),i=l=>Pb({...a,message:r,feedback:l});return{feedback:s,rate:l=>{s?.rating!==l&&i({rating:l})},clear:()=>{s&&i(null)},comment:l=>{s&&i({rating:s.rating,comment:l})}}})}const vy=150;function by(e){const n=t.ref(!1),o=t.ref(""),a=t.ref(0),r=t.shallowRef(null);let s,i=!1,l=!1,c=!1,u=!1;const d=()=>{const g=l;return l=!1,g},p=()=>{s!==void 0&&(clearTimeout(s),s=void 0)},h=()=>e.value?.feedback?.comment??"",f=({save:g=!0}={})=>{if(p(),l=!1,c=!1,!n.value)return;const v=e.value;g&&v?.feedback&&o.value.trim()!==h()&&v.comment(o.value),i=!1,n.value=!1},m=({comment:g,focus:v})=>{p(),o.value=g,v&&(l=!0,a.value++),n.value=!0};return t.onBeforeUnmount(()=>{p();const g=e.value;n.value&&g?.feedback&&o.value.trim()!==h()&&g.comment(o.value)}),{open:n,draft:o,focusRequest:a,takeFocusRequest:d,input:r,show:m,enter:(g="focus")=>{p(),g==="pointer"&&(c=!0),!u&&!n.value&&e.value?.feedback&&m({comment:h(),focus:!1})},leave:(g="focus")=>{if(g==="pointer")c=!1;else if(c)return;p(),s=setTimeout(()=>{s=void 0,i||f()},vy)},setEditing:g=>{i=g},close:f,returnFocus:g=>{u=!0;try{g?.focus()}finally{u=!1}}}}const yy=["data-message-id"],ky={class:"cpk-markdown cpk-assistant-message-markdown"},Sy={"data-testid":"copilot-assistant-toolbar",class:"cpk-assistant-message-toolbar"},wy={class:"cpk-assistant-message-toolbar-items"},Jl=t.defineComponent({__name:"CopilotChatAssistantMessage",props:{message:{},messages:{default:()=>[]},isRunning:{type:Boolean,default:!1},toolbarVisible:{type:Boolean,default:!0},onThumbsUp:{},onThumbsDown:{},onReadAloud:{},onRegenerate:{}},emits:["thumbs-up","thumbs-down","read-aloud","regenerate"],setup(e,{emit:n}){const o=e,a=n,r=Re(),s=t.computed(()=>r.value?.labels??x.CopilotChatDefaultLabels),i=t.ref(!1);let l=null;function c($){return $?typeof $=="string"?$:Array.isArray($)?$.map(Y=>Y&&typeof Y=="object"&&"type"in Y&&Y.type==="text"&&typeof Y.text=="string"?Y.text:"").filter(Y=>Y.length>0).join(`
|
|
78
|
+
`):"":""}const u=t.computed(()=>c(o.message.content)),d=t.computed(()=>u.value.trim().length>0),p=bl(),h=t.computed(()=>yl(p)),f=t.computed(()=>h.value?p:ka),m=t.computed(()=>h.value||!p?{}:p),g=t.inject(al,null),v=Yb(),y=t.computed(()=>!!g?.isInspectorEnabled.value&&!v.value),k=gy(t.toRef(o,"message")),b=by(k),w=t.computed(()=>k.value?.feedback?.rating),S=t.ref(null),C=t.shallowRef(null);let A=w.value;const E=t.computed(()=>typeof o.onThumbsUp=="function"||!!k.value),L=t.computed(()=>typeof o.onThumbsDown=="function"||!!k.value),z=t.computed(()=>typeof o.onReadAloud=="function"),O=t.computed(()=>typeof o.onRegenerate=="function"),N=t.computed(()=>o.messages[o.messages.length-1]?.id===o.message.id),K=t.computed(()=>o.toolbarVisible&&(d.value||y.value)&&!(o.isRunning&&N.value));function ae(){b.open.value&&!C.value?.isConnected&&w.value&&S.value&&(C.value=S.value.querySelector(`[data-copilotkit-rating="${w.value}"]`)??S.value.querySelector('button[aria-pressed="true"]')??null)}t.onUpdated(ae),t.watch(()=>b.open.value,ae,{flush:"post"});function H($){try{return $.matches(":focus-visible")}catch{return!1}}const M={checkVisibilityCSS:!0,visibilityProperty:!0};function I($,P){const Y=k.value;return Y?w.value===$?(b.close({save:!1}),Y.clear(),!1):(Y.rate($),A=$,C.value=P?.currentTarget instanceof HTMLElement?P.currentTarget:null,b.show({comment:"",focus:P?.detail===0}),!0):!0}function B($){if(!k.value)return{};const P={"data-copilotkit-rating":$};if(w.value!==$)return{...P,"aria-pressed":!1};const Y=(q,ne)=>{b.open.value||(A=$),C.value=q,b.enter(ne)};return{...P,"aria-pressed":!0,"aria-haspopup":"dialog","aria-expanded":b.open.value,onPointerenter:q=>{q.pointerType!=="touch"&&Y(q.currentTarget,"pointer")},onPointerleave:q=>{q.pointerType!=="touch"&&b.leave("pointer")},onFocus:q=>{const ne=q.currentTarget;H(ne)&&Y(ne,"focus")},onBlur:()=>b.leave(),onKeydown:q=>{const ne=b.input.value;q.key==="Tab"&&!q.shiftKey&&b.open.value&&ne&&ne.checkVisibility?.(M)!==!1&&(q.preventDefault(),ne.focus())}}}const F=t.computed(()=>B("up")),V=t.computed(()=>B("down"));t.watch([()=>b.open.value,K,w],([$,P,Y])=>{$&&(Y!==A?b.close({save:!1}):P||b.close())});function oe(){g?.openInspector({messageId:o.message.id,threadId:r.value?.threadId,agentId:r.value?.agentId})}function ie(){l&&clearTimeout(l),i.value=!0,l=setTimeout(()=>{i.value=!1,l=null},2e3)}async function Te(){const $=u.value;if($&&!(typeof navigator>"u"||typeof navigator.clipboard?.writeText!="function"))try{await navigator.clipboard.writeText($),ie()}catch(P){console.error("Failed to copy to clipboard:",P)}}function Ee($){I("up",$)&&a("thumbs-up",o.message)}function Ie($){I("down",$)&&a("thumbs-down",o.message)}function Ne(){a("read-aloud",o.message)}function D(){a("regenerate",o.message)}return t.onBeforeUnmount(()=>{l&&clearTimeout(l)}),($,P)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.renderSlot($.$slots,"layout",{message:e.message,content:u.value,isRunning:e.isRunning,toolbarVisible:e.toolbarVisible,shouldShowToolbar:K.value,messageRenderer:$.$slots["message-renderer"]??(()=>null),toolbar:$.$slots.toolbar??(()=>null),copyButton:$.$slots["copy-button"]??(()=>null),thumbsUpButton:$.$slots["thumbs-up-button"]??(()=>null),thumbsDownButton:$.$slots["thumbs-down-button"]??(()=>null),readAloudButton:$.$slots["read-aloud-button"]??(()=>null),regenerateButton:$.$slots["regenerate-button"]??(()=>null),toolCallsView:$.$slots["tool-calls-view"]??(()=>null),onCopy:Te,onThumbsUp:Ee,onThumbsDown:Ie,onReadAloud:Ne,onRegenerate:D},()=>[t.createElementVNode("div",t.mergeProps({ref_key:"root",ref:S,"data-copilotkit":"","data-testid":"copilot-assistant-message",class:"copilotKitMessage copilotKitAssistantMessage","data-message-id":e.message.id},$.$attrs),[t.createVNode(t.unref(Cb),{"message-id":e.message.id},{default:t.withCtx(()=>[t.createElementVNode("div",ky,[t.renderSlot($.$slots,"message-renderer",{message:e.message,content:u.value},()=>[d.value?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(f.value),t.mergeProps({key:0},m.value,{content:u.value,"is-streaming":e.isRunning&&N.value}),null,16,["content","is-streaming"])):t.createCommentVNode("",!0)])])]),_:3},8,["message-id"]),t.renderSlot($.$slots,"tool-calls-view",{message:e.message,messages:e.messages},()=>[t.createVNode(zl,{message:e.message,messages:e.messages},t.createSlots({_:2},[t.renderList($.$slots,(Y,q)=>({name:q,fn:t.withCtx(ne=>[t.renderSlot($.$slots,q,t.normalizeProps(t.guardReactiveProps(ne)))])}))]),1032,["message","messages"])]),K.value?t.renderSlot($.$slots,"toolbar",{key:0,message:e.message,shouldShowToolbar:K.value},()=>[t.createElementVNode("div",Sy,[t.createElementVNode("div",wy,[t.renderSlot($.$slots,"copy-button",{onCopy:Te,copied:i.value,label:s.value.assistantMessageToolbarCopyMessageLabel},()=>[t.createVNode(sn,{"data-testid":"copilot-copy-button",label:s.value.assistantMessageToolbarCopyMessageLabel,onClick:Te},{default:t.withCtx(()=>[i.value?(t.openBlock(),t.createBlock(t.unref(so),{key:0,class:"cpk-assistant-message-toolbar-icon"})):(t.openBlock(),t.createBlock(t.unref(Ll),{key:1,class:"cpk-assistant-message-toolbar-icon"}))]),_:1},8,["label"])]),E.value||$.$slots["thumbs-up-button"]?t.renderSlot($.$slots,"thumbs-up-button",{key:0,onThumbsUp:Ee,label:s.value.assistantMessageToolbarThumbsUpLabel,pressed:w.value==="up",thumbProps:F.value},()=>[t.createVNode(sn,t.mergeProps({"data-testid":"copilot-thumbs-up-button",label:s.value.assistantMessageToolbarThumbsUpLabel},F.value,{onClick:Ee}),{default:t.withCtx(()=>[t.createVNode(t.unref(Pv),{class:"cpk-assistant-message-toolbar-icon",fill:w.value==="up"?"currentColor":"none"},null,8,["fill"])]),_:1},16,["label"])]):t.createCommentVNode("",!0),L.value||$.$slots["thumbs-down-button"]?t.renderSlot($.$slots,"thumbs-down-button",{key:1,onThumbsDown:Ie,label:s.value.assistantMessageToolbarThumbsDownLabel,pressed:w.value==="down",thumbProps:V.value},()=>[t.createVNode(sn,t.mergeProps({"data-testid":"copilot-thumbs-down-button",label:s.value.assistantMessageToolbarThumbsDownLabel},V.value,{onClick:Ie}),{default:t.withCtx(()=>[t.createVNode(t.unref(Fv),{class:"cpk-assistant-message-toolbar-icon",fill:w.value==="down"?"currentColor":"none"},null,8,["fill"])]),_:1},16,["label"])]):t.createCommentVNode("",!0),z.value||$.$slots["read-aloud-button"]?t.renderSlot($.$slots,"read-aloud-button",{key:2,onReadAloud:Ne,label:s.value.assistantMessageToolbarReadAloudLabel},()=>[t.createVNode(sn,{"data-testid":"copilot-read-aloud-button",label:s.value.assistantMessageToolbarReadAloudLabel,onClick:Ne},{default:t.withCtx(()=>[t.createVNode(t.unref(Vv),{class:"cpk-assistant-message-read-aloud-icon"})]),_:1},8,["label"])]):t.createCommentVNode("",!0),O.value||$.$slots["regenerate-button"]?t.renderSlot($.$slots,"regenerate-button",{key:3,onRegenerate:D,label:s.value.assistantMessageToolbarRegenerateLabel},()=>[t.createVNode(sn,{"data-testid":"copilot-regenerate-button",label:s.value.assistantMessageToolbarRegenerateLabel,onClick:D},{default:t.withCtx(()=>[t.createVNode(t.unref(Bv),{class:"cpk-assistant-message-toolbar-icon"})]),_:1},8,["label"])]):t.createCommentVNode("",!0),t.renderSlot($.$slots,"toolbar-items"),y.value?t.renderSlot($.$slots,"inspector-button",{key:4,onInspect:oe,label:s.value.assistantMessageToolbarInspectorLabel},()=>[t.createVNode(fy,{onClick:oe})]):t.createCommentVNode("",!0)])])]):t.createCommentVNode("",!0)],16,yy)]),t.unref(k)?.feedback&&K.value?(t.openBlock(),t.createBlock(jb,{key:0,comment:t.unref(b),"saved-comment":t.unref(k).feedback.comment??"",rating:t.unref(k).feedback.rating,anchor:C.value,"message-id":e.message.id},t.createSlots({_:2},[$.$slots["feedback-comment"]?{name:"feedback-comment",fn:t.withCtx(Y=>[t.renderSlot($.$slots,"feedback-comment",t.normalizeProps(t.guardReactiveProps(Y)))]),key:"0"}:void 0]),1032,["comment","saved-comment","rating","anchor","message-id"])):t.createCommentVNode("",!0)],64))}});class Kt extends Error{constructor(n){super(n),this.name="AudioRecorderError"}}const Yl=t.defineComponent({inheritAttrs:!1,__name:"CopilotChatAudioRecorder",setup(e,{expose:n}){const o=t.useAttrs(),a=t.ref(null),r=t.ref("idle"),s=t.ref(null),i=t.ref(null),l=t.ref(null),c=t.ref(null),u=t.ref(null),d=t.ref([]),p=t.ref([]),h=t.ref(0),f=t.ref(0),m=t.ref(0);function g(){u.value!==null&&(cancelAnimationFrame(u.value),u.value=null);const w=s.value;if(w&&w.state!=="inactive")try{w.stop()}catch{}i.value&&(i.value.getTracks().forEach(C=>C.stop()),i.value=null);const S=c.value;S&&S.state!=="closed"&&S.close().catch(()=>{}),s.value=null,l.value=null,c.value=null,d.value=[],p.value=[],h.value=0,f.value=0,m.value=0}async function v(){if(r.value!=="idle")throw new Kt("Recorder is already active");try{const w=await navigator.mediaDevices.getUserMedia({audio:!0});i.value=w;const S=new AudioContext;c.value=S;const C=S.createMediaStreamSource(w),A=S.createAnalyser();A.fftSize=2048,C.connect(A),l.value=A;const E=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",L=E?{mimeType:E}:{},z=new MediaRecorder(w,L);s.value=z,d.value=[],z.ondataavailable=O=>{O.data.size>0&&d.value.push(O.data)},z.start(100),r.value="recording"}catch(w){throw g(),w instanceof Error&&w.name==="NotAllowedError"?new Kt("Microphone permission denied"):w instanceof Error&&w.name==="NotFoundError"?new Kt("No microphone found"):new Kt(w instanceof Error?w.message:"Failed to start recording")}}function y(){return new Promise((w,S)=>{const C=s.value;if(!C||r.value!=="recording"){S(new Kt("No active recording"));return}r.value="processing",C.onstop=()=>{const A=new Blob(d.value,{type:C.mimeType||"audio/webm"});g(),r.value="idle",w(A)},C.onerror=()=>{g(),r.value="idle",S(new Kt("Recording failed"))},C.stop()})}function k(w){let S=0;for(let C=0;C<w.length;C+=1){const A=(w[C]??128)/128-1;S+=A*A}return Math.sqrt(S/w.length)}function b(){const w=a.value;if(!w)return;const S=w.getContext("2d");if(!S)return;const C=w.getBoundingClientRect(),A=window.devicePixelRatio||1;(w.width!==C.width*A||w.height!==C.height*A)&&(w.width=C.width*A,w.height=C.height*A,S.scale(A,A));const E=2,z=E+1,O=Math.floor(C.width/z)+2;if(l.value&&r.value==="recording"){p.value.length===0&&(p.value=Array.from({length:O},()=>0)),m.value<1&&(m.value=Math.min(1,m.value+.03)),h.value+=1/3;const M=l.value.fftSize,I=new Uint8Array(M);l.value.getByteTimeDomainData(I);const B=k(I),oe=B>f.value?.12:.08;f.value+=(B-f.value)*oe,h.value>=z&&(h.value-=z,p.value.push(f.value),p.value.length>O&&(p.value=p.value.slice(-O)))}S.clearRect(0,0,C.width,C.height);const N=window.getComputedStyle(w);S.fillStyle=N.color,S.globalAlpha=m.value;const K=C.height/2,ae=C.height/2-2,H=12;for(let M=0;M<p.value.length;M+=1){const I=p.value[M]??0,B=Math.min(I*4,1),F=Math.max(2,B*ae*2),V=C.width-(p.value.length-M)*z-h.value,oe=K-F/2;if(V+E<=0||V>=C.width)continue;let ie=1;V<H?ie=Math.max(0,V/H):V>C.width-H&&(ie=Math.max(0,(C.width-V)/H)),S.globalAlpha=m.value*ie,S.fillRect(V,oe,E,F)}u.value=requestAnimationFrame(b)}return t.watch(r,()=>{u.value!==null&&(cancelAnimationFrame(u.value),u.value=null),u.value=requestAnimationFrame(b)},{immediate:!0}),t.onBeforeUnmount(()=>{g()}),n({get state(){return r.value},start:v,stop:y,dispose:g}),(w,S)=>(t.openBlock(),t.createElementBlock("div",t.mergeProps({"data-copilotkit":"",class:"cpk-audio-recorder"},t.unref(o)),[t.createElementVNode("canvas",{ref_key:"canvasRef",ref:a,class:"cpk-audio-recorder-canvas"},null,512)],16))}}),_a=t.defineComponent({__name:"InlineFeatureWarning",props:{featureName:{}},setup(e){const n={padding:"8px 12px",backgroundColor:"#fffbeb",border:"1px solid #fbbf24",borderRadius:"6px",fontSize:"13px",color:"#92400e",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif"},o={color:"#b45309",textDecoration:"underline"};return(a,r)=>(t.openBlock(),t.createElementBlock("div",{style:n,"data-testid":"copilot-inline-feature-warning"},[t.createTextVNode(' ⚠ The "'+t.toDisplayString(e.featureName)+'" feature requires a CopilotKit license. ',1),t.createElementVNode("a",{href:"https://copilotkit.ai/pricing",target:"_blank",rel:"noopener noreferrer",style:o}," Get one at copilotkit.ai/pricing ")]))}});var Xl=(e=>(e.OnMessagesChanged="OnMessagesChanged",e.OnStateChanged="OnStateChanged",e.OnRunStatusChanged="OnRunStatusChanged",e))(Xl||{});const Cy=["OnMessagesChanged","OnStateChanged","OnRunStatusChanged"];function io(e={}){const n=e.threadId!==void 0,o=e.runtimeAgentId!==void 0,a=e.agentId!==void 0;if(n&&!o)throw new Error('useAgent: `threadId` requires `runtimeAgentId`. A threadId is written onto a single agent, but an agent resolved by agentId alone is shared, so scoping a thread to it would clobber other useAgent callers. Pass a distinct local `agentId` and the runtime agent to route to, e.g. useAgent({ agentId: "chat-1", runtimeAgentId: "assistant", threadId }).');if(o&&!n)throw new Error("useAgent: `runtimeAgentId` requires `threadId`. A proxied agent exists to scope a thread to a private instance; without a threadId it behaves like the shared agent while adding a registration and a local agentId to keep unique. Either pass the thread, or bind to the agent directly with useAgent({ agentId }).");if(o&&!a)throw new Error(`useAgent: \`runtimeAgentId\` requires an explicit \`agentId\`. The proxied agent is registered under \`agentId\`, and the usual fallbacks (chat configuration, then "${Q.DEFAULT_AGENT_ID}") name agents that already exist — registering over one throws or shadows it. Pick a local id for this hook, e.g. useAgent({ agentId: "chat-1", runtimeAgentId: "assistant", threadId }).`);const r=o,s=Re(),i=t.computed(()=>t.toValue(e.agentId)??s.value?.agentId??Q.DEFAULT_AGENT_ID),l=t.computed(()=>r?t.toValue(e.runtimeAgentId):void 0),c=t.computed(()=>t.toValue(e.threadId)??(s.value?.hasExplicitThreadId?s.value.threadId:void 0)),{copilotkit:u}=Ve(),d=t.computed(()=>e.updates??Cy),p=t.computed(()=>u.value.defaultThrottleMs),h=t.computed(()=>t.toValue(e.throttleMs)),f=t.shallowRef(null),m=t.shallowRef(null),g=new Map,v=(b,w,S)=>{const C=new x.ProxiedCopilotRuntimeAgent({runtimeUrl:w,agentId:b,transport:S,runtimeMode:"pending"});return u.value.applyHeadersToAgent(C),C},y=t.shallowRef(null);r&&t.watch([i,l,()=>u.value],([b,w],S,C)=>{const{agent:A,unregister:E}=u.value.registerProxiedAgent({agentId:b,runtimeAgentId:w});g.delete(b),y.value=A,C(()=>{E(),y.value=null})},{immediate:!0});const k=()=>{const b=i.value,w=u.value;if(r){const z=y.value;if(z){g.delete(b);const K=f.value===z;f.value=z,m.value=z,K&&t.triggerRef(f);return}const O=g.get(b);if(O){w.applyHeadersToAgent(O),f.value=O,m.value=O;return}const N=new x.ProxiedCopilotRuntimeAgent({runtimeUrl:w.runtimeUrl,agentId:b,runtimeAgentId:l.value,transport:w.runtimeTransport,runtimeMode:"pending"});w.applyHeadersToAgent(N),g.set(b,N),f.value=N,m.value=N;return}const S=w.getAgent(b);if(S){g.delete(b);const z=f.value===S;f.value=S,m.value=S,z&&t.triggerRef(f);return}const C=w.runtimeUrl!==void 0,A=w.runtimeConnectionStatus;if(C&&(A===x.CopilotKitCoreRuntimeConnectionStatus.Disconnected||A===x.CopilotKitCoreRuntimeConnectionStatus.Connecting||A===x.CopilotKitCoreRuntimeConnectionStatus.Error)){const z=g.get(b);if(z){w.applyHeadersToAgent(z),f.value=z,m.value=z;return}const O=v(b,w.runtimeUrl,w.runtimeTransport);g.set(b,O),f.value=O,m.value=O;return}const E=Object.keys(w.agents??{}),L=C?`runtimeUrl=${w.runtimeUrl}`:"no runtimeUrl";throw new Error(`useAgent: Agent '${b}' not found after runtime sync (${L}). `+(E.length?`Known agents: [${E.join(", ")}]`:"No agents registered.")+" Verify your runtime /info and/or agents__unsafe_dev_only.")};return t.watch([i,()=>y.value,()=>u.value.agents,()=>u.value.runtimeConnectionStatus,()=>u.value.runtimeUrl,()=>u.value.runtimeTransport,()=>u.value.ɵheadersGeneration],k,{immediate:!0}),t.watch([()=>f.value,c],([b,w])=>{!b||!w||(b.threadId=w)},{immediate:!0}),t.watch([m,()=>u.value.ɵheadersGeneration],([b])=>{x.ɵisHttpAgent(b)&&u.value.applyHeadersToAgent(b)},{immediate:!0}),t.watch([m,d,h,p],([b,w],S,C)=>{const A=w;if(!b||A.length===0)return;let E=!0,L=!1;const z=()=>{E&&(L||(L=!0,queueMicrotask(()=>{L=!1,E&&t.triggerRef(f)})))},O={};A.includes("OnMessagesChanged")&&(O.onMessagesChanged=()=>{E&&t.triggerRef(f)}),A.includes("OnStateChanged")&&(O.onStateChanged=z),A.includes("OnRunStatusChanged")&&(O.onRunInitialized=z,O.onRunFinalized=z,O.onRunFailed=z,O.onRunErrorEvent=z);const N=u.value.subscribeToAgentWithOptions(b,O,{throttleMs:t.toValue(e.throttleMs)});C(()=>{E=!1,N.unsubscribe()})},{immediate:!0}),{agent:f}}function Ql(e={}){const{copilotkit:n}=Ve(),o=Re(),a=t.computed(()=>t.toValue(e.agentId)??o.value?.agentId??Q.DEFAULT_AGENT_ID),r=t.ref([]),s=t.ref(!1),i=()=>{const u=n.value.getSuggestions(a.value);r.value=u.suggestions,s.value=u.isLoading};return t.watch([()=>n.value,a],()=>i(),{immediate:!0}),t.watch([()=>n.value,a],(u,d,p)=>{const h=n.value,f=a.value,m=h.subscribe({onSuggestionsChanged:({agentId:g,suggestions:v})=>{if(g!==f)return;r.value=v;const y=h.getSuggestions(f);s.value=y.isLoading},onSuggestionsStartedLoading:({agentId:g})=>{g===f&&(s.value=!0)},onSuggestionsFinishedLoading:({agentId:g})=>{g===f&&(s.value=!1)},onSuggestionsConfigChanged:()=>{const g=h.getSuggestions(f);r.value=g.suggestions,s.value=g.isLoading}});p(()=>m.unsubscribe())},{immediate:!0}),{suggestions:r,isLoading:s,reloadSuggestions:()=>{n.value.reloadSuggestions(a.value)},clearSuggestions:()=>{n.value.clearSuggestions(a.value)}}}function ec(e){const n=t.shallowRef([]),o=t.ref(!1),a=t.ref(null),r=t.ref(null),s=t.ref(t.toValue(e.config)),i=t.shallowRef(n.value),l=t.computed(()=>s.value?.enabled??!1);t.watch(()=>t.toValue(e.config),k=>{s.value=k},{immediate:!0});const c=k=>{n.value=k,i.value=k},u=k=>{c(k(i.value))};async function d(k){const b=s.value,w=b?.accept??"*/*",S=b?.maxSize??20*1024*1024,C=k.filter(E=>!Q.matchesAcceptFilter(E,w));for(const E of C)b?.onUploadFailed?.({reason:"invalid-type",file:E,message:`File "${E.name}" is not accepted. Supported types: ${w}`});const A=k.filter(E=>Q.matchesAcceptFilter(E,w));for(const E of A){if(Q.exceedsMaxSize(E,S)){b?.onUploadFailed?.({reason:"file-too-large",file:E,message:`File "${E.name}" exceeds the maximum size of ${Q.formatFileSize(S)}`});continue}const L=Q.getModalityFromMimeType(E.type),z=Q.randomUUID();u(O=>[...O,{id:z,type:L,source:{type:"data",value:"",mimeType:E.type},filename:E.name,size:E.size,status:"uploading"}]);try{let O,N;if(b?.onUpload){const ae=await b.onUpload(E),{metadata:H,...M}=ae;O=M,N=H}else O={type:"data",value:await Q.readFileAsBase64(E),mimeType:E.type};let K;L==="video"&&(K=await Q.generateVideoThumbnail(E)),u(ae=>ae.map(H=>H.id===z?{...H,source:O,status:"ready",thumbnail:K,metadata:N}:H))}catch(O){u(N=>N.filter(K=>K.id!==z)),console.error(`[CopilotKit] Failed to upload "${E.name}":`,O),b?.onUploadFailed?.({reason:"upload-failed",file:E,message:O instanceof Error?O.message:`Failed to upload "${E.name}"`})}}}async function p(k){const b=k.target;b?.files?.length&&(await d(Array.from(b.files)),b&&(b.value=""))}function h(k){l.value&&(k.preventDefault(),k.stopPropagation(),o.value=!0)}function f(k){k.preventDefault(),k.stopPropagation(),o.value=!1}async function m(k){if(k.preventDefault(),k.stopPropagation(),o.value=!1,!l.value)return;const b=Array.from(k.dataTransfer?.files??[]);b.length>0&&await d(b)}function g(k){u(b=>b.filter(w=>w.id!==k))}function v(){const k=i.value.filter(b=>b.status==="ready");return k.length===0||(u(b=>b.filter(w=>w.status!=="ready")),a.value&&(a.value.value="")),k}async function y(k){if(!l.value)return;const b=k.target;if(!b||!r.value?.contains(b))return;const w=s.value?.accept??"*/*",C=Array.from(k.clipboardData?.items??[]).filter(E=>{if(E.kind!=="file")return!1;const L=E.getAsFile();return L!==null&&Q.matchesAcceptFilter(L,w)});if(C.length===0)return;k.preventDefault();const A=C.map(E=>E.getAsFile()).filter(E=>E!==null);await d(A)}return t.onMounted(()=>{typeof document<"u"&&document.addEventListener("paste",y)}),t.onBeforeUnmount(()=>{typeof document<"u"&&document.removeEventListener("paste",y)}),{attachments:n,enabled:l,dragOver:o,fileInputRef:a,containerRef:r,processFiles:d,handleFileUpload:p,handleDragOver:h,handleDragLeave:f,handleDrop:m,removeAttachment:g,consumeAttachments:v}}function tc(){const e=typeof window<"u"?window.innerHeight:0,n=t.ref(!1),o=t.ref(0),a=t.ref(e),r=t.ref(e),s=()=>{if(typeof window>"u")return;const l=window.visualViewport;if(!l)return;const c=window.innerHeight,u=l.height,d=Math.max(0,c-u),p=d>150;o.value=d,n.value=p,a.value=u,r.value=c};let i=null;return t.onMounted(()=>{typeof window>"u"||(i=window.visualViewport??null,i&&(s(),i.addEventListener("resize",s),i.addEventListener("scroll",s)))}),t.onBeforeUnmount(()=>{i&&(i.removeEventListener("resize",s),i.removeEventListener("scroll",s),i=null)}),{isKeyboardOpen:t.readonly(n),keyboardHeight:t.readonly(o),availableHeight:t.readonly(a),viewportHeight:t.readonly(r)}}const Ty={id:null,sendNonce:0},nc=Symbol("LastUserMessage");function Ey(){return t.ref({...Ty})}function Iy({scrollRef:e,contentRef:n,spacerRef:o,topOffset:a=16}){const r=t.inject(nc,Ey(),!0);let s=-1,i=null,l=null;function c(){i!==null&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(i),i=null,l?.disconnect(),l=null}t.watch([()=>r.value.id,()=>r.value.sendNonce,e,n,o,()=>a],([u,d,p,h,f],m,g)=>{if(g(c),d===s||(s=d,!u)||!p||!h||!f)return;const v=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(u):u.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g,"\\$&"),y=h.querySelector(`[data-message-id="${v}"]`);if(!y)return;const k=p.clientHeight,b=y.getBoundingClientRect().height,w=parseFloat(getComputedStyle(y).paddingTop)||0,S=Math.max(0,b-w),C=Math.max(0,k-S-a);f.style.height=`${C}px`,typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(()=>{const A=Ir(y,p)+w-a;p.scrollTo({top:Math.max(0,A),behavior:"smooth"})})),typeof ResizeObserver<"u"&&(l=new ResizeObserver(()=>{if(!h||!f||!p)return;const A=h.getBoundingClientRect().height,E=Ir(y,h),L=A-E-b,z=Math.max(0,C-L);f.style.height=`${z}px`}),l.observe(h))},{immediate:!0,flush:"post"})}function Ir(e,n){const o=e.getBoundingClientRect(),a=n.getBoundingClientRect();return o.top-a.top+n.scrollTop}const _y={class:"cpk-chat-input-wrapper"},Ay=["data-layout"],$y=["data-layout"],Ry=["aria-label","aria-expanded","aria-controls","data-state","disabled"],xy={class:"cpk-chat-input-add-menu-tooltip"},Oy={class:"cpk-chat-input-field"},Ny={key:1,class:"cpk-chat-input-processing"},My=["value","placeholder","disabled"],By=["aria-label"],Dy={key:0,class:"cpk-chat-input-slash-menu-empty"},Fy=["data-slash-index","aria-selected","data-active","onMouseenter","onMousedown"],Py=["aria-label","disabled"],Ly=["aria-label","disabled"],Vy=["aria-label","disabled"],zy={class:"cpk-chat-input-send"},Uy=["aria-label","disabled"],jy={"data-testid":"copilot-chat-input-disclaimer",class:"cpk-chat-input-disclaimer"},gn=t.defineComponent({inheritAttrs:!1,__name:"CopilotChatInput",props:{modelValue:{},disabled:{type:Boolean,default:!1},placeholder:{},autoFocus:{type:Boolean,default:!0},clearOnSubmit:{type:Boolean,default:!0},mode:{default:"input"},toolsMenu:{default:()=>[]},isRunning:{type:Boolean,default:!1},positioning:{default:"static"},keyboardHeight:{default:0},showDisclaimer:{type:Boolean,default:void 0},maxRows:{default:5},bottomAnchored:{type:Boolean,default:!1},onSubmitMessage:{},onStop:{},onAddFile:{},onStartTranscribe:{},onCancelTranscribe:{},onFinishTranscribe:{},onFinishTranscribeWithAudio:{}},emits:["update:modelValue","submit-message","stop","add-file","start-transcribe","cancel-transcribe","finish-transcribe","finish-transcribe-with-audio"],setup(e,{emit:n}){const o=e,a=n,r=t.useAttrs(),s=t.ref(null),i=t.ref(null),l=t.ref(null),c=t.ref(null),u=t.ref(null),d=t.ref(null),p=t.ref(null),h=t.ref(o.modelValue??""),f=t.ref(!1),m=t.ref("compact"),g=t.ref(null),v=t.ref(0),y=t.ref(null),k=t.ref(!1),b=t.ref("content"),w=t.ref(null),S=dt("cpk-add-menu"),C=`${S}-trigger`,A=t.ref({singleLineHeight:0,maxHeight:0,paddingLeft:0,paddingRight:0}),E=t.ref(null),L=t.ref(!1),z=t.ref(null),O=t.ref(null),N=t.ref(!1),K=t.ref(!1);let ae=null;const H=t.computed(()=>o.modelValue!==void 0),M=t.computed(()=>H.value?o.modelValue??"":h.value),I=mt(),B=t.computed(()=>o.placeholder??I.value.chatInputPlaceholder),F=t.computed(()=>o.mode==="input"&&m.value==="expanded"),V=t.computed(()=>o.showDisclaimer??o.positioning==="absolute"),oe=t.computed(()=>typeof o.onSubmitMessage=="function"),ie=t.computed(()=>typeof o.onStop=="function"),Te=t.computed(()=>typeof o.onAddFile=="function"),Ee=t.computed(()=>typeof o.onStartTranscribe=="function"),Ie=t.computed(()=>typeof o.onCancelTranscribe=="function"),Ne=t.computed(()=>typeof o.onFinishTranscribe=="function"||typeof o.onFinishTranscribeWithAudio=="function"),D=t.computed(()=>({mode:o.mode,isRunning:o.isRunning,value:M.value,canSubmit:oe.value,canStop:ie.value,disabled:o.disabled})),$=t.computed(()=>x.ɵcomposerButtonState(D.value)),P=t.computed(()=>$.value.isProcessing),Y=t.computed(()=>$.value.disabled),q=t.computed(()=>$.value.action==="stop"),ne=t.computed(()=>["cpk-chat-input",o.positioning==="absolute"&&"cpk-chat-input-absolute",r.class]),Qe=t.computed(()=>{const T={...r};return delete T.class,T});function et(T){return Array.isArray(T.items)}function Z(){return Te.value?{label:I.value.chatInputToolbarAddButtonLabel,action:()=>a("add-file")}:null}function ye(){const T=[],j=Z();if(j&&T.push(j),o.toolsMenu.length>0){T.length>0&&T.push("-");for(const ee of o.toolsMenu){if(ee==="-"){if(T.length===0||T[T.length-1]==="-")continue;T.push("-");continue}T.push(ee)}}for(;T.length>0&&T[T.length-1]==="-";)T.pop();return T}const Pe=t.computed(()=>ye()),We=t.computed(()=>Pe.value.length>0);function Ct(T){const j=new Set,ee=[],he=Se=>{for(const fe of Se)if(fe!=="-"){if(et(fe)&&fe.items.length>0){he(fe.items);continue}!fe.action||j.has(fe.label)||(j.add(fe.label),ee.push(fe))}};return he(T),ee}const rt=t.computed(()=>Ct(Pe.value));function Tt(T,j=0,ee="root"){const he=[];for(const[Se,fe]of T.entries()){const Le=`${ee}-${Se}`;if(fe==="-"){he.push({type:"separator",key:`sep-${Le}`});continue}if(et(fe)&&fe.items.length>0){he.push({type:"label",key:`label-${Le}`,label:fe.label,depth:j}),he.push(...Tt(fe.items,j+1,Le));continue}fe.action&&he.push({type:"item",key:`item-${Le}`,label:fe.label,depth:j,action:fe.action})}return he}const Dt=t.computed(()=>Tt(Pe.value)),Ue=t.computed(()=>{if(g.value===null||rt.value.length===0)return[];const T=g.value.trim().toLowerCase();if(T.length===0)return rt.value;const j=[],ee=[];for(const he of rt.value){const Se=he.label.toLowerCase();if(Se.startsWith(T)){j.push(he);continue}Se.includes(T)&&ee.push(he)}return[...j,...ee]}),Et=t.computed(()=>g.value!==null&&rt.value.length>0);function Ft(T){H.value||(h.value=T),a("update:modelValue",T)}function ht(){Ft("")}function W(T){if(rt.value.length===0){g.value=null;return}if(T.startsWith("/")){const j=T.split(/\r?\n/,1)[0]??"";g.value=j.slice(1);return}g.value=null}function ce(T){ht(),T.action?.(),g.value=null,v.value=0,requestAnimationFrame(()=>{i.value?.focus()})}function pe(){if(o.mode!=="input"||o.disabled||!oe.value)return;const j=(i.value?.value??M.value).trim();j&&(a("submit-message",j),o.clearOnSubmit&&ht(),i.value?.focus())}function Je(T){const j=T.target.value;Ft(j),W(j)}function He(){if(q.value){a("stop");return}P.value||pe()}function we(T){if(o.disabled||f.value||T.isComposing||T.keyCode===229)return;if(g.value!==null&&o.mode==="input"){if(T.key==="ArrowDown"){Ue.value.length>0&&(T.preventDefault(),v.value=v.value<0?0:(v.value+1)%Ue.value.length);return}if(T.key==="ArrowUp"){Ue.value.length>0&&(T.preventDefault(),v.value<0?v.value=Ue.value.length-1:v.value=v.value<=0?Ue.value.length-1:v.value-1);return}if(T.key==="Enter"){const ee=v.value>=0?Ue.value[v.value]:void 0;if(ee){T.preventDefault(),ce(ee);return}}if(T.key==="Escape"){T.preventDefault(),g.value=null;return}}if(o.mode!=="input")return;const j=x.ɵresolveComposerKey(T,{...D.value,value:i.value?.value??M.value});T.key==="Enter"&&!T.shiftKey&&T.preventDefault(),j==="send"?pe():j==="stop"&&a("stop")}function Me(){const T=c.value;return T?.querySelector("button")??T??null}function Oe(T="content"){if(!(!We.value||o.mode==="transcribe"||o.disabled)){if(k.value){Ke();return}w.value=Me(),b.value=T,k.value=!0}}function Ke(T={}){k.value&&(k.value=!1,T.returnFocus&&Me()?.focus())}function Ge(T){Ke({returnFocus:!0}),T()}function gt(T){T.action&&Ge(T.action)}function je(T){Ke({returnFocus:T!=="outside"})}let on=!1;function G(T){T.button!==0||T.ctrlKey||(on=!0,k.value||T.preventDefault(),Oe("content"))}function le(T){if(on){on=!1;return}Oe(T.detail===0?"first":"content")}function J(T){T.key==="Enter"||T.key===" "?(T.preventDefault(),Oe("first")):(T.key==="ArrowDown"||T.key==="ArrowUp")&&(T.preventDefault(),k.value||Oe(T.key==="ArrowDown"?"first":"last"))}async function ke(){const T=p.value;if(T&&T.state==="recording")try{const j=await T.stop();a("finish-transcribe-with-audio",j)}catch(j){console.error("Failed to stop recording:",j)}a("finish-transcribe")}function lt(T){const j=T.target;!j||o.mode!=="input"||j.tagName==="BUTTON"||j.closest("button")||i.value?.focus()}function Be(){const T=i.value;if(!T||f.value)return;const j=T.value,ee=T.style.height;T.style.height="auto";const he=window.getComputedStyle(T),Se=parseFloat(he.paddingLeft)||0,fe=parseFloat(he.paddingRight)||0,Le=parseFloat(he.paddingTop)||0,Ye=parseFloat(he.paddingBottom)||0;T.value="";const bt=T.scrollHeight;T.value=j;const _t=(bt-Le-Ye)*o.maxRows+Le+Ye;A.value={singleLineHeight:bt,maxHeight:_t,paddingLeft:Se,paddingRight:fe},T.style.height=ee,T.style.maxHeight=`${_t}px`}function tt(){const T=i.value;if(!T)return 0;A.value.singleLineHeight===0&&Be();const{maxHeight:j}=A.value;j&&(T.style.maxHeight=`${j}px`),T.style.height="auto";const ee=T.scrollHeight;return T.style.height=`${j?Math.min(ee,j):ee}px`,ee}function st(T){m.value!==T&&(L.value=!0,m.value=T)}function ct(T){const j=window.getComputedStyle(T);if(j.font?.trim())return j.font;if(j.fontSize&&j.fontFamily){const ee=`${j.fontStyle} ${j.fontVariant} ${j.fontWeight} ${j.fontSize}/${j.lineHeight} ${j.fontFamily}`;if(ee.trim())return ee}return process.env.NODE_ENV!=="production"&&!N.value&&(N.value=!0,console.warn("[CopilotChatInput] Could not resolve textarea font for layout measurement. Text-width-based expansion will be skipped until the next container resize.")),null}function Pt(){const T=l.value,j=c.value,ee=u.value;if(!T||!j||!ee)return O.value=null,null;const he=window.getComputedStyle(T),Se=parseFloat(he.paddingLeft)||0,fe=parseFloat(he.paddingRight)||0,Le=parseFloat(he.columnGap)||0,Ye=T.clientWidth-Se-fe;if(Ye<=0)return O.value=null,null;const bt=j.getBoundingClientRect().width,Ht=ee.getBoundingClientRect().width,_t=Math.max(Ye-bt-Ht-Le*2,0);if(_t<=0)return O.value=null,null;const Tn={compactWidth:_t};return O.value=Tn,Tn}function vt(){if(o.mode!=="input"){st("compact");return}if(typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 767px)").matches){Be(),tt(),st("expanded");return}const T=i.value;if(!T||!l.value||!c.value||!u.value)return;A.value.singleLineHeight===0&&Be();const j=tt(),ee=A.value.singleLineHeight,he=M.value.includes(`
|
|
79
|
+
`),Se=ee>0?j>ee+1:!1;let fe=he||Se;if(!fe){const Le=O.value??Pt();if(Le&&Le.compactWidth>0){const Ye=Math.max(Le.compactWidth-A.value.paddingLeft-A.value.paddingRight,0);if(Ye>0){const bt=z.value??document.createElement("canvas");z.value||(z.value=bt);const Ht=bt.getContext("2d");if(Ht){const _t=ct(T);if(_t){Ht.font=_t;const Tn=M.value.length>0?M.value.split(`
|
|
80
|
+
`):[""];let lo=0;for(const kc of Tn){const Ma=Ht.measureText(kc||" ").width;Ma>lo&&(lo=Ma)}lo>Ye&&(fe=!0)}}else process.env.NODE_ENV!=="production"&&!K.value&&(K.value=!0,console.warn("[CopilotChatInput] canvas.getContext('2d') returned null. Text-width-based expansion will be skipped."))}}}st(fe?"expanded":"compact")}function It(T){if(L.value){L.value=!1;return}T&&(O.value=null,N.value=!1,K.value=!1),E.value!==null&&cancelAnimationFrame(E.value),E.value=requestAnimationFrame(()=>{E.value=null,vt()})}return t.watch(()=>o.modelValue,T=>{H.value&&(h.value=T??"")}),t.watch(M,T=>{W(T),vt()}),t.watch(rt,()=>{rt.value.length===0&&(g.value=null)}),t.watch([g,()=>Ue.value.length],([T,j])=>{T!==null&&T!==y.value&&j>0&&(v.value=0),y.value=T},{immediate:!0}),t.watch([g,Ue],()=>{if(g.value===null){v.value=0;return}if(Ue.value.length===0){v.value=-1;return}(v.value<0||v.value>=Ue.value.length)&&(v.value=0)},{immediate:!0}),t.watch(()=>o.mode,async T=>{T!=="input"&&(m.value="compact",g.value=null,Ke());const j=p.value;if(j){if(T==="transcribe"){try{await j.start()}catch(ee){console.error(ee)}return}if(j.state==="recording")try{await j.stop()}catch{}}},{immediate:!0}),t.watch(p,async T=>{if(!(!T||o.mode!=="transcribe")&&T.state==="idle")try{await T.start()}catch(j){console.error(j)}},{immediate:!0}),t.watch(v,async T=>{if(!Et.value||T<0)return;await t.nextTick(),d.value?.querySelector(`[data-slash-index="${T}"]`)?.scrollIntoView?.({block:"nearest"})}),t.watch(()=>o.disabled,T=>{T&&Ke()}),t.onMounted(()=>{if(o.autoFocus&&o.mode==="input"&&i.value?.focus(),vt(),typeof ResizeObserver<"u"){const T=new Set;l.value&&T.add(l.value),c.value&&T.add(c.value),u.value&&T.add(u.value),ae=new ResizeObserver(j=>{const ee=j.some(he=>T.has(he.target));It(ee)}),l.value&&ae.observe(l.value),c.value&&ae.observe(c.value),u.value&&ae.observe(u.value),i.value&&ae.observe(i.value)}}),t.onBeforeUnmount(()=>{ae?.disconnect(),ae=null,E.value!==null&&(cancelAnimationFrame(E.value),E.value=null)}),(T,j)=>(t.openBlock(),t.createElementBlock("div",t.mergeProps({"data-copilotkit":"","data-testid":"copilot-chat-input-container",class:ne.value,style:{transform:e.keyboardHeight>0?`translateY(-${e.keyboardHeight}px)`:void 0,transition:"transform 0.2s ease-out",...e.positioning==="absolute"||e.bottomAnchored?{paddingBottom:"var(--copilotkit-license-banner-offset, 0px)"}:{}}},Qe.value),[t.createElementVNode("div",_y,[t.renderSlot(T.$slots,"layout",{mode:e.mode,isMultiline:F.value,value:M.value,disabled:e.disabled,placeholder:B.value,isProcessing:P.value,sendDisabled:Y.value,menuOpen:k.value,menuItems:Dt.value,onToggleMenu:()=>Oe(),onMenuAction:Ge,onUpdateValue:Ft,onSubmit:pe,onKeydown:we,onSendClick:He,onStartTranscribe:()=>a("start-transcribe"),onCancelTranscribe:()=>a("cancel-transcribe"),onFinishTranscribe:ke},()=>[t.createElementVNode("div",{ref_key:"shellRef",ref:s,"data-testid":"copilot-chat-input-shell",class:"copilotKitInput cpk-chat-input-pill","data-layout":F.value?"expanded":"compact",onClick:lt},[t.createElementVNode("div",{ref_key:"gridRef",ref:l,class:"cpk-chat-input-grid","data-layout":F.value?"expanded":"compact"},[t.createElementVNode("div",{ref_key:"addButtonContainerRef",ref:c,class:"cpk-chat-input-start"},[t.renderSlot(T.$slots,"add-menu-button",{disabled:e.disabled||e.mode==="transcribe"||!We.value,menuOpen:k.value,toggleMenu:()=>Oe(),labels:t.unref(I)},()=>[t.createVNode(Rt,{side:"bottom",suppressed:k.value},{default:t.withCtx(({triggerProps:ee})=>[t.createElementVNode("button",t.mergeProps(ee,{id:C,type:"button","data-testid":"copilot-chat-input-add","aria-label":t.unref(I).chatInputToolbarAddButtonLabel,"aria-haspopup":"menu","aria-expanded":k.value,"aria-controls":k.value?t.unref(S):void 0,"data-state":k.value?"open":"closed",disabled:e.disabled||e.mode==="transcribe"||!We.value,class:"cpk-button cpk-button-chat-input-toolbar-secondary cpk-button-size-chat-input-toolbar-icon cpk-chat-input-add-menu-button",onPointerdown:G,onClick:t.withModifiers(le,["stop"]),onKeydown:J}),[t.createVNode(t.unref(Mv),{class:"cpk-chat-input-add-menu-icon"})],16,Ry)]),content:t.withCtx(()=>[t.createElementVNode("p",xy,[t.createElementVNode("span",null,t.toDisplayString(t.unref(I).chatInputToolbarAddButtonLabel),1),j[4]||(j[4]=t.createElementVNode("code",{class:"cpk-chat-input-add-menu-shortcut"},"/",-1))])]),_:1},8,["suppressed"])]),t.createVNode(Gl,{id:t.unref(S),open:k.value&&We.value,anchor:w.value,items:Pe.value,"menu-id":t.unref(S),"labelled-by":w.value?.id||void 0,side:"top",align:"start","side-offset":4,"initial-focus":b.value,"data-testid":"copilot-chat-input-add-menu",onSelect:gt,onDismiss:je},null,8,["id","open","anchor","items","menu-id","labelled-by","initial-focus"])],512),t.createElementVNode("div",Oy,[e.mode==="transcribe"?t.renderSlot(T.$slots,"audio-recorder",{key:0},()=>[t.createVNode(Yl,{ref_key:"audioRecorderRef",ref:p},null,512)]):e.mode==="processing"?(t.openBlock(),t.createElementBlock("div",Ny,[t.createVNode(t.unref(Sa),{class:"cpk-chat-input-processing-spinner"})])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[t.renderSlot(T.$slots,"text-area",{value:M.value,disabled:e.disabled,placeholder:B.value,onInput:Je,onKeydown:we,autoFocus:e.autoFocus,isExpanded:F.value,rows:1,labels:t.unref(I)},()=>[t.createElementVNode("textarea",{ref_key:"textareaRef",ref:i,"data-testid":"copilot-chat-input-textarea",value:M.value,placeholder:B.value,disabled:e.disabled,rows:"1",class:t.normalizeClass(["cpk-chat-input-textarea",F.value?"cpk-chat-input-textarea-expanded":"cpk-chat-input-textarea-compact"]),style:{overflow:"auto",resize:"none"},onInput:Je,onKeydown:we,onCompositionstart:j[0]||(j[0]=ee=>f.value=!0),onCompositionend:j[1]||(j[1]=ee=>f.value=!1)},null,42,My)]),Et.value?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"slashMenuRef",ref:d,"data-testid":"copilot-slash-menu",role:"listbox","aria-label":t.unref(I).chatInputSlashMenuLabel,class:"cpk-chat-input-slash-menu",style:{maxHeight:"200px"}},[Ue.value.length===0?(t.openBlock(),t.createElementBlock("div",Dy,t.toDisplayString(t.unref(I).chatInputSlashMenuEmptyText),1)):(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:1},t.renderList(Ue.value,(ee,he)=>(t.openBlock(),t.createElementBlock("button",{key:`${ee.label}-${he}`,type:"button",role:"option","data-slash-index":he,"aria-selected":he===v.value,"data-active":he===v.value?"true":void 0,class:"cpk-chat-input-slash-menu-item",onMouseenter:Se=>v.value=he,onMousedown:t.withModifiers(Se=>ce(ee),["prevent"])},t.toDisplayString(ee.label),41,Fy))),128))],8,By)):t.createCommentVNode("",!0)],64))]),t.createElementVNode("div",{ref_key:"actionsContainerRef",ref:u,class:"cpk-chat-input-actions"},[e.mode==="transcribe"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[Ie.value||T.$slots["cancel-transcribe-button"]?t.renderSlot(T.$slots,"cancel-transcribe-button",{key:0,disabled:e.disabled,onClick:()=>a("cancel-transcribe"),labels:t.unref(I)},()=>[t.createVNode(Rt,{side:"bottom",content:t.unref(I).chatInputToolbarCancelTranscribeButtonLabel},{default:t.withCtx(({triggerProps:ee})=>[t.createElementVNode("button",t.mergeProps(ee,{type:"button","data-testid":"copilot-chat-input-cancel-transcribe","aria-label":t.unref(I).chatInputToolbarCancelTranscribeButtonLabel,disabled:e.disabled,class:"cpk-button cpk-button-chat-input-toolbar-secondary cpk-button-size-chat-input-toolbar-icon cpk-chat-input-cancel-transcribe-button",onClick:j[2]||(j[2]=he=>a("cancel-transcribe"))}),[t.createVNode(t.unref(wn),{class:"cpk-chat-input-toolbar-icon"})],16,Py)]),_:1},8,["content"])]):t.createCommentVNode("",!0),Ne.value||T.$slots["finish-transcribe-button"]?t.renderSlot(T.$slots,"finish-transcribe-button",{key:1,disabled:e.disabled,onClick:ke,labels:t.unref(I)},()=>[t.createVNode(Rt,{side:"bottom",content:t.unref(I).chatInputToolbarFinishTranscribeButtonLabel},{default:t.withCtx(({triggerProps:ee})=>[t.createElementVNode("button",t.mergeProps(ee,{type:"button","data-testid":"copilot-chat-input-finish-transcribe","aria-label":t.unref(I).chatInputToolbarFinishTranscribeButtonLabel,disabled:e.disabled,class:"cpk-button cpk-button-chat-input-toolbar-secondary cpk-button-size-chat-input-toolbar-icon cpk-chat-input-finish-transcribe-button",onClick:ke}),[t.createVNode(t.unref(so),{class:"cpk-chat-input-toolbar-icon"})],16,Ly)]),_:1},8,["content"])]):t.createCommentVNode("",!0)],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[Ee.value||T.$slots["start-transcribe-button"]?t.renderSlot(T.$slots,"start-transcribe-button",{key:0,disabled:e.disabled,onClick:()=>a("start-transcribe"),labels:t.unref(I)},()=>[t.createVNode(Rt,{side:"bottom",content:t.unref(I).chatInputToolbarStartTranscribeButtonLabel},{default:t.withCtx(({triggerProps:ee})=>[t.createElementVNode("button",t.mergeProps(ee,{type:"button","data-testid":"copilot-chat-input-start-transcribe","aria-label":t.unref(I).chatInputToolbarStartTranscribeButtonLabel,disabled:e.disabled,class:"cpk-button cpk-button-chat-input-toolbar-secondary cpk-button-size-chat-input-toolbar-icon cpk-chat-input-start-transcribe-button",onClick:j[3]||(j[3]=he=>a("start-transcribe"))}),[t.createVNode(t.unref(xv),{class:"cpk-chat-input-toolbar-icon"})],16,Vy)]),_:1},8,["content"])]):t.createCommentVNode("",!0),t.renderSlot(T.$slots,"send-button",{disabled:Y.value,isProcessing:P.value,onClick:He},()=>[t.createElementVNode("div",zy,[t.createElementVNode("button",{type:"button","data-testid":"copilot-chat-input-send","aria-label":q.value?t.unref(I).chatInputToolbarStopButtonLabel:t.unref(I).chatInputToolbarSendButtonLabel,disabled:Y.value,class:"cpk-button cpk-button-chat-input-toolbar-primary cpk-button-size-chat-input-toolbar-icon cpk-chat-input-send-button",onClick:He},[q.value?(t.openBlock(),t.createBlock(t.unref(Dv),{key:0,class:"cpk-chat-input-stop-icon"})):(t.openBlock(),t.createBlock(t.unref(Pl),{key:1,class:"cpk-chat-input-send-icon"}))],8,Uy)])])],64))],512)],8,$y)],8,Ay)])]),V.value?t.renderSlot(T.$slots,"disclaimer",{key:0,labels:t.unref(I)},()=>[t.createElementVNode("p",jy,t.toDisplayString(t.unref(I).chatDisclaimerText),1)]):t.createCommentVNode("",!0)],16))}}),Zy=["aria-label"],Wy=["aria-label"],Hy='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), audio[controls], video[controls], iframe, [tabindex]:not([tabindex="-1"])',oc=t.defineComponent({__name:"CopilotChatLightbox",props:{label:{},returnFocusTo:{}},emits:["close"],setup(e,{emit:n}){const o=e,a=n,r=Re(),s=t.computed(()=>r.value?.labels??x.CopilotChatDefaultLabels),i=t.ref(null),l=t.ref(null);let c=null;function u(p){p.key==="Escape"&&a("close")}function d(p){if(p.key!=="Tab"||!i.value)return;const h=Array.from(i.value.querySelectorAll(Hy)),f=h[0],m=h[h.length-1];if(!f||!m)return;const g=document.activeElement;p.shiftKey&&(g===f||!i.value.contains(g))?(p.preventDefault(),m.focus()):!p.shiftKey&&g===m&&(p.preventDefault(),f.focus())}return t.onMounted(()=>{typeof document>"u"||(c=document.activeElement instanceof HTMLElement?document.activeElement:null,document.addEventListener("keydown",u),t.nextTick(()=>l.value?.focus()))}),t.onBeforeUnmount(()=>{if(typeof document>"u")return;document.removeEventListener("keydown",u);const p=o.returnFocusTo??c;p?.isConnected&&p.focus()}),(p,h)=>(t.openBlock(),t.createBlock(t.Teleport,{to:"body"},[t.createElementVNode("div",{ref_key:"root",ref:i,class:"cpk-attachment-lightbox",role:"dialog","aria-modal":"true","aria-label":e.label,"data-testid":"copilot-chat-attachment-lightbox",onClick:h[2]||(h[2]=f=>a("close")),onKeydown:d},[t.createElementVNode("button",{ref_key:"closeButton",ref:l,type:"button",class:"cpk-attachment-lightbox-close-button","aria-label":s.value.attachmentPreviewCloseButtonLabel,onClick:h[0]||(h[0]=t.withModifiers(f=>a("close"),["stop"]))},[t.createVNode(t.unref(wn),{class:"cpk-attachment-lightbox-close-icon","aria-hidden":"true"})],8,Wy),t.createElementVNode("div",{"data-testid":"copilot-chat-attachment-lightbox-content",onClick:h[1]||(h[1]=t.withModifiers(()=>{},["stop"]))},[t.renderSlot(p.$slots,"default")])],40,Zy)]))}}),Ky=["data-card-type"],Gy={key:0,class:"cpk-attachment-queue-uploading-overlay","data-testid":"copilot-chat-attachment-uploading-overlay"},qy=["onClick"],Jy=["src","alt"],Yy={class:"cpk-attachment-queue-video"},Xy=["src","alt"],Qy=["src"],ek=["aria-label","onClick"],tk={class:"cpk-attachment-queue-video-play-badge"},nk={key:2,class:"cpk-attachment-queue-audio"},ok=["src"],ak={key:0,class:"cpk-attachment-queue-audio-filename"},rk=["onClick"],sk={class:"cpk-attachment-queue-document-icon"},ik={class:"cpk-attachment-queue-document-info"},lk={class:"cpk-attachment-queue-document-name","data-testid":"copilot-chat-attachment-document-filename"},ck={key:0,class:"cpk-attachment-queue-document-size"},uk={key:2,class:"cpk-attachment-queue-placeholder","data-testid":"copilot-chat-attachment-placeholder"},dk=["aria-label","onClick"],pk=["src","alt"],fk=["src"],mk=["src","title"],hk={key:1,class:"cpk-attachment-queue-text-preview"},gk={key:0,class:"cpk-attachment-queue-text-preview-filename"},vk={key:1,class:"cpk-attachment-queue-text-preview-content","data-testid":"copilot-chat-attachment-lightbox-document-text"},bk=["src","title"],yk={key:2,class:"cpk-attachment-queue-document-card","data-testid":"copilot-chat-attachment-lightbox-document-fallback"},kk={class:"cpk-attachment-queue-document-card-icon"},Sk={class:"cpk-attachment-queue-document-card-details"},wk={class:"cpk-attachment-queue-document-card-name"},Ck={class:"cpk-attachment-queue-document-card-meta"},Tk={class:"cpk-attachment-queue-document-card-note"},Ko=t.defineComponent({__name:"CopilotChatAttachmentQueue",props:{attachments:{default:()=>[]},className:{default:""}},emits:["remove-attachment"],setup(e,{emit:n}){const o=e,a=n,r=mt(),s=t.ref(null),i=t.ref(null),l=t.computed(()=>{const y=s.value;if(y)return y.filename?y.filename:y.type==="image"?r.value.attachmentImageAltText:y.type==="video"?"Video attachment":r.value.attachmentDocumentLabel}),c=t.computed(()=>{const y=s.value;if(!y||y.type!=="document")return!1;const k=y.source.mimeType;return m(k)||g(k)}),u=t.computed(()=>{const y=s.value;if(!y||y.type!=="document")return null;const k=y.source.mimeType;if(!g(k)||y.source.type!=="data")return null;try{return atob(y.source.value)}catch{return y.source.value}}),d=t.computed(()=>{const y=s.value;return!y||y.type!=="document"?null:y.source.type==="url"?y.source.value:i.value});t.watch(s,(y,k)=>{if(i.value&&(URL.revokeObjectURL(i.value),i.value=null),!y||y.type!=="document"||y.source.type!=="data"||typeof window>"u")return;const b=y.source.mimeType;if(!m(b)&&!g(b))return;const w=v(y.source.value,b);i.value=w},{immediate:!0}),t.onBeforeUnmount(()=>{i.value&&(URL.revokeObjectURL(i.value),i.value=null)});function p(y){if(typeof document<"u"){const k=document;if(typeof k.startViewTransition=="function"){k.startViewTransition(()=>{s.value=y});return}}s.value=y}function h(){s.value=null}function f(y){return y.type==="image"||y.type==="video"?"cpk-attachment-queue-item-media":y.type==="audio"?"cpk-attachment-queue-item-audio":"cpk-attachment-queue-item-document"}function m(y){return!!y&&y.includes("pdf")}function g(y){return!!y&&y.startsWith("text/")}function v(y,k){try{const b=atob(y),w=new Uint8Array(b.length);for(let C=0;C<b.length;C+=1)w[C]=b.charCodeAt(C);const S=new Blob([w],{type:k||"application/octet-stream"});return URL.createObjectURL(S)}catch(b){return console.error("[CopilotKit] Failed to decode attachment data:",b),null}}return(y,k)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[o.attachments.length>0?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["cpk-attachment-queue",o.className]),"data-testid":"copilot-chat-attachment-queue"},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.attachments,b=>(t.openBlock(),t.createElementBlock("div",{key:b.id,class:t.normalizeClass(["cpk-attachment-queue-item",f(b)]),"data-testid":"copilot-chat-attachment-item","data-card-type":b.type},[b.status==="uploading"?(t.openBlock(),t.createElementBlock("div",Gy,[...k[0]||(k[0]=[t.createElementVNode("div",{class:"cpk-attachment-queue-uploading-spinner"},null,-1)])])):t.createCommentVNode("",!0),b.status==="ready"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[b.type==="image"?(t.openBlock(),t.createElementBlock("button",{key:0,type:"button",class:"cpk-attachment-queue-preview-button","data-testid":"copilot-chat-attachment-image-button",onClick:w=>p(b)},[t.createElementVNode("img",{src:t.unref(Q.getSourceUrl)(b.source),alt:b.filename||"Image attachment",class:"cpk-attachment-queue-image","data-testid":"copilot-chat-attachment-image-thumbnail"},null,8,Jy)],8,qy)):b.type==="video"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createElementVNode("div",Yy,[b.thumbnail?(t.openBlock(),t.createElementBlock("img",{key:0,src:b.thumbnail,alt:b.filename||"Video thumbnail",class:"cpk-attachment-queue-video-thumbnail","data-testid":"copilot-chat-attachment-video-thumbnail"},null,8,Xy)):(t.openBlock(),t.createElementBlock("video",{key:1,src:t.unref(Q.getSourceUrl)(b.source),preload:"metadata",muted:"",class:"cpk-attachment-queue-video-thumbnail","data-testid":"copilot-chat-attachment-video-fallback"},null,8,Qy))]),t.createElementVNode("button",{type:"button",class:"cpk-attachment-queue-video-play-button","aria-label":t.unref(r).attachmentPlayVideoButtonLabel,"data-testid":"copilot-chat-attachment-video-play",onClick:w=>p(b)},[t.createElementVNode("div",tk,[t.createVNode(t.unref(Nv),{class:"cpk-attachment-queue-video-play-icon"})])],8,ek)],64)):b.type==="audio"?(t.openBlock(),t.createElementBlock("div",nk,[t.createElementVNode("audio",{src:t.unref(Q.getSourceUrl)(b.source),controls:"",preload:"metadata",class:"cpk-attachment-queue-audio-player","data-testid":"copilot-chat-attachment-audio-player"},null,8,ok),b.filename?(t.openBlock(),t.createElementBlock("span",ak,t.toDisplayString(b.filename),1)):t.createCommentVNode("",!0)])):(t.openBlock(),t.createElementBlock("button",{key:3,type:"button",class:t.normalizeClass(["cpk-attachment-queue-preview-button cpk-attachment-queue-document",{"cpk-attachment-queue-document-previewable":m(b.source.mimeType)||g(b.source.mimeType)}]),"data-testid":"copilot-chat-attachment-document-button",onClick:w=>(m(b.source.mimeType)||g(b.source.mimeType))&&p(b)},[t.createElementVNode("div",sk,t.toDisplayString(t.unref(Q.getDocumentIcon)(b.source.mimeType??"")),1),t.createElementVNode("div",ik,[t.createElementVNode("span",lk,t.toDisplayString(b.filename||t.unref(r).attachmentDocumentLabel),1),b.size!=null?(t.openBlock(),t.createElementBlock("span",ck,t.toDisplayString(t.unref(Q.formatFileSize)(b.size)),1)):t.createCommentVNode("",!0)])],10,rk))],64)):(t.openBlock(),t.createElementBlock("div",uk)),t.createElementVNode("button",{type:"button",class:"cpk-attachment-queue-remove-button","aria-label":t.unref(r).attachmentRemoveButtonLabel,onClick:w=>a("remove-attachment",b.id)}," ✕ ",8,dk)],10,Ky))),128))],2)):t.createCommentVNode("",!0),s.value?(t.openBlock(),t.createBlock(oc,{key:1,label:l.value,onClose:h},{default:t.withCtx(()=>[s.value.type==="image"?(t.openBlock(),t.createElementBlock("img",{key:0,src:t.unref(Q.getSourceUrl)(s.value.source),alt:s.value.filename||"Image attachment",class:"cpk-attachment-queue-lightbox-image","data-testid":"copilot-chat-attachment-lightbox-image"},null,8,pk)):s.value.type==="video"?(t.openBlock(),t.createElementBlock("video",{key:1,src:t.unref(Q.getSourceUrl)(s.value.source),controls:"",autoplay:"",class:"cpk-attachment-queue-lightbox-video","data-testid":"copilot-chat-attachment-lightbox-video"},null,8,fk)):s.value.type==="document"?(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[c.value&&m(s.value.source.mimeType)&&d.value?(t.openBlock(),t.createElementBlock("iframe",{key:0,src:d.value,title:s.value.filename||"PDF preview",class:"cpk-attachment-queue-pdf-preview","data-testid":"copilot-chat-attachment-lightbox-document-iframe"},null,8,mk)):c.value&&g(s.value.source.mimeType)?(t.openBlock(),t.createElementBlock("div",hk,[s.value.filename?(t.openBlock(),t.createElementBlock("div",gk,t.toDisplayString(s.value.filename),1)):t.createCommentVNode("",!0),u.value!==null?(t.openBlock(),t.createElementBlock("pre",vk,t.toDisplayString(u.value),1)):d.value?(t.openBlock(),t.createElementBlock("iframe",{key:2,src:d.value,title:s.value.filename||"Text preview",class:"cpk-attachment-queue-text-preview-frame","data-testid":"copilot-chat-attachment-lightbox-document-iframe"},null,8,bk)):t.createCommentVNode("",!0)])):(t.openBlock(),t.createElementBlock("div",yk,[t.createElementVNode("div",kk,t.toDisplayString(t.unref(Q.getDocumentIcon)(s.value.source.mimeType??"")),1),t.createElementVNode("div",Sk,[t.createElementVNode("div",wk,t.toDisplayString(s.value.filename||t.unref(r).attachmentDocumentLabel),1),t.createElementVNode("div",Ck,t.toDisplayString(s.value.source.mimeType||t.unref(r).attachmentUnknownTypeText)+" "+t.toDisplayString(s.value.size!=null?` · ${t.unref(Q.formatFileSize)(s.value.size)}`:""),1)]),t.createElementVNode("div",Tk,t.toDisplayString(t.unref(r).attachmentNoPreviewText),1)]))],64)):t.createCommentVNode("",!0)]),_:1},8,["label"])):t.createCommentVNode("",!0)],64))}}),Ek=["data-message-id"],Ik=["aria-expanded"],_k={class:"cpk-reasoning-message-label"},Ak={key:0,class:"cpk-reasoning-message-indicator"},$k={class:"cpk-reasoning-message-toggle-content"},Rk={key:0,class:"cpk-reasoning-message-content"},xk={class:"cpk-reasoning-message-text"},Ok={key:0,class:"cpk-reasoning-message-cursor"},ac=t.defineComponent({__name:"CopilotChatReasoningMessage",props:{message:{},messages:{default:()=>[]},isRunning:{type:Boolean,default:!1}},setup(e){const n=e;function o(y,k){const b=x.ɵformatReasoningDuration(k);switch(b.unit){case"fewSeconds":return y.reasoningMessageDurationFewSeconds;case"seconds":return x.ɵformatLabel(y.reasoningMessageDurationSeconds,{count:b.seconds});case"minutes":return x.ɵformatLabel(b.minutes===1?y.reasoningMessageDurationMinutesOne:y.reasoningMessageDurationMinutesOther,{count:b.minutes});case"minutesSeconds":return x.ɵformatLabel(y.reasoningMessageDurationMinutesSeconds,{minutes:b.minutes,seconds:b.seconds})}}const a=t.computed(()=>typeof n.message.content=="string"?n.message.content:""),r=t.computed(()=>a.value.length>0),s=t.computed(()=>n.messages[n.messages.length-1]?.id===n.message.id),i=t.computed(()=>!!(n.isRunning&&s.value)),l=t.ref(0),c=t.ref(i.value),u=t.ref(!1);let d=null,p=null;function h(){p&&(clearInterval(p),p=null)}function f(){d!==null&&(l.value=(Date.now()-d)/1e3)}t.watch(i,y=>{if(y){d===null&&(d=Date.now()),h(),p=setInterval(f,1e3),u.value=!1,c.value=!0;return}h(),f(),u.value||(c.value=!1)},{immediate:!0}),t.onBeforeUnmount(()=>{h()});const m=mt(),g=t.computed(()=>i.value?m.value.reasoningMessageThinkingLabel:x.ɵformatLabel(m.value.reasoningMessageThoughtForLabel,{duration:o(m.value,l.value)}));function v(){r.value&&(u.value=!0,c.value=!c.value)}return(y,k)=>(t.openBlock(),t.createElementBlock("div",{"data-copilotkit":"",class:"cpk-reasoning-message","data-message-id":e.message.id},[t.renderSlot(y.$slots,"layout",{message:e.message,messages:e.messages,isRunning:e.isRunning,header:{isOpen:c.value,label:g.value,hasContent:r.value,isStreaming:i.value,elapsedSeconds:l.value,onClick:r.value?v:void 0},contentView:{isStreaming:i.value,hasContent:r.value,content:a.value},toggle:{isOpen:c.value,contentView:{isStreaming:i.value,hasContent:r.value,content:a.value}}},()=>[t.renderSlot(y.$slots,"header",{isOpen:c.value,label:g.value,hasContent:r.value,isStreaming:i.value,elapsedSeconds:l.value,onClick:r.value?v:void 0},()=>[t.createElementVNode("button",{type:"button",class:t.normalizeClass(["cpk-reasoning-message-header",{"cpk-reasoning-message-header-expandable":r.value}]),"aria-expanded":r.value?c.value:void 0,onClick:k[0]||(k[0]=b=>r.value?v():void 0)},[t.createElementVNode("span",_k,t.toDisplayString(g.value),1),i.value&&!r.value?(t.openBlock(),t.createElementBlock("span",Ak,[...k[1]||(k[1]=[t.createElementVNode("span",{class:"cpk-reasoning-message-indicator-dot"},null,-1)])])):t.createCommentVNode("",!0),r.value?(t.openBlock(),t.createBlock(t.unref(tn),{key:1,class:t.normalizeClass(["cpk-reasoning-message-chevron",{"cpk-reasoning-message-chevron-open":c.value}])},null,8,["class"])):t.createCommentVNode("",!0)],10,Ik)]),t.renderSlot(y.$slots,"toggle",{isOpen:c.value,contentView:{isStreaming:i.value,hasContent:r.value,content:a.value}},()=>[t.createElementVNode("div",{class:"cpk-reasoning-message-toggle",style:t.normalizeStyle({gridTemplateRows:c.value?"1fr":"0fr"})},[t.createElementVNode("div",$k,[t.renderSlot(y.$slots,"content-view",{isStreaming:i.value,hasContent:r.value,content:a.value},()=>[r.value||i.value?(t.openBlock(),t.createElementBlock("div",Rk,[t.createElementVNode("div",xk,[t.createVNode(ka,{content:a.value,"is-streaming":i.value},null,8,["content","is-streaming"]),i.value&&r.value?(t.openBlock(),t.createElementBlock("span",Ok,[...k[2]||(k[2]=[t.createElementVNode("span",{class:"cpk-reasoning-message-cursor-dot"},null,-1)])])):t.createCommentVNode("",!0)])])):t.createCommentVNode("",!0)])])],4)])])],8,Ek))}});function Nk(){const e=t.ref(null),n=t.ref(!1),o=dt("cpk-lightbox").replace(/[^\w-]/g,"-");return{thumbnailRef:e,vtName:o,open:n,openLightbox:()=>{const s=e.value,i=typeof document>"u"?void 0:document;i?.startViewTransition&&s?(s.style.viewTransitionName=o,i.startViewTransition(async()=>{s.style.viewTransitionName="",n.value=!0,await t.nextTick()})):n.value=!0},closeLightbox:()=>{const s=e.value,i=typeof document>"u"?void 0:document;if(i?.startViewTransition&&s){const l=i.startViewTransition(async()=>{n.value=!1,await t.nextTick(),s.style.viewTransitionName=o}),c=()=>{s.style.viewTransitionName=""};l.finished.then(c,c)}else n.value=!1}}}const Mk=["src","alt"],Bk=["src","alt"],Dk=["src"],Fk={key:0,class:"cpk-attachment-renderer-audio-filename","data-testid":"copilot-chat-attachment-renderer-audio-filename"},Pk=["src"],Lk=["href","download","aria-label"],Vk={class:"cpk-attachment-renderer-document-icon","data-testid":"copilot-chat-attachment-renderer-document-icon"},zk={class:"cpk-attachment-renderer-document-name","data-testid":"copilot-chat-attachment-renderer-document-label"},rc=t.defineComponent({__name:"CopilotChatAttachmentRenderer",props:{type:{},source:{},filename:{default:void 0},className:{default:""}},setup(e){const n=e,o=mt(),a=t.ref(!1),r=t.computed(()=>Q.getSourceUrl(n.source)),s=t.computed(()=>n.filename||n.source.mimeType||o.value.attachmentUnknownTypeText),i=t.computed(()=>n.filename||n.source.mimeType||o.value.attachmentDocumentAltText),l=t.ref(null),{thumbnailRef:c,vtName:u,open:d,openLightbox:p,closeLightbox:h}=Nk();return(f,m)=>n.type==="image"&&!a.value?(t.openBlock(),t.createElementBlock("button",{key:0,ref_key:"imageButton",ref:l,type:"button",class:"cpk-attachment-renderer-image-button","data-testid":"copilot-chat-attachment-renderer-image-button",onClick:m[1]||(m[1]=(...g)=>t.unref(p)&&t.unref(p)(...g))},[t.createElementVNode("img",{ref_key:"thumbnailRef",ref:c,src:r.value,alt:t.unref(o).attachmentImageAltText,class:t.normalizeClass(["cpk-attachment-renderer cpk-attachment-renderer-image",n.className]),"data-testid":"copilot-chat-attachment-renderer-image",onError:m[0]||(m[0]=g=>a.value=!0)},null,42,Mk),t.unref(d)?(t.openBlock(),t.createBlock(oc,{key:0,label:t.unref(o).attachmentImageAltText,"return-focus-to":l.value,onClose:t.unref(h)},{default:t.withCtx(()=>[t.createElementVNode("img",{style:t.normalizeStyle({viewTransitionName:t.unref(u)}),src:r.value,alt:t.unref(o).attachmentImageAltText,class:"cpk-attachment-renderer-lightbox-image","data-testid":"copilot-chat-attachment-renderer-lightbox-image"},null,12,Bk)]),_:1},8,["label","return-focus-to","onClose"])):t.createCommentVNode("",!0)],512)):n.type==="image"?(t.openBlock(),t.createElementBlock("div",{key:1,class:t.normalizeClass(["cpk-attachment-renderer cpk-attachment-renderer-image-error",n.className]),"data-testid":"copilot-chat-attachment-renderer-image-fallback"},[t.createElementVNode("span",null,t.toDisplayString(t.unref(o).attachmentImageLoadErrorText),1)],2)):n.type==="audio"?(t.openBlock(),t.createElementBlock("div",{key:2,class:t.normalizeClass(["cpk-attachment-renderer cpk-attachment-renderer-audio",n.className]),"data-testid":"copilot-chat-attachment-renderer-audio"},[t.createElementVNode("audio",{src:r.value,controls:"",preload:"metadata",class:"cpk-attachment-renderer-audio-player"},null,8,Dk),n.filename?(t.openBlock(),t.createElementBlock("span",Fk,t.toDisplayString(n.filename),1)):t.createCommentVNode("",!0)],2)):n.type==="video"?(t.openBlock(),t.createElementBlock("video",{key:3,src:r.value,controls:"",preload:"metadata",class:t.normalizeClass(["cpk-attachment-renderer cpk-attachment-renderer-video",n.className]),"data-testid":"copilot-chat-attachment-renderer-video"},null,10,Pk)):(t.openBlock(),t.createElementBlock("a",{key:4,href:r.value,download:n.filename??"",target:"_blank",rel:"noopener noreferrer","aria-label":i.value,class:t.normalizeClass(["cpk-attachment-renderer cpk-attachment-renderer-document",n.className]),"data-testid":"copilot-chat-attachment-renderer-document"},[t.createElementVNode("span",Vk,t.toDisplayString(t.unref(Q.getDocumentIcon)(n.source.mimeType??"")),1),t.createElementVNode("span",zk,t.toDisplayString(s.value),1)],10,Lk))}}),Uk=["data-message-id"],jk={key:0,class:"cpk-user-message-attachments","data-testid":"copilot-user-message-attachments"},Zk={class:"cpk-user-message-bubble"},Wk={"data-testid":"copilot-user-toolbar",class:"cpk-user-message-toolbar"},Hk={class:"cpk-user-message-toolbar-items"},Kk=["aria-label"],Gk=["aria-label"],qk={"data-testid":"copilot-branch-navigation",class:"cpk-user-message-branch-navigation"},Jk=["disabled","aria-label"],Yk={class:"cpk-user-message-branch-counter"},Xk=["disabled","aria-label"],Nn="cpk-button cpk-button-assistant-message-toolbar cpk-button-size-default",sc=t.defineComponent({__name:"CopilotChatUserMessage",props:{message:{},branchIndex:{default:0},numberOfBranches:{default:1},onEditMessage:{},onSwitchToBranch:{}},emits:["edit-message","switch-to-branch"],setup(e,{emit:n}){const o=e,a=n,r=Re(),s=t.computed(()=>r.value?.labels??x.CopilotChatDefaultLabels),i=t.ref(!1);let l=null;function c(E){return E?typeof E=="string"?E:E.map(L=>L&&typeof L=="object"&&"type"in L&&L.type==="text"&&typeof L.text=="string"?L.text:"").filter(L=>L.length>0).join(`
|
|
81
|
+
`):""}function u(E){return!E||typeof E=="string"?[]:E.filter(L=>L.type==="image"||L.type==="audio"||L.type==="video"||L.type==="document")}function d(E){const L=E.metadata;if(L!=null&&typeof L=="object"&&"filename"in L&&typeof L.filename=="string")return L.filename}const p=t.computed(()=>u(o.message.content)),h=t.computed(()=>c(o.message.content)),f=t.computed(()=>h.value.includes(`
|
|
82
|
+
`)),m=t.computed(()=>typeof o.onEditMessage=="function"),g=t.computed(()=>o.numberOfBranches>1&&typeof o.onSwitchToBranch=="function"),v=t.computed(()=>g.value&&o.branchIndex>0),y=t.computed(()=>g.value&&o.branchIndex<o.numberOfBranches-1);function k(){l&&clearTimeout(l),i.value=!0,l=setTimeout(()=>{i.value=!1,l=null},2e3)}async function b(){if(h.value&&!(typeof navigator>"u"||typeof navigator.clipboard?.writeText!="function"))try{await navigator.clipboard.writeText(h.value),k()}catch(E){console.error("Failed to copy to clipboard:",E)}}function w(){if(!m.value)return;const E={message:o.message};a("edit-message",E)}function S(E){if(!g.value)return;const L={branchIndex:E,numberOfBranches:o.numberOfBranches,message:o.message};a("switch-to-branch",L)}function C(){v.value&&S(o.branchIndex-1)}function A(){y.value&&S(o.branchIndex+1)}return t.onBeforeUnmount(()=>{l&&clearTimeout(l)}),(E,L)=>t.renderSlot(E.$slots,"layout",{message:e.message,content:h.value,isMultiline:f.value,showBranchNavigation:g.value,hasEditAction:m.value,branchIndex:e.branchIndex,numberOfBranches:e.numberOfBranches,canGoPrev:v.value,canGoNext:y.value,onCopy:b,onEdit:w,goPrev:C,goNext:A,copied:i.value},()=>[t.createElementVNode("div",t.mergeProps({"data-copilotkit":"","data-testid":"copilot-user-message",class:"copilotKitMessage copilotKitUserMessage cpk-user-message","data-message-id":e.message.id},E.$attrs),[p.value.length>0?(t.openBlock(),t.createElementBlock("div",jk,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(p.value,(z,O)=>(t.openBlock(),t.createBlock(rc,{key:O,type:z.type,source:z.source,filename:d(z)},null,8,["type","source","filename"]))),128))])):t.createCommentVNode("",!0),t.renderSlot(E.$slots,"message-renderer",{message:e.message,content:h.value,isMultiline:f.value},()=>[t.createElementVNode("div",Zk,t.toDisplayString(h.value),1)]),t.renderSlot(E.$slots,"toolbar",{message:e.message,showBranchNavigation:g.value,hasEditAction:m.value},()=>[t.createElementVNode("div",Wk,[t.createElementVNode("div",Hk,[t.renderSlot(E.$slots,"toolbar-items"),t.renderSlot(E.$slots,"copy-button",{onCopy:b,copied:i.value,label:s.value.userMessageToolbarCopyMessageLabel},()=>[t.createVNode(Rt,{content:s.value.userMessageToolbarCopyMessageLabel,side:"bottom"},{default:t.withCtx(({triggerProps:z})=>[t.createElementVNode("button",t.mergeProps({"data-testid":"copilot-user-copy-button",type:"button",class:Nn,"aria-label":s.value.userMessageToolbarCopyMessageLabel},z,{onClick:b}),[i.value?(t.openBlock(),t.createBlock(t.unref(so),{key:0,class:"cpk-user-message-toolbar-icon"})):(t.openBlock(),t.createBlock(t.unref(Ll),{key:1,class:"cpk-user-message-toolbar-icon"}))],16,Kk)]),_:1},8,["content"])]),m.value||E.$slots["edit-button"]?t.renderSlot(E.$slots,"edit-button",{key:0,onEdit:w,label:s.value.userMessageToolbarEditMessageLabel},()=>[t.createVNode(Rt,{content:s.value.userMessageToolbarEditMessageLabel,side:"bottom"},{default:t.withCtx(({triggerProps:z})=>[t.createElementVNode("button",t.mergeProps({"data-testid":"copilot-edit-button",type:"button",class:Nn,"aria-label":s.value.userMessageToolbarEditMessageLabel},z,{onClick:w}),[t.createVNode(t.unref(Av),{class:"cpk-user-message-toolbar-icon"})],16,Gk)]),_:1},8,["content"])]):t.createCommentVNode("",!0),e.numberOfBranches>1&&(g.value||E.$slots["branch-navigation"])?t.renderSlot(E.$slots,"branch-navigation",{key:1,branchIndex:e.branchIndex,numberOfBranches:e.numberOfBranches,canGoPrev:v.value,canGoNext:y.value,goPrev:C,goNext:A},()=>[t.createElementVNode("div",qk,[t.createElementVNode("button",{type:"button",class:t.normalizeClass([Nn,"cpk-user-message-branch-button"]),disabled:!v.value,"aria-label":s.value.userMessageToolbarPreviousBranchLabel,onClick:C},[t.createVNode(t.unref(Iv),{class:"cpk-user-message-branch-icon"})],8,Jk),t.createElementVNode("span",Yk,t.toDisplayString(e.branchIndex+1)+"/"+t.toDisplayString(e.numberOfBranches),1),t.createElementVNode("button",{type:"button",class:t.normalizeClass([Nn,"cpk-user-message-branch-button"]),disabled:!y.value,"aria-label":s.value.userMessageToolbarNextBranchLabel,onClick:A},[t.createVNode(t.unref(tn),{class:"cpk-user-message-branch-icon"})],8,Xk)])]):t.createCommentVNode("",!0)])])])],16,Uk)])}}),Qk=["data-state","aria-expanded"],eS={class:"cpk-work-summary-label cpk-shimmer"},tS={key:0,class:"cpk-work-summary-detail cpk-work-summary-timer"},nS={class:"cpk-work-summary-label"},oS={key:0,class:"cpk-work-summary-detail"},aS={key:1,class:"cpk-work-summary-failed"},ic=t.defineComponent({__name:"CopilotChatWorkSummary",props:{isWorking:{type:Boolean},isOpen:{type:Boolean},calls:{},elapsedMs:{},workingSince:{}},setup(e){const n=e,o=t.ref(Date.now());t.watch(()=>n.isWorking,(p,h,f)=>{if(!p)return;o.value=Date.now();const m=setInterval(()=>{o.value=Date.now()},1e3);f(()=>clearInterval(m))},{immediate:!0});const a=mt(),r=t.computed(()=>x.ɵcountFailedToolCalls(n.calls)),s=t.computed(()=>n.elapsedMs!==void 0&&n.workingSince!==void 0?n.elapsedMs+Math.max(0,o.value-n.workingSince):void 0),i=t.computed(()=>n.elapsedMs!==void 0?x.ɵformatWorkDuration(Math.max(1e3,n.elapsedMs)):void 0),l=t.computed(()=>x.ɵformatCountLabel(n.calls.length,{one:a.value.toolCallToolCountOne,other:a.value.toolCallToolCountOther})),c=t.computed(()=>i.value?x.ɵformatLabel(a.value.workSummaryWorkedForLabel,{duration:i.value}):x.ɵformatCountLabel(n.calls.length,{one:a.value.toolCallUsedToolsOne,other:a.value.toolCallUsedToolsOther})),u=t.computed(()=>s.value!==void 0?x.ɵformatWorkDuration(s.value):void 0),d=t.computed(()=>x.ɵformatLabel(a.value.toolCallFailedCountLabel,{count:r.value}));return(p,h)=>(t.openBlock(),t.createElementBlock("button",{type:"button","data-copilotkit":"","data-testid":"copilot-work-summary","data-state":e.isWorking?"working":"done","aria-expanded":e.isOpen?"true":"false",class:"cpk-work-summary"},[e.isWorking?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("span",eS,t.toDisplayString(t.unref(a).workSummaryWorkingLabel),1),u.value!==void 0?(t.openBlock(),t.createElementBlock("span",tS,t.toDisplayString(u.value),1)):t.createCommentVNode("",!0)],64)):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createElementVNode("span",nS,t.toDisplayString(c.value),1),i.value?(t.openBlock(),t.createElementBlock("span",oS,t.toDisplayString(l.value),1)):t.createCommentVNode("",!0),r.value>0?(t.openBlock(),t.createElementBlock("span",aS,t.toDisplayString(d.value),1)):t.createCommentVNode("",!0)],64)),t.createVNode(t.unref(tn),{"aria-hidden":"true",class:t.normalizeClass(["cpk-work-summary-chevron",e.isOpen&&"cpk-work-summary-chevron-open"])},null,8,["class"])],8,Qk))}}),rS={key:2,class:"cpk-message-view-cursor-container"},lc=t.defineComponent({__name:"CopilotChatMessageView",props:{messages:{default:()=>[]},isRunning:{type:Boolean,default:!1},toolCallDisplay:{default:"grouped"},messageFeedback:{type:Boolean,default:!0}},setup(e){const n=e,{copilotkit:o}=Ve(),a=Re(),r=t.ref(0),s=t.ref(null),i=t.useSlots(),l=t.computed(()=>Object.keys(i)),c=t.computed(()=>a.value?.agentId??Q.DEFAULT_AGENT_ID),u=t.computed(()=>(o.value.agents,o.value.getAgent(c.value)));t.watch([c,()=>a.value?.threadId,()=>o.value,()=>o.value.runtimeConnectionStatus],(B,F,V)=>{const oe=u.value;if(!oe)return;const ie=oe.subscribe({onStateChanged:()=>{r.value+=1},onRunStartedEvent:()=>{r.value+=1},onRunFinishedEvent:()=>{r.value+=1},onRunErrorEvent:()=>{r.value+=1}});V(()=>ie.unsubscribe())},{immediate:!0}),t.watch(()=>o.value,(B,F,V)=>{s.value=B.interruptState;const oe=B.subscribe({onInterruptStateChanged:({interruptState:ie})=>{s.value=ie},onRuntimeConnectionStatusChanged:()=>{r.value+=1}});V(()=>oe.unsubscribe())},{immediate:!0});const d=t.computed(()=>x.ɵdeduplicateMessages(n.messages)),p=t.computed(()=>n.toolCallDisplay==="separate"?new Map:x.ɵgetToolCallLayouts(d.value,n.messages,x.ɵgetToolCallRendererNames(o.value.renderToolCalls,{slotNames:l.value}))),h=hy(o);t.provide(ql,t.computed(()=>n.messageFeedback&&h.value&&a.value?.agentId!==void 0&&a.value?.threadId!==void 0?{copilotkit:o.value,agentId:a.value.agentId,threadId:a.value.threadId}:null));const f=t.computed(()=>n.toolCallDisplay==="turn"?x.ɵgetTurnWork(d.value,p.value):void 0),m=t.computed(()=>{const B=new Map;for(const F of f.value?.values()??[])B.set(F.firstMessageId,F);return B}),g=t.computed(()=>d.value[d.value.length-1]),v=t.computed(()=>x.ɵgetLatestTurnKey(d.value)),y=t.ref(new Map),k=t.computed(()=>({toggledTurns:y.value,isRunning:n.isRunning,latestTurnKey:v.value})),b=new Map,w=t.ref(0);t.watch([()=>n.toolCallDisplay,()=>n.isRunning,v,()=>g.value?.role],([B,F,V,oe])=>{B==="turn"&&(x.ɵrecordWorkTime(b,{isRunning:F,latestTurnKey:V,lastMessageRole:oe,now:Date.now()}),w.value++)},{immediate:!0});const S=t.computed(()=>x.ɵgetWorkOpenState(f.value?.values()??[],k.value));t.provide(Ca,t.computed(()=>({display:n.toolCallDisplay,isRunning:n.isRunning,layouts:p.value,workOpen:S.value.workOpen,workTextOpen:S.value.workTextOpen})));const C=({turnKey:B,calls:F})=>{w.value;const V=x.ɵisTurnWorking(B,k.value),oe=x.ɵisTurnWorkOpen(B,k.value),ie=b.get(B),Te={isWorking:V,isOpen:oe,calls:F,elapsedMs:ie?.elapsedMs,workingSince:ie?.workingSince,onClick:()=>{y.value=new Map(y.value).set(B,!oe)}},Ee=i["work-summary"];return t.h(Zt,{open:V||F.length>0},()=>[t.h("div",{class:"cpk-message-view-work-summary"},Ee?Ee(Te):[t.h(ic,Te)])])};C.props=["turnKey","calls"];const A=Q.createRowKeyStore(),E=t.computed(()=>Q.resolveRowRenderKeysById(A,d.value));t.onMounted(()=>Q.commitRowKeyStore(A,d.value)),t.watch(d,B=>Q.commitRowKeyStore(A,B),{flush:"post"});const L=t.computed(()=>n.messages[n.messages.length-1]),z=t.computed(()=>n.isRunning&&L.value?.role!=="reasoning"&&n.toolCallDisplay!=="turn"),O=t.computed(()=>n.toolCallDisplay==="turn"&&n.isRunning&&g.value?.role==="user");t.watch([()=>n.messages.length,()=>d.value.length],([B,F])=>{process.env.NODE_ENV==="development"&&F<B&&console.warn(`CopilotChatMessageView: Deduplicated ${B-F} message(s) with duplicate IDs.`)},{immediate:!0});function N(B){r.value+=0;const F=c.value,V=a.value?.threadId??"",oe=o.value,ie=oe.getRunIdForMessage(F,V,B.id)??oe.getRunIdsForThread(F,V).slice(-1)[0],Te=ie??`missing-run-id:${B.id}`,Ee=u.value??oe.getAgent(F),Ie=ie&&Ee?Ee.messages.filter(ne=>oe.getRunIdForMessage(F,V,ne.id)===ie).map(ne=>ne.id):[B.id],Ne=Ee?Ee.messages.findIndex(ne=>ne.id===B.id):-1,D=Ne>=0?Ne:0,$=ie?Math.max(Ie.indexOf(B.id),0):0,P=ie?Ie.length:1;let Y,q=!1;return{runId:Te,messageIndex:D,messageIndexInRun:$,numberOfMessagesInRun:P,agentId:F,get stateSnapshot(){return q||(q=!0,Y=ie?oe.getStateByRun(F,V,ie):void 0),Y}}}function K(B,F){return Object.assign(N(B),{message:B,position:F})}const ae=({render:B,slotProps:F})=>B(F);ae.props=["render","slotProps"];function H(B){return`activity-${B}`}function M(B,F){if(r.value+=0,i[F==="before"?"message-before":"message-after"])return null;const oe=x.ɵresolveCustomMessageRenderers(o.value.renderCustomMessages,c.value).find(ie=>ie.render);return oe?{renderer:oe.render,props:K(B,F)}:null}function I(B){r.value+=0;const F=x.ɵresolveActivityRenderer(o.value.renderActivityMessages,{activityType:B.activityType,agentId:c.value,content:B.content});return F?{renderer:F.renderer.render,props:{activityType:B.activityType,content:F.content,message:B,agent:u.value}}:null}return(B,F)=>(t.openBlock(),t.createElementBlock("div",t.mergeProps({"data-copilotkit":"",class:"copilotKitMessages cpk-message-view"},B.$attrs),[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(d.value,V=>(t.openBlock(),t.createElementBlock(t.Fragment,{key:E.value.get(V.id)??V.id},[m.value.get(V.id)?(t.openBlock(),t.createBlock(C,{key:0,"turn-key":m.value.get(V.id).key,calls:m.value.get(V.id).calls},null,8,["turn-key","calls"])):t.createCommentVNode("",!0),t.unref(i)["message-before"]?(t.openBlock(),t.createBlock(ae,{key:1,render:t.unref(i)["message-before"],"slot-props":K(V,"before")},null,8,["render","slot-props"])):M(V,"before")?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(M(V,"before").renderer),t.mergeProps({key:2,ref_for:!0},M(V,"before").props),null,16)):t.createCommentVNode("",!0),V.role==="assistant"?t.renderSlot(B.$slots,"assistant-message",{key:3,message:V,messages:e.messages,isRunning:e.isRunning},()=>[t.createVNode(Jl,{message:V,messages:e.messages,"is-running":e.isRunning},t.createSlots({_:2},[t.renderList(l.value,oe=>({name:oe,fn:t.withCtx(ie=>[t.renderSlot(B.$slots,oe,t.mergeProps({ref_for:!0},ie))])}))]),1032,["message","messages","is-running"])]):V.role==="user"?t.renderSlot(B.$slots,"user-message",{key:4,message:V},()=>[t.createVNode(sc,{message:V},t.createSlots({_:2},[t.renderList(l.value,oe=>({name:oe,fn:t.withCtx(ie=>[t.renderSlot(B.$slots,oe,t.mergeProps({ref_for:!0},ie))])}))]),1032,["message"])]):V.role==="reasoning"?(t.openBlock(),t.createBlock(t.unref(Ul),{key:5,open:e.toolCallDisplay==="turn"?S.value.workOpen.get(V.id)??!0:void 0},{default:t.withCtx(()=>[t.renderSlot(B.$slots,"reasoning-message",{message:V,messages:e.messages,isRunning:e.isRunning},()=>[t.createVNode(ac,{message:V,messages:e.messages,"is-running":e.isRunning},null,8,["message","messages","is-running"])])]),_:2},1032,["open"])):V.role==="activity"?t.renderSlot(B.$slots,H(V.activityType),{key:6,activityType:V.activityType,content:V.content,message:V,agent:u.value},()=>[t.renderSlot(B.$slots,"activity-message",{activityType:V.activityType,content:V.content,message:V,agent:u.value},()=>[I(V)?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(I(V).renderer),t.mergeProps({key:0,ref_for:!0},I(V).props),null,16)):t.createCommentVNode("",!0)])]):t.createCommentVNode("",!0),t.unref(i)["message-after"]?(t.openBlock(),t.createBlock(ae,{key:7,render:t.unref(i)["message-after"],"slot-props":K(V,"after")},null,8,["render","slot-props"])):M(V,"after")?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(M(V,"after").renderer),t.mergeProps({key:8,ref_for:!0},M(V,"after").props),null,16)):t.createCommentVNode("",!0)],64))),128)),s.value?t.renderSlot(B.$slots,"interrupt",{key:0,event:s.value.event,interrupt:s.value.interrupt,interrupts:s.value.interrupts,result:s.value.result,resolve:s.value.resolve,cancel:s.value.cancel}):t.createCommentVNode("",!0),O.value?(t.openBlock(),t.createBlock(C,{key:1,"turn-key":v.value,calls:[]},null,8,["turn-key"])):t.createCommentVNode("",!0),z.value?(t.openBlock(),t.createElementBlock("div",rS,[t.renderSlot(B.$slots,"cursor",{},()=>[F[0]||(F[0]=t.createElementVNode("div",{class:"cpk-message-view-cursor","data-testid":"copilot-loading-cursor"},null,-1))])])):t.createCommentVNode("",!0)],16))}}),sS=["type","aria-busy","disabled"],iS={key:0,class:"cpk-suggestion-pill-icon"},lS={key:1,class:"cpk-suggestion-pill-icon"},cS={class:"cpk-suggestion-pill-label"},cc=t.defineComponent({__name:"CopilotChatSuggestionPill",props:{icon:{default:void 0},isLoading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},type:{default:"button"}},setup(e){const n=e,o=t.computed(()=>n.isLoading||n.disabled);return(a,r)=>(t.openBlock(),t.createElementBlock("button",t.mergeProps({"data-copilotkit":"","data-slot":"suggestion-pill","data-testid":"copilot-chat-suggestion-pill",type:e.type,"aria-busy":e.isLoading?"true":void 0,disabled:o.value,class:"cpk-suggestion-pill"},a.$attrs),[e.isLoading?(t.openBlock(),t.createElementBlock("span",iS,[t.createVNode(t.unref(Sa),{class:"cpk-suggestion-pill-spinner","aria-hidden":"true"})])):a.$slots.icon||e.icon?(t.openBlock(),t.createElementBlock("span",lS,[t.renderSlot(a.$slots,"icon",{},()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.icon)))])])):t.createCommentVNode("",!0),t.createElementVNode("span",cS,[t.renderSlot(a.$slots,"default")])],16,sS))}}),vn=t.defineComponent({inheritAttrs:!1,__name:"CopilotChatSuggestionView",props:{suggestions:{},loadingIndexes:{default:()=>[]}},emits:["select-suggestion"],setup(e,{emit:n}){const o=e,a=n,r=t.useAttrs(),s=t.computed(()=>new Set(o.loadingIndexes)),i=t.computed(()=>["cpk-suggestion-view",r.class]),l=t.computed(()=>{const{class:p,...h}=r;return h});function c(p,h){return s.value.has(p)||h.isLoading===!0}function u(p,h){a("select-suggestion",p,h)}const d=t.computed(()=>({suggestions:o.suggestions,loadingIndexes:o.loadingIndexes,onSelectSuggestion:u,containerClass:i.value,containerAttrs:l.value}));return(p,h)=>t.renderSlot(p.$slots,"layout",t.normalizeProps(t.guardReactiveProps(d.value)),()=>[t.renderSlot(p.$slots,"container",t.normalizeProps(t.guardReactiveProps(d.value)),()=>[t.createElementVNode("div",t.mergeProps({"data-copilotkit":"","data-testid":"copilot-chat-suggestion-view",class:i.value},l.value),[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.suggestions,(f,m)=>t.renderSlot(p.$slots,"suggestion",{key:`${f.title}-${m}`,suggestion:f,index:m,isLoading:c(m,f),onSelect:()=>u(f,m)},()=>[t.createVNode(cc,{"is-loading":c(m,f),type:"button",onClick:g=>u(f,m)},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(f.title),1)]),_:2},1032,["is-loading","onClick"])])),128))],16)])])}}),uS=["pin-to-bottom","pin-to-send","none"];function dS(e){return e===void 0||e===!0?"pin-to-bottom":e===!1?"none":uS.includes(e)?e:"pin-to-bottom"}const pS=["data-copilot-running"],fS={key:0,class:"cpk-chat-view-drop-overlay","data-testid":"copilot-chat-drop-overlay"},mS={class:"cpk-chat-view-drop-overlay-content"},hS={class:"cpk-chat-view-drop-overlay-label"},gS={class:"cpk-chat-view-welcome-screen","data-testid":"copilot-chat-view-welcome-screen"},vS={class:"cpk-chat-view-welcome-screen-content"},bS={class:"cpk-chat-view-welcome-screen-message"},yS={class:"cpk-chat-view-welcome-message"},kS={class:"cpk-chat-view-welcome-screen-input cpk-chat-view-welcome-input-group"},SS={key:0,class:"cpk-chat-view-welcome-screen-suggestions"},wS={class:"cpk-chat-view-scroll-content"},CS={class:"cpk-chat-view-feed"},TS={key:0,class:"cpk-chat-view-suggestions"},ES=["aria-label"],IS={key:0,class:"cpk-chat-view-attachments"},_S=16,AS=12,Cn=t.defineComponent({__name:"CopilotChatView",props:{messages:{default:()=>[]},autoScroll:{type:[String,Boolean],default:!0},isRunning:{type:Boolean,default:!1},suggestions:{default:()=>[]},suggestionLoadingIndexes:{default:()=>[]},welcomeScreen:{type:Boolean,default:!0},attachments:{},dragOver:{type:Boolean},inputValue:{default:void 0},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},onSubmitMessage:{},onStop:{},onInputChange:{},onSelectSuggestion:{},onStartTranscribe:{},onCancelTranscribe:{},onFinishTranscribe:{},isConnecting:{type:Boolean,default:!1},hasExplicitThreadId:{type:Boolean,default:!1},onRemoveAttachment:{},onAddFile:{},onDragOver:{},onDragLeave:{},onDrop:{},onFinishTranscribeWithAudio:{type:Function,default:void 0},toolCallDisplay:{},messageFeedback:{type:Boolean,default:!0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(e,{emit:n}){const o=e,a=n,r=mt(),s=t.useSlots(),i=t.ref(null),l=t.ref(null),c=t.ref(null),u=t.ref(null),d=t.ref(0),p=t.ref(!0),h=t.computed(()=>o.inputValue!==void 0),f=t.ref(o.inputValue??""),m=t.computed(()=>dS(o.autoScroll)),g=t.computed(()=>m.value==="pin-to-bottom"),v=t.computed(()=>m.value==="pin-to-send");Iy({scrollRef:i,contentRef:l,spacerRef:c,topOffset:16});const{isKeyboardOpen:y,keyboardHeight:k}=tc(),b=t.computed(()=>y.value?k.value:0),w=t.computed(()=>h.value?o.inputValue??"":f.value),S=t.computed(()=>!o.isConnecting&&!o.isRunning&&Array.isArray(o.suggestions)&&o.suggestions.length>0),C=t.computed(()=>Array.isArray(o.attachments)&&o.attachments.length>0),A=t.computed(()=>Object.keys(s).filter(Z=>Z!=="message-view"&&Z!=="scroll-view"&&Z!=="feather"&&Z!=="scroll-to-bottom-button"&&Z!=="input"&&Z!=="suggestion-view"&&Z!=="welcome-screen"&&Z!=="welcome-message")),E=t.computed(()=>o.messages.length===0&&o.welcomeScreen!==!1&&!o.isConnecting&&!o.hasExplicitThreadId),L=t.computed(()=>`${d.value+(S.value?4:32)}px`),z=t.computed(()=>!E.value&&!p.value);let O=null,N=null;function K(){if(typeof ResizeObserver>"u")return;O?.disconnect(),O=null;const Z=u.value;Z&&(O=new ResizeObserver(ye=>{const Pe=p.value,We=ye[0]?.contentRect?.height;typeof We=="number"?d.value=We:M(),H(),g.value&&Pe&&I("auto")}),O.observe(Z))}function ae(){if(typeof ResizeObserver>"u")return;N?.disconnect(),N=null;const Z=l.value;Z&&(N=new ResizeObserver(()=>{const ye=p.value;H(),g.value&&ye&&I("auto")}),N.observe(Z))}t.watch(E,async Z=>{Z||(await t.nextTick(),M(),K(),ae())}),t.watch(()=>o.inputValue,Z=>{h.value&&(f.value=Z??"")}),t.watch([()=>o.messages,()=>o.suggestions,()=>o.isRunning],async()=>{const Z=p.value;await t.nextTick(),!(!g.value||!Z)&&(I("auto"),typeof requestAnimationFrame=="function"&&requestAnimationFrame(()=>{I("auto")}))},{deep:!0});function H(){const Z=i.value;if(!Z){p.value=!0;return}const ye=Z.scrollHeight-Z.scrollTop-Z.clientHeight;p.value=ye<=AS}function M(){const Z=u.value;d.value=Z?.offsetHeight??0}function I(Z="smooth"){const ye=i.value;ye&&(typeof ye.scrollTo=="function"?ye.scrollTo({top:ye.scrollHeight,behavior:Z}):ye.scrollTop=ye.scrollHeight,H())}function B(){H()}function F(Z){h.value||(f.value=Z),a("input-change",Z)}function V(Z){a("submit-message",Z)}function oe(){a("stop")}function ie(Z,ye){a("select-suggestion",Z,ye)}function Te(){a("add-file")}function Ee(Z){o.onDragOver?.(Z)}function Ie(Z){o.onDragLeave?.(Z)}function Ne(Z){o.onDrop?.(Z)}function D(){a("start-transcribe")}function $(){a("cancel-transcribe")}function P(){a("finish-transcribe")}async function Y(Z){await o.onFinishTranscribeWithAudio?.(Z)}const q=t.computed(()=>{const Z={"onUpdate:modelValue":F,onSubmitMessage:o.onSubmitMessage?V:void 0};return o.onStop&&(Z.onStop=oe),o.onAddFile&&(Z.onAddFile=Te),o.onStartTranscribe&&(Z.onStartTranscribe=D),o.onCancelTranscribe&&(Z.onCancelTranscribe=$),o.onFinishTranscribe&&(Z.onFinishTranscribe=P),o.onFinishTranscribeWithAudio&&(Z.onFinishTranscribeWithAudio=Y),Z}),ne=t.computed(()=>!!o.onStop),Qe=t.computed(()=>!!o.onAddFile),et=t.computed(()=>!!o.onStartTranscribe);return t.onMounted(async()=>{await t.nextTick(),M(),H(),g.value&&(I("auto"),typeof requestAnimationFrame=="function"&&requestAnimationFrame(()=>{I("auto")})),K(),ae()}),t.onBeforeUnmount(()=>{O?.disconnect(),N?.disconnect(),O=null,N=null}),(Z,ye)=>(t.openBlock(),t.createElementBlock("div",t.mergeProps({"data-copilotkit":"",class:"copilotKitChat cpk-chat-view","data-testid":"copilot-chat-view","data-copilot-running":e.isRunning?"true":"false"},Z.$attrs,{onDragover:Ee,onDragleave:Ie,onDrop:Ne}),[e.dragOver?(t.openBlock(),t.createElementBlock("div",fS,[t.createElementVNode("div",mS,[t.createVNode(t.unref(Lv),{class:"cpk-chat-view-drop-overlay-icon"}),t.createElementVNode("span",hS,t.toDisplayString(t.unref(r).chatDropFilesLabel),1)])])):t.createCommentVNode("",!0),E.value?t.renderSlot(Z.$slots,"welcome-screen",{key:1,suggestions:e.suggestions,loadingIndexes:e.suggestionLoadingIndexes,attachments:e.attachments??[],modelValue:w.value,isRunning:e.isRunning,inputMode:e.inputMode,inputToolsMenu:e.inputToolsMenu,canStop:ne.value,canAddFile:Qe.value,canTranscribe:et.value,onUpdateModelValue:F,onSubmitMessage:V,onStop:oe,onAddFile:Te,onStartTranscribe:D,onCancelTranscribe:$,onFinishTranscribe:P,onFinishTranscribeWithAudio:Y,onSelectSuggestion:ie},()=>[t.createElementVNode("div",gS,[t.createElementVNode("div",vS,[t.createElementVNode("div",bS,[t.renderSlot(Z.$slots,"welcome-message",{},()=>[t.createElementVNode("h1",yS,t.toDisplayString(t.unref(r).welcomeMessageText),1)])]),t.createElementVNode("div",kS,[C.value?(t.openBlock(),t.createBlock(Ko,{key:0,attachments:e.attachments??[],"class-name":"cpk-chat-view-welcome-attachment-queue",onRemoveAttachment:ye[0]||(ye[0]=Pe=>e.onRemoveAttachment&&e.onRemoveAttachment(Pe))},null,8,["attachments"])):t.createCommentVNode("",!0),t.renderSlot(Z.$slots,"input",{modelValue:w.value,isRunning:e.isRunning,inputMode:e.inputMode,inputToolsMenu:e.inputToolsMenu,attachments:e.attachments??[],canStop:ne.value,canAddFile:Qe.value,canTranscribe:et.value,onUpdateModelValue:F,onSubmitMessage:V,onStop:oe,onAddFile:Te,onStartTranscribe:D,onCancelTranscribe:$,onFinishTranscribe:P,onFinishTranscribeWithAudio:Y},()=>[t.createVNode(gn,t.mergeProps({"model-value":w.value,"is-running":e.isRunning,mode:e.inputMode,"tools-menu":e.inputToolsMenu,positioning:"static","show-disclaimer":!0,"keyboard-height":b.value},q.value),null,16,["model-value","is-running","mode","tools-menu","keyboard-height"])])]),S.value?(t.openBlock(),t.createElementBlock("div",SS,[t.renderSlot(Z.$slots,"suggestion-view",{suggestions:e.suggestions,loadingIndexes:e.suggestionLoadingIndexes,onSelectSuggestion:ie},()=>[t.createVNode(vn,{class:"cpk-chat-view-suggestion-view",suggestions:e.suggestions,"loading-indexes":e.suggestionLoadingIndexes,onSelectSuggestion:ie},null,8,["suggestions","loading-indexes"])])])):t.createCommentVNode("",!0)])])]):(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[t.renderSlot(Z.$slots,"scroll-view",{messages:e.messages,isRunning:e.isRunning,suggestions:e.suggestions,loadingIndexes:e.suggestionLoadingIndexes,messagePaddingBottom:L.value,showScrollToBottomButton:z.value,onSelectSuggestion:ie,onScroll:B,scrollToBottom:I},()=>[t.createElementVNode("div",{ref_key:"scrollContainerRef",ref:i,"data-testid":"copilot-chat-view-scroll",class:"cpk-chat-view-scroll-area cpk-chat-view-scroll-viewport",onScroll:B},[t.createElementVNode("div",wS,[t.createElementVNode("div",{ref_key:"scrollContentRef",ref:l,"data-testid":"copilot-scroll-content",style:t.normalizeStyle({paddingBottom:L.value})},[t.createElementVNode("div",CS,[t.renderSlot(Z.$slots,"message-view",{messages:e.messages,isRunning:e.isRunning},()=>[t.createVNode(lc,{messages:e.messages,"is-running":e.isRunning,"tool-call-display":e.toolCallDisplay,"message-feedback":e.messageFeedback},t.createSlots({_:2},[t.renderList(A.value,Pe=>({name:Pe,fn:t.withCtx(We=>[t.renderSlot(Z.$slots,Pe,t.normalizeProps(t.guardReactiveProps(We)))])}))]),1032,["messages","is-running","tool-call-display","message-feedback"])]),S.value?(t.openBlock(),t.createElementBlock("div",TS,[t.renderSlot(Z.$slots,"suggestion-view",{suggestions:e.suggestions,loadingIndexes:e.suggestionLoadingIndexes,onSelectSuggestion:ie},()=>[t.createVNode(vn,{class:"cpk-chat-view-suggestion-view",suggestions:e.suggestions,"loading-indexes":e.suggestionLoadingIndexes,onSelectSuggestion:ie},null,8,["suggestions","loading-indexes"])])])):t.createCommentVNode("",!0)])],4),v.value?(t.openBlock(),t.createElementBlock("div",{key:0,ref_key:"spacerRef",ref:c,"data-pin-to-send-spacer":"","aria-hidden":"true",style:{height:"0px",flex:"0 0 auto"}},null,512)):t.createCommentVNode("",!0)])],544)]),t.renderSlot(Z.$slots,"feather",{},()=>[ye[3]||(ye[3]=t.createElementVNode("div",{"data-testid":"copilot-chat-view-feather"},null,-1))]),z.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"cpk-chat-view-scroll-to-bottom",style:t.normalizeStyle({bottom:`${d.value+_S}px`})},[t.renderSlot(Z.$slots,"scroll-to-bottom-button",{onClick:()=>I()},()=>[t.createElementVNode("button",{type:"button","data-testid":"copilot-chat-view-scroll-to-bottom","aria-label":t.unref(r).chatScrollToBottomLabel,"data-slot":"button",class:"cpk-button cpk-button-outline cpk-button-size-sm cpk-chat-view-scroll-to-bottom-button",onClick:ye[1]||(ye[1]=Pe=>I())},[t.createVNode(t.unref(Ev),{class:"cpk-chat-view-scroll-to-bottom-icon"})],8,ES)])],4)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"inputContainerRef",ref:u,class:"cpk-chat-view-input-overlay","data-testid":"copilot-input-overlay"},[C.value?(t.openBlock(),t.createElementBlock("div",IS,[t.createVNode(Ko,{attachments:e.attachments??[],"class-name":"cpk-chat-view-attachment-queue",onRemoveAttachment:ye[2]||(ye[2]=Pe=>e.onRemoveAttachment&&e.onRemoveAttachment(Pe))},null,8,["attachments"])])):t.createCommentVNode("",!0),t.renderSlot(Z.$slots,"input",{modelValue:w.value,isRunning:e.isRunning,inputMode:e.inputMode,inputToolsMenu:e.inputToolsMenu,attachments:e.attachments??[],canStop:ne.value,canAddFile:Qe.value,canTranscribe:et.value,onUpdateModelValue:F,onSubmitMessage:V,onStop:oe,onAddFile:Te,onStartTranscribe:D,onCancelTranscribe:$,onFinishTranscribe:P,onFinishTranscribeWithAudio:Y},()=>[t.createVNode(gn,t.mergeProps({"model-value":w.value,"is-running":e.isRunning,mode:e.inputMode,"tools-menu":e.inputToolsMenu,positioning:"static","show-disclaimer":!0,"keyboard-height":b.value,"bottom-anchored":!0},q.value),null,16,["model-value","is-running","mode","tools-menu","keyboard-height"])])],512)],64))],16,pS))}});function $S(e){const n=t.ref(null),o=(r,s)=>{n.value=null,x.emitInspectorActiveThread({requestId:r.requestId,threadId:s,agentId:r.agentId,source:"app"})},a=r=>{const s=n.value;!s||s.requestId!==r||(x.emitInspectorViewThreadResult({requestId:r,threadId:s.threadId,agentId:s.agentId,ok:!1,reason:"connect-failed"}),o(s,s.previousThreadId))};if(x.isInspectorThreadBridgeEnabled()){const r=x.onInspectorViewThread(i=>i.agentId!==e.agentId.value?!1:(n.value=n.value?{...n.value,...i}:{...i,previousThreadId:e.baseThreadId.value},x.emitInspectorViewThreadResult({...i,ok:!0}),x.emitInspectorActiveThread({...i,source:"override"}),!0)),s=x.onInspectorStopViewing(i=>{const l=n.value;l&&i.requestId===l.requestId&&i.agentId===l.agentId&&o(l,l.previousThreadId)});t.onBeforeUnmount(()=>{r(),s()})}return t.watch([e.agentId,e.baseThreadId],([r,s])=>{const i=n.value;if(i){if(r!==i.agentId){o(i,i.previousThreadId);return}s!==i.previousThreadId&&s!==i.threadId&&o(i,s)}}),{inspectorThreadId:t.computed(()=>n.value?.threadId??null),inspectorRequestId:t.computed(()=>n.value?.requestId??null),failInspectorOverride:a}}const _r=new WeakMap,uc=t.defineComponent({name:"CopilotKitStyles",setup(){const e=t.inject(rl,()=>t.computed(()=>({inject:!0})),!0),n=t.getCurrentInstance().appContext;let o=_r.get(n);o||(o=t.shallowRef([]),_r.set(n,o));const a=o,r={enabled:()=>e.value.inject},s=()=>{a.value.includes(r)||(a.value=[...a.value,r])},i=()=>{a.value=a.value.filter(c=>c!==r)};s(),t.onUnmounted(i),t.onDeactivated(i),t.onActivated(s);const l=t.computed(()=>a.value.find(c=>c.enabled())===r);return()=>{if(!l.value)return null;const{nonce:c}=e.value;return t.h("style",{"data-copilotkit-styles":"",nonce:c,"data-allow-mismatch":c?"attribute":void 0,innerHTML:Ac.stylesheet})}}}),RS=["accept"],xS={key:2,style:{position:"absolute",bottom:"100px",left:"50%",transform:"translateX(-50%)","background-color":"#ef4444",color:"white",padding:"8px 16px","border-radius":"8px","font-size":"14px","z-index":"50"}},Aa=t.defineComponent({inheritAttrs:!1,__name:"CopilotChat",props:{inputMode:{default:"input"},agentId:{},threadId:{},throttleMs:{},labels:{},attachments:{},onError:{},autoScroll:{type:[String,Boolean],default:!0},welcomeScreen:{type:Boolean,default:!0},inputValue:{default:void 0},inputToolsMenu:{default:()=>[]},isConnecting:{type:Boolean},hasExplicitThreadId:{type:Boolean},onFinishTranscribeWithAudio:{type:Function,default:void 0},toolCallDisplay:{},messageFeedback:{type:Boolean,default:!0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(e,{emit:n}){const o=e,a=n,r=t.useAttrs(),s=t.useSlots(),i=Re(),{copilotkit:l}=Ve(),c=t.computed(()=>Object.keys(s).filter(G=>G!=="chat-view")),u=t.ref(Q.randomUUID()),d=t.ref("input"),p=t.ref(o.inputValue??""),h=t.ref(null),f=t.ref(!1),m=t.ref(!1),g=t.ref(!1),v=t.shallowRef(null);let y=null;const k=new WeakMap;let b=Promise.resolve();const w=new WeakMap,S=t.computed(()=>o.agentId??i.value?.agentId??Q.DEFAULT_AGENT_ID),C=t.computed(()=>o.threadId??i.value?.threadId),A=t.computed(()=>C.value??u.value),E=t.computed(()=>!!o.threadId||!!i.value?.hasExplicitThreadId),{inspectorThreadId:L,inspectorRequestId:z,failInspectorOverride:O}=$S({agentId:S,baseThreadId:A}),N=t.computed(()=>L.value??A.value),K=t.computed(()=>L.value!==null||E.value),ae=t.ref(null),H=t.computed(()=>K.value&&ae.value!==N.value),M=Sl(t.computed(()=>o.labels)),I=t.computed(()=>M.value),B=t.computed(()=>({...x.CopilotChatDefaultLabels,...i.value?.labels,...I.value})),{agent:F}=io({agentId:S,throttleMs:t.computed(()=>o.throttleMs)}),{suggestions:V}=Ql({agentId:S}),oe=Sn(),ie=t.computed(()=>oe.value.checkFeature("chat"));t.watch(ie,G=>{G||console.warn('[CopilotKit] Warning: "chat" feature is not licensed. Visit copilotkit.ai/pricing')},{immediate:!0});const Te=t.computed(()=>l.value.audioFileTranscriptionEnabled),Ee=t.computed(()=>typeof window<"u"&&typeof MediaRecorder<"u"),Ie=t.computed(()=>Te.value&&Ee.value),{attachments:Ne,enabled:D,dragOver:$,fileInputRef:P,containerRef:Y,handleFileUpload:q,handleDragOver:ne,handleDragLeave:Qe,handleDrop:et,removeAttachment:Z,consumeAttachments:ye}=ec({config:t.computed(()=>o.attachments)}),Pe=t.computed(()=>f.value?"processing":d.value),We=t.ref(0),Ct=t.computed(()=>[...F.value?.messages??[]]),rt=t.computed(()=>(We.value,F.value?.isRunning??!1)),Tt=t.computed(()=>rt.value&&Ct.value.length>0),Dt=t.computed(()=>{for(let G=Ct.value.length-1;G>=0;G--){const le=Ct.value[G];if(le?.role==="user")return le.id}return null}),Ue=t.ref(0);let Et=Dt.value;t.watch(Dt,G=>{G&&G!==Et&&(Ue.value+=1,Et=G)});const Ft=t.computed(()=>({id:Dt.value,sendNonce:Ue.value}));t.provide(nc,Ft),t.watch(()=>F.value,(G,le,J)=>{if(!G)return;const ke=G.subscribe({onRunStartedEvent:()=>{We.value+=1},onRunFinishedEvent:()=>{We.value+=1},onRunErrorEvent:()=>{We.value+=1}});J(()=>ke.unsubscribe())},{immediate:!0}),t.watch(()=>o.inputValue,G=>{G!==void 0&&(p.value=G)}),t.watch([()=>o.threadId,()=>i.value?.threadId],([G,le],J)=>{G||le||J&&(J[0]||J[1])&&(u.value=Q.randomUUID())}),t.watch([()=>l.value,S,()=>o.onError],([G,le,J],ke,lt)=>{if(!J)return;const Be=G.subscribe({onError:tt=>{(tt.context?.agentId===le||!tt.context?.agentId)&&J({error:tt.error,code:tt.code,context:tt.context})}});lt(()=>Be.unsubscribe())},{immediate:!0}),t.watch([()=>l.value,S,N,z],([G,le,J,ke],lt,Be)=>{if(!ke)return;const tt=G.subscribe({onError:st=>{st.code===x.CopilotKitCoreErrorCode.AGENT_CONNECT_FAILED&&st.context?.agentId===le&&st.context?.threadId===J&&O(ke)}});Be(()=>tt.unsubscribe())},{immediate:!0}),t.watch([m,()=>l.value,()=>F.value,N,K,z],([G,le,J,ke,lt,Be],tt,st)=>{if(!G||typeof window>"u"||!J)return;const ct=v.value;if(ct!==null&&ct.threadId!==ke&&ct.inspectorRequestId!==Be&&(ct.inspectorRequestId!==null||Be!==null))try{le.stopAgent({agent:J})}catch{}if(w.set(J,J.threadId),J.threadId=ke,!lt)return;const vt=zn.AbstractAgent.prototype,It=J,T=It.connect!==vt.connect,j=It.connectAgent!==vt.connectAgent;if(!T&&!j){ae.value=ke;return}const ee=v.value,he=ee&&ee.core===le&&ee.agent===J&&ee.threadId===ke&&ee.inspectorRequestId===Be;let Se;if(he&&ee)Se=ee;else{const fe=new AbortController;Se={core:le,agent:J,threadId:ke,inspectorRequestId:Be,abortController:fe,detached:!1},v.value=Se,y=Se,b.then(()=>{if(!Se.detached)return x.ɵisHttpAgent(J)&&(J.abortController=fe),le.connectAgent({agent:J})}).catch(Le=>{if(Se.detached){Se.clearDiscardedBaseline?.();return}Le instanceof zn.AGUIConnectNotImplementedError||(console.error("CopilotChat: connectAgent failed",Le),Be&&O(Be))}).finally(()=>{if(Se.detached){Se.clearDiscardedBaseline?.();return}(typeof requestAnimationFrame=="function"?requestAnimationFrame:Ye=>setTimeout(Ye,16))(()=>{Se.detached||(ae.value=Se.threadId)})})}st(()=>{const fe=v.value;if(!fe||fe!==Se||!(g.value||l.value!==fe.core||F.value!==fe.agent||N.value!==fe.threadId))return;fe.detached=!0,fe.abortController.abort();const Ye=fe.agent.detachActiveRun().catch(bt=>{console.error("CopilotChat: detachActiveRun failed",bt)});k.set(fe.agent,Ye),b=Promise.all([b,Ye]).then(()=>{}),Ye.then(()=>{k.get(fe.agent)===Ye&&k.delete(fe.agent)}),v.value=null})},{immediate:!0});let ht;t.watch([N,K,()=>F.value],([G,le,J],ke,lt)=>{const Be=ht,tt={threadId:G,agent:J};if(ht=tt,!J||le||Be===void 0||G===Be.threadId)return;let st=!0,ct=!0;lt(()=>{st=!1});const Pt=Be.agent===J?Be.threadId:w.get(J),vt=()=>{Pt&&("clearReplayCursor"in J&&typeof J.clearReplayCursor=="function"&&J.clearReplayCursor(Pt),"clearReconnectCursor"in J&&typeof J.clearReconnectCursor=="function"&&J.clearReconnectCursor(Pt))},It=()=>{!st||!ct||g.value||ht!==tt||F.value!==J||(J.setMessages([]),J.setState({}),J.pendingInterrupts=[],vt())};y?.agent===J&&y.threadId===Pt&&(y.clearDiscardedBaseline=It);const T=k.get(J)??J.detachActiveRun();k.set(J,T);const j=()=>{ct&&(vt(),It(),ct=!1)};It(),b=Promise.all([b,T]).then(j).catch(ee=>{console.error("CopilotChat: detachActiveRun failed",ee)}).finally(()=>{k.get(J)===T&&k.delete(J)})},{immediate:!0}),t.onBeforeUnmount(()=>{g.value=!0}),t.onMounted(()=>{m.value=!0}),t.watch(h,(G,le,J)=>{if(!G)return;const ke=setTimeout(()=>{h.value=null},5e3);J(()=>clearTimeout(ke))});async function W(){const G=F.value;if(G)try{const le=v.value;le&&le.agent===G&&le.threadId===N.value&&(le.detached=!0,le.abortController.abort(),v.value=null,await le.agent.detachActiveRun?.()),await l.value.runAgent({agent:G})}catch(le){console.error("CopilotChat: runAgent failed",le)}}async function ce(G){if(Ne.value.some(ke=>ke.status==="uploading")){console.error("[CopilotKit] Cannot send while attachments are uploading");return}if(a("submit-message",G),!F.value){console.error("[CopilotKit] Cannot send message: no agent available");return}const J=ye();if(J.length>0){const ke=[];G.trim()&&ke.push({type:"text",text:G});for(const lt of J)ke.push(Q.createAttachmentContent(lt));F.value.addMessage({id:Q.randomUUID(),role:"user",content:ke})}else F.value.addMessage({id:Q.randomUUID(),role:"user",content:G});p.value="",await W()}async function pe(G,le){a("select-suggestion",G,le),F.value?.addMessage({id:Q.randomUUID(),role:"user",content:G.message}),await W()}function Je(){const G=F.value;if(G)try{l.value.stopAgent({agent:G})}catch(le){console.error("CopilotChat: stopAgent failed",le);try{G.abortRun()}catch(J){console.error("CopilotChat: abortRun fallback failed",J)}}}function He(){a("stop"),Tt.value&&Je()}function we(G){p.value=G,a("input-change",G)}function Me(){a("add-file"),D.value&&setTimeout(()=>{P.value?.click()},100)}function Oe(){Ie.value&&(h.value=null,d.value="transcribe",a("start-transcribe"))}function Ke(){Ie.value&&(h.value=null,d.value="input",a("cancel-transcribe"))}function Ge(){Ie.value&&(d.value="input",a("finish-transcribe"))}async function gt(G){if(Ie.value){if(o.onFinishTranscribeWithAudio){await o.onFinishTranscribeWithAudio(G);return}f.value=!0;try{h.value=null;const le=await x.ɵtranscribeAudio(l.value,G),J=p.value.trim();p.value=J?`${J} ${le.text}`:le.text}catch(le){console.error("CopilotChat: Transcription failed",le);const J=B.value;if(le instanceof x.TranscriptionError){const ke=x.ɵtranscriptionErrorMessageKey(le.info);h.value=ke?J[ke]:le.info.message}else h.value=J.transcriptionErrorGenericText}finally{f.value=!1}}}const je=t.computed(()=>({messages:Ct.value,autoScroll:o.autoScroll,isRunning:rt.value,suggestions:V.value,suggestionLoadingIndexes:[],welcomeScreen:o.welcomeScreen,attachments:Ne.value,dragOver:$.value,inputValue:p.value,inputMode:Pe.value,inputToolsMenu:o.inputToolsMenu,isConnecting:H.value,hasExplicitThreadId:K.value,toolCallDisplay:o.toolCallDisplay,messageFeedback:o.messageFeedback,canStop:Tt.value,canAddFile:D.value,canTranscribe:Ie.value,onSubmitMessage:ce,onStop:He,onInputChange:we,onSelectSuggestion:pe,onRemoveAttachment:Z,onAddFile:Me,onDragOver:D.value?ne:void 0,onDragLeave:D.value?Qe:void 0,onDrop:D.value?et:void 0,onStartTranscribe:Oe,onCancelTranscribe:Ke,onFinishTranscribe:Ge,onFinishTranscribeWithAudio:gt})),on=t.computed(()=>{const G={...r,onSubmitMessage:ce,onInputChange:we,onSelectSuggestion:pe};return Tt.value&&(G.onStop=He),D.value&&(G.onAddFile=Me,G.attachments=Ne.value,G.onRemoveAttachment=Z,G.dragOver=$.value,G.onDragOver=ne,G.onDragLeave=Qe,G.onDrop=et),Ie.value&&(G.onStartTranscribe=Oe,G.onCancelTranscribe=Ke,G.onFinishTranscribe=Ge),G});return(G,le)=>(t.openBlock(),t.createBlock(ro,{"agent-id":S.value,"thread-id":N.value,"has-explicit-thread-id":K.value,labels:I.value},{default:t.withCtx(()=>[t.createElementVNode("div",{ref_key:"attachmentContainerRef",ref:Y,style:{display:"contents"}},[t.createVNode(t.unref(uc)),t.unref(D)?(t.openBlock(),t.createElementBlock("input",{key:0,ref_key:"fileInputRef",ref:P,type:"file",multiple:"",accept:o.attachments?.accept??"*/*",style:{display:"none"},onChange:le[0]||(le[0]=J=>{t.unref(q)(J)})},null,40,RS)):t.createCommentVNode("",!0),ie.value?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(_a,{key:1,"feature-name":"Chat"})),h.value?(t.openBlock(),t.createElementBlock("div",xS,t.toDisplayString(h.value),1)):t.createCommentVNode("",!0),t.renderSlot(G.$slots,"chat-view",t.normalizeProps(t.guardReactiveProps(je.value)),()=>[t.createVNode(Cn,t.mergeProps(on.value,{messages:je.value.messages,"auto-scroll":je.value.autoScroll,"is-running":je.value.isRunning,suggestions:je.value.suggestions,"suggestion-loading-indexes":je.value.suggestionLoadingIndexes,"welcome-screen":je.value.welcomeScreen,"input-value":je.value.inputValue,"input-mode":je.value.inputMode,"input-tools-menu":je.value.inputToolsMenu,"is-connecting":je.value.isConnecting,"has-explicit-thread-id":je.value.hasExplicitThreadId,"tool-call-display":je.value.toolCallDisplay,"message-feedback":je.value.messageFeedback,"on-finish-transcribe-with-audio":je.value.onFinishTranscribeWithAudio}),t.createSlots({_:2},[t.renderList(c.value,J=>({name:J,fn:t.withCtx(ke=>[t.renderSlot(G.$slots,J,t.normalizeProps(t.guardReactiveProps(ke)))])}))]),1040,["messages","auto-scroll","is-running","suggestions","suggestion-loading-indexes","welcome-screen","input-value","input-mode","input-tools-menu","is-connecting","has-explicit-thread-id","tool-call-display","message-feedback","on-finish-transcribe-with-audio"])])],512)]),_:3},8,["agent-id","thread-id","has-explicit-thread-id","labels"]))}});function Vt(e,n,o){o.value=n(e.getState());const a=e.select(n).subscribe(()=>{o.value=n(e.getState())});t.onScopeDispose(()=>a.unsubscribe())}function dc(e){const{copilotkit:n}=Ve(),o=x.ɵcreateThreadStore({fetch:n.value.ɵruntimeFetch}),a=t.computed(()=>t.toValue(e.agentId)),r=t.computed(()=>t.toValue(e.includeArchived)),s=t.computed(()=>t.toValue(e.limit)),i=t.computed(()=>t.toValue(e.enabled)??!0),l=t.computed(()=>n.value.threadEndpoints?.list!==!1),c=t.computed(()=>n.value.threadEndpoints?.mutations!==!1),u=t.computed(()=>!!n.value.runtimeUrl&&n.value.runtimeConnectionStatus===x.CopilotKitCoreRuntimeConnectionStatus.Connected&&!l.value),d=t.computed(()=>u.value?new Error("Thread endpoints are not available on this CopilotKit runtime"):null),p=t.computed(()=>c.value?null:new Error("Thread mutations are not available on this CopilotKit runtime")),h=t.computed(()=>n.value.ɵheadersGeneration),f=t.ref([]),m=t.ref(!1),g=t.ref(null),v=t.ref(null),y=t.ref(!1),k=t.ref(!1),b=t.ref(!1);Vt(o,x.ɵselectThreads,f),Vt(o,x.ɵselectThreadsIsLoading,m),Vt(o,x.ɵselectThreadsError,g),Vt(o,x.ɵselectFetchMoreError,v),Vt(o,x.ɵselectHasNextPage,y),Vt(o,x.ɵselectIsFetchingNextPage,k),Vt(o,x.ɵselectIsMutating,b),o.start(),t.onScopeDispose(()=>{o.stop()}),t.watch([i,a],([O,N],K,ae)=>{O&&(n.value.registerThreadStore(N,o),ae(()=>{n.value.unregisterThreadStore(N)}))},{immediate:!0});const w=t.ref(!1);t.watch([()=>n.value.runtimeUrl,()=>n.value.runtimeConnectionStatus,h,()=>n.value.intelligence?.wsUrl,a,r,s,i,l],([O,N,,K,ae,H,M,I,B])=>{if(!O||!I){o.setContext(null),w.value=!1;return}if(N!==x.CopilotKitCoreRuntimeConnectionStatus.Connected)return;if(!B){o.setContext(null),w.value=!1;return}const F={runtimeUrl:O,wsUrl:K,agentId:ae,includeArchived:H,limit:M};o.setContext(F),w.value=!0},{immediate:!0});const S=t.computed(()=>n.value.runtimeUrl?null:new Error("Runtime URL is not configured")),C=t.computed(()=>!!n.value.runtimeUrl&&i.value&&!u.value&&!w.value),A=t.computed(()=>S.value||d.value?!1:C.value||m.value),E=t.computed(()=>S.value??d.value??g.value),L=t.computed(()=>g.value);function z(O){return(...N)=>p.value?Promise.reject(p.value):O(...N)}return{threads:t.computed(()=>f.value.map(({id:O,agentId:N,name:K,archived:ae,createdAt:H,updatedAt:M,lastRunAt:I})=>({id:O,agentId:N,name:K,archived:ae,createdAt:H,updatedAt:M,...I!==void 0?{lastRunAt:I}:{}}))),isLoading:A,error:E,listError:L,fetchMoreError:v,hasMoreThreads:y,isFetchingMoreThreads:k,isMutating:b,fetchMoreThreads:()=>o.fetchNextPage(),refetchThreads:()=>o.refetchThreads(),startNewThread:()=>o.startNewThread(),renameThread:z((O,N)=>o.renameThread(O,N)),archiveThread:z(O=>o.archiveThread(O)),unarchiveThread:z(O=>o.unarchiveThread(O)),deleteThread:z(O=>o.deleteThread(O))}}const Ar="copilot-chat-input-textarea",OS="copilot-chat-view",NS=t.defineComponent({__name:"CopilotThreadsDrawer",props:{agentId:{},onThreadSelect:{},onNewThread:{},onLicensed:{},licenseUrl:{},label:{},recentLabel:{},collapsible:{type:Boolean,default:!0},limit:{},dataTestId:{default:"copilot-threads-drawer"}},emits:["collapse-change"],setup(e,{emit:n}){const o=e,a=n,r=Re(),s=Sn(),i=t.computed(()=>{const I=s.value.status;return I==="unknown"?!0:(I==="valid"||I==="expiring")&&s.value.checkFeature("threads")}),l=t.computed(()=>s.value.status===null),c=t.computed(()=>o.agentId??r.value?.agentId??Q.DEFAULT_AGENT_ID),u=t.computed(()=>r.value?.threadId??null),d=t.ref(!1),p=t.computed(()=>r.value?r.value.drawerOpen:d.value);function h(I){r.value?r.value.setDrawerOpen?.(I):d.value=I}const f=dc({agentId:c,includeArchived:!0,enabled:i,limit:()=>o.limit});function m(I){return{id:I.id,name:I.name,archived:I.archived,createdAt:I.createdAt,updatedAt:I.updatedAt,...I.lastRunAt!==void 0?{lastRunAt:I.lastRunAt}:{}}}const g=t.computed(()=>f.threads.value.map(m)),v=t.ref(!1),y=t.ref(null),k=t.ref(null);t.onMounted(async()=>{const I=await import("@copilotkit/web-components/threads-drawer");I.defineCopilotKitThreadsDrawer(),y.value=I.COPILOTKIT_THREADS_DRAWER_TAG,v.value=!0}),t.watchEffect(()=>{const I=k.value;I&&(I.threads=g.value,I.loading=f.isLoading.value||l.value,I.error=f.listError.value?.message??null,I.activeThreadId=u.value,I.licensed=i.value||l.value,I.hasMore=f.hasMoreThreads.value,I.fetchingMore=f.isFetchingMoreThreads.value,I.fetchMoreError=f.fetchMoreError.value?.message??null,I.open=p.value,o.label!==void 0&&(I.label=o.label),o.licenseUrl!==void 0&&(I.licenseUrl=o.licenseUrl),o.collapsible!==void 0&&(I.collapsible=o.collapsible))},{flush:"post"});const b=r.value?.registerDrawer?.();b&&t.onScopeDispose(b);function w(I){if(typeof document>"u")return null;const B=I?.closest?.(`[data-testid="${OS}"]`);if(B){const F=B.querySelector(`[data-testid="${Ar}"]`);if(F)return F}return document.querySelector(`[data-testid="${Ar}"]`)}function S(){w(k.value)?.focus()}function C(I){const{threadId:B}=I.detail;o.onThreadSelect?o.onThreadSelect(B):r.value?.setActiveThreadId?.(B,{explicit:!0}),S()}function A(){f.startNewThread(),o.onNewThread?o.onNewThread():r.value?.startNewThread?.()}function E(I){const{threadId:B}=I.detail;f.archiveThread(B).catch(F=>console.error("CopilotThreadsDrawer: archiveThread failed",F))}function L(I){const{threadId:B}=I.detail;f.unarchiveThread(B).catch(F=>console.error("CopilotThreadsDrawer: unarchiveThread failed",F))}function z(I){const{threadId:B}=I.detail,F=B===u.value;f.deleteThread(B).then(()=>{F&&A()}).catch(V=>console.error("CopilotThreadsDrawer: deleteThread failed",V))}function O(){f.refetchThreads()}function N(I){const{collapsed:B}=I.detail;a("collapse-change",B)}function K(I){const{scope:B}=I.detail;B==="fetch-more"?f.fetchMoreThreads():f.refetchThreads()}function ae(){f.fetchMoreThreads()}function H(I){const{open:B}=I.detail;h(B)}function M(){o.onLicensed?.()}return(I,B)=>v.value?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(y.value),{key:0,ref_key:"elRef",ref:k,"data-testid":e.dataTestId,"recent-label":e.recentLabel,onThreadSelected:C,onNewThread:A,onArchive:E,onUnarchive:L,onDelete:z,onFilterChange:O,onCollapseChange:N,onRetry:K,onLoadMore:ae,onOpenChange:H,onLicensed:M},{default:t.withCtx(()=>[t.renderSlot(I.$slots,"default"),I.$slots.row?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:0},t.renderList(t.unref(f).threads.value,F=>(t.openBlock(),t.createElementBlock("div",t.mergeProps({key:F.id},{ref_for:!0},{slot:`row:${F.id}`}),[t.renderSlot(I.$slots,"row",{thread:F})],16))),128)):t.createCommentVNode("",!0)]),_:3},40,["data-testid","recent-label"])):t.createCommentVNode("",!0)}}),$a=t.defineComponent({name:"CopilotChatToggleButtonCloseIcon",inheritAttrs:!1,setup(e,{attrs:n}){return()=>{const{class:o,...a}=n;return t.h(wn,{...a,class:["cpk-chat-toggle-button-icon",o],strokeWidth:1.75})}}}),Ra=t.defineComponent({name:"CopilotChatToggleButtonOpenIcon",inheritAttrs:!1,setup(e,{attrs:n}){return()=>{const{class:o,...a}=n;return t.h(Rv,{...a,class:["cpk-chat-toggle-button-icon",o],strokeWidth:1.75,fill:"currentColor"})}}}),MS=["type","data-state","aria-label","aria-pressed","disabled"],Mn="cpk-chat-toggle-button-icon",$r="cpk-chat-toggle-button-icon-wrapper",xa=t.defineComponent({inheritAttrs:!1,__name:"CopilotChatToggleButton",props:{disabled:{type:Boolean,default:!1},type:{default:"button"}},setup(e){const n=e,o=t.useAttrs(),a=Re(),r=t.ref(!1),s=t.computed(()=>a.value?.labels??x.CopilotChatDefaultLabels),i=t.computed(()=>a.value?.isModalOpen??r.value),l=t.computed(()=>i.value?s.value.chatToggleCloseLabel:s.value.chatToggleOpenLabel),c=t.computed(()=>["copilotKitButton cpk-chat-toggle-button",o.class]),u=t.computed(()=>{const{class:m,onClick:g,...v}=o;return v}),d=Object.freeze({transition:"opacity 120ms ease-out, transform 260ms cubic-bezier(0.22, 1, 0.36, 1)"});function p(m){if(a.value?.setModalOpen){a.value.setModalOpen(m);return}r.value=m}function h(){const m=o.onClick;return Array.isArray(m)?m.filter(g=>typeof g=="function"):typeof m=="function"?[m]:[]}function f(m){if(!n.disabled){for(const g of h())g(m);m.defaultPrevented||p(!i.value)}}return(m,g)=>(t.openBlock(),t.createElementBlock("button",t.mergeProps({"data-copilotkit":"",type:e.type,"data-slot":"chat-toggle-button","data-state":i.value?"open":"closed",class:c.value,"aria-label":l.value,"aria-pressed":i.value,disabled:e.disabled},u.value,{onClick:f}),[t.createElementVNode("span",{"aria-hidden":"true","data-slot":"chat-toggle-button-open-icon",class:t.normalizeClass($r),style:t.normalizeStyle({...t.unref(d),opacity:i.value?0:1,transform:`scale(${i.value?.75:1}) rotate(${i.value?90:0}deg)`})},[t.renderSlot(m.$slots,"open-icon",{iconClass:Mn,isOpen:i.value},()=>[t.createVNode(t.unref(Ra),{class:t.normalizeClass(Mn),"aria-hidden":"true",focusable:!1})])],4),t.createElementVNode("span",{"aria-hidden":"true","data-slot":"chat-toggle-button-close-icon",class:t.normalizeClass($r),style:t.normalizeStyle({...t.unref(d),opacity:i.value?1:0,transform:`scale(${i.value?1:.75}) rotate(${i.value?0:-90}deg)`})},[t.renderSlot(m.$slots,"close-icon",{iconClass:Mn,isOpen:i.value},()=>[t.createVNode(t.unref($a),{class:t.normalizeClass(Mn),"aria-hidden":"true",focusable:!1})])],4)],16,MS))}}),pc=t.defineComponent({name:"CopilotModalHeaderCloseButton",inheritAttrs:!1,setup(e,{slots:n}){const o=t.useAttrs(),a=Re(),r=t.computed(()=>typeof o["aria-label"]=="string"?o["aria-label"]:(a.value?.labels??x.CopilotChatDefaultLabels).modalHeaderCloseButtonLabel);return()=>{const{class:s,type:i,...l}=o;return t.h("button",{...l,type:typeof i=="string"?i:"button",class:["cpk-modal-header-close-button",s],"aria-label":r.value},n.default?n.default():[t.h(wn,{class:"cpk-modal-header-close-icon","aria-hidden":!0})])}}}),fc=t.defineComponent({name:"CopilotModalHeaderTitle",inheritAttrs:!1,setup(e,{attrs:n,slots:o}){return()=>{const{class:a,...r}=n;return t.h("div",{...r,class:["cpk-modal-header-title",a]},o.default?o.default():[])}}}),BS={class:"cpk-modal-header-content"},DS={class:"cpk-modal-header-start"},FS=["aria-expanded","aria-label"],PS={key:1,"aria-hidden":"true"},LS={class:"cpk-modal-header-center"},VS={class:"cpk-modal-header-end"},Oa=t.defineComponent({inheritAttrs:!1,__name:"CopilotModalHeader",props:{title:{}},setup(e){const n=e,o=t.useAttrs(),a=Re(),r=t.computed(()=>n.title??a.value?.labels.modalHeaderTitle??x.CopilotChatDefaultLabels.modalHeaderTitle),s=t.computed(()=>["copilotKitHeader cpk-modal-header",o.class]),i=t.computed(()=>{const{class:f,...m}=o;return m});function l(){a.value?.setModalOpen?.(!1)}const c=t.ref(!1);let u=null;function d(){u&&(c.value=u.matches)}t.onMounted(()=>{typeof window>"u"||typeof window.matchMedia!="function"||(u=window.matchMedia(wl),u.addEventListener("change",d),d())}),t.onBeforeUnmount(()=>{u?.removeEventListener("change",d),u=null});const p=t.computed(()=>(a.value?.drawerRegistered??!1)&&c.value);function h(){a.value?.setDrawerOpen?.(!a.value?.drawerOpen)}return(f,m)=>(t.openBlock(),t.createElementBlock("header",t.mergeProps({"data-copilotkit":"","data-slot":"copilot-modal-header",class:s.value},i.value),[t.renderSlot(f.$slots,"layout",{title:r.value,onClose:l},()=>[t.createElementVNode("div",BS,[t.createElementVNode("div",DS,[p.value?(t.openBlock(),t.createElementBlock("button",{key:0,type:"button","data-testid":"drawer-launcher",class:"cpk-modal-header-drawer-launcher","aria-expanded":t.unref(a)?.drawerOpen??!1,"aria-label":t.unref(a)?.labels.modalHeaderThreadsButtonLabel??t.unref(x.CopilotChatDefaultLabels).modalHeaderThreadsButtonLabel,onClick:h},[t.createVNode(t.unref(Ov),{class:"cpk-modal-header-drawer-launcher-icon","aria-hidden":"true"})],8,FS)):(t.openBlock(),t.createElementBlock("span",PS))]),t.createElementVNode("div",LS,[t.renderSlot(f.$slots,"title-content",{title:r.value},()=>[t.createVNode(t.unref(fc),null,{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(r.value),1)]),_:1})])]),t.createElementVNode("div",VS,[t.renderSlot(f.$slots,"close-button",{onClose:l},()=>[t.createVNode(t.unref(pc),{onClick:l})])])])])],16))}});function nn(e,n=[]){return Object.keys(e).filter(o=>!n.includes(o))}const zS={key:0,"data-copilotkit":"",class:"cpk-popup-view"},US=["aria-label"],jS={class:"cpk-popup-view-chat","data-popup-chat":""},ZS=420,WS=560,Rr=200,HS=t.defineComponent({inheritAttrs:!1,__name:"CopilotPopupViewInternal",props:{width:{default:void 0},height:{default:void 0},clickOutsideToClose:{type:Boolean,default:!1},messages:{default:()=>[]},autoScroll:{type:[String,Boolean],default:!0},isRunning:{type:Boolean,default:!1},suggestions:{default:()=>[]},suggestionLoadingIndexes:{default:()=>[]},welcomeScreen:{type:Boolean,default:!0},attachments:{},dragOver:{type:Boolean},inputValue:{default:void 0},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},onSubmitMessage:{},onStop:{},onInputChange:{},onSelectSuggestion:{},onStartTranscribe:{},onCancelTranscribe:{},onFinishTranscribe:{},isConnecting:{type:Boolean},hasExplicitThreadId:{type:Boolean},onRemoveAttachment:{},onAddFile:{},onDragOver:{},onDragLeave:{},onDrop:{},onFinishTranscribeWithAudio:{type:Function,default:void 0},toolCallDisplay:{},messageFeedback:{type:Boolean,default:!0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(e,{emit:n}){const o=e,a=["header","toggle-button"],r=n,s=t.useAttrs(),i=Re(),l=t.ref(null),c=t.ref(i.value?.isModalOpen??!1),u=t.ref(!1);let d,p;const h=t.computed(()=>i.value?.isModalOpen??!1),f=t.computed(()=>i.value?.labels??x.CopilotChatDefaultLabels),m=t.computed(()=>f.value.modalHeaderTitle),g=t.computed(()=>h.value&&!u.value?"cpk-popup-view-window-open":void 0),v=t.computed(()=>({"--copilot-popup-width":y(o.width,ZS),"--copilot-popup-height":y(o.height,WS),"--copilot-popup-max-width":"calc(100vw - 3rem)","--copilot-popup-max-height":"calc(100dvh - 7.5rem)",paddingTop:"env(safe-area-inset-top)",paddingBottom:"env(safe-area-inset-bottom)",paddingLeft:"env(safe-area-inset-left)",paddingRight:"env(safe-area-inset-right)"}));function y(H,M){return typeof H=="number"&&Number.isFinite(H)?`${H}px`:typeof H=="string"&&H.trim().length>0?H:`${M}px`}function k(){i.value?.setModalOpen?.(!1)}function b(){i.value?.setModalOpen?.(!0)}function w(){i.value?.setModalOpen?.(!h.value)}function S(H){r("submit-message",H)}function C(){r("stop")}function A(H){r("input-change",H)}function E(H,M){r("select-suggestion",H,M)}function L(){r("add-file")}function z(){r("start-transcribe")}function O(){r("cancel-transcribe")}function N(){r("finish-transcribe")}const K=t.computed(()=>{const H={onSubmitMessage:S,onInputChange:A,onSelectSuggestion:E};return o.onStop&&(H.onStop=C),o.onAddFile&&(H.onAddFile=L),o.onStartTranscribe&&(H.onStartTranscribe=z),o.onCancelTranscribe&&(H.onCancelTranscribe=O),o.onFinishTranscribe&&(H.onFinishTranscribe=N),H}),ae=t.computed(()=>({...s,...K.value}));return t.watch(h,H=>{if(d&&(clearTimeout(d),d=void 0),H){c.value=!0,u.value=!1;return}c.value&&(u.value=!0,d=setTimeout(()=>{c.value=!1,u.value=!1,d=void 0},Rr))},{immediate:!0}),t.watch(h,(H,M,I)=>{if(!H||typeof window>"u")return;const B=F=>{F.key==="Escape"&&(F.preventDefault(),k())};window.addEventListener("keydown",B),I(()=>{window.removeEventListener("keydown",B)})},{immediate:!0}),t.watch(h,(H,M,I)=>{H&&(p=setTimeout(()=>{if(typeof document>"u")return;const B=l.value;B&&!B.contains(document.activeElement)&&B.focus({preventScroll:!0})},Rr),I(()=>{p&&(clearTimeout(p),p=void 0)}))},{immediate:!0}),t.watch([h,()=>o.clickOutsideToClose],([H,M],I,B)=>{if(!H||!M||typeof document>"u")return;const F=V=>{const oe=V.target;!oe||l.value?.contains(oe)||document.querySelector("[data-slot='chat-toggle-button']")?.contains(oe)||k()};document.addEventListener("pointerdown",F),B(()=>{document.removeEventListener("pointerdown",F)})},{immediate:!0}),t.onMounted(async()=>{await t.nextTick()}),t.onBeforeUnmount(()=>{d&&clearTimeout(d),p&&clearTimeout(p)}),(H,M)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.renderSlot(H.$slots,"toggle-button",{isOpen:h.value,toggle:w,open:b,close:k},()=>[t.createVNode(xa)]),c.value?(t.openBlock(),t.createElementBlock("div",zS,[t.createElementVNode("div",{ref_key:"containerRef",ref:l,tabindex:"-1",role:"dialog","aria-label":f.value.modalHeaderTitle,"data-copilot-popup":"",class:t.normalizeClass(["copilotKitPopup copilotKitWindow cpk-popup-view-window",g.value]),style:t.normalizeStyle(v.value)},[t.renderSlot(H.$slots,"header",{title:m.value,onClose:k,isOpen:h.value},()=>[t.createVNode(Oa,{title:m.value},null,8,["title"])]),t.createElementVNode("div",jS,[t.createVNode(Cn,t.mergeProps({class:"cpk-popup-view-chat-view",messages:e.messages,"auto-scroll":e.autoScroll,"is-running":e.isRunning,suggestions:e.suggestions,"suggestion-loading-indexes":e.suggestionLoadingIndexes,"welcome-screen":e.welcomeScreen,"input-value":e.inputValue,"input-mode":e.inputMode,"input-tools-menu":e.inputToolsMenu,"tool-call-display":e.toolCallDisplay,"message-feedback":e.messageFeedback,"on-finish-transcribe-with-audio":e.onFinishTranscribeWithAudio},ae.value),t.createSlots({_:2},[t.renderList(t.unref(nn)(H.$slots,a),I=>({name:I,fn:t.withCtx(B=>[t.renderSlot(H.$slots,I,t.normalizeProps(t.guardReactiveProps(B)))])}))]),1040,["messages","auto-scroll","is-running","suggestions","suggestion-loading-indexes","welcome-screen","input-value","input-mode","input-tools-menu","tool-call-display","message-feedback","on-finish-transcribe-with-audio"])])],14,US)])):t.createCommentVNode("",!0)],64))}}),mc=t.defineComponent({inheritAttrs:!1,__name:"CopilotPopupView",props:{width:{default:void 0},height:{default:void 0},clickOutsideToClose:{type:Boolean,default:!1},defaultOpen:{type:Boolean,default:!0},messages:{default:()=>[]},autoScroll:{type:[String,Boolean],default:!0},isRunning:{type:Boolean,default:!1},suggestions:{default:()=>[]},suggestionLoadingIndexes:{default:()=>[]},welcomeScreen:{type:Boolean,default:!0},attachments:{},dragOver:{type:Boolean},inputValue:{default:void 0},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},onSubmitMessage:{},onStop:{},onInputChange:{},onSelectSuggestion:{},onStartTranscribe:{},onCancelTranscribe:{},onFinishTranscribe:{},isConnecting:{type:Boolean},hasExplicitThreadId:{type:Boolean},onRemoveAttachment:{},onAddFile:{},onDragOver:{},onDragLeave:{},onDrop:{},onFinishTranscribeWithAudio:{type:Function,default:void 0},toolCallDisplay:{},messageFeedback:{type:Boolean,default:!0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(e,{emit:n}){const o=e,a=n,r=t.useAttrs(),s=t.computed(()=>{const{defaultOpen:c,...u}=o;return u}),i=t.computed(()=>{const c={onSubmitMessage:u=>a("submit-message",u),onInputChange:u=>a("input-change",u),onSelectSuggestion:(u,d)=>a("select-suggestion",u,d)};return o.onStop&&(c.onStop=()=>a("stop")),o.onAddFile&&(c.onAddFile=()=>a("add-file")),o.onStartTranscribe&&(c.onStartTranscribe=()=>a("start-transcribe")),o.onCancelTranscribe&&(c.onCancelTranscribe=()=>a("cancel-transcribe")),o.onFinishTranscribe&&(c.onFinishTranscribe=()=>a("finish-transcribe")),c}),l=t.computed(()=>({...r,...s.value,...i.value}));return(c,u)=>(t.openBlock(),t.createBlock(ro,{"is-modal-default-open":e.defaultOpen},{default:t.withCtx(()=>[t.createVNode(HS,t.normalizeProps(t.guardReactiveProps(l.value)),t.createSlots({_:2},[t.renderList(t.unref(nn)(c.$slots),d=>({name:d,fn:t.withCtx(p=>[t.renderSlot(c.$slots,d,t.normalizeProps(t.guardReactiveProps(p)))])}))]),1040)]),_:3},8,["is-modal-default-open"]))}}),KS={"data-copilotkit":"",class:"cpk-popup-view-welcome-screen","data-testid":"copilot-popup-welcome-screen"},GS={class:"cpk-popup-view-welcome-screen-message"},qS={class:"cpk-chat-view-welcome-message"},JS={class:"cpk-popup-view-welcome-screen-suggestions"},hc=t.defineComponent({__name:"CopilotPopupWelcomeScreen",props:{modelValue:{default:""},isRunning:{type:Boolean,default:!1},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},onUpdateModelValue:{},onSubmitMessage:{},suggestions:{default:()=>[]},loadingIndexes:{default:()=>[]},onSelectSuggestion:{},onStop:{},onAddFile:{type:Function,default:void 0},onStartTranscribe:{type:Function,default:void 0},onCancelTranscribe:{type:Function,default:void 0},onFinishTranscribe:{type:Function,default:void 0},onFinishTranscribeWithAudio:{type:Function,default:void 0},canStop:{type:Boolean,default:void 0},canAddFile:{type:Boolean,default:void 0},canTranscribe:{type:Boolean,default:void 0}},setup(e){const n=e,o=Re(),a=t.computed(()=>o.value?.labels??x.CopilotChatDefaultLabels);function r(){n.onStop?.()}function s(){n.onAddFile?.()}function i(){n.onStartTranscribe?.()}function l(){n.onCancelTranscribe?.()}function c(){n.onFinishTranscribe?.()}async function u(m){await n.onFinishTranscribeWithAudio?.(m)}const d=t.computed(()=>({modelValue:n.modelValue,isRunning:n.isRunning,inputMode:n.inputMode,inputToolsMenu:n.inputToolsMenu,canStop:n.canStop??!!n.onStop,canAddFile:n.canAddFile??!!n.onAddFile,canTranscribe:n.canTranscribe??!!n.onStartTranscribe,onUpdateModelValue:n.onUpdateModelValue,onSubmitMessage:n.onSubmitMessage,onStop:r,onAddFile:s,onStartTranscribe:i,onCancelTranscribe:l,onFinishTranscribe:c,onFinishTranscribeWithAudio:u})),p=t.computed(()=>({suggestions:n.suggestions,loadingIndexes:n.loadingIndexes,onSelectSuggestion:n.onSelectSuggestion})),h=t.computed(()=>({...d.value,...p.value})),f=t.computed(()=>{const m={"onUpdate:modelValue":n.onUpdateModelValue,onSubmitMessage:n.onSubmitMessage,onStop:n.onStop};return n.onAddFile&&(m.onAddFile=n.onAddFile),n.onStartTranscribe&&(m.onStartTranscribe=n.onStartTranscribe),n.onCancelTranscribe&&(m.onCancelTranscribe=n.onCancelTranscribe),n.onFinishTranscribe&&(m.onFinishTranscribe=n.onFinishTranscribe),n.onFinishTranscribeWithAudio&&(m.onFinishTranscribeWithAudio=n.onFinishTranscribeWithAudio),m});return(m,g)=>t.renderSlot(m.$slots,"layout",t.normalizeProps(t.guardReactiveProps(h.value)),()=>[t.createElementVNode("div",KS,[t.createElementVNode("div",GS,[t.renderSlot(m.$slots,"welcome-message",{},()=>[t.createElementVNode("h1",qS,t.toDisplayString(a.value.welcomeMessageText),1)])]),t.createElementVNode("div",null,[t.createElementVNode("div",JS,[t.renderSlot(m.$slots,"suggestion-view",t.normalizeProps(t.guardReactiveProps(p.value)),()=>[t.createVNode(vn,{class:"cpk-chat-view-suggestion-view",suggestions:e.suggestions,"loading-indexes":e.loadingIndexes,onSelectSuggestion:e.onSelectSuggestion},null,8,["suggestions","loading-indexes","onSelectSuggestion"])])]),t.renderSlot(m.$slots,"input",t.normalizeProps(t.guardReactiveProps(d.value)),()=>[t.createVNode(gn,t.mergeProps({"model-value":e.modelValue,"is-running":e.isRunning,mode:e.inputMode,"tools-menu":e.inputToolsMenu,positioning:"static","show-disclaimer":!0},f.value),null,16,["model-value","is-running","mode","tools-menu"])])])])])}}),YS=["data-position","aria-label","aria-hidden"],XS={class:"cpk-sidebar-view-panel"},QS={class:"cpk-sidebar-view-chat","data-sidebar-chat":""},ew=480,tw=260,nw=t.defineComponent({inheritAttrs:!1,__name:"CopilotSidebarViewInternal",props:{width:{default:void 0},position:{default:"right"},messages:{default:()=>[]},autoScroll:{type:[String,Boolean],default:!0},isRunning:{type:Boolean,default:!1},suggestions:{default:()=>[]},suggestionLoadingIndexes:{default:()=>[]},welcomeScreen:{type:Boolean,default:!0},attachments:{},dragOver:{type:Boolean},inputValue:{default:void 0},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},onSubmitMessage:{},onStop:{},onInputChange:{},onSelectSuggestion:{},onStartTranscribe:{},onCancelTranscribe:{},onFinishTranscribe:{},isConnecting:{type:Boolean},hasExplicitThreadId:{type:Boolean},onRemoveAttachment:{},onAddFile:{},onDragOver:{},onDragLeave:{},onDrop:{},onFinishTranscribeWithAudio:{type:Function,default:void 0},toolCallDisplay:{},messageFeedback:{type:Boolean,default:!0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(e,{emit:n}){const o=e,a=["header","toggle-button"],r=n,s=t.useAttrs(),i=Re(),l=t.ref(null),c=t.ref(o.width??ew);let u=null;const d=t.computed(()=>i.value?.isModalOpen??!1),p=t.computed(()=>o.width??c.value),h=t.computed(()=>i.value?.labels.modalHeaderTitle??x.CopilotChatDefaultLabels.modalHeaderTitle),f=t.computed(()=>["copilotKitSidebar copilotKitWindow cpk-sidebar-view",!d.value&&"cpk-sidebar-view-closed",s.class]),m=t.computed(()=>{const{class:M,...I}=s;return I}),g=t.computed(()=>({"--sidebar-width":y(p.value),paddingTop:"env(safe-area-inset-top)",paddingBottom:"env(safe-area-inset-bottom)"})),v=t.computed(()=>{const M=o.position==="left"?"margin-inline-start":"margin-inline-end";return`
|
|
83
|
+
@media (min-width: 768px) {
|
|
84
|
+
body {
|
|
85
|
+
${M}: ${k(p.value)};
|
|
86
|
+
transition: ${M} ${tw}ms ease;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
`});function y(M){return typeof M=="number"?`${M}px`:M}function k(M){return typeof M=="number"?`${M}px`:M}function b(){if(o.width!==void 0||!l.value)return;const M=l.value.getBoundingClientRect().width;M>0&&(c.value=M)}function w(){i.value?.setModalOpen?.(!1)}function S(){i.value?.setModalOpen?.(!0)}function C(){i.value?.setModalOpen?.(!d.value)}function A(M){r("submit-message",M)}function E(){r("stop")}function L(M){r("input-change",M)}function z(M,I){r("select-suggestion",M,I)}function O(){r("add-file")}function N(){r("start-transcribe")}function K(){r("cancel-transcribe")}function ae(){r("finish-transcribe")}const H=t.computed(()=>{const M={onSubmitMessage:A,onInputChange:L,onSelectSuggestion:z};return o.onStop&&(M.onStop=E),o.onAddFile&&(M.onAddFile=O),o.onStartTranscribe&&(M.onStartTranscribe=N),o.onCancelTranscribe&&(M.onCancelTranscribe=K),o.onFinishTranscribe&&(M.onFinishTranscribe=ae),M});return t.watch(()=>o.width,M=>{if(M!==void 0){c.value=M;return}b()}),t.onMounted(async()=>{await t.nextTick(),b(),!(o.width!==void 0||!l.value||typeof ResizeObserver>"u")&&(u=new ResizeObserver(()=>{b()}),u.observe(l.value))}),t.onBeforeUnmount(()=>{u?.disconnect(),u=null}),(M,I)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[d.value?(t.openBlock(),t.createBlock(t.resolveDynamicComponent("style"),{key:0},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(v.value),1)]),_:1})):t.createCommentVNode("",!0),t.renderSlot(M.$slots,"toggle-button",{isOpen:d.value,toggle:C,open:S,close:w},()=>[t.createVNode(xa,{class:t.normalizeClass(e.position==="left"?"cpk-sidebar-view-toggle-button-left":void 0)},null,8,["class"])]),t.createElementVNode("aside",t.mergeProps({ref_key:"sidebarRef",ref:l,"data-copilotkit":"","data-copilot-sidebar":"","data-position":e.position,class:f.value,style:g.value,"aria-label":t.unref(i)?.labels.sidebarLabel??t.unref(x.CopilotChatDefaultLabels).sidebarLabel,"aria-hidden":!d.value,role:"complementary"},m.value),[t.createElementVNode("div",XS,[t.renderSlot(M.$slots,"header",{title:h.value,onClose:w,isOpen:d.value},()=>[t.createVNode(Oa,{title:h.value},null,8,["title"])]),t.createElementVNode("div",QS,[t.createVNode(Cn,t.mergeProps({messages:e.messages,"auto-scroll":e.autoScroll,"is-running":e.isRunning,suggestions:e.suggestions,"suggestion-loading-indexes":e.suggestionLoadingIndexes,"welcome-screen":e.welcomeScreen,"input-value":e.inputValue,"input-mode":e.inputMode,"input-tools-menu":e.inputToolsMenu,"tool-call-display":e.toolCallDisplay,"message-feedback":e.messageFeedback,"on-finish-transcribe-with-audio":e.onFinishTranscribeWithAudio},H.value),t.createSlots({_:2},[t.renderList(t.unref(nn)(M.$slots,a),B=>({name:B,fn:t.withCtx(F=>[t.renderSlot(M.$slots,B,t.normalizeProps(t.guardReactiveProps(F)))])}))]),1040,["messages","auto-scroll","is-running","suggestions","suggestion-loading-indexes","welcome-screen","input-value","input-mode","input-tools-menu","tool-call-display","message-feedback","on-finish-transcribe-with-audio"])])])],16,YS)],64))}}),gc=t.defineComponent({inheritAttrs:!1,__name:"CopilotSidebarView",props:{width:{default:void 0},defaultOpen:{type:Boolean,default:!0},position:{default:"right"},messages:{default:()=>[]},autoScroll:{type:[String,Boolean],default:!0},isRunning:{type:Boolean,default:!1},suggestions:{default:()=>[]},suggestionLoadingIndexes:{default:()=>[]},welcomeScreen:{type:Boolean,default:!0},attachments:{},dragOver:{type:Boolean},inputValue:{default:void 0},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},onSubmitMessage:{},onStop:{},onInputChange:{},onSelectSuggestion:{},onStartTranscribe:{},onCancelTranscribe:{},onFinishTranscribe:{},isConnecting:{type:Boolean},hasExplicitThreadId:{type:Boolean},onRemoveAttachment:{},onAddFile:{},onDragOver:{},onDragLeave:{},onDrop:{},onFinishTranscribeWithAudio:{type:Function,default:void 0},toolCallDisplay:{},messageFeedback:{type:Boolean,default:!0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(e,{emit:n}){const o=e,a=n,r=t.useAttrs(),s=t.computed(()=>{const{defaultOpen:c,...u}=o;return u}),i=t.computed(()=>({...r,...s.value,...l.value})),l=t.computed(()=>{const c={onSubmitMessage:u=>a("submit-message",u),onInputChange:u=>a("input-change",u),onSelectSuggestion:(u,d)=>a("select-suggestion",u,d)};return o.onStop&&(c.onStop=()=>a("stop")),o.onAddFile&&(c.onAddFile=()=>a("add-file")),o.onStartTranscribe&&(c.onStartTranscribe=()=>a("start-transcribe")),o.onCancelTranscribe&&(c.onCancelTranscribe=()=>a("cancel-transcribe")),o.onFinishTranscribe&&(c.onFinishTranscribe=()=>a("finish-transcribe")),c});return(c,u)=>(t.openBlock(),t.createBlock(ro,{"is-modal-default-open":e.defaultOpen},{default:t.withCtx(()=>[t.createVNode(nw,t.normalizeProps(t.guardReactiveProps(i.value)),t.createSlots({_:2},[t.renderList(t.unref(nn)(c.$slots),d=>({name:d,fn:t.withCtx(p=>[t.renderSlot(c.$slots,d,t.normalizeProps(t.guardReactiveProps(p)))])}))]),1040)]),_:3},8,["is-modal-default-open"]))}}),ow={"data-copilotkit":"",class:"cpk-sidebar-view-welcome-screen","data-testid":"copilot-sidebar-welcome-screen"},aw={class:"cpk-sidebar-view-welcome-screen-message"},rw={class:"cpk-chat-view-welcome-message"},sw={class:"cpk-sidebar-view-welcome-screen-footer"},iw={class:"cpk-sidebar-view-welcome-screen-content"},lw={class:"cpk-sidebar-view-welcome-screen-suggestions"},vc=t.defineComponent({__name:"CopilotSidebarWelcomeScreen",props:{modelValue:{default:""},isRunning:{type:Boolean,default:!1},inputMode:{default:"input"},inputToolsMenu:{default:()=>[]},onUpdateModelValue:{},onSubmitMessage:{},suggestions:{default:()=>[]},loadingIndexes:{default:()=>[]},onSelectSuggestion:{},onStop:{},onAddFile:{type:Function,default:void 0},onStartTranscribe:{type:Function,default:void 0},onCancelTranscribe:{type:Function,default:void 0},onFinishTranscribe:{type:Function,default:void 0},onFinishTranscribeWithAudio:{type:Function,default:void 0},canStop:{type:Boolean,default:void 0},canAddFile:{type:Boolean,default:void 0},canTranscribe:{type:Boolean,default:void 0}},setup(e){const n=e,o=Re(),a=t.computed(()=>o.value?.labels??x.CopilotChatDefaultLabels);function r(){n.onStop?.()}function s(){n.onAddFile?.()}function i(){n.onStartTranscribe?.()}function l(){n.onCancelTranscribe?.()}function c(){n.onFinishTranscribe?.()}async function u(m){await n.onFinishTranscribeWithAudio?.(m)}const d=t.computed(()=>({modelValue:n.modelValue,isRunning:n.isRunning,inputMode:n.inputMode,inputToolsMenu:n.inputToolsMenu,canStop:n.canStop??!!n.onStop,canAddFile:n.canAddFile??!!n.onAddFile,canTranscribe:n.canTranscribe??!!n.onStartTranscribe,onUpdateModelValue:n.onUpdateModelValue,onSubmitMessage:n.onSubmitMessage,onStop:r,onAddFile:s,onStartTranscribe:i,onCancelTranscribe:l,onFinishTranscribe:c,onFinishTranscribeWithAudio:u})),p=t.computed(()=>({suggestions:n.suggestions,loadingIndexes:n.loadingIndexes,onSelectSuggestion:n.onSelectSuggestion})),h=t.computed(()=>({...d.value,...p.value})),f=t.computed(()=>{const m={"onUpdate:modelValue":n.onUpdateModelValue,onSubmitMessage:n.onSubmitMessage,onStop:n.onStop};return n.onAddFile&&(m.onAddFile=n.onAddFile),n.onStartTranscribe&&(m.onStartTranscribe=n.onStartTranscribe),n.onCancelTranscribe&&(m.onCancelTranscribe=n.onCancelTranscribe),n.onFinishTranscribe&&(m.onFinishTranscribe=n.onFinishTranscribe),n.onFinishTranscribeWithAudio&&(m.onFinishTranscribeWithAudio=n.onFinishTranscribeWithAudio),m});return(m,g)=>t.renderSlot(m.$slots,"layout",t.normalizeProps(t.guardReactiveProps(h.value)),()=>[t.createElementVNode("div",ow,[t.createElementVNode("div",aw,[t.renderSlot(m.$slots,"welcome-message",{},()=>[t.createElementVNode("h1",rw,t.toDisplayString(a.value.welcomeMessageText),1)])]),t.createElementVNode("div",sw,[t.createElementVNode("div",iw,[t.createElementVNode("div",lw,[t.renderSlot(m.$slots,"suggestion-view",t.normalizeProps(t.guardReactiveProps(p.value)),()=>[t.createVNode(vn,{class:"cpk-chat-view-suggestion-view",suggestions:e.suggestions,"loading-indexes":e.loadingIndexes,onSelectSuggestion:e.onSelectSuggestion},null,8,["suggestions","loading-indexes","onSelectSuggestion"])])]),t.renderSlot(m.$slots,"input",t.normalizeProps(t.guardReactiveProps(d.value)),()=>[t.createVNode(gn,t.mergeProps({"model-value":e.modelValue,"is-running":e.isRunning,mode:e.inputMode,"tools-menu":e.inputToolsMenu,positioning:"static","show-disclaimer":!0},f.value),null,16,["model-value","is-running","mode","tools-menu"])])])])])])}}),cw=t.defineComponent({__name:"CopilotPopup",props:{width:{default:void 0},height:{default:void 0},clickOutsideToClose:{type:Boolean,default:!1},defaultOpen:{type:Boolean,default:!0},inputMode:{default:"input"},agentId:{},threadId:{},throttleMs:{},labels:{},attachments:{},onError:{},autoScroll:{type:[String,Boolean],default:!0},welcomeScreen:{type:Boolean,default:!0},inputValue:{default:void 0},inputToolsMenu:{default:()=>[]},isConnecting:{type:Boolean},hasExplicitThreadId:{type:Boolean},onFinishTranscribeWithAudio:{type:Function,default:void 0},toolCallDisplay:{},messageFeedback:{type:Boolean,default:!0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(e){function n(i){return{onSubmitMessage:i.onSubmitMessage,onInputChange:i.onInputChange,onSelectSuggestion:i.onSelectSuggestion,...i.canStop?{onStop:i.onStop}:{},...i.canAddFile?{onAddFile:i.onAddFile}:{},...i.canTranscribe?{onStartTranscribe:i.onStartTranscribe,onCancelTranscribe:i.onCancelTranscribe,onFinishTranscribe:i.onFinishTranscribe}:{}}}const o=e,a=["chat-view","welcome-screen","welcome-message"],r=Sn(),s=t.computed(()=>r.value.checkFeature("popup"));return t.watch(s,i=>{i||console.warn('[CopilotKit] Warning: "popup" feature is not licensed. Visit copilotkit.ai/pricing')},{immediate:!0}),(i,l)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[s.value?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(_a,{key:0,"feature-name":"Popup"})),t.createVNode(Aa,t.mergeProps(o,{onSubmitMessage:l[0]||(l[0]=c=>i.$emit("submit-message",c)),onStop:l[1]||(l[1]=c=>i.$emit("stop")),onInputChange:l[2]||(l[2]=c=>i.$emit("input-change",c)),onSelectSuggestion:l[3]||(l[3]=(c,u)=>i.$emit("select-suggestion",c,u)),onAddFile:l[4]||(l[4]=c=>i.$emit("add-file")),onStartTranscribe:l[5]||(l[5]=c=>i.$emit("start-transcribe")),onCancelTranscribe:l[6]||(l[6]=c=>i.$emit("cancel-transcribe")),onFinishTranscribe:l[7]||(l[7]=c=>i.$emit("finish-transcribe"))}),{"chat-view":t.withCtx(c=>[i.$slots["chat-view"]?t.renderSlot(i.$slots,"chat-view",t.normalizeProps(t.mergeProps({key:0},c))):(t.openBlock(),t.createBlock(mc,t.mergeProps({key:1,messages:c.messages,"auto-scroll":c.autoScroll,"is-running":c.isRunning,suggestions:c.suggestions,"suggestion-loading-indexes":c.suggestionLoadingIndexes,"welcome-screen":c.welcomeScreen,"input-value":c.inputValue,"input-mode":c.inputMode,"input-tools-menu":c.inputToolsMenu,width:e.width,"tool-call-display":c.toolCallDisplay,"message-feedback":c.messageFeedback,height:e.height,"click-outside-to-close":e.clickOutsideToClose,"default-open":e.defaultOpen,"on-finish-transcribe-with-audio":c.onFinishTranscribeWithAudio},n(c)),t.createSlots({"welcome-screen":t.withCtx(u=>[i.$slots["welcome-screen"]?t.renderSlot(i.$slots,"welcome-screen",t.normalizeProps(t.mergeProps({key:0},u))):(t.openBlock(),t.createBlock(hc,t.normalizeProps(t.mergeProps({key:1},u)),t.createSlots({_:2},[i.$slots["welcome-message"]?{name:"welcome-message",fn:t.withCtx(()=>[t.renderSlot(i.$slots,"welcome-message")]),key:"0"}:void 0,i.$slots["suggestion-view"]?{name:"suggestion-view",fn:t.withCtx(d=>[t.renderSlot(i.$slots,"suggestion-view",t.normalizeProps(t.guardReactiveProps(d)))]),key:"1"}:void 0,i.$slots.input?{name:"input",fn:t.withCtx(d=>[t.renderSlot(i.$slots,"input",t.normalizeProps(t.guardReactiveProps(d)))]),key:"2"}:void 0]),1040))]),_:2},[t.renderList(t.unref(nn)(i.$slots,a),u=>({name:u,fn:t.withCtx(d=>[t.renderSlot(i.$slots,u,t.normalizeProps(t.guardReactiveProps(d)))])}))]),1040,["messages","auto-scroll","is-running","suggestions","suggestion-loading-indexes","welcome-screen","input-value","input-mode","input-tools-menu","width","tool-call-display","message-feedback","height","click-outside-to-close","default-open","on-finish-transcribe-with-audio"]))]),_:3},16)],64))}}),uw=t.defineComponent({__name:"CopilotSidebar",props:{width:{default:void 0},defaultOpen:{type:Boolean,default:!0},position:{default:"right"},inputMode:{default:"input"},agentId:{},threadId:{},throttleMs:{},labels:{},attachments:{},onError:{},autoScroll:{type:[String,Boolean],default:!0},welcomeScreen:{type:Boolean,default:!0},inputValue:{default:void 0},inputToolsMenu:{default:()=>[]},isConnecting:{type:Boolean},hasExplicitThreadId:{type:Boolean},onFinishTranscribeWithAudio:{type:Function,default:void 0},toolCallDisplay:{},messageFeedback:{type:Boolean,default:!0}},emits:["submit-message","stop","input-change","select-suggestion","add-file","start-transcribe","cancel-transcribe","finish-transcribe"],setup(e){function n(i){return{onSubmitMessage:i.onSubmitMessage,onInputChange:i.onInputChange,onSelectSuggestion:i.onSelectSuggestion,...i.canStop?{onStop:i.onStop}:{},...i.canAddFile?{onAddFile:i.onAddFile}:{},...i.canTranscribe?{onStartTranscribe:i.onStartTranscribe,onCancelTranscribe:i.onCancelTranscribe,onFinishTranscribe:i.onFinishTranscribe}:{}}}const o=e,a=["chat-view","welcome-screen","welcome-message"],r=Sn(),s=t.computed(()=>r.value.checkFeature("sidebar"));return t.watch(s,i=>{i||console.warn('[CopilotKit] Warning: "sidebar" feature is not licensed. Visit copilotkit.ai/pricing')},{immediate:!0}),(i,l)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[s.value?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(_a,{key:0,"feature-name":"Sidebar"})),t.createVNode(Aa,t.mergeProps(o,{onSubmitMessage:l[0]||(l[0]=c=>i.$emit("submit-message",c)),onStop:l[1]||(l[1]=c=>i.$emit("stop")),onInputChange:l[2]||(l[2]=c=>i.$emit("input-change",c)),onSelectSuggestion:l[3]||(l[3]=(c,u)=>i.$emit("select-suggestion",c,u)),onAddFile:l[4]||(l[4]=c=>i.$emit("add-file")),onStartTranscribe:l[5]||(l[5]=c=>i.$emit("start-transcribe")),onCancelTranscribe:l[6]||(l[6]=c=>i.$emit("cancel-transcribe")),onFinishTranscribe:l[7]||(l[7]=c=>i.$emit("finish-transcribe"))}),{"chat-view":t.withCtx(c=>[i.$slots["chat-view"]?t.renderSlot(i.$slots,"chat-view",t.normalizeProps(t.mergeProps({key:0},c))):(t.openBlock(),t.createBlock(gc,t.mergeProps({key:1,messages:c.messages,"auto-scroll":c.autoScroll,"is-running":c.isRunning,suggestions:c.suggestions,"suggestion-loading-indexes":c.suggestionLoadingIndexes,"welcome-screen":c.welcomeScreen,"input-value":c.inputValue,"input-mode":c.inputMode,"input-tools-menu":c.inputToolsMenu,width:e.width,"tool-call-display":c.toolCallDisplay,"message-feedback":c.messageFeedback,"default-open":e.defaultOpen,position:e.position,"on-finish-transcribe-with-audio":c.onFinishTranscribeWithAudio},n(c)),t.createSlots({"welcome-screen":t.withCtx(u=>[i.$slots["welcome-screen"]?t.renderSlot(i.$slots,"welcome-screen",t.normalizeProps(t.mergeProps({key:0},u))):(t.openBlock(),t.createBlock(vc,t.normalizeProps(t.mergeProps({key:1},u)),t.createSlots({_:2},[i.$slots["welcome-message"]?{name:"welcome-message",fn:t.withCtx(()=>[t.renderSlot(i.$slots,"welcome-message")]),key:"0"}:void 0,i.$slots["suggestion-view"]?{name:"suggestion-view",fn:t.withCtx(d=>[t.renderSlot(i.$slots,"suggestion-view",t.normalizeProps(t.guardReactiveProps(d)))]),key:"1"}:void 0,i.$slots.input?{name:"input",fn:t.withCtx(d=>[t.renderSlot(i.$slots,"input",t.normalizeProps(t.guardReactiveProps(d)))]),key:"2"}:void 0]),1040))]),_:2},[t.renderList(t.unref(nn)(i.$slots,a),u=>({name:u,fn:t.withCtx(d=>[t.renderSlot(i.$slots,u,t.normalizeProps(t.guardReactiveProps(d)))])}))]),1040,["messages","auto-scroll","is-running","suggestions","suggestion-loading-indexes","welcome-screen","input-value","input-mode","input-tools-menu","width","tool-call-display","message-feedback","default-open","position","on-finish-transcribe-with-audio"]))]),_:3},16)],64))}}),dw=Object.assign(Aa,{View:Cn}),pw=Object.assign(xa,{OpenIcon:Ra,CloseIcon:$a}),fw=Object.assign(Oa,{Title:fc,CloseButton:pc}),mw=Object.assign(mc,{WelcomeScreen:hc}),hw=Object.assign(gc,{WelcomeScreen:vc});function gw(e){const{copilotkit:n}=Ve(),o=t.computed(()=>t.toValue(e.description)),a=t.computed(()=>t.toValue(e.value)),r=t.computed(()=>typeof a.value=="string"?a.value:JSON.stringify(a.value));t.watch([()=>n.value,o,r],(s,i,l)=>{const c=n.value,u=c.addContext({description:o.value,value:r.value});l(()=>c.removeContext(u))},{immediate:!0})}const vw=[];function Na(e,n){const{copilotkit:o}=Ve(),a=n??vw;t.watch([()=>e.name,()=>e.available,()=>JSON.stringify(e.webmcp??null),()=>a.length,...a],(r,s,i)=>{const l=o.value,c=e.name,u=l.addTool(e);e.render&&l.addHookRenderToolCall({name:c,args:e.parameters,agentId:e.agentId,render:e.render}),i(u)},{immediate:!0})}function bw(e,n){const o=`Use this tool to display the "${e.name}" component in the chat. This tool renders a visual UI component for the user.`,a=e.description?`${o}
|
|
90
|
+
|
|
91
|
+
${e.description}`:o;Na({name:e.name,description:a,parameters:e.parameters,render:({args:r})=>{const s=e.render;return t.h(s,r)},agentId:e.agentId},n)}const yw=[];function bc(e,n){const{copilotkit:o}=Ve(),a=n??yw;t.watch([()=>o.value,()=>e.name,()=>e.agentId,()=>e.group,()=>a.length,...a],()=>{const r=i=>typeof e.render=="function"?e.render(i):t.h(e.render,i),s=e.name==="*"&&!e.parameters?Kn({name:"*",render:i=>r({...i,parameters:i.args}),...e.agentId?{agentId:e.agentId}:{},...e.group?{group:!0}:{}}):Kn({name:e.name,args:e.parameters,render:i=>r({...i,parameters:i.args}),...e.agentId?{agentId:e.agentId}:{},...e.group?{group:!0}:{}});o.value.addHookRenderToolCall(s)},{immediate:!0})}const xr=new Set;function kw(e){switch(e){case x.ToolCallStatus.Complete:return"complete";case x.ToolCallStatus.Executing:return"executing";case x.ToolCallStatus.InProgress:return"inProgress";default:{const n=String(e);return xr.has(n)||(xr.add(n),console.warn(`[CopilotKit] Unknown ToolCallStatus "${n}" in default tool-call renderer; falling back to "inProgress".`)),"inProgress"}}}function To(e){const n=e.parameters!==void 0?e.parameters:e.args,o=e.status,a=o==="inProgress"||o==="executing"||o==="complete"?o:kw(o);return{name:e.name,toolCallId:e.toolCallId,parameters:n,status:a,result:e.result}}function Or(e){try{return JSON.stringify(e,null,2)}catch(n){console.warn("[CopilotKit] Failed to JSON.stringify tool-call payload for default renderer; falling back to String():",n);try{return String(e)}catch(o){return console.warn("[CopilotKit] safeStringifyForPre: value could not be stringified:",o),"[unserializable]"}}}const Sw=t.defineComponent({props:{name:{type:String,required:!0},toolCallId:{type:String,required:!0},parameters:{type:null,required:!1,default:void 0},status:{type:String,required:!0},result:{type:null,required:!1,default:void 0}},setup(e){const n=t.ref(!1),o=t.inject(Ta,null);return()=>{const a=o?.value;if(a)return t.h(qv,{"data-testid":"copilot-tool-render","data-tool-name":e.name,"data-tool-call-id":e.toolCallId,"data-status":e.status,"data-args":Bn(e.parameters),"data-result":Bn(e.result),name:e.name,parameters:e.parameters,result:e.result,status:e.status==="complete"?a.failedIds.has(e.toolCallId)?"failed":"done":a.active?"running":"stopped",appearance:a.appearance});const r=e.status==="inProgress"||e.status==="executing",s=e.status==="complete",i=r?"Running":s?"Done":e.status,l=r?"running":s?"done":"other";return t.h("div",{"data-testid":"copilot-tool-render","data-tool-name":e.name,"data-tool-call-id":e.toolCallId,"data-status":e.status,"data-args":Bn(e.parameters),"data-result":Bn(e.result),class:"cpk-default-tool-call"},[t.h("div",{class:"cpk-default-tool-call-card"},[t.h("button",{type:"button","aria-expanded":String(n.value),onClick:()=>{n.value=!n.value},class:"cpk-default-tool-call-header",style:{font:"inherit"}},[t.h("div",{class:"cpk-default-tool-call-title"},[t.h("svg",{class:["cpk-default-tool-call-chevron",n.value&&"cpk-default-tool-call-chevron-open"],fill:"none",viewBox:"0 0 24 24","stroke-width":2,stroke:"currentColor"},[t.h("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M8.25 4.5l7.5 7.5-7.5 7.5"})]),t.h("span",{class:`cpk-default-tool-call-dot cpk-default-tool-call-dot-${l}`}),t.h("span",{"data-testid":"copilot-tool-render-name",class:"cpk-default-tool-call-name"},e.name)]),t.h("span",{"data-testid":"copilot-tool-render-status",class:`cpk-default-tool-call-badge cpk-default-tool-call-badge-${l}`},i)]),n.value?t.h("div",{class:"cpk-default-tool-call-details"},[t.h("div",[t.h("div",{class:"cpk-default-tool-call-label"},"Arguments"),t.h("pre",{class:"cpk-default-tool-call-code"},Or(e.parameters??{}))]),e.result!==void 0?t.h("div",[t.h("div",{class:"cpk-default-tool-call-label"},"Result"),t.h("pre",{class:"cpk-default-tool-call-code"},typeof e.result=="string"?e.result:Or(e.result))]):null]):null])])}}});function Bn(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch(n){console.warn("[CopilotKit] Failed to JSON.stringify tool-call payload for data-* attribute; falling back to String():",n);try{return String(e)}catch(o){return console.warn("[CopilotKit] safeStringifyForAttr: value could not be stringified:",o),""}}}function ww(e,n){const o=e?.render;let a;if(typeof o=="function"){const r=o;a=(s=>{const i=To(s);return r(i)})}else if(o){const r=o;a=(s=>{const i=To(s);return t.h(r,{name:i.name,toolCallId:i.toolCallId,parameters:i.parameters,status:i.status,result:i.result})})}else a=(r=>{const s=To(r);return t.h(Sw,{name:s.name,toolCallId:s.toolCallId,parameters:s.parameters,status:s.status,result:s.result})});bc({name:"*",render:a,group:o?e?.group===!0:!0},n)}function Cw(e,n){const{copilotkit:o}=Ve(),a=t.ref(null),r=t.ref(null),s=t.ref(null),i=async d=>{a.value&&(s.value?.(),s.value=null,a.value(d),a.value=null,r.value=null)},u={...e,type:"human-in-the-loop",handler:async(d,p)=>{const h=p?.signal;return new Promise((f,m)=>{if(h?.aborted){m(new Error("Human-in-the-loop interaction aborted"));return}if(a.value=f,r.value=m,h){const g=()=>{s.value=null,a.value=null;const v=r.value;r.value=null,v?.(new Error("Human-in-the-loop interaction aborted"))};h.addEventListener("abort",g,{once:!0}),s.value=()=>{h.removeEventListener("abort",g)}}})},render:d=>{const p=e.render;return d.status===x.ToolCallStatus.InProgress?t.h(p,{...d,name:e.name,description:e.description||"",agentId:e.agentId,respond:void 0}):d.status===x.ToolCallStatus.Executing?t.h(p,{...d,name:e.name,description:e.description||"",agentId:e.agentId,respond:i}):d.status===x.ToolCallStatus.Complete?t.h(p,{...d,name:e.name,description:e.description||"",agentId:e.agentId,respond:void 0}):d}};Na(u,n),t.onScopeDispose(()=>{o.value.removeHookRenderToolCall(e.name,e.agentId)})}function Tw(e){return"instructions"in e}function Ew(e){return e.map(n=>({...n,isLoading:n.isLoading??!1}))}function Iw(e,n){const{copilotkit:o}=Ve(),a=Re(),r=n??[],s=t.computed(()=>a.value?.agentId??Q.DEFAULT_AGENT_ID),i=t.computed(()=>e?e.consumerAgentId:void 0),l=t.computed(()=>{if(!e||e.available==="disabled")return null;if(Tw(e))return{...e};const v=Ew(e.suggestions);return{...e,suggestions:v}}),c=t.computed(()=>l.value?JSON.stringify(l.value):null),u=t.computed(()=>{if(!l.value)return s.value;const v=l.value.consumerAgentId;return!v||v==="*"?s.value:v}),d=t.computed(()=>i.value===void 0||i.value==="*"),p=t.ref(!1),h=t.ref(null),f=t.ref(null),m=()=>{if(!p.value||!d.value)return;if(Object.values(o.value.agents??{}).some(y=>!!y.agentId&&y.isRunning)){h.value=setTimeout(()=>{h.value=null,m()},0);return}p.value=!1,g()},g=()=>{if(l.value){if(d.value){let v=!1;const y=Object.values(o.value.agents??{});for(const k of y){const b=k.agentId;b&&(k.isRunning?v=!0:o.value.reloadSuggestions(b))}p.value=v,v&&h.value===null&&(h.value=setTimeout(()=>{h.value=null,m()},0));return}u.value&&o.value.reloadSuggestions(u.value)}};t.watch([()=>o.value,c],([v,y],k,b)=>{if(!y||!l.value)return;const w=o.value,S=l.value,C=w.addSuggestionsConfig(S);g(),b(()=>w.removeSuggestionsConfig(C))},{immediate:!0}),t.watch([l,c],([v,y])=>{if(!v){f.value=null;return}y&&f.value===y||(y&&(f.value=y),g())},{immediate:!1}),t.watch([l,()=>r.length,...r],([v])=>{!v||r.length===0||g()},{immediate:!0}),t.watch([()=>o.value,p],(v,y,k)=>{k(()=>{h.value!==null&&(clearTimeout(h.value),h.value=null)})},{immediate:!0}),t.watch([()=>o.value,d],([v,y],k,b)=>{if(!y)return;const w=Object.values(v.agents??{}).filter(S=>!!S).map(S=>S.subscribe({onRunStartedEvent:m,onRunFinishedEvent:m,onRunFinalized:m,onRunFailed:m,onRunErrorEvent:m}));b(()=>{for(const S of w)S.unsubscribe()})},{immediate:!0})}const yc="on_interrupt";function _w(e){return(typeof e=="object"||typeof e=="function")&&e!==null&&typeof Reflect.get(e,"then")=="function"}function Aw(e){return e instanceof Promise?e:new Promise((n,o)=>{try{e.then(n,o)}catch(a){o(a)}})}function Eo(e){return e.kind==="legacy"?e.event:{name:yc,value:e.interrupts[0]}}function $w(e={}){const{copilotkit:n}=Ve(),{agent:o}=io({agentId:e.agentId}),a=t.shallowRef(null),r=t.shallowRef(null),s={};t.watch(o,(f,m,g)=>{if(!f){a.value=null,r.value=null;return}let v=null,y=null;const k=f.subscribe({onCustomEvent:({event:b})=>{b.name===yc&&(v={name:b.name,value:b.value})},onRunFinishedEvent:b=>{b.outcome==="interrupt"&&(y=b.interrupts)},onRunStartedEvent:()=>{v=null,y=null;for(const b of Object.keys(s))delete s[b];a.value=null},onRunFinalized:()=>{y&&y.length>0?a.value={kind:"standard",interrupts:y}:v&&(a.value={kind:"legacy",event:v}),v=null,y=null},onRunFailed:()=>{v=null,y=null;for(const b of Object.keys(s))delete s[b];a.value=null}});g(()=>k.unsubscribe())},{immediate:!0});const i=async f=>{if(!f.every(k=>s[k.id]))return;const g=f.find(k=>zn.isInterruptExpired(k));if(g){console.error(`[CopilotKit] useInterrupt: interrupt ${g.id} expired at ${g.expiresAt}; not resuming.`);for(const k of Object.keys(s))delete s[k];a.value=null;return}const v=zn.buildResumeArray(f,s);for(const k of Object.keys(s))delete s[k];const y=o.value;if(y)try{return await n.value.runAgent({agent:y,resume:v})}catch(k){throw console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing",k),a.value=null,k}},l=async(f,m)=>{const g=a.value;if(!g)return;const v=o.value;if(!v)return;if(g.kind==="legacy"){const k=g.event.value;try{return await n.value.runAgent({agent:v,forwardedProps:{command:{resume:f,interruptEvent:k}}})}catch(b){throw console.error("[CopilotKit] useInterrupt resolve: runAgent rejected; clearing pending + rethrowing",b),a.value=null,b}}g.interrupts.length>1&&m===void 0&&console.warn(`[CopilotKit] useInterrupt: resolve()/cancel() called without an interruptId while ${g.interrupts.length} interrupts are open; defaulting to the first. Pass an interruptId to address a specific interrupt.`);const y=m??g.interrupts[0]?.id;if(y)return s[y]={status:"resolved",payload:f},i(g.interrupts)},c=async f=>{const m=a.value;if(!m)return;if(m.kind==="legacy"){console.warn("[CopilotKit] useInterrupt: cancel() is not supported for legacy on_interrupt interrupts; dismissing."),a.value=null;return}m.interrupts.length>1&&f===void 0&&console.warn(`[CopilotKit] useInterrupt: resolve()/cancel() called without an interruptId while ${m.interrupts.length} interrupts are open; defaulting to the first. Pass an interruptId to address a specific interrupt.`);const g=f??m.interrupts[0]?.id;if(g)return s[g]={status:"cancelled"},i(m.interrupts)},u=l,d=c;t.watch(a,(f,m,g)=>{if(!f){r.value=null;return}const v=Eo(f);if(e.enabled&&!e.enabled(v)){r.value=null;return}const y=e.handler;if(!y){r.value=null;return}let k=!1;const b=y({event:v,interrupt:f.kind==="standard"?f.interrupts[0]??null:null,interrupts:f.kind==="standard"?f.interrupts:[],resolve:l,cancel:c});_w(b)?Aw(b).then(w=>{k||(r.value=w)}).catch(w=>{k||(console.error("[CopilotKit] useInterrupt handler failed:",w),r.value=null)}):r.value=b,g(()=>{k=!0})},{immediate:!0});const p=t.computed(()=>a.value?Eo(a.value):null),h=t.computed(()=>{const f=a.value;if(!f)return null;const m=Eo(f);return e.enabled&&!e.enabled(m)?null:{event:m,interrupt:f.kind==="standard"?f.interrupts[0]??null:null,interrupts:f.kind==="standard"?f.interrupts:[],result:r.value,resolve:l,cancel:c}});return t.watch([()=>n.value,h,()=>e.renderInChat!==!1],([f,m,g],v,y)=>{if(!g)return;f.setInterruptState(m);const k=m;y(()=>{f.interruptState===k&&f.setInterruptState(null)})},{immediate:!0}),t.onScopeDispose(()=>{const f=n.value;e.renderInChat!==!1&&f.interruptState===h.value&&f.setInterruptState(null)}),{interrupt:p,result:r,hasInterrupt:t.computed(()=>h.value!==null),resolve:l,resolveInterrupt:u,cancel:c,cancelInterrupt:d,slotProps:h}}function Rw(e){const{agent:n}=io({agentId:e});return t.computed(()=>{const o=n.value;if(o&&"capabilities"in o)return o.capabilities})}function xw(){const{copilotkit:e}=Ve(),n=Re();return function(a){const r=n.value;if(!r)return null;const s=r.agentId||Q.DEFAULT_AGENT_ID,{threadId:i}=r,l=e.value,c=x.ɵresolveCustomMessageRenderers(l.renderCustomMessages,s);if(!c.length)return null;const{message:u,position:d}=a,p=l.getRunIdForMessage(s,i,u.id)??l.getRunIdsForThread(s,i).slice(-1)[0],h=p??`missing-run-id:${u.id}`,f=l.getAgent(s);if(!f)return null;const m=p?f.messages.filter(C=>l.getRunIdForMessage(s,i,C.id)===p).map(C=>C.id):[u.id],g=f.messages.findIndex(C=>C.id===u.id);g<0&&console.warn(`[CopilotKit] useRenderCustomMessages: message "${u.id}" not found in agent "${s}" messages`);const v=Math.max(0,g),y=p?Math.max(m.indexOf(u.id),0):0,k=p?m.length:1,b=p?l.getStateByRun(s,i,p):void 0,w={message:u,position:d,runId:h,messageIndex:v,messageIndexInRun:y,numberOfMessagesInRun:k,agentId:s,stateSnapshot:b},S=c.find(C=>C.render);return S?{renderer:S.render,props:w}:null}}function Ow(){const{copilotkit:e}=Ve(),n=Re(),o=t.computed(()=>n.value?.agentId??Q.DEFAULT_AGENT_ID);function a(s){const i=e.value.renderActivityMessages,l=i.filter(c=>c.activityType===s);return l.find(c=>c.agentId===o.value)??l.find(c=>c.agentId===void 0)??i.find(c=>c.activityType==="*")??null}function r(s){const i=x.ɵresolveActivityRenderer(e.value.renderActivityMessages,{activityType:s.activityType,agentId:o.value,content:s.content});return i?{renderer:i.renderer.render,props:{activityType:s.activityType,content:i.content,message:s,agent:e.value.getAgent(o.value)}}:(a(s.activityType)&&console.warn(`Failed to validate content for activity message '${s.activityType}'.`),null)}return{renderActivityMessage:r,findRenderer:a}}exports.A2UIActivityContentSchema=bh;exports.A2UISurfaceActivityType=vh;exports.ActivityDeltaEventSchema=fi;exports.ActivityMessageSchema=ci;exports.ActivitySnapshotEventSchema=pi;exports.AddOperationSchema=Gs;exports.AgentCapabilitiesSchema=dh;exports.AssistantMessageSchema=si;exports.AttributableSchema=ph;exports.AudioPartSchema=js;exports.BaseEventSchema=fh;exports.BaseMessageSchema=mh;exports.ContentPartSchema=to;exports.ContextSchema=gi;exports.CopilotChat=dw;exports.CopilotChatToggleButton=pw;exports.CopilotChatToggleButtonCloseIcon=$a;exports.CopilotChatToggleButtonOpenIcon=Ra;exports.CopilotKitCoreVue=sl;exports.CopilotKitStyles=uc;exports.CopilotModalHeader=fw;exports.CopilotPopupView=mw;exports.CopilotSidebarView=hw;exports.CopyOperationSchema=Xs;exports.CustomEventSchema=hi;exports.DataSourceSchema=Ls;exports.DeveloperMessageSchema=ni;exports.DocumentPartSchema=Ws;exports.EventSchema=ch;exports.EventTypeSchema=$s;exports.ExecutionCapabilitiesSchema=el;exports.FileSourceSchema=zs;exports.FunctionCallSchema=ai;exports.GenerateSandboxedUiArgsSchema=ml;exports.HumanInTheLoopCapabilitiesSchema=tl;exports.IdentityCapabilitiesSchema=Zi;exports.ImagePartSchema=Us;exports.InterruptSchema=Si;exports.JsonPatchOperationSchema=ei;exports.JsonPatchSchema=ca;exports.JsonPointerSchema=St;exports.LicenseContextKey=va;exports.MARKDOWN_RENDERER_KEY=ga;exports.MCPAppsActivityRenderer=Po;exports.MessageSchema=ua;exports.MessagesSnapshotEventSchema=di;exports.MetadataSchema=se;exports.MoveOperationSchema=Ys;exports.MultiAgentCapabilitiesSchema=qi;exports.MultimodalCapabilitiesSchema=Qi;exports.MultimodalInputCapabilitiesSchema=Yi;exports.MultimodalOutputCapabilitiesSchema=Xi;exports.OpenGenerativeUIActivityRenderer=gl;exports.OpenGenerativeUIActivityType=pl;exports.OpenGenerativeUIContentSchema=fl;exports.OpenGenerativeUIRenderer=hl;exports.OpenGenerativeUIToolRenderer=vl;exports.OptionalMetadataSchema=hh;exports.OutputCapabilitiesSchema=Ki;exports.PartSourceSchema=yn;exports.RawEventSchema=mi;exports.ReasoningCapabilitiesSchema=Ji;exports.ReasoningEncryptedValueEventSchema=Di;exports.ReasoningEncryptedValueSubtypeSchema=Bi;exports.ReasoningEndEventSchema=Mi;exports.ReasoningMessageChunkEventSchema=Ni;exports.ReasoningMessageContentEventSchema=xi;exports.ReasoningMessageEndEventSchema=Oi;exports.ReasoningMessageSchema=ui;exports.ReasoningMessageStartEventSchema=Ri;exports.ReasoningStartEventSchema=$i;exports.RemoveOperationSchema=qs;exports.ReplaceOperationSchema=Js;exports.ResumeEntrySchema=vi;exports.RoleSchema=uh;exports.RunAgentInputSchema=bi;exports.RunErrorEventSchema=Ii;exports.RunFinishedCancelledOutcomeSchema=Ci;exports.RunFinishedEventSchema=Ei;exports.RunFinishedInterruptOutcomeSchema=wi;exports.RunFinishedOutcomeSchema=Ti;exports.RunFinishedSuccessOutcomeSchema=ki;exports.RunStartedEventSchema=yi;exports.StateCapabilitiesSchema=Gi;exports.StateDeltaEventSchema=ti;exports.StateSchema=la;exports.StateSnapshotEventSchema=Ks;exports.StepFinishedEventSchema=Ai;exports.StepStartedEventSchema=_i;exports.SubagentErrorEventSchema=Ui;exports.SubagentFinishedEventSchema=zi;exports.SubagentFinishedOutcomeSchema=Vi;exports.SubagentFinishedSuccessOutcomeSchema=Pi;exports.SubagentFinishedSuspendedOutcomeSchema=Li;exports.SubagentInfoSchema=ji;exports.SubagentRunIdSchema=me;exports.SubagentStartedEventSchema=Fi;exports.SystemMessageSchema=oi;exports.TestOperationSchema=Qs;exports.TextMessageChunkEventSchema=Ns;exports.TextMessageContentEventSchema=xs;exports.TextMessageEndEventSchema=Os;exports.TextMessageRoleSchema=ia;exports.TextMessageStartEventSchema=Rs;exports.TextPartSchema=Ps;exports.TokenUsageSchema=pa;exports.ToolCallArgsEventSchema=Bs;exports.ToolCallChunkEventSchema=Fs;exports.ToolCallEndEventSchema=Ds;exports.ToolCallResultEventSchema=Hs;exports.ToolCallSchema=ri;exports.ToolCallStartEventSchema=Ms;exports.ToolMessageSchema=li;exports.ToolSchema=da;exports.ToolsCapabilitiesSchema=Hi;exports.TransportCapabilitiesSchema=Wi;exports.UrlSourceSchema=Vs;exports.UseAgentUpdate=Xl;exports.UserMessageSchema=ii;exports.VideoPartSchema=Zs;exports._sfc_main=Tl;exports._sfc_main$1=Jl;exports._sfc_main$10=vn;exports._sfc_main$11=Vl;exports._sfc_main$12=zl;exports._sfc_main$13=sc;exports._sfc_main$14=Cn;exports._sfc_main$15=ic;exports._sfc_main$16=nl;exports._sfc_main$17=ig;exports._sfc_main$18=cw;exports._sfc_main$19=uw;exports._sfc_main$2=Ko;exports._sfc_main$20=NS;exports._sfc_main$21=ka;exports._sfc_main$3=rc;exports._sfc_main$4=Yl;exports._sfc_main$5=ro;exports._sfc_main$6=gn;exports._sfc_main$7=lc;exports._sfc_main$8=ac;exports._sfc_main$9=cc;exports.createA2UIMessageRenderer=cl;exports.createDefaultLicenseRef=kl;exports.defineToolCallRenderer=Kn;exports.getOperationSurfaceId=Lo;exports.isVueComponentRenderer=yl;exports.useAgent=io;exports.useAgentContext=gw;exports.useAttachments=ec;exports.useCapabilities=Rw;exports.useComponent=bw;exports.useConfigureSuggestions=Iw;exports.useCopilotChatConfiguration=Re;exports.useCopilotKit=Ve;exports.useDefaultRenderTool=ww;exports.useFrontendTool=Na;exports.useHumanInTheLoop=Cw;exports.useInterrupt=$w;exports.useKeyboardHeight=tc;exports.useLicenseContext=Sn;exports.useMarkdownRenderer=bl;exports.useRenderActivityMessage=Ow;exports.useRenderCustomMessages=xw;exports.useRenderTool=bc;exports.useSandboxFunctions=dl;exports.useSuggestions=Ql;exports.useThreads=dc;exports.vueBasicCatalog=ao;
|
|
92
|
+
//# sourceMappingURL=use-render-activity-message-ChWFrgM2.cjs.map
|