@telepath-computer/television 1.4.12 → 1.4.14
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/dist/cli.cjs
CHANGED
|
@@ -53345,7 +53345,7 @@ function disabledTelemetryRuntime() {
|
|
|
53345
53345
|
|
|
53346
53346
|
// ../server/src/updates/version.ts
|
|
53347
53347
|
function readVersionStamp() {
|
|
53348
|
-
if ("1.4.
|
|
53348
|
+
if ("1.4.14".length > 0) return "1.4.14";
|
|
53349
53349
|
return void 0;
|
|
53350
53350
|
}
|
|
53351
53351
|
function resolveUpdateReleaseVersion(env = process.env, stamp = readVersionStamp()) {
|
|
@@ -53887,8 +53887,8 @@ var Server = class {
|
|
|
53887
53887
|
};
|
|
53888
53888
|
};
|
|
53889
53889
|
function readServerPackageVersion() {
|
|
53890
|
-
if ("1.4.
|
|
53891
|
-
return telemetryVersion("1.4.
|
|
53890
|
+
if ("1.4.14".length > 0) {
|
|
53891
|
+
return telemetryVersion("1.4.14");
|
|
53892
53892
|
}
|
|
53893
53893
|
const packageJsonPath = import_node_path13.default.resolve(import_node_path13.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)), "..", "package.json");
|
|
53894
53894
|
if (!(0, import_node_fs11.existsSync)(packageJsonPath)) return telemetryVersion("0.0.0");
|
|
@@ -56119,8 +56119,8 @@ function resolveVercelSkillsInstallerBin() {
|
|
|
56119
56119
|
return localRequire.resolve("skills/bin/cli.mjs");
|
|
56120
56120
|
}
|
|
56121
56121
|
function readCLIVersion() {
|
|
56122
|
-
if ("1.4.
|
|
56123
|
-
return "1.4.
|
|
56122
|
+
if ("1.4.14".length > 0) {
|
|
56123
|
+
return "1.4.14";
|
|
56124
56124
|
}
|
|
56125
56125
|
const devPackageJsonPath = import_node_path20.default.join(getDevPackageDir(), "package.json");
|
|
56126
56126
|
if (!(0, import_node_fs18.existsSync)(devPackageJsonPath)) {
|
|
@@ -40,7 +40,7 @@ var Q4=Object.defineProperty;var Iv=n=>{throw TypeError(n)};var eA=(n,t,e)=>t in
|
|
|
40
40
|
`)}v.write("payload.value = newResult;"),v.write("return payload;");const L=v.compile();return(P,B)=>L(y,P,B)};let o;const a=Bc,l=!x8.jitless,u=l&&Uk.value,p=t.catchall;let f;n._zod.parse=(y,v)=>{f??(f=r.value);const S=y.value;return a(S)?l&&u&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(o||(o=i(t.shape)),y=o(y,v),p?G8([],S,y,v,f,n):y):e(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:S,inst:n}),y)}});function u2(n,t,e,r){for(const o of n)if(o.issues.length===0)return t.value=o.value,t;const i=n.filter(o=>!$a(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:e,errors:n.map(o=>o.issues.map(a=>Ts(a,r,ks())))}),t)}const Y8=R("$ZodUnion",(n,t)=>{Ue.init(n,t),Ae(n._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Ae(n._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ae(n._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),Ae(n._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>q1(o.source)).join("|")})$`)}});const e=t.options.length===1,r=t.options[0]._zod.run;n._zod.parse=(i,o)=>{if(e)return r(i,o);let a=!1;const l=[];for(const c of t.options){const u=c._zod.run({value:i.value,issues:[]},o);if(u instanceof Promise)l.push(u),a=!0;else{if(u.issues.length===0)return u;l.push(u)}}return a?Promise.all(l).then(c=>u2(c,i,n,o)):u2(l,i,n,o)}}),CC=R("$ZodDiscriminatedUnion",(n,t)=>{t.inclusive=!1,Y8.init(n,t);const e=n._zod.parse;Ae(n._zod,"propValues",()=>{const i={};for(const o of t.options){const a=o._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[l,c]of Object.entries(a)){i[l]||(i[l]=new Set);for(const u of c)i[l].add(u)}}return i});const r=Mp(()=>{var a;const i=t.options,o=new Map;for(const l of i){const c=(a=l._zod.propValues)==null?void 0:a[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(l)}"`);for(const u of c){if(o.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);o.set(u,l)}}return o});n._zod.parse=(i,o)=>{const a=i.value;if(!Bc(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:n}),i;const l=r.value.get(a==null?void 0:a[t.discriminator]);return l?l._zod.run(i,o):t.unionFallback?e(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:n}),i)}}),RC=R("$ZodIntersection",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>{const i=e.value,o=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,u])=>h2(e,c,u)):h2(e,o,a)}});function Wm(n,t){if(n===t)return{valid:!0,data:n};if(n instanceof Date&&t instanceof Date&&+n==+t)return{valid:!0,data:n};if(Ml(n)&&Ml(t)){const e=Object.keys(t),r=Object.keys(n).filter(o=>e.indexOf(o)!==-1),i={...n,...t};for(const o of r){const a=Wm(n[o],t[o]);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};i[o]=a.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return{valid:!1,mergeErrorPath:[]};const e=[];for(let r=0;r<n.length;r++){const i=n[r],o=t[r],a=Wm(i,o);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};e.push(a.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function h2(n,t,e){const r=new Map;let i;for(const l of t.issues)if(l.code==="unrecognized_keys"){i??(i=l);for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else n.issues.push(l);for(const l of e.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(l);const o=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(o.length&&i&&n.issues.push({...i,keys:o}),$a(n))return n;const a=Wm(t.value,e.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return n.value=a.data,n}const IC=R("$ZodRecord",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!Ml(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),e;const o=[],a=t.keyType._zod.values;if(a){e.value={};const l=new Set;for(const u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){l.add(typeof u=="number"?u.toString():u);const p=t.valueType._zod.run({value:i[u],issues:[]},r);p instanceof Promise?o.push(p.then(f=>{f.issues.length&&e.issues.push(...xa(u,f.issues)),e.value[u]=f.value})):(p.issues.length&&e.issues.push(...xa(u,p.issues)),e.value[u]=p.value)}let c;for(const u in i)l.has(u)||(c=c??[],c.push(u));c&&c.length>0&&e.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{e.value={};for(const l of Reflect.ownKeys(i)){if(l==="__proto__")continue;let c=t.keyType._zod.run({value:l,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&U8.test(l)&&c.issues.length){const f=t.keyType._zod.run({value:Number(l),issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");f.issues.length===0&&(c=f)}if(c.issues.length){t.mode==="loose"?e.value[l]=i[l]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(f=>Ts(f,r,ks())),input:l,path:[l],inst:n});continue}const p=t.valueType._zod.run({value:i[l],issues:[]},r);p instanceof Promise?o.push(p.then(f=>{f.issues.length&&e.issues.push(...xa(l,f.issues)),e.value[c.value]=f.value})):(p.issues.length&&e.issues.push(...xa(l,p.issues)),e.value[c.value]=p.value)}}return o.length?Promise.all(o).then(()=>e):e}}),$C=R("$ZodEnum",(n,t)=>{Ue.init(n,t);const e=P8(t.entries),r=new Set(e);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.filter(i=>Fk.has(typeof i)).map(i=>typeof i=="string"?Nl(i):i.toString()).join("|")})$`),n._zod.parse=(i,o)=>{const a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:e,input:a,inst:n}),i}}),xC=R("$ZodLiteral",(n,t)=>{if(Ue.init(n,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const e=new Set(t.values);n._zod.values=e,n._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Nl(r):r?Nl(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const o=r.value;return e.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:n}),r}}),PC=R("$ZodTransform",(n,t)=>{Ue.init(n,t),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new $8(n.constructor.name);const i=t.transform(e.value,e);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(e.value=a,e));if(i instanceof Promise)throw new La;return e.value=i,e}});function d2(n,t){return n.issues.length&&t===void 0?{issues:[],value:void 0}:n}const K8=R("$ZodOptional",(n,t)=>{Ue.init(n,t),n._zod.optin="optional",n._zod.optout="optional",Ae(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ae(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${q1(e.source)})?$`):void 0}),n._zod.parse=(e,r)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(o=>d2(o,e.value)):d2(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,r)}}),DC=R("$ZodExactOptional",(n,t)=>{K8.init(n,t),Ae(n._zod,"values",()=>t.innerType._zod.values),Ae(n._zod,"pattern",()=>t.innerType._zod.pattern),n._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),LC=R("$ZodNullable",(n,t)=>{Ue.init(n,t),Ae(n._zod,"optin",()=>t.innerType._zod.optin),Ae(n._zod,"optout",()=>t.innerType._zod.optout),Ae(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${q1(e.source)}|null)$`):void 0}),Ae(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),n._zod.parse=(e,r)=>e.value===null?e:t.innerType._zod.run(e,r)}),OC=R("$ZodDefault",(n,t)=>{Ue.init(n,t),n._zod.optin="optional",Ae(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);if(e.value===void 0)return e.value=t.defaultValue,e;const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(o=>p2(o,t)):p2(i,t)}});function p2(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}const MC=R("$ZodPrefault",(n,t)=>{Ue.init(n,t),n._zod.optin="optional",Ae(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>(r.direction==="backward"||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),NC=R("$ZodNonOptional",(n,t)=>{Ue.init(n,t),Ae(n._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(r=>r!==void 0)):void 0}),n._zod.parse=(e,r)=>{const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(o=>f2(o,n)):f2(i,n)}});function f2(n,t){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:t}),n}const zC=R("$ZodCatch",(n,t)=>{Ue.init(n,t),Ae(n._zod,"optin",()=>t.innerType._zod.optin),Ae(n._zod,"optout",()=>t.innerType._zod.optout),Ae(n._zod,"values",()=>t.innerType._zod.values),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(o=>(e.value=o.value,o.issues.length&&(e.value=t.catchValue({...e,error:{issues:o.issues.map(a=>Ts(a,r,ks()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(o=>Ts(o,r,ks()))},input:e.value}),e.issues=[]),e)}}),HC=R("$ZodPipe",(n,t)=>{Ue.init(n,t),Ae(n._zod,"values",()=>t.in._zod.values),Ae(n._zod,"optin",()=>t.in._zod.optin),Ae(n._zod,"optout",()=>t.out._zod.optout),Ae(n._zod,"propValues",()=>t.in._zod.propValues),n._zod.parse=(e,r)=>{if(r.direction==="backward"){const o=t.out._zod.run(e,r);return o instanceof Promise?o.then(a=>$h(a,t.in,r)):$h(o,t.in,r)}const i=t.in._zod.run(e,r);return i instanceof Promise?i.then(o=>$h(o,t.out,r)):$h(i,t.out,r)}});function $h(n,t,e){return n.issues.length?(n.aborted=!0,n):t._zod.run({value:n.value,issues:n.issues},e)}const ZC=R("$ZodReadonly",(n,t)=>{Ue.init(n,t),Ae(n._zod,"propValues",()=>t.innerType._zod.propValues),Ae(n._zod,"values",()=>t.innerType._zod.values),Ae(n._zod,"optin",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optin}),Ae(n._zod,"optout",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optout}),n._zod.parse=(e,r)=>{if(r.direction==="backward")return t.innerType._zod.run(e,r);const i=t.innerType._zod.run(e,r);return i instanceof Promise?i.then(m2):m2(i)}});function m2(n){return n.value=Object.freeze(n.value),n}const UC=R("$ZodCustom",(n,t)=>{Wt.init(n,t),Ue.init(n,t),n._zod.parse=(e,r)=>e,n._zod.check=e=>{const r=e.value,i=t.fn(r);if(i instanceof Promise)return i.then(o=>g2(o,e,r,n));g2(i,e,r,n)}});function g2(n,t,e,r){if(!n){const i={code:"custom",input:e,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(Wc(i))}}var v2;class FC{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...e){const r=e[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const e=this._map.get(t);return e&&typeof e=="object"&&"id"in e&&this._idmap.delete(e.id),this._map.delete(t),this}get(t){const e=t._zod.parent;if(e){const r={...this.get(e)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function qC(){return new FC}(v2=globalThis).__zod_globalRegistry??(v2.__zod_globalRegistry=qC());const _c=globalThis.__zod_globalRegistry;function VC(n,t){return new n({type:"string",...K(t)})}function BC(n,t){return new n({type:"string",format:"email",check:"string_format",abort:!1,...K(t)})}function y2(n,t){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...K(t)})}function WC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...K(t)})}function jC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...K(t)})}function GC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...K(t)})}function YC(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...K(t)})}function KC(n,t){return new n({type:"string",format:"url",check:"string_format",abort:!1,...K(t)})}function JC(n,t){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...K(t)})}function XC(n,t){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...K(t)})}function QC(n,t){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...K(t)})}function eR(n,t){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...K(t)})}function tR(n,t){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...K(t)})}function nR(n,t){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...K(t)})}function rR(n,t){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...K(t)})}function iR(n,t){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...K(t)})}function sR(n,t){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...K(t)})}function oR(n,t){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...K(t)})}function aR(n,t){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...K(t)})}function lR(n,t){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...K(t)})}function cR(n,t){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...K(t)})}function uR(n,t){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...K(t)})}function hR(n,t){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...K(t)})}function dR(n,t){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...K(t)})}function pR(n,t){return new n({type:"string",format:"date",check:"string_format",...K(t)})}function fR(n,t){return new n({type:"string",format:"time",check:"string_format",precision:null,...K(t)})}function mR(n,t){return new n({type:"string",format:"duration",check:"string_format",...K(t)})}function gR(n,t){return new n({type:"number",checks:[],...K(t)})}function vR(n,t){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...K(t)})}function yR(n,t){return new n({type:"boolean",...K(t)})}function wR(n){return new n({type:"unknown"})}function bR(n,t){return new n({type:"never",...K(t)})}function w2(n,t){return new q8({check:"less_than",...K(t),value:n,inclusive:!1})}function Sm(n,t){return new q8({check:"less_than",...K(t),value:n,inclusive:!0})}function b2(n,t){return new V8({check:"greater_than",...K(t),value:n,inclusive:!1})}function _m(n,t){return new V8({check:"greater_than",...K(t),value:n,inclusive:!0})}function S2(n,t){return new OT({check:"multiple_of",...K(t),value:n})}function J8(n,t){return new NT({check:"max_length",...K(t),maximum:n})}function Ed(n,t){return new zT({check:"min_length",...K(t),minimum:n})}function X8(n,t){return new HT({check:"length_equals",...K(t),length:n})}function SR(n,t){return new ZT({check:"string_format",format:"regex",...K(t),pattern:n})}function _R(n){return new UT({check:"string_format",format:"lowercase",...K(n)})}function AR(n){return new FT({check:"string_format",format:"uppercase",...K(n)})}function ER(n,t){return new qT({check:"string_format",format:"includes",...K(t),includes:n})}function kR(n,t){return new VT({check:"string_format",format:"starts_with",...K(t),prefix:n})}function TR(n,t){return new BT({check:"string_format",format:"ends_with",...K(t),suffix:n})}function Gl(n){return new WT({check:"overwrite",tx:n})}function CR(n){return Gl(t=>t.normalize(n))}function RR(){return Gl(n=>n.trim())}function IR(){return Gl(n=>n.toLowerCase())}function $R(){return Gl(n=>n.toUpperCase())}function xR(){return Gl(n=>Zk(n))}function PR(n,t,e){return new n({type:"array",element:t,...K(e)})}function DR(n,t,e){return new n({type:"custom",check:"custom",fn:t,...K(e)})}function LR(n){const t=OR(e=>(e.addIssue=r=>{if(typeof r=="string")e.issues.push(Wc(r,e.value,t._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=e.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),e.issues.push(Wc(i))}},n(e.value,e)));return t}function OR(n,t){const e=new Wt({check:"custom",...K(t)});return e._zod.check=n,e}function Q8(n){let t=(n==null?void 0:n.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??_c,target:t,unrepresentable:(n==null?void 0:n.unrepresentable)??"throw",override:(n==null?void 0:n.override)??(()=>{}),io:(n==null?void 0:n.io)??"output",counter:0,seen:new Map,cycles:(n==null?void 0:n.cycles)??"ref",reused:(n==null?void 0:n.reused)??"inline",external:(n==null?void 0:n.external)??void 0}}function Qe(n,t,e={path:[],schemaPath:[]}){var p,f;var r;const i=n._zod.def,o=t.seen.get(n);if(o)return o.count++,e.schemaPath.includes(n)&&(o.cycle=e.path),o.schema;const a={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(n,a);const l=(f=(p=n._zod).toJSONSchema)==null?void 0:f.call(p);if(l)a.schema=l;else{const y={...e,schemaPath:[...e.schemaPath,n],path:e.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(t,a.schema,y);else{const S=a.schema,_=t.processors[i.type];if(!_)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);_(n,t,S,y)}const v=n._zod.parent;v&&(a.ref||(a.ref=v),Qe(v,t,y),t.seen.get(v).isParent=!0)}const c=t.metadataRegistry.get(n);return c&&Object.assign(a.schema,c),t.io==="input"&&At(n)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(n).schema}function e6(n,t){var a,l,c,u;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const p of n.seen.entries()){const f=(a=n.metadataRegistry.get(p[0]))==null?void 0:a.id;if(f){const y=r.get(f);if(y&&y!==p[0])throw new Error(`Duplicate schema id "${f}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(f,p[0])}}const i=p=>{var _;const f=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const x=(_=n.external.registry.get(p[0]))==null?void 0:_.id,Z=n.external.uri??(z=>z);if(x)return{ref:Z(x)};const L=p[1].defId??p[1].schema.id??`schema${n.counter++}`;return p[1].defId=L,{defId:L,ref:`${Z("__shared")}#/${f}/${L}`}}if(p[1]===e)return{ref:"#"};const v=`#/${f}/`,S=p[1].schema.id??`__schema${n.counter++}`;return{defId:S,ref:v+S}},o=p=>{if(p[1].schema.$ref)return;const f=p[1],{ref:y,defId:v}=i(p);f.def={...f.schema},v&&(f.defId=v);const S=f.schema;for(const _ in S)delete S[_];S.$ref=y};if(n.cycles==="throw")for(const p of n.seen.entries()){const f=p[1];if(f.cycle)throw new Error(`Cycle detected: #/${(l=f.cycle)==null?void 0:l.join("/")}/<root>
|
|
41
41
|
|
|
42
42
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const p of n.seen.entries()){const f=p[1];if(t===p[0]){o(p);continue}if(n.external){const v=(c=n.external.registry.get(p[0]))==null?void 0:c.id;if(t!==p[0]&&v){o(p);continue}}if((u=n.metadataRegistry.get(p[0]))==null?void 0:u.id){o(p);continue}if(f.cycle){o(p);continue}if(f.count>1&&n.reused==="ref"){o(p);continue}}}function t6(n,t){var a,l,c;const e=n.seen.get(t);if(!e)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=u=>{const p=n.seen.get(u);if(p.ref===null)return;const f=p.def??p.schema,y={...f},v=p.ref;if(p.ref=null,v){r(v);const _=n.seen.get(v),x=_.schema;if(x.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(f.allOf=f.allOf??[],f.allOf.push(x)):Object.assign(f,x),Object.assign(f,y),u._zod.parent===v)for(const L in f)L==="$ref"||L==="allOf"||L in y||delete f[L];if(x.$ref&&_.def)for(const L in f)L==="$ref"||L==="allOf"||L in _.def&&JSON.stringify(f[L])===JSON.stringify(_.def[L])&&delete f[L]}const S=u._zod.parent;if(S&&S!==v){r(S);const _=n.seen.get(S);if(_!=null&&_.schema.$ref&&(f.$ref=_.schema.$ref,_.def))for(const x in f)x==="$ref"||x==="allOf"||x in _.def&&JSON.stringify(f[x])===JSON.stringify(_.def[x])&&delete f[x]}n.override({zodSchema:u,jsonSchema:f,path:p.path??[]})};for(const u of[...n.seen.entries()].reverse())r(u[0]);const i={};if(n.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":n.target,(a=n.external)!=null&&a.uri){const u=(l=n.external.registry.get(t))==null?void 0:l.id;if(!u)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(u)}Object.assign(i,e.def??e.schema);const o=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const p=u[1];p.def&&p.defId&&(o[p.defId]=p.def)}n.external||Object.keys(o).length>0&&(n.target==="draft-2020-12"?i.$defs=o:i.definitions=o);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:kd(t,"input",n.processors),output:kd(t,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function At(n,t){const e=t??{seen:new Set};if(e.seen.has(n))return!1;e.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return At(r.element,e);if(r.type==="set")return At(r.valueType,e);if(r.type==="lazy")return At(r.getter(),e);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return At(r.innerType,e);if(r.type==="intersection")return At(r.left,e)||At(r.right,e);if(r.type==="record"||r.type==="map")return At(r.keyType,e)||At(r.valueType,e);if(r.type==="pipe")return At(r.in,e)||At(r.out,e);if(r.type==="object"){for(const i in r.shape)if(At(r.shape[i],e))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(At(i,e))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(At(i,e))return!0;return!!(r.rest&&At(r.rest,e))}return!1}const MR=(n,t={})=>e=>{const r=Q8({...e,processors:t});return Qe(n,r),e6(r,n),t6(r,n)},kd=(n,t,e={})=>r=>{const{libraryOptions:i,target:o}=r??{},a=Q8({...i??{},target:o,io:t,processors:e});return Qe(n,a),e6(a,n),t6(a,n)},NR={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},zR=(n,t,e,r)=>{const i=e;i.type="string";const{minimum:o,maximum:a,format:l,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof a=="number"&&(i.maxLength=a),l&&(i.format=NR[l]??l,i.format===""&&delete i.format,l==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const p=[...c];p.length===1?i.pattern=p[0].source:p.length>1&&(i.allOf=[...p.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},HR=(n,t,e,r)=>{const i=e,{minimum:o,maximum:a,format:l,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:p}=n._zod.bag;typeof l=="string"&&l.includes("int")?i.type="integer":i.type="number",typeof p=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=p,i.exclusiveMinimum=!0):i.exclusiveMinimum=p),typeof o=="number"&&(i.minimum=o,typeof p=="number"&&t.target!=="draft-04"&&(p>=o?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof a=="number"&&(i.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},ZR=(n,t,e,r)=>{e.type="boolean"},UR=(n,t,e,r)=>{e.not={}},FR=(n,t,e,r)=>{},qR=(n,t,e,r)=>{const i=n._zod.def,o=P8(i.entries);o.every(a=>typeof a=="number")&&(e.type="number"),o.every(a=>typeof a=="string")&&(e.type="string"),e.enum=o},VR=(n,t,e,r)=>{const i=n._zod.def,o=[];for(const a of i.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){const a=o[0];e.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?e.enum=[a]:e.const=a}else o.every(a=>typeof a=="number")&&(e.type="number"),o.every(a=>typeof a=="string")&&(e.type="string"),o.every(a=>typeof a=="boolean")&&(e.type="boolean"),o.every(a=>a===null)&&(e.type="null"),e.enum=o},BR=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},WR=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},jR=(n,t,e,r)=>{const i=e,o=n._zod.def,{minimum:a,maximum:l}=n._zod.bag;typeof a=="number"&&(i.minItems=a),typeof l=="number"&&(i.maxItems=l),i.type="array",i.items=Qe(o.element,t,{...r,path:[...r.path,"items"]})},GR=(n,t,e,r)=>{var u;const i=e,o=n._zod.def;i.type="object",i.properties={};const a=o.shape;for(const p in a)i.properties[p]=Qe(a[p],t,{...r,path:[...r.path,"properties",p]});const l=new Set(Object.keys(a)),c=new Set([...l].filter(p=>{const f=o.shape[p]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=o.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=Qe(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},YR=(n,t,e,r)=>{const i=n._zod.def,o=i.inclusive===!1,a=i.options.map((l,c)=>Qe(l,t,{...r,path:[...r.path,o?"oneOf":"anyOf",c]}));o?e.oneOf=a:e.anyOf=a},KR=(n,t,e,r)=>{const i=n._zod.def,o=Qe(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Qe(i.right,t,{...r,path:[...r.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(o)?o.allOf:[o],...l(a)?a.allOf:[a]];e.allOf=c},JR=(n,t,e,r)=>{const i=e,o=n._zod.def;i.type="object";const a=o.keyType,l=a._zod.bag,c=l==null?void 0:l.patterns;if(o.mode==="loose"&&c&&c.size>0){const p=Qe(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const f of c)i.patternProperties[f.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Qe(o.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Qe(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=a._zod.values;if(u){const p=[...u].filter(f=>typeof f=="string"||typeof f=="number");p.length>0&&(i.required=p)}},XR=(n,t,e,r)=>{const i=n._zod.def,o=Qe(i.innerType,t,r),a=t.seen.get(n);t.target==="openapi-3.0"?(a.ref=i.innerType,e.nullable=!0):e.anyOf=[o,{type:"null"}]},QR=(n,t,e,r)=>{const i=n._zod.def;Qe(i.innerType,t,r);const o=t.seen.get(n);o.ref=i.innerType},e3=(n,t,e,r)=>{const i=n._zod.def;Qe(i.innerType,t,r);const o=t.seen.get(n);o.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},t3=(n,t,e,r)=>{const i=n._zod.def;Qe(i.innerType,t,r);const o=t.seen.get(n);o.ref=i.innerType,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},n3=(n,t,e,r)=>{const i=n._zod.def;Qe(i.innerType,t,r);const o=t.seen.get(n);o.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}e.default=a},r3=(n,t,e,r)=>{const i=n._zod.def,o=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Qe(o,t,r);const a=t.seen.get(n);a.ref=o},i3=(n,t,e,r)=>{const i=n._zod.def;Qe(i.innerType,t,r);const o=t.seen.get(n);o.ref=i.innerType,e.readOnly=!0},n6=(n,t,e,r)=>{const i=n._zod.def;Qe(i.innerType,t,r);const o=t.seen.get(n);o.ref=i.innerType},s3=R("ZodISODateTime",(n,t)=>{oC.init(n,t),qe.init(n,t)});function o3(n){return dR(s3,n)}const a3=R("ZodISODate",(n,t)=>{aC.init(n,t),qe.init(n,t)});function l3(n){return pR(a3,n)}const c3=R("ZodISOTime",(n,t)=>{lC.init(n,t),qe.init(n,t)});function u3(n){return fR(c3,n)}const h3=R("ZodISODuration",(n,t)=>{cC.init(n,t),qe.init(n,t)});function d3(n){return mR(h3,n)}const r6=(n,t)=>{M8.init(n,t),n.name="ZodError",Object.defineProperties(n,{format:{value:e=>Qk(n,e)},flatten:{value:e=>Xk(n,e)},addIssue:{value:e=>{n.issues.push(e),n.message=JSON.stringify(n.issues,Bm,2)}},addIssues:{value:e=>{n.issues.push(...e),n.message=JSON.stringify(n.issues,Bm,2)}},isEmpty:{get(){return n.issues.length===0}}})},_2=R("ZodError",r6),In=R("ZodError",r6,{Parent:Error}),p3=B1(In),f3=W1(In),m3=Np(In),g3=zp(In),v3=nT(In),y3=rT(In),w3=iT(In),b3=sT(In),S3=oT(In),_3=aT(In),A3=lT(In),E3=cT(In),Fe=R("ZodType",(n,t)=>(Ue.init(n,t),Object.assign(n["~standard"],{jsonSchema:{input:kd(n,"input"),output:kd(n,"output")}}),n.toJSONSchema=MR(n,{}),n.def=t,n.type=t.type,Object.defineProperty(n,"_def",{value:t}),n.check=(...e)=>n.clone($s(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(e,r)=>xs(n,e,r),n.brand=()=>n,n.register=((e,r)=>(e.add(n,r),n)),n.parse=(e,r)=>p3(n,e,r,{callee:n.parse}),n.safeParse=(e,r)=>m3(n,e,r),n.parseAsync=async(e,r)=>f3(n,e,r,{callee:n.parseAsync}),n.safeParseAsync=async(e,r)=>g3(n,e,r),n.spa=n.safeParseAsync,n.encode=(e,r)=>v3(n,e,r),n.decode=(e,r)=>y3(n,e,r),n.encodeAsync=async(e,r)=>w3(n,e,r),n.decodeAsync=async(e,r)=>b3(n,e,r),n.safeEncode=(e,r)=>S3(n,e,r),n.safeDecode=(e,r)=>_3(n,e,r),n.safeEncodeAsync=async(e,r)=>A3(n,e,r),n.safeDecodeAsync=async(e,r)=>E3(n,e,r),n.refine=(e,r)=>n.check(gI(e,r)),n.superRefine=e=>n.check(vI(e)),n.overwrite=e=>n.check(Gl(e)),n.optional=()=>k2(n),n.exactOptional=()=>rI(n),n.nullable=()=>T2(n),n.nullish=()=>k2(T2(n)),n.nonoptional=e=>cI(n,e),n.array=()=>G(n),n.or=e=>ae([n,e]),n.and=e=>Zp(n,e),n.transform=e=>C2(n,tI(e)),n.default=e=>oI(n,e),n.prefault=e=>lI(n,e),n.catch=e=>hI(n,e),n.pipe=e=>C2(n,e),n.readonly=()=>fI(n),n.describe=e=>{const r=n.clone();return _c.add(r,{description:e}),r},Object.defineProperty(n,"description",{get(){var e;return(e=_c.get(n))==null?void 0:e.description},configurable:!0}),n.meta=(...e)=>{if(e.length===0)return _c.get(n);const r=n.clone();return _c.add(r,e[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=e=>e(n),n)),i6=R("_ZodString",(n,t)=>{j1.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(r,i,o)=>zR(n,r,i);const e=n._zod.bag;n.format=e.format??null,n.minLength=e.minimum??null,n.maxLength=e.maximum??null,n.regex=(...r)=>n.check(SR(...r)),n.includes=(...r)=>n.check(ER(...r)),n.startsWith=(...r)=>n.check(kR(...r)),n.endsWith=(...r)=>n.check(TR(...r)),n.min=(...r)=>n.check(Ed(...r)),n.max=(...r)=>n.check(J8(...r)),n.length=(...r)=>n.check(X8(...r)),n.nonempty=(...r)=>n.check(Ed(1,...r)),n.lowercase=r=>n.check(_R(r)),n.uppercase=r=>n.check(AR(r)),n.trim=()=>n.check(RR()),n.normalize=(...r)=>n.check(CR(...r)),n.toLowerCase=()=>n.check(IR()),n.toUpperCase=()=>n.check($R()),n.slugify=()=>n.check(xR())}),k3=R("ZodString",(n,t)=>{j1.init(n,t),i6.init(n,t),n.email=e=>n.check(BC(T3,e)),n.url=e=>n.check(KC(C3,e)),n.jwt=e=>n.check(hR(F3,e)),n.emoji=e=>n.check(JC(R3,e)),n.guid=e=>n.check(y2(A2,e)),n.uuid=e=>n.check(WC(xh,e)),n.uuidv4=e=>n.check(jC(xh,e)),n.uuidv6=e=>n.check(GC(xh,e)),n.uuidv7=e=>n.check(YC(xh,e)),n.nanoid=e=>n.check(XC(I3,e)),n.guid=e=>n.check(y2(A2,e)),n.cuid=e=>n.check(QC($3,e)),n.cuid2=e=>n.check(eR(x3,e)),n.ulid=e=>n.check(tR(P3,e)),n.base64=e=>n.check(lR(H3,e)),n.base64url=e=>n.check(cR(Z3,e)),n.xid=e=>n.check(nR(D3,e)),n.ksuid=e=>n.check(rR(L3,e)),n.ipv4=e=>n.check(iR(O3,e)),n.ipv6=e=>n.check(sR(M3,e)),n.cidrv4=e=>n.check(oR(N3,e)),n.cidrv6=e=>n.check(aR(z3,e)),n.e164=e=>n.check(uR(U3,e)),n.datetime=e=>n.check(o3(e)),n.date=e=>n.check(l3(e)),n.time=e=>n.check(u3(e)),n.duration=e=>n.check(d3(e))});function g(n){return VC(k3,n)}const qe=R("ZodStringFormat",(n,t)=>{Me.init(n,t),i6.init(n,t)}),T3=R("ZodEmail",(n,t)=>{JT.init(n,t),qe.init(n,t)}),A2=R("ZodGUID",(n,t)=>{YT.init(n,t),qe.init(n,t)}),xh=R("ZodUUID",(n,t)=>{KT.init(n,t),qe.init(n,t)}),C3=R("ZodURL",(n,t)=>{XT.init(n,t),qe.init(n,t)}),R3=R("ZodEmoji",(n,t)=>{QT.init(n,t),qe.init(n,t)}),I3=R("ZodNanoID",(n,t)=>{eC.init(n,t),qe.init(n,t)}),$3=R("ZodCUID",(n,t)=>{tC.init(n,t),qe.init(n,t)}),x3=R("ZodCUID2",(n,t)=>{nC.init(n,t),qe.init(n,t)}),P3=R("ZodULID",(n,t)=>{rC.init(n,t),qe.init(n,t)}),D3=R("ZodXID",(n,t)=>{iC.init(n,t),qe.init(n,t)}),L3=R("ZodKSUID",(n,t)=>{sC.init(n,t),qe.init(n,t)}),O3=R("ZodIPv4",(n,t)=>{uC.init(n,t),qe.init(n,t)}),M3=R("ZodIPv6",(n,t)=>{hC.init(n,t),qe.init(n,t)}),N3=R("ZodCIDRv4",(n,t)=>{dC.init(n,t),qe.init(n,t)}),z3=R("ZodCIDRv6",(n,t)=>{pC.init(n,t),qe.init(n,t)}),H3=R("ZodBase64",(n,t)=>{fC.init(n,t),qe.init(n,t)}),Z3=R("ZodBase64URL",(n,t)=>{gC.init(n,t),qe.init(n,t)}),U3=R("ZodE164",(n,t)=>{vC.init(n,t),qe.init(n,t)}),F3=R("ZodJWT",(n,t)=>{wC.init(n,t),qe.init(n,t)}),s6=R("ZodNumber",(n,t)=>{W8.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(r,i,o)=>HR(n,r,i),n.gt=(r,i)=>n.check(b2(r,i)),n.gte=(r,i)=>n.check(_m(r,i)),n.min=(r,i)=>n.check(_m(r,i)),n.lt=(r,i)=>n.check(w2(r,i)),n.lte=(r,i)=>n.check(Sm(r,i)),n.max=(r,i)=>n.check(Sm(r,i)),n.int=r=>n.check(E2(r)),n.safe=r=>n.check(E2(r)),n.positive=r=>n.check(b2(0,r)),n.nonnegative=r=>n.check(_m(0,r)),n.negative=r=>n.check(w2(0,r)),n.nonpositive=r=>n.check(Sm(0,r)),n.multipleOf=(r,i)=>n.check(S2(r,i)),n.step=(r,i)=>n.check(S2(r,i)),n.finite=()=>n;const e=n._zod.bag;n.minValue=Math.max(e.minimum??Number.NEGATIVE_INFINITY,e.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(e.maximum??Number.POSITIVE_INFINITY,e.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(e.format??"").includes("int")||Number.isSafeInteger(e.multipleOf??.5),n.isFinite=!0,n.format=e.format??null});function ie(n){return gR(s6,n)}const q3=R("ZodNumberFormat",(n,t)=>{bC.init(n,t),s6.init(n,t)});function E2(n){return vR(q3,n)}const V3=R("ZodBoolean",(n,t)=>{SC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>ZR(n,e,r)});function lt(n){return yR(V3,n)}const B3=R("ZodUnknown",(n,t)=>{_C.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>FR()});function E(){return wR(B3)}const W3=R("ZodNever",(n,t)=>{AC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>UR(n,e,r)});function j3(n){return bR(W3,n)}const G3=R("ZodArray",(n,t)=>{EC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>jR(n,e,r,i),n.element=t.element,n.min=(e,r)=>n.check(Ed(e,r)),n.nonempty=e=>n.check(Ed(1,e)),n.max=(e,r)=>n.check(J8(e,r)),n.length=(e,r)=>n.check(X8(e,r)),n.unwrap=()=>n.element});function G(n,t){return PR(G3,n,t)}const o6=R("ZodObject",(n,t)=>{TC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>GR(n,e,r,i),Ae(n,"shape",()=>t.shape),n.keyof=()=>c6(Object.keys(n._zod.def.shape)),n.catchall=e=>n.clone({...n._zod.def,catchall:e}),n.passthrough=()=>n.clone({...n._zod.def,catchall:E()}),n.loose=()=>n.clone({...n._zod.def,catchall:E()}),n.strict=()=>n.clone({...n._zod.def,catchall:j3()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=e=>jk(n,e),n.safeExtend=e=>Gk(n,e),n.merge=e=>Yk(n,e),n.pick=e=>Bk(n,e),n.omit=e=>Wk(n,e),n.partial=(...e)=>Kk(u6,n,e[0]),n.required=(...e)=>Jk(h6,n,e[0])});function a6(n,t){const e={type:"object",shape:n??{},...K(t)};return new o6(e)}function b(n,t){return new o6({type:"object",shape:n,catchall:E(),...K(t)})}const l6=R("ZodUnion",(n,t)=>{Y8.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>YR(n,e,r,i),n.options=t.options});function ae(n,t){return new l6({type:"union",options:n,...K(t)})}const Y3=R("ZodDiscriminatedUnion",(n,t)=>{l6.init(n,t),CC.init(n,t)});function K3(n,t,e){return new Y3({type:"union",options:t,discriminator:n,...K(e)})}const J3=R("ZodIntersection",(n,t)=>{RC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>KR(n,e,r,i)});function Zp(n,t){return new J3({type:"intersection",left:n,right:t})}const X3=R("ZodRecord",(n,t)=>{IC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>JR(n,e,r,i),n.keyType=t.keyType,n.valueType=t.valueType});function T(n,t,e){return new X3({type:"record",keyType:n,valueType:t,...K(e)})}const jm=R("ZodEnum",(n,t)=>{$C.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(r,i,o)=>qR(n,r,i),n.enum=t.entries,n.options=Object.values(t.entries);const e=new Set(Object.keys(t.entries));n.extract=(r,i)=>{const o={};for(const a of r)if(e.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new jm({...t,checks:[],...K(i),entries:o})},n.exclude=(r,i)=>{const o={...t.entries};for(const a of r)if(e.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new jm({...t,checks:[],...K(i),entries:o})}});function c6(n,t){const e=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new jm({type:"enum",entries:e,...K(t)})}const Q3=R("ZodLiteral",(n,t)=>{xC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>VR(n,e,r),n.values=new Set(t.values),Object.defineProperty(n,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function D(n,t){return new Q3({type:"literal",values:Array.isArray(n)?n:[n],...K(t)})}const eI=R("ZodTransform",(n,t)=>{PC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>WR(n,e),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new $8(n.constructor.name);e.addIssue=o=>{if(typeof o=="string")e.issues.push(Wc(o,e.value,t));else{const a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=e.value),a.inst??(a.inst=n),e.issues.push(Wc(a))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(o=>(e.value=o,e)):(e.value=i,e)}});function tI(n){return new eI({type:"transform",transform:n})}const u6=R("ZodOptional",(n,t)=>{K8.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>n6(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function k2(n){return new u6({type:"optional",innerType:n})}const nI=R("ZodExactOptional",(n,t)=>{DC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>n6(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function rI(n){return new nI({type:"optional",innerType:n})}const iI=R("ZodNullable",(n,t)=>{LC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>XR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function T2(n){return new iI({type:"nullable",innerType:n})}const sI=R("ZodDefault",(n,t)=>{OC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>e3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function oI(n,t){return new sI({type:"default",innerType:n,get defaultValue(){return typeof t=="function"?t():L8(t)}})}const aI=R("ZodPrefault",(n,t)=>{MC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>t3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function lI(n,t){return new aI({type:"prefault",innerType:n,get defaultValue(){return typeof t=="function"?t():L8(t)}})}const h6=R("ZodNonOptional",(n,t)=>{NC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>QR(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function cI(n,t){return new h6({type:"nonoptional",innerType:n,...K(t)})}const uI=R("ZodCatch",(n,t)=>{zC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>n3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function hI(n,t){return new uI({type:"catch",innerType:n,catchValue:typeof t=="function"?t:()=>t})}const dI=R("ZodPipe",(n,t)=>{HC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>r3(n,e,r,i),n.in=t.in,n.out=t.out});function C2(n,t){return new dI({type:"pipe",in:n,out:t})}const pI=R("ZodReadonly",(n,t)=>{ZC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>i3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function fI(n){return new pI({type:"readonly",innerType:n})}const mI=R("ZodCustom",(n,t)=>{UC.init(n,t),Fe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>BR(n,e)});function gI(n,t={}){return DR(mI,n,t)}function vI(n){return LR(n)}const yI=[".md",".markdown"];function d6(n){if(n.length===0)return!1;const t=n.at(-1);return t==="/"||t==="\\"}function p6(n){const t=n.lastIndexOf("/"),e=n.lastIndexOf("\\");return n.slice(Math.max(t,e)+1)}function wI(n){return p6(n).toLowerCase()}function bI(n,t){const e=wI(n);return t.some(r=>e.endsWith(r))}function Gm(n){return!d6(n)&&bI(n,yI)}function SI(n){let t;try{t=new URL(n)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}function qr(n){try{const{pathname:t}=new URL(n);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(t)}catch{return!1}}const _I=a6({id:g().min(1),kind:D("path"),title:g(),path:g()}).strict(),AI=a6({id:g().min(1),kind:D("url"),title:g(),url:g().refine(SI,{message:"url must be an http(s) URL"})}).strict();K3("kind",[_I,AI]);const EI=new Set(["about:","blob:","chrome-extension:","chrome:","data:","devtools:","file:","filesystem:","javascript:","view-source:"]);function kI(n,t){try{const e=new URL(t),r=new URL(n,e);return r.protocol==="http:"||r.protocol==="https:"?{kind:"web",url:r.href}:EI.has(r.protocol)?{kind:"browser-local",url:r.href}:{kind:"application",url:r.href}}catch{return{kind:"invalid"}}}function R2(n,t){return kI(n,t).kind==="web"}const TI="/views/markdown/",CI="/views/url-unsupported/";function RI(n){try{const{protocol:t}=new URL(n);return t==="http:"||t==="https:"}catch{return!1}}function f6(n){return`/artifact/${encodeURIComponent(n)}`}function II(n,t){return`${f6(n)}/${encodeURIComponent(t)}`}function $I(n){return`/markdown/${encodeURIComponent(n)}`}function Td(n,t={electron:!1}){if(n.kind==="url")return t.electron?{renderer:"url-webview",viewURL:n.url,contentURL:null}:qr(n.url)?{renderer:"proxy-iframe",viewURL:n.url,contentURL:null}:t.browserDemo&&RI(n.url)?{renderer:"url-direct",viewURL:n.url,contentURL:null}:{renderer:"url-unsupported",viewURL:CI,contentURL:null};if(Gm(n.path)){const r={viewURL:TI,contentURL:$I(n.id)};return t.electron?{renderer:"url-webview",...r}:{renderer:"markdown",...r}}const e=d6(n.path)?`${f6(n.id)}/`:II(n.id,p6(n.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const xI="serverURL",PI="token",DI="mode",LI="desktopAppVersion",OI="electron";function MI(n=window.location.search,t=window.location.origin){const r=new URLSearchParams(n).get(xI);return r?new URL(r).origin:new URL(t).origin}function NI(n=window.location.search){return new URLSearchParams(n).get(PI)}function wi(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(DI)===OI}function m6(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(LI)}const I2="tv.telemetry.clientId",zI=5,HI=60,ZI=1e3,UI=zI*HI*ZI,$2=["pointerdown","scroll","keydown"],x2=["focus"],P2=["visibilitychange"],FI="hidden";function qI(n,t=GI){const e=n.getItem(I2);if(e)return e;const r=t();return n.setItem(I2,r),r}function VI(n){return{clientId:qI(n.storage,n.idFactory),userAgent:n.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:n.clientApp,...n.desktopAppVersion?{desktopAppVersion:n.desktopAppVersion}:{}}}function BI(n){const t=new URLSearchParams;return t.set("clientId",n.clientId),t.set("userAgent",n.userAgent),t.set("clientApp",n.clientApp),n.desktopAppVersion&&t.set("desktopAppVersion",n.desktopAppVersion),t}function WI(n){return new jI(n)}var eu,Gr,Vi,tu,nu,fn,co,ru,Hd,g6;class jI{constructor(t){m(this,Hd);m(this,eu);m(this,Gr);m(this,Vi);m(this,tu);m(this,nu);m(this,fn);m(this,co,!1);m(this,ru,Number.NEGATIVE_INFINITY);d(this,eu,t.meta),d(this,Gr,t.documentTarget),d(this,Vi,t.windowTarget),d(this,tu,t.send),d(this,nu,t.nowMs??Date.now),d(this,fn,()=>h(this,Hd,g6).call(this))}start(){if(!s(this,co)){d(this,co,!0);for(const t of $2)s(this,Vi).addEventListener(t,s(this,fn)),s(this,Gr).addEventListener(t,s(this,fn));for(const t of x2)s(this,Vi).addEventListener(t,s(this,fn));for(const t of P2)s(this,Gr).addEventListener(t,s(this,fn))}}stop(){if(s(this,co)){d(this,co,!1);for(const t of $2)s(this,Vi).removeEventListener(t,s(this,fn)),s(this,Gr).removeEventListener(t,s(this,fn));for(const t of x2)s(this,Vi).removeEventListener(t,s(this,fn));for(const t of P2)s(this,Gr).removeEventListener(t,s(this,fn))}}}eu=new WeakMap,Gr=new WeakMap,Vi=new WeakMap,tu=new WeakMap,nu=new WeakMap,fn=new WeakMap,co=new WeakMap,ru=new WeakMap,Hd=new WeakSet,g6=function(){if(s(this,Gr).visibilityState===FI)return;const t=s(this,nu).call(this);t-s(this,ru)<UI||(d(this,ru,t),s(this,tu).call(this,{type:ZE,clientId:s(this,eu).clientId}))};function GI(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():U1().toLowerCase()}const De={authenticate:"authenticate",document_did_change:"document/didChange",document_did_close:"document/didClose",document_did_focus:"document/didFocus",document_did_open:"document/didOpen",document_did_save:"document/didSave",initialize:"initialize",logout:"logout",nes_accept:"nes/accept",nes_close:"nes/close",nes_reject:"nes/reject",nes_start:"nes/start",nes_suggest:"nes/suggest",session_cancel:"session/cancel",session_close:"session/close",session_fork:"session/fork",session_list:"session/list",session_load:"session/load",session_new:"session/new",session_prompt:"session/prompt",session_resume:"session/resume",session_set_config_option:"session/set_config_option",session_set_mode:"session/set_mode",session_set_model:"session/set_model"},Zr={fs_read_text_file:"fs/read_text_file",fs_write_text_file:"fs/write_text_file",session_request_permission:"session/request_permission",session_update:"session/update",terminal_create:"terminal/create",terminal_kill:"terminal/kill",terminal_output:"terminal/output",terminal_release:"terminal/release",terminal_wait_for_exit:"terminal/wait_for_exit"},YI=1,KI=b({_meta:T(g(),E()).nullish(),terminal:lt().optional().default(!1)}),JI=b({_meta:T(g(),E()).nullish(),label:g().nullish(),name:g(),optional:lt().optional().default(!1),secret:lt().optional().default(!0)}),XI=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:g(),name:g()}),QI=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:g(),link:g().nullish(),name:g(),vars:G(JI)}),e$=b({_meta:T(g(),E()).nullish(),args:G(g()).optional(),description:g().nullish(),env:T(g(),g()).optional(),id:g(),name:g()}),t$=ae([QI.and(b({type:D("env_var")})),e$.and(b({type:D("terminal")})),XI]),n$=b({_meta:T(g(),E()).nullish(),methodId:g()}),r$=b({_meta:T(g(),E()).nullish()}),i$=b({_meta:T(g(),E()).nullish(),blob:g(),mimeType:g().nullish(),uri:g()}),s$=b({default:lt().nullish(),description:g().nullish(),title:g().nullish()}),o$=b({_meta:T(g(),E()).nullish()}),a$=b({_meta:T(g(),E()).nullish()}),l$=b({amount:ie(),currency:g()}),c$=b({_meta:T(g(),E()).nullish(),terminalId:g()}),u$=b({_meta:T(g(),E()).nullish(),newText:g(),oldText:g().nullish(),path:g()}),h$=ae([g(),ie(),ie(),lt(),G(g())]),d$=b({content:T(g(),h$).nullish()}),p$=ae([d$.and(b({action:D("accept")})),b({action:D("decline")}),b({action:D("cancel")})]),f$=b({_meta:T(g(),E()).nullish()}),v6=g(),m$=b({_meta:T(g(),E()).nullish(),elicitationId:v6}),g$=b({_meta:T(g(),E()).nullish(),action:p$}),v$=D("object"),y$=D("string"),w$=b({_meta:T(g(),E()).nullish()}),b$=b({_meta:T(g(),E()).nullish(),form:f$.nullish(),url:w$.nullish()}),S$=b({elicitationId:v6,url:g().url()}),y6=b({const:g(),title:g()}),w6=b({_meta:T(g(),E()).nullish(),name:g(),value:g()}),_$=ae([D(-32700),D(-32600),D(-32601),D(-32602),D(-32603),D(-32800),D(-32e3),D(-32002),D(-32042),ie().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),b6=b({code:_$,data:E().optional(),message:g()}),S6=E(),_6=E(),A6=E(),A$=b({_meta:T(g(),E()).nullish(),readTextFile:lt().optional().default(!1),writeTextFile:lt().optional().default(!1)}),E6=b({_meta:T(g(),E()).nullish(),name:g(),value:g()}),k6=b({_meta:T(g(),E()).nullish(),name:g(),title:g().nullish(),version:g()}),E$=b({default:ie().nullish(),description:g().nullish(),maximum:ie().nullish(),minimum:ie().nullish(),title:g().nullish()}),k$=b({_meta:T(g(),E()).nullish()}),T$=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cursor:g().nullish(),cwd:g().nullish()}),C$=b({_meta:T(g(),E()).nullish()}),R$=b({_meta:T(g(),E()).nullish(),logout:C$.nullish()}),I$=b({_meta:T(g(),E()).nullish()}),$$=b({_meta:T(g(),E()).nullish()}),x$=b({_meta:T(g(),E()).nullish(),http:lt().optional().default(!1),sse:lt().optional().default(!1)}),P$=b({_meta:T(g(),E()).nullish(),headers:G(E6),name:g(),url:g()}),D$=b({_meta:T(g(),E()).nullish(),headers:G(E6),name:g(),url:g()}),L$=b({_meta:T(g(),E()).nullish(),args:G(g()),command:g(),env:G(w6),name:g()}),Up=ae([P$.and(b({type:D("http")})),D$.and(b({type:D("sse")})),L$]),G1=g(),O$=b({_meta:T(g(),E()).nullish(),description:g().nullish(),modelId:G1,name:g()}),M$=ae([D("error"),D("warning"),D("information"),D("hint")]),N$=b({_meta:T(g(),E()).nullish()}),z$=b({_meta:T(g(),E()).nullish()}),H$=b({_meta:T(g(),E()).nullish()}),Z$=b({_meta:T(g(),E()).nullish()}),U$=b({_meta:T(g(),E()).nullish()}),F$=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),q$=b({diff:g(),uri:g()}),V$=b({endLine:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:g()}),B$=b({_meta:T(g(),E()).nullish()}),W$=b({_meta:T(g(),E()).nullish()}),j$=b({languageId:g(),text:g(),uri:g()}),G$=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),Y$=ae([D("rejected"),D("ignored"),D("replaced"),D("cancelled")]),K$=b({excerpts:G(V$),uri:g()}),J$=b({_meta:T(g(),E()).nullish()}),X$=b({_meta:T(g(),E()).nullish()}),Q$=b({name:g(),owner:g(),remoteUrl:g()}),ex=b({_meta:T(g(),E()).nullish()}),tx=b({_meta:T(g(),E()).nullish(),jump:B$.nullish(),rename:X$.nullish(),searchAndReplace:ex.nullish()}),nx=b({id:g(),isRegex:lt().nullish(),replace:g(),search:g(),uri:g()}),rx=ae([D("automatic"),D("diagnostic"),D("manual")]),ix=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),sx=b({_meta:T(g(),E()).nullish(),diagnostics:N$.nullish(),editHistory:F$.nullish(),openFiles:W$.nullish(),recentFiles:G$.nullish(),relatedSnippets:J$.nullish(),userActions:ix.nullish()}),ox=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Up)}),ax=b({default:ie().nullish(),description:g().nullish(),maximum:ie().nullish(),minimum:ie().nullish(),title:g().nullish()}),T6=g(),lx=ae([D("allow_once"),D("allow_always"),D("reject_once"),D("reject_always")]),cx=b({_meta:T(g(),E()).nullish(),kind:lx,name:g(),optionId:T6}),ux=ae([D("high"),D("medium"),D("low")]),hx=ae([D("pending"),D("in_progress"),D("completed")]),dx=b({_meta:T(g(),E()).nullish(),content:g(),priority:ux,status:hx}),px=b({_meta:T(g(),E()).nullish(),entries:G(dx)}),Cs=b({character:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),fx=b({id:g(),position:Cs,uri:g()}),mx=b({id:g(),newName:g(),position:Cs,uri:g()}),gx=b({action:g(),position:Cs,timestampMs:ie(),uri:g()}),C6=ae([D("utf-16"),D("utf-32"),D("utf-8")]),vx=b({_meta:T(g(),E()).nullish(),auth:KI.optional().default({terminal:!1}),elicitation:b$.nullish(),fs:A$.optional().default({readTextFile:!1,writeTextFile:!1}),nes:tx.nullish(),positionEncodings:G(C6).optional(),terminal:lt().optional().default(!1)}),yx=b({_meta:T(g(),E()).nullish(),audio:lt().optional().default(!1),embeddedContext:lt().optional().default(!1),image:lt().optional().default(!1)}),R6=ie().int().gte(0).lte(65535),wx=b({_meta:T(g(),E()).nullish(),clientCapabilities:vx.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:k6.nullish(),protocolVersion:R6}),Yl=b({end:Cs,start:Cs}),bx=b({message:g(),range:Yl,severity:M$,uri:g()}),Sx=b({languageId:g(),lastFocusedMs:ie().nullish(),uri:g(),visibleRange:Yl.nullish()}),_x=b({_meta:T(g(),E()).nullish(),diagnostics:G(bx).nullish(),editHistory:G(q$).nullish(),openFiles:G(Sx).nullish(),recentFiles:G(j$).nullish(),relatedSnippets:G(K$).nullish(),userActions:G(gx).nullish()}),Ax=b({newText:g(),range:Yl}),Ex=b({cursorPosition:Cs.nullish(),edits:G(Ax),id:g(),uri:g()}),kx=ae([Ex.and(b({kind:D("edit")})),fx.and(b({kind:D("jump")})),mx.and(b({kind:D("rename")})),nx.and(b({kind:D("searchAndReplace")}))]),Tx=b({_meta:T(g(),E()).nullish(),content:g()}),Cx=b({_meta:T(g(),E()).nullish()}),Qo=ae([ie(),g()]).nullable();b({_meta:T(g(),E()).nullish(),requestId:Qo});const Rx=c6(["assistant","user"]),ph=b({_meta:T(g(),E()).nullish(),audience:G(Rx).nullish(),lastModified:g().nullish(),priority:ie().nullish()}),Ix=b({_meta:T(g(),E()).nullish(),annotations:ph.nullish(),data:g(),mimeType:g()}),$x=b({_meta:T(g(),E()).nullish(),annotations:ph.nullish(),data:g(),mimeType:g(),uri:g().nullish()}),xx=b({_meta:T(g(),E()).nullish(),annotations:ph.nullish(),description:g().nullish(),mimeType:g().nullish(),name:g(),size:ie().nullish(),title:g().nullish(),uri:g()}),Px=b({_meta:T(g(),E()).nullish(),optionId:T6}),Dx=ae([b({outcome:D("cancelled")}),Px.and(b({outcome:D("selected")}))]),Lx=b({_meta:T(g(),E()).nullish(),outcome:Dx}),Ox=b({_meta:T(g(),E()).nullish()}),Mx=b({_meta:T(g(),E()).nullish()}),Nx=b({currentValue:lt()}),zx=g(),I6=g(),Hx=ae([D("mode"),D("model"),D("thought_level"),g()]),Y1=g(),$6=b({_meta:T(g(),E()).nullish(),description:g().nullish(),name:g(),value:Y1}),Zx=b({_meta:T(g(),E()).nullish(),group:zx,name:g(),options:G($6)}),Ux=ae([G($6),G(Zx)]),Fx=b({currentValue:Y1,options:Ux}),Kl=Zp(ae([Fx.and(b({type:D("select")})),Nx.and(b({type:D("boolean")}))]),b({_meta:T(g(),E()).nullish(),category:Hx.nullish(),description:g().nullish(),id:I6,name:g()})),qx=b({_meta:T(g(),E()).nullish(),configOptions:G(Kl)}),Vx=b({_meta:T(g(),E()).nullish()}),be=g(),Bx=b({_meta:T(g(),E()).nullish(),id:g(),sessionId:be}),Wx=b({_meta:T(g(),E()).nullish(),sessionId:be}),jx=b({_meta:T(g(),E()).nullish(),sessionId:be}),Gx=b({_meta:T(g(),E()).nullish(),sessionId:be}),x6=b({_meta:T(g(),E()).nullish(),args:G(g()).optional(),command:g(),cwd:g().nullish(),env:G(w6).optional(),outputByteLimit:ie().nullish(),sessionId:be}),Yx=b({_meta:T(g(),E()).nullish(),sessionId:be,uri:g()}),Kx=b({_meta:T(g(),E()).nullish(),position:Cs,sessionId:be,uri:g(),version:ie(),visibleRange:Yl}),Jx=b({_meta:T(g(),E()).nullish(),languageId:g(),sessionId:be,text:g(),uri:g(),version:ie()}),Xx=b({_meta:T(g(),E()).nullish(),sessionId:be,uri:g()}),Qx=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Up).optional(),sessionId:be}),P6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),eP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Up),sessionId:be}),D6=b({_meta:T(g(),E()).nullish(),limit:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:g(),sessionId:be}),tP=b({_meta:T(g(),E()).nullish(),id:g(),reason:Y$.nullish(),sessionId:be}),L6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),nP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),mcpServers:G(Up).optional(),sessionId:be}),rP=b({_meta:T(g(),E()).nullish(),additionalDirectories:G(g()).optional(),cwd:g(),sessionId:be,title:g().nullish(),updatedAt:g().nullish()}),iP=b({_meta:T(g(),E()).nullish(),nextCursor:g().nullish(),sessions:G(rP)}),sP=b({_meta:T(g(),E()).nullish(),title:g().nullish(),updatedAt:g().nullish()}),oP=b({_meta:T(g(),E()).nullish()}),Fp=g(),aP=b({_meta:T(g(),E()).nullish(),currentModeId:Fp}),lP=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:Fp,name:g()}),qp=b({_meta:T(g(),E()).nullish(),availableModes:G(lP),currentModeId:Fp}),Vp=b({_meta:T(g(),E()).nullish(),availableModels:G(O$),currentModelId:G1}),cP=b({_meta:T(g(),E()).nullish(),configOptions:G(Kl).nullish(),models:Vp.nullish(),modes:qp.nullish(),sessionId:be}),uP=b({_meta:T(g(),E()).nullish(),configOptions:G(Kl).nullish(),models:Vp.nullish(),modes:qp.nullish()}),hP=b({_meta:T(g(),E()).nullish(),configOptions:G(Kl).nullish(),models:Vp.nullish(),modes:qp.nullish(),sessionId:be}),dP=b({_meta:T(g(),E()).nullish(),configOptions:G(Kl).nullish(),models:Vp.nullish(),modes:qp.nullish()}),pP=b({_meta:T(g(),E()).nullish()}),fP=b({_meta:T(g(),E()).nullish(),additionalDirectories:Ox.nullish(),close:Mx.nullish(),fork:Vx.nullish(),list:oP.nullish(),resume:pP.nullish()}),mP=Zp(ae([b({type:D("boolean"),value:lt()}),b({value:Y1})]),b({_meta:T(g(),E()).nullish(),configId:I6,sessionId:be})),gP=b({_meta:T(g(),E()).nullish(),configOptions:G(Kl)}),vP=b({_meta:T(g(),E()).nullish(),modeId:Fp,sessionId:be}),yP=b({_meta:T(g(),E()).nullish()}),wP=b({_meta:T(g(),E()).nullish(),modelId:G1,sessionId:be}),bP=b({_meta:T(g(),E()).nullish()}),SP=b({_meta:T(g(),E()).nullish(),sessionId:be}),_P=ae([D("end_turn"),D("max_tokens"),D("max_turn_requests"),D("refusal"),D("cancelled")]),AP=ae([D("email"),D("uri"),D("date"),D("date-time")]),EP=b({default:g().nullish(),description:g().nullish(),enum:G(g()).nullish(),format:AP.nullish(),maxLength:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:G(y6).nullish(),pattern:g().nullish(),title:g().nullish()}),kP=b({_meta:T(g(),E()).nullish(),context:_x.nullish(),position:Cs,selection:Yl.nullish(),sessionId:be,triggerKind:rx,uri:g(),version:ie()}),TP=b({_meta:T(g(),E()).nullish(),suggestions:G(kx)}),CP=b({_meta:T(g(),E()).nullish(),terminalId:g()}),RP=b({_meta:T(g(),E()).nullish(),exitCode:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:g().nullish()}),O6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),IP=b({_meta:T(g(),E()).nullish(),exitStatus:RP.nullish(),output:g(),truncated:lt()}),$P=b({_meta:T(g(),E()).nullish(),annotations:ph.nullish(),text:g()}),xP=b({range:Yl.nullish(),text:g()}),PP=b({_meta:T(g(),E()).nullish(),contentChanges:G(xP),sessionId:be,uri:g(),version:ie()});b({method:g(),params:ae([Wx,Jx,PP,Yx,Xx,Kx,Bx,tP,S6]).nullish()});const DP=ae([D("full"),D("incremental")]),LP=b({_meta:T(g(),E()).nullish(),syncKind:DP}),OP=b({_meta:T(g(),E()).nullish(),didChange:LP.nullish(),didClose:z$.nullish(),didFocus:H$.nullish(),didOpen:Z$.nullish(),didSave:U$.nullish()}),MP=b({_meta:T(g(),E()).nullish(),document:OP.nullish()}),NP=b({_meta:T(g(),E()).nullish(),context:sx.nullish(),events:MP.nullish()}),zP=b({_meta:T(g(),E()).nullish(),auth:R$.optional().default({}),loadSession:lt().optional().default(!1),mcpCapabilities:x$.optional().default({http:!1,sse:!1}),nes:NP.nullish(),positionEncoding:C6.nullish(),promptCapabilities:yx.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:fP.optional().default({})}),HP=b({_meta:T(g(),E()).nullish(),agentCapabilities:zP.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:k6.nullish(),authMethods:G(t$).optional().default([]),protocolVersion:R6}),ZP=b({_meta:T(g(),E()).nullish(),mimeType:g().nullish(),text:g(),uri:g()}),UP=ae([ZP,i$]),FP=b({_meta:T(g(),E()).nullish(),annotations:ph.nullish(),resource:UP}),K1=ae([$P.and(b({type:D("text")})),$x.and(b({type:D("image")})),Ix.and(b({type:D("audio")})),xx.and(b({type:D("resource_link")})),FP.and(b({type:D("resource")}))]),qP=b({_meta:T(g(),E()).nullish(),content:K1}),Am=b({_meta:T(g(),E()).nullish(),content:K1,messageId:g().nullish()}),VP=b({_meta:T(g(),E()).nullish(),messageId:g().nullish(),prompt:G(K1),sessionId:be}),BP=b({anyOf:G(y6)}),M6=ae([qP.and(b({type:D("content")})),u$.and(b({type:D("diff")})),CP.and(b({type:D("terminal")}))]),N6=g(),z6=b({_meta:T(g(),E()).nullish(),line:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:g()}),H6=ae([D("pending"),D("in_progress"),D("completed"),D("failed")]),Z6=ae([D("read"),D("edit"),D("delete"),D("move"),D("search"),D("execute"),D("think"),D("fetch"),D("switch_mode"),D("other")]),WP=b({_meta:T(g(),E()).nullish(),content:G(M6).optional(),kind:Z6.optional(),locations:G(z6).optional(),rawInput:E().optional(),rawOutput:E().optional(),status:H6.optional(),title:g(),toolCallId:N6}),U6=b({_meta:T(g(),E()).nullish(),content:G(M6).nullish(),kind:Z6.nullish(),locations:G(z6).nullish(),rawInput:E().optional(),rawOutput:E().optional(),status:H6.nullish(),title:g().nullish(),toolCallId:N6}),F6=b({_meta:T(g(),E()).nullish(),options:G(cx),sessionId:be,toolCall:U6}),jP=b({_meta:T(g(),E()).nullish(),hint:g()}),GP=jP,YP=b({_meta:T(g(),E()).nullish(),description:g(),input:GP.nullish(),name:g()}),KP=b({_meta:T(g(),E()).nullish(),availableCommands:G(YP)}),JP=b({enum:G(g()),type:y$}),XP=ae([JP,BP]),QP=b({default:G(g()).nullish(),description:g().nullish(),items:XP,maxItems:ie().nullish(),minItems:ie().nullish(),title:g().nullish()}),e5=ae([EP.and(b({type:D("string")})),ax.and(b({type:D("number")})),E$.and(b({type:D("integer")})),s$.and(b({type:D("boolean")})),QP.and(b({type:D("array")}))]),t5=b({description:g().nullish(),properties:T(g(),e5).optional().default({}),required:G(g()).nullish(),title:g().nullish(),type:v$.optional().default("object")}),n5=b({requestedSchema:t5}),r5=Zp(ae([n5.and(b({mode:D("form")})),S$.and(b({mode:D("url")}))]),b({_meta:T(g(),E()).nullish(),message:g(),sessionId:be})),i5=b({cachedReadTokens:ie().nullish(),cachedWriteTokens:ie().nullish(),inputTokens:ie(),outputTokens:ie(),thoughtTokens:ie().nullish(),totalTokens:ie()}),s5=b({_meta:T(g(),E()).nullish(),stopReason:_P,usage:i5.nullish(),userMessageId:g().nullish()});ae([b({id:Qo,result:ae([HP,r$,$$,hP,uP,iP,cP,dP,a$,yP,gP,s5,bP,SP,TP,o$,A6])}),b({error:b6,id:Qo})]);const o5=b({_meta:T(g(),E()).nullish(),cost:l$.nullish(),size:ie(),used:ie()}),a5=ae([Am.and(b({sessionUpdate:D("user_message_chunk")})),Am.and(b({sessionUpdate:D("agent_message_chunk")})),Am.and(b({sessionUpdate:D("agent_thought_chunk")})),WP.and(b({sessionUpdate:D("tool_call")})),U6.and(b({sessionUpdate:D("tool_call_update")})),px.and(b({sessionUpdate:D("plan")})),KP.and(b({sessionUpdate:D("available_commands_update")})),aP.and(b({sessionUpdate:D("current_mode_update")})),qx.and(b({sessionUpdate:D("config_option_update")})),sP.and(b({sessionUpdate:D("session_info_update")})),o5.and(b({sessionUpdate:D("usage_update")}))]),q6=b({_meta:T(g(),E()).nullish(),sessionId:be,update:a5});b({method:g(),params:ae([q6,m$,S6]).nullish()});const V6=b({_meta:T(g(),E()).nullish(),sessionId:be,terminalId:g()}),l5=b({_meta:T(g(),E()).nullish(),exitCode:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:g().nullish()}),c5=b({name:g(),uri:g()}),u5=b({_meta:T(g(),E()).nullish(),repository:Q$.nullish(),workspaceFolders:G(c5).nullish(),workspaceUri:g().nullish()});b({id:Qo,method:g(),params:ae([wx,n$,I$,ox,eP,T$,Qx,nP,Gx,vP,mP,VP,wP,u5,kP,jx,_6]).nullish()});const B6=b({_meta:T(g(),E()).nullish(),content:g(),path:g(),sessionId:be});b({id:Qo,method:g(),params:ae([B6,D6,F6,x6,O6,L6,V6,P6,r5,_6]).nullish()});const h5=b({_meta:T(g(),E()).nullish()});ae([b({id:Qo,result:ae([h5,Tx,Lx,c$,IP,Cx,l5,k$,g$,A6])}),b({error:b6,id:Qo})]);var we;class d5{constructor(t,e){m(this,we);const r=t(this),i=async(a,l)=>{var c,u,p,f,y,v,S;switch(a){case Zr.fs_write_text_file:{const _=B6.parse(l);return(c=r.writeTextFile)==null?void 0:c.call(r,_)}case Zr.fs_read_text_file:{const _=D6.parse(l);return(u=r.readTextFile)==null?void 0:u.call(r,_)}case Zr.session_request_permission:{const _=F6.parse(l);return r.requestPermission(_)}case Zr.terminal_create:{const _=x6.parse(l);return(p=r.createTerminal)==null?void 0:p.call(r,_)}case Zr.terminal_output:{const _=O6.parse(l);return(f=r.terminalOutput)==null?void 0:f.call(r,_)}case Zr.terminal_release:{const _=L6.parse(l);return await((y=r.releaseTerminal)==null?void 0:y.call(r,_))??{}}case Zr.terminal_wait_for_exit:{const _=V6.parse(l);return(v=r.waitForTerminalExit)==null?void 0:v.call(r,_)}case Zr.terminal_kill:{const _=P6.parse(l);return await((S=r.killTerminal)==null?void 0:S.call(r,_))??{}}default:if(r.extMethod)return r.extMethod(a,l);throw rt.methodNotFound(a)}},o=async(a,l)=>{switch(a){case Zr.session_update:{const c=q6.parse(l);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(a,l);throw rt.methodNotFound(a)}};d(this,we,new p5(i,o,e))}async initialize(t){return await s(this,we).sendRequest(De.initialize,t)}async newSession(t){return await s(this,we).sendRequest(De.session_new,t)}async loadSession(t){return await s(this,we).sendRequest(De.session_load,t)??{}}async unstable_forkSession(t){return await s(this,we).sendRequest(De.session_fork,t)}async listSessions(t){return await s(this,we).sendRequest(De.session_list,t)}async unstable_resumeSession(t){return await s(this,we).sendRequest(De.session_resume,t)}async unstable_closeSession(t){return await s(this,we).sendRequest(De.session_close,t)}async setSessionMode(t){return await s(this,we).sendRequest(De.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await s(this,we).sendRequest(De.session_set_model,t)??{}}async setSessionConfigOption(t){return await s(this,we).sendRequest(De.session_set_config_option,t)}async authenticate(t){return await s(this,we).sendRequest(De.authenticate,t)??{}}async unstable_logout(t){return await s(this,we).sendRequest(De.logout,t)??{}}async prompt(t){return await s(this,we).sendRequest(De.session_prompt,t)}async cancel(t){return await s(this,we).sendNotification(De.session_cancel,t)}async unstable_startNes(t){return await s(this,we).sendRequest(De.nes_start,t)}async unstable_suggestNes(t){return await s(this,we).sendRequest(De.nes_suggest,t)}async unstable_closeNes(t){return await s(this,we).sendRequest(De.nes_close,t)??{}}async unstable_didOpenDocument(t){return await s(this,we).sendNotification(De.document_did_open,t)}async unstable_didChangeDocument(t){return await s(this,we).sendNotification(De.document_did_change,t)}async unstable_didCloseDocument(t){return await s(this,we).sendNotification(De.document_did_close,t)}async unstable_didSaveDocument(t){return await s(this,we).sendNotification(De.document_did_save,t)}async unstable_didFocusDocument(t){return await s(this,we).sendNotification(De.document_did_focus,t)}async unstable_acceptNes(t){return await s(this,we).sendNotification(De.nes_accept,t)}async unstable_rejectNes(t){return await s(this,we).sendNotification(De.nes_reject,t)}async extMethod(t,e){return await s(this,we).sendRequest(t,e)}async extNotification(t,e){return await s(this,we).sendNotification(t,e)}get signal(){return s(this,we).signal}get closed(){return s(this,we).closed}}we=new WeakMap;var Bi,Zd,iu,su,Ha,Za,or,ou,Ze,W6,Ym,j6,G6,Y6,K6,Km,Ac;class p5{constructor(t,e,r){m(this,Ze);m(this,Bi,new Map);m(this,Zd,0);m(this,iu);m(this,su);m(this,Ha);m(this,Za,Promise.resolve());m(this,or,new AbortController);m(this,ou);d(this,iu,t),d(this,su,e),d(this,Ha,r),d(this,ou,new Promise(i=>{s(this,or).signal.addEventListener("abort",()=>i())})),h(this,Ze,W6).call(this)}get signal(){return s(this,or).signal}get closed(){return s(this,ou)}async sendRequest(t,e){h(this,Ze,Km).call(this);const r=kh(this,Zd)._++,i=new Promise((o,a)=>{s(this,Bi).set(r,{resolve:o,reject:a})});return await h(this,Ze,Ac).call(this,{jsonrpc:"2.0",id:r,method:t,params:e}),i}async sendNotification(t,e){h(this,Ze,Km).call(this),await h(this,Ze,Ac).call(this,{jsonrpc:"2.0",method:t,params:e})}}Bi=new WeakMap,Zd=new WeakMap,iu=new WeakMap,su=new WeakMap,Ha=new WeakMap,Za=new WeakMap,or=new WeakMap,ou=new WeakMap,Ze=new WeakSet,W6=async function(){let t;try{const e=s(this,Ha).readable.getReader();try{for(;!s(this,or).signal.aborted;){const{value:r,done:i}=await e.read();if(i)break;if(r)try{h(this,Ze,j6).call(this,r)}catch(o){console.error("Unexpected error during message processing:",r,o),"id"in r&&r.id!==void 0&&h(this,Ze,Ac).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{h(this,Ze,Ym).call(this,t)}},Ym=function(t){if(s(this,or).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const r of s(this,Bi).values())r.reject(e);s(this,Bi).clear(),s(this,or).abort(e)},j6=async function(t){if("method"in t&&"id"in t){const e=await h(this,Ze,G6).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await h(this,Ze,Ac).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await h(this,Ze,Y6).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?h(this,Ze,K6).call(this,t):console.error("Invalid message",{message:t})},G6=async function(t,e){try{return{result:await s(this,iu).call(this,t,e)??null}}catch(r){if(r instanceof rt)return r.toResult();if(r instanceof _2)return rt.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return rt.internalError(i?JSON.parse(i):{}).toResult()}catch{return rt.internalError({details:i}).toResult()}}},Y6=async function(t,e){try{return await s(this,su).call(this,t,e),{result:null}}catch(r){if(r instanceof rt)return r.toResult();if(r instanceof _2)return rt.invalidParams(r.format()).toResult();let i;(r instanceof Error||typeof r=="object"&&r!=null&&"message"in r&&typeof r.message=="string")&&(i=r.message);try{return rt.internalError(i?JSON.parse(i):{}).toResult()}catch{return rt.internalError({details:i}).toResult()}}},K6=function(t){const e=s(this,Bi).get(t.id);if(e){if("result"in t)e.resolve(t.result);else if("error"in t){const{code:r,message:i,data:o}=t.error;e.reject(new rt(r,i,o))}s(this,Bi).delete(t.id)}else console.error("Got response to unknown request",t.id)},Km=function(){if(s(this,or).signal.aborted)throw s(this,or).signal.reason??new Error("ACP connection closed")},Ac=async function(t){return d(this,Za,s(this,Za).then(async()=>{const e=s(this,Ha).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{h(this,Ze,Ym).call(this,e)})),s(this,Za)};class rt extends Error{constructor(e,r,i){super(r);I(this,"code");I(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,r){return new rt(-32700,`Parse error${r?`: ${r}`:""}`,e)}static invalidRequest(e,r){return new rt(-32600,`Invalid request${r?`: ${r}`:""}`,e)}static methodNotFound(e){return new rt(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,r){return new rt(-32602,`Invalid params${r?`: ${r}`:""}`,e)}static internalError(e,r){return new rt(-32603,`Internal error${r?`: ${r}`:""}`,e)}static authRequired(e,r){return new rt(-32e3,`Authentication required${r?`: ${r}`:""}`,e)}static resourceNotFound(e){return new rt(-32002,`Resource not found${e?`: ${e}`:""}`,e&&{uri:e})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}function f5(n,t,e){const r=n.dispose.bind(n);n.dispose=(()=>{if(!t())return e(),r()})}function J6(n){var e;class t extends n{constructor(...o){super(...o);m(this,e,!1);f5(this,()=>s(this,e),()=>{d(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return s(this,e)}}return e=new WeakMap,t}const m5=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,g5=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,v5=/\[Television channel context\][\s\S]*?\[\/Television channel context\]\n*/,y5=/\b(tv|television|channel|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,w5=/^[A-Za-z0-9_@%+=:,./-]+$/,b5=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,S5="single_session",_5={name:"television-acp-client",version:"0.0.0"},X6="agent:main:television",A5=J6(Ti);var Ua,ar,Xt,lr,Wi,On,Yr,cr,Mn,ji,Nn,Fa,qa,ur,Et,Kr,Va,uo,Jr,Gi,au,zn,hr,Ud,dr,O,Jm,Q6,eS,tS,Vh,nS,rS,iS,sS,oS,aS,lS,Vs,va,ya,Fr,cS,wa,Xm,Qm,Bh,uS,Wh,eg,tg,lu,cu,jh,ba,ng,hS;class E5 extends A5{constructor(e){super();m(this,O);m(this,Ua,"disconnected");m(this,ar,null);m(this,Xt,new Map);m(this,lr,null);m(this,Wi,null);m(this,On,null);m(this,Yr,null);m(this,cr,null);m(this,Mn,null);m(this,ji);m(this,Nn,null);m(this,Fa,0);m(this,qa,1);m(this,ur,null);m(this,Et,null);m(this,Kr,!1);m(this,Va,!1);m(this,uo,!1);m(this,Jr,null);m(this,Gi,new Set);m(this,au);m(this,zn);m(this,hr);m(this,Ud,e=>{h(this,O,eS).call(this,e)});m(this,dr,null);m(this,lu,()=>{h(this,O,ba).call(this,"ACP bridge websocket closed")});m(this,cu,()=>{h(this,O,ba).call(this,"ACP bridge websocket error")});d(this,zn,e),d(this,hr,e.sessionMode??S5),d(this,ji,e.mappedSessionStore??k5()),d(this,au,e.createSocket??(r=>new WebSocket(r)))}get status(){return s(this,Ua)}get messages(){return[...s(this,Xt).values()]}get enabled(){return s(this,zn).enabled??!1}setToken(e){s(this,zn).token=e??""}setEnabled(e){s(this,zn).enabled=e,e||(h(this,O,jh).call(this),d(this,ar,null),h(this,O,Fr).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){s(this,Wi)===null&&(d(this,ar,null),d(this,Wi,h(this,O,Q6).call(this)));try{await s(this,Wi),await h(this,O,Vh).call(this)}catch(e){throw h(this,O,ba).call(this,Em(e)),e}}}dispose(){h(this,O,jh).call(this),d(this,ar,null),h(this,O,Fr).call(this,"disposed")}async sendMessage(e){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,O,Jm).call(this,"ready")),(s(this,cr)===null||s(this,Nn)!==h(this,O,Wh).call(this))&&await h(this,O,Vh).call(this),this.status!=="ready")throw new Error("ACPClient is not ready to send a new message");const r=e.text.trim();if(!r)throw new Error("Cannot send an empty message");h(this,O,va).call(this,{id:h(this,O,wa).call(this,"user"),kind:"user",text:r,status:"final"}),h(this,O,Fr).call(this,"running");try{const i=await h(this,O,Bh).call(this).prompt({sessionId:h(this,O,Qm).call(this),prompt:[{type:"text",text:h(this,O,cS).call(this,r)}]});h(this,O,Vs).call(this,i.stopReason==="cancelled"?"cancelled":"final"),h(this,O,Fr).call(this,"ready")}catch(i){throw h(this,O,hS).call(this)||(h(this,O,Vs).call(this,"error"),h(this,O,Fr).call(this,"ready")),i}}async startNewSession(){var r;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,O,Jm).call(this,"ready"));const e=h(this,O,Wh).call(this);((r=s(this,Mn))==null?void 0:r.sessionIdStrategy)==="mapped"?s(this,ji).clearActualSessionId(e):d(this,Fa,s(this,Fa)+1),d(this,On,null),d(this,Yr,null),d(this,cr,null),d(this,Nn,null),h(this,O,ng).call(this)}async cancel(){this.status==="running"&&(h(this,O,Fr).call(this,"cancelling"),await h(this,O,Bh).call(this).cancel({sessionId:h(this,O,Qm).call(this)}))}setChannelContext(e){var o,a,l;if(e===null){if(s(this,Et)===null)return;d(this,Et,null),d(this,Kr,!1);return}const r={channelID:e.channelID,channelName:e.channelName};if(((o=s(this,Et))==null?void 0:o.channelID)===r.channelID&&((a=s(this,Et))==null?void 0:a.channelName)===r.channelName)return;const i=((l=s(this,Et))==null?void 0:l.channelID)??null;if(d(this,Et,r),s(this,hr)==="single_session"){(!s(this,Nn)||i!==r.channelID)&&d(this,Kr,!0);return}s(this,Nn)!==h(this,O,eg).call(this,r.channelID)&&(d(this,On,null),d(this,Yr,null),s(this,lr)&&this.status==="ready"&&h(this,O,Vh).call(this).catch(c=>{h(this,O,ba).call(this,Em(c))}))}}Ua=new WeakMap,ar=new WeakMap,Xt=new WeakMap,lr=new WeakMap,Wi=new WeakMap,On=new WeakMap,Yr=new WeakMap,cr=new WeakMap,Mn=new WeakMap,ji=new WeakMap,Nn=new WeakMap,Fa=new WeakMap,qa=new WeakMap,ur=new WeakMap,Et=new WeakMap,Kr=new WeakMap,Va=new WeakMap,uo=new WeakMap,Jr=new WeakMap,Gi=new WeakMap,au=new WeakMap,zn=new WeakMap,hr=new WeakMap,Ud=new WeakMap,dr=new WeakMap,O=new WeakSet,Jm=async function(e){if(this.status!==e){if(this.status==="disposed")throw new Error("ACPClient has been disposed");if(this.status==="disconnected")throw new Error(s(this,ar)??"ACPClient is disconnected");await new Promise((r,i)=>{const o=()=>{this.removeEventListener("status-changed",a)},a=()=>{if(this.status===e){o(),r();return}if(this.status==="disposed"){o(),i(new Error("ACPClient has been disposed"));return}this.status==="disconnected"&&(o(),i(new Error(s(this,ar)??"ACPClient is disconnected")))};this.addEventListener("status-changed",a)})}},Q6=async function(){try{const{stream:e,socket:r,metadata:i}=await I5({serverURL:s(this,zn).serverURL,token:s(this,zn).token,createSocket:s(this,au),onDisconnect:s(this,Ud)});d(this,Mn,i),d(this,dr,r),r.addEventListener("close",s(this,lu)),r.addEventListener("error",s(this,cu)),d(this,lr,new d5(o=>({connection:o,sessionUpdate:async a=>{await h(this,O,rS).call(this,a)},requestPermission:async a=>h(this,O,iS).call(this,a)}),e)),await s(this,lr).initialize({protocolVersion:YI,clientCapabilities:{},clientInfo:_5})}catch(e){throw e}},eS=function(e){h(this,O,ba).call(this,Em(e))},tS=function(e){const r=e==null?void 0:e.models;if(!(r!=null&&r.currentModelId))return;const i=r.availableModels.find(o=>o.modelId===r.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??r.currentModelId,`(${r.currentModelId})`)},Vh=async function(){const e=h(this,O,Wh).call(this);if(s(this,On)&&s(this,Yr)===e){await s(this,On);return}d(this,Yr,e),d(this,On,h(this,O,nS).call(this,e)),await s(this,On)},nS=async function(e){var c;const r=h(this,O,Bh).call(this);h(this,O,ng).call(this);let i,o=!1,a=null;const l={cwd:h(this,O,uS).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(d(this,uo,!0),d(this,Jr,null),((c=s(this,Mn))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=s(this,ji).getActualSessionId(e);if(u)try{const p=await r.loadSession({...l,sessionId:u});if(T5(p))throw new Error("Mapped ACP session was not found");a=p,i=u,o=!0}catch{const p=await r.newSession(l);a=p,i=p.sessionId,s(this,ji).setActualSessionId(e,i),o=!1}else{const p=await r.newSession(l);a=p,i=p.sessionId,s(this,ji).setActualSessionId(e,i),o=!1}}else try{a=await r.loadSession({...l,sessionId:e}),i=e,o=s(this,Xt).size>0}catch{const u=await r.newSession(l);a=u,i=u.sessionId,o=!1}}finally{d(this,uo,!1),d(this,Jr,null),h(this,O,Vs).call(this,"final")}h(this,O,tS).call(this,a),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),d(this,cr,i),d(this,Nn,e),d(this,Va,!0),o?(s(this,Gi).add(e),s(this,hr)==="single_session"&&d(this,Kr,!1)):(s(this,Gi).delete(e),d(this,Kr,s(this,hr)==="single_session")),d(this,ar,null),h(this,O,Fr).call(this,"ready")},rS=async function(e){const r=e.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&h(this,O,lS).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&h(this,O,sS).call(this,r.content.text);return;case"tool_call":h(this,O,oS).call(this,r);return;case"tool_call_update":h(this,O,aS).call(this,r);return;case"agent_thought_chunk":return;default:return}},iS=async function(e){return{outcome:{outcome:"cancelled"}}},sS=function(e){d(this,Jr,null);const r=R5(e);if(!r)return;if(!s(this,ur)){const o={id:h(this,O,wa).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};d(this,ur,o.id),h(this,O,va).call(this,o);return}const i=s(this,Xt).get(s(this,ur));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");h(this,O,ya).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},oS=function(e){h(this,O,Vs).call(this,"final");const r=h(this,O,Xm).call(this,e.toolCallId),i=L2("content"in e?e.content:void 0),o={id:(r==null?void 0:r.id)??h(this,O,wa).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:e.title,toolKind:e.kind??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:e.locations??(r==null?void 0:r.locations)};if(r){h(this,O,ya).call(this,o);return}h(this,O,va).call(this,o)},aS=function(e){const r=h(this,O,Xm).call(this,e.toolCallId),i=(r==null?void 0:r.text)??"",o=L2(e.content),a=o?`${i}${o}`:i,l={id:(r==null?void 0:r.id)??h(this,O,wa).call(this,"tool"),kind:"tool_call",toolCallId:e.toolCallId,title:(r==null?void 0:r.title)??e.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:e.status==="failed"?"failed":e.status==="completed"?"completed":"in_progress",text:a,locations:e.locations??(r==null?void 0:r.locations)};if(r){h(this,O,ya).call(this,l);return}h(this,O,va).call(this,l)},lS=function(e){if(h(this,O,Vs).call(this,"final"),!e)return;const r=s(this,uo)?s(this,Jr):null;if(!r){const o=D2(e);if(!o)return;const a={id:h(this,O,wa).call(this,"user"),kind:"user",text:o,status:"final"};h(this,O,va).call(this,a),s(this,uo)&&d(this,Jr,a.id);return}const i=s(this,Xt).get(r);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");h(this,O,ya).call(this,{...i,text:D2(`${i.text}${e}`)})},Vs=function(e){if(!s(this,ur))return;const r=s(this,Xt).get(s(this,ur));(r==null?void 0:r.kind)==="assistant"&&h(this,O,ya).call(this,{...r,status:e}),d(this,ur,null)},va=function(e){s(this,Xt).set(e.id,e),this.dispatchEvent(new bm("messages-changed"))},ya=function(e){s(this,Xt).set(e.id,e),this.dispatchEvent(new bm("messages-changed"))},Fr=function(e){s(this,Ua)!==e&&(d(this,Ua,e),this.dispatchEvent(new Pk("status-changed")))},cS=function(e){var u;const r=s(this,Nn);if(!r)return e;const i=s(this,Et)?s(this,hr)==="single_session"?s(this,Kr)||!s(this,Gi).has(r):!s(this,Gi).has(r):!1,o=s(this,Va)&&(s(this,Et)!==null||y5.test(e));if(!(o||i))return e;o&&d(this,Va,!1),i&&(d(this,Kr,!1),s(this,Gi).add(r));const l=["[Television channel context]","This chat session is coming from a Television client.","Using Television requires the knowledge in the `television` skill. Re-read it only if it is not already in context or you know it changed.","If the skill is not installed, it can be installed via `tv skills install <your agent skills path>`."],c=((u=s(this,Mn))==null?void 0:u.tvArgs)??[];return c.length>0&&l.push(`To reach this Television server, add these arguments to each tv command that contacts it: ${c.map(P5).join(" ")}`),s(this,Et)?(l.push("This conversation is currently attached to the channel below."),l.push(`channel_id: ${s(this,Et).channelID}`),l.push(`channel_name: ${s(this,Et).channelName??""}`),l.push("When the user asks to inspect or change Television state with the tv CLI, use this channel ID with the --channel argument.")):l.push("There is currently no active Television channel."),l.push("[/Television channel context]","",e),l.join(`
|
|
43
|
-
`)},wa=function(e){const r=`${e}-${s(this,qa)}`;return d(this,qa,s(this,qa)+1),r},Xm=function(e){for(const r of s(this,Xt).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},Qm=function(){if(!s(this,cr))throw new Error("ACP session is not ready");return s(this,cr)},Bh=function(){if(!s(this,lr))throw new Error("ACP connection is not ready");return s(this,lr)},uS=function(){var r;const e=(r=s(this,Mn))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},Wh=function(){var r;if(s(this,hr)==="single_session")return h(this,O,tg).call(this,`${X6}-${(s(this,zn).clientGUID??"default-client").toLowerCase()}`);const e=(r=s(this,Et))==null?void 0:r.channelID;if(!e)throw new Error("Channel context is required for per-channel session mode");return h(this,O,eg).call(this,e)},eg=function(e){return h(this,O,tg).call(this,C5(s(this,hr),e,s(this,zn).clientGUID??"default-client"))},tg=function(e){var r;return((r=s(this,Mn))==null?void 0:r.sessionIdStrategy)==="deterministic"&&s(this,Fa)>0?`${e}:epoch-${s(this,Fa)}`:e},lu=new WeakMap,cu=new WeakMap,jh=function(){d(this,lr,null),d(this,Wi,null),d(this,On,null),d(this,Yr,null),d(this,cr,null),d(this,Nn,null),d(this,Mn,null),s(this,dr)&&(s(this,dr).removeEventListener("close",s(this,lu)),s(this,dr).removeEventListener("error",s(this,cu)),s(this,dr).close(),d(this,dr,null))},ba=function(e){const r=s(this,lr)!==null||s(this,Wi)!==null||s(this,On)!==null||s(this,Yr)!==null||s(this,cr)!==null||s(this,Nn)!==null||s(this,Mn)!==null||s(this,dr)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,O,Vs).call(this,"error"),h(this,O,jh).call(this),d(this,ar,e??null),h(this,O,Fr).call(this,"disconnected"))},ng=function(){const e=s(this,Xt).size>0;d(this,ur,null),d(this,Jr,null),d(this,qa,1),s(this,Xt).clear(),e&&this.dispatchEvent(new bm("messages-changed"))},hS=function(){return this.status==="disconnected"};function k5(){const n=new Map;return{getActualSessionId(t){return n.get(t)??null},setActualSessionId(t,e){n.set(t,e)},clearActualSessionId(t){n.delete(t)}}}function T5(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function C5(n,t,e){return n==="single_session"?`${X6}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function dS(n){return n.replace(/^(?:\s*\n)+/,"")}function D2(n){let t=n;return t=t.replace(m5,""),t=t.replace(g5,""),t=t.replace(v5,""),t=dS(t),t}function R5(n){let t=n;return t=t.replace(b5,""),t=dS(t),t}function L2(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function I5(n){const t=n.createSocket(L5(n.serverURL,n.token));let e=!1,r,i;const o=new Promise((u,p)=>{r=u,i=p}),a=new ReadableStream({start(u){let p=!1;const f=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=_=>{const x=D5(_);if(!x)return;let Z;try{Z=JSON.parse(x)}catch(L){const z=L instanceof Error?L:new Error(String(L));i(z),u.error(z);return}switch(Z.type){case"acp-bridge-status":if(Z.status==="ready"){let L;try{L=$5(Z)}catch(z){const P=z instanceof Error?z:new Error(String(z));e||i(P),u.error(P);return}e||(e=!0,r(L));return}if(Z.status==="error"||Z.status==="exited"){const L=new Error(Z.error??`ACP bridge ${Z.status}`);e||i(L),u.error(L)}return;case"acp-bridge-message":u.enqueue(Z.message);return}},v=()=>{var x;if(p)return;p=!0;const _=new Error("ACP bridge websocket closed");e||i(_),(x=n.onDisconnect)==null||x.call(n,_),u.close()},S=()=>{var x;if(p)return;p=!0;const _=new Error("ACP bridge websocket error");e||i(_),(x=n.onDisconnect)==null||x.call(n,_),u.error(_)};t.addEventListener("open",f),t.addEventListener("message",y),t.addEventListener("close",v),t.addEventListener("error",S)}}),l=new WritableStream({async write(u){await o,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await o;return{stream:{readable:a,writable:l},socket:t,metadata:c}}function $5(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0&&x5(i))return{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function x5(n){return Array.isArray(n)&&n.every(t=>typeof t=="string")}function P5(n){return w5.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function D5(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const t=n.data;if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(Array.isArray(t))return Buffer.concat(t).toString("utf8")}return null}function L5(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function Em(n){return n instanceof Error?n.message:String(n)}const O2="television.acpClientGUID",M2="television.acpMappedSessions",N2=1;var Ba;class O5{constructor(){m(this,Ba,new Map)}getActualSessionId(t){return s(this,Ba).get(t)??null}setActualSessionId(t,e){s(this,Ba).set(t,e)}clearActualSessionId(t){s(this,Ba).delete(t)}}Ba=new WeakMap;var Wa,uu,sn,Gh,Yh,rg;class M5{constructor(t,e){m(this,sn);m(this,Wa);m(this,uu);d(this,Wa,t),d(this,uu,e)}getActualSessionId(t){const e=h(this,sn,Yh).call(this)[h(this,sn,Gh).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,sn,Yh).call(this);r[h(this,sn,Gh).call(this,t)]=e,h(this,sn,rg).call(this,r)}clearActualSessionId(t){const e=h(this,sn,Yh).call(this);delete e[h(this,sn,Gh).call(this,t)],h(this,sn,rg).call(this,e)}}Wa=new WeakMap,uu=new WeakMap,sn=new WeakSet,Gh=function(t){return JSON.stringify([s(this,uu),t])},Yh=function(){const t=s(this,Wa).getItem(M2);if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(typeof e!="object"||e===null||Array.isArray(e))return{};const r=e;return r.version!==N2?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},rg=function(t){const e={version:N2,entries:t};s(this,Wa).setItem(M2,JSON.stringify(e))};function pS(){return typeof window>"u"?null:window.localStorage}function N5(n){const t=n.getItem(O2);if(t)return t;const e=U1().toLowerCase();return n.setItem(O2,e),e}const z2=4401,z5=401,Ph=1e3,H5=3e4;class Kh extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class Z5 extends Ti{constructor(e){var a,l;super();I(this,"url");I(this,"name");I(this,"telemetryMeta");I(this,"status","unauthorized");I(this,"channels",new Map);I(this,"client");I(this,"acpClient");I(this,"_token");I(this,"attempting",!1);I(this,"nextRetryAt",null);I(this,"hasEverConnected",!1);I(this,"browserDemoMode",!1);I(this,"hasAuthRejected",!1);I(this,"hasAuthTokenRejected",!1);I(this,"bootState","pending");I(this,"serverVersion",null);I(this,"updateState",null);I(this,"decideBoot");I(this,"navigationPending");I(this,"createSocket");I(this,"createClient");I(this,"socket",null);I(this,"connectAttempt",0);I(this,"autoReconnect",!1);I(this,"retryTimer",null);I(this,"retryDelay",Ph);I(this,"visibilityEventTarget");I(this,"networkEventTarget");I(this,"onVisibilityChange");I(this,"onNetworkOnline");I(this,"telemetryActivityAgent");this.url=Es(e.url),this.name=e.name,this.decideBoot=e.decideBoot??null,this.navigationPending=e.navigationPending??(()=>!1),this._token=e.token??null,this.telemetryMeta=e.telemetryMeta??null,this.createSocket=e.createSocket??(c=>new WebSocket(c)),this.createClient=e.createClient??((c,u,p)=>new sk(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...p?{telemetryMeta:p}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new M5(e.acpStorage,this.url):new O5);this.acpClient=new E5({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:r}),this.visibilityEventTarget=e.visibilityEventTarget!==void 0?e.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=e.networkEventTarget!==void 0?e.networkEventTarget:typeof window<"u"?window:null,this.onVisibilityChange=()=>{this.isPageVisible()&&this.kickReconnect()},this.onNetworkOnline=()=>{this.kickReconnect()},(a=this.visibilityEventTarget)==null||a.addEventListener("visibilitychange",this.onVisibilityChange),(l=this.networkEventTarget)==null||l.addEventListener("online",this.onNetworkOnline);const i=e.telemetryDocumentTarget!==void 0?e.telemetryDocumentTarget:typeof document<"u"?document:null,o=e.telemetryWindowTarget!==void 0?e.telemetryWindowTarget:typeof window<"u"?window:null;this.telemetryActivityAgent=this.telemetryMeta&&i&&o?WI({meta:this.telemetryMeta,documentTarget:i,windowTarget:o,send:c=>this.sendTelemetryActivity(c)}):null}get token(){return this._token}clearToken(){this._token=null,this.acpClient.setToken(null),this.client=this.createClient(this.url,null,this.telemetryMeta)}async connect(e){this._token=e,this.hasAuthRejected=!1,this.hasAuthTokenRejected=!1,this.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=Ph,this.autoReconnect=!0,await this.attempt()}dispose(){var e,r,i,o;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(e=this.socket)==null||e.close(),this.socket=null,this.setStatus("unauthorized"),(r=this.visibilityEventTarget)==null||r.removeEventListener("visibilitychange",this.onVisibilityChange),(i=this.networkEventTarget)==null||i.removeEventListener("online",this.onNetworkOnline),(o=this.telemetryActivityAgent)==null||o.stop(),this.acpClient.dispose()}getViewURL(e){const r=Td(e,this.renderOptions());return wi()?new URL(r.viewURL,this.url).toString():r.renderer==="proxy-iframe"?new URL(r.viewURL,this.url).toString():r.viewURL}async readDemoMode(){try{return await this.client.demoMode()}catch{return null}}renderOptions(){return{electron:wi(),browserDemo:this.browserDemoMode}}getContentURL(e){const r=Td(e,this.renderOptions()).contentURL;return r===null?null:new URL(r,this.url).toString()}async createChannel(e){const{channel:r}=await this.client.channels.create({name:e});return this.channels.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"channel-created":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Sc("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Sc("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new Sc("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!FE(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...g8},size:{...v8}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=zm(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"channel-changed":case"pinned-channels-changed":case"theme-changed":case"appearance-changed":case"artifact-focus":break;default:return U5(e,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1,this.bootState="pending";const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token,this.telemetryMeta),this.setStatus("disconnected"),this.dispatchEvent(new Bt("change"));const r=this.createSocket(F5(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((o,a)=>{let l=!1;const c=()=>{var f;l||this.connectAttempt!==e||(l=!0,this.retryDelay=Ph,this.hasEverConnected=!0,this.setStatus("connected"),(f=this.telemetryActivityAgent)==null||f.start(),o())},u=f=>{l||this.connectAttempt!==e||(l=!0,a(f))},p=async()=>{const f=this.hasEverConnected;try{const[{channels:y},v,S]=await Promise.all([this.client.channels.list(),this.client.display.get(),f?null:this.readDemoMode()]);f||(this.browserDemoMode=(S==null?void 0:S.browserExternalPages)===!0),this.channels=new Map(y.map(_=>[_.id,structuredClone(_)])),this.acpClient.setEnabled(v.acpEnabled),this.dispatchEvent(new Bt("change")),f&&this.dispatchEvent(new Sc("channels-changed")),this.dispatchEvent(new Fh("server-event",{serverURL:this.url,event:{type:"channel-changed",channelID:v.focusedChannelId}})),this.dispatchEvent(new Fh("server-event",{serverURL:this.url,event:{type:"pinned-channels-changed",pinnedChannelIds:[...v.pinnedChannelIds]}})),c(),f&&this.connectAttempt===e&&this.dispatchEvent(new R8("server-reconnected",{serverURL:this.url}))}catch(y){if(G5(y)){u(new Kh);return}u(y instanceof Error?y:new Error(String(y)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||p())}),r.addEventListener("message",f=>{const y=j5(f);if(!y)return;if(y.type==="server-status"){const S=y;this.serverVersion=S.version,this.updateState=S.update??null;let _=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(S)==="boot"?(this.bootState="booted",_=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new I8("server-status",{serverURL:this.url,message:S})),_?this.navigationPending()||p():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new Bt("change"));return}if(!W5(y.type))return;const v=y;this.applyServerEvent(v),this.dispatchEvent(new Fh("server-event",{serverURL:this.url,event:v}))}),r.addEventListener("close",f=>{if(this.connectAttempt!==e)return;this.socket=null;const y=q5(f);if(!l){u(y===z2?new Kh:new Error("Connection closed before initialization"));return}if(y===z2){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){this.handleTransportFailure(new Error("WebSocket error"));return}u(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},o=>{throw this.attempting=!1,this.handleAttemptFailure(o),o})}handleAuthRejected(){this.hasAuthRejected=!0,this.hasAuthTokenRejected=this._token!==null,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof Kh){this.handleAuthRejected();return}this.autoReconnect&&this.scheduleRetry()}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,H5),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new Bt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new Bt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=Ph,this.attempt().catch(()=>{})))}sendTelemetryActivity(e){var r;this.status==="connected"&&((r=this.socket)==null||r.send(JSON.stringify(e)))}sendTelemetrySignal(e,r){var o;if(!this.telemetryMeta||this.status!=="connected"&&this.bootState!=="halted")return;const i={type:UE,clientId:this.telemetryMeta.clientId,event:e,properties:r};(o=this.socket)==null||o.send(JSON.stringify(i))}setStatus(e){this.status!==e&&(this.status=e,this.dispatchEvent(new Bt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function U5(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function F5(n,t,e=null){const r=new URL(n);if(r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname="/events",r.search="",t&&r.searchParams.set("token",t),e)for(const[i,o]of BI(e))r.searchParams.set(i,o);return r.hash="",r.toString()}function q5(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const V5={"artifact-created":!0,"artifact-updated":!0,"artifact-content-changed":!0,"artifact-removed":!0,"channel-created":!0,"channel-updated":!0,"channel-removed":!0,"channel-changed":!0,"pinned-channels-changed":!0,"theme-changed":!0,"appearance-changed":!0,"artifact-focus":!0},B5=new Set(Object.keys(V5));function W5(n){return B5.has(n)}function j5(n){const t=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}return typeof e!="object"||e===null||!("type"in e)||typeof e.type!="string"?null:e}function G5(n){return n instanceof jl&&n.status===z5}const Y5="Local";var mn,Hn,$r,ig,sg,fS,hu,du,pu,fu,mu;class K5 extends Ti{constructor(e){super();m(this,$r);I(this,"connection");I(this,"clientGUID");I(this,"acpStorage");I(this,"connectError",null);m(this,mn);m(this,Hn,!1);m(this,hu,()=>{s(this,Hn)||(h(this,$r,fS).call(this),this.dispatchEvent(new Bt("change")))});m(this,du,e=>{s(this,Hn)||this.dispatchEvent(new Fh("server-event",{serverURL:e.serverURL,event:e.event}))});m(this,pu,()=>{s(this,Hn)||this.dispatchEvent(new Sc("channels-changed"))});m(this,fu,e=>{s(this,Hn)||this.dispatchEvent(new R8("server-reconnected",{serverURL:e.serverURL}))});m(this,mu,e=>{s(this,Hn)||this.dispatchEvent(new I8("server-status",{serverURL:e.serverURL,message:e.message}))});d(this,mn,e.localStore),this.acpStorage=e.acpStorage===void 0?pS():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?N5(this.acpStorage):U1().toLowerCase());const r=Es(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&s(this,mn).set(s2(s(this,mn).get(),r,e.launchToken));const i=e.launchToken??i2(s(this,mn).get(),r),o=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new Z5(l));this.connection=a({url:r,name:e.connectionName??Y5,token:i,createSocket:o,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:e.telemetryMeta??null,decideBoot:e.decideBoot,navigationPending:e.navigationPending}),this.connection.addEventListener("change",s(this,hu)),this.connection.addEventListener("server-event",s(this,du)),this.connection.addEventListener("channels-changed",s(this,pu)),this.connection.addEventListener("server-reconnected",s(this,fu)),this.connection.addEventListener("server-status",s(this,mu))}get storedAuthToken(){return i2(s(this,mn).get(),this.connection.url)}async connect(){await h(this,$r,ig).call(this,this.connection.token)}async authenticate(e){s(this,mn).set(s2(s(this,mn).get(),this.connection.url,e)),await h(this,$r,ig).call(this,e)}dispose(){s(this,Hn)||(d(this,Hn,!0),this.connection.removeEventListener("change",s(this,hu)),this.connection.removeEventListener("server-event",s(this,du)),this.connection.removeEventListener("channels-changed",s(this,pu)),this.connection.removeEventListener("server-reconnected",s(this,fu)),this.connection.removeEventListener("server-status",s(this,mu)),this.connection.dispose())}}mn=new WeakMap,Hn=new WeakMap,$r=new WeakSet,ig=async function(e){if(!s(this,Hn)){h(this,$r,sg).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,$r,sg).call(this,r instanceof Kh?null:r instanceof Error?r.message:String(r))}}},sg=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new Bt("change")))},fS=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=s(this,mn).get(),r=Mk(e,this.connection.url);r!==e&&s(this,mn).set(r),this.connection.token!==null&&this.connection.clearToken()},hu=new WeakMap,du=new WeakMap,pu=new WeakMap,fu=new WeakMap,mu=new WeakMap;const og="tv-nav:",zl="tv-reload",H2=100,J5=1e3,X5=60,Q5=60,eD=24,tD=30,nD=tD*eD*Q5*X5*J5;function bi(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(zl);return t.searchParams.delete(zl),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var gu,ja,$e,Ce,ho,Xe,mS,Mi,gS,ag,lg;class rD extends Ti{constructor(e,r){super();m(this,Xe);m(this,gu);m(this,ja);m(this,$e,[]);m(this,Ce,-1);m(this,ho,0);d(this,gu,e),d(this,ja,bi(r)),h(this,Xe,mS).call(this)}get currentURL(){var e;return s(this,Ce)===-1?null:((e=s(this,$e)[s(this,Ce)])==null?void 0:e.url)??null}get canGoBack(){return s(this,Ce)>-1}get canGoForward(){return s(this,Ce)<s(this,$e).length-1}get entries(){return s(this,$e).map(e=>({...e}))}get cursor(){return s(this,Ce)}navigate(e){const r=bi(e);if(r===s(this,ja)){if(s(this,Ce)===-1)return;d(this,Ce,-1),h(this,Xe,Mi).call(this);return}s(this,Ce)<s(this,$e).length-1&&d(this,$e,s(this,$e).slice(0,s(this,Ce)+1)),s(this,$e).push({url:r}),d(this,Ce,s(this,$e).length-1),h(this,Xe,ag).call(this),h(this,Xe,Mi).call(this)}replace(e){var i;if(s(this,Ce)===-1){this.navigate(e);return}const r=bi(e);if(r===s(this,ja)){d(this,$e,s(this,$e).filter((o,a)=>a!==s(this,Ce))),d(this,Ce,-1),h(this,Xe,Mi).call(this);return}((i=s(this,$e)[s(this,Ce)])==null?void 0:i.url)!==r&&(d(this,$e,s(this,$e).map((o,a)=>a===s(this,Ce)?{url:r}:o)),h(this,Xe,Mi).call(this))}back(){s(this,Ce)!==-1&&(d(this,Ce,s(this,Ce)-1),h(this,Xe,Mi).call(this))}forward(){this.canGoForward&&(d(this,Ce,s(this,Ce)+1),h(this,Xe,Mi).call(this))}reset(){s(this,Ce)===-1&&s(this,$e).length===0||(d(this,$e,[]),d(this,Ce,-1),h(this,Xe,Mi).call(this))}}gu=new WeakMap,ja=new WeakMap,$e=new WeakMap,Ce=new WeakMap,ho=new WeakMap,Xe=new WeakSet,mS=function(){const e=localStorage.getItem(s(this,Xe,lg));if(e!==null)try{const r=JSON.parse(e);if(!vS(r))return;d(this,$e,r.entries.map(i=>({url:i.url}))),d(this,Ce,r.cursor),d(this,ho,r.lastWritten),h(this,Xe,ag).call(this)}catch{d(this,$e,[]),d(this,Ce,-1),d(this,ho,0)}},Mi=function(){d(this,ho,Date.now());try{localStorage.setItem(s(this,Xe,lg),JSON.stringify(h(this,Xe,gS).call(this)))}catch(e){if(!oD(e))throw e}this.dispatchEvent(new Bt("change"))},gS=function(){return{v:1,entries:s(this,$e).map(e=>({...e})),cursor:s(this,Ce),lastWritten:s(this,ho)}},ag=function(){if(s(this,$e).length<=H2)return;const e=s(this,$e).length-H2;d(this,$e,s(this,$e).slice(e)),d(this,Ce,Math.max(-1,s(this,Ce)-e))},lg=function(){return iD(s(this,gu))};function iD(n){return`${og}${n}`}function sD(n){const t=Date.now()-nD,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(og)))continue;const o=i.slice(og.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!vS(l)){e.push(i);continue}!n.has(o)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function oD(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function vS(n){if(typeof n!="object"||n===null)return!1;const t=n;if(t.v!==1||!Array.isArray(t.entries))return!1;const e=t.cursor;return typeof e!="number"||!Number.isInteger(e)||typeof t.lastWritten!="number"||!Number.isFinite(t.lastWritten)||e<-1||e>=t.entries.length?!1:t.entries.every(r=>typeof r=="object"&&r!==null&&typeof r.url=="string")}const km="tv-channel-sidebar-collapsed";var po;class aD{constructor(t){m(this,po);d(this,po,t)}read(){return s(this,po).getItem(km)==="true"}setCollapsed(t){try{t?s(this,po).setItem(km,"true"):s(this,po).removeItem(km)}catch{}}}po=new WeakMap;const Tm="tv-channel-sidebar-width",cg=160,ug=350,Dh=260,lD=/^-?\d+$/;var fo;class cD{constructor(t){m(this,fo);d(this,fo,t)}read(){const t=s(this,fo).getItem(Tm);if(t===null||!lD.test(t))return null;const e=BigInt(t);return e<BigInt(cg)?cg:e>BigInt(ug)?ug:Number(e)}commit(t){const e=yS(Math.round(t));try{s(this,fo).setItem(Tm,String(e))}catch{}return e}clear(){try{s(this,fo).removeItem(Tm)}catch{}}}fo=new WeakMap;function yS(n){return Math.min(Math.max(n,cg),ug)}const uD="1.4.12";function J1(n=uD){return n!==void 0&&n.length>0?n:"0.0.0"}function X1(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const hg="tv-reload-attempted";function hD(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:lk(n.bundleVersion,n.serverVersion)?n.marker!==null&&n.marker.serverVersion===n.serverVersion?{action:"none"}:{action:"reload",marker:{serverVersion:n.serverVersion,fromVersion:n.bundleVersion}}:{action:"none"}:{action:"none"}}function dD(n){const t=n.getItem(hg);if(t===null)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object")return null;const r=e;return typeof r.serverVersion!="string"||typeof r.fromVersion!="string"?null:{serverVersion:r.serverVersion,fromVersion:r.fromVersion}}function pD(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??X1(),i=n.bundleVersion??J1();if(t===null)return{dispose(){}};let o=null;const a=()=>{if(o===null)return;const u=n.owner.connection;if(u.url!==n.primaryServerURL||u.status!=="connected")return;const p=o;o=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:p.fromVersion,to_version:p.toVersion})},l=u=>{if(r.pending)return;const p=hD({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:dD(t)});switch(p.action){case"reload":t.setItem(hg,JSON.stringify(p.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(hg),o={fromVersion:p.fromVersion,toVersion:p.toVersion},a();return;case"none":return}},c=()=>{a()};return n.owner.addEventListener("server-status",l),n.owner.addEventListener("change",c),{dispose(){n.owner.removeEventListener("server-status",l),n.owner.removeEventListener("change",c)}}}function fD(n){const t=wi(n.search),e=m6(n.search),r=e!==null&&Op(e)?e:null;return{electron:t,shellVersion:r}}function mD(n){return!n.electron||n.requiredDesktopVersion===null||!Op(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===bd?!1:Z1(n.requiredDesktopVersion,n.shellVersion)}const gD=`# Desktop app update required
|
|
43
|
+
`)},wa=function(e){const r=`${e}-${s(this,qa)}`;return d(this,qa,s(this,qa)+1),r},Xm=function(e){for(const r of s(this,Xt).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},Qm=function(){if(!s(this,cr))throw new Error("ACP session is not ready");return s(this,cr)},Bh=function(){if(!s(this,lr))throw new Error("ACP connection is not ready");return s(this,lr)},uS=function(){var r;const e=(r=s(this,Mn))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},Wh=function(){var r;if(s(this,hr)==="single_session")return h(this,O,tg).call(this,`${X6}-${(s(this,zn).clientGUID??"default-client").toLowerCase()}`);const e=(r=s(this,Et))==null?void 0:r.channelID;if(!e)throw new Error("Channel context is required for per-channel session mode");return h(this,O,eg).call(this,e)},eg=function(e){return h(this,O,tg).call(this,C5(s(this,hr),e,s(this,zn).clientGUID??"default-client"))},tg=function(e){var r;return((r=s(this,Mn))==null?void 0:r.sessionIdStrategy)==="deterministic"&&s(this,Fa)>0?`${e}:epoch-${s(this,Fa)}`:e},lu=new WeakMap,cu=new WeakMap,jh=function(){d(this,lr,null),d(this,Wi,null),d(this,On,null),d(this,Yr,null),d(this,cr,null),d(this,Nn,null),d(this,Mn,null),s(this,dr)&&(s(this,dr).removeEventListener("close",s(this,lu)),s(this,dr).removeEventListener("error",s(this,cu)),s(this,dr).close(),d(this,dr,null))},ba=function(e){const r=s(this,lr)!==null||s(this,Wi)!==null||s(this,On)!==null||s(this,Yr)!==null||s(this,cr)!==null||s(this,Nn)!==null||s(this,Mn)!==null||s(this,dr)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,O,Vs).call(this,"error"),h(this,O,jh).call(this),d(this,ar,e??null),h(this,O,Fr).call(this,"disconnected"))},ng=function(){const e=s(this,Xt).size>0;d(this,ur,null),d(this,Jr,null),d(this,qa,1),s(this,Xt).clear(),e&&this.dispatchEvent(new bm("messages-changed"))},hS=function(){return this.status==="disconnected"};function k5(){const n=new Map;return{getActualSessionId(t){return n.get(t)??null},setActualSessionId(t,e){n.set(t,e)},clearActualSessionId(t){n.delete(t)}}}function T5(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function C5(n,t,e){return n==="single_session"?`${X6}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function dS(n){return n.replace(/^(?:\s*\n)+/,"")}function D2(n){let t=n;return t=t.replace(m5,""),t=t.replace(g5,""),t=t.replace(v5,""),t=dS(t),t}function R5(n){let t=n;return t=t.replace(b5,""),t=dS(t),t}function L2(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function I5(n){const t=n.createSocket(L5(n.serverURL,n.token));let e=!1,r,i;const o=new Promise((u,p)=>{r=u,i=p}),a=new ReadableStream({start(u){let p=!1;const f=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=_=>{const x=D5(_);if(!x)return;let Z;try{Z=JSON.parse(x)}catch(L){const z=L instanceof Error?L:new Error(String(L));i(z),u.error(z);return}switch(Z.type){case"acp-bridge-status":if(Z.status==="ready"){let L;try{L=$5(Z)}catch(z){const P=z instanceof Error?z:new Error(String(z));e||i(P),u.error(P);return}e||(e=!0,r(L));return}if(Z.status==="error"||Z.status==="exited"){const L=new Error(Z.error??`ACP bridge ${Z.status}`);e||i(L),u.error(L)}return;case"acp-bridge-message":u.enqueue(Z.message);return}},v=()=>{var x;if(p)return;p=!0;const _=new Error("ACP bridge websocket closed");e||i(_),(x=n.onDisconnect)==null||x.call(n,_),u.close()},S=()=>{var x;if(p)return;p=!0;const _=new Error("ACP bridge websocket error");e||i(_),(x=n.onDisconnect)==null||x.call(n,_),u.error(_)};t.addEventListener("open",f),t.addEventListener("message",y),t.addEventListener("close",v),t.addEventListener("error",S)}}),l=new WritableStream({async write(u){await o,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await o;return{stream:{readable:a,writable:l},socket:t,metadata:c}}function $5(n){const{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i}=n;if((t==="openclaw"||t==="hermes")&&(e==="deterministic"||e==="mapped")&&typeof r=="string"&&r.length>0&&x5(i))return{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function x5(n){return Array.isArray(n)&&n.every(t=>typeof t=="string")}function P5(n){return w5.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function D5(n){if(typeof n=="string")return n;if(n instanceof Uint8Array)return new TextDecoder().decode(n);if(typeof Buffer<"u"&&n instanceof Buffer)return n.toString("utf8");if(typeof n=="object"&&n!==null&&"data"in n){const t=n.data;if(typeof t=="string")return t;if(t instanceof Uint8Array)return new TextDecoder().decode(t);if(Array.isArray(t))return Buffer.concat(t).toString("utf8")}return null}function L5(n,t){const e=new URL(n);return e.protocol=e.protocol==="https:"?"wss:":"ws:",e.pathname="/acp",e.search="",e.searchParams.set("token",t),e.hash="",e.toString()}function Em(n){return n instanceof Error?n.message:String(n)}const O2="television.acpClientGUID",M2="television.acpMappedSessions",N2=1;var Ba;class O5{constructor(){m(this,Ba,new Map)}getActualSessionId(t){return s(this,Ba).get(t)??null}setActualSessionId(t,e){s(this,Ba).set(t,e)}clearActualSessionId(t){s(this,Ba).delete(t)}}Ba=new WeakMap;var Wa,uu,sn,Gh,Yh,rg;class M5{constructor(t,e){m(this,sn);m(this,Wa);m(this,uu);d(this,Wa,t),d(this,uu,e)}getActualSessionId(t){const e=h(this,sn,Yh).call(this)[h(this,sn,Gh).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,sn,Yh).call(this);r[h(this,sn,Gh).call(this,t)]=e,h(this,sn,rg).call(this,r)}clearActualSessionId(t){const e=h(this,sn,Yh).call(this);delete e[h(this,sn,Gh).call(this,t)],h(this,sn,rg).call(this,e)}}Wa=new WeakMap,uu=new WeakMap,sn=new WeakSet,Gh=function(t){return JSON.stringify([s(this,uu),t])},Yh=function(){const t=s(this,Wa).getItem(M2);if(!t)return{};let e;try{e=JSON.parse(t)}catch{return{}}if(typeof e!="object"||e===null||Array.isArray(e))return{};const r=e;return r.version!==N2?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},rg=function(t){const e={version:N2,entries:t};s(this,Wa).setItem(M2,JSON.stringify(e))};function pS(){return typeof window>"u"?null:window.localStorage}function N5(n){const t=n.getItem(O2);if(t)return t;const e=U1().toLowerCase();return n.setItem(O2,e),e}const z2=4401,z5=401,Ph=1e3,H5=3e4;class Kh extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class Z5 extends Ti{constructor(e){var a,l;super();I(this,"url");I(this,"name");I(this,"telemetryMeta");I(this,"status","unauthorized");I(this,"channels",new Map);I(this,"client");I(this,"acpClient");I(this,"_token");I(this,"attempting",!1);I(this,"nextRetryAt",null);I(this,"hasEverConnected",!1);I(this,"browserDemoMode",!1);I(this,"hasAuthRejected",!1);I(this,"hasAuthTokenRejected",!1);I(this,"bootState","pending");I(this,"serverVersion",null);I(this,"updateState",null);I(this,"decideBoot");I(this,"navigationPending");I(this,"createSocket");I(this,"createClient");I(this,"socket",null);I(this,"connectAttempt",0);I(this,"autoReconnect",!1);I(this,"retryTimer",null);I(this,"retryDelay",Ph);I(this,"visibilityEventTarget");I(this,"networkEventTarget");I(this,"onVisibilityChange");I(this,"onNetworkOnline");I(this,"telemetryActivityAgent");this.url=Es(e.url),this.name=e.name,this.decideBoot=e.decideBoot??null,this.navigationPending=e.navigationPending??(()=>!1),this._token=e.token??null,this.telemetryMeta=e.telemetryMeta??null,this.createSocket=e.createSocket??(c=>new WebSocket(c)),this.createClient=e.createClient??((c,u,p)=>new sk(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...p?{telemetryMeta:p}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new M5(e.acpStorage,this.url):new O5);this.acpClient=new E5({serverURL:this.url,token:this._token??"",...e.createACPSocket?{createSocket:e.createACPSocket}:e.createSocket?{createSocket:e.createSocket}:{},...e.clientGUID?{clientGUID:e.clientGUID}:{},mappedSessionStore:r}),this.visibilityEventTarget=e.visibilityEventTarget!==void 0?e.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=e.networkEventTarget!==void 0?e.networkEventTarget:typeof window<"u"?window:null,this.onVisibilityChange=()=>{this.isPageVisible()&&this.kickReconnect()},this.onNetworkOnline=()=>{this.kickReconnect()},(a=this.visibilityEventTarget)==null||a.addEventListener("visibilitychange",this.onVisibilityChange),(l=this.networkEventTarget)==null||l.addEventListener("online",this.onNetworkOnline);const i=e.telemetryDocumentTarget!==void 0?e.telemetryDocumentTarget:typeof document<"u"?document:null,o=e.telemetryWindowTarget!==void 0?e.telemetryWindowTarget:typeof window<"u"?window:null;this.telemetryActivityAgent=this.telemetryMeta&&i&&o?WI({meta:this.telemetryMeta,documentTarget:i,windowTarget:o,send:c=>this.sendTelemetryActivity(c)}):null}get token(){return this._token}clearToken(){this._token=null,this.acpClient.setToken(null),this.client=this.createClient(this.url,null,this.telemetryMeta)}async connect(e){this._token=e,this.hasAuthRejected=!1,this.hasAuthTokenRejected=!1,this.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=Ph,this.autoReconnect=!0,await this.attempt()}dispose(){var e,r,i,o;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(e=this.socket)==null||e.close(),this.socket=null,this.setStatus("unauthorized"),(r=this.visibilityEventTarget)==null||r.removeEventListener("visibilitychange",this.onVisibilityChange),(i=this.networkEventTarget)==null||i.removeEventListener("online",this.onNetworkOnline),(o=this.telemetryActivityAgent)==null||o.stop(),this.acpClient.dispose()}getViewURL(e){const r=Td(e,this.renderOptions());return wi()?new URL(r.viewURL,this.url).toString():r.renderer==="proxy-iframe"?new URL(r.viewURL,this.url).toString():r.viewURL}async readDemoMode(){try{return await this.client.demoMode()}catch{return null}}renderOptions(){return{electron:wi(),browserDemo:this.browserDemoMode}}getContentURL(e){const r=Td(e,this.renderOptions()).contentURL;return r===null?null:new URL(r,this.url).toString()}async createChannel(e){const{channel:r}=await this.client.channels.create({name:e});return this.channels.set(r.id,structuredClone(r)),r}applyServerEvent(e){switch(e.type){case"channel-created":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Sc("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new Sc("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new Sc("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!FE(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...g8},size:{...v8}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=zm(r.layout,e.artifactID));break}case"artifact-updated":case"artifact-content-changed":case"channel-changed":case"pinned-channels-changed":case"theme-changed":case"appearance-changed":case"artifact-focus":break;default:return U5(e,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1,this.bootState="pending";const e=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token,this.telemetryMeta),this.setStatus("disconnected"),this.dispatchEvent(new Bt("change"));const r=this.createSocket(F5(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((o,a)=>{let l=!1;const c=()=>{var f;l||this.connectAttempt!==e||(l=!0,this.retryDelay=Ph,this.hasEverConnected=!0,this.setStatus("connected"),(f=this.telemetryActivityAgent)==null||f.start(),o())},u=f=>{l||this.connectAttempt!==e||(l=!0,a(f))},p=async()=>{const f=this.hasEverConnected;try{const[{channels:y},v,S]=await Promise.all([this.client.channels.list(),this.client.display.get(),f?null:this.readDemoMode()]);f||(this.browserDemoMode=(S==null?void 0:S.browserExternalPages)===!0),this.channels=new Map(y.map(_=>[_.id,structuredClone(_)])),this.acpClient.setEnabled(v.acpEnabled),this.dispatchEvent(new Bt("change")),f&&this.dispatchEvent(new Sc("channels-changed")),this.dispatchEvent(new Fh("server-event",{serverURL:this.url,event:{type:"channel-changed",channelID:v.focusedChannelId}})),this.dispatchEvent(new Fh("server-event",{serverURL:this.url,event:{type:"pinned-channels-changed",pinnedChannelIds:[...v.pinnedChannelIds]}})),c(),f&&this.connectAttempt===e&&this.dispatchEvent(new R8("server-reconnected",{serverURL:this.url}))}catch(y){if(G5(y)){u(new Kh);return}u(y instanceof Error?y:new Error(String(y)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||p())}),r.addEventListener("message",f=>{const y=j5(f);if(!y)return;if(y.type==="server-status"){const S=y;this.serverVersion=S.version,this.updateState=S.update??null;let _=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(S)==="boot"?(this.bootState="booted",_=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new I8("server-status",{serverURL:this.url,message:S})),_?this.navigationPending()||p():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new Bt("change"));return}if(!W5(y.type))return;const v=y;this.applyServerEvent(v),this.dispatchEvent(new Fh("server-event",{serverURL:this.url,event:v}))}),r.addEventListener("close",f=>{if(this.connectAttempt!==e)return;this.socket=null;const y=q5(f);if(!l){u(y===z2?new Kh:new Error("Connection closed before initialization"));return}if(y===z2){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){this.handleTransportFailure(new Error("WebSocket error"));return}u(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},o=>{throw this.attempting=!1,this.handleAttemptFailure(o),o})}handleAuthRejected(){this.hasAuthRejected=!0,this.hasAuthTokenRejected=this._token!==null,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof Kh){this.handleAuthRejected();return}this.autoReconnect&&this.scheduleRetry()}handleTransportFailure(e){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const e=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,H5),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new Bt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new Bt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=Ph,this.attempt().catch(()=>{})))}sendTelemetryActivity(e){var r;this.status==="connected"&&((r=this.socket)==null||r.send(JSON.stringify(e)))}sendTelemetrySignal(e,r){var o;if(!this.telemetryMeta||this.status!=="connected"&&this.bootState!=="halted")return;const i={type:UE,clientId:this.telemetryMeta.clientId,event:e,properties:r};(o=this.socket)==null||o.send(JSON.stringify(i))}setStatus(e){this.status!==e&&(this.status=e,this.dispatchEvent(new Bt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function U5(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function F5(n,t,e=null){const r=new URL(n);if(r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname="/events",r.search="",t&&r.searchParams.set("token",t),e)for(const[i,o]of BI(e))r.searchParams.set(i,o);return r.hash="",r.toString()}function q5(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const V5={"artifact-created":!0,"artifact-updated":!0,"artifact-content-changed":!0,"artifact-removed":!0,"channel-created":!0,"channel-updated":!0,"channel-removed":!0,"channel-changed":!0,"pinned-channels-changed":!0,"theme-changed":!0,"appearance-changed":!0,"artifact-focus":!0},B5=new Set(Object.keys(V5));function W5(n){return B5.has(n)}function j5(n){const t=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!t)return null;let e;try{e=JSON.parse(t)}catch{return null}return typeof e!="object"||e===null||!("type"in e)||typeof e.type!="string"?null:e}function G5(n){return n instanceof jl&&n.status===z5}const Y5="Local";var mn,Hn,$r,ig,sg,fS,hu,du,pu,fu,mu;class K5 extends Ti{constructor(e){super();m(this,$r);I(this,"connection");I(this,"clientGUID");I(this,"acpStorage");I(this,"connectError",null);m(this,mn);m(this,Hn,!1);m(this,hu,()=>{s(this,Hn)||(h(this,$r,fS).call(this),this.dispatchEvent(new Bt("change")))});m(this,du,e=>{s(this,Hn)||this.dispatchEvent(new Fh("server-event",{serverURL:e.serverURL,event:e.event}))});m(this,pu,()=>{s(this,Hn)||this.dispatchEvent(new Sc("channels-changed"))});m(this,fu,e=>{s(this,Hn)||this.dispatchEvent(new R8("server-reconnected",{serverURL:e.serverURL}))});m(this,mu,e=>{s(this,Hn)||this.dispatchEvent(new I8("server-status",{serverURL:e.serverURL,message:e.message}))});d(this,mn,e.localStore),this.acpStorage=e.acpStorage===void 0?pS():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?N5(this.acpStorage):U1().toLowerCase());const r=Es(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&s(this,mn).set(s2(s(this,mn).get(),r,e.launchToken));const i=e.launchToken??i2(s(this,mn).get(),r),o=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new Z5(l));this.connection=a({url:r,name:e.connectionName??Y5,token:i,createSocket:o,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:e.telemetryMeta??null,decideBoot:e.decideBoot,navigationPending:e.navigationPending}),this.connection.addEventListener("change",s(this,hu)),this.connection.addEventListener("server-event",s(this,du)),this.connection.addEventListener("channels-changed",s(this,pu)),this.connection.addEventListener("server-reconnected",s(this,fu)),this.connection.addEventListener("server-status",s(this,mu))}get storedAuthToken(){return i2(s(this,mn).get(),this.connection.url)}async connect(){await h(this,$r,ig).call(this,this.connection.token)}async authenticate(e){s(this,mn).set(s2(s(this,mn).get(),this.connection.url,e)),await h(this,$r,ig).call(this,e)}dispose(){s(this,Hn)||(d(this,Hn,!0),this.connection.removeEventListener("change",s(this,hu)),this.connection.removeEventListener("server-event",s(this,du)),this.connection.removeEventListener("channels-changed",s(this,pu)),this.connection.removeEventListener("server-reconnected",s(this,fu)),this.connection.removeEventListener("server-status",s(this,mu)),this.connection.dispose())}}mn=new WeakMap,Hn=new WeakMap,$r=new WeakSet,ig=async function(e){if(!s(this,Hn)){h(this,$r,sg).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,$r,sg).call(this,r instanceof Kh?null:r instanceof Error?r.message:String(r))}}},sg=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new Bt("change")))},fS=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=s(this,mn).get(),r=Mk(e,this.connection.url);r!==e&&s(this,mn).set(r),this.connection.token!==null&&this.connection.clearToken()},hu=new WeakMap,du=new WeakMap,pu=new WeakMap,fu=new WeakMap,mu=new WeakMap;const og="tv-nav:",zl="tv-reload",H2=100,J5=1e3,X5=60,Q5=60,eD=24,tD=30,nD=tD*eD*Q5*X5*J5;function bi(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(zl);return t.searchParams.delete(zl),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var gu,ja,$e,Ce,ho,Xe,mS,Mi,gS,ag,lg;class rD extends Ti{constructor(e,r){super();m(this,Xe);m(this,gu);m(this,ja);m(this,$e,[]);m(this,Ce,-1);m(this,ho,0);d(this,gu,e),d(this,ja,bi(r)),h(this,Xe,mS).call(this)}get currentURL(){var e;return s(this,Ce)===-1?null:((e=s(this,$e)[s(this,Ce)])==null?void 0:e.url)??null}get canGoBack(){return s(this,Ce)>-1}get canGoForward(){return s(this,Ce)<s(this,$e).length-1}get entries(){return s(this,$e).map(e=>({...e}))}get cursor(){return s(this,Ce)}navigate(e){const r=bi(e);if(r===s(this,ja)){if(s(this,Ce)===-1)return;d(this,Ce,-1),h(this,Xe,Mi).call(this);return}s(this,Ce)<s(this,$e).length-1&&d(this,$e,s(this,$e).slice(0,s(this,Ce)+1)),s(this,$e).push({url:r}),d(this,Ce,s(this,$e).length-1),h(this,Xe,ag).call(this),h(this,Xe,Mi).call(this)}replace(e){var i;if(s(this,Ce)===-1){this.navigate(e);return}const r=bi(e);if(r===s(this,ja)){d(this,$e,s(this,$e).filter((o,a)=>a!==s(this,Ce))),d(this,Ce,-1),h(this,Xe,Mi).call(this);return}((i=s(this,$e)[s(this,Ce)])==null?void 0:i.url)!==r&&(d(this,$e,s(this,$e).map((o,a)=>a===s(this,Ce)?{url:r}:o)),h(this,Xe,Mi).call(this))}back(){s(this,Ce)!==-1&&(d(this,Ce,s(this,Ce)-1),h(this,Xe,Mi).call(this))}forward(){this.canGoForward&&(d(this,Ce,s(this,Ce)+1),h(this,Xe,Mi).call(this))}reset(){s(this,Ce)===-1&&s(this,$e).length===0||(d(this,$e,[]),d(this,Ce,-1),h(this,Xe,Mi).call(this))}}gu=new WeakMap,ja=new WeakMap,$e=new WeakMap,Ce=new WeakMap,ho=new WeakMap,Xe=new WeakSet,mS=function(){const e=localStorage.getItem(s(this,Xe,lg));if(e!==null)try{const r=JSON.parse(e);if(!vS(r))return;d(this,$e,r.entries.map(i=>({url:i.url}))),d(this,Ce,r.cursor),d(this,ho,r.lastWritten),h(this,Xe,ag).call(this)}catch{d(this,$e,[]),d(this,Ce,-1),d(this,ho,0)}},Mi=function(){d(this,ho,Date.now());try{localStorage.setItem(s(this,Xe,lg),JSON.stringify(h(this,Xe,gS).call(this)))}catch(e){if(!oD(e))throw e}this.dispatchEvent(new Bt("change"))},gS=function(){return{v:1,entries:s(this,$e).map(e=>({...e})),cursor:s(this,Ce),lastWritten:s(this,ho)}},ag=function(){if(s(this,$e).length<=H2)return;const e=s(this,$e).length-H2;d(this,$e,s(this,$e).slice(e)),d(this,Ce,Math.max(-1,s(this,Ce)-e))},lg=function(){return iD(s(this,gu))};function iD(n){return`${og}${n}`}function sD(n){const t=Date.now()-nD,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(og)))continue;const o=i.slice(og.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!vS(l)){e.push(i);continue}!n.has(o)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function oD(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function vS(n){if(typeof n!="object"||n===null)return!1;const t=n;if(t.v!==1||!Array.isArray(t.entries))return!1;const e=t.cursor;return typeof e!="number"||!Number.isInteger(e)||typeof t.lastWritten!="number"||!Number.isFinite(t.lastWritten)||e<-1||e>=t.entries.length?!1:t.entries.every(r=>typeof r=="object"&&r!==null&&typeof r.url=="string")}const km="tv-channel-sidebar-collapsed";var po;class aD{constructor(t){m(this,po);d(this,po,t)}read(){return s(this,po).getItem(km)==="true"}setCollapsed(t){try{t?s(this,po).setItem(km,"true"):s(this,po).removeItem(km)}catch{}}}po=new WeakMap;const Tm="tv-channel-sidebar-width",cg=160,ug=350,Dh=260,lD=/^-?\d+$/;var fo;class cD{constructor(t){m(this,fo);d(this,fo,t)}read(){const t=s(this,fo).getItem(Tm);if(t===null||!lD.test(t))return null;const e=BigInt(t);return e<BigInt(cg)?cg:e>BigInt(ug)?ug:Number(e)}commit(t){const e=yS(Math.round(t));try{s(this,fo).setItem(Tm,String(e))}catch{}return e}clear(){try{s(this,fo).removeItem(Tm)}catch{}}}fo=new WeakMap;function yS(n){return Math.min(Math.max(n,cg),ug)}const uD="1.4.14";function J1(n=uD){return n!==void 0&&n.length>0?n:"0.0.0"}function X1(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const hg="tv-reload-attempted";function hD(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:lk(n.bundleVersion,n.serverVersion)?n.marker!==null&&n.marker.serverVersion===n.serverVersion?{action:"none"}:{action:"reload",marker:{serverVersion:n.serverVersion,fromVersion:n.bundleVersion}}:{action:"none"}:{action:"none"}}function dD(n){const t=n.getItem(hg);if(t===null)return null;let e;try{e=JSON.parse(t)}catch{return null}if(!e||typeof e!="object")return null;const r=e;return typeof r.serverVersion!="string"||typeof r.fromVersion!="string"?null:{serverVersion:r.serverVersion,fromVersion:r.fromVersion}}function pD(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??X1(),i=n.bundleVersion??J1();if(t===null)return{dispose(){}};let o=null;const a=()=>{if(o===null)return;const u=n.owner.connection;if(u.url!==n.primaryServerURL||u.status!=="connected")return;const p=o;o=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:p.fromVersion,to_version:p.toVersion})},l=u=>{if(r.pending)return;const p=hD({bundleVersion:i,serverVersion:u.message.version,originMatch:u.serverURL===n.primaryServerURL,marker:dD(t)});switch(p.action){case"reload":t.setItem(hg,JSON.stringify(p.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(hg),o={fromVersion:p.fromVersion,toVersion:p.toVersion},a();return;case"none":return}},c=()=>{a()};return n.owner.addEventListener("server-status",l),n.owner.addEventListener("change",c),{dispose(){n.owner.removeEventListener("server-status",l),n.owner.removeEventListener("change",c)}}}function fD(n){const t=wi(n.search),e=m6(n.search),r=e!==null&&Op(e)?e:null;return{electron:t,shellVersion:r}}function mD(n){return!n.electron||n.requiredDesktopVersion===null||!Op(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===bd?!1:Z1(n.requiredDesktopVersion,n.shellVersion)}const gD=`# Desktop app update required
|
|
44
44
|
|
|
45
45
|
This version of the Television desktop app does not work with this server and needs to be updated. The new version has already downloaded and installs when you restart the app.`,vD=`# Desktop app update required
|
|
46
46
|
|
package/dist/web/index.html
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
|
41
41
|
<link rel="icon" type="image/svg+xml" href="./assets/favicon-DaYMFRha.svg" />
|
|
42
42
|
<title>Television</title>
|
|
43
|
-
<script type="module" crossorigin src="./assets/main-
|
|
43
|
+
<script type="module" crossorigin src="./assets/main-nG2AR2Sh.js"></script>
|
|
44
44
|
<link rel="modulepreload" crossorigin href="./assets/artifact-bridge-BEUWXKq7.js">
|
|
45
45
|
<link rel="modulepreload" crossorigin href="./assets/missing-artifact-page-DVzJ41AE.js">
|
|
46
46
|
<link rel="stylesheet" crossorigin href="./assets/main-FbuXtkKu.css">
|
package/package.json
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telepath-computer/television",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.14",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/telepath-computer/television.git",
|
|
8
|
+
"directory": "packages/cli"
|
|
9
|
+
},
|
|
5
10
|
"engines": {
|
|
6
11
|
"node": ">=22.12.0"
|
|
7
12
|
},
|