@telepath-computer/television 1.4.8 → 1.4.9

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
@@ -54125,7 +54125,7 @@ function disabledTelemetryRuntime() {
54125
54125
 
54126
54126
  // ../server/src/updates/version.ts
54127
54127
  function readVersionStamp() {
54128
- if ("1.4.8".length > 0) return "1.4.8";
54128
+ if ("1.4.9".length > 0) return "1.4.9";
54129
54129
  return void 0;
54130
54130
  }
54131
54131
  function resolveUpdateReleaseVersion(env = process.env, stamp = readVersionStamp()) {
@@ -54667,8 +54667,8 @@ var Server = class {
54667
54667
  };
54668
54668
  };
54669
54669
  function readServerPackageVersion() {
54670
- if ("1.4.8".length > 0) {
54671
- return telemetryVersion("1.4.8");
54670
+ if ("1.4.9".length > 0) {
54671
+ return telemetryVersion("1.4.9");
54672
54672
  }
54673
54673
  const packageJsonPath = import_node_path13.default.resolve(import_node_path13.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)), "..", "package.json");
54674
54674
  if (!(0, import_node_fs11.existsSync)(packageJsonPath)) return telemetryVersion("0.0.0");
@@ -56897,8 +56897,8 @@ function resolveVercelSkillsInstallerBin() {
56897
56897
  return localRequire.resolve("skills/bin/cli.mjs");
56898
56898
  }
56899
56899
  function readCLIVersion() {
56900
- if ("1.4.8".length > 0) {
56901
- return "1.4.8";
56900
+ if ("1.4.9".length > 0) {
56901
+ return "1.4.9";
56902
56902
  }
56903
56903
  const devPackageJsonPath = import_node_path20.default.join(getDevPackageDir(), "package.json");
56904
56904
  if (!(0, import_node_fs18.existsSync)(devPackageJsonPath)) {
@@ -40,7 +40,7 @@ var __=Object.defineProperty;var T1=n=>{throw TypeError(n)};var A_=(n,e,t)=>e in
40
40
  `)}v.write("payload.value = newResult;"),v.write("return payload;");const P=v.compile();return(O,Y)=>P(y,O,Y)};let o;const a=fc,l=!r8.jitless,d=l&&f$.value,f=e.catchall;let g;n._zod.parse=(y,v)=>{g??(g=r.value);const _=y.value;return a(_)?l&&d&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(o||(o=i(e.shape)),y=o(y,v),f?b8([],_,y,v,g,n):y):t(y,v):(y.issues.push({expected:"object",code:"invalid_type",input:_,inst:n}),y)}});function hy(n,e,t,r){for(const o of n)if(o.issues.length===0)return e.value=o.value,e;const i=n.filter(o=>!Wo(o));return i.length===1?(e.value=i[0].value,i[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(o=>o.issues.map(a=>qi(a,r,Bi())))}),e)}const S8=k("$ZodUnion",(n,e)=>{Ee.init(n,e),ue(n._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),ue(n._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),ue(n._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),ue(n._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){const i=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>Rg(o.source)).join("|")})$`)}});const t=e.options.length===1,r=e.options[0]._zod.run;n._zod.parse=(i,o)=>{if(t)return r(i,o);let a=!1;const l=[];for(const c of e.options){const d=c._zod.run({value:i.value,issues:[]},o);if(d instanceof Promise)l.push(d),a=!0;else{if(d.issues.length===0)return d;l.push(d)}}return a?Promise.all(l).then(c=>hy(c,i,n,o)):hy(l,i,n,o)}}),eI=k("$ZodDiscriminatedUnion",(n,e)=>{e.inclusive=!1,S8.init(n,e);const t=n._zod.parse;ue(n._zod,"propValues",()=>{const i={};for(const o of e.options){const a=o._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(const[l,c]of Object.entries(a)){i[l]||(i[l]=new Set);for(const d of c)i[l].add(d)}}return i});const r=Np(()=>{var a;const i=e.options,o=new Map;for(const l of i){const c=(a=l._zod.propValues)==null?void 0:a[e.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(l)}"`);for(const d of c){if(o.has(d))throw new Error(`Duplicate discriminator value "${String(d)}"`);o.set(d,l)}}return o});n._zod.parse=(i,o)=>{const a=i.value;if(!fc(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[e.discriminator]);return l?l._zod.run(i,o):e.unionFallback?t(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,input:a,path:[e.discriminator],inst:n}),i)}}),tI=k("$ZodIntersection",(n,e)=>{Ee.init(n,e),n._zod.parse=(t,r)=>{const i=t.value,o=e.left._zod.run({value:i,issues:[]},r),a=e.right._zod.run({value:i,issues:[]},r);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,d])=>dy(t,c,d)):dy(t,o,a)}});function A0(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n==+e)return{valid:!0,data:n};if(el(n)&&el(e)){const t=Object.keys(e),r=Object.keys(n).filter(o=>t.indexOf(o)!==-1),i={...n,...e};for(const o of r){const a=A0(n[o],e[o]);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};i[o]=a.data}return{valid:!0,data:i}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};const t=[];for(let r=0;r<n.length;r++){const i=n[r],o=e[r],a=A0(i,o);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};t.push(a.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function dy(n,e,t){const r=new Map;let i;for(const l of e.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 t.issues)if(l.code==="unrecognized_keys")for(const c of l.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else n.issues.push(l);const o=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(o.length&&i&&n.issues.push({...i,keys:o}),Wo(n))return n;const a=A0(e.value,t.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return n.value=a.data,n}const nI=k("$ZodRecord",(n,e)=>{Ee.init(n,e),n._zod.parse=(t,r)=>{const i=t.value;if(!el(i))return t.issues.push({expected:"record",code:"invalid_type",input:i,inst:n}),t;const o=[],a=e.keyType._zod.values;if(a){t.value={};const l=new Set;for(const d of a)if(typeof d=="string"||typeof d=="number"||typeof d=="symbol"){l.add(typeof d=="number"?d.toString():d);const f=e.valueType._zod.run({value:i[d],issues:[]},r);f instanceof Promise?o.push(f.then(g=>{g.issues.length&&t.issues.push(...jo(d,g.issues)),t.value[d]=g.value})):(f.issues.length&&t.issues.push(...jo(d,f.issues)),t.value[d]=f.value)}let c;for(const d in i)l.has(d)||(c=c??[],c.push(d));c&&c.length>0&&t.issues.push({code:"unrecognized_keys",input:i,inst:n,keys:c})}else{t.value={};for(const l of Reflect.ownKeys(i)){if(l==="__proto__")continue;let c=e.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"&&p8.test(l)&&c.issues.length){const g=e.keyType._zod.run({value:Number(l),issues:[]},r);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(c=g)}if(c.issues.length){e.mode==="loose"?t.value[l]=i[l]:t.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(g=>qi(g,r,Bi())),input:l,path:[l],inst:n});continue}const f=e.valueType._zod.run({value:i[l],issues:[]},r);f instanceof Promise?o.push(f.then(g=>{g.issues.length&&t.issues.push(...jo(l,g.issues)),t.value[c.value]=g.value})):(f.issues.length&&t.issues.push(...jo(l,f.issues)),t.value[c.value]=f.value)}}return o.length?Promise.all(o).then(()=>t):t}}),rI=k("$ZodEnum",(n,e)=>{Ee.init(n,e);const t=i8(e.entries),r=new Set(t);n._zod.values=r,n._zod.pattern=new RegExp(`^(${t.filter(i=>m$.has(typeof i)).map(i=>typeof i=="string"?tl(i):i.toString()).join("|")})$`),n._zod.parse=(i,o)=>{const a=i.value;return r.has(a)||i.issues.push({code:"invalid_value",values:t,input:a,inst:n}),i}}),iI=k("$ZodLiteral",(n,e)=>{if(Ee.init(n,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");const t=new Set(e.values);n._zod.values=t,n._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?tl(r):r?tl(r.toString()):String(r)).join("|")})$`),n._zod.parse=(r,i)=>{const o=r.value;return t.has(o)||r.issues.push({code:"invalid_value",values:e.values,input:o,inst:n}),r}}),sI=k("$ZodTransform",(n,e)=>{Ee.init(n,e),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new n8(n.constructor.name);const i=e.transform(t.value,t);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(t.value=a,t));if(i instanceof Promise)throw new Ko;return t.value=i,t}});function py(n,e){return n.issues.length&&e===void 0?{issues:[],value:void 0}:n}const _8=k("$ZodOptional",(n,e)=>{Ee.init(n,e),n._zod.optin="optional",n._zod.optout="optional",ue(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ue(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${Rg(t.source)})?$`):void 0}),n._zod.parse=(t,r)=>{if(e.innerType._zod.optin==="optional"){const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(o=>py(o,t.value)):py(i,t.value)}return t.value===void 0?t:e.innerType._zod.run(t,r)}}),oI=k("$ZodExactOptional",(n,e)=>{_8.init(n,e),ue(n._zod,"values",()=>e.innerType._zod.values),ue(n._zod,"pattern",()=>e.innerType._zod.pattern),n._zod.parse=(t,r)=>e.innerType._zod.run(t,r)}),aI=k("$ZodNullable",(n,e)=>{Ee.init(n,e),ue(n._zod,"optin",()=>e.innerType._zod.optin),ue(n._zod,"optout",()=>e.innerType._zod.optout),ue(n._zod,"pattern",()=>{const t=e.innerType._zod.pattern;return t?new RegExp(`^(${Rg(t.source)}|null)$`):void 0}),ue(n._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),n._zod.parse=(t,r)=>t.value===null?t:e.innerType._zod.run(t,r)}),lI=k("$ZodDefault",(n,e)=>{Ee.init(n,e),n._zod.optin="optional",ue(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);if(t.value===void 0)return t.value=e.defaultValue,t;const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(o=>fy(o,e)):fy(i,e)}});function fy(n,e){return n.value===void 0&&(n.value=e.defaultValue),n}const cI=k("$ZodPrefault",(n,e)=>{Ee.init(n,e),n._zod.optin="optional",ue(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>(r.direction==="backward"||t.value===void 0&&(t.value=e.defaultValue),e.innerType._zod.run(t,r))}),uI=k("$ZodNonOptional",(n,e)=>{Ee.init(n,e),ue(n._zod,"values",()=>{const t=e.innerType._zod.values;return t?new Set([...t].filter(r=>r!==void 0)):void 0}),n._zod.parse=(t,r)=>{const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(o=>my(o,n)):my(i,n)}});function my(n,e){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}const hI=k("$ZodCatch",(n,e)=>{Ee.init(n,e),ue(n._zod,"optin",()=>e.innerType._zod.optin),ue(n._zod,"optout",()=>e.innerType._zod.optout),ue(n._zod,"values",()=>e.innerType._zod.values),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(o=>(t.value=o.value,o.issues.length&&(t.value=e.catchValue({...t,error:{issues:o.issues.map(a=>qi(a,r,Bi()))},input:t.value}),t.issues=[]),t)):(t.value=i.value,i.issues.length&&(t.value=e.catchValue({...t,error:{issues:i.issues.map(o=>qi(o,r,Bi()))},input:t.value}),t.issues=[]),t)}}),dI=k("$ZodPipe",(n,e)=>{Ee.init(n,e),ue(n._zod,"values",()=>e.in._zod.values),ue(n._zod,"optin",()=>e.in._zod.optin),ue(n._zod,"optout",()=>e.out._zod.optout),ue(n._zod,"propValues",()=>e.in._zod.propValues),n._zod.parse=(t,r)=>{if(r.direction==="backward"){const o=e.out._zod.run(t,r);return o instanceof Promise?o.then(a=>dh(a,e.in,r)):dh(o,e.in,r)}const i=e.in._zod.run(t,r);return i instanceof Promise?i.then(o=>dh(o,e.out,r)):dh(i,e.out,r)}});function dh(n,e,t){return n.issues.length?(n.aborted=!0,n):e._zod.run({value:n.value,issues:n.issues},t)}const pI=k("$ZodReadonly",(n,e)=>{Ee.init(n,e),ue(n._zod,"propValues",()=>e.innerType._zod.propValues),ue(n._zod,"values",()=>e.innerType._zod.values),ue(n._zod,"optin",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optin}),ue(n._zod,"optout",()=>{var t,r;return(r=(t=e.innerType)==null?void 0:t._zod)==null?void 0:r.optout}),n._zod.parse=(t,r)=>{if(r.direction==="backward")return e.innerType._zod.run(t,r);const i=e.innerType._zod.run(t,r);return i instanceof Promise?i.then(gy):gy(i)}});function gy(n){return n.value=Object.freeze(n.value),n}const fI=k("$ZodCustom",(n,e)=>{Ct.init(n,e),Ee.init(n,e),n._zod.parse=(t,r)=>t,n._zod.check=t=>{const r=t.value,i=e.fn(r);if(i instanceof Promise)return i.then(o=>vy(o,t,r,n));vy(i,t,r,n)}});function vy(n,e,t,r){if(!n){const i={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(mc(i))}}var yy;class mI{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&typeof t=="object"&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const i={...r,...this._map.get(e)};return Object.keys(i).length?i:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function gI(){return new mI}(yy=globalThis).__zod_globalRegistry??(yy.__zod_globalRegistry=gI());const Vl=globalThis.__zod_globalRegistry;function vI(n,e){return new n({type:"string",...H(e)})}function yI(n,e){return new n({type:"string",format:"email",check:"string_format",abort:!1,...H(e)})}function wy(n,e){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...H(e)})}function wI(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...H(e)})}function bI(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...H(e)})}function SI(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...H(e)})}function _I(n,e){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...H(e)})}function AI(n,e){return new n({type:"string",format:"url",check:"string_format",abort:!1,...H(e)})}function EI(n,e){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...H(e)})}function kI(n,e){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...H(e)})}function CI(n,e){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...H(e)})}function TI(n,e){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...H(e)})}function $I(n,e){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...H(e)})}function RI(n,e){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...H(e)})}function II(n,e){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...H(e)})}function xI(n,e){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...H(e)})}function PI(n,e){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...H(e)})}function LI(n,e){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...H(e)})}function DI(n,e){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...H(e)})}function MI(n,e){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...H(e)})}function OI(n,e){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...H(e)})}function NI(n,e){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...H(e)})}function zI(n,e){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...H(e)})}function ZI(n,e){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...H(e)})}function HI(n,e){return new n({type:"string",format:"date",check:"string_format",...H(e)})}function UI(n,e){return new n({type:"string",format:"time",check:"string_format",precision:null,...H(e)})}function VI(n,e){return new n({type:"string",format:"duration",check:"string_format",...H(e)})}function FI(n,e){return new n({type:"number",checks:[],...H(e)})}function BI(n,e){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...H(e)})}function qI(n,e){return new n({type:"boolean",...H(e)})}function WI(n){return new n({type:"unknown"})}function jI(n,e){return new n({type:"never",...H(e)})}function by(n,e){return new m8({check:"less_than",...H(e),value:n,inclusive:!1})}function Vf(n,e){return new m8({check:"less_than",...H(e),value:n,inclusive:!0})}function Sy(n,e){return new g8({check:"greater_than",...H(e),value:n,inclusive:!1})}function Ff(n,e){return new g8({check:"greater_than",...H(e),value:n,inclusive:!0})}function _y(n,e){return new lR({check:"multiple_of",...H(e),value:n})}function A8(n,e){return new uR({check:"max_length",...H(e),maximum:n})}function Sd(n,e){return new hR({check:"min_length",...H(e),minimum:n})}function E8(n,e){return new dR({check:"length_equals",...H(e),length:n})}function GI(n,e){return new pR({check:"string_format",format:"regex",...H(e),pattern:n})}function YI(n){return new fR({check:"string_format",format:"lowercase",...H(n)})}function JI(n){return new mR({check:"string_format",format:"uppercase",...H(n)})}function KI(n,e){return new gR({check:"string_format",format:"includes",...H(e),includes:n})}function XI(n,e){return new vR({check:"string_format",format:"starts_with",...H(e),prefix:n})}function QI(n,e){return new yR({check:"string_format",format:"ends_with",...H(e),suffix:n})}function fl(n){return new wR({check:"overwrite",tx:n})}function ex(n){return fl(e=>e.normalize(n))}function tx(){return fl(n=>n.trim())}function nx(){return fl(n=>n.toLowerCase())}function rx(){return fl(n=>n.toUpperCase())}function ix(){return fl(n=>p$(n))}function sx(n,e,t){return new n({type:"array",element:e,...H(t)})}function ox(n,e,t){return new n({type:"custom",check:"custom",fn:e,...H(t)})}function ax(n){const e=lx(t=>(t.addIssue=r=>{if(typeof r=="string")t.issues.push(mc(r,t.value,e._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=t.value),i.inst??(i.inst=e),i.continue??(i.continue=!e._zod.def.abort),t.issues.push(mc(i))}},n(t.value,t)));return e}function lx(n,e){const t=new Ct({check:"custom",...H(e)});return t._zod.check=n,t}function k8(n){let e=(n==null?void 0:n.target)??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:n.processors??{},metadataRegistry:(n==null?void 0:n.metadata)??Vl,target:e,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 Le(n,e,t={path:[],schemaPath:[]}){var f,g;var r;const i=n._zod.def,o=e.seen.get(n);if(o)return o.count++,t.schemaPath.includes(n)&&(o.cycle=t.path),o.schema;const a={schema:{},count:1,cycle:void 0,path:t.path};e.seen.set(n,a);const l=(g=(f=n._zod).toJSONSchema)==null?void 0:g.call(f);if(l)a.schema=l;else{const y={...t,schemaPath:[...t.schemaPath,n],path:t.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(e,a.schema,y);else{const _=a.schema,E=e.processors[i.type];if(!E)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);E(n,e,_,y)}const v=n._zod.parent;v&&(a.ref||(a.ref=v),Le(v,e,y),e.seen.get(v).isParent=!0)}const c=e.metadataRegistry.get(n);return c&&Object.assign(a.schema,c),e.io==="input"&&et(n)&&(delete a.schema.examples,delete a.schema.default),e.io==="input"&&a.schema._prefault&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,e.seen.get(n).schema}function C8(n,e){var a,l,c,d;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const f of n.seen.entries()){const g=(a=n.metadataRegistry.get(f[0]))==null?void 0:a.id;if(g){const y=r.get(g);if(y&&y!==f[0])throw new Error(`Duplicate schema id "${g}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(g,f[0])}}const i=f=>{var E;const g=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const x=(E=n.external.registry.get(f[0]))==null?void 0:E.id,B=n.external.uri??(J=>J);if(x)return{ref:B(x)};const P=f[1].defId??f[1].schema.id??`schema${n.counter++}`;return f[1].defId=P,{defId:P,ref:`${B("__shared")}#/${g}/${P}`}}if(f[1]===t)return{ref:"#"};const v=`#/${g}/`,_=f[1].schema.id??`__schema${n.counter++}`;return{defId:_,ref:v+_}},o=f=>{if(f[1].schema.$ref)return;const g=f[1],{ref:y,defId:v}=i(f);g.def={...g.schema},v&&(g.defId=v);const _=g.schema;for(const E in _)delete _[E];_.$ref=y};if(n.cycles==="throw")for(const f of n.seen.entries()){const g=f[1];if(g.cycle)throw new Error(`Cycle detected: #/${(l=g.cycle)==null?void 0:l.join("/")}/<root>
41
41
 
42
42
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of n.seen.entries()){const g=f[1];if(e===f[0]){o(f);continue}if(n.external){const v=(c=n.external.registry.get(f[0]))==null?void 0:c.id;if(e!==f[0]&&v){o(f);continue}}if((d=n.metadataRegistry.get(f[0]))==null?void 0:d.id){o(f);continue}if(g.cycle){o(f);continue}if(g.count>1&&n.reused==="ref"){o(f);continue}}}function T8(n,e){var a,l,c;const t=n.seen.get(e);if(!t)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=d=>{const f=n.seen.get(d);if(f.ref===null)return;const g=f.def??f.schema,y={...g},v=f.ref;if(f.ref=null,v){r(v);const E=n.seen.get(v),x=E.schema;if(x.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(g.allOf=g.allOf??[],g.allOf.push(x)):Object.assign(g,x),Object.assign(g,y),d._zod.parent===v)for(const P in g)P==="$ref"||P==="allOf"||P in y||delete g[P];if(x.$ref&&E.def)for(const P in g)P==="$ref"||P==="allOf"||P in E.def&&JSON.stringify(g[P])===JSON.stringify(E.def[P])&&delete g[P]}const _=d._zod.parent;if(_&&_!==v){r(_);const E=n.seen.get(_);if(E!=null&&E.schema.$ref&&(g.$ref=E.schema.$ref,E.def))for(const x in g)x==="$ref"||x==="allOf"||x in E.def&&JSON.stringify(g[x])===JSON.stringify(E.def[x])&&delete g[x]}n.override({zodSchema:d,jsonSchema:g,path:f.path??[]})};for(const d of[...n.seen.entries()].reverse())r(d[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 d=(l=n.external.registry.get(e))==null?void 0:l.id;if(!d)throw new Error("Schema is missing an `id` property");i.$id=n.external.uri(d)}Object.assign(i,t.def??t.schema);const o=((c=n.external)==null?void 0:c.defs)??{};for(const d of n.seen.entries()){const f=d[1];f.def&&f.defId&&(o[f.defId]=f.def)}n.external||Object.keys(o).length>0&&(n.target==="draft-2020-12"?i.$defs=o:i.definitions=o);try{const d=JSON.parse(JSON.stringify(i));return Object.defineProperty(d,"~standard",{value:{...e["~standard"],jsonSchema:{input:_d(e,"input",n.processors),output:_d(e,"output",n.processors)}},enumerable:!1,writable:!1}),d}catch{throw new Error("Error converting schema to JSON.")}}function et(n,e){const t=e??{seen:new Set};if(t.seen.has(n))return!1;t.seen.add(n);const r=n._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return et(r.element,t);if(r.type==="set")return et(r.valueType,t);if(r.type==="lazy")return et(r.getter(),t);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,t);if(r.type==="intersection")return et(r.left,t)||et(r.right,t);if(r.type==="record"||r.type==="map")return et(r.keyType,t)||et(r.valueType,t);if(r.type==="pipe")return et(r.in,t)||et(r.out,t);if(r.type==="object"){for(const i in r.shape)if(et(r.shape[i],t))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(et(i,t))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(et(i,t))return!0;return!!(r.rest&&et(r.rest,t))}return!1}const cx=(n,e={})=>t=>{const r=k8({...t,processors:e});return Le(n,r),C8(r,n),T8(r,n)},_d=(n,e,t={})=>r=>{const{libraryOptions:i,target:o}=r??{},a=k8({...i??{},target:o,io:e,processors:t});return Le(n,a),C8(a,n),T8(a,n)},ux={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},hx=(n,e,t,r)=>{const i=t;i.type="string";const{minimum:o,maximum:a,format:l,patterns:c,contentEncoding:d}=n._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof a=="number"&&(i.maxLength=a),l&&(i.format=ux[l]??l,i.format===""&&delete i.format,l==="time"&&delete i.format),d&&(i.contentEncoding=d),c&&c.size>0){const f=[...c];f.length===1?i.pattern=f[0].source:f.length>1&&(i.allOf=[...f.map(g=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},dx=(n,e,t,r)=>{const i=t,{minimum:o,maximum:a,format:l,multipleOf:c,exclusiveMaximum:d,exclusiveMinimum:f}=n._zod.bag;typeof l=="string"&&l.includes("int")?i.type="integer":i.type="number",typeof f=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.minimum=f,i.exclusiveMinimum=!0):i.exclusiveMinimum=f),typeof o=="number"&&(i.minimum=o,typeof f=="number"&&e.target!=="draft-04"&&(f>=o?delete i.minimum:delete i.exclusiveMinimum)),typeof d=="number"&&(e.target==="draft-04"||e.target==="openapi-3.0"?(i.maximum=d,i.exclusiveMaximum=!0):i.exclusiveMaximum=d),typeof a=="number"&&(i.maximum=a,typeof d=="number"&&e.target!=="draft-04"&&(d<=a?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},px=(n,e,t,r)=>{t.type="boolean"},fx=(n,e,t,r)=>{t.not={}},mx=(n,e,t,r)=>{},gx=(n,e,t,r)=>{const i=n._zod.def,o=i8(i.entries);o.every(a=>typeof a=="number")&&(t.type="number"),o.every(a=>typeof a=="string")&&(t.type="string"),t.enum=o},vx=(n,e,t,r)=>{const i=n._zod.def,o=[];for(const a of i.values)if(a===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){const a=o[0];t.type=a===null?"null":typeof a,e.target==="draft-04"||e.target==="openapi-3.0"?t.enum=[a]:t.const=a}else o.every(a=>typeof a=="number")&&(t.type="number"),o.every(a=>typeof a=="string")&&(t.type="string"),o.every(a=>typeof a=="boolean")&&(t.type="boolean"),o.every(a=>a===null)&&(t.type="null"),t.enum=o},yx=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},wx=(n,e,t,r)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},bx=(n,e,t,r)=>{const i=t,o=n._zod.def,{minimum:a,maximum:l}=n._zod.bag;typeof a=="number"&&(i.minItems=a),typeof l=="number"&&(i.maxItems=l),i.type="array",i.items=Le(o.element,e,{...r,path:[...r.path,"items"]})},Sx=(n,e,t,r)=>{var d;const i=t,o=n._zod.def;i.type="object",i.properties={};const a=o.shape;for(const f in a)i.properties[f]=Le(a[f],e,{...r,path:[...r.path,"properties",f]});const l=new Set(Object.keys(a)),c=new Set([...l].filter(f=>{const g=o.shape[f]._zod;return e.io==="input"?g.optin===void 0:g.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((d=o.catchall)==null?void 0:d._zod.def.type)==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=Le(o.catchall,e,{...r,path:[...r.path,"additionalProperties"]})):e.io==="output"&&(i.additionalProperties=!1)},_x=(n,e,t,r)=>{const i=n._zod.def,o=i.inclusive===!1,a=i.options.map((l,c)=>Le(l,e,{...r,path:[...r.path,o?"oneOf":"anyOf",c]}));o?t.oneOf=a:t.anyOf=a},Ax=(n,e,t,r)=>{const i=n._zod.def,o=Le(i.left,e,{...r,path:[...r.path,"allOf",0]}),a=Le(i.right,e,{...r,path:[...r.path,"allOf",1]}),l=d=>"allOf"in d&&Object.keys(d).length===1,c=[...l(o)?o.allOf:[o],...l(a)?a.allOf:[a]];t.allOf=c},Ex=(n,e,t,r)=>{const i=t,o=n._zod.def;i.type="object";const a=o.keyType,l=a._zod.bag,c=l==null?void 0:l.patterns;if(o.mode==="loose"&&c&&c.size>0){const f=Le(o.valueType,e,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const g of c)i.patternProperties[g.source]=f}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(i.propertyNames=Le(o.keyType,e,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=Le(o.valueType,e,{...r,path:[...r.path,"additionalProperties"]});const d=a._zod.values;if(d){const f=[...d].filter(g=>typeof g=="string"||typeof g=="number");f.length>0&&(i.required=f)}},kx=(n,e,t,r)=>{const i=n._zod.def,o=Le(i.innerType,e,r),a=e.seen.get(n);e.target==="openapi-3.0"?(a.ref=i.innerType,t.nullable=!0):t.anyOf=[o,{type:"null"}]},Cx=(n,e,t,r)=>{const i=n._zod.def;Le(i.innerType,e,r);const o=e.seen.get(n);o.ref=i.innerType},Tx=(n,e,t,r)=>{const i=n._zod.def;Le(i.innerType,e,r);const o=e.seen.get(n);o.ref=i.innerType,t.default=JSON.parse(JSON.stringify(i.defaultValue))},$x=(n,e,t,r)=>{const i=n._zod.def;Le(i.innerType,e,r);const o=e.seen.get(n);o.ref=i.innerType,e.io==="input"&&(t._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Rx=(n,e,t,r)=>{const i=n._zod.def;Le(i.innerType,e,r);const o=e.seen.get(n);o.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}t.default=a},Ix=(n,e,t,r)=>{const i=n._zod.def,o=e.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;Le(o,e,r);const a=e.seen.get(n);a.ref=o},xx=(n,e,t,r)=>{const i=n._zod.def;Le(i.innerType,e,r);const o=e.seen.get(n);o.ref=i.innerType,t.readOnly=!0},$8=(n,e,t,r)=>{const i=n._zod.def;Le(i.innerType,e,r);const o=e.seen.get(n);o.ref=i.innerType},Px=k("ZodISODateTime",(n,e)=>{LR.init(n,e),Ce.init(n,e)});function Lx(n){return ZI(Px,n)}const Dx=k("ZodISODate",(n,e)=>{DR.init(n,e),Ce.init(n,e)});function Mx(n){return HI(Dx,n)}const Ox=k("ZodISOTime",(n,e)=>{MR.init(n,e),Ce.init(n,e)});function Nx(n){return UI(Ox,n)}const zx=k("ZodISODuration",(n,e)=>{OR.init(n,e),Ce.init(n,e)});function Zx(n){return VI(zx,n)}const R8=(n,e)=>{l8.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:t=>C$(n,t)},flatten:{value:t=>k$(n,t)},addIssue:{value:t=>{n.issues.push(t),n.message=JSON.stringify(n.issues,_0,2)}},addIssues:{value:t=>{n.issues.push(...t),n.message=JSON.stringify(n.issues,_0,2)}},isEmpty:{get(){return n.issues.length===0}}})},Ay=k("ZodError",R8),on=k("ZodError",R8,{Parent:Error}),Hx=xg(on),Ux=Pg(on),Vx=zp(on),Fx=Zp(on),Bx=R$(on),qx=I$(on),Wx=x$(on),jx=P$(on),Gx=L$(on),Yx=D$(on),Jx=M$(on),Kx=O$(on),ke=k("ZodType",(n,e)=>(Ee.init(n,e),Object.assign(n["~standard"],{jsonSchema:{input:_d(n,"input"),output:_d(n,"output")}}),n.toJSONSchema=cx(n,{}),n.def=e,n.type=e.type,Object.defineProperty(n,"_def",{value:e}),n.check=(...t)=>n.clone(Ji(e,{checks:[...e.checks??[],...t.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),n.with=n.check,n.clone=(t,r)=>Ki(n,t,r),n.brand=()=>n,n.register=(t,r)=>(t.add(n,r),n),n.parse=(t,r)=>Hx(n,t,r,{callee:n.parse}),n.safeParse=(t,r)=>Vx(n,t,r),n.parseAsync=async(t,r)=>Ux(n,t,r,{callee:n.parseAsync}),n.safeParseAsync=async(t,r)=>Fx(n,t,r),n.spa=n.safeParseAsync,n.encode=(t,r)=>Bx(n,t,r),n.decode=(t,r)=>qx(n,t,r),n.encodeAsync=async(t,r)=>Wx(n,t,r),n.decodeAsync=async(t,r)=>jx(n,t,r),n.safeEncode=(t,r)=>Gx(n,t,r),n.safeDecode=(t,r)=>Yx(n,t,r),n.safeEncodeAsync=async(t,r)=>Jx(n,t,r),n.safeDecodeAsync=async(t,r)=>Kx(n,t,r),n.refine=(t,r)=>n.check(F5(t,r)),n.superRefine=t=>n.check(B5(t)),n.overwrite=t=>n.check(fl(t)),n.optional=()=>Cy(n),n.exactOptional=()=>I5(n),n.nullable=()=>Ty(n),n.nullish=()=>Cy(Ty(n)),n.nonoptional=t=>O5(n,t),n.array=()=>z(n),n.or=t=>X([n,t]),n.and=t=>Up(n,t),n.transform=t=>$y(n,$5(t)),n.default=t=>L5(n,t),n.prefault=t=>M5(n,t),n.catch=t=>z5(n,t),n.pipe=t=>$y(n,t),n.readonly=()=>U5(n),n.describe=t=>{const r=n.clone();return Vl.add(r,{description:t}),r},Object.defineProperty(n,"description",{get(){var t;return(t=Vl.get(n))==null?void 0:t.description},configurable:!0}),n.meta=(...t)=>{if(t.length===0)return Vl.get(n);const r=n.clone();return Vl.add(r,t[0]),r},n.isOptional=()=>n.safeParse(void 0).success,n.isNullable=()=>n.safeParse(null).success,n.apply=t=>t(n),n)),I8=k("_ZodString",(n,e)=>{Lg.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(r,i,o)=>hx(n,r,i);const t=n._zod.bag;n.format=t.format??null,n.minLength=t.minimum??null,n.maxLength=t.maximum??null,n.regex=(...r)=>n.check(GI(...r)),n.includes=(...r)=>n.check(KI(...r)),n.startsWith=(...r)=>n.check(XI(...r)),n.endsWith=(...r)=>n.check(QI(...r)),n.min=(...r)=>n.check(Sd(...r)),n.max=(...r)=>n.check(A8(...r)),n.length=(...r)=>n.check(E8(...r)),n.nonempty=(...r)=>n.check(Sd(1,...r)),n.lowercase=r=>n.check(YI(r)),n.uppercase=r=>n.check(JI(r)),n.trim=()=>n.check(tx()),n.normalize=(...r)=>n.check(ex(...r)),n.toLowerCase=()=>n.check(nx()),n.toUpperCase=()=>n.check(rx()),n.slugify=()=>n.check(ix())}),Xx=k("ZodString",(n,e)=>{Lg.init(n,e),I8.init(n,e),n.email=t=>n.check(yI(Qx,t)),n.url=t=>n.check(AI(e5,t)),n.jwt=t=>n.check(zI(m5,t)),n.emoji=t=>n.check(EI(t5,t)),n.guid=t=>n.check(wy(Ey,t)),n.uuid=t=>n.check(wI(ph,t)),n.uuidv4=t=>n.check(bI(ph,t)),n.uuidv6=t=>n.check(SI(ph,t)),n.uuidv7=t=>n.check(_I(ph,t)),n.nanoid=t=>n.check(kI(n5,t)),n.guid=t=>n.check(wy(Ey,t)),n.cuid=t=>n.check(CI(r5,t)),n.cuid2=t=>n.check(TI(i5,t)),n.ulid=t=>n.check($I(s5,t)),n.base64=t=>n.check(MI(d5,t)),n.base64url=t=>n.check(OI(p5,t)),n.xid=t=>n.check(RI(o5,t)),n.ksuid=t=>n.check(II(a5,t)),n.ipv4=t=>n.check(xI(l5,t)),n.ipv6=t=>n.check(PI(c5,t)),n.cidrv4=t=>n.check(LI(u5,t)),n.cidrv6=t=>n.check(DI(h5,t)),n.e164=t=>n.check(NI(f5,t)),n.datetime=t=>n.check(Lx(t)),n.date=t=>n.check(Mx(t)),n.time=t=>n.check(Nx(t)),n.duration=t=>n.check(Zx(t))});function m(n){return vI(Xx,n)}const Ce=k("ZodStringFormat",(n,e)=>{_e.init(n,e),I8.init(n,e)}),Qx=k("ZodEmail",(n,e)=>{ER.init(n,e),Ce.init(n,e)}),Ey=k("ZodGUID",(n,e)=>{_R.init(n,e),Ce.init(n,e)}),ph=k("ZodUUID",(n,e)=>{AR.init(n,e),Ce.init(n,e)}),e5=k("ZodURL",(n,e)=>{kR.init(n,e),Ce.init(n,e)}),t5=k("ZodEmoji",(n,e)=>{CR.init(n,e),Ce.init(n,e)}),n5=k("ZodNanoID",(n,e)=>{TR.init(n,e),Ce.init(n,e)}),r5=k("ZodCUID",(n,e)=>{$R.init(n,e),Ce.init(n,e)}),i5=k("ZodCUID2",(n,e)=>{RR.init(n,e),Ce.init(n,e)}),s5=k("ZodULID",(n,e)=>{IR.init(n,e),Ce.init(n,e)}),o5=k("ZodXID",(n,e)=>{xR.init(n,e),Ce.init(n,e)}),a5=k("ZodKSUID",(n,e)=>{PR.init(n,e),Ce.init(n,e)}),l5=k("ZodIPv4",(n,e)=>{NR.init(n,e),Ce.init(n,e)}),c5=k("ZodIPv6",(n,e)=>{zR.init(n,e),Ce.init(n,e)}),u5=k("ZodCIDRv4",(n,e)=>{ZR.init(n,e),Ce.init(n,e)}),h5=k("ZodCIDRv6",(n,e)=>{HR.init(n,e),Ce.init(n,e)}),d5=k("ZodBase64",(n,e)=>{UR.init(n,e),Ce.init(n,e)}),p5=k("ZodBase64URL",(n,e)=>{FR.init(n,e),Ce.init(n,e)}),f5=k("ZodE164",(n,e)=>{BR.init(n,e),Ce.init(n,e)}),m5=k("ZodJWT",(n,e)=>{WR.init(n,e),Ce.init(n,e)}),x8=k("ZodNumber",(n,e)=>{y8.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(r,i,o)=>dx(n,r,i),n.gt=(r,i)=>n.check(Sy(r,i)),n.gte=(r,i)=>n.check(Ff(r,i)),n.min=(r,i)=>n.check(Ff(r,i)),n.lt=(r,i)=>n.check(by(r,i)),n.lte=(r,i)=>n.check(Vf(r,i)),n.max=(r,i)=>n.check(Vf(r,i)),n.int=r=>n.check(ky(r)),n.safe=r=>n.check(ky(r)),n.positive=r=>n.check(Sy(0,r)),n.nonnegative=r=>n.check(Ff(0,r)),n.negative=r=>n.check(by(0,r)),n.nonpositive=r=>n.check(Vf(0,r)),n.multipleOf=(r,i)=>n.check(_y(r,i)),n.step=(r,i)=>n.check(_y(r,i)),n.finite=()=>n;const t=n._zod.bag;n.minValue=Math.max(t.minimum??Number.NEGATIVE_INFINITY,t.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(t.maximum??Number.POSITIVE_INFINITY,t.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(t.format??"").includes("int")||Number.isSafeInteger(t.multipleOf??.5),n.isFinite=!0,n.format=t.format??null});function G(n){return FI(x8,n)}const g5=k("ZodNumberFormat",(n,e)=>{jR.init(n,e),x8.init(n,e)});function ky(n){return BI(g5,n)}const v5=k("ZodBoolean",(n,e)=>{GR.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>px(n,t,r)});function Ve(n){return qI(v5,n)}const y5=k("ZodUnknown",(n,e)=>{YR.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>mx()});function S(){return WI(y5)}const w5=k("ZodNever",(n,e)=>{JR.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>fx(n,t,r)});function b5(n){return jI(w5,n)}const S5=k("ZodArray",(n,e)=>{KR.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>bx(n,t,r,i),n.element=e.element,n.min=(t,r)=>n.check(Sd(t,r)),n.nonempty=t=>n.check(Sd(1,t)),n.max=(t,r)=>n.check(A8(t,r)),n.length=(t,r)=>n.check(E8(t,r)),n.unwrap=()=>n.element});function z(n,e){return sx(S5,n,e)}const P8=k("ZodObject",(n,e)=>{QR.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Sx(n,t,r,i),ue(n,"shape",()=>e.shape),n.keyof=()=>M8(Object.keys(n._zod.def.shape)),n.catchall=t=>n.clone({...n._zod.def,catchall:t}),n.passthrough=()=>n.clone({...n._zod.def,catchall:S()}),n.loose=()=>n.clone({...n._zod.def,catchall:S()}),n.strict=()=>n.clone({...n._zod.def,catchall:b5()}),n.strip=()=>n.clone({...n._zod.def,catchall:void 0}),n.extend=t=>b$(n,t),n.safeExtend=t=>S$(n,t),n.merge=t=>_$(n,t),n.pick=t=>y$(n,t),n.omit=t=>w$(n,t),n.partial=(...t)=>A$(O8,n,t[0]),n.required=(...t)=>E$(N8,n,t[0])});function L8(n,e){const t={type:"object",shape:n??{},...H(e)};return new P8(t)}function w(n,e){return new P8({type:"object",shape:n,catchall:S(),...H(e)})}const D8=k("ZodUnion",(n,e)=>{S8.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>_x(n,t,r,i),n.options=e.options});function X(n,e){return new D8({type:"union",options:n,...H(e)})}const _5=k("ZodDiscriminatedUnion",(n,e)=>{D8.init(n,e),eI.init(n,e)});function A5(n,e,t){return new _5({type:"union",options:e,discriminator:n,...H(t)})}const E5=k("ZodIntersection",(n,e)=>{tI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Ax(n,t,r,i)});function Up(n,e){return new E5({type:"intersection",left:n,right:e})}const k5=k("ZodRecord",(n,e)=>{nI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Ex(n,t,r,i),n.keyType=e.keyType,n.valueType=e.valueType});function A(n,e,t){return new k5({type:"record",keyType:n,valueType:e,...H(t)})}const E0=k("ZodEnum",(n,e)=>{rI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(r,i,o)=>gx(n,r,i),n.enum=e.entries,n.options=Object.values(e.entries);const t=new Set(Object.keys(e.entries));n.extract=(r,i)=>{const o={};for(const a of r)if(t.has(a))o[a]=e.entries[a];else throw new Error(`Key ${a} not found in enum`);return new E0({...e,checks:[],...H(i),entries:o})},n.exclude=(r,i)=>{const o={...e.entries};for(const a of r)if(t.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new E0({...e,checks:[],...H(i),entries:o})}});function M8(n,e){const t=Array.isArray(n)?Object.fromEntries(n.map(r=>[r,r])):n;return new E0({type:"enum",entries:t,...H(e)})}const C5=k("ZodLiteral",(n,e)=>{iI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>vx(n,t,r),n.values=new Set(e.values),Object.defineProperty(n,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function $(n,e){return new C5({type:"literal",values:Array.isArray(n)?n:[n],...H(e)})}const T5=k("ZodTransform",(n,e)=>{sI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>wx(n,t),n._zod.parse=(t,r)=>{if(r.direction==="backward")throw new n8(n.constructor.name);t.addIssue=o=>{if(typeof o=="string")t.issues.push(mc(o,t.value,e));else{const a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=t.value),a.inst??(a.inst=n),t.issues.push(mc(a))}};const i=e.transform(t.value,t);return i instanceof Promise?i.then(o=>(t.value=o,t)):(t.value=i,t)}});function $5(n){return new T5({type:"transform",transform:n})}const O8=k("ZodOptional",(n,e)=>{_8.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>$8(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function Cy(n){return new O8({type:"optional",innerType:n})}const R5=k("ZodExactOptional",(n,e)=>{oI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>$8(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function I5(n){return new R5({type:"optional",innerType:n})}const x5=k("ZodNullable",(n,e)=>{aI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>kx(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function Ty(n){return new x5({type:"nullable",innerType:n})}const P5=k("ZodDefault",(n,e)=>{lI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Tx(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function L5(n,e){return new P5({type:"default",innerType:n,get defaultValue(){return typeof e=="function"?e():o8(e)}})}const D5=k("ZodPrefault",(n,e)=>{cI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>$x(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function M5(n,e){return new D5({type:"prefault",innerType:n,get defaultValue(){return typeof e=="function"?e():o8(e)}})}const N8=k("ZodNonOptional",(n,e)=>{uI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Cx(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function O5(n,e){return new N8({type:"nonoptional",innerType:n,...H(e)})}const N5=k("ZodCatch",(n,e)=>{hI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Rx(n,t,r,i),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function z5(n,e){return new N5({type:"catch",innerType:n,catchValue:typeof e=="function"?e:()=>e})}const Z5=k("ZodPipe",(n,e)=>{dI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>Ix(n,t,r,i),n.in=e.in,n.out=e.out});function $y(n,e){return new Z5({type:"pipe",in:n,out:e})}const H5=k("ZodReadonly",(n,e)=>{pI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>xx(n,t,r,i),n.unwrap=()=>n._zod.def.innerType});function U5(n){return new H5({type:"readonly",innerType:n})}const V5=k("ZodCustom",(n,e)=>{fI.init(n,e),ke.init(n,e),n._zod.processJSONSchema=(t,r,i)=>yx(n,t)});function F5(n,e={}){return ox(V5,n,e)}function B5(n){return ax(n)}const q5=[".md",".markdown"];function z8(n){if(n.length===0)return!1;const e=n.at(-1);return e==="/"||e==="\\"}function Z8(n){const e=n.lastIndexOf("/"),t=n.lastIndexOf("\\");return n.slice(Math.max(e,t)+1)}function W5(n){return Z8(n).toLowerCase()}function j5(n,e){const t=W5(n);return e.some(r=>t.endsWith(r))}function k0(n){return!z8(n)&&j5(n,q5)}function G5(n){let e;try{e=new URL(n)}catch{return!1}return e.protocol==="http:"||e.protocol==="https:"}function fr(n){try{const{pathname:e}=new URL(n);return/^\/artifact\/[0-9A-Za-z]{26}(\/|$)/.test(e)}catch{return!1}}const Y5=L8({id:m().min(1),kind:$("path"),title:m(),path:m()}).strict(),J5=L8({id:m().min(1),kind:$("url"),title:m(),url:m().refine(G5,{message:"url must be an http(s) URL"})}).strict();A5("kind",[Y5,J5]);const K5=new Set(["about:","blob:","chrome-extension:","chrome:","data:","devtools:","file:","filesystem:","javascript:","view-source:"]);function X5(n,e){try{const t=new URL(e),r=new URL(n,t);return r.protocol==="http:"||r.protocol==="https:"?{kind:"web",url:r.href}:K5.has(r.protocol)?{kind:"browser-local",url:r.href}:{kind:"application",url:r.href}}catch{return{kind:"invalid"}}}function Ry(n,e){return X5(n,e).kind==="web"}const Q5="/views/markdown/",eP="/views/url-unsupported/";function tP(n){try{const{protocol:e}=new URL(n);return e==="http:"||e==="https:"}catch{return!1}}function H8(n){return`/artifact/${encodeURIComponent(n)}`}function nP(n,e){return`${H8(n)}/${encodeURIComponent(e)}`}function rP(n){return`/markdown/${encodeURIComponent(n)}`}function Ad(n,e={electron:!1}){if(n.kind==="url")return e.electron?{renderer:"url-webview",viewURL:n.url,contentURL:null}:fr(n.url)?{renderer:"proxy-iframe",viewURL:n.url,contentURL:null}:e.browserDemo&&tP(n.url)?{renderer:"url-direct",viewURL:n.url,contentURL:null}:{renderer:"url-unsupported",viewURL:eP,contentURL:null};if(k0(n.path)){const r={viewURL:Q5,contentURL:rP(n.id)};return e.electron?{renderer:"url-webview",...r}:{renderer:"markdown",...r}}const t=z8(n.path)?`${H8(n.id)}/`:nP(n.id,Z8(n.path));return e.electron?{renderer:"url-webview",viewURL:t,contentURL:null}:{renderer:"proxy-iframe",viewURL:t,contentURL:null}}const iP="serverURL",sP="token",oP="mode",aP="desktopAppVersion",lP="electron";function cP(n=window.location.search,e=window.location.origin){const r=new URLSearchParams(n).get(iP);return r?new URL(r).origin:new URL(e).origin}function uP(n=window.location.search){return new URLSearchParams(n).get(sP)}function Br(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(oP)===lP}function U8(n=typeof window>"u"?"":window.location.search){return new URLSearchParams(n).get(aP)}const Iy="tv.telemetry.clientId",hP=5,dP=60,pP=1e3,fP=hP*dP*pP,xy=["pointerdown","scroll","keydown"],Py=["focus"],Ly=["visibilitychange"],mP="hidden";function gP(n,e=SP){const t=n.getItem(Iy);if(t)return t;const r=e();return n.setItem(Iy,r),r}function vP(n){return{clientId:gP(n.storage,n.idFactory),userAgent:n.userAgent??(typeof navigator>"u"?"":navigator.userAgent),clientApp:n.clientApp,...n.desktopAppVersion?{desktopAppVersion:n.desktopAppVersion}:{}}}function yP(n){const e=new URLSearchParams;return e.set("clientId",n.clientId),e.set("userAgent",n.userAgent),e.set("clientApp",n.clientApp),n.desktopAppVersion&&e.set("desktopAppVersion",n.desktopAppVersion),e}function wP(n){return new bP(n)}var Ac,wr,ai,Ec,kc,Ut,Ss,Cc,Od,V8;class bP{constructor(e){p(this,Od);p(this,Ac);p(this,wr);p(this,ai);p(this,Ec);p(this,kc);p(this,Ut);p(this,Ss,!1);p(this,Cc,Number.NEGATIVE_INFINITY);h(this,Ac,e.meta),h(this,wr,e.documentTarget),h(this,ai,e.windowTarget),h(this,Ec,e.send),h(this,kc,e.nowMs??Date.now),h(this,Ut,()=>u(this,Od,V8).call(this))}start(){if(!s(this,Ss)){h(this,Ss,!0);for(const e of xy)s(this,ai).addEventListener(e,s(this,Ut)),s(this,wr).addEventListener(e,s(this,Ut));for(const e of Py)s(this,ai).addEventListener(e,s(this,Ut));for(const e of Ly)s(this,wr).addEventListener(e,s(this,Ut))}}stop(){if(s(this,Ss)){h(this,Ss,!1);for(const e of xy)s(this,ai).removeEventListener(e,s(this,Ut)),s(this,wr).removeEventListener(e,s(this,Ut));for(const e of Py)s(this,ai).removeEventListener(e,s(this,Ut));for(const e of Ly)s(this,wr).removeEventListener(e,s(this,Ut))}}}Ac=new WeakMap,wr=new WeakMap,ai=new WeakMap,Ec=new WeakMap,kc=new WeakMap,Ut=new WeakMap,Ss=new WeakMap,Cc=new WeakMap,Od=new WeakSet,V8=function(){if(s(this,wr).visibilityState===mP)return;const e=s(this,kc).call(this);e-s(this,Cc)<fP||(h(this,Cc,e),s(this,Ec).call(this,{type:pT,clientId:s(this,Ac).clientId}))};function SP(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Tg().toLowerCase()}const we={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"},ur={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"},_P=1,AP=w({_meta:A(m(),S()).nullish(),terminal:Ve().optional().default(!1)}),EP=w({_meta:A(m(),S()).nullish(),label:m().nullish(),name:m(),optional:Ve().optional().default(!1),secret:Ve().optional().default(!0)}),kP=w({_meta:A(m(),S()).nullish(),description:m().nullish(),id:m(),name:m()}),CP=w({_meta:A(m(),S()).nullish(),description:m().nullish(),id:m(),link:m().nullish(),name:m(),vars:z(EP)}),TP=w({_meta:A(m(),S()).nullish(),args:z(m()).optional(),description:m().nullish(),env:A(m(),m()).optional(),id:m(),name:m()}),$P=X([CP.and(w({type:$("env_var")})),TP.and(w({type:$("terminal")})),kP]),RP=w({_meta:A(m(),S()).nullish(),methodId:m()}),IP=w({_meta:A(m(),S()).nullish()}),xP=w({_meta:A(m(),S()).nullish(),blob:m(),mimeType:m().nullish(),uri:m()}),PP=w({default:Ve().nullish(),description:m().nullish(),title:m().nullish()}),LP=w({_meta:A(m(),S()).nullish()}),DP=w({_meta:A(m(),S()).nullish()}),MP=w({amount:G(),currency:m()}),OP=w({_meta:A(m(),S()).nullish(),terminalId:m()}),NP=w({_meta:A(m(),S()).nullish(),newText:m(),oldText:m().nullish(),path:m()}),zP=X([m(),G(),G(),Ve(),z(m())]),ZP=w({content:A(m(),zP).nullish()}),HP=X([ZP.and(w({action:$("accept")})),w({action:$("decline")}),w({action:$("cancel")})]),UP=w({_meta:A(m(),S()).nullish()}),F8=m(),VP=w({_meta:A(m(),S()).nullish(),elicitationId:F8}),FP=w({_meta:A(m(),S()).nullish(),action:HP}),BP=$("object"),qP=$("string"),WP=w({_meta:A(m(),S()).nullish()}),jP=w({_meta:A(m(),S()).nullish(),form:UP.nullish(),url:WP.nullish()}),GP=w({elicitationId:F8,url:m().url()}),B8=w({const:m(),title:m()}),q8=w({_meta:A(m(),S()).nullish(),name:m(),value:m()}),YP=X([$(-32700),$(-32600),$(-32601),$(-32602),$(-32603),$(-32800),$(-32e3),$(-32002),$(-32042),G().int().min(-2147483648,{message:"Invalid value: Expected int32 to be >= -2147483648"}).max(2147483647,{message:"Invalid value: Expected int32 to be <= 2147483647"})]),W8=w({code:YP,data:S().optional(),message:m()}),j8=S(),G8=S(),Y8=S(),JP=w({_meta:A(m(),S()).nullish(),readTextFile:Ve().optional().default(!1),writeTextFile:Ve().optional().default(!1)}),J8=w({_meta:A(m(),S()).nullish(),name:m(),value:m()}),K8=w({_meta:A(m(),S()).nullish(),name:m(),title:m().nullish(),version:m()}),KP=w({default:G().nullish(),description:m().nullish(),maximum:G().nullish(),minimum:G().nullish(),title:m().nullish()}),XP=w({_meta:A(m(),S()).nullish()}),QP=w({_meta:A(m(),S()).nullish(),additionalDirectories:z(m()).optional(),cursor:m().nullish(),cwd:m().nullish()}),eL=w({_meta:A(m(),S()).nullish()}),tL=w({_meta:A(m(),S()).nullish(),logout:eL.nullish()}),nL=w({_meta:A(m(),S()).nullish()}),rL=w({_meta:A(m(),S()).nullish()}),iL=w({_meta:A(m(),S()).nullish(),http:Ve().optional().default(!1),sse:Ve().optional().default(!1)}),sL=w({_meta:A(m(),S()).nullish(),headers:z(J8),name:m(),url:m()}),oL=w({_meta:A(m(),S()).nullish(),headers:z(J8),name:m(),url:m()}),aL=w({_meta:A(m(),S()).nullish(),args:z(m()),command:m(),env:z(q8),name:m()}),Vp=X([sL.and(w({type:$("http")})),oL.and(w({type:$("sse")})),aL]),Dg=m(),lL=w({_meta:A(m(),S()).nullish(),description:m().nullish(),modelId:Dg,name:m()}),cL=X([$("error"),$("warning"),$("information"),$("hint")]),uL=w({_meta:A(m(),S()).nullish()}),hL=w({_meta:A(m(),S()).nullish()}),dL=w({_meta:A(m(),S()).nullish()}),pL=w({_meta:A(m(),S()).nullish()}),fL=w({_meta:A(m(),S()).nullish()}),mL=w({_meta:A(m(),S()).nullish(),maxCount:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),gL=w({diff:m(),uri:m()}),vL=w({endLine:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),startLine:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),text:m()}),yL=w({_meta:A(m(),S()).nullish()}),wL=w({_meta:A(m(),S()).nullish()}),bL=w({languageId:m(),text:m(),uri:m()}),SL=w({_meta:A(m(),S()).nullish(),maxCount:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),_L=X([$("rejected"),$("ignored"),$("replaced"),$("cancelled")]),AL=w({excerpts:z(vL),uri:m()}),EL=w({_meta:A(m(),S()).nullish()}),kL=w({_meta:A(m(),S()).nullish()}),CL=w({name:m(),owner:m(),remoteUrl:m()}),TL=w({_meta:A(m(),S()).nullish()}),$L=w({_meta:A(m(),S()).nullish(),jump:yL.nullish(),rename:kL.nullish(),searchAndReplace:TL.nullish()}),RL=w({id:m(),isRegex:Ve().nullish(),replace:m(),search:m(),uri:m()}),IL=X([$("automatic"),$("diagnostic"),$("manual")]),xL=w({_meta:A(m(),S()).nullish(),maxCount:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish()}),PL=w({_meta:A(m(),S()).nullish(),diagnostics:uL.nullish(),editHistory:mL.nullish(),openFiles:wL.nullish(),recentFiles:SL.nullish(),relatedSnippets:EL.nullish(),userActions:xL.nullish()}),LL=w({_meta:A(m(),S()).nullish(),additionalDirectories:z(m()).optional(),cwd:m(),mcpServers:z(Vp)}),DL=w({default:G().nullish(),description:m().nullish(),maximum:G().nullish(),minimum:G().nullish(),title:m().nullish()}),X8=m(),ML=X([$("allow_once"),$("allow_always"),$("reject_once"),$("reject_always")]),OL=w({_meta:A(m(),S()).nullish(),kind:ML,name:m(),optionId:X8}),NL=X([$("high"),$("medium"),$("low")]),zL=X([$("pending"),$("in_progress"),$("completed")]),ZL=w({_meta:A(m(),S()).nullish(),content:m(),priority:NL,status:zL}),HL=w({_meta:A(m(),S()).nullish(),entries:z(ZL)}),Wi=w({character:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}),line:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"})}),UL=w({id:m(),position:Wi,uri:m()}),VL=w({id:m(),newName:m(),position:Wi,uri:m()}),FL=w({action:m(),position:Wi,timestampMs:G(),uri:m()}),Q8=X([$("utf-16"),$("utf-32"),$("utf-8")]),BL=w({_meta:A(m(),S()).nullish(),auth:AP.optional().default({terminal:!1}),elicitation:jP.nullish(),fs:JP.optional().default({readTextFile:!1,writeTextFile:!1}),nes:$L.nullish(),positionEncodings:z(Q8).optional(),terminal:Ve().optional().default(!1)}),qL=w({_meta:A(m(),S()).nullish(),audio:Ve().optional().default(!1),embeddedContext:Ve().optional().default(!1),image:Ve().optional().default(!1)}),eb=G().int().gte(0).lte(65535),WL=w({_meta:A(m(),S()).nullish(),clientCapabilities:BL.optional().default({auth:{terminal:!1},fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}),clientInfo:K8.nullish(),protocolVersion:eb}),ml=w({end:Wi,start:Wi}),jL=w({message:m(),range:ml,severity:cL,uri:m()}),GL=w({languageId:m(),lastFocusedMs:G().nullish(),uri:m(),visibleRange:ml.nullish()}),YL=w({_meta:A(m(),S()).nullish(),diagnostics:z(jL).nullish(),editHistory:z(gL).nullish(),openFiles:z(GL).nullish(),recentFiles:z(bL).nullish(),relatedSnippets:z(AL).nullish(),userActions:z(FL).nullish()}),JL=w({newText:m(),range:ml}),KL=w({cursorPosition:Wi.nullish(),edits:z(JL),id:m(),uri:m()}),XL=X([KL.and(w({kind:$("edit")})),UL.and(w({kind:$("jump")})),VL.and(w({kind:$("rename")})),RL.and(w({kind:$("searchAndReplace")}))]),QL=w({_meta:A(m(),S()).nullish(),content:m()}),eD=w({_meta:A(m(),S()).nullish()}),ho=X([G(),m()]).nullable();w({_meta:A(m(),S()).nullish(),requestId:ho});const tD=M8(["assistant","user"]),Fu=w({_meta:A(m(),S()).nullish(),audience:z(tD).nullish(),lastModified:m().nullish(),priority:G().nullish()}),nD=w({_meta:A(m(),S()).nullish(),annotations:Fu.nullish(),data:m(),mimeType:m()}),rD=w({_meta:A(m(),S()).nullish(),annotations:Fu.nullish(),data:m(),mimeType:m(),uri:m().nullish()}),iD=w({_meta:A(m(),S()).nullish(),annotations:Fu.nullish(),description:m().nullish(),mimeType:m().nullish(),name:m(),size:G().nullish(),title:m().nullish(),uri:m()}),sD=w({_meta:A(m(),S()).nullish(),optionId:X8}),oD=X([w({outcome:$("cancelled")}),sD.and(w({outcome:$("selected")}))]),aD=w({_meta:A(m(),S()).nullish(),outcome:oD}),lD=w({_meta:A(m(),S()).nullish()}),cD=w({_meta:A(m(),S()).nullish()}),uD=w({currentValue:Ve()}),hD=m(),tb=m(),dD=X([$("mode"),$("model"),$("thought_level"),m()]),Mg=m(),nb=w({_meta:A(m(),S()).nullish(),description:m().nullish(),name:m(),value:Mg}),pD=w({_meta:A(m(),S()).nullish(),group:hD,name:m(),options:z(nb)}),fD=X([z(nb),z(pD)]),mD=w({currentValue:Mg,options:fD}),gl=Up(X([mD.and(w({type:$("select")})),uD.and(w({type:$("boolean")}))]),w({_meta:A(m(),S()).nullish(),category:dD.nullish(),description:m().nullish(),id:tb,name:m()})),gD=w({_meta:A(m(),S()).nullish(),configOptions:z(gl)}),vD=w({_meta:A(m(),S()).nullish()}),ae=m(),yD=w({_meta:A(m(),S()).nullish(),id:m(),sessionId:ae}),wD=w({_meta:A(m(),S()).nullish(),sessionId:ae}),bD=w({_meta:A(m(),S()).nullish(),sessionId:ae}),SD=w({_meta:A(m(),S()).nullish(),sessionId:ae}),rb=w({_meta:A(m(),S()).nullish(),args:z(m()).optional(),command:m(),cwd:m().nullish(),env:z(q8).optional(),outputByteLimit:G().nullish(),sessionId:ae}),_D=w({_meta:A(m(),S()).nullish(),sessionId:ae,uri:m()}),AD=w({_meta:A(m(),S()).nullish(),position:Wi,sessionId:ae,uri:m(),version:G(),visibleRange:ml}),ED=w({_meta:A(m(),S()).nullish(),languageId:m(),sessionId:ae,text:m(),uri:m(),version:G()}),kD=w({_meta:A(m(),S()).nullish(),sessionId:ae,uri:m()}),CD=w({_meta:A(m(),S()).nullish(),additionalDirectories:z(m()).optional(),cwd:m(),mcpServers:z(Vp).optional(),sessionId:ae}),ib=w({_meta:A(m(),S()).nullish(),sessionId:ae,terminalId:m()}),TD=w({_meta:A(m(),S()).nullish(),additionalDirectories:z(m()).optional(),cwd:m(),mcpServers:z(Vp),sessionId:ae}),sb=w({_meta:A(m(),S()).nullish(),limit:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),line:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:m(),sessionId:ae}),$D=w({_meta:A(m(),S()).nullish(),id:m(),reason:_L.nullish(),sessionId:ae}),ob=w({_meta:A(m(),S()).nullish(),sessionId:ae,terminalId:m()}),RD=w({_meta:A(m(),S()).nullish(),additionalDirectories:z(m()).optional(),cwd:m(),mcpServers:z(Vp).optional(),sessionId:ae}),ID=w({_meta:A(m(),S()).nullish(),additionalDirectories:z(m()).optional(),cwd:m(),sessionId:ae,title:m().nullish(),updatedAt:m().nullish()}),xD=w({_meta:A(m(),S()).nullish(),nextCursor:m().nullish(),sessions:z(ID)}),PD=w({_meta:A(m(),S()).nullish(),title:m().nullish(),updatedAt:m().nullish()}),LD=w({_meta:A(m(),S()).nullish()}),Fp=m(),DD=w({_meta:A(m(),S()).nullish(),currentModeId:Fp}),MD=w({_meta:A(m(),S()).nullish(),description:m().nullish(),id:Fp,name:m()}),Bp=w({_meta:A(m(),S()).nullish(),availableModes:z(MD),currentModeId:Fp}),qp=w({_meta:A(m(),S()).nullish(),availableModels:z(lL),currentModelId:Dg}),OD=w({_meta:A(m(),S()).nullish(),configOptions:z(gl).nullish(),models:qp.nullish(),modes:Bp.nullish(),sessionId:ae}),ND=w({_meta:A(m(),S()).nullish(),configOptions:z(gl).nullish(),models:qp.nullish(),modes:Bp.nullish()}),zD=w({_meta:A(m(),S()).nullish(),configOptions:z(gl).nullish(),models:qp.nullish(),modes:Bp.nullish(),sessionId:ae}),ZD=w({_meta:A(m(),S()).nullish(),configOptions:z(gl).nullish(),models:qp.nullish(),modes:Bp.nullish()}),HD=w({_meta:A(m(),S()).nullish()}),UD=w({_meta:A(m(),S()).nullish(),additionalDirectories:lD.nullish(),close:cD.nullish(),fork:vD.nullish(),list:LD.nullish(),resume:HD.nullish()}),VD=Up(X([w({type:$("boolean"),value:Ve()}),w({value:Mg})]),w({_meta:A(m(),S()).nullish(),configId:tb,sessionId:ae})),FD=w({_meta:A(m(),S()).nullish(),configOptions:z(gl)}),BD=w({_meta:A(m(),S()).nullish(),modeId:Fp,sessionId:ae}),qD=w({_meta:A(m(),S()).nullish()}),WD=w({_meta:A(m(),S()).nullish(),modelId:Dg,sessionId:ae}),jD=w({_meta:A(m(),S()).nullish()}),GD=w({_meta:A(m(),S()).nullish(),sessionId:ae}),YD=X([$("end_turn"),$("max_tokens"),$("max_turn_requests"),$("refusal"),$("cancelled")]),JD=X([$("email"),$("uri"),$("date"),$("date-time")]),KD=w({default:m().nullish(),description:m().nullish(),enum:z(m()).nullish(),format:JD.nullish(),maxLength:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),minLength:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),oneOf:z(B8).nullish(),pattern:m().nullish(),title:m().nullish()}),XD=w({_meta:A(m(),S()).nullish(),context:YL.nullish(),position:Wi,selection:ml.nullish(),sessionId:ae,triggerKind:IL,uri:m(),version:G()}),QD=w({_meta:A(m(),S()).nullish(),suggestions:z(XL)}),eM=w({_meta:A(m(),S()).nullish(),terminalId:m()}),tM=w({_meta:A(m(),S()).nullish(),exitCode:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:m().nullish()}),ab=w({_meta:A(m(),S()).nullish(),sessionId:ae,terminalId:m()}),nM=w({_meta:A(m(),S()).nullish(),exitStatus:tM.nullish(),output:m(),truncated:Ve()}),rM=w({_meta:A(m(),S()).nullish(),annotations:Fu.nullish(),text:m()}),iM=w({range:ml.nullish(),text:m()}),sM=w({_meta:A(m(),S()).nullish(),contentChanges:z(iM),sessionId:ae,uri:m(),version:G()});w({method:m(),params:X([wD,ED,sM,_D,kD,AD,yD,$D,j8]).nullish()});const oM=X([$("full"),$("incremental")]),aM=w({_meta:A(m(),S()).nullish(),syncKind:oM}),lM=w({_meta:A(m(),S()).nullish(),didChange:aM.nullish(),didClose:hL.nullish(),didFocus:dL.nullish(),didOpen:pL.nullish(),didSave:fL.nullish()}),cM=w({_meta:A(m(),S()).nullish(),document:lM.nullish()}),uM=w({_meta:A(m(),S()).nullish(),context:PL.nullish(),events:cM.nullish()}),hM=w({_meta:A(m(),S()).nullish(),auth:tL.optional().default({}),loadSession:Ve().optional().default(!1),mcpCapabilities:iL.optional().default({http:!1,sse:!1}),nes:uM.nullish(),positionEncoding:Q8.nullish(),promptCapabilities:qL.optional().default({audio:!1,embeddedContext:!1,image:!1}),sessionCapabilities:UD.optional().default({})}),dM=w({_meta:A(m(),S()).nullish(),agentCapabilities:hM.optional().default({auth:{},loadSession:!1,mcpCapabilities:{http:!1,sse:!1},promptCapabilities:{audio:!1,embeddedContext:!1,image:!1},sessionCapabilities:{}}),agentInfo:K8.nullish(),authMethods:z($P).optional().default([]),protocolVersion:eb}),pM=w({_meta:A(m(),S()).nullish(),mimeType:m().nullish(),text:m(),uri:m()}),fM=X([pM,xP]),mM=w({_meta:A(m(),S()).nullish(),annotations:Fu.nullish(),resource:fM}),Og=X([rM.and(w({type:$("text")})),rD.and(w({type:$("image")})),nD.and(w({type:$("audio")})),iD.and(w({type:$("resource_link")})),mM.and(w({type:$("resource")}))]),gM=w({_meta:A(m(),S()).nullish(),content:Og}),Bf=w({_meta:A(m(),S()).nullish(),content:Og,messageId:m().nullish()}),vM=w({_meta:A(m(),S()).nullish(),messageId:m().nullish(),prompt:z(Og),sessionId:ae}),yM=w({anyOf:z(B8)}),lb=X([gM.and(w({type:$("content")})),NP.and(w({type:$("diff")})),eM.and(w({type:$("terminal")}))]),cb=m(),ub=w({_meta:A(m(),S()).nullish(),line:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),path:m()}),hb=X([$("pending"),$("in_progress"),$("completed"),$("failed")]),db=X([$("read"),$("edit"),$("delete"),$("move"),$("search"),$("execute"),$("think"),$("fetch"),$("switch_mode"),$("other")]),wM=w({_meta:A(m(),S()).nullish(),content:z(lb).optional(),kind:db.optional(),locations:z(ub).optional(),rawInput:S().optional(),rawOutput:S().optional(),status:hb.optional(),title:m(),toolCallId:cb}),pb=w({_meta:A(m(),S()).nullish(),content:z(lb).nullish(),kind:db.nullish(),locations:z(ub).nullish(),rawInput:S().optional(),rawOutput:S().optional(),status:hb.nullish(),title:m().nullish(),toolCallId:cb}),fb=w({_meta:A(m(),S()).nullish(),options:z(OL),sessionId:ae,toolCall:pb}),bM=w({_meta:A(m(),S()).nullish(),hint:m()}),SM=bM,_M=w({_meta:A(m(),S()).nullish(),description:m(),input:SM.nullish(),name:m()}),AM=w({_meta:A(m(),S()).nullish(),availableCommands:z(_M)}),EM=w({enum:z(m()),type:qP}),kM=X([EM,yM]),CM=w({default:z(m()).nullish(),description:m().nullish(),items:kM,maxItems:G().nullish(),minItems:G().nullish(),title:m().nullish()}),TM=X([KD.and(w({type:$("string")})),DL.and(w({type:$("number")})),KP.and(w({type:$("integer")})),PP.and(w({type:$("boolean")})),CM.and(w({type:$("array")}))]),$M=w({description:m().nullish(),properties:A(m(),TM).optional().default({}),required:z(m()).nullish(),title:m().nullish(),type:BP.optional().default("object")}),RM=w({requestedSchema:$M}),IM=Up(X([RM.and(w({mode:$("form")})),GP.and(w({mode:$("url")}))]),w({_meta:A(m(),S()).nullish(),message:m(),sessionId:ae})),xM=w({cachedReadTokens:G().nullish(),cachedWriteTokens:G().nullish(),inputTokens:G(),outputTokens:G(),thoughtTokens:G().nullish(),totalTokens:G()}),PM=w({_meta:A(m(),S()).nullish(),stopReason:YD,usage:xM.nullish(),userMessageId:m().nullish()});X([w({id:ho,result:X([dM,IP,rL,zD,ND,xD,OD,ZD,DP,qD,FD,PM,jD,GD,QD,LP,Y8])}),w({error:W8,id:ho})]);const LM=w({_meta:A(m(),S()).nullish(),cost:MP.nullish(),size:G(),used:G()}),DM=X([Bf.and(w({sessionUpdate:$("user_message_chunk")})),Bf.and(w({sessionUpdate:$("agent_message_chunk")})),Bf.and(w({sessionUpdate:$("agent_thought_chunk")})),wM.and(w({sessionUpdate:$("tool_call")})),pb.and(w({sessionUpdate:$("tool_call_update")})),HL.and(w({sessionUpdate:$("plan")})),AM.and(w({sessionUpdate:$("available_commands_update")})),DD.and(w({sessionUpdate:$("current_mode_update")})),gD.and(w({sessionUpdate:$("config_option_update")})),PD.and(w({sessionUpdate:$("session_info_update")})),LM.and(w({sessionUpdate:$("usage_update")}))]),mb=w({_meta:A(m(),S()).nullish(),sessionId:ae,update:DM});w({method:m(),params:X([mb,VP,j8]).nullish()});const gb=w({_meta:A(m(),S()).nullish(),sessionId:ae,terminalId:m()}),MM=w({_meta:A(m(),S()).nullish(),exitCode:G().int().gte(0).max(4294967295,{message:"Invalid value: Expected uint32 to be <= 4294967295"}).nullish(),signal:m().nullish()}),OM=w({name:m(),uri:m()}),NM=w({_meta:A(m(),S()).nullish(),repository:CL.nullish(),workspaceFolders:z(OM).nullish(),workspaceUri:m().nullish()});w({id:ho,method:m(),params:X([WL,RP,nL,LL,TD,QP,CD,RD,SD,BD,VD,vM,WD,NM,XD,bD,G8]).nullish()});const vb=w({_meta:A(m(),S()).nullish(),content:m(),path:m(),sessionId:ae});w({id:ho,method:m(),params:X([vb,sb,fb,rb,ab,ob,gb,ib,IM,G8]).nullish()});const zM=w({_meta:A(m(),S()).nullish()});X([w({id:ho,result:X([zM,QL,aD,OP,nM,eD,MM,XP,FP,Y8])}),w({error:W8,id:ho})]);var oe;class ZM{constructor(e,t){p(this,oe);const r=e(this),i=async(a,l)=>{var c,d,f,g,y,v,_;switch(a){case ur.fs_write_text_file:{const E=vb.parse(l);return(c=r.writeTextFile)==null?void 0:c.call(r,E)}case ur.fs_read_text_file:{const E=sb.parse(l);return(d=r.readTextFile)==null?void 0:d.call(r,E)}case ur.session_request_permission:{const E=fb.parse(l);return r.requestPermission(E)}case ur.terminal_create:{const E=rb.parse(l);return(f=r.createTerminal)==null?void 0:f.call(r,E)}case ur.terminal_output:{const E=ab.parse(l);return(g=r.terminalOutput)==null?void 0:g.call(r,E)}case ur.terminal_release:{const E=ob.parse(l);return await((y=r.releaseTerminal)==null?void 0:y.call(r,E))??{}}case ur.terminal_wait_for_exit:{const E=gb.parse(l);return(v=r.waitForTerminalExit)==null?void 0:v.call(r,E)}case ur.terminal_kill:{const E=ib.parse(l);return await((_=r.killTerminal)==null?void 0:_.call(r,E))??{}}default:if(r.extMethod)return r.extMethod(a,l);throw Oe.methodNotFound(a)}},o=async(a,l)=>{switch(a){case ur.session_update:{const c=mb.parse(l);return r.sessionUpdate(c)}default:if(r.extNotification)return r.extNotification(a,l);throw Oe.methodNotFound(a)}};h(this,oe,new HM(i,o,t))}async initialize(e){return await s(this,oe).sendRequest(we.initialize,e)}async newSession(e){return await s(this,oe).sendRequest(we.session_new,e)}async loadSession(e){return await s(this,oe).sendRequest(we.session_load,e)??{}}async unstable_forkSession(e){return await s(this,oe).sendRequest(we.session_fork,e)}async listSessions(e){return await s(this,oe).sendRequest(we.session_list,e)}async unstable_resumeSession(e){return await s(this,oe).sendRequest(we.session_resume,e)}async unstable_closeSession(e){return await s(this,oe).sendRequest(we.session_close,e)}async setSessionMode(e){return await s(this,oe).sendRequest(we.session_set_mode,e)??{}}async unstable_setSessionModel(e){return await s(this,oe).sendRequest(we.session_set_model,e)??{}}async setSessionConfigOption(e){return await s(this,oe).sendRequest(we.session_set_config_option,e)}async authenticate(e){return await s(this,oe).sendRequest(we.authenticate,e)??{}}async unstable_logout(e){return await s(this,oe).sendRequest(we.logout,e)??{}}async prompt(e){return await s(this,oe).sendRequest(we.session_prompt,e)}async cancel(e){return await s(this,oe).sendNotification(we.session_cancel,e)}async unstable_startNes(e){return await s(this,oe).sendRequest(we.nes_start,e)}async unstable_suggestNes(e){return await s(this,oe).sendRequest(we.nes_suggest,e)}async unstable_closeNes(e){return await s(this,oe).sendRequest(we.nes_close,e)??{}}async unstable_didOpenDocument(e){return await s(this,oe).sendNotification(we.document_did_open,e)}async unstable_didChangeDocument(e){return await s(this,oe).sendNotification(we.document_did_change,e)}async unstable_didCloseDocument(e){return await s(this,oe).sendNotification(we.document_did_close,e)}async unstable_didSaveDocument(e){return await s(this,oe).sendNotification(we.document_did_save,e)}async unstable_didFocusDocument(e){return await s(this,oe).sendNotification(we.document_did_focus,e)}async unstable_acceptNes(e){return await s(this,oe).sendNotification(we.nes_accept,e)}async unstable_rejectNes(e){return await s(this,oe).sendNotification(we.nes_reject,e)}async extMethod(e,t){return await s(this,oe).sendRequest(e,t)}async extNotification(e,t){return await s(this,oe).sendNotification(e,t)}get signal(){return s(this,oe).signal}get closed(){return s(this,oe).closed}}oe=new WeakMap;var li,Nd,Tc,$c,ta,na,Pn,Rc,Ae,yb,C0,wb,bb,Sb,_b,T0,Fl;class HM{constructor(e,t,r){p(this,Ae);p(this,li,new Map);p(this,Nd,0);p(this,Tc);p(this,$c);p(this,ta);p(this,na,Promise.resolve());p(this,Pn,new AbortController);p(this,Rc);h(this,Tc,e),h(this,$c,t),h(this,ta,r),h(this,Rc,new Promise(i=>{s(this,Pn).signal.addEventListener("abort",()=>i())})),u(this,Ae,yb).call(this)}get signal(){return s(this,Pn).signal}get closed(){return s(this,Rc)}async sendRequest(e,t){u(this,Ae,T0).call(this);const r=nh(this,Nd)._++,i=new Promise((o,a)=>{s(this,li).set(r,{resolve:o,reject:a})});return await u(this,Ae,Fl).call(this,{jsonrpc:"2.0",id:r,method:e,params:t}),i}async sendNotification(e,t){u(this,Ae,T0).call(this),await u(this,Ae,Fl).call(this,{jsonrpc:"2.0",method:e,params:t})}}li=new WeakMap,Nd=new WeakMap,Tc=new WeakMap,$c=new WeakMap,ta=new WeakMap,na=new WeakMap,Pn=new WeakMap,Rc=new WeakMap,Ae=new WeakSet,yb=async function(){let e;try{const t=s(this,ta).readable.getReader();try{for(;!s(this,Pn).signal.aborted;){const{value:r,done:i}=await t.read();if(i)break;if(r)try{u(this,Ae,wb).call(this,r)}catch(o){console.error("Unexpected error during message processing:",r,o),"id"in r&&r.id!==void 0&&u(this,Ae,Fl).call(this,{jsonrpc:"2.0",id:r.id,error:{code:-32700,message:"Parse error"}})}}}finally{t.releaseLock()}}catch(t){e=t}finally{u(this,Ae,C0).call(this,e)}},C0=function(e){if(s(this,Pn).signal.aborted)return;const t=e??new Error("ACP connection closed");for(const r of s(this,li).values())r.reject(t);s(this,li).clear(),s(this,Pn).abort(t)},wb=async function(e){if("method"in e&&"id"in e){const t=await u(this,Ae,bb).call(this,e.method,e.params);"error"in t&&console.error("Error handling request",e,t.error),await u(this,Ae,Fl).call(this,{jsonrpc:"2.0",id:e.id,...t})}else if("method"in e){const t=await u(this,Ae,Sb).call(this,e.method,e.params);"error"in t&&console.error("Error handling notification",e,t.error)}else"id"in e?u(this,Ae,_b).call(this,e):console.error("Invalid message",{message:e})},bb=async function(e,t){try{return{result:await s(this,Tc).call(this,e,t)??null}}catch(r){if(r instanceof Oe)return r.toResult();if(r instanceof Ay)return Oe.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 Oe.internalError(i?JSON.parse(i):{}).toResult()}catch{return Oe.internalError({details:i}).toResult()}}},Sb=async function(e,t){try{return await s(this,$c).call(this,e,t),{result:null}}catch(r){if(r instanceof Oe)return r.toResult();if(r instanceof Ay)return Oe.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 Oe.internalError(i?JSON.parse(i):{}).toResult()}catch{return Oe.internalError({details:i}).toResult()}}},_b=function(e){const t=s(this,li).get(e.id);if(t){if("result"in e)t.resolve(e.result);else if("error"in e){const{code:r,message:i,data:o}=e.error;t.reject(new Oe(r,i,o))}s(this,li).delete(e.id)}else console.error("Got response to unknown request",e.id)},T0=function(){if(s(this,Pn).signal.aborted)throw s(this,Pn).signal.reason??new Error("ACP connection closed")},Fl=async function(e){return h(this,na,s(this,na).then(async()=>{const t=s(this,ta).writable.getWriter();try{await t.write(e)}finally{t.releaseLock()}}).catch(t=>{u(this,Ae,C0).call(this,t)})),s(this,na)};class Oe extends Error{constructor(t,r,i){super(r);C(this,"code");C(this,"data");this.code=t,this.name="RequestError",this.data=i}static parseError(t,r){return new Oe(-32700,`Parse error${r?`: ${r}`:""}`,t)}static invalidRequest(t,r){return new Oe(-32600,`Invalid request${r?`: ${r}`:""}`,t)}static methodNotFound(t){return new Oe(-32601,`"Method not found": ${t}`,{method:t})}static invalidParams(t,r){return new Oe(-32602,`Invalid params${r?`: ${r}`:""}`,t)}static internalError(t,r){return new Oe(-32603,`Internal error${r?`: ${r}`:""}`,t)}static authRequired(t,r){return new Oe(-32e3,`Authentication required${r?`: ${r}`:""}`,t)}static resourceNotFound(t){return new Oe(-32002,`Resource not found${t?`: ${t}`:""}`,t&&{uri:t})}toResult(){return{error:{code:this.code,message:this.message,data:this.data}}}toErrorResponse(){return{code:this.code,message:this.message,data:this.data}}}function UM(n,e,t){const r=n.dispose.bind(n);n.dispose=()=>{if(!e())return t(),r()}}function Ab(n){var t;class e extends n{constructor(...o){super(...o);p(this,t,!1);UM(this,()=>s(this,t),()=>{h(this,t,!0)})}[Symbol.dispose](){this.dispose()}get disposed(){return s(this,t)}}return t=new WeakMap,e}const VM=/^Sender \(untrusted metadata\):\n```json\n[\s\S]*?\n```\n\n?/,FM=/^\[[^\n]*Working directory:[^\n]*\]\n\n?/,BM=/\[Television channel context\][\s\S]*?\[\/Television channel context\]\n*/,qM=/\b(tv|television|channel|artifact|artifacts|viewer|filmstrip|layout|focus)\b/i,WM=/^[A-Za-z0-9_@%+=:,./-]+$/,jM=/\[\[\s*(?:reply_to_current|reply_to\s*:\s*[^\]\n]+|audio_as_voice)\s*\]\]\s*/gi,GM="single_session",YM={name:"television-acp-client",version:"0.0.0"},Eb="agent:main:television",JM=Ab(Kr);var ra,Ln,Rt,Dn,ci,ln,br,Mn,cn,ui,un,ia,sa,On,tt,Sr,oa,_s,_r,hi,Ic,hn,Nn,zd,zn,R,$0,kb,Cb,Tb,Dh,$b,Rb,Ib,xb,Pb,Lb,Db,rs,Lo,Do,dr,Mb,Mo,R0,I0,Mh,Ob,Oh,x0,P0,xc,Pc,Nh,Oo,L0,Nb;class KM extends JM{constructor(t){super();p(this,R);p(this,ra,"disconnected");p(this,Ln,null);p(this,Rt,new Map);p(this,Dn,null);p(this,ci,null);p(this,ln,null);p(this,br,null);p(this,Mn,null);p(this,cn,null);p(this,ui);p(this,un,null);p(this,ia,0);p(this,sa,1);p(this,On,null);p(this,tt,null);p(this,Sr,!1);p(this,oa,!1);p(this,_s,!1);p(this,_r,null);p(this,hi,new Set);p(this,Ic);p(this,hn);p(this,Nn);p(this,zd,t=>{u(this,R,Cb).call(this,t)});p(this,zn,null);p(this,xc,()=>{u(this,R,Oo).call(this,"ACP bridge websocket closed")});p(this,Pc,()=>{u(this,R,Oo).call(this,"ACP bridge websocket error")});h(this,hn,t),h(this,Nn,t.sessionMode??GM),h(this,ui,t.mappedSessionStore??XM()),h(this,Ic,t.createSocket??(r=>new WebSocket(r)))}get status(){return s(this,ra)}get messages(){return[...s(this,Rt).values()]}get enabled(){return s(this,hn).enabled??!1}setToken(t){s(this,hn).token=t??""}setEnabled(t){s(this,hn).enabled=t,t||(u(this,R,Nh).call(this),h(this,Ln,null),u(this,R,dr).call(this,"disconnected"))}async connect(){if(this.disposed)throw new Error("ACPClient has been disposed");if(this.enabled&&this.status==="disconnected"){s(this,ci)===null&&(h(this,Ln,null),h(this,ci,u(this,R,kb).call(this)));try{await s(this,ci),await u(this,R,Dh).call(this)}catch(t){throw u(this,R,Oo).call(this,qf(t)),t}}}dispose(){u(this,R,Nh).call(this),h(this,Ln,null),u(this,R,dr).call(this,"disposed")}async sendMessage(t){if(await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await u(this,R,$0).call(this,"ready")),(s(this,Mn)===null||s(this,un)!==u(this,R,Oh).call(this))&&await u(this,R,Dh).call(this),this.status!=="ready")throw new Error("ACPClient is not ready to send a new message");const r=t.text.trim();if(!r)throw new Error("Cannot send an empty message");u(this,R,Lo).call(this,{id:u(this,R,Mo).call(this,"user"),kind:"user",text:r,status:"final"}),u(this,R,dr).call(this,"running");try{const i=await u(this,R,Mh).call(this).prompt({sessionId:u(this,R,I0).call(this),prompt:[{type:"text",text:u(this,R,Mb).call(this,r)}]});u(this,R,rs).call(this,i.stopReason==="cancelled"?"cancelled":"final"),u(this,R,dr).call(this,"ready")}catch(i){throw u(this,R,Nb).call(this)||(u(this,R,rs).call(this,"error"),u(this,R,dr).call(this,"ready")),i}}async startNewSession(){var r;await this.connect(),(this.status==="running"||this.status==="cancelling")&&(await this.cancel(),await u(this,R,$0).call(this,"ready"));const t=u(this,R,Oh).call(this);((r=s(this,cn))==null?void 0:r.sessionIdStrategy)==="mapped"?s(this,ui).clearActualSessionId(t):h(this,ia,s(this,ia)+1),h(this,ln,null),h(this,br,null),h(this,Mn,null),h(this,un,null),u(this,R,L0).call(this)}async cancel(){this.status==="running"&&(u(this,R,dr).call(this,"cancelling"),await u(this,R,Mh).call(this).cancel({sessionId:u(this,R,I0).call(this)}))}setChannelContext(t){var o,a,l;if(t===null){if(s(this,tt)===null)return;h(this,tt,null),h(this,Sr,!1);return}const r={channelID:t.channelID,channelName:t.channelName};if(((o=s(this,tt))==null?void 0:o.channelID)===r.channelID&&((a=s(this,tt))==null?void 0:a.channelName)===r.channelName)return;const i=((l=s(this,tt))==null?void 0:l.channelID)??null;if(h(this,tt,r),s(this,Nn)==="single_session"){(!s(this,un)||i!==r.channelID)&&h(this,Sr,!0);return}s(this,un)!==u(this,R,x0).call(this,r.channelID)&&(h(this,ln,null),h(this,br,null),s(this,Dn)&&this.status==="ready"&&u(this,R,Dh).call(this).catch(c=>{u(this,R,Oo).call(this,qf(c))}))}}ra=new WeakMap,Ln=new WeakMap,Rt=new WeakMap,Dn=new WeakMap,ci=new WeakMap,ln=new WeakMap,br=new WeakMap,Mn=new WeakMap,cn=new WeakMap,ui=new WeakMap,un=new WeakMap,ia=new WeakMap,sa=new WeakMap,On=new WeakMap,tt=new WeakMap,Sr=new WeakMap,oa=new WeakMap,_s=new WeakMap,_r=new WeakMap,hi=new WeakMap,Ic=new WeakMap,hn=new WeakMap,Nn=new WeakMap,zd=new WeakMap,zn=new WeakMap,R=new WeakSet,$0=async function(t){if(this.status!==t){if(this.status==="disposed")throw new Error("ACPClient has been disposed");if(this.status==="disconnected")throw new Error(s(this,Ln)??"ACPClient is disconnected");await new Promise((r,i)=>{const o=()=>{this.removeEventListener("status-changed",a)},a=()=>{if(this.status===t){o(),r();return}if(this.status==="disposed"){o(),i(new Error("ACPClient has been disposed"));return}this.status==="disconnected"&&(o(),i(new Error(s(this,Ln)??"ACPClient is disconnected")))};this.addEventListener("status-changed",a)})}},kb=async function(){try{const{stream:t,socket:r,metadata:i}=await nO({serverURL:s(this,hn).serverURL,token:s(this,hn).token,createSocket:s(this,Ic),onDisconnect:s(this,zd)});h(this,cn,i),h(this,zn,r),r.addEventListener("close",s(this,xc)),r.addEventListener("error",s(this,Pc)),h(this,Dn,new ZM(o=>({connection:o,sessionUpdate:async a=>{await u(this,R,Rb).call(this,a)},requestPermission:async a=>u(this,R,Ib).call(this,a)}),t)),await s(this,Dn).initialize({protocolVersion:_P,clientCapabilities:{},clientInfo:YM})}catch(t){throw t}},Cb=function(t){u(this,R,Oo).call(this,qf(t))},Tb=function(t){const r=t==null?void 0:t.models;if(!(r!=null&&r.currentModelId))return;const i=r.availableModels.find(o=>o.modelId===r.currentModelId);console.info("[ACPClient] Current model:",(i==null?void 0:i.name)??r.currentModelId,`(${r.currentModelId})`)},Dh=async function(){const t=u(this,R,Oh).call(this);if(s(this,ln)&&s(this,br)===t){await s(this,ln);return}h(this,br,t),h(this,ln,u(this,R,$b).call(this,t)),await s(this,ln)},$b=async function(t){var c;const r=u(this,R,Mh).call(this);u(this,R,L0).call(this);let i,o=!1,a=null;const l={cwd:u(this,R,Ob).call(this),mcpServers:[],_meta:{sessionKey:t}};try{if(h(this,_s,!0),h(this,_r,null),((c=s(this,cn))==null?void 0:c.sessionIdStrategy)==="mapped"){const d=s(this,ui).getActualSessionId(t);if(d)try{const f=await r.loadSession({...l,sessionId:d});if(QM(f))throw new Error("Mapped ACP session was not found");a=f,i=d,o=!0}catch{const f=await r.newSession(l);a=f,i=f.sessionId,s(this,ui).setActualSessionId(t,i),o=!1}else{const f=await r.newSession(l);a=f,i=f.sessionId,s(this,ui).setActualSessionId(t,i),o=!1}}else try{a=await r.loadSession({...l,sessionId:t}),i=t,o=s(this,Rt).size>0}catch{const d=await r.newSession(l);a=d,i=d.sessionId,o=!1}}finally{h(this,_s,!1),h(this,_r,null),u(this,R,rs).call(this,"final")}u(this,R,Tb).call(this,a),await r.setSessionConfigOption({sessionId:i,configId:"verbose_level",value:"full"}),h(this,Mn,i),h(this,un,t),h(this,oa,!0),o?(s(this,hi).add(t),s(this,Nn)==="single_session"&&h(this,Sr,!1)):(s(this,hi).delete(t),h(this,Sr,s(this,Nn)==="single_session")),h(this,Ln,null),u(this,R,dr).call(this,"ready")},Rb=async function(t){const r=t.update;switch(r.sessionUpdate){case"user_message_chunk":r.content.type==="text"&&u(this,R,Db).call(this,r.content.text);return;case"agent_message_chunk":r.content.type==="text"&&u(this,R,xb).call(this,r.content.text);return;case"tool_call":u(this,R,Pb).call(this,r);return;case"tool_call_update":u(this,R,Lb).call(this,r);return;case"agent_thought_chunk":return;default:return}},Ib=async function(t){return{outcome:{outcome:"cancelled"}}},xb=function(t){h(this,_r,null);const r=tO(t);if(!r)return;if(!s(this,On)){const o={id:u(this,R,Mo).call(this,"assistant"),kind:"assistant",text:r,status:"streaming"};h(this,On,o.id),u(this,R,Lo).call(this,o);return}const i=s(this,Rt).get(s(this,On));if(!i||i.kind!=="assistant")throw new Error("Open assistant message invariant violated");u(this,R,Do).call(this,{...i,text:`${i.text}${r}`,status:"streaming"})},Pb=function(t){u(this,R,rs).call(this,"final");const r=u(this,R,R0).call(this,t.toolCallId),i=My("content"in t?t.content:void 0),o={id:(r==null?void 0:r.id)??u(this,R,Mo).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:t.title,toolKind:t.kind??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:(r==null?void 0:r.text)??i,locations:t.locations??(r==null?void 0:r.locations)};if(r){u(this,R,Do).call(this,o);return}u(this,R,Lo).call(this,o)},Lb=function(t){const r=u(this,R,R0).call(this,t.toolCallId),i=(r==null?void 0:r.text)??"",o=My(t.content),a=o?`${i}${o}`:i,l={id:(r==null?void 0:r.id)??u(this,R,Mo).call(this,"tool"),kind:"tool_call",toolCallId:t.toolCallId,title:(r==null?void 0:r.title)??t.toolCallId,toolKind:(r==null?void 0:r.toolKind)??"other",status:t.status==="failed"?"failed":t.status==="completed"?"completed":"in_progress",text:a,locations:t.locations??(r==null?void 0:r.locations)};if(r){u(this,R,Do).call(this,l);return}u(this,R,Lo).call(this,l)},Db=function(t){if(u(this,R,rs).call(this,"final"),!t)return;const r=s(this,_s)?s(this,_r):null;if(!r){const o=Dy(t);if(!o)return;const a={id:u(this,R,Mo).call(this,"user"),kind:"user",text:o,status:"final"};u(this,R,Lo).call(this,a),s(this,_s)&&h(this,_r,a.id);return}const i=s(this,Rt).get(r);if(!i||i.kind!=="user")throw new Error("Replay user message invariant violated");u(this,R,Do).call(this,{...i,text:Dy(`${i.text}${t}`)})},rs=function(t){if(!s(this,On))return;const r=s(this,Rt).get(s(this,On));(r==null?void 0:r.kind)==="assistant"&&u(this,R,Do).call(this,{...r,status:t}),h(this,On,null)},Lo=function(t){s(this,Rt).set(t.id,t),this.dispatchEvent(new Uf("messages-changed"))},Do=function(t){s(this,Rt).set(t.id,t),this.dispatchEvent(new Uf("messages-changed"))},dr=function(t){s(this,ra)!==t&&(h(this,ra,t),this.dispatchEvent(new s$("status-changed")))},Mb=function(t){var d;const r=s(this,un);if(!r)return t;const i=s(this,tt)?s(this,Nn)==="single_session"?s(this,Sr)||!s(this,hi).has(r):!s(this,hi).has(r):!1,o=s(this,oa)&&(s(this,tt)!==null||qM.test(t));if(!(o||i))return t;o&&h(this,oa,!1),i&&(h(this,Sr,!1),s(this,hi).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=((d=s(this,cn))==null?void 0:d.tvArgs)??[];return c.length>0&&l.push(`To reach this Television server, add these arguments to each tv command that contacts it: ${c.map(sO).join(" ")}`),s(this,tt)?(l.push("This conversation is currently attached to the channel below."),l.push(`channel_id: ${s(this,tt).channelID}`),l.push(`channel_name: ${s(this,tt).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]","",t),l.join(`
43
- `)},Mo=function(t){const r=`${t}-${s(this,sa)}`;return h(this,sa,s(this,sa)+1),r},R0=function(t){for(const r of s(this,Rt).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===t)return r;return null},I0=function(){if(!s(this,Mn))throw new Error("ACP session is not ready");return s(this,Mn)},Mh=function(){if(!s(this,Dn))throw new Error("ACP connection is not ready");return s(this,Dn)},Ob=function(){var r;const t=(r=s(this,cn))==null?void 0:r.sessionCwd;if(!t)throw new Error("ACP bridge session cwd is not ready");return t},Oh=function(){var r;if(s(this,Nn)==="single_session")return u(this,R,P0).call(this,`${Eb}-${(s(this,hn).clientGUID??"default-client").toLowerCase()}`);const t=(r=s(this,tt))==null?void 0:r.channelID;if(!t)throw new Error("Channel context is required for per-channel session mode");return u(this,R,x0).call(this,t)},x0=function(t){return u(this,R,P0).call(this,eO(s(this,Nn),t,s(this,hn).clientGUID??"default-client"))},P0=function(t){var r;return((r=s(this,cn))==null?void 0:r.sessionIdStrategy)==="deterministic"&&s(this,ia)>0?`${t}:epoch-${s(this,ia)}`:t},xc=new WeakMap,Pc=new WeakMap,Nh=function(){h(this,Dn,null),h(this,ci,null),h(this,ln,null),h(this,br,null),h(this,Mn,null),h(this,un,null),h(this,cn,null),s(this,zn)&&(s(this,zn).removeEventListener("close",s(this,xc)),s(this,zn).removeEventListener("error",s(this,Pc)),s(this,zn).close(),h(this,zn,null))},Oo=function(t){const r=s(this,Dn)!==null||s(this,ci)!==null||s(this,ln)!==null||s(this,br)!==null||s(this,Mn)!==null||s(this,un)!==null||s(this,cn)!==null||s(this,zn)!==null;this.disposed||this.status==="disconnected"&&!r||(u(this,R,rs).call(this,"error"),u(this,R,Nh).call(this),h(this,Ln,t??null),u(this,R,dr).call(this,"disconnected"))},L0=function(){const t=s(this,Rt).size>0;h(this,On,null),h(this,_r,null),h(this,sa,1),s(this,Rt).clear(),t&&this.dispatchEvent(new Uf("messages-changed"))},Nb=function(){return this.status==="disconnected"};function XM(){const n=new Map;return{getActualSessionId(e){return n.get(e)??null},setActualSessionId(e,t){n.set(e,t)},clearActualSessionId(e){n.delete(e)}}}function QM(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function eO(n,e,t){return n==="single_session"?`${Eb}-${t.toLowerCase()}`:`agent:main:television-${t.toLowerCase()}-${e.toLowerCase()}`}function zb(n){return n.replace(/^(?:\s*\n)+/,"")}function Dy(n){let e=n;return e=e.replace(VM,""),e=e.replace(FM,""),e=e.replace(BM,""),e=zb(e),e}function tO(n){let e=n;return e=e.replace(jM,""),e=zb(e),e}function My(n){return!n||n.length===0?"":n.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function nO(n){const e=n.createSocket(aO(n.serverURL,n.token));let t=!1,r,i;const o=new Promise((d,f)=>{r=d,i=f}),a=new ReadableStream({start(d){let f=!1;const g=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},y=E=>{const x=oO(E);if(!x)return;let B;try{B=JSON.parse(x)}catch(P){const J=P instanceof Error?P:new Error(String(P));i(J),d.error(J);return}switch(B.type){case"acp-bridge-status":if(B.status==="ready"){let P;try{P=rO(B)}catch(J){const O=J instanceof Error?J:new Error(String(J));t||i(O),d.error(O);return}t||(t=!0,r(P));return}if(B.status==="error"||B.status==="exited"){const P=new Error(B.error??`ACP bridge ${B.status}`);t||i(P),d.error(P)}return;case"acp-bridge-message":d.enqueue(B.message);return}},v=()=>{var x;if(f)return;f=!0;const E=new Error("ACP bridge websocket closed");t||i(E),(x=n.onDisconnect)==null||x.call(n,E),d.close()},_=()=>{var x;if(f)return;f=!0;const E=new Error("ACP bridge websocket error");t||i(E),(x=n.onDisconnect)==null||x.call(n,E),d.error(E)};e.addEventListener("open",g),e.addEventListener("message",y),e.addEventListener("close",v),e.addEventListener("error",_)}}),l=new WritableStream({async write(d){await o,e.send(JSON.stringify({type:"acp-bridge-message",message:d}))},close(){e.close()},abort(){e.close()}}),c=await o;return{stream:{readable:a,writable:l},socket:e,metadata:c}}function rO(n){const{agent:e,sessionIdStrategy:t,sessionCwd:r,tvArgs:i}=n;if((e==="openclaw"||e==="hermes")&&(t==="deterministic"||t==="mapped")&&typeof r=="string"&&r.length>0&&iO(i))return{agent:e,sessionIdStrategy:t,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function iO(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function sO(n){return WM.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function oO(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 e=n.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function aO(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/acp",t.search="",t.searchParams.set("token",e),t.hash="",t.toString()}function qf(n){return n instanceof Error?n.message:String(n)}const Oy="television.acpClientGUID",Ny="television.acpMappedSessions",zy=1;var aa;class lO{constructor(){p(this,aa,new Map)}getActualSessionId(e){return s(this,aa).get(e)??null}setActualSessionId(e,t){s(this,aa).set(e,t)}clearActualSessionId(e){s(this,aa).delete(e)}}aa=new WeakMap;var la,Lc,Mt,zh,Zh,D0;class cO{constructor(e,t){p(this,Mt);p(this,la);p(this,Lc);h(this,la,e),h(this,Lc,t)}getActualSessionId(e){const t=u(this,Mt,Zh).call(this)[u(this,Mt,zh).call(this,e)];return typeof t=="string"&&t.length>0?t:null}setActualSessionId(e,t){const r=u(this,Mt,Zh).call(this);r[u(this,Mt,zh).call(this,e)]=t,u(this,Mt,D0).call(this,r)}clearActualSessionId(e){const t=u(this,Mt,Zh).call(this);delete t[u(this,Mt,zh).call(this,e)],u(this,Mt,D0).call(this,t)}}la=new WeakMap,Lc=new WeakMap,Mt=new WeakSet,zh=function(e){return JSON.stringify([s(this,Lc),e])},Zh=function(){const e=s(this,la).getItem(Ny);if(!e)return{};let t;try{t=JSON.parse(e)}catch{return{}}if(typeof t!="object"||t===null||Array.isArray(t))return{};const r=t;return r.version!==zy?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},D0=function(e){const t={version:zy,entries:e};s(this,la).setItem(Ny,JSON.stringify(t))};function Zb(){return typeof window>"u"?null:window.localStorage}function uO(n){const e=n.getItem(Oy);if(e)return e;const t=Tg().toLowerCase();return n.setItem(Oy,t),t}const Zy=4401,hO=401,fh=1e3,dO=3e4;class Hh extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class pO extends Kr{constructor(t){var a,l;super();C(this,"url");C(this,"name");C(this,"telemetryMeta");C(this,"status","unauthorized");C(this,"channels",new Map);C(this,"client");C(this,"acpClient");C(this,"_token");C(this,"attempting",!1);C(this,"nextRetryAt",null);C(this,"hasEverConnected",!1);C(this,"browserDemoMode",!1);C(this,"hasAuthRejected",!1);C(this,"hasAuthTokenRejected",!1);C(this,"bootState","pending");C(this,"serverVersion",null);C(this,"updateState",null);C(this,"decideBoot");C(this,"navigationPending");C(this,"createSocket");C(this,"createClient");C(this,"socket",null);C(this,"connectAttempt",0);C(this,"autoReconnect",!1);C(this,"retryTimer",null);C(this,"retryDelay",fh);C(this,"visibilityEventTarget");C(this,"networkEventTarget");C(this,"onVisibilityChange");C(this,"onNetworkOnline");C(this,"telemetryActivityAgent");this.url=Fi(t.url),this.name=t.name,this.decideBoot=t.decideBoot??null,this.navigationPending=t.navigationPending??(()=>!1),this._token=t.token??null,this.telemetryMeta=t.telemetryMeta??null,this.createSocket=t.createSocket??(c=>new WebSocket(c)),this.createClient=t.createClient??((c,d,f)=>new PT(c,{token:d??void 0,onUnauthorized:()=>this.handleAuthRejected(),...f?{telemetryMeta:f}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=t.mappedSessionStore??(t.acpStorage?new cO(t.acpStorage,this.url):new lO);this.acpClient=new KM({serverURL:this.url,token:this._token??"",...t.createACPSocket?{createSocket:t.createACPSocket}:t.createSocket?{createSocket:t.createSocket}:{},...t.clientGUID?{clientGUID:t.clientGUID}:{},mappedSessionStore:r}),this.visibilityEventTarget=t.visibilityEventTarget!==void 0?t.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=t.networkEventTarget!==void 0?t.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=t.telemetryDocumentTarget!==void 0?t.telemetryDocumentTarget:typeof document<"u"?document:null,o=t.telemetryWindowTarget!==void 0?t.telemetryWindowTarget:typeof window<"u"?window:null;this.telemetryActivityAgent=this.telemetryMeta&&i&&o?wP({meta:this.telemetryMeta,documentTarget:i,windowTarget:o,send:c=>this.sendTelemetryActivity(c)}):null}get token(){return this._token}clearToken(){this._token=null,this.acpClient.setToken(null),this.client=this.createClient(this.url,null,this.telemetryMeta)}async connect(t){this._token=t,this.hasAuthRejected=!1,this.hasAuthTokenRejected=!1,this.acpClient.setToken(t),this.cancelRetryTimer(),this.retryDelay=fh,this.autoReconnect=!0,await this.attempt()}dispose(){var t,r,i,o;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(t=this.socket)==null||t.close(),this.socket=null,this.setStatus("unauthorized"),(r=this.visibilityEventTarget)==null||r.removeEventListener("visibilitychange",this.onVisibilityChange),(i=this.networkEventTarget)==null||i.removeEventListener("online",this.onNetworkOnline),(o=this.telemetryActivityAgent)==null||o.stop(),this.acpClient.dispose()}getViewURL(t){const r=Ad(t,this.renderOptions());return Br()?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:Br(),browserDemo:this.browserDemoMode}}getContentURL(t){const r=Ad(t,this.renderOptions()).contentURL;return r===null?null:new URL(r,this.url).toString()}async createChannel(t){const{channel:r}=await this.client.channels.create({name:t});return this.channels.set(r.id,structuredClone(r)),r}applyServerEvent(t){switch(t.type){case"channel-created":this.channels.set(t.channel.id,structuredClone(t.channel)),this.dispatchEvent(new Ul("channels-changed"));break;case"channel-updated":this.channels.set(t.channel.id,structuredClone(t.channel)),this.dispatchEvent(new Ul("channels-changed"));break;case"channel-removed":this.channels.delete(t.channelID),this.dispatchEvent(new Ul("channels-changed"));break;case"artifact-created":{const r=this.channels.get(t.channelID);r&&!mT(r).includes(t.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[t.artifact.id],geometry:{...V2},size:{...F2}}]);break}case"artifact-removed":{const r=this.channels.get(t.channelID);r&&(r.layout=m0(r.layout,t.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 fO(t,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1,this.bootState="pending";const t=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token,this.telemetryMeta),this.setStatus("disconnected"),this.dispatchEvent(new At("change"));const r=this.createSocket(mO(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((o,a)=>{let l=!1;const c=()=>{var g;l||this.connectAttempt!==t||(l=!0,this.retryDelay=fh,this.hasEverConnected=!0,this.setStatus("connected"),(g=this.telemetryActivityAgent)==null||g.start(),o())},d=g=>{l||this.connectAttempt!==t||(l=!0,a(g))},f=async()=>{const g=this.hasEverConnected;try{const[{channels:y},v,_]=await Promise.all([this.client.channels.list(),this.client.display.get(),g?null:this.readDemoMode()]);g||(this.browserDemoMode=(_==null?void 0:_.browserExternalPages)===!0),this.channels=new Map(y.map(E=>[E.id,structuredClone(E)])),this.acpClient.setEnabled(v.acpEnabled),this.dispatchEvent(new At("change")),g&&this.dispatchEvent(new Ul("channels-changed")),this.dispatchEvent(new Ph("server-event",{serverURL:this.url,event:{type:"channel-changed",channelID:v.focusedChannelId}})),this.dispatchEvent(new Ph("server-event",{serverURL:this.url,event:{type:"pinned-channels-changed",pinnedChannelIds:[...v.pinnedChannelIds]}})),c(),g&&this.connectAttempt===t&&this.dispatchEvent(new e8("server-reconnected",{serverURL:this.url}))}catch(y){if(SO(y)){d(new Hh);return}d(y instanceof Error?y:new Error(String(y)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||f())}),r.addEventListener("message",g=>{const y=bO(g);if(!y)return;if(y.type==="server-status"){const _=y;this.serverVersion=_.version,this.updateState=_.update??null;let E=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===t&&(this.decideBoot(_)==="boot"?(this.bootState="booted",E=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new t8("server-status",{serverURL:this.url,message:_})),E?this.navigationPending()||f():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new At("change"));return}if(!wO(y.type))return;const v=y;this.applyServerEvent(v),this.dispatchEvent(new Ph("server-event",{serverURL:this.url,event:v}))}),r.addEventListener("close",g=>{if(this.connectAttempt!==t)return;this.socket=null;const y=gO(g);if(!l){d(y===Zy?new Hh:new Error("Connection closed before initialization"));return}if(y===Zy){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}),r.addEventListener("error",()=>{if(this.connectAttempt===t){if(l){this.handleTransportFailure(new Error("WebSocket error"));return}d(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},o=>{throw this.attempting=!1,this.handleAttemptFailure(o),o})}handleAuthRejected(){this.hasAuthRejected=!0,this.hasAuthTokenRejected=this._token!==null,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(t){if(t instanceof Hh){this.handleAuthRejected();return}this.autoReconnect&&this.scheduleRetry()}handleTransportFailure(t){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const t=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,dO),this.nextRetryAt=Date.now()+t,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},t),this.dispatchEvent(new At("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new At("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=fh,this.attempt().catch(()=>{})))}sendTelemetryActivity(t){var r;this.status==="connected"&&((r=this.socket)==null||r.send(JSON.stringify(t)))}sendTelemetrySignal(t,r){var o;if(!this.telemetryMeta||this.status!=="connected"&&this.bootState!=="halted")return;const i={type:fT,clientId:this.telemetryMeta.clientId,event:t,properties:r};(o=this.socket)==null||o.send(JSON.stringify(i))}setStatus(t){this.status!==t&&(this.status=t,this.dispatchEvent(new At("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function fO(n,e){throw new Error(`Unexpected ${e}: ${JSON.stringify(n)}`)}function mO(n,e,t=null){const r=new URL(n);if(r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname="/events",r.search="",e&&r.searchParams.set("token",e),t)for(const[i,o]of yP(t))r.searchParams.set(i,o);return r.hash="",r.toString()}function gO(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const vO={"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},yO=new Set(Object.keys(vO));function wO(n){return yO.has(n)}function bO(n){const e=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return typeof t!="object"||t===null||!("type"in t)||typeof t.type!="string"?null:t}function SO(n){return n instanceof pl&&n.status===hO}const _O="Local";var Vt,dn,rr,M0,O0,Hb,Dc,Mc,Oc,Nc,zc;class AO extends Kr{constructor(t){super();p(this,rr);C(this,"connection");C(this,"clientGUID");C(this,"acpStorage");C(this,"connectError",null);p(this,Vt);p(this,dn,!1);p(this,Dc,()=>{s(this,dn)||(u(this,rr,Hb).call(this),this.dispatchEvent(new At("change")))});p(this,Mc,t=>{s(this,dn)||this.dispatchEvent(new Ph("server-event",{serverURL:t.serverURL,event:t.event}))});p(this,Oc,()=>{s(this,dn)||this.dispatchEvent(new Ul("channels-changed"))});p(this,Nc,t=>{s(this,dn)||this.dispatchEvent(new e8("server-reconnected",{serverURL:t.serverURL}))});p(this,zc,t=>{s(this,dn)||this.dispatchEvent(new t8("server-status",{serverURL:t.serverURL,message:t.message}))});h(this,Vt,t.localStore),this.acpStorage=t.acpStorage===void 0?Zb():t.acpStorage,this.clientGUID=t.clientGUID??(this.acpStorage?uO(this.acpStorage):Tg().toLowerCase());const r=Fi(t.serverURL);t.launchToken!==void 0&&t.launchToken!==null&&s(this,Vt).set(oy(s(this,Vt).get(),r,t.launchToken));const i=t.launchToken??sy(s(this,Vt).get(),r),o=t.createSocket??(l=>new WebSocket(l)),a=t.createConnection??(l=>new pO(l));this.connection=a({url:r,name:t.connectionName??_O,token:i,createSocket:o,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:t.telemetryMeta??null,decideBoot:t.decideBoot,navigationPending:t.navigationPending}),this.connection.addEventListener("change",s(this,Dc)),this.connection.addEventListener("server-event",s(this,Mc)),this.connection.addEventListener("channels-changed",s(this,Oc)),this.connection.addEventListener("server-reconnected",s(this,Nc)),this.connection.addEventListener("server-status",s(this,zc))}get storedAuthToken(){return sy(s(this,Vt).get(),this.connection.url)}async connect(){await u(this,rr,M0).call(this,this.connection.token)}async authenticate(t){s(this,Vt).set(oy(s(this,Vt).get(),this.connection.url,t)),await u(this,rr,M0).call(this,t)}dispose(){s(this,dn)||(h(this,dn,!0),this.connection.removeEventListener("change",s(this,Dc)),this.connection.removeEventListener("server-event",s(this,Mc)),this.connection.removeEventListener("channels-changed",s(this,Oc)),this.connection.removeEventListener("server-reconnected",s(this,Nc)),this.connection.removeEventListener("server-status",s(this,zc)),this.connection.dispose())}}Vt=new WeakMap,dn=new WeakMap,rr=new WeakSet,M0=async function(t){if(!s(this,dn)){u(this,rr,O0).call(this,null);try{await this.connection.connect(t)}catch(r){u(this,rr,O0).call(this,r instanceof Hh?null:r instanceof Error?r.message:String(r))}}},O0=function(t){this.connectError!==t&&(this.connectError=t,this.dispatchEvent(new At("change")))},Hb=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const t=s(this,Vt).get(),r=c$(t,this.connection.url);r!==t&&s(this,Vt).set(r),this.connection.token!==null&&this.connection.clearToken()},Dc=new WeakMap,Mc=new WeakMap,Oc=new WeakMap,Nc=new WeakMap,zc=new WeakMap;const N0="tv-nav:",nl="tv-reload",Hy=100,EO=1e3,kO=60,CO=60,TO=24,$O=30,RO=$O*TO*CO*kO*EO;function qr(n){try{const e=new URL(n,window.location.href),t=e.searchParams.has(nl);return e.searchParams.delete(nl),e.origin===window.location.origin?`${e.pathname}${e.search}${e.hash}`:t?e.toString():n}catch{return n}}var Zc,ca,ge,pe,As,Pe,Ub,Qr,Vb,z0,Z0;class IO extends Kr{constructor(t,r){super();p(this,Pe);p(this,Zc);p(this,ca);p(this,ge,[]);p(this,pe,-1);p(this,As,0);h(this,Zc,t),h(this,ca,qr(r)),u(this,Pe,Ub).call(this)}get currentURL(){var t;return s(this,pe)===-1?null:((t=s(this,ge)[s(this,pe)])==null?void 0:t.url)??null}get canGoBack(){return s(this,pe)>-1}get canGoForward(){return s(this,pe)<s(this,ge).length-1}get entries(){return s(this,ge).map(t=>({...t}))}get cursor(){return s(this,pe)}navigate(t){const r=qr(t);if(r===s(this,ca)){if(s(this,pe)===-1)return;h(this,pe,-1),u(this,Pe,Qr).call(this);return}s(this,pe)<s(this,ge).length-1&&h(this,ge,s(this,ge).slice(0,s(this,pe)+1)),s(this,ge).push({url:r}),h(this,pe,s(this,ge).length-1),u(this,Pe,z0).call(this),u(this,Pe,Qr).call(this)}replace(t){var i;if(s(this,pe)===-1){this.navigate(t);return}const r=qr(t);if(r===s(this,ca)){h(this,ge,s(this,ge).filter((o,a)=>a!==s(this,pe))),h(this,pe,-1),u(this,Pe,Qr).call(this);return}((i=s(this,ge)[s(this,pe)])==null?void 0:i.url)!==r&&(h(this,ge,s(this,ge).map((o,a)=>a===s(this,pe)?{url:r}:o)),u(this,Pe,Qr).call(this))}back(){s(this,pe)!==-1&&(h(this,pe,s(this,pe)-1),u(this,Pe,Qr).call(this))}forward(){this.canGoForward&&(h(this,pe,s(this,pe)+1),u(this,Pe,Qr).call(this))}reset(){s(this,pe)===-1&&s(this,ge).length===0||(h(this,ge,[]),h(this,pe,-1),u(this,Pe,Qr).call(this))}}Zc=new WeakMap,ca=new WeakMap,ge=new WeakMap,pe=new WeakMap,As=new WeakMap,Pe=new WeakSet,Ub=function(){const t=localStorage.getItem(s(this,Pe,Z0));if(t!==null)try{const r=JSON.parse(t);if(!Fb(r))return;h(this,ge,r.entries.map(i=>({url:i.url}))),h(this,pe,r.cursor),h(this,As,r.lastWritten),u(this,Pe,z0).call(this)}catch{h(this,ge,[]),h(this,pe,-1),h(this,As,0)}},Qr=function(){h(this,As,Date.now());try{localStorage.setItem(s(this,Pe,Z0),JSON.stringify(u(this,Pe,Vb).call(this)))}catch(t){if(!LO(t))throw t}this.dispatchEvent(new At("change"))},Vb=function(){return{v:1,entries:s(this,ge).map(t=>({...t})),cursor:s(this,pe),lastWritten:s(this,As)}},z0=function(){if(s(this,ge).length<=Hy)return;const t=s(this,ge).length-Hy;h(this,ge,s(this,ge).slice(t)),h(this,pe,Math.max(-1,s(this,pe)-t))},Z0=function(){return xO(s(this,Zc))};function xO(n){return`${N0}${n}`}function PO(n){const e=Date.now()-RO,t=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(N0)))continue;const o=i.slice(N0.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{t.push(i);continue}if(!Fb(l)){t.push(i);continue}!n.has(o)&&l.lastWritten<e&&t.push(i)}for(const r of t)localStorage.removeItem(r)}function LO(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function Fb(n){if(typeof n!="object"||n===null)return!1;const e=n;if(e.v!==1||!Array.isArray(e.entries))return!1;const t=e.cursor;return typeof t!="number"||!Number.isInteger(t)||typeof e.lastWritten!="number"||!Number.isFinite(e.lastWritten)||t<-1||t>=e.entries.length?!1:e.entries.every(r=>typeof r=="object"&&r!==null&&typeof r.url=="string")}const Wf="tv-channel-sidebar-collapsed";var Es;class DO{constructor(e){p(this,Es);h(this,Es,e)}read(){return s(this,Es).getItem(Wf)==="true"}setCollapsed(e){try{e?s(this,Es).setItem(Wf,"true"):s(this,Es).removeItem(Wf)}catch{}}}Es=new WeakMap;const jf="tv-channel-sidebar-width",H0=160,U0=350,mh=260,MO=/^-?\d+$/;var ks;class OO{constructor(e){p(this,ks);h(this,ks,e)}read(){const e=s(this,ks).getItem(jf);if(e===null||!MO.test(e))return null;const t=BigInt(e);return t<BigInt(H0)?H0:t>BigInt(U0)?U0:Number(t)}commit(e){const t=Bb(Math.round(e));try{s(this,ks).setItem(jf,String(t))}catch{}return t}clear(){try{s(this,ks).removeItem(jf)}catch{}}}ks=new WeakMap;function Bb(n){return Math.min(Math.max(n,H0),U0)}const NO="1.4.8";function Ng(n=NO){return n!==void 0&&n.length>0?n:"0.0.0"}function zg(){let n=!1;return{get pending(){return n},begin(e){n||(n=!0,e())}}}const V0="tv-reload-attempted";function zO(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:MT(n.bundleVersion,n.serverVersion)?n.marker!==null&&n.marker.serverVersion===n.serverVersion?{action:"none"}:{action:"reload",marker:{serverVersion:n.serverVersion,fromVersion:n.bundleVersion}}:{action:"none"}:{action:"none"}}function ZO(n){const e=n.getItem(V0);if(e===null)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const r=t;return typeof r.serverVersion!="string"||typeof r.fromVersion!="string"?null:{serverVersion:r.serverVersion,fromVersion:r.fromVersion}}function HO(n){const e=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,t=n.reload??(()=>location.reload()),r=n.navigationLatch??zg(),i=n.bundleVersion??Ng();if(e===null)return{dispose(){}};let o=null;const a=()=>{if(o===null)return;const d=n.owner.connection;if(d.url!==n.primaryServerURL||d.status!=="connected")return;const f=o;o=null,d.sendTelemetrySignal("client_autoreloaded",{from_version:f.fromVersion,to_version:f.toVersion})},l=d=>{if(r.pending)return;const f=zO({bundleVersion:i,serverVersion:d.message.version,originMatch:d.serverURL===n.primaryServerURL,marker:ZO(e)});switch(f.action){case"reload":e.setItem(V0,JSON.stringify(f.marker)),r.begin(t);return;case"signal-autoreloaded":e.removeItem(V0),o={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 UO(n){const e=Br(n.search),t=U8(n.search),r=t!==null&&Op(t)?t:null;return{electron:e,shellVersion:r}}function VO(n){return!n.electron||n.requiredDesktopVersion===null||!Op(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===vd?!1:Cg(n.requiredDesktopVersion,n.shellVersion)}const FO=`# Desktop app update required
43
+ `)},Mo=function(t){const r=`${t}-${s(this,sa)}`;return h(this,sa,s(this,sa)+1),r},R0=function(t){for(const r of s(this,Rt).values())if((r==null?void 0:r.kind)==="tool_call"&&r.toolCallId===t)return r;return null},I0=function(){if(!s(this,Mn))throw new Error("ACP session is not ready");return s(this,Mn)},Mh=function(){if(!s(this,Dn))throw new Error("ACP connection is not ready");return s(this,Dn)},Ob=function(){var r;const t=(r=s(this,cn))==null?void 0:r.sessionCwd;if(!t)throw new Error("ACP bridge session cwd is not ready");return t},Oh=function(){var r;if(s(this,Nn)==="single_session")return u(this,R,P0).call(this,`${Eb}-${(s(this,hn).clientGUID??"default-client").toLowerCase()}`);const t=(r=s(this,tt))==null?void 0:r.channelID;if(!t)throw new Error("Channel context is required for per-channel session mode");return u(this,R,x0).call(this,t)},x0=function(t){return u(this,R,P0).call(this,eO(s(this,Nn),t,s(this,hn).clientGUID??"default-client"))},P0=function(t){var r;return((r=s(this,cn))==null?void 0:r.sessionIdStrategy)==="deterministic"&&s(this,ia)>0?`${t}:epoch-${s(this,ia)}`:t},xc=new WeakMap,Pc=new WeakMap,Nh=function(){h(this,Dn,null),h(this,ci,null),h(this,ln,null),h(this,br,null),h(this,Mn,null),h(this,un,null),h(this,cn,null),s(this,zn)&&(s(this,zn).removeEventListener("close",s(this,xc)),s(this,zn).removeEventListener("error",s(this,Pc)),s(this,zn).close(),h(this,zn,null))},Oo=function(t){const r=s(this,Dn)!==null||s(this,ci)!==null||s(this,ln)!==null||s(this,br)!==null||s(this,Mn)!==null||s(this,un)!==null||s(this,cn)!==null||s(this,zn)!==null;this.disposed||this.status==="disconnected"&&!r||(u(this,R,rs).call(this,"error"),u(this,R,Nh).call(this),h(this,Ln,t??null),u(this,R,dr).call(this,"disconnected"))},L0=function(){const t=s(this,Rt).size>0;h(this,On,null),h(this,_r,null),h(this,sa,1),s(this,Rt).clear(),t&&this.dispatchEvent(new Uf("messages-changed"))},Nb=function(){return this.status==="disconnected"};function XM(){const n=new Map;return{getActualSessionId(e){return n.get(e)??null},setActualSessionId(e,t){n.set(e,t)},clearActualSessionId(e){n.delete(e)}}}function QM(n){return n==null?!0:typeof n=="object"&&Object.keys(n).length===0}function eO(n,e,t){return n==="single_session"?`${Eb}-${t.toLowerCase()}`:`agent:main:television-${t.toLowerCase()}-${e.toLowerCase()}`}function zb(n){return n.replace(/^(?:\s*\n)+/,"")}function Dy(n){let e=n;return e=e.replace(VM,""),e=e.replace(FM,""),e=e.replace(BM,""),e=zb(e),e}function tO(n){let e=n;return e=e.replace(jM,""),e=zb(e),e}function My(n){return!n||n.length===0?"":n.flatMap(e=>e.type==="content"&&e.content.type==="text"?[e.content.text]:[]).join("")}async function nO(n){const e=n.createSocket(aO(n.serverURL,n.token));let t=!1,r,i;const o=new Promise((d,f)=>{r=d,i=f}),a=new ReadableStream({start(d){let f=!1;const g=()=>{e.send(JSON.stringify({type:"acp-bridge-connect"}))},y=E=>{const x=oO(E);if(!x)return;let B;try{B=JSON.parse(x)}catch(P){const J=P instanceof Error?P:new Error(String(P));i(J),d.error(J);return}switch(B.type){case"acp-bridge-status":if(B.status==="ready"){let P;try{P=rO(B)}catch(J){const O=J instanceof Error?J:new Error(String(J));t||i(O),d.error(O);return}t||(t=!0,r(P));return}if(B.status==="error"||B.status==="exited"){const P=new Error(B.error??`ACP bridge ${B.status}`);t||i(P),d.error(P)}return;case"acp-bridge-message":d.enqueue(B.message);return}},v=()=>{var x;if(f)return;f=!0;const E=new Error("ACP bridge websocket closed");t||i(E),(x=n.onDisconnect)==null||x.call(n,E),d.close()},_=()=>{var x;if(f)return;f=!0;const E=new Error("ACP bridge websocket error");t||i(E),(x=n.onDisconnect)==null||x.call(n,E),d.error(E)};e.addEventListener("open",g),e.addEventListener("message",y),e.addEventListener("close",v),e.addEventListener("error",_)}}),l=new WritableStream({async write(d){await o,e.send(JSON.stringify({type:"acp-bridge-message",message:d}))},close(){e.close()},abort(){e.close()}}),c=await o;return{stream:{readable:a,writable:l},socket:e,metadata:c}}function rO(n){const{agent:e,sessionIdStrategy:t,sessionCwd:r,tvArgs:i}=n;if((e==="openclaw"||e==="hermes")&&(t==="deterministic"||t==="mapped")&&typeof r=="string"&&r.length>0&&iO(i))return{agent:e,sessionIdStrategy:t,sessionCwd:r,tvArgs:i};throw new Error("ACP bridge ready status missing bootstrap metadata")}function iO(n){return Array.isArray(n)&&n.every(e=>typeof e=="string")}function sO(n){return WM.test(n)?n:`'${n.replace(/'/g,"'\\''")}'`}function oO(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 e=n.data;if(typeof e=="string")return e;if(e instanceof Uint8Array)return new TextDecoder().decode(e);if(Array.isArray(e))return Buffer.concat(e).toString("utf8")}return null}function aO(n,e){const t=new URL(n);return t.protocol=t.protocol==="https:"?"wss:":"ws:",t.pathname="/acp",t.search="",t.searchParams.set("token",e),t.hash="",t.toString()}function qf(n){return n instanceof Error?n.message:String(n)}const Oy="television.acpClientGUID",Ny="television.acpMappedSessions",zy=1;var aa;class lO{constructor(){p(this,aa,new Map)}getActualSessionId(e){return s(this,aa).get(e)??null}setActualSessionId(e,t){s(this,aa).set(e,t)}clearActualSessionId(e){s(this,aa).delete(e)}}aa=new WeakMap;var la,Lc,Mt,zh,Zh,D0;class cO{constructor(e,t){p(this,Mt);p(this,la);p(this,Lc);h(this,la,e),h(this,Lc,t)}getActualSessionId(e){const t=u(this,Mt,Zh).call(this)[u(this,Mt,zh).call(this,e)];return typeof t=="string"&&t.length>0?t:null}setActualSessionId(e,t){const r=u(this,Mt,Zh).call(this);r[u(this,Mt,zh).call(this,e)]=t,u(this,Mt,D0).call(this,r)}clearActualSessionId(e){const t=u(this,Mt,Zh).call(this);delete t[u(this,Mt,zh).call(this,e)],u(this,Mt,D0).call(this,t)}}la=new WeakMap,Lc=new WeakMap,Mt=new WeakSet,zh=function(e){return JSON.stringify([s(this,Lc),e])},Zh=function(){const e=s(this,la).getItem(Ny);if(!e)return{};let t;try{t=JSON.parse(e)}catch{return{}}if(typeof t!="object"||t===null||Array.isArray(t))return{};const r=t;return r.version!==zy?{}:typeof r.entries!="object"||r.entries===null||Array.isArray(r.entries)?{}:Object.fromEntries(Object.entries(r.entries).filter(i=>typeof i[1]=="string"))},D0=function(e){const t={version:zy,entries:e};s(this,la).setItem(Ny,JSON.stringify(t))};function Zb(){return typeof window>"u"?null:window.localStorage}function uO(n){const e=n.getItem(Oy);if(e)return e;const t=Tg().toLowerCase();return n.setItem(Oy,t),t}const Zy=4401,hO=401,fh=1e3,dO=3e4;class Hh extends Error{constructor(e="Authentication required"){super(e),this.name="AuthError"}}class pO extends Kr{constructor(t){var a,l;super();C(this,"url");C(this,"name");C(this,"telemetryMeta");C(this,"status","unauthorized");C(this,"channels",new Map);C(this,"client");C(this,"acpClient");C(this,"_token");C(this,"attempting",!1);C(this,"nextRetryAt",null);C(this,"hasEverConnected",!1);C(this,"browserDemoMode",!1);C(this,"hasAuthRejected",!1);C(this,"hasAuthTokenRejected",!1);C(this,"bootState","pending");C(this,"serverVersion",null);C(this,"updateState",null);C(this,"decideBoot");C(this,"navigationPending");C(this,"createSocket");C(this,"createClient");C(this,"socket",null);C(this,"connectAttempt",0);C(this,"autoReconnect",!1);C(this,"retryTimer",null);C(this,"retryDelay",fh);C(this,"visibilityEventTarget");C(this,"networkEventTarget");C(this,"onVisibilityChange");C(this,"onNetworkOnline");C(this,"telemetryActivityAgent");this.url=Fi(t.url),this.name=t.name,this.decideBoot=t.decideBoot??null,this.navigationPending=t.navigationPending??(()=>!1),this._token=t.token??null,this.telemetryMeta=t.telemetryMeta??null,this.createSocket=t.createSocket??(c=>new WebSocket(c)),this.createClient=t.createClient??((c,d,f)=>new PT(c,{token:d??void 0,onUnauthorized:()=>this.handleAuthRejected(),...f?{telemetryMeta:f}:{}})),this.client=this.createClient(this.url,this._token,this.telemetryMeta);const r=t.mappedSessionStore??(t.acpStorage?new cO(t.acpStorage,this.url):new lO);this.acpClient=new KM({serverURL:this.url,token:this._token??"",...t.createACPSocket?{createSocket:t.createACPSocket}:t.createSocket?{createSocket:t.createSocket}:{},...t.clientGUID?{clientGUID:t.clientGUID}:{},mappedSessionStore:r}),this.visibilityEventTarget=t.visibilityEventTarget!==void 0?t.visibilityEventTarget:typeof document<"u"?document:null,this.networkEventTarget=t.networkEventTarget!==void 0?t.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=t.telemetryDocumentTarget!==void 0?t.telemetryDocumentTarget:typeof document<"u"?document:null,o=t.telemetryWindowTarget!==void 0?t.telemetryWindowTarget:typeof window<"u"?window:null;this.telemetryActivityAgent=this.telemetryMeta&&i&&o?wP({meta:this.telemetryMeta,documentTarget:i,windowTarget:o,send:c=>this.sendTelemetryActivity(c)}):null}get token(){return this._token}clearToken(){this._token=null,this.acpClient.setToken(null),this.client=this.createClient(this.url,null,this.telemetryMeta)}async connect(t){this._token=t,this.hasAuthRejected=!1,this.hasAuthTokenRejected=!1,this.acpClient.setToken(t),this.cancelRetryTimer(),this.retryDelay=fh,this.autoReconnect=!0,await this.attempt()}dispose(){var t,r,i,o;this.autoReconnect=!1,this.connectAttempt+=1,this.cancelRetryTimer(),(t=this.socket)==null||t.close(),this.socket=null,this.setStatus("unauthorized"),(r=this.visibilityEventTarget)==null||r.removeEventListener("visibilitychange",this.onVisibilityChange),(i=this.networkEventTarget)==null||i.removeEventListener("online",this.onNetworkOnline),(o=this.telemetryActivityAgent)==null||o.stop(),this.acpClient.dispose()}getViewURL(t){const r=Ad(t,this.renderOptions());return Br()?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:Br(),browserDemo:this.browserDemoMode}}getContentURL(t){const r=Ad(t,this.renderOptions()).contentURL;return r===null?null:new URL(r,this.url).toString()}async createChannel(t){const{channel:r}=await this.client.channels.create({name:t});return this.channels.set(r.id,structuredClone(r)),r}applyServerEvent(t){switch(t.type){case"channel-created":this.channels.set(t.channel.id,structuredClone(t.channel)),this.dispatchEvent(new Ul("channels-changed"));break;case"channel-updated":this.channels.set(t.channel.id,structuredClone(t.channel)),this.dispatchEvent(new Ul("channels-changed"));break;case"channel-removed":this.channels.delete(t.channelID),this.dispatchEvent(new Ul("channels-changed"));break;case"artifact-created":{const r=this.channels.get(t.channelID);r&&!mT(r).includes(t.artifact.id)&&(r.layout=[...r.layout,{artifactIds:[t.artifact.id],geometry:{...V2},size:{...F2}}]);break}case"artifact-removed":{const r=this.channels.get(t.channelID);r&&(r.layout=m0(r.layout,t.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 fO(t,"server event")}}async attempt(){var i;this.attempting=!0,this.nextRetryAt=null,this.connectAttempt+=1,this.bootState="pending";const t=this.connectAttempt;(i=this.socket)==null||i.close(),this.client=this.createClient(this.url,this._token,this.telemetryMeta),this.setStatus("disconnected"),this.dispatchEvent(new At("change"));const r=this.createSocket(mO(this.url,this._token,this.telemetryMeta));return this.socket=r,await new Promise((o,a)=>{let l=!1;const c=()=>{var g;l||this.connectAttempt!==t||(l=!0,this.retryDelay=fh,this.hasEverConnected=!0,this.setStatus("connected"),(g=this.telemetryActivityAgent)==null||g.start(),o())},d=g=>{l||this.connectAttempt!==t||(l=!0,a(g))},f=async()=>{const g=this.hasEverConnected;try{const[{channels:y},v,_]=await Promise.all([this.client.channels.list(),this.client.display.get(),g?null:this.readDemoMode()]);g||(this.browserDemoMode=(_==null?void 0:_.browserExternalPages)===!0),this.channels=new Map(y.map(E=>[E.id,structuredClone(E)])),this.acpClient.setEnabled(v.acpEnabled),this.dispatchEvent(new At("change")),g&&this.dispatchEvent(new Ul("channels-changed")),this.dispatchEvent(new Ph("server-event",{serverURL:this.url,event:{type:"channel-changed",channelID:v.focusedChannelId}})),this.dispatchEvent(new Ph("server-event",{serverURL:this.url,event:{type:"pinned-channels-changed",pinnedChannelIds:[...v.pinnedChannelIds]}})),c(),g&&this.connectAttempt===t&&this.dispatchEvent(new e8("server-reconnected",{serverURL:this.url}))}catch(y){if(SO(y)){d(new Hh);return}d(y instanceof Error?y:new Error(String(y)))}};r.addEventListener("open",()=>{this.decideBoot===null&&(this.bootState="booted",this.navigationPending()||f())}),r.addEventListener("message",g=>{const y=bO(g);if(!y)return;if(y.type==="server-status"){const _=y;this.serverVersion=_.version,this.updateState=_.update??null;let E=!1;this.decideBoot!==null&&this.bootState==="pending"&&this.connectAttempt===t&&(this.decideBoot(_)==="boot"?(this.bootState="booted",E=!0):(this.bootState="halted",this.attempting=!1)),this.dispatchEvent(new t8("server-status",{serverURL:this.url,message:_})),E?this.navigationPending()||f():this.bootState==="halted"&&!this.navigationPending()&&this.dispatchEvent(new At("change"));return}if(!wO(y.type))return;const v=y;this.applyServerEvent(v),this.dispatchEvent(new Ph("server-event",{serverURL:this.url,event:v}))}),r.addEventListener("close",g=>{if(this.connectAttempt!==t)return;this.socket=null;const y=gO(g);if(!l){d(y===Zy?new Hh:new Error("Connection closed before initialization"));return}if(y===Zy){this.handleAuthRejected();return}this.handleTransportFailure(new Error("Connection closed"))}),r.addEventListener("error",()=>{if(this.connectAttempt===t){if(l){this.handleTransportFailure(new Error("WebSocket error"));return}d(new Error("WebSocket connection failed"))}})}).then(()=>{this.attempting=!1},o=>{throw this.attempting=!1,this.handleAttemptFailure(o),o})}handleAuthRejected(){this.hasAuthRejected=!0,this.hasAuthTokenRejected=this._token!==null,this.autoReconnect=!1,this.cancelRetryTimer(),this.setStatus("unauthorized")}handleAttemptFailure(t){if(t instanceof Hh){this.handleAuthRejected();return}this.autoReconnect&&this.scheduleRetry()}handleTransportFailure(t){this.autoReconnect&&(this.setStatus("disconnected"),this.scheduleRetry())}scheduleRetry(){this.cancelRetryTimer(),this.connectAttempt+=1;const t=this.retryDelay;this.retryDelay=Math.min(this.retryDelay*2,dO),this.nextRetryAt=Date.now()+t,this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.attempt().catch(()=>{})},t),this.dispatchEvent(new At("change"))}cancelRetryTimer(){this.retryTimer!==null&&(clearTimeout(this.retryTimer),this.retryTimer=null),this.nextRetryAt!==null&&(this.nextRetryAt=null,this.dispatchEvent(new At("change")))}kickReconnect(){this.autoReconnect&&this.status!=="connected"&&(this.attempting||(this.cancelRetryTimer(),this.retryDelay=fh,this.attempt().catch(()=>{})))}sendTelemetryActivity(t){var r;this.status==="connected"&&((r=this.socket)==null||r.send(JSON.stringify(t)))}sendTelemetrySignal(t,r){var o;if(!this.telemetryMeta||this.status!=="connected"&&this.bootState!=="halted")return;const i={type:fT,clientId:this.telemetryMeta.clientId,event:t,properties:r};(o=this.socket)==null||o.send(JSON.stringify(i))}setStatus(t){this.status!==t&&(this.status=t,this.dispatchEvent(new At("change")))}isPageVisible(){return this.visibilityEventTarget===null?!0:this.visibilityEventTarget.visibilityState==="visible"}}function fO(n,e){throw new Error(`Unexpected ${e}: ${JSON.stringify(n)}`)}function mO(n,e,t=null){const r=new URL(n);if(r.protocol=r.protocol==="https:"?"wss:":"ws:",r.pathname="/events",r.search="",e&&r.searchParams.set("token",e),t)for(const[i,o]of yP(t))r.searchParams.set(i,o);return r.hash="",r.toString()}function gO(n){return typeof n=="object"&&n!==null&&"code"in n&&typeof n.code=="number"?n.code:null}const vO={"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},yO=new Set(Object.keys(vO));function wO(n){return yO.has(n)}function bO(n){const e=typeof n=="string"?n:typeof n=="object"&&n!==null&&"data"in n&&typeof n.data=="string"?n.data:"";if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return typeof t!="object"||t===null||!("type"in t)||typeof t.type!="string"?null:t}function SO(n){return n instanceof pl&&n.status===hO}const _O="Local";var Vt,dn,rr,M0,O0,Hb,Dc,Mc,Oc,Nc,zc;class AO extends Kr{constructor(t){super();p(this,rr);C(this,"connection");C(this,"clientGUID");C(this,"acpStorage");C(this,"connectError",null);p(this,Vt);p(this,dn,!1);p(this,Dc,()=>{s(this,dn)||(u(this,rr,Hb).call(this),this.dispatchEvent(new At("change")))});p(this,Mc,t=>{s(this,dn)||this.dispatchEvent(new Ph("server-event",{serverURL:t.serverURL,event:t.event}))});p(this,Oc,()=>{s(this,dn)||this.dispatchEvent(new Ul("channels-changed"))});p(this,Nc,t=>{s(this,dn)||this.dispatchEvent(new e8("server-reconnected",{serverURL:t.serverURL}))});p(this,zc,t=>{s(this,dn)||this.dispatchEvent(new t8("server-status",{serverURL:t.serverURL,message:t.message}))});h(this,Vt,t.localStore),this.acpStorage=t.acpStorage===void 0?Zb():t.acpStorage,this.clientGUID=t.clientGUID??(this.acpStorage?uO(this.acpStorage):Tg().toLowerCase());const r=Fi(t.serverURL);t.launchToken!==void 0&&t.launchToken!==null&&s(this,Vt).set(oy(s(this,Vt).get(),r,t.launchToken));const i=t.launchToken??sy(s(this,Vt).get(),r),o=t.createSocket??(l=>new WebSocket(l)),a=t.createConnection??(l=>new pO(l));this.connection=a({url:r,name:t.connectionName??_O,token:i,createSocket:o,clientGUID:this.clientGUID,acpStorage:this.acpStorage,telemetryMeta:t.telemetryMeta??null,decideBoot:t.decideBoot,navigationPending:t.navigationPending}),this.connection.addEventListener("change",s(this,Dc)),this.connection.addEventListener("server-event",s(this,Mc)),this.connection.addEventListener("channels-changed",s(this,Oc)),this.connection.addEventListener("server-reconnected",s(this,Nc)),this.connection.addEventListener("server-status",s(this,zc))}get storedAuthToken(){return sy(s(this,Vt).get(),this.connection.url)}async connect(){await u(this,rr,M0).call(this,this.connection.token)}async authenticate(t){s(this,Vt).set(oy(s(this,Vt).get(),this.connection.url,t)),await u(this,rr,M0).call(this,t)}dispose(){s(this,dn)||(h(this,dn,!0),this.connection.removeEventListener("change",s(this,Dc)),this.connection.removeEventListener("server-event",s(this,Mc)),this.connection.removeEventListener("channels-changed",s(this,Oc)),this.connection.removeEventListener("server-reconnected",s(this,Nc)),this.connection.removeEventListener("server-status",s(this,zc)),this.connection.dispose())}}Vt=new WeakMap,dn=new WeakMap,rr=new WeakSet,M0=async function(t){if(!s(this,dn)){u(this,rr,O0).call(this,null);try{await this.connection.connect(t)}catch(r){u(this,rr,O0).call(this,r instanceof Hh?null:r instanceof Error?r.message:String(r))}}},O0=function(t){this.connectError!==t&&(this.connectError=t,this.dispatchEvent(new At("change")))},Hb=function(){if(this.connection.status!=="unauthorized"||!this.connection.hasAuthRejected)return;const t=s(this,Vt).get(),r=c$(t,this.connection.url);r!==t&&s(this,Vt).set(r),this.connection.token!==null&&this.connection.clearToken()},Dc=new WeakMap,Mc=new WeakMap,Oc=new WeakMap,Nc=new WeakMap,zc=new WeakMap;const N0="tv-nav:",nl="tv-reload",Hy=100,EO=1e3,kO=60,CO=60,TO=24,$O=30,RO=$O*TO*CO*kO*EO;function qr(n){try{const e=new URL(n,window.location.href),t=e.searchParams.has(nl);return e.searchParams.delete(nl),e.origin===window.location.origin?`${e.pathname}${e.search}${e.hash}`:t?e.toString():n}catch{return n}}var Zc,ca,ge,pe,As,Pe,Ub,Qr,Vb,z0,Z0;class IO extends Kr{constructor(t,r){super();p(this,Pe);p(this,Zc);p(this,ca);p(this,ge,[]);p(this,pe,-1);p(this,As,0);h(this,Zc,t),h(this,ca,qr(r)),u(this,Pe,Ub).call(this)}get currentURL(){var t;return s(this,pe)===-1?null:((t=s(this,ge)[s(this,pe)])==null?void 0:t.url)??null}get canGoBack(){return s(this,pe)>-1}get canGoForward(){return s(this,pe)<s(this,ge).length-1}get entries(){return s(this,ge).map(t=>({...t}))}get cursor(){return s(this,pe)}navigate(t){const r=qr(t);if(r===s(this,ca)){if(s(this,pe)===-1)return;h(this,pe,-1),u(this,Pe,Qr).call(this);return}s(this,pe)<s(this,ge).length-1&&h(this,ge,s(this,ge).slice(0,s(this,pe)+1)),s(this,ge).push({url:r}),h(this,pe,s(this,ge).length-1),u(this,Pe,z0).call(this),u(this,Pe,Qr).call(this)}replace(t){var i;if(s(this,pe)===-1){this.navigate(t);return}const r=qr(t);if(r===s(this,ca)){h(this,ge,s(this,ge).filter((o,a)=>a!==s(this,pe))),h(this,pe,-1),u(this,Pe,Qr).call(this);return}((i=s(this,ge)[s(this,pe)])==null?void 0:i.url)!==r&&(h(this,ge,s(this,ge).map((o,a)=>a===s(this,pe)?{url:r}:o)),u(this,Pe,Qr).call(this))}back(){s(this,pe)!==-1&&(h(this,pe,s(this,pe)-1),u(this,Pe,Qr).call(this))}forward(){this.canGoForward&&(h(this,pe,s(this,pe)+1),u(this,Pe,Qr).call(this))}reset(){s(this,pe)===-1&&s(this,ge).length===0||(h(this,ge,[]),h(this,pe,-1),u(this,Pe,Qr).call(this))}}Zc=new WeakMap,ca=new WeakMap,ge=new WeakMap,pe=new WeakMap,As=new WeakMap,Pe=new WeakSet,Ub=function(){const t=localStorage.getItem(s(this,Pe,Z0));if(t!==null)try{const r=JSON.parse(t);if(!Fb(r))return;h(this,ge,r.entries.map(i=>({url:i.url}))),h(this,pe,r.cursor),h(this,As,r.lastWritten),u(this,Pe,z0).call(this)}catch{h(this,ge,[]),h(this,pe,-1),h(this,As,0)}},Qr=function(){h(this,As,Date.now());try{localStorage.setItem(s(this,Pe,Z0),JSON.stringify(u(this,Pe,Vb).call(this)))}catch(t){if(!LO(t))throw t}this.dispatchEvent(new At("change"))},Vb=function(){return{v:1,entries:s(this,ge).map(t=>({...t})),cursor:s(this,pe),lastWritten:s(this,As)}},z0=function(){if(s(this,ge).length<=Hy)return;const t=s(this,ge).length-Hy;h(this,ge,s(this,ge).slice(t)),h(this,pe,Math.max(-1,s(this,pe)-t))},Z0=function(){return xO(s(this,Zc))};function xO(n){return`${N0}${n}`}function PO(n){const e=Date.now()-RO,t=[];for(let r=0;r<localStorage.length;r+=1){const i=localStorage.key(r);if(!(i!=null&&i.startsWith(N0)))continue;const o=i.slice(N0.length),a=localStorage.getItem(i);if(a===null)continue;let l;try{l=JSON.parse(a)}catch{t.push(i);continue}if(!Fb(l)){t.push(i);continue}!n.has(o)&&l.lastWritten<e&&t.push(i)}for(const r of t)localStorage.removeItem(r)}function LO(n){return n instanceof DOMException&&n.name==="QuotaExceededError"}function Fb(n){if(typeof n!="object"||n===null)return!1;const e=n;if(e.v!==1||!Array.isArray(e.entries))return!1;const t=e.cursor;return typeof t!="number"||!Number.isInteger(t)||typeof e.lastWritten!="number"||!Number.isFinite(e.lastWritten)||t<-1||t>=e.entries.length?!1:e.entries.every(r=>typeof r=="object"&&r!==null&&typeof r.url=="string")}const Wf="tv-channel-sidebar-collapsed";var Es;class DO{constructor(e){p(this,Es);h(this,Es,e)}read(){return s(this,Es).getItem(Wf)==="true"}setCollapsed(e){try{e?s(this,Es).setItem(Wf,"true"):s(this,Es).removeItem(Wf)}catch{}}}Es=new WeakMap;const jf="tv-channel-sidebar-width",H0=160,U0=350,mh=260,MO=/^-?\d+$/;var ks;class OO{constructor(e){p(this,ks);h(this,ks,e)}read(){const e=s(this,ks).getItem(jf);if(e===null||!MO.test(e))return null;const t=BigInt(e);return t<BigInt(H0)?H0:t>BigInt(U0)?U0:Number(t)}commit(e){const t=Bb(Math.round(e));try{s(this,ks).setItem(jf,String(t))}catch{}return t}clear(){try{s(this,ks).removeItem(jf)}catch{}}}ks=new WeakMap;function Bb(n){return Math.min(Math.max(n,H0),U0)}const NO="1.4.9";function Ng(n=NO){return n!==void 0&&n.length>0?n:"0.0.0"}function zg(){let n=!1;return{get pending(){return n},begin(e){n||(n=!0,e())}}}const V0="tv-reload-attempted";function zO(n){return n.originMatch?n.marker!==null&&n.bundleVersion===n.serverVersion?{action:"signal-autoreloaded",fromVersion:n.marker.fromVersion,toVersion:n.bundleVersion}:MT(n.bundleVersion,n.serverVersion)?n.marker!==null&&n.marker.serverVersion===n.serverVersion?{action:"none"}:{action:"reload",marker:{serverVersion:n.serverVersion,fromVersion:n.bundleVersion}}:{action:"none"}:{action:"none"}}function ZO(n){const e=n.getItem(V0);if(e===null)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const r=t;return typeof r.serverVersion!="string"||typeof r.fromVersion!="string"?null:{serverVersion:r.serverVersion,fromVersion:r.fromVersion}}function HO(n){const e=n.storage!==void 0?n.storage:typeof sessionStorage<"u"?sessionStorage:null,t=n.reload??(()=>location.reload()),r=n.navigationLatch??zg(),i=n.bundleVersion??Ng();if(e===null)return{dispose(){}};let o=null;const a=()=>{if(o===null)return;const d=n.owner.connection;if(d.url!==n.primaryServerURL||d.status!=="connected")return;const f=o;o=null,d.sendTelemetrySignal("client_autoreloaded",{from_version:f.fromVersion,to_version:f.toVersion})},l=d=>{if(r.pending)return;const f=zO({bundleVersion:i,serverVersion:d.message.version,originMatch:d.serverURL===n.primaryServerURL,marker:ZO(e)});switch(f.action){case"reload":e.setItem(V0,JSON.stringify(f.marker)),r.begin(t);return;case"signal-autoreloaded":e.removeItem(V0),o={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 UO(n){const e=Br(n.search),t=U8(n.search),r=t!==null&&Op(t)?t:null;return{electron:e,shellVersion:r}}function VO(n){return!n.electron||n.requiredDesktopVersion===null||!Op(n.requiredDesktopVersion)?!1:n.shellVersion===null?!0:n.shellVersion===vd?!1:Cg(n.requiredDesktopVersion,n.shellVersion)}const FO=`# Desktop app update required
44
44
 
45
45
  This version of the Television desktop app does not work with this server and needs to be updated. The new version has already downloaded and installs when you restart the app.`,BO=`# Desktop app update required
46
46
 
@@ -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-STJy4m8t.js"></script>
43
+ <script type="module" crossorigin src="./assets/main-BrG-Z2HH.js"></script>
44
44
  <link rel="modulepreload" crossorigin href="./assets/artifact-bridge-BEUWXKq7.js">
45
45
  <link rel="modulepreload" crossorigin href="./assets/missing-artifact-page-DVzJ41AE.js">
46
46
  <link rel="stylesheet" crossorigin href="./assets/main-Cyghm6HD.css">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telepath-computer/television",
3
- "version": "1.4.8",
3
+ "version": "1.4.9",
4
4
  "license": "MIT",
5
5
  "engines": {
6
6
  "node": ">=22.12.0"