@telepath-computer/television 1.5.5 → 1.5.7
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
|
@@ -54288,7 +54288,7 @@ function disabledTelemetryRuntime() {
|
|
|
54288
54288
|
|
|
54289
54289
|
// ../server/src/updates/version.ts
|
|
54290
54290
|
function readVersionStamp() {
|
|
54291
|
-
if ("1.5.
|
|
54291
|
+
if ("1.5.7".length > 0) return "1.5.7";
|
|
54292
54292
|
return void 0;
|
|
54293
54293
|
}
|
|
54294
54294
|
function resolveUpdateReleaseVersion(env = process.env, stamp = readVersionStamp()) {
|
|
@@ -56712,8 +56712,8 @@ var Server = class {
|
|
|
56712
56712
|
};
|
|
56713
56713
|
};
|
|
56714
56714
|
function readServerPackageVersion() {
|
|
56715
|
-
if ("1.5.
|
|
56716
|
-
return telemetryVersion("1.5.
|
|
56715
|
+
if ("1.5.7".length > 0) {
|
|
56716
|
+
return telemetryVersion("1.5.7");
|
|
56717
56717
|
}
|
|
56718
56718
|
const packageJsonPath = import_node_path17.default.resolve(import_node_path17.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)), "..", "package.json");
|
|
56719
56719
|
if (!(0, import_node_fs13.existsSync)(packageJsonPath)) return telemetryVersion("0.0.0");
|
|
@@ -59344,8 +59344,8 @@ function resolveVercelSkillsInstallerBin() {
|
|
|
59344
59344
|
return localRequire.resolve("skills/bin/cli.mjs");
|
|
59345
59345
|
}
|
|
59346
59346
|
function readCLIVersion() {
|
|
59347
|
-
if ("1.5.
|
|
59348
|
-
return "1.5.
|
|
59347
|
+
if ("1.5.7".length > 0) {
|
|
59348
|
+
return "1.5.7";
|
|
59349
59349
|
}
|
|
59350
59350
|
const devPackageJsonPath = import_node_path24.default.join(getDevPackageDir(), "package.json");
|
|
59351
59351
|
if (!(0, import_node_fs20.existsSync)(devPackageJsonPath)) {
|
|
@@ -62,7 +62,7 @@ var E4=Object.defineProperty;var Uv=n=>{throw TypeError(n)};var k4=(n,t,e)=>t in
|
|
|
62
62
|
`)}v.write("payload.value = newResult;"),v.write("return payload;");const O=v.compile();return(P,V)=>O(y,P,V)};let s;const a=tu,l=!Q8.jitless,u=l&&xT.value,f=t.catchall;let p;n._zod.parse=(y,v)=>{p??(p=r.value);const S=y.value;return a(S)?l&&u&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(s||(s=i(t.shape)),y=s(y,v),f?g6([],S,y,v,p,n):y):e(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:S,inst:n}),y)}});function k2(n,t,e,r){for(const s of n)if(s.issues.length===0)return t.value=s.value,t;const i=n.filter(s=>!Na(s));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(s=>s.issues.map(a=>Is(a,r,Rs())))}),t)}const v6=$("$ZodUnion",(n,t)=>{Fe.init(n,t),ke(n._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ke(n._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ke(n._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),ke(n._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${i.map(s=>nv(s.source)).join("|")})$`)}});const e=t.options.length===1,r=t.options[0]._zod.run;n._zod.parse=(i,s)=>{if(e)return r(i,s);let a=!1;const l=[];for(const c of t.options){const u=c._zod.run({value:i.value,issues:[]},s);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=>k2(c,i,n,s)):k2(l,i,n,s)}}),vR=$("$ZodDiscriminatedUnion",(n,t)=>{t.inclusive=!1,v6.init(n,t);const e=n._zod.parse;ke(n._zod,"propValues",()=>{const i={};for(const s of t.options){const a=s._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);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=Vf(()=>{var a;const i=t.options,s=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(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,l)}}return s});n._zod.parse=(i,s)=>{const a=i.value;if(!tu(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,s):t.unionFallback?e(i,s):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:n}),i)}}),yR=$("$ZodIntersection",(n,t)=>{Fe.init(n,t),n._zod.parse=(e,r)=>{const i=e.value,s=t.left._zod.run({value:i,issues:[]},r),a=t.right._zod.run({value:i,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([c,u])=>T2(e,c,u)):T2(e,s,a)}});function ng(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(ql(n)&&ql(t)){const e=Object.keys(t),r=Object.keys(n).filter(s=>e.indexOf(s)!==-1),i={...n,...t};for(const s of r){const a=ng(n[s],t[s]);if(!a.valid)return{valid:!1,mergeErrorPath:[s,...a.mergeErrorPath]};i[s]=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],s=t[r],a=ng(i,s);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};e.push(a.data)}return{valid:!0,data:e}}return{valid:!1,mergeErrorPath:[]}}function T2(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 s=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(s.length&&i&&n.issues.push({...i,keys:s}),Na(n))return n;const a=ng(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 wR=$("$ZodRecord",(n,t)=>{Fe.init(n,t),n._zod.parse=(e,r)=>{const i=e.value;if(!ql(i))return e.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),e;const s=[],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 f=t.valueType._zod.run({value:i[u],issues:[]},r);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&e.issues.push(...za(u,p.issues)),e.value[u]=p.value})):(f.issues.length&&e.issues.push(...za(u,f.issues)),e.value[u]=f.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"&&c6.test(l)&&c.issues.length){const p=t.keyType._zod.run({value:Number(l),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?e.value[l]=i[l]:e.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>Is(p,r,Rs())),input:l,path:[l],inst:n});continue}const f=t.valueType._zod.run({value:i[l],issues:[]},r);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&e.issues.push(...za(l,p.issues)),e.value[c.value]=p.value})):(f.issues.length&&e.issues.push(...za(l,f.issues)),e.value[c.value]=f.value)}}return s.length?Promise.all(s).then(()=>e):e}}),bR=$("$ZodEnum",(n,t)=>{Fe.init(n,t);const e=e6(t.entries),r=new Set(e);n._zod.values=r,n._zod.pattern=new RegExp(`^(${e.filter(i=>PT.has(typeof i)).map(i=>typeof i=="string"?Vl(i):i.toString()).join("|")})$`),n._zod.parse=(i,s)=>{const a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:e,input:a,inst:n}),i}}),SR=$("$ZodLiteral",(n,t)=>{if(Fe.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"?Vl(r):r?Vl(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const s=r.value;return e.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:n}),r}}),_R=$("$ZodTransform",(n,t)=>{Fe.init(n,t),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new X8(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 Ua;return e.value=i,e}});function C2(n,t){return n.issues.length&&t===void 0?{issues:[],value:void 0}:n}const y6=$("$ZodOptional",(n,t)=>{Fe.init(n,t),n._zod.optin="optional",n._zod.optout="optional",ke(n._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ke(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${nv(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(s=>C2(s,e.value)):C2(i,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,r)}}),AR=$("$ZodExactOptional",(n,t)=>{y6.init(n,t),ke(n._zod,"values",()=>t.innerType._zod.values),ke(n._zod,"pattern",()=>t.innerType._zod.pattern),n._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),ER=$("$ZodNullable",(n,t)=>{Fe.init(n,t),ke(n._zod,"optin",()=>t.innerType._zod.optin),ke(n._zod,"optout",()=>t.innerType._zod.optout),ke(n._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${nv(e.source)}|null)$`):void 0}),ke(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)}),kR=$("$ZodDefault",(n,t)=>{Fe.init(n,t),n._zod.optin="optional",ke(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(s=>R2(s,t)):R2(i,t)}});function R2(n,t){return n.value===void 0&&(n.value=t.defaultValue),n}const TR=$("$ZodPrefault",(n,t)=>{Fe.init(n,t),n._zod.optin="optional",ke(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))}),CR=$("$ZodNonOptional",(n,t)=>{Fe.init(n,t),ke(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(s=>I2(s,n)):I2(i,n)}});function I2(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 RR=$("$ZodCatch",(n,t)=>{Fe.init(n,t),ke(n._zod,"optin",()=>t.innerType._zod.optin),ke(n._zod,"optout",()=>t.innerType._zod.optout),ke(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(s=>(e.value=s.value,s.issues.length&&(e.value=t.catchValue({...e,error:{issues:s.issues.map(a=>Is(a,r,Rs()))},input:e.value}),e.issues=[]),e)):(e.value=i.value,i.issues.length&&(e.value=t.catchValue({...e,error:{issues:i.issues.map(s=>Is(s,r,Rs()))},input:e.value}),e.issues=[]),e)}}),IR=$("$ZodPipe",(n,t)=>{Fe.init(n,t),ke(n._zod,"values",()=>t.in._zod.values),ke(n._zod,"optin",()=>t.in._zod.optin),ke(n._zod,"optout",()=>t.out._zod.optout),ke(n._zod,"propValues",()=>t.in._zod.propValues),n._zod.parse=(e,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(e,r);return s instanceof Promise?s.then(a=>Uh(a,t.in,r)):Uh(s,t.in,r)}const i=t.in._zod.run(e,r);return i instanceof Promise?i.then(s=>Uh(s,t.out,r)):Uh(i,t.out,r)}});function Uh(n,t,e){return n.issues.length?(n.aborted=!0,n):t._zod.run({value:n.value,issues:n.issues},e)}const $R=$("$ZodReadonly",(n,t)=>{Fe.init(n,t),ke(n._zod,"propValues",()=>t.innerType._zod.propValues),ke(n._zod,"values",()=>t.innerType._zod.values),ke(n._zod,"optin",()=>{var e,r;return(r=(e=t.innerType)==null?void 0:e._zod)==null?void 0:r.optin}),ke(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($2):$2(i)}});function $2(n){return n.value=Object.freeze(n.value),n}const xR=$("$ZodCustom",(n,t)=>{Jt.init(n,t),Fe.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(s=>x2(s,e,r,n));x2(i,e,r,n)}});function x2(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(nu(i))}}var P2;class PR{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 DR(){return new PR}(P2=globalThis).__zod_globalRegistry??(P2.__zod_globalRegistry=DR());const xc=globalThis.__zod_globalRegistry;function OR(n,t){return new n({type:"string",...J(t)})}function LR(n,t){return new n({type:"string",format:"email",check:"string_format",abort:!1,...J(t)})}function D2(n,t){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...J(t)})}function MR(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...J(t)})}function NR(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...J(t)})}function zR(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...J(t)})}function HR(n,t){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...J(t)})}function ZR(n,t){return new n({type:"string",format:"url",check:"string_format",abort:!1,...J(t)})}function UR(n,t){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...J(t)})}function FR(n,t){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...J(t)})}function qR(n,t){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...J(t)})}function VR(n,t){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...J(t)})}function BR(n,t){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...J(t)})}function jR(n,t){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...J(t)})}function WR(n,t){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...J(t)})}function GR(n,t){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...J(t)})}function JR(n,t){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...J(t)})}function YR(n,t){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...J(t)})}function KR(n,t){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...J(t)})}function XR(n,t){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...J(t)})}function QR(n,t){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...J(t)})}function e3(n,t){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...J(t)})}function t3(n,t){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...J(t)})}function n3(n,t){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...J(t)})}function r3(n,t){return new n({type:"string",format:"date",check:"string_format",...J(t)})}function i3(n,t){return new n({type:"string",format:"time",check:"string_format",precision:null,...J(t)})}function s3(n,t){return new n({type:"string",format:"duration",check:"string_format",...J(t)})}function o3(n,t){return new n({type:"number",checks:[],...J(t)})}function a3(n,t){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...J(t)})}function l3(n,t){return new n({type:"boolean",...J(t)})}function c3(n){return new n({type:"unknown"})}function u3(n,t){return new n({type:"never",...J(t)})}function O2(n,t){return new h6({check:"less_than",...J(t),value:n,inclusive:!1})}function Rm(n,t){return new h6({check:"less_than",...J(t),value:n,inclusive:!0})}function L2(n,t){return new d6({check:"greater_than",...J(t),value:n,inclusive:!1})}function Im(n,t){return new d6({check:"greater_than",...J(t),value:n,inclusive:!0})}function M2(n,t){return new kC({check:"multiple_of",...J(t),value:n})}function w6(n,t){return new CC({check:"max_length",...J(t),maximum:n})}function Od(n,t){return new RC({check:"min_length",...J(t),minimum:n})}function b6(n,t){return new IC({check:"length_equals",...J(t),length:n})}function h3(n,t){return new $C({check:"string_format",format:"regex",...J(t),pattern:n})}function d3(n){return new xC({check:"string_format",format:"lowercase",...J(n)})}function f3(n){return new PC({check:"string_format",format:"uppercase",...J(n)})}function p3(n,t){return new DC({check:"string_format",format:"includes",...J(t),includes:n})}function m3(n,t){return new OC({check:"string_format",format:"starts_with",...J(t),prefix:n})}function g3(n,t){return new LC({check:"string_format",format:"ends_with",...J(t),suffix:n})}function tc(n){return new MC({check:"overwrite",tx:n})}function v3(n){return tc(t=>t.normalize(n))}function y3(){return tc(n=>n.trim())}function w3(){return tc(n=>n.toLowerCase())}function b3(){return tc(n=>n.toUpperCase())}function S3(){return tc(n=>$T(n))}function _3(n,t,e){return new n({type:"array",element:t,...J(e)})}function A3(n,t,e){return new n({type:"custom",check:"custom",fn:t,...J(e)})}function E3(n){const t=k3(e=>(e.addIssue=r=>{if(typeof r=="string")e.issues.push(nu(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(nu(i))}},n(e.value,e)));return t}function k3(n,t){const e=new Jt({check:"custom",...J(t)});return e._zod.check=n,e}function S6(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)??xc,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 Xe(n,t,e={path:[],schemaPath:[]}){var f,p;var r;const i=n._zod.def,s=t.seen.get(n);if(s)return s.count++,e.schemaPath.includes(n)&&(s.cycle=e.path),s.schema;const a={schema:{},count:1,cycle:void 0,path:e.path};t.seen.set(n,a);const l=(p=(f=n._zod).toJSONSchema)==null?void 0:p.call(f);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),Xe(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"&&Et(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 _6(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 f of n.seen.entries()){const p=(a=n.metadataRegistry.get(f[0]))==null?void 0:a.id;if(p){const y=r.get(p);if(y&&y!==f[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(p,f[0])}}const i=f=>{var _;const p=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const I=(_=n.external.registry.get(f[0]))==null?void 0:_.id,Z=n.external.uri??(z=>z);if(I)return{ref:Z(I)};const O=f[1].defId??f[1].schema.id??`schema${n.counter++}`;return f[1].defId=O,{defId:O,ref:`${Z("__shared")}#/${p}/${O}`}}if(f[1]===e)return{ref:"#"};const v=`#/${p}/`,S=f[1].schema.id??`__schema${n.counter++}`;return{defId:S,ref:v+S}},s=f=>{if(f[1].schema.$ref)return;const p=f[1],{ref:y,defId:v}=i(f);p.def={...p.schema},v&&(p.defId=v);const S=p.schema;for(const _ in S)delete S[_];S.$ref=y};if(n.cycles==="throw")for(const f of n.seen.entries()){const p=f[1];if(p.cycle)throw new Error(`Cycle detected: #/${(l=p.cycle)==null?void 0:l.join("/")}/<root>
|
|
63
63
|
|
|
64
64
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of n.seen.entries()){const p=f[1];if(t===f[0]){s(f);continue}if(n.external){const v=(c=n.external.registry.get(f[0]))==null?void 0:c.id;if(t!==f[0]&&v){s(f);continue}}if((u=n.metadataRegistry.get(f[0]))==null?void 0:u.id){s(f);continue}if(p.cycle){s(f);continue}if(p.count>1&&n.reused==="ref"){s(f);continue}}}function A6(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 f=n.seen.get(u);if(f.ref===null)return;const p=f.def??f.schema,y={...p},v=f.ref;if(f.ref=null,v){r(v);const _=n.seen.get(v),I=_.schema;if(I.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(p.allOf=p.allOf??[],p.allOf.push(I)):Object.assign(p,I),Object.assign(p,y),u._zod.parent===v)for(const O in p)O==="$ref"||O==="allOf"||O in y||delete p[O];if(I.$ref&&_.def)for(const O in p)O==="$ref"||O==="allOf"||O in _.def&&JSON.stringify(p[O])===JSON.stringify(_.def[O])&&delete p[O]}const S=u._zod.parent;if(S&&S!==v){r(S);const _=n.seen.get(S);if(_!=null&&_.schema.$ref&&(p.$ref=_.schema.$ref,_.def))for(const I in p)I==="$ref"||I==="allOf"||I in _.def&&JSON.stringify(p[I])===JSON.stringify(_.def[I])&&delete p[I]}n.override({zodSchema:u,jsonSchema:p,path:f.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 s=((c=n.external)==null?void 0:c.defs)??{};for(const u of n.seen.entries()){const f=u[1];f.def&&f.defId&&(s[f.defId]=f.def)}n.external||Object.keys(s).length>0&&(n.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const u=JSON.parse(JSON.stringify(i));return Object.defineProperty(u,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ld(t,"input",n.processors),output:Ld(t,"output",n.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function Et(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 Et(r.element,e);if(r.type==="set")return Et(r.valueType,e);if(r.type==="lazy")return Et(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 Et(r.innerType,e);if(r.type==="intersection")return Et(r.left,e)||Et(r.right,e);if(r.type==="record"||r.type==="map")return Et(r.keyType,e)||Et(r.valueType,e);if(r.type==="pipe")return Et(r.in,e)||Et(r.out,e);if(r.type==="object"){for(const i in r.shape)if(Et(r.shape[i],e))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(Et(i,e))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(Et(i,e))return!0;return!!(r.rest&&Et(r.rest,e))}return!1}const T3=(n,t={})=>e=>{const r=S6({...e,processors:t});return Xe(n,r),_6(r,n),A6(r,n)},Ld=(n,t,e={})=>r=>{const{libraryOptions:i,target:s}=r??{},a=S6({...i??{},target:s,io:t,processors:e});return Xe(n,a),_6(a,n),A6(a,n)},C3={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},R3=(n,t,e,r)=>{const i=e;i.type="string";const{minimum:s,maximum:a,format:l,patterns:c,contentEncoding:u}=n._zod.bag;if(typeof s=="number"&&(i.minLength=s),typeof a=="number"&&(i.maxLength=a),l&&(i.format=C3[l]??l,i.format===""&&delete i.format,l==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){const f=[...c];f.length===1?i.pattern=f[0].source:f.length>1&&(i.allOf=[...f.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},I3=(n,t,e,r)=>{const i=e,{minimum:s,maximum:a,format:l,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:f}=n._zod.bag;typeof l=="string"&&l.includes("int")?i.type="integer":i.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=f,i.exclusiveMinimum=!0):i.exclusiveMinimum=f),typeof s=="number"&&(i.minimum=s,typeof f=="number"&&t.target!=="draft-04"&&(f>=s?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)},$3=(n,t,e,r)=>{e.type="boolean"},x3=(n,t,e,r)=>{e.not={}},P3=(n,t,e,r)=>{},D3=(n,t,e,r)=>{const i=n._zod.def,s=e6(i.entries);s.every(a=>typeof a=="number")&&(e.type="number"),s.every(a=>typeof a=="string")&&(e.type="string"),e.enum=s},O3=(n,t,e,r)=>{const i=n._zod.def,s=[];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");s.push(Number(a))}else s.push(a);if(s.length!==0)if(s.length===1){const a=s[0];e.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?e.enum=[a]:e.const=a}else s.every(a=>typeof a=="number")&&(e.type="number"),s.every(a=>typeof a=="string")&&(e.type="string"),s.every(a=>typeof a=="boolean")&&(e.type="boolean"),s.every(a=>a===null)&&(e.type="null"),e.enum=s},L3=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},M3=(n,t,e,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},N3=(n,t,e,r)=>{const i=e,s=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=Xe(s.element,t,{...r,path:[...r.path,"items"]})},z3=(n,t,e,r)=>{var u;const i=e,s=n._zod.def;i.type="object",i.properties={};const a=s.shape;for(const f in a)i.properties[f]=Xe(a[f],t,{...r,path:[...r.path,"properties",f]});const l=new Set(Object.keys(a)),c=new Set([...l].filter(f=>{const p=s.shape[f]._zod;return t.io==="input"?p.optin===void 0:p.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((u=s.catchall)==null?void 0:u._zod.def.type)==="never"?i.additionalProperties=!1:s.catchall?s.catchall&&(i.additionalProperties=Xe(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},H3=(n,t,e,r)=>{const i=n._zod.def,s=i.inclusive===!1,a=i.options.map((l,c)=>Xe(l,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?e.oneOf=a:e.anyOf=a},Z3=(n,t,e,r)=>{const i=n._zod.def,s=Xe(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Xe(i.right,t,{...r,path:[...r.path,"allOf",1]}),l=u=>"allOf"in u&&Object.keys(u).length===1,c=[...l(s)?s.allOf:[s],...l(a)?a.allOf:[a]];e.allOf=c},U3=(n,t,e,r)=>{const i=e,s=n._zod.def;i.type="object";const a=s.keyType,l=a._zod.bag,c=l==null?void 0:l.patterns;if(s.mode==="loose"&&c&&c.size>0){const f=Xe(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const p of c)i.patternProperties[p.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=Xe(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Xe(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=a._zod.values;if(u){const f=[...u].filter(p=>typeof p=="string"||typeof p=="number");f.length>0&&(i.required=f)}},F3=(n,t,e,r)=>{const i=n._zod.def,s=Xe(i.innerType,t,r),a=t.seen.get(n);t.target==="openapi-3.0"?(a.ref=i.innerType,e.nullable=!0):e.anyOf=[s,{type:"null"}]},q3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},V3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.default=JSON.parse(JSON.stringify(i.defaultValue))},B3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,t.io==="input"&&(e._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},j3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.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},W3=(n,t,e,r)=>{const i=n._zod.def,s=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Xe(s,t,r);const a=t.seen.get(n);a.ref=s},G3=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType,e.readOnly=!0},E6=(n,t,e,r)=>{const i=n._zod.def;Xe(i.innerType,t,r);const s=t.seen.get(n);s.ref=i.innerType},J3=$("ZodISODateTime",(n,t)=>{YC.init(n,t),Ve.init(n,t)});function Y3(n){return n3(J3,n)}const K3=$("ZodISODate",(n,t)=>{KC.init(n,t),Ve.init(n,t)});function X3(n){return r3(K3,n)}const Q3=$("ZodISOTime",(n,t)=>{XC.init(n,t),Ve.init(n,t)});function eI(n){return i3(Q3,n)}const tI=$("ZodISODuration",(n,t)=>{QC.init(n,t),Ve.init(n,t)});function nI(n){return s3(tI,n)}const k6=(n,t)=>{i6.init(n,t),n.name="ZodError",Object.defineProperties(n,{format:{value:e=>qT(n,e)},flatten:{value:e=>FT(n,e)},addIssue:{value:e=>{n.issues.push(e),n.message=JSON.stringify(n.issues,tg,2)}},addIssues:{value:e=>{n.issues.push(...e),n.message=JSON.stringify(n.issues,tg,2)}},isEmpty:{get(){return n.issues.length===0}}})},N2=$("ZodError",k6),xn=$("ZodError",k6,{Parent:Error}),rI=iv(xn),iI=sv(xn),sI=Bf(xn),oI=jf(xn),aI=jT(xn),lI=WT(xn),cI=GT(xn),uI=JT(xn),hI=YT(xn),dI=KT(xn),fI=XT(xn),pI=QT(xn),qe=$("ZodType",(n,t)=>(Fe.init(n,t),Object.assign(n["~standard"],{jsonSchema:{input:Ld(n,"input"),output:Ld(n,"output")}}),n.toJSONSchema=T3(n,{}),n.def=t,n.type=t.type,Object.defineProperty(n,"_def",{value:t}),n.check=(...e)=>n.clone(Ds(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)=>Os(n,e,r),n.brand=()=>n,n.register=((e,r)=>(e.add(n,r),n)),n.parse=(e,r)=>rI(n,e,r,{callee:n.parse}),n.safeParse=(e,r)=>sI(n,e,r),n.parseAsync=async(e,r)=>iI(n,e,r,{callee:n.parseAsync}),n.safeParseAsync=async(e,r)=>oI(n,e,r),n.spa=n.safeParseAsync,n.encode=(e,r)=>aI(n,e,r),n.decode=(e,r)=>lI(n,e,r),n.encodeAsync=async(e,r)=>cI(n,e,r),n.decodeAsync=async(e,r)=>uI(n,e,r),n.safeEncode=(e,r)=>hI(n,e,r),n.safeDecode=(e,r)=>dI(n,e,r),n.safeEncodeAsync=async(e,r)=>fI(n,e,r),n.safeDecodeAsync=async(e,r)=>pI(n,e,r),n.refine=(e,r)=>n.check(o$(e,r)),n.superRefine=e=>n.check(a$(e)),n.overwrite=e=>n.check(tc(e)),n.optional=()=>Z2(n),n.exactOptional=()=>WI(n),n.nullable=()=>U2(n),n.nullish=()=>Z2(U2(n)),n.nonoptional=e=>QI(n,e),n.array=()=>W(n),n.or=e=>le([n,e]),n.and=e=>Gf(n,e),n.transform=e=>F2(n,BI(e)),n.default=e=>YI(n,e),n.prefault=e=>XI(n,e),n.catch=e=>t$(n,e),n.pipe=e=>F2(n,e),n.readonly=()=>i$(n),n.describe=e=>{const r=n.clone();return xc.add(r,{description:e}),r},Object.defineProperty(n,"description",{get(){var e;return(e=xc.get(n))==null?void 0:e.description},configurable:!0}),n.meta=(...e)=>{if(e.length===0)return xc.get(n);const r=n.clone();return xc.add(r,e[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=e=>e(n),n)),T6=$("_ZodString",(n,t)=>{ov.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>R3(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(h3(...r)),n.includes=(...r)=>n.check(p3(...r)),n.startsWith=(...r)=>n.check(m3(...r)),n.endsWith=(...r)=>n.check(g3(...r)),n.min=(...r)=>n.check(Od(...r)),n.max=(...r)=>n.check(w6(...r)),n.length=(...r)=>n.check(b6(...r)),n.nonempty=(...r)=>n.check(Od(1,...r)),n.lowercase=r=>n.check(d3(r)),n.uppercase=r=>n.check(f3(r)),n.trim=()=>n.check(y3()),n.normalize=(...r)=>n.check(v3(...r)),n.toLowerCase=()=>n.check(w3()),n.toUpperCase=()=>n.check(b3()),n.slugify=()=>n.check(S3())}),mI=$("ZodString",(n,t)=>{ov.init(n,t),T6.init(n,t),n.email=e=>n.check(LR(gI,e)),n.url=e=>n.check(ZR(vI,e)),n.jwt=e=>n.check(t3(PI,e)),n.emoji=e=>n.check(UR(yI,e)),n.guid=e=>n.check(D2(z2,e)),n.uuid=e=>n.check(MR(Fh,e)),n.uuidv4=e=>n.check(NR(Fh,e)),n.uuidv6=e=>n.check(zR(Fh,e)),n.uuidv7=e=>n.check(HR(Fh,e)),n.nanoid=e=>n.check(FR(wI,e)),n.guid=e=>n.check(D2(z2,e)),n.cuid=e=>n.check(qR(bI,e)),n.cuid2=e=>n.check(VR(SI,e)),n.ulid=e=>n.check(BR(_I,e)),n.base64=e=>n.check(XR(II,e)),n.base64url=e=>n.check(QR($I,e)),n.xid=e=>n.check(jR(AI,e)),n.ksuid=e=>n.check(WR(EI,e)),n.ipv4=e=>n.check(GR(kI,e)),n.ipv6=e=>n.check(JR(TI,e)),n.cidrv4=e=>n.check(YR(CI,e)),n.cidrv6=e=>n.check(KR(RI,e)),n.e164=e=>n.check(e3(xI,e)),n.datetime=e=>n.check(Y3(e)),n.date=e=>n.check(X3(e)),n.time=e=>n.check(eI(e)),n.duration=e=>n.check(nI(e))});function g(n){return OR(mI,n)}const Ve=$("ZodStringFormat",(n,t)=>{ze.init(n,t),T6.init(n,t)}),gI=$("ZodEmail",(n,t)=>{UC.init(n,t),Ve.init(n,t)}),z2=$("ZodGUID",(n,t)=>{HC.init(n,t),Ve.init(n,t)}),Fh=$("ZodUUID",(n,t)=>{ZC.init(n,t),Ve.init(n,t)}),vI=$("ZodURL",(n,t)=>{FC.init(n,t),Ve.init(n,t)}),yI=$("ZodEmoji",(n,t)=>{qC.init(n,t),Ve.init(n,t)}),wI=$("ZodNanoID",(n,t)=>{VC.init(n,t),Ve.init(n,t)}),bI=$("ZodCUID",(n,t)=>{BC.init(n,t),Ve.init(n,t)}),SI=$("ZodCUID2",(n,t)=>{jC.init(n,t),Ve.init(n,t)}),_I=$("ZodULID",(n,t)=>{WC.init(n,t),Ve.init(n,t)}),AI=$("ZodXID",(n,t)=>{GC.init(n,t),Ve.init(n,t)}),EI=$("ZodKSUID",(n,t)=>{JC.init(n,t),Ve.init(n,t)}),kI=$("ZodIPv4",(n,t)=>{eR.init(n,t),Ve.init(n,t)}),TI=$("ZodIPv6",(n,t)=>{tR.init(n,t),Ve.init(n,t)}),CI=$("ZodCIDRv4",(n,t)=>{nR.init(n,t),Ve.init(n,t)}),RI=$("ZodCIDRv6",(n,t)=>{rR.init(n,t),Ve.init(n,t)}),II=$("ZodBase64",(n,t)=>{iR.init(n,t),Ve.init(n,t)}),$I=$("ZodBase64URL",(n,t)=>{oR.init(n,t),Ve.init(n,t)}),xI=$("ZodE164",(n,t)=>{aR.init(n,t),Ve.init(n,t)}),PI=$("ZodJWT",(n,t)=>{cR.init(n,t),Ve.init(n,t)}),C6=$("ZodNumber",(n,t)=>{p6.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>I3(n,r,i),n.gt=(r,i)=>n.check(L2(r,i)),n.gte=(r,i)=>n.check(Im(r,i)),n.min=(r,i)=>n.check(Im(r,i)),n.lt=(r,i)=>n.check(O2(r,i)),n.lte=(r,i)=>n.check(Rm(r,i)),n.max=(r,i)=>n.check(Rm(r,i)),n.int=r=>n.check(H2(r)),n.safe=r=>n.check(H2(r)),n.positive=r=>n.check(L2(0,r)),n.nonnegative=r=>n.check(Im(0,r)),n.negative=r=>n.check(O2(0,r)),n.nonpositive=r=>n.check(Rm(0,r)),n.multipleOf=(r,i)=>n.check(M2(r,i)),n.step=(r,i)=>n.check(M2(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 o3(C6,n)}const DI=$("ZodNumberFormat",(n,t)=>{uR.init(n,t),C6.init(n,t)});function H2(n){return a3(DI,n)}const OI=$("ZodBoolean",(n,t)=>{hR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>$3(n,e,r)});function ct(n){return l3(OI,n)}const LI=$("ZodUnknown",(n,t)=>{dR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>P3()});function E(){return c3(LI)}const MI=$("ZodNever",(n,t)=>{fR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>x3(n,e,r)});function NI(n){return u3(MI,n)}const zI=$("ZodArray",(n,t)=>{pR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>N3(n,e,r,i),n.element=t.element,n.min=(e,r)=>n.check(Od(e,r)),n.nonempty=e=>n.check(Od(1,e)),n.max=(e,r)=>n.check(w6(e,r)),n.length=(e,r)=>n.check(b6(e,r)),n.unwrap=()=>n.element});function W(n,t){return _3(zI,n,t)}const R6=$("ZodObject",(n,t)=>{gR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>z3(n,e,r,i),ke(n,"shape",()=>t.shape),n.keyof=()=>av(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:NI()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=e=>NT(n,e),n.safeExtend=e=>zT(n,e),n.merge=e=>HT(n,e),n.pick=e=>LT(n,e),n.omit=e=>MT(n,e),n.partial=(...e)=>ZT($6,n,e[0]),n.required=(...e)=>UT(x6,n,e[0])});function rg(n,t){const e={type:"object",shape:n??{},...J(t)};return new R6(e)}function b(n,t){return new R6({type:"object",shape:n,catchall:E(),...J(t)})}const I6=$("ZodUnion",(n,t)=>{v6.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>H3(n,e,r,i),n.options=t.options});function le(n,t){return new I6({type:"union",options:n,...J(t)})}const HI=$("ZodDiscriminatedUnion",(n,t)=>{I6.init(n,t),vR.init(n,t)});function ZI(n,t,e){return new HI({type:"union",options:t,discriminator:n,...J(e)})}const UI=$("ZodIntersection",(n,t)=>{yR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>Z3(n,e,r,i)});function Gf(n,t){return new UI({type:"intersection",left:n,right:t})}const FI=$("ZodRecord",(n,t)=>{wR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>U3(n,e,r,i),n.keyType=t.keyType,n.valueType=t.valueType});function T(n,t,e){return new FI({type:"record",keyType:n,valueType:t,...J(e)})}const ig=$("ZodEnum",(n,t)=>{bR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(r,i,s)=>D3(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 s={};for(const a of r)if(e.has(a))s[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new ig({...t,checks:[],...J(i),entries:s})},n.exclude=(r,i)=>{const s={...t.entries};for(const a of r)if(e.has(a))delete s[a];else throw new Error(`Key ${a} not found in enum`);return new ig({...t,checks:[],...J(i),entries:s})}});function av(n,t){const e=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new ig({type:"enum",entries:e,...J(t)})}const qI=$("ZodLiteral",(n,t)=>{SR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>O3(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 qI({type:"literal",values:Array.isArray(n)?n:[n],...J(t)})}const VI=$("ZodTransform",(n,t)=>{_R.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>M3(n,e),n._zod.parse=(e,r)=>{if(r.direction==="backward")throw new X8(n.constructor.name);e.addIssue=s=>{if(typeof s=="string")e.issues.push(nu(s,e.value,t));else{const a=s;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=e.value),a.inst??(a.inst=n),e.issues.push(nu(a))}};const i=t.transform(e.value,e);return i instanceof Promise?i.then(s=>(e.value=s,e)):(e.value=i,e)}});function BI(n){return new VI({type:"transform",transform:n})}const $6=$("ZodOptional",(n,t)=>{y6.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>E6(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function Z2(n){return new $6({type:"optional",innerType:n})}const jI=$("ZodExactOptional",(n,t)=>{AR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>E6(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function WI(n){return new jI({type:"optional",innerType:n})}const GI=$("ZodNullable",(n,t)=>{ER.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>F3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function U2(n){return new GI({type:"nullable",innerType:n})}const JI=$("ZodDefault",(n,t)=>{kR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>V3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function YI(n,t){return new JI({type:"default",innerType:n,get defaultValue(){return typeof t=="function"?t():n6(t)}})}const KI=$("ZodPrefault",(n,t)=>{TR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>B3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function XI(n,t){return new KI({type:"prefault",innerType:n,get defaultValue(){return typeof t=="function"?t():n6(t)}})}const x6=$("ZodNonOptional",(n,t)=>{CR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>q3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function QI(n,t){return new x6({type:"nonoptional",innerType:n,...J(t)})}const e$=$("ZodCatch",(n,t)=>{RR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>j3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function t$(n,t){return new e$({type:"catch",innerType:n,catchValue:typeof t=="function"?t:()=>t})}const n$=$("ZodPipe",(n,t)=>{IR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>W3(n,e,r,i),n.in=t.in,n.out=t.out});function F2(n,t){return new n$({type:"pipe",in:n,out:t})}const r$=$("ZodReadonly",(n,t)=>{$R.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>G3(n,e,r,i),n.unwrap=()=>n._zod.def.innerType});function i$(n){return new r$({type:"readonly",innerType:n})}const s$=$("ZodCustom",(n,t)=>{xR.init(n,t),qe.init(n,t),n._zod.processJSONSchema=(e,r,i)=>L3(n,e)});function o$(n,t={}){return A3(s$,n,t)}function a$(n){return E3(n)}const l$=[".md",".markdown"];function P6(n){if(n.length===0)return!1;const t=n.at(-1);return t==="/"||t==="\\"}function D6(n){const t=n.lastIndexOf("/"),e=n.lastIndexOf("\\");return n.slice(Math.max(t,e)+1)}function c$(n){return D6(n).toLowerCase()}function u$(n,t){const e=c$(n);return t.some(r=>e.endsWith(r))}function sg(n){return!P6(n)&&u$(n,l$)}function h$(n){let t;try{t=new URL(n)}catch{return!1}return t.protocol==="http:"||t.protocol==="https:"}function Vr(n){try{const{pathname:t}=new URL(n);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(t)}catch{return!1}}const d$=rg({id:g().min(1),kind:D("path"),title:g(),path:g(),store:g().optional(),share:rg({id:g().min(1),access:av(["read","read-write"])}).strict().optional()}).strict(),f$=rg({id:g().min(1),kind:D("url"),title:g(),url:g().refine(h$,{message:"url must be an http(s) URL"})}).strict();ZI("kind",[d$,f$]);const p$=new Set(["about:","blob:","chrome-extension:","chrome:","data:","devtools:","file:","filesystem:","javascript:","view-source:"]);function m$(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}:p$.has(r.protocol)?{kind:"browser-local",url:r.href}:{kind:"application",url:r.href}}catch{return{kind:"invalid"}}}function q2(n,t){return m$(n,t).kind==="web"}const g$="/views/markdown/",v$="/views/url-unsupported/";function y$(n){try{const{protocol:t}=new URL(n);return t==="http:"||t==="https:"}catch{return!1}}function O6(n){return`/artifact/${encodeURIComponent(n)}`}function w$(n,t){return`${O6(n)}/${encodeURIComponent(t)}`}function b$(n){return`/markdown/${encodeURIComponent(n)}`}function ru(n,t={electron:!1}){if(n.kind==="url")return t.electron?{renderer:"url-webview",viewURL:n.url,contentURL:null}:Vr(n.url)?{renderer:"proxy-iframe",viewURL:n.url,contentURL:null}:t.browserDemo&&y$(n.url)?{renderer:"url-direct",viewURL:n.url,contentURL:null}:{renderer:"url-unsupported",viewURL:v$,contentURL:null};if(sg(n.path)){const r={viewURL:g$,contentURL:b$(n.id)};return t.electron?{renderer:"url-webview",...r}:{renderer:"markdown",...r}}const e=P6(n.path)?`${O6(n.id)}/`:w$(n.id,D6(n.path));return t.electron?{renderer:"url-webview",viewURL:e,contentURL:null}:{renderer:"proxy-iframe",viewURL:e,contentURL:null}}const S$="token",_$="mode",A$="desktopAppVersion",E$="electron";function k$(n=window.location.search){return new URLSearchParams(n).get(S$)}function bi(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(_$)===E$}function L6(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(A$)}const V2="tv.telemetry.clientId",T$=5,C$=60,R$=1e3,I$=T$*C$*R$,B2=["pointerdown","scroll","keydown"],j2=["focus"],W2=["visibilitychange"],$$="hidden";function x$(n,t=M$){const e=n.getItem(V2);if(e)return e;const r=t();return n.setItem(V2,r),r}function P$(n){return{clientId:x$(n.storage,n.idFactory),userAgent:n.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:n.clientApp,...n.desktopAppVersion?{desktopAppVersion:n.desktopAppVersion}:{}}}function D$(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 O$(n){return new L$(n)}var hu,Gr,Wi,du,fu,yn,po,pu,Gd,M6;class L${constructor(t){m(this,Gd);m(this,hu);m(this,Gr);m(this,Wi);m(this,du);m(this,fu);m(this,yn);m(this,po,!1);m(this,pu,Number.NEGATIVE_INFINITY);d(this,hu,t.meta),d(this,Gr,t.documentTarget),d(this,Wi,t.windowTarget),d(this,du,t.send),d(this,fu,t.nowMs??Date.now),d(this,yn,()=>h(this,Gd,M6).call(this))}start(){if(!o(this,po)){d(this,po,!0);for(const t of B2)o(this,Wi).addEventListener(t,o(this,yn)),o(this,Gr).addEventListener(t,o(this,yn));for(const t of j2)o(this,Wi).addEventListener(t,o(this,yn));for(const t of W2)o(this,Gr).addEventListener(t,o(this,yn))}}stop(){if(o(this,po)){d(this,po,!1);for(const t of B2)o(this,Wi).removeEventListener(t,o(this,yn)),o(this,Gr).removeEventListener(t,o(this,yn));for(const t of j2)o(this,Wi).removeEventListener(t,o(this,yn));for(const t of W2)o(this,Gr).removeEventListener(t,o(this,yn))}}}hu=new WeakMap,Gr=new WeakMap,Wi=new WeakMap,du=new WeakMap,fu=new WeakMap,yn=new WeakMap,po=new WeakMap,pu=new WeakMap,Gd=new WeakSet,M6=function(){if(o(this,Gr).visibilityState===$$)return;const t=o(this,fu).call(this);t-o(this,pu)<I$||(d(this,pu,t),o(this,du).call(this,{type:hk,clientId:o(this,hu).clientId}))};function M$(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():ev().toLowerCase()}const Le={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"},N$=1,z$=b({_meta:T(g(),E()).nullish(),terminal:ct().optional().default(!1)}),H$=b({_meta:T(g(),E()).nullish(),label:g().nullish(),name:g(),optional:ct().optional().default(!1),secret:ct().optional().default(!0)}),Z$=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:g(),name:g()}),U$=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:g(),link:g().nullish(),name:g(),vars:W(H$)}),F$=b({_meta:T(g(),E()).nullish(),args:W(g()).optional(),description:g().nullish(),env:T(g(),g()).optional(),id:g(),name:g()}),q$=le([U$.and(b({type:D("env_var")})),F$.and(b({type:D("terminal")})),Z$]),V$=b({_meta:T(g(),E()).nullish(),methodId:g()}),B$=b({_meta:T(g(),E()).nullish()}),j$=b({_meta:T(g(),E()).nullish(),blob:g(),mimeType:g().nullish(),uri:g()}),W$=b({default:ct().nullish(),description:g().nullish(),title:g().nullish()}),G$=b({_meta:T(g(),E()).nullish()}),J$=b({_meta:T(g(),E()).nullish()}),Y$=b({amount:ie(),currency:g()}),K$=b({_meta:T(g(),E()).nullish(),terminalId:g()}),X$=b({_meta:T(g(),E()).nullish(),newText:g(),oldText:g().nullish(),path:g()}),Q$=le([g(),ie(),ie(),ct(),W(g())]),ex=b({content:T(g(),Q$).nullish()}),tx=le([ex.and(b({action:D("accept")})),b({action:D("decline")}),b({action:D("cancel")})]),nx=b({_meta:T(g(),E()).nullish()}),N6=g(),rx=b({_meta:T(g(),E()).nullish(),elicitationId:N6}),ix=b({_meta:T(g(),E()).nullish(),action:tx}),sx=D("object"),ox=D("string"),ax=b({_meta:T(g(),E()).nullish()}),lx=b({_meta:T(g(),E()).nullish(),form:nx.nullish(),url:ax.nullish()}),cx=b({elicitationId:N6,url:g().url()}),z6=b({const:g(),title:g()}),H6=b({_meta:T(g(),E()).nullish(),name:g(),value:g()}),ux=le([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"})]),Z6=b({code:ux,data:E().optional(),message:g()}),U6=E(),F6=E(),q6=E(),hx=b({_meta:T(g(),E()).nullish(),readTextFile:ct().optional().default(!1),writeTextFile:ct().optional().default(!1)}),V6=b({_meta:T(g(),E()).nullish(),name:g(),value:g()}),B6=b({_meta:T(g(),E()).nullish(),name:g(),title:g().nullish(),version:g()}),dx=b({default:ie().nullish(),description:g().nullish(),maximum:ie().nullish(),minimum:ie().nullish(),title:g().nullish()}),fx=b({_meta:T(g(),E()).nullish()}),px=b({_meta:T(g(),E()).nullish(),additionalDirectories:W(g()).optional(),cursor:g().nullish(),cwd:g().nullish()}),mx=b({_meta:T(g(),E()).nullish()}),gx=b({_meta:T(g(),E()).nullish(),logout:mx.nullish()}),vx=b({_meta:T(g(),E()).nullish()}),yx=b({_meta:T(g(),E()).nullish()}),wx=b({_meta:T(g(),E()).nullish(),http:ct().optional().default(!1),sse:ct().optional().default(!1)}),bx=b({_meta:T(g(),E()).nullish(),headers:W(V6),name:g(),url:g()}),Sx=b({_meta:T(g(),E()).nullish(),headers:W(V6),name:g(),url:g()}),_x=b({_meta:T(g(),E()).nullish(),args:W(g()),command:g(),env:W(H6),name:g()}),Jf=le([bx.and(b({type:D("http")})),Sx.and(b({type:D("sse")})),_x]),lv=g(),Ax=b({_meta:T(g(),E()).nullish(),description:g().nullish(),modelId:lv,name:g()}),Ex=le([D("error"),D("warning"),D("information"),D("hint")]),kx=b({_meta:T(g(),E()).nullish()}),Tx=b({_meta:T(g(),E()).nullish()}),Cx=b({_meta:T(g(),E()).nullish()}),Rx=b({_meta:T(g(),E()).nullish()}),Ix=b({_meta:T(g(),E()).nullish()}),$x=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),xx=b({diff:g(),uri:g()}),Px=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()}),Dx=b({_meta:T(g(),E()).nullish()}),Ox=b({_meta:T(g(),E()).nullish()}),Lx=b({languageId:g(),text:g(),uri:g()}),Mx=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),Nx=le([D("rejected"),D("ignored"),D("replaced"),D("cancelled")]),zx=b({excerpts:W(Px),uri:g()}),Hx=b({_meta:T(g(),E()).nullish()}),Zx=b({_meta:T(g(),E()).nullish()}),Ux=b({name:g(),owner:g(),remoteUrl:g()}),Fx=b({_meta:T(g(),E()).nullish()}),qx=b({_meta:T(g(),E()).nullish(),jump:Dx.nullish(),rename:Zx.nullish(),searchAndReplace:Fx.nullish()}),Vx=b({id:g(),isRegex:ct().nullish(),replace:g(),search:g(),uri:g()}),Bx=le([D("automatic"),D("diagnostic"),D("manual")]),jx=b({_meta:T(g(),E()).nullish(),maxCount:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),Wx=b({_meta:T(g(),E()).nullish(),diagnostics:kx.nullish(),editHistory:$x.nullish(),openFiles:Ox.nullish(),recentFiles:Mx.nullish(),relatedSnippets:Hx.nullish(),userActions:jx.nullish()}),Gx=b({_meta:T(g(),E()).nullish(),additionalDirectories:W(g()).optional(),cwd:g(),mcpServers:W(Jf)}),Jx=b({default:ie().nullish(),description:g().nullish(),maximum:ie().nullish(),minimum:ie().nullish(),title:g().nullish()}),j6=g(),Yx=le([D("allow_once"),D("allow_always"),D("reject_once"),D("reject_always")]),Kx=b({_meta:T(g(),E()).nullish(),kind:Yx,name:g(),optionId:j6}),Xx=le([D("high"),D("medium"),D("low")]),Qx=le([D("pending"),D("in_progress"),D("completed")]),eP=b({_meta:T(g(),E()).nullish(),content:g(),priority:Xx,status:Qx}),tP=b({_meta:T(g(),E()).nullish(),entries:W(eP)}),$s=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"})}),nP=b({id:g(),position:$s,uri:g()}),rP=b({id:g(),newName:g(),position:$s,uri:g()}),iP=b({action:g(),position:$s,timestampMs:ie(),uri:g()}),W6=le([D("utf-16"),D("utf-32"),D("utf-8")]),sP=b({_meta:T(g(),E()).nullish(),auth:z$.optional().default({terminal:!1}),elicitation:lx.nullish(),fs:hx.optional().default({readTextFile:!1,writeTextFile:!1}),nes:qx.nullish(),positionEncodings:W(W6).optional(),terminal:ct().optional().default(!1)}),oP=b({_meta:T(g(),E()).nullish(),audio:ct().optional().default(!1),embeddedContext:ct().optional().default(!1),image:ct().optional().default(!1)}),G6=ie().int().gte(0).lte(65535),aP=b({_meta:T(g(),E()).nullish(),clientCapabilities:sP.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:B6.nullish(),protocolVersion:G6}),nc=b({end:$s,start:$s}),lP=b({message:g(),range:nc,severity:Ex,uri:g()}),cP=b({languageId:g(),lastFocusedMs:ie().nullish(),uri:g(),visibleRange:nc.nullish()}),uP=b({_meta:T(g(),E()).nullish(),diagnostics:W(lP).nullish(),editHistory:W(xx).nullish(),openFiles:W(cP).nullish(),recentFiles:W(Lx).nullish(),relatedSnippets:W(zx).nullish(),userActions:W(iP).nullish()}),hP=b({newText:g(),range:nc}),dP=b({cursorPosition:$s.nullish(),edits:W(hP),id:g(),uri:g()}),fP=le([dP.and(b({kind:D("edit")})),nP.and(b({kind:D("jump")})),rP.and(b({kind:D("rename")})),Vx.and(b({kind:D("searchAndReplace")}))]),pP=b({_meta:T(g(),E()).nullish(),content:g()}),mP=b({_meta:T(g(),E()).nullish()}),ra=le([ie(),g()]).nullable();b({_meta:T(g(),E()).nullish(),requestId:ra});const gP=av(["assistant","user"]),Eh=b({_meta:T(g(),E()).nullish(),audience:W(gP).nullish(),lastModified:g().nullish(),priority:ie().nullish()}),vP=b({_meta:T(g(),E()).nullish(),annotations:Eh.nullish(),data:g(),mimeType:g()}),yP=b({_meta:T(g(),E()).nullish(),annotations:Eh.nullish(),data:g(),mimeType:g(),uri:g().nullish()}),wP=b({_meta:T(g(),E()).nullish(),annotations:Eh.nullish(),description:g().nullish(),mimeType:g().nullish(),name:g(),size:ie().nullish(),title:g().nullish(),uri:g()}),bP=b({_meta:T(g(),E()).nullish(),optionId:j6}),SP=le([b({outcome:D("cancelled")}),bP.and(b({outcome:D("selected")}))]),_P=b({_meta:T(g(),E()).nullish(),outcome:SP}),AP=b({_meta:T(g(),E()).nullish()}),EP=b({_meta:T(g(),E()).nullish()}),kP=b({currentValue:ct()}),TP=g(),J6=g(),CP=le([D("mode"),D("model"),D("thought_level"),g()]),cv=g(),Y6=b({_meta:T(g(),E()).nullish(),description:g().nullish(),name:g(),value:cv}),RP=b({_meta:T(g(),E()).nullish(),group:TP,name:g(),options:W(Y6)}),IP=le([W(Y6),W(RP)]),$P=b({currentValue:cv,options:IP}),rc=Gf(le([$P.and(b({type:D("select")})),kP.and(b({type:D("boolean")}))]),b({_meta:T(g(),E()).nullish(),category:CP.nullish(),description:g().nullish(),id:J6,name:g()})),xP=b({_meta:T(g(),E()).nullish(),configOptions:W(rc)}),PP=b({_meta:T(g(),E()).nullish()}),Se=g(),DP=b({_meta:T(g(),E()).nullish(),id:g(),sessionId:Se}),OP=b({_meta:T(g(),E()).nullish(),sessionId:Se}),LP=b({_meta:T(g(),E()).nullish(),sessionId:Se}),MP=b({_meta:T(g(),E()).nullish(),sessionId:Se}),K6=b({_meta:T(g(),E()).nullish(),args:W(g()).optional(),command:g(),cwd:g().nullish(),env:W(H6).optional(),outputByteLimit:ie().nullish(),sessionId:Se}),NP=b({_meta:T(g(),E()).nullish(),sessionId:Se,uri:g()}),zP=b({_meta:T(g(),E()).nullish(),position:$s,sessionId:Se,uri:g(),version:ie(),visibleRange:nc}),HP=b({_meta:T(g(),E()).nullish(),languageId:g(),sessionId:Se,text:g(),uri:g(),version:ie()}),ZP=b({_meta:T(g(),E()).nullish(),sessionId:Se,uri:g()}),UP=b({_meta:T(g(),E()).nullish(),additionalDirectories:W(g()).optional(),cwd:g(),mcpServers:W(Jf).optional(),sessionId:Se}),X6=b({_meta:T(g(),E()).nullish(),sessionId:Se,terminalId:g()}),FP=b({_meta:T(g(),E()).nullish(),additionalDirectories:W(g()).optional(),cwd:g(),mcpServers:W(Jf),sessionId:Se}),Q6=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:Se}),qP=b({_meta:T(g(),E()).nullish(),id:g(),reason:Nx.nullish(),sessionId:Se}),eS=b({_meta:T(g(),E()).nullish(),sessionId:Se,terminalId:g()}),VP=b({_meta:T(g(),E()).nullish(),additionalDirectories:W(g()).optional(),cwd:g(),mcpServers:W(Jf).optional(),sessionId:Se}),BP=b({_meta:T(g(),E()).nullish(),additionalDirectories:W(g()).optional(),cwd:g(),sessionId:Se,title:g().nullish(),updatedAt:g().nullish()}),jP=b({_meta:T(g(),E()).nullish(),nextCursor:g().nullish(),sessions:W(BP)}),WP=b({_meta:T(g(),E()).nullish(),title:g().nullish(),updatedAt:g().nullish()}),GP=b({_meta:T(g(),E()).nullish()}),Yf=g(),JP=b({_meta:T(g(),E()).nullish(),currentModeId:Yf}),YP=b({_meta:T(g(),E()).nullish(),description:g().nullish(),id:Yf,name:g()}),Kf=b({_meta:T(g(),E()).nullish(),availableModes:W(YP),currentModeId:Yf}),Xf=b({_meta:T(g(),E()).nullish(),availableModels:W(Ax),currentModelId:lv}),KP=b({_meta:T(g(),E()).nullish(),configOptions:W(rc).nullish(),models:Xf.nullish(),modes:Kf.nullish(),sessionId:Se}),XP=b({_meta:T(g(),E()).nullish(),configOptions:W(rc).nullish(),models:Xf.nullish(),modes:Kf.nullish()}),QP=b({_meta:T(g(),E()).nullish(),configOptions:W(rc).nullish(),models:Xf.nullish(),modes:Kf.nullish(),sessionId:Se}),e5=b({_meta:T(g(),E()).nullish(),configOptions:W(rc).nullish(),models:Xf.nullish(),modes:Kf.nullish()}),t5=b({_meta:T(g(),E()).nullish()}),n5=b({_meta:T(g(),E()).nullish(),additionalDirectories:AP.nullish(),close:EP.nullish(),fork:PP.nullish(),list:GP.nullish(),resume:t5.nullish()}),r5=Gf(le([b({type:D("boolean"),value:ct()}),b({value:cv})]),b({_meta:T(g(),E()).nullish(),configId:J6,sessionId:Se})),i5=b({_meta:T(g(),E()).nullish(),configOptions:W(rc)}),s5=b({_meta:T(g(),E()).nullish(),modeId:Yf,sessionId:Se}),o5=b({_meta:T(g(),E()).nullish()}),a5=b({_meta:T(g(),E()).nullish(),modelId:lv,sessionId:Se}),l5=b({_meta:T(g(),E()).nullish()}),c5=b({_meta:T(g(),E()).nullish(),sessionId:Se}),u5=le([D("end_turn"),D("max_tokens"),D("max_turn_requests"),D("refusal"),D("cancelled")]),h5=le([D("email"),D("uri"),D("date"),D("date-time")]),d5=b({default:g().nullish(),description:g().nullish(),enum:W(g()).nullish(),format:h5.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:W(z6).nullish(),pattern:g().nullish(),title:g().nullish()}),f5=b({_meta:T(g(),E()).nullish(),context:uP.nullish(),position:$s,selection:nc.nullish(),sessionId:Se,triggerKind:Bx,uri:g(),version:ie()}),p5=b({_meta:T(g(),E()).nullish(),suggestions:W(fP)}),m5=b({_meta:T(g(),E()).nullish(),terminalId:g()}),g5=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()}),tS=b({_meta:T(g(),E()).nullish(),sessionId:Se,terminalId:g()}),v5=b({_meta:T(g(),E()).nullish(),exitStatus:g5.nullish(),output:g(),truncated:ct()}),y5=b({_meta:T(g(),E()).nullish(),annotations:Eh.nullish(),text:g()}),w5=b({range:nc.nullish(),text:g()}),b5=b({_meta:T(g(),E()).nullish(),contentChanges:W(w5),sessionId:Se,uri:g(),version:ie()});b({method:g(),params:le([OP,HP,b5,NP,ZP,zP,DP,qP,U6]).nullish()});const S5=le([D("full"),D("incremental")]),_5=b({_meta:T(g(),E()).nullish(),syncKind:S5}),A5=b({_meta:T(g(),E()).nullish(),didChange:_5.nullish(),didClose:Tx.nullish(),didFocus:Cx.nullish(),didOpen:Rx.nullish(),didSave:Ix.nullish()}),E5=b({_meta:T(g(),E()).nullish(),document:A5.nullish()}),k5=b({_meta:T(g(),E()).nullish(),context:Wx.nullish(),events:E5.nullish()}),T5=b({_meta:T(g(),E()).nullish(),auth:gx.optional().default({}),loadSession:ct().optional().default(!1),mcpCapabilities:wx.optional().default({http:!1,sse:!1}),nes:k5.nullish(),positionEncoding:W6.nullish(),promptCapabilities:oP.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:n5.optional().default({})}),C5=b({_meta:T(g(),E()).nullish(),agentCapabilities:T5.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:B6.nullish(),authMethods:W(q$).optional().default([]),protocolVersion:G6}),R5=b({_meta:T(g(),E()).nullish(),mimeType:g().nullish(),text:g(),uri:g()}),I5=le([R5,j$]),$5=b({_meta:T(g(),E()).nullish(),annotations:Eh.nullish(),resource:I5}),uv=le([y5.and(b({type:D("text")})),yP.and(b({type:D("image")})),vP.and(b({type:D("audio")})),wP.and(b({type:D("resource_link")})),$5.and(b({type:D("resource")}))]),x5=b({_meta:T(g(),E()).nullish(),content:uv}),$m=b({_meta:T(g(),E()).nullish(),content:uv,messageId:g().nullish()}),P5=b({_meta:T(g(),E()).nullish(),messageId:g().nullish(),prompt:W(uv),sessionId:Se}),D5=b({anyOf:W(z6)}),nS=le([x5.and(b({type:D("content")})),X$.and(b({type:D("diff")})),m5.and(b({type:D("terminal")}))]),rS=g(),iS=b({_meta:T(g(),E()).nullish(),line:ie().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:g()}),sS=le([D("pending"),D("in_progress"),D("completed"),D("failed")]),oS=le([D("read"),D("edit"),D("delete"),D("move"),D("search"),D("execute"),D("think"),D("fetch"),D("switch_mode"),D("other")]),O5=b({_meta:T(g(),E()).nullish(),content:W(nS).optional(),kind:oS.optional(),locations:W(iS).optional(),rawInput:E().optional(),rawOutput:E().optional(),status:sS.optional(),title:g(),toolCallId:rS}),aS=b({_meta:T(g(),E()).nullish(),content:W(nS).nullish(),kind:oS.nullish(),locations:W(iS).nullish(),rawInput:E().optional(),rawOutput:E().optional(),status:sS.nullish(),title:g().nullish(),toolCallId:rS}),lS=b({_meta:T(g(),E()).nullish(),options:W(Kx),sessionId:Se,toolCall:aS}),L5=b({_meta:T(g(),E()).nullish(),hint:g()}),M5=L5,N5=b({_meta:T(g(),E()).nullish(),description:g(),input:M5.nullish(),name:g()}),z5=b({_meta:T(g(),E()).nullish(),availableCommands:W(N5)}),H5=b({enum:W(g()),type:ox}),Z5=le([H5,D5]),U5=b({default:W(g()).nullish(),description:g().nullish(),items:Z5,maxItems:ie().nullish(),minItems:ie().nullish(),title:g().nullish()}),F5=le([d5.and(b({type:D("string")})),Jx.and(b({type:D("number")})),dx.and(b({type:D("integer")})),W$.and(b({type:D("boolean")})),U5.and(b({type:D("array")}))]),q5=b({description:g().nullish(),properties:T(g(),F5).optional().default({}),required:W(g()).nullish(),title:g().nullish(),type:sx.optional().default("object")}),V5=b({requestedSchema:q5}),B5=Gf(le([V5.and(b({mode:D("form")})),cx.and(b({mode:D("url")}))]),b({_meta:T(g(),E()).nullish(),message:g(),sessionId:Se})),j5=b({cachedReadTokens:ie().nullish(),cachedWriteTokens:ie().nullish(),inputTokens:ie(),outputTokens:ie(),thoughtTokens:ie().nullish(),totalTokens:ie()}),W5=b({_meta:T(g(),E()).nullish(),stopReason:u5,usage:j5.nullish(),userMessageId:g().nullish()});le([b({id:ra,result:le([C5,B$,yx,QP,XP,jP,KP,e5,J$,o5,i5,W5,l5,c5,p5,G$,q6])}),b({error:Z6,id:ra})]);const G5=b({_meta:T(g(),E()).nullish(),cost:Y$.nullish(),size:ie(),used:ie()}),J5=le([$m.and(b({sessionUpdate:D("user_message_chunk")})),$m.and(b({sessionUpdate:D("agent_message_chunk")})),$m.and(b({sessionUpdate:D("agent_thought_chunk")})),O5.and(b({sessionUpdate:D("tool_call")})),aS.and(b({sessionUpdate:D("tool_call_update")})),tP.and(b({sessionUpdate:D("plan")})),z5.and(b({sessionUpdate:D("available_commands_update")})),JP.and(b({sessionUpdate:D("current_mode_update")})),xP.and(b({sessionUpdate:D("config_option_update")})),WP.and(b({sessionUpdate:D("session_info_update")})),G5.and(b({sessionUpdate:D("usage_update")}))]),cS=b({_meta:T(g(),E()).nullish(),sessionId:Se,update:J5});b({method:g(),params:le([cS,rx,U6]).nullish()});const uS=b({_meta:T(g(),E()).nullish(),sessionId:Se,terminalId:g()}),Y5=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()}),K5=b({name:g(),uri:g()}),X5=b({_meta:T(g(),E()).nullish(),repository:Ux.nullish(),workspaceFolders:W(K5).nullish(),workspaceUri:g().nullish()});b({id:ra,method:g(),params:le([aP,V$,vx,Gx,FP,px,UP,VP,MP,s5,r5,P5,a5,X5,f5,LP,F6]).nullish()});const hS=b({_meta:T(g(),E()).nullish(),content:g(),path:g(),sessionId:Se});b({id:ra,method:g(),params:le([hS,Q6,lS,K6,tS,eS,uS,X6,B5,F6]).nullish()});const Q5=b({_meta:T(g(),E()).nullish()});le([b({id:ra,result:le([Q5,pP,_P,K$,v5,mP,Y5,fx,ix,q6])}),b({error:Z6,id:ra})]);var be;class eD{constructor(t,e){m(this,be);const r=t(this),i=async(a,l)=>{var c,u,f,p,y,v,S;switch(a){case Zr.fs_write_text_file:{const _=hS.parse(l);return(c=r.writeTextFile)==null?void 0:c.call(r,_)}case Zr.fs_read_text_file:{const _=Q6.parse(l);return(u=r.readTextFile)==null?void 0:u.call(r,_)}case Zr.session_request_permission:{const _=lS.parse(l);return r.requestPermission(_)}case Zr.terminal_create:{const _=K6.parse(l);return(f=r.createTerminal)==null?void 0:f.call(r,_)}case Zr.terminal_output:{const _=tS.parse(l);return(p=r.terminalOutput)==null?void 0:p.call(r,_)}case Zr.terminal_release:{const _=eS.parse(l);return await((y=r.releaseTerminal)==null?void 0:y.call(r,_))??{}}case Zr.terminal_wait_for_exit:{const _=uS.parse(l);return(v=r.waitForTerminalExit)==null?void 0:v.call(r,_)}case Zr.terminal_kill:{const _=X6.parse(l);return await((S=r.killTerminal)==null?void 0:S.call(r,_))??{}}default:if(r.extMethod)return r.extMethod(a,l);throw nt.methodNotFound(a)}},s=async(a,l)=>{switch(a){case Zr.session_update:{const c=cS.parse(l);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(a,l);throw nt.methodNotFound(a)}};d(this,be,new tD(i,s,e))}async initialize(t){return await o(this,be).sendRequest(Le.initialize,t)}async newSession(t){return await o(this,be).sendRequest(Le.session_new,t)}async loadSession(t){return await o(this,be).sendRequest(Le.session_load,t)??{}}async unstable_forkSession(t){return await o(this,be).sendRequest(Le.session_fork,t)}async listSessions(t){return await o(this,be).sendRequest(Le.session_list,t)}async unstable_resumeSession(t){return await o(this,be).sendRequest(Le.session_resume,t)}async unstable_closeSession(t){return await o(this,be).sendRequest(Le.session_close,t)}async setSessionMode(t){return await o(this,be).sendRequest(Le.session_set_mode,t)??{}}async unstable_setSessionModel(t){return await o(this,be).sendRequest(Le.session_set_model,t)??{}}async setSessionConfigOption(t){return await o(this,be).sendRequest(Le.session_set_config_option,t)}async authenticate(t){return await o(this,be).sendRequest(Le.authenticate,t)??{}}async unstable_logout(t){return await o(this,be).sendRequest(Le.logout,t)??{}}async prompt(t){return await o(this,be).sendRequest(Le.session_prompt,t)}async cancel(t){return await o(this,be).sendNotification(Le.session_cancel,t)}async unstable_startNes(t){return await o(this,be).sendRequest(Le.nes_start,t)}async unstable_suggestNes(t){return await o(this,be).sendRequest(Le.nes_suggest,t)}async unstable_closeNes(t){return await o(this,be).sendRequest(Le.nes_close,t)??{}}async unstable_didOpenDocument(t){return await o(this,be).sendNotification(Le.document_did_open,t)}async unstable_didChangeDocument(t){return await o(this,be).sendNotification(Le.document_did_change,t)}async unstable_didCloseDocument(t){return await o(this,be).sendNotification(Le.document_did_close,t)}async unstable_didSaveDocument(t){return await o(this,be).sendNotification(Le.document_did_save,t)}async unstable_didFocusDocument(t){return await o(this,be).sendNotification(Le.document_did_focus,t)}async unstable_acceptNes(t){return await o(this,be).sendNotification(Le.nes_accept,t)}async unstable_rejectNes(t){return await o(this,be).sendNotification(Le.nes_reject,t)}async extMethod(t,e){return await o(this,be).sendRequest(t,e)}async extNotification(t,e){return await o(this,be).sendNotification(t,e)}get signal(){return o(this,be).signal}get closed(){return o(this,be).closed}}be=new WeakMap;var Gi,Jd,mu,gu,ja,Wa,ar,vu,Ue,dS,og,fS,pS,mS,gS,ag,Pc;class tD{constructor(t,e,r){m(this,Ue);m(this,Gi,new Map);m(this,Jd,0);m(this,mu);m(this,gu);m(this,ja);m(this,Wa,Promise.resolve());m(this,ar,new AbortController);m(this,vu);d(this,mu,t),d(this,gu,e),d(this,ja,r),d(this,vu,new Promise(i=>{o(this,ar).signal.addEventListener("abort",()=>i())})),h(this,Ue,dS).call(this)}get signal(){return o(this,ar).signal}get closed(){return o(this,vu)}async sendRequest(t,e){h(this,Ue,ag).call(this);const r=Mh(this,Jd)._++,i=new Promise((s,a)=>{o(this,Gi).set(r,{resolve:s,reject:a})});return await h(this,Ue,Pc).call(this,{jsonrpc:"2.0",id:r,method:t,params:e}),i}async sendNotification(t,e){h(this,Ue,ag).call(this),await h(this,Ue,Pc).call(this,{jsonrpc:"2.0",method:t,params:e})}}Gi=new WeakMap,Jd=new WeakMap,mu=new WeakMap,gu=new WeakMap,ja=new WeakMap,Wa=new WeakMap,ar=new WeakMap,vu=new WeakMap,Ue=new WeakSet,dS=async function(){let t;try{const e=o(this,ja).readable.getReader();try{for(;!o(this,ar).signal.aborted;){const{value:r,done:i}=await e.read();if(i)break;if(r)try{h(this,Ue,fS).call(this,r)}catch(s){console.error("Unexpected error during message processing:",r,s),"id"in r&&r.id!==void 0&&h(this,Ue,Pc).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{e.releaseLock()}}catch(e){t=e}finally{h(this,Ue,og).call(this,t)}},og=function(t){if(o(this,ar).signal.aborted)return;const e=t??new Error("ACP connection closed");for(const r of o(this,Gi).values())r.reject(e);o(this,Gi).clear(),o(this,ar).abort(e)},fS=async function(t){if("method"in t&&"id"in t){const e=await h(this,Ue,pS).call(this,t.method,t.params);"error"in e&&console.error("Error handling request",t,e.error),await h(this,Ue,Pc).call(this,{jsonrpc:"2.0",id:t.id,...e})}else if("method"in t){const e=await h(this,Ue,mS).call(this,t.method,t.params);"error"in e&&console.error("Error handling notification",t,e.error)}else"id"in t?h(this,Ue,gS).call(this,t):console.error("Invalid message",{message:t})},pS=async function(t,e){try{return{result:await o(this,mu).call(this,t,e)??null}}catch(r){if(r instanceof nt)return r.toResult();if(r instanceof N2)return nt.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 nt.internalError(i?JSON.parse(i):{}).toResult()}catch{return nt.internalError({details:i}).toResult()}}},mS=async function(t,e){try{return await o(this,gu).call(this,t,e),{result:null}}catch(r){if(r instanceof nt)return r.toResult();if(r instanceof N2)return nt.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 nt.internalError(i?JSON.parse(i):{}).toResult()}catch{return nt.internalError({details:i}).toResult()}}},gS=function(t){const e=o(this,Gi).get(t.id);if(e){if("result"in t)e.resolve(t.result);else if("error"in t){const{code:r,message:i,data:s}=t.error;e.reject(new nt(r,i,s))}o(this,Gi).delete(t.id)}else console.error("Got response to unknown request",t.id)},ag=function(){if(o(this,ar).signal.aborted)throw o(this,ar).signal.reason??new Error("ACP connection closed")},Pc=async function(t){return d(this,Wa,o(this,Wa).then(async()=>{const e=o(this,ja).writable.getWriter();try{await e.write(t)}finally{e.releaseLock()}}).catch(e=>{h(this,Ue,og).call(this,e)})),o(this,Wa)};class nt extends Error{constructor(e,r,i){super(r);R(this,"code");R(this,"data");this.code=e,this.name="RequestError",this.data=i}static parseError(e,r){return new nt(-32700,`Parse error${r?`: ${r}`:""}`,e)}static invalidRequest(e,r){return new nt(-32600,`Invalid request${r?`: ${r}`:""}`,e)}static methodNotFound(e){return new nt(-32601,`"Method not found": ${e}`,{method:e})}static invalidParams(e,r){return new nt(-32602,`Invalid params${r?`: ${r}`:""}`,e)}static internalError(e,r){return new nt(-32603,`Internal error${r?`: ${r}`:""}`,e)}static authRequired(e,r){return new nt(-32e3,`Authentication required${r?`: ${r}`:""}`,e)}static resourceNotFound(e){return new nt(-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 nD(n,t,e){const r=n.dispose.bind(n);n.dispose=(()=>{if(!t())return e(),r()})}function vS(n){var e;class t extends n{constructor(...s){super(...s);m(this,e,!1);nD(this,()=>o(this,e),()=>{d(this,e,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return o(this,e)}}return e=new WeakMap,t}const rD=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,iD=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,sD=/\[Television channel context\][\s\S]*?\[\/Television channel context\]\n*/,oD=/\b(tv|television|channel|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,aD=/^[A-Za-z0-9_@%+=:,./-]+$/,lD=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,cD="single_session",uD={name:"television-acp-client",version:"0.0.0"},yS="agent:main:television",hD=vS(Ri);var Ga,lr,rn,cr,Ji,Nn,Jr,ur,zn,Yi,Hn,Ja,Ya,hr,kt,Yr,Ka,mo,Kr,Ki,yu,Zn,dr,Yd,fr,L,lg,wS,bS,SS,td,_S,AS,ES,kS,TS,CS,RS,Ws,Ea,ka,Fr,IS,Ta,cg,ug,nd,$S,rd,hg,dg,wu,bu,id,Ca,fg,xS;class dD extends hD{constructor(e){super();m(this,L);m(this,Ga,"disconnected");m(this,lr,null);m(this,rn,new Map);m(this,cr,null);m(this,Ji,null);m(this,Nn,null);m(this,Jr,null);m(this,ur,null);m(this,zn,null);m(this,Yi);m(this,Hn,null);m(this,Ja,0);m(this,Ya,1);m(this,hr,null);m(this,kt,null);m(this,Yr,!1);m(this,Ka,!1);m(this,mo,!1);m(this,Kr,null);m(this,Ki,new Set);m(this,yu);m(this,Zn);m(this,dr);m(this,Yd,e=>{h(this,L,bS).call(this,e)});m(this,fr,null);m(this,wu,()=>{h(this,L,Ca).call(this,"ACP bridge websocket closed")});m(this,bu,()=>{h(this,L,Ca).call(this,"ACP bridge websocket error")});d(this,Zn,e),d(this,dr,e.sessionMode??cD),d(this,Yi,e.mappedSessionStore??fD()),d(this,yu,e.createSocket??(r=>new WebSocket(r)))}get status(){return o(this,Ga)}get messages(){return[...o(this,rn).values()]}get enabled(){return o(this,Zn).enabled??!1}setToken(e){o(this,Zn).token=e??""}setEnabled(e){o(this,Zn).enabled=e,e||(h(this,L,id).call(this),d(this,lr,null),h(this,L,Fr).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){o(this,Ji)===null&&(d(this,lr,null),d(this,Ji,h(this,L,wS).call(this)));try{await o(this,Ji),await h(this,L,td).call(this)}catch(e){throw h(this,L,Ca).call(this,xm(e)),e}}}dispose(){h(this,L,id).call(this),d(this,lr,null),h(this,L,Fr).call(this,"disposed")}async sendMessage(e){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,L,lg).call(this,"ready")),(o(this,ur)===null||o(this,Hn)!==h(this,L,rd).call(this))&&await h(this,L,td).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,L,Ea).call(this,{id:h(this,L,Ta).call(this,"user"),kind:"user",text:r,status:"final"}),h(this,L,Fr).call(this,"running");try{const i=await h(this,L,nd).call(this).prompt({sessionId:h(this,L,ug).call(this),prompt:[{type:"text",text:h(this,L,IS).call(this,r)}]});h(this,L,Ws).call(this,i.stopReason==="cancelled"?"cancelled":"final"),h(this,L,Fr).call(this,"ready")}catch(i){throw h(this,L,xS).call(this)||(h(this,L,Ws).call(this,"error"),h(this,L,Fr).call(this,"ready")),i}}async startNewSession(){var r;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await h(this,L,lg).call(this,"ready"));const e=h(this,L,rd).call(this);((r=o(this,zn))==null?void 0:r.sessionIdStrategy)==="mapped"?o(this,Yi).clearActualSessionId(e):d(this,Ja,o(this,Ja)+1),d(this,Nn,null),d(this,Jr,null),d(this,ur,null),d(this,Hn,null),h(this,L,fg).call(this)}async cancel(){this.status==="running"&&(h(this,L,Fr).call(this,"cancelling"),await h(this,L,nd).call(this).cancel({sessionId:h(this,L,ug).call(this)}))}setChannelContext(e){var s,a,l;if(e===null){if(o(this,kt)===null)return;d(this,kt,null),d(this,Yr,!1);return}const r={channelID:e.channelID,channelName:e.channelName};if(((s=o(this,kt))==null?void 0:s.channelID)===r.channelID&&((a=o(this,kt))==null?void 0:a.channelName)===r.channelName)return;const i=((l=o(this,kt))==null?void 0:l.channelID)??null;if(d(this,kt,r),o(this,dr)==="single_session"){(!o(this,Hn)||i!==r.channelID)&&d(this,Yr,!0);return}o(this,Hn)!==h(this,L,hg).call(this,r.channelID)&&(d(this,Nn,null),d(this,Jr,null),o(this,cr)&&this.status==="ready"&&h(this,L,td).call(this).catch(c=>{h(this,L,Ca).call(this,xm(c))}))}}Ga=new WeakMap,lr=new WeakMap,rn=new WeakMap,cr=new WeakMap,Ji=new WeakMap,Nn=new WeakMap,Jr=new WeakMap,ur=new WeakMap,zn=new WeakMap,Yi=new WeakMap,Hn=new WeakMap,Ja=new WeakMap,Ya=new WeakMap,hr=new WeakMap,kt=new WeakMap,Yr=new WeakMap,Ka=new WeakMap,mo=new WeakMap,Kr=new WeakMap,Ki=new WeakMap,yu=new WeakMap,Zn=new WeakMap,dr=new WeakMap,Yd=new WeakMap,fr=new WeakMap,L=new WeakSet,lg=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(o(this,lr)??"ACPClient is disconnected");await new Promise((r,i)=>{const s=()=>{this.removeEventListener("status-changed",a)},a=()=>{if(this.status===e){s(),r();return}if(this.status==="disposed"){s(),i(new Error("ACPClient has been disposed"));return}this.status==="disconnected"&&(s(),i(new Error(o(this,lr)??"ACPClient is disconnected")))};this.addEventListener("status-changed",a)})}},wS=async function(){try{const{stream:e,socket:r,metadata:i}=await vD({serverURL:o(this,Zn).serverURL,token:o(this,Zn).token,createSocket:o(this,yu),onDisconnect:o(this,Yd)});d(this,zn,i),d(this,fr,r),r.addEventListener("close",o(this,wu)),r.addEventListener("error",o(this,bu)),d(this,cr,new eD(s=>({connection:s,sessionUpdate:async a=>{await h(this,L,AS).call(this,a)},requestPermission:async a=>h(this,L,ES).call(this,a)}),e)),await o(this,cr).initialize({protocolVersion:N$,clientCapabilities:{},clientInfo:uD})}catch(e){throw e}},bS=function(e){h(this,L,Ca).call(this,xm(e))},SS=function(e){const r=e==null?void 0:e.models;if(!(r!=null&&r.currentModelId))return;const i=r.availableModels.find(s=>s.modelId===r.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??r.currentModelId,`(${r.currentModelId})`)},td=async function(){const e=h(this,L,rd).call(this);if(o(this,Nn)&&o(this,Jr)===e){await o(this,Nn);return}d(this,Jr,e),d(this,Nn,h(this,L,_S).call(this,e)),await o(this,Nn)},_S=async function(e){var c;const r=h(this,L,nd).call(this);h(this,L,fg).call(this);let i,s=!1,a=null;const l={cwd:h(this,L,$S).call(this),mcpServers:[],_meta:{sessionKey:e}};try{if(d(this,mo,!0),d(this,Kr,null),((c=o(this,zn))==null?void 0:c.sessionIdStrategy)==="mapped"){const u=o(this,Yi).getActualSessionId(e);if(u)try{const f=await r.loadSession({...l,sessionId:u});if(pD(f))throw new Error("Mapped ACP session was not found");a=f,i=u,s=!0}catch{const f=await r.newSession(l);a=f,i=f.sessionId,o(this,Yi).setActualSessionId(e,i),s=!1}else{const f=await r.newSession(l);a=f,i=f.sessionId,o(this,Yi).setActualSessionId(e,i),s=!1}}else try{a=await r.loadSession({...l,sessionId:e}),i=e,s=o(this,rn).size>0}catch{const u=await r.newSession(l);a=u,i=u.sessionId,s=!1}}finally{d(this,mo,!1),d(this,Kr,null),h(this,L,Ws).call(this,"final")}h(this,L,SS).call(this,a),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),d(this,ur,i),d(this,Hn,e),d(this,Ka,!0),s?(o(this,Ki).add(e),o(this,dr)==="single_session"&&d(this,Yr,!1)):(o(this,Ki).delete(e),d(this,Yr,o(this,dr)==="single_session")),d(this,lr,null),h(this,L,Fr).call(this,"ready")},AS=async function(e){const r=e.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&h(this,L,RS).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&h(this,L,kS).call(this,r.content.text);return;case"tool_call":h(this,L,TS).call(this,r);return;case"tool_call_update":h(this,L,CS).call(this,r);return;case"agent_thought_chunk":return;default:return}},ES=async function(e){return{outcome:{outcome:"cancelled"}}},kS=function(e){d(this,Kr,null);const r=gD(e);if(!r)return;if(!o(this,hr)){const s={id:h(this,L,Ta).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};d(this,hr,s.id),h(this,L,Ea).call(this,s);return}const i=o(this,rn).get(o(this,hr));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");h(this,L,ka).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},TS=function(e){h(this,L,Ws).call(this,"final");const r=h(this,L,cg).call(this,e.toolCallId),i=J2("content"in e?e.content:void 0),s={id:(r==null?void 0:r.id)??h(this,L,Ta).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,L,ka).call(this,s);return}h(this,L,Ea).call(this,s)},CS=function(e){const r=h(this,L,cg).call(this,e.toolCallId),i=(r==null?void 0:r.text)??"",s=J2(e.content),a=s?`${i}${s}`:i,l={id:(r==null?void 0:r.id)??h(this,L,Ta).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,L,ka).call(this,l);return}h(this,L,Ea).call(this,l)},RS=function(e){if(h(this,L,Ws).call(this,"final"),!e)return;const r=o(this,mo)?o(this,Kr):null;if(!r){const s=G2(e);if(!s)return;const a={id:h(this,L,Ta).call(this,"user"),kind:"user",text:s,status:"final"};h(this,L,Ea).call(this,a),o(this,mo)&&d(this,Kr,a.id);return}const i=o(this,rn).get(r);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");h(this,L,ka).call(this,{...i,text:G2(`${i.text}${e}`)})},Ws=function(e){if(!o(this,hr))return;const r=o(this,rn).get(o(this,hr));(r==null?void 0:r.kind)==="assistant"&&h(this,L,ka).call(this,{...r,status:e}),d(this,hr,null)},Ea=function(e){o(this,rn).set(e.id,e),this.dispatchEvent(new Cm("messages-changed"))},ka=function(e){o(this,rn).set(e.id,e),this.dispatchEvent(new Cm("messages-changed"))},Fr=function(e){o(this,Ga)!==e&&(d(this,Ga,e),this.dispatchEvent(new ST("status-changed")))},IS=function(e){var u;const r=o(this,Hn);if(!r)return e;const i=o(this,kt)?o(this,dr)==="single_session"?o(this,Yr)||!o(this,Ki).has(r):!o(this,Ki).has(r):!1,s=o(this,Ka)&&(o(this,kt)!==null||oD.test(e));if(!(s||i))return e;s&&d(this,Ka,!1),i&&(d(this,Yr,!1),o(this,Ki).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=o(this,zn))==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(bD).join(" ")}`),o(this,kt)?(l.push("This conversation is currently attached to the channel below."),l.push(`channel_id: ${o(this,kt).channelID}`),l.push(`channel_name: ${o(this,kt).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(`
|
|
65
|
-
`)},Ta=function(e){const r=`${e}-${o(this,Ya)}`;return d(this,Ya,o(this,Ya)+1),r},cg=function(e){for(const r of o(this,rn).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},ug=function(){if(!o(this,ur))throw new Error("ACP session is not ready");return o(this,ur)},nd=function(){if(!o(this,cr))throw new Error("ACP connection is not ready");return o(this,cr)},$S=function(){var r;const e=(r=o(this,zn))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},rd=function(){var r;if(o(this,dr)==="single_session")return h(this,L,dg).call(this,`${yS}-${(o(this,Zn).clientGUID??"default-client").toLowerCase()}`);const e=(r=o(this,kt))==null?void 0:r.channelID;if(!e)throw new Error("Channel context is required for per-channel session mode");return h(this,L,hg).call(this,e)},hg=function(e){return h(this,L,dg).call(this,mD(o(this,dr),e,o(this,Zn).clientGUID??"default-client"))},dg=function(e){var r;return((r=o(this,zn))==null?void 0:r.sessionIdStrategy)==="deterministic"&&o(this,Ja)>0?`${e}:epoch-${o(this,Ja)}`:e},wu=new WeakMap,bu=new WeakMap,id=function(){d(this,cr,null),d(this,Ji,null),d(this,Nn,null),d(this,Jr,null),d(this,ur,null),d(this,Hn,null),d(this,zn,null),o(this,fr)&&(o(this,fr).removeEventListener("close",o(this,wu)),o(this,fr).removeEventListener("error",o(this,bu)),o(this,fr).close(),d(this,fr,null))},Ca=function(e){const r=o(this,cr)!==null||o(this,Ji)!==null||o(this,Nn)!==null||o(this,Jr)!==null||o(this,ur)!==null||o(this,Hn)!==null||o(this,zn)!==null||o(this,fr)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,L,Ws).call(this,"error"),h(this,L,id).call(this),d(this,lr,e??null),h(this,L,Fr).call(this,"disconnected"))},fg=function(){const e=o(this,rn).size>0;d(this,hr,null),d(this,Kr,null),d(this,Ya,1),o(this,rn).clear(),e&&this.dispatchEvent(new Cm("messages-changed"))},xS=function(){return this.status==="disconnected"};function fD(){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 pD(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function mD(n,t,e){return n==="single_session"?`${yS}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function PS(n){return n.replace(/^(?:\s*\n)+/,"")}function G2(n){let t=n;return t=t.replace(rD,""),t=t.replace(iD,""),t=t.replace(sD,""),t=PS(t),t}function gD(n){let t=n;return t=t.replace(lD,""),t=PS(t),t}function J2(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function vD(n){const t=n.createSocket(_D(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,f)=>{r=u,i=f}),a=new ReadableStream({start(u){let f=!1;const p=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=_=>{const I=SD(_);if(!I)return;let Z;try{Z=JSON.parse(I)}catch(O){const z=O instanceof Error?O:new Error(String(O));i(z),u.error(z);return}switch(Z.type){case"acp-bridge-status":if(Z.status==="ready"){let O;try{O=yD(Z)}catch(z){const P=z instanceof Error?z:new Error(String(z));e||i(P),u.error(P);return}e||(e=!0,r(O));return}if(Z.status==="error"||Z.status==="exited"){const O=new Error(Z.error??`ACP bridge ${Z.status}`);e||i(O),u.error(O)}return;case"acp-bridge-message":u.enqueue(Z.message);return}},v=()=>{var I;if(f)return;f=!0;const _=new Error("ACP bridge websocket closed");e||i(_),(I=n.onDisconnect)==null||I.call(n,_),u.close()},S=()=>{var I;if(f)return;f=!0;const _=new Error("ACP bridge websocket error");e||i(_),(I=n.onDisconnect)==null||I.call(n,_),u.error(_)};t.addEventListener("open",p),t.addEventListener("message",y),t.addEventListener("close",v),t.addEventListener("error",S)}}),l=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:a,writable:l},socket:t,metadata:c}}function yD(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&&wD(i))return{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function wD(n){return Array.isArray(n)&&n.every(t=>typeof t=="string")}function bD(n){return aD.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function SD(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 _D(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 xm(n){return n instanceof Error?n.message:String(n)}const Y2="television.acpClientGUID",K2="television.acpMappedSessions",X2=1;var Xa;class AD{constructor(){m(this,Xa,new Map)}getActualSessionId(t){return o(this,Xa).get(t)??null}setActualSessionId(t,e){o(this,Xa).set(t,e)}clearActualSessionId(t){o(this,Xa).delete(t)}}Xa=new WeakMap;var Qa,Su,hn,sd,od,pg;class ED{constructor(t,e){m(this,hn);m(this,Qa);m(this,Su);d(this,Qa,t),d(this,Su,e)}getActualSessionId(t){const e=h(this,hn,od).call(this)[h(this,hn,sd).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,hn,od).call(this);r[h(this,hn,sd).call(this,t)]=e,h(this,hn,pg).call(this,r)}clearActualSessionId(t){const e=h(this,hn,od).call(this);delete e[h(this,hn,sd).call(this,t)],h(this,hn,pg).call(this,e)}}Qa=new WeakMap,Su=new WeakMap,hn=new WeakSet,sd=function(t){return JSON.stringify([o(this,Su),t])},od=function(){const t=o(this,Qa).getItem(K2);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!==X2?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},pg=function(t){const e={version:X2,entries:t};o(this,Qa).setItem(K2,JSON.stringify(e))};function DS(){return typeof window>"u"?null:window.localStorage}function kD(n){const t=n.getItem(Y2);if(t)return t;const e=ev().toLowerCase();return n.setItem(Y2,e),e}const Q2=4401,TD=401,qh=1e3,CD=3e4;class ad extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class RD extends Ri{constructor(e){var a,l;super();R(this,"url");R(this,"name");R(this,"telemetryMeta");R(this,"status","unauthorized");R(this,"channels",new Map);R(this,"client");R(this,"acpClient");R(this,"_token");R(this,"attempting",!1);R(this,"nextRetryAt",null);R(this,"hasEverConnected",!1);R(this,"failedReconnectAttempts",0);R(this,"browserDemoMode",!1);R(this,"hasAuthRejected",!1);R(this,"bootState","pending");R(this,"serverVersion",null);R(this,"updateState",null);R(this,"decideBoot");R(this,"navigationPending");R(this,"createSocket");R(this,"createClient");R(this,"socket",null);R(this,"connectAttempt",0);R(this,"autoReconnect",!1);R(this,"retryTimer",null);R(this,"retryDelay",qh);R(this,"visibilityEventTarget");R(this,"networkEventTarget");R(this,"onVisibilityChange");R(this,"onNetworkOnline");R(this,"telemetryActivityAgent");this.url=aa(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,f)=>new Gk(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...f?{telemetryMeta:f}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new ED(e.acpStorage,this.url):new AD);this.acpClient=new dD({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,s=e.telemetryWindowTarget!==void 0?e.telemetryWindowTarget:typeof window<"u"?window:null;this.telemetryActivityAgent=this.telemetryMeta&&i&&s?O$({meta:this.telemetryMeta,documentTarget:i,windowTarget:s,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.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=qh,this.autoReconnect=!0,await this.attempt()}dispose(){var e,r,i,s;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),(s=this.telemetryActivityAgent)==null||s.stop(),this.acpClient.dispose()}getViewURL(e){const r=ru(e,this.renderOptions());return bi()?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:bi(),browserDemo:this.browserDemoMode}}getContentURL(e){const r=ru(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 $c("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new $c("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new $c("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!fk(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...D8},size:{...O8}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=Bm(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 ID(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 Wt("change"));const r=this.createSocket($D(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((s,a)=>{let l=!1,c=!1;const u=()=>{var y;l||this.connectAttempt!==e||(l=!0,c=!0,this.retryDelay=qh,this.hasEverConnected=!0,this.failedReconnectAttempts=0,this.setStatus("connected"),(y=this.telemetryActivityAgent)==null||y.start(),s())},f=y=>{l||this.connectAttempt!==e||(l=!0,a(y))},p=async()=>{const y=this.hasEverConnected;try{const[{channels:v},S,_]=await Promise.all([this.client.channels.list(),this.client.display.get(),y?null:this.readDemoMode()]);y||(this.browserDemoMode=(_==null?void 0:_.browserExternalPages)===!0),this.channels=new Map(v.map(I=>[I.id,structuredClone(I)])),this.acpClient.setEnabled(S.acpEnabled),this.dispatchEvent(new Wt("change")),y&&this.dispatchEvent(new $c("channels-changed")),this.dispatchEvent(new Qh("server-event",{event:{type:"channel-changed",channelID:S.focusedChannelId}})),this.dispatchEvent(new Qh("server-event",{event:{type:"pinned-channels-changed",pinnedChannelIds:[...S.pinnedChannelIds]}})),u(),y&&this.connectAttempt===e&&this.dispatchEvent(new Y8("server-reconnected"))}catch(v){if(MD(v)){f(new ad);return}f(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||p())}),r.addEventListener("message",y=>{const v=LD(y);if(!v)return;if(v.type==="server-status"){const _=v;this.serverVersion=_.version,this.updateState=_.update??null;let I=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(_)==="boot"?(this.bootState="booted",I=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new K8("server-status",{message:_})),I?this.navigationPending()||p():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new Wt("change"));return}if(!OD(v.type))return;const S=v;this.applyServerEvent(S),this.dispatchEvent(new Qh("server-event",{event:S}))}),r.addEventListener("close",y=>{if(this.connectAttempt!==e)return;this.socket=null;const v=xD(y);if(!l){f(v===Q2?new ad:new Error("Connection closed before initialization"));return}if(c){if(v===Q2){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){if(!c)return;this.handleTransportFailure(new Error("WebSocket error"));return}f(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAuthRejected(){this.hasAuthRejected=!0,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof ad){this.handleAuthRejected();return}this.autoReconnect&&(this.hasEverConnected&&(this.failedReconnectAttempts+=1),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,CD),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new Wt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new Wt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=qh,this.attempt().catch(()=>{})))}sendTelemetryActivity(e){var r;this.status==="connected"&&((r=this.socket)==null||r.send(JSON.stringify(e)))}sendTelemetrySignal(e,r){var s;if(!this.telemetryMeta||this.status!=="connected"&&this.bootState!=="halted")return;const i={type:dk,clientId:this.telemetryMeta.clientId,event:e,properties:r};(s=this.socket)==null||s.send(JSON.stringify(i))}setStatus(e){this.status!==e&&(this.status=e,this.dispatchEvent(new Wt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function ID(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function $D(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,s]of D$(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function xD(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const PD={"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},DD=new Set(Object.keys(PD));function OD(n){return DD.has(n)}function LD(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 MD(n){return n instanceof ec&&n.status===TD}const ND="Local";var pr,Un,Ei,OS,mg,LS,_u,Au,Eu,ku,Tu;class zD extends Ri{constructor(e){super();m(this,Ei);R(this,"connection");R(this,"clientGUID");R(this,"acpStorage");R(this,"connectError",null);m(this,pr);m(this,Un,!1);m(this,_u,()=>{o(this,Un)||(h(this,Ei,LS).call(this),this.dispatchEvent(new Wt("change")))});m(this,Au,e=>{o(this,Un)||this.dispatchEvent(new Qh("server-event",{event:e.event}))});m(this,Eu,()=>{o(this,Un)||this.dispatchEvent(new $c("channels-changed"))});m(this,ku,()=>{o(this,Un)||this.dispatchEvent(new Y8("server-reconnected"))});m(this,Tu,e=>{o(this,Un)||this.dispatchEvent(new K8("server-status",{message:e.message}))});d(this,pr,e.localStore),this.acpStorage=e.acpStorage===void 0?DS():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?kD(this.acpStorage):ev().toLowerCase());const r=aa(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&o(this,pr).set(kT(o(this,pr).get(),r,e.launchToken));const i=e.launchToken??b2(o(this,pr).get(),r),s=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new RD(l));this.connection=a({url:r,name:e.connectionName??ND,token:i,createSocket:s,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:e.telemetryMeta??null,decideBoot:e.decideBoot,navigationPending:e.navigationPending}),this.connection.addEventListener("change",o(this,_u)),this.connection.addEventListener("server-event",o(this,Au)),this.connection.addEventListener("channels-changed",o(this,Eu)),this.connection.addEventListener("server-reconnected",o(this,ku)),this.connection.addEventListener("server-status",o(this,Tu))}get storedAuthToken(){return b2(o(this,pr).get(),this.connection.url)}async connect(){await h(this,Ei,OS).call(this,this.connection.token)}dispose(){o(this,Un)||(d(this,Un,!0),this.connection.removeEventListener("change",o(this,_u)),this.connection.removeEventListener("server-event",o(this,Au)),this.connection.removeEventListener("channels-changed",o(this,Eu)),this.connection.removeEventListener("server-reconnected",o(this,ku)),this.connection.removeEventListener("server-status",o(this,Tu)),this.connection.dispose())}}pr=new WeakMap,Un=new WeakMap,Ei=new WeakSet,OS=async function(e){if(!o(this,Un)){h(this,Ei,mg).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,Ei,mg).call(this,r instanceof ad?null:r instanceof Error?r.message:String(r))}}},mg=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new Wt("change")))},LS=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=o(this,pr).get(),r=TT(e,this.connection.url);r!==e&&o(this,pr).set(r),this.connection.token!==null&&this.connection.clearToken()},_u=new WeakMap,Au=new WeakMap,Eu=new WeakMap,ku=new WeakMap,Tu=new WeakMap;const gg="tv-nav:",Bl="tv-reload",eb=100,HD=1e3,ZD=60,UD=60,FD=24,qD=30,VD=qD*FD*UD*ZD*HD;function Si(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(Bl);return t.searchParams.delete(Bl),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var Cu,el,De,Ie,go,Ke,MS,zi,NS,vg,yg;class BD extends Ri{constructor(e,r){super();m(this,Ke);m(this,Cu);m(this,el);m(this,De,[]);m(this,Ie,-1);m(this,go,0);d(this,Cu,e),d(this,el,Si(r)),h(this,Ke,MS).call(this)}get currentURL(){var e;return o(this,Ie)===-1?null:((e=o(this,De)[o(this,Ie)])==null?void 0:e.url)??null}get canGoBack(){return o(this,Ie)>-1}get canGoForward(){return o(this,Ie)<o(this,De).length-1}get entries(){return o(this,De).map(e=>({...e}))}get cursor(){return o(this,Ie)}navigate(e){const r=Si(e);if(r===o(this,el)){if(o(this,Ie)===-1)return;d(this,Ie,-1),h(this,Ke,zi).call(this);return}o(this,Ie)<o(this,De).length-1&&d(this,De,o(this,De).slice(0,o(this,Ie)+1)),o(this,De).push({url:r}),d(this,Ie,o(this,De).length-1),h(this,Ke,vg).call(this),h(this,Ke,zi).call(this)}replace(e){var i;if(o(this,Ie)===-1){this.navigate(e);return}const r=Si(e);if(r===o(this,el)){d(this,De,o(this,De).filter((s,a)=>a!==o(this,Ie))),d(this,Ie,-1),h(this,Ke,zi).call(this);return}((i=o(this,De)[o(this,Ie)])==null?void 0:i.url)!==r&&(d(this,De,o(this,De).map((s,a)=>a===o(this,Ie)?{url:r}:s)),h(this,Ke,zi).call(this))}back(){o(this,Ie)!==-1&&(d(this,Ie,o(this,Ie)-1),h(this,Ke,zi).call(this))}forward(){this.canGoForward&&(d(this,Ie,o(this,Ie)+1),h(this,Ke,zi).call(this))}reset(){o(this,Ie)===-1&&o(this,De).length===0||(d(this,De,[]),d(this,Ie,-1),h(this,Ke,zi).call(this))}}Cu=new WeakMap,el=new WeakMap,De=new WeakMap,Ie=new WeakMap,go=new WeakMap,Ke=new WeakSet,MS=function(){const e=localStorage.getItem(o(this,Ke,yg));if(e!==null)try{const r=JSON.parse(e);if(!zS(r))return;d(this,De,r.entries.map(i=>({url:i.url}))),d(this,Ie,r.cursor),d(this,go,r.lastWritten),h(this,Ke,vg).call(this)}catch{d(this,De,[]),d(this,Ie,-1),d(this,go,0)}},zi=function(){d(this,go,Date.now());try{localStorage.setItem(o(this,Ke,yg),JSON.stringify(h(this,Ke,NS).call(this)))}catch(e){if(!GD(e))throw e}this.dispatchEvent(new Wt("change"))},NS=function(){return{v:1,entries:o(this,De).map(e=>({...e})),cursor:o(this,Ie),lastWritten:o(this,go)}},vg=function(){if(o(this,De).length<=eb)return;const e=o(this,De).length-eb;d(this,De,o(this,De).slice(e)),d(this,Ie,Math.max(-1,o(this,Ie)-e))},yg=function(){return jD(o(this,Cu))};function jD(n){return`${gg}${n}`}function WD(n){const t=Date.now()-VD,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(gg)))continue;const s=i.slice(gg.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!zS(l)){e.push(i);continue}!n.has(s)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function GD(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function zS(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 Pm="tv-channel-sidebar-collapsed";var vo;class JD{constructor(t){m(this,vo);d(this,vo,t)}read(){return o(this,vo).getItem(Pm)==="true"}setCollapsed(t){try{t?o(this,vo).setItem(Pm,"true"):o(this,vo).removeItem(Pm)}catch{}}}vo=new WeakMap;const Dm="tv-channel-sidebar-width",wg=160,bg=350,Vh=260,YD=/^-?\d+$/;var yo;class KD{constructor(t){m(this,yo);d(this,yo,t)}read(){const t=o(this,yo).getItem(Dm);if(t===null||!YD.test(t))return null;const e=BigInt(t);return e<BigInt(wg)?wg:e>BigInt(bg)?bg:Number(e)}commit(t){const e=HS(Math.round(t));try{o(this,yo).setItem(Dm,String(e))}catch{}return e}clear(){try{o(this,yo).removeItem(Dm)}catch{}}}yo=new WeakMap;function HS(n){return Math.min(Math.max(n,wg),bg)}const XD="1.5.5";function hv(n=XD){return n!==void 0&&n.length>0?n:"0.0.0"}function dv(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const Sg="tv-reload-attempted";function QD(n){return n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:Kk(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"}}function eO(n){const t=n.getItem(Sg);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 tO(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??dv(),i=n.bundleVersion??hv();if(t===null)return{dispose(){}};let s=null;const a=()=>{if(s===null)return;const u=n.owner.connection;if(u.status!=="connected")return;const f=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:f.fromVersion,to_version:f.toVersion})},l=u=>{if(r.pending)return;const f=QD({bundleVersion:i,serverVersion:u.message.version,marker:eO(t)});switch(f.action){case"reload":t.setItem(Sg,JSON.stringify(f.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(Sg),s={fromVersion:f.fromVersion,toVersion:f.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 nO(n){const t=bi(n.search),e=L6(n.search),r=e!==null&&qf(e)?e:null;return{electron:t,shellVersion:r}}function rO(n){return!n.electron||n.requiredDesktopVersion===null||!qf(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===$d?!1:Q1(n.requiredDesktopVersion,n.shellVersion)}const iO=`# Desktop app update required
|
|
65
|
+
`)},Ta=function(e){const r=`${e}-${o(this,Ya)}`;return d(this,Ya,o(this,Ya)+1),r},cg=function(e){for(const r of o(this,rn).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===e)return r;return null},ug=function(){if(!o(this,ur))throw new Error("ACP session is not ready");return o(this,ur)},nd=function(){if(!o(this,cr))throw new Error("ACP connection is not ready");return o(this,cr)},$S=function(){var r;const e=(r=o(this,zn))==null?void 0:r.sessionCwd;if(!e)throw new Error("ACP bridge session cwd is not ready");return e},rd=function(){var r;if(o(this,dr)==="single_session")return h(this,L,dg).call(this,`${yS}-${(o(this,Zn).clientGUID??"default-client").toLowerCase()}`);const e=(r=o(this,kt))==null?void 0:r.channelID;if(!e)throw new Error("Channel context is required for per-channel session mode");return h(this,L,hg).call(this,e)},hg=function(e){return h(this,L,dg).call(this,mD(o(this,dr),e,o(this,Zn).clientGUID??"default-client"))},dg=function(e){var r;return((r=o(this,zn))==null?void 0:r.sessionIdStrategy)==="deterministic"&&o(this,Ja)>0?`${e}:epoch-${o(this,Ja)}`:e},wu=new WeakMap,bu=new WeakMap,id=function(){d(this,cr,null),d(this,Ji,null),d(this,Nn,null),d(this,Jr,null),d(this,ur,null),d(this,Hn,null),d(this,zn,null),o(this,fr)&&(o(this,fr).removeEventListener("close",o(this,wu)),o(this,fr).removeEventListener("error",o(this,bu)),o(this,fr).close(),d(this,fr,null))},Ca=function(e){const r=o(this,cr)!==null||o(this,Ji)!==null||o(this,Nn)!==null||o(this,Jr)!==null||o(this,ur)!==null||o(this,Hn)!==null||o(this,zn)!==null||o(this,fr)!==null;this.disposed||this.status==="disconnected"&&!r||(h(this,L,Ws).call(this,"error"),h(this,L,id).call(this),d(this,lr,e??null),h(this,L,Fr).call(this,"disconnected"))},fg=function(){const e=o(this,rn).size>0;d(this,hr,null),d(this,Kr,null),d(this,Ya,1),o(this,rn).clear(),e&&this.dispatchEvent(new Cm("messages-changed"))},xS=function(){return this.status==="disconnected"};function fD(){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 pD(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function mD(n,t,e){return n==="single_session"?`${yS}-${e.toLowerCase()}`:`agent:main:television-${e.toLowerCase()}-${t.toLowerCase()}`}function PS(n){return n.replace(/^(?:\s*\n)+/,"")}function G2(n){let t=n;return t=t.replace(rD,""),t=t.replace(iD,""),t=t.replace(sD,""),t=PS(t),t}function gD(n){let t=n;return t=t.replace(lD,""),t=PS(t),t}function J2(n){return!n||n.length===0?"":n.flatMap(t=>t.type==="content"&&t.content.type==="text"?[t.content.text]:[]).join("")}async function vD(n){const t=n.createSocket(_D(n.serverURL,n.token));let e=!1,r,i;const s=new Promise((u,f)=>{r=u,i=f}),a=new ReadableStream({start(u){let f=!1;const p=()=>{t.send(JSON.stringify({type:"acp-bridge-connect"}))},y=_=>{const I=SD(_);if(!I)return;let Z;try{Z=JSON.parse(I)}catch(O){const z=O instanceof Error?O:new Error(String(O));i(z),u.error(z);return}switch(Z.type){case"acp-bridge-status":if(Z.status==="ready"){let O;try{O=yD(Z)}catch(z){const P=z instanceof Error?z:new Error(String(z));e||i(P),u.error(P);return}e||(e=!0,r(O));return}if(Z.status==="error"||Z.status==="exited"){const O=new Error(Z.error??`ACP bridge ${Z.status}`);e||i(O),u.error(O)}return;case"acp-bridge-message":u.enqueue(Z.message);return}},v=()=>{var I;if(f)return;f=!0;const _=new Error("ACP bridge websocket closed");e||i(_),(I=n.onDisconnect)==null||I.call(n,_),u.close()},S=()=>{var I;if(f)return;f=!0;const _=new Error("ACP bridge websocket error");e||i(_),(I=n.onDisconnect)==null||I.call(n,_),u.error(_)};t.addEventListener("open",p),t.addEventListener("message",y),t.addEventListener("close",v),t.addEventListener("error",S)}}),l=new WritableStream({async write(u){await s,t.send(JSON.stringify({type:"acp-bridge-message",message:u}))},close(){t.close()},abort(){t.close()}}),c=await s;return{stream:{readable:a,writable:l},socket:t,metadata:c}}function yD(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&&wD(i))return{agent:t,sessionIdStrategy:e,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function wD(n){return Array.isArray(n)&&n.every(t=>typeof t=="string")}function bD(n){return aD.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function SD(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 _D(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 xm(n){return n instanceof Error?n.message:String(n)}const Y2="television.acpClientGUID",K2="television.acpMappedSessions",X2=1;var Xa;class AD{constructor(){m(this,Xa,new Map)}getActualSessionId(t){return o(this,Xa).get(t)??null}setActualSessionId(t,e){o(this,Xa).set(t,e)}clearActualSessionId(t){o(this,Xa).delete(t)}}Xa=new WeakMap;var Qa,Su,hn,sd,od,pg;class ED{constructor(t,e){m(this,hn);m(this,Qa);m(this,Su);d(this,Qa,t),d(this,Su,e)}getActualSessionId(t){const e=h(this,hn,od).call(this)[h(this,hn,sd).call(this,t)];return typeof e=="string"&&e.length>0?e:null}setActualSessionId(t,e){const r=h(this,hn,od).call(this);r[h(this,hn,sd).call(this,t)]=e,h(this,hn,pg).call(this,r)}clearActualSessionId(t){const e=h(this,hn,od).call(this);delete e[h(this,hn,sd).call(this,t)],h(this,hn,pg).call(this,e)}}Qa=new WeakMap,Su=new WeakMap,hn=new WeakSet,sd=function(t){return JSON.stringify([o(this,Su),t])},od=function(){const t=o(this,Qa).getItem(K2);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!==X2?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},pg=function(t){const e={version:X2,entries:t};o(this,Qa).setItem(K2,JSON.stringify(e))};function DS(){return typeof window>"u"?null:window.localStorage}function kD(n){const t=n.getItem(Y2);if(t)return t;const e=ev().toLowerCase();return n.setItem(Y2,e),e}const Q2=4401,TD=401,qh=1e3,CD=3e4;class ad extends Error{constructor(t="Authentication required"){super(t),this.name="AuthError"}}class RD extends Ri{constructor(e){var a,l;super();R(this,"url");R(this,"name");R(this,"telemetryMeta");R(this,"status","unauthorized");R(this,"channels",new Map);R(this,"client");R(this,"acpClient");R(this,"_token");R(this,"attempting",!1);R(this,"nextRetryAt",null);R(this,"hasEverConnected",!1);R(this,"failedReconnectAttempts",0);R(this,"browserDemoMode",!1);R(this,"hasAuthRejected",!1);R(this,"bootState","pending");R(this,"serverVersion",null);R(this,"updateState",null);R(this,"decideBoot");R(this,"navigationPending");R(this,"createSocket");R(this,"createClient");R(this,"socket",null);R(this,"connectAttempt",0);R(this,"autoReconnect",!1);R(this,"retryTimer",null);R(this,"retryDelay",qh);R(this,"visibilityEventTarget");R(this,"networkEventTarget");R(this,"onVisibilityChange");R(this,"onNetworkOnline");R(this,"telemetryActivityAgent");this.url=aa(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,f)=>new Gk(c,{token:u??void 0,onUnauthorized:()=>this.handleAuthRejected(),...f?{telemetryMeta:f}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=e.mappedSessionStore??(e.acpStorage?new ED(e.acpStorage,this.url):new AD);this.acpClient=new dD({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,s=e.telemetryWindowTarget!==void 0?e.telemetryWindowTarget:typeof window<"u"?window:null;this.telemetryActivityAgent=this.telemetryMeta&&i&&s?O$({meta:this.telemetryMeta,documentTarget:i,windowTarget:s,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.acpClient.setToken(e),this.cancelRetryTimer(),this.retryDelay=qh,this.autoReconnect=!0,await this.attempt()}dispose(){var e,r,i,s;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),(s=this.telemetryActivityAgent)==null||s.stop(),this.acpClient.dispose()}getViewURL(e){const r=ru(e,this.renderOptions());return bi()?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:bi(),browserDemo:this.browserDemoMode}}getContentURL(e){const r=ru(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 $c("channels-changed"));break;case"channel-updated":this.channels.set(e.channel.id,structuredClone(e.channel)),this.dispatchEvent(new $c("channels-changed"));break;case"channel-removed":this.channels.delete(e.channelID),this.dispatchEvent(new $c("channels-changed"));break;case"artifact-created":{const r=this.channels.get(e.channelID);r&&!fk(r).includes(e.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[e.artifact.id],geometry:{...D8},size:{...O8}}]);break}case"artifact-removed":{const r=this.channels.get(e.channelID);r&&(r.layout=Bm(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 ID(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 Wt("change"));const r=this.createSocket($D(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((s,a)=>{let l=!1,c=!1;const u=()=>{var y;l||this.connectAttempt!==e||(l=!0,c=!0,this.retryDelay=qh,this.hasEverConnected=!0,this.failedReconnectAttempts=0,this.setStatus("connected"),(y=this.telemetryActivityAgent)==null||y.start(),s())},f=y=>{l||this.connectAttempt!==e||(l=!0,a(y))},p=async()=>{const y=this.hasEverConnected;try{const[{channels:v},S,_]=await Promise.all([this.client.channels.list(),this.client.display.get(),y?null:this.readDemoMode()]);y||(this.browserDemoMode=(_==null?void 0:_.browserExternalPages)===!0),this.channels=new Map(v.map(I=>[I.id,structuredClone(I)])),this.acpClient.setEnabled(S.acpEnabled),this.dispatchEvent(new Wt("change")),y&&this.dispatchEvent(new $c("channels-changed")),this.dispatchEvent(new Qh("server-event",{event:{type:"channel-changed",channelID:S.focusedChannelId}})),this.dispatchEvent(new Qh("server-event",{event:{type:"pinned-channels-changed",pinnedChannelIds:[...S.pinnedChannelIds]}})),u(),y&&this.connectAttempt===e&&this.dispatchEvent(new Y8("server-reconnected"))}catch(v){if(MD(v)){f(new ad);return}f(v instanceof Error?v:new Error(String(v)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||p())}),r.addEventListener("message",y=>{const v=LD(y);if(!v)return;if(v.type==="server-status"){const _=v;this.serverVersion=_.version,this.updateState=_.update??null;let I=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===e&&(this.decideBoot(_)==="boot"?(this.bootState="booted",I=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new K8("server-status",{message:_})),I?this.navigationPending()||p():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new Wt("change"));return}if(!OD(v.type))return;const S=v;this.applyServerEvent(S),this.dispatchEvent(new Qh("server-event",{event:S}))}),r.addEventListener("close",y=>{if(this.connectAttempt!==e)return;this.socket=null;const v=xD(y);if(!l){f(v===Q2?new ad:new Error("Connection closed before initialization"));return}if(c){if(v===Q2){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}}),r.addEventListener("error",()=>{if(this.connectAttempt===e){if(l){if(!c)return;this.handleTransportFailure(new Error("WebSocket error"));return}f(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},s=>{throw this.attempting=!1,this.handleAttemptFailure(s),s})}handleAuthRejected(){this.hasAuthRejected=!0,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(e){if(e instanceof ad){this.handleAuthRejected();return}this.autoReconnect&&(this.hasEverConnected&&(this.failedReconnectAttempts+=1),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,CD),this.nextRetryAt=Date.now()+e,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},e),this.dispatchEvent(new Wt("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new Wt("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=qh,this.attempt().catch(()=>{})))}sendTelemetryActivity(e){var r;this.status==="connected"&&((r=this.socket)==null||r.send(JSON.stringify(e)))}sendTelemetrySignal(e,r){var s;if(!this.telemetryMeta||this.status!=="connected"&&this.bootState!=="halted")return;const i={type:dk,clientId:this.telemetryMeta.clientId,event:e,properties:r};(s=this.socket)==null||s.send(JSON.stringify(i))}setStatus(e){this.status!==e&&(this.status=e,this.dispatchEvent(new Wt("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function ID(n,t){throw new Error(`Unexpected ${t}: ${JSON.stringify(n)}`)}function $D(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,s]of D$(e))r.searchParams.set(i,s);return r.hash="",r.toString()}function xD(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const PD={"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},DD=new Set(Object.keys(PD));function OD(n){return DD.has(n)}function LD(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 MD(n){return n instanceof ec&&n.status===TD}const ND="Local";var pr,Un,Ei,OS,mg,LS,_u,Au,Eu,ku,Tu;class zD extends Ri{constructor(e){super();m(this,Ei);R(this,"connection");R(this,"clientGUID");R(this,"acpStorage");R(this,"connectError",null);m(this,pr);m(this,Un,!1);m(this,_u,()=>{o(this,Un)||(h(this,Ei,LS).call(this),this.dispatchEvent(new Wt("change")))});m(this,Au,e=>{o(this,Un)||this.dispatchEvent(new Qh("server-event",{event:e.event}))});m(this,Eu,()=>{o(this,Un)||this.dispatchEvent(new $c("channels-changed"))});m(this,ku,()=>{o(this,Un)||this.dispatchEvent(new Y8("server-reconnected"))});m(this,Tu,e=>{o(this,Un)||this.dispatchEvent(new K8("server-status",{message:e.message}))});d(this,pr,e.localStore),this.acpStorage=e.acpStorage===void 0?DS():e.acpStorage,this.clientGUID=e.clientGUID??(this.acpStorage?kD(this.acpStorage):ev().toLowerCase());const r=aa(e.serverURL);e.launchToken!==void 0&&e.launchToken!==null&&o(this,pr).set(kT(o(this,pr).get(),r,e.launchToken));const i=e.launchToken??b2(o(this,pr).get(),r),s=e.createSocket??(l=>new WebSocket(l)),a=e.createConnection??(l=>new RD(l));this.connection=a({url:r,name:e.connectionName??ND,token:i,createSocket:s,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:e.telemetryMeta??null,decideBoot:e.decideBoot,navigationPending:e.navigationPending}),this.connection.addEventListener("change",o(this,_u)),this.connection.addEventListener("server-event",o(this,Au)),this.connection.addEventListener("channels-changed",o(this,Eu)),this.connection.addEventListener("server-reconnected",o(this,ku)),this.connection.addEventListener("server-status",o(this,Tu))}get storedAuthToken(){return b2(o(this,pr).get(),this.connection.url)}async connect(){await h(this,Ei,OS).call(this,this.connection.token)}dispose(){o(this,Un)||(d(this,Un,!0),this.connection.removeEventListener("change",o(this,_u)),this.connection.removeEventListener("server-event",o(this,Au)),this.connection.removeEventListener("channels-changed",o(this,Eu)),this.connection.removeEventListener("server-reconnected",o(this,ku)),this.connection.removeEventListener("server-status",o(this,Tu)),this.connection.dispose())}}pr=new WeakMap,Un=new WeakMap,Ei=new WeakSet,OS=async function(e){if(!o(this,Un)){h(this,Ei,mg).call(this,null);try{await this.connection.connect(e)}catch(r){h(this,Ei,mg).call(this,r instanceof ad?null:r instanceof Error?r.message:String(r))}}},mg=function(e){this.connectError!==e&&(this.connectError=e,this.dispatchEvent(new Wt("change")))},LS=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const e=o(this,pr).get(),r=TT(e,this.connection.url);r!==e&&o(this,pr).set(r),this.connection.token!==null&&this.connection.clearToken()},_u=new WeakMap,Au=new WeakMap,Eu=new WeakMap,ku=new WeakMap,Tu=new WeakMap;const gg="tv-nav:",Bl="tv-reload",eb=100,HD=1e3,ZD=60,UD=60,FD=24,qD=30,VD=qD*FD*UD*ZD*HD;function Si(n){try{const t=new URL(n,window.location.href),e=t.searchParams.has(Bl);return t.searchParams.delete(Bl),t.origin===window.location.origin?`${t.pathname}${t.search}${t.hash}`:e?t.toString():n}catch{return n}}var Cu,el,De,Ie,go,Ke,MS,zi,NS,vg,yg;class BD extends Ri{constructor(e,r){super();m(this,Ke);m(this,Cu);m(this,el);m(this,De,[]);m(this,Ie,-1);m(this,go,0);d(this,Cu,e),d(this,el,Si(r)),h(this,Ke,MS).call(this)}get currentURL(){var e;return o(this,Ie)===-1?null:((e=o(this,De)[o(this,Ie)])==null?void 0:e.url)??null}get canGoBack(){return o(this,Ie)>-1}get canGoForward(){return o(this,Ie)<o(this,De).length-1}get entries(){return o(this,De).map(e=>({...e}))}get cursor(){return o(this,Ie)}navigate(e){const r=Si(e);if(r===o(this,el)){if(o(this,Ie)===-1)return;d(this,Ie,-1),h(this,Ke,zi).call(this);return}o(this,Ie)<o(this,De).length-1&&d(this,De,o(this,De).slice(0,o(this,Ie)+1)),o(this,De).push({url:r}),d(this,Ie,o(this,De).length-1),h(this,Ke,vg).call(this),h(this,Ke,zi).call(this)}replace(e){var i;if(o(this,Ie)===-1){this.navigate(e);return}const r=Si(e);if(r===o(this,el)){d(this,De,o(this,De).filter((s,a)=>a!==o(this,Ie))),d(this,Ie,-1),h(this,Ke,zi).call(this);return}((i=o(this,De)[o(this,Ie)])==null?void 0:i.url)!==r&&(d(this,De,o(this,De).map((s,a)=>a===o(this,Ie)?{url:r}:s)),h(this,Ke,zi).call(this))}back(){o(this,Ie)!==-1&&(d(this,Ie,o(this,Ie)-1),h(this,Ke,zi).call(this))}forward(){this.canGoForward&&(d(this,Ie,o(this,Ie)+1),h(this,Ke,zi).call(this))}reset(){o(this,Ie)===-1&&o(this,De).length===0||(d(this,De,[]),d(this,Ie,-1),h(this,Ke,zi).call(this))}}Cu=new WeakMap,el=new WeakMap,De=new WeakMap,Ie=new WeakMap,go=new WeakMap,Ke=new WeakSet,MS=function(){const e=localStorage.getItem(o(this,Ke,yg));if(e!==null)try{const r=JSON.parse(e);if(!zS(r))return;d(this,De,r.entries.map(i=>({url:i.url}))),d(this,Ie,r.cursor),d(this,go,r.lastWritten),h(this,Ke,vg).call(this)}catch{d(this,De,[]),d(this,Ie,-1),d(this,go,0)}},zi=function(){d(this,go,Date.now());try{localStorage.setItem(o(this,Ke,yg),JSON.stringify(h(this,Ke,NS).call(this)))}catch(e){if(!GD(e))throw e}this.dispatchEvent(new Wt("change"))},NS=function(){return{v:1,entries:o(this,De).map(e=>({...e})),cursor:o(this,Ie),lastWritten:o(this,go)}},vg=function(){if(o(this,De).length<=eb)return;const e=o(this,De).length-eb;d(this,De,o(this,De).slice(e)),d(this,Ie,Math.max(-1,o(this,Ie)-e))},yg=function(){return jD(o(this,Cu))};function jD(n){return`${gg}${n}`}function WD(n){const t=Date.now()-VD,e=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(gg)))continue;const s=i.slice(gg.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{e.push(i);continue}if(!zS(l)){e.push(i);continue}!n.has(s)&&l.lastWritten<t&&e.push(i)}for(const r of e)localStorage.removeItem(r)}function GD(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function zS(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 Pm="tv-channel-sidebar-collapsed";var vo;class JD{constructor(t){m(this,vo);d(this,vo,t)}read(){return o(this,vo).getItem(Pm)==="true"}setCollapsed(t){try{t?o(this,vo).setItem(Pm,"true"):o(this,vo).removeItem(Pm)}catch{}}}vo=new WeakMap;const Dm="tv-channel-sidebar-width",wg=160,bg=350,Vh=260,YD=/^-?\d+$/;var yo;class KD{constructor(t){m(this,yo);d(this,yo,t)}read(){const t=o(this,yo).getItem(Dm);if(t===null||!YD.test(t))return null;const e=BigInt(t);return e<BigInt(wg)?wg:e>BigInt(bg)?bg:Number(e)}commit(t){const e=HS(Math.round(t));try{o(this,yo).setItem(Dm,String(e))}catch{}return e}clear(){try{o(this,yo).removeItem(Dm)}catch{}}}yo=new WeakMap;function HS(n){return Math.min(Math.max(n,wg),bg)}const XD="1.5.7";function hv(n=XD){return n!==void 0&&n.length>0?n:"0.0.0"}function dv(){let n=!1;return{get pending(){return n},begin(t){n||(n=!0,t())}}}const Sg="tv-reload-attempted";function QD(n){return n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:Kk(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"}}function eO(n){const t=n.getItem(Sg);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 tO(n){const t=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,e=n.reload??(()=>location.reload()),r=n.navigationLatch??dv(),i=n.bundleVersion??hv();if(t===null)return{dispose(){}};let s=null;const a=()=>{if(s===null)return;const u=n.owner.connection;if(u.status!=="connected")return;const f=s;s=null,u.sendTelemetrySignal("client_autoreloaded",{from_version:f.fromVersion,to_version:f.toVersion})},l=u=>{if(r.pending)return;const f=QD({bundleVersion:i,serverVersion:u.message.version,marker:eO(t)});switch(f.action){case"reload":t.setItem(Sg,JSON.stringify(f.marker)),r.begin(e);return;case"signal-autoreloaded":t.removeItem(Sg),s={fromVersion:f.fromVersion,toVersion:f.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 nO(n){const t=bi(n.search),e=L6(n.search),r=e!==null&&qf(e)?e:null;return{electron:t,shellVersion:r}}function rO(n){return!n.electron||n.requiredDesktopVersion===null||!qf(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===$d?!1:Q1(n.requiredDesktopVersion,n.shellVersion)}const iO=`# Desktop app update required
|
|
66
66
|
|
|
67
67
|
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.`,sO=`# Desktop app update required
|
|
68
68
|
|
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-BZqXOBKL.js"></script>
|
|
44
44
|
<link rel="modulepreload" crossorigin href="./assets/artifact-bridge-DTPacxDw.js">
|
|
45
45
|
<link rel="modulepreload" crossorigin href="./assets/missing-artifact-page-DVzJ41AE.js">
|
|
46
46
|
<link rel="stylesheet" crossorigin href="./assets/main-CunC2_Nx.css">
|