typebulb 0.61.10 → 0.61.12

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/index.js CHANGED
@@ -1,172 +1,172 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
3
- var hk=Object.create;var Ol=Object.defineProperty;var mk=Object.getOwnPropertyDescriptor;var gk=Object.getOwnPropertyNames;var yk=Object.getPrototypeOf,bk=Object.prototype.hasOwnProperty;var vi=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var S=(t,e)=>()=>(t&&(e=t(t=0)),e);var _=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Si=(t,e)=>{for(var n in e)Ol(t,n,{get:e[n],enumerable:!0})},wk=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of gk(e))!bk.call(t,s)&&s!==n&&Ol(t,s,{get:()=>e[s],enumerable:!(r=mk(e,s))||r.enumerable});return t};var vk=(t,e,n)=>(n=t!=null?hk(yk(t)):{},wk(e||!t||!t.__esModule?Ol(n,"default",{value:t,enumerable:!0}):n,t));import*as hp from"fs/promises";import{existsSync as Ln,readFileSync as Sk}from"fs";import*as se from"path";import{pathToFileURL as kk}from"url";import{resolve as Cl}from"resolve.exports";import{init as mp,parse as gp}from"es-module-lexer";function yp(t,e){let n=se.join(t,"package.json");try{return JSON.parse(Sk(n,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${n}`)}}function bp(t){let e=t.indexOf("=");if(e===-1)throw new Error(`--replace must be <name>=<path> (got '${t}')`);let n=t.slice(0,e).trim(),r=t.slice(e+1).trim();if(!n)throw new Error(`--replace missing package name (got '${t}')`);if(!r)throw new Error(`--replace missing path for '${n}'`);if(n.startsWith("@"))throw new Error(`--replace does not support scoped names yet; '${n}' is scoped`);return{name:n,dir:se.resolve(r)}}async function wp(t){let{name:e,dir:n}=t;if(!Ln(n))throw new Error(`--replace path for '${e}' does not exist: ${n}`);let r=yp(n,e),s=xk(r,e),i=se.resolve(n,s);if(!Ln(i))throw new Error(`--replace package '${e}' entry not found on disk: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);let o=se.dirname(i),a=`/local/${e}/${se.basename(i)}`,l=Ek(r,n);return await Ak(e,i,o),{name:e,dir:n,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:l}}function xk(t,e){if(t.exports!==void 0){let r;try{r=Cl(t,".",{browser:!0,conditions:Pl})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${Pl.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=_l(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${Pl.join(", ")}); too complex to override.`);return s}let n=t.module??t.main;if(!n)throw new Error(`--replace package '${e}' has no "exports", "module", or "main" entry to resolve.`);return n}function Ek(t,e){if(t.exports!==void 0)try{let r=Cl(t,".",{conditions:["types"]}),s=_l(r);if(s){let i=se.resolve(e,s);if(Ln(i))return i}}catch{}let n=t.types??t.typings;if(n){let r=se.resolve(e,n);if(Ln(r))return r}}function _l(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.find(e=>typeof e=="string")}async function Ak(t,e,n){await mp;let r=se.normalize(n),s=new Set,i=[e];for(;i.length;){let o=i.shift();if(s.has(o))continue;s.add(o);let a;try{a=await hp.readFile(o,"utf8")}catch{continue}let l,c;try{[l,,,c]=gp(a,o)}catch{continue}if(o===e&&!c)throw new Error(`override package '${t}' entry is not an ES module (no import/export syntax); CommonJS or non-module entries aren't supported (esm.sh would have to transform it).`);for(let f of l){if(f.d===-2)continue;let d=f.n;if(d&&!d.startsWith("node:")){if(d.startsWith("./")||d.startsWith("../")||d.startsWith("/")){let u=Tk(o,d,r);u&&!s.has(u)&&i.push(u);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${t} externalizes '${d}'`)}}}}function Tk(t,e,n){let r=e.replace(/[?#].*$/,""),s=se.resolve(se.dirname(t),r),i=[s,s+".js",s+".mjs",se.join(s,"index.js"),se.join(s,"index.mjs")];for(let o of i)if(se.normalize(o).startsWith(n)&&Ln(o))return o}function Ok(t,e,n){let r=yp(t,e),s;if(r.exports!==void 0)try{s=_l(Cl(r,n,{conditions:pp}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${n}' (conditions: ${pp.join(", ")}): ${o instanceof Error?o.message:o}`)}else n==="."&&(s=r.main??r.module);if(!s)throw new Error(`--replace package '${e}' has no node export for '${n}'.`);let i=se.resolve(t,s);if(!Ln(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return kk(i).href}async function vp(t,e){await mp;let n;try{[n]=gp(t)}catch{return t}let r="",s=0;for(let i of n){if(i.d!==-1)continue;let o=i.n;if(!o||o!==e.name&&!o.startsWith(e.name+"/"))continue;let a=o===e.name?".":"."+o.slice(e.name.length),l=Ok(e.dir,e.name,a);r+=t.slice(s,i.s)+l,s=i.e}return r+t.slice(s)}var Pl,pp,ki=S(()=>{"use strict";Pl=["browser","import","default"],pp=["node","import","default"]});function Sp(t){return Je.find(e=>le[e].path===t)}function xp(t){return!!t?.startsWith("typebulb")}var le,Je,kp,xi=S(()=>{le={code:{path:"code.tsx",language:"typescript"},css:{path:"styles.css",language:"css"},html:{path:"index.html",language:"html"},config:{path:"config.json",language:"json"},notes:{path:"notes.md",language:"markdown"},data:{path:"data.txt",language:"text"},infer:{path:"infer.md",language:"markdown"},insight:{path:"insight.json",language:"json"}},Je=["code","css","html","data","infer","insight","config","notes"];kp="typebulb/v1"});function Rl(t){return/[:\n"']/.test(t)||t.startsWith(" ")||t.endsWith(" ")?`"${t.replace(/"/g,'\\"')}"`:t}function Il(t){return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\"/g,'"'):t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}var Ei=S(()=>{});function Mn(t){let e=Ap(t);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function We(t){let e=Ap(t);return"bulb"in e?e.bulb:void 0}function Ap(t){try{let e=t.split(`
4
- `),n=0;if(e[n]?.trim()!=="---")return{reason:Ck(t,e)};n++;let r=[];for(;n<e.length&&e[n]?.trim()!=="---";)r.push(e[n]),n++;if(e[n]?.trim()!=="---")return{reason:"the frontmatter opened on line 1 but never closed (no second '---')"};n++;let s=Ik(r);if(!xp(s.format))return{reason:s.format?`frontmatter 'format: ${s.format}' is not a typebulb format (expected 'format: typebulb/v1')`:"frontmatter has no 'format:' (expected 'format: typebulb/v1')"};if(!s.name)return{reason:"frontmatter has no 'name:'"};let i=s,o=new Map,a=new Map,l=[],c=n;for(;n<e.length;){let d=e[n]?.trim()?.match(Ep);if(d){let u=d[1].trim();for(n++;n<e.length&&e[n]?.trim()==="";)n++;let p=e[n]?.match(Ai);if(!p){l.push(`**${u}** has no code fence \u2014 block skipped`);continue}let m=p[1];n++;let h=n+1,g=[],E=Nl(m);for(;n<e.length&&!e[n]?.match(E);)g.push(e[n]),n++;let O=n<e.length;n++,l.push(..._k(u,g,O)),o.set(u,g.join(`
5
- `)),a.set(u,h),c=n}else n++}return{bulb:{frontmatter:i,files:o,warnings:l,bodyEndLine:c,starts:a}}}catch(e){return{reason:`unexpected parse error: ${e instanceof Error?e.message:String(e)}`}}}function Ck(t,e){let n=Nk(t)[0];if(n&&n.start>0)return`expected '---' on line 1; the frontmatter starts on line ${n.start+1} instead. Is there content above it?`;let r=e.find(s=>s.trim())?.trim()??"";return r?`expected '---' on line 1, found '${r.length>40?`${r.slice(0,40)}\u2026`:r}'`:"expected '---' on line 1, found an empty file"}function _k(t,e,n){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(Ep);i&&Pk.has(i[1].trim())&&Rk(e,s)&&r.push(i[1].trim())}return r.length?r.map(s=>`**${t}** block has an unterminated code fence \u2014 it swallowed the **${s}** block.`):n?[]:[`**${t}** block has an unterminated code fence (it runs to the end of the file).`]}function Rk(t,e){let n=e+1;for(;n<t.length&&t[n]?.trim()==="";)n++;return!!t[n]?.match(Ai)}function Ik(t){let e={};for(let n of t){let r=n.indexOf(":");if(r===-1)continue;let s=n.slice(0,r).trim(),i=n.slice(r+1).trim();switch(s){case"format":e.format=i;break;case"name":e.name=Il(i);break}}return e}function Tp(t){return We(t)?.warnings??[]}function Nk(t){let e=t.split(`
3
+ var gk=Object.create;var Ol=Object.defineProperty;var yk=Object.getOwnPropertyDescriptor;var bk=Object.getOwnPropertyNames;var wk=Object.getPrototypeOf,vk=Object.prototype.hasOwnProperty;var vi=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var S=(t,e)=>()=>(t&&(e=t(t=0)),e);var _=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Si=(t,e)=>{for(var n in e)Ol(t,n,{get:e[n],enumerable:!0})},Sk=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of bk(e))!vk.call(t,s)&&s!==n&&Ol(t,s,{get:()=>e[s],enumerable:!(r=yk(e,s))||r.enumerable});return t};var kk=(t,e,n)=>(n=t!=null?gk(wk(t)):{},Sk(e||!t||!t.__esModule?Ol(n,"default",{value:t,enumerable:!0}):n,t));import*as hp from"fs/promises";import{existsSync as Ln,readFileSync as xk}from"fs";import*as ie from"path";import{pathToFileURL as Ek}from"url";import{resolve as Cl}from"resolve.exports";import{init as mp,parse as gp}from"es-module-lexer";function yp(t,e){let n=ie.join(t,"package.json");try{return JSON.parse(xk(n,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${n}`)}}function bp(t){let e=t.indexOf("=");if(e===-1)throw new Error(`--replace must be <name>=<path> (got '${t}')`);let n=t.slice(0,e).trim(),r=t.slice(e+1).trim();if(!n)throw new Error(`--replace missing package name (got '${t}')`);if(!r)throw new Error(`--replace missing path for '${n}'`);if(n.startsWith("@"))throw new Error(`--replace does not support scoped names yet; '${n}' is scoped`);return{name:n,dir:ie.resolve(r)}}async function wp(t){let{name:e,dir:n}=t;if(!Ln(n))throw new Error(`--replace path for '${e}' does not exist: ${n}`);let r=yp(n,e),s=Ak(r,e),i=ie.resolve(n,s);if(!Ln(i))throw new Error(`--replace package '${e}' entry not found on disk: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);let o=ie.dirname(i),a=`/local/${e}/${ie.basename(i)}`,l=Tk(r,n);return await Ok(e,i,o),{name:e,dir:n,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:l}}function Ak(t,e){if(t.exports!==void 0){let r;try{r=Cl(t,".",{browser:!0,conditions:Pl})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${Pl.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=_l(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${Pl.join(", ")}); too complex to override.`);return s}let n=t.module??t.main;if(!n)throw new Error(`--replace package '${e}' has no "exports", "module", or "main" entry to resolve.`);return n}function Tk(t,e){if(t.exports!==void 0)try{let r=Cl(t,".",{conditions:["types"]}),s=_l(r);if(s){let i=ie.resolve(e,s);if(Ln(i))return i}}catch{}let n=t.types??t.typings;if(n){let r=ie.resolve(e,n);if(Ln(r))return r}}function _l(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.find(e=>typeof e=="string")}async function Ok(t,e,n){await mp;let r=ie.normalize(n),s=new Set,i=[e];for(;i.length;){let o=i.shift();if(s.has(o))continue;s.add(o);let a;try{a=await hp.readFile(o,"utf8")}catch{continue}let l,c;try{[l,,,c]=gp(a,o)}catch{continue}if(o===e&&!c)throw new Error(`override package '${t}' entry is not an ES module (no import/export syntax); CommonJS or non-module entries aren't supported (esm.sh would have to transform it).`);for(let f of l){if(f.d===-2)continue;let d=f.n;if(d&&!d.startsWith("node:")){if(d.startsWith("./")||d.startsWith("../")||d.startsWith("/")){let u=Pk(o,d,r);u&&!s.has(u)&&i.push(u);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${t} externalizes '${d}'`)}}}}function Pk(t,e,n){let r=e.replace(/[?#].*$/,""),s=ie.resolve(ie.dirname(t),r),i=[s,s+".js",s+".mjs",ie.join(s,"index.js"),ie.join(s,"index.mjs")];for(let o of i)if(ie.normalize(o).startsWith(n)&&Ln(o))return o}function Ck(t,e,n){let r=yp(t,e),s;if(r.exports!==void 0)try{s=_l(Cl(r,n,{conditions:pp}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${n}' (conditions: ${pp.join(", ")}): ${o instanceof Error?o.message:o}`)}else n==="."&&(s=r.main??r.module);if(!s)throw new Error(`--replace package '${e}' has no node export for '${n}'.`);let i=ie.resolve(t,s);if(!Ln(i))throw new Error(`--replace package '${e}' built file not found: ${i} \u2014 did you build it (e.g. \`pnpm run build\`)?`);return Ek(i).href}async function vp(t,e){await mp;let n;try{[n]=gp(t)}catch{return t}let r="",s=0;for(let i of n){if(i.d!==-1)continue;let o=i.n;if(!o||o!==e.name&&!o.startsWith(e.name+"/"))continue;let a=o===e.name?".":"."+o.slice(e.name.length),l=Ck(e.dir,e.name,a);r+=t.slice(s,i.s)+l,s=i.e}return r+t.slice(s)}var Pl,pp,ki=S(()=>{"use strict";Pl=["browser","import","default"],pp=["node","import","default"]});function Sp(t){return Je.find(e=>ce[e].path===t)}function xp(t){return!!t?.startsWith("typebulb")}var ce,Je,kp,xi=S(()=>{ce={code:{path:"code.tsx",language:"typescript"},css:{path:"styles.css",language:"css"},html:{path:"index.html",language:"html"},config:{path:"config.json",language:"json"},notes:{path:"notes.md",language:"markdown"},data:{path:"data.txt",language:"text"},infer:{path:"infer.md",language:"markdown"},insight:{path:"insight.json",language:"json"}},Je=["code","css","html","data","infer","insight","config","notes"];kp="typebulb/v1"});function Rl(t){return/[:\n"']/.test(t)||t.startsWith(" ")||t.endsWith(" ")?`"${t.replace(/"/g,'\\"')}"`:t}function Il(t){return t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1).replace(/\\"/g,'"'):t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1):t}var Ei=S(()=>{});function Mn(t){let e=Ap(t);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function We(t){let e=Ap(t);return"bulb"in e?e.bulb:void 0}function Ap(t){try{let e=t.split(`
4
+ `),n=0;if(e[n]?.trim()!=="---")return{reason:Rk(t,e)};n++;let r=[];for(;n<e.length&&e[n]?.trim()!=="---";)r.push(e[n]),n++;if(e[n]?.trim()!=="---")return{reason:"the frontmatter opened on line 1 but never closed (no second '---')"};n++;let s=$k(r);if(!xp(s.format))return{reason:s.format?`frontmatter 'format: ${s.format}' is not a typebulb format (expected 'format: typebulb/v1')`:"frontmatter has no 'format:' (expected 'format: typebulb/v1')"};if(!s.name)return{reason:"frontmatter has no 'name:'"};let i=s,o=new Map,a=new Map,l=[],c=n;for(;n<e.length;){let d=e[n]?.trim()?.match(Ep);if(d){let u=d[1].trim();for(n++;n<e.length&&e[n]?.trim()==="";)n++;let p=e[n]?.match(Ai);if(!p){l.push(`**${u}** has no code fence \u2014 block skipped`);continue}let m=p[1];n++;let h=n+1,g=[],x=Nl(m);for(;n<e.length&&!e[n]?.match(x);)g.push(e[n]),n++;let O=n<e.length;n++,l.push(...Ik(u,g,O)),o.set(u,g.join(`
5
+ `)),a.set(u,h),c=n}else n++}return{bulb:{frontmatter:i,files:o,warnings:l,bodyEndLine:c,starts:a}}}catch(e){return{reason:`unexpected parse error: ${e instanceof Error?e.message:String(e)}`}}}function Rk(t,e){let n=Lk(t)[0];if(n&&n.start>0)return`expected '---' on line 1; the frontmatter starts on line ${n.start+1} instead. Is there content above it?`;let r=e.find(s=>s.trim())?.trim()??"";return r?`expected '---' on line 1, found '${r.length>40?`${r.slice(0,40)}\u2026`:r}'`:"expected '---' on line 1, found an empty file"}function Ik(t,e,n){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(Ep);i&&_k.has(i[1].trim())&&Nk(e,s)&&r.push(i[1].trim())}return r.length?r.map(s=>`**${t}** block has an unterminated code fence \u2014 it swallowed the **${s}** block.`):n?[]:[`**${t}** block has an unterminated code fence (it runs to the end of the file).`]}function Nk(t,e){let n=e+1;for(;n<t.length&&t[n]?.trim()==="";)n++;return!!t[n]?.match(Ai)}function $k(t){let e={};for(let n of t){let r=n.indexOf(":");if(r===-1)continue;let s=n.slice(0,r).trim(),i=n.slice(r+1).trim();switch(s){case"format":e.format=i;break;case"name":e.name=Il(i);break}}return e}function Tp(t){return We(t)?.warnings??[]}function Lk(t){let e=t.split(`
6
6
  `),n=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s=We(e.slice(r).join(`
7
7
  `));if(s&&s.files.size>0){let i=r+s.bodyEndLine;n.push({start:r,end:i,source:e.slice(r,i).join(`
8
- `)}),r=i}else r++}return n}function Op(t){let e=Object.fromEntries(Je.map(n=>[n,t.files.get(le[n].path)||""]));return{name:t.frontmatter.name,...e}}var Ep,Ai,Pk,Nl,$l=S(()=>{xi();Ei();Ep=/^\*\*(.+)\*\*$/,Ai=/^(`{3,})(\w*)\s*$/,Pk=new Set(Je.map(t=>le[t].path)),Nl=t=>new RegExp(`^${t}\\s*$`)});function Pp(t){let e=t.match(/^`{3,}/gm),n=e?Math.max(...e.map(r=>r.length)):0;return"`".repeat(Math.max(3,n+1))}function Cp(t,e){let{path:n}=le[t],r=n.split(".").pop(),s=Pp(e);return`**${n}**
8
+ `)}),r=i}else r++}return n}function Op(t){let e=Object.fromEntries(Je.map(n=>[n,t.files.get(ce[n].path)||""]));return{name:t.frontmatter.name,...e}}var Ep,Ai,_k,Nl,$l=S(()=>{xi();Ei();Ep=/^\*\*(.+)\*\*$/,Ai=/^(`{3,})(\w*)\s*$/,_k=new Set(Je.map(t=>ce[t].path)),Nl=t=>new RegExp(`^${t}\\s*$`)});function Pp(t){let e=t.match(/^`{3,}/gm),n=e?Math.max(...e.map(r=>r.length)):0;return"`".repeat(Math.max(3,n+1))}function Cp(t,e){let{path:n}=ce[t],r=n.split(".").pop(),s=Pp(e);return`**${n}**
9
9
 
10
10
  ${s}${r}
11
11
  ${e}
12
12
  ${s}`}function _p(t){let e=Je.filter(n=>t[n]).map(n=>Cp(n,t[n]));return["---",`format: ${kp}`,`name: ${Rl(t.name)}`,"---","",...e].join(`
13
- `)}function Rp(t,e){for(let n=0;n<t.length;n++){if(t[n]?.trim()!==`**${e}**`)continue;let r=n+1;for(;r<t.length&&t[r]?.trim()==="";)r++;let s=t[r]?.match(Ai);if(!s)continue;let i=Nl(s[1]),o=r+1;for(;o<t.length&&!t[o]?.match(i);)o++;return o>=t.length?"unterminated":{header:n,open:r,close:o,fence:s[1],lang:s[2]}}}function Mr(t,e,n){let r=t.split(`
14
- `),s=Rp(r,le[e].path);if(s==="unterminated")return t;if(!s)return`${t.replace(/\s*$/,"")}
13
+ `)}function Rp(t,e){for(let n=0;n<t.length;n++){if(t[n]?.trim()!==`**${e}**`)continue;let r=n+1;for(;r<t.length&&t[r]?.trim()==="";)r++;let s=t[r]?.match(Ai);if(!s)continue;let i=Nl(s[1]),o=r+1;for(;o<t.length&&!t[o]?.match(i);)o++;return o>=t.length?"unterminated":{header:n,open:r,close:o,fence:s[1],lang:s[2]}}}function Dr(t,e,n){let r=t.split(`
14
+ `),s=Rp(r,ce[e].path);if(s==="unterminated")return t;if(!s)return`${t.replace(/\s*$/,"")}
15
15
 
16
16
  ${Cp(e,n)}
17
17
  `;let i=Pp(n),o=i.length>s.fence.length?i:s.fence;return[...r.slice(0,s.open),o+s.lang,...n.split(`
18
18
  `),o,...r.slice(s.close+1)].join(`
19
19
  `)}function Ip(t,e){let n=t.split(`
20
- `),r=Rp(n,le[e].path);if(!r||r==="unterminated")return t;let s=r.close+1;for(;s<n.length&&n[s]?.trim()==="";)s++;return[...n.slice(0,r.header),...n.slice(s)].join(`
20
+ `),r=Rp(n,ce[e].path);if(!r||r==="unterminated")return t;let s=r.close+1;for(;s<n.length&&n[s]?.trim()==="";)s++;return[...n.slice(0,r.header),...n.slice(s)].join(`
21
21
  `).replace(/\s*$/,"")+`
22
- `}var Np=S(()=>{xi();$l();Ei()});function Dr(t){if(!t.trim())return{};try{return JSON.parse(t)}catch{return{}}}function Lp(t){switch($p(t)){case".js":case".mjs":return"text/javascript";case".wasm":return"application/wasm";case".json":case".map":return"application/json";case".svg":return"image/svg+xml";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";case".avif":return"image/avif";case".ico":return"image/x-icon";case".mp3":return"audio/mpeg";case".wav":return"audio/wav";case".ogg":return"audio/ogg";case".m4a":return"audio/mp4";case".mp4":return"video/mp4";case".webm":return"video/webm";case".woff2":return"font/woff2";case".ttf":return"font/ttf";case".css":return"text/css";case".txt":return"text/plain; charset=utf-8";default:return"application/octet-stream"}}function Mp(t){let e=$p(t);return e!==void 0&&Lk.has(e)?e:void 0}function Dk(t){return t.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function Ll(t){let e=Dr(t??"").description?.trim();if(!e)return Mk;let n=Dk(e);return(n.length>200?n.slice(0,197)+"...":n).replace(/\n/g," ")}var $k,Ti,$p,Lk,Mk,Dp=S(()=>{$k="https://assets.typebulb.com",Ti=(t,e)=>`${$k}/u/${encodeURIComponent(t)}/${encodeURIComponent(e)}/`,$p=t=>/\.[^./\\]+$/.exec(t)?.[0]?.toLowerCase();Lk=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);Mk="A Typebulb bulb."});var Bp=S(()=>{});function Ml(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index:-1}var jp=S(()=>{});function Br(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index+s[0].length-1:-1}var Fp=S(()=>{});function Oi(t,e){let n=new RegExp(e,"g"),r=t.match(n);return r?r.length:0}var Up=S(()=>{});function jr(t,e,n){let r=n&&n.debug||!1,s=!(n&&typeof n.nested===!1),i=n&&n.startIndex||0;r&&console.log("[xml-utils] starting findTagByName with",e," and ",n);let o=Ml(t,`<${e}[
23
- >/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=t.slice(o+e.length),l=Br(a,"^[^<]*[ /]>",0),c=l!==-1&&a[l-1]==="/";if(r&&console.log("[xml-utils] selfClosing:",c),c===!1)if(s){let p=0,m=1,h=0;for(;(l=Br(a,"[ /]"+e+">",p))!==-1;){let g=a.substring(p,l+1);if(m+=Oi(g,"<"+e+`[
24
- >]`),h+=Oi(g,"</"+e+">"),h>=m)break;p=l}}else l=Br(a,"[ /]"+e+">",0);let f=o+e.length+l+1;if(r&&console.log("[xml-utils] end:",f),f===-1)return;let d=t.slice(o,f),u;return c?u=null:u=d.slice(d.indexOf(">")+1,d.lastIndexOf("<")),{inner:u,outer:d,start:o,end:f}}var Dl=S(()=>{jp();Fp();Up()});var Bl=S(()=>{Dl()});var jl=S(()=>{Bl()});var qp=S(()=>{jl()});var Jp=S(()=>{});var Wp=S(()=>{Bp();Dl();Bl();qp();jl();Jp()});var J=_(de=>{"use strict";var Fl=Symbol.for("yaml.alias"),Kp=Symbol.for("yaml.document"),Pi=Symbol.for("yaml.map"),Hp=Symbol.for("yaml.pair"),Ul=Symbol.for("yaml.scalar"),Ci=Symbol.for("yaml.seq"),dt=Symbol.for("yaml.node.type"),Fk=t=>!!t&&typeof t=="object"&&t[dt]===Fl,Uk=t=>!!t&&typeof t=="object"&&t[dt]===Kp,qk=t=>!!t&&typeof t=="object"&&t[dt]===Pi,Jk=t=>!!t&&typeof t=="object"&&t[dt]===Hp,zp=t=>!!t&&typeof t=="object"&&t[dt]===Ul,Wk=t=>!!t&&typeof t=="object"&&t[dt]===Ci;function Yp(t){if(t&&typeof t=="object")switch(t[dt]){case Pi:case Ci:return!0}return!1}function Kk(t){if(t&&typeof t=="object")switch(t[dt]){case Fl:case Pi:case Ul:case Ci:return!0}return!1}var Hk=t=>(zp(t)||Yp(t))&&!!t.anchor;de.ALIAS=Fl;de.DOC=Kp;de.MAP=Pi;de.NODE_TYPE=dt;de.PAIR=Hp;de.SCALAR=Ul;de.SEQ=Ci;de.hasAnchor=Hk;de.isAlias=Fk;de.isCollection=Yp;de.isDocument=Uk;de.isMap=qk;de.isNode=Kk;de.isPair=Jk;de.isScalar=zp;de.isSeq=Wk});var Fr=_(ql=>{"use strict";var ie=J(),we=Symbol("break visit"),Vp=Symbol("skip children"),nt=Symbol("remove node");function _i(t,e){let n=Gp(e);ie.isDocument(t)?Dn(null,t.contents,n,Object.freeze([t]))===nt&&(t.contents=null):Dn(null,t,n,Object.freeze([]))}_i.BREAK=we;_i.SKIP=Vp;_i.REMOVE=nt;function Dn(t,e,n,r){let s=Xp(t,e,n,r);if(ie.isNode(s)||ie.isPair(s))return Qp(t,r,s),Dn(t,s,n,r);if(typeof s!="symbol"){if(ie.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=Dn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===we)return we;o===nt&&(e.items.splice(i,1),i-=1)}}}else if(ie.isPair(e)){r=Object.freeze(r.concat(e));let i=Dn("key",e.key,n,r);if(i===we)return we;i===nt&&(e.key=null);let o=Dn("value",e.value,n,r);if(o===we)return we;o===nt&&(e.value=null)}}return s}async function Ri(t,e){let n=Gp(e);ie.isDocument(t)?await Bn(null,t.contents,n,Object.freeze([t]))===nt&&(t.contents=null):await Bn(null,t,n,Object.freeze([]))}Ri.BREAK=we;Ri.SKIP=Vp;Ri.REMOVE=nt;async function Bn(t,e,n,r){let s=await Xp(t,e,n,r);if(ie.isNode(s)||ie.isPair(s))return Qp(t,r,s),Bn(t,s,n,r);if(typeof s!="symbol"){if(ie.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await Bn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===we)return we;o===nt&&(e.items.splice(i,1),i-=1)}}}else if(ie.isPair(e)){r=Object.freeze(r.concat(e));let i=await Bn("key",e.key,n,r);if(i===we)return we;i===nt&&(e.key=null);let o=await Bn("value",e.value,n,r);if(o===we)return we;o===nt&&(e.value=null)}}return s}function Gp(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function Xp(t,e,n,r){if(typeof n=="function")return n(t,e,r);if(ie.isMap(e))return n.Map?.(t,e,r);if(ie.isSeq(e))return n.Seq?.(t,e,r);if(ie.isPair(e))return n.Pair?.(t,e,r);if(ie.isScalar(e))return n.Scalar?.(t,e,r);if(ie.isAlias(e))return n.Alias?.(t,e,r)}function Qp(t,e,n){let r=e[e.length-1];if(ie.isCollection(r))r.items[t]=n;else if(ie.isPair(r))t==="key"?r.key=n:r.value=n;else if(ie.isDocument(r))r.contents=n;else{let s=ie.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}ql.visit=_i;ql.visitAsync=Ri});var Jl=_(eh=>{"use strict";var Zp=J(),zk=Fr(),Yk={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Vk=t=>t.replace(/[!,[\]{}]/g,e=>Yk[e]),Ur=class t{constructor(e,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,n)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,n){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),s=r.shift();switch(s){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[i,o]=r;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[i]=r;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return n(6,`Unsupported YAML version ${i}`,o),!1}}default:return n(0,`Unknown directive ${s}`,!0),!1}}tagName(e,n){if(e==="!")return"!";if(e[0]!=="!")return n(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}let[,r,s]=e.match(/^(.*!)([^!]*)$/s);s||n(`The ${e} tag has no suffix`);let i=this.tags[r];if(i)try{return i+decodeURIComponent(s)}catch(o){return n(String(o)),null}return r==="!"?e:(n(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[n,r]of Object.entries(this.tags))if(e.startsWith(r))return n+Vk(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),s;if(e&&r.length>0&&Zp.isNode(e.contents)){let i={};zk.visit(e.contents,(o,a)=>{Zp.isNode(a)&&a.tag&&(i[a.tag]=!0)}),s=Object.keys(i)}else s=[];for(let[i,o]of r)i==="!!"&&o==="tag:yaml.org,2002:"||(!e||s.some(a=>a.startsWith(o)))&&n.push(`%TAG ${i} ${o}`);return n.join(`
25
- `)}};Ur.defaultYaml={explicit:!1,version:"1.2"};Ur.defaultTags={"!!":"tag:yaml.org,2002:"};eh.Directives=Ur});var Ii=_(qr=>{"use strict";var th=J(),Gk=Fr();function Xk(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function nh(t){let e=new Set;return Gk.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function rh(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function Qk(t,e){let n=[],r=new Map,s=null;return{onAnchor:i=>{n.push(i),s??(s=nh(t));let o=rh(e,s);return s.add(o),o},setAnchors:()=>{for(let i of n){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(th.isScalar(o.node)||th.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:r}}qr.anchorIsValid=Xk;qr.anchorNames=nh;qr.createNodeAnchors=Qk;qr.findNewAnchor=rh});var Wl=_(sh=>{"use strict";function Jr(t,e,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let s=0,i=r.length;s<i;++s){let o=r[s],a=Jr(t,r,String(s),o);a===void 0?delete r[s]:a!==o&&(r[s]=a)}else if(r instanceof Map)for(let s of Array.from(r.keys())){let i=r.get(s),o=Jr(t,r,s,i);o===void 0?r.delete(s):o!==i&&r.set(s,o)}else if(r instanceof Set)for(let s of Array.from(r)){let i=Jr(t,r,s,s);i===void 0?r.delete(s):i!==s&&(r.delete(s),r.add(i))}else for(let[s,i]of Object.entries(r)){let o=Jr(t,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return t.call(e,n,r)}sh.applyReviver=Jr});var Pt=_(oh=>{"use strict";var Zk=J();function ih(t,e,n){if(Array.isArray(t))return t.map((r,s)=>ih(r,String(s),n));if(t&&typeof t.toJSON=="function"){if(!n||!Zk.hasAnchor(t))return t.toJSON(e,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(t,r),n.onCreate=i=>{r.res=i,delete n.onCreate};let s=t.toJSON(e,n);return n.onCreate&&n.onCreate(s),s}return typeof t=="bigint"&&!n?.keep?Number(t):t}oh.toJS=ih});var Ni=_(lh=>{"use strict";var ex=Wl(),ah=J(),tx=Pt(),Kl=class{constructor(e){Object.defineProperty(this,ah.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:r,onAnchor:s,reviver:i}={}){if(!ah.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=tx.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?ex.applyReviver(i,{"":a},"",a):a}};lh.NodeBase=Kl});var Wr=_(ch=>{"use strict";var nx=Ii(),rx=Fr(),jn=J(),sx=Ni(),ix=Pt(),Hl=class extends sx.NodeBase{constructor(e){super(jn.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],rx.visit(e,{Node:(i,o)=>{(jn.isAlias(o)||jn.hasAnchor(o))&&r.push(o)}}),n&&(n.aliasResolveCache=r));let s;for(let i of r){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(e,n){if(!n)return{source:this.source};let{anchors:r,doc:s,maxAliasCount:i}=n,o=this.resolve(s,n);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=r.get(o);if(a||(ix.toJS(o,null,n),a=r.get(o)),a?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=$i(s,o,r)),a.count*a.aliasCount>i)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,n,r){let s=`*${this.source}`;if(e){if(nx.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(e.implicitKey)return`${s} `}return s}};function $i(t,e,n){if(jn.isAlias(e)){let r=e.resolve(t),s=n&&r&&n.get(r);return s?s.count*s.aliasCount:0}else if(jn.isCollection(e)){let r=0;for(let s of e.items){let i=$i(t,s,n);i>r&&(r=i)}return r}else if(jn.isPair(e)){let r=$i(t,e.key,n),s=$i(t,e.value,n);return Math.max(r,s)}return 1}ch.Alias=Hl});var ne=_(zl=>{"use strict";var ox=J(),ax=Ni(),lx=Pt(),cx=t=>!t||typeof t!="function"&&typeof t!="object",Ct=class extends ax.NodeBase{constructor(e){super(ox.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:lx.toJS(this.value,e,n)}toString(){return String(this.value)}};Ct.BLOCK_FOLDED="BLOCK_FOLDED";Ct.BLOCK_LITERAL="BLOCK_LITERAL";Ct.PLAIN="PLAIN";Ct.QUOTE_DOUBLE="QUOTE_DOUBLE";Ct.QUOTE_SINGLE="QUOTE_SINGLE";zl.Scalar=Ct;zl.isScalarValue=cx});var Kr=_(dh=>{"use strict";var ux=Wr(),nn=J(),uh=ne(),dx="tag:yaml.org,2002:";function fx(t,e,n){if(e){let r=n.filter(i=>i.tag===e),s=r.find(i=>!i.format)??r[0];if(!s)throw new Error(`Tag ${e} not found`);return s}return n.find(r=>r.identify?.(t)&&!r.format)}function px(t,e,n){if(nn.isDocument(t)&&(t=t.contents),nn.isNode(t))return t;if(nn.isPair(t)){let d=n.schema[nn.MAP].createNode?.(n.schema,null,n);return d.items.push(t),d}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:s,onTagObj:i,schema:o,sourceObjects:a}=n,l;if(r&&t&&typeof t=="object"){if(l=a.get(t),l)return l.anchor??(l.anchor=s(t)),new ux.Alias(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=dx+e.slice(2));let c=fx(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new uh.Scalar(t);return l&&(l.node=d),d}c=t instanceof Map?o[nn.MAP]:Symbol.iterator in Object(t)?o[nn.SEQ]:o[nn.MAP]}i&&(i(c),delete n.onTagObj);let f=c?.createNode?c.createNode(n.schema,t,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,t,n):new uh.Scalar(t);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}dh.createNode=px});var Mi=_(Li=>{"use strict";var hx=Kr(),rt=J(),mx=Ni();function Yl(t,e,n){let r=n;for(let s=e.length-1;s>=0;--s){let i=e[s];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=r,r=o}else r=new Map([[i,r]])}return hx.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var fh=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Vl=class extends mx.NodeBase{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(r=>rt.isNode(r)||rt.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(fh(e))this.add(n);else{let[r,...s]=e,i=this.get(r,!0);if(rt.isCollection(i))i.addIn(s,n);else if(i===void 0&&this.schema)this.set(r,Yl(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}deleteIn(e){let[n,...r]=e;if(r.length===0)return this.delete(n);let s=this.get(n,!0);if(rt.isCollection(s))return s.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(e,n){let[r,...s]=e,i=this.get(r,!0);return s.length===0?!n&&rt.isScalar(i)?i.value:i:rt.isCollection(i)?i.getIn(s,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!rt.isPair(n))return!1;let r=n.value;return r==null||e&&rt.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[n,...r]=e;if(r.length===0)return this.has(n);let s=this.get(n,!0);return rt.isCollection(s)?s.hasIn(r):!1}setIn(e,n){let[r,...s]=e;if(s.length===0)this.set(r,n);else{let i=this.get(r,!0);if(rt.isCollection(i))i.setIn(s,n);else if(i===void 0&&this.schema)this.set(r,Yl(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};Li.Collection=Vl;Li.collectionFromPath=Yl;Li.isEmptyPath=fh});var Hr=_(Di=>{"use strict";var gx=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Gl(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var yx=(t,e,n)=>t.endsWith(`
22
+ `}var Np=S(()=>{xi();$l();Ei()});function Br(t){if(!t.trim())return{};try{return JSON.parse(t)}catch{return{}}}function Lp(t){switch($p(t)){case".js":case".mjs":return"text/javascript";case".wasm":return"application/wasm";case".json":case".map":return"application/json";case".svg":return"image/svg+xml";case".png":return"image/png";case".jpg":case".jpeg":return"image/jpeg";case".gif":return"image/gif";case".webp":return"image/webp";case".avif":return"image/avif";case".ico":return"image/x-icon";case".mp3":return"audio/mpeg";case".wav":return"audio/wav";case".ogg":return"audio/ogg";case".m4a":return"audio/mp4";case".mp4":return"video/mp4";case".webm":return"video/webm";case".woff2":return"font/woff2";case".ttf":return"font/ttf";case".css":return"text/css";case".txt":return"text/plain; charset=utf-8";default:return"application/octet-stream"}}function Mp(t){let e=$p(t);return e!==void 0&&Dk.has(e)?e:void 0}function jk(t){return t.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function Ll(t){let e=Br(t??"").description?.trim();if(!e)return Bk;let n=jk(e);return(n.length>200?n.slice(0,197)+"...":n).replace(/\n/g," ")}var Mk,Ti,$p,Dk,Bk,Dp=S(()=>{Mk="https://assets.typebulb.com",Ti=(t,e)=>`${Mk}/u/${encodeURIComponent(t)}/${encodeURIComponent(e)}/`,$p=t=>/\.[^./\\]+$/.exec(t)?.[0]?.toLowerCase();Dk=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);Bk="A Typebulb bulb."});var Bp=S(()=>{});function Ml(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index:-1}var jp=S(()=>{});function jr(t,e,n){let s=new RegExp(e).exec(t.slice(n));return s?n+s.index+s[0].length-1:-1}var Fp=S(()=>{});function Oi(t,e){let n=new RegExp(e,"g"),r=t.match(n);return r?r.length:0}var Up=S(()=>{});function Fr(t,e,n){let r=n&&n.debug||!1,s=!(n&&typeof n.nested===!1),i=n&&n.startIndex||0;r&&console.log("[xml-utils] starting findTagByName with",e," and ",n);let o=Ml(t,`<${e}[
23
+ >/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=t.slice(o+e.length),l=jr(a,"^[^<]*[ /]>",0),c=l!==-1&&a[l-1]==="/";if(r&&console.log("[xml-utils] selfClosing:",c),c===!1)if(s){let p=0,m=1,h=0;for(;(l=jr(a,"[ /]"+e+">",p))!==-1;){let g=a.substring(p,l+1);if(m+=Oi(g,"<"+e+`[
24
+ >]`),h+=Oi(g,"</"+e+">"),h>=m)break;p=l}}else l=jr(a,"[ /]"+e+">",0);let f=o+e.length+l+1;if(r&&console.log("[xml-utils] end:",f),f===-1)return;let d=t.slice(o,f),u;return c?u=null:u=d.slice(d.indexOf(">")+1,d.lastIndexOf("<")),{inner:u,outer:d,start:o,end:f}}var Dl=S(()=>{jp();Fp();Up()});var Bl=S(()=>{Dl()});var jl=S(()=>{Bl()});var qp=S(()=>{jl()});var Jp=S(()=>{});var Wp=S(()=>{Bp();Dl();Bl();qp();jl();Jp()});var J=_(fe=>{"use strict";var Fl=Symbol.for("yaml.alias"),Kp=Symbol.for("yaml.document"),Pi=Symbol.for("yaml.map"),Hp=Symbol.for("yaml.pair"),Ul=Symbol.for("yaml.scalar"),Ci=Symbol.for("yaml.seq"),dt=Symbol.for("yaml.node.type"),qk=t=>!!t&&typeof t=="object"&&t[dt]===Fl,Jk=t=>!!t&&typeof t=="object"&&t[dt]===Kp,Wk=t=>!!t&&typeof t=="object"&&t[dt]===Pi,Kk=t=>!!t&&typeof t=="object"&&t[dt]===Hp,zp=t=>!!t&&typeof t=="object"&&t[dt]===Ul,Hk=t=>!!t&&typeof t=="object"&&t[dt]===Ci;function Yp(t){if(t&&typeof t=="object")switch(t[dt]){case Pi:case Ci:return!0}return!1}function zk(t){if(t&&typeof t=="object")switch(t[dt]){case Fl:case Pi:case Ul:case Ci:return!0}return!1}var Yk=t=>(zp(t)||Yp(t))&&!!t.anchor;fe.ALIAS=Fl;fe.DOC=Kp;fe.MAP=Pi;fe.NODE_TYPE=dt;fe.PAIR=Hp;fe.SCALAR=Ul;fe.SEQ=Ci;fe.hasAnchor=Yk;fe.isAlias=qk;fe.isCollection=Yp;fe.isDocument=Jk;fe.isMap=Wk;fe.isNode=zk;fe.isPair=Kk;fe.isScalar=zp;fe.isSeq=Hk});var Ur=_(ql=>{"use strict";var oe=J(),we=Symbol("break visit"),Vp=Symbol("skip children"),nt=Symbol("remove node");function _i(t,e){let n=Gp(e);oe.isDocument(t)?Dn(null,t.contents,n,Object.freeze([t]))===nt&&(t.contents=null):Dn(null,t,n,Object.freeze([]))}_i.BREAK=we;_i.SKIP=Vp;_i.REMOVE=nt;function Dn(t,e,n,r){let s=Xp(t,e,n,r);if(oe.isNode(s)||oe.isPair(s))return Qp(t,r,s),Dn(t,s,n,r);if(typeof s!="symbol"){if(oe.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=Dn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===we)return we;o===nt&&(e.items.splice(i,1),i-=1)}}}else if(oe.isPair(e)){r=Object.freeze(r.concat(e));let i=Dn("key",e.key,n,r);if(i===we)return we;i===nt&&(e.key=null);let o=Dn("value",e.value,n,r);if(o===we)return we;o===nt&&(e.value=null)}}return s}async function Ri(t,e){let n=Gp(e);oe.isDocument(t)?await Bn(null,t.contents,n,Object.freeze([t]))===nt&&(t.contents=null):await Bn(null,t,n,Object.freeze([]))}Ri.BREAK=we;Ri.SKIP=Vp;Ri.REMOVE=nt;async function Bn(t,e,n,r){let s=await Xp(t,e,n,r);if(oe.isNode(s)||oe.isPair(s))return Qp(t,r,s),Bn(t,s,n,r);if(typeof s!="symbol"){if(oe.isCollection(e)){r=Object.freeze(r.concat(e));for(let i=0;i<e.items.length;++i){let o=await Bn(i,e.items[i],n,r);if(typeof o=="number")i=o-1;else{if(o===we)return we;o===nt&&(e.items.splice(i,1),i-=1)}}}else if(oe.isPair(e)){r=Object.freeze(r.concat(e));let i=await Bn("key",e.key,n,r);if(i===we)return we;i===nt&&(e.key=null);let o=await Bn("value",e.value,n,r);if(o===we)return we;o===nt&&(e.value=null)}}return s}function Gp(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function Xp(t,e,n,r){if(typeof n=="function")return n(t,e,r);if(oe.isMap(e))return n.Map?.(t,e,r);if(oe.isSeq(e))return n.Seq?.(t,e,r);if(oe.isPair(e))return n.Pair?.(t,e,r);if(oe.isScalar(e))return n.Scalar?.(t,e,r);if(oe.isAlias(e))return n.Alias?.(t,e,r)}function Qp(t,e,n){let r=e[e.length-1];if(oe.isCollection(r))r.items[t]=n;else if(oe.isPair(r))t==="key"?r.key=n:r.value=n;else if(oe.isDocument(r))r.contents=n;else{let s=oe.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}ql.visit=_i;ql.visitAsync=Ri});var Jl=_(eh=>{"use strict";var Zp=J(),Vk=Ur(),Gk={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Xk=t=>t.replace(/[!,[\]{}]/g,e=>Gk[e]),qr=class t{constructor(e,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,n)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,n){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),s=r.shift();switch(s){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[i,o]=r;return this.tags[i]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[i]=r;if(i==="1.1"||i==="1.2")return this.yaml.version=i,!0;{let o=/^\d+\.\d+$/.test(i);return n(6,`Unsupported YAML version ${i}`,o),!1}}default:return n(0,`Unknown directive ${s}`,!0),!1}}tagName(e,n){if(e==="!")return"!";if(e[0]!=="!")return n(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}let[,r,s]=e.match(/^(.*!)([^!]*)$/s);s||n(`The ${e} tag has no suffix`);let i=this.tags[r];if(i)try{return i+decodeURIComponent(s)}catch(o){return n(String(o)),null}return r==="!"?e:(n(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[n,r]of Object.entries(this.tags))if(e.startsWith(r))return n+Xk(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),s;if(e&&r.length>0&&Zp.isNode(e.contents)){let i={};Vk.visit(e.contents,(o,a)=>{Zp.isNode(a)&&a.tag&&(i[a.tag]=!0)}),s=Object.keys(i)}else s=[];for(let[i,o]of r)i==="!!"&&o==="tag:yaml.org,2002:"||(!e||s.some(a=>a.startsWith(o)))&&n.push(`%TAG ${i} ${o}`);return n.join(`
25
+ `)}};qr.defaultYaml={explicit:!1,version:"1.2"};qr.defaultTags={"!!":"tag:yaml.org,2002:"};eh.Directives=qr});var Ii=_(Jr=>{"use strict";var th=J(),Qk=Ur();function Zk(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function nh(t){let e=new Set;return Qk.visit(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function rh(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function ex(t,e){let n=[],r=new Map,s=null;return{onAnchor:i=>{n.push(i),s??(s=nh(t));let o=rh(e,s);return s.add(o),o},setAnchors:()=>{for(let i of n){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(th.isScalar(o.node)||th.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:r}}Jr.anchorIsValid=Zk;Jr.anchorNames=nh;Jr.createNodeAnchors=ex;Jr.findNewAnchor=rh});var Wl=_(sh=>{"use strict";function Wr(t,e,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let s=0,i=r.length;s<i;++s){let o=r[s],a=Wr(t,r,String(s),o);a===void 0?delete r[s]:a!==o&&(r[s]=a)}else if(r instanceof Map)for(let s of Array.from(r.keys())){let i=r.get(s),o=Wr(t,r,s,i);o===void 0?r.delete(s):o!==i&&r.set(s,o)}else if(r instanceof Set)for(let s of Array.from(r)){let i=Wr(t,r,s,s);i===void 0?r.delete(s):i!==s&&(r.delete(s),r.add(i))}else for(let[s,i]of Object.entries(r)){let o=Wr(t,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return t.call(e,n,r)}sh.applyReviver=Wr});var Pt=_(oh=>{"use strict";var tx=J();function ih(t,e,n){if(Array.isArray(t))return t.map((r,s)=>ih(r,String(s),n));if(t&&typeof t.toJSON=="function"){if(!n||!tx.hasAnchor(t))return t.toJSON(e,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(t,r),n.onCreate=i=>{r.res=i,delete n.onCreate};let s=t.toJSON(e,n);return n.onCreate&&n.onCreate(s),s}return typeof t=="bigint"&&!n?.keep?Number(t):t}oh.toJS=ih});var Ni=_(lh=>{"use strict";var nx=Wl(),ah=J(),rx=Pt(),Kl=class{constructor(e){Object.defineProperty(this,ah.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:r,onAnchor:s,reviver:i}={}){if(!ah.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=rx.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?nx.applyReviver(i,{"":a},"",a):a}};lh.NodeBase=Kl});var Kr=_(ch=>{"use strict";var sx=Ii(),ix=Ur(),jn=J(),ox=Ni(),ax=Pt(),Hl=class extends ox.NodeBase{constructor(e){super(jn.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],ix.visit(e,{Node:(i,o)=>{(jn.isAlias(o)||jn.hasAnchor(o))&&r.push(o)}}),n&&(n.aliasResolveCache=r));let s;for(let i of r){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(e,n){if(!n)return{source:this.source};let{anchors:r,doc:s,maxAliasCount:i}=n,o=this.resolve(s,n);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=r.get(o);if(a||(ax.toJS(o,null,n),a=r.get(o)),a?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=$i(s,o,r)),a.count*a.aliasCount>i)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,n,r){let s=`*${this.source}`;if(e){if(sx.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let i=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(i)}if(e.implicitKey)return`${s} `}return s}};function $i(t,e,n){if(jn.isAlias(e)){let r=e.resolve(t),s=n&&r&&n.get(r);return s?s.count*s.aliasCount:0}else if(jn.isCollection(e)){let r=0;for(let s of e.items){let i=$i(t,s,n);i>r&&(r=i)}return r}else if(jn.isPair(e)){let r=$i(t,e.key,n),s=$i(t,e.value,n);return Math.max(r,s)}return 1}ch.Alias=Hl});var re=_(zl=>{"use strict";var lx=J(),cx=Ni(),ux=Pt(),dx=t=>!t||typeof t!="function"&&typeof t!="object",Ct=class extends cx.NodeBase{constructor(e){super(lx.SCALAR),this.value=e}toJSON(e,n){return n?.keep?this.value:ux.toJS(this.value,e,n)}toString(){return String(this.value)}};Ct.BLOCK_FOLDED="BLOCK_FOLDED";Ct.BLOCK_LITERAL="BLOCK_LITERAL";Ct.PLAIN="PLAIN";Ct.QUOTE_DOUBLE="QUOTE_DOUBLE";Ct.QUOTE_SINGLE="QUOTE_SINGLE";zl.Scalar=Ct;zl.isScalarValue=dx});var Hr=_(dh=>{"use strict";var fx=Kr(),nn=J(),uh=re(),px="tag:yaml.org,2002:";function hx(t,e,n){if(e){let r=n.filter(i=>i.tag===e),s=r.find(i=>!i.format)??r[0];if(!s)throw new Error(`Tag ${e} not found`);return s}return n.find(r=>r.identify?.(t)&&!r.format)}function mx(t,e,n){if(nn.isDocument(t)&&(t=t.contents),nn.isNode(t))return t;if(nn.isPair(t)){let d=n.schema[nn.MAP].createNode?.(n.schema,null,n);return d.items.push(t),d}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:s,onTagObj:i,schema:o,sourceObjects:a}=n,l;if(r&&t&&typeof t=="object"){if(l=a.get(t),l)return l.anchor??(l.anchor=s(t)),new fx.Alias(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=px+e.slice(2));let c=hx(t,e,o.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let d=new uh.Scalar(t);return l&&(l.node=d),d}c=t instanceof Map?o[nn.MAP]:Symbol.iterator in Object(t)?o[nn.SEQ]:o[nn.MAP]}i&&(i(c),delete n.onTagObj);let f=c?.createNode?c.createNode(n.schema,t,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,t,n):new uh.Scalar(t);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}dh.createNode=mx});var Mi=_(Li=>{"use strict";var gx=Hr(),rt=J(),yx=Ni();function Yl(t,e,n){let r=n;for(let s=e.length-1;s>=0;--s){let i=e[s];if(typeof i=="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=r,r=o}else r=new Map([[i,r]])}return gx.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var fh=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,Vl=class extends yx.NodeBase{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(r=>rt.isNode(r)||rt.isPair(r)?r.clone(e):r),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(fh(e))this.add(n);else{let[r,...s]=e,i=this.get(r,!0);if(rt.isCollection(i))i.addIn(s,n);else if(i===void 0&&this.schema)this.set(r,Yl(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}deleteIn(e){let[n,...r]=e;if(r.length===0)return this.delete(n);let s=this.get(n,!0);if(rt.isCollection(s))return s.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(e,n){let[r,...s]=e,i=this.get(r,!0);return s.length===0?!n&&rt.isScalar(i)?i.value:i:rt.isCollection(i)?i.getIn(s,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!rt.isPair(n))return!1;let r=n.value;return r==null||e&&rt.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[n,...r]=e;if(r.length===0)return this.has(n);let s=this.get(n,!0);return rt.isCollection(s)?s.hasIn(r):!1}setIn(e,n){let[r,...s]=e;if(s.length===0)this.set(r,n);else{let i=this.get(r,!0);if(rt.isCollection(i))i.setIn(s,n);else if(i===void 0&&this.schema)this.set(r,Yl(this.schema,s,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};Li.Collection=Vl;Li.collectionFromPath=Yl;Li.isEmptyPath=fh});var zr=_(Di=>{"use strict";var bx=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Gl(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var wx=(t,e,n)=>t.endsWith(`
26
26
  `)?Gl(n,e):n.includes(`
27
27
  `)?`
28
- `+Gl(n,e):(t.endsWith(" ")?"":" ")+n;Di.indentComment=Gl;Di.lineComment=yx;Di.stringifyComment=gx});var hh=_(zr=>{"use strict";var bx="flow",Xl="block",Bi="quoted";function wx(t,e,n="flow",{indentAtStart:r,lineWidth:s=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return t;s<i&&(i=0);let l=Math.max(1+i,1+s-e.length);if(t.length<=l)return t;let c=[],f={},d=s-e.length;typeof r=="number"&&(r>s-Math.max(2,i)?c.push(0):d=s-r);let u,p,m=!1,h=-1,g=-1,E=-1;n===Xl&&(h=ph(t,h,e.length),h!==-1&&(d=h+l));for(let C;C=t[h+=1];){if(n===Bi&&C==="\\"){switch(g=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}E=h}if(C===`
28
+ `+Gl(n,e):(t.endsWith(" ")?"":" ")+n;Di.indentComment=Gl;Di.lineComment=wx;Di.stringifyComment=bx});var hh=_(Yr=>{"use strict";var vx="flow",Xl="block",Bi="quoted";function Sx(t,e,n="flow",{indentAtStart:r,lineWidth:s=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return t;s<i&&(i=0);let l=Math.max(1+i,1+s-e.length);if(t.length<=l)return t;let c=[],f={},d=s-e.length;typeof r=="number"&&(r>s-Math.max(2,i)?c.push(0):d=s-r);let u,p,m=!1,h=-1,g=-1,x=-1;n===Xl&&(h=ph(t,h,e.length),h!==-1&&(d=h+l));for(let C;C=t[h+=1];){if(n===Bi&&C==="\\"){switch(g=h,t[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}x=h}if(C===`
29
29
  `)n===Xl&&(h=ph(t,h,e.length)),d=h+e.length+l,u=void 0;else{if(C===" "&&p&&p!==" "&&p!==`
30
- `&&p!==" "){let x=t[h+1];x&&x!==" "&&x!==`
31
- `&&x!==" "&&(u=h)}if(h>=d)if(u)c.push(u),d=u+l,u=void 0;else if(n===Bi){for(;p===" "||p===" ";)p=C,C=t[h+=1],m=!0;let x=h>E+1?h-2:g-1;if(f[x])return t;c.push(x),f[x]=!0,d=x+l,u=void 0}else m=!0}p=C}if(m&&a&&a(),c.length===0)return t;o&&o();let O=t.slice(0,c[0]);for(let C=0;C<c.length;++C){let x=c[C],R=c[C+1]||t.length;x===0?O=`
32
- ${e}${t.slice(0,R)}`:(n===Bi&&f[x]&&(O+=`${t[x]}\\`),O+=`
33
- ${e}${t.slice(x+1,R)}`)}return O}function ph(t,e,n){let r=e,s=e+1,i=t[s];for(;i===" "||i===" ";)if(e<s+n)i=t[++e];else{do i=t[++e];while(i&&i!==`
34
- `);r=e,s=e+1,i=t[s]}return r}zr.FOLD_BLOCK=Xl;zr.FOLD_FLOW=bx;zr.FOLD_QUOTED=Bi;zr.foldFlowLines=wx});var Vr=_(mh=>{"use strict";var Ke=ne(),_t=hh(),Fi=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Ui=t=>/^(%|---|\.\.\.)/m.test(t);function vx(t,e,n){if(!e||e<0)return!1;let r=e-n,s=t.length;if(s<=r)return!1;for(let i=0,o=0;i<s;++i)if(t[i]===`
35
- `){if(i-o>r)return!0;if(o=i+1,s-o<=r)return!1}return!0}function Yr(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(Ui(t)?" ":""),o="",a=0;for(let l=0,c=n[l];c;c=n[++l])if(c===" "&&n[l+1]==="\\"&&n[l+2]==="n"&&(o+=n.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(n[l+1]){case"u":{o+=n.slice(a,l);let f=n.substr(l+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=n.substr(l,6)}l+=5,a=l+1}break;case"n":if(r||n[l+2]==='"'||n.length<s)l+=1;else{for(o+=n.slice(a,l)+`
30
+ `&&p!==" "){let E=t[h+1];E&&E!==" "&&E!==`
31
+ `&&E!==" "&&(u=h)}if(h>=d)if(u)c.push(u),d=u+l,u=void 0;else if(n===Bi){for(;p===" "||p===" ";)p=C,C=t[h+=1],m=!0;let E=h>x+1?h-2:g-1;if(f[E])return t;c.push(E),f[E]=!0,d=E+l,u=void 0}else m=!0}p=C}if(m&&a&&a(),c.length===0)return t;o&&o();let O=t.slice(0,c[0]);for(let C=0;C<c.length;++C){let E=c[C],R=c[C+1]||t.length;E===0?O=`
32
+ ${e}${t.slice(0,R)}`:(n===Bi&&f[E]&&(O+=`${t[E]}\\`),O+=`
33
+ ${e}${t.slice(E+1,R)}`)}return O}function ph(t,e,n){let r=e,s=e+1,i=t[s];for(;i===" "||i===" ";)if(e<s+n)i=t[++e];else{do i=t[++e];while(i&&i!==`
34
+ `);r=e,s=e+1,i=t[s]}return r}Yr.FOLD_BLOCK=Xl;Yr.FOLD_FLOW=vx;Yr.FOLD_QUOTED=Bi;Yr.foldFlowLines=Sx});var Gr=_(mh=>{"use strict";var Ke=re(),_t=hh(),Fi=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Ui=t=>/^(%|---|\.\.\.)/m.test(t);function kx(t,e,n){if(!e||e<0)return!1;let r=e-n,s=t.length;if(s<=r)return!1;for(let i=0,o=0;i<s;++i)if(t[i]===`
35
+ `){if(i-o>r)return!0;if(o=i+1,s-o<=r)return!1}return!0}function Vr(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(Ui(t)?" ":""),o="",a=0;for(let l=0,c=n[l];c;c=n[++l])if(c===" "&&n[l+1]==="\\"&&n[l+2]==="n"&&(o+=n.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(n[l+1]){case"u":{o+=n.slice(a,l);let f=n.substr(l+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=n.substr(l,6)}l+=5,a=l+1}break;case"n":if(r||n[l+2]==='"'||n.length<s)l+=1;else{for(o+=n.slice(a,l)+`
36
36
 
37
37
  `;n[l+2]==="\\"&&n[l+3]==="n"&&n[l+4]!=='"';)o+=`
38
38
  `,l+=2;o+=i,n[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+n.slice(a):n,r?o:_t.foldFlowLines(o,i,_t.FOLD_QUOTED,Fi(e,!1))}function Ql(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
39
- `)||/[ \t]\n|\n[ \t]/.test(t))return Yr(t,e);let n=e.indent||(Ui(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
40
- ${n}`)+"'";return e.implicitKey?r:_t.foldFlowLines(r,n,_t.FOLD_FLOW,Fi(e,!1))}function Fn(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=Yr;else{let s=t.includes('"'),i=t.includes("'");s&&!i?r=Ql:i&&!s?r=Yr:r=n?Ql:Yr}return r(t,e)}var Zl;try{Zl=new RegExp(`(^|(?<!
39
+ `)||/[ \t]\n|\n[ \t]/.test(t))return Vr(t,e);let n=e.indent||(Ui(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
40
+ ${n}`)+"'";return e.implicitKey?r:_t.foldFlowLines(r,n,_t.FOLD_FLOW,Fi(e,!1))}function Fn(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=Vr;else{let s=t.includes('"'),i=t.includes("'");s&&!i?r=Ql:i&&!s?r=Vr:r=n?Ql:Vr}return r(t,e)}var Zl;try{Zl=new RegExp(`(^|(?<!
41
41
  ))
42
42
  +(?!
43
- |$)`,"g")}catch{Zl=/\n+(?!\n|$)/g}function ji({comment:t,type:e,value:n},r,s,i){let{blockQuote:o,commentString:a,lineWidth:l}=r.options;if(!o||/\n[\t ]+$/.test(n))return Fn(n,r);let c=r.indent||(r.forceBlockIndent||Ui(n)?" ":""),f=o==="literal"?!0:o==="folded"||e===Ke.Scalar.BLOCK_FOLDED?!1:e===Ke.Scalar.BLOCK_LITERAL?!0:!vx(n,l,c.length);if(!n)return f?`|
43
+ |$)`,"g")}catch{Zl=/\n+(?!\n|$)/g}function ji({comment:t,type:e,value:n},r,s,i){let{blockQuote:o,commentString:a,lineWidth:l}=r.options;if(!o||/\n[\t ]+$/.test(n))return Fn(n,r);let c=r.indent||(r.forceBlockIndent||Ui(n)?" ":""),f=o==="literal"?!0:o==="folded"||e===Ke.Scalar.BLOCK_FOLDED?!1:e===Ke.Scalar.BLOCK_LITERAL?!0:!kx(n,l,c.length);if(!n)return f?`|
44
44
  `:`>
45
45
  `;let d,u;for(u=n.length;u>0;--u){let R=n[u-1];if(R!==`
46
46
  `&&R!==" "&&R!==" ")break}let p=n.substring(u),m=p.indexOf(`
47
47
  `);m===-1?d="-":n===p||m!==p.length-1?(d="+",i&&i()):d="",p&&(n=n.slice(0,-p.length),p[p.length-1]===`
48
- `&&(p=p.slice(0,-1)),p=p.replace(Zl,`$&${c}`));let h=!1,g,E=-1;for(g=0;g<n.length;++g){let R=n[g];if(R===" ")h=!0;else if(R===`
49
- `)E=g;else break}let O=n.substring(0,E<g?E+1:g);O&&(n=n.substring(O.length),O=O.replace(/\n+/g,`$&${c}`));let x=(h?c?"2":"1":"")+d;if(t&&(x+=" "+a(t.replace(/ ?[\r\n]+/g," ")),s&&s()),!f){let R=n.replace(/\n+/g,`
50
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),I=!1,L=Fi(r,!0);o!=="folded"&&e!==Ke.Scalar.BLOCK_FOLDED&&(L.onOverflow=()=>{I=!0});let A=_t.foldFlowLines(`${O}${R}${p}`,c,_t.FOLD_BLOCK,L);if(!I)return`>${x}
51
- ${c}${A}`}return n=n.replace(/\n+/g,`$&${c}`),`|${x}
52
- ${c}${O}${n}${p}`}function Sx(t,e,n,r){let{type:s,value:i}=t,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=e;if(a&&i.includes(`
48
+ `&&(p=p.slice(0,-1)),p=p.replace(Zl,`$&${c}`));let h=!1,g,x=-1;for(g=0;g<n.length;++g){let R=n[g];if(R===" ")h=!0;else if(R===`
49
+ `)x=g;else break}let O=n.substring(0,x<g?x+1:g);O&&(n=n.substring(O.length),O=O.replace(/\n+/g,`$&${c}`));let E=(h?c?"2":"1":"")+d;if(t&&(E+=" "+a(t.replace(/ ?[\r\n]+/g," ")),s&&s()),!f){let R=n.replace(/\n+/g,`
50
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),I=!1,L=Fi(r,!0);o!=="folded"&&e!==Ke.Scalar.BLOCK_FOLDED&&(L.onOverflow=()=>{I=!0});let A=_t.foldFlowLines(`${O}${R}${p}`,c,_t.FOLD_BLOCK,L);if(!I)return`>${E}
51
+ ${c}${A}`}return n=n.replace(/\n+/g,`$&${c}`),`|${E}
52
+ ${c}${O}${n}${p}`}function xx(t,e,n,r){let{type:s,value:i}=t,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=e;if(a&&i.includes(`
53
53
  `)||f&&/[[\]{},]/.test(i))return Fn(i,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||f||!i.includes(`
54
54
  `)?Fn(i,e):ji(t,e,n,r);if(!a&&!f&&s!==Ke.Scalar.PLAIN&&i.includes(`
55
55
  `))return ji(t,e,n,r);if(Ui(i)){if(l==="")return e.forceBlockIndent=!0,ji(t,e,n,r);if(a&&l===c)return Fn(i,e)}let d=i.replace(/\n+/g,`$&
56
- ${l}`);if(o){let u=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:p,tags:m}=e.doc.schema;if(m.some(u)||p?.some(u))return Fn(i,e)}return a?d:_t.foldFlowLines(d,l,_t.FOLD_FLOW,Fi(e,!1))}function kx(t,e,n,r){let{implicitKey:s,inFlow:i}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==Ke.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=Ke.Scalar.QUOTE_DOUBLE);let l=f=>{switch(f){case Ke.Scalar.BLOCK_FOLDED:case Ke.Scalar.BLOCK_LITERAL:return s||i?Fn(o.value,e):ji(o,e,n,r);case Ke.Scalar.QUOTE_DOUBLE:return Yr(o.value,e);case Ke.Scalar.QUOTE_SINGLE:return Ql(o.value,e);case Ke.Scalar.PLAIN:return Sx(o,e,n,r);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:d}=e.options,u=s&&f||d;if(c=l(u),c===null)throw new Error(`Unsupported default string type ${u}`)}return c}mh.stringifyString=kx});var Gr=_(ec=>{"use strict";var xx=Ii(),Rt=J(),Ex=Hr(),Ax=Vr();function Tx(t,e){let n=Object.assign({blockQuote:!0,commentString:Ex.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),r;switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function Ox(t,e){if(e.tag){let s=t.filter(i=>i.tag===e.tag);if(s.length>0)return s.find(i=>i.format===e.format)??s[0]}let n,r;if(Rt.isScalar(e)){r=e.value;let s=t.filter(i=>i.identify?.(r));if(s.length>1){let i=s.filter(o=>o.test);i.length>0&&(s=i)}n=s.find(i=>i.format===e.format)??s.find(i=>!i.format)}else r=e,n=t.find(s=>s.nodeClass&&r instanceof s.nodeClass);if(!n){let s=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${s} value`)}return n}function Px(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let s=[],i=(Rt.isScalar(t)||Rt.isCollection(t))&&t.anchor;i&&xx.anchorIsValid(i)&&(n.add(i),s.push(`&${i}`));let o=t.tag??(e.default?null:e.tag);return o&&s.push(r.directives.tagString(o)),s.join(" ")}function Cx(t,e,n,r){if(Rt.isPair(t))return t.toString(e,n,r);if(Rt.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let s,i=Rt.isNode(t)?t:e.doc.createNode(t,{onTagObj:l=>s=l});s??(s=Ox(e.doc.schema.tags,i));let o=Px(i,s,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof s.stringify=="function"?s.stringify(i,e,n,r):Rt.isScalar(i)?Ax.stringifyString(i,e,n,r):i.toString(e,n,r);return o?Rt.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
57
- ${e.indent}${a}`:a}ec.createStringifyContext=Tx;ec.stringify=Cx});var wh=_(bh=>{"use strict";var ft=J(),gh=ne(),yh=Gr(),Xr=Hr();function _x({key:t,value:e},n,r,s){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:d}}=n,u=ft.isNode(t)&&t.comment||null;if(d){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(ft.isCollection(t)||!ft.isNode(t)&&typeof t=="object"){let L="With simple keys, collection cannot be used as a key value";throw new Error(L)}}let p=!d&&(!t||u&&e==null&&!n.inFlow||ft.isCollection(t)||(ft.isScalar(t)?t.type===gh.Scalar.BLOCK_FOLDED||t.type===gh.Scalar.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!i),indent:a+l});let m=!1,h=!1,g=yh.stringify(t,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(i||e==null)return m&&r&&r(),g===""?"?":p?`? ${g}`:g}else if(i&&!d||e==null&&p)return g=`? ${g}`,u&&!m?g+=Xr.lineComment(g,n.indent,c(u)):h&&s&&s(),g;m&&(u=null),p?(u&&(g+=Xr.lineComment(g,n.indent,c(u))),g=`? ${g}
58
- ${a}:`):(g=`${g}:`,u&&(g+=Xr.lineComment(g,n.indent,c(u))));let E,O,C;ft.isNode(e)?(E=!!e.spaceBefore,O=e.commentBefore,C=e.comment):(E=!1,O=null,C=null,e&&typeof e=="object"&&(e=o.createNode(e))),n.implicitKey=!1,!p&&!u&&ft.isScalar(e)&&(n.indentAtStart=g.length+1),h=!1,!f&&l.length>=2&&!n.inFlow&&!p&&ft.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let x=!1,R=yh.stringify(e,n,()=>x=!0,()=>h=!0),I=" ";if(u||E||O){if(I=E?`
56
+ ${l}`);if(o){let u=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:p,tags:m}=e.doc.schema;if(m.some(u)||p?.some(u))return Fn(i,e)}return a?d:_t.foldFlowLines(d,l,_t.FOLD_FLOW,Fi(e,!1))}function Ex(t,e,n,r){let{implicitKey:s,inFlow:i}=e,o=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==Ke.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=Ke.Scalar.QUOTE_DOUBLE);let l=f=>{switch(f){case Ke.Scalar.BLOCK_FOLDED:case Ke.Scalar.BLOCK_LITERAL:return s||i?Fn(o.value,e):ji(o,e,n,r);case Ke.Scalar.QUOTE_DOUBLE:return Vr(o.value,e);case Ke.Scalar.QUOTE_SINGLE:return Ql(o.value,e);case Ke.Scalar.PLAIN:return xx(o,e,n,r);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:d}=e.options,u=s&&f||d;if(c=l(u),c===null)throw new Error(`Unsupported default string type ${u}`)}return c}mh.stringifyString=Ex});var Xr=_(ec=>{"use strict";var Ax=Ii(),Rt=J(),Tx=zr(),Ox=Gr();function Px(t,e){let n=Object.assign({blockQuote:!0,commentString:Tx.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),r;switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function Cx(t,e){if(e.tag){let s=t.filter(i=>i.tag===e.tag);if(s.length>0)return s.find(i=>i.format===e.format)??s[0]}let n,r;if(Rt.isScalar(e)){r=e.value;let s=t.filter(i=>i.identify?.(r));if(s.length>1){let i=s.filter(o=>o.test);i.length>0&&(s=i)}n=s.find(i=>i.format===e.format)??s.find(i=>!i.format)}else r=e,n=t.find(s=>s.nodeClass&&r instanceof s.nodeClass);if(!n){let s=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${s} value`)}return n}function _x(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let s=[],i=(Rt.isScalar(t)||Rt.isCollection(t))&&t.anchor;i&&Ax.anchorIsValid(i)&&(n.add(i),s.push(`&${i}`));let o=t.tag??(e.default?null:e.tag);return o&&s.push(r.directives.tagString(o)),s.join(" ")}function Rx(t,e,n,r){if(Rt.isPair(t))return t.toString(e,n,r);if(Rt.isAlias(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let s,i=Rt.isNode(t)?t:e.doc.createNode(t,{onTagObj:l=>s=l});s??(s=Cx(e.doc.schema.tags,i));let o=_x(i,s,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof s.stringify=="function"?s.stringify(i,e,n,r):Rt.isScalar(i)?Ox.stringifyString(i,e,n,r):i.toString(e,n,r);return o?Rt.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
57
+ ${e.indent}${a}`:a}ec.createStringifyContext=Px;ec.stringify=Rx});var wh=_(bh=>{"use strict";var ft=J(),gh=re(),yh=Xr(),Qr=zr();function Ix({key:t,value:e},n,r,s){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:d}}=n,u=ft.isNode(t)&&t.comment||null;if(d){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(ft.isCollection(t)||!ft.isNode(t)&&typeof t=="object"){let L="With simple keys, collection cannot be used as a key value";throw new Error(L)}}let p=!d&&(!t||u&&e==null&&!n.inFlow||ft.isCollection(t)||(ft.isScalar(t)?t.type===gh.Scalar.BLOCK_FOLDED||t.type===gh.Scalar.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!i),indent:a+l});let m=!1,h=!1,g=yh.stringify(t,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(i||e==null)return m&&r&&r(),g===""?"?":p?`? ${g}`:g}else if(i&&!d||e==null&&p)return g=`? ${g}`,u&&!m?g+=Qr.lineComment(g,n.indent,c(u)):h&&s&&s(),g;m&&(u=null),p?(u&&(g+=Qr.lineComment(g,n.indent,c(u))),g=`? ${g}
58
+ ${a}:`):(g=`${g}:`,u&&(g+=Qr.lineComment(g,n.indent,c(u))));let x,O,C;ft.isNode(e)?(x=!!e.spaceBefore,O=e.commentBefore,C=e.comment):(x=!1,O=null,C=null,e&&typeof e=="object"&&(e=o.createNode(e))),n.implicitKey=!1,!p&&!u&&ft.isScalar(e)&&(n.indentAtStart=g.length+1),h=!1,!f&&l.length>=2&&!n.inFlow&&!p&&ft.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let E=!1,R=yh.stringify(e,n,()=>E=!0,()=>h=!0),I=" ";if(u||x||O){if(I=x?`
59
59
  `:"",O){let L=c(O);I+=`
60
- ${Xr.indentComment(L,n.indent)}`}R===""&&!n.inFlow?I===`
60
+ ${Qr.indentComment(L,n.indent)}`}R===""&&!n.inFlow?I===`
61
61
  `&&C&&(I=`
62
62
 
63
63
  `):I+=`
64
64
  ${n.indent}`}else if(!p&&ft.isCollection(e)){let L=R[0],A=R.indexOf(`
65
- `),U=A!==-1,Q=n.inFlow??e.flow??e.items.length===0;if(U||!Q){let G=!1;if(U&&(L==="&"||L==="!")){let F=R.indexOf(" ");L==="&"&&F!==-1&&F<A&&R[F+1]==="!"&&(F=R.indexOf(" ",F+1)),(F===-1||A<F)&&(G=!0)}G||(I=`
65
+ `),F=A!==-1,Z=n.inFlow??e.flow??e.items.length===0;if(F||!Z){let te=!1;if(F&&(L==="&"||L==="!")){let U=R.indexOf(" ");L==="&"&&U!==-1&&U<A&&R[U+1]==="!"&&(U=R.indexOf(" ",U+1)),(U===-1||A<U)&&(te=!0)}te||(I=`
66
66
  ${n.indent}`)}}else(R===""||R[0]===`
67
- `)&&(I="");return g+=I+R,n.inFlow?x&&r&&r():C&&!x?g+=Xr.lineComment(g,n.indent,c(C)):h&&s&&s(),g}bh.stringifyPair=_x});var nc=_(tc=>{"use strict";var vh=vi("process");function Rx(t,...e){t==="debug"&&console.log(...e)}function Ix(t,e){(t==="debug"||t==="warn")&&(typeof vh.emitWarning=="function"?vh.emitWarning(e):console.warn(e))}tc.debug=Rx;tc.warn=Ix});var Ki=_(Wi=>{"use strict";var Qr=J(),Sh=ne(),qi="<<",Ji={identify:t=>t===qi||typeof t=="symbol"&&t.description===qi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Sh.Scalar(Symbol(qi)),{addToJSMap:kh}),stringify:()=>qi},Nx=(t,e)=>(Ji.identify(e)||Qr.isScalar(e)&&(!e.type||e.type===Sh.Scalar.PLAIN)&&Ji.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===Ji.tag&&n.default);function kh(t,e,n){if(n=t&&Qr.isAlias(n)?n.resolve(t.doc):n,Qr.isSeq(n))for(let r of n.items)rc(t,e,r);else if(Array.isArray(n))for(let r of n)rc(t,e,r);else rc(t,e,n)}function rc(t,e,n){let r=t&&Qr.isAlias(n)?n.resolve(t.doc):n;if(!Qr.isMap(r))throw new Error("Merge sources must be maps or map aliases");let s=r.toJSON(null,t,Map);for(let[i,o]of s)e instanceof Map?e.has(i)||e.set(i,o):e instanceof Set?e.add(i):Object.prototype.hasOwnProperty.call(e,i)||Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}Wi.addMergeToJSMap=kh;Wi.isMergeKey=Nx;Wi.merge=Ji});var ic=_(Ah=>{"use strict";var $x=nc(),xh=Ki(),Lx=Gr(),Eh=J(),sc=Pt();function Mx(t,e,{key:n,value:r}){if(Eh.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(xh.isMergeKey(t,n))xh.addMergeToJSMap(t,e,r);else{let s=sc.toJS(n,"",t);if(e instanceof Map)e.set(s,sc.toJS(r,s,t));else if(e instanceof Set)e.add(s);else{let i=Dx(n,s,t),o=sc.toJS(r,i,t);i in e?Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[i]=o}}return e}function Dx(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(Eh.isNode(t)&&n?.doc){let r=Lx.createStringifyContext(n.doc,{});r.anchors=new Set;for(let i of n.anchors.keys())r.anchors.add(i.anchor);r.inFlow=!0,r.inStringifyKey=!0;let s=t.toString(r);if(!n.mapKeyWarned){let i=JSON.stringify(s);i.length>40&&(i=i.substring(0,36)+'..."'),$x.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return s}return JSON.stringify(e)}Ah.addPairToJSMap=Mx});var It=_(oc=>{"use strict";var Th=Kr(),Bx=wh(),jx=ic(),Hi=J();function Fx(t,e,n){let r=Th.createNode(t,void 0,n),s=Th.createNode(e,void 0,n);return new zi(r,s)}var zi=class t{constructor(e,n=null){Object.defineProperty(this,Hi.NODE_TYPE,{value:Hi.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return Hi.isNode(n)&&(n=n.clone(e)),Hi.isNode(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return jx.addPairToJSMap(n,r,this)}toString(e,n,r){return e?.doc?Bx.stringifyPair(this,e,n,r):JSON.stringify(this)}};oc.Pair=zi;oc.createPair=Fx});var ac=_(Ph=>{"use strict";var rn=J(),Oh=Gr(),Yi=Hr();function Ux(t,e,n){return(e.inFlow??t.flow?Jx:qx)(t,e,n)}function qx({comment:t,items:e},n,{blockItemPrefix:r,flowChars:s,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=n,f=Object.assign({},n,{indent:i,type:null}),d=!1,u=[];for(let m=0;m<e.length;++m){let h=e[m],g=null;if(rn.isNode(h))!d&&h.spaceBefore&&u.push(""),Vi(n,u,h.commentBefore,d),h.comment&&(g=h.comment);else if(rn.isPair(h)){let O=rn.isNode(h.key)?h.key:null;O&&(!d&&O.spaceBefore&&u.push(""),Vi(n,u,O.commentBefore,d))}d=!1;let E=Oh.stringify(h,f,()=>g=null,()=>d=!0);g&&(E+=Yi.lineComment(E,i,c(g))),d&&g&&(d=!1),u.push(r+E)}let p;if(u.length===0)p=s.start+s.end;else{p=u[0];for(let m=1;m<u.length;++m){let h=u[m];p+=h?`
67
+ `)&&(I="");return g+=I+R,n.inFlow?E&&r&&r():C&&!E?g+=Qr.lineComment(g,n.indent,c(C)):h&&s&&s(),g}bh.stringifyPair=Ix});var nc=_(tc=>{"use strict";var vh=vi("process");function Nx(t,...e){t==="debug"&&console.log(...e)}function $x(t,e){(t==="debug"||t==="warn")&&(typeof vh.emitWarning=="function"?vh.emitWarning(e):console.warn(e))}tc.debug=Nx;tc.warn=$x});var Ki=_(Wi=>{"use strict";var Zr=J(),Sh=re(),qi="<<",Ji={identify:t=>t===qi||typeof t=="symbol"&&t.description===qi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Sh.Scalar(Symbol(qi)),{addToJSMap:kh}),stringify:()=>qi},Lx=(t,e)=>(Ji.identify(e)||Zr.isScalar(e)&&(!e.type||e.type===Sh.Scalar.PLAIN)&&Ji.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===Ji.tag&&n.default);function kh(t,e,n){if(n=t&&Zr.isAlias(n)?n.resolve(t.doc):n,Zr.isSeq(n))for(let r of n.items)rc(t,e,r);else if(Array.isArray(n))for(let r of n)rc(t,e,r);else rc(t,e,n)}function rc(t,e,n){let r=t&&Zr.isAlias(n)?n.resolve(t.doc):n;if(!Zr.isMap(r))throw new Error("Merge sources must be maps or map aliases");let s=r.toJSON(null,t,Map);for(let[i,o]of s)e instanceof Map?e.has(i)||e.set(i,o):e instanceof Set?e.add(i):Object.prototype.hasOwnProperty.call(e,i)||Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}Wi.addMergeToJSMap=kh;Wi.isMergeKey=Lx;Wi.merge=Ji});var ic=_(Ah=>{"use strict";var Mx=nc(),xh=Ki(),Dx=Xr(),Eh=J(),sc=Pt();function Bx(t,e,{key:n,value:r}){if(Eh.isNode(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(xh.isMergeKey(t,n))xh.addMergeToJSMap(t,e,r);else{let s=sc.toJS(n,"",t);if(e instanceof Map)e.set(s,sc.toJS(r,s,t));else if(e instanceof Set)e.add(s);else{let i=jx(n,s,t),o=sc.toJS(r,i,t);i in e?Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[i]=o}}return e}function jx(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(Eh.isNode(t)&&n?.doc){let r=Dx.createStringifyContext(n.doc,{});r.anchors=new Set;for(let i of n.anchors.keys())r.anchors.add(i.anchor);r.inFlow=!0,r.inStringifyKey=!0;let s=t.toString(r);if(!n.mapKeyWarned){let i=JSON.stringify(s);i.length>40&&(i=i.substring(0,36)+'..."'),Mx.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return s}return JSON.stringify(e)}Ah.addPairToJSMap=Bx});var It=_(oc=>{"use strict";var Th=Hr(),Fx=wh(),Ux=ic(),Hi=J();function qx(t,e,n){let r=Th.createNode(t,void 0,n),s=Th.createNode(e,void 0,n);return new zi(r,s)}var zi=class t{constructor(e,n=null){Object.defineProperty(this,Hi.NODE_TYPE,{value:Hi.PAIR}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return Hi.isNode(n)&&(n=n.clone(e)),Hi.isNode(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return Ux.addPairToJSMap(n,r,this)}toString(e,n,r){return e?.doc?Fx.stringifyPair(this,e,n,r):JSON.stringify(this)}};oc.Pair=zi;oc.createPair=qx});var ac=_(Ph=>{"use strict";var rn=J(),Oh=Xr(),Yi=zr();function Jx(t,e,n){return(e.inFlow??t.flow?Kx:Wx)(t,e,n)}function Wx({comment:t,items:e},n,{blockItemPrefix:r,flowChars:s,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=n,f=Object.assign({},n,{indent:i,type:null}),d=!1,u=[];for(let m=0;m<e.length;++m){let h=e[m],g=null;if(rn.isNode(h))!d&&h.spaceBefore&&u.push(""),Vi(n,u,h.commentBefore,d),h.comment&&(g=h.comment);else if(rn.isPair(h)){let O=rn.isNode(h.key)?h.key:null;O&&(!d&&O.spaceBefore&&u.push(""),Vi(n,u,O.commentBefore,d))}d=!1;let x=Oh.stringify(h,f,()=>g=null,()=>d=!0);g&&(x+=Yi.lineComment(x,i,c(g))),d&&g&&(d=!1),u.push(r+x)}let p;if(u.length===0)p=s.start+s.end;else{p=u[0];for(let m=1;m<u.length;++m){let h=u[m];p+=h?`
68
68
  ${l}${h}`:`
69
69
  `}}return t?(p+=`
70
- `+Yi.indentComment(c(t),l),a&&a()):d&&o&&o(),p}function Jx({items:t},e,{flowChars:n,itemIndent:r}){let{indent:s,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=e;r+=i;let l=Object.assign({},e,{indent:r,inFlow:!0,type:null}),c=!1,f=0,d=[];for(let m=0;m<t.length;++m){let h=t[m],g=null;if(rn.isNode(h))h.spaceBefore&&d.push(""),Vi(e,d,h.commentBefore,!1),h.comment&&(g=h.comment);else if(rn.isPair(h)){let O=rn.isNode(h.key)?h.key:null;O&&(O.spaceBefore&&d.push(""),Vi(e,d,O.commentBefore,!1),O.comment&&(c=!0));let C=rn.isNode(h.value)?h.value:null;C?(C.comment&&(g=C.comment),C.commentBefore&&(c=!0)):h.value==null&&O?.comment&&(g=O.comment)}g&&(c=!0);let E=Oh.stringify(h,l,()=>g=null);m<t.length-1&&(E+=","),g&&(E+=Yi.lineComment(E,r,a(g))),!c&&(d.length>f||E.includes(`
71
- `))&&(c=!0),d.push(E),f=d.length}let{start:u,end:p}=n;if(d.length===0)return u+p;if(!c){let m=d.reduce((h,g)=>h+g.length+2,2);c=e.options.lineWidth>0&&m>e.options.lineWidth}if(c){let m=u;for(let h of d)m+=h?`
70
+ `+Yi.indentComment(c(t),l),a&&a()):d&&o&&o(),p}function Kx({items:t},e,{flowChars:n,itemIndent:r}){let{indent:s,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=e;r+=i;let l=Object.assign({},e,{indent:r,inFlow:!0,type:null}),c=!1,f=0,d=[];for(let m=0;m<t.length;++m){let h=t[m],g=null;if(rn.isNode(h))h.spaceBefore&&d.push(""),Vi(e,d,h.commentBefore,!1),h.comment&&(g=h.comment);else if(rn.isPair(h)){let O=rn.isNode(h.key)?h.key:null;O&&(O.spaceBefore&&d.push(""),Vi(e,d,O.commentBefore,!1),O.comment&&(c=!0));let C=rn.isNode(h.value)?h.value:null;C?(C.comment&&(g=C.comment),C.commentBefore&&(c=!0)):h.value==null&&O?.comment&&(g=O.comment)}g&&(c=!0);let x=Oh.stringify(h,l,()=>g=null);m<t.length-1&&(x+=","),g&&(x+=Yi.lineComment(x,r,a(g))),!c&&(d.length>f||x.includes(`
71
+ `))&&(c=!0),d.push(x),f=d.length}let{start:u,end:p}=n;if(d.length===0)return u+p;if(!c){let m=d.reduce((h,g)=>h+g.length+2,2);c=e.options.lineWidth>0&&m>e.options.lineWidth}if(c){let m=u;for(let h of d)m+=h?`
72
72
  ${i}${s}${h}`:`
73
73
  `;return`${m}
74
- ${s}${p}`}else return`${u}${o}${d.join(" ")}${o}${p}`}function Vi({indent:t,options:{commentString:e}},n,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=Yi.indentComment(e(r),t);n.push(i.trimStart())}}Ph.stringifyCollection=Ux});var $t=_(cc=>{"use strict";var Wx=ac(),Kx=ic(),Hx=Mi(),Nt=J(),Gi=It(),zx=ne();function Zr(t,e){let n=Nt.isScalar(e)?e.value:e;for(let r of t)if(Nt.isPair(r)&&(r.key===e||r.key===n||Nt.isScalar(r.key)&&r.key.value===n))return r}var lc=class extends Hx.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Nt.MAP,e),this.items=[]}static from(e,n,r){let{keepUndefined:s,replacer:i}=r,o=new this(e),a=(l,c)=>{if(typeof i=="function")c=i.call(n,l,c);else if(Array.isArray(i)&&!i.includes(l))return;(c!==void 0||s)&&o.items.push(Gi.createPair(l,c,r))};if(n instanceof Map)for(let[l,c]of n)a(l,c);else if(n&&typeof n=="object")for(let l of Object.keys(n))a(l,n[l]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,n){let r;Nt.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new Gi.Pair(e,e?.value):r=new Gi.Pair(e.key,e.value);let s=Zr(this.items,r.key),i=this.schema?.sortMapEntries;if(s){if(!n)throw new Error(`Key ${r.key} already set`);Nt.isScalar(s.value)&&zx.isScalarValue(r.value)?s.value.value=r.value:s.value=r.value}else if(i){let o=this.items.findIndex(a=>i(r,a)<0);o===-1?this.items.push(r):this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let n=Zr(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let s=Zr(this.items,e)?.value;return(!n&&Nt.isScalar(s)?s.value:s)??void 0}has(e){return!!Zr(this.items,e)}set(e,n){this.add(new Gi.Pair(e,n),!0)}toJSON(e,n,r){let s=r?new r:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(s);for(let i of this.items)Kx.addPairToJSMap(n,s,i);return s}toString(e,n,r){if(!e)return JSON.stringify(this);for(let s of this.items)if(!Nt.isPair(s))throw new Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Wx.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};cc.YAMLMap=lc;cc.findPair=Zr});var Un=_(_h=>{"use strict";var Yx=J(),Ch=$t(),Vx={collection:"map",default:!0,nodeClass:Ch.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return Yx.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>Ch.YAMLMap.from(t,e,n)};_h.map=Vx});var Lt=_(Rh=>{"use strict";var Gx=Kr(),Xx=ac(),Qx=Mi(),Qi=J(),Zx=ne(),e0=Pt(),uc=class extends Qx.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Qi.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=Xi(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=Xi(e);if(typeof r!="number")return;let s=this.items[r];return!n&&Qi.isScalar(s)?s.value:s}has(e){let n=Xi(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=Xi(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];Qi.isScalar(s)&&Zx.isScalarValue(n)?s.value=n:this.items[r]=n}toJSON(e,n){let r=[];n?.onCreate&&n.onCreate(r);let s=0;for(let i of this.items)r.push(e0.toJS(i,String(s++),n));return r}toString(e,n,r){return e?Xx.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:n}):JSON.stringify(this)}static from(e,n,r){let{replacer:s}=r,i=new this(e);if(n&&Symbol.iterator in Object(n)){let o=0;for(let a of n){if(typeof s=="function"){let l=n instanceof Set?a:String(o++);a=s.call(n,l,a)}i.items.push(Gx.createNode(a,void 0,r))}}return i}};function Xi(t){let e=Qi.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}Rh.YAMLSeq=uc});var qn=_(Nh=>{"use strict";var t0=J(),Ih=Lt(),n0={collection:"seq",default:!0,nodeClass:Ih.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return t0.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>Ih.YAMLSeq.from(t,e,n)};Nh.seq=n0});var es=_($h=>{"use strict";var r0=Vr(),s0={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,n,r){return e=Object.assign({actualString:!0},e),r0.stringifyString(t,e,n,r)}};$h.string=s0});var Zi=_(Dh=>{"use strict";var Lh=ne(),Mh={identify:t=>t==null,createNode:()=>new Lh.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Lh.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Mh.test.test(t)?t:e.options.nullStr};Dh.nullTag=Mh});var dc=_(jh=>{"use strict";var i0=ne(),Bh={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new i0.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&Bh.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};jh.boolTag=Bh});var Jn=_(Fh=>{"use strict";function o0({format:t,minFractionDigits:e,tag:n,value:r}){if(typeof r=="bigint")return String(r);let s=typeof r=="number"?r:Number(r);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let i=Object.is(r,-0)?"-0":JSON.stringify(r);if(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^\d/.test(i)){let o=i.indexOf(".");o<0&&(o=i.length,i+=".");let a=e-(i.length-o-1);for(;a-- >0;)i+="0"}return i}Fh.stringifyNumber=o0});var pc=_(eo=>{"use strict";var a0=ne(),fc=Jn(),l0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:fc.stringifyNumber},c0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():fc.stringifyNumber(t)}},u0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new a0.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:fc.stringifyNumber};eo.float=u0;eo.floatExp=c0;eo.floatNaN=l0});var mc=_(no=>{"use strict";var Uh=Jn(),to=t=>typeof t=="bigint"||Number.isInteger(t),hc=(t,e,n,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),n);function qh(t,e,n){let{value:r}=t;return to(r)&&r>=0?n+r.toString(e):Uh.stringifyNumber(t)}var d0={identify:t=>to(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>hc(t,2,8,n),stringify:t=>qh(t,8,"0o")},f0={identify:to,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>hc(t,0,10,n),stringify:Uh.stringifyNumber},p0={identify:t=>to(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>hc(t,2,16,n),stringify:t=>qh(t,16,"0x")};no.int=f0;no.intHex=p0;no.intOct=d0});var Wh=_(Jh=>{"use strict";var h0=Un(),m0=Zi(),g0=qn(),y0=es(),b0=dc(),gc=pc(),yc=mc(),w0=[h0.map,g0.seq,y0.string,m0.nullTag,b0.boolTag,yc.intOct,yc.int,yc.intHex,gc.floatNaN,gc.floatExp,gc.float];Jh.schema=w0});var zh=_(Hh=>{"use strict";var v0=ne(),S0=Un(),k0=qn();function Kh(t){return typeof t=="bigint"||Number.isInteger(t)}var ro=({value:t})=>JSON.stringify(t),x0=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:ro},{identify:t=>t==null,createNode:()=>new v0.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:ro},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:ro},{identify:Kh,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:n})=>n?BigInt(t):parseInt(t,10),stringify:({value:t})=>Kh(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:ro}],E0={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},A0=[S0.map,k0.seq].concat(x0,E0);Hh.schema=A0});var wc=_(Yh=>{"use strict";var ts=vi("buffer"),bc=ne(),T0=Vr(),O0={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof ts.Buffer=="function")return ts.Buffer.from(t,"base64");if(typeof atob=="function"){let n=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(n.length);for(let s=0;s<n.length;++s)r[s]=n.charCodeAt(s);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:n},r,s,i){if(!n)return"";let o=n,a;if(typeof ts.Buffer=="function")a=o instanceof ts.Buffer?o.toString("base64"):ts.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=bc.Scalar.BLOCK_LITERAL),e!==bc.Scalar.QUOTE_DOUBLE){let l=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),c=Math.ceil(a.length/l),f=new Array(c);for(let d=0,u=0;d<c;++d,u+=l)f[d]=a.substr(u,l);a=f.join(e===bc.Scalar.BLOCK_LITERAL?`
75
- `:" ")}return T0.stringifyString({comment:t,type:e,value:a},r,s,i)}};Yh.binary=O0});var oo=_(io=>{"use strict";var so=J(),vc=It(),P0=ne(),C0=Lt();function Vh(t,e){if(so.isSeq(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!so.isPair(r)){if(so.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let s=r.items[0]||new vc.Pair(new P0.Scalar(null));if(r.commentBefore&&(s.key.commentBefore=s.key.commentBefore?`${r.commentBefore}
74
+ ${s}${p}`}else return`${u}${o}${d.join(" ")}${o}${p}`}function Vi({indent:t,options:{commentString:e}},n,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=Yi.indentComment(e(r),t);n.push(i.trimStart())}}Ph.stringifyCollection=Jx});var $t=_(cc=>{"use strict";var Hx=ac(),zx=ic(),Yx=Mi(),Nt=J(),Gi=It(),Vx=re();function es(t,e){let n=Nt.isScalar(e)?e.value:e;for(let r of t)if(Nt.isPair(r)&&(r.key===e||r.key===n||Nt.isScalar(r.key)&&r.key.value===n))return r}var lc=class extends Yx.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Nt.MAP,e),this.items=[]}static from(e,n,r){let{keepUndefined:s,replacer:i}=r,o=new this(e),a=(l,c)=>{if(typeof i=="function")c=i.call(n,l,c);else if(Array.isArray(i)&&!i.includes(l))return;(c!==void 0||s)&&o.items.push(Gi.createPair(l,c,r))};if(n instanceof Map)for(let[l,c]of n)a(l,c);else if(n&&typeof n=="object")for(let l of Object.keys(n))a(l,n[l]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,n){let r;Nt.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new Gi.Pair(e,e?.value):r=new Gi.Pair(e.key,e.value);let s=es(this.items,r.key),i=this.schema?.sortMapEntries;if(s){if(!n)throw new Error(`Key ${r.key} already set`);Nt.isScalar(s.value)&&Vx.isScalarValue(r.value)?s.value.value=r.value:s.value=r.value}else if(i){let o=this.items.findIndex(a=>i(r,a)<0);o===-1?this.items.push(r):this.items.splice(o,0,r)}else this.items.push(r)}delete(e){let n=es(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let s=es(this.items,e)?.value;return(!n&&Nt.isScalar(s)?s.value:s)??void 0}has(e){return!!es(this.items,e)}set(e,n){this.add(new Gi.Pair(e,n),!0)}toJSON(e,n,r){let s=r?new r:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(s);for(let i of this.items)zx.addPairToJSMap(n,s,i);return s}toString(e,n,r){if(!e)return JSON.stringify(this);for(let s of this.items)if(!Nt.isPair(s))throw new Error(`Map items must all be pairs; found ${JSON.stringify(s)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Hx.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};cc.YAMLMap=lc;cc.findPair=es});var Un=_(_h=>{"use strict";var Gx=J(),Ch=$t(),Xx={collection:"map",default:!0,nodeClass:Ch.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(t,e){return Gx.isMap(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>Ch.YAMLMap.from(t,e,n)};_h.map=Xx});var Lt=_(Rh=>{"use strict";var Qx=Hr(),Zx=ac(),e0=Mi(),Qi=J(),t0=re(),n0=Pt(),uc=class extends e0.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Qi.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=Xi(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=Xi(e);if(typeof r!="number")return;let s=this.items[r];return!n&&Qi.isScalar(s)?s.value:s}has(e){let n=Xi(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=Xi(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];Qi.isScalar(s)&&t0.isScalarValue(n)?s.value=n:this.items[r]=n}toJSON(e,n){let r=[];n?.onCreate&&n.onCreate(r);let s=0;for(let i of this.items)r.push(n0.toJS(i,String(s++),n));return r}toString(e,n,r){return e?Zx.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:n}):JSON.stringify(this)}static from(e,n,r){let{replacer:s}=r,i=new this(e);if(n&&Symbol.iterator in Object(n)){let o=0;for(let a of n){if(typeof s=="function"){let l=n instanceof Set?a:String(o++);a=s.call(n,l,a)}i.items.push(Qx.createNode(a,void 0,r))}}return i}};function Xi(t){let e=Qi.isScalar(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}Rh.YAMLSeq=uc});var qn=_(Nh=>{"use strict";var r0=J(),Ih=Lt(),s0={collection:"seq",default:!0,nodeClass:Ih.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(t,e){return r0.isSeq(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>Ih.YAMLSeq.from(t,e,n)};Nh.seq=s0});var ts=_($h=>{"use strict";var i0=Gr(),o0={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,n,r){return e=Object.assign({actualString:!0},e),i0.stringifyString(t,e,n,r)}};$h.string=o0});var Zi=_(Dh=>{"use strict";var Lh=re(),Mh={identify:t=>t==null,createNode:()=>new Lh.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Lh.Scalar(null),stringify:({source:t},e)=>typeof t=="string"&&Mh.test.test(t)?t:e.options.nullStr};Dh.nullTag=Mh});var dc=_(jh=>{"use strict";var a0=re(),Bh={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new a0.Scalar(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&Bh.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};jh.boolTag=Bh});var Jn=_(Fh=>{"use strict";function l0({format:t,minFractionDigits:e,tag:n,value:r}){if(typeof r=="bigint")return String(r);let s=typeof r=="number"?r:Number(r);if(!isFinite(s))return isNaN(s)?".nan":s<0?"-.inf":".inf";let i=Object.is(r,-0)?"-0":JSON.stringify(r);if(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^\d/.test(i)){let o=i.indexOf(".");o<0&&(o=i.length,i+=".");let a=e-(i.length-o-1);for(;a-- >0;)i+="0"}return i}Fh.stringifyNumber=l0});var pc=_(eo=>{"use strict";var c0=re(),fc=Jn(),u0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:fc.stringifyNumber},d0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():fc.stringifyNumber(t)}},f0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new c0.Scalar(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:fc.stringifyNumber};eo.float=f0;eo.floatExp=d0;eo.floatNaN=u0});var mc=_(no=>{"use strict";var Uh=Jn(),to=t=>typeof t=="bigint"||Number.isInteger(t),hc=(t,e,n,{intAsBigInt:r})=>r?BigInt(t):parseInt(t.substring(e),n);function qh(t,e,n){let{value:r}=t;return to(r)&&r>=0?n+r.toString(e):Uh.stringifyNumber(t)}var p0={identify:t=>to(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>hc(t,2,8,n),stringify:t=>qh(t,8,"0o")},h0={identify:to,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>hc(t,0,10,n),stringify:Uh.stringifyNumber},m0={identify:t=>to(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>hc(t,2,16,n),stringify:t=>qh(t,16,"0x")};no.int=h0;no.intHex=m0;no.intOct=p0});var Wh=_(Jh=>{"use strict";var g0=Un(),y0=Zi(),b0=qn(),w0=ts(),v0=dc(),gc=pc(),yc=mc(),S0=[g0.map,b0.seq,w0.string,y0.nullTag,v0.boolTag,yc.intOct,yc.int,yc.intHex,gc.floatNaN,gc.floatExp,gc.float];Jh.schema=S0});var zh=_(Hh=>{"use strict";var k0=re(),x0=Un(),E0=qn();function Kh(t){return typeof t=="bigint"||Number.isInteger(t)}var ro=({value:t})=>JSON.stringify(t),A0=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:ro},{identify:t=>t==null,createNode:()=>new k0.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:ro},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:ro},{identify:Kh,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:n})=>n?BigInt(t):parseInt(t,10),stringify:({value:t})=>Kh(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:ro}],T0={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},O0=[x0.map,E0.seq].concat(A0,T0);Hh.schema=O0});var wc=_(Yh=>{"use strict";var ns=vi("buffer"),bc=re(),P0=Gr(),C0={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof ns.Buffer=="function")return ns.Buffer.from(t,"base64");if(typeof atob=="function"){let n=atob(t.replace(/[\n\r]/g,"")),r=new Uint8Array(n.length);for(let s=0;s<n.length;++s)r[s]=n.charCodeAt(s);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:n},r,s,i){if(!n)return"";let o=n,a;if(typeof ns.Buffer=="function")a=o instanceof ns.Buffer?o.toString("base64"):ns.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=bc.Scalar.BLOCK_LITERAL),e!==bc.Scalar.QUOTE_DOUBLE){let l=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),c=Math.ceil(a.length/l),f=new Array(c);for(let d=0,u=0;d<c;++d,u+=l)f[d]=a.substr(u,l);a=f.join(e===bc.Scalar.BLOCK_LITERAL?`
75
+ `:" ")}return P0.stringifyString({comment:t,type:e,value:a},r,s,i)}};Yh.binary=C0});var oo=_(io=>{"use strict";var so=J(),vc=It(),_0=re(),R0=Lt();function Vh(t,e){if(so.isSeq(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!so.isPair(r)){if(so.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let s=r.items[0]||new vc.Pair(new _0.Scalar(null));if(r.commentBefore&&(s.key.commentBefore=s.key.commentBefore?`${r.commentBefore}
76
76
  ${s.key.commentBefore}`:r.commentBefore),r.comment){let i=s.value??s.key;i.comment=i.comment?`${r.comment}
77
- ${i.comment}`:r.comment}r=s}t.items[n]=so.isPair(r)?r:new vc.Pair(r)}}else e("Expected a sequence for this tag");return t}function Gh(t,e,n){let{replacer:r}=n,s=new C0.YAMLSeq(t);s.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof r=="function"&&(o=r.call(e,String(i++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;s.items.push(vc.createPair(a,l,n))}return s}var _0={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Vh,createNode:Gh};io.createPairs=Gh;io.pairs=_0;io.resolvePairs=Vh});var xc=_(kc=>{"use strict";var Xh=J(),Sc=Pt(),ns=$t(),R0=Lt(),Qh=oo(),sn=class t extends R0.YAMLSeq{constructor(){super(),this.add=ns.YAMLMap.prototype.add.bind(this),this.delete=ns.YAMLMap.prototype.delete.bind(this),this.get=ns.YAMLMap.prototype.get.bind(this),this.has=ns.YAMLMap.prototype.has.bind(this),this.set=ns.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let r=new Map;n?.onCreate&&n.onCreate(r);for(let s of this.items){let i,o;if(Xh.isPair(s)?(i=Sc.toJS(s.key,"",n),o=Sc.toJS(s.value,i,n)):i=Sc.toJS(s,"",n),r.has(i))throw new Error("Ordered maps must not include duplicate keys");r.set(i,o)}return r}static from(e,n,r){let s=Qh.createPairs(e,n,r),i=new this;return i.items=s.items,i}};sn.tag="tag:yaml.org,2002:omap";var I0={collection:"seq",identify:t=>t instanceof Map,nodeClass:sn,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=Qh.resolvePairs(t,e),r=[];for(let{key:s}of n.items)Xh.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new sn,n)},createNode:(t,e,n)=>sn.from(t,e,n)};kc.YAMLOMap=sn;kc.omap=I0});var rm=_(Ec=>{"use strict";var Zh=ne();function em({value:t,source:e},n){return e&&(t?tm:nm).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var tm={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Zh.Scalar(!0),stringify:em},nm={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Zh.Scalar(!1),stringify:em};Ec.falseTag=nm;Ec.trueTag=tm});var sm=_(ao=>{"use strict";var N0=ne(),Ac=Jn(),$0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ac.stringifyNumber},L0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Ac.stringifyNumber(t)}},M0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new N0.Scalar(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let r=t.substring(n+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:Ac.stringifyNumber};ao.float=M0;ao.floatExp=L0;ao.floatNaN=$0});var om=_(ss=>{"use strict";var im=Jn(),rs=t=>typeof t=="bigint"||Number.isInteger(t);function lo(t,e,n,{intAsBigInt:r}){let s=t[0];if((s==="-"||s==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return s==="-"?BigInt(-1)*o:o}let i=parseInt(t,n);return s==="-"?-1*i:i}function Tc(t,e,n){let{value:r}=t;if(rs(r)){let s=r.toString(e);return r<0?"-"+n+s.substr(1):n+s}return im.stringifyNumber(t)}var D0={identify:rs,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>lo(t,2,2,n),stringify:t=>Tc(t,2,"0b")},B0={identify:rs,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>lo(t,1,8,n),stringify:t=>Tc(t,8,"0")},j0={identify:rs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>lo(t,0,10,n),stringify:im.stringifyNumber},F0={identify:rs,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>lo(t,2,16,n),stringify:t=>Tc(t,16,"0x")};ss.int=j0;ss.intBin=D0;ss.intHex=F0;ss.intOct=B0});var Pc=_(Oc=>{"use strict";var fo=J(),co=It(),uo=$t(),on=class t extends uo.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;fo.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new co.Pair(e.key,null):n=new co.Pair(e,null),uo.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=uo.findPair(this.items,e);return!n&&fo.isPair(r)?fo.isScalar(r.key)?r.key.value:r.key:r}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let r=uo.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new co.Pair(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,r);throw new Error("Set items must all have null values")}static from(e,n,r){let{replacer:s}=r,i=new this(e);if(n&&Symbol.iterator in Object(n))for(let o of n)typeof s=="function"&&(o=s.call(n,o,o)),i.items.push(co.createPair(o,null,r));return i}};on.tag="tag:yaml.org,2002:set";var U0={collection:"map",identify:t=>t instanceof Set,nodeClass:on,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>on.from(t,e,n),resolve(t,e){if(fo.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new on,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Oc.YAMLSet=on;Oc.set=U0});var _c=_(po=>{"use strict";var q0=Jn();function Cc(t,e){let n=t[0],r=n==="-"||n==="+"?t.substring(1):t,s=o=>e?BigInt(o):Number(o),i=r.replace(/_/g,"").split(":").reduce((o,a)=>o*s(60)+s(a),s(0));return n==="-"?s(-1)*i:i}function am(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return q0.stringifyNumber(t);let r="";e<0&&(r="-",e*=n(-1));let s=n(60),i=[e%s];return e<60?i.unshift(0):(e=(e-i[0])/s,i.unshift(e%s),e>=60&&(e=(e-i[0])/s,i.unshift(e))),r+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var J0={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>Cc(t,n),stringify:am},W0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Cc(t,!1),stringify:am},lm={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(lm.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,s,i,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(n,r-1,s,i||0,o||0,a||0,l),f=e[8];if(f&&f!=="Z"){let d=Cc(f,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};po.floatTime=W0;po.intTime=J0;po.timestamp=lm});var dm=_(um=>{"use strict";var K0=Un(),H0=Zi(),z0=qn(),Y0=es(),V0=wc(),cm=rm(),Rc=sm(),ho=om(),G0=Ki(),X0=xc(),Q0=oo(),Z0=Pc(),Ic=_c(),eE=[K0.map,z0.seq,Y0.string,H0.nullTag,cm.trueTag,cm.falseTag,ho.intBin,ho.intOct,ho.int,ho.intHex,Rc.floatNaN,Rc.floatExp,Rc.float,V0.binary,G0.merge,X0.omap,Q0.pairs,Z0.set,Ic.intTime,Ic.floatTime,Ic.timestamp];um.schema=eE});var Sm=_(Lc=>{"use strict";var mm=Un(),tE=Zi(),gm=qn(),nE=es(),rE=dc(),Nc=pc(),$c=mc(),sE=Wh(),iE=zh(),ym=wc(),is=Ki(),bm=xc(),wm=oo(),fm=dm(),vm=Pc(),mo=_c(),pm=new Map([["core",sE.schema],["failsafe",[mm.map,gm.seq,nE.string]],["json",iE.schema],["yaml11",fm.schema],["yaml-1.1",fm.schema]]),hm={binary:ym.binary,bool:rE.boolTag,float:Nc.float,floatExp:Nc.floatExp,floatNaN:Nc.floatNaN,floatTime:mo.floatTime,int:$c.int,intHex:$c.intHex,intOct:$c.intOct,intTime:mo.intTime,map:mm.map,merge:is.merge,null:tE.nullTag,omap:bm.omap,pairs:wm.pairs,seq:gm.seq,set:vm.set,timestamp:mo.timestamp},oE={"tag:yaml.org,2002:binary":ym.binary,"tag:yaml.org,2002:merge":is.merge,"tag:yaml.org,2002:omap":bm.omap,"tag:yaml.org,2002:pairs":wm.pairs,"tag:yaml.org,2002:set":vm.set,"tag:yaml.org,2002:timestamp":mo.timestamp};function aE(t,e,n){let r=pm.get(e);if(r&&!t)return n&&!r.includes(is.merge)?r.concat(is.merge):r.slice();let s=r;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(pm.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${i} or define customTags array`)}if(Array.isArray(t))for(let i of t)s=s.concat(i);else typeof t=="function"&&(s=t(s.slice()));return n&&(s=s.concat(is.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?hm[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(hm).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return i.includes(a)||i.push(a),i},[])}Lc.coreKnownTags=oE;Lc.getTags=aE});var Bc=_(km=>{"use strict";var Mc=J(),lE=Un(),cE=qn(),uE=es(),go=Sm(),dE=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Dc=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?go.getTags(e,"compat"):e?go.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?go.coreKnownTags:{},this.tags=go.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,Mc.MAP,{value:lE.map}),Object.defineProperty(this,Mc.SCALAR,{value:uE.string}),Object.defineProperty(this,Mc.SEQ,{value:cE.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?dE:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};km.Schema=Dc});var Em=_(xm=>{"use strict";var fE=J(),jc=Gr(),os=Hr();function pE(t,e){let n=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let l=t.directives.toString(t);l?(n.push(l),r=!0):t.directives.docStart&&(r=!0)}r&&n.push("---");let s=jc.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=i(t.commentBefore);n.unshift(os.indentComment(l,""))}let o=!1,a=null;if(t.contents){if(fE.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let f=i(t.contents.commentBefore);n.push(os.indentComment(f,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>o=!0,c=jc.stringify(t.contents,s,()=>a=null,l);a&&(c+=os.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(jc.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let l=i(t.comment);l.includes(`
78
- `)?(n.push("..."),n.push(os.indentComment(l,""))):n.push(`... ${l}`)}else n.push("...");else{let l=t.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&n[n.length-1]!==""&&n.push(""),n.push(os.indentComment(i(l),"")))}return n.join(`
77
+ ${i.comment}`:r.comment}r=s}t.items[n]=so.isPair(r)?r:new vc.Pair(r)}}else e("Expected a sequence for this tag");return t}function Gh(t,e,n){let{replacer:r}=n,s=new R0.YAMLSeq(t);s.tag="tag:yaml.org,2002:pairs";let i=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof r=="function"&&(o=r.call(e,String(i++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;s.items.push(vc.createPair(a,l,n))}return s}var I0={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Vh,createNode:Gh};io.createPairs=Gh;io.pairs=I0;io.resolvePairs=Vh});var xc=_(kc=>{"use strict";var Xh=J(),Sc=Pt(),rs=$t(),N0=Lt(),Qh=oo(),sn=class t extends N0.YAMLSeq{constructor(){super(),this.add=rs.YAMLMap.prototype.add.bind(this),this.delete=rs.YAMLMap.prototype.delete.bind(this),this.get=rs.YAMLMap.prototype.get.bind(this),this.has=rs.YAMLMap.prototype.has.bind(this),this.set=rs.YAMLMap.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let r=new Map;n?.onCreate&&n.onCreate(r);for(let s of this.items){let i,o;if(Xh.isPair(s)?(i=Sc.toJS(s.key,"",n),o=Sc.toJS(s.value,i,n)):i=Sc.toJS(s,"",n),r.has(i))throw new Error("Ordered maps must not include duplicate keys");r.set(i,o)}return r}static from(e,n,r){let s=Qh.createPairs(e,n,r),i=new this;return i.items=s.items,i}};sn.tag="tag:yaml.org,2002:omap";var $0={collection:"seq",identify:t=>t instanceof Map,nodeClass:sn,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=Qh.resolvePairs(t,e),r=[];for(let{key:s}of n.items)Xh.isScalar(s)&&(r.includes(s.value)?e(`Ordered maps must not include duplicate keys: ${s.value}`):r.push(s.value));return Object.assign(new sn,n)},createNode:(t,e,n)=>sn.from(t,e,n)};kc.YAMLOMap=sn;kc.omap=$0});var rm=_(Ec=>{"use strict";var Zh=re();function em({value:t,source:e},n){return e&&(t?tm:nm).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var tm={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Zh.Scalar(!0),stringify:em},nm={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Zh.Scalar(!1),stringify:em};Ec.falseTag=nm;Ec.trueTag=tm});var sm=_(ao=>{"use strict";var L0=re(),Ac=Jn(),M0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ac.stringifyNumber},D0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Ac.stringifyNumber(t)}},B0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new L0.Scalar(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let r=t.substring(n+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:Ac.stringifyNumber};ao.float=B0;ao.floatExp=D0;ao.floatNaN=M0});var om=_(is=>{"use strict";var im=Jn(),ss=t=>typeof t=="bigint"||Number.isInteger(t);function lo(t,e,n,{intAsBigInt:r}){let s=t[0];if((s==="-"||s==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let o=BigInt(t);return s==="-"?BigInt(-1)*o:o}let i=parseInt(t,n);return s==="-"?-1*i:i}function Tc(t,e,n){let{value:r}=t;if(ss(r)){let s=r.toString(e);return r<0?"-"+n+s.substr(1):n+s}return im.stringifyNumber(t)}var j0={identify:ss,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>lo(t,2,2,n),stringify:t=>Tc(t,2,"0b")},F0={identify:ss,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>lo(t,1,8,n),stringify:t=>Tc(t,8,"0")},U0={identify:ss,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>lo(t,0,10,n),stringify:im.stringifyNumber},q0={identify:ss,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>lo(t,2,16,n),stringify:t=>Tc(t,16,"0x")};is.int=U0;is.intBin=j0;is.intHex=q0;is.intOct=F0});var Pc=_(Oc=>{"use strict";var fo=J(),co=It(),uo=$t(),on=class t extends uo.YAMLMap{constructor(e){super(e),this.tag=t.tag}add(e){let n;fo.isPair(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new co.Pair(e.key,null):n=new co.Pair(e,null),uo.findPair(this.items,n.key)||this.items.push(n)}get(e,n){let r=uo.findPair(this.items,e);return!n&&fo.isPair(r)?fo.isScalar(r.key)?r.key.value:r.key:r}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let r=uo.findPair(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new co.Pair(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,r);throw new Error("Set items must all have null values")}static from(e,n,r){let{replacer:s}=r,i=new this(e);if(n&&Symbol.iterator in Object(n))for(let o of n)typeof s=="function"&&(o=s.call(n,o,o)),i.items.push(co.createPair(o,null,r));return i}};on.tag="tag:yaml.org,2002:set";var J0={collection:"map",identify:t=>t instanceof Set,nodeClass:on,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>on.from(t,e,n),resolve(t,e){if(fo.isMap(t)){if(t.hasAllNullValues(!0))return Object.assign(new on,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};Oc.YAMLSet=on;Oc.set=J0});var _c=_(po=>{"use strict";var W0=Jn();function Cc(t,e){let n=t[0],r=n==="-"||n==="+"?t.substring(1):t,s=o=>e?BigInt(o):Number(o),i=r.replace(/_/g,"").split(":").reduce((o,a)=>o*s(60)+s(a),s(0));return n==="-"?s(-1)*i:i}function am(t){let{value:e}=t,n=o=>o;if(typeof e=="bigint")n=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return W0.stringifyNumber(t);let r="";e<0&&(r="-",e*=n(-1));let s=n(60),i=[e%s];return e<60?i.unshift(0):(e=(e-i[0])/s,i.unshift(e%s),e>=60&&(e=(e-i[0])/s,i.unshift(e))),r+i.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var K0={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>Cc(t,n),stringify:am},H0={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Cc(t,!1),stringify:am},lm={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(lm.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,s,i,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(n,r-1,s,i||0,o||0,a||0,l),f=e[8];if(f&&f!=="Z"){let d=Cc(f,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};po.floatTime=H0;po.intTime=K0;po.timestamp=lm});var dm=_(um=>{"use strict";var z0=Un(),Y0=Zi(),V0=qn(),G0=ts(),X0=wc(),cm=rm(),Rc=sm(),ho=om(),Q0=Ki(),Z0=xc(),eE=oo(),tE=Pc(),Ic=_c(),nE=[z0.map,V0.seq,G0.string,Y0.nullTag,cm.trueTag,cm.falseTag,ho.intBin,ho.intOct,ho.int,ho.intHex,Rc.floatNaN,Rc.floatExp,Rc.float,X0.binary,Q0.merge,Z0.omap,eE.pairs,tE.set,Ic.intTime,Ic.floatTime,Ic.timestamp];um.schema=nE});var Sm=_(Lc=>{"use strict";var mm=Un(),rE=Zi(),gm=qn(),sE=ts(),iE=dc(),Nc=pc(),$c=mc(),oE=Wh(),aE=zh(),ym=wc(),os=Ki(),bm=xc(),wm=oo(),fm=dm(),vm=Pc(),mo=_c(),pm=new Map([["core",oE.schema],["failsafe",[mm.map,gm.seq,sE.string]],["json",aE.schema],["yaml11",fm.schema],["yaml-1.1",fm.schema]]),hm={binary:ym.binary,bool:iE.boolTag,float:Nc.float,floatExp:Nc.floatExp,floatNaN:Nc.floatNaN,floatTime:mo.floatTime,int:$c.int,intHex:$c.intHex,intOct:$c.intOct,intTime:mo.intTime,map:mm.map,merge:os.merge,null:rE.nullTag,omap:bm.omap,pairs:wm.pairs,seq:gm.seq,set:vm.set,timestamp:mo.timestamp},lE={"tag:yaml.org,2002:binary":ym.binary,"tag:yaml.org,2002:merge":os.merge,"tag:yaml.org,2002:omap":bm.omap,"tag:yaml.org,2002:pairs":wm.pairs,"tag:yaml.org,2002:set":vm.set,"tag:yaml.org,2002:timestamp":mo.timestamp};function cE(t,e,n){let r=pm.get(e);if(r&&!t)return n&&!r.includes(os.merge)?r.concat(os.merge):r.slice();let s=r;if(!s)if(Array.isArray(t))s=[];else{let i=Array.from(pm.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${i} or define customTags array`)}if(Array.isArray(t))for(let i of t)s=s.concat(i);else typeof t=="function"&&(s=t(s.slice()));return n&&(s=s.concat(os.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?hm[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(hm).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return i.includes(a)||i.push(a),i},[])}Lc.coreKnownTags=lE;Lc.getTags=cE});var Bc=_(km=>{"use strict";var Mc=J(),uE=Un(),dE=qn(),fE=ts(),go=Sm(),pE=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,Dc=class t{constructor({compat:e,customTags:n,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?go.getTags(e,"compat"):e?go.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?go.coreKnownTags:{},this.tags=go.getTags(n,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,Mc.MAP,{value:uE.map}),Object.defineProperty(this,Mc.SCALAR,{value:fE.string}),Object.defineProperty(this,Mc.SEQ,{value:dE.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?pE:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};km.Schema=Dc});var Em=_(xm=>{"use strict";var hE=J(),jc=Xr(),as=zr();function mE(t,e){let n=[],r=e.directives===!0;if(e.directives!==!1&&t.directives){let l=t.directives.toString(t);l?(n.push(l),r=!0):t.directives.docStart&&(r=!0)}r&&n.push("---");let s=jc.createStringifyContext(t,e),{commentString:i}=s.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=i(t.commentBefore);n.unshift(as.indentComment(l,""))}let o=!1,a=null;if(t.contents){if(hE.isNode(t.contents)){if(t.contents.spaceBefore&&r&&n.push(""),t.contents.commentBefore){let f=i(t.contents.commentBefore);n.push(as.indentComment(f,""))}s.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>o=!0,c=jc.stringify(t.contents,s,()=>a=null,l);a&&(c+=as.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(jc.stringify(t.contents,s));if(t.directives?.docEnd)if(t.comment){let l=i(t.comment);l.includes(`
78
+ `)?(n.push("..."),n.push(as.indentComment(l,""))):n.push(`... ${l}`)}else n.push("...");else{let l=t.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&n[n.length-1]!==""&&n.push(""),n.push(as.indentComment(i(l),"")))}return n.join(`
79
79
  `)+`
80
- `}xm.stringifyDocument=pE});var as=_(Am=>{"use strict";var hE=Wr(),Wn=Mi(),Ne=J(),mE=It(),gE=Pt(),yE=Bc(),bE=Em(),Fc=Ii(),wE=Wl(),vE=Kr(),Uc=Jl(),qc=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Ne.NODE_TYPE,{value:Ne.DOC});let s=null;typeof n=="function"||Array.isArray(n)?s=n:r===void 0&&n&&(r=n,n=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=i;let{version:o}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new Uc.Directives({version:o}),this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,s,r)}clone(){let e=Object.create(t.prototype,{[Ne.NODE_TYPE]:{value:Ne.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=Ne.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Kn(this.contents)&&this.contents.add(e)}addIn(e,n){Kn(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=Fc.anchorNames(this);e.anchor=!n||r.has(n)?Fc.findNewAnchor(n||"a",r):n}return new hE.Alias(e.anchor)}createNode(e,n,r){let s;if(typeof n=="function")e=n.call({"":e},"",e),s=n;else if(Array.isArray(n)){let g=O=>typeof O=="number"||O instanceof String||O instanceof Number,E=n.filter(g).map(String);E.length>0&&(n=n.concat(E)),s=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:f}=r??{},{onAnchor:d,setAnchors:u,sourceObjects:p}=Fc.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:s,schema:this.schema,sourceObjects:p},h=vE.createNode(e,f,m);return a&&Ne.isCollection(h)&&(h.flow=!0),u(),h}createPair(e,n,r={}){let s=this.createNode(e,null,r),i=this.createNode(n,null,r);return new mE.Pair(s,i)}delete(e){return Kn(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Wn.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Kn(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return Ne.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return Wn.isEmptyPath(e)?!n&&Ne.isScalar(this.contents)?this.contents.value:this.contents:Ne.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return Ne.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Wn.isEmptyPath(e)?this.contents!==void 0:Ne.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Wn.collectionFromPath(this.schema,[e],n):Kn(this.contents)&&this.contents.set(e,n)}setIn(e,n){Wn.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=Wn.collectionFromPath(this.schema,Array.from(e),n):Kn(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Uc.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Uc.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let s=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${s}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(r)this.schema=new yE.Schema(Object.assign(r,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:n,mapAsMap:r,maxAliasCount:s,onAnchor:i,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},l=gE.toJS(this.contents,n??"",a);if(typeof i=="function")for(let{count:c,res:f}of a.anchors.values())i(f,c);return typeof o=="function"?wE.applyReviver(o,{"":l},"",l):l}toJSON(e,n){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:n})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let n=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return bE.stringifyDocument(this,e)}};function Kn(t){if(Ne.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}Am.Document=qc});var us=_(cs=>{"use strict";var ls=class extends Error{constructor(e,n,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=n}},Jc=class extends ls{constructor(e,n,r){super("YAMLParseError",e,n,r)}},Wc=class extends ls{constructor(e,n,r){super("YAMLWarning",e,n,r)}},SE=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:r,col:s}=n.linePos[0];n.message+=` at line ${r}, column ${s}`;let i=s-1,o=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(i>=60&&o.length>80){let a=Math.min(i-39,o.length-79);o="\u2026"+o.substring(a),i-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),r>1&&/^ *$/.test(o.substring(0,i))){let a=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
80
+ `}xm.stringifyDocument=mE});var ls=_(Am=>{"use strict";var gE=Kr(),Wn=Mi(),Ne=J(),yE=It(),bE=Pt(),wE=Bc(),vE=Em(),Fc=Ii(),SE=Wl(),kE=Hr(),Uc=Jl(),qc=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Ne.NODE_TYPE,{value:Ne.DOC});let s=null;typeof n=="function"||Array.isArray(n)?s=n:r===void 0&&n&&(r=n,n=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=i;let{version:o}=i;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new Uc.Directives({version:o}),this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,s,r)}clone(){let e=Object.create(t.prototype,{[Ne.NODE_TYPE]:{value:Ne.DOC}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=Ne.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Kn(this.contents)&&this.contents.add(e)}addIn(e,n){Kn(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=Fc.anchorNames(this);e.anchor=!n||r.has(n)?Fc.findNewAnchor(n||"a",r):n}return new gE.Alias(e.anchor)}createNode(e,n,r){let s;if(typeof n=="function")e=n.call({"":e},"",e),s=n;else if(Array.isArray(n)){let g=O=>typeof O=="number"||O instanceof String||O instanceof Number,x=n.filter(g).map(String);x.length>0&&(n=n.concat(x)),s=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:f}=r??{},{onAnchor:d,setAnchors:u,sourceObjects:p}=Fc.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:s,schema:this.schema,sourceObjects:p},h=kE.createNode(e,f,m);return a&&Ne.isCollection(h)&&(h.flow=!0),u(),h}createPair(e,n,r={}){let s=this.createNode(e,null,r),i=this.createNode(n,null,r);return new yE.Pair(s,i)}delete(e){return Kn(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Wn.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Kn(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return Ne.isCollection(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return Wn.isEmptyPath(e)?!n&&Ne.isScalar(this.contents)?this.contents.value:this.contents:Ne.isCollection(this.contents)?this.contents.getIn(e,n):void 0}has(e){return Ne.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Wn.isEmptyPath(e)?this.contents!==void 0:Ne.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Wn.collectionFromPath(this.schema,[e],n):Kn(this.contents)&&this.contents.set(e,n)}setIn(e,n){Wn.isEmptyPath(e)?this.contents=n:this.contents==null?this.contents=Wn.collectionFromPath(this.schema,Array.from(e),n):Kn(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Uc.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Uc.Directives({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let s=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${s}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(r)this.schema=new wE.Schema(Object.assign(r,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:n,mapAsMap:r,maxAliasCount:s,onAnchor:i,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},l=bE.toJS(this.contents,n??"",a);if(typeof i=="function")for(let{count:c,res:f}of a.anchors.values())i(f,c);return typeof o=="function"?SE.applyReviver(o,{"":l},"",l):l}toJSON(e,n){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:n})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let n=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return vE.stringifyDocument(this,e)}};function Kn(t){if(Ne.isCollection(t))return!0;throw new Error("Expected a YAML collection as document contents")}Am.Document=qc});var ds=_(us=>{"use strict";var cs=class extends Error{constructor(e,n,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=n}},Jc=class extends cs{constructor(e,n,r){super("YAMLParseError",e,n,r)}},Wc=class extends cs{constructor(e,n,r){super("YAMLWarning",e,n,r)}},xE=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:r,col:s}=n.linePos[0];n.message+=` at line ${r}, column ${s}`;let i=s-1,o=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(i>=60&&o.length>80){let a=Math.min(i-39,o.length-79);o="\u2026"+o.substring(a),i-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),r>1&&/^ *$/.test(o.substring(0,i))){let a=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
81
81
  `),o=a+o}if(/[^ ]/.test(o)){let a=1,l=n.linePos[1];l?.line===r&&l.col>s&&(a=Math.max(1,Math.min(l.col-s,80-i)));let c=" ".repeat(i)+"^".repeat(a);n.message+=`:
82
82
 
83
83
  ${o}
84
84
  ${c}
85
- `}};cs.YAMLError=ls;cs.YAMLParseError=Jc;cs.YAMLWarning=Wc;cs.prettifyError=SE});var ds=_(Tm=>{"use strict";function kE(t,{flow:e,indicator:n,next:r,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,d="",u="",p=!1,m=!1,h=null,g=null,E=null,O=null,C=null,x=null,R=null;for(let A of t)switch(m&&(A.type!=="space"&&A.type!=="newline"&&A.type!=="comma"&&i(A.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),h&&(c&&A.type!=="comment"&&A.type!=="newline"&&i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),A.type){case"space":!e&&(n!=="doc-start"||r?.type!=="flow-collection")&&A.source.includes(" ")&&(h=A),f=!0;break;case"comment":{f||i(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let U=A.source.substring(1)||" ";d?d+=u+U:d=U,u="",c=!1;break}case"newline":c?d?d+=A.source:(!x||n!=="seq-item-ind")&&(l=!0):u+=A.source,c=!0,p=!0,(g||E)&&(O=A),f=!0;break;case"anchor":g&&i(A,"MULTIPLE_ANCHORS","A node can have at most one anchor"),A.source.endsWith(":")&&i(A.offset+A.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=A,R??(R=A.offset),c=!1,f=!1,m=!0;break;case"tag":{E&&i(A,"MULTIPLE_TAGS","A node can have at most one tag"),E=A,R??(R=A.offset),c=!1,f=!1,m=!0;break}case n:(g||E)&&i(A,"BAD_PROP_ORDER",`Anchors and tags must be after the ${A.source} indicator`),x&&i(A,"UNEXPECTED_TOKEN",`Unexpected ${A.source} in ${e??"collection"}`),x=A,c=n==="seq-item-ind"||n==="explicit-key-ind",f=!1;break;case"comma":if(e){C&&i(A,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),C=A,c=!1,f=!1;break}default:i(A,"UNEXPECTED_TOKEN",`Unexpected ${A.type} token`),c=!1,f=!1}let I=t[t.length-1],L=I?I.offset+I.source.length:s;return m&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&i(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(c&&h.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:C,found:x,spaceBefore:l,comment:d,hasNewline:p,anchor:g,tag:E,newlineAfterProp:O,end:L,start:R??L}}Tm.resolveProps=kE});var yo=_(Om=>{"use strict";function Kc(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
86
- `))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(Kc(e.key)||Kc(e.value))return!0}return!1;default:return!0}}Om.containsNewline=Kc});var Hc=_(Pm=>{"use strict";var xE=yo();function EE(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&xE.containsNewline(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Pm.flowIndentCheck=EE});var zc=_(_m=>{"use strict";var Cm=J();function AE(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||Cm.isScalar(i)&&Cm.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,n))}_m.mapIncludes=AE});var Mm=_(Lm=>{"use strict";var Rm=It(),TE=$t(),Im=ds(),OE=yo(),Nm=Hc(),PE=zc(),$m="All mapping items must start at the same column";function CE({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??TE.YAMLMap,a=new o(n.schema);n.atRoot&&(n.atRoot=!1);let l=r.offset,c=null;for(let f of r.items){let{start:d,key:u,sep:p,value:m}=f,h=Im.resolveProps(d,{indicator:"explicit-key-ind",next:u??p?.[0],offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0}),g=!h.found;if(g){if(u&&(u.type==="block-seq"?s(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in u&&u.indent!==r.indent&&s(l,"BAD_INDENT",$m)),!h.anchor&&!h.tag&&!p){c=h.end,h.comment&&(a.comment?a.comment+=`
87
- `+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||OE.containsNewline(u))&&s(u??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&s(l,"BAD_INDENT",$m);n.atKey=!0;let E=h.end,O=u?t(n,u,h,s):e(n,E,d,null,h,s);n.schema.compat&&Nm.flowIndentCheck(r.indent,u,s),n.atKey=!1,PE.mapIncludes(n,a.items,O)&&s(E,"DUPLICATE_KEY","Map keys must be unique");let C=Im.resolveProps(p??[],{indicator:"map-value-ind",next:m,offset:O.range[2],onError:s,parentIndent:r.indent,startOnNewline:!u||u.type==="block-scalar"});if(l=C.end,C.found){g&&(m?.type==="block-map"&&!C.hasNewline&&s(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&h.start<C.found.offset-1024&&s(O.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let x=m?t(n,m,C,s):e(n,l,p,null,C,s);n.schema.compat&&Nm.flowIndentCheck(r.indent,m,s),l=x.range[2];let R=new Rm.Pair(O,x);n.options.keepSourceTokens&&(R.srcToken=f),a.items.push(R)}else{g&&s(O.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),C.comment&&(O.comment?O.comment+=`
88
- `+C.comment:O.comment=C.comment);let x=new Rm.Pair(O);n.options.keepSourceTokens&&(x.srcToken=f),a.items.push(x)}}return c&&c<l&&s(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,l,c??l],a}Lm.resolveBlockMap=CE});var Bm=_(Dm=>{"use strict";var _E=Lt(),RE=ds(),IE=Hc();function NE({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??_E.YAMLSeq,a=new o(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let l=r.offset,c=null;for(let{start:f,value:d}of r.items){let u=RE.resolveProps(f,{indicator:"seq-item-ind",next:d,offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||d)d?.type==="block-seq"?s(u.end,"BAD_INDENT","All sequence items must start at the same column"):s(l,"MISSING_CHAR","Sequence item without - indicator");else{c=u.end,u.comment&&(a.comment=u.comment);continue}let p=d?t(n,d,u,s):e(n,u.end,f,null,u,s);n.schema.compat&&IE.flowIndentCheck(r.indent,d,s),l=p.range[2],a.items.push(p)}return a.range=[r.offset,l,c??l],a}Dm.resolveBlockSeq=NE});var Hn=_(jm=>{"use strict";function $E(t,e,n,r){let s="";if(t){let i=!1,o="";for(let a of t){let{source:l,type:c}=a;switch(c){case"space":i=!0;break;case"comment":{n&&!i&&r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";s?s+=o+f:s=f,o="";break}case"newline":s&&(o+=l),i=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:s,offset:e}}jm.resolveEnd=$E});var Jm=_(qm=>{"use strict";var LE=J(),ME=It(),Fm=$t(),DE=Lt(),BE=Hn(),Um=ds(),jE=yo(),FE=zc(),Yc="Block collections are not allowed within flow collections",Vc=t=>t&&(t.type==="block-map"||t.type==="block-seq");function UE({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=i?.nodeClass??(o?Fm.YAMLMap:DE.YAMLSeq),c=new l(n.schema);c.flow=!0;let f=n.atRoot;f&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let d=r.offset+r.start.source.length;for(let g=0;g<r.items.length;++g){let E=r.items[g],{start:O,key:C,sep:x,value:R}=E,I=Um.resolveProps(O,{flow:a,indicator:"explicit-key-ind",next:C??x?.[0],offset:d,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!I.found){if(!I.anchor&&!I.tag&&!x&&!R){g===0&&I.comma?s(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<r.items.length-1&&s(I.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),I.comment&&(c.comment?c.comment+=`
89
- `+I.comment:c.comment=I.comment),d=I.end;continue}!o&&n.options.strict&&jE.containsNewline(C)&&s(C,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)I.comma&&s(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(I.comma||s(I.start,"MISSING_CHAR",`Missing , between ${a} items`),I.comment){let L="";e:for(let A of O)switch(A.type){case"comma":case"space":break;case"comment":L=A.source.substring(1);break e;default:break e}if(L){let A=c.items[c.items.length-1];LE.isPair(A)&&(A=A.value??A.key),A.comment?A.comment+=`
90
- `+L:A.comment=L,I.comment=I.comment.substring(L.length+1)}}if(!o&&!x&&!I.found){let L=R?t(n,R,I,s):e(n,I.end,x,null,I,s);c.items.push(L),d=L.range[2],Vc(R)&&s(L.range,"BLOCK_IN_FLOW",Yc)}else{n.atKey=!0;let L=I.end,A=C?t(n,C,I,s):e(n,L,O,null,I,s);Vc(C)&&s(A.range,"BLOCK_IN_FLOW",Yc),n.atKey=!1;let U=Um.resolveProps(x??[],{flow:a,indicator:"map-value-ind",next:R,offset:A.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(U.found){if(!o&&!I.found&&n.options.strict){if(x)for(let F of x){if(F===U.found)break;if(F.type==="newline"){s(F,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}I.start<U.found.offset-1024&&s(U.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else R&&("source"in R&&R.source?.[0]===":"?s(R,"MISSING_CHAR",`Missing space after : in ${a}`):s(U.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let Q=R?t(n,R,U,s):U.found?e(n,U.end,x,null,U,s):null;Q?Vc(R)&&s(Q.range,"BLOCK_IN_FLOW",Yc):U.comment&&(A.comment?A.comment+=`
91
- `+U.comment:A.comment=U.comment);let G=new ME.Pair(A,Q);if(n.options.keepSourceTokens&&(G.srcToken=E),o){let F=c;FE.mapIncludes(n,F.items,A)&&s(L,"DUPLICATE_KEY","Map keys must be unique"),F.items.push(G)}else{let F=new Fm.YAMLMap(n.schema);F.flow=!0,F.items.push(G);let me=(Q??A).range;F.range=[A.range[0],me[1],me[2]],c.items.push(F)}d=Q?Q.range[2]:U.end}}let u=o?"}":"]",[p,...m]=r.end,h=d;if(p?.source===u)h=p.offset+p.source.length;else{let g=a[0].toUpperCase()+a.substring(1),E=f?`${g} must end with a ${u}`:`${g} in block collection must be sufficiently indented and end with a ${u}`;s(d,f?"MISSING_CHAR":"BAD_INDENT",E),p&&p.source.length!==1&&m.unshift(p)}if(m.length>0){let g=BE.resolveEnd(m,h,n.options.strict,s);g.comment&&(c.comment?c.comment+=`
92
- `+g.comment:c.comment=g.comment),c.range=[r.offset,h,g.offset]}else c.range=[r.offset,h,h];return c}qm.resolveFlowCollection=UE});var Km=_(Wm=>{"use strict";var qE=J(),JE=ne(),WE=$t(),KE=Lt(),HE=Mm(),zE=Bm(),YE=Jm();function Gc(t,e,n,r,s,i){let o=n.type==="block-map"?HE.resolveBlockMap(t,e,n,r,i):n.type==="block-seq"?zE.resolveBlockSeq(t,e,n,r,i):YE.resolveFlowCollection(t,e,n,r,i),a=o.constructor;return s==="!"||s===a.tagName?(o.tag=a.tagName,o):(s&&(o.tag=s),o)}function VE(t,e,n,r,s){let i=r.tag,o=i?e.directives.tagName(i.source,u=>s(i,"TAG_RESOLVE_FAILED",u)):null;if(n.type==="block-seq"){let{anchor:u,newlineAfterProp:p}=r,m=u&&i?u.offset>i.offset?u:i:u??i;m&&(!p||p.offset<m.offset)&&s(m,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===WE.YAMLMap.tagName&&a==="map"||o===KE.YAMLSeq.tagName&&a==="seq")return Gc(t,e,n,s,o);let l=e.schema.tags.find(u=>u.tag===o&&u.collection===a);if(!l){let u=e.schema.knownTags[o];if(u?.collection===a)e.schema.tags.push(Object.assign({},u,{default:!1})),l=u;else return u?s(i,"BAD_COLLECTION_TYPE",`${u.tag} used for ${a} collection, but expects ${u.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Gc(t,e,n,s,o)}let c=Gc(t,e,n,s,o,l),f=l.resolve?.(c,u=>s(i,"TAG_RESOLVE_FAILED",u),e.options)??c,d=qE.isNode(f)?f:new JE.Scalar(f);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}Wm.composeCollection=VE});var Qc=_(Hm=>{"use strict";var Xc=ne();function GE(t,e,n){let r=e.offset,s=XE(e,t.options.strict,n);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?Xc.Scalar.BLOCK_FOLDED:Xc.Scalar.BLOCK_LITERAL,o=e.source?QE(e.source):[],a=o.length;for(let h=o.length-1;h>=0;--h){let g=o[h][1];if(g===""||g==="\r")a=h;else break}if(a===0){let h=s.chomp==="+"&&o.length>0?`
93
- `.repeat(Math.max(1,o.length-1)):"",g=r+s.length;return e.source&&(g+=e.source.length),{value:h,type:i,comment:s.comment,range:[r,g,g]}}let l=e.indent+s.indent,c=e.offset+s.length,f=0;for(let h=0;h<a;++h){let[g,E]=o[h];if(E===""||E==="\r")s.indent===0&&g.length>l&&(l=g.length);else{g.length<l&&n(c+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),s.indent===0&&(l=g.length),f=h,l===0&&!t.atRoot&&n(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=g.length+E.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>l&&(a=h+1);let d="",u="",p=!1;for(let h=0;h<f;++h)d+=o[h][0].slice(l)+`
94
- `;for(let h=f;h<a;++h){let[g,E]=o[h];c+=g.length+E.length+1;let O=E[E.length-1]==="\r";if(O&&(E=E.slice(0,-1)),E&&g.length<l){let x=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;n(c-E.length-(O?2:1),"BAD_INDENT",x),g=""}i===Xc.Scalar.BLOCK_LITERAL?(d+=u+g.slice(l)+E,u=`
95
- `):g.length>l||E[0]===" "?(u===" "?u=`
85
+ `}};us.YAMLError=cs;us.YAMLParseError=Jc;us.YAMLWarning=Wc;us.prettifyError=xE});var fs=_(Tm=>{"use strict";function EE(t,{flow:e,indicator:n,next:r,offset:s,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,d="",u="",p=!1,m=!1,h=null,g=null,x=null,O=null,C=null,E=null,R=null;for(let A of t)switch(m&&(A.type!=="space"&&A.type!=="newline"&&A.type!=="comma"&&i(A.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),h&&(c&&A.type!=="comment"&&A.type!=="newline"&&i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),A.type){case"space":!e&&(n!=="doc-start"||r?.type!=="flow-collection")&&A.source.includes(" ")&&(h=A),f=!0;break;case"comment":{f||i(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let F=A.source.substring(1)||" ";d?d+=u+F:d=F,u="",c=!1;break}case"newline":c?d?d+=A.source:(!E||n!=="seq-item-ind")&&(l=!0):u+=A.source,c=!0,p=!0,(g||x)&&(O=A),f=!0;break;case"anchor":g&&i(A,"MULTIPLE_ANCHORS","A node can have at most one anchor"),A.source.endsWith(":")&&i(A.offset+A.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=A,R??(R=A.offset),c=!1,f=!1,m=!0;break;case"tag":{x&&i(A,"MULTIPLE_TAGS","A node can have at most one tag"),x=A,R??(R=A.offset),c=!1,f=!1,m=!0;break}case n:(g||x)&&i(A,"BAD_PROP_ORDER",`Anchors and tags must be after the ${A.source} indicator`),E&&i(A,"UNEXPECTED_TOKEN",`Unexpected ${A.source} in ${e??"collection"}`),E=A,c=n==="seq-item-ind"||n==="explicit-key-ind",f=!1;break;case"comma":if(e){C&&i(A,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),C=A,c=!1,f=!1;break}default:i(A,"UNEXPECTED_TOKEN",`Unexpected ${A.type} token`),c=!1,f=!1}let I=t[t.length-1],L=I?I.offset+I.source.length:s;return m&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&i(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(c&&h.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&i(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:C,found:E,spaceBefore:l,comment:d,hasNewline:p,anchor:g,tag:x,newlineAfterProp:O,end:L,start:R??L}}Tm.resolveProps=EE});var yo=_(Om=>{"use strict";function Kc(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
86
+ `))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(Kc(e.key)||Kc(e.value))return!0}return!1;default:return!0}}Om.containsNewline=Kc});var Hc=_(Pm=>{"use strict";var AE=yo();function TE(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&AE.containsNewline(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Pm.flowIndentCheck=TE});var zc=_(_m=>{"use strict";var Cm=J();function OE(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||Cm.isScalar(i)&&Cm.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,n))}_m.mapIncludes=OE});var Mm=_(Lm=>{"use strict";var Rm=It(),PE=$t(),Im=fs(),CE=yo(),Nm=Hc(),_E=zc(),$m="All mapping items must start at the same column";function RE({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??PE.YAMLMap,a=new o(n.schema);n.atRoot&&(n.atRoot=!1);let l=r.offset,c=null;for(let f of r.items){let{start:d,key:u,sep:p,value:m}=f,h=Im.resolveProps(d,{indicator:"explicit-key-ind",next:u??p?.[0],offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0}),g=!h.found;if(g){if(u&&(u.type==="block-seq"?s(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in u&&u.indent!==r.indent&&s(l,"BAD_INDENT",$m)),!h.anchor&&!h.tag&&!p){c=h.end,h.comment&&(a.comment?a.comment+=`
87
+ `+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||CE.containsNewline(u))&&s(u??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&s(l,"BAD_INDENT",$m);n.atKey=!0;let x=h.end,O=u?t(n,u,h,s):e(n,x,d,null,h,s);n.schema.compat&&Nm.flowIndentCheck(r.indent,u,s),n.atKey=!1,_E.mapIncludes(n,a.items,O)&&s(x,"DUPLICATE_KEY","Map keys must be unique");let C=Im.resolveProps(p??[],{indicator:"map-value-ind",next:m,offset:O.range[2],onError:s,parentIndent:r.indent,startOnNewline:!u||u.type==="block-scalar"});if(l=C.end,C.found){g&&(m?.type==="block-map"&&!C.hasNewline&&s(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&h.start<C.found.offset-1024&&s(O.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let E=m?t(n,m,C,s):e(n,l,p,null,C,s);n.schema.compat&&Nm.flowIndentCheck(r.indent,m,s),l=E.range[2];let R=new Rm.Pair(O,E);n.options.keepSourceTokens&&(R.srcToken=f),a.items.push(R)}else{g&&s(O.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),C.comment&&(O.comment?O.comment+=`
88
+ `+C.comment:O.comment=C.comment);let E=new Rm.Pair(O);n.options.keepSourceTokens&&(E.srcToken=f),a.items.push(E)}}return c&&c<l&&s(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,l,c??l],a}Lm.resolveBlockMap=RE});var Bm=_(Dm=>{"use strict";var IE=Lt(),NE=fs(),$E=Hc();function LE({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=i?.nodeClass??IE.YAMLSeq,a=new o(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let l=r.offset,c=null;for(let{start:f,value:d}of r.items){let u=NE.resolveProps(f,{indicator:"seq-item-ind",next:d,offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||d)d?.type==="block-seq"?s(u.end,"BAD_INDENT","All sequence items must start at the same column"):s(l,"MISSING_CHAR","Sequence item without - indicator");else{c=u.end,u.comment&&(a.comment=u.comment);continue}let p=d?t(n,d,u,s):e(n,u.end,f,null,u,s);n.schema.compat&&$E.flowIndentCheck(r.indent,d,s),l=p.range[2],a.items.push(p)}return a.range=[r.offset,l,c??l],a}Dm.resolveBlockSeq=LE});var Hn=_(jm=>{"use strict";function ME(t,e,n,r){let s="";if(t){let i=!1,o="";for(let a of t){let{source:l,type:c}=a;switch(c){case"space":i=!0;break;case"comment":{n&&!i&&r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";s?s+=o+f:s=f,o="";break}case"newline":s&&(o+=l),i=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:s,offset:e}}jm.resolveEnd=ME});var Jm=_(qm=>{"use strict";var DE=J(),BE=It(),Fm=$t(),jE=Lt(),FE=Hn(),Um=fs(),UE=yo(),qE=zc(),Yc="Block collections are not allowed within flow collections",Vc=t=>t&&(t.type==="block-map"||t.type==="block-seq");function JE({composeNode:t,composeEmptyNode:e},n,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=i?.nodeClass??(o?Fm.YAMLMap:jE.YAMLSeq),c=new l(n.schema);c.flow=!0;let f=n.atRoot;f&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let d=r.offset+r.start.source.length;for(let g=0;g<r.items.length;++g){let x=r.items[g],{start:O,key:C,sep:E,value:R}=x,I=Um.resolveProps(O,{flow:a,indicator:"explicit-key-ind",next:C??E?.[0],offset:d,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!I.found){if(!I.anchor&&!I.tag&&!E&&!R){g===0&&I.comma?s(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<r.items.length-1&&s(I.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),I.comment&&(c.comment?c.comment+=`
89
+ `+I.comment:c.comment=I.comment),d=I.end;continue}!o&&n.options.strict&&UE.containsNewline(C)&&s(C,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)I.comma&&s(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(I.comma||s(I.start,"MISSING_CHAR",`Missing , between ${a} items`),I.comment){let L="";e:for(let A of O)switch(A.type){case"comma":case"space":break;case"comment":L=A.source.substring(1);break e;default:break e}if(L){let A=c.items[c.items.length-1];DE.isPair(A)&&(A=A.value??A.key),A.comment?A.comment+=`
90
+ `+L:A.comment=L,I.comment=I.comment.substring(L.length+1)}}if(!o&&!E&&!I.found){let L=R?t(n,R,I,s):e(n,I.end,E,null,I,s);c.items.push(L),d=L.range[2],Vc(R)&&s(L.range,"BLOCK_IN_FLOW",Yc)}else{n.atKey=!0;let L=I.end,A=C?t(n,C,I,s):e(n,L,O,null,I,s);Vc(C)&&s(A.range,"BLOCK_IN_FLOW",Yc),n.atKey=!1;let F=Um.resolveProps(E??[],{flow:a,indicator:"map-value-ind",next:R,offset:A.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(F.found){if(!o&&!I.found&&n.options.strict){if(E)for(let U of E){if(U===F.found)break;if(U.type==="newline"){s(U,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}I.start<F.found.offset-1024&&s(F.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else R&&("source"in R&&R.source?.[0]===":"?s(R,"MISSING_CHAR",`Missing space after : in ${a}`):s(F.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let Z=R?t(n,R,F,s):F.found?e(n,F.end,E,null,F,s):null;Z?Vc(R)&&s(Z.range,"BLOCK_IN_FLOW",Yc):F.comment&&(A.comment?A.comment+=`
91
+ `+F.comment:A.comment=F.comment);let te=new BE.Pair(A,Z);if(n.options.keepSourceTokens&&(te.srcToken=x),o){let U=c;qE.mapIncludes(n,U.items,A)&&s(L,"DUPLICATE_KEY","Map keys must be unique"),U.items.push(te)}else{let U=new Fm.YAMLMap(n.schema);U.flow=!0,U.items.push(te);let ne=(Z??A).range;U.range=[A.range[0],ne[1],ne[2]],c.items.push(U)}d=Z?Z.range[2]:F.end}}let u=o?"}":"]",[p,...m]=r.end,h=d;if(p?.source===u)h=p.offset+p.source.length;else{let g=a[0].toUpperCase()+a.substring(1),x=f?`${g} must end with a ${u}`:`${g} in block collection must be sufficiently indented and end with a ${u}`;s(d,f?"MISSING_CHAR":"BAD_INDENT",x),p&&p.source.length!==1&&m.unshift(p)}if(m.length>0){let g=FE.resolveEnd(m,h,n.options.strict,s);g.comment&&(c.comment?c.comment+=`
92
+ `+g.comment:c.comment=g.comment),c.range=[r.offset,h,g.offset]}else c.range=[r.offset,h,h];return c}qm.resolveFlowCollection=JE});var Km=_(Wm=>{"use strict";var WE=J(),KE=re(),HE=$t(),zE=Lt(),YE=Mm(),VE=Bm(),GE=Jm();function Gc(t,e,n,r,s,i){let o=n.type==="block-map"?YE.resolveBlockMap(t,e,n,r,i):n.type==="block-seq"?VE.resolveBlockSeq(t,e,n,r,i):GE.resolveFlowCollection(t,e,n,r,i),a=o.constructor;return s==="!"||s===a.tagName?(o.tag=a.tagName,o):(s&&(o.tag=s),o)}function XE(t,e,n,r,s){let i=r.tag,o=i?e.directives.tagName(i.source,u=>s(i,"TAG_RESOLVE_FAILED",u)):null;if(n.type==="block-seq"){let{anchor:u,newlineAfterProp:p}=r,m=u&&i?u.offset>i.offset?u:i:u??i;m&&(!p||p.offset<m.offset)&&s(m,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===HE.YAMLMap.tagName&&a==="map"||o===zE.YAMLSeq.tagName&&a==="seq")return Gc(t,e,n,s,o);let l=e.schema.tags.find(u=>u.tag===o&&u.collection===a);if(!l){let u=e.schema.knownTags[o];if(u?.collection===a)e.schema.tags.push(Object.assign({},u,{default:!1})),l=u;else return u?s(i,"BAD_COLLECTION_TYPE",`${u.tag} used for ${a} collection, but expects ${u.collection??"scalar"}`,!0):s(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Gc(t,e,n,s,o)}let c=Gc(t,e,n,s,o,l),f=l.resolve?.(c,u=>s(i,"TAG_RESOLVE_FAILED",u),e.options)??c,d=WE.isNode(f)?f:new KE.Scalar(f);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}Wm.composeCollection=XE});var Qc=_(Hm=>{"use strict";var Xc=re();function QE(t,e,n){let r=e.offset,s=ZE(e,t.options.strict,n);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?Xc.Scalar.BLOCK_FOLDED:Xc.Scalar.BLOCK_LITERAL,o=e.source?eA(e.source):[],a=o.length;for(let h=o.length-1;h>=0;--h){let g=o[h][1];if(g===""||g==="\r")a=h;else break}if(a===0){let h=s.chomp==="+"&&o.length>0?`
93
+ `.repeat(Math.max(1,o.length-1)):"",g=r+s.length;return e.source&&(g+=e.source.length),{value:h,type:i,comment:s.comment,range:[r,g,g]}}let l=e.indent+s.indent,c=e.offset+s.length,f=0;for(let h=0;h<a;++h){let[g,x]=o[h];if(x===""||x==="\r")s.indent===0&&g.length>l&&(l=g.length);else{g.length<l&&n(c+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),s.indent===0&&(l=g.length),f=h,l===0&&!t.atRoot&&n(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=g.length+x.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>l&&(a=h+1);let d="",u="",p=!1;for(let h=0;h<f;++h)d+=o[h][0].slice(l)+`
94
+ `;for(let h=f;h<a;++h){let[g,x]=o[h];c+=g.length+x.length+1;let O=x[x.length-1]==="\r";if(O&&(x=x.slice(0,-1)),x&&g.length<l){let E=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;n(c-x.length-(O?2:1),"BAD_INDENT",E),g=""}i===Xc.Scalar.BLOCK_LITERAL?(d+=u+g.slice(l)+x,u=`
95
+ `):g.length>l||x[0]===" "?(u===" "?u=`
96
96
  `:!p&&u===`
97
97
  `&&(u=`
98
98
 
99
- `),d+=u+g.slice(l)+E,u=`
100
- `,p=!0):E===""?u===`
99
+ `),d+=u+g.slice(l)+x,u=`
100
+ `,p=!0):x===""?u===`
101
101
  `?d+=`
102
102
  `:u=`
103
- `:(d+=u+E,u=" ",p=!1)}switch(s.chomp){case"-":break;case"+":for(let h=a;h<o.length;++h)d+=`
103
+ `:(d+=u+x,u=" ",p=!1)}switch(s.chomp){case"-":break;case"+":for(let h=a;h<o.length;++h)d+=`
104
104
  `+o[h][0].slice(l);d[d.length-1]!==`
105
105
  `&&(d+=`
106
106
  `);break;default:d+=`
107
- `}let m=r+s.length+e.source.length;return{value:d,type:i,comment:s.comment,range:[r,m,m]}}function XE({offset:t,props:e},n,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:s}=e[0],i=s[0],o=0,a="",l=-1;for(let u=1;u<s.length;++u){let p=s[u];if(!a&&(p==="-"||p==="+"))a=p;else{let m=Number(p);!o&&m?o=m:l===-1&&(l=t+u)}}l!==-1&&r(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let c=!1,f="",d=s.length;for(let u=1;u<e.length;++u){let p=e[u];switch(p.type){case"space":c=!0;case"newline":d+=p.source.length;break;case"comment":n&&!c&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=p.source.length,f=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let m=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",m);let h=p.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:i,indent:o,chomp:a,comment:f,length:d}}function QE(t){let e=t.split(/\n( *)/),n=e[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let o=1;o<e.length;o+=2)i.push([e[o],e[o+1]]);return i}Hm.resolveBlockScalar=GE});var eu=_(Ym=>{"use strict";var Zc=ne(),ZE=Hn();function eA(t,e,n){let{offset:r,type:s,source:i,end:o}=t,a,l,c=(u,p,m)=>n(r+u,p,m);switch(s){case"scalar":a=Zc.Scalar.PLAIN,l=tA(i,c);break;case"single-quoted-scalar":a=Zc.Scalar.QUOTE_SINGLE,l=nA(i,c);break;case"double-quoted-scalar":a=Zc.Scalar.QUOTE_DOUBLE,l=rA(i,c);break;default:return n(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[r,r+i.length,r+i.length]}}let f=r+i.length,d=ZE.resolveEnd(o,f,e,n);return{value:l,type:a,comment:d.comment,range:[r,f,d.offset]}}function tA(t,e){let n="";switch(t[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${t[0]}`;break}case"@":case"`":{n=`reserved character ${t[0]}`;break}}return n&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),zm(t)}function nA(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),zm(t.slice(1,-1)).replace(/''/g,"'")}function zm(t){let e,n;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
107
+ `}let m=r+s.length+e.source.length;return{value:d,type:i,comment:s.comment,range:[r,m,m]}}function ZE({offset:t,props:e},n,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:s}=e[0],i=s[0],o=0,a="",l=-1;for(let u=1;u<s.length;++u){let p=s[u];if(!a&&(p==="-"||p==="+"))a=p;else{let m=Number(p);!o&&m?o=m:l===-1&&(l=t+u)}}l!==-1&&r(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${s}`);let c=!1,f="",d=s.length;for(let u=1;u<e.length;++u){let p=e[u];switch(p.type){case"space":c=!0;case"newline":d+=p.source.length;break;case"comment":n&&!c&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=p.source.length,f=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let m=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",m);let h=p.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:i,indent:o,chomp:a,comment:f,length:d}}function eA(t){let e=t.split(/\n( *)/),n=e[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let o=1;o<e.length;o+=2)i.push([e[o],e[o+1]]);return i}Hm.resolveBlockScalar=QE});var eu=_(Ym=>{"use strict";var Zc=re(),tA=Hn();function nA(t,e,n){let{offset:r,type:s,source:i,end:o}=t,a,l,c=(u,p,m)=>n(r+u,p,m);switch(s){case"scalar":a=Zc.Scalar.PLAIN,l=rA(i,c);break;case"single-quoted-scalar":a=Zc.Scalar.QUOTE_SINGLE,l=sA(i,c);break;case"double-quoted-scalar":a=Zc.Scalar.QUOTE_DOUBLE,l=iA(i,c);break;default:return n(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${s}`),{value:"",type:null,comment:"",range:[r,r+i.length,r+i.length]}}let f=r+i.length,d=tA.resolveEnd(o,f,e,n);return{value:l,type:a,comment:d.comment,range:[r,f,d.offset]}}function rA(t,e){let n="";switch(t[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${t[0]}`;break}case"@":case"`":{n=`reserved character ${t[0]}`;break}}return n&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),zm(t)}function sA(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),zm(t.slice(1,-1)).replace(/''/g,"'")}function zm(t){let e,n;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
108
108
  `,"sy"),n=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
109
109
  `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=e.exec(t);if(!r)return t;let s=r[1],i=" ",o=e.lastIndex;for(n.lastIndex=o;r=n.exec(t);)r[1]===""?i===`
110
110
  `?s+=i:i=`
111
- `:(s+=i+r[1],i=" "),o=n.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,r=a.exec(t),s+i+(r?.[1]??"")}function rA(t,e){let n="";for(let r=1;r<t.length-1;++r){let s=t[r];if(!(s==="\r"&&t[r+1]===`
111
+ `:(s+=i+r[1],i=" "),o=n.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,r=a.exec(t),s+i+(r?.[1]??"")}function iA(t,e){let n="";for(let r=1;r<t.length-1;++r){let s=t[r];if(!(s==="\r"&&t[r+1]===`
112
112
  `))if(s===`
113
- `){let{fold:i,offset:o}=sA(t,r);n+=i,r=o}else if(s==="\\"){let i=t[++r],o=iA[i];if(o)n+=o;else if(i===`
113
+ `){let{fold:i,offset:o}=oA(t,r);n+=i,r=o}else if(s==="\\"){let i=t[++r],o=aA[i];if(o)n+=o;else if(i===`
114
114
  `)for(i=t[r+1];i===" "||i===" ";)i=t[++r+1];else if(i==="\r"&&t[r+1]===`
115
- `)for(i=t[++r+1];i===" "||i===" ";)i=t[++r+1];else if(i==="x"||i==="u"||i==="U"){let a={x:2,u:4,U:8}[i];n+=oA(t,r+1,a,e),r+=a}else{let a=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(s===" "||s===" "){let i=r,o=t[r+1];for(;o===" "||o===" ";)o=t[++r+1];o!==`
115
+ `)for(i=t[++r+1];i===" "||i===" ";)i=t[++r+1];else if(i==="x"||i==="u"||i==="U"){let a={x:2,u:4,U:8}[i];n+=lA(t,r+1,a,e),r+=a}else{let a=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(s===" "||s===" "){let i=r,o=t[r+1];for(;o===" "||o===" ";)o=t[++r+1];o!==`
116
116
  `&&!(o==="\r"&&t[r+2]===`
117
- `)&&(n+=r>i?t.slice(i,r+1):s)}else n+=s}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function sA(t,e){let n="",r=t[e+1];for(;(r===" "||r===" "||r===`
117
+ `)&&(n+=r>i?t.slice(i,r+1):s)}else n+=s}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function oA(t,e){let n="",r=t[e+1];for(;(r===" "||r===" "||r===`
118
118
  `||r==="\r")&&!(r==="\r"&&t[e+2]!==`
119
119
  `);)r===`
120
120
  `&&(n+=`
121
- `),e+=1,r=t[e+1];return n||(n=" "),{fold:n,offset:e}}var iA={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
122
- `,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function oA(t,e,n,r){let s=t.substr(e,n),o=s.length===n&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;if(isNaN(o)){let a=t.substr(e-2,n+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}Ym.resolveFlowScalar=eA});var Xm=_(Gm=>{"use strict";var an=J(),Vm=ne(),aA=Qc(),lA=eu();function cA(t,e,n,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?aA.resolveBlockScalar(t,e,r):lA.resolveFlowScalar(e,t.options.strict,r),l=n?t.directives.tagName(n.source,d=>r(n,"TAG_RESOLVE_FAILED",d)):null,c;t.options.stringKeys&&t.atKey?c=t.schema[an.SCALAR]:l?c=uA(t.schema,s,l,n,r):e.type==="scalar"?c=dA(t,s,e,r):c=t.schema[an.SCALAR];let f;try{let d=c.resolve(s,u=>r(n??e,"TAG_RESOLVE_FAILED",u),t.options);f=an.isScalar(d)?d:new Vm.Scalar(d)}catch(d){let u=d instanceof Error?d.message:String(d);r(n??e,"TAG_RESOLVE_FAILED",u),f=new Vm.Scalar(s)}return f.range=a,f.source=s,i&&(f.type=i),l&&(f.tag=l),c.format&&(f.format=c.format),o&&(f.comment=o),f}function uA(t,e,n,r,s){if(n==="!")return t[an.SCALAR];let i=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(e))return a;let o=t.knownTags[n];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(s(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),t[an.SCALAR])}function dA({atKey:t,directives:e,schema:n},r,s,i){let o=n.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(r))||n[an.SCALAR];if(n.compat){let a=n.compat.find(l=>l.default&&l.test?.test(r))??n[an.SCALAR];if(o.tag!==a.tag){let l=e.tagString(o.tag),c=e.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;i(s,"TAG_RESOLVE_FAILED",f,!0)}}return o}Gm.composeScalar=cA});var Zm=_(Qm=>{"use strict";function fA(t,e,n){if(e){n??(n=e.length);for(let r=n-1;r>=0;--r){let s=e[r];switch(s.type){case"space":case"comment":case"newline":t-=s.source.length;continue}for(s=e[++r];s?.type==="space";)t+=s.source.length,s=e[++r];break}}return t}Qm.emptyScalarPosition=fA});var ng=_(nu=>{"use strict";var pA=Wr(),hA=J(),mA=Km(),eg=Xm(),gA=Hn(),yA=Zm(),bA={composeNode:tg,composeEmptyNode:tu};function tg(t,e,n,r){let s=t.atKey,{spaceBefore:i,comment:o,anchor:a,tag:l}=n,c,f=!0;switch(e.type){case"alias":c=wA(t,e,r),(a||l)&&r(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=eg.composeScalar(t,e,l,r),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=mA.composeCollection(bA,t,e,n,r),a&&(c.anchor=a.source.substring(1));break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",d),c=tu(t,e.offset,void 0,null,n,r),f=!1}}return a&&c.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&t.options.stringKeys&&(!hA.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&r(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),i&&(c.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?c.comment=o:c.commentBefore=o),t.options.keepSourceTokens&&f&&(c.srcToken=e),c}function tu(t,e,n,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:yA.emptyScalarPosition(e,n,r),indent:-1,source:""},d=eg.composeScalar(t,f,a,c);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(d.spaceBefore=!0),i&&(d.comment=i,d.range[2]=l),d}function wA({options:t},{offset:e,source:n,end:r},s){let i=new pA.Alias(n.substring(1));i.source===""&&s(e,"BAD_ALIAS","Alias cannot be an empty string"),i.source.endsWith(":")&&s(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+n.length,a=gA.resolveEnd(r,o,t.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}nu.composeEmptyNode=tu;nu.composeNode=tg});var ig=_(sg=>{"use strict";var vA=as(),rg=ng(),SA=Hn(),kA=ds();function xA(t,e,{offset:n,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},t),l=new vA.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=kA.resolveProps(r,{indicator:"doc-start",next:s??i?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(l.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=s?rg.composeNode(c,s,f,o):rg.composeEmptyNode(c,f.end,r,null,f,o);let d=l.contents.range[2],u=SA.resolveEnd(i,d,!1,o);return u.comment&&(l.comment=u.comment),l.range=[n,d,u.offset],l}sg.composeDoc=xA});var su=_(lg=>{"use strict";var EA=vi("process"),AA=Jl(),TA=as(),fs=us(),og=J(),OA=ig(),PA=Hn();function ps(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:n}=t;return[e,e+(typeof n=="string"?n.length:1)]}function ag(t){let e="",n=!1,r=!1;for(let s=0;s<t.length;++s){let i=t[s];switch(i[0]){case"#":e+=(e===""?"":r?`
121
+ `),e+=1,r=t[e+1];return n||(n=" "),{fold:n,offset:e}}var aA={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
122
+ `,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function lA(t,e,n,r){let s=t.substr(e,n),o=s.length===n&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;if(isNaN(o)){let a=t.substr(e-2,n+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}Ym.resolveFlowScalar=nA});var Xm=_(Gm=>{"use strict";var an=J(),Vm=re(),cA=Qc(),uA=eu();function dA(t,e,n,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?cA.resolveBlockScalar(t,e,r):uA.resolveFlowScalar(e,t.options.strict,r),l=n?t.directives.tagName(n.source,d=>r(n,"TAG_RESOLVE_FAILED",d)):null,c;t.options.stringKeys&&t.atKey?c=t.schema[an.SCALAR]:l?c=fA(t.schema,s,l,n,r):e.type==="scalar"?c=pA(t,s,e,r):c=t.schema[an.SCALAR];let f;try{let d=c.resolve(s,u=>r(n??e,"TAG_RESOLVE_FAILED",u),t.options);f=an.isScalar(d)?d:new Vm.Scalar(d)}catch(d){let u=d instanceof Error?d.message:String(d);r(n??e,"TAG_RESOLVE_FAILED",u),f=new Vm.Scalar(s)}return f.range=a,f.source=s,i&&(f.type=i),l&&(f.tag=l),c.format&&(f.format=c.format),o&&(f.comment=o),f}function fA(t,e,n,r,s){if(n==="!")return t[an.SCALAR];let i=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(e))return a;let o=t.knownTags[n];return o&&!o.collection?(t.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(s(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),t[an.SCALAR])}function pA({atKey:t,directives:e,schema:n},r,s,i){let o=n.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(r))||n[an.SCALAR];if(n.compat){let a=n.compat.find(l=>l.default&&l.test?.test(r))??n[an.SCALAR];if(o.tag!==a.tag){let l=e.tagString(o.tag),c=e.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;i(s,"TAG_RESOLVE_FAILED",f,!0)}}return o}Gm.composeScalar=dA});var Zm=_(Qm=>{"use strict";function hA(t,e,n){if(e){n??(n=e.length);for(let r=n-1;r>=0;--r){let s=e[r];switch(s.type){case"space":case"comment":case"newline":t-=s.source.length;continue}for(s=e[++r];s?.type==="space";)t+=s.source.length,s=e[++r];break}}return t}Qm.emptyScalarPosition=hA});var ng=_(nu=>{"use strict";var mA=Kr(),gA=J(),yA=Km(),eg=Xm(),bA=Hn(),wA=Zm(),vA={composeNode:tg,composeEmptyNode:tu};function tg(t,e,n,r){let s=t.atKey,{spaceBefore:i,comment:o,anchor:a,tag:l}=n,c,f=!0;switch(e.type){case"alias":c=SA(t,e,r),(a||l)&&r(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=eg.composeScalar(t,e,l,r),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=yA.composeCollection(vA,t,e,n,r),a&&(c.anchor=a.source.substring(1));break;default:{let d=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",d),c=tu(t,e.offset,void 0,null,n,r),f=!1}}return a&&c.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&t.options.stringKeys&&(!gA.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&r(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),i&&(c.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?c.comment=o:c.commentBefore=o),t.options.keepSourceTokens&&f&&(c.srcToken=e),c}function tu(t,e,n,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:wA.emptyScalarPosition(e,n,r),indent:-1,source:""},d=eg.composeScalar(t,f,a,c);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),s&&(d.spaceBefore=!0),i&&(d.comment=i,d.range[2]=l),d}function SA({options:t},{offset:e,source:n,end:r},s){let i=new mA.Alias(n.substring(1));i.source===""&&s(e,"BAD_ALIAS","Alias cannot be an empty string"),i.source.endsWith(":")&&s(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+n.length,a=bA.resolveEnd(r,o,t.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}nu.composeEmptyNode=tu;nu.composeNode=tg});var ig=_(sg=>{"use strict";var kA=ls(),rg=ng(),xA=Hn(),EA=fs();function AA(t,e,{offset:n,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},t),l=new kA.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=EA.resolveProps(r,{indicator:"doc-start",next:s??i?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(l.directives.docStart=!0,s&&(s.type==="block-map"||s.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=s?rg.composeNode(c,s,f,o):rg.composeEmptyNode(c,f.end,r,null,f,o);let d=l.contents.range[2],u=xA.resolveEnd(i,d,!1,o);return u.comment&&(l.comment=u.comment),l.range=[n,d,u.offset],l}sg.composeDoc=AA});var su=_(lg=>{"use strict";var TA=vi("process"),OA=Jl(),PA=ls(),ps=ds(),og=J(),CA=ig(),_A=Hn();function hs(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:n}=t;return[e,e+(typeof n=="string"?n.length:1)]}function ag(t){let e="",n=!1,r=!1;for(let s=0;s<t.length;++s){let i=t[s];switch(i[0]){case"#":e+=(e===""?"":r?`
123
123
 
124
124
  `:`
125
- `)+(i.substring(1)||" "),n=!0,r=!1;break;case"%":t[s+1]?.[0]!=="#"&&(s+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:e,afterEmptyLine:r}}var ru=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,s,i)=>{let o=ps(n);i?this.warnings.push(new fs.YAMLWarning(o,r,s)):this.errors.push(new fs.YAMLParseError(o,r,s))},this.directives=new AA.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:s}=ag(this.prelude);if(r){let i=e.contents;if(n)e.comment=e.comment?`${e.comment}
125
+ `)+(i.substring(1)||" "),n=!0,r=!1;break;case"%":t[s+1]?.[0]!=="#"&&(s+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:e,afterEmptyLine:r}}var ru=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,s,i)=>{let o=hs(n);i?this.warnings.push(new ps.YAMLWarning(o,r,s)):this.errors.push(new ps.YAMLParseError(o,r,s))},this.directives=new OA.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:s}=ag(this.prelude);if(r){let i=e.contents;if(n)e.comment=e.comment?`${e.comment}
126
126
  ${r}`:r;else if(s||e.directives.docStart||!i)e.commentBefore=r;else if(og.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];og.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${r}
127
127
  ${a}`:r}else{let o=i.commentBefore;i.commentBefore=o?`${r}
128
- ${o}`:r}}n?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:ag(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,n=!1,r=-1){for(let s of e)yield*this.next(s);yield*this.end(n,r)}*next(e){switch(EA.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,r,s)=>{let i=ps(e);i[0]+=n,this.onError(i,"BAD_DIRECTIVE",r,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=OA.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let n=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new fs.YAMLParseError(ps(e),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new fs.YAMLParseError(ps(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=PA.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
129
- ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new fs.YAMLParseError(ps(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),s=new TA.Document(void 0,r);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),s.range=[0,n,n],this.decorate(s,!1),yield s}}};lg.Composer=ru});var dg=_(bo=>{"use strict";var CA=Qc(),_A=eu(),RA=us(),cg=Vr();function IA(t,e=!0,n){if(t){let r=(s,i,o)=>{let a=typeof s=="number"?s:Array.isArray(s)?s[0]:s.offset;if(n)n(a,i,o);else throw new RA.YAMLParseError([a,a+1],i,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return _A.resolveFlowScalar(t,e,r);case"block-scalar":return CA.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function NA(t,e){let{implicitKey:n=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=cg.stringifyString({type:o,value:t},{implicitKey:n,indent:r>0?" ".repeat(r):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),l=e.end??[{type:"newline",offset:-1,indent:r,source:`
128
+ ${o}`:r}}n?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:ag(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,n=!1,r=-1){for(let s of e)yield*this.next(s);yield*this.end(n,r)}*next(e){switch(TA.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(n,r,s)=>{let i=hs(e);i[0]+=n,this.onError(i,"BAD_DIRECTIVE",r,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=CA.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let n=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new ps.YAMLParseError(hs(e),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new ps.YAMLParseError(hs(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=_A.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
129
+ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new ps.YAMLParseError(hs(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),s=new PA.Document(void 0,r);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),s.range=[0,n,n],this.decorate(s,!1),yield s}}};lg.Composer=ru});var dg=_(bo=>{"use strict";var RA=Qc(),IA=eu(),NA=ds(),cg=Gr();function $A(t,e=!0,n){if(t){let r=(s,i,o)=>{let a=typeof s=="number"?s:Array.isArray(s)?s[0]:s.offset;if(n)n(a,i,o);else throw new NA.YAMLParseError([a,a+1],i,o)};switch(t.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return IA.resolveFlowScalar(t,e,r);case"block-scalar":return RA.resolveBlockScalar({options:{strict:e}},t,r)}}return null}function LA(t,e){let{implicitKey:n=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=cg.stringifyString({type:o,value:t},{implicitKey:n,indent:r>0?" ".repeat(r):"",inFlow:s,options:{blockQuote:!0,lineWidth:-1}}),l=e.end??[{type:"newline",offset:-1,indent:r,source:`
130
130
  `}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
131
131
  `),f=a.substring(0,c),d=a.substring(c+1)+`
132
132
  `,u=[{type:"block-scalar-header",offset:i,indent:r,source:f}];return ug(u,l)||u.push({type:"newline",offset:-1,indent:r,source:`
133
- `}),{type:"block-scalar",offset:i,indent:r,props:u,source:d}}case'"':return{type:"double-quoted-scalar",offset:i,indent:r,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:i,indent:r,source:a,end:l};default:return{type:"scalar",offset:i,indent:r,source:a,end:l}}}function $A(t,e,n={}){let{afterKey:r=!1,implicitKey:s=!1,inFlow:i=!1,type:o}=n,a="indent"in t?t.indent:null;if(r&&typeof a=="number"&&(a+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=t.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=cg.stringifyString({type:o,value:e},{implicitKey:s||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":LA(t,l);break;case'"':iu(t,l,"double-quoted-scalar");break;case"'":iu(t,l,"single-quoted-scalar");break;default:iu(t,l,"scalar")}}function LA(t,e){let n=e.indexOf(`
133
+ `}),{type:"block-scalar",offset:i,indent:r,props:u,source:d}}case'"':return{type:"double-quoted-scalar",offset:i,indent:r,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:i,indent:r,source:a,end:l};default:return{type:"scalar",offset:i,indent:r,source:a,end:l}}}function MA(t,e,n={}){let{afterKey:r=!1,implicitKey:s=!1,inFlow:i=!1,type:o}=n,a="indent"in t?t.indent:null;if(r&&typeof a=="number"&&(a+=2),!o)switch(t.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=t.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=cg.stringifyString({type:o,value:e},{implicitKey:s||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":DA(t,l);break;case'"':iu(t,l,"double-quoted-scalar");break;case"'":iu(t,l,"single-quoted-scalar");break;default:iu(t,l,"scalar")}}function DA(t,e){let n=e.indexOf(`
134
134
  `),r=e.substring(0,n),s=e.substring(n+1)+`
135
135
  `;if(t.type==="block-scalar"){let i=t.props[0];if(i.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i.source=r,t.source=s}else{let{offset:i}=t,o="indent"in t?t.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:r}];ug(a,"end"in t?t.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
136
136
  `});for(let l of Object.keys(t))l!=="type"&&l!=="offset"&&delete t[l];Object.assign(t,{type:"block-scalar",indent:o,props:a,source:s})}}function ug(t,e){if(e)for(let n of e)switch(n.type){case"space":case"comment":t.push(n);break;case"newline":return t.push(n),!0}return!1}function iu(t,e,n){switch(t.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":t.type=n,t.source=e;break;case"block-scalar":{let r=t.props.slice(1),s=e.length;t.props[0].type==="block-scalar-header"&&(s-=t.props[0].source.length);for(let i of r)i.offset+=s;delete t.props,Object.assign(t,{type:n,source:e,end:r});break}case"block-map":case"block-seq":{let s={type:"newline",offset:t.offset+e.length,indent:t.indent,source:`
137
- `};delete t.items,Object.assign(t,{type:n,source:e,end:[s]});break}default:{let r="indent"in t?t.indent:-1,s="end"in t&&Array.isArray(t.end)?t.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(t))i!=="type"&&i!=="offset"&&delete t[i];Object.assign(t,{type:n,indent:r,source:e,end:s})}}}bo.createScalarToken=NA;bo.resolveAsScalar=IA;bo.setScalarValue=$A});var pg=_(fg=>{"use strict";var MA=t=>"type"in t?vo(t):wo(t);function vo(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=vo(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=wo(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=wo(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=wo(t);if(t.end)for(let n of t.end)e+=n.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let n of t.end)e+=n.source;return e}}}function wo({start:t,key:e,sep:n,value:r}){let s="";for(let i of t)s+=i.source;if(e&&(s+=vo(e)),n)for(let i of n)s+=i.source;return r&&(s+=vo(r)),s}fg.stringify=MA});var yg=_(gg=>{"use strict";var ou=Symbol("break visit"),DA=Symbol("skip children"),hg=Symbol("remove item");function ln(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),mg(Object.freeze([]),t,e)}ln.BREAK=ou;ln.SKIP=DA;ln.REMOVE=hg;ln.itemAtPath=(t,e)=>{let n=t;for(let[r,s]of e){let i=n?.[r];if(i&&"items"in i)n=i.items[s];else return}return n};ln.parentCollection=(t,e)=>{let n=ln.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],s=n?.[r];if(s&&"items"in s)return s;throw new Error("Parent collection not found")};function mg(t,e,n){let r=n(e,t);if(typeof r=="symbol")return r;for(let s of["key","value"]){let i=e[s];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=mg(Object.freeze(t.concat([[s,o]])),i.items[o],n);if(typeof a=="number")o=a-1;else{if(a===ou)return ou;a===hg&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&s==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}gg.visit=ln});var So=_(ve=>{"use strict";var au=dg(),BA=pg(),jA=yg(),lu="\uFEFF",cu="",uu="",du="",FA=t=>!!t&&"items"in t,UA=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function qA(t){switch(t){case lu:return"<BOM>";case cu:return"<DOC>";case uu:return"<FLOW_END>";case du:return"<SCALAR>";default:return JSON.stringify(t)}}function JA(t){switch(t){case lu:return"byte-order-mark";case cu:return"doc-mode";case uu:return"flow-error-end";case du:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
137
+ `};delete t.items,Object.assign(t,{type:n,source:e,end:[s]});break}default:{let r="indent"in t?t.indent:-1,s="end"in t&&Array.isArray(t.end)?t.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(t))i!=="type"&&i!=="offset"&&delete t[i];Object.assign(t,{type:n,indent:r,source:e,end:s})}}}bo.createScalarToken=LA;bo.resolveAsScalar=$A;bo.setScalarValue=MA});var pg=_(fg=>{"use strict";var BA=t=>"type"in t?vo(t):wo(t);function vo(t){switch(t.type){case"block-scalar":{let e="";for(let n of t.props)e+=vo(n);return e+t.source}case"block-map":case"block-seq":{let e="";for(let n of t.items)e+=wo(n);return e}case"flow-collection":{let e=t.start.source;for(let n of t.items)e+=wo(n);for(let n of t.end)e+=n.source;return e}case"document":{let e=wo(t);if(t.end)for(let n of t.end)e+=n.source;return e}default:{let e=t.source;if("end"in t&&t.end)for(let n of t.end)e+=n.source;return e}}}function wo({start:t,key:e,sep:n,value:r}){let s="";for(let i of t)s+=i.source;if(e&&(s+=vo(e)),n)for(let i of n)s+=i.source;return r&&(s+=vo(r)),s}fg.stringify=BA});var yg=_(gg=>{"use strict";var ou=Symbol("break visit"),jA=Symbol("skip children"),hg=Symbol("remove item");function ln(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),mg(Object.freeze([]),t,e)}ln.BREAK=ou;ln.SKIP=jA;ln.REMOVE=hg;ln.itemAtPath=(t,e)=>{let n=t;for(let[r,s]of e){let i=n?.[r];if(i&&"items"in i)n=i.items[s];else return}return n};ln.parentCollection=(t,e)=>{let n=ln.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],s=n?.[r];if(s&&"items"in s)return s;throw new Error("Parent collection not found")};function mg(t,e,n){let r=n(e,t);if(typeof r=="symbol")return r;for(let s of["key","value"]){let i=e[s];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=mg(Object.freeze(t.concat([[s,o]])),i.items[o],n);if(typeof a=="number")o=a-1;else{if(a===ou)return ou;a===hg&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&s==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}gg.visit=ln});var So=_(ve=>{"use strict";var au=dg(),FA=pg(),UA=yg(),lu="\uFEFF",cu="",uu="",du="",qA=t=>!!t&&"items"in t,JA=t=>!!t&&(t.type==="scalar"||t.type==="single-quoted-scalar"||t.type==="double-quoted-scalar"||t.type==="block-scalar");function WA(t){switch(t){case lu:return"<BOM>";case cu:return"<DOC>";case uu:return"<FLOW_END>";case du:return"<SCALAR>";default:return JSON.stringify(t)}}function KA(t){switch(t){case lu:return"byte-order-mark";case cu:return"doc-mode";case uu:return"flow-error-end";case du:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
138
138
  `:case`\r
139
- `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}ve.createScalarToken=au.createScalarToken;ve.resolveAsScalar=au.resolveAsScalar;ve.setScalarValue=au.setScalarValue;ve.stringify=BA.stringify;ve.visit=jA.visit;ve.BOM=lu;ve.DOCUMENT=cu;ve.FLOW_END=uu;ve.SCALAR=du;ve.isCollection=FA;ve.isScalar=UA;ve.prettyToken=qA;ve.tokenType=JA});var hu=_(wg=>{"use strict";var hs=So();function He(t){switch(t){case void 0:case" ":case`
140
- `:case"\r":case" ":return!0;default:return!1}}var bg=new Set("0123456789ABCDEFabcdef"),WA=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ko=new Set(",[]{}"),KA=new Set(` ,[]{}
141
- \r `),fu=t=>!t||KA.has(t),pu=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let r=this.next??"stream";for(;r&&(n||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
139
+ `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}ve.createScalarToken=au.createScalarToken;ve.resolveAsScalar=au.resolveAsScalar;ve.setScalarValue=au.setScalarValue;ve.stringify=FA.stringify;ve.visit=UA.visit;ve.BOM=lu;ve.DOCUMENT=cu;ve.FLOW_END=uu;ve.SCALAR=du;ve.isCollection=qA;ve.isScalar=JA;ve.prettyToken=WA;ve.tokenType=KA});var hu=_(wg=>{"use strict";var ms=So();function He(t){switch(t){case void 0:case" ":case`
140
+ `:case"\r":case" ":return!0;default:return!1}}var bg=new Set("0123456789ABCDEFabcdef"),HA=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ko=new Set(",[]{}"),zA=new Set(` ,[]{}
141
+ \r `),fu=t=>!t||zA.has(t),pu=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let r=this.next??"stream";for(;r&&(n||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
142
142
  `?!0:n==="\r"?this.buffer[e+1]===`
143
143
  `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let n=this.buffer[e];if(this.indentNext>0){let r=0;for(;n===" ";)n=this.buffer[++r+e];if(n==="\r"){let s=this.buffer[r+e+1];if(s===`
144
144
  `||!s&&!this.atEnd)return e+r+1}return n===`
145
145
  `||r>=this.indentNext||!n&&!this.atEnd?e+r:-1}if(n==="-"||n==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&He(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
146
- `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===hs.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,r=e.indexOf("#");for(;r!==-1;){let i=e[r-1];if(i===" "||i===" "){n=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let i=e[n-1];if(i===" "||i===" ")n-=1;else break}let s=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-s),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield hs.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&He(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,n==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!He(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&He(n)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(e[n]){case"#":yield*this.pushCount(e.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(fu),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,n,r=-1;do e=yield*this.pushNewline(),e>0?(n=yield*this.pushSpaces(!1),this.indentValue=r=n):n=0,n+=yield*this.pushSpaces(!0);while(e+n>0);let s=this.getLine();if(s===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&s[0]!=="#"||r===0&&(s.startsWith("---")||s.startsWith("..."))&&He(s[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield hs.FLOW_END,yield*this.parseLineStart();let i=0;for(;s[i]===",";)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),s[i]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-i),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(fu),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||He(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let i=0;for(;this.buffer[n-1-i]==="\\";)i+=1;if(i%2===0)break;n=this.buffer.indexOf('"',n+1)}let r=this.buffer.substring(0,n),s=r.indexOf(`
146
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===ms.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,r=e.indexOf("#");for(;r!==-1;){let i=e[r-1];if(i===" "||i===" "){n=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let i=e[n-1];if(i===" "||i===" ")n-=1;else break}let s=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-s),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield ms.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&He(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,n==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!He(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&He(n)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(e[n]){case"#":yield*this.pushCount(e.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(fu),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,n,r=-1;do e=yield*this.pushNewline(),e>0?(n=yield*this.pushSpaces(!1),this.indentValue=r=n):n=0,n+=yield*this.pushSpaces(!0);while(e+n>0);let s=this.getLine();if(s===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&s[0]!=="#"||r===0&&(s.startsWith("---")||s.startsWith("..."))&&He(s[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(s[0]==="]"||s[0]==="}")))return this.flowLevel=0,yield ms.FLOW_END,yield*this.parseLineStart();let i=0;for(;s[i]===",";)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),s[i]){case void 0:return"flow";case"#":return yield*this.pushCount(s.length-i),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(fu),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||He(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let i=0;for(;this.buffer[n-1-i]==="\\";)i+=1;if(i%2===0)break;n=this.buffer.indexOf('"',n+1)}let r=this.buffer.substring(0,n),s=r.indexOf(`
147
147
  `,this.pos);if(s!==-1){for(;s!==-1;){let i=this.continueScalar(s+1);if(i===-1)break;s=r.indexOf(`
148
148
  `,i)}s!==-1&&(n=s-(r[s-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>He(n)||n==="#")}*parseBlockScalar(){let e=this.pos-1,n=0,r;e:for(let i=this.pos;r=this.buffer[i];++i)switch(r){case" ":n+=1;break;case`
149
149
  `:e=i,n=0;break;case"\r":{let o=this.buffer[i+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
150
150
  `)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(n>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=n:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let i=this.continueScalar(e+1);if(i===-1)break;e=this.buffer.indexOf(`
151
151
  `,i)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let s=e+1;for(r=this.buffer[s];r===" ";)r=this.buffer[++s];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
152
152
  `;)r=this.buffer[++s];e=s-1}else if(!this.blockScalarKeep)do{let i=e-1,o=this.buffer[i];o==="\r"&&(o=this.buffer[--i]);let a=i;for(;o===" ";)o=this.buffer[--i];if(o===`
153
- `&&i>=this.pos&&i+1+n>a)e=i;else break}while(!0);return yield hs.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,n=this.pos-1,r=this.pos-1,s;for(;s=this.buffer[++r];)if(s===":"){let i=this.buffer[r+1];if(He(i)||e&&ko.has(i))break;n=r}else if(He(s)){let i=this.buffer[r+1];if(s==="\r"&&(i===`
153
+ `&&i>=this.pos&&i+1+n>a)e=i;else break}while(!0);return yield ms.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,n=this.pos-1,r=this.pos-1,s;for(;s=this.buffer[++r];)if(s===":"){let i=this.buffer[r+1];if(He(i)||e&&ko.has(i))break;n=r}else if(He(s)){let i=this.buffer[r+1];if(s==="\r"&&(i===`
154
154
  `?(r+=1,s=`
155
155
  `,i=this.buffer[r+1]):n=r),i==="#"||e&&ko.has(i))break;if(s===`
156
- `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&ko.has(s))break;n=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield hs.SCALAR,yield*this.pushToIndex(n+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,n){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(n&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(fu))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,n=this.charAt(1);if(He(n)||e&&ko.has(n))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,n=this.buffer[e];for(;!He(n)&&n!==">";)n=this.buffer[++e];return yield*this.pushToIndex(n===">"?e+1:e,!1)}else{let e=this.pos+1,n=this.buffer[e];for(;n;)if(WA.has(n))n=this.buffer[++e];else if(n==="%"&&bg.has(this.buffer[e+1])&&bg.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
156
+ `){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(e&&ko.has(s))break;n=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield ms.SCALAR,yield*this.pushToIndex(n+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,n){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(n&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(fu))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,n=this.charAt(1);if(He(n)||e&&ko.has(n))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,n=this.buffer[e];for(;!He(n)&&n!==">";)n=this.buffer[++e];return yield*this.pushToIndex(n===">"?e+1:e,!1)}else{let e=this.pos+1,n=this.buffer[e];for(;n;)if(HA.has(n))n=this.buffer[++e];else if(n==="%"&&bg.has(this.buffer[e+1])&&bg.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
157
157
  `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
158
- `?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,r;do r=this.buffer[++n];while(r===" "||e&&r===" ");let s=n-this.pos;return s>0&&(yield this.buffer.substr(this.pos,s),this.pos=n),s}*pushUntil(e){let n=this.pos,r=this.buffer[n];for(;!e(r);)r=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};wg.Lexer=pu});var gu=_(vg=>{"use strict";var mu=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,r=this.lineStarts.length;for(;n<r;){let i=n+r>>1;this.lineStarts[i]<e?n=i+1:r=i}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let s=this.lineStarts[n-1];return{line:n,col:e-s+1}}}};vg.LineCounter=mu});var bu=_(Ag=>{"use strict";var HA=vi("process"),Sg=So(),zA=hu();function Mt(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function kg(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Eg(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function xo(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function zn(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function xg(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Mt(e.start,"explicit-key-ind")&&!Mt(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Eg(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}var yu=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new zA.Lexer,this.onNewLine=e}*parse(e,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,n))yield*this.next(r);n||(yield*this.end())}*next(e){if(this.source=e,HA.env.LOG_TOKENS&&console.log("|",Sg.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=Sg.tokenType(e);if(n)if(n==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=n,yield*this.step(),n){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let n=e??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{let r=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in r?r.indent:0:n.type==="flow-collection"&&r.type==="document"&&(n.indent=0),n.type==="flow-collection"&&xg(n),r.type){case"document":r.value=n;break;case"block-scalar":r.props.push(n);break;case"block-map":{let s=r.items[r.items.length-1];if(s.value){r.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(s.sep)s.value=n;else{Object.assign(s,{key:n,sep:[]}),this.onKeyLine=!s.explicitKey;return}break}case"block-seq":{let s=r.items[r.items.length-1];s.value?r.items.push({start:[],value:n}):s.value=n;break}case"flow-collection":{let s=r.items[r.items.length-1];!s||s.value?r.items.push({start:[],key:n,sep:[]}):s.sep?s.value=n:Object.assign(s,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let s=n.items[n.items.length-1];s&&!s.sep&&!s.value&&s.start.length>0&&kg(s.start)===-1&&(n.indent===0||s.start.every(i=>i.type!=="comment"||i.indent<n.indent))&&(r.type==="document"?r.end=s.start:r.items.push({start:s.start}),n.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{kg(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let n=xo(this.peek(2)),r=zn(n),s;e.end?(s=e.end,s.push(this.sourceToken),delete e.end):s=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(`
158
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,r;do r=this.buffer[++n];while(r===" "||e&&r===" ");let s=n-this.pos;return s>0&&(yield this.buffer.substr(this.pos,s),this.pos=n),s}*pushUntil(e){let n=this.pos,r=this.buffer[n];for(;!e(r);)r=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};wg.Lexer=pu});var gu=_(vg=>{"use strict";var mu=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,r=this.lineStarts.length;for(;n<r;){let i=n+r>>1;this.lineStarts[i]<e?n=i+1:r=i}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let s=this.lineStarts[n-1];return{line:n,col:e-s+1}}}};vg.LineCounter=mu});var bu=_(Ag=>{"use strict";var YA=vi("process"),Sg=So(),VA=hu();function Mt(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function kg(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Eg(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function xo(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function zn(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function xg(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!Mt(e.start,"explicit-key-ind")&&!Mt(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Eg(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}var yu=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new VA.Lexer,this.onNewLine=e}*parse(e,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,n))yield*this.next(r);n||(yield*this.end())}*next(e){if(this.source=e,YA.env.LOG_TOKENS&&console.log("|",Sg.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=Sg.tokenType(e);if(n)if(n==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=n,yield*this.step(),n){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let n=e??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{let r=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in r?r.indent:0:n.type==="flow-collection"&&r.type==="document"&&(n.indent=0),n.type==="flow-collection"&&xg(n),r.type){case"document":r.value=n;break;case"block-scalar":r.props.push(n);break;case"block-map":{let s=r.items[r.items.length-1];if(s.value){r.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(s.sep)s.value=n;else{Object.assign(s,{key:n,sep:[]}),this.onKeyLine=!s.explicitKey;return}break}case"block-seq":{let s=r.items[r.items.length-1];s.value?r.items.push({start:[],value:n}):s.value=n;break}case"flow-collection":{let s=r.items[r.items.length-1];!s||s.value?r.items.push({start:[],key:n,sep:[]}):s.sep?s.value=n:Object.assign(s,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let s=n.items[n.items.length-1];s&&!s.sep&&!s.value&&s.start.length>0&&kg(s.start)===-1&&(n.indent===0||s.start.every(i=>i.type!=="comment"||i.indent<n.indent))&&(r.type==="document"?r.end=s.start:r.items.push({start:s.start}),n.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{kg(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let n=xo(this.peek(2)),r=zn(n),s;e.end?(s=e.end,s.push(this.sourceToken),delete e.end):s=[this.sourceToken];let i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:s}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(`
159
159
  `)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
160
160
  `,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,n.start),s.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,s=r&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",i=[];if(s&&n.sep&&!n.value){let o=[];for(let a=0;a<n.sep.length;++a){let l=n.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(i=n.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":s||n.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):s||n.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(n.explicitKey)if(n.sep)if(n.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Mt(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Eg(n.key)&&!Mt(n.sep,"newline")){let o=zn(n.start),a=n.key,l=n.sep;l.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:l}]})}else i.length>0?n.sep=n.sep.concat(i,this.sourceToken):n.sep.push(this.sourceToken);else if(Mt(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let o=zn(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||s?e.items.push({start:i,key:null,sep:[this.sourceToken]}):Mt(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);s||n.value?(e.items.push({start:i,key:o,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(o):(Object.assign(n,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!n.explicitKey&&n.sep&&!Mt(n.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&e.items.push({start:i});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,n.start),s.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||Mt(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let n=e.items[e.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?e.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);!n||n.value?e.items.push({start:[],key:s,sep:[]}):n.sep?this.stack.push(s):Object.assign(n,{key:s,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let r=this.startBlockValue(e);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===e.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let s=xo(r),i=zn(s);xg(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let n=this.source.indexOf(`
161
161
  `)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
162
- `,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=xo(e),r=zn(n);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=xo(e),r=zn(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Ag.Parser=yu});var _g=_(gs=>{"use strict";var Tg=su(),YA=as(),ms=us(),VA=nc(),GA=J(),XA=gu(),Og=bu();function Pg(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new XA.LineCounter||null,prettyErrors:e}}function QA(t,e={}){let{lineCounter:n,prettyErrors:r}=Pg(e),s=new Og.Parser(n?.addNewLine),i=new Tg.Composer(e),o=Array.from(i.compose(s.parse(t)));if(r&&n)for(let a of o)a.errors.forEach(ms.prettifyError(t,n)),a.warnings.forEach(ms.prettifyError(t,n));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function Cg(t,e={}){let{lineCounter:n,prettyErrors:r}=Pg(e),s=new Og.Parser(n?.addNewLine),i=new Tg.Composer(e),o=null;for(let a of i.compose(s.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new ms.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(o.errors.forEach(ms.prettifyError(t,n)),o.warnings.forEach(ms.prettifyError(t,n))),o}function ZA(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let s=Cg(t,n);if(!s)return null;if(s.warnings.forEach(i=>VA.warn(s.options.logLevel,i)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:r},n))}function eT(t,e,n){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:n===void 0&&e&&(n=e),typeof n=="string"&&(n=n.length),typeof n=="number"){let s=Math.round(n);n=s<1?void 0:s>8?{indent:8}:{indent:s}}if(t===void 0){let{keepUndefined:s}=n??e??{};if(!s)return}return GA.isDocument(t)&&!r?t.toString(n):new YA.Document(t,r,n).toString(n)}gs.parse=ZA;gs.parseAllDocuments=QA;gs.parseDocument=Cg;gs.stringify=eT});var Ig=_(K=>{"use strict";var tT=su(),nT=as(),rT=Bc(),wu=us(),sT=Wr(),Dt=J(),iT=It(),oT=ne(),aT=$t(),lT=Lt(),cT=So(),uT=hu(),dT=gu(),fT=bu(),Eo=_g(),Rg=Fr();K.Composer=tT.Composer;K.Document=nT.Document;K.Schema=rT.Schema;K.YAMLError=wu.YAMLError;K.YAMLParseError=wu.YAMLParseError;K.YAMLWarning=wu.YAMLWarning;K.Alias=sT.Alias;K.isAlias=Dt.isAlias;K.isCollection=Dt.isCollection;K.isDocument=Dt.isDocument;K.isMap=Dt.isMap;K.isNode=Dt.isNode;K.isPair=Dt.isPair;K.isScalar=Dt.isScalar;K.isSeq=Dt.isSeq;K.Pair=iT.Pair;K.Scalar=oT.Scalar;K.YAMLMap=aT.YAMLMap;K.YAMLSeq=lT.YAMLSeq;K.CST=cT;K.Lexer=uT.Lexer;K.LineCounter=dT.LineCounter;K.Parser=fT.Parser;K.parse=Eo.parse;K.parseAllDocuments=Eo.parseAllDocuments;K.parseDocument=Eo.parseDocument;K.stringify=Eo.stringify;K.visit=Rg.visit;K.visitAsync=Rg.visitAsync});function hT(t){try{return JSON.parse(t.trim()),!0}catch{return!1}}function mT(t){let e=t.trim();if(!e.startsWith("<"))return!1;let n=e.match(pT);return n?jr(e,n[1])!==null:!1}function gT(t){let e=t.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let n=Ng.parse(e);return n!==null&&typeof n=="object"}catch{return!1}}function $g(t){return hT(t)||mT(t)||gT(t)}var Ng,pT,vu=S(()=>{Wp();Ng=vk(Ig(),1),pT=/<([a-zA-Z_][\w.-]*)/});function yT(t){if(!t?.trim())return[];let e=t.replace(/\r\n/g,`
162
+ `,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=xo(e),r=zn(n);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=xo(e),r=zn(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Ag.Parser=yu});var _g=_(ys=>{"use strict";var Tg=su(),GA=ls(),gs=ds(),XA=nc(),QA=J(),ZA=gu(),Og=bu();function Pg(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new ZA.LineCounter||null,prettyErrors:e}}function eT(t,e={}){let{lineCounter:n,prettyErrors:r}=Pg(e),s=new Og.Parser(n?.addNewLine),i=new Tg.Composer(e),o=Array.from(i.compose(s.parse(t)));if(r&&n)for(let a of o)a.errors.forEach(gs.prettifyError(t,n)),a.warnings.forEach(gs.prettifyError(t,n));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function Cg(t,e={}){let{lineCounter:n,prettyErrors:r}=Pg(e),s=new Og.Parser(n?.addNewLine),i=new Tg.Composer(e),o=null;for(let a of i.compose(s.parse(t),!0,t.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new gs.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(o.errors.forEach(gs.prettifyError(t,n)),o.warnings.forEach(gs.prettifyError(t,n))),o}function tT(t,e,n){let r;typeof e=="function"?r=e:n===void 0&&e&&typeof e=="object"&&(n=e);let s=Cg(t,n);if(!s)return null;if(s.warnings.forEach(i=>XA.warn(s.options.logLevel,i)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:r},n))}function nT(t,e,n){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:n===void 0&&e&&(n=e),typeof n=="string"&&(n=n.length),typeof n=="number"){let s=Math.round(n);n=s<1?void 0:s>8?{indent:8}:{indent:s}}if(t===void 0){let{keepUndefined:s}=n??e??{};if(!s)return}return QA.isDocument(t)&&!r?t.toString(n):new GA.Document(t,r,n).toString(n)}ys.parse=tT;ys.parseAllDocuments=eT;ys.parseDocument=Cg;ys.stringify=nT});var Ig=_(K=>{"use strict";var rT=su(),sT=ls(),iT=Bc(),wu=ds(),oT=Kr(),Dt=J(),aT=It(),lT=re(),cT=$t(),uT=Lt(),dT=So(),fT=hu(),pT=gu(),hT=bu(),Eo=_g(),Rg=Ur();K.Composer=rT.Composer;K.Document=sT.Document;K.Schema=iT.Schema;K.YAMLError=wu.YAMLError;K.YAMLParseError=wu.YAMLParseError;K.YAMLWarning=wu.YAMLWarning;K.Alias=oT.Alias;K.isAlias=Dt.isAlias;K.isCollection=Dt.isCollection;K.isDocument=Dt.isDocument;K.isMap=Dt.isMap;K.isNode=Dt.isNode;K.isPair=Dt.isPair;K.isScalar=Dt.isScalar;K.isSeq=Dt.isSeq;K.Pair=aT.Pair;K.Scalar=lT.Scalar;K.YAMLMap=cT.YAMLMap;K.YAMLSeq=uT.YAMLSeq;K.CST=dT;K.Lexer=fT.Lexer;K.LineCounter=pT.LineCounter;K.Parser=hT.Parser;K.parse=Eo.parse;K.parseAllDocuments=Eo.parseAllDocuments;K.parseDocument=Eo.parseDocument;K.stringify=Eo.stringify;K.visit=Rg.visit;K.visitAsync=Rg.visitAsync});function gT(t){try{return JSON.parse(t.trim()),!0}catch{return!1}}function yT(t){let e=t.trim();if(!e.startsWith("<"))return!1;let n=e.match(mT);return n?Fr(e,n[1])!==null:!1}function bT(t){let e=t.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let n=Ng.parse(e);return n!==null&&typeof n=="object"}catch{return!1}}function $g(t){return gT(t)||yT(t)||bT(t)}var Ng,mT,vu=S(()=>{Wp();Ng=kk(Ig(),1),mT=/<([a-zA-Z_][\w.-]*)/});function wT(t){if(!t?.trim())return[];let e=t.replace(/\r\n/g,`
163
163
  `),n=e.trim();if($g(n))return[{text:n,startLine:1,endLine:e.split(`
164
164
  `).length}];let r=e.split(`
165
165
  `),s=[],i=0,o=-1,a=0,l=()=>{if(o>=i){let c=r.slice(i,o+1).join(`
166
- `).trim();c&&s.push({text:c,startLine:i+1,endLine:o+1})}};for(let c=0;c<r.length;c++)r[c].trim()?(a>=2&&o>=i&&(l(),i=c),a=0,o=c):a++;return l(),s}function Ao(t){return yT(t).map(e=>e.text)}var Lg,Mg=S(()=>{vu();Lg=`
166
+ `).trim();c&&s.push({text:c,startLine:i+1,endLine:o+1})}};for(let c=0;c<r.length;c++)r[c].trim()?(a>=2&&o>=i&&(l(),i=c),a=0,o=c):a++;return l(),s}function Ao(t){return wT(t).map(e=>e.text)}var Lg,Mg=S(()=>{vu();Lg=`
167
167
 
168
168
 
169
- `});function To(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Dg=S(()=>{});var bT,wT,Su,Bg=S(()=>{bT=[["\xDF","ss"],["\u1E9E","Ss"],["\xE4","ae"],["\xC4","Ae"],["\xF6","oe"],["\xD6","Oe"],["\xFC","ue"],["\xDC","Ue"],["\xC0","A"],["\xC1","A"],["\xC2","A"],["\xC3","A"],["\xC4","Ae"],["\xC5","A"],["\xC6","AE"],["\xC7","C"],["\xC8","E"],["\xC9","E"],["\xCA","E"],["\xCB","E"],["\u018F","A"],["\xCC","I"],["\xCD","I"],["\xCE","I"],["\xCF","I"],["\xD0","D"],["\xD1","N"],["\xD2","O"],["\xD3","O"],["\xD4","O"],["\xD5","O"],["\xD6","Oe"],["\u014C","O"],["\u0150","O"],["\xD8","O"],["\u0152","OE"],["\xD9","U"],["\xDA","U"],["\xDB","U"],["\xDC","Ue"],["\u0170","U"],["\xDD","Y"],["\xDE","TH"],["\xDF","ss"],["\xE0","a"],["\xE1","a"],["\xE2","a"],["\xE3","a"],["\xE4","ae"],["\xE5","a"],["\xE6","ae"],["\xE7","c"],["\xE8","e"],["\xE9","e"],["\xEA","e"],["\xEB","e"],["\u0259","a"],["\xEC","i"],["\xED","i"],["\xEE","i"],["\xEF","i"],["\xF0","d"],["\xF1","n"],["\xF2","o"],["\xF3","o"],["\xF4","o"],["\xF5","o"],["\xF6","oe"],["\u014D","o"],["\u0151","o"],["\xF8","o"],["\u0153","oe"],["\xF9","u"],["\xFA","u"],["\xFB","u"],["\xFC","ue"],["\u0171","u"],["\xFD","y"],["\xFE","th"],["\xFF","y"],["\xE0","a"],["\xC0","A"],["\xE1","a"],["\xC1","A"],["\xE2","a"],["\xC2","A"],["\xE3","a"],["\xC3","A"],["\xE8","e"],["\xC8","E"],["\xE9","e"],["\xC9","E"],["\xEA","e"],["\xCA","E"],["\xEC","i"],["\xCC","I"],["\xED","i"],["\xCD","I"],["\xF2","o"],["\xD2","O"],["\xF3","o"],["\xD3","O"],["\xF4","o"],["\xD4","O"],["\xF5","o"],["\xD5","O"],["\xF9","u"],["\xD9","U"],["\xFA","u"],["\xDA","U"],["\xFD","y"],["\xDD","Y"],["\u0103","a"],["\u0102","A"],["\u0110","D"],["\u0111","d"],["\u0129","i"],["\u0128","I"],["\u0169","u"],["\u0168","U"],["\u01A1","o"],["\u01A0","O"],["\u01B0","u"],["\u01AF","U"],["\u1EA1","a"],["\u1EA0","A"],["\u1EA3","a"],["\u1EA2","A"],["\u1EA5","a"],["\u1EA4","A"],["\u1EA7","a"],["\u1EA6","A"],["\u1EA9","a"],["\u1EA8","A"],["\u1EAB","a"],["\u1EAA","A"],["\u1EAD","a"],["\u1EAC","A"],["\u1EAF","a"],["\u1EAE","A"],["\u1EB1","a"],["\u1EB0","A"],["\u1EB3","a"],["\u1EB2","A"],["\u1EB5","a"],["\u1EB4","A"],["\u1EB7","a"],["\u1EB6","A"],["\u1EB9","e"],["\u1EB8","E"],["\u1EBB","e"],["\u1EBA","E"],["\u1EBD","e"],["\u1EBC","E"],["\u1EBF","e"],["\u1EBE","E"],["\u1EC1","e"],["\u1EC0","E"],["\u1EC3","e"],["\u1EC2","E"],["\u1EC5","e"],["\u1EC4","E"],["\u1EC7","e"],["\u1EC6","E"],["\u1EC9","i"],["\u1EC8","I"],["\u1ECB","i"],["\u1ECA","I"],["\u1ECD","o"],["\u1ECC","O"],["\u1ECF","o"],["\u1ECE","O"],["\u1ED1","o"],["\u1ED0","O"],["\u1ED3","o"],["\u1ED2","O"],["\u1ED5","o"],["\u1ED4","O"],["\u1ED7","o"],["\u1ED6","O"],["\u1ED9","o"],["\u1ED8","O"],["\u1EDB","o"],["\u1EDA","O"],["\u1EDD","o"],["\u1EDC","O"],["\u1EDF","o"],["\u1EDE","O"],["\u1EE1","o"],["\u1EE0","O"],["\u1EE3","o"],["\u1EE2","O"],["\u1EE5","u"],["\u1EE4","U"],["\u1EE7","u"],["\u1EE6","U"],["\u1EE9","u"],["\u1EE8","U"],["\u1EEB","u"],["\u1EEA","U"],["\u1EED","u"],["\u1EEC","U"],["\u1EEF","u"],["\u1EEE","U"],["\u1EF1","u"],["\u1EF0","U"],["\u1EF3","y"],["\u1EF2","Y"],["\u1EF5","y"],["\u1EF4","Y"],["\u1EF7","y"],["\u1EF6","Y"],["\u1EF9","y"],["\u1EF8","Y"],["\u0621","e"],["\u0622","a"],["\u0623","a"],["\u0624","w"],["\u0625","a"],["\u0626","y"],["\u0627","a"],["\u0628","b"],["\u0629","t"],["\u062A","t"],["\u062B","th"],["\u062C","j"],["\u062D","h"],["\u062E","kh"],["\u062F","d"],["\u0630","dh"],["\u0631","r"],["\u0632","z"],["\u0633","s"],["\u0634","sh"],["\u0635","s"],["\u0636","d"],["\u0637","t"],["\u0638","z"],["\u0639","e"],["\u063A","gh"],["\u0640","_"],["\u0641","f"],["\u0642","q"],["\u0643","k"],["\u0644","l"],["\u0645","m"],["\u0646","n"],["\u0647","h"],["\u0648","w"],["\u0649","a"],["\u064A","y"],["\u064E\u200E","a"],["\u064F","u"],["\u0650\u200E","i"],["\u0660","0"],["\u0661","1"],["\u0662","2"],["\u0663","3"],["\u0664","4"],["\u0665","5"],["\u0666","6"],["\u0667","7"],["\u0668","8"],["\u0669","9"],["\u0686","ch"],["\u06A9","k"],["\u06AF","g"],["\u067E","p"],["\u0698","zh"],["\u06CC","y"],["\u06F0","0"],["\u06F1","1"],["\u06F2","2"],["\u06F3","3"],["\u06F4","4"],["\u06F5","5"],["\u06F6","6"],["\u06F7","7"],["\u06F8","8"],["\u06F9","9"],["\u067C","p"],["\u0681","z"],["\u0685","c"],["\u0689","d"],["\uFEAB","d"],["\uFEAD","r"],["\u0693","r"],["\uFEAF","z"],["\u0696","g"],["\u069A","x"],["\u06AB","g"],["\u06BC","n"],["\u06C0","e"],["\u06D0","e"],["\u06CD","ai"],["\u0679","t"],["\u0688","d"],["\u0691","r"],["\u06BA","n"],["\u06C1","h"],["\u06BE","h"],["\u06D2","e"],["\u0410","A"],["\u0430","a"],["\u0411","B"],["\u0431","b"],["\u0412","V"],["\u0432","v"],["\u0413","G"],["\u0433","g"],["\u0414","D"],["\u0434","d"],["\u044A\u0435","ye"],["\u042A\u0435","Ye"],["\u044A\u0415","yE"],["\u042A\u0415","YE"],["\u0415","E"],["\u0435","e"],["\u0401","Yo"],["\u0451","yo"],["\u0416","Zh"],["\u0436","zh"],["\u0417","Z"],["\u0437","z"],["\u0418","I"],["\u0438","i"],["\u044B\u0439","iy"],["\u042B\u0439","Iy"],["\u042B\u0419","IY"],["\u044B\u0419","iY"],["\u0419","Y"],["\u0439","y"],["\u041A","K"],["\u043A","k"],["\u041B","L"],["\u043B","l"],["\u041C","M"],["\u043C","m"],["\u041D","N"],["\u043D","n"],["\u041E","O"],["\u043E","o"],["\u041F","P"],["\u043F","p"],["\u0420","R"],["\u0440","r"],["\u0421","S"],["\u0441","s"],["\u0422","T"],["\u0442","t"],["\u0423","U"],["\u0443","u"],["\u0424","F"],["\u0444","f"],["\u0425","Kh"],["\u0445","kh"],["\u0426","Ts"],["\u0446","ts"],["\u0427","Ch"],["\u0447","ch"],["\u0428","Sh"],["\u0448","sh"],["\u0429","Sch"],["\u0449","sch"],["\u042A",""],["\u044A",""],["\u042B","Y"],["\u044B","y"],["\u042C",""],["\u044C",""],["\u042D","E"],["\u044D","e"],["\u042E","Yu"],["\u044E","yu"],["\u042F","Ya"],["\u044F","ya"],["\u0103","a"],["\u0102","A"],["\u0219","s"],["\u0218","S"],["\u021B","t"],["\u021A","T"],["\u0163","t"],["\u0162","T"],["\u015F","s"],["\u015E","S"],["\xE7","c"],["\xC7","C"],["\u011F","g"],["\u011E","G"],["\u0131","i"],["\u0130","I"],["\u0561","a"],["\u0531","A"],["\u0562","b"],["\u0532","B"],["\u0563","g"],["\u0533","G"],["\u0564","d"],["\u0534","D"],["\u0565","ye"],["\u0535","Ye"],["\u0566","z"],["\u0536","Z"],["\u0567","e"],["\u0537","E"],["\u0568","y"],["\u0538","Y"],["\u0569","t"],["\u0539","T"],["\u056A","zh"],["\u053A","Zh"],["\u056B","i"],["\u053B","I"],["\u056C","l"],["\u053C","L"],["\u056D","kh"],["\u053D","Kh"],["\u056E","ts"],["\u053E","Ts"],["\u056F","k"],["\u053F","K"],["\u0570","h"],["\u0540","H"],["\u0571","dz"],["\u0541","Dz"],["\u0572","gh"],["\u0542","Gh"],["\u0573","tch"],["\u0543","Tch"],["\u0574","m"],["\u0544","M"],["\u0575","y"],["\u0545","Y"],["\u0576","n"],["\u0546","N"],["\u0577","sh"],["\u0547","Sh"],["\u0578\u0582","u"],["\u0548\u0552","U"],["\u0548\u0582","U"],["\u0578","vo"],["\u0548","Vo"],["\u0579","ch"],["\u0549","Ch"],["\u057A","p"],["\u054A","P"],["\u057B","j"],["\u054B","J"],["\u057C","r"],["\u054C","R"],["\u057D","s"],["\u054D","S"],["\u057E","v"],["\u054E","V"],["\u057F","t"],["\u054F","T"],["\u0580","r"],["\u0550","R"],["\u0581","c"],["\u0551","C"],["\u0583","p"],["\u0553","P"],["\u0584","q"],["\u0554","Q"],["\u0585","o"],["\u0555","O"],["\u0586","f"],["\u0556","F"],["\u0587","yev"],["\u10D0","a"],["\u10D1","b"],["\u10D2","g"],["\u10D3","d"],["\u10D4","e"],["\u10D5","v"],["\u10D6","z"],["\u10D7","t"],["\u10D8","i"],["\u10D9","k"],["\u10DA","l"],["\u10DB","m"],["\u10DC","n"],["\u10DD","o"],["\u10DE","p"],["\u10DF","zh"],["\u10E0","r"],["\u10E1","s"],["\u10E2","t"],["\u10E3","u"],["\u10E4","ph"],["\u10E5","q"],["\u10E6","gh"],["\u10E7","k"],["\u10E8","sh"],["\u10E9","ch"],["\u10EA","ts"],["\u10EB","dz"],["\u10EC","ts"],["\u10ED","tch"],["\u10EE","kh"],["\u10EF","j"],["\u10F0","h"],["\u010D","c"],["\u010F","d"],["\u011B","e"],["\u0148","n"],["\u0159","r"],["\u0161","s"],["\u0165","t"],["\u016F","u"],["\u017E","z"],["\u010C","C"],["\u010E","D"],["\u011A","E"],["\u0147","N"],["\u0158","R"],["\u0160","S"],["\u0164","T"],["\u016E","U"],["\u017D","Z"],["\u0780","h"],["\u0781","sh"],["\u0782","n"],["\u0783","r"],["\u0784","b"],["\u0785","lh"],["\u0786","k"],["\u0787","a"],["\u0788","v"],["\u0789","m"],["\u078A","f"],["\u078B","dh"],["\u078C","th"],["\u078D","l"],["\u078E","g"],["\u078F","gn"],["\u0790","s"],["\u0791","d"],["\u0792","z"],["\u0793","t"],["\u0794","y"],["\u0795","p"],["\u0796","j"],["\u0797","ch"],["\u0798","tt"],["\u0799","hh"],["\u079A","kh"],["\u079B","th"],["\u079C","z"],["\u079D","sh"],["\u079E","s"],["\u079F","d"],["\u07A0","t"],["\u07A1","z"],["\u07A2","a"],["\u07A3","gh"],["\u07A4","q"],["\u07A5","w"],["\u07A6","a"],["\u07A7","aa"],["\u07A8","i"],["\u07A9","ee"],["\u07AA","u"],["\u07AB","oo"],["\u07AC","e"],["\u07AD","ey"],["\u07AE","o"],["\u07AF","oa"],["\u07B0",""],["\u03B1","a"],["\u03B2","v"],["\u03B3","g"],["\u03B4","d"],["\u03B5","e"],["\u03B6","z"],["\u03B7","i"],["\u03B8","th"],["\u03B9","i"],["\u03BA","k"],["\u03BB","l"],["\u03BC","m"],["\u03BD","n"],["\u03BE","ks"],["\u03BF","o"],["\u03C0","p"],["\u03C1","r"],["\u03C3","s"],["\u03C4","t"],["\u03C5","y"],["\u03C6","f"],["\u03C7","x"],["\u03C8","ps"],["\u03C9","o"],["\u03AC","a"],["\u03AD","e"],["\u03AF","i"],["\u03CC","o"],["\u03CD","y"],["\u03AE","i"],["\u03CE","o"],["\u03C2","s"],["\u03CA","i"],["\u03B0","y"],["\u03CB","y"],["\u0390","i"],["\u0391","A"],["\u0392","B"],["\u0393","G"],["\u0394","D"],["\u0395","E"],["\u0396","Z"],["\u0397","I"],["\u0398","TH"],["\u0399","I"],["\u039A","K"],["\u039B","L"],["\u039C","M"],["\u039D","N"],["\u039E","KS"],["\u039F","O"],["\u03A0","P"],["\u03A1","R"],["\u03A3","S"],["\u03A4","T"],["\u03A5","Y"],["\u03A6","F"],["\u03A7","X"],["\u03A8","PS"],["\u03A9","O"],["\u0386","A"],["\u0388","E"],["\u038A","I"],["\u038C","O"],["\u038E","Y"],["\u0389","I"],["\u038F","O"],["\u03AA","I"],["\u03AB","Y"],["\u0101","a"],["\u0113","e"],["\u0123","g"],["\u012B","i"],["\u0137","k"],["\u013C","l"],["\u0146","n"],["\u016B","u"],["\u0100","A"],["\u0112","E"],["\u0122","G"],["\u012A","I"],["\u0136","K"],["\u013B","L"],["\u0145","N"],["\u016A","U"],["\u010D","c"],["\u0161","s"],["\u017E","z"],["\u010C","C"],["\u0160","S"],["\u017D","Z"],["\u0105","a"],["\u010D","c"],["\u0119","e"],["\u0117","e"],["\u012F","i"],["\u0161","s"],["\u0173","u"],["\u016B","u"],["\u017E","z"],["\u0104","A"],["\u010C","C"],["\u0118","E"],["\u0116","E"],["\u012E","I"],["\u0160","S"],["\u0172","U"],["\u016A","U"],["\u040C","Kj"],["\u045C","kj"],["\u0409","Lj"],["\u0459","lj"],["\u040A","Nj"],["\u045A","nj"],["\u0422\u0441","Ts"],["\u0442\u0441","ts"],["\u0105","a"],["\u0107","c"],["\u0119","e"],["\u0142","l"],["\u0144","n"],["\u015B","s"],["\u017A","z"],["\u017C","z"],["\u0104","A"],["\u0106","C"],["\u0118","E"],["\u0141","L"],["\u0143","N"],["\u015A","S"],["\u0179","Z"],["\u017B","Z"],["\u0404","Ye"],["\u0406","I"],["\u0407","Yi"],["\u0490","G"],["\u0454","ye"],["\u0456","i"],["\u0457","yi"],["\u0491","g"],["\u0132","IJ"],["\u0133","ij"],["\xA2","c"],["\xA5","Y"],["\u07FF","b"],["\u09F3","t"],["\u0AF1","Bo"],["\u0E3F","B"],["\u20A0","CE"],["\u20A1","C"],["\u20A2","Cr"],["\u20A3","F"],["\u20A5","m"],["\u20A6","N"],["\u20A7","Pt"],["\u20A8","Rs"],["\u20A9","W"],["\u20AB","s"],["\u20AC","E"],["\u20AD","K"],["\u20AE","T"],["\u20AF","Dp"],["\u20B0","S"],["\u20B1","P"],["\u20B2","G"],["\u20B3","A"],["\u20B4","S"],["\u20B5","C"],["\u20B6","tt"],["\u20B7","S"],["\u20B8","T"],["\u20B9","R"],["\u20BA","L"],["\u20BD","P"],["\u20BF","B"],["\uFE69","$"],["\uFFE0","c"],["\uFFE5","Y"],["\uFFE6","W"],["\u{1D400}","A"],["\u{1D401}","B"],["\u{1D402}","C"],["\u{1D403}","D"],["\u{1D404}","E"],["\u{1D405}","F"],["\u{1D406}","G"],["\u{1D407}","H"],["\u{1D408}","I"],["\u{1D409}","J"],["\u{1D40A}","K"],["\u{1D40B}","L"],["\u{1D40C}","M"],["\u{1D40D}","N"],["\u{1D40E}","O"],["\u{1D40F}","P"],["\u{1D410}","Q"],["\u{1D411}","R"],["\u{1D412}","S"],["\u{1D413}","T"],["\u{1D414}","U"],["\u{1D415}","V"],["\u{1D416}","W"],["\u{1D417}","X"],["\u{1D418}","Y"],["\u{1D419}","Z"],["\u{1D41A}","a"],["\u{1D41B}","b"],["\u{1D41C}","c"],["\u{1D41D}","d"],["\u{1D41E}","e"],["\u{1D41F}","f"],["\u{1D420}","g"],["\u{1D421}","h"],["\u{1D422}","i"],["\u{1D423}","j"],["\u{1D424}","k"],["\u{1D425}","l"],["\u{1D426}","m"],["\u{1D427}","n"],["\u{1D428}","o"],["\u{1D429}","p"],["\u{1D42A}","q"],["\u{1D42B}","r"],["\u{1D42C}","s"],["\u{1D42D}","t"],["\u{1D42E}","u"],["\u{1D42F}","v"],["\u{1D430}","w"],["\u{1D431}","x"],["\u{1D432}","y"],["\u{1D433}","z"],["\u{1D434}","A"],["\u{1D435}","B"],["\u{1D436}","C"],["\u{1D437}","D"],["\u{1D438}","E"],["\u{1D439}","F"],["\u{1D43A}","G"],["\u{1D43B}","H"],["\u{1D43C}","I"],["\u{1D43D}","J"],["\u{1D43E}","K"],["\u{1D43F}","L"],["\u{1D440}","M"],["\u{1D441}","N"],["\u{1D442}","O"],["\u{1D443}","P"],["\u{1D444}","Q"],["\u{1D445}","R"],["\u{1D446}","S"],["\u{1D447}","T"],["\u{1D448}","U"],["\u{1D449}","V"],["\u{1D44A}","W"],["\u{1D44B}","X"],["\u{1D44C}","Y"],["\u{1D44D}","Z"],["\u{1D44E}","a"],["\u{1D44F}","b"],["\u{1D450}","c"],["\u{1D451}","d"],["\u{1D452}","e"],["\u{1D453}","f"],["\u{1D454}","g"],["\u{1D456}","i"],["\u{1D457}","j"],["\u{1D458}","k"],["\u{1D459}","l"],["\u{1D45A}","m"],["\u{1D45B}","n"],["\u{1D45C}","o"],["\u{1D45D}","p"],["\u{1D45E}","q"],["\u{1D45F}","r"],["\u{1D460}","s"],["\u{1D461}","t"],["\u{1D462}","u"],["\u{1D463}","v"],["\u{1D464}","w"],["\u{1D465}","x"],["\u{1D466}","y"],["\u{1D467}","z"],["\u{1D468}","A"],["\u{1D469}","B"],["\u{1D46A}","C"],["\u{1D46B}","D"],["\u{1D46C}","E"],["\u{1D46D}","F"],["\u{1D46E}","G"],["\u{1D46F}","H"],["\u{1D470}","I"],["\u{1D471}","J"],["\u{1D472}","K"],["\u{1D473}","L"],["\u{1D474}","M"],["\u{1D475}","N"],["\u{1D476}","O"],["\u{1D477}","P"],["\u{1D478}","Q"],["\u{1D479}","R"],["\u{1D47A}","S"],["\u{1D47B}","T"],["\u{1D47C}","U"],["\u{1D47D}","V"],["\u{1D47E}","W"],["\u{1D47F}","X"],["\u{1D480}","Y"],["\u{1D481}","Z"],["\u{1D482}","a"],["\u{1D483}","b"],["\u{1D484}","c"],["\u{1D485}","d"],["\u{1D486}","e"],["\u{1D487}","f"],["\u{1D488}","g"],["\u{1D489}","h"],["\u{1D48A}","i"],["\u{1D48B}","j"],["\u{1D48C}","k"],["\u{1D48D}","l"],["\u{1D48E}","m"],["\u{1D48F}","n"],["\u{1D490}","o"],["\u{1D491}","p"],["\u{1D492}","q"],["\u{1D493}","r"],["\u{1D494}","s"],["\u{1D495}","t"],["\u{1D496}","u"],["\u{1D497}","v"],["\u{1D498}","w"],["\u{1D499}","x"],["\u{1D49A}","y"],["\u{1D49B}","z"],["\u{1D49C}","A"],["\u{1D49E}","C"],["\u{1D49F}","D"],["\u{1D4A2}","g"],["\u{1D4A5}","J"],["\u{1D4A6}","K"],["\u{1D4A9}","N"],["\u{1D4AA}","O"],["\u{1D4AB}","P"],["\u{1D4AC}","Q"],["\u{1D4AE}","S"],["\u{1D4AF}","T"],["\u{1D4B0}","U"],["\u{1D4B1}","V"],["\u{1D4B2}","W"],["\u{1D4B3}","X"],["\u{1D4B4}","Y"],["\u{1D4B5}","Z"],["\u{1D4B6}","a"],["\u{1D4B7}","b"],["\u{1D4B8}","c"],["\u{1D4B9}","d"],["\u{1D4BB}","f"],["\u{1D4BD}","h"],["\u{1D4BE}","i"],["\u{1D4BF}","j"],["\u{1D4C0}","k"],["\u{1D4C1}","l"],["\u{1D4C2}","m"],["\u{1D4C3}","n"],["\u{1D4C5}","p"],["\u{1D4C6}","q"],["\u{1D4C7}","r"],["\u{1D4C8}","s"],["\u{1D4C9}","t"],["\u{1D4CA}","u"],["\u{1D4CB}","v"],["\u{1D4CC}","w"],["\u{1D4CD}","x"],["\u{1D4CE}","y"],["\u{1D4CF}","z"],["\u{1D4D0}","A"],["\u{1D4D1}","B"],["\u{1D4D2}","C"],["\u{1D4D3}","D"],["\u{1D4D4}","E"],["\u{1D4D5}","F"],["\u{1D4D6}","G"],["\u{1D4D7}","H"],["\u{1D4D8}","I"],["\u{1D4D9}","J"],["\u{1D4DA}","K"],["\u{1D4DB}","L"],["\u{1D4DC}","M"],["\u{1D4DD}","N"],["\u{1D4DE}","O"],["\u{1D4DF}","P"],["\u{1D4E0}","Q"],["\u{1D4E1}","R"],["\u{1D4E2}","S"],["\u{1D4E3}","T"],["\u{1D4E4}","U"],["\u{1D4E5}","V"],["\u{1D4E6}","W"],["\u{1D4E7}","X"],["\u{1D4E8}","Y"],["\u{1D4E9}","Z"],["\u{1D4EA}","a"],["\u{1D4EB}","b"],["\u{1D4EC}","c"],["\u{1D4ED}","d"],["\u{1D4EE}","e"],["\u{1D4EF}","f"],["\u{1D4F0}","g"],["\u{1D4F1}","h"],["\u{1D4F2}","i"],["\u{1D4F3}","j"],["\u{1D4F4}","k"],["\u{1D4F5}","l"],["\u{1D4F6}","m"],["\u{1D4F7}","n"],["\u{1D4F8}","o"],["\u{1D4F9}","p"],["\u{1D4FA}","q"],["\u{1D4FB}","r"],["\u{1D4FC}","s"],["\u{1D4FD}","t"],["\u{1D4FE}","u"],["\u{1D4FF}","v"],["\u{1D500}","w"],["\u{1D501}","x"],["\u{1D502}","y"],["\u{1D503}","z"],["\u{1D504}","A"],["\u{1D505}","B"],["\u{1D507}","D"],["\u{1D508}","E"],["\u{1D509}","F"],["\u{1D50A}","G"],["\u{1D50D}","J"],["\u{1D50E}","K"],["\u{1D50F}","L"],["\u{1D510}","M"],["\u{1D511}","N"],["\u{1D512}","O"],["\u{1D513}","P"],["\u{1D514}","Q"],["\u{1D516}","S"],["\u{1D517}","T"],["\u{1D518}","U"],["\u{1D519}","V"],["\u{1D51A}","W"],["\u{1D51B}","X"],["\u{1D51C}","Y"],["\u{1D51E}","a"],["\u{1D51F}","b"],["\u{1D520}","c"],["\u{1D521}","d"],["\u{1D522}","e"],["\u{1D523}","f"],["\u{1D524}","g"],["\u{1D525}","h"],["\u{1D526}","i"],["\u{1D527}","j"],["\u{1D528}","k"],["\u{1D529}","l"],["\u{1D52A}","m"],["\u{1D52B}","n"],["\u{1D52C}","o"],["\u{1D52D}","p"],["\u{1D52E}","q"],["\u{1D52F}","r"],["\u{1D530}","s"],["\u{1D531}","t"],["\u{1D532}","u"],["\u{1D533}","v"],["\u{1D534}","w"],["\u{1D535}","x"],["\u{1D536}","y"],["\u{1D537}","z"],["\u{1D538}","A"],["\u{1D539}","B"],["\u{1D53B}","D"],["\u{1D53C}","E"],["\u{1D53D}","F"],["\u{1D53E}","G"],["\u{1D540}","I"],["\u{1D541}","J"],["\u{1D542}","K"],["\u{1D543}","L"],["\u{1D544}","M"],["\u{1D546}","O"],["\u{1D54A}","S"],["\u{1D54B}","T"],["\u{1D54C}","U"],["\u{1D54D}","V"],["\u{1D54E}","W"],["\u{1D54F}","X"],["\u{1D550}","Y"],["\u{1D552}","a"],["\u{1D553}","b"],["\u{1D554}","c"],["\u{1D555}","d"],["\u{1D556}","e"],["\u{1D557}","f"],["\u{1D558}","g"],["\u{1D559}","h"],["\u{1D55A}","i"],["\u{1D55B}","j"],["\u{1D55C}","k"],["\u{1D55D}","l"],["\u{1D55E}","m"],["\u{1D55F}","n"],["\u{1D560}","o"],["\u{1D561}","p"],["\u{1D562}","q"],["\u{1D563}","r"],["\u{1D564}","s"],["\u{1D565}","t"],["\u{1D566}","u"],["\u{1D567}","v"],["\u{1D568}","w"],["\u{1D569}","x"],["\u{1D56A}","y"],["\u{1D56B}","z"],["\u{1D56C}","A"],["\u{1D56D}","B"],["\u{1D56E}","C"],["\u{1D56F}","D"],["\u{1D570}","E"],["\u{1D571}","F"],["\u{1D572}","G"],["\u{1D573}","H"],["\u{1D574}","I"],["\u{1D575}","J"],["\u{1D576}","K"],["\u{1D577}","L"],["\u{1D578}","M"],["\u{1D579}","N"],["\u{1D57A}","O"],["\u{1D57B}","P"],["\u{1D57C}","Q"],["\u{1D57D}","R"],["\u{1D57E}","S"],["\u{1D57F}","T"],["\u{1D580}","U"],["\u{1D581}","V"],["\u{1D582}","W"],["\u{1D583}","X"],["\u{1D584}","Y"],["\u{1D585}","Z"],["\u{1D586}","a"],["\u{1D587}","b"],["\u{1D588}","c"],["\u{1D589}","d"],["\u{1D58A}","e"],["\u{1D58B}","f"],["\u{1D58C}","g"],["\u{1D58D}","h"],["\u{1D58E}","i"],["\u{1D58F}","j"],["\u{1D590}","k"],["\u{1D591}","l"],["\u{1D592}","m"],["\u{1D593}","n"],["\u{1D594}","o"],["\u{1D595}","p"],["\u{1D596}","q"],["\u{1D597}","r"],["\u{1D598}","s"],["\u{1D599}","t"],["\u{1D59A}","u"],["\u{1D59B}","v"],["\u{1D59C}","w"],["\u{1D59D}","x"],["\u{1D59E}","y"],["\u{1D59F}","z"],["\u{1D5A0}","A"],["\u{1D5A1}","B"],["\u{1D5A2}","C"],["\u{1D5A3}","D"],["\u{1D5A4}","E"],["\u{1D5A5}","F"],["\u{1D5A6}","G"],["\u{1D5A7}","H"],["\u{1D5A8}","I"],["\u{1D5A9}","J"],["\u{1D5AA}","K"],["\u{1D5AB}","L"],["\u{1D5AC}","M"],["\u{1D5AD}","N"],["\u{1D5AE}","O"],["\u{1D5AF}","P"],["\u{1D5B0}","Q"],["\u{1D5B1}","R"],["\u{1D5B2}","S"],["\u{1D5B3}","T"],["\u{1D5B4}","U"],["\u{1D5B5}","V"],["\u{1D5B6}","W"],["\u{1D5B7}","X"],["\u{1D5B8}","Y"],["\u{1D5B9}","Z"],["\u{1D5BA}","a"],["\u{1D5BB}","b"],["\u{1D5BC}","c"],["\u{1D5BD}","d"],["\u{1D5BE}","e"],["\u{1D5BF}","f"],["\u{1D5C0}","g"],["\u{1D5C1}","h"],["\u{1D5C2}","i"],["\u{1D5C3}","j"],["\u{1D5C4}","k"],["\u{1D5C5}","l"],["\u{1D5C6}","m"],["\u{1D5C7}","n"],["\u{1D5C8}","o"],["\u{1D5C9}","p"],["\u{1D5CA}","q"],["\u{1D5CB}","r"],["\u{1D5CC}","s"],["\u{1D5CD}","t"],["\u{1D5CE}","u"],["\u{1D5CF}","v"],["\u{1D5D0}","w"],["\u{1D5D1}","x"],["\u{1D5D2}","y"],["\u{1D5D3}","z"],["\u{1D5D4}","A"],["\u{1D5D5}","B"],["\u{1D5D6}","C"],["\u{1D5D7}","D"],["\u{1D5D8}","E"],["\u{1D5D9}","F"],["\u{1D5DA}","G"],["\u{1D5DB}","H"],["\u{1D5DC}","I"],["\u{1D5DD}","J"],["\u{1D5DE}","K"],["\u{1D5DF}","L"],["\u{1D5E0}","M"],["\u{1D5E1}","N"],["\u{1D5E2}","O"],["\u{1D5E3}","P"],["\u{1D5E4}","Q"],["\u{1D5E5}","R"],["\u{1D5E6}","S"],["\u{1D5E7}","T"],["\u{1D5E8}","U"],["\u{1D5E9}","V"],["\u{1D5EA}","W"],["\u{1D5EB}","X"],["\u{1D5EC}","Y"],["\u{1D5ED}","Z"],["\u{1D5EE}","a"],["\u{1D5EF}","b"],["\u{1D5F0}","c"],["\u{1D5F1}","d"],["\u{1D5F2}","e"],["\u{1D5F3}","f"],["\u{1D5F4}","g"],["\u{1D5F5}","h"],["\u{1D5F6}","i"],["\u{1D5F7}","j"],["\u{1D5F8}","k"],["\u{1D5F9}","l"],["\u{1D5FA}","m"],["\u{1D5FB}","n"],["\u{1D5FC}","o"],["\u{1D5FD}","p"],["\u{1D5FE}","q"],["\u{1D5FF}","r"],["\u{1D600}","s"],["\u{1D601}","t"],["\u{1D602}","u"],["\u{1D603}","v"],["\u{1D604}","w"],["\u{1D605}","x"],["\u{1D606}","y"],["\u{1D607}","z"],["\u{1D608}","A"],["\u{1D609}","B"],["\u{1D60A}","C"],["\u{1D60B}","D"],["\u{1D60C}","E"],["\u{1D60D}","F"],["\u{1D60E}","G"],["\u{1D60F}","H"],["\u{1D610}","I"],["\u{1D611}","J"],["\u{1D612}","K"],["\u{1D613}","L"],["\u{1D614}","M"],["\u{1D615}","N"],["\u{1D616}","O"],["\u{1D617}","P"],["\u{1D618}","Q"],["\u{1D619}","R"],["\u{1D61A}","S"],["\u{1D61B}","T"],["\u{1D61C}","U"],["\u{1D61D}","V"],["\u{1D61E}","W"],["\u{1D61F}","X"],["\u{1D620}","Y"],["\u{1D621}","Z"],["\u{1D622}","a"],["\u{1D623}","b"],["\u{1D624}","c"],["\u{1D625}","d"],["\u{1D626}","e"],["\u{1D627}","f"],["\u{1D628}","g"],["\u{1D629}","h"],["\u{1D62A}","i"],["\u{1D62B}","j"],["\u{1D62C}","k"],["\u{1D62D}","l"],["\u{1D62E}","m"],["\u{1D62F}","n"],["\u{1D630}","o"],["\u{1D631}","p"],["\u{1D632}","q"],["\u{1D633}","r"],["\u{1D634}","s"],["\u{1D635}","t"],["\u{1D636}","u"],["\u{1D637}","v"],["\u{1D638}","w"],["\u{1D639}","x"],["\u{1D63A}","y"],["\u{1D63B}","z"],["\u{1D63C}","A"],["\u{1D63D}","B"],["\u{1D63E}","C"],["\u{1D63F}","D"],["\u{1D640}","E"],["\u{1D641}","F"],["\u{1D642}","G"],["\u{1D643}","H"],["\u{1D644}","I"],["\u{1D645}","J"],["\u{1D646}","K"],["\u{1D647}","L"],["\u{1D648}","M"],["\u{1D649}","N"],["\u{1D64A}","O"],["\u{1D64B}","P"],["\u{1D64C}","Q"],["\u{1D64D}","R"],["\u{1D64E}","S"],["\u{1D64F}","T"],["\u{1D650}","U"],["\u{1D651}","V"],["\u{1D652}","W"],["\u{1D653}","X"],["\u{1D654}","Y"],["\u{1D655}","Z"],["\u{1D656}","a"],["\u{1D657}","b"],["\u{1D658}","c"],["\u{1D659}","d"],["\u{1D65A}","e"],["\u{1D65B}","f"],["\u{1D65C}","g"],["\u{1D65D}","h"],["\u{1D65E}","i"],["\u{1D65F}","j"],["\u{1D660}","k"],["\u{1D661}","l"],["\u{1D662}","m"],["\u{1D663}","n"],["\u{1D664}","o"],["\u{1D665}","p"],["\u{1D666}","q"],["\u{1D667}","r"],["\u{1D668}","s"],["\u{1D669}","t"],["\u{1D66A}","u"],["\u{1D66B}","v"],["\u{1D66C}","w"],["\u{1D66D}","x"],["\u{1D66E}","y"],["\u{1D66F}","z"],["\u{1D670}","A"],["\u{1D671}","B"],["\u{1D672}","C"],["\u{1D673}","D"],["\u{1D674}","E"],["\u{1D675}","F"],["\u{1D676}","G"],["\u{1D677}","H"],["\u{1D678}","I"],["\u{1D679}","J"],["\u{1D67A}","K"],["\u{1D67B}","L"],["\u{1D67C}","M"],["\u{1D67D}","N"],["\u{1D67E}","O"],["\u{1D67F}","P"],["\u{1D680}","Q"],["\u{1D681}","R"],["\u{1D682}","S"],["\u{1D683}","T"],["\u{1D684}","U"],["\u{1D685}","V"],["\u{1D686}","W"],["\u{1D687}","X"],["\u{1D688}","Y"],["\u{1D689}","Z"],["\u{1D68A}","a"],["\u{1D68B}","b"],["\u{1D68C}","c"],["\u{1D68D}","d"],["\u{1D68E}","e"],["\u{1D68F}","f"],["\u{1D690}","g"],["\u{1D691}","h"],["\u{1D692}","i"],["\u{1D693}","j"],["\u{1D694}","k"],["\u{1D695}","l"],["\u{1D696}","m"],["\u{1D697}","n"],["\u{1D698}","o"],["\u{1D699}","p"],["\u{1D69A}","q"],["\u{1D69B}","r"],["\u{1D69C}","s"],["\u{1D69D}","t"],["\u{1D69E}","u"],["\u{1D69F}","v"],["\u{1D6A0}","w"],["\u{1D6A1}","x"],["\u{1D6A2}","y"],["\u{1D6A3}","z"],["\u{1D6A4}","l"],["\u{1D6A5}","j"],["\u{1D6E2}","A"],["\u{1D6E3}","B"],["\u{1D6E4}","G"],["\u{1D6E5}","D"],["\u{1D6E6}","E"],["\u{1D6E7}","Z"],["\u{1D6E8}","I"],["\u{1D6E9}","TH"],["\u{1D6EA}","I"],["\u{1D6EB}","K"],["\u{1D6EC}","L"],["\u{1D6ED}","M"],["\u{1D6EE}","N"],["\u{1D6EF}","KS"],["\u{1D6F0}","O"],["\u{1D6F1}","P"],["\u{1D6F2}","R"],["\u{1D6F3}","TH"],["\u{1D6F4}","S"],["\u{1D6F5}","T"],["\u{1D6F6}","Y"],["\u{1D6F7}","F"],["\u{1D6F8}","x"],["\u{1D6F9}","PS"],["\u{1D6FA}","O"],["\u{1D6FB}","D"],["\u{1D6FC}","a"],["\u{1D6FD}","b"],["\u{1D6FE}","g"],["\u{1D6FF}","d"],["\u{1D700}","e"],["\u{1D701}","z"],["\u{1D702}","i"],["\u{1D703}","th"],["\u{1D704}","i"],["\u{1D705}","k"],["\u{1D706}","l"],["\u{1D707}","m"],["\u{1D708}","n"],["\u{1D709}","ks"],["\u{1D70A}","o"],["\u{1D70B}","p"],["\u{1D70C}","r"],["\u{1D70D}","s"],["\u{1D70E}","s"],["\u{1D70F}","t"],["\u{1D710}","y"],["\u{1D711}","f"],["\u{1D712}","x"],["\u{1D713}","ps"],["\u{1D714}","o"],["\u{1D715}","d"],["\u{1D716}","E"],["\u{1D717}","TH"],["\u{1D718}","K"],["\u{1D719}","f"],["\u{1D71A}","r"],["\u{1D71B}","p"],["\u{1D71C}","A"],["\u{1D71D}","V"],["\u{1D71E}","G"],["\u{1D71F}","D"],["\u{1D720}","E"],["\u{1D721}","Z"],["\u{1D722}","I"],["\u{1D723}","TH"],["\u{1D724}","I"],["\u{1D725}","K"],["\u{1D726}","L"],["\u{1D727}","M"],["\u{1D728}","N"],["\u{1D729}","KS"],["\u{1D72A}","O"],["\u{1D72B}","P"],["\u{1D72C}","S"],["\u{1D72D}","TH"],["\u{1D72E}","S"],["\u{1D72F}","T"],["\u{1D730}","Y"],["\u{1D731}","F"],["\u{1D732}","X"],["\u{1D733}","PS"],["\u{1D734}","O"],["\u{1D735}","D"],["\u{1D736}","a"],["\u{1D737}","v"],["\u{1D738}","g"],["\u{1D739}","d"],["\u{1D73A}","e"],["\u{1D73B}","z"],["\u{1D73C}","i"],["\u{1D73D}","th"],["\u{1D73E}","i"],["\u{1D73F}","k"],["\u{1D740}","l"],["\u{1D741}","m"],["\u{1D742}","n"],["\u{1D743}","ks"],["\u{1D744}","o"],["\u{1D745}","p"],["\u{1D746}","r"],["\u{1D747}","s"],["\u{1D748}","s"],["\u{1D749}","t"],["\u{1D74A}","y"],["\u{1D74B}","f"],["\u{1D74C}","x"],["\u{1D74D}","ps"],["\u{1D74E}","o"],["\u{1D74F}","a"],["\u{1D750}","e"],["\u{1D751}","i"],["\u{1D752}","k"],["\u{1D753}","f"],["\u{1D754}","r"],["\u{1D755}","p"],["\u{1D756}","A"],["\u{1D757}","B"],["\u{1D758}","G"],["\u{1D759}","D"],["\u{1D75A}","E"],["\u{1D75B}","Z"],["\u{1D75C}","I"],["\u{1D75D}","TH"],["\u{1D75E}","I"],["\u{1D75F}","K"],["\u{1D760}","L"],["\u{1D761}","M"],["\u{1D762}","N"],["\u{1D763}","KS"],["\u{1D764}","O"],["\u{1D765}","P"],["\u{1D766}","R"],["\u{1D767}","TH"],["\u{1D768}","S"],["\u{1D769}","T"],["\u{1D76A}","Y"],["\u{1D76B}","F"],["\u{1D76C}","X"],["\u{1D76D}","PS"],["\u{1D76E}","O"],["\u{1D76F}","D"],["\u{1D770}","a"],["\u{1D771}","v"],["\u{1D772}","g"],["\u{1D773}","d"],["\u{1D774}","e"],["\u{1D775}","z"],["\u{1D776}","i"],["\u{1D777}","th"],["\u{1D778}","i"],["\u{1D779}","k"],["\u{1D77A}","l"],["\u{1D77B}","m"],["\u{1D77C}","n"],["\u{1D77D}","ks"],["\u{1D77E}","o"],["\u{1D77F}","p"],["\u{1D780}","r"],["\u{1D781}","s"],["\u{1D782}","s"],["\u{1D783}","t"],["\u{1D784}","y"],["\u{1D785}","f"],["\u{1D786}","x"],["\u{1D787}","ps"],["\u{1D788}","o"],["\u{1D789}","a"],["\u{1D78A}","e"],["\u{1D78B}","i"],["\u{1D78C}","k"],["\u{1D78D}","f"],["\u{1D78E}","r"],["\u{1D78F}","p"],["\u{1D790}","A"],["\u{1D791}","V"],["\u{1D792}","G"],["\u{1D793}","D"],["\u{1D794}","E"],["\u{1D795}","Z"],["\u{1D796}","I"],["\u{1D797}","TH"],["\u{1D798}","I"],["\u{1D799}","K"],["\u{1D79A}","L"],["\u{1D79B}","M"],["\u{1D79C}","N"],["\u{1D79D}","KS"],["\u{1D79E}","O"],["\u{1D79F}","P"],["\u{1D7A0}","S"],["\u{1D7A1}","TH"],["\u{1D7A2}","S"],["\u{1D7A3}","T"],["\u{1D7A4}","Y"],["\u{1D7A5}","F"],["\u{1D7A6}","X"],["\u{1D7A7}","PS"],["\u{1D7A8}","O"],["\u{1D7A9}","D"],["\u{1D7AA}","av"],["\u{1D7AB}","g"],["\u{1D7AC}","d"],["\u{1D7AD}","e"],["\u{1D7AE}","z"],["\u{1D7AF}","i"],["\u{1D7B0}","i"],["\u{1D7B1}","th"],["\u{1D7B2}","i"],["\u{1D7B3}","k"],["\u{1D7B4}","l"],["\u{1D7B5}","m"],["\u{1D7B6}","n"],["\u{1D7B7}","ks"],["\u{1D7B8}","o"],["\u{1D7B9}","p"],["\u{1D7BA}","r"],["\u{1D7BB}","s"],["\u{1D7BC}","s"],["\u{1D7BD}","t"],["\u{1D7BE}","y"],["\u{1D7BF}","f"],["\u{1D7C0}","x"],["\u{1D7C1}","ps"],["\u{1D7C2}","o"],["\u{1D7C3}","a"],["\u{1D7C4}","e"],["\u{1D7C5}","i"],["\u{1D7C6}","k"],["\u{1D7C7}","f"],["\u{1D7C8}","r"],["\u{1D7C9}","p"],["\u{1D7CA}","F"],["\u{1D7CB}","f"],["\u249C","(a)"],["\u249D","(b)"],["\u249E","(c)"],["\u249F","(d)"],["\u24A0","(e)"],["\u24A1","(f)"],["\u24A2","(g)"],["\u24A3","(h)"],["\u24A4","(i)"],["\u24A5","(j)"],["\u24A6","(k)"],["\u24A7","(l)"],["\u24A8","(m)"],["\u24A9","(n)"],["\u24AA","(o)"],["\u24AB","(p)"],["\u24AC","(q)"],["\u24AD","(r)"],["\u24AE","(s)"],["\u24AF","(t)"],["\u24B0","(u)"],["\u24B1","(v)"],["\u24B2","(w)"],["\u24B3","(x)"],["\u24B4","(y)"],["\u24B5","(z)"],["\u24B6","(A)"],["\u24B7","(B)"],["\u24B8","(C)"],["\u24B9","(D)"],["\u24BA","(E)"],["\u24BB","(F)"],["\u24BC","(G)"],["\u24BD","(H)"],["\u24BE","(I)"],["\u24BF","(J)"],["\u24C0","(K)"],["\u24C1","(L)"],["\u24C3","(N)"],["\u24C4","(O)"],["\u24C5","(P)"],["\u24C6","(Q)"],["\u24C7","(R)"],["\u24C8","(S)"],["\u24C9","(T)"],["\u24CA","(U)"],["\u24CB","(V)"],["\u24CC","(W)"],["\u24CD","(X)"],["\u24CE","(Y)"],["\u24CF","(Z)"],["\u24D0","(a)"],["\u24D1","(b)"],["\u24D2","(c)"],["\u24D3","(d)"],["\u24D4","(e)"],["\u24D5","(f)"],["\u24D6","(g)"],["\u24D7","(h)"],["\u24D8","(i)"],["\u24D9","(j)"],["\u24DA","(k)"],["\u24DB","(l)"],["\u24DC","(m)"],["\u24DD","(n)"],["\u24DE","(o)"],["\u24DF","(p)"],["\u24E0","(q)"],["\u24E1","(r)"],["\u24E2","(s)"],["\u24E3","(t)"],["\u24E4","(u)"],["\u24E5","(v)"],["\u24E6","(w)"],["\u24E7","(x)"],["\u24E8","(y)"],["\u24E9","(z)"],["\u010A","C"],["\u010B","c"],["\u0120","G"],["\u0121","g"],["\u0126","H"],["\u0127","h"],["\u017B","Z"],["\u017C","z"],["\u{1D7CE}","0"],["\u{1D7CF}","1"],["\u{1D7D0}","2"],["\u{1D7D1}","3"],["\u{1D7D2}","4"],["\u{1D7D3}","5"],["\u{1D7D4}","6"],["\u{1D7D5}","7"],["\u{1D7D6}","8"],["\u{1D7D7}","9"],["\u{1D7D8}","0"],["\u{1D7D9}","1"],["\u{1D7DA}","2"],["\u{1D7DB}","3"],["\u{1D7DC}","4"],["\u{1D7DD}","5"],["\u{1D7DE}","6"],["\u{1D7DF}","7"],["\u{1D7E0}","8"],["\u{1D7E1}","9"],["\u{1D7E2}","0"],["\u{1D7E3}","1"],["\u{1D7E4}","2"],["\u{1D7E5}","3"],["\u{1D7E6}","4"],["\u{1D7E7}","5"],["\u{1D7E8}","6"],["\u{1D7E9}","7"],["\u{1D7EA}","8"],["\u{1D7EB}","9"],["\u{1D7EC}","0"],["\u{1D7ED}","1"],["\u{1D7EE}","2"],["\u{1D7EF}","3"],["\u{1D7F0}","4"],["\u{1D7F1}","5"],["\u{1D7F2}","6"],["\u{1D7F3}","7"],["\u{1D7F4}","8"],["\u{1D7F5}","9"],["\u{1D7F6}","0"],["\u{1D7F7}","1"],["\u{1D7F8}","2"],["\u{1D7F9}","3"],["\u{1D7FA}","4"],["\u{1D7FB}","5"],["\u{1D7FC}","6"],["\u{1D7FD}","7"],["\u{1D7FE}","8"],["\u{1D7FF}","9"],["\u2460","1"],["\u2461","2"],["\u2462","3"],["\u2463","4"],["\u2464","5"],["\u2465","6"],["\u2466","7"],["\u2467","8"],["\u2468","9"],["\u2469","10"],["\u246A","11"],["\u246B","12"],["\u246C","13"],["\u246D","14"],["\u246E","15"],["\u246F","16"],["\u2470","17"],["\u2471","18"],["\u2472","19"],["\u2473","20"],["\u2474","1"],["\u2475","2"],["\u2476","3"],["\u2477","4"],["\u2478","5"],["\u2479","6"],["\u247A","7"],["\u247B","8"],["\u247C","9"],["\u247D","10"],["\u247E","11"],["\u247F","12"],["\u2480","13"],["\u2481","14"],["\u2482","15"],["\u2483","16"],["\u2484","17"],["\u2485","18"],["\u2486","19"],["\u2487","20"],["\u2488","1."],["\u2489","2."],["\u248A","3."],["\u248B","4."],["\u248C","5."],["\u248D","6."],["\u248E","7."],["\u248F","8."],["\u2490","9."],["\u2491","10."],["\u2492","11."],["\u2493","12."],["\u2494","13."],["\u2495","14."],["\u2496","15."],["\u2497","16."],["\u2498","17."],["\u2499","18."],["\u249A","19."],["\u249B","20."],["\u24EA","0"],["\u24EB","11"],["\u24EC","12"],["\u24ED","13"],["\u24EE","14"],["\u24EF","15"],["\u24F0","16"],["\u24F1","17"],["\u24F2","18"],["\u24F3","19"],["\u24F4","20"],["\u24F5","1"],["\u24F6","2"],["\u24F7","3"],["\u24F8","4"],["\u24F9","5"],["\u24FA","6"],["\u24FB","7"],["\u24FC","8"],["\u24FD","9"],["\u24FE","10"],["\u24FF","0"],["\u{1F670}","&"],["\u{1F671}","&"],["\u{1F672}","&"],["\u{1F673}","&"],["\u{1F674}","&"],["\u{1F675}","&"],["\u{1F676}",'"'],["\u{1F677}",'"'],["\u{1F678}",'"'],["\u203D","?!"],["\u{1F679}","?!"],["\u{1F67A}","?!"],["\u{1F67B}","?!"],["\u{1F67C}","/"],["\u{1F67D}","\\"],["\u{1F707}","AR"],["\u{1F708}","V"],["\u{1F709}","V"],["\u{1F706}","VR"],["\u{1F705}","VF"],["\u{1F729}","2"],["\u{1F72A}","5"],["\u{1F761}","f"],["\u{1F762}","W"],["\u{1F763}","U"],["\u{1F767}","V"],["\u{1F768}","T"],["\u{1F76A}","V"],["\u{1F76B}","MB"],["\u{1F76C}","VB"],["\u{1F772}","3B"],["\u{1F773}","3B"],["\u{1F4AF}","100"],["\u{1F519}","BACK"],["\u{1F51A}","END"],["\u{1F51B}","ON!"],["\u{1F51C}","SOON"],["\u{1F51D}","TOP"],["\u{1F51E}","18"],["\u{1F524}","abc"],["\u{1F520}","ABCD"],["\u{1F521}","abcd"],["\u{1F522}","1234"],["\u{1F523}","T&@%"],["#\uFE0F\u20E3","#"],["*\uFE0F\u20E3","*"],["0\uFE0F\u20E3","0"],["1\uFE0F\u20E3","1"],["2\uFE0F\u20E3","2"],["3\uFE0F\u20E3","3"],["4\uFE0F\u20E3","4"],["5\uFE0F\u20E3","5"],["6\uFE0F\u20E3","6"],["7\uFE0F\u20E3","7"],["8\uFE0F\u20E3","8"],["9\uFE0F\u20E3","9"],["\u{1F51F}","10"],["\u{1F170}\uFE0F","A"],["\u{1F171}\uFE0F","B"],["\u{1F18E}","AB"],["\u{1F191}","CL"],["\u{1F17E}\uFE0F","O"],["\u{1F17F}","P"],["\u{1F198}","SOS"],["\u{1F172}","C"],["\u{1F173}","D"],["\u{1F174}","E"],["\u{1F175}","F"],["\u{1F176}","G"],["\u{1F177}","H"],["\u{1F178}","I"],["\u{1F179}","J"],["\u{1F17A}","K"],["\u{1F17B}","L"],["\u{1F17C}","M"],["\u{1F17D}","N"],["\u{1F180}","Q"],["\u{1F181}","R"],["\u{1F182}","S"],["\u{1F183}","T"],["\u{1F184}","U"],["\u{1F185}","V"],["\u{1F186}","W"],["\u{1F187}","X"],["\u{1F188}","Y"],["\u{1F189}","Z"],["\u2212","-"],["\u2053","-"]],wT=new Map(bT),Su=wT});var jg,Oo,ku,Fg=S(()=>{jg=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],Oo={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:jg,nb:jg,de:[["\xE4","ae"],["\xC4","Ae"],["\xF6","oe"],["\xD6","Oe"],["\xFC","ue"],["\xDC","Ue"],["\xDF","ss"],["\u1E9E","Ss"]],tr:[["\xE2","a"],["\xC2","A"],["\xF6","o"],["\xD6","O"],["\xFC","u"],["\xDC","U"]],hu:[["\u0171","u"],["\u0170","U"],["\xF6","o"],["\xD6","O"],["\xFC","u"],["\xDC","U"],["\xE1","a"],["\xC1","A"],["\xE9","e"],["\xC9","E"],["\xED","i"],["\xCD","I"],["\xF3","o"],["\xD3","O"],["\xFA","u"],["\xDA","U"]],sr:[["\u0452","dj"],["\u0402","Dj"],["\u045F","dz"],["\u040F","Dz"],["\u0459","lj"],["\u0409","Lj"],["\u045A","nj"],["\u040A","Nj"],["\u045B","c"],["\u040B","C"],["\u0447","ch"],["\u0427","Ch"],["\u0448","sh"],["\u0428","Sh"],["\u0436","zh"],["\u0416","Zh"]]};for(let t of Object.keys(Oo))Oo[t]=new Map(Oo[t]);ku=Oo});function xu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={customReplacements:[],...e};let n=ST(e.locale),r=Su,s=e.customReplacements.length>0||e.customReplacements.size>0;if(n||s){if(r=new Map(Su),n)for(let[i,o]of n)r.set(i,o);for(let[i,o]of e.customReplacements)r.set(i,o)}return t=t.normalize(),t=vT(t,r),t=t.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),t=t.replaceAll(/\p{Dash_Punctuation}/gu,"-"),t}var vT,ST,Ug=S(()=>{Bg();Fg();vT=(t,e)=>{for(let[n,r]of e)t=t.replaceAll(n,r);return t},ST=t=>{if(!t)return;let e=t.toLowerCase().replace(/^no(-|$)/,"nb$1");return ku[e]||ku[e.split("-")[0]]||void 0}});var kT,qg,Jg=S(()=>{kT=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],qg=kT});function Eu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={separator:"-",lowercase:!0,decamelize:!0,customReplacements:[],preserveLeadingUnderscore:!1,preserveTrailingDash:!1,preserveCharacters:[],transliterate:!0,...e};let n=e.preserveLeadingUnderscore&&t.startsWith("_"),r=e.preserveTrailingDash&&t.endsWith("-");if(e.transliterate){let i=new Map([...qg,...e.customReplacements]);t=xu(t,{customReplacements:i,locale:e.locale})}else if(e.customReplacements.length>0)for(let[i,o]of e.customReplacements)t=t.replaceAll(i,o);e.decamelize&&(t=xT(t));let s=AT(e);return e.lowercase&&(t=e.locale?t.toLocaleLowerCase(e.locale):t.toLowerCase()),t=t.replaceAll(/([a-zA-Z\d]+)['\u2019]([ts])(\s|$)/g,"$1$2$3"),t=t.replace(s,e.separator),t=t.replaceAll("\\",""),e.separator&&(t=ET(t,e.separator)),n&&(t=`_${t}`),r&&(t=`${t}-`),t}var xT,ET,AT,Wg=S(()=>{Dg();Ug();Jg();xT=t=>t.replaceAll(/([A-Z]{2,})(\d+)/g,"$1 $2").replaceAll(/([a-z\d]+)([A-Z]{2,})/g,"$1 $2").replaceAll(/([a-z\d])([A-Z])/g,"$1 $2").replaceAll(/([A-Z]+)([A-Z][a-rt-z\d]+)/g,"$1 $2"),ET=(t,e)=>{let n=To(e);return t.replaceAll(new RegExp(`(?:${n}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${n})|(?:${n})$`,"g"),"")},AT=t=>{let e=String.raw`a-z\d`;if(e+=t.lowercase?"":"A-Z",t.transliterate===!1&&(e+=String.raw`\p{L}\p{N}`),t.preserveCharacters.length>0)for(let r of t.preserveCharacters){if(r===t.separator)throw new Error(`The separator character \`${t.separator}\` cannot be included in preserved characters: ${t.preserveCharacters}`);e+=To(r)}let n=t.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,n)}});function Yn(t){return Eu(t)}var Kg=S(()=>{Wg()});var Vn,Hg,zg=S(()=>{Vn={local:"local",ide:"ide",published:"published",inline:"inline"},Hg=Object.values(Vn).map(t=>`'${t}'`).join(" | ")});var ys,Au,Yg=S(()=>{ys=` *, *::before, *::after { box-sizing: border-box; }
169
+ `});function To(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Dg=S(()=>{});var vT,ST,Su,Bg=S(()=>{vT=[["\xDF","ss"],["\u1E9E","Ss"],["\xE4","ae"],["\xC4","Ae"],["\xF6","oe"],["\xD6","Oe"],["\xFC","ue"],["\xDC","Ue"],["\xC0","A"],["\xC1","A"],["\xC2","A"],["\xC3","A"],["\xC4","Ae"],["\xC5","A"],["\xC6","AE"],["\xC7","C"],["\xC8","E"],["\xC9","E"],["\xCA","E"],["\xCB","E"],["\u018F","A"],["\xCC","I"],["\xCD","I"],["\xCE","I"],["\xCF","I"],["\xD0","D"],["\xD1","N"],["\xD2","O"],["\xD3","O"],["\xD4","O"],["\xD5","O"],["\xD6","Oe"],["\u014C","O"],["\u0150","O"],["\xD8","O"],["\u0152","OE"],["\xD9","U"],["\xDA","U"],["\xDB","U"],["\xDC","Ue"],["\u0170","U"],["\xDD","Y"],["\xDE","TH"],["\xDF","ss"],["\xE0","a"],["\xE1","a"],["\xE2","a"],["\xE3","a"],["\xE4","ae"],["\xE5","a"],["\xE6","ae"],["\xE7","c"],["\xE8","e"],["\xE9","e"],["\xEA","e"],["\xEB","e"],["\u0259","a"],["\xEC","i"],["\xED","i"],["\xEE","i"],["\xEF","i"],["\xF0","d"],["\xF1","n"],["\xF2","o"],["\xF3","o"],["\xF4","o"],["\xF5","o"],["\xF6","oe"],["\u014D","o"],["\u0151","o"],["\xF8","o"],["\u0153","oe"],["\xF9","u"],["\xFA","u"],["\xFB","u"],["\xFC","ue"],["\u0171","u"],["\xFD","y"],["\xFE","th"],["\xFF","y"],["\xE0","a"],["\xC0","A"],["\xE1","a"],["\xC1","A"],["\xE2","a"],["\xC2","A"],["\xE3","a"],["\xC3","A"],["\xE8","e"],["\xC8","E"],["\xE9","e"],["\xC9","E"],["\xEA","e"],["\xCA","E"],["\xEC","i"],["\xCC","I"],["\xED","i"],["\xCD","I"],["\xF2","o"],["\xD2","O"],["\xF3","o"],["\xD3","O"],["\xF4","o"],["\xD4","O"],["\xF5","o"],["\xD5","O"],["\xF9","u"],["\xD9","U"],["\xFA","u"],["\xDA","U"],["\xFD","y"],["\xDD","Y"],["\u0103","a"],["\u0102","A"],["\u0110","D"],["\u0111","d"],["\u0129","i"],["\u0128","I"],["\u0169","u"],["\u0168","U"],["\u01A1","o"],["\u01A0","O"],["\u01B0","u"],["\u01AF","U"],["\u1EA1","a"],["\u1EA0","A"],["\u1EA3","a"],["\u1EA2","A"],["\u1EA5","a"],["\u1EA4","A"],["\u1EA7","a"],["\u1EA6","A"],["\u1EA9","a"],["\u1EA8","A"],["\u1EAB","a"],["\u1EAA","A"],["\u1EAD","a"],["\u1EAC","A"],["\u1EAF","a"],["\u1EAE","A"],["\u1EB1","a"],["\u1EB0","A"],["\u1EB3","a"],["\u1EB2","A"],["\u1EB5","a"],["\u1EB4","A"],["\u1EB7","a"],["\u1EB6","A"],["\u1EB9","e"],["\u1EB8","E"],["\u1EBB","e"],["\u1EBA","E"],["\u1EBD","e"],["\u1EBC","E"],["\u1EBF","e"],["\u1EBE","E"],["\u1EC1","e"],["\u1EC0","E"],["\u1EC3","e"],["\u1EC2","E"],["\u1EC5","e"],["\u1EC4","E"],["\u1EC7","e"],["\u1EC6","E"],["\u1EC9","i"],["\u1EC8","I"],["\u1ECB","i"],["\u1ECA","I"],["\u1ECD","o"],["\u1ECC","O"],["\u1ECF","o"],["\u1ECE","O"],["\u1ED1","o"],["\u1ED0","O"],["\u1ED3","o"],["\u1ED2","O"],["\u1ED5","o"],["\u1ED4","O"],["\u1ED7","o"],["\u1ED6","O"],["\u1ED9","o"],["\u1ED8","O"],["\u1EDB","o"],["\u1EDA","O"],["\u1EDD","o"],["\u1EDC","O"],["\u1EDF","o"],["\u1EDE","O"],["\u1EE1","o"],["\u1EE0","O"],["\u1EE3","o"],["\u1EE2","O"],["\u1EE5","u"],["\u1EE4","U"],["\u1EE7","u"],["\u1EE6","U"],["\u1EE9","u"],["\u1EE8","U"],["\u1EEB","u"],["\u1EEA","U"],["\u1EED","u"],["\u1EEC","U"],["\u1EEF","u"],["\u1EEE","U"],["\u1EF1","u"],["\u1EF0","U"],["\u1EF3","y"],["\u1EF2","Y"],["\u1EF5","y"],["\u1EF4","Y"],["\u1EF7","y"],["\u1EF6","Y"],["\u1EF9","y"],["\u1EF8","Y"],["\u0621","e"],["\u0622","a"],["\u0623","a"],["\u0624","w"],["\u0625","a"],["\u0626","y"],["\u0627","a"],["\u0628","b"],["\u0629","t"],["\u062A","t"],["\u062B","th"],["\u062C","j"],["\u062D","h"],["\u062E","kh"],["\u062F","d"],["\u0630","dh"],["\u0631","r"],["\u0632","z"],["\u0633","s"],["\u0634","sh"],["\u0635","s"],["\u0636","d"],["\u0637","t"],["\u0638","z"],["\u0639","e"],["\u063A","gh"],["\u0640","_"],["\u0641","f"],["\u0642","q"],["\u0643","k"],["\u0644","l"],["\u0645","m"],["\u0646","n"],["\u0647","h"],["\u0648","w"],["\u0649","a"],["\u064A","y"],["\u064E\u200E","a"],["\u064F","u"],["\u0650\u200E","i"],["\u0660","0"],["\u0661","1"],["\u0662","2"],["\u0663","3"],["\u0664","4"],["\u0665","5"],["\u0666","6"],["\u0667","7"],["\u0668","8"],["\u0669","9"],["\u0686","ch"],["\u06A9","k"],["\u06AF","g"],["\u067E","p"],["\u0698","zh"],["\u06CC","y"],["\u06F0","0"],["\u06F1","1"],["\u06F2","2"],["\u06F3","3"],["\u06F4","4"],["\u06F5","5"],["\u06F6","6"],["\u06F7","7"],["\u06F8","8"],["\u06F9","9"],["\u067C","p"],["\u0681","z"],["\u0685","c"],["\u0689","d"],["\uFEAB","d"],["\uFEAD","r"],["\u0693","r"],["\uFEAF","z"],["\u0696","g"],["\u069A","x"],["\u06AB","g"],["\u06BC","n"],["\u06C0","e"],["\u06D0","e"],["\u06CD","ai"],["\u0679","t"],["\u0688","d"],["\u0691","r"],["\u06BA","n"],["\u06C1","h"],["\u06BE","h"],["\u06D2","e"],["\u0410","A"],["\u0430","a"],["\u0411","B"],["\u0431","b"],["\u0412","V"],["\u0432","v"],["\u0413","G"],["\u0433","g"],["\u0414","D"],["\u0434","d"],["\u044A\u0435","ye"],["\u042A\u0435","Ye"],["\u044A\u0415","yE"],["\u042A\u0415","YE"],["\u0415","E"],["\u0435","e"],["\u0401","Yo"],["\u0451","yo"],["\u0416","Zh"],["\u0436","zh"],["\u0417","Z"],["\u0437","z"],["\u0418","I"],["\u0438","i"],["\u044B\u0439","iy"],["\u042B\u0439","Iy"],["\u042B\u0419","IY"],["\u044B\u0419","iY"],["\u0419","Y"],["\u0439","y"],["\u041A","K"],["\u043A","k"],["\u041B","L"],["\u043B","l"],["\u041C","M"],["\u043C","m"],["\u041D","N"],["\u043D","n"],["\u041E","O"],["\u043E","o"],["\u041F","P"],["\u043F","p"],["\u0420","R"],["\u0440","r"],["\u0421","S"],["\u0441","s"],["\u0422","T"],["\u0442","t"],["\u0423","U"],["\u0443","u"],["\u0424","F"],["\u0444","f"],["\u0425","Kh"],["\u0445","kh"],["\u0426","Ts"],["\u0446","ts"],["\u0427","Ch"],["\u0447","ch"],["\u0428","Sh"],["\u0448","sh"],["\u0429","Sch"],["\u0449","sch"],["\u042A",""],["\u044A",""],["\u042B","Y"],["\u044B","y"],["\u042C",""],["\u044C",""],["\u042D","E"],["\u044D","e"],["\u042E","Yu"],["\u044E","yu"],["\u042F","Ya"],["\u044F","ya"],["\u0103","a"],["\u0102","A"],["\u0219","s"],["\u0218","S"],["\u021B","t"],["\u021A","T"],["\u0163","t"],["\u0162","T"],["\u015F","s"],["\u015E","S"],["\xE7","c"],["\xC7","C"],["\u011F","g"],["\u011E","G"],["\u0131","i"],["\u0130","I"],["\u0561","a"],["\u0531","A"],["\u0562","b"],["\u0532","B"],["\u0563","g"],["\u0533","G"],["\u0564","d"],["\u0534","D"],["\u0565","ye"],["\u0535","Ye"],["\u0566","z"],["\u0536","Z"],["\u0567","e"],["\u0537","E"],["\u0568","y"],["\u0538","Y"],["\u0569","t"],["\u0539","T"],["\u056A","zh"],["\u053A","Zh"],["\u056B","i"],["\u053B","I"],["\u056C","l"],["\u053C","L"],["\u056D","kh"],["\u053D","Kh"],["\u056E","ts"],["\u053E","Ts"],["\u056F","k"],["\u053F","K"],["\u0570","h"],["\u0540","H"],["\u0571","dz"],["\u0541","Dz"],["\u0572","gh"],["\u0542","Gh"],["\u0573","tch"],["\u0543","Tch"],["\u0574","m"],["\u0544","M"],["\u0575","y"],["\u0545","Y"],["\u0576","n"],["\u0546","N"],["\u0577","sh"],["\u0547","Sh"],["\u0578\u0582","u"],["\u0548\u0552","U"],["\u0548\u0582","U"],["\u0578","vo"],["\u0548","Vo"],["\u0579","ch"],["\u0549","Ch"],["\u057A","p"],["\u054A","P"],["\u057B","j"],["\u054B","J"],["\u057C","r"],["\u054C","R"],["\u057D","s"],["\u054D","S"],["\u057E","v"],["\u054E","V"],["\u057F","t"],["\u054F","T"],["\u0580","r"],["\u0550","R"],["\u0581","c"],["\u0551","C"],["\u0583","p"],["\u0553","P"],["\u0584","q"],["\u0554","Q"],["\u0585","o"],["\u0555","O"],["\u0586","f"],["\u0556","F"],["\u0587","yev"],["\u10D0","a"],["\u10D1","b"],["\u10D2","g"],["\u10D3","d"],["\u10D4","e"],["\u10D5","v"],["\u10D6","z"],["\u10D7","t"],["\u10D8","i"],["\u10D9","k"],["\u10DA","l"],["\u10DB","m"],["\u10DC","n"],["\u10DD","o"],["\u10DE","p"],["\u10DF","zh"],["\u10E0","r"],["\u10E1","s"],["\u10E2","t"],["\u10E3","u"],["\u10E4","ph"],["\u10E5","q"],["\u10E6","gh"],["\u10E7","k"],["\u10E8","sh"],["\u10E9","ch"],["\u10EA","ts"],["\u10EB","dz"],["\u10EC","ts"],["\u10ED","tch"],["\u10EE","kh"],["\u10EF","j"],["\u10F0","h"],["\u010D","c"],["\u010F","d"],["\u011B","e"],["\u0148","n"],["\u0159","r"],["\u0161","s"],["\u0165","t"],["\u016F","u"],["\u017E","z"],["\u010C","C"],["\u010E","D"],["\u011A","E"],["\u0147","N"],["\u0158","R"],["\u0160","S"],["\u0164","T"],["\u016E","U"],["\u017D","Z"],["\u0780","h"],["\u0781","sh"],["\u0782","n"],["\u0783","r"],["\u0784","b"],["\u0785","lh"],["\u0786","k"],["\u0787","a"],["\u0788","v"],["\u0789","m"],["\u078A","f"],["\u078B","dh"],["\u078C","th"],["\u078D","l"],["\u078E","g"],["\u078F","gn"],["\u0790","s"],["\u0791","d"],["\u0792","z"],["\u0793","t"],["\u0794","y"],["\u0795","p"],["\u0796","j"],["\u0797","ch"],["\u0798","tt"],["\u0799","hh"],["\u079A","kh"],["\u079B","th"],["\u079C","z"],["\u079D","sh"],["\u079E","s"],["\u079F","d"],["\u07A0","t"],["\u07A1","z"],["\u07A2","a"],["\u07A3","gh"],["\u07A4","q"],["\u07A5","w"],["\u07A6","a"],["\u07A7","aa"],["\u07A8","i"],["\u07A9","ee"],["\u07AA","u"],["\u07AB","oo"],["\u07AC","e"],["\u07AD","ey"],["\u07AE","o"],["\u07AF","oa"],["\u07B0",""],["\u03B1","a"],["\u03B2","v"],["\u03B3","g"],["\u03B4","d"],["\u03B5","e"],["\u03B6","z"],["\u03B7","i"],["\u03B8","th"],["\u03B9","i"],["\u03BA","k"],["\u03BB","l"],["\u03BC","m"],["\u03BD","n"],["\u03BE","ks"],["\u03BF","o"],["\u03C0","p"],["\u03C1","r"],["\u03C3","s"],["\u03C4","t"],["\u03C5","y"],["\u03C6","f"],["\u03C7","x"],["\u03C8","ps"],["\u03C9","o"],["\u03AC","a"],["\u03AD","e"],["\u03AF","i"],["\u03CC","o"],["\u03CD","y"],["\u03AE","i"],["\u03CE","o"],["\u03C2","s"],["\u03CA","i"],["\u03B0","y"],["\u03CB","y"],["\u0390","i"],["\u0391","A"],["\u0392","B"],["\u0393","G"],["\u0394","D"],["\u0395","E"],["\u0396","Z"],["\u0397","I"],["\u0398","TH"],["\u0399","I"],["\u039A","K"],["\u039B","L"],["\u039C","M"],["\u039D","N"],["\u039E","KS"],["\u039F","O"],["\u03A0","P"],["\u03A1","R"],["\u03A3","S"],["\u03A4","T"],["\u03A5","Y"],["\u03A6","F"],["\u03A7","X"],["\u03A8","PS"],["\u03A9","O"],["\u0386","A"],["\u0388","E"],["\u038A","I"],["\u038C","O"],["\u038E","Y"],["\u0389","I"],["\u038F","O"],["\u03AA","I"],["\u03AB","Y"],["\u0101","a"],["\u0113","e"],["\u0123","g"],["\u012B","i"],["\u0137","k"],["\u013C","l"],["\u0146","n"],["\u016B","u"],["\u0100","A"],["\u0112","E"],["\u0122","G"],["\u012A","I"],["\u0136","K"],["\u013B","L"],["\u0145","N"],["\u016A","U"],["\u010D","c"],["\u0161","s"],["\u017E","z"],["\u010C","C"],["\u0160","S"],["\u017D","Z"],["\u0105","a"],["\u010D","c"],["\u0119","e"],["\u0117","e"],["\u012F","i"],["\u0161","s"],["\u0173","u"],["\u016B","u"],["\u017E","z"],["\u0104","A"],["\u010C","C"],["\u0118","E"],["\u0116","E"],["\u012E","I"],["\u0160","S"],["\u0172","U"],["\u016A","U"],["\u040C","Kj"],["\u045C","kj"],["\u0409","Lj"],["\u0459","lj"],["\u040A","Nj"],["\u045A","nj"],["\u0422\u0441","Ts"],["\u0442\u0441","ts"],["\u0105","a"],["\u0107","c"],["\u0119","e"],["\u0142","l"],["\u0144","n"],["\u015B","s"],["\u017A","z"],["\u017C","z"],["\u0104","A"],["\u0106","C"],["\u0118","E"],["\u0141","L"],["\u0143","N"],["\u015A","S"],["\u0179","Z"],["\u017B","Z"],["\u0404","Ye"],["\u0406","I"],["\u0407","Yi"],["\u0490","G"],["\u0454","ye"],["\u0456","i"],["\u0457","yi"],["\u0491","g"],["\u0132","IJ"],["\u0133","ij"],["\xA2","c"],["\xA5","Y"],["\u07FF","b"],["\u09F3","t"],["\u0AF1","Bo"],["\u0E3F","B"],["\u20A0","CE"],["\u20A1","C"],["\u20A2","Cr"],["\u20A3","F"],["\u20A5","m"],["\u20A6","N"],["\u20A7","Pt"],["\u20A8","Rs"],["\u20A9","W"],["\u20AB","s"],["\u20AC","E"],["\u20AD","K"],["\u20AE","T"],["\u20AF","Dp"],["\u20B0","S"],["\u20B1","P"],["\u20B2","G"],["\u20B3","A"],["\u20B4","S"],["\u20B5","C"],["\u20B6","tt"],["\u20B7","S"],["\u20B8","T"],["\u20B9","R"],["\u20BA","L"],["\u20BD","P"],["\u20BF","B"],["\uFE69","$"],["\uFFE0","c"],["\uFFE5","Y"],["\uFFE6","W"],["\u{1D400}","A"],["\u{1D401}","B"],["\u{1D402}","C"],["\u{1D403}","D"],["\u{1D404}","E"],["\u{1D405}","F"],["\u{1D406}","G"],["\u{1D407}","H"],["\u{1D408}","I"],["\u{1D409}","J"],["\u{1D40A}","K"],["\u{1D40B}","L"],["\u{1D40C}","M"],["\u{1D40D}","N"],["\u{1D40E}","O"],["\u{1D40F}","P"],["\u{1D410}","Q"],["\u{1D411}","R"],["\u{1D412}","S"],["\u{1D413}","T"],["\u{1D414}","U"],["\u{1D415}","V"],["\u{1D416}","W"],["\u{1D417}","X"],["\u{1D418}","Y"],["\u{1D419}","Z"],["\u{1D41A}","a"],["\u{1D41B}","b"],["\u{1D41C}","c"],["\u{1D41D}","d"],["\u{1D41E}","e"],["\u{1D41F}","f"],["\u{1D420}","g"],["\u{1D421}","h"],["\u{1D422}","i"],["\u{1D423}","j"],["\u{1D424}","k"],["\u{1D425}","l"],["\u{1D426}","m"],["\u{1D427}","n"],["\u{1D428}","o"],["\u{1D429}","p"],["\u{1D42A}","q"],["\u{1D42B}","r"],["\u{1D42C}","s"],["\u{1D42D}","t"],["\u{1D42E}","u"],["\u{1D42F}","v"],["\u{1D430}","w"],["\u{1D431}","x"],["\u{1D432}","y"],["\u{1D433}","z"],["\u{1D434}","A"],["\u{1D435}","B"],["\u{1D436}","C"],["\u{1D437}","D"],["\u{1D438}","E"],["\u{1D439}","F"],["\u{1D43A}","G"],["\u{1D43B}","H"],["\u{1D43C}","I"],["\u{1D43D}","J"],["\u{1D43E}","K"],["\u{1D43F}","L"],["\u{1D440}","M"],["\u{1D441}","N"],["\u{1D442}","O"],["\u{1D443}","P"],["\u{1D444}","Q"],["\u{1D445}","R"],["\u{1D446}","S"],["\u{1D447}","T"],["\u{1D448}","U"],["\u{1D449}","V"],["\u{1D44A}","W"],["\u{1D44B}","X"],["\u{1D44C}","Y"],["\u{1D44D}","Z"],["\u{1D44E}","a"],["\u{1D44F}","b"],["\u{1D450}","c"],["\u{1D451}","d"],["\u{1D452}","e"],["\u{1D453}","f"],["\u{1D454}","g"],["\u{1D456}","i"],["\u{1D457}","j"],["\u{1D458}","k"],["\u{1D459}","l"],["\u{1D45A}","m"],["\u{1D45B}","n"],["\u{1D45C}","o"],["\u{1D45D}","p"],["\u{1D45E}","q"],["\u{1D45F}","r"],["\u{1D460}","s"],["\u{1D461}","t"],["\u{1D462}","u"],["\u{1D463}","v"],["\u{1D464}","w"],["\u{1D465}","x"],["\u{1D466}","y"],["\u{1D467}","z"],["\u{1D468}","A"],["\u{1D469}","B"],["\u{1D46A}","C"],["\u{1D46B}","D"],["\u{1D46C}","E"],["\u{1D46D}","F"],["\u{1D46E}","G"],["\u{1D46F}","H"],["\u{1D470}","I"],["\u{1D471}","J"],["\u{1D472}","K"],["\u{1D473}","L"],["\u{1D474}","M"],["\u{1D475}","N"],["\u{1D476}","O"],["\u{1D477}","P"],["\u{1D478}","Q"],["\u{1D479}","R"],["\u{1D47A}","S"],["\u{1D47B}","T"],["\u{1D47C}","U"],["\u{1D47D}","V"],["\u{1D47E}","W"],["\u{1D47F}","X"],["\u{1D480}","Y"],["\u{1D481}","Z"],["\u{1D482}","a"],["\u{1D483}","b"],["\u{1D484}","c"],["\u{1D485}","d"],["\u{1D486}","e"],["\u{1D487}","f"],["\u{1D488}","g"],["\u{1D489}","h"],["\u{1D48A}","i"],["\u{1D48B}","j"],["\u{1D48C}","k"],["\u{1D48D}","l"],["\u{1D48E}","m"],["\u{1D48F}","n"],["\u{1D490}","o"],["\u{1D491}","p"],["\u{1D492}","q"],["\u{1D493}","r"],["\u{1D494}","s"],["\u{1D495}","t"],["\u{1D496}","u"],["\u{1D497}","v"],["\u{1D498}","w"],["\u{1D499}","x"],["\u{1D49A}","y"],["\u{1D49B}","z"],["\u{1D49C}","A"],["\u{1D49E}","C"],["\u{1D49F}","D"],["\u{1D4A2}","g"],["\u{1D4A5}","J"],["\u{1D4A6}","K"],["\u{1D4A9}","N"],["\u{1D4AA}","O"],["\u{1D4AB}","P"],["\u{1D4AC}","Q"],["\u{1D4AE}","S"],["\u{1D4AF}","T"],["\u{1D4B0}","U"],["\u{1D4B1}","V"],["\u{1D4B2}","W"],["\u{1D4B3}","X"],["\u{1D4B4}","Y"],["\u{1D4B5}","Z"],["\u{1D4B6}","a"],["\u{1D4B7}","b"],["\u{1D4B8}","c"],["\u{1D4B9}","d"],["\u{1D4BB}","f"],["\u{1D4BD}","h"],["\u{1D4BE}","i"],["\u{1D4BF}","j"],["\u{1D4C0}","k"],["\u{1D4C1}","l"],["\u{1D4C2}","m"],["\u{1D4C3}","n"],["\u{1D4C5}","p"],["\u{1D4C6}","q"],["\u{1D4C7}","r"],["\u{1D4C8}","s"],["\u{1D4C9}","t"],["\u{1D4CA}","u"],["\u{1D4CB}","v"],["\u{1D4CC}","w"],["\u{1D4CD}","x"],["\u{1D4CE}","y"],["\u{1D4CF}","z"],["\u{1D4D0}","A"],["\u{1D4D1}","B"],["\u{1D4D2}","C"],["\u{1D4D3}","D"],["\u{1D4D4}","E"],["\u{1D4D5}","F"],["\u{1D4D6}","G"],["\u{1D4D7}","H"],["\u{1D4D8}","I"],["\u{1D4D9}","J"],["\u{1D4DA}","K"],["\u{1D4DB}","L"],["\u{1D4DC}","M"],["\u{1D4DD}","N"],["\u{1D4DE}","O"],["\u{1D4DF}","P"],["\u{1D4E0}","Q"],["\u{1D4E1}","R"],["\u{1D4E2}","S"],["\u{1D4E3}","T"],["\u{1D4E4}","U"],["\u{1D4E5}","V"],["\u{1D4E6}","W"],["\u{1D4E7}","X"],["\u{1D4E8}","Y"],["\u{1D4E9}","Z"],["\u{1D4EA}","a"],["\u{1D4EB}","b"],["\u{1D4EC}","c"],["\u{1D4ED}","d"],["\u{1D4EE}","e"],["\u{1D4EF}","f"],["\u{1D4F0}","g"],["\u{1D4F1}","h"],["\u{1D4F2}","i"],["\u{1D4F3}","j"],["\u{1D4F4}","k"],["\u{1D4F5}","l"],["\u{1D4F6}","m"],["\u{1D4F7}","n"],["\u{1D4F8}","o"],["\u{1D4F9}","p"],["\u{1D4FA}","q"],["\u{1D4FB}","r"],["\u{1D4FC}","s"],["\u{1D4FD}","t"],["\u{1D4FE}","u"],["\u{1D4FF}","v"],["\u{1D500}","w"],["\u{1D501}","x"],["\u{1D502}","y"],["\u{1D503}","z"],["\u{1D504}","A"],["\u{1D505}","B"],["\u{1D507}","D"],["\u{1D508}","E"],["\u{1D509}","F"],["\u{1D50A}","G"],["\u{1D50D}","J"],["\u{1D50E}","K"],["\u{1D50F}","L"],["\u{1D510}","M"],["\u{1D511}","N"],["\u{1D512}","O"],["\u{1D513}","P"],["\u{1D514}","Q"],["\u{1D516}","S"],["\u{1D517}","T"],["\u{1D518}","U"],["\u{1D519}","V"],["\u{1D51A}","W"],["\u{1D51B}","X"],["\u{1D51C}","Y"],["\u{1D51E}","a"],["\u{1D51F}","b"],["\u{1D520}","c"],["\u{1D521}","d"],["\u{1D522}","e"],["\u{1D523}","f"],["\u{1D524}","g"],["\u{1D525}","h"],["\u{1D526}","i"],["\u{1D527}","j"],["\u{1D528}","k"],["\u{1D529}","l"],["\u{1D52A}","m"],["\u{1D52B}","n"],["\u{1D52C}","o"],["\u{1D52D}","p"],["\u{1D52E}","q"],["\u{1D52F}","r"],["\u{1D530}","s"],["\u{1D531}","t"],["\u{1D532}","u"],["\u{1D533}","v"],["\u{1D534}","w"],["\u{1D535}","x"],["\u{1D536}","y"],["\u{1D537}","z"],["\u{1D538}","A"],["\u{1D539}","B"],["\u{1D53B}","D"],["\u{1D53C}","E"],["\u{1D53D}","F"],["\u{1D53E}","G"],["\u{1D540}","I"],["\u{1D541}","J"],["\u{1D542}","K"],["\u{1D543}","L"],["\u{1D544}","M"],["\u{1D546}","O"],["\u{1D54A}","S"],["\u{1D54B}","T"],["\u{1D54C}","U"],["\u{1D54D}","V"],["\u{1D54E}","W"],["\u{1D54F}","X"],["\u{1D550}","Y"],["\u{1D552}","a"],["\u{1D553}","b"],["\u{1D554}","c"],["\u{1D555}","d"],["\u{1D556}","e"],["\u{1D557}","f"],["\u{1D558}","g"],["\u{1D559}","h"],["\u{1D55A}","i"],["\u{1D55B}","j"],["\u{1D55C}","k"],["\u{1D55D}","l"],["\u{1D55E}","m"],["\u{1D55F}","n"],["\u{1D560}","o"],["\u{1D561}","p"],["\u{1D562}","q"],["\u{1D563}","r"],["\u{1D564}","s"],["\u{1D565}","t"],["\u{1D566}","u"],["\u{1D567}","v"],["\u{1D568}","w"],["\u{1D569}","x"],["\u{1D56A}","y"],["\u{1D56B}","z"],["\u{1D56C}","A"],["\u{1D56D}","B"],["\u{1D56E}","C"],["\u{1D56F}","D"],["\u{1D570}","E"],["\u{1D571}","F"],["\u{1D572}","G"],["\u{1D573}","H"],["\u{1D574}","I"],["\u{1D575}","J"],["\u{1D576}","K"],["\u{1D577}","L"],["\u{1D578}","M"],["\u{1D579}","N"],["\u{1D57A}","O"],["\u{1D57B}","P"],["\u{1D57C}","Q"],["\u{1D57D}","R"],["\u{1D57E}","S"],["\u{1D57F}","T"],["\u{1D580}","U"],["\u{1D581}","V"],["\u{1D582}","W"],["\u{1D583}","X"],["\u{1D584}","Y"],["\u{1D585}","Z"],["\u{1D586}","a"],["\u{1D587}","b"],["\u{1D588}","c"],["\u{1D589}","d"],["\u{1D58A}","e"],["\u{1D58B}","f"],["\u{1D58C}","g"],["\u{1D58D}","h"],["\u{1D58E}","i"],["\u{1D58F}","j"],["\u{1D590}","k"],["\u{1D591}","l"],["\u{1D592}","m"],["\u{1D593}","n"],["\u{1D594}","o"],["\u{1D595}","p"],["\u{1D596}","q"],["\u{1D597}","r"],["\u{1D598}","s"],["\u{1D599}","t"],["\u{1D59A}","u"],["\u{1D59B}","v"],["\u{1D59C}","w"],["\u{1D59D}","x"],["\u{1D59E}","y"],["\u{1D59F}","z"],["\u{1D5A0}","A"],["\u{1D5A1}","B"],["\u{1D5A2}","C"],["\u{1D5A3}","D"],["\u{1D5A4}","E"],["\u{1D5A5}","F"],["\u{1D5A6}","G"],["\u{1D5A7}","H"],["\u{1D5A8}","I"],["\u{1D5A9}","J"],["\u{1D5AA}","K"],["\u{1D5AB}","L"],["\u{1D5AC}","M"],["\u{1D5AD}","N"],["\u{1D5AE}","O"],["\u{1D5AF}","P"],["\u{1D5B0}","Q"],["\u{1D5B1}","R"],["\u{1D5B2}","S"],["\u{1D5B3}","T"],["\u{1D5B4}","U"],["\u{1D5B5}","V"],["\u{1D5B6}","W"],["\u{1D5B7}","X"],["\u{1D5B8}","Y"],["\u{1D5B9}","Z"],["\u{1D5BA}","a"],["\u{1D5BB}","b"],["\u{1D5BC}","c"],["\u{1D5BD}","d"],["\u{1D5BE}","e"],["\u{1D5BF}","f"],["\u{1D5C0}","g"],["\u{1D5C1}","h"],["\u{1D5C2}","i"],["\u{1D5C3}","j"],["\u{1D5C4}","k"],["\u{1D5C5}","l"],["\u{1D5C6}","m"],["\u{1D5C7}","n"],["\u{1D5C8}","o"],["\u{1D5C9}","p"],["\u{1D5CA}","q"],["\u{1D5CB}","r"],["\u{1D5CC}","s"],["\u{1D5CD}","t"],["\u{1D5CE}","u"],["\u{1D5CF}","v"],["\u{1D5D0}","w"],["\u{1D5D1}","x"],["\u{1D5D2}","y"],["\u{1D5D3}","z"],["\u{1D5D4}","A"],["\u{1D5D5}","B"],["\u{1D5D6}","C"],["\u{1D5D7}","D"],["\u{1D5D8}","E"],["\u{1D5D9}","F"],["\u{1D5DA}","G"],["\u{1D5DB}","H"],["\u{1D5DC}","I"],["\u{1D5DD}","J"],["\u{1D5DE}","K"],["\u{1D5DF}","L"],["\u{1D5E0}","M"],["\u{1D5E1}","N"],["\u{1D5E2}","O"],["\u{1D5E3}","P"],["\u{1D5E4}","Q"],["\u{1D5E5}","R"],["\u{1D5E6}","S"],["\u{1D5E7}","T"],["\u{1D5E8}","U"],["\u{1D5E9}","V"],["\u{1D5EA}","W"],["\u{1D5EB}","X"],["\u{1D5EC}","Y"],["\u{1D5ED}","Z"],["\u{1D5EE}","a"],["\u{1D5EF}","b"],["\u{1D5F0}","c"],["\u{1D5F1}","d"],["\u{1D5F2}","e"],["\u{1D5F3}","f"],["\u{1D5F4}","g"],["\u{1D5F5}","h"],["\u{1D5F6}","i"],["\u{1D5F7}","j"],["\u{1D5F8}","k"],["\u{1D5F9}","l"],["\u{1D5FA}","m"],["\u{1D5FB}","n"],["\u{1D5FC}","o"],["\u{1D5FD}","p"],["\u{1D5FE}","q"],["\u{1D5FF}","r"],["\u{1D600}","s"],["\u{1D601}","t"],["\u{1D602}","u"],["\u{1D603}","v"],["\u{1D604}","w"],["\u{1D605}","x"],["\u{1D606}","y"],["\u{1D607}","z"],["\u{1D608}","A"],["\u{1D609}","B"],["\u{1D60A}","C"],["\u{1D60B}","D"],["\u{1D60C}","E"],["\u{1D60D}","F"],["\u{1D60E}","G"],["\u{1D60F}","H"],["\u{1D610}","I"],["\u{1D611}","J"],["\u{1D612}","K"],["\u{1D613}","L"],["\u{1D614}","M"],["\u{1D615}","N"],["\u{1D616}","O"],["\u{1D617}","P"],["\u{1D618}","Q"],["\u{1D619}","R"],["\u{1D61A}","S"],["\u{1D61B}","T"],["\u{1D61C}","U"],["\u{1D61D}","V"],["\u{1D61E}","W"],["\u{1D61F}","X"],["\u{1D620}","Y"],["\u{1D621}","Z"],["\u{1D622}","a"],["\u{1D623}","b"],["\u{1D624}","c"],["\u{1D625}","d"],["\u{1D626}","e"],["\u{1D627}","f"],["\u{1D628}","g"],["\u{1D629}","h"],["\u{1D62A}","i"],["\u{1D62B}","j"],["\u{1D62C}","k"],["\u{1D62D}","l"],["\u{1D62E}","m"],["\u{1D62F}","n"],["\u{1D630}","o"],["\u{1D631}","p"],["\u{1D632}","q"],["\u{1D633}","r"],["\u{1D634}","s"],["\u{1D635}","t"],["\u{1D636}","u"],["\u{1D637}","v"],["\u{1D638}","w"],["\u{1D639}","x"],["\u{1D63A}","y"],["\u{1D63B}","z"],["\u{1D63C}","A"],["\u{1D63D}","B"],["\u{1D63E}","C"],["\u{1D63F}","D"],["\u{1D640}","E"],["\u{1D641}","F"],["\u{1D642}","G"],["\u{1D643}","H"],["\u{1D644}","I"],["\u{1D645}","J"],["\u{1D646}","K"],["\u{1D647}","L"],["\u{1D648}","M"],["\u{1D649}","N"],["\u{1D64A}","O"],["\u{1D64B}","P"],["\u{1D64C}","Q"],["\u{1D64D}","R"],["\u{1D64E}","S"],["\u{1D64F}","T"],["\u{1D650}","U"],["\u{1D651}","V"],["\u{1D652}","W"],["\u{1D653}","X"],["\u{1D654}","Y"],["\u{1D655}","Z"],["\u{1D656}","a"],["\u{1D657}","b"],["\u{1D658}","c"],["\u{1D659}","d"],["\u{1D65A}","e"],["\u{1D65B}","f"],["\u{1D65C}","g"],["\u{1D65D}","h"],["\u{1D65E}","i"],["\u{1D65F}","j"],["\u{1D660}","k"],["\u{1D661}","l"],["\u{1D662}","m"],["\u{1D663}","n"],["\u{1D664}","o"],["\u{1D665}","p"],["\u{1D666}","q"],["\u{1D667}","r"],["\u{1D668}","s"],["\u{1D669}","t"],["\u{1D66A}","u"],["\u{1D66B}","v"],["\u{1D66C}","w"],["\u{1D66D}","x"],["\u{1D66E}","y"],["\u{1D66F}","z"],["\u{1D670}","A"],["\u{1D671}","B"],["\u{1D672}","C"],["\u{1D673}","D"],["\u{1D674}","E"],["\u{1D675}","F"],["\u{1D676}","G"],["\u{1D677}","H"],["\u{1D678}","I"],["\u{1D679}","J"],["\u{1D67A}","K"],["\u{1D67B}","L"],["\u{1D67C}","M"],["\u{1D67D}","N"],["\u{1D67E}","O"],["\u{1D67F}","P"],["\u{1D680}","Q"],["\u{1D681}","R"],["\u{1D682}","S"],["\u{1D683}","T"],["\u{1D684}","U"],["\u{1D685}","V"],["\u{1D686}","W"],["\u{1D687}","X"],["\u{1D688}","Y"],["\u{1D689}","Z"],["\u{1D68A}","a"],["\u{1D68B}","b"],["\u{1D68C}","c"],["\u{1D68D}","d"],["\u{1D68E}","e"],["\u{1D68F}","f"],["\u{1D690}","g"],["\u{1D691}","h"],["\u{1D692}","i"],["\u{1D693}","j"],["\u{1D694}","k"],["\u{1D695}","l"],["\u{1D696}","m"],["\u{1D697}","n"],["\u{1D698}","o"],["\u{1D699}","p"],["\u{1D69A}","q"],["\u{1D69B}","r"],["\u{1D69C}","s"],["\u{1D69D}","t"],["\u{1D69E}","u"],["\u{1D69F}","v"],["\u{1D6A0}","w"],["\u{1D6A1}","x"],["\u{1D6A2}","y"],["\u{1D6A3}","z"],["\u{1D6A4}","l"],["\u{1D6A5}","j"],["\u{1D6E2}","A"],["\u{1D6E3}","B"],["\u{1D6E4}","G"],["\u{1D6E5}","D"],["\u{1D6E6}","E"],["\u{1D6E7}","Z"],["\u{1D6E8}","I"],["\u{1D6E9}","TH"],["\u{1D6EA}","I"],["\u{1D6EB}","K"],["\u{1D6EC}","L"],["\u{1D6ED}","M"],["\u{1D6EE}","N"],["\u{1D6EF}","KS"],["\u{1D6F0}","O"],["\u{1D6F1}","P"],["\u{1D6F2}","R"],["\u{1D6F3}","TH"],["\u{1D6F4}","S"],["\u{1D6F5}","T"],["\u{1D6F6}","Y"],["\u{1D6F7}","F"],["\u{1D6F8}","x"],["\u{1D6F9}","PS"],["\u{1D6FA}","O"],["\u{1D6FB}","D"],["\u{1D6FC}","a"],["\u{1D6FD}","b"],["\u{1D6FE}","g"],["\u{1D6FF}","d"],["\u{1D700}","e"],["\u{1D701}","z"],["\u{1D702}","i"],["\u{1D703}","th"],["\u{1D704}","i"],["\u{1D705}","k"],["\u{1D706}","l"],["\u{1D707}","m"],["\u{1D708}","n"],["\u{1D709}","ks"],["\u{1D70A}","o"],["\u{1D70B}","p"],["\u{1D70C}","r"],["\u{1D70D}","s"],["\u{1D70E}","s"],["\u{1D70F}","t"],["\u{1D710}","y"],["\u{1D711}","f"],["\u{1D712}","x"],["\u{1D713}","ps"],["\u{1D714}","o"],["\u{1D715}","d"],["\u{1D716}","E"],["\u{1D717}","TH"],["\u{1D718}","K"],["\u{1D719}","f"],["\u{1D71A}","r"],["\u{1D71B}","p"],["\u{1D71C}","A"],["\u{1D71D}","V"],["\u{1D71E}","G"],["\u{1D71F}","D"],["\u{1D720}","E"],["\u{1D721}","Z"],["\u{1D722}","I"],["\u{1D723}","TH"],["\u{1D724}","I"],["\u{1D725}","K"],["\u{1D726}","L"],["\u{1D727}","M"],["\u{1D728}","N"],["\u{1D729}","KS"],["\u{1D72A}","O"],["\u{1D72B}","P"],["\u{1D72C}","S"],["\u{1D72D}","TH"],["\u{1D72E}","S"],["\u{1D72F}","T"],["\u{1D730}","Y"],["\u{1D731}","F"],["\u{1D732}","X"],["\u{1D733}","PS"],["\u{1D734}","O"],["\u{1D735}","D"],["\u{1D736}","a"],["\u{1D737}","v"],["\u{1D738}","g"],["\u{1D739}","d"],["\u{1D73A}","e"],["\u{1D73B}","z"],["\u{1D73C}","i"],["\u{1D73D}","th"],["\u{1D73E}","i"],["\u{1D73F}","k"],["\u{1D740}","l"],["\u{1D741}","m"],["\u{1D742}","n"],["\u{1D743}","ks"],["\u{1D744}","o"],["\u{1D745}","p"],["\u{1D746}","r"],["\u{1D747}","s"],["\u{1D748}","s"],["\u{1D749}","t"],["\u{1D74A}","y"],["\u{1D74B}","f"],["\u{1D74C}","x"],["\u{1D74D}","ps"],["\u{1D74E}","o"],["\u{1D74F}","a"],["\u{1D750}","e"],["\u{1D751}","i"],["\u{1D752}","k"],["\u{1D753}","f"],["\u{1D754}","r"],["\u{1D755}","p"],["\u{1D756}","A"],["\u{1D757}","B"],["\u{1D758}","G"],["\u{1D759}","D"],["\u{1D75A}","E"],["\u{1D75B}","Z"],["\u{1D75C}","I"],["\u{1D75D}","TH"],["\u{1D75E}","I"],["\u{1D75F}","K"],["\u{1D760}","L"],["\u{1D761}","M"],["\u{1D762}","N"],["\u{1D763}","KS"],["\u{1D764}","O"],["\u{1D765}","P"],["\u{1D766}","R"],["\u{1D767}","TH"],["\u{1D768}","S"],["\u{1D769}","T"],["\u{1D76A}","Y"],["\u{1D76B}","F"],["\u{1D76C}","X"],["\u{1D76D}","PS"],["\u{1D76E}","O"],["\u{1D76F}","D"],["\u{1D770}","a"],["\u{1D771}","v"],["\u{1D772}","g"],["\u{1D773}","d"],["\u{1D774}","e"],["\u{1D775}","z"],["\u{1D776}","i"],["\u{1D777}","th"],["\u{1D778}","i"],["\u{1D779}","k"],["\u{1D77A}","l"],["\u{1D77B}","m"],["\u{1D77C}","n"],["\u{1D77D}","ks"],["\u{1D77E}","o"],["\u{1D77F}","p"],["\u{1D780}","r"],["\u{1D781}","s"],["\u{1D782}","s"],["\u{1D783}","t"],["\u{1D784}","y"],["\u{1D785}","f"],["\u{1D786}","x"],["\u{1D787}","ps"],["\u{1D788}","o"],["\u{1D789}","a"],["\u{1D78A}","e"],["\u{1D78B}","i"],["\u{1D78C}","k"],["\u{1D78D}","f"],["\u{1D78E}","r"],["\u{1D78F}","p"],["\u{1D790}","A"],["\u{1D791}","V"],["\u{1D792}","G"],["\u{1D793}","D"],["\u{1D794}","E"],["\u{1D795}","Z"],["\u{1D796}","I"],["\u{1D797}","TH"],["\u{1D798}","I"],["\u{1D799}","K"],["\u{1D79A}","L"],["\u{1D79B}","M"],["\u{1D79C}","N"],["\u{1D79D}","KS"],["\u{1D79E}","O"],["\u{1D79F}","P"],["\u{1D7A0}","S"],["\u{1D7A1}","TH"],["\u{1D7A2}","S"],["\u{1D7A3}","T"],["\u{1D7A4}","Y"],["\u{1D7A5}","F"],["\u{1D7A6}","X"],["\u{1D7A7}","PS"],["\u{1D7A8}","O"],["\u{1D7A9}","D"],["\u{1D7AA}","av"],["\u{1D7AB}","g"],["\u{1D7AC}","d"],["\u{1D7AD}","e"],["\u{1D7AE}","z"],["\u{1D7AF}","i"],["\u{1D7B0}","i"],["\u{1D7B1}","th"],["\u{1D7B2}","i"],["\u{1D7B3}","k"],["\u{1D7B4}","l"],["\u{1D7B5}","m"],["\u{1D7B6}","n"],["\u{1D7B7}","ks"],["\u{1D7B8}","o"],["\u{1D7B9}","p"],["\u{1D7BA}","r"],["\u{1D7BB}","s"],["\u{1D7BC}","s"],["\u{1D7BD}","t"],["\u{1D7BE}","y"],["\u{1D7BF}","f"],["\u{1D7C0}","x"],["\u{1D7C1}","ps"],["\u{1D7C2}","o"],["\u{1D7C3}","a"],["\u{1D7C4}","e"],["\u{1D7C5}","i"],["\u{1D7C6}","k"],["\u{1D7C7}","f"],["\u{1D7C8}","r"],["\u{1D7C9}","p"],["\u{1D7CA}","F"],["\u{1D7CB}","f"],["\u249C","(a)"],["\u249D","(b)"],["\u249E","(c)"],["\u249F","(d)"],["\u24A0","(e)"],["\u24A1","(f)"],["\u24A2","(g)"],["\u24A3","(h)"],["\u24A4","(i)"],["\u24A5","(j)"],["\u24A6","(k)"],["\u24A7","(l)"],["\u24A8","(m)"],["\u24A9","(n)"],["\u24AA","(o)"],["\u24AB","(p)"],["\u24AC","(q)"],["\u24AD","(r)"],["\u24AE","(s)"],["\u24AF","(t)"],["\u24B0","(u)"],["\u24B1","(v)"],["\u24B2","(w)"],["\u24B3","(x)"],["\u24B4","(y)"],["\u24B5","(z)"],["\u24B6","(A)"],["\u24B7","(B)"],["\u24B8","(C)"],["\u24B9","(D)"],["\u24BA","(E)"],["\u24BB","(F)"],["\u24BC","(G)"],["\u24BD","(H)"],["\u24BE","(I)"],["\u24BF","(J)"],["\u24C0","(K)"],["\u24C1","(L)"],["\u24C3","(N)"],["\u24C4","(O)"],["\u24C5","(P)"],["\u24C6","(Q)"],["\u24C7","(R)"],["\u24C8","(S)"],["\u24C9","(T)"],["\u24CA","(U)"],["\u24CB","(V)"],["\u24CC","(W)"],["\u24CD","(X)"],["\u24CE","(Y)"],["\u24CF","(Z)"],["\u24D0","(a)"],["\u24D1","(b)"],["\u24D2","(c)"],["\u24D3","(d)"],["\u24D4","(e)"],["\u24D5","(f)"],["\u24D6","(g)"],["\u24D7","(h)"],["\u24D8","(i)"],["\u24D9","(j)"],["\u24DA","(k)"],["\u24DB","(l)"],["\u24DC","(m)"],["\u24DD","(n)"],["\u24DE","(o)"],["\u24DF","(p)"],["\u24E0","(q)"],["\u24E1","(r)"],["\u24E2","(s)"],["\u24E3","(t)"],["\u24E4","(u)"],["\u24E5","(v)"],["\u24E6","(w)"],["\u24E7","(x)"],["\u24E8","(y)"],["\u24E9","(z)"],["\u010A","C"],["\u010B","c"],["\u0120","G"],["\u0121","g"],["\u0126","H"],["\u0127","h"],["\u017B","Z"],["\u017C","z"],["\u{1D7CE}","0"],["\u{1D7CF}","1"],["\u{1D7D0}","2"],["\u{1D7D1}","3"],["\u{1D7D2}","4"],["\u{1D7D3}","5"],["\u{1D7D4}","6"],["\u{1D7D5}","7"],["\u{1D7D6}","8"],["\u{1D7D7}","9"],["\u{1D7D8}","0"],["\u{1D7D9}","1"],["\u{1D7DA}","2"],["\u{1D7DB}","3"],["\u{1D7DC}","4"],["\u{1D7DD}","5"],["\u{1D7DE}","6"],["\u{1D7DF}","7"],["\u{1D7E0}","8"],["\u{1D7E1}","9"],["\u{1D7E2}","0"],["\u{1D7E3}","1"],["\u{1D7E4}","2"],["\u{1D7E5}","3"],["\u{1D7E6}","4"],["\u{1D7E7}","5"],["\u{1D7E8}","6"],["\u{1D7E9}","7"],["\u{1D7EA}","8"],["\u{1D7EB}","9"],["\u{1D7EC}","0"],["\u{1D7ED}","1"],["\u{1D7EE}","2"],["\u{1D7EF}","3"],["\u{1D7F0}","4"],["\u{1D7F1}","5"],["\u{1D7F2}","6"],["\u{1D7F3}","7"],["\u{1D7F4}","8"],["\u{1D7F5}","9"],["\u{1D7F6}","0"],["\u{1D7F7}","1"],["\u{1D7F8}","2"],["\u{1D7F9}","3"],["\u{1D7FA}","4"],["\u{1D7FB}","5"],["\u{1D7FC}","6"],["\u{1D7FD}","7"],["\u{1D7FE}","8"],["\u{1D7FF}","9"],["\u2460","1"],["\u2461","2"],["\u2462","3"],["\u2463","4"],["\u2464","5"],["\u2465","6"],["\u2466","7"],["\u2467","8"],["\u2468","9"],["\u2469","10"],["\u246A","11"],["\u246B","12"],["\u246C","13"],["\u246D","14"],["\u246E","15"],["\u246F","16"],["\u2470","17"],["\u2471","18"],["\u2472","19"],["\u2473","20"],["\u2474","1"],["\u2475","2"],["\u2476","3"],["\u2477","4"],["\u2478","5"],["\u2479","6"],["\u247A","7"],["\u247B","8"],["\u247C","9"],["\u247D","10"],["\u247E","11"],["\u247F","12"],["\u2480","13"],["\u2481","14"],["\u2482","15"],["\u2483","16"],["\u2484","17"],["\u2485","18"],["\u2486","19"],["\u2487","20"],["\u2488","1."],["\u2489","2."],["\u248A","3."],["\u248B","4."],["\u248C","5."],["\u248D","6."],["\u248E","7."],["\u248F","8."],["\u2490","9."],["\u2491","10."],["\u2492","11."],["\u2493","12."],["\u2494","13."],["\u2495","14."],["\u2496","15."],["\u2497","16."],["\u2498","17."],["\u2499","18."],["\u249A","19."],["\u249B","20."],["\u24EA","0"],["\u24EB","11"],["\u24EC","12"],["\u24ED","13"],["\u24EE","14"],["\u24EF","15"],["\u24F0","16"],["\u24F1","17"],["\u24F2","18"],["\u24F3","19"],["\u24F4","20"],["\u24F5","1"],["\u24F6","2"],["\u24F7","3"],["\u24F8","4"],["\u24F9","5"],["\u24FA","6"],["\u24FB","7"],["\u24FC","8"],["\u24FD","9"],["\u24FE","10"],["\u24FF","0"],["\u{1F670}","&"],["\u{1F671}","&"],["\u{1F672}","&"],["\u{1F673}","&"],["\u{1F674}","&"],["\u{1F675}","&"],["\u{1F676}",'"'],["\u{1F677}",'"'],["\u{1F678}",'"'],["\u203D","?!"],["\u{1F679}","?!"],["\u{1F67A}","?!"],["\u{1F67B}","?!"],["\u{1F67C}","/"],["\u{1F67D}","\\"],["\u{1F707}","AR"],["\u{1F708}","V"],["\u{1F709}","V"],["\u{1F706}","VR"],["\u{1F705}","VF"],["\u{1F729}","2"],["\u{1F72A}","5"],["\u{1F761}","f"],["\u{1F762}","W"],["\u{1F763}","U"],["\u{1F767}","V"],["\u{1F768}","T"],["\u{1F76A}","V"],["\u{1F76B}","MB"],["\u{1F76C}","VB"],["\u{1F772}","3B"],["\u{1F773}","3B"],["\u{1F4AF}","100"],["\u{1F519}","BACK"],["\u{1F51A}","END"],["\u{1F51B}","ON!"],["\u{1F51C}","SOON"],["\u{1F51D}","TOP"],["\u{1F51E}","18"],["\u{1F524}","abc"],["\u{1F520}","ABCD"],["\u{1F521}","abcd"],["\u{1F522}","1234"],["\u{1F523}","T&@%"],["#\uFE0F\u20E3","#"],["*\uFE0F\u20E3","*"],["0\uFE0F\u20E3","0"],["1\uFE0F\u20E3","1"],["2\uFE0F\u20E3","2"],["3\uFE0F\u20E3","3"],["4\uFE0F\u20E3","4"],["5\uFE0F\u20E3","5"],["6\uFE0F\u20E3","6"],["7\uFE0F\u20E3","7"],["8\uFE0F\u20E3","8"],["9\uFE0F\u20E3","9"],["\u{1F51F}","10"],["\u{1F170}\uFE0F","A"],["\u{1F171}\uFE0F","B"],["\u{1F18E}","AB"],["\u{1F191}","CL"],["\u{1F17E}\uFE0F","O"],["\u{1F17F}","P"],["\u{1F198}","SOS"],["\u{1F172}","C"],["\u{1F173}","D"],["\u{1F174}","E"],["\u{1F175}","F"],["\u{1F176}","G"],["\u{1F177}","H"],["\u{1F178}","I"],["\u{1F179}","J"],["\u{1F17A}","K"],["\u{1F17B}","L"],["\u{1F17C}","M"],["\u{1F17D}","N"],["\u{1F180}","Q"],["\u{1F181}","R"],["\u{1F182}","S"],["\u{1F183}","T"],["\u{1F184}","U"],["\u{1F185}","V"],["\u{1F186}","W"],["\u{1F187}","X"],["\u{1F188}","Y"],["\u{1F189}","Z"],["\u2212","-"],["\u2053","-"]],ST=new Map(vT),Su=ST});var jg,Oo,ku,Fg=S(()=>{jg=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],Oo={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:jg,nb:jg,de:[["\xE4","ae"],["\xC4","Ae"],["\xF6","oe"],["\xD6","Oe"],["\xFC","ue"],["\xDC","Ue"],["\xDF","ss"],["\u1E9E","Ss"]],tr:[["\xE2","a"],["\xC2","A"],["\xF6","o"],["\xD6","O"],["\xFC","u"],["\xDC","U"]],hu:[["\u0171","u"],["\u0170","U"],["\xF6","o"],["\xD6","O"],["\xFC","u"],["\xDC","U"],["\xE1","a"],["\xC1","A"],["\xE9","e"],["\xC9","E"],["\xED","i"],["\xCD","I"],["\xF3","o"],["\xD3","O"],["\xFA","u"],["\xDA","U"]],sr:[["\u0452","dj"],["\u0402","Dj"],["\u045F","dz"],["\u040F","Dz"],["\u0459","lj"],["\u0409","Lj"],["\u045A","nj"],["\u040A","Nj"],["\u045B","c"],["\u040B","C"],["\u0447","ch"],["\u0427","Ch"],["\u0448","sh"],["\u0428","Sh"],["\u0436","zh"],["\u0416","Zh"]]};for(let t of Object.keys(Oo))Oo[t]=new Map(Oo[t]);ku=Oo});function xu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={customReplacements:[],...e};let n=xT(e.locale),r=Su,s=e.customReplacements.length>0||e.customReplacements.size>0;if(n||s){if(r=new Map(Su),n)for(let[i,o]of n)r.set(i,o);for(let[i,o]of e.customReplacements)r.set(i,o)}return t=t.normalize(),t=kT(t,r),t=t.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),t=t.replaceAll(/\p{Dash_Punctuation}/gu,"-"),t}var kT,xT,Ug=S(()=>{Bg();Fg();kT=(t,e)=>{for(let[n,r]of e)t=t.replaceAll(n,r);return t},xT=t=>{if(!t)return;let e=t.toLowerCase().replace(/^no(-|$)/,"nb$1");return ku[e]||ku[e.split("-")[0]]||void 0}});var ET,qg,Jg=S(()=>{ET=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],qg=ET});function Eu(t,e){if(typeof t!="string")throw new TypeError(`Expected a string, got \`${typeof t}\``);e={separator:"-",lowercase:!0,decamelize:!0,customReplacements:[],preserveLeadingUnderscore:!1,preserveTrailingDash:!1,preserveCharacters:[],transliterate:!0,...e};let n=e.preserveLeadingUnderscore&&t.startsWith("_"),r=e.preserveTrailingDash&&t.endsWith("-");if(e.transliterate){let i=new Map([...qg,...e.customReplacements]);t=xu(t,{customReplacements:i,locale:e.locale})}else if(e.customReplacements.length>0)for(let[i,o]of e.customReplacements)t=t.replaceAll(i,o);e.decamelize&&(t=AT(t));let s=OT(e);return e.lowercase&&(t=e.locale?t.toLocaleLowerCase(e.locale):t.toLowerCase()),t=t.replaceAll(/([a-zA-Z\d]+)['\u2019]([ts])(\s|$)/g,"$1$2$3"),t=t.replace(s,e.separator),t=t.replaceAll("\\",""),e.separator&&(t=TT(t,e.separator)),n&&(t=`_${t}`),r&&(t=`${t}-`),t}var AT,TT,OT,Wg=S(()=>{Dg();Ug();Jg();AT=t=>t.replaceAll(/([A-Z]{2,})(\d+)/g,"$1 $2").replaceAll(/([a-z\d]+)([A-Z]{2,})/g,"$1 $2").replaceAll(/([a-z\d])([A-Z])/g,"$1 $2").replaceAll(/([A-Z]+)([A-Z][a-rt-z\d]+)/g,"$1 $2"),TT=(t,e)=>{let n=To(e);return t.replaceAll(new RegExp(`(?:${n}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${n})|(?:${n})$`,"g"),"")},OT=t=>{let e=String.raw`a-z\d`;if(e+=t.lowercase?"":"A-Z",t.transliterate===!1&&(e+=String.raw`\p{L}\p{N}`),t.preserveCharacters.length>0)for(let r of t.preserveCharacters){if(r===t.separator)throw new Error(`The separator character \`${t.separator}\` cannot be included in preserved characters: ${t.preserveCharacters}`);e+=To(r)}let n=t.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,n)}});function Yn(t){return Eu(t)}var Kg=S(()=>{Wg()});var Vn,Hg,zg=S(()=>{Vn={local:"local",ide:"ide",published:"published",inline:"inline"},Hg=Object.values(Vn).map(t=>`'${t}'`).join(" | ")});var bs,Au,Yg=S(()=>{bs=` *, *::before, *::after { box-sizing: border-box; }
170
170
  canvas { max-width: 100%; }
171
171
  body { margin: 0; display: flow-root; font-family: system-ui, -apple-system, sans-serif; }
172
172
  html[data-theme="dark"] { color-scheme: dark; }
@@ -292,40 +292,40 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
292
292
  return publish();
293
293
  }
294
294
  };
295
- })();`});var ee=S(()=>{xi();$l();Np();Dp();vu();Mg();Kg();zg();Yg();Gg();Qg();Ei()});function Se(t){let e=Math.max(0,Math.round(t/1e3));if(e<60)return`${e}s`;let n=Math.floor(e/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function ny(t,e){if(!e)return t;let n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return n.toLowerCase().startsWith(r.toLowerCase()+"/")?n.slice(r.length+1):t}function Ou(t){return t.replace(/[/\\]+$/,"").split(/[/\\]/).pop()??""}function Pu(t){return!t||typeof t!="object"?"":ge(t.command)??ge(t.file_path)??ge(t.filePath)??ge(t.path)??ge(t.pattern)??ge(t.query)??ge(t.url)??ge(t.skill)??ge(t.description)??""}function Cu(t){let e=/^mcp__(.+?)__(.+)$/.exec(t);return e?`${e[1][0].toUpperCase()}${e[1].slice(1)} [${e[2]}]`:t}var ge,bs,ey,ty,Po=S(()=>{"use strict";ge=t=>typeof t=="string"?t:void 0,bs=t=>t.replace(/\u001b\[[0-9;]*m/g,""),ey=t=>` (+${t} line${t===1?"":"s"})`,ty=/ \(\+\d+ lines?\)$/});function Oe(t){return t.length>_u?t.slice(0,_u)+`
296
- \u2026[${t.length-_u} more characters truncated]`:t}function $e(t){let e=bs(t).split(`
297
- `).map(i=>i.trim()).filter(Boolean),n=e[0];if(!n)return"";let r=n.length>300?n.slice(0,300).trimEnd()+"\u2026":n,s=e.length-1;return s>0?r+ey(s):r}var _u,ke,Co,ws=S(()=>{"use strict";Po();_u=5e4,ke=(t,e,n=e+"s")=>`${t} ${t===1?e:n}`;Co=(t,e)=>`![pasted image](data:${e||"image/png"};base64,${t})`});import{closeSync as ry,existsSync as TT,fstatSync as OT,openSync as sy,readdirSync as PT,readSync as iy,statSync as CT}from"fs";import{join as _T}from"path";function vs(t,e){let n;try{n=sy(t,"r")}catch{return}try{let r=Buffer.alloc(e),s=iy(n,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{ry(n)}}function _o(t,e){let n;try{n=sy(t,"r")}catch{return}try{let r=OT(n).size,s=Math.min(e,r),i=Buffer.alloc(s),o=iy(n,i,0,s,r-s);return{text:i.subarray(0,o).toString("utf8"),partial:r>s}}finally{ry(n)}}function Ro(t){if(!TT(t))return[];let e;try{e=PT(t)}catch{return[]}let n=[];for(let r of e){if(!r.endsWith(".jsonl"))continue;let s=_T(t,r);try{let i=CT(s);i.isFile()&&n.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return n}var Io=S(()=>{"use strict"});var Bt,No=S(()=>{"use strict";Bt=class{ensureHarnessSupport(){}childBriefs=!0;forRead(){return this}linker(){return{link(){}}}}});import{openSync as RT,readSync as IT,closeSync as NT,statSync as cy,readdirSync as uy,readFileSync as dy,existsSync as $T}from"fs";import{join as cn}from"path";import{homedir as LT}from"os";function MT(t){return t.replace(/[^a-zA-Z0-9]/g,"-")}function BT(t,e,n){let r=cn(Ru(t,e),n,DT),s;try{s=uy(r)}catch{return[]}let i=tO(t,n),o=[];for(let a of s){if(!a.endsWith(".jsonl"))continue;let l=cn(r,a),c;try{c=cy(l)}catch{continue}let f=a.slice(0,-6),d={};try{d=JSON.parse(dy(cn(r,`${f}.meta.json`),"utf8"))}catch{}let u=UT(l,c.size,c.mtimeMs);o.push({id:f.startsWith("agent-")?f.slice(6):f,file:l,mtime:c.mtimeMs,started:c.birthtimeMs||void 0,tokens:u.tokens,failing:u.failing,running:!!u.running&&(i===void 0||c.mtimeMs>=i),label:d.description??"",kind:d.agentType===jT?void 0:d.agentType,model:u.model?.replace(/^claude-/,"").replace(/-\d{8}$/,"")??d.model,spawnId:d.toolUseId,parentId:d.parentAgentId,depth:d.spawnDepth??1,stopped:!!d.stoppedByUser})}return o}function UT(t,e,n){let r=oy.get(t);if(r&&r.size===e&&r.mtime===n)return r;let s={};for(let i of FT){let o=_o(t,i);if(!o)break;let a=o.text.split(`
298
- `);o.partial&&a.shift();let l=[];for(let u of a)if(u.trim())try{l.push(JSON.parse(u))}catch{}if(o.partial&&!l.some(u=>u.type==="user"||u.type==="assistant"))continue;let c,f;for(let u=l.length-1;u>=0&&!f;u--){let p=l[u];p?.type==="assistant"&&(c??=p,!p.isApiErrorMessage&&p.message?.usage&&(f=p))}let d=f?.message?.usage;if(s={tokens:d?(d.input_tokens??0)+(d.output_tokens??0)+(d.cache_read_input_tokens??0)+(d.cache_creation_input_tokens??0):r?.tokens,model:f?.message?.model??r?.model,running:py(l),failing:!!c?.isApiErrorMessage},!(s.tokens===void 0&&o.partial))break}return s.model??=qT(t),oy.set(t,{size:e,mtime:n,...s}),s}function qT(t){for(let e of(vs(t,256*1024)?.text??"").split(`
295
+ })();`});var Q=S(()=>{xi();$l();Np();Dp();vu();Mg();Kg();zg();Yg();Gg();Qg();Ei()});function Se(t){let e=Math.max(0,Math.round(t/1e3));if(e<60)return`${e}s`;let n=Math.floor(e/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function ny(t,e){if(!e)return t;let n=t.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return n.toLowerCase().startsWith(r.toLowerCase()+"/")?n.slice(r.length+1):t}function Ou(t){return t.replace(/[/\\]+$/,"").split(/[/\\]/).pop()??""}function Pu(t){return!t||typeof t!="object"?"":ge(t.command)??ge(t.file_path)??ge(t.filePath)??ge(t.path)??ge(t.pattern)??ge(t.query)??ge(t.url)??ge(t.skill)??ge(t.description)??""}function Cu(t){let e=/^mcp__(.+?)__(.+)$/.exec(t);return e?`${e[1][0].toUpperCase()}${e[1].slice(1)} [${e[2]}]`:t}var ge,ws,ey,ty,Po=S(()=>{"use strict";ge=t=>typeof t=="string"?t:void 0,ws=t=>t.replace(/\u001b\[[0-9;]*m/g,""),ey=t=>` (+${t} line${t===1?"":"s"})`,ty=/ \(\+\d+ lines?\)$/});function Oe(t){return t.length>_u?t.slice(0,_u)+`
296
+ \u2026[${t.length-_u} more characters truncated]`:t}function $e(t){let e=ws(t).split(`
297
+ `).map(i=>i.trim()).filter(Boolean),n=e[0];if(!n)return"";let r=n.length>300?n.slice(0,300).trimEnd()+"\u2026":n,s=e.length-1;return s>0?r+ey(s):r}var _u,ke,Co,vs=S(()=>{"use strict";Po();_u=5e4,ke=(t,e,n=e+"s")=>`${t} ${t===1?e:n}`;Co=(t,e)=>`![pasted image](data:${e||"image/png"};base64,${t})`});import{closeSync as ry,existsSync as PT,fstatSync as CT,openSync as sy,readdirSync as _T,readSync as iy,statSync as RT}from"fs";import{join as IT}from"path";function Gn(t,e){let n;try{n=sy(t,"r")}catch{return}try{let r=Buffer.alloc(e),s=iy(n,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{ry(n)}}function _o(t,e){let n;try{n=sy(t,"r")}catch{return}try{let r=CT(n).size,s=Math.min(e,r),i=Buffer.alloc(s),o=iy(n,i,0,s,r-s);return{text:i.subarray(0,o).toString("utf8"),partial:r>s}}finally{ry(n)}}function Ro(t){if(!PT(t))return[];let e;try{e=_T(t)}catch{return[]}let n=[];for(let r of e){if(!r.endsWith(".jsonl"))continue;let s=IT(t,r);try{let i=RT(s);i.isFile()&&n.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return n}var Io=S(()=>{"use strict"});var Bt,No=S(()=>{"use strict";Bt=class{ensureHarnessSupport(){}childBriefs=!0;forRead(){return this}linker(){return{link(){}}}}});import{openSync as NT,readSync as $T,closeSync as LT,statSync as cy,readdirSync as uy,readFileSync as dy,existsSync as MT}from"fs";import{join as cn}from"path";import{homedir as DT}from"os";function BT(t){return t.replace(/[^a-zA-Z0-9]/g,"-")}function FT(t,e,n){let r=cn(Ru(t,e),n,jT),s;try{s=uy(r)}catch{return[]}let i=rO(t,n),o=[];for(let a of s){if(!a.endsWith(".jsonl"))continue;let l=cn(r,a),c;try{c=cy(l)}catch{continue}let f=a.slice(0,-6),d={};try{d=JSON.parse(dy(cn(r,`${f}.meta.json`),"utf8"))}catch{}let u=JT(l,c.size,c.mtimeMs);o.push({id:f.startsWith("agent-")?f.slice(6):f,file:l,mtime:c.mtimeMs,started:c.birthtimeMs||void 0,tokens:u.tokens,failing:u.failing,running:!!u.running&&(i===void 0||c.mtimeMs>=i),label:d.description??"",kind:d.agentType===UT?void 0:d.agentType,model:u.model?.replace(/^claude-/,"").replace(/-\d{8}$/,"")??d.model,effort:u.effort,spawnId:d.toolUseId,parentId:d.parentAgentId,depth:d.spawnDepth??1,stopped:!!d.stoppedByUser})}return o}function JT(t,e,n){let r=oy.get(t);if(r&&r.size===e&&r.mtime===n)return r;let s={};for(let i of qT){let o=_o(t,i);if(!o)break;let a=o.text.split(`
298
+ `);o.partial&&a.shift();let l=[];for(let u of a)if(u.trim())try{l.push(JSON.parse(u))}catch{}if(o.partial&&!l.some(u=>u.type==="user"||u.type==="assistant"))continue;let c,f;for(let u=l.length-1;u>=0&&!f;u--){let p=l[u];p?.type==="assistant"&&(c??=p,!p.isApiErrorMessage&&p.message?.usage&&(f=p))}let d=f?.message?.usage;if(s={tokens:d?(d.input_tokens??0)+(d.output_tokens??0)+(d.cache_read_input_tokens??0)+(d.cache_creation_input_tokens??0):r?.tokens,model:f?.message?.model??r?.model,effort:f?.effort??r?.effort,running:py(l),failing:!!c?.isApiErrorMessage},!(s.tokens===void 0&&o.partial))break}return s.model??=WT(t),oy.set(t,{size:e,mtime:n,...s}),s}function WT(t){for(let e of(Gn(t,256*1024)?.text??"").split(`
299
299
  `))if(e.includes('"modelId"'))try{let n=JSON.parse(e).attachment?.identity?.modelId;if(n)return n}catch{}}function py(t){let e;for(let i of t)(i.type==="user"||i.type==="assistant")&&(e=i);if(!e)return!1;if(e.type==="user"){try{let i=e.message?.content,o=typeof i=="string"?i:Array.isArray(i)?i.filter(a=>a&&a.type==="text").map(a=>a.text??"").join(""):"";if(!fy(e)&&o.trim()&&jt(o)==="")return!1}catch{}return!0}let r=(Array.isArray(e.message?.content)?e.message.content:[]).filter(i=>i.type==="tool_use").map(i=>i.id);if(r.length===0)return!e.message?.stop_reason||e.message.stop_reason==="tool_use";let s=new Set;for(let i of t){let o=i.message?.content;if(Array.isArray(o))for(let a of o)a.type==="tool_result"&&a.tool_use_id&&s.add(a.tool_use_id)}return r.some(i=>i&&!s.has(i))}function Lo(t){let e=t?.type==="image"?t.source:void 0;return e?.type==="base64"&&e.data?Co(e.data,e.media_type):""}function Iu(t){return typeof t=="string"?Oe(t):Array.isArray(t)?t.map(e=>{if(typeof e=="string")return Oe(e);let n=e;return typeof n?.text=="string"?Oe(n.text):n?.content!=null?Iu(n.content):Lo(n)}).join(`
300
- `):t==null?"":Oe(JSON.stringify(t))}function JT(t){let e=t.trim();return!!e&&hy.some(n=>n.test(e))}function WT(t){let e=t.trim();return e?hy.some(n=>{let r=n.exec(e);return!!r&&r.index===0}):!0}function HT(t){return t.replace(KT,"")}function zT(t){let e=/^<command-name>([\s\S]*?)<\/command-name>/.exec(t)?.[1]?.trim();if(!e)return;let n=/<command-args>([\s\S]*?)<\/command-args>/.exec(t)?.[1]?.trim();return n?`${e} ${n}`:e}function jt(t){let e=HT(t).trim();return e?zT(e)??(JT(e)?"":e):""}function Mo(t){let e=YT.exec(t.trim());if(e)return{from:e[1],body:GT(e[2].replace(VT,""))}}function GT(t){let e=t.split(`
300
+ `):t==null?"":Oe(JSON.stringify(t))}function KT(t){let e=t.trim();return!!e&&hy.some(n=>n.test(e))}function HT(t){let e=t.trim();return e?hy.some(n=>{let r=n.exec(e);return!!r&&r.index===0}):!0}function YT(t){return t.replace(zT,"")}function VT(t){let e=/^<command-name>([\s\S]*?)<\/command-name>/.exec(t)?.[1]?.trim();if(!e)return;let n=/<command-args>([\s\S]*?)<\/command-args>/.exec(t)?.[1]?.trim();return n?`${e} ${n}`:e}function jt(t){let e=YT(t).trim();return e?VT(e)??(KT(e)?"":e):""}function Mo(t){let e=GT.exec(t.trim());if(e)return{from:e[1],body:QT(e[2].replace(XT,""))}}function QT(t){let e=t.split(`
301
301
  `).filter(r=>r.trim()).map(r=>r.length-r.trimStart().length),n=e.length?Math.min(...e):0;return n?t.split(`
302
302
  `).map(r=>r.slice(n)).join(`
303
- `):t}function $o(t){let e=Mo(t);return e?{type:"user",text:e.body,agent:{from:e.from}}:{type:"user",text:t}}function XT(t){let e=t.message?.content;return typeof e=="string"&&!!Mo(e)}function QT(t){let e=t.message?.content;return typeof e=="string"&&e.startsWith(ay)?e.slice(ay.length).trim():void 0}function Nu(t){return t?.type==="text"&&typeof t.text=="string"?jt(t.text):""}function $u(t,e){if(typeof t=="string")return $e(t);if(!t||typeof t!="object")return $e(e);let n=t;if(n.type==="text"&&typeof n.file?.numLines=="number")return ke(n.file.numLines,"line");if(n.type==="image"){let r=ly(n.file?.originalSize);return r?`image (${r})`:"image"}if(n.type==="pdf"){let r=ly(n.file?.originalSize);return r?`PDF (${r})`:"PDF"}if(n.type==="parts"&&typeof n.file?.count=="number")return ke(n.file.count,"page");if(n.type==="file_unchanged")return"unchanged since last read";if(n.type==="create"&&typeof n.content=="string")return`created, ${ke(n.content.split(`
304
- `).length,"line")}`;if(n.mode==="content")return ke(n.numLines??0,"line");if(n.mode==="count")return`${ke(n.numMatches??0,"match","matches")} (${ke(n.numFiles??0,"file")})`;if(n.mode==="files_with_matches")return ke(n.numFiles??0,"file");if(Array.isArray(n.structuredPatch)){let r=0,s=0;for(let i of n.structuredPatch)for(let o of i?.lines??[])typeof o=="string"&&(o.startsWith("+")?r++:o.startsWith("-")&&s++);return`+${r} \u2212${s}`}return typeof n.stdout=="string"||typeof n.stderr=="string"?n.backgroundTaskId?"running in background":n.interrupted?"interrupted":$e(n.stdout||n.stderr||"")||"no output":typeof n.code=="number"&&typeof n.codeText=="string"?`${n.code} ${n.codeText}`:typeof n.searchCount=="number"?ke(n.searchCount,"search","searches"):Array.isArray(n.matches)&&typeof n.total_deferred_tools=="number"?ke(n.matches.length,"tool"):Array.isArray(n.newTodos)?ke(n.newTodos.length,"todo"):typeof n.numFiles=="number"?ke(n.numFiles,"file"):$e(e)}function Ss(t){return!!t.isMeta}function ZT(t){let e;try{e=RT(t,"r")}catch{return""}try{let r=65536;try{r=cy(t).size}catch{}let s=(c,f)=>{if(f<=0)return"";let d=Buffer.alloc(f),u=IT(e,d,0,f,c);return d.subarray(0,u).toString("utf8")},i=(c,f,d)=>{let u="";for(let p of c.split(`
303
+ `):t}function $o(t){let e=Mo(t);return e?{type:"user",text:e.body,agent:{from:e.from}}:{type:"user",text:t}}function ZT(t){let e=t.message?.content;return typeof e=="string"&&!!Mo(e)}function eO(t){let e=t.message?.content;return typeof e=="string"&&e.startsWith(ay)?e.slice(ay.length).trim():void 0}function Nu(t){return t?.type==="text"&&typeof t.text=="string"?jt(t.text):""}function $u(t,e){if(typeof t=="string")return $e(t);if(!t||typeof t!="object")return $e(e);let n=t;if(n.type==="text"&&typeof n.file?.numLines=="number")return ke(n.file.numLines,"line");if(n.type==="image"){let r=ly(n.file?.originalSize);return r?`image (${r})`:"image"}if(n.type==="pdf"){let r=ly(n.file?.originalSize);return r?`PDF (${r})`:"PDF"}if(n.type==="parts"&&typeof n.file?.count=="number")return ke(n.file.count,"page");if(n.type==="file_unchanged")return"unchanged since last read";if(n.type==="create"&&typeof n.content=="string")return`created, ${ke(n.content.split(`
304
+ `).length,"line")}`;if(n.mode==="content")return ke(n.numLines??0,"line");if(n.mode==="count")return`${ke(n.numMatches??0,"match","matches")} (${ke(n.numFiles??0,"file")})`;if(n.mode==="files_with_matches")return ke(n.numFiles??0,"file");if(Array.isArray(n.structuredPatch)){let r=0,s=0;for(let i of n.structuredPatch)for(let o of i?.lines??[])typeof o=="string"&&(o.startsWith("+")?r++:o.startsWith("-")&&s++);return`+${r} \u2212${s}`}return typeof n.stdout=="string"||typeof n.stderr=="string"?n.backgroundTaskId?"running in background":n.interrupted?"interrupted":$e(n.stdout||n.stderr||"")||"no output":typeof n.code=="number"&&typeof n.codeText=="string"?`${n.code} ${n.codeText}`:typeof n.searchCount=="number"?ke(n.searchCount,"search","searches"):Array.isArray(n.matches)&&typeof n.total_deferred_tools=="number"?ke(n.matches.length,"tool"):Array.isArray(n.newTodos)?ke(n.newTodos.length,"todo"):typeof n.numFiles=="number"?ke(n.numFiles,"file"):$e(e)}function Ss(t){return!!t.isMeta}function tO(t){let e;try{e=NT(t,"r")}catch{return""}try{let r=65536;try{r=cy(t).size}catch{}let s=(c,f)=>{if(f<=0)return"";let d=Buffer.alloc(f),u=$T(e,d,0,f,c);return d.subarray(0,u).toString("utf8")},i=(c,f,d)=>{let u="";for(let p of c.split(`
305
305
  `)){if(!p.includes(`"${f}"`))continue;let m;try{m=JSON.parse(p)}catch{continue}let h=m?.[d];m?.type===f&&typeof h=="string"&&h&&(u=h)}return u},o=s(0,Math.min(65536,r)),a=r>65536?s(r-65536,65536):"",l=i(a,"custom-title","customTitle")||i(o,"custom-title","customTitle")||i(a,"ai-title","aiTitle")||i(o,"ai-title","aiTitle");if(l)return l.replace(/\s+/g," ").trim().slice(0,200);for(let c of o.split(`
306
- `)){if(!c.trim())continue;let f;try{f=JSON.parse(c)}catch{continue}if(!f||Ss(f)||f.type!=="user")continue;let d=f.message?.content,u="";typeof d=="string"?u=jt(d):Array.isArray(d)&&(u=d.map(Nu).filter(Boolean).join(" "));let p=u.replace(/\s+/g," ").trim();if(p)return(p.replace(/^Continuing from a prior session\. Here is the summary of our work so far:\s*/i,"").trim()||p).slice(0,200)}return""}finally{NT(e)}}function Lu(t){let e=cn(t,"sessions"),n;try{n=uy(e)}catch{return[]}let r=[];for(let s of n)if(s.endsWith(".json"))try{let i=JSON.parse(dy(cn(e,s),"utf8"));if(!i?.sessionId)continue;process.kill(i.pid,0),r.push(i)}catch{}return r}function eO(t,e){return Lu(t).some(n=>n.sessionId===e)}function tO(t,e){let n=Lu(t).filter(r=>r.sessionId===e).map(r=>r.startedAt);return n.length&&n.every(r=>typeof r=="number")?Math.min(...n):void 0}function nO(t){return new Set(Lu(t).filter(e=>e.status==="busy").map(e=>e.sessionId))}var fy,Ru,DT,jT,FT,oy,hy,KT,YT,VT,ay,ly,Gn,Do=S(()=>{"use strict";ws();Io();No();fy=t=>t.type==="user"&&Array.isArray(t.message?.content)&&t.message.content.some(e=>e?.type==="tool_result");Ru=(t,e)=>cn(t,"projects",MT(e)),DT="subagents";jT="general-purpose",FT=[256*1024,4*1024*1024,64*1024*1024],oy=new Map;hy=[/\[Request interrupted by user\b/i,/\[Tool use was interrupted\]/i,/Claude Code returned an error/i,/\[ede_diagnostic\]/i,/^No response requested\.?$/i,/^<task-notification\b/i,/^<system-reminder\b/i,/^<local-command-stdout\b/i,/^<local-command-stderr\b/i];KT=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;YT=/^(?:[^\n<][^\n]*\n)?<agent-message from="([^"]+)">\n([\s\S]*?)(?:\n?<\/agent-message>[\s\S]*)?$/,VT=/^\[[^\]\n]+\][\s\S]*?The report follows:\n/;ay=`The coordinator sent a message while you were working:
307
- `;ly=t=>typeof t!="number"?"":t<1024?`${t}B`:t<1048576?`${Math.round(t/1024)}KB`:`${(t/1048576).toFixed(1)}MB`;Gn=class extends Bt{constructor(n=cn(LT(),".claude")){super();this.root=n}displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return $T(this.root)}sessionsDir(n){return Ru(this.root,n)}listSessionFiles(n){return Ro(Ru(this.root,n))}listChildren(n,r){return BT(this.root,n,r)}callerSessionId(){return process.env.CLAUDE_CODE_SESSION_ID||void 0}parseEntry(n){try{return JSON.parse(n)}catch{return null}}idOf(n){return n.uuid}parentOf(n){return n.parentUuid}linker(){let n=new Map,r=new Map;return{link(s){if(!s.uuid||n.has(s.uuid))return;let i=s.parentUuid===void 0?void 0:n.get(s.parentUuid),o=s.type==="assistant"?s.message?.id:fy(s)?i:void 0;o&&(i===o&&(s.parentUuid=r.get(o)),n.set(s.uuid,o),r.set(o,s.uuid))}}}timestampOf(n){return n.timestamp}isSidechain(n,r){return!!n.isSidechain!=(r==="child")}isLeafType(n){return n.type==="user"||n.type==="assistant"}isRecoveryNoise(n){return!!n.isApiErrorMessage}apply(n,r){let s=QT(n);if(s)return{events:[$o(s)]};if(Ss(n)&&!XT(n))return{events:[]};let i=[];if(n.type==="user"){let o=n.message?.content;if(typeof o=="string"){let a=jt(o);a&&i.push($o(a))}else if(Array.isArray(o))for(let a of o)if(a?.type==="tool_result"){let l=Iu(a.content);i.push({type:"tool_result",id:a.tool_use_id??"",content:l,isError:!!a.is_error,digest:$u(n.toolUseResult,l)})}else{let l=Nu(a)||Lo(a);l&&i.push($o(l))}return{events:i}}if(n.type==="attachment"&&n.attachment?.type==="queued_command"){let o=jt(Iu(n.attachment.prompt));return o&&i.push($o(o)),{events:i}}if(n.type==="assistant"){let o=n.message?.content,a=Array.isArray(o)?o:[],l=a.filter(p=>p.type==="text").map(p=>p.text??"").filter(p=>!WT(p)).join(""),c=a.filter(p=>p.type==="thinking").map(p=>p.thinking??"").join(`
308
- `),f=a.filter(p=>p.type==="tool_use").map(p=>({id:p.id??"",name:p.name??"",input:p.input??{}}));if(l||c||f.length){let p=Date.parse(n.timestamp??""),m=!isNaN(p)&&p>=r;i.push({type:"assistant",text:l,thinking:c,tools:f,live:m,error:n.isApiErrorMessage||void 0})}let d=n.message?.usage??n.usage,u=d&&{in:d.input_tokens??0,out:d.output_tokens??0,cached:d.cache_read_input_tokens??0,cacheCreate:d.cache_creation_input_tokens??0};return{events:i,usage:u,model:n.message?.model}}return{events:i}}chainWorking(n){return py(n)}sessionAlive(n){return eO(this.root,n)}sessionsWorking(n){return nO(this.root)}readPreview(n){return ZT(n)}searchText(n){if(!n||Ss(n)||n.type!=="user"&&n.type!=="assistant")return"";let r=n.message?.content,s="";if(typeof r=="string")s=jt(r);else if(Array.isArray(r)){let i=r;s=n.type==="user"?i.map(Nu).filter(Boolean).join(" "):i.filter(o=>o.type==="text"&&typeof o.text=="string").map(o=>o.text).join(" ")}return s.replace(/\s+/g," ").trim()}}});import{statSync as Bo,readdirSync as rO,existsSync as sO}from"fs";import{basename as my,join as Mu,resolve as iO}from"path";import{homedir as gy}from"os";function aO(t){let e=t.trimStart();return oO.some(n=>e.startsWith(n))}function Xn(t,e){return Array.isArray(t)?t.map(n=>typeof n?.text=="string"?e&&aO(n.text)?"":Oe(n.text):n?.type==="input_image"&&typeof n.image_url=="string"&&n.image_url.startsWith("data:")?`![image](${n.image_url})`:"").filter(Boolean).join(`
309
- `):""}function lO(t){return typeof t=="string"?Oe(t):Xn(t,!1)}function cO(t,e){let n=e??"",r=SO(n);if(!r.length)return{name:t,input:{script:n}};let s=r.map(i=>Du(i.fn)&&ks(i.arg)?yO(String(i.arg.cmd??i.arg.command??"")):void 0);if(s.every(i=>i!==void 0))return{name:"read",input:yy(s.flat().map(i=>["path",i])),pending:{kind:"read"}};if(r.length===1){let{fn:i,arg:o}=r[0];if(i==="apply_patch"&&typeof o=="string"){let{files:a,diff:l}=by(o);return{name:i,input:new Set(a).size===1?{path:a[0],patch:l}:{patch:l},pending:{kind:"patch",digest:fO(l)}}}return ks(o)?Du(i)?{name:t,input:dO(o)}:{name:i,input:o}:typeof o=="string"?{name:i,input:{arg:o}}:{name:t,input:{script:n}}}return{name:t,input:yy(r.map(({fn:i,arg:o})=>i==="apply_patch"&&typeof o=="string"?["patch",by(o).diff]:Du(i)&&ks(o)?["command",o.cmd??o.command]:[i,o]))}}function dO(t){let e=Object.fromEntries(Object.entries(t).filter(([r])=>r!=="cmd"&&r!=="command"&&!uO.has(r))),n=t.command??t.cmd;return n===void 0?e:{command:n,...e}}function yy(t){let e={};for(let[n,r]of t){let s=n;for(let i=2;s in e;i++)s=`${n} (${i})`;e[s]=r}return e}function fO(t){let e=0,n=0;for(let r of t.split(`
310
- `))r.startsWith("+")&&!r.startsWith("+++")?e++:r.startsWith("-")&&!r.startsWith("---")&&n++;return`+${e} \u2212${n}`}function yO(t){let e=wO(t),n=e.map(bO);return e.length&&n.every(r=>r!==void 0)?n:void 0}function bO(t){let[e,...n]=t.split("|");if(!n.every(i=>gO.test(i.trim())))return;let r=vO(e);if(!pO.test(r[0]??""))return;let s=[];for(let i=1;i<r.length;i++){let o=r[i];if(hO.test(o)){i+1<r.length&&s.push(r[++i]);continue}if(mO.test(o)){i++;continue}o.startsWith("-")||/^\d+(,\d+)?p?$/.test(o)||s.push(o)}return s.length===1?s[0]:void 0}function wO(t){let e=[],n=0;for(let r=0;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"){let o=t.indexOf(s,r+1);if(o<0)break;r=o;continue}let i=t.slice(r,r+2);(s===";"||s===`
311
- `||i==="&&"||i==="||")&&(e.push(t.slice(n,r)),(i==="&&"||i==="||")&&r++,n=r+1)}return e.push(t.slice(n)),e.map(r=>r.trim()).filter(Boolean)}function vO(t){return(t.match(/'[^']*'|"[^"]*"|\S+/g)??[]).map(e=>/^(['"])(.*)\1$/.exec(e)?.[2]??e)}function SO(t){let e=[],n=/tools\.([A-Za-z_$][\w$]*)\s*\(/g;for(let r=n.exec(t);r;r=n.exec(t)){let s=r.index+r[0].length-1,i=ky(t,s);if(i<0)break;e.push({fn:r[1],arg:Sy(t.slice(s+1,i).trim(),t)}),n.lastIndex=i+1}return e}function Sy(t,e){let n=t[0];if(n==='"'||n==="'"||n==="`")return Fo(t,0)===t.length-1?xy(t.slice(1,-1)):t;if(n==="{"){for(let r of[t,xO(t)])try{let s=JSON.parse(r);if(ks(s))return s}catch{}return t}if(/^[A-Za-z_$][\w$]*$/.test(t)){let r=new RegExp(`\\b(?:const|let|var)\\s+${t.replace(/\$/g,"\\$")}\\s*=\\s*`).exec(e);if(r){let s=r.index+r[0].length,i=e[s],o=i==='"'||i==="'"||i==="`"?Fo(e,s):i==="{"?ky(e,s):-1;if(o>s)return Sy(e.slice(s,o+1),"")}}return t}function ky(t,e){let n=0;for(let r=e;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"||s==="`"){if(r=Fo(t,r),r<0)return-1}else if(s==="("||s==="["||s==="{")n++;else if((s===")"||s==="]"||s==="}")&&--n===0)return r}return-1}function Fo(t,e){let n=t[e];for(let r=e+1;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===n)return r;return-1}function xy(t){return t.replace(/\\(?:u\{([0-9a-fA-F]+)\}|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|([\s\S]))/g,(e,n,r,s,i)=>n||r||s?String.fromCodePoint(parseInt(n||r||s,16)):kO[i]??i)}function xO(t){let e=/[A-Za-z_$][\w$]*(?=\s*:)/y,n=/,(?=\s*[}\]])/y,r="",s="";for(let i=0;i<t.length;i++){let o=t[i];if(o==='"'||o==="'"||o==="`"){let l=Fo(t,i);if(l<0)return t;r+=JSON.stringify(xy(t.slice(i+1,l))),i=l,s=o;continue}e.lastIndex=i;let a=s==="{"||s===","?e.exec(t):null;if(a){r+=`"${a[0]}"`,i+=a[0].length-1,s='"';continue}n.lastIndex=i,!n.test(t)&&(r+=o,/\s/.test(o)||(s=o))}return r}function by(t){let e=[],n=[],r=!1;for(let s of t.split(/\r?\n/)){let i=/^\*\*\* (Update|Add|Delete) File: (.+)$/.exec(s);if(i){let o=i[2].trim();e.push(o),n.push(`--- ${i[1]==="Add"?"/dev/null":`a/${o}`}`,`+++ ${i[1]==="Delete"?"/dev/null":`b/${o}`}`),r=!0;continue}if(!/^\*\*\* (Begin|End) Patch$/.test(s)){if(s.startsWith("*** Move to:")){n.push(s);continue}r&&!s.startsWith("@@")&&n.push("@@"),r=!1,n.push(s)}}return r&&n.push("@@"),{files:e,diff:n.join(`
312
- `)}}function EO(t,e){let n=/^Script (completed|failed|running with cell ID (\d+))\nWall time [^\n]*\nOutput:\n([\s\S]*)$/.exec(t);if(!n)return{content:t,isError:!1,digest:$e(t)};let r=n[3].replace(/^\n+/,"").replace(/^Script error:\n/,""),s=n[1]==="failed",i=AO(r);return i&&(r=i.output,i.exit_code&&(s=!0)),n[2]?{content:r,isError:s,digest:`running (cell ${n[2]})`}:e?.kind==="read"&&!s?{content:r,isError:s,digest:ke(TO(r),"line")}:e?.kind==="patch"&&!s?{content:e.digest,isError:s,digest:e.digest}:{content:r,isError:s,digest:$e(r)}}function AO(t){if(t.startsWith("{"))try{let e=JSON.parse(t);if(ks(e)&&typeof e.output=="string")return{output:e.output,exit_code:typeof e.exit_code=="number"?e.exit_code:void 0}}catch{}}function OO(t){if(typeof t=="string"&&t)try{let e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}return{arguments:t??""}}function CO(t){let e,n;for(let r of PO){let s=_o(t,r);if(s===void 0)return{};let i=s.text.split(`
313
- `);s.partial&&i.shift();let o;for(let a=i.length-1;a>=0;a--){if(!i[a].trim())continue;let l;try{l=JSON.parse(i[a])}catch{continue}if(o===void 0){let c=Date.parse(l.timestamp??"");Number.isNaN(c)||(o=c)}if(e===void 0&&l.type==="event_msg"){let c=l.payload?.type;c==="task_started"?e=!0:(c==="task_complete"||c==="turn_aborted")&&(e=!1)}if(n===void 0&&l.type==="event_msg"&&l.payload?.type==="token_count"&&l.payload.info?.last_token_usage){let c=Ey(l.payload.info.last_token_usage);n=c.in+c.out+c.cached+c.cacheCreate}if(o!==void 0&&e!==void 0&&n!==void 0)break}if(o!==void 0)return{ms:o,running:e??!0,tokens:n};if(!s.partial)break}return{running:e??!0,tokens:n}}function Ey(t){return{in:Math.max(0,(t.input_tokens??0)-(t.cached_input_tokens??0)),out:t.output_tokens??0,cached:t.cached_input_tokens??0,cacheCreate:t.cache_write_input_tokens??0}}function vy(t){let n=vs(t,65536);if(n===void 0)return;let r=n.text.indexOf(`
314
- `);if(r<0)return n.bytes>=65536?{cwd:"",subagent:!1}:void 0;try{let s=JSON.parse(n.text.slice(0,r)),i=s?.type==="session_meta"?s.payload:void 0;if(typeof i?.cwd!="string")return{cwd:"",subagent:!1};let o=typeof i.source=="object"?i.source?.subagent:void 0;return{cwd:i.cwd,subagent:!!o,id:i.id,spawn:_O(i,o),model:RO(n.text,r)}}catch{return{cwd:"",subagent:!1}}}function _O(t,e){let n=e?.thread_spawn;if(!n)return;let r=n.parent_thread_id??t.parent_thread_id;if(!(!t.id||!r))return{id:t.id,parent:r,path:n.agent_path??"",role:n.agent_role??void 0,depth:n.depth??1}}function RO(t,e){for(let n of t.slice(e+1).split(`
315
- `))if(n.trim())try{let r=JSON.parse(n);if(r.type==="turn_context"&&typeof r.payload?.model=="string")return r.payload.model}catch{}}var oO,ks,Du,uO,pO,hO,mO,gO,kO,TO,jo,wy,Qn,PO,Bu=S(()=>{"use strict";ws();No();Io();oO=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<node_repl_review_evidence>","# AGENTS.md instructions for "];ks=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Du=t=>t==="shell_command"||t==="exec_command",uO=new Set(["max_output_tokens","yield_time_ms","timeout_ms"]);pO=/^(Get-Content|gc|cat|type|nl|bat|sed|head|tail)$/i,hO=/^-(Path|LiteralPath)$/i,mO=/^-(Encoding|TotalCount|Head|Tail|ReadCount|Delimiter)$/i,gO=/^(sed -n|head|tail|Select-Object|select)(\s|$)/i;kO={n:`
316
- `,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};TO=t=>t?t.replace(/\r?\n$/,"").split(`
317
- `).length:0;jo=t=>{let e=iO(t);return process.platform==="win32"?e.toLowerCase():e},wy=12e4,Qn=class t extends Bt{constructor(n=Mu(gy(),".codex","sessions")){super();this.root=n}displayName="Codex Mirror";childBriefs=!1;#t=0;#l;#n=!1;#i;#h=0;#s=new Map;#d=new Map;#o=new Map;#c=new Map;detectsSelf(){return!!process.env.CODEX_THREAD_ID}forRead(){return new t(this.root)}callerSessionId(n){let r=process.env.CODEX_THREAD_ID;return r?this.listSessionFiles(n).find(s=>s.sessionId.endsWith(r))?.sessionId:void 0}detectsInstalled(){return sO(Mu(gy(),".codex"))}sessionsDir(n){return this.root}listSessionFiles(n){let r=jo(n),s=[];for(let i of this.#u()){let o=0,a=0;try{let f=Bo(i);if(!f.isFile())continue;o=f.size,a=f.mtimeMs}catch{continue}let l=this.#s.get(i);if(l===void 0){if(l=vy(i),l===void 0)continue;this.#s.set(i,l)}if(l.subagent||jo(l.cwd)!==r)continue;let c=my(i,".jsonl");this.#o.set(c,i),s.push({sessionId:c,file:i,mtime:this.#e(i,o,a)})}return s}listChildren(n,r){let s=jo(n),i=new Map,o;for(let c of this.#u()){let f=0,d=0,u;try{let g=Bo(c);if(!g.isFile())continue;f=g.size,d=g.mtimeMs,u=g.birthtimeMs||void 0}catch{continue}let p=this.#s.get(c);if(p===void 0){if(p=vy(c),p===void 0)continue;this.#s.set(c,p)}if(my(c,".jsonl")===r&&(o=p.id),!p.spawn||jo(p.cwd)!==s)continue;let{running:m,tokens:h}=this.#r(c,f,d);i.set(p.spawn.id,{file:c,mtime:this.#e(c,f,d),started:u,running:m,tokens:h,spawn:p.spawn,model:p.model})}if(!o)return[];let a=(c,f=new Set)=>{if(c.parent===o)return!0;if(f.has(c.id))return!1;f.add(c.id);let d=i.get(c.parent);return d?a(d.spawn,f):!1},l=[];for(let{file:c,mtime:f,started:d,running:u,tokens:p,spawn:m,model:h}of i.values())a(m)&&l.push({id:m.id,file:c,mtime:f,started:d,tokens:p,label:m.path.split("/").filter(Boolean).pop()??m.path,kind:m.role||void 0,model:h,parentId:i.has(m.parent)?m.parent:void 0,depth:m.depth,stopped:!1,running:u});return l}sessionsWorking(n){let r=new Set,s=Date.now();for(let{sessionId:i,file:o,mtime:a}of this.listSessionFiles(n)){if(s-a>=wy)continue;let l;try{let c=Bo(o);l=this.#r(o,c.size,c.mtimeMs)}catch{continue}l.running&&r.add(i)}return r}#e(n,r,s){return Math.max(s,this.#r(n,r,s).ms??0)}#r(n,r,s){let i=this.#d.get(n);if(i&&i.size===r&&i.mtime===s)return i;let o={size:r,mtime:s,...CO(n)};return this.#d.set(n,o),o}#u(){let n=[],r=s=>{try{return rO(s).map(i=>Mu(s,i))}catch{return[]}};for(let s of r(this.root))for(let i of r(s))for(let o of r(i))for(let a of r(o))a.endsWith(".jsonl")&&n.push(a);return n}parseEntry(n){let r;try{r=JSON.parse(n)}catch{return null}return!r||typeof r.type!="string"?null:r}idOf(n){return n.ord===void 0&&(this.#a(n),n.ord=String(this.#t++),n.parent=this.#l,this.#l=n.ord),n.ord}#a(n){let r=n.payload;if(n.type==="session_meta"){if(++this.#h===1){let s=typeof r?.source=="object"?r.source?.subagent?.thread_spawn:void 0;this.#i=s?.agent_path,this.#n=!!s}}else this.#h=0,this.#n&&r?.type==="agent_message"&&r.recipient===this.#i&&(this.#n=!1);n.inherited=this.#n}parentOf(n){return n.parent}timestampOf(n){return n.timestamp}isSidechain(n,r){return r==="child"&&!!n.inherited}isLeafType(n){return!0}isRecoveryNoise(n){return!1}apply(n,r){let s=[],i=n.payload;if(!i)return{events:s};let o=()=>{let a=Date.parse(n.timestamp??"");return!isNaN(a)&&a>=r};if(n.type==="response_item"){if(i.type==="message"){if(i.role==="user"){let a=Xn(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=Xn(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=Xn(i.summary,!1);return a&&s.push({type:"assistant",text:"",thinking:a,tools:[],live:o()}),{events:s}}if(i.type==="custom_tool_call"||i.type==="function_call"){let a=i.call_id??"",{pending:l,...c}=i.type==="custom_tool_call"?cO(i.name??"",i.input):{name:i.name??"",input:OO(i.arguments)};return l&&this.#c.set(a,l),s.push({type:"assistant",text:"",thinking:"",tools:[{id:a,...c}],live:o()}),{events:s}}if(i.type==="custom_tool_call_output"||i.type==="function_call_output"){let a=i.call_id??"",l=this.#c.get(a);return this.#c.delete(a),s.push({type:"tool_result",id:a,...EO(lO(i.output),l)}),{events:s}}return{events:s}}if(n.type==="event_msg"){if(i.type==="token_count"){let a=i.info?.last_token_usage;return a?{events:s,usage:Ey(a)}:{events:s}}return{events:s}}return n.type==="turn_context"?{events:s,model:i.model}:{events:s}}chainWorking(n){let r=!1;for(let s of n){if(s.type!=="event_msg")continue;let i=s.payload?.type;i==="task_started"?r=!0:(i==="task_complete"||i==="turn_aborted")&&(r=!1)}return r}sessionAlive(n){let r=this.#o.get(n);if(!r)return;let s;try{let i=Bo(r);s=this.#e(r,i.size,i.mtimeMs)}catch{return}return Date.now()-s<wy}readPreview(n){for(let r of(vs(n,256*1024)?.text??"").split(`
318
- `))if(!(!r.includes('"user_message"')&&!r.includes('"UserMessage"')))try{let s=JSON.parse(r);if(s?.type!=="event_msg")continue;let i=s.payload,a=((i?.type==="user_message"?i.message:i?.type==="item_completed"&&i.item?.type==="UserMessage"?Xn(i.item.content,!0):void 0)??"").replace(/\s+/g," ").trim();if(a)return a.slice(0,200)}catch{}return""}searchText(n){if(n?.type!=="response_item"||n.payload?.type!=="message")return"";let r=n.payload.role;return r!=="user"&&r!=="assistant"?"":Xn(n.payload.content,r==="user").replace(/\s+/g," ").trim()}},PO=[64*1024,1024*1024]});import{realpathSync as IO}from"fs";import{createHash as NO}from"crypto";import{join as Uo,resolve as $O}from"path";import{homedir as LO}from"os";function ze(){let t=process.env.TYPEBULB_SERVERS_DIR;return t?Uo(t,".."):Uo(LO(),".typebulb")}function pt(){Ay||(Ay=!0,console.error(`${ze()} not writable \u2014 continuing stateless: ports won't stick, caches stay cold, and typebulb logs/wait/send/stop may not see this run`))}function ht(){return process.env.TYPEBULB_SERVERS_DIR||Uo(ze(),"servers")}function Ty(t){let e=re(t),n=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return Uo(ze(),"canvas",`${n}-${xs(t)}.png`)}function xs(t){return NO("sha1").update(re(t)).digest("hex").slice(0,8)}function re(t){let e=$O(t),n=e;try{n=IO.native(e)}catch{}return(process.platform==="win32"?n.toLowerCase():n).replace(/\\/g,"/")}function Oy(t,e){let n=re(t),r=re(e);return n.startsWith(r.endsWith("/")?r:r+"/")?!n.includes("/node_modules/"):!1}var Ay,Ye=S(()=>{"use strict";Ay=!1});import*as _y from"net";import{mkdir as MO,readFile as DO,writeFile as Ry}from"fs/promises";import{existsSync as BO}from"fs";import{join as Iy}from"path";function Ly(){return Iy(ze(),"blocks")}function ju(t){return Iy(Ly(),`${t}.json`)}function Jo(t){return new Promise(e=>{let n=_y.createServer();n.once("error",()=>e(!1)),n.listen(t,"127.0.0.1",()=>n.close(()=>e(!0)))})}async function qO(t){for(let e=t;e<65535;e++)if(await Jo(e))return e;throw new Error(`No free port found above ${t}`)}async function Fu(t){let{listBulbServers:e}=await Promise.resolve().then(()=>(Le(),My)),n=(await e()).find(s=>s.port===t),r=n?` (pid ${n.pid}, ${n.agent?`agent:${n.agent}`:n.file})`:"";console.error(`port ${t} in use${r}`),process.exit(1)}async function Wo(t){try{let e=JSON.parse(await DO(ju(t),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function Ko(t,e){try{return await Ry(ju(t),JSON.stringify(e,null,2)),!0}catch{return pt(),!1}}async function JO(t){let e=re(t);try{await MO(Ly(),{recursive:!0})}catch{return}let n=[];for(let o=0;o<$y;o++)n.push(Ny+o*un);let r=await Promise.all(n.map(async o=>({base:o,block:await Wo(o)})));for(let{base:o,block:a}of r)if(a?.cwd===e)return o;let s={cwd:e,slots:{},mirrors:{}};for(let{base:o,block:a}of r){if(!a)try{return await Ry(ju(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(l){if((await Wo(o))?.cwd===e)return o;l.code!=="EEXIST"&&pt();continue}if(!BO(a.cwd))return await Ko(o,s)?o:void 0}let i=r.filter(o=>!!o.block).sort((o,a)=>Py(o.block)-Py(a.block))[0];if(i)return await Ko(i.base,s)?i.base:void 0}function Py(t){return Object.values(t.slots).reduce((e,n)=>Math.max(e,n.usedAt??0),0)}async function WO(t,e){let n=await Wo(t)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=n.mirrors[e.agent];if(i!==void 0)return i;let o=Cy(n),a=o.has(0)?FO:0;for(;a>qo&&o.has(a);)a--;return n.mirrors[e.agent]=a,await Ko(t,n),a}let r=re(e.file),s=n.slots[r]?.offset;if(s===void 0){let i=Cy(n);for(s=qo;s<un&&i.has(s);)s++;if(s>=un){let o=Object.entries(n.slots).sort((a,l)=>(a[1].usedAt??0)-(l[1].usedAt??0))[0];s=o?o[1].offset:qo,o&&delete n.slots[o[0]]}}return n.slots[r]={offset:s,usedAt:Date.now()},await Ko(t,n),s}function Cy(t){return new Set([...Object.values(t.mirrors),...Object.values(t.slots).map(e=>e.offset)])}async function Zn(t,e){let n=await JO(e);return n===void 0?void 0:n+await WO(n,t)}async function dn(t){let e=re(t);for(let n=0;n<$y;n++){let r=await Wo(Ny+n*un);if(r?.cwd===e)return s=>r.slots[re(s)]?.usedAt??0}return()=>0}async function Ho(t){if(t.explicit!==void 0)return await Jo(t.explicit)||await Fu(t.explicit),t.target.kind==="bulb"&&await Zn(t.target,t.cwd),{port:t.explicit};let e=await Zn(t.target,t.cwd);if(e!==void 0){let r=e-e%un,s=Date.now()+UO;do{if(await Jo(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=qo;i<un;i++){let o=r+i;if(o!==e&&await Jo(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await qO(jO),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var Ny,un,$y,jO,qo,FO,UO,fn=S(()=>{"use strict";Ye();Ny=20100,un=100,$y=19,jO=23e3,qo=1,FO=un-1,UO=3e3});var Me,zo=S(()=>{"use strict";Me="0.61.10"});var My={};Si(My,{agentViewerCommand:()=>Hy,bulbServerCommand:()=>Ky,clearServerLog:()=>Ku,findProjectViewer:()=>Go,isAlive:()=>er,isMirror:()=>ye,isProjectBulb:()=>Gu,isProjectMirror:()=>rr,launchAgentViewer:()=>Zu,launchBulbServer:()=>Ts,listBulbServers:()=>Z,probePageCount:()=>Qu,readServerLog:()=>Ve,readWaitCursor:()=>Vo,recordDenial:()=>Vu,registerServer:()=>Yu,relayOpen:()=>Xu,runMarker:()=>Hu,serverLogPath:()=>nr,serversForBulb:()=>hn,sliceRunLog:()=>zu,startServerLog:()=>As,stopBulbServer:()=>tr,stopServer:()=>Ft,stopServersForBulb:()=>Xo,typebulbBinPath:()=>sr,unregisterServer:()=>pn,writeWaitCursor:()=>Es});import{spawn as Dy}from"child_process";import{readdir as KO,readFile as Fy,writeFile as Uy,unlink as Uu,mkdir as HO}from"fs/promises";import{mkdirSync as qy,writeFileSync as Yo,appendFileSync as zO,readFileSync as qu}from"fs";import*as Pe from"path";import{fileURLToPath as YO}from"url";function Ju(t){return Pe.join(ht(),`${t}.json`)}function nr(t){return Pe.join(ht(),`${t}.log`)}function Wu(t){return Pe.join(ht(),`${t}.wait.json`)}function Jy(t){try{let e=JSON.parse(qu(Wu(t),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function Vo(t,e=""){let n=Jy(t)[e];return typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0}function Es(t,e,n=""){try{qy(ht(),{recursive:!0});let r=Jy(t);r[n]=e,Yo(Wu(t),JSON.stringify({cursors:r}))}catch{}}function As(t){let e=nr(t);try{qy(ht(),{recursive:!0}),Yo(e,"")}catch{return()=>{}}let n=process.stdout.write.bind(process.stdout),r=process.stderr.write.bind(process.stderr),s=0,i=!1,o=a=>{if(!i)try{let l=typeof a=="string"?Buffer.from(a,"utf8"):Buffer.from(a);if(zO(e,l),s+=l.length,s>2*By){let c=qu(e),f=c.subarray(Math.max(0,c.length-By));Yo(e,f),s=f.length}}catch{i=!0}};return process.stdout.write=((a,...l)=>(o(a),n(a,...l))),process.stderr.write=((a,...l)=>(o(a),r(a,...l))),()=>{process.stdout.write=n,process.stderr.write=r}}function Ku(t){try{Yo(nr(t),"")}catch{}}function Ve(t,e=0){try{let n=qu(nr(t)),r=e>=0&&e<=n.length?e:0;return{text:n.subarray(r).toString("utf8"),offset:n.length}}catch{return{text:"",offset:0}}}function Hu(t){return`\u2500\u2500 run ${t} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function GO(t){let e=VO.exec(t);return e?Number(e[1]):void 0}function zu(t,e){let n=t.split(`
319
- `),r=[];if(n.forEach((o,a)=>{let l=GO(o);l!==void 0&&r.push({id:l,idx:a})}),!r.length)return e==="latest"?t:"";let s=e==="latest"?r[r.length-1]:r.find(o=>o.id===e);if(!s)return"";let i=r.find(o=>o.idx>s.idx);return n.slice(s.idx,i?i.idx:n.length).join(`
320
- `)}function er(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function Yu(t){try{await HO(ht(),{recursive:!0}),await Uy(Ju(t.pid),JSON.stringify({version:Me,...t}))}catch{pt()}}async function Vu(t,e){let n=Ju(t);try{let r=JSON.parse(await Fy(n,"utf8"));if(r.denied===e)return;r.denied=e,await Uy(n,JSON.stringify(r))}catch{}}async function pn(t){await Uu(Ju(t)).catch(()=>{}),await Uu(nr(t)).catch(()=>{}),await Uu(Wu(t)).catch(()=>{})}function ye(t){return t.agent!=null}function rr(t,e){return ye(t)&&t.cwd!=null&&re(t.cwd)===re(e)}function Gu(t,e){return!ye(t)&&Oy(t.file,e)}async function Z(t){let e;try{e=await KO(ht())}catch{return[]}let n=[];return await Promise.all(e.map(async s=>{if(!/^\d+\.json$/.test(s))return;let i=parseInt(s,10),o;try{o=JSON.parse(await Fy(Pe.join(ht(),s),"utf8"))}catch{await pn(i);return}o&&typeof o.pid=="number"&&er(o.pid)?n.push(o):await pn(i)})),(t?n.filter(s=>Gu(s,t)):n).sort((s,i)=>s.startedAt-i.startedAt)}async function Go(t,e){return(await Z()).find(n=>rr(n,t)&&(e?n.agent===e:!0))}async function Xu(t,e){let n=new URL(t).port,r=(await Z()).filter(a=>String(a.port)!==n),s=r.filter(a=>rr(a,e)),i=r.filter(a=>Gu(a,e)),o=0;for(let a of[...s,...i])try{let l=await fetch(`${a.url}/__open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t}),signal:AbortSignal.timeout(2e3)});if(!l.ok)continue;let{opened:c,pages:f}=await l.json();if(c)return{where:"editor",via:a.agent?"the agent mirror":`${Pe.basename(a.file)}'s page`};ye(a)&&(o+=f??0)}catch{}return o>0?{where:"external"}:void 0}async function tr(t){try{process.kill(t,"SIGTERM")}catch{}await pn(t)}async function Qu(t){try{let e=await fetch(`${t.url}/__pages`,{signal:AbortSignal.timeout(XO)});if(!e.ok)return;let{pages:n}=await e.json();return typeof n=="number"?n:void 0}catch{return}}async function Ft(t,e=ye(t)?"keep":"close"){try{let n=await fetch(`${t.url}/__stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pages:e}),signal:AbortSignal.timeout(jy)});if(!n.ok)throw new Error(`/__stop ${n.status}`);let{closed:r=0,stuck:s=0}=await n.json(),i=Date.now()+jy;for(;er(t.pid)&&Date.now()<i;)await Wy(100);return er(t.pid)?(await tr(t.pid),"killed"):(await pn(t.pid),{closed:r,stuck:s})}catch{return await tr(t.pid),"killed"}}function hn(t,e){let n=re(e);return t.filter(r=>!ye(r)&&r.pid!==process.pid&&re(r.file)===n)}async function Xo(t,e){let n=hn(await Z(),t);for(let r of n)await Ft(r,e!==void 0&&r.port===e?"keep":"close");return n}function QO(t,e,n){(process.platform==="win32"?Dy("cmd",["/c","start","","/b",t,...e],{cwd:n,stdio:"ignore",windowsHide:!0}):Dy(t,e,{cwd:n,detached:!0,stdio:"ignore"})).unref()}function sr(){return Pe.join(Pe.dirname(YO(import.meta.url)),"index.js")}function Ky(t,e={}){return{command:process.execPath,args:[sr(),...e.trust?["--trust"]:[],...e.mode?["--mode",e.mode]:[],t,...e.open===!1?["--no-open"]:[]]}}function Hy(t){return{command:process.execPath,args:[sr(),`agent:${t}`,"--no-open"]}}async function zy(t,e,n,r){let s=await t();if(s)return s;QO(e.command,e.args,n);let i=Date.now()+2e4;for(;Date.now()<i;){await Wy(150);let o=await t();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function Ts(t,e={}){let n=e.cwd??process.cwd(),r=Pe.resolve(n,t),s=await Zn({kind:"bulb",file:r},n),[i]=await Xo(r,s),o={...e,mode:e.mode??i?.mode};return zy(async()=>hn(await Z(),r)[0],Ky(t,o),n,Pe.basename(t))}async function Zu(t,e=process.cwd()){return zy(()=>Go(e,t),Hy(t),e,`the ${t} mirror`)}var By,VO,jy,XO,Wy,Le=S(()=>{"use strict";Ye();fn();zo();By=1e6;VO=/^── run (\d+) ── /;jy=6e3,XO=500;Wy=t=>new Promise(e=>setTimeout(e,t))});function ir(t){return{...Op(t),server:t.files.get("server.ts")??""}}function Qo(t){return!!t.server&&!t.code}var Os=S(()=>{"use strict";ee();ee()});function Zo(t){let e=/^---[^\n]*\n([\s\S]*?)\n---/.exec(t),n=e?/^\s*name:\s*(.+?)\s*$/m.exec(e[1]):null;return n?n[1].replace(/^["']|["']$/g,""):void 0}function ed(t){return Yn(Zo(t)??"bulb")||"bulb"}var td=S(()=>{"use strict";ee()});import{readdirSync as ZO,readFileSync as eP,statSync as tP}from"fs";import{join as Yy,basename as nP}from"path";function Gy(t,e,n){if(e>8)return n;let r;try{r=ZO(t,{withFileTypes:!0})}catch{return n}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;Gy(Yy(t,s.name),e+1,n)}else s.isFile()&&s.name.endsWith(".bulb.md")&&n.push(Yy(t,s.name));return n}function rP(t,e){let n,r=!1;try{let s=eP(t,"utf8");n=Zo(s.slice(0,1024));let i=We(s);r=!!i&&Qo(ir(i))}catch{}return{mtime:e,name:n??nP(t).replace(/\.bulb\.md$/,""),serverOnly:r}}function ea(t){let e=new Map,n=Gy(t,0,[]).map(r=>{let s=0;try{s=tP(r).mtimeMs}catch{}let i=s?Vy.get(r):void 0,o=i?.mtime===s?i:rP(r,s);return s&&e.set(r,o),{path:r,...o}});return Vy=e,n}var Vy,Xy=S(()=>{"use strict";ee();Os();td();Vy=new Map});function or(t){if(t.server.trim())return"server-side code (server.ts)";let e=t.code;if(/\btb\s*\.\s*fs\b/.test(e)||e.includes("/__fs"))return"the filesystem";if(/\btb\s*\.\s*ai\b/.test(e)||e.includes("/__ai")||t.infer.trim()||/\btb\s*\.\s*infer\b/.test(e))return"AI (your API keys)";if(/\btb\s*\.\s*server\s*\.\s*\w/.test(e)||e.includes("/__api"))return"server-side code (server.ts)"}var ta=S(()=>{"use strict"});import{readFile as sP}from"fs/promises";async function nd(t){try{let e=We(await sP(t,"utf-8"));return e?or(ir(e)):void 0}catch{return}}var Qy=S(()=>{"use strict";Os();ta()});function rd(t){let e=t.split(""),n=(i,o)=>{for(let a=i;a<o&&a<e.length;a++)e[a]!==`
306
+ `)){if(!c.trim())continue;let f;try{f=JSON.parse(c)}catch{continue}if(!f||Ss(f)||f.type!=="user")continue;let d=f.message?.content,u="";typeof d=="string"?u=jt(d):Array.isArray(d)&&(u=d.map(Nu).filter(Boolean).join(" "));let p=u.replace(/\s+/g," ").trim();if(p)return(p.replace(/^Continuing from a prior session\. Here is the summary of our work so far:\s*/i,"").trim()||p).slice(0,200)}return""}finally{LT(e)}}function Lu(t){let e=cn(t,"sessions"),n;try{n=uy(e)}catch{return[]}let r=[];for(let s of n)if(s.endsWith(".json"))try{let i=JSON.parse(dy(cn(e,s),"utf8"));if(!i?.sessionId)continue;process.kill(i.pid,0),r.push(i)}catch{}return r}function nO(t,e){return Lu(t).some(n=>n.sessionId===e)}function rO(t,e){let n=Lu(t).filter(r=>r.sessionId===e).map(r=>r.startedAt);return n.length&&n.every(r=>typeof r=="number")?Math.min(...n):void 0}function sO(t){return new Set(Lu(t).filter(e=>e.status==="busy").map(e=>e.sessionId))}var fy,Ru,jT,UT,qT,oy,hy,zT,GT,XT,ay,ly,Xn,Do=S(()=>{"use strict";vs();Io();No();fy=t=>t.type==="user"&&Array.isArray(t.message?.content)&&t.message.content.some(e=>e?.type==="tool_result");Ru=(t,e)=>cn(t,"projects",BT(e)),jT="subagents";UT="general-purpose",qT=[256*1024,4*1024*1024,64*1024*1024],oy=new Map;hy=[/\[Request interrupted by user\b/i,/\[Tool use was interrupted\]/i,/Claude Code returned an error/i,/\[ede_diagnostic\]/i,/^No response requested\.?$/i,/^<task-notification\b/i,/^<system-reminder\b/i,/^<local-command-stdout\b/i,/^<local-command-stderr\b/i];zT=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;GT=/^(?:[^\n<][^\n]*\n)?<agent-message from="([^"]+)">\n([\s\S]*?)(?:\n?<\/agent-message>[\s\S]*)?$/,XT=/^\[[^\]\n]+\][\s\S]*?The report follows:\n/;ay=`The coordinator sent a message while you were working:
307
+ `;ly=t=>typeof t!="number"?"":t<1024?`${t}B`:t<1048576?`${Math.round(t/1024)}KB`:`${(t/1048576).toFixed(1)}MB`;Xn=class extends Bt{constructor(n=cn(DT(),".claude")){super();this.root=n}displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return MT(this.root)}sessionsDir(n){return Ru(this.root,n)}listSessionFiles(n){return Ro(Ru(this.root,n))}listChildren(n,r){return FT(this.root,n,r)}callerSessionId(){return process.env.CLAUDE_CODE_SESSION_ID||void 0}parseEntry(n){try{return JSON.parse(n)}catch{return null}}idOf(n){return n.uuid}parentOf(n){return n.parentUuid}linker(){let n=new Map,r=new Map;return{link(s){if(!s.uuid||n.has(s.uuid))return;let i=s.parentUuid===void 0?void 0:n.get(s.parentUuid),o=s.type==="assistant"?s.message?.id:fy(s)?i:void 0;o&&(i===o&&(s.parentUuid=r.get(o)),n.set(s.uuid,o),r.set(o,s.uuid))}}}timestampOf(n){return n.timestamp}isSidechain(n,r){return!!n.isSidechain!=(r==="child")}isLeafType(n){return n.type==="user"||n.type==="assistant"}isRecoveryNoise(n){return!!n.isApiErrorMessage}apply(n,r){let s=eO(n);if(s)return{events:[$o(s)]};if(Ss(n)&&!ZT(n))return{events:[]};let i=[];if(n.type==="user"){let o=n.message?.content;if(typeof o=="string"){let a=jt(o);a&&i.push($o(a))}else if(Array.isArray(o))for(let a of o)if(a?.type==="tool_result"){let l=Iu(a.content);i.push({type:"tool_result",id:a.tool_use_id??"",content:l,isError:!!a.is_error,digest:$u(n.toolUseResult,l)})}else{let l=Nu(a)||Lo(a);l&&i.push($o(l))}return{events:i}}if(n.type==="attachment"&&n.attachment?.type==="queued_command"){let o=jt(Iu(n.attachment.prompt));return o&&i.push($o(o)),{events:i}}if(n.type==="assistant"){let o=n.message?.content,a=Array.isArray(o)?o:[],l=a.filter(p=>p.type==="text").map(p=>p.text??"").filter(p=>!HT(p)).join(""),c=a.filter(p=>p.type==="thinking").map(p=>p.thinking??"").join(`
308
+ `),f=a.filter(p=>p.type==="tool_use").map(p=>({id:p.id??"",name:p.name??"",input:p.input??{}}));if(l||c||f.length){let p=Date.parse(n.timestamp??""),m=!isNaN(p)&&p>=r;i.push({type:"assistant",text:l,thinking:c,tools:f,live:m,error:n.isApiErrorMessage||void 0})}let d=n.message?.usage??n.usage,u=d&&{in:d.input_tokens??0,out:d.output_tokens??0,cached:d.cache_read_input_tokens??0,cacheCreate:d.cache_creation_input_tokens??0};return{events:i,usage:u,model:n.message?.model}}return{events:i}}chainWorking(n){return py(n)}sessionAlive(n){return nO(this.root,n)}sessionsWorking(n){return sO(this.root)}readPreview(n){return tO(n)}searchText(n){if(!n||Ss(n)||n.type!=="user"&&n.type!=="assistant")return"";let r=n.message?.content,s="";if(typeof r=="string")s=jt(r);else if(Array.isArray(r)){let i=r;s=n.type==="user"?i.map(Nu).filter(Boolean).join(" "):i.filter(o=>o.type==="text"&&typeof o.text=="string").map(o=>o.text).join(" ")}return s.replace(/\s+/g," ").trim()}}});import{statSync as Bo,readdirSync as iO,existsSync as oO}from"fs";import{basename as my,join as Mu,resolve as aO}from"path";import{homedir as gy}from"os";function cO(t){let e=t.trimStart();return lO.some(n=>e.startsWith(n))}function Qn(t,e){return Array.isArray(t)?t.map(n=>typeof n?.text=="string"?e&&cO(n.text)?"":Oe(n.text):n?.type==="input_image"&&typeof n.image_url=="string"&&n.image_url.startsWith("data:")?`![image](${n.image_url})`:"").filter(Boolean).join(`
309
+ `):""}function uO(t){return typeof t=="string"?Oe(t):Qn(t,!1)}function dO(t,e){let n=e??"",r=xO(n);if(!r.length)return{name:t,input:{script:n}};let s=r.map(i=>Du(i.fn)&&ks(i.arg)?wO(String(i.arg.cmd??i.arg.command??"")):void 0);if(s.every(i=>i!==void 0))return{name:"read",input:yy(s.flat().map(i=>["path",i])),pending:{kind:"read"}};if(r.length===1){let{fn:i,arg:o}=r[0];if(i==="apply_patch"&&typeof o=="string"){let{files:a,diff:l}=by(o);return{name:i,input:new Set(a).size===1?{path:a[0],patch:l}:{patch:l},pending:{kind:"patch",digest:hO(l)}}}return ks(o)?Du(i)?{name:t,input:pO(o)}:{name:i,input:o}:typeof o=="string"?{name:i,input:{arg:o}}:{name:t,input:{script:n}}}return{name:t,input:yy(r.map(({fn:i,arg:o})=>i==="apply_patch"&&typeof o=="string"?["patch",by(o).diff]:Du(i)&&ks(o)?["command",o.cmd??o.command]:[i,o]))}}function pO(t){let e=Object.fromEntries(Object.entries(t).filter(([r])=>r!=="cmd"&&r!=="command"&&!fO.has(r))),n=t.command??t.cmd;return n===void 0?e:{command:n,...e}}function yy(t){let e={};for(let[n,r]of t){let s=n;for(let i=2;s in e;i++)s=`${n} (${i})`;e[s]=r}return e}function hO(t){let e=0,n=0;for(let r of t.split(`
310
+ `))r.startsWith("+")&&!r.startsWith("+++")?e++:r.startsWith("-")&&!r.startsWith("---")&&n++;return`+${e} \u2212${n}`}function wO(t){let e=SO(t),n=e.map(vO);return e.length&&n.every(r=>r!==void 0)?n:void 0}function vO(t){let[e,...n]=t.split("|");if(!n.every(i=>bO.test(i.trim())))return;let r=kO(e);if(!mO.test(r[0]??""))return;let s=[];for(let i=1;i<r.length;i++){let o=r[i];if(gO.test(o)){i+1<r.length&&s.push(r[++i]);continue}if(yO.test(o)){i++;continue}o.startsWith("-")||/^\d+(,\d+)?p?$/.test(o)||s.push(o)}return s.length===1?s[0]:void 0}function SO(t){let e=[],n=0;for(let r=0;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"){let o=t.indexOf(s,r+1);if(o<0)break;r=o;continue}let i=t.slice(r,r+2);(s===";"||s===`
311
+ `||i==="&&"||i==="||")&&(e.push(t.slice(n,r)),(i==="&&"||i==="||")&&r++,n=r+1)}return e.push(t.slice(n)),e.map(r=>r.trim()).filter(Boolean)}function kO(t){return(t.match(/'[^']*'|"[^"]*"|\S+/g)??[]).map(e=>/^(['"])(.*)\1$/.exec(e)?.[2]??e)}function xO(t){let e=[],n=/tools\.([A-Za-z_$][\w$]*)\s*\(/g;for(let r=n.exec(t);r;r=n.exec(t)){let s=r.index+r[0].length-1,i=Ey(t,s);if(i<0)break;e.push({fn:r[1],arg:xy(t.slice(s+1,i).trim(),t)}),n.lastIndex=i+1}return e}function xy(t,e){let n=t[0];if(n==='"'||n==="'"||n==="`")return Fo(t,0)===t.length-1?Ay(t.slice(1,-1)):t;if(n==="{"){for(let r of[t,AO(t)])try{let s=JSON.parse(r);if(ks(s))return s}catch{}return t}if(/^[A-Za-z_$][\w$]*$/.test(t)){let r=new RegExp(`\\b(?:const|let|var)\\s+${t.replace(/\$/g,"\\$")}\\s*=\\s*`).exec(e);if(r){let s=r.index+r[0].length,i=e[s],o=i==='"'||i==="'"||i==="`"?Fo(e,s):i==="{"?Ey(e,s):-1;if(o>s)return xy(e.slice(s,o+1),"")}}return t}function Ey(t,e){let n=0;for(let r=e;r<t.length;r++){let s=t[r];if(s==='"'||s==="'"||s==="`"){if(r=Fo(t,r),r<0)return-1}else if(s==="("||s==="["||s==="{")n++;else if((s===")"||s==="]"||s==="}")&&--n===0)return r}return-1}function Fo(t,e){let n=t[e];for(let r=e+1;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===n)return r;return-1}function Ay(t){return t.replace(/\\(?:u\{([0-9a-fA-F]+)\}|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|([\s\S]))/g,(e,n,r,s,i)=>n||r||s?String.fromCodePoint(parseInt(n||r||s,16)):EO[i]??i)}function AO(t){let e=/[A-Za-z_$][\w$]*(?=\s*:)/y,n=/,(?=\s*[}\]])/y,r="",s="";for(let i=0;i<t.length;i++){let o=t[i];if(o==='"'||o==="'"||o==="`"){let l=Fo(t,i);if(l<0)return t;r+=JSON.stringify(Ay(t.slice(i+1,l))),i=l,s=o;continue}e.lastIndex=i;let a=s==="{"||s===","?e.exec(t):null;if(a){r+=`"${a[0]}"`,i+=a[0].length-1,s='"';continue}n.lastIndex=i,!n.test(t)&&(r+=o,/\s/.test(o)||(s=o))}return r}function by(t){let e=[],n=[],r=!1;for(let s of t.split(/\r?\n/)){let i=/^\*\*\* (Update|Add|Delete) File: (.+)$/.exec(s);if(i){let o=i[2].trim();e.push(o),n.push(`--- ${i[1]==="Add"?"/dev/null":`a/${o}`}`,`+++ ${i[1]==="Delete"?"/dev/null":`b/${o}`}`),r=!0;continue}if(!/^\*\*\* (Begin|End) Patch$/.test(s)){if(s.startsWith("*** Move to:")){n.push(s);continue}r&&!s.startsWith("@@")&&n.push("@@"),r=!1,n.push(s)}}return r&&n.push("@@"),{files:e,diff:n.join(`
312
+ `)}}function TO(t,e){let n=/^Script (completed|failed|running with cell ID (\d+))\nWall time [^\n]*\nOutput:\n([\s\S]*)$/.exec(t);if(!n)return{content:t,isError:!1,digest:$e(t)};let r=n[3].replace(/^\n+/,"").replace(/^Script error:\n/,""),s=n[1]==="failed",i=OO(r);return i&&(r=i.output,i.exit_code&&(s=!0)),n[2]?{content:r,isError:s,digest:`running (cell ${n[2]})`}:e?.kind==="read"&&!s?{content:r,isError:s,digest:ke(PO(r),"line")}:e?.kind==="patch"&&!s?{content:e.digest,isError:s,digest:e.digest}:{content:r,isError:s,digest:$e(r)}}function OO(t){if(t.startsWith("{"))try{let e=JSON.parse(t);if(ks(e)&&typeof e.output=="string")return{output:e.output,exit_code:typeof e.exit_code=="number"?e.exit_code:void 0}}catch{}}function CO(t){if(typeof t=="string"&&t)try{let e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}return{arguments:t??""}}function RO(t){let e,n,r;for(let s of _O){let i=_o(t,s);if(i===void 0)return{};let o=i.text.split(`
313
+ `);i.partial&&o.shift();let a;for(let l=o.length-1;l>=0;l--){if(!o[l].trim())continue;let c;try{c=JSON.parse(o[l])}catch{continue}if(a===void 0){let f=Date.parse(c.timestamp??"");Number.isNaN(f)||(a=f)}if(e===void 0&&c.type==="event_msg"){let f=c.payload?.type;f==="task_started"?e=!0:(f==="task_complete"||f==="turn_aborted")&&(e=!1)}if(n===void 0&&c.type==="event_msg"&&c.payload?.type==="token_count"&&c.payload.info?.last_token_usage){let f=Ty(c.payload.info.last_token_usage);n=f.in+f.out+f.cached+f.cacheCreate}if(r===void 0&&c.type==="turn_context"&&(r={model:c.payload?.model,effort:c.payload?.effort}),a!==void 0&&e!==void 0&&n!==void 0&&r!==void 0)break}if(a!==void 0)return{ms:a,running:e??!0,tokens:n,turn:r};if(!i.partial)break}return{running:e??!0,tokens:n,turn:r}}function Ty(t){return{in:Math.max(0,(t.input_tokens??0)-(t.cached_input_tokens??0)),out:t.output_tokens??0,cached:t.cached_input_tokens??0,cacheCreate:t.cache_write_input_tokens??0}}function vy(t){let n=Gn(t,65536);if(n===void 0)return;let r=n.text.indexOf(`
314
+ `);if(r<0)return n.bytes>=65536?{cwd:"",subagent:!1}:void 0;try{let s=JSON.parse(n.text.slice(0,r)),i=s?.type==="session_meta"?s.payload:void 0;if(typeof i?.cwd!="string")return{cwd:"",subagent:!1};let o=typeof i.source=="object"?i.source?.subagent:void 0,a=IO(i,o),l=ky(n.text,r),c=a&&!l&&n.bytes>=65536?Gn(t,Sy):void 0,f=l??(c&&ky(c.text,r)),d=!!a&&!f&&(c??n).bytes<(c?Sy:65536);return{cwd:i.cwd,subagent:!!o,id:i.id,spawn:a,turn:f,modelPending:d}}catch{return{cwd:"",subagent:!1}}}function IO(t,e){let n=e?.thread_spawn;if(!n)return;let r=n.parent_thread_id??t.parent_thread_id;if(!(!t.id||!r))return{id:t.id,parent:r,path:n.agent_path??"",role:n.agent_role??void 0,depth:n.depth??1}}function ky(t,e){for(let n of t.slice(e+1).split(`
315
+ `))if(n.trim())try{let r=JSON.parse(n);if(r.type==="turn_context"&&typeof r.payload?.model=="string")return{model:r.payload.model,effort:r.payload.effort}}catch{}}var lO,ks,Du,fO,mO,gO,yO,bO,EO,PO,jo,wy,Zn,_O,Sy,Bu=S(()=>{"use strict";vs();No();Io();lO=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<node_repl_review_evidence>","# AGENTS.md instructions for "];ks=t=>!!t&&typeof t=="object"&&!Array.isArray(t),Du=t=>t==="shell_command"||t==="exec_command",fO=new Set(["max_output_tokens","yield_time_ms","timeout_ms"]);mO=/^(Get-Content|gc|cat|type|nl|bat|sed|head|tail)$/i,gO=/^-(Path|LiteralPath)$/i,yO=/^-(Encoding|TotalCount|Head|Tail|ReadCount|Delimiter)$/i,bO=/^(sed -n|head|tail|Select-Object|select)(\s|$)/i;EO={n:`
316
+ `,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};PO=t=>t?t.replace(/\r?\n$/,"").split(`
317
+ `).length:0;jo=t=>{let e=aO(t);return process.platform==="win32"?e.toLowerCase():e},wy=12e4,Zn=class t extends Bt{constructor(n=Mu(gy(),".codex","sessions")){super();this.root=n}displayName="Codex Mirror";childBriefs=!1;#t=0;#l;#n=!1;#i;#h=0;#s=new Map;#d=new Map;#o=new Map;#c=new Map;detectsSelf(){return!!process.env.CODEX_THREAD_ID}forRead(){return new t(this.root)}callerSessionId(n){let r=process.env.CODEX_THREAD_ID;return r?this.listSessionFiles(n).find(s=>s.sessionId.endsWith(r))?.sessionId:void 0}detectsInstalled(){return oO(Mu(gy(),".codex"))}sessionsDir(n){return this.root}listSessionFiles(n){let r=jo(n),s=[];for(let i of this.#u()){let o=0,a=0;try{let f=Bo(i);if(!f.isFile())continue;o=f.size,a=f.mtimeMs}catch{continue}let l=this.#s.get(i);if(l===void 0){if(l=vy(i),l===void 0)continue;this.#s.set(i,l)}if(l.subagent||jo(l.cwd)!==r)continue;let c=my(i,".jsonl");this.#o.set(c,i),s.push({sessionId:c,file:i,mtime:this.#e(i,o,a)})}return s}listChildren(n,r){let s=jo(n),i=new Map,o;for(let c of this.#u()){let f=0,d=0,u;try{let x=Bo(c);if(!x.isFile())continue;f=x.size,d=x.mtimeMs,u=x.birthtimeMs||void 0}catch{continue}let p=this.#s.get(c);if(p===void 0||p.modelPending){if(p=vy(c),p===void 0)continue;this.#s.set(c,p)}if(my(c,".jsonl")===r&&(o=p.id),!p.spawn||jo(p.cwd)!==s)continue;let{running:m,tokens:h,turn:g}=this.#r(c,f,d);i.set(p.spawn.id,{file:c,mtime:this.#e(c,f,d),started:u,running:m,tokens:h,spawn:p.spawn,turn:g??p.turn})}if(!o)return[];let a=(c,f=new Set)=>{if(c.parent===o)return!0;if(f.has(c.id))return!1;f.add(c.id);let d=i.get(c.parent);return d?a(d.spawn,f):!1},l=[];for(let{file:c,mtime:f,started:d,running:u,tokens:p,spawn:m,turn:h}of i.values())a(m)&&l.push({id:m.id,file:c,mtime:f,started:d,tokens:p,label:m.path.split("/").filter(Boolean).pop()??m.path,kind:m.role||void 0,model:h?.model,effort:h?.effort,parentId:i.has(m.parent)?m.parent:void 0,depth:m.depth,stopped:!1,running:u});return l}sessionsWorking(n){let r=new Set,s=Date.now();for(let{sessionId:i,file:o,mtime:a}of this.listSessionFiles(n)){if(s-a>=wy)continue;let l;try{let c=Bo(o);l=this.#r(o,c.size,c.mtimeMs)}catch{continue}l.running&&r.add(i)}return r}#e(n,r,s){return Math.max(s,this.#r(n,r,s).ms??0)}#r(n,r,s){let i=this.#d.get(n);if(i&&i.size===r&&i.mtime===s)return i;let o=RO(n),a={size:r,mtime:s,...o,turn:o.turn??i?.turn};return this.#d.set(n,a),a}#u(){let n=[],r=s=>{try{return iO(s).map(i=>Mu(s,i))}catch{return[]}};for(let s of r(this.root))for(let i of r(s))for(let o of r(i))for(let a of r(o))a.endsWith(".jsonl")&&n.push(a);return n}parseEntry(n){let r;try{r=JSON.parse(n)}catch{return null}return!r||typeof r.type!="string"?null:r}idOf(n){return n.ord===void 0&&(this.#a(n),n.ord=String(this.#t++),n.parent=this.#l,this.#l=n.ord),n.ord}#a(n){let r=n.payload;if(n.type==="session_meta"){if(++this.#h===1){let s=typeof r?.source=="object"?r.source?.subagent?.thread_spawn:void 0;this.#i=s?.agent_path,this.#n=!!s}}else this.#h=0,this.#n&&r?.type==="agent_message"&&r.recipient===this.#i&&(this.#n=!1);n.inherited=this.#n}parentOf(n){return n.parent}timestampOf(n){return n.timestamp}isSidechain(n,r){return r==="child"&&!!n.inherited}isLeafType(n){return!0}isRecoveryNoise(n){return!1}apply(n,r){let s=[],i=n.payload;if(!i)return{events:s};let o=()=>{let a=Date.parse(n.timestamp??"");return!isNaN(a)&&a>=r};if(n.type==="response_item"){if(i.type==="message"){if(i.role==="user"){let a=Qn(i.content,!0).trim();a&&s.push({type:"user",text:a})}else if(i.role==="assistant"){let a=Qn(i.content,!1);a&&s.push({type:"assistant",text:a,thinking:"",tools:[],live:o()})}return{events:s}}if(i.type==="reasoning"){let a=Qn(i.summary,!1);return a&&s.push({type:"assistant",text:"",thinking:a,tools:[],live:o()}),{events:s}}if(i.type==="custom_tool_call"||i.type==="function_call"){let a=i.call_id??"",{pending:l,...c}=i.type==="custom_tool_call"?dO(i.name??"",i.input):{name:i.name??"",input:CO(i.arguments)};return l&&this.#c.set(a,l),s.push({type:"assistant",text:"",thinking:"",tools:[{id:a,...c}],live:o()}),{events:s}}if(i.type==="custom_tool_call_output"||i.type==="function_call_output"){let a=i.call_id??"",l=this.#c.get(a);return this.#c.delete(a),s.push({type:"tool_result",id:a,...TO(uO(i.output),l)}),{events:s}}return{events:s}}if(n.type==="event_msg"){if(i.type==="token_count"){let a=i.info?.last_token_usage;return a?{events:s,usage:Ty(a)}:{events:s}}return{events:s}}return n.type==="turn_context"?{events:s,model:i.model}:{events:s}}chainWorking(n){let r=!1;for(let s of n){if(s.type!=="event_msg")continue;let i=s.payload?.type;i==="task_started"?r=!0:(i==="task_complete"||i==="turn_aborted")&&(r=!1)}return r}sessionAlive(n){let r=this.#o.get(n);if(!r)return;let s;try{let i=Bo(r);s=this.#e(r,i.size,i.mtimeMs)}catch{return}return Date.now()-s<wy}readPreview(n){for(let r of(Gn(n,256*1024)?.text??"").split(`
318
+ `))if(!(!r.includes('"user_message"')&&!r.includes('"UserMessage"')))try{let s=JSON.parse(r);if(s?.type!=="event_msg")continue;let i=s.payload,a=((i?.type==="user_message"?i.message:i?.type==="item_completed"&&i.item?.type==="UserMessage"?Qn(i.item.content,!0):void 0)??"").replace(/\s+/g," ").trim();if(a)return a.slice(0,200)}catch{}return""}searchText(n){if(n?.type!=="response_item"||n.payload?.type!=="message")return"";let r=n.payload.role;return r!=="user"&&r!=="assistant"?"":Qn(n.payload.content,r==="user").replace(/\s+/g," ").trim()}},_O=[64*1024,1024*1024];Sy=512*1024});import{realpathSync as NO}from"fs";import{createHash as $O}from"crypto";import{join as Uo,resolve as LO}from"path";import{homedir as MO}from"os";function ze(){let t=process.env.TYPEBULB_SERVERS_DIR;return t?Uo(t,".."):Uo(MO(),".typebulb")}function pt(){Oy||(Oy=!0,console.error(`${ze()} not writable \u2014 continuing stateless: ports won't stick, caches stay cold, and typebulb logs/wait/send/stop may not see this run`))}function ht(){return process.env.TYPEBULB_SERVERS_DIR||Uo(ze(),"servers")}function Py(t){let e=se(t),n=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return Uo(ze(),"canvas",`${n}-${xs(t)}.png`)}function xs(t){return $O("sha1").update(se(t)).digest("hex").slice(0,8)}function se(t){let e=LO(t),n=e;try{n=NO.native(e)}catch{}return(process.platform==="win32"?n.toLowerCase():n).replace(/\\/g,"/")}function Cy(t,e){let n=se(t),r=se(e);return n.startsWith(r.endsWith("/")?r:r+"/")?!n.includes("/node_modules/"):!1}var Oy,Ye=S(()=>{"use strict";Oy=!1});import*as Iy from"net";import{mkdir as DO,readFile as BO,writeFile as Ny}from"fs/promises";import{existsSync as jO}from"fs";import{join as $y}from"path";function Dy(){return $y(ze(),"blocks")}function ju(t){return $y(Dy(),`${t}.json`)}function Jo(t){return new Promise(e=>{let n=Iy.createServer();n.once("error",()=>e(!1)),n.listen(t,"127.0.0.1",()=>n.close(()=>e(!0)))})}async function JO(t){for(let e=t;e<65535;e++)if(await Jo(e))return e;throw new Error(`No free port found above ${t}`)}async function Fu(t){let{listBulbServers:e}=await Promise.resolve().then(()=>(Le(),By)),n=(await e()).find(s=>s.port===t),r=n?` (pid ${n.pid}, ${n.agent?`agent:${n.agent}`:n.file})`:"";console.error(`port ${t} in use${r}`),process.exit(1)}async function Wo(t){try{let e=JSON.parse(await BO(ju(t),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function Ko(t,e){try{return await Ny(ju(t),JSON.stringify(e,null,2)),!0}catch{return pt(),!1}}async function WO(t){let e=se(t);try{await DO(Dy(),{recursive:!0})}catch{return}let n=[];for(let o=0;o<My;o++)n.push(Ly+o*un);let r=await Promise.all(n.map(async o=>({base:o,block:await Wo(o)})));for(let{base:o,block:a}of r)if(a?.cwd===e)return o;let s={cwd:e,slots:{},mirrors:{}};for(let{base:o,block:a}of r){if(!a)try{return await Ny(ju(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(l){if((await Wo(o))?.cwd===e)return o;l.code!=="EEXIST"&&pt();continue}if(!jO(a.cwd))return await Ko(o,s)?o:void 0}let i=r.filter(o=>!!o.block).sort((o,a)=>_y(o.block)-_y(a.block))[0];if(i)return await Ko(i.base,s)?i.base:void 0}function _y(t){return Object.values(t.slots).reduce((e,n)=>Math.max(e,n.usedAt??0),0)}async function KO(t,e){let n=await Wo(t)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=n.mirrors[e.agent];if(i!==void 0)return i;let o=Ry(n),a=o.has(0)?UO:0;for(;a>qo&&o.has(a);)a--;return n.mirrors[e.agent]=a,await Ko(t,n),a}let r=se(e.file),s=n.slots[r]?.offset;if(s===void 0){let i=Ry(n);for(s=qo;s<un&&i.has(s);)s++;if(s>=un){let o=Object.entries(n.slots).sort((a,l)=>(a[1].usedAt??0)-(l[1].usedAt??0))[0];s=o?o[1].offset:qo,o&&delete n.slots[o[0]]}}return n.slots[r]={offset:s,usedAt:Date.now()},await Ko(t,n),s}function Ry(t){return new Set([...Object.values(t.mirrors),...Object.values(t.slots).map(e=>e.offset)])}async function er(t,e){let n=await WO(e);return n===void 0?void 0:n+await KO(n,t)}async function dn(t){let e=se(t);for(let n=0;n<My;n++){let r=await Wo(Ly+n*un);if(r?.cwd===e)return s=>r.slots[se(s)]?.usedAt??0}return()=>0}async function Ho(t){if(t.explicit!==void 0)return await Jo(t.explicit)||await Fu(t.explicit),t.target.kind==="bulb"&&await er(t.target,t.cwd),{port:t.explicit};let e=await er(t.target,t.cwd);if(e!==void 0){let r=e-e%un,s=Date.now()+qO;do{if(await Jo(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=qo;i<un;i++){let o=r+i;if(o!==e&&await Jo(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await JO(FO),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var Ly,un,My,FO,qo,UO,qO,fn=S(()=>{"use strict";Ye();Ly=20100,un=100,My=19,FO=23e3,qo=1,UO=un-1,qO=3e3});var Me,zo=S(()=>{"use strict";Me="0.61.12"});var By={};Si(By,{agentViewerCommand:()=>Yy,bulbServerCommand:()=>zy,clearServerLog:()=>Ku,findProjectViewer:()=>Go,isAlive:()=>tr,isMirror:()=>ye,isProjectBulb:()=>Gu,isProjectMirror:()=>sr,launchAgentViewer:()=>Zu,launchBulbServer:()=>Ts,listBulbServers:()=>X,probePageCount:()=>Qu,readServerLog:()=>Ve,readWaitCursor:()=>Vo,recordDenial:()=>Vu,registerServer:()=>Yu,relayOpen:()=>Xu,runMarker:()=>Hu,serverLogPath:()=>rr,serversForBulb:()=>hn,sliceRunLog:()=>zu,startServerLog:()=>As,stopBulbServer:()=>nr,stopServer:()=>Ft,stopServersForBulb:()=>Xo,typebulbBinPath:()=>ir,unregisterServer:()=>pn,writeWaitCursor:()=>Es});import{spawn as jy}from"child_process";import{readdir as HO,readFile as qy,writeFile as Jy,unlink as Uu,mkdir as zO}from"fs/promises";import{mkdirSync as Wy,writeFileSync as Yo,appendFileSync as YO,readFileSync as qu}from"fs";import*as Pe from"path";import{fileURLToPath as VO}from"url";function Ju(t){return Pe.join(ht(),`${t}.json`)}function rr(t){return Pe.join(ht(),`${t}.log`)}function Wu(t){return Pe.join(ht(),`${t}.wait.json`)}function Ky(t){try{let e=JSON.parse(qu(Wu(t),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function Vo(t,e=""){let n=Ky(t)[e];return typeof n=="number"&&Number.isFinite(n)&&n>=0?n:void 0}function Es(t,e,n=""){try{Wy(ht(),{recursive:!0});let r=Ky(t);r[n]=e,Yo(Wu(t),JSON.stringify({cursors:r}))}catch{}}function As(t){let e=rr(t);try{Wy(ht(),{recursive:!0}),Yo(e,"")}catch{return()=>{}}let n=process.stdout.write.bind(process.stdout),r=process.stderr.write.bind(process.stderr),s=0,i=!1,o=a=>{if(!i)try{let l=typeof a=="string"?Buffer.from(a,"utf8"):Buffer.from(a);if(YO(e,l),s+=l.length,s>2*Fy){let c=qu(e),f=c.subarray(Math.max(0,c.length-Fy));Yo(e,f),s=f.length}}catch{i=!0}};return process.stdout.write=((a,...l)=>(o(a),n(a,...l))),process.stderr.write=((a,...l)=>(o(a),r(a,...l))),()=>{process.stdout.write=n,process.stderr.write=r}}function Ku(t){try{Yo(rr(t),"")}catch{}}function Ve(t,e=0){try{let n=qu(rr(t)),r=e>=0&&e<=n.length?e:0;return{text:n.subarray(r).toString("utf8"),offset:n.length}}catch{return{text:"",offset:0}}}function Hu(t){return`\u2500\u2500 run ${t} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function XO(t){let e=GO.exec(t);return e?Number(e[1]):void 0}function zu(t,e){let n=t.split(`
319
+ `),r=[];if(n.forEach((o,a)=>{let l=XO(o);l!==void 0&&r.push({id:l,idx:a})}),!r.length)return e==="latest"?t:"";let s=e==="latest"?r[r.length-1]:r.find(o=>o.id===e);if(!s)return"";let i=r.find(o=>o.idx>s.idx);return n.slice(s.idx,i?i.idx:n.length).join(`
320
+ `)}function tr(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}async function Yu(t){try{await zO(ht(),{recursive:!0}),await Jy(Ju(t.pid),JSON.stringify({version:Me,...t}))}catch{pt()}}async function Vu(t,e){let n=Ju(t);try{let r=JSON.parse(await qy(n,"utf8"));if(r.denied===e)return;r.denied=e,await Jy(n,JSON.stringify(r))}catch{}}async function pn(t){await Uu(Ju(t)).catch(()=>{}),await Uu(rr(t)).catch(()=>{}),await Uu(Wu(t)).catch(()=>{})}function ye(t){return t.agent!=null}function sr(t,e){return ye(t)&&t.cwd!=null&&se(t.cwd)===se(e)}function Gu(t,e){return!ye(t)&&Cy(t.file,e)}async function X(t){let e;try{e=await HO(ht())}catch{return[]}let n=[];return await Promise.all(e.map(async s=>{if(!/^\d+\.json$/.test(s))return;let i=parseInt(s,10),o;try{o=JSON.parse(await qy(Pe.join(ht(),s),"utf8"))}catch{await pn(i);return}o&&typeof o.pid=="number"&&tr(o.pid)?n.push(o):await pn(i)})),(t?n.filter(s=>Gu(s,t)):n).sort((s,i)=>s.startedAt-i.startedAt)}async function Go(t,e){return(await X()).find(n=>sr(n,t)&&(e?n.agent===e:!0))}async function Xu(t,e){let n=new URL(t).port,r=(await X()).filter(a=>String(a.port)!==n),s=r.filter(a=>sr(a,e)),i=r.filter(a=>Gu(a,e)),o=0;for(let a of[...s,...i])try{let l=await fetch(`${a.url}/__open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t}),signal:AbortSignal.timeout(2e3)});if(!l.ok)continue;let{opened:c,pages:f}=await l.json();if(c)return{where:"editor",via:a.agent?"the agent mirror":`${Pe.basename(a.file)}'s page`};ye(a)&&(o+=f??0)}catch{}return o>0?{where:"external"}:void 0}async function nr(t){try{process.kill(t,"SIGTERM")}catch{}await pn(t)}async function Qu(t){try{let e=await fetch(`${t.url}/__pages`,{signal:AbortSignal.timeout(QO)});if(!e.ok)return;let{pages:n}=await e.json();return typeof n=="number"?n:void 0}catch{return}}async function Ft(t,e=ye(t)?"keep":"close"){try{let n=await fetch(`${t.url}/__stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pages:e}),signal:AbortSignal.timeout(Uy)});if(!n.ok)throw new Error(`/__stop ${n.status}`);let{closed:r=0,stuck:s=0}=await n.json(),i=Date.now()+Uy;for(;tr(t.pid)&&Date.now()<i;)await Hy(100);return tr(t.pid)?(await nr(t.pid),"killed"):(await pn(t.pid),{closed:r,stuck:s})}catch{return await nr(t.pid),"killed"}}function hn(t,e){let n=se(e);return t.filter(r=>!ye(r)&&r.pid!==process.pid&&se(r.file)===n)}async function Xo(t,e){let n=hn(await X(),t);for(let r of n)await Ft(r,e!==void 0&&r.port===e?"keep":"close");return n}function ZO(t,e,n){(process.platform==="win32"?jy("cmd",["/c","start","","/b",t,...e],{cwd:n,stdio:"ignore",windowsHide:!0}):jy(t,e,{cwd:n,detached:!0,stdio:"ignore"})).unref()}function ir(){return Pe.join(Pe.dirname(VO(import.meta.url)),"index.js")}function zy(t,e={}){return{command:process.execPath,args:[ir(),...e.trust?["--trust"]:[],...e.mode?["--mode",e.mode]:[],t,...e.open===!1?["--no-open"]:[]]}}function Yy(t){return{command:process.execPath,args:[ir(),`agent:${t}`,"--no-open"]}}async function Vy(t,e,n,r){let s=await t();if(s)return s;ZO(e.command,e.args,n);let i=Date.now()+2e4;for(;Date.now()<i;){await Hy(150);let o=await t();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function Ts(t,e={}){let n=e.cwd??process.cwd(),r=Pe.resolve(n,t),s=await er({kind:"bulb",file:r},n),[i]=await Xo(r,s),o={...e,mode:e.mode??i?.mode};return Vy(async()=>hn(await X(),r)[0],zy(t,o),n,Pe.basename(t))}async function Zu(t,e=process.cwd()){return Vy(()=>Go(e,t),Yy(t),e,`the ${t} mirror`)}var Fy,GO,Uy,QO,Hy,Le=S(()=>{"use strict";Ye();fn();zo();Fy=1e6;GO=/^── run (\d+) ── /;Uy=6e3,QO=500;Hy=t=>new Promise(e=>setTimeout(e,t))});function or(t){return{...Op(t),server:t.files.get("server.ts")??""}}function Qo(t){return!!t.server&&!t.code}var Os=S(()=>{"use strict";Q();Q()});function Zo(t){let e=/^---[^\n]*\n([\s\S]*?)\n---/.exec(t),n=e?/^\s*name:\s*(.+?)\s*$/m.exec(e[1]):null;return n?n[1].replace(/^["']|["']$/g,""):void 0}function ed(t){return Yn(Zo(t)??"bulb")||"bulb"}var td=S(()=>{"use strict";Q()});import{readdirSync as eP,readFileSync as tP,statSync as nP}from"fs";import{join as Gy,basename as rP}from"path";function Qy(t,e,n){if(e>8)return n;let r;try{r=eP(t,{withFileTypes:!0})}catch{return n}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;Qy(Gy(t,s.name),e+1,n)}else s.isFile()&&s.name.endsWith(".bulb.md")&&n.push(Gy(t,s.name));return n}function sP(t,e){let n,r=!1;try{let s=tP(t,"utf8");n=Zo(s.slice(0,1024));let i=We(s);r=!!i&&Qo(or(i))}catch{}return{mtime:e,name:n??rP(t).replace(/\.bulb\.md$/,""),serverOnly:r}}function ea(t){let e=new Map,n=Qy(t,0,[]).map(r=>{let s=0;try{s=nP(r).mtimeMs}catch{}let i=s?Xy.get(r):void 0,o=i?.mtime===s?i:sP(r,s);return s&&e.set(r,o),{path:r,...o}});return Xy=e,n}var Xy,Zy=S(()=>{"use strict";Q();Os();td();Xy=new Map});function ar(t){if(t.server.trim())return"server-side code (server.ts)";let e=t.code;if(/\btb\s*\.\s*fs\b/.test(e)||e.includes("/__fs"))return"the filesystem";if(/\btb\s*\.\s*ai\b/.test(e)||e.includes("/__ai")||t.infer.trim()||/\btb\s*\.\s*infer\b/.test(e))return"AI (your API keys)";if(/\btb\s*\.\s*server\s*\.\s*\w/.test(e)||e.includes("/__api"))return"server-side code (server.ts)"}var ta=S(()=>{"use strict"});import{readFile as iP}from"fs/promises";async function nd(t){try{let e=We(await iP(t,"utf-8"));return e?ar(or(e)):void 0}catch{return}}var eb=S(()=>{"use strict";Os();ta()});function rd(t){let e=t.split(""),n=(i,o)=>{for(let a=i;a<o&&a<e.length;a++)e[a]!==`
321
321
  `&&(e[a]=" ")},r=0,s="";for(;r<t.length;){let i=t[r],o=t[r+1];if(i==="/"&&o==="/"){let a=r;for(;a<t.length&&t[a]!==`
322
- `;)a++;n(r,a),r=a}else if(i==="/"&&o==="*"){let a=r+2;for(;a<t.length&&!(t[a]==="*"&&t[a+1]==="/");)a++;n(r,Math.min(a+2,t.length)),r=a+2}else if(i==="/"&&iP.has(s)){let a=r+1,l=!1;for(;a<t.length&&t[a]!==`
322
+ `;)a++;n(r,a),r=a}else if(i==="/"&&o==="*"){let a=r+2;for(;a<t.length&&!(t[a]==="*"&&t[a+1]==="/");)a++;n(r,Math.min(a+2,t.length)),r=a+2}else if(i==="/"&&oP.has(s)){let a=r+1,l=!1;for(;a<t.length&&t[a]!==`
323
323
  `;){let c=t[a];if(c==="\\")a++;else if(c==="[")l=!0;else if(c==="]")l=!1;else if(c==="/"&&!l)break;a++}r=a+1,s="/"}else if(i==='"'||i==="'"){let a=r+1;for(;a<t.length&&t[a]!==i&&t[a]!==`
324
- `;)t[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=Zy(t,r);n(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function Zy(t,e){let n=e+1,r=0;for(;n<t.length;){let s=t[n];if(s==="\\"){n+=2;continue}if(s==="`"){if(r===0)return n+1;n=Zy(t,n);continue}if(s==="$"&&t[n+1]==="{"){r++,n+=2;continue}if(s==="}"&&r>0){r--,n++;continue}n++}return t.length}var iP,eb=S(()=>{iP=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function lP(t){if(/^[./]/.test(t)||/^[a-z][a-z0-9+.-]*:/i.test(t))return;let e=t.split("/");return t.startsWith("@")?e.slice(0,2).join("/"):e[0]}function tb(t){let e=[];for(let s of aP)for(let i of t.matchAll(s)){let o=lP(i[1]);o&&e.push({root:o,index:i.index??0})}e.sort((s,i)=>s.index-i.index);let n=new Set,r=[];for(let{root:s,index:i}of e)n.has(s)||(n.add(s),r.push({root:s,lineIndex:t.slice(0,i).split(`
325
- `).length-1}));return r}function nb(t){return tb(rd(t)).map(e=>e.root)}function Ps(t,e){if(!t)return[];let{target:n,dependencies:r}=e,s=(e.lineOffset??1)-1,i=[],o=t.split(`
324
+ `;)t[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=tb(t,r);n(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function tb(t,e){let n=e+1,r=0;for(;n<t.length;){let s=t[n];if(s==="\\"){n+=2;continue}if(s==="`"){if(r===0)return n+1;n=tb(t,n);continue}if(s==="$"&&t[n+1]==="{"){r++,n+=2;continue}if(s==="}"&&r>0){r--,n++;continue}n++}return t.length}var oP,nb=S(()=>{oP=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function cP(t){if(/^[./]/.test(t)||/^[a-z][a-z0-9+.-]*:/i.test(t))return;let e=t.split("/");return t.startsWith("@")?e.slice(0,2).join("/"):e[0]}function rb(t){let e=[];for(let s of lP)for(let i of t.matchAll(s)){let o=cP(i[1]);o&&e.push({root:o,index:i.index??0})}e.sort((s,i)=>s.index-i.index);let n=new Set,r=[];for(let{root:s,index:i}of e)n.has(s)||(n.add(s),r.push({root:s,lineIndex:t.slice(0,i).split(`
325
+ `).length-1}));return r}function sb(t){return rb(rd(t)).map(e=>e.root)}function Ps(t,e){if(!t)return[];let{target:n,dependencies:r}=e,s=(e.lineOffset??1)-1,i=[],o=t.split(`
326
326
  `),a=rd(t).split(`
327
- `);for(let l=0;l<o.length;l++){let c=a[l],f=l+1+s;for(let d of oP)d.targets.includes(n)&&d.pattern.test(c)&&i.push({type:d.type,severity:"error",message:dP(d.type,f),lineNumber:f,lineContent:o[l]})}return n==="client"&&r&&i.push(...cP(a,o,r,s)),i}function cP(t,e,n,r){let s=new Set(Object.keys(n));return tb(t.join(`
328
- `)).filter(({root:i})=>!s.has(i)).map(({root:i,lineIndex:o})=>{let a=o+1+r;return{type:"UNDECLARED_IMPORT",severity:"error",message:uP(i,a),lineNumber:a,lineContent:e[o]}})}function uP(t,e){return`Import "${t}" is not declared in config.json dependencies! Found on line ${e}.
327
+ `);for(let l=0;l<o.length;l++){let c=a[l],f=l+1+s;for(let d of aP)d.targets.includes(n)&&d.pattern.test(c)&&i.push({type:d.type,severity:"error",message:fP(d.type,f),lineNumber:f,lineContent:o[l]})}return n==="client"&&r&&i.push(...uP(a,o,r,s)),i}function uP(t,e,n,r){let s=new Set(Object.keys(n));return rb(t.join(`
328
+ `)).filter(({root:i})=>!s.has(i)).map(({root:i,lineIndex:o})=>{let a=o+1+r;return{type:"UNDECLARED_IMPORT",severity:"error",message:dP(i,a),lineNumber:a,lineContent:e[o]}})}function dP(t,e){return`Import "${t}" is not declared in config.json dependencies! Found on line ${e}.
329
329
 
330
330
  **CRITICAL**: Every bare import in code.tsx must be declared in the **config.json** "dependencies" block. A bulb that imports a package it doesn't declare is incomplete \u2014 it won't type-check, its versions aren't pinned, and it can't be reliably re-run or ported to typebulb.com.
331
331
 
@@ -339,7 +339,7 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
339
339
  }
340
340
  \`\`\`
341
341
 
342
- **Fix:** Add a **config.json** block (or extend the existing one) with a "dependencies" entry for "${t}" \u2014 and for every other bare import in code.tsx. Pin a real version where you can (e.g. "react": "^19.2.7").`}function dP(t,e){return t==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
342
+ **Fix:** Add a **config.json** block (or extend the existing one) with a "dependencies" entry for "${t}" \u2014 and for every other bare import in code.tsx. Pin a real version where you can (e.g. "react": "^19.2.7").`}function fP(t,e){return t==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
343
343
 
344
344
  **CRITICAL**: Import packages by name only. Do NOT use CDN URLs:
345
345
 
@@ -493,22 +493,22 @@ import { something } from 'module-name'
493
493
  const something = require('module-name') // NOT SUPPORTED!
494
494
  \`\`\`
495
495
 
496
- **Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var mn,gn,oP,aP,na=S(()=>{eb();mn=["client"],gn=["client","server"],oP=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:mn},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:gn},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:mn},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:mn},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:mn},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:gn},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:gn},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:gn},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:gn},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:gn},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:gn},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:mn},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:mn},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:mn}],aP=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function sd(t){let e=We(t);if(!e)return t;let n=e.files.get("code.tsx");if(!n)return t;let r=nb(n);if(!r.length)return t;let s=e.files.get("config.json"),i={};if(s)try{let c=JSON.parse(s);c&&typeof c=="object"&&(i=c)}catch{}let o=i.dependencies&&typeof i.dependencies=="object"?{...i.dependencies}:{},a=r.filter(c=>!(c in o));if(!a.length)return t;for(let c of a)o[c]="latest";i.dependencies=o;let l={name:e.frontmatter.name};for(let[c,f]of e.files){let d=Sp(c);d&&(l[d]=f)}return l.config=JSON.stringify(i,null,2),_p(l)}var rb=S(()=>{"use strict";ee();na()});import{spawn as sb}from"child_process";import{basename as fP}from"path";function pP(){return process.env.TYPEBULB_EDITOR||"code"}function mP(t,e,n){return n==null?[e]:hP.test(fP(t))?["-g",`${e}:${n}`]:[`+${n}`,e]}function gP(t,e){let n=pP();return{command:n,args:mP(n,t,e)}}function id(t,e){let{command:n,args:r}=gP(t,e),s=process.platform==="win32"?sb("cmd.exe",["/d","/s","/c",n,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):sb(n,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var hP,ib=S(()=>{"use strict";hP=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as yP,writeFileSync as bP,mkdirSync as wP,statSync as vP}from"fs";import{join as SP}from"path";function od(){return SP(ze(),"trust.json")}function ad(){try{let t=od(),e=vP(t).mtimeMs;if(Cs?.mtime!==e){let n=JSON.parse(yP(t,"utf8"));Cs={mtime:e,set:new Set(Array.isArray(n)?n:[])}}return Cs.set}catch{return Cs=void 0,new Set}}function kP(t){try{wP(ze(),{recursive:!0}),bP(od(),JSON.stringify([...t])),Cs=void 0}catch(e){throw new Error(`can't write ${od()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function yn(t){return ad().has(re(t))}function ar(t,e){let n=new Set(ad()),r=re(t);(e?n.has(r):!n.has(r))||(e?n.add(r):n.delete(r),kP(n))}function ld(){return[...ad()]}var Cs,_s=S(()=>{"use strict";Ye()});function cr(t){return(t.includes("://")?t:`http://${t}`).replace(/\/+$/,"")}function cd(){return Is}async function mt(){let[t,e]=await Promise.all([ab(),CP()]);return PP([..._P(e),...t],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function PP(t,e,n){return!e||!n?t:t.map(r=>r.provider===e&&r.name===n?{...r,default:!0}:r)}async function ob(){let t;try{t=await fetch(xP,{signal:AbortSignal.timeout(AP)})}catch(e){Is=`catalog fetch failed: ${e?.message??e}`;return}if(!t.ok){Is=`catalog fetch failed: HTTP ${t.status}`;return}try{return await t.json()}catch(e){Is=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function CP(){if(Rs&&Date.now()-Rs.fetchedAt<=EP)return Rs.models;let t=await ob()??await ob();return t?(Rs={models:t,fetchedAt:Date.now()},Is=void 0,t):Rs?.models??[]}async function ab(){if(ra&&Date.now()-ra.fetchedAt<=TP)return ra.models;let t=cr(process.env.OLLAMA_HOST??"http://localhost:11434"),e=[];try{let n=await fetch(new URL("/api/tags",t).toString(),{signal:AbortSignal.timeout(OP)});n.ok&&(e=((await n.json()).models??[]).map(s=>s.name).filter(s=>!!s).map(s=>({provider:"ollama",name:s,friendlyName:s,providerName:"Ollama"})))}catch{}return ra={models:e,fetchedAt:Date.now()},e}function _P(t){let e=new Set(Object.entries(lr).filter(([,n])=>!!process.env[n]).map(([n])=>n));return t.filter(n=>e.has(n.provider))}function ud(){return Object.values(lr).some(t=>!!process.env[t])}async function sa(){return ud()||process.env.TB_AI_BASE_URL||(await ab()).length>0?"own":"none"}function lb(t,e,n){let r=Math.max(...t.map(o=>o.name.length)),s=Math.max(...t.map(o=>o.friendlyName.length)),i=["Models available to tb.ai (filtered by your .env keys):",""];for(let o of t)i.push(` ${o.name.padEnd(r)} ${o.friendlyName.padEnd(s)} (${o.provider})`);return i.push("","Pass an id as the `model` in tb.ai({ provider, model })."),e&&n&&i.push(`Default (from .env): ${e} / ${n}`),i.join(`
497
- `)}var lr,xP,EP,AP,TP,OP,Rs,ra,Is,bn=S(()=>{"use strict";lr={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};xP="https://api.typebulb.com/api/models",EP=1440*60*1e3,AP=5e3,TP=60*1e3,OP=1500});var cb,ub,st,wn=S(()=>{cb=t=>t!=null&&t>=0&&t<=4?t:void 0,ub=(t,e)=>{let n={...t};for(let r of["input","output","reasoning","cacheRead"])e[r]!==void 0&&(n[r]=e[r]);return n},st=t=>t===void 0||t.input===void 0&&t.output===void 0?void 0:{input:t.input??0,output:t.output??0,reasoning:t.reasoning,cacheRead:t.cacheRead}});var Ce,Ge,ur=S(()=>{Ce=class extends Error{constructor(e,n="unknown",r=!1){super(e),this.code=n,this.retryable=r}},Ge=class{getPath(e,n){return this.path}parseError(e,n){return this.parseJsonError(e,n)}parseStreamChunk(e){return this.checkAndThrowError(e),this.parseProviderStreamChunk(e)}extractSystemMessages(e,n=`
496
+ **Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var mn,gn,aP,lP,na=S(()=>{nb();mn=["client"],gn=["client","server"],aP=[{type:"DYNAMIC_IMPORT",pattern:/\bimport\s*\(\s*['"`]/,targets:mn},{type:"COMMONJS_REQUIRE",pattern:/\brequire\s*\(\s*['"`]/,targets:gn},{type:"JS_EXTENSION_IMPORT",pattern:/from\s+['"][^'"]*\/[^'"]*\.js['"]/,targets:mn},{type:"URL_IMPORT",pattern:/from\s+['"]https?:\/\//,targets:mn},{type:"VERSION_SPECIFIER_IMPORT",pattern:/from\s+['"][^'"]*@[\d^~]/,targets:mn},{type:"REDUNDANT_TB_DECLARATION",pattern:/declare\s+(const|var|let)\s+tb\b/,targets:gn},{type:"CONST_ENUM",pattern:/\bconst\s+enum\b/,targets:gn},{type:"NAMESPACE_DECLARATION",pattern:/\bnamespace\s+\w+/,targets:gn},{type:"COMMONJS_EXPORT_EQUALS",pattern:/\bexport\s*=/,targets:gn},{type:"COMMONJS_IMPORT_EQUALS",pattern:/\bimport\s+\w+\s*=/,targets:gn},{type:"MODULE_DECLARATION",pattern:/\bmodule\s+\w+\s*\{/,targets:gn},{type:"CSS_FILE_IMPORT",pattern:/(?:from|import)\s+['"][^'"]*\.css['"]/,targets:mn},{type:"NAVIGATION",pattern:/window\.(location\.(reload|assign|replace)\s*\(|open\s*\()/,targets:mn},{type:"NAVIGATION",pattern:/window\.location(\.href)?\s*=[^=]/,targets:mn}],lP=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function sd(t){let e=We(t);if(!e)return t;let n=e.files.get("code.tsx");if(!n)return t;let r=sb(n);if(!r.length)return t;let s=e.files.get("config.json"),i={};if(s)try{let c=JSON.parse(s);c&&typeof c=="object"&&(i=c)}catch{}let o=i.dependencies&&typeof i.dependencies=="object"?{...i.dependencies}:{},a=r.filter(c=>!(c in o));if(!a.length)return t;for(let c of a)o[c]="latest";i.dependencies=o;let l={name:e.frontmatter.name};for(let[c,f]of e.files){let d=Sp(c);d&&(l[d]=f)}return l.config=JSON.stringify(i,null,2),_p(l)}var ib=S(()=>{"use strict";Q();na()});import{spawn as ob}from"child_process";import{basename as pP}from"path";function hP(){return process.env.TYPEBULB_EDITOR||"code"}function gP(t,e,n){return n==null?[e]:mP.test(pP(t))?["-g",`${e}:${n}`]:[`+${n}`,e]}function yP(t,e){let n=hP();return{command:n,args:gP(n,t,e)}}function id(t,e){let{command:n,args:r}=yP(t,e),s=process.platform==="win32"?ob("cmd.exe",["/d","/s","/c",n,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):ob(n,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var mP,ab=S(()=>{"use strict";mP=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as bP,writeFileSync as wP,mkdirSync as vP,statSync as SP}from"fs";import{join as kP}from"path";function od(){return kP(ze(),"trust.json")}function ad(){try{let t=od(),e=SP(t).mtimeMs;if(Cs?.mtime!==e){let n=JSON.parse(bP(t,"utf8"));Cs={mtime:e,set:new Set(Array.isArray(n)?n:[])}}return Cs.set}catch{return Cs=void 0,new Set}}function xP(t){try{vP(ze(),{recursive:!0}),wP(od(),JSON.stringify([...t])),Cs=void 0}catch(e){throw new Error(`can't write ${od()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function yn(t){return ad().has(se(t))}function lr(t,e){let n=new Set(ad()),r=se(t);(e?n.has(r):!n.has(r))||(e?n.add(r):n.delete(r),xP(n))}function ld(){return[...ad()]}var Cs,_s=S(()=>{"use strict";Ye()});function ur(t){return(t.includes("://")?t:`http://${t}`).replace(/\/+$/,"")}function cd(){return Is}async function mt(){let[t,e]=await Promise.all([cb(),_P()]);return CP([...RP(e),...t],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function CP(t,e,n){return!e||!n?t:t.map(r=>r.provider===e&&r.name===n?{...r,default:!0}:r)}async function lb(){let t;try{t=await fetch(EP,{signal:AbortSignal.timeout(TP)})}catch(e){Is=`catalog fetch failed: ${e?.message??e}`;return}if(!t.ok){Is=`catalog fetch failed: HTTP ${t.status}`;return}try{return await t.json()}catch(e){Is=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function _P(){if(Rs&&Date.now()-Rs.fetchedAt<=AP)return Rs.models;let t=await lb()??await lb();return t?(Rs={models:t,fetchedAt:Date.now()},Is=void 0,t):Rs?.models??[]}async function cb(){if(ra&&Date.now()-ra.fetchedAt<=OP)return ra.models;let t=ur(process.env.OLLAMA_HOST??"http://localhost:11434"),e=[];try{let n=await fetch(new URL("/api/tags",t).toString(),{signal:AbortSignal.timeout(PP)});n.ok&&(e=((await n.json()).models??[]).map(s=>s.name).filter(s=>!!s).map(s=>({provider:"ollama",name:s,friendlyName:s,providerName:"Ollama"})))}catch{}return ra={models:e,fetchedAt:Date.now()},e}function RP(t){let e=new Set(Object.entries(cr).filter(([,n])=>!!process.env[n]).map(([n])=>n));return t.filter(n=>e.has(n.provider))}function ud(){return Object.values(cr).some(t=>!!process.env[t])}async function sa(){return ud()||process.env.TB_AI_BASE_URL||(await cb()).length>0?"own":"none"}function ub(t,e,n){let r=Math.max(...t.map(o=>o.name.length)),s=Math.max(...t.map(o=>o.friendlyName.length)),i=["Models available to tb.ai (filtered by your .env keys):",""];for(let o of t)i.push(` ${o.name.padEnd(r)} ${o.friendlyName.padEnd(s)} (${o.provider})`);return i.push("","Pass an id as the `model` in tb.ai({ provider, model })."),e&&n&&i.push(`Default (from .env): ${e} / ${n}`),i.join(`
497
+ `)}var cr,EP,AP,TP,OP,PP,Rs,ra,Is,bn=S(()=>{"use strict";cr={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};EP="https://api.typebulb.com/api/models",AP=1440*60*1e3,TP=5e3,OP=60*1e3,PP=1500});var db,fb,st,wn=S(()=>{db=t=>t!=null&&t>=0&&t<=4?t:void 0,fb=(t,e)=>{let n={...t};for(let r of["input","output","reasoning","cacheRead"])e[r]!==void 0&&(n[r]=e[r]);return n},st=t=>t===void 0||t.input===void 0&&t.output===void 0?void 0:{input:t.input??0,output:t.output??0,reasoning:t.reasoning,cacheRead:t.cacheRead}});var Ce,Ge,dr=S(()=>{Ce=class extends Error{constructor(e,n="unknown",r=!1){super(e),this.code=n,this.retryable=r}},Ge=class{getPath(e,n){return this.path}parseError(e,n){return this.parseJsonError(e,n)}parseStreamChunk(e){return this.checkAndThrowError(e),this.parseProviderStreamChunk(e)}extractSystemMessages(e,n=`
498
498
 
499
- `){let r=e.filter(s=>s.role==="system").map(s=>s.content);return{system:r.length?r.join(n):void 0,conversationMessages:e.filter(s=>s.role!=="system")}}parseJsonError(e,n){if(!e)return{message:`HTTP ${n}`};try{let r=JSON.parse(e);return r.error&&typeof r.error=="object"?{message:r.error.message||`HTTP ${n}`,type:r.error.type}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}checkAndThrowError(e){if(typeof e!="object"||e===null)return;let n=e;if(n.type==="error"&&"message"in n){let r=n.code||"unknown";throw new Ce(n.message,r,!!n.retryable)}if(n.error){let r=n.error,s=typeof r=="object"&&r!==null?String(r.type??r.code??""):"",i=/rate_limit|too_many_requests/i.test(s),o=/overloaded|server_error|unavailable/i.test(s),a=/context_length/i.test(s);throw new Ce(this.extractErrorMessage(n.error),i?"rate_limit":a?"context_exceeded":"unknown",i||o)}}extractErrorMessage(e){if(typeof e=="string")try{let n=JSON.parse(e);return n.error?.message||n.message||e}catch{return e}return typeof e=="object"&&e!==null?e.message||JSON.stringify(e):`${this.providerName} returned an error`}}});var ia,dd=S(()=>{wn();ur();ia=class extends Ge{constructor(){super(...arguments),this.providerName="OpenAI",this.defaultBaseUrl="https://api.openai.com",this.path="/v1/responses",this.effortMap={0:"none",1:"low",2:"medium",3:"high",4:"xhigh"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,n,r,s){let i=this.convertMessagesToInput(e),o={model:n,input:i,stream:s};if(r?.webSearch===!0&&(o.tools=[{type:"web_search"}]),r?.effort!==void 0){let a=this.effortMap[r.effort];o.reasoning=a==="none"?{effort:a}:{effort:a,summary:"auto"}}return r?.maxOutputTokens!==void 0&&(o.max_output_tokens=r.maxOutputTokens),o}parseNonStreamingResponse(e){if(!this.isResponsesApiResponse(e))return{text:""};let n=e.output_text||"",r;if(e.output&&Array.isArray(e.output))for(let s of e.output)s.type==="reasoning"&&s.summary&&(r=s.summary.map(i=>i.text).join(`
499
+ `){let r=e.filter(s=>s.role==="system").map(s=>s.content);return{system:r.length?r.join(n):void 0,conversationMessages:e.filter(s=>s.role!=="system")}}parseJsonError(e,n){if(!e)return{message:`HTTP ${n}`};try{let r=JSON.parse(e);return r.error&&typeof r.error=="object"?{message:r.error.message||`HTTP ${n}`,type:r.error.type}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}checkAndThrowError(e){if(typeof e!="object"||e===null)return;let n=e;if(n.type==="error"&&"message"in n){let r=n.code||"unknown";throw new Ce(n.message,r,!!n.retryable)}if(n.error){let r=n.error,s=typeof r=="object"&&r!==null?String(r.type??r.code??""):"",i=/rate_limit|too_many_requests/i.test(s),o=/overloaded|server_error|unavailable/i.test(s),a=/context_length/i.test(s);throw new Ce(this.extractErrorMessage(n.error),i?"rate_limit":a?"context_exceeded":"unknown",i||o)}}extractErrorMessage(e){if(typeof e=="string")try{let n=JSON.parse(e);return n.error?.message||n.message||e}catch{return e}return typeof e=="object"&&e!==null?e.message||JSON.stringify(e):`${this.providerName} returned an error`}}});var ia,dd=S(()=>{wn();dr();ia=class extends Ge{constructor(){super(...arguments),this.providerName="OpenAI",this.defaultBaseUrl="https://api.openai.com",this.path="/v1/responses",this.effortMap={0:"none",1:"low",2:"medium",3:"high",4:"xhigh"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,n,r,s){let i=this.convertMessagesToInput(e),o={model:n,input:i,stream:s};if(r?.webSearch===!0&&(o.tools=[{type:"web_search"}]),r?.effort!==void 0){let a=this.effortMap[r.effort];o.reasoning=a==="none"?{effort:a}:{effort:a,summary:"auto"}}return r?.maxOutputTokens!==void 0&&(o.max_output_tokens=r.maxOutputTokens),o}parseNonStreamingResponse(e){if(!this.isResponsesApiResponse(e))return{text:""};let n=e.output_text||"",r;if(e.output&&Array.isArray(e.output))for(let s of e.output)s.type==="reasoning"&&s.summary&&(r=s.summary.map(i=>i.text).join(`
500
500
  `)),!n&&s.type==="message"&&s.content&&(n=s.content.filter(i=>i.type==="output_text").map(i=>i.text).join(""));return{text:n,reasoning:r,usage:this.mapUsage(e.usage)}}parseProviderStreamChunk(e){if(this.isResponsesApiEvent(e))switch(e.type){case"response.failed":{let r=e.response?.error,s=r?.message||"Response failed",i=r?.code==="insufficient_quota"||r?.code==="rate_limit_exceeded";throw new Ce(s,i?"rate_limit":"unknown",i)}case"response.output_text.delta":return{text:e.delta};case"response.reasoning_summary_text.delta":return{reasoning:e.delta};case"response.completed":{let n=this.mapUsage(e.response?.usage);return n?{usage:n}:void 0}default:return}}mapUsage(e){if(e)return st({input:e.input_tokens,output:e.output_tokens,reasoning:e.output_tokens_details?.reasoning_tokens,cacheRead:e.input_tokens_details?.cached_tokens})}convertMessagesToInput(e){return e.map(n=>n.role==="system"?`System: ${n.content}`:n.role==="user"?`User: ${n.content}`:n.role==="assistant"?`Assistant: ${n.content}`:n.content).join(`
501
501
 
502
- `)}isResponsesApiEvent(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"}isResponsesApiResponse(e){return typeof e=="object"&&e!==null&&e.object==="response"}}});var dr,oa=S(()=>{wn();ur();dr=class extends Ge{parseNonStreamingResponse(e){if(!this.hasChoices(e))return{text:""};let n=e,r=n.choices[0],s=r?.message,i=s?.content??r?.text??"",o=s?.reasoning??s?.reasoning_content??n.reasoning;return{text:i,reasoning:o,usage:this.mapUsage(n.usage)}}parseProviderStreamChunk(e){if(!this.hasChoices(e))return;let n=e,r=this.mapUsage(n.usage),s=n.choices[0]?.delta||n.choices[0]?.message,i=s?.content||void 0,o=s?.reasoning||s?.reasoning_content||void 0;if(!(!i&&!o&&!r))return{text:i,reasoning:o,usage:r}}hasChoices(e){return typeof e=="object"&&e!==null&&"choices"in e&&Array.isArray(e.choices)}mapUsage(e){if(e)return st({input:e.prompt_tokens,output:e.completion_tokens,reasoning:e.completion_tokens_details?.reasoning_tokens,cacheRead:e.prompt_tokens_details?.cached_tokens})}}});var fd,aa,pd=S(()=>{oa();fd={"HTTP-Referer":"https://typebulb.com","X-OpenRouter-Title":"Typebulb"},aa=class extends dr{constructor(){super(...arguments),this.providerName="OpenRouter",this.defaultBaseUrl="https://openrouter.ai",this.path="/api/v1/chat/completions",this.effortMap={0:"none",1:"low",2:"medium",3:"high",4:"xhigh"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"x-api-key":e,"Content-Type":"application/json",Accept:"application/json",...fd}}buildPayload(e,n,r,s){let i={model:n,messages:e,stream:s};s&&(i.stream_options={include_usage:!0}),r?.webSearch===!0&&(i.plugins=[{id:"web"}]);let o=r?.effort;return o!==void 0&&(i.reasoning={effort:this.effortMap[o]}),r?.maxOutputTokens!==void 0&&(i.max_tokens=r.maxOutputTokens),i}}});var la,hd=S(()=>{wn();ur();la=class extends Ge{constructor(){super(...arguments),this.providerName="Anthropic",this.defaultBaseUrl="https://api.anthropic.com",this.path="/v1/messages"}buildHeaders(e){return{"x-api-key":e,"anthropic-version":"2023-06-01","Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,n,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e),a={model:n,max_tokens:Math.min(this.getMaxTokens(n),r?.maxOutputTokens??1/0),messages:this.withTailMessagesCached(o),stream:s};r?.webSearch===!0&&(a.tools=[{type:"web_search_20250305",name:"web_search"}]),i&&(a.system=[{type:"text",text:i,cache_control:{type:"ephemeral"}}]);let l=r?.effort;if(l!==void 0){if(this.isModernModel(n))if(l===0)this.alwaysThinks(n)||(a.thinking={type:"disabled"}),a.output_config={effort:"low"};else{let c={1:"low",2:"medium",3:"high",4:"max"};a.thinking={type:"adaptive",display:"summarized"},a.output_config={effort:c[l]}}else if(l!==0){let c={1:2048,2:4096,3:8192,4:16384};a.thinking={type:"enabled",budget_tokens:c[l]}}}return a}parseNonStreamingResponse(e){if(!this.isAnthropicResponse(e))return{text:""};let n=e.content.filter(s=>s.type==="text").map(s=>s.text).join(""),r=e.content.filter(s=>s.type==="thinking").map(s=>s.thinking).join(`
502
+ `)}isResponsesApiEvent(e){return typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string"}isResponsesApiResponse(e){return typeof e=="object"&&e!==null&&e.object==="response"}}});var fr,oa=S(()=>{wn();dr();fr=class extends Ge{parseNonStreamingResponse(e){if(!this.hasChoices(e))return{text:""};let n=e,r=n.choices[0],s=r?.message,i=s?.content??r?.text??"",o=s?.reasoning??s?.reasoning_content??n.reasoning;return{text:i,reasoning:o,usage:this.mapUsage(n.usage)}}parseProviderStreamChunk(e){if(!this.hasChoices(e))return;let n=e,r=this.mapUsage(n.usage),s=n.choices[0]?.delta||n.choices[0]?.message,i=s?.content||void 0,o=s?.reasoning||s?.reasoning_content||void 0;if(!(!i&&!o&&!r))return{text:i,reasoning:o,usage:r}}hasChoices(e){return typeof e=="object"&&e!==null&&"choices"in e&&Array.isArray(e.choices)}mapUsage(e){if(e)return st({input:e.prompt_tokens,output:e.completion_tokens,reasoning:e.completion_tokens_details?.reasoning_tokens,cacheRead:e.prompt_tokens_details?.cached_tokens})}}});var fd,aa,pd=S(()=>{oa();fd={"HTTP-Referer":"https://typebulb.com","X-OpenRouter-Title":"Typebulb"},aa=class extends fr{constructor(){super(...arguments),this.providerName="OpenRouter",this.defaultBaseUrl="https://openrouter.ai",this.path="/api/v1/chat/completions",this.effortMap={0:"none",1:"low",2:"medium",3:"high",4:"xhigh"}}buildHeaders(e){return{Authorization:`Bearer ${e}`,"x-api-key":e,"Content-Type":"application/json",Accept:"application/json",...fd}}buildPayload(e,n,r,s){let i={model:n,messages:e,stream:s};s&&(i.stream_options={include_usage:!0}),r?.webSearch===!0&&(i.plugins=[{id:"web"}]);let o=r?.effort;return o!==void 0&&(i.reasoning={effort:this.effortMap[o]}),r?.maxOutputTokens!==void 0&&(i.max_tokens=r.maxOutputTokens),i}}});var la,hd=S(()=>{wn();dr();la=class extends Ge{constructor(){super(...arguments),this.providerName="Anthropic",this.defaultBaseUrl="https://api.anthropic.com",this.path="/v1/messages"}buildHeaders(e){return{"x-api-key":e,"anthropic-version":"2023-06-01","Content-Type":"application/json",Accept:"application/json"}}buildPayload(e,n,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e),a={model:n,max_tokens:Math.min(this.getMaxTokens(n),r?.maxOutputTokens??1/0),messages:this.withTailMessagesCached(o),stream:s};r?.webSearch===!0&&(a.tools=[{type:"web_search_20250305",name:"web_search"}]),i&&(a.system=[{type:"text",text:i,cache_control:{type:"ephemeral"}}]);let l=r?.effort;if(l!==void 0){if(this.isModernModel(n))if(l===0)this.alwaysThinks(n)||(a.thinking={type:"disabled"}),a.output_config={effort:"low"};else{let c={1:"low",2:"medium",3:"high",4:"max"};a.thinking={type:"adaptive",display:"summarized"},a.output_config={effort:c[l]}}else if(l!==0){let c={1:2048,2:4096,3:8192,4:16384};a.thinking={type:"enabled",budget_tokens:c[l]}}}return a}parseNonStreamingResponse(e){if(!this.isAnthropicResponse(e))return{text:""};let n=e.content.filter(s=>s.type==="text").map(s=>s.text).join(""),r=e.content.filter(s=>s.type==="thinking").map(s=>s.thinking).join(`
503
503
 
504
- `);return{text:n,reasoning:r||void 0,usage:st(this.mapUsage(e.usage))}}parseProviderStreamChunk(e){if(this.isAnthropicEvent(e))switch(e.type){case"content_block_delta":return e.delta.type==="text_delta"?{text:e.delta.text||""}:e.delta.type==="thinking_delta"?{reasoning:e.delta.thinking||""}:void 0;case"message_start":{let n=this.mapUsage(e.message?.usage);return n?{usage:n}:void 0}case"message_delta":{let n=this.mapUsage(e.usage);return n?{usage:n}:void 0}default:return}}mapUsage(e){if(typeof e!="object"||e===null)return;let n=e,r=c=>typeof c=="number"?c:void 0,s=r(n.input_tokens),i=r(n.cache_read_input_tokens),o=r(n.cache_creation_input_tokens),a=r(n.output_tokens),l=s!==void 0||i!==void 0||o!==void 0?(s??0)+(i??0)+(o??0):void 0;if(!(l===void 0&&a===void 0))return{input:l,output:a,cacheRead:i}}withTailMessagesCached(e){let n=Math.max(0,e.length-2);return e.map((r,s)=>s>=n?{role:r.role,content:[{type:"text",text:r.content,cache_control:{type:"ephemeral"}}]}:r)}isAnthropicResponse(e){return typeof e=="object"&&e!==null&&e.type==="message"&&Array.isArray(e.content)}isAnthropicEvent(e){return typeof e=="object"&&e!==null&&"type"in e}isModernModel(e){let n=e.match(/^claude-[a-z]+-(\d+)(?:-(\d+))?/i);if(!n)return!1;let r=+n[1],s=n[2]?+n[2]:0;return r>4||r===4&&s>=6}alwaysThinks(e){return/^claude-(fable|mythos)\b/i.test(e)}getMaxTokens(e){return this.isModernModel(e)?64e3:32e3}}});var ca,md=S(()=>{wn();ur();ca=class extends Ge{constructor(){super(...arguments),this.providerName="Gemini",this.defaultBaseUrl="https://generativelanguage.googleapis.com",this.path="/v1beta/models",this.budgetMap={0:0,1:1024,2:8192,3:-1,4:-1}}getPath(e,n){return`/v1beta/models/${e}:${n?"streamGenerateContent":"generateContent"}${n?"?alt=sse":""}`}buildHeaders(e){return{"Content-Type":"application/json","x-goog-api-key":e}}buildPayload(e,n,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e,`
504
+ `);return{text:n,reasoning:r||void 0,usage:st(this.mapUsage(e.usage))}}parseProviderStreamChunk(e){if(this.isAnthropicEvent(e))switch(e.type){case"content_block_delta":return e.delta.type==="text_delta"?{text:e.delta.text||""}:e.delta.type==="thinking_delta"?{reasoning:e.delta.thinking||""}:void 0;case"message_start":{let n=this.mapUsage(e.message?.usage);return n?{usage:n}:void 0}case"message_delta":{let n=this.mapUsage(e.usage);return n?{usage:n}:void 0}default:return}}mapUsage(e){if(typeof e!="object"||e===null)return;let n=e,r=c=>typeof c=="number"?c:void 0,s=r(n.input_tokens),i=r(n.cache_read_input_tokens),o=r(n.cache_creation_input_tokens),a=r(n.output_tokens),l=s!==void 0||i!==void 0||o!==void 0?(s??0)+(i??0)+(o??0):void 0;if(!(l===void 0&&a===void 0))return{input:l,output:a,cacheRead:i}}withTailMessagesCached(e){let n=Math.max(0,e.length-2);return e.map((r,s)=>s>=n?{role:r.role,content:[{type:"text",text:r.content,cache_control:{type:"ephemeral"}}]}:r)}isAnthropicResponse(e){return typeof e=="object"&&e!==null&&e.type==="message"&&Array.isArray(e.content)}isAnthropicEvent(e){return typeof e=="object"&&e!==null&&"type"in e}isModernModel(e){let n=e.match(/^claude-[a-z]+-(\d+)(?:-(\d+))?/i);if(!n)return!1;let r=+n[1],s=n[2]?+n[2]:0;return r>4||r===4&&s>=6}alwaysThinks(e){return/^claude-(fable|mythos)\b/i.test(e)}getMaxTokens(e){return this.isModernModel(e)?64e3:32e3}}});var ca,md=S(()=>{wn();dr();ca=class extends Ge{constructor(){super(...arguments),this.providerName="Gemini",this.defaultBaseUrl="https://generativelanguage.googleapis.com",this.path="/v1beta/models",this.budgetMap={0:0,1:1024,2:8192,3:-1,4:-1}}getPath(e,n){return`/v1beta/models/${e}:${n?"streamGenerateContent":"generateContent"}${n?"?alt=sse":""}`}buildHeaders(e){return{"Content-Type":"application/json","x-goog-api-key":e}}buildPayload(e,n,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e,`
505
505
  `),l={contents:o.map(f=>({role:f.role==="assistant"?"model":"user",parts:[{text:f.content}]}))};r?.webSearch===!0&&(l.tools=[{google_search:{}}]),i&&(l.systemInstruction={role:"system",parts:[{text:i}]});let c=r?.effort;if(c!==void 0){let f=this.geminiVersion(n),d=f!==void 0&&f>=3?{thinkingLevel:this.thinkingLevelFor(f,c)}:{thinkingBudget:this.budgetMap[c]};l.generationConfig={thinkingConfig:c===0?d:{includeThoughts:!0,...d}}}return r?.maxOutputTokens!==void 0&&(l.generationConfig={...l.generationConfig,maxOutputTokens:r.maxOutputTokens}),l}parseError(e,n){if(!e)return{message:`HTTP ${n}`};try{let r=JSON.parse(e),s=Array.isArray(r)?r[0]?.error:r?.error;return s&&typeof s=="object"?{message:(s.message||`HTTP ${n}`).split(`
506
- `)[0],type:s.status,code:s.code?.toString()}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}parseNonStreamingResponse(e){if(this.checkAndThrowError(e),this.checkGeminiError(e),!this.isGeminiResponse(e))return{text:"",status:"failed",error:"Invalid response format"};let n=this.extractParts(e).text||"",r=e.candidates?.[0]?.finishReason,s="complete";return r==="MAX_TOKENS"?s="interrupted":(r==="SAFETY"||r==="RECITATION")&&(s="failed"),{text:n,status:s,usage:this.mapUsage(e.usageMetadata)}}parseProviderStreamChunk(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return;let n=this.extractParts(e),r=this.mapUsage(e.usageMetadata);return r&&(n.usage=r),n.text||n.reasoning||n.usage?n:void 0}mapUsage(e){if(!e)return;let n=e.candidatesTokenCount!==void 0||e.thoughtsTokenCount!==void 0;return st({input:e.promptTokenCount,output:n?(e.candidatesTokenCount??0)+(e.thoughtsTokenCount??0):void 0,reasoning:e.thoughtsTokenCount,cacheRead:e.cachedContentTokenCount})}geminiVersion(e){let n=e.match(/^gemini-(\d+(?:\.\d+)?)/);return n?Number(n[1]):void 0}thinkingLevelFor(e,n){let r=["minimal","low","medium","high","high"][n];return r==="minimal"&&e<3.5?"low":r}isGeminiResponse(e){return typeof e=="object"&&e!==null&&"candidates"in e&&Array.isArray(e.candidates)}extractParts(e){let n=e.candidates?.[0]?.content?.parts;if(!n)return{};let r="",s="";for(let i of n)i.text&&(i.thought?s+=i.text:r+=i.text);return{text:r||void 0,reasoning:s||void 0}}checkGeminiError(e){if(this.isGeminiResponse(e)&&e.promptFeedback?.blockReason){let n=e.promptFeedback.blockReason;throw new Ce(`Prompt blocked: ${n}`)}}}});var ua,gd=S(()=>{oa();ua=class extends dr{constructor(){super(...arguments),this.providerName="Ollama",this.defaultBaseUrl="http://localhost:11434",this.path="/chat/completions"}buildHeaders(e){let n={"Content-Type":"application/json",Accept:"application/json"};return e&&(n.Authorization=`Bearer ${e}`),n}buildPayload(e,n,r,s){return s?{model:n,messages:e,stream:s,stream_options:{include_usage:!0}}:{model:n,messages:e,stream:s}}}});function vn(t){let e=RP.get(t);if(!e)throw new Error(`Unsupported protocol: ${t}`);return e}function IP(t,e){return t.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function yd(t,e){let n=vn(t.protocol),r=n.getPath(t.model,e.stream),s=IP(t.baseUrl,r),i=n.buildHeaders(t.apiKey),o=n.buildPayload(e.messages,t.model,{effort:e.effort,webSearch:e.webSearch,maxOutputTokens:e.maxOutputTokens},e.stream);return fetch(s,{method:"POST",headers:i,body:JSON.stringify(o),signal:e.signal})}function NP(t){return/prompt is too long|context[_ ](length|window)|maximum context|token count exceeds|too many tokens/i.test(t)}async function fr(t,e){let n=vn(e),r=await t.text().catch(()=>""),{message:s}=n.parseError(r,t.status),i=t.status,o="unknown";return i===429?o="rate_limit":(i===413||NP(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var db,RP,bd=S(()=>{dd();pd();hd();md();gd();db=new ua,RP=new Map([["openai",new ia],["openrouter",new aa],["anthropic",new la],["gemini",new ca],["ollama",db],["openai-compat",db]])});function fb(t){let e=t.indexOf(`\r
506
+ `)[0],type:s.status,code:s.code?.toString()}:r.message?{message:r.message}:{message:e}}catch{return{message:e}}}parseNonStreamingResponse(e){if(this.checkAndThrowError(e),this.checkGeminiError(e),!this.isGeminiResponse(e))return{text:"",status:"failed",error:"Invalid response format"};let n=this.extractParts(e).text||"",r=e.candidates?.[0]?.finishReason,s="complete";return r==="MAX_TOKENS"?s="interrupted":(r==="SAFETY"||r==="RECITATION")&&(s="failed"),{text:n,status:s,usage:this.mapUsage(e.usageMetadata)}}parseProviderStreamChunk(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return;let n=this.extractParts(e),r=this.mapUsage(e.usageMetadata);return r&&(n.usage=r),n.text||n.reasoning||n.usage?n:void 0}mapUsage(e){if(!e)return;let n=e.candidatesTokenCount!==void 0||e.thoughtsTokenCount!==void 0;return st({input:e.promptTokenCount,output:n?(e.candidatesTokenCount??0)+(e.thoughtsTokenCount??0):void 0,reasoning:e.thoughtsTokenCount,cacheRead:e.cachedContentTokenCount})}geminiVersion(e){let n=e.match(/^gemini-(\d+(?:\.\d+)?)/);return n?Number(n[1]):void 0}thinkingLevelFor(e,n){let r=["minimal","low","medium","high","high"][n];return r==="minimal"&&e<3.5?"low":r}isGeminiResponse(e){return typeof e=="object"&&e!==null&&"candidates"in e&&Array.isArray(e.candidates)}extractParts(e){let n=e.candidates?.[0]?.content?.parts;if(!n)return{};let r="",s="";for(let i of n)i.text&&(i.thought?s+=i.text:r+=i.text);return{text:r||void 0,reasoning:s||void 0}}checkGeminiError(e){if(this.isGeminiResponse(e)&&e.promptFeedback?.blockReason){let n=e.promptFeedback.blockReason;throw new Ce(`Prompt blocked: ${n}`)}}}});var ua,gd=S(()=>{oa();ua=class extends fr{constructor(){super(...arguments),this.providerName="Ollama",this.defaultBaseUrl="http://localhost:11434",this.path="/chat/completions"}buildHeaders(e){let n={"Content-Type":"application/json",Accept:"application/json"};return e&&(n.Authorization=`Bearer ${e}`),n}buildPayload(e,n,r,s){return s?{model:n,messages:e,stream:s,stream_options:{include_usage:!0}}:{model:n,messages:e,stream:s}}}});function vn(t){let e=IP.get(t);if(!e)throw new Error(`Unsupported protocol: ${t}`);return e}function NP(t,e){return t.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function yd(t,e){let n=vn(t.protocol),r=n.getPath(t.model,e.stream),s=NP(t.baseUrl,r),i=n.buildHeaders(t.apiKey),o=n.buildPayload(e.messages,t.model,{effort:e.effort,webSearch:e.webSearch,maxOutputTokens:e.maxOutputTokens},e.stream);return fetch(s,{method:"POST",headers:i,body:JSON.stringify(o),signal:e.signal})}function $P(t){return/prompt is too long|context[_ ](length|window)|maximum context|token count exceeds|too many tokens/i.test(t)}async function pr(t,e){let n=vn(e),r=await t.text().catch(()=>""),{message:s}=n.parseError(r,t.status),i=t.status,o="unknown";return i===429?o="rate_limit":(i===413||$P(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var pb,IP,bd=S(()=>{dd();pd();hd();md();gd();pb=new ua,IP=new Map([["openai",new ia],["openrouter",new aa],["anthropic",new la],["gemini",new ca],["ollama",pb],["openai-compat",pb]])});function hb(t){let e=t.indexOf(`\r
507
507
  \r
508
508
  `),n=t.indexOf(`
509
509
 
510
510
  `);return e!==-1&&(n===-1||e<n)?{pos:e,len:4}:n!==-1?{pos:n,len:2}:{pos:-1,len:0}}function wd(t){let n=t.split(/\r?\n/).filter(s=>s.startsWith("data:"));if(!n.length)return;let r=n.map(s=>s.replace(/^data:\s?/,"")).join(`
511
- `).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*pb(t,e,n){let r=new TextDecoder,s="",i,o=e?new Promise((a,l)=>{e.aborted&&l(new Error("Aborted")),i=()=>l(new Error("Aborted")),e.addEventListener("abort",i,{once:!0})}):void 0;o?.catch(()=>{});try{for(;;){let{done:a,value:l}=o?await Promise.race([t.read(),o]):await t.read();if(a){if(s.trim()){let d=wd(s);d!==void 0&&d!=="done"&&(yield d)}return}n?.(),s+=r.decode(l,{stream:!0});let{pos:c,len:f}=fb(s);for(;c!==-1;){let d=s.slice(0,c);s=s.slice(c+f);let u=wd(d);if(u==="done")return;u!==void 0&&(yield u),{pos:c,len:f}=fb(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await t.cancel()}catch{}}}async function vd(t,e){return(await pr(t,e)).text}async function pr(t,e){if(!t.body)throw new Error("Response body is missing");let n="",r;for await(let s of Sn(t,e))s.kind==="text"?n+=s.text:s.kind==="usage"&&(r=s.usage);return{text:n,usage:r}}async function*Sn(t,e){let n=e??(t.headers.get("X-Provider-Protocol")||"openai"),r=vn(n);if(!t.body)return;let s=t.body.getReader(),i;for await(let a of pb(s)){let l=r.parseStreamChunk(a);l?.reasoning&&(yield{kind:"reasoning",text:l.reasoning}),l?.text&&(yield{kind:"text",text:l.text}),l?.usage&&(i=ub(i,l.usage))}let o=st(i);o&&(yield{kind:"usage",usage:o})}var hb=S(()=>{wn();bd()});import{strToU8 as $P,strFromU8 as LP,deflateSync as MP,inflateSync as DP}from"fflate";function kd(t,e){let n=[];if(n.push(`You are a data processor. Follow the instructions to analyze the provided data. Output valid JSON that the code can consume.
511
+ `).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*mb(t,e,n){let r=new TextDecoder,s="",i,o=e?new Promise((a,l)=>{e.aborted&&l(new Error("Aborted")),i=()=>l(new Error("Aborted")),e.addEventListener("abort",i,{once:!0})}):void 0;o?.catch(()=>{});try{for(;;){let{done:a,value:l}=o?await Promise.race([t.read(),o]):await t.read();if(a){if(s.trim()){let d=wd(s);d!==void 0&&d!=="done"&&(yield d)}return}n?.(),s+=r.decode(l,{stream:!0});let{pos:c,len:f}=hb(s);for(;c!==-1;){let d=s.slice(0,c);s=s.slice(c+f);let u=wd(d);if(u==="done")return;u!==void 0&&(yield u),{pos:c,len:f}=hb(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await t.cancel()}catch{}}}async function vd(t,e){return(await hr(t,e)).text}async function hr(t,e){if(!t.body)throw new Error("Response body is missing");let n="",r;for await(let s of Sn(t,e))s.kind==="text"?n+=s.text:s.kind==="usage"&&(r=s.usage);return{text:n,usage:r}}async function*Sn(t,e){let n=e??(t.headers.get("X-Provider-Protocol")||"openai"),r=vn(n);if(!t.body)return;let s=t.body.getReader(),i;for await(let a of mb(s)){let l=r.parseStreamChunk(a);l?.reasoning&&(yield{kind:"reasoning",text:l.reasoning}),l?.text&&(yield{kind:"text",text:l.text}),l?.usage&&(i=fb(i,l.usage))}let o=st(i);o&&(yield{kind:"usage",usage:o})}var gb=S(()=>{wn();bd()});import{strToU8 as LP,strFromU8 as MP,deflateSync as DP,inflateSync as BP}from"fflate";function kd(t,e){let n=[];if(n.push(`You are a data processor. Follow the instructions to analyze the provided data. Output valid JSON that the code can consume.
512
512
 
513
513
  ---
514
514
  Instructions:
@@ -526,12 +526,12 @@ ${r}
526
526
  </data>`)}return n.push(`
527
527
  Output only valid JSON. No explanation, no markdown fences, just the JSON object. Every number must be a JSON literal \u2014 never an expression like 2 * pi; write the computed decimal instead.`),n.join(`
528
528
 
529
- `)}function Ns(t){try{return JSON.parse(t)}catch{return}}function mb(t,e){let n="",r=0,s=!1,i=!1;for(let o=0;o<t.length;o++){let a=t[o];if(i){i=!1;continue}if(a==="\\"){i=!0;continue}a==='"'&&(s?(n+=t.slice(r,o+1),r=o+1):(n+=e(t.slice(r,o))+'"',r=o+1),s=!s)}return n+=s?t.slice(r):e(t.slice(r)),n}function jP(t){let e=mb(t,n=>n.replace(/,(\s*[}\]])/g,"$1"));return e!==t?e:void 0}function FP(t){let e=mb(t,n=>n.replace(/\bpi\b/g,"3.141592653589793").replace(/\be\b/g,"2.718281828459045").replace(/-?\d[\d.\s+\-*/()]*\d|\(-?\d[\d.\s+\-*/()]*\d\)/g,r=>{if(!/[+\-*/]/.test(r.replace(/^-/,""))||r.length>64||!/^[\d\s.+\-*/()]+$/.test(r))return r;try{let s=Function(`"use strict"; return (${r})`)();return typeof s=="number"&&Number.isFinite(s)?String(s):r}catch{return r}}));return e!==t?e:void 0}function UP(t,e){let n=0,r=!1,s=!1;for(let i=e;i<t.length;i++){let o=t[i];if(s){s=!1;continue}if(o==="\\"){s=!0;continue}if(o==='"'){r=!r;continue}if(!r){if(o==="{"||o==="[")n++;else if((o==="}"||o==="]")&&(n--,n===0))return i}}return-1}function qP(t){let e,n=0;for(;n<t.length;){let r=t[n];if(r==="{"||r==="["){let s=UP(t,n);if(s!==-1){let i=t.slice(n,s+1),o=Ns(i);o!==void 0&&(e={parsed:o,json:i}),n=s+1;continue}}n++}return e}function xd(t){let e=[],n=t.trim();n.startsWith("```")&&(n=n.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=Ns(n);if(r!==void 0)return{parsed:r,json:n,fixesApplied:e};let s=n.match(/```(?:json)?\s*\n([\s\S]*?)\n?```\s*$/);if(s&&(n=s[1].trim(),e.push("preamble before fenced JSON"),r=Ns(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e};if(!n.startsWith("{")&&!n.startsWith("[")){let o=n.indexOf("{"),a=n.indexOf("["),l=o>=0&&a>=0?Math.min(o,a):o>=0?o:a;if(l>0&&(n=n.slice(l),e.push("preamble text"),r=Ns(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e}}for(let[o,a]of BP){let l=a(n);if(l!==void 0){let c=Ns(l);if(c!==void 0)return{parsed:c,json:l,fixesApplied:[...e,o]}}}let i=qP(t);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:n,fixesApplied:e}}function Ed(t){try{let e={};if(t.insight!==void 0&&(e.i=t.insight),t.data!==void 0&&(e.d=t.data),e.i===void 0&&e.d===void 0)return"";let n=JSON.stringify(e),r=MP($P(n),{level:9}),s=WP(r),i=`${gb}:${s}`;return i.length>JP?"":"#"+Sd+i}catch{return""}}function Ad(t){try{let e=t.startsWith("#")?t.slice(1):t;if(!e.startsWith(Sd))return;let n=e.slice(Sd.length),r=n.indexOf(":");if(r===-1||n.slice(0,r)!==gb)return;let s=KP(n.slice(r+1)),i=JSON.parse(LP(DP(s)));if(!i||typeof i!="object")return;let o=i.i!==void 0,a=Array.isArray(i.d);if(!o&&!a)return;let l={};return o&&(l.insight=i.i,l.insightJson=JSON.stringify(i.i,null,2)),a&&(l.data=i.d),l}catch{return}}function WP(t){let e="";for(let n=0;n<t.length;n+=32768)e+=String.fromCharCode(...t.subarray(n,n+32768));return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function KP(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";let n=atob(e),r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return r}var BP,Sd,gb,JP,yb=S(()=>{BP=[["orphan quote",t=>{let e=t.replace(/^[ \t]*"[ \t]*\r?\n/gm,"");return e!==t?e:void 0}],["trailing }",t=>t.endsWith("}}")?t.slice(0,-1):void 0],["trailing ]",t=>t.endsWith("]]")?t.slice(0,-1):void 0],["trailing },",t=>t.endsWith("},")?t.slice(0,-1):void 0],["trailing ],",t=>t.endsWith("],")?t.slice(0,-1):void 0],["trailing commas",jP],["arithmetic constants",FP]];Sd="tb=",gb="1",JP=6e4});var Ut=S(()=>{wn();ur();bd();hb();yb();oa();hd();md();dd();pd();gd()});import{readFileSync as bb,existsSync as HP}from"fs";import*as it from"path";function wb(t){return[...t?[`.env.${t}.local`,`.env.${t}`]:[],".env.local",".env"]}function xe(t,e=process.cwd()){let n={},r=[];for(let s of wb(t)){let i;try{i=bb(it.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of vb(i))process.env[o]===void 0&&(process.env[o]=a,n[o]=s)}return{mode:t,sources:n,loaded:r}}function*vb(t){for(let e of t.split(`
530
- `)){let n=e.trim();if(!n||n.startsWith("#"))continue;let r=n.indexOf("=");if(r===-1)continue;let s=n.slice(0,r).trim(),i=n.slice(r+1).trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),yield[s,i]}}function da(t,e=process.cwd()){for(let n of wb()){let r;try{r=bb(it.resolve(e,n),"utf-8")}catch{continue}for(let[s,i]of vb(r))if(s===t)return i}return process.env[t]}function zP(t){let e=new Set,n=/process\.env\.([A-Za-z_$][\w$]*)|process\.env\[\s*['"]([^'"]+)['"]\s*\]/g;for(let r;r=n.exec(t);)e.add(r[1]??r[2]);return[...e]}function Sb(){return`.env loads from ${process.cwd()} (the directory you ran from, not the bulb's)`}function qt(t,e,n){let{sources:r,mode:s,loaded:i}=t,o=process.cwd(),a=it.dirname(e),l=`(mode: ${s??"none"})`,c=n?zP(n):[],f=c.filter(p=>r[p]).map(p=>`${p} \u2190 ${r[p]}`);f.length?console.log(`env: ${f.join(", ")} ${l}`):i.length&&console.log(`env: loaded ${i.join(", ")} ${l}`),s&&!i.some(p=>p===`.env.${s}`||p===`.env.${s}.local`)&&console.log(`env: mode=${s} \u2014 no .env.${s} found; using .env`);let d=it.resolve(a)!==it.resolve(o);if(d)for(let p of[".env.local",".env"])HP(it.join(a,p))&&console.log(`env: ${it.join(a,p)} present but not loaded (cwd is ${o})`);let u=c.filter(p=>process.env[p]===void 0);if(u.length){let p=d?` \u2014 try running from ${a}`:"";console.log(`env: server.ts reads ${u.join(", ")} but ${u.length>1?"they are":"it's"} unset${p}`)}}var ot=S(()=>{"use strict"});function gt(t,e){let n=t??process.env.TB_AI_PROVIDER,r=e??process.env.TB_AI_MODEL;if(!n)return"No provider specified. Set TB_AI_PROVIDER in your .env file or pass provider in the tb.ai() call.";if(!r)return"No model specified. Set TB_AI_MODEL in your .env file or pass model in the tb.ai() call.";let s;try{s=vn(n)}catch{return`Unknown provider '${n}'.`}if(n==="ollama")return{apiKey:"",baseUrl:`${cr(process.env.OLLAMA_HOST??s.defaultBaseUrl)}/v1`,protocol:n,model:r,isFreeModel:!1};if(n==="openai-compat"){let a=process.env.TB_AI_BASE_URL;return a?{apiKey:process.env.TB_AI_API_KEY??"",baseUrl:a,protocol:n,model:r,isFreeModel:!1}:"No base URL for openai-compat. Set TB_AI_BASE_URL (the OpenAI-style base ending in /v1, e.g. http://localhost:1234/v1) in your .env file."}let i=lr[n];if(!i)return`Unknown provider '${n}'.`;let o=process.env[i];return o?{apiKey:o,baseUrl:s.defaultBaseUrl,protocol:n,model:r,isFreeModel:!1}:`No API key for '${n}'. Set ${i} \u2014 ${Sb()}.`}function Jt(t,e){let n=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return yd(t,{messages:n,stream:!0,effort:cb(e.effort),webSearch:e.webSearch,signal:e.signal})}var fa=S(()=>{"use strict";Ut();Ut();ot();bn()});import{readFileSync as UB,existsSync as YP}from"fs";import*as hr from"path";import{fileURLToPath as VP}from"url";function GP(){let t=hr.dirname(VP(import.meta.url));for(;!YP(hr.join(t,"package.json"));){let e=hr.dirname(t);if(e===t)break;t=e}return t}function $s(){return hr.join(GP(),"SKILL.md")}var Td=S(()=>{"use strict"});import{transform as XP}from"sucrase";function Od(t,e={}){let n=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=XP(t,{transforms:n,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var kb=S(()=>{});function QP(t){return t.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
529
+ `)}function Ns(t){try{return JSON.parse(t)}catch{return}}function yb(t,e){let n="",r=0,s=!1,i=!1;for(let o=0;o<t.length;o++){let a=t[o];if(i){i=!1;continue}if(a==="\\"){i=!0;continue}a==='"'&&(s?(n+=t.slice(r,o+1),r=o+1):(n+=e(t.slice(r,o))+'"',r=o+1),s=!s)}return n+=s?t.slice(r):e(t.slice(r)),n}function FP(t){let e=yb(t,n=>n.replace(/,(\s*[}\]])/g,"$1"));return e!==t?e:void 0}function UP(t){let e=yb(t,n=>n.replace(/\bpi\b/g,"3.141592653589793").replace(/\be\b/g,"2.718281828459045").replace(/-?\d[\d.\s+\-*/()]*\d|\(-?\d[\d.\s+\-*/()]*\d\)/g,r=>{if(!/[+\-*/]/.test(r.replace(/^-/,""))||r.length>64||!/^[\d\s.+\-*/()]+$/.test(r))return r;try{let s=Function(`"use strict"; return (${r})`)();return typeof s=="number"&&Number.isFinite(s)?String(s):r}catch{return r}}));return e!==t?e:void 0}function qP(t,e){let n=0,r=!1,s=!1;for(let i=e;i<t.length;i++){let o=t[i];if(s){s=!1;continue}if(o==="\\"){s=!0;continue}if(o==='"'){r=!r;continue}if(!r){if(o==="{"||o==="[")n++;else if((o==="}"||o==="]")&&(n--,n===0))return i}}return-1}function JP(t){let e,n=0;for(;n<t.length;){let r=t[n];if(r==="{"||r==="["){let s=qP(t,n);if(s!==-1){let i=t.slice(n,s+1),o=Ns(i);o!==void 0&&(e={parsed:o,json:i}),n=s+1;continue}}n++}return e}function xd(t){let e=[],n=t.trim();n.startsWith("```")&&(n=n.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=Ns(n);if(r!==void 0)return{parsed:r,json:n,fixesApplied:e};let s=n.match(/```(?:json)?\s*\n([\s\S]*?)\n?```\s*$/);if(s&&(n=s[1].trim(),e.push("preamble before fenced JSON"),r=Ns(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e};if(!n.startsWith("{")&&!n.startsWith("[")){let o=n.indexOf("{"),a=n.indexOf("["),l=o>=0&&a>=0?Math.min(o,a):o>=0?o:a;if(l>0&&(n=n.slice(l),e.push("preamble text"),r=Ns(n),r!==void 0))return{parsed:r,json:n,fixesApplied:e}}for(let[o,a]of jP){let l=a(n);if(l!==void 0){let c=Ns(l);if(c!==void 0)return{parsed:c,json:l,fixesApplied:[...e,o]}}}let i=JP(t);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:n,fixesApplied:e}}function Ed(t){try{let e={};if(t.insight!==void 0&&(e.i=t.insight),t.data!==void 0&&(e.d=t.data),e.i===void 0&&e.d===void 0)return"";let n=JSON.stringify(e),r=DP(LP(n),{level:9}),s=KP(r),i=`${bb}:${s}`;return i.length>WP?"":"#"+Sd+i}catch{return""}}function Ad(t){try{let e=t.startsWith("#")?t.slice(1):t;if(!e.startsWith(Sd))return;let n=e.slice(Sd.length),r=n.indexOf(":");if(r===-1||n.slice(0,r)!==bb)return;let s=HP(n.slice(r+1)),i=JSON.parse(MP(BP(s)));if(!i||typeof i!="object")return;let o=i.i!==void 0,a=Array.isArray(i.d);if(!o&&!a)return;let l={};return o&&(l.insight=i.i,l.insightJson=JSON.stringify(i.i,null,2)),a&&(l.data=i.d),l}catch{return}}function KP(t){let e="";for(let n=0;n<t.length;n+=32768)e+=String.fromCharCode(...t.subarray(n,n+32768));return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function HP(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";let n=atob(e),r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return r}var jP,Sd,bb,WP,wb=S(()=>{jP=[["orphan quote",t=>{let e=t.replace(/^[ \t]*"[ \t]*\r?\n/gm,"");return e!==t?e:void 0}],["trailing }",t=>t.endsWith("}}")?t.slice(0,-1):void 0],["trailing ]",t=>t.endsWith("]]")?t.slice(0,-1):void 0],["trailing },",t=>t.endsWith("},")?t.slice(0,-1):void 0],["trailing ],",t=>t.endsWith("],")?t.slice(0,-1):void 0],["trailing commas",FP],["arithmetic constants",UP]];Sd="tb=",bb="1",WP=6e4});var Ut=S(()=>{wn();dr();bd();gb();wb();oa();hd();md();dd();pd();gd()});import{readFileSync as vb,existsSync as zP}from"fs";import*as it from"path";function Sb(t){return[...t?[`.env.${t}.local`,`.env.${t}`]:[],".env.local",".env"]}function xe(t,e=process.cwd()){let n={},r=[];for(let s of Sb(t)){let i;try{i=vb(it.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of kb(i))process.env[o]===void 0&&(process.env[o]=a,n[o]=s)}return{mode:t,sources:n,loaded:r}}function*kb(t){for(let e of t.split(`
530
+ `)){let n=e.trim();if(!n||n.startsWith("#"))continue;let r=n.indexOf("=");if(r===-1)continue;let s=n.slice(0,r).trim(),i=n.slice(r+1).trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),yield[s,i]}}function da(t,e=process.cwd()){for(let n of Sb()){let r;try{r=vb(it.resolve(e,n),"utf-8")}catch{continue}for(let[s,i]of kb(r))if(s===t)return i}return process.env[t]}function YP(t){let e=new Set,n=/process\.env\.([A-Za-z_$][\w$]*)|process\.env\[\s*['"]([^'"]+)['"]\s*\]/g;for(let r;r=n.exec(t);)e.add(r[1]??r[2]);return[...e]}function xb(){return`.env loads from ${process.cwd()} (the directory you ran from, not the bulb's)`}function qt(t,e,n){let{sources:r,mode:s,loaded:i}=t,o=process.cwd(),a=it.dirname(e),l=`(mode: ${s??"none"})`,c=n?YP(n):[],f=c.filter(p=>r[p]).map(p=>`${p} \u2190 ${r[p]}`);f.length?console.log(`env: ${f.join(", ")} ${l}`):i.length&&console.log(`env: loaded ${i.join(", ")} ${l}`),s&&!i.some(p=>p===`.env.${s}`||p===`.env.${s}.local`)&&console.log(`env: mode=${s} \u2014 no .env.${s} found; using .env`);let d=it.resolve(a)!==it.resolve(o);if(d)for(let p of[".env.local",".env"])zP(it.join(a,p))&&console.log(`env: ${it.join(a,p)} present but not loaded (cwd is ${o})`);let u=c.filter(p=>process.env[p]===void 0);if(u.length){let p=d?` \u2014 try running from ${a}`:"";console.log(`env: server.ts reads ${u.join(", ")} but ${u.length>1?"they are":"it's"} unset${p}`)}}var ot=S(()=>{"use strict"});function gt(t,e){let n=t??process.env.TB_AI_PROVIDER,r=e??process.env.TB_AI_MODEL;if(!n)return"No provider specified. Set TB_AI_PROVIDER in your .env file or pass provider in the tb.ai() call.";if(!r)return"No model specified. Set TB_AI_MODEL in your .env file or pass model in the tb.ai() call.";let s;try{s=vn(n)}catch{return`Unknown provider '${n}'.`}if(n==="ollama")return{apiKey:"",baseUrl:`${ur(process.env.OLLAMA_HOST??s.defaultBaseUrl)}/v1`,protocol:n,model:r,isFreeModel:!1};if(n==="openai-compat"){let a=process.env.TB_AI_BASE_URL;return a?{apiKey:process.env.TB_AI_API_KEY??"",baseUrl:a,protocol:n,model:r,isFreeModel:!1}:"No base URL for openai-compat. Set TB_AI_BASE_URL (the OpenAI-style base ending in /v1, e.g. http://localhost:1234/v1) in your .env file."}let i=cr[n];if(!i)return`Unknown provider '${n}'.`;let o=process.env[i];return o?{apiKey:o,baseUrl:s.defaultBaseUrl,protocol:n,model:r,isFreeModel:!1}:`No API key for '${n}'. Set ${i} \u2014 ${xb()}.`}function Jt(t,e){let n=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return yd(t,{messages:n,stream:!0,effort:db(e.effort),webSearch:e.webSearch,signal:e.signal})}var fa=S(()=>{"use strict";Ut();Ut();ot();bn()});import{readFileSync as qB,existsSync as VP}from"fs";import*as mr from"path";import{fileURLToPath as GP}from"url";function XP(){let t=mr.dirname(GP(import.meta.url));for(;!VP(mr.join(t,"package.json"));){let e=mr.dirname(t);if(e===t)break;t=e}return t}function $s(){return mr.join(XP(),"SKILL.md")}var Td=S(()=>{"use strict"});import{transform as QP}from"sucrase";function Od(t,e={}){let n=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=QP(t,{transforms:n,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var Eb=S(()=>{});function ZP(t){return t.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
531
531
  `)[0]}`).join(`
532
- `)}function xb(t,e){let n=Ps(t,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(n.length)throw new Error(`Lint failed:
533
- ${QP(n)}`)}var Eb=S(()=>{"use strict";na()});var Wt,Ls,Pd,Ms=S(()=>{Wt="https://esm.sh",Ls="https://cdn.jsdelivr.net/npm/",Pd="https://data.jsdelivr.com/v1/package/npm/"});function Ab(t){let e=(t||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var B,mr,Tb,Ds=S(()=>{Ms();B=class t{constructor(e,n,r){let s=typeof e=="string"?t.parse(e):e;this.name=s.name,this.version=mr(n??s.version),this.subpath=mr(r??s.subpath)}static parse(e){let n=Ab(e||"");if(!n.length)return new t({name:""});if(n[0].startsWith("@")){let s=n[0],[i,o]=Tb(n[1]??""),a=mr(n.slice(2).join("/"));return new t({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=Tb(n[0]),o=mr(n.slice(1).join("/"));return new t({name:s,version:i,subpath:o})}}static fromUrl(e){try{let n=new URL(e),r=new URL(Wt).host,s=new URL(Ls).host;if(n.host===r){let i=Ab(n.pathname.replace(/^\/v\d+\//,"/"));if(!i.length)return;let o=i[0].startsWith("@")?`${i[0]}/${i[1]??""}`:i[0];return t.parse(o)}if(n.host===s){let i=n.pathname.split("/npm/")[1];if(!i)return;let o=i.split("/")[0]||"";return t.parse(o)}return}catch{return}}format(){let e=this.version?`${this.name}@${this.version}`:this.name;return this.subpath?`${e}/${this.subpath}`:e}root(){return this.name}static rootOf(e){return t.parse(e).name}withVersion(e){return new t({name:this.name,version:mr(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},mr=t=>t&&t.length?t:void 0,Tb=t=>{let e=t.indexOf("@");return e<0?[t,void 0]:[t.slice(0,e),mr(t.slice(e+1))]}});async function Ee(t){try{return await t()}catch{return}}var pa=S(()=>{});function kn(t){let e=t||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function Cd(t){return t.startsWith("./")?t:`./${t}`}var Bs,_d=S(()=>{Ds();pa();Ms();Bs=class{constructor(e,n){this.cache=e,this.http=n,this.pinMs=1e4,this.versionsIndexMs=1440*60*1e3,this.metaTtlMs=10080*60*1e3,this.pinCache=new Map}baseDir(e){let n=typeof e=="string"?new B(e):e;return`${Ls}${n.name}${n.version?`@${n.version}`:""}/`}file(e,n){return new URL(kn(n),this.baseDir(e)).toString()}packageJson(e){return this.file(e,"package.json")}buildEsmUrl(e,n={}){let{target:r="es2022",bundle:s=!1,external:i}=n,o=new URLSearchParams({target:r});return s&&o.append("bundle",""),i?.length&&o.append("external",i.join(",")),`${Wt}/${e}?${o.toString()}`}async resolveExactVersion(e){let n=Date.now(),r=this.pinCache.get(e);if(r&&n-r.ts<this.pinMs)return r.value;let s=await this.tryResolveFromUrls([this.buildEsmUrl(e),`${Wt}/${e}`]);return this.pinCache.set(e,{value:s,ts:n}),s}async tryResolveFromUrls(e){for(let n of e){let r=await Ee(()=>this.http.head(n)),s=this.parseVersionFromUrl(r?.url||n);if(s)return s}}async fetchVersionsIndex(e){if(await this.cache.isNegative(e))return;let n=await this.cache.getIndex(e);if(n&&Date.now()-n.updatedAt<this.versionsIndexMs)return{versions:n.versions,distTags:n.distTags};let r=await Ee(()=>this.http.getJson(`${Pd}${encodeURIComponent(e)}`));if(!r?.versions?.length){await this.cache.recordNegative(e);return}await this.cache.clearNegative(e);let s=r.tags&&Object.keys(r.tags).length?r.tags:void 0;return await this.cache.setIndex(e,r.versions,s),{versions:r.versions,distTags:s}}parseVersionFromUrl(e){let n=B.fromUrl(e)?.version;return n&&/\d+\.\d+\.\d+/.test(n)?n:void 0}async fetchPackageMeta(e,n){let r=await this.cache.getMeta(e,n);if(r&&Date.now()-r.updatedAt<this.metaTtlMs){let{dependencies:f,peerDependencies:d,peerDependenciesMeta:u}=r;return{name:e,version:n,dependencies:f,peerDependencies:d,peerDependenciesMeta:u}}let s=this.packageJson(new B(`${e}@${n}`)),i=await Ee(()=>this.http.getJson(s));if(!i)return;let o=f=>f&&Object.keys(f).length?f:void 0,a=o(i.dependencies),l=o(i.peerDependencies),c=o(i.peerDependenciesMeta);return await this.cache.setMeta(e,n,a,l,c),{name:e,version:n,dependencies:a,peerDependencies:l,peerDependenciesMeta:c}}}});var Ob,js,Rd,ZP,Fs,ha=S(()=>{Ob=t=>t.startsWith("@types/"),js=t=>Object.keys(t?.peerDependencies||{}).filter(e=>!Ob(e)),Rd=t=>Object.keys(t?.dependencies||{}).filter(e=>!Ob(e)),ZP=t=>js(t).filter(e=>!t?.peerDependenciesMeta?.[e]?.optional),Fs=class{constructor(e){this.cdn=e}async resolve(e,n){let r=await this.fetchMeta(e),{allRoots:s,autoAddedPeers:i}=await this.expandWithPeers(r,n),o=this.computeFlags(s);return{allRoots:s,flags:o,autoAddedPeers:i}}async fetchMeta(e){return Promise.all(e.map(async({name:n,version:r})=>({name:n,version:r,meta:await this.cdn.fetchPackageMeta(n,r)})))}async expandWithPeers(e,n){let r=new Map(e.map(i=>[i.name,i])),s=[];for(let i of e)for(let o of ZP(i.meta))!r.has(o)&&!s.some(a=>a.name===o)&&s.push({name:o,requiredBy:i.name});for(let{name:i,requiredBy:o}of s)try{let a=await n(i),l=await this.cdn.fetchPackageMeta(i,a);r.set(i,{name:i,version:a,meta:l})}catch(a){console.warn(`[typebulb] Failed to resolve peer "${i}" for "${o}":`,a)}return{allRoots:[...r.values()],autoAddedPeers:s.filter(i=>r.has(i.name))}}computeFlags(e){let n=new Set(e.flatMap(i=>js(i.meta))),r=new Map;for(let i of e)for(let o of Rd(i.meta))r.set(o,(r.get(o)||0)+1);let s=new Set([...r.entries()].filter(([,i])=>i>=2).map(([i])=>i));return new Map(e.map(i=>[i.name,{isPeerRoot:n.has(i.name),hasPeers:js(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var Us,Id=S(()=>{Ds();pa();Us=class{constructor(e,n,r){this.cache=e,this.cdn=n,this.semver=r}async learnExactVersion(e){let n=await Ee(()=>this.cdn.fetchVersionsIndex(e));if(n?.versions?.length){let r=this.semver.selectBestVersion(n.versions,{distTags:n.distTags});if(r)return r}return this.cdn.resolveExactVersion(e)}async resolveExactForRoot(e,n){if(!n)return this.learnExactVersion(e);let r=a=>!this.semver.isRange(n)||this.semver.satisfies(n,a),s=await this.cache.getPinnedExact(e,n);if(s){if(this.semver.isExactVersion(s)&&r(s))return s;console.debug("[typebulb] cached version for",e,"is not exact or not in",n,"(",s,"); re-resolving from registry")}let i=async a=>{if(a&&this.semver.isExactVersion(a)&&r(a))return await this.cache.setPinnedExact(e,n,a),a},o=await Ee(()=>this.cdn.fetchVersionsIndex(e));if(o?.versions?.length){let a=this.semver.selectBestVersion(o.versions,{range:n,distTags:o.distTags});if(a){let l=await i(a);if(l)return l}else{console.debug("[typebulb] refreshing version cache for",e,"(",n,"not in cached set \u2014 likely a new release)"),await this.cache.invalidateVersionsCache(e);let l=await Ee(()=>this.cdn.fetchVersionsIndex(e));if(l?.versions?.length){let c=await i(this.semver.selectBestVersion(l.versions,{range:n,distTags:l.distTags}));if(c)return c}}}return i(await this.cdn.resolveExactVersion(`${e}@${n}`))}async effectivePackage(e,n){let r=new B(e),s=r.root(),i=n[s],o=i?await Ee(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as eC,parse as tC}from"es-module-lexer";var gr,Nd=S(()=>{Ds();Ms();ha();gr=class t{constructor(e,n,r){this.version=e,this.cdn=n,this.peer=r}extractImportsSync(e){let n=new Set;for(let r of t.importPatterns){r.lastIndex=0;for(let s of e.matchAll(r))B.isBare(s[1])&&n.add(s[1])}return Array.from(n)}async extractImports(e){let n=new Set,r=s=>{B.isBare(s)&&n.add(s)};try{await eC;let[s]=tC(e);s.forEach(i=>r(e.slice(i.s,i.e).trim()))}catch{return this.extractImportsSync(e)}return Array.from(n)}async buildImportMap(e,n,r){let s=(await this.extractImports(e)).filter(d=>!r?.has(B.rootOf(d))),i=[...new Set(s.map(B.rootOf))],o=await Promise.all(i.map(async d=>({name:d,version:await this.resolveVersion(d,n)}))),{allRoots:a,flags:l,autoAddedPeers:c}=await this.peer.resolve(o,d=>this.resolveVersion(d,n)),f=this.buildEntries([...s,...c.map(d=>d.name)],a,l);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,d])=>d)}}async resolveVersion(e,n){let r=n[e],s=await this.version.resolveExactForRoot(e,r);if(!s)throw new Error(`Cannot resolve ${r?`${e}@${r}`:e}: no matching version is published (the package or version may not exist, or the registry was unreachable).`);return s}buildEntries(e,n,r){let s=new Map(n.map(p=>[p.name,p])),i=p=>{let m=s.get(B.rootOf(p));return new B(p).withVersion(m.version).format()},o=new Set([...r.entries()].filter(([,p])=>p.isPeerRoot||p.isSharedDep).map(([p])=>p)),a=new Set(e.filter(p=>p!==B.rootOf(p)).map(B.rootOf)),l=[],c=new Set,f=new Set(e.filter(p=>p===B.rootOf(p))),d=new Set;for(let p of e){let m=B.rootOf(p),h=s.get(m),{isPeerRoot:g,hasPeers:E,isSharedDep:O}=r.get(m),C=a.has(m),x=p!==m,I=!(g||O)&&(C||!E),L=this.singletonDepsOf(h,o),A=x&&f.has(m);A&&d.add(m);let U=A?[...L,m]:L.length?L:void 0;l.push([p,this.cdn.buildEsmUrl(i(p),{bundle:I,external:U})]),c.add(p)}let u=new Set([...o,...d]);for(let p of u)s.has(p)&&(c.has(p)||l.push([p,this.cdn.buildEsmUrl(i(p),{})]),l.push([`${p}/`,`${Wt}/${i(p)}/`]));return l}singletonDepsOf(e,n){return[...new Set([...js(e.meta),...Rd(e.meta)])].filter(r=>n.has(r))}};gr.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as Pb,satisfies as nC,maxSatisfying as Cb,major as rC,valid as sC,validRange as iC}from"semver";var ma,xn,$d=S(()=>{ma=class{cmp(e,n){return e===n?0:Pb(e,n)?1:Pb(n,e)?-1:0}satisfies(e,n){return!e||!e.trim()?!0:!!nC(n,e,{includePrerelease:!0})}selectBestVersion(e,n){if(!e?.length)return;let r=n?.range?.trim()||"*",s=n?.preferStable??!0,i=n?.distTags?.latest;if(i&&e.includes(i)&&this.satisfies(r,i))return i;if(s){let a=Cb(e,r,{includePrerelease:!1});if(a)return a}return Cb(e,r,{includePrerelease:!0})??void 0}majorOf(e){return rC(e)}isExactVersion(e){return sC(e)!==null}isRange(e){return iC(e)!==null}},xn=new ma});function oC(t){return Math.min(9e5*Math.pow(2,Math.max(0,t-1)),864e5)}var En,_b=S(()=>{pa();En=class{constructor(e){this.store=e}async isNegative(e){let n=await Ee(()=>this.store.get(e));return!!n&&n.until>Date.now()}async recordNegative(e){let r=((await Ee(()=>this.store.get(e)))?.attempts||0)+1;await Ee(()=>this.store.set(e,{until:Date.now()+oC(r),attempts:r}))}async clearNegative(e){await Ee(()=>this.store.delete(e))}}});function Rb(t,e){let n=new Bs(t,e),r=new Fs(n),s=new Us(t,n,xn);return{packageService:new gr(s,n,r),versionResolver:s,cdnClient:n,peerResolver:r}}var yt=S(()=>{_d();ha();Id();Nd();$d();Ds();$d();Ms();_d();ha();Id();Nd();_b()});import*as Ld from"fs/promises";import*as Ib from"crypto";function Xe(t){return Ib.createHash("sha1").update(t).digest("hex")}async function bt(t){try{return JSON.parse(await Ld.readFile(t,"utf8"))}catch{return}}async function ga(t){try{return await Ld.readFile(t,"utf8")}catch{return}}var yr=S(()=>{"use strict"});import*as Ht from"fs/promises";import*as wt from"path";import*as $b from"os";function te(){return Md||(Md=lC().catch(()=>pt())),Md}function ba(t,e){return wt.join(aC,Xe(t),e)}async function lC(){await Ht.mkdir(Kt,{recursive:!0});let t=wt.join(Kt,"version.json");if((await bt(t))?.version===Nb)return;let n=await Ht.readdir(Kt).catch(()=>[]);await Promise.all(n.map(r=>Ht.rm(wt.join(Kt,r),{recursive:!0,force:!0}))),await Ht.writeFile(t,JSON.stringify({version:Nb})+`
534
- `,"utf8")}var Nb,Kt,qs,Js,ya,aC,Md,br=S(()=>{"use strict";yr();Ye();Nb=1,Kt=wt.join($b.homedir(),".typebulb","cache"),qs=wt.join(Kt,"packages"),Js=wt.join(Kt,"proxy"),ya=wt.join(Kt,"dts"),aC=wt.join(Kt,"emit")});import*as zt from"fs/promises";import*as Lb from"path";async function De(t,e){let n=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await zt.mkdir(Lb.dirname(t),{recursive:!0}),await zt.writeFile(n,e,"utf8")}catch{pt();return}await zt.rename(n,t).catch(async()=>{await zt.rm(n,{force:!0}).catch(()=>{})})}var Ws=S(()=>{"use strict";Ye()});var wr,Dd=S(()=>{"use strict";Ws();yr();wr=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=bt(this.filePath).then(e=>(this.mem=new Map(Object.entries(e??{})),this.mem))),this.loadPromise)}async get(e){return(await this.load()).get(e)}async set(e,n){let r=await this.load();r.set(e,n),await this.persist(r)}async delete(e){let n=await this.load();n.delete(e)&&await this.persist(n)}async persist(e){await De(this.filePath,JSON.stringify(Object.fromEntries(e)))}}});import*as Bb from"fs/promises";import*as Qe from"path";function Db(t,e){return Qe.join(cC,wa(t),encodeURIComponent(e)+".json")}function wa(t){return t.replace(/\//g,"__")}var Bd,Mb,cC,uC,va,jb=S(()=>{"use strict";yt();br();Ws();Dd();yr();Bd=Qe.join(qs,"indexes"),Mb=Qe.join(qs,"pinned"),cC=Qe.join(qs,"meta"),uC=Qe.join(qs,"negative.json"),va=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new En(new wr(uC));async getPinnedExact(e,n){let r=`${e}@${n}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await te();let s=await ga(Qe.join(Mb,Xe(r)+".txt"));return this.pinnedMem.set(r,s),s}async setPinnedExact(e,n,r){let s=`${e}@${n}`;this.pinnedMem.set(s,r),await te(),await De(Qe.join(Mb,Xe(s)+".txt"),r)}async getIndex(e){if(this.indexMem.has(e))return this.indexMem.get(e);await te();let n=await bt(Qe.join(Bd,wa(e)+".json"));return this.indexMem.set(e,n),n}async setIndex(e,n,r){let s={versions:n,distTags:r,updatedAt:Date.now()};this.indexMem.set(e,s),await te(),await De(Qe.join(Bd,wa(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await Bb.rm(Qe.join(Bd,wa(e)+".json"),{force:!0}).catch(()=>{})}async isNegative(e){return await te(),this.negativeCache.isNegative(e)}async recordNegative(e){await te(),await this.negativeCache.recordNegative(e)}async clearNegative(e){await this.negativeCache.clearNegative(e)}async getMeta(e,n){let r=`${e}@${n}`;if(this.metaMem.has(r))return this.metaMem.get(r);await te();let s=await bt(Db(e,n));return this.metaMem.set(r,s),s}async setMeta(e,n,r,s,i){let o={dependencies:r,peerDependencies:s,peerDependenciesMeta:i,updatedAt:Date.now()};this.metaMem.set(`${e}@${n}`,o),await te(),await De(Db(e,n),JSON.stringify(o))}}});var Fb,Ub=S(()=>{"use strict";Fb={async getJson(t){try{let e=await fetch(t,{redirect:"follow"});return e.ok?await e.json():void 0}catch{return}},async head(t){try{let e=await fetch(t,{method:"HEAD",redirect:"follow"});return{ok:e.ok,url:e.url}}catch{return}}}});var dC,Sa,qb,Jb,Yj,jd=S(()=>{"use strict";yt();jb();Ub();dC=new va,{packageService:Sa,versionResolver:qb,cdnClient:Jb,peerResolver:Yj}=Rb(dC,Fb)});function ka(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Wb(){return` <script>
532
+ `)}function Ab(t,e){let n=Ps(t,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(n.length)throw new Error(`Lint failed:
533
+ ${ZP(n)}`)}var Tb=S(()=>{"use strict";na()});var Wt,Ls,Pd,Ms=S(()=>{Wt="https://esm.sh",Ls="https://cdn.jsdelivr.net/npm/",Pd="https://data.jsdelivr.com/v1/package/npm/"});function Ob(t){let e=(t||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var B,gr,Pb,Ds=S(()=>{Ms();B=class t{constructor(e,n,r){let s=typeof e=="string"?t.parse(e):e;this.name=s.name,this.version=gr(n??s.version),this.subpath=gr(r??s.subpath)}static parse(e){let n=Ob(e||"");if(!n.length)return new t({name:""});if(n[0].startsWith("@")){let s=n[0],[i,o]=Pb(n[1]??""),a=gr(n.slice(2).join("/"));return new t({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=Pb(n[0]),o=gr(n.slice(1).join("/"));return new t({name:s,version:i,subpath:o})}}static fromUrl(e){try{let n=new URL(e),r=new URL(Wt).host,s=new URL(Ls).host;if(n.host===r){let i=Ob(n.pathname.replace(/^\/v\d+\//,"/"));if(!i.length)return;let o=i[0].startsWith("@")?`${i[0]}/${i[1]??""}`:i[0];return t.parse(o)}if(n.host===s){let i=n.pathname.split("/npm/")[1];if(!i)return;let o=i.split("/")[0]||"";return t.parse(o)}return}catch{return}}format(){let e=this.version?`${this.name}@${this.version}`:this.name;return this.subpath?`${e}/${this.subpath}`:e}root(){return this.name}static rootOf(e){return t.parse(e).name}withVersion(e){return new t({name:this.name,version:gr(e),subpath:this.subpath})}static isBare(e){return!e||e.startsWith(".")||e.startsWith("/")?!1:!/^[a-z][a-z0-9+.-]*:/i.test(e)}},gr=t=>t&&t.length?t:void 0,Pb=t=>{let e=t.indexOf("@");return e<0?[t,void 0]:[t.slice(0,e),gr(t.slice(e+1))]}});async function Ee(t){try{return await t()}catch{return}}var pa=S(()=>{});function kn(t){let e=t||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function Cd(t){return t.startsWith("./")?t:`./${t}`}var Bs,_d=S(()=>{Ds();pa();Ms();Bs=class{constructor(e,n){this.cache=e,this.http=n,this.pinMs=1e4,this.versionsIndexMs=1440*60*1e3,this.metaTtlMs=10080*60*1e3,this.pinCache=new Map}baseDir(e){let n=typeof e=="string"?new B(e):e;return`${Ls}${n.name}${n.version?`@${n.version}`:""}/`}file(e,n){return new URL(kn(n),this.baseDir(e)).toString()}packageJson(e){return this.file(e,"package.json")}buildEsmUrl(e,n={}){let{target:r="es2022",bundle:s=!1,external:i}=n,o=new URLSearchParams({target:r});return s&&o.append("bundle",""),i?.length&&o.append("external",i.join(",")),`${Wt}/${e}?${o.toString()}`}async resolveExactVersion(e){let n=Date.now(),r=this.pinCache.get(e);if(r&&n-r.ts<this.pinMs)return r.value;let s=await this.tryResolveFromUrls([this.buildEsmUrl(e),`${Wt}/${e}`]);return this.pinCache.set(e,{value:s,ts:n}),s}async tryResolveFromUrls(e){for(let n of e){let r=await Ee(()=>this.http.head(n)),s=this.parseVersionFromUrl(r?.url||n);if(s)return s}}async fetchVersionsIndex(e){if(await this.cache.isNegative(e))return;let n=await this.cache.getIndex(e);if(n&&Date.now()-n.updatedAt<this.versionsIndexMs)return{versions:n.versions,distTags:n.distTags};let r=await Ee(()=>this.http.getJson(`${Pd}${encodeURIComponent(e)}`));if(!r?.versions?.length){await this.cache.recordNegative(e);return}await this.cache.clearNegative(e);let s=r.tags&&Object.keys(r.tags).length?r.tags:void 0;return await this.cache.setIndex(e,r.versions,s),{versions:r.versions,distTags:s}}parseVersionFromUrl(e){let n=B.fromUrl(e)?.version;return n&&/\d+\.\d+\.\d+/.test(n)?n:void 0}async fetchPackageMeta(e,n){let r=await this.cache.getMeta(e,n);if(r&&Date.now()-r.updatedAt<this.metaTtlMs){let{dependencies:f,peerDependencies:d,peerDependenciesMeta:u}=r;return{name:e,version:n,dependencies:f,peerDependencies:d,peerDependenciesMeta:u}}let s=this.packageJson(new B(`${e}@${n}`)),i=await Ee(()=>this.http.getJson(s));if(!i)return;let o=f=>f&&Object.keys(f).length?f:void 0,a=o(i.dependencies),l=o(i.peerDependencies),c=o(i.peerDependenciesMeta);return await this.cache.setMeta(e,n,a,l,c),{name:e,version:n,dependencies:a,peerDependencies:l,peerDependenciesMeta:c}}}});var Cb,js,Rd,eC,Fs,ha=S(()=>{Cb=t=>t.startsWith("@types/"),js=t=>Object.keys(t?.peerDependencies||{}).filter(e=>!Cb(e)),Rd=t=>Object.keys(t?.dependencies||{}).filter(e=>!Cb(e)),eC=t=>js(t).filter(e=>!t?.peerDependenciesMeta?.[e]?.optional),Fs=class{constructor(e){this.cdn=e}async resolve(e,n){let r=await this.fetchMeta(e),{allRoots:s,autoAddedPeers:i}=await this.expandWithPeers(r,n),o=this.computeFlags(s);return{allRoots:s,flags:o,autoAddedPeers:i}}async fetchMeta(e){return Promise.all(e.map(async({name:n,version:r})=>({name:n,version:r,meta:await this.cdn.fetchPackageMeta(n,r)})))}async expandWithPeers(e,n){let r=new Map(e.map(i=>[i.name,i])),s=[];for(let i of e)for(let o of eC(i.meta))!r.has(o)&&!s.some(a=>a.name===o)&&s.push({name:o,requiredBy:i.name});for(let{name:i,requiredBy:o}of s)try{let a=await n(i),l=await this.cdn.fetchPackageMeta(i,a);r.set(i,{name:i,version:a,meta:l})}catch(a){console.warn(`[typebulb] Failed to resolve peer "${i}" for "${o}":`,a)}return{allRoots:[...r.values()],autoAddedPeers:s.filter(i=>r.has(i.name))}}computeFlags(e){let n=new Set(e.flatMap(i=>js(i.meta))),r=new Map;for(let i of e)for(let o of Rd(i.meta))r.set(o,(r.get(o)||0)+1);let s=new Set([...r.entries()].filter(([,i])=>i>=2).map(([i])=>i));return new Map(e.map(i=>[i.name,{isPeerRoot:n.has(i.name),hasPeers:js(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var Us,Id=S(()=>{Ds();pa();Us=class{constructor(e,n,r){this.cache=e,this.cdn=n,this.semver=r}async learnExactVersion(e){let n=await Ee(()=>this.cdn.fetchVersionsIndex(e));if(n?.versions?.length){let r=this.semver.selectBestVersion(n.versions,{distTags:n.distTags});if(r)return r}return this.cdn.resolveExactVersion(e)}async resolveExactForRoot(e,n){if(!n)return this.learnExactVersion(e);let r=a=>!this.semver.isRange(n)||this.semver.satisfies(n,a),s=await this.cache.getPinnedExact(e,n);if(s){if(this.semver.isExactVersion(s)&&r(s))return s;console.debug("[typebulb] cached version for",e,"is not exact or not in",n,"(",s,"); re-resolving from registry")}let i=async a=>{if(a&&this.semver.isExactVersion(a)&&r(a))return await this.cache.setPinnedExact(e,n,a),a},o=await Ee(()=>this.cdn.fetchVersionsIndex(e));if(o?.versions?.length){let a=this.semver.selectBestVersion(o.versions,{range:n,distTags:o.distTags});if(a){let l=await i(a);if(l)return l}else{console.debug("[typebulb] refreshing version cache for",e,"(",n,"not in cached set \u2014 likely a new release)"),await this.cache.invalidateVersionsCache(e);let l=await Ee(()=>this.cdn.fetchVersionsIndex(e));if(l?.versions?.length){let c=await i(this.semver.selectBestVersion(l.versions,{range:n,distTags:l.distTags}));if(c)return c}}}return i(await this.cdn.resolveExactVersion(`${e}@${n}`))}async effectivePackage(e,n){let r=new B(e),s=r.root(),i=n[s],o=i?await Ee(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as tC,parse as nC}from"es-module-lexer";var yr,Nd=S(()=>{Ds();Ms();ha();yr=class t{constructor(e,n,r){this.version=e,this.cdn=n,this.peer=r}extractImportsSync(e){let n=new Set;for(let r of t.importPatterns){r.lastIndex=0;for(let s of e.matchAll(r))B.isBare(s[1])&&n.add(s[1])}return Array.from(n)}async extractImports(e){let n=new Set,r=s=>{B.isBare(s)&&n.add(s)};try{await tC;let[s]=nC(e);s.forEach(i=>r(e.slice(i.s,i.e).trim()))}catch{return this.extractImportsSync(e)}return Array.from(n)}async buildImportMap(e,n,r){let s=(await this.extractImports(e)).filter(d=>!r?.has(B.rootOf(d))),i=[...new Set(s.map(B.rootOf))],o=await Promise.all(i.map(async d=>({name:d,version:await this.resolveVersion(d,n)}))),{allRoots:a,flags:l,autoAddedPeers:c}=await this.peer.resolve(o,d=>this.resolveVersion(d,n)),f=this.buildEntries([...s,...c.map(d=>d.name)],a,l);return{importMap:{imports:Object.fromEntries(f)},prefetchUrls:f.map(([,d])=>d)}}async resolveVersion(e,n){let r=n[e],s=await this.version.resolveExactForRoot(e,r);if(!s)throw new Error(`Cannot resolve ${r?`${e}@${r}`:e}: no matching version is published (the package or version may not exist, or the registry was unreachable).`);return s}buildEntries(e,n,r){let s=new Map(n.map(p=>[p.name,p])),i=p=>{let m=s.get(B.rootOf(p));return new B(p).withVersion(m.version).format()},o=new Set([...r.entries()].filter(([,p])=>p.isPeerRoot||p.isSharedDep).map(([p])=>p)),a=new Set(e.filter(p=>p!==B.rootOf(p)).map(B.rootOf)),l=[],c=new Set,f=new Set(e.filter(p=>p===B.rootOf(p))),d=new Set;for(let p of e){let m=B.rootOf(p),h=s.get(m),{isPeerRoot:g,hasPeers:x,isSharedDep:O}=r.get(m),C=a.has(m),E=p!==m,I=!(g||O)&&(C||!x),L=this.singletonDepsOf(h,o),A=E&&f.has(m);A&&d.add(m);let F=A?[...L,m]:L.length?L:void 0;l.push([p,this.cdn.buildEsmUrl(i(p),{bundle:I,external:F})]),c.add(p)}let u=new Set([...o,...d]);for(let p of u)s.has(p)&&(c.has(p)||l.push([p,this.cdn.buildEsmUrl(i(p),{})]),l.push([`${p}/`,`${Wt}/${i(p)}/`]));return l}singletonDepsOf(e,n){return[...new Set([...js(e.meta),...Rd(e.meta)])].filter(r=>n.has(r))}};yr.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as _b,satisfies as rC,maxSatisfying as Rb,major as sC,valid as iC,validRange as oC}from"semver";var ma,xn,$d=S(()=>{ma=class{cmp(e,n){return e===n?0:_b(e,n)?1:_b(n,e)?-1:0}satisfies(e,n){return!e||!e.trim()?!0:!!rC(n,e,{includePrerelease:!0})}selectBestVersion(e,n){if(!e?.length)return;let r=n?.range?.trim()||"*",s=n?.preferStable??!0,i=n?.distTags?.latest;if(i&&e.includes(i)&&this.satisfies(r,i))return i;if(s){let a=Rb(e,r,{includePrerelease:!1});if(a)return a}return Rb(e,r,{includePrerelease:!0})??void 0}majorOf(e){return sC(e)}isExactVersion(e){return iC(e)!==null}isRange(e){return oC(e)!==null}},xn=new ma});function aC(t){return Math.min(9e5*Math.pow(2,Math.max(0,t-1)),864e5)}var En,Ib=S(()=>{pa();En=class{constructor(e){this.store=e}async isNegative(e){let n=await Ee(()=>this.store.get(e));return!!n&&n.until>Date.now()}async recordNegative(e){let r=((await Ee(()=>this.store.get(e)))?.attempts||0)+1;await Ee(()=>this.store.set(e,{until:Date.now()+aC(r),attempts:r}))}async clearNegative(e){await Ee(()=>this.store.delete(e))}}});function Nb(t,e){let n=new Bs(t,e),r=new Fs(n),s=new Us(t,n,xn);return{packageService:new yr(s,n,r),versionResolver:s,cdnClient:n,peerResolver:r}}var yt=S(()=>{_d();ha();Id();Nd();$d();Ds();$d();Ms();_d();ha();Id();Nd();Ib()});import*as Ld from"fs/promises";import*as $b from"crypto";function Xe(t){return $b.createHash("sha1").update(t).digest("hex")}async function bt(t){try{return JSON.parse(await Ld.readFile(t,"utf8"))}catch{return}}async function ga(t){try{return await Ld.readFile(t,"utf8")}catch{return}}var br=S(()=>{"use strict"});import*as Ht from"fs/promises";import*as wt from"path";import*as Mb from"os";function ee(){return Md||(Md=cC().catch(()=>pt())),Md}function ba(t,e){return wt.join(lC,Xe(t),e)}async function cC(){await Ht.mkdir(Kt,{recursive:!0});let t=wt.join(Kt,"version.json");if((await bt(t))?.version===Lb)return;let n=await Ht.readdir(Kt).catch(()=>[]);await Promise.all(n.map(r=>Ht.rm(wt.join(Kt,r),{recursive:!0,force:!0}))),await Ht.writeFile(t,JSON.stringify({version:Lb})+`
534
+ `,"utf8")}var Lb,Kt,qs,Js,ya,lC,Md,wr=S(()=>{"use strict";br();Ye();Lb=1,Kt=wt.join(Mb.homedir(),".typebulb","cache"),qs=wt.join(Kt,"packages"),Js=wt.join(Kt,"proxy"),ya=wt.join(Kt,"dts"),lC=wt.join(Kt,"emit")});import*as zt from"fs/promises";import*as Db from"path";async function De(t,e){let n=`${t}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await zt.mkdir(Db.dirname(t),{recursive:!0}),await zt.writeFile(n,e,"utf8")}catch{pt();return}await zt.rename(n,t).catch(async()=>{await zt.rm(n,{force:!0}).catch(()=>{})})}var Ws=S(()=>{"use strict";Ye()});var vr,Dd=S(()=>{"use strict";Ws();br();vr=class{constructor(e){this.filePath=e}mem;loadPromise;load(){return this.mem?Promise.resolve(this.mem):(this.loadPromise||(this.loadPromise=bt(this.filePath).then(e=>(this.mem=new Map(Object.entries(e??{})),this.mem))),this.loadPromise)}async get(e){return(await this.load()).get(e)}async set(e,n){let r=await this.load();r.set(e,n),await this.persist(r)}async delete(e){let n=await this.load();n.delete(e)&&await this.persist(n)}async persist(e){await De(this.filePath,JSON.stringify(Object.fromEntries(e)))}}});import*as Fb from"fs/promises";import*as Qe from"path";function jb(t,e){return Qe.join(uC,wa(t),encodeURIComponent(e)+".json")}function wa(t){return t.replace(/\//g,"__")}var Bd,Bb,uC,dC,va,Ub=S(()=>{"use strict";yt();wr();Ws();Dd();br();Bd=Qe.join(qs,"indexes"),Bb=Qe.join(qs,"pinned"),uC=Qe.join(qs,"meta"),dC=Qe.join(qs,"negative.json"),va=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new En(new vr(dC));async getPinnedExact(e,n){let r=`${e}@${n}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await ee();let s=await ga(Qe.join(Bb,Xe(r)+".txt"));return this.pinnedMem.set(r,s),s}async setPinnedExact(e,n,r){let s=`${e}@${n}`;this.pinnedMem.set(s,r),await ee(),await De(Qe.join(Bb,Xe(s)+".txt"),r)}async getIndex(e){if(this.indexMem.has(e))return this.indexMem.get(e);await ee();let n=await bt(Qe.join(Bd,wa(e)+".json"));return this.indexMem.set(e,n),n}async setIndex(e,n,r){let s={versions:n,distTags:r,updatedAt:Date.now()};this.indexMem.set(e,s),await ee(),await De(Qe.join(Bd,wa(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await Fb.rm(Qe.join(Bd,wa(e)+".json"),{force:!0}).catch(()=>{})}async isNegative(e){return await ee(),this.negativeCache.isNegative(e)}async recordNegative(e){await ee(),await this.negativeCache.recordNegative(e)}async clearNegative(e){await this.negativeCache.clearNegative(e)}async getMeta(e,n){let r=`${e}@${n}`;if(this.metaMem.has(r))return this.metaMem.get(r);await ee();let s=await bt(jb(e,n));return this.metaMem.set(r,s),s}async setMeta(e,n,r,s,i){let o={dependencies:r,peerDependencies:s,peerDependenciesMeta:i,updatedAt:Date.now()};this.metaMem.set(`${e}@${n}`,o),await ee(),await De(jb(e,n),JSON.stringify(o))}}});var qb,Jb=S(()=>{"use strict";qb={async getJson(t){try{let e=await fetch(t,{redirect:"follow"});return e.ok?await e.json():void 0}catch{return}},async head(t){try{let e=await fetch(t,{method:"HEAD",redirect:"follow"});return{ok:e.ok,url:e.url}}catch{return}}}});var fC,Sa,Wb,Kb,Vj,jd=S(()=>{"use strict";yt();Ub();Jb();fC=new va,{packageService:Sa,versionResolver:Wb,cdnClient:Kb,peerResolver:Vj}=Nb(fC,qb)});function ka(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Hb(){return` <script>
535
535
  ${Vg}
536
536
  (function () {
537
537
  try {
@@ -590,7 +590,7 @@ ${Vg}
590
590
  });
591
591
  } catch (e) {}
592
592
  })();
593
- </script>`}var vt,Kb,Fd,fC,pC,Ea,vr=S(()=>{"use strict";ee();ee();vt=t=>t.replace(/<\/script/gi,"<\\/script");Kb=30*6e4,Fd=1e3,fC=6e4,pC=3e4,Ea=(t="'/__reload'")=>`
593
+ </script>`}var vt,zb,Fd,pC,hC,Ea,Sr=S(()=>{"use strict";Q();Q();vt=t=>t.replace(/<\/script/gi,"<\\/script");zb=30*6e4,Fd=1e3,pC=6e4,hC=3e4,Ea=(t="'/__reload'")=>`
594
594
  let es = null;
595
595
  let bootId = null;
596
596
  let firstErrorAt = 0;
@@ -605,9 +605,9 @@ ${Vg}
605
605
  es.onerror = () => {
606
606
  if (!firstErrorAt) firstErrorAt = Date.now();
607
607
  // Inside the replace window, EventSource's own retry is faster than anything we'd schedule.
608
- if (Date.now() - firstErrorAt <= ${fC}) return;
608
+ if (Date.now() - firstErrorAt <= ${pC}) return;
609
609
  es.close();
610
- backoff = Math.min(${pC}, backoff ? backoff * 2 : ${Fd} * 2);
610
+ backoff = Math.min(${hC}, backoff ? backoff * 2 : ${Fd} * 2);
611
611
  setTimeout(tbConnect, backoff);
612
612
  };
613
613
  };
@@ -623,7 +623,7 @@ ${Vg}
623
623
  // A relay open (TB-VSCode-Browser.md): the CLI asks a page of ours inside VS Code to open a URL,
624
624
  // since its integrated browser honors a gesture-less window.open and keeps the new tab in-editor.
625
625
  tbOn('open-url', (e) => { window.open(e.data, '_blank', 'noopener'); });
626
- tbConnect();`});var Hb,zb=S(()=>{"use strict";vr();ee();Hb=`
626
+ tbConnect();`});var Yb,Vb=S(()=>{"use strict";Sr();Q();Yb=`
627
627
  (() => {
628
628
  // Inline (bulb-in-a-bulb): runs inside a sandboxed iframe with no parent
629
629
  // bridge, so privileged tb.* (AI, fs, server RPC) can't reach a host and would
@@ -1583,20 +1583,20 @@ ${Ea("tbStreamUrl")}
1583
1583
  });
1584
1584
  }
1585
1585
  })();
1586
- `});function Yb(t){let{name:e,code:n,css:r,html:s,data:i,insight:o,importMap:a,theme:l,inline:c,dir:f,source:d,bulbKey:u,compileError:p}=t,m=s.trim()||'<div id="app"></div>',h=c?"":`
1587
- `+Au,g={imports:bC(a.imports)};return`<!DOCTYPE html>
1586
+ `});function Gb(t){let{name:e,code:n,css:r,html:s,data:i,insight:o,importMap:a,theme:l,inline:c,dir:f,source:d,bulbKey:u,compileError:p}=t,m=s.trim()||'<div id="app"></div>',h=c?"":`
1587
+ `+Au,g={imports:wC(a.imports)};return`<!DOCTYPE html>
1588
1588
  <html>
1589
1589
  <head>
1590
1590
  <meta charset="utf-8">
1591
1591
  <meta name="viewport" content="width=device-width, initial-scale=1">
1592
1592
  <title>${ka(e)} - typebulb</title>
1593
1593
  ${xa(e,l)}
1594
- ${c?"":Wb()}
1594
+ ${c?"":Hb()}
1595
1595
  <script type="importmap">
1596
1596
  ${JSON.stringify(g,null,2)}
1597
1597
  </script>
1598
1598
  <style>
1599
- ${ys}${h}
1599
+ ${bs}${h}
1600
1600
  </style>
1601
1601
  <style>
1602
1602
  ${r}
@@ -1613,19 +1613,19 @@ ${p?`<script>window.__TB_COMPILE_ERROR__ = ${vt(JSON.stringify(p))};</script>`:"
1613
1613
 
1614
1614
  <script>
1615
1615
  ${Xg}
1616
- ${Hb}
1616
+ ${Yb}
1617
1617
  </script>
1618
1618
 
1619
- ${yC}
1619
+ ${bC}
1620
1620
 
1621
- ${mC(n,d)}
1621
+ ${gC(n,d)}
1622
1622
  </body>
1623
- </html>`}function mC(t,e){let n=["",...hC],r=e?Array(Math.max(0,e.codeLine-n.length-1)).fill(""):[],s=[...n,...r,vt(t)].join(`
1624
- `);return`<script type="module">${s}${gC(e,s)}
1625
- </script>`}function gC(t,e){if(!t)return"";let n=e.split(`
1623
+ </html>`}function gC(t,e){let n=["",...mC],r=e?Array(Math.max(0,e.codeLine-n.length-1)).fill(""):[],s=[...n,...r,vt(t)].join(`
1624
+ `);return`<script type="module">${s}${yC(e,s)}
1625
+ </script>`}function yC(t,e){if(!t)return"";let n=e.split(`
1626
1626
  `).length,r={version:3,file:t.file,sources:[`/__source/${t.file}`],names:[],mappings:["AAAA",...Array(Math.max(0,n-1)).fill("AACA")].join(";")};return`
1627
1627
  //# sourceURL=${t.file.replace(/\s/g,"%20")}
1628
- //# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function bC(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.startsWith("https://")?"/proxy/"+r:r;return e}var hC,yC,Vb=S(()=>{"use strict";ee();zb();vr();hC=["globalThis.__tbEntryRan = true; /* import graph resolved \u2014 the load-failure backstop's signal (imports hoist above this line) */","await globalThis.__tbBoot; /* #tb= fragment restore, set by the shim when present (TB-Inference.md) */"];yC=`<script>
1628
+ //# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function wC(t){let e={};for(let[n,r]of Object.entries(t))e[n]=r.startsWith("https://")?"/proxy/"+r:r;return e}var mC,bC,Xb=S(()=>{"use strict";Q();Vb();Sr();mC=["globalThis.__tbEntryRan = true; /* import graph resolved \u2014 the load-failure backstop's signal (imports hoist above this line) */","await globalThis.__tbBoot; /* #tb= fragment restore, set by the shim when present (TB-Inference.md) */"];bC=`<script>
1629
1629
  (function () {
1630
1630
  var framed = window.parent !== window;
1631
1631
  var post = function (m) { try { parent.postMessage(m, '*'); } catch (e) {} }; /* framed only */
@@ -1724,20 +1724,20 @@ ${mC(n,d)}
1724
1724
  }
1725
1725
  });
1726
1726
  })();
1727
- </script>`});import*as Ta from"fs/promises";import*as Aa from"path";import{existsSync as Gb,readFileSync as wC}from"fs";import{execFile as vC}from"child_process";import{promisify as SC}from"util";import{builtinModules as kC}from"node:module";import{satisfies as xC}from"semver";async function Oa(t,e,n,r){let i=t.map(c=>OC(c,n)).filter(c=>!PC(c,e));if(i.length===0)return;let o=i.filter(c=>!TC.test(c));if(o.length)throw new Error(`Refusing to install npm spec(s) with unsupported characters: ${o.join(", ")}
1728
- Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await Ta.mkdir(e,{recursive:!0});let a=Aa.join(e,"package.json");Gb(a)||await Ta.writeFile(a,JSON.stringify({name:"typebulb-server",private:!0})),console.log(` Installing: ${i.join(", ")}`);let l=["--no-audit","--no-fund",...r?.ignoreScripts?["--ignore-scripts"]:[]];await EC("npm",["install",...l,...i],{cwd:e,shell:!0})}function OC(t,e){if(!e||B.parse(t).version)return t;let n=e[t];return n?`${t}@${n}`:t}function PC(t,e){let{name:n,version:r}=B.parse(t),s=Aa.join(e,"node_modules",n);if(!Gb(s))return!1;if(!r)return!0;try{let i=JSON.parse(wC(Aa.join(s,"package.json"),"utf-8")).version;return xC(i,r)}catch{return!1}}function Pa(t){let e=new Set,n=/\bimport\s+(?:[\s\S]*?\s+from\s+)?['"]([^./][^'"]*)['"]/g,r;for(;r=n.exec(t);){let s=r[1];if(s.includes(":"))continue;let i=B.rootOf(s);AC.has(i)||e.add(i)}return[...e]}var EC,AC,TC,Ud=S(()=>{"use strict";yt();EC=SC(vC),AC=new Set(kC),TC=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});import*as Be from"fs/promises";import*as _e from"path";function Sr(t,e){let n=_e.resolve(e,t),r=_e.normalize(e),s=_e.normalize(n);if(s!==r&&!s.startsWith(r+_e.sep))throw new Error("Path traversal detected - access denied");return n}async function Ks(t,e){return Be.readFile(Sr(t,e))}async function Ca(t,e,n){let r=Sr(t,n);await Be.mkdir(_e.dirname(r),{recursive:!0}),await Be.writeFile(r,typeof e=="string"?e:Buffer.from(e))}async function _a(t,e){let n=Sr(t,e),r=await Be.readdir(n,{withFileTypes:!0});return Promise.all(r.map(async s=>{let i=await Be.stat(_e.join(n,s.name)).then(o=>o.mtimeMs).catch(()=>0);return{name:s.name,dir:s.isDirectory(),mtime:i}}))}async function Ra(t,e){let n=Sr(t,e);if(_e.normalize(n)===_e.normalize(e))throw new Error("Cannot remove the bulb's folder itself: remove its contents instead");await Be.rm(n,{recursive:!0})}var qd=S(()=>{"use strict"});async function Xb(t){let e=gt(t.provider,t.model);if(typeof e=="string")throw new Error(e);let n=await Jt(e,t);if(!n.ok){let r=await fr(n,e.protocol);throw new Error(r.message)}return{response:n,protocol:e.protocol}}async function CC(t){let{response:e,protocol:n}=await Xb(t);return pr(e,n)}async function*_C(t){let{response:e,protocol:n}=await Xb(t);yield*Sn(e,n)}function Qb(t){let e=Object.assign(CC,{stream:_C}),n={read:async r=>{let s=await Ks(r,t);try{return new TextDecoder("utf-8",{fatal:!0}).decode(s)}catch{throw new Error(`File is not valid UTF-8 text: ${r} \u2014 use tb.fs.readBytes() for binary files.`)}},readBytes:async r=>new Uint8Array(await Ks(r,t)),write:async(r,s)=>(await Ca(r,s,t),!0),list:async(r=".")=>_a(r,t),remove:async r=>(await Ra(r,t),!0)};globalThis.tb=Object.freeze({log:(...r)=>{console.log(...r)},ai:e,fs:n,dir:t,models:()=>mt(),aiAccess:sa,mode:Vn.local})}var Zb=S(()=>{"use strict";Ut();ee();fa();bn();qd()});import*as Yt from"fs/promises";import*as ce from"path";import{pathToFileURL as RC}from"url";async function ew(t){let n=(await Yt.readdir(t)).find(r=>r.endsWith(".bulb.md"));return n?ce.join(t,n):void 0}function kr(t){let e=ce.resolve(t);return ce.join(ce.dirname(e),ce.basename(e).replace(/\.bulb\.md$/,""))}function xr(t){let[e,n,r,s]=t.split(ce.sep).slice(-4);if(!(e!=="typebulbs"||n!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function Ze(t){let e=await Yt.readFile(t,"utf-8"),n=Mn(e),r=ir(n);return{bulb:r,config:Dr(r.config),warnings:Tp(e),starts:n.starts}}function Jd(t){let e=ce.basename(t).replace(/\.bulb\.md$/i,"");return ce.join(ce.dirname(t),".typebulb",`${e}.server.mjs`)}async function Hs(t,e,n,r){let s=Od(t,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;n&&(i=await vp(i,n));let o=ce.join(ce.dirname(e),".typebulb");await Yt.mkdir(o,{recursive:!0});let a=Pa(i);a.length>0&&await Oa(a,o,r);let l=Jd(e);return await Yt.writeFile(l,i,"utf-8"),Qb(kr(e)),await import(`${RC(l).href}?t=${Date.now()}`)}async function Wd(t,e,n,r){let{bulb:s,config:i,starts:o}=await Ze(t),a=Ao(s.data),l,c=m=>{l??=m instanceof Error?m.message:String(m)};try{xb(s.code,i.dependencies??{})}catch(m){c(m)}let f=Od(s.code,{jsxImportSource:i.ts?.jsxImportSource});f.error&&c(f.error);let d={imports:{}};if(!l)try{({importMap:d}=await Sa.buildImportMap(f.code,i.dependencies??{},r?new Set([r.name]):void 0))}catch(m){c(`Dependency resolution failed: ${m instanceof Error?m.message:String(m)}`)}l&&console.error("Build error:",l),r&&(d.imports[r.name]=r.entryUrl);let u=Yb({name:s.name,code:l?"":f.code,css:s.css,html:s.html,data:a,insight:s.insight,importMap:d,dir:kr(t),watch:e,source:{file:ce.basename(t),codeLine:o.get("code.tsx")??1},bulbKey:xs(t),compileError:l}),p;return s.server&&n&&(p=await Hs(s.server,t,r,i.dependencies)),{html:u,bulb:s,serverExports:p,buildError:l}}var An,St=S(()=>{"use strict";Os();kb();Eb();jd();Vb();Ud();ki();Ye();Zb();An=t=>ce.join(kr(t),"assets")});import*as Re from"fs/promises";import*as je from"path";import{createHash as IC}from"crypto";async function Hd(t,e,n){let r=[...t],s=async()=>{for(let i=r.shift();i!==void 0;i=r.shift())await n(i)};await Promise.all(Array.from({length:Math.min(e,t.length)},s))}function Er(t){try{return JSON.parse(t).error||t}catch{return t}}async function Yd(t,e){try{let n=await fetch(zs(t),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});return n.ok?n.headers.get("content-type")?.includes("json")?{entries:await n.json()}:{error:"manifest response is not JSON \u2014 wrong origin?"}:{error:`manifest request failed (${n.status}): ${Er(await n.text())}`}}catch(n){return{error:n instanceof Error?n.message:String(n)}}}function Vd(t,e){xe(e);let n=process.env.TYPEBULB_ORIGIN||NC;try{return $a(t,process.cwd(),n)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function $a(t,e,n){if(/^https?:\/\//i.test(t)){let i=new URL(t),o=i.pathname.split("/").filter(Boolean).map(decodeURIComponent),a=o[0]==="api"&&o[1]==="scripts"?o.slice(2):o;if(a[0]!=="u"||!a[1]||!a[2])throw new Error(`Not a bulb URL: ${t}
1729
- Expected <origin>/u/<user>/<slug>`);let l=a[1],c=a[2].replace(/(\.bulb)?\.md$/,"");return{origin:i.origin,userSlug:l,slug:c,dest:je.join(e,Ia(l,c))}}let r=je.resolve(e,t),s=xr(r);if(!s)throw new Error(`Not a conventional bulb path: ${t}
1730
- A pull target must be a bulb URL, or a local file at typebulbs/u/<user>/<slug>.bulb.md \u2014 the path is its remote identity.`);return{origin:n,...s,dest:r}}async function $C(t,e){let n=await Yd(t,e);if("error"in n||!n.entries.length)return{kind:"none"};let r=n.entries,s=An(t.dest),i=[],o=[],a=0;for(let l of r){let c=await Re.readFile(je.join(s,...l.path.split("/"))).catch(()=>{});c===void 0?i.push(l.path):zd(c)===l.md5?a++:e.force?i.push(l.path):o.push(l.path)}return o.length?{kind:"conflict",paths:o}:{kind:"plan",toGet:i,unchanged:a}}async function LC(t,e,n){let r=An(t.dest),s=[],i=0;return await Hd(e.toGet,4,async o=>{try{let a=await fetch(`${zs(t)}/${Na(o)}`,{headers:n.token?{Authorization:`Bearer ${n.token}`}:{},signal:AbortSignal.timeout(n.timeoutMs??3e4)});if(!a.ok){s.push(`${o}: HTTP ${a.status}`);return}let l=je.join(r,...o.split("/"));await Re.mkdir(je.dirname(l),{recursive:!0}),await Re.writeFile(l,new Uint8Array(await a.arrayBuffer())),i++}catch(a){s.push(`${o}: ${a instanceof Error?a.message:String(a)}`)}}),{downloaded:i,unchanged:e.unchanged,errors:s}}async function La(t,e={}){let n=await fetch(Kd(t),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});if(!n.ok)return{kind:"http-error",status:n.status};let r=n.headers.get("content-type");if(!r?.includes("text/markdown"))return{kind:"not-markdown",contentType:r??void 0};let s=await n.text(),i;try{i=await Re.readFile(t.dest,"utf-8")}catch{}let o=i!==void 0&&MC(i,s);if(i!==void 0&&!o&&!e.force){let{mtime:c}=await Re.stat(t.dest);return{kind:"conflict",dest:t.dest,localMtime:c,remoteLastModified:n.headers.get("last-modified")??void 0}}let a=await $C(t,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:t.dest,paths:a.paths};if(!o){await Re.mkdir(je.dirname(t.dest),{recursive:!0}),await Re.writeFile(t.dest,s);let c=new Date(n.headers.get("last-modified")??"");isNaN(c.getTime())||await Re.utimes(t.dest,new Date,c)}let l=a.kind==="plan"?await LC(t,a,e):void 0;return o?{kind:"up-to-date",dest:t.dest,assets:l}:{kind:"written",dest:t.dest,created:i===void 0,assets:l}}function MC(t,e){let n=i=>i.replace(/\r\n/g,`
1731
- `),r=We(n(t)),s=We(n(e));return!r||!s?n(t)===n(e):r.frontmatter.name===s.frontmatter.name&&Je.every(i=>(r.files.get(le[i].path)||"")===(s.files.get(le[i].path)||""))}async function nw(t,e){t||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let n=Vd(t,e.mode),r=`${n.origin}/u/${n.userSlug}/${n.slug}`,s;try{s=await La(n,{force:e.force,token:process.env.TYPEBULB_TOKEN})}catch(o){console.error(`Could not reach ${n.origin}: ${o instanceof Error?o.message:String(o)}`),process.exitCode=1;return}let i=je.relative(process.cwd(),n.dest)||n.dest;switch(s.kind){case"written":console.log(`pulled ${r} \u2192 ${i}${s.created?"":" (overwritten)"}`),tw(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),tw(s.assets);return;case"conflict":console.error(`Refusing to overwrite ${i} \u2014 it differs from ${r}
1727
+ </script>`});import*as Ta from"fs/promises";import*as Aa from"path";import{existsSync as Qb,readFileSync as vC}from"fs";import{execFile as SC}from"child_process";import{promisify as kC}from"util";import{builtinModules as xC}from"node:module";import{satisfies as EC}from"semver";async function Oa(t,e,n,r){let i=t.map(c=>PC(c,n)).filter(c=>!CC(c,e));if(i.length===0)return;let o=i.filter(c=>!OC.test(c));if(o.length)throw new Error(`Refusing to install npm spec(s) with unsupported characters: ${o.join(", ")}
1728
+ Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await Ta.mkdir(e,{recursive:!0});let a=Aa.join(e,"package.json");Qb(a)||await Ta.writeFile(a,JSON.stringify({name:"typebulb-server",private:!0})),console.log(` Installing: ${i.join(", ")}`);let l=["--no-audit","--no-fund",...r?.ignoreScripts?["--ignore-scripts"]:[]];await AC("npm",["install",...l,...i],{cwd:e,shell:!0})}function PC(t,e){if(!e||B.parse(t).version)return t;let n=e[t];return n?`${t}@${n}`:t}function CC(t,e){let{name:n,version:r}=B.parse(t),s=Aa.join(e,"node_modules",n);if(!Qb(s))return!1;if(!r)return!0;try{let i=JSON.parse(vC(Aa.join(s,"package.json"),"utf-8")).version;return EC(i,r)}catch{return!1}}function Pa(t){let e=new Set,n=/\bimport\s+(?:[\s\S]*?\s+from\s+)?['"]([^./][^'"]*)['"]/g,r;for(;r=n.exec(t);){let s=r[1];if(s.includes(":"))continue;let i=B.rootOf(s);TC.has(i)||e.add(i)}return[...e]}var AC,TC,OC,Ud=S(()=>{"use strict";yt();AC=kC(SC),TC=new Set(xC),OC=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});import*as Be from"fs/promises";import*as _e from"path";function kr(t,e){let n=_e.resolve(e,t),r=_e.normalize(e),s=_e.normalize(n);if(s!==r&&!s.startsWith(r+_e.sep))throw new Error("Path traversal detected - access denied");return n}async function Ks(t,e){return Be.readFile(kr(t,e))}async function Ca(t,e,n){let r=kr(t,n);await Be.mkdir(_e.dirname(r),{recursive:!0}),await Be.writeFile(r,typeof e=="string"?e:Buffer.from(e))}async function _a(t,e){let n=kr(t,e),r=await Be.readdir(n,{withFileTypes:!0});return Promise.all(r.map(async s=>{let i=await Be.stat(_e.join(n,s.name)).then(o=>o.mtimeMs).catch(()=>0);return{name:s.name,dir:s.isDirectory(),mtime:i}}))}async function Ra(t,e){let n=kr(t,e);if(_e.normalize(n)===_e.normalize(e))throw new Error("Cannot remove the bulb's folder itself: remove its contents instead");await Be.rm(n,{recursive:!0})}var qd=S(()=>{"use strict"});async function Zb(t){let e=gt(t.provider,t.model);if(typeof e=="string")throw new Error(e);let n=await Jt(e,t);if(!n.ok){let r=await pr(n,e.protocol);throw new Error(r.message)}return{response:n,protocol:e.protocol}}async function _C(t){let{response:e,protocol:n}=await Zb(t);return hr(e,n)}async function*RC(t){let{response:e,protocol:n}=await Zb(t);yield*Sn(e,n)}function ew(t){let e=Object.assign(_C,{stream:RC}),n={read:async r=>{let s=await Ks(r,t);try{return new TextDecoder("utf-8",{fatal:!0}).decode(s)}catch{throw new Error(`File is not valid UTF-8 text: ${r} \u2014 use tb.fs.readBytes() for binary files.`)}},readBytes:async r=>new Uint8Array(await Ks(r,t)),write:async(r,s)=>(await Ca(r,s,t),!0),list:async(r=".")=>_a(r,t),remove:async r=>(await Ra(r,t),!0)};globalThis.tb=Object.freeze({log:(...r)=>{console.log(...r)},ai:e,fs:n,dir:t,models:()=>mt(),aiAccess:sa,mode:Vn.local})}var tw=S(()=>{"use strict";Ut();Q();fa();bn();qd()});import*as Yt from"fs/promises";import*as ue from"path";import{pathToFileURL as IC}from"url";async function nw(t){let n=(await Yt.readdir(t)).find(r=>r.endsWith(".bulb.md"));return n?ue.join(t,n):void 0}function xr(t){let e=ue.resolve(t);return ue.join(ue.dirname(e),ue.basename(e).replace(/\.bulb\.md$/,""))}function Er(t){let[e,n,r,s]=t.split(ue.sep).slice(-4);if(!(e!=="typebulbs"||n!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function Ze(t){let e=await Yt.readFile(t,"utf-8"),n=Mn(e),r=or(n);return{bulb:r,config:Br(r.config),warnings:Tp(e),starts:n.starts}}function Jd(t){let e=ue.basename(t).replace(/\.bulb\.md$/i,"");return ue.join(ue.dirname(t),".typebulb",`${e}.server.mjs`)}async function Hs(t,e,n,r){let s=Od(t,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;n&&(i=await vp(i,n));let o=ue.join(ue.dirname(e),".typebulb");await Yt.mkdir(o,{recursive:!0});let a=Pa(i);a.length>0&&await Oa(a,o,r);let l=Jd(e);return await Yt.writeFile(l,i,"utf-8"),ew(xr(e)),await import(`${IC(l).href}?t=${Date.now()}`)}async function Wd(t,e,n,r){let{bulb:s,config:i,starts:o}=await Ze(t),a=Ao(s.data),l,c=m=>{l??=m instanceof Error?m.message:String(m)};try{Ab(s.code,i.dependencies??{})}catch(m){c(m)}let f=Od(s.code,{jsxImportSource:i.ts?.jsxImportSource});f.error&&c(f.error);let d={imports:{}};if(!l)try{({importMap:d}=await Sa.buildImportMap(f.code,i.dependencies??{},r?new Set([r.name]):void 0))}catch(m){c(`Dependency resolution failed: ${m instanceof Error?m.message:String(m)}`)}l&&console.error("Build error:",l),r&&(d.imports[r.name]=r.entryUrl);let u=Gb({name:s.name,code:l?"":f.code,css:s.css,html:s.html,data:a,insight:s.insight,importMap:d,dir:xr(t),watch:e,source:{file:ue.basename(t),codeLine:o.get("code.tsx")??1},bulbKey:xs(t),compileError:l}),p;return s.server&&n&&(p=await Hs(s.server,t,r,i.dependencies)),{html:u,bulb:s,serverExports:p,buildError:l}}var An,St=S(()=>{"use strict";Os();Eb();Tb();jd();Xb();Ud();ki();Ye();tw();An=t=>ue.join(xr(t),"assets")});import*as Re from"fs/promises";import*as je from"path";import{createHash as NC}from"crypto";async function Hd(t,e,n){let r=[...t],s=async()=>{for(let i=r.shift();i!==void 0;i=r.shift())await n(i)};await Promise.all(Array.from({length:Math.min(e,t.length)},s))}function Ar(t){try{return JSON.parse(t).error||t}catch{return t}}async function Yd(t,e){try{let n=await fetch(zs(t),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});return n.ok?n.headers.get("content-type")?.includes("json")?{entries:await n.json()}:{error:"manifest response is not JSON \u2014 wrong origin?"}:{error:`manifest request failed (${n.status}): ${Ar(await n.text())}`}}catch(n){return{error:n instanceof Error?n.message:String(n)}}}function Vd(t,e){xe(e);let n=process.env.TYPEBULB_ORIGIN||$C;try{return $a(t,process.cwd(),n)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function $a(t,e,n){if(/^https?:\/\//i.test(t)){let i=new URL(t),o=i.pathname.split("/").filter(Boolean).map(decodeURIComponent),a=o[0]==="api"&&o[1]==="scripts"?o.slice(2):o;if(a[0]!=="u"||!a[1]||!a[2])throw new Error(`Not a bulb URL: ${t}
1729
+ Expected <origin>/u/<user>/<slug>`);let l=a[1],c=a[2].replace(/(\.bulb)?\.md$/,"");return{origin:i.origin,userSlug:l,slug:c,dest:je.join(e,Ia(l,c))}}let r=je.resolve(e,t),s=Er(r);if(!s)throw new Error(`Not a conventional bulb path: ${t}
1730
+ A pull target must be a bulb URL, or a local file at typebulbs/u/<user>/<slug>.bulb.md \u2014 the path is its remote identity.`);return{origin:n,...s,dest:r}}async function LC(t,e){let n=await Yd(t,e);if("error"in n||!n.entries.length)return{kind:"none"};let r=n.entries,s=An(t.dest),i=[],o=[],a=0;for(let l of r){let c=await Re.readFile(je.join(s,...l.path.split("/"))).catch(()=>{});c===void 0?i.push(l.path):zd(c)===l.md5?a++:e.force?i.push(l.path):o.push(l.path)}return o.length?{kind:"conflict",paths:o}:{kind:"plan",toGet:i,unchanged:a}}async function MC(t,e,n){let r=An(t.dest),s=[],i=0;return await Hd(e.toGet,4,async o=>{try{let a=await fetch(`${zs(t)}/${Na(o)}`,{headers:n.token?{Authorization:`Bearer ${n.token}`}:{},signal:AbortSignal.timeout(n.timeoutMs??3e4)});if(!a.ok){s.push(`${o}: HTTP ${a.status}`);return}let l=je.join(r,...o.split("/"));await Re.mkdir(je.dirname(l),{recursive:!0}),await Re.writeFile(l,new Uint8Array(await a.arrayBuffer())),i++}catch(a){s.push(`${o}: ${a instanceof Error?a.message:String(a)}`)}}),{downloaded:i,unchanged:e.unchanged,errors:s}}async function La(t,e={}){let n=await fetch(Kd(t),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});if(!n.ok)return{kind:"http-error",status:n.status};let r=n.headers.get("content-type");if(!r?.includes("text/markdown"))return{kind:"not-markdown",contentType:r??void 0};let s=await n.text(),i;try{i=await Re.readFile(t.dest,"utf-8")}catch{}let o=i!==void 0&&DC(i,s);if(i!==void 0&&!o&&!e.force){let{mtime:c}=await Re.stat(t.dest);return{kind:"conflict",dest:t.dest,localMtime:c,remoteLastModified:n.headers.get("last-modified")??void 0}}let a=await LC(t,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:t.dest,paths:a.paths};if(!o){await Re.mkdir(je.dirname(t.dest),{recursive:!0}),await Re.writeFile(t.dest,s);let c=new Date(n.headers.get("last-modified")??"");isNaN(c.getTime())||await Re.utimes(t.dest,new Date,c)}let l=a.kind==="plan"?await MC(t,a,e):void 0;return o?{kind:"up-to-date",dest:t.dest,assets:l}:{kind:"written",dest:t.dest,created:i===void 0,assets:l}}function DC(t,e){let n=i=>i.replace(/\r\n/g,`
1731
+ `),r=We(n(t)),s=We(n(e));return!r||!s?n(t)===n(e):r.frontmatter.name===s.frontmatter.name&&Je.every(i=>(r.files.get(ce[i].path)||"")===(s.files.get(ce[i].path)||""))}async function sw(t,e){t||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let n=Vd(t,e.mode),r=`${n.origin}/u/${n.userSlug}/${n.slug}`,s;try{s=await La(n,{force:e.force,token:process.env.TYPEBULB_TOKEN})}catch(o){console.error(`Could not reach ${n.origin}: ${o instanceof Error?o.message:String(o)}`),process.exitCode=1;return}let i=je.relative(process.cwd(),n.dest)||n.dest;switch(s.kind){case"written":console.log(`pulled ${r} \u2192 ${i}${s.created?"":" (overwritten)"}`),rw(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),rw(s.assets);return;case"conflict":console.error(`Refusing to overwrite ${i} \u2014 it differs from ${r}
1732
1732
  local file modified ${s.localMtime.toISOString()}
1733
1733
  remote last saved ${s.remoteLastModified??"unknown"}
1734
1734
  Re-run with --force to overwrite the local file.`),process.exitCode=1;return;case"asset-conflict":console.error(`Refusing to overwrite local assets that differ from the hosted copies:
1735
1735
  `+s.paths.map(o=>` assets/${o}`).join(`
1736
1736
  `)+`
1737
- Re-run with --force to overwrite them.`),process.exitCode=1;return;case"http-error":s.status===404?console.error(`Bulb not found: ${r}`):s.status===401||s.status===403?console.error(`This bulb is private (${s.status}) \u2014 pulling it needs a TYPEBULB_TOKEN for its owner.`):console.error(`Pull failed: ${n.origin} responded ${s.status}`),process.exitCode=1;return;case"not-markdown":console.error(`${r}.md did not return bulb markdown (got ${s.contentType??"no content-type"}) \u2014 is ${n.origin} a typebulb host?`),process.exitCode=1}}function tw(t){if(!(!t||!t.downloaded&&!t.errors.length)){console.log(`assets: ${t.downloaded} downloaded${t.unchanged?`, ${t.unchanged} unchanged`:""}`);for(let e of t.errors)console.error(` asset failed \u2014 ${e} (a re-pull retries just the missing ones)`);t.errors.length&&(process.exitCode=1)}}var NC,Ia,Kd,Na,zs,zd,Ma=S(()=>{"use strict";ot();ee();St();NC="https://typebulb.com",Ia=(t,e)=>je.join("typebulbs","u",t,`${e}.bulb.md`),Kd=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}.md`,Na=t=>t.split("/").map(encodeURIComponent).join("/"),zs=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}/assets`;zd=t=>IC("md5").update(t).digest("hex")});import*as at from"fs/promises";import*as Ys from"path";async function rw(t,e=""){let n=await at.readdir(t,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of n)s.isDirectory()?r.push(...await rw(Ys.join(t,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function DC(t,e){let n=e.timeoutMs??3e4,r=zs(t),s={Authorization:`Bearer ${e.token}`},i=An(t.dest);if(!await at.stat(i).then(m=>m.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await rw(i),a=await Yd(t,{token:e.token,timeoutMs:n});if("error"in a)return{kind:"sync-error",message:a.error};let l=a.entries;if(!o.length&&!l.length)return{kind:"skipped"};let c=new Map(l.map(m=>[m.path,m.md5])),f=new Set(o),d=l.map(m=>m.path).filter(m=>!f.has(m)),u=0,p=0;try{await Hd(o,4,async m=>{let h=await at.readFile(Ys.join(i,...m.split("/")));if(c.get(m)===zd(h)){p++;return}let g=await fetch(`${r}/${Na(m)}`,{method:"PUT",body:new Uint8Array(h),headers:s,signal:AbortSignal.timeout(n)});if(!g.ok)throw new Error(`upload of '${m}' refused (${g.status}): ${Er(await g.text())}`);u++})}catch(m){return{kind:"sync-error",message:m instanceof Error?m.message:String(m)}}return{kind:"synced",uploaded:u,unchanged:p,toDelete:d,base:Ti(t.userSlug,t.slug)}}async function BC(t,e,n){let r=n.timeoutMs??3e4,s=zs(t),i=[];for(let o of e)try{let a=await fetch(`${s}/${Na(o)}`,{method:"DELETE",headers:{Authorization:`Bearer ${n.token}`},signal:AbortSignal.timeout(r)});if(!a.ok)return{deleted:i,error:`delete of '${o}' refused (${a.status}): ${Er(await a.text())}`};i.push(o)}catch(a){return{deleted:i,error:a instanceof Error?a.message:String(a)}}return{deleted:i}}async function Da(t,e){let n=await at.readFile(t.dest,"utf-8"),{mtime:r}=await at.stat(t.dest),s=await DC(t,{token:e.token,timeoutMs:e.timeoutMs});if(s.kind==="sync-error")return{kind:"asset-error",message:s.message};let i=s.kind==="synced"?{uploaded:s.uploaded,unchanged:s.unchanged,deleted:[],base:s.base}:void 0,o={Authorization:`Bearer ${e.token}`,"Content-Type":"text/markdown; charset=utf-8"};e.force||(o["If-Unmodified-Since"]=r.toUTCString());let a=await fetch(Kd(t),{method:"PUT",body:n,headers:o,signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0}),l=await a.text();if(a.status===409)return{kind:"conflict",message:Er(l),assets:i};if(!a.ok)return{kind:"http-error",status:a.status,message:Er(l),assets:i};let c=JSON.parse(l);if(await at.utimes(t.dest,new Date,new Date(c.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let f=await BC(t,s.toDelete,{token:e.token,timeoutMs:e.timeoutMs});i.deleted=f.deleted,f.error&&(i.pruneError=f.error)}return{kind:"pushed",created:c.created,serverStripped:c.serverStripped,updatedAt:c.updatedAt,assets:i}}async function sw(t,e){t||(console.error("Usage: typebulb push <typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1)),/^https?:\/\//i.test(t)&&(console.error("push takes a local .bulb.md file, not a URL (the path is its remote identity)"),process.exit(1));let n=Vd(t,e.mode),r=process.env.TYPEBULB_TOKEN;r||(console.error("push needs TYPEBULB_TOKEN in your .env \u2014 create one on your typebulb.com settings page."),process.exit(1));let s=`${n.origin}/u/${n.userSlug}/${n.slug}`,i=Ys.relative(process.cwd(),n.dest)||n.dest,o;try{o=await Da(n,{token:r,force:e.force})}catch(a){let l=a instanceof Error?a.message:String(a);console.error(a?.code==="ENOENT"?`File not found: ${i}`:`Could not push to ${n.origin}: ${l}`),process.exitCode=1;return}switch(o.kind!=="asset-error"&&o.assets&&console.log(`assets: ${o.assets.uploaded} uploaded, ${o.assets.unchanged} unchanged \u2192 ${o.assets.base}`),o.kind){case"asset-error":console.error(`assets sync failed: ${o.message}
1737
+ Re-run with --force to overwrite them.`),process.exitCode=1;return;case"http-error":s.status===404?console.error(`Bulb not found: ${r}`):s.status===401||s.status===403?console.error(`This bulb is private (${s.status}) \u2014 pulling it needs a TYPEBULB_TOKEN for its owner.`):console.error(`Pull failed: ${n.origin} responded ${s.status}`),process.exitCode=1;return;case"not-markdown":console.error(`${r}.md did not return bulb markdown (got ${s.contentType??"no content-type"}) \u2014 is ${n.origin} a typebulb host?`),process.exitCode=1}}function rw(t){if(!(!t||!t.downloaded&&!t.errors.length)){console.log(`assets: ${t.downloaded} downloaded${t.unchanged?`, ${t.unchanged} unchanged`:""}`);for(let e of t.errors)console.error(` asset failed \u2014 ${e} (a re-pull retries just the missing ones)`);t.errors.length&&(process.exitCode=1)}}var $C,Ia,Kd,Na,zs,zd,Ma=S(()=>{"use strict";ot();Q();St();$C="https://typebulb.com",Ia=(t,e)=>je.join("typebulbs","u",t,`${e}.bulb.md`),Kd=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}.md`,Na=t=>t.split("/").map(encodeURIComponent).join("/"),zs=t=>`${t.origin}/u/${encodeURIComponent(t.userSlug)}/${encodeURIComponent(t.slug)}/assets`;zd=t=>NC("md5").update(t).digest("hex")});import*as at from"fs/promises";import*as Ys from"path";async function iw(t,e=""){let n=await at.readdir(t,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of n)s.isDirectory()?r.push(...await iw(Ys.join(t,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function BC(t,e){let n=e.timeoutMs??3e4,r=zs(t),s={Authorization:`Bearer ${e.token}`},i=An(t.dest);if(!await at.stat(i).then(m=>m.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await iw(i),a=await Yd(t,{token:e.token,timeoutMs:n});if("error"in a)return{kind:"sync-error",message:a.error};let l=a.entries;if(!o.length&&!l.length)return{kind:"skipped"};let c=new Map(l.map(m=>[m.path,m.md5])),f=new Set(o),d=l.map(m=>m.path).filter(m=>!f.has(m)),u=0,p=0;try{await Hd(o,4,async m=>{let h=await at.readFile(Ys.join(i,...m.split("/")));if(c.get(m)===zd(h)){p++;return}let g=await fetch(`${r}/${Na(m)}`,{method:"PUT",body:new Uint8Array(h),headers:s,signal:AbortSignal.timeout(n)});if(!g.ok)throw new Error(`upload of '${m}' refused (${g.status}): ${Ar(await g.text())}`);u++})}catch(m){return{kind:"sync-error",message:m instanceof Error?m.message:String(m)}}return{kind:"synced",uploaded:u,unchanged:p,toDelete:d,base:Ti(t.userSlug,t.slug)}}async function jC(t,e,n){let r=n.timeoutMs??3e4,s=zs(t),i=[];for(let o of e)try{let a=await fetch(`${s}/${Na(o)}`,{method:"DELETE",headers:{Authorization:`Bearer ${n.token}`},signal:AbortSignal.timeout(r)});if(!a.ok)return{deleted:i,error:`delete of '${o}' refused (${a.status}): ${Ar(await a.text())}`};i.push(o)}catch(a){return{deleted:i,error:a instanceof Error?a.message:String(a)}}return{deleted:i}}async function Da(t,e){let n=await at.readFile(t.dest,"utf-8"),{mtime:r}=await at.stat(t.dest),s=await BC(t,{token:e.token,timeoutMs:e.timeoutMs});if(s.kind==="sync-error")return{kind:"asset-error",message:s.message};let i=s.kind==="synced"?{uploaded:s.uploaded,unchanged:s.unchanged,deleted:[],base:s.base}:void 0,o={Authorization:`Bearer ${e.token}`,"Content-Type":"text/markdown; charset=utf-8"};e.force||(o["If-Unmodified-Since"]=r.toUTCString());let a=await fetch(Kd(t),{method:"PUT",body:n,headers:o,signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0}),l=await a.text();if(a.status===409)return{kind:"conflict",message:Ar(l),assets:i};if(!a.ok)return{kind:"http-error",status:a.status,message:Ar(l),assets:i};let c=JSON.parse(l);if(await at.utimes(t.dest,new Date,new Date(c.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let f=await jC(t,s.toDelete,{token:e.token,timeoutMs:e.timeoutMs});i.deleted=f.deleted,f.error&&(i.pruneError=f.error)}return{kind:"pushed",created:c.created,serverStripped:c.serverStripped,updatedAt:c.updatedAt,assets:i}}async function ow(t,e){t||(console.error("Usage: typebulb push <typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1)),/^https?:\/\//i.test(t)&&(console.error("push takes a local .bulb.md file, not a URL (the path is its remote identity)"),process.exit(1));let n=Vd(t,e.mode),r=process.env.TYPEBULB_TOKEN;r||(console.error("push needs TYPEBULB_TOKEN in your .env \u2014 create one on your typebulb.com settings page."),process.exit(1));let s=`${n.origin}/u/${n.userSlug}/${n.slug}`,i=Ys.relative(process.cwd(),n.dest)||n.dest,o;try{o=await Da(n,{token:r,force:e.force})}catch(a){let l=a instanceof Error?a.message:String(a);console.error(a?.code==="ENOENT"?`File not found: ${i}`:`Could not push to ${n.origin}: ${l}`),process.exitCode=1;return}switch(o.kind!=="asset-error"&&o.assets&&console.log(`assets: ${o.assets.uploaded} uploaded, ${o.assets.unchanged} unchanged \u2192 ${o.assets.base}`),o.kind){case"asset-error":console.error(`assets sync failed: ${o.message}
1738
1738
  push refused: the bulb text was not pushed.`),process.exitCode=1;return;case"pushed":{console.log(`pushed ${i} \u2192 ${s}/full`),o.created&&(console.log(" created a new bulb, unlisted \u2014 nothing existed at this URL before"),console.log(" if you renamed this file, its previous bulb is still live at the old URL")),o.serverStripped&&console.log("note: the server.ts block was stripped on the server copy (CLI-only); your local file is untouched.");for(let a of o.assets?.deleted??[])console.log(` deleted ${a} (no longer in assets/)`);o.assets?.pruneError&&console.log(`note: asset cleanup incomplete \u2014 ${o.assets.pruneError}; the next push will retry.`);return}case"conflict":console.error(`${o.message}
1739
1739
  pull to see the remote: typebulb pull ${i}
1740
- or overwrite it: typebulb push ${i} --force`),process.exitCode=1;return;case"http-error":o.status===401?console.error("The server rejected TYPEBULB_TOKEN (401) \u2014 it may be revoked; mint a new one on the settings page."):console.error(`Push failed: ${n.origin} responded ${o.status}${o.message?` \u2014 ${o.message}`:""}`),process.exitCode=1}}var Gd=S(()=>{"use strict";ee();Ma();St()});var Tn=S(()=>{"use strict";Le();Xy();fn();Qy();td();rb();ib();_s();bn();bn();fa();Td();Le();Ma();Gd();ot();Ye()});import{existsSync as jC,mkdirSync as FC,readFileSync as UC,rmSync as qC,writeFileSync as JC}from"fs";import{homedir as WC}from"os";import*as Ar from"path";function YC(){return zC.replace('"__TB_SKILL_PATH__"',JSON.stringify($s())).replace('"__TB_BIN_PATH__"',JSON.stringify(sr()))}function iw(){try{if(!jC(Xd()))return}catch{return}try{let t=KC(),e=YC(),n;try{n=UC(t,"utf8")}catch{}n!==e&&(FC(Ar.dirname(t),{recursive:!0}),JC(t,e))}catch{}for(let t of HC())try{qC(t,{force:!0})}catch{}}var Xd,KC,HC,zC,ow=S(()=>{"use strict";Tn();Xd=()=>Ar.join(WC(),".pi","agent"),KC=()=>Ar.join(Xd(),"extensions","typebulb.ts"),HC=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(t=>Ar.join(Xd(),"extensions",t)),zC=String.raw`// Generated by typebulb — do not edit; overwritten on each run.
1740
+ or overwrite it: typebulb push ${i} --force`),process.exitCode=1;return;case"http-error":o.status===401?console.error("The server rejected TYPEBULB_TOKEN (401) \u2014 it may be revoked; mint a new one on the settings page."):console.error(`Push failed: ${n.origin} responded ${o.status}${o.message?` \u2014 ${o.message}`:""}`),process.exitCode=1}}var Gd=S(()=>{"use strict";Q();Ma();St()});var Tn=S(()=>{"use strict";Le();Zy();fn();eb();td();ib();ab();_s();bn();bn();fa();Td();Le();Ma();Gd();ot();Ye()});import{existsSync as FC,mkdirSync as UC,readFileSync as qC,rmSync as JC,writeFileSync as WC}from"fs";import{homedir as KC}from"os";import*as Tr from"path";function VC(){return YC.replace('"__TB_SKILL_PATH__"',JSON.stringify($s())).replace('"__TB_BIN_PATH__"',JSON.stringify(ir()))}function aw(){try{if(!FC(Xd()))return}catch{return}try{let t=HC(),e=VC(),n;try{n=qC(t,"utf8")}catch{}n!==e&&(UC(Tr.dirname(t),{recursive:!0}),WC(t,e))}catch{}for(let t of zC())try{JC(t,{force:!0})}catch{}}var Xd,HC,zC,YC,lw=S(()=>{"use strict";Tn();Xd=()=>Tr.join(KC(),".pi","agent"),HC=()=>Tr.join(Xd(),"extensions","typebulb.ts"),zC=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(t=>Tr.join(Xd(),"extensions",t)),YC=String.raw`// Generated by typebulb — do not edit; overwritten on each run.
1741
1741
  import { spawn } from "node:child_process";
1742
1742
  import { existsSync } from "node:fs";
1743
1743
 
@@ -2005,23 +2005,23 @@ export default function (pi) {
2005
2005
  try { pi.on("session_shutdown", () => { stopping = true; if (watcher) { try { watcher.kill(); } catch (e) {} watcher = null; } for (const c of pending) { try { c.kill(); } catch (e) {} } pending.clear(); }); } catch (e) {}
2006
2006
  } catch (e) { logErr("load", e && e.message); }
2007
2007
  }
2008
- `});function Y(t){return t?.message??String(t)}var V,Vt=S(()=>{"use strict";V=process.cwd()});import{spawn as aw}from"child_process";import{StringDecoder as VC}from"string_decoder";function t_(t,e){let n=new VC("utf8"),r="";t.on("data",s=>{r+=typeof s=="string"?s:n.write(s);let i;for(;(i=r.indexOf(`
2009
- `))>=0;){let o=r.slice(0,i);r=r.slice(i+1),o.endsWith("\r")&&(o=o.slice(0,-1)),o&&e(o)}})}var GC,lw,cw,Qd,uw,XC,QC,ZC,dw,e_,Ba,ja,fw,pw=S(()=>{"use strict";Vt();GC=3e4,lw=18e4,cw="starting pi\u2026",Qd=5e3,uw=2e3,XC=2e3,QC=12e4,ZC=8e3,dw=15e3,e_=new Set(["get_state","get_commands","get_available_models","set_model","set_thinking_level","cycle_thinking_level","get_session_stats","compact","set_auto_compaction","get_fork_messages","fork","clone","set_session_name","export_html","bash","abort_bash"]),Ba=new Set;process.on("exit",()=>{for(let t of Ba)try{t.kill()}catch{}});ja=class{#t;#l=!1;#n=0;#i=!1;#h=0;#s=!1;#d=null;#o=[];#c=null;#e=null;#r=null;#u=new Map;#a=[];#b=null;#k=null;#w=null;#m;#g;#v="";#_=1;#f=new Map;#x;#S;constructor(e,n,r=(s,i)=>aw(s,{cwd:i,shell:!0,stdio:["pipe","pipe","pipe"],env:{...process.env,TYPEBULB_MIRROR:"1"}})){if(this.#x=new Promise(o=>{this.#S=o}),n?.includes('"')){this.#g="session path contains a quote \u2014 cannot drive it",this.#S();return}let s=n?`pi --mode rpc --session "${n}"`:"pi --mode rpc",i;try{i=r(s,e)}catch(o){this.#g=`could not start pi: ${Y(o)}`,this.#S();return}this.#t=i,this.#m=n,this.#i=!0,this.#h=Date.now()+lw,this.#e={text:cw,kind:"info"},Ba.add(i),i.stdout&&t_(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#v=(this.#v+o.toString()).slice(-XC)}),i.on("error",o=>this.#P(`could not start pi: ${o.message}`)),i.on("exit",o=>{this.#t===i&&this.#P(o?`pi exited (code ${o})${this.#v.trim()?`: ${this.#v.trim()}`:""}`:"pi exited"),Ba.delete(i),this.#S()}),this.#p({type:"get_state"}).then(o=>{let a=o.data?.sessionFile;typeof a=="string"&&a&&(this.#m=a);let l=o.data?.model;l&&typeof l.id=="string"&&l.id&&(this.#w=l.id)}).catch(()=>{}).finally(()=>this.#R())}#R(){this.#i&&(this.#i=!1,this.#e?.text===cw&&(this.#e=null),this.#r&&(this.#r.until=Date.now()+dw),!this.#l&&Date.now()<this.#n&&(this.#n=Date.now()+Qd),this.#T())}get streaming(){return this.#l||Date.now()<this.#n}get draft(){return this.#d}get echo(){return this.#c}get queue(){return this.#b}get stats(){return this.#k}get model(){return this.#w}get sessionFile(){return this.#m}get error(){return this.#g}get status(){if(this.#e)return this.#e;if(this.#r){if(Date.now()<this.#r.until)return{text:this.#r.text,kind:this.#r.kind};this.#r=null}return this.#u.size?{text:[...this.#u.values()].join(" \xB7 "),kind:"info"}:null}get dialog(){let e=Date.now();for(;this.#a.length;){let n=this.#a[0];if(e<n.until)return n.req;this.#a.shift(),n.ownTimeout||this.#E({type:"extension_ui_response",id:n.req.id,cancelled:!0})}return null}notice(e,n){this.#y(e,n)}respondUi(e,n){let r=this.#a.findIndex(o=>o.req.id===e);if(r<0)return{ok:!1,error:"dialog expired or already answered"};let[s]=this.#a.splice(r,1),i={type:"extension_ui_response",id:e};return n.cancelled?i.cancelled=!0:s.req.method==="confirm"?i.confirmed=!!n.confirmed:i.value=n.value??"",this.#E(i),{ok:!0}}async rpc(e){if(!e_.has(e.type))return{ok:!1,error:`command not allowed: ${e.type}`};try{let n=await this.#p(e);if(n.success&&e.type==="set_model"){let r=n.data?.id;typeof r=="string"&&r&&(this.#w=r)}if(n.success&&(e.type==="fork"||e.type==="clone")){try{let s=(await this.#p({type:"get_state"})).data?.sessionFile;typeof s=="string"&&s&&(this.#m=s)}catch{}return{ok:!0,data:{...n.data??{},sessionFile:this.#m}}}return n.success?{ok:!0,data:n.data}:{ok:!1,error:n.error??`pi rejected ${e.type}`}}catch(n){return{ok:!1,error:Y(n)}}}async send(e,n){let r=this.streaming,s=e.trimStart().startsWith("/"),i=r?s?{type:"prompt",message:e,streamingBehavior:n?.followUp?"followUp":"steer"}:{type:n?.followUp?"follow_up":"steer",message:e}:{type:"prompt",message:e},o=l=>{r||(this.#n=l,s||(this.#c=e))};if(this.#i)return this.#p(i).catch(()=>{}),o(this.#h+Qd),{ok:!0};let a;try{a=await this.#p(i)}catch(l){return{ok:!1,error:Y(l)}}return a.success&&o(Date.now()+Qd),a.success?{ok:!0}:{ok:!1,error:a.error??"pi rejected the message"}}async stop(){if(this.#t){if(this.#i){this.#E({type:"abort"}),this.#n=0;return}try{await this.#p({type:"abort"})}catch{}}}clearCompletedDraft(){this.#s||(this.#d=null)}clearEcho(){this.#c=null}async dispose(){let e=this.#t;if(e){if(this.#t=void 0,this.#i=!1,this.#l){try{e.stdin?.write(JSON.stringify({type:"abort"})+`
2010
- `)}catch{}await Promise.race([this.#x,fw(uw)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#x,fw(uw)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{aw("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"})}catch{}else try{e.kill("SIGKILL")}catch{}Ba.delete(e),this.#a=[],this.#C("pi was shut down")}}#E(e){try{this.#t?.stdin?.write(JSON.stringify(e)+`
2008
+ `});function Y(t){return t?.message??String(t)}var V,Vt=S(()=>{"use strict";V=process.cwd()});import{spawn as cw}from"child_process";import{StringDecoder as GC}from"string_decoder";function n_(t,e){let n=new GC("utf8"),r="";t.on("data",s=>{r+=typeof s=="string"?s:n.write(s);let i;for(;(i=r.indexOf(`
2009
+ `))>=0;){let o=r.slice(0,i);r=r.slice(i+1),o.endsWith("\r")&&(o=o.slice(0,-1)),o&&e(o)}})}var XC,uw,dw,Qd,fw,QC,ZC,e_,pw,t_,Ba,ja,hw,mw=S(()=>{"use strict";Vt();XC=3e4,uw=18e4,dw="starting pi\u2026",Qd=5e3,fw=2e3,QC=2e3,ZC=12e4,e_=8e3,pw=15e3,t_=new Set(["get_state","get_commands","get_available_models","set_model","set_thinking_level","cycle_thinking_level","get_session_stats","compact","set_auto_compaction","get_fork_messages","fork","clone","set_session_name","export_html","bash","abort_bash"]),Ba=new Set;process.on("exit",()=>{for(let t of Ba)try{t.kill()}catch{}});ja=class{#t;#l=!1;#n=0;#i=!1;#h=0;#s=!1;#d=null;#o=[];#c=null;#e=null;#r=null;#u=new Map;#a=[];#b=null;#k=null;#w=null;#m;#g;#v="";#_=1;#f=new Map;#x;#S;constructor(e,n,r=(s,i)=>cw(s,{cwd:i,shell:!0,stdio:["pipe","pipe","pipe"],env:{...process.env,TYPEBULB_MIRROR:"1"}})){if(this.#x=new Promise(o=>{this.#S=o}),n?.includes('"')){this.#g="session path contains a quote \u2014 cannot drive it",this.#S();return}let s=n?`pi --mode rpc --session "${n}"`:"pi --mode rpc",i;try{i=r(s,e)}catch(o){this.#g=`could not start pi: ${Y(o)}`,this.#S();return}this.#t=i,this.#m=n,this.#i=!0,this.#h=Date.now()+uw,this.#e={text:dw,kind:"info"},Ba.add(i),i.stdout&&n_(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#v=(this.#v+o.toString()).slice(-QC)}),i.on("error",o=>this.#P(`could not start pi: ${o.message}`)),i.on("exit",o=>{this.#t===i&&this.#P(o?`pi exited (code ${o})${this.#v.trim()?`: ${this.#v.trim()}`:""}`:"pi exited"),Ba.delete(i),this.#S()}),this.#p({type:"get_state"}).then(o=>{let a=o.data?.sessionFile;typeof a=="string"&&a&&(this.#m=a);let l=o.data?.model;l&&typeof l.id=="string"&&l.id&&(this.#w=l.id)}).catch(()=>{}).finally(()=>this.#R())}#R(){this.#i&&(this.#i=!1,this.#e?.text===dw&&(this.#e=null),this.#r&&(this.#r.until=Date.now()+pw),!this.#l&&Date.now()<this.#n&&(this.#n=Date.now()+Qd),this.#T())}get streaming(){return this.#l||Date.now()<this.#n}get draft(){return this.#d}get echo(){return this.#c}get queue(){return this.#b}get stats(){return this.#k}get model(){return this.#w}get sessionFile(){return this.#m}get error(){return this.#g}get status(){if(this.#e)return this.#e;if(this.#r){if(Date.now()<this.#r.until)return{text:this.#r.text,kind:this.#r.kind};this.#r=null}return this.#u.size?{text:[...this.#u.values()].join(" \xB7 "),kind:"info"}:null}get dialog(){let e=Date.now();for(;this.#a.length;){let n=this.#a[0];if(e<n.until)return n.req;this.#a.shift(),n.ownTimeout||this.#E({type:"extension_ui_response",id:n.req.id,cancelled:!0})}return null}notice(e,n){this.#y(e,n)}respondUi(e,n){let r=this.#a.findIndex(o=>o.req.id===e);if(r<0)return{ok:!1,error:"dialog expired or already answered"};let[s]=this.#a.splice(r,1),i={type:"extension_ui_response",id:e};return n.cancelled?i.cancelled=!0:s.req.method==="confirm"?i.confirmed=!!n.confirmed:i.value=n.value??"",this.#E(i),{ok:!0}}async rpc(e){if(!t_.has(e.type))return{ok:!1,error:`command not allowed: ${e.type}`};try{let n=await this.#p(e);if(n.success&&e.type==="set_model"){let r=n.data?.id;typeof r=="string"&&r&&(this.#w=r)}if(n.success&&(e.type==="fork"||e.type==="clone")){try{let s=(await this.#p({type:"get_state"})).data?.sessionFile;typeof s=="string"&&s&&(this.#m=s)}catch{}return{ok:!0,data:{...n.data??{},sessionFile:this.#m}}}return n.success?{ok:!0,data:n.data}:{ok:!1,error:n.error??`pi rejected ${e.type}`}}catch(n){return{ok:!1,error:Y(n)}}}async send(e,n){let r=this.streaming,s=e.trimStart().startsWith("/"),i=r?s?{type:"prompt",message:e,streamingBehavior:n?.followUp?"followUp":"steer"}:{type:n?.followUp?"follow_up":"steer",message:e}:{type:"prompt",message:e},o=l=>{r||(this.#n=l,s||(this.#c=e))};if(this.#i)return this.#p(i).catch(()=>{}),o(this.#h+Qd),{ok:!0};let a;try{a=await this.#p(i)}catch(l){return{ok:!1,error:Y(l)}}return a.success&&o(Date.now()+Qd),a.success?{ok:!0}:{ok:!1,error:a.error??"pi rejected the message"}}async stop(){if(this.#t){if(this.#i){this.#E({type:"abort"}),this.#n=0;return}try{await this.#p({type:"abort"})}catch{}}}clearCompletedDraft(){this.#s||(this.#d=null)}clearEcho(){this.#c=null}async dispose(){let e=this.#t;if(e){if(this.#t=void 0,this.#i=!1,this.#l){try{e.stdin?.write(JSON.stringify({type:"abort"})+`
2010
+ `)}catch{}await Promise.race([this.#x,hw(fw)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#x,hw(fw)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{cw("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"})}catch{}else try{e.kill("SIGKILL")}catch{}Ba.delete(e),this.#a=[],this.#C("pi was shut down")}}#E(e){try{this.#t?.stdin?.write(JSON.stringify(e)+`
2011
2011
  `)}catch{}}#O(){let e=this.#o[this.#o.length-1];this.#d={text:this.#o.filter(n=>n?.kind==="text").map(n=>n.text).join(""),thinking:this.#o.filter(n=>n?.kind==="thinking").map(n=>n.text).join(`
2012
- `),tool:e?.kind==="tool"?e.name:void 0}}#A(e){let n=Array.isArray(e?.content)?e.content:[];this.#o=n.map(r=>({kind:r.type==="thinking"?"thinking":r.type==="toolCall"?"tool":"text",text:(r.type==="thinking"?r.thinking:r.text)??"",name:r.name})),this.#O()}#y(e,n){let r=e.length>200?e.slice(0,200)+"\u2026":e;r&&(this.#r={text:r,kind:n,until:Date.now()+(n==="info"?ZC:dw)})}#T(){this.#p({type:"get_session_stats"}).then(e=>{if(!e.success||!e.data)return;let n=e.data;this.#k={cost:typeof n.cost=="number"?n.cost:0,contextTokens:typeof n.contextUsage?.tokens=="number"?n.contextUsage.tokens:null,contextPercent:typeof n.contextUsage?.percent=="number"?n.contextUsage.percent:null}}).catch(()=>{})}#p(e){let n=this.#t;if(!n?.stdin?.writable)return Promise.reject(new Error(this.#g??"pi is not running"));let r=this.#i?lw:GC,s=`tb-${this.#_++}`;return new Promise((i,o)=>{let a=setTimeout(()=>{this.#f.delete(s),o(new Error(`pi did not respond (${Math.round(r/1e3)}s)`))},r);a.unref?.(),this.#f.set(s,{resolve:i,timer:a});try{n.stdin.write(JSON.stringify({id:s,...e})+`
2013
- `)}catch(l){clearTimeout(a),this.#f.delete(s),o(new Error(Y(l)))}})}#I(e){let n;try{n=JSON.parse(e)}catch{return}switch(n.type){case"response":{let r=n,s=r.id?this.#f.get(r.id):void 0;s&&(this.#f.delete(r.id),clearTimeout(s.timer),s.resolve(r));return}case"agent_start":this.#l=!0,this.#n=0;return;case"agent_end":this.#l=!1,this.#n=0,this.#s=!1,this.#e=null,this.#b=null,this.#T();return;case"message_start":{let r=n.message;if(r?.role!=="assistant")return;this.#s=!0,this.#A(r);return}case"message_update":{if(!this.#s)return;if(n.message){this.#A(n.message);return}let r=n.assistantMessageEvent;if(!r||typeof r.contentIndex!="number")return;let s=r.type.startsWith("thinking")?"thinking":r.type.startsWith("toolcall")?"tool":"text",i=this.#o[r.contentIndex]??={kind:s,text:""};i.kind=s,typeof r.delta=="string"&&s!=="tool"&&(i.text+=r.delta),typeof r.content=="string"&&(i.text=r.content),r.toolCall?.name&&(i.name=r.toolCall.name),this.#O();return}case"message_end":if(!this.#s)return;n.message&&this.#A(n.message),this.#s=!1;return;case"auto_retry_start":this.#e={text:`retrying after a transient error (attempt ${Number(n.attempt)||1}/${Number(n.maxAttempts)||"?"})\u2026`,kind:"warning"};return;case"auto_retry_end":this.#e=null,n.success===!1&&this.#y(`retries exhausted: ${String(n.finalError??"unknown error")}`,"error");return;case"compaction_start":this.#e={text:"compacting context\u2026",kind:"info"};return;case"compaction_end":{this.#e=null;let r=n.result;typeof n.errorMessage=="string"&&n.errorMessage?this.#y(`compaction failed: ${n.errorMessage}`,"error"):r?.tokensBefore&&this.#y(`compacted: ~${Math.round(r.tokensBefore/1e3)}k \u2192 ~${Math.round((r.estimatedTokensAfter??0)/1e3)}k tokens`,"info"),this.#T();return}case"queue_update":{let r=Array.isArray(n.steering)?n.steering.map(String):[],s=Array.isArray(n.followUp)?n.followUp.map(String):[];this.#b=r.length||s.length?{steering:r,followUp:s}:null;return}case"extension_ui_request":{let r=String(n.method??"");if(r==="select"||r==="confirm"||r==="input"||r==="editor"){let s=typeof n.timeout=="number"&&n.timeout>0?n.timeout:void 0;this.#a.push({req:{id:String(n.id??""),method:r,title:typeof n.title=="string"?n.title:void 0,message:typeof n.message=="string"?n.message:void 0,options:Array.isArray(n.options)?n.options.map(String):void 0,placeholder:typeof n.placeholder=="string"?n.placeholder:void 0,prefill:typeof n.prefill=="string"?n.prefill:void 0},until:Date.now()+(s??QC),ownTimeout:s!==void 0})}else if(r==="notify"){let s=n.notifyType==="warning"?"warning":n.notifyType==="error"?"error":"info";this.#y(String(n.message??""),s),console.log(`[composer] pi extension: ${String(n.message??"")}`)}else if(r==="setStatus"){let s=String(n.statusKey??"");typeof n.statusText=="string"&&n.statusText?this.#u.set(s,n.statusText):this.#u.delete(s)}return}default:return}}#P(e){this.#g=e,this.#i=!1,this.#l=!1,this.#n=0,this.#s=!1,this.#d=null,this.#o=[],this.#c=null,this.#e=null,this.#r=null,this.#u.clear(),this.#a=[],this.#b=null,this.#k=null,this.#w=null,this.#t=void 0,this.#C(e)}#C(e){for(let[,n]of this.#f)clearTimeout(n.timer),n.resolve({type:"response",success:!1,error:e});this.#f.clear()}},fw=t=>new Promise(e=>{setTimeout(e,t).unref?.()})});import{existsSync as hw,readFileSync as n_,realpathSync as r_}from"fs";import{join as On,dirname as bw,resolve as s_}from"path";import{homedir as mw}from"os";function o_(t,e){let n=On(t,".pi");if(i_.some(s=>hw(On(n,s))))return!0;let r=On(e,".agents","skills");for(let s=t;;){let i=On(s,".agents","skills");if(i!==r&&hw(i))return!0;let o=bw(s);if(o===s)return!1;s=o}}function a_(t,e){for(let n=e;;){if(t[n]===!0||t[n]===!1)return!0;let r=bw(n);if(r===n)return!1;n=r}}function ww(t,e){try{let n=e?.agentDir??On(mw(),".pi","agent"),r=gw(e?.home??process.env.HOME??mw()),s=gw(s_(t));if(!o_(s,r))return null;let i=yw(On(n,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||a_(yw(On(n,"trust.json")),s)?null:"pi has no trust decision for this project \u2014 running untrusted; run `pi` once in a terminal to grant it"}catch{return null}}var i_,gw,yw,vw=S(()=>{"use strict";i_=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],gw=t=>{try{return r_(t)}catch{return t}},yw=t=>{try{return JSON.parse(n_(t,"utf8"))}catch{return{}}}});import{statSync as l_,openSync as c_,readSync as u_,closeSync as d_,existsSync as kw}from"fs";import{join as Fa}from"path";import{homedir as Zd}from"os";import{execFile as f_}from"child_process";async function h_(t){let e=Fa(Zd(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let n of["fd","fdfind",...kw(e)?[e]:[]]){let r=await new Promise(s=>{f_(n,["--base-directory",t,"--type","f","--follow","--hidden","--exclude",".git"],{maxBuffer:67108864},(i,o)=>s(i?null:o))});if(r!==null)return r.split(`
2014
- `).filter(Boolean).map(s=>s.replace(/\\/g,"/"))}return null}function m_(t){return`--${t.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function Sw(t){return t.type==="message"?g_(t.message?.role):t.type==="custom_message"?t.display!==!1:!1}var p_,g_,Tr,ef=S(()=>{"use strict";ws();Io();No();ow();pw();vw();p_=Fa(Zd(),".pi","agent","sessions");g_=t=>t==="user"||t==="assistant"||t==="toolResult"||t==="bashExecution";Tr=class extends Bt{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return kw(Fa(Zd(),".pi","agent"))}ensureHarnessSupport(){iw()}createDriver(e,n){let r=new ja(e,n),s=ww(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return h_(e)}sessionsDir(e){return Fa(p_,m_(e))}listSessionFiles(e){return Ro(this.sessionsDir(e))}parseEntry(e){let n;try{n=JSON.parse(e)}catch{return null}return!n||n.type==="session"||!n.id?null:n}idOf(e){return e.id}parentOf(e){return e.parentId??void 0}timestampOf(e){return e.timestamp}isSidechain(e){return!1}isLeafType(e){return Sw(e)}isRecoveryNoise(e){return!1}apply(e,n){let r=[];if(e.type==="custom_message"){if(e.display===!1)return{events:r};let i=this.contentText(e.content).trim();return i&&r.push({type:"user",text:i}),{events:r}}if(e.type!=="message"||!e.message)return{events:r};let s=e.message;if(s.role==="user"){let i=this.contentText(s.content).trim();return i&&r.push({type:"user",text:i}),{events:r}}if(s.role==="toolResult"){let i=this.contentText(s.content);return r.push({type:"tool_result",id:s.toolCallId??"",content:i,isError:!!s.isError,digest:$e(i)}),{events:r}}if(s.role==="bashExecution")return s.command&&!s.excludeFromContext&&r.push({type:"user",text:`$ ${s.command}`}),{events:r};if(s.role==="assistant"){let i=Array.isArray(s.content)?s.content:[],o=i.filter(u=>u.type==="text").map(u=>u.text??"").join(""),a=i.filter(u=>u.type==="thinking").map(u=>u.thinking??"").join(`
2015
- `),l=i.filter(u=>u.type==="toolCall").map(u=>({id:u.id??"",name:u.name??"",input:u.arguments??{}}));if(o||a||l.length){let u=Date.parse(e.timestamp??""),p=!isNaN(u)&&u>=n;r.push({type:"assistant",text:o,thinking:a,tools:l,live:p})}let c=s.usage,f=c?(c.input??0)+(c.output??0)+(c.cacheRead??0)+(c.cacheWrite??0):0,d=c&&f>0&&s.stopReason!=="aborted"&&s.stopReason!=="error"?{in:c.input??0,out:c.output??0,cached:c.cacheRead??0,cacheCreate:c.cacheWrite??0}:void 0;return{events:r,usage:d,model:s.model,cost:c?.cost?.total}}return{events:r}}chainWorking(e){let n;for(let a of e)Sw(a)&&(n=a);if(!n||n.type==="custom_message")return!1;let r=n.message.role;if(r==="user"||r==="toolResult"||r==="bashExecution")return!0;if(r!=="assistant")return!1;let i=(Array.isArray(n.message.content)?n.message.content:[]).filter(a=>a.type==="toolCall").map(a=>a.id);if(!i.length)return!1;let o=new Set;for(let a of e)a.type==="message"&&a.message?.role==="toolResult"&&a.message.toolCallId&&o.add(a.message.toolCallId);return i.some(a=>a&&!o.has(a))}sessionAlive(){}readPreview(e){let n;try{n=c_(e,"r")}catch{return""}try{let s=65536;try{s=l_(e).size}catch{}let i=(d,u)=>{let p=Buffer.alloc(u),m=u_(n,p,0,u,d);return p.subarray(0,m).toString("utf8")},o=i(0,Math.min(65536,s)),a=s>65536?i(s-65536,65536):"",l=d=>{let u="";for(let p of d.split(`
2012
+ `),tool:e?.kind==="tool"?e.name:void 0}}#A(e){let n=Array.isArray(e?.content)?e.content:[];this.#o=n.map(r=>({kind:r.type==="thinking"?"thinking":r.type==="toolCall"?"tool":"text",text:(r.type==="thinking"?r.thinking:r.text)??"",name:r.name})),this.#O()}#y(e,n){let r=e.length>200?e.slice(0,200)+"\u2026":e;r&&(this.#r={text:r,kind:n,until:Date.now()+(n==="info"?e_:pw)})}#T(){this.#p({type:"get_session_stats"}).then(e=>{if(!e.success||!e.data)return;let n=e.data;this.#k={cost:typeof n.cost=="number"?n.cost:0,contextTokens:typeof n.contextUsage?.tokens=="number"?n.contextUsage.tokens:null,contextPercent:typeof n.contextUsage?.percent=="number"?n.contextUsage.percent:null}}).catch(()=>{})}#p(e){let n=this.#t;if(!n?.stdin?.writable)return Promise.reject(new Error(this.#g??"pi is not running"));let r=this.#i?uw:XC,s=`tb-${this.#_++}`;return new Promise((i,o)=>{let a=setTimeout(()=>{this.#f.delete(s),o(new Error(`pi did not respond (${Math.round(r/1e3)}s)`))},r);a.unref?.(),this.#f.set(s,{resolve:i,timer:a});try{n.stdin.write(JSON.stringify({id:s,...e})+`
2013
+ `)}catch(l){clearTimeout(a),this.#f.delete(s),o(new Error(Y(l)))}})}#I(e){let n;try{n=JSON.parse(e)}catch{return}switch(n.type){case"response":{let r=n,s=r.id?this.#f.get(r.id):void 0;s&&(this.#f.delete(r.id),clearTimeout(s.timer),s.resolve(r));return}case"agent_start":this.#l=!0,this.#n=0;return;case"agent_end":this.#l=!1,this.#n=0,this.#s=!1,this.#e=null,this.#b=null,this.#T();return;case"message_start":{let r=n.message;if(r?.role!=="assistant")return;this.#s=!0,this.#A(r);return}case"message_update":{if(!this.#s)return;if(n.message){this.#A(n.message);return}let r=n.assistantMessageEvent;if(!r||typeof r.contentIndex!="number")return;let s=r.type.startsWith("thinking")?"thinking":r.type.startsWith("toolcall")?"tool":"text",i=this.#o[r.contentIndex]??={kind:s,text:""};i.kind=s,typeof r.delta=="string"&&s!=="tool"&&(i.text+=r.delta),typeof r.content=="string"&&(i.text=r.content),r.toolCall?.name&&(i.name=r.toolCall.name),this.#O();return}case"message_end":if(!this.#s)return;n.message&&this.#A(n.message),this.#s=!1;return;case"auto_retry_start":this.#e={text:`retrying after a transient error (attempt ${Number(n.attempt)||1}/${Number(n.maxAttempts)||"?"})\u2026`,kind:"warning"};return;case"auto_retry_end":this.#e=null,n.success===!1&&this.#y(`retries exhausted: ${String(n.finalError??"unknown error")}`,"error");return;case"compaction_start":this.#e={text:"compacting context\u2026",kind:"info"};return;case"compaction_end":{this.#e=null;let r=n.result;typeof n.errorMessage=="string"&&n.errorMessage?this.#y(`compaction failed: ${n.errorMessage}`,"error"):r?.tokensBefore&&this.#y(`compacted: ~${Math.round(r.tokensBefore/1e3)}k \u2192 ~${Math.round((r.estimatedTokensAfter??0)/1e3)}k tokens`,"info"),this.#T();return}case"queue_update":{let r=Array.isArray(n.steering)?n.steering.map(String):[],s=Array.isArray(n.followUp)?n.followUp.map(String):[];this.#b=r.length||s.length?{steering:r,followUp:s}:null;return}case"extension_ui_request":{let r=String(n.method??"");if(r==="select"||r==="confirm"||r==="input"||r==="editor"){let s=typeof n.timeout=="number"&&n.timeout>0?n.timeout:void 0;this.#a.push({req:{id:String(n.id??""),method:r,title:typeof n.title=="string"?n.title:void 0,message:typeof n.message=="string"?n.message:void 0,options:Array.isArray(n.options)?n.options.map(String):void 0,placeholder:typeof n.placeholder=="string"?n.placeholder:void 0,prefill:typeof n.prefill=="string"?n.prefill:void 0},until:Date.now()+(s??ZC),ownTimeout:s!==void 0})}else if(r==="notify"){let s=n.notifyType==="warning"?"warning":n.notifyType==="error"?"error":"info";this.#y(String(n.message??""),s),console.log(`[composer] pi extension: ${String(n.message??"")}`)}else if(r==="setStatus"){let s=String(n.statusKey??"");typeof n.statusText=="string"&&n.statusText?this.#u.set(s,n.statusText):this.#u.delete(s)}return}default:return}}#P(e){this.#g=e,this.#i=!1,this.#l=!1,this.#n=0,this.#s=!1,this.#d=null,this.#o=[],this.#c=null,this.#e=null,this.#r=null,this.#u.clear(),this.#a=[],this.#b=null,this.#k=null,this.#w=null,this.#t=void 0,this.#C(e)}#C(e){for(let[,n]of this.#f)clearTimeout(n.timer),n.resolve({type:"response",success:!1,error:e});this.#f.clear()}},hw=t=>new Promise(e=>{setTimeout(e,t).unref?.()})});import{existsSync as gw,readFileSync as r_,realpathSync as s_}from"fs";import{join as On,dirname as vw,resolve as i_}from"path";import{homedir as yw}from"os";function a_(t,e){let n=On(t,".pi");if(o_.some(s=>gw(On(n,s))))return!0;let r=On(e,".agents","skills");for(let s=t;;){let i=On(s,".agents","skills");if(i!==r&&gw(i))return!0;let o=vw(s);if(o===s)return!1;s=o}}function l_(t,e){for(let n=e;;){if(t[n]===!0||t[n]===!1)return!0;let r=vw(n);if(r===n)return!1;n=r}}function Sw(t,e){try{let n=e?.agentDir??On(yw(),".pi","agent"),r=bw(e?.home??process.env.HOME??yw()),s=bw(i_(t));if(!a_(s,r))return null;let i=ww(On(n,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||l_(ww(On(n,"trust.json")),s)?null:"pi has no trust decision for this project \u2014 running untrusted; run `pi` once in a terminal to grant it"}catch{return null}}var o_,bw,ww,kw=S(()=>{"use strict";o_=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],bw=t=>{try{return s_(t)}catch{return t}},ww=t=>{try{return JSON.parse(r_(t,"utf8"))}catch{return{}}}});import{statSync as c_,openSync as u_,readSync as d_,closeSync as f_,existsSync as Ew}from"fs";import{join as Fa}from"path";import{homedir as Zd}from"os";import{execFile as p_}from"child_process";async function m_(t){let e=Fa(Zd(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let n of["fd","fdfind",...Ew(e)?[e]:[]]){let r=await new Promise(s=>{p_(n,["--base-directory",t,"--type","f","--follow","--hidden","--exclude",".git"],{maxBuffer:67108864},(i,o)=>s(i?null:o))});if(r!==null)return r.split(`
2014
+ `).filter(Boolean).map(s=>s.replace(/\\/g,"/"))}return null}function g_(t){return`--${t.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function xw(t){return t.type==="message"?y_(t.message?.role):t.type==="custom_message"?t.display!==!1:!1}var h_,y_,Or,ef=S(()=>{"use strict";vs();Io();No();lw();mw();kw();h_=Fa(Zd(),".pi","agent","sessions");y_=t=>t==="user"||t==="assistant"||t==="toolResult"||t==="bashExecution";Or=class extends Bt{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return Ew(Fa(Zd(),".pi","agent"))}ensureHarnessSupport(){aw()}createDriver(e,n){let r=new ja(e,n),s=Sw(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return m_(e)}sessionsDir(e){return Fa(h_,g_(e))}listSessionFiles(e){return Ro(this.sessionsDir(e))}parseEntry(e){let n;try{n=JSON.parse(e)}catch{return null}return!n||n.type==="session"||!n.id?null:n}idOf(e){return e.id}parentOf(e){return e.parentId??void 0}timestampOf(e){return e.timestamp}isSidechain(e){return!1}isLeafType(e){return xw(e)}isRecoveryNoise(e){return!1}apply(e,n){let r=[];if(e.type==="custom_message"){if(e.display===!1)return{events:r};let i=this.contentText(e.content).trim();return i&&r.push({type:"user",text:i}),{events:r}}if(e.type!=="message"||!e.message)return{events:r};let s=e.message;if(s.role==="user"){let i=this.contentText(s.content).trim();return i&&r.push({type:"user",text:i}),{events:r}}if(s.role==="toolResult"){let i=this.contentText(s.content);return r.push({type:"tool_result",id:s.toolCallId??"",content:i,isError:!!s.isError,digest:$e(i)}),{events:r}}if(s.role==="bashExecution")return s.command&&!s.excludeFromContext&&r.push({type:"user",text:`$ ${s.command}`}),{events:r};if(s.role==="assistant"){let i=Array.isArray(s.content)?s.content:[],o=i.filter(u=>u.type==="text").map(u=>u.text??"").join(""),a=i.filter(u=>u.type==="thinking").map(u=>u.thinking??"").join(`
2015
+ `),l=i.filter(u=>u.type==="toolCall").map(u=>({id:u.id??"",name:u.name??"",input:u.arguments??{}}));if(o||a||l.length){let u=Date.parse(e.timestamp??""),p=!isNaN(u)&&u>=n;r.push({type:"assistant",text:o,thinking:a,tools:l,live:p})}let c=s.usage,f=c?(c.input??0)+(c.output??0)+(c.cacheRead??0)+(c.cacheWrite??0):0,d=c&&f>0&&s.stopReason!=="aborted"&&s.stopReason!=="error"?{in:c.input??0,out:c.output??0,cached:c.cacheRead??0,cacheCreate:c.cacheWrite??0}:void 0;return{events:r,usage:d,model:s.model,cost:c?.cost?.total}}return{events:r}}chainWorking(e){let n;for(let a of e)xw(a)&&(n=a);if(!n||n.type==="custom_message")return!1;let r=n.message.role;if(r==="user"||r==="toolResult"||r==="bashExecution")return!0;if(r!=="assistant")return!1;let i=(Array.isArray(n.message.content)?n.message.content:[]).filter(a=>a.type==="toolCall").map(a=>a.id);if(!i.length)return!1;let o=new Set;for(let a of e)a.type==="message"&&a.message?.role==="toolResult"&&a.message.toolCallId&&o.add(a.message.toolCallId);return i.some(a=>a&&!o.has(a))}sessionAlive(){}readPreview(e){let n;try{n=u_(e,"r")}catch{return""}try{let s=65536;try{s=c_(e).size}catch{}let i=(d,u)=>{let p=Buffer.alloc(u),m=d_(n,p,0,u,d);return p.subarray(0,m).toString("utf8")},o=i(0,Math.min(65536,s)),a=s>65536?i(s-65536,65536):"",l=d=>{let u="";for(let p of d.split(`
2016
2016
  `))if(p.includes('"session_info"'))try{let m=JSON.parse(p);m?.type==="session_info"&&typeof m.name=="string"&&m.name&&(u=m.name)}catch{}return u},c="";for(let d of o.split(`
2017
- `))if(!(c||!d.includes('"type"')))try{let u=JSON.parse(d);u?.type==="message"&&u.message?.role==="user"&&(c=this.contentText(u.message.content).replace(/\s+/g," ").trim())}catch{}let f=l(a)||l(o)||c;return f?f.slice(0,200):""}finally{d_(n)}}searchText(e){if(e?.type!=="message")return"";let n=e.message?.role;if(n!=="user"&&n!=="assistant")return"";let r=e.message?.content,s="";return typeof r=="string"?s=r:Array.isArray(r)&&(s=r.filter(i=>i.type==="text"&&typeof i.text=="string").map(i=>i.text).join(" ")),s.replace(/\s+/g," ").trim()}contentText(e){return typeof e=="string"?Oe(e):Array.isArray(e)?e.map(n=>typeof n?.text=="string"?Oe(n.text):n?.type==="image"&&n.data?Co(n.data,n.mimeType):"").filter(Boolean).join(`
2018
- `):""}}});var Ua,xw=S(()=>{"use strict";Ua=class{#t=new Map;accept(e,n){return this.#t.get(e)===n?!1:(this.#t.set(e,n),!0)}}});import{execFile as y_}from"child_process";import{promisify as b_}from"util";import{readFile as w_}from"fs/promises";import{resolve as Ew,sep as v_}from"path";async function et(t,e){let{stdout:n}=await S_("git",t,{cwd:e,maxBuffer:67108864});return n}async function Pn(){if(qa)return qa;try{qa=(await et(["rev-parse","--show-toplevel"],V)).trim()}catch{}return qa}function k_(t,e){let n=e===" "?t:e;return n==="?"?"U":n}async function nf(){let t=await Pn();if(!t)return{repo:!1,root:"",files:[]};try{let e=await et(["status","--porcelain","-z"],t),n=[],r=e.split("\0");for(let s=0;s<r.length;s++){let i=r[s];i.length<4||((i[0]==="R"||i[0]==="C")&&s++,n.push({path:i.slice(3),status:k_(i[0],i[1])}))}try{let s=await et(["diff","--numstat","-z","HEAD"],t),i=new Map,o=s.split("\0");for(let a=0;a<o.length;a++){let l=/^(\d+|-)\t(\d+|-)\t(.*)$/.exec(o[a]);if(!l)continue;let c=l[3]||o[a+=2];c&&i.set(c,{add:+l[1]||0,del:+l[2]||0,binary:l[1]==="-"})}for(let a of n){let l=i.get(a.path);l&&(l.binary?a.binary=!0:(a.add=l.add,a.del=l.del))}}catch{}return n.sort((s,i)=>s.path.localeCompare(i.path)),{repo:!0,root:t,files:n}}catch(e){return{repo:!1,root:"",files:[],error:Y(e)}}}async function rf(t){let e=await Pn();if(!e)return{ok:!1,error:"not a git repository"};try{if((await et(["status","--porcelain","-z","--",t],e)).startsWith("??")){let s=Ew(e,t);if(!s.startsWith(Ew(e)+v_))return{ok:!1,error:"outside repository"};let i=await w_(s);return i.includes(0)?tf("Binary file (not shown)",!1):tf(i.toString("utf8"),!0)}let r;try{r=await et(["diff","--no-color","--unified=999999","HEAD","--",t],e)}catch{r=await et(["diff","--no-color","--unified=999999","--",t],e)}return tf(r,!1)}catch(n){return{ok:!1,error:Y(n)}}}var S_,Aw,qa,tf,Vs=S(()=>{"use strict";Vt();S_=b_(y_),Aw=2e6;tf=(t,e)=>({ok:!0,text:t.slice(0,Aw),untracked:e,truncated:t.length>Aw})});function Gs(t,e){let n=0,r="";for(let s of t){let i=s.lower.indexOf(e);if(!(i<0)&&(n++,!r)){let o=Math.max(0,i-110),a=Math.min(s.text.length,i+e.length+110);r=(o>0?"\u2026":"")+s.text.slice(o,a)+(a<s.text.length?"\u2026":"")}}return{hitCount:n,snippet:r}}var sf=S(()=>{"use strict"});function Tw(){return x_.map(([t,e])=>gt(t,e)).filter(t=>typeof t!="string")}function of(){return Tw().length>0}async function Xs(t,e,n=0){let r=AbortSignal.timeout(e);for(let s of Tw()){try{let i=await Jt(s,{messages:[{role:"user",content:t}],effort:n,webSearch:!1,signal:r});if(i.ok){let o=(await vd(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var x_,af=S(()=>{"use strict";Ut();Tn();x_=[["openrouter","openai/gpt-6-luna"],["openai","gpt-6-luna"]]});var Ja,Wa,Cn,Qs=S(()=>{"use strict";Ja=".typebulb/paste",Wa={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},Cn=t=>t.label||t.kind||"agent"});import{existsSync as E_,mkdirSync as A_,writeFileSync as T_,readFileSync as O_}from"fs";import{join as Ka}from"path";function Ow(){let t=new Date,e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}${e(t.getMonth()+1)}${e(t.getDate())}-${e(t.getHours())}${e(t.getMinutes())}${e(t.getSeconds())}`}function __(t){return t.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function R_(t){let e=await Xs(`Reply with ONLY a short kebab-case filename (2-5 words, lowercase, no extension) describing this text:
2017
+ `))if(!(c||!d.includes('"type"')))try{let u=JSON.parse(d);u?.type==="message"&&u.message?.role==="user"&&(c=this.contentText(u.message.content).replace(/\s+/g," ").trim())}catch{}let f=l(a)||l(o)||c;return f?f.slice(0,200):""}finally{f_(n)}}searchText(e){if(e?.type!=="message")return"";let n=e.message?.role;if(n!=="user"&&n!=="assistant")return"";let r=e.message?.content,s="";return typeof r=="string"?s=r:Array.isArray(r)&&(s=r.filter(i=>i.type==="text"&&typeof i.text=="string").map(i=>i.text).join(" ")),s.replace(/\s+/g," ").trim()}contentText(e){return typeof e=="string"?Oe(e):Array.isArray(e)?e.map(n=>typeof n?.text=="string"?Oe(n.text):n?.type==="image"&&n.data?Co(n.data,n.mimeType):"").filter(Boolean).join(`
2018
+ `):""}}});var Ua,Aw=S(()=>{"use strict";Ua=class{#t=new Map;accept(e,n){return this.#t.get(e)===n?!1:(this.#t.set(e,n),!0)}}});import{execFile as b_}from"child_process";import{promisify as w_}from"util";import{readFile as v_}from"fs/promises";import{resolve as Tw,sep as S_}from"path";async function et(t,e){let{stdout:n}=await k_("git",t,{cwd:e,maxBuffer:67108864});return n}async function Pn(){if(qa)return qa;try{qa=(await et(["rev-parse","--show-toplevel"],V)).trim()}catch{}return qa}function x_(t,e){let n=e===" "?t:e;return n==="?"?"U":n}async function nf(){let t=await Pn();if(!t)return{repo:!1,root:"",files:[]};try{let e=await et(["status","--porcelain","-z"],t),n=[],r=e.split("\0");for(let s=0;s<r.length;s++){let i=r[s];i.length<4||((i[0]==="R"||i[0]==="C")&&s++,n.push({path:i.slice(3),status:x_(i[0],i[1])}))}try{let s=await et(["diff","--numstat","-z","HEAD"],t),i=new Map,o=s.split("\0");for(let a=0;a<o.length;a++){let l=/^(\d+|-)\t(\d+|-)\t(.*)$/.exec(o[a]);if(!l)continue;let c=l[3]||o[a+=2];c&&i.set(c,{add:+l[1]||0,del:+l[2]||0,binary:l[1]==="-"})}for(let a of n){let l=i.get(a.path);l&&(l.binary?a.binary=!0:(a.add=l.add,a.del=l.del))}}catch{}return n.sort((s,i)=>s.path.localeCompare(i.path)),{repo:!0,root:t,files:n}}catch(e){return{repo:!1,root:"",files:[],error:Y(e)}}}async function rf(t){let e=await Pn();if(!e)return{ok:!1,error:"not a git repository"};try{if((await et(["status","--porcelain","-z","--",t],e)).startsWith("??")){let s=Tw(e,t);if(!s.startsWith(Tw(e)+S_))return{ok:!1,error:"outside repository"};let i=await v_(s);return i.includes(0)?tf("Binary file (not shown)",!1):tf(i.toString("utf8"),!0)}let r;try{r=await et(["diff","--no-color","--unified=999999","HEAD","--",t],e)}catch{r=await et(["diff","--no-color","--unified=999999","--",t],e)}return tf(r,!1)}catch(n){return{ok:!1,error:Y(n)}}}var k_,Ow,qa,tf,Vs=S(()=>{"use strict";Vt();k_=w_(b_),Ow=2e6;tf=(t,e)=>({ok:!0,text:t.slice(0,Ow),untracked:e,truncated:t.length>Ow})});function Gs(t,e){let n=0,r="";for(let s of t){let i=s.lower.indexOf(e);if(!(i<0)&&(n++,!r)){let o=Math.max(0,i-110),a=Math.min(s.text.length,i+e.length+110);r=(o>0?"\u2026":"")+s.text.slice(o,a)+(a<s.text.length?"\u2026":"")}}return{hitCount:n,snippet:r}}var sf=S(()=>{"use strict"});function Pw(){return E_.map(([t,e])=>gt(t,e)).filter(t=>typeof t!="string")}function of(){return Pw().length>0}async function Xs(t,e,n=0){let r=AbortSignal.timeout(e);for(let s of Pw()){try{let i=await Jt(s,{messages:[{role:"user",content:t}],effort:n,webSearch:!1,signal:r});if(i.ok){let o=(await vd(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var E_,af=S(()=>{"use strict";Ut();Tn();E_=[["openrouter","openai/gpt-6-luna"],["openai","gpt-6-luna"]]});var Ja,Wa,Cn,Qs=S(()=>{"use strict";Ja=".typebulb/paste",Wa={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},Cn=t=>t.label||t.kind||"agent"});import{existsSync as A_,mkdirSync as T_,writeFileSync as O_,readFileSync as P_}from"fs";import{join as Ka}from"path";function Cw(){let t=new Date,e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}${e(t.getMonth()+1)}${e(t.getDate())}-${e(t.getHours())}${e(t.getMinutes())}${e(t.getSeconds())}`}function R_(t){return t.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function I_(t){let e=await Xs(`Reply with ONLY a short kebab-case filename (2-5 words, lowercase, no extension) describing this text:
2019
2019
 
2020
- ${t.slice(0,C_)}`,P_);return e&&__(e)||void 0}async function Pw(t,e){if(!e||e.kind!=="image"&&e.kind!=="text")return{ok:!1,error:"bad paste kind"};if(typeof e.data!="string"||!e.data)return{ok:!1,error:"empty paste"};let n=Ka(t,Ja);try{A_(n,{recursive:!0})}catch(a){return{ok:!1,error:Y(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${Ow()}`,s=Object.keys(Wa).find(a=>Wa[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await R_(e.data)??`paste-${Ow()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;E_(Ka(n,o));a++)o=`${r}-${a}.${s}`;try{T_(Ka(n,o),i)}catch(a){return{ok:!1,error:Y(a)}}return{ok:!0,path:`${Ja}/${o}`}}function Cw(t,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let n=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=Wa[n];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:O_(Ka(t,Ja,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var P_,C_,_w=S(()=>{"use strict";af();Vt();Qs();P_=4e3,C_=4e3});async function Lw(t,e=""){let n=t.trim();if(!n)return{ok:!1,error:"nothing to summarize"};if(!of())return Nw;let r=e.trim()?Rw+`CONTEXT \u2014 the user message this reply answers. It is context only: never summarize it, and never report it as the reply's content.
2021
- `+I_(e.trim())+`
2020
+ ${t.slice(0,__)}`,C_);return e&&R_(e)||void 0}async function _w(t,e){if(!e||e.kind!=="image"&&e.kind!=="text")return{ok:!1,error:"bad paste kind"};if(typeof e.data!="string"||!e.data)return{ok:!1,error:"empty paste"};let n=Ka(t,Ja);try{T_(n,{recursive:!0})}catch(a){return{ok:!1,error:Y(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${Cw()}`,s=Object.keys(Wa).find(a=>Wa[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await I_(e.data)??`paste-${Cw()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;A_(Ka(n,o));a++)o=`${r}-${a}.${s}`;try{O_(Ka(n,o),i)}catch(a){return{ok:!1,error:Y(a)}}return{ok:!0,path:`${Ja}/${o}`}}function Rw(t,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let n=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=Wa[n];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:P_(Ka(t,Ja,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var C_,__,Iw=S(()=>{"use strict";af();Vt();Qs();C_=4e3,__=4e3});async function Dw(t,e=""){let n=t.trim();if(!n)return{ok:!1,error:"nothing to summarize"};if(!of())return Lw;let r=e.trim()?Nw+`CONTEXT \u2014 the user message this reply answers. It is context only: never summarize it, and never report it as the reply's content.
2021
+ `+N_(e.trim())+`
2022
2022
 
2023
2023
  REPLY TO SUMMARIZE:
2024
- `+n.slice(0,cf):Rw+n.slice(0,cf),s=await Xs(r,Iw,1);return s?{ok:!0,text:s}:$w}async function Zs(t,e){if(!of())return Nw;let n;if(t==="plan"){let s=String(e??"").trim();if(!s)return{ok:!1,error:"nothing to summarize"};n=N_+s.slice(0,cf)}else{let s=e;if(!Array.isArray(s?.subtasks)||typeof s.log!="string")return{ok:!1,error:"nothing to summarize"};n=$_({...s,log:L_(s.log)})}let r=await Xs(n,Iw*2,1);if(!r)return $w;try{return{ok:!0,data:JSON.parse(r.replace(/^```(?:json)?\s*|\s*```$/g,""))}}catch{return{ok:!1,error:"the model answered in the wrong shape"}}}var Iw,cf,Rw,I_,Nw,$w,N_,$_,lf,L_,uf=S(()=>{"use strict";af();Iw=2e4,cf=24e3,Rw=`Summarize this assistant reply for someone who wants its substance without the prose.
2024
+ `+n.slice(0,cf):Nw+n.slice(0,cf),s=await Xs(r,$w,1);return s?{ok:!0,text:s}:Mw}async function Zs(t,e){if(!of())return Lw;let n;if(t==="plan"){let s=String(e??"").trim();if(!s)return{ok:!1,error:"nothing to summarize"};n=$_+s.slice(0,cf)}else{let s=e;if(!Array.isArray(s?.subtasks)||typeof s.log!="string")return{ok:!1,error:"nothing to summarize"};n=L_({...s,log:M_(s.log)})}let r=await Xs(n,$w*2,1);if(!r)return Mw;try{return{ok:!0,data:JSON.parse(r.replace(/^```(?:json)?\s*|\s*```$/g,""))}}catch{return{ok:!1,error:"the model answered in the wrong shape"}}}var $w,cf,Nw,N_,Lw,Mw,$_,L_,lf,M_,uf=S(()=>{"use strict";af();$w=2e4,cf=24e3,Nw=`Summarize this assistant reply for someone who wants its substance without the prose.
2025
2025
 
2026
2026
  - Markdown. Start with the direct answer, recommendation, result, or status. If it is qualified, put the qualification in that same opening sentence; do not make the reader infer it from later bullets.
2027
2027
  - Preserve material limits and conditions that change the answer: exceptions, tradeoffs, prerequisites, uncertainty, incomplete validation, and clauses such as but, only when, unless, or if. Cut only filler hedges (for example, "I think" or "arguably") that change nothing.
@@ -2036,17 +2036,17 @@ Reply with the summary alone.
2036
2036
 
2037
2037
  ---
2038
2038
 
2039
- `,I_=(t,e=4e3)=>{if(t.length<=e)return t;let n=Math.floor(e/2)-20;return t.slice(0,n)+`
2039
+ `,N_=(t,e=4e3)=>{if(t.length<=e)return t;let n=Math.floor(e/2)-20;return t.slice(0,n)+`
2040
2040
 
2041
2041
  [snipped for brevity]
2042
2042
 
2043
- `+t.slice(t.length-n)},Nw={ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0},$w={ok:!1,error:"the model call failed or timed out"};N_=`A coordinator sent this message to a sub-agent. Return JSON only:
2043
+ `+t.slice(t.length-n)},Lw={ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0},Mw={ok:!1,error:"the model call failed or timed out"};$_=`A coordinator sent this message to a sub-agent. Return JSON only:
2044
2044
  {"request": "one or two plain sentences: what it asks for and what must be delivered", "subtasks": ["..."]}
2045
2045
 
2046
2046
  Subtasks: in the message's own order, following its numbering if it has one. Each named deliverable belongs to a subtask. Omit orientation (reading docs or guidance): a subtask produces or decides something. At most 8, each a short imperative under 10 words. If the message assigns no new work (a status question, a notification), return "subtasks": [].
2047
2047
 
2048
2048
  MESSAGE:
2049
- `,$_=t=>`You report on a sub-agent's progress to whoever delegated the work, often an orchestrating agent. They will not read the log. They are deciding whether to intervene, re-scope or wait, so they want what the sub-agent has found, where each subtask stands, and anything unusual.
2049
+ `,L_=t=>`You report on a sub-agent's progress to whoever delegated the work, often an orchestrating agent. They will not read the log. They are deciding whether to intervene, re-scope or wait, so they want what the sub-agent has found, where each subtask stands, and anything unusual.
2050
2050
 
2051
2051
  SUBTASKS:
2052
2052
  ${t.subtasks.map((e,n)=>`${n+1}. ${e}`).join(`
@@ -2076,34 +2076,34 @@ FACTS (counted from the log):
2076
2076
  ${t.facts||"none"}
2077
2077
 
2078
2078
  LOG (steps numbered in brackets):
2079
- ${t.log}`,lf=2e5,L_=t=>t.length<=lf?t:t.slice(0,lf/3)+`
2079
+ ${t.log}`,lf=2e5,M_=t=>t.length<=lf?t:t.slice(0,lf/3)+`
2080
2080
  [\u2026 earlier steps omitted \u2026]
2081
- `+t.slice(-lf*2/3)});import{readFileSync as M_,statSync as D_}from"fs";function Ha(t,e,n,r){let s=t.apply(e,r),i=Date.parse(t.timestampOf(e)??""),o=s.events.map(a=>{let l=n==="child"&&a.type==="user"?{...a,authored:!0}:a;return!isNaN(i)&&(l.type==="user"||l.type==="assistant"||l.type==="tool_result")&&(l.at=i),l});return{...s,events:o}}function za(t){let e=new Map,n=t.linker();return{entries:e,add(r,s){let i;for(let o of r){if(!o.trim())continue;let a=t.parseEntry(o);if(!a)continue;n.link(a);let l=t.idOf(a);l&&(e.set(l,a),!t.isSidechain(a,s)&&t.isLeafType(a)&&(i=l))}return i}}}function Mw(t,e,n){let r=t.forRead(),s;try{s=M_(e,"utf8")}catch{return[]}let{entries:i,add:o}=za(r),a=o(s.split(`
2082
- `),n),l=[],c=new Set;for(let u=a;u&&!c.has(u);){let p=i.get(u);if(!p)break;c.add(u),l.push(p),u=r.parentOf(p)}let f=[],d=Date.now();for(let u of l.reverse())if(!r.isSidechain(u,n))try{f.push(...Ha(r,u,n,d).events)}catch{}return f}function Ya(t,e,n,r){let s=t.sessionAlive(e,n);if(s!==void 0)return s;if(!r)return!1;try{return Date.now()-D_(r).mtimeMs<1e4}catch{return!1}}function ei(t,e){return t.stopped?"stopped":t.running&&e?"running":"done"}var df=S(()=>{"use strict"});function B_(t,...e){return t.slice().sort((n,r)=>{for(let{key:s,desc:i}of e){let o=s(n),a=s(r);if(o!==a)return o==null?i?-1:1:a==null||o<a?i?1:-1:i?-1:1}return 0})}var ti,ff=S(()=>{"use strict";ti=(t,e)=>B_(t,{key:e,desc:!0})});function G_(t,e){let n=t.digest??"",r=ty.exec(n)?.[0]??"",s=Or(n.slice(0,n.length-r.length),e)+r,i=r&&pf(t)?Or(W_(t.result??""),e):"";return i?`${s}, last: ${i}`:s}function jw(t){let e=[];for(let n of t)if(n.type==="cleared")e.length=0;else if(n.type==="user"){let r=e.at(-1);r?.role==="user"&&!n.agent&&!r.agent?r.text+=`
2083
-
2084
- `+n.text:e.push({role:"user",text:n.text,tools:[],agent:n.agent,at:n.at})}else if(n.type==="assistant")e.push({role:"assistant",text:n.text,tools:n.tools.map(r=>({...r,isError:!1,at:n.at})),at:n.at});else if(n.type==="tool_result"){let r=e.flatMap(s=>s.tools).find(s=>s.id===n.id);r&&(r.result=n.content,r.isError=n.isError,r.digest=n.digest,r.doneAt=n.at)}return e}function Fw(t){let e="",n=[],r=[],s=[],i=[],o=0;for(let d of t)if(o=Math.max(o,d.at??0,...d.tools.map(u=>u.doneAt??u.at??0)),d.role!=="fork"){if(d.role==="user"){if(d.agent){i.push({after:r.length,line:"REPORT FROM ITS OWN SUB-AGENT: "+ni(d.text,1500)});continue}if(!e){e=d.text;continue}n.push(d.text),i.push({after:r.length,line:`FOLLOW-UP FROM PARENT: ${ni(d.text,1500)}`});continue}d.text&&i.push({after:r.length,line:"AGENT SAYS: "+ni(d.text,1500)});for(let u of d.tools){r.push({n:r.length+1,tool:u,wall:0,parts:[]});let p=u.input?.message;typeof p=="string"&&p.length>200&&i.push({after:r.length,line:`AGENT SENDS (${Cu(u.name)}): ${ni(p,8e3)}`})}}let a=Q_(t,r,o),l=i.at(-1);if(l&&/^AGENT SAYS/.test(l.line)){let d=[...t].reverse().find(u=>u.role==="assistant"&&u.text);d&&(l.line="AGENT SAYS: "+ni(d.text,8e3))}let c=new Map;for(let d of i)c.set(d.after,[...c.get(d.after)??[],d.line]);s.push(...c.get(0)??[]);let f=r.length-j_;for(let d=0;d<r.length;){let u=r[d];if(u.n<=f&&Dw.has(u.tool.name)&&!u.tool.isError){let g=d;for(;g<r.length&&r[g].n<=f&&Dw.has(r[g].tool.name)&&!r[g].tool.isError&&(g===d||!c.has(r[g-1].n));)g++;if(g-d>=3){let E=[...new Set(r.slice(d,g).map(O=>Ou(Pu(O.tool.input))))];s.push(`[${u.n}-${r[g-1].n}] explored ${g-d} files/searches: ${Or(E.join(", "),160)}`),s.push(...c.get(r[g-1].n)??[]),d=g;continue}}let p=u.n>f,m=u.tool,h=m.result===void 0?"(running)":m.isError?"ERROR: "+Or(J_(m.result),160):G_(m,p?120:60)||"ok";s.push(`[${u.n}] ${Va(m,p?160:80)} \u2192 ${h}`),s.push(...c.get(u.n)??[]),d++}return{brief:e,followups:n,steps:r,log:s.join(`
2085
- `),facts:eR(r),...a,tests:X_(r),lastAt:o}}function X_(t){for(let e=t.length-1;e>=0;e--){let n=t[e].tool,r=pf(n);if(!r||!q_.test(r)||n.result===void 0)continue;let s=(bs(n.result).split(`
2086
- `).filter(o=>/\b\d+\s+(passed|failed)\b/i.test(o)).at(-1)??"").trim().replace(/^tests?:?\s+/i,""),i=n.isError||/\b[1-9]\d*\s+failed\b/i.test(s)?"red":/\bpassed\b/i.test(s)?"green":"unknown";return{n:t[e].n,state:i,line:Or(s,90),ms:Bw(n)}}}function Q_(t,e,n){let r=t.flatMap(u=>u.tools),s=[],i=[],o;for(let u of t)if(u.role!=="fork"){if(u.role==="user"){o===void 0&&!u.agent?o=u.at:u.at&&i.push(u.at);continue}u.at&&s.push(u.at);for(let p of u.tools)p.at&&s.push(p.at),p.doneAt&&s.push(p.doneAt)}let a=o??e[0]?.tool.at??n,l=[];for(let u of i){let p=-1/0;for(let h of s)h<=u&&h>p&&(p=h);let m=r.some(h=>h.at!==void 0&&h.at<u&&(h.doneAt??1/0)>u);p>-1/0&&!m&&u-p>=U_&&l.push([p,u])}let c=u=>l.reduce((p,[m,h])=>p+Math.max(0,Math.min(u,h)-m),0),f=u=>Math.max(0,u-a-c(u)),d=[];e.forEach((u,p)=>{let m=e[p-1]?.tool,h=p===0?a:m?.doneAt??m?.at??a;d.push(Math.min(n,Math.max(d[p-1]??a,h)))}),e.forEach((u,p)=>{let m=d[p],h=d[p+1]??n,g=m,E=!0;for(let[O,C]of l){if(C<=m||O>=h)continue;let x=E&&p>0?e[p-1]:u;O>g&&x.parts.push({from:f(g),to:f(O)}),g=Math.max(g,C),E=!1}h>g&&u.parts.push({from:f(g),to:f(h)})});for(let u of e)u.wall=u.parts.reduce((p,m)=>p+m.to-m.from,0);return{span:f(n),idle:c(n),wakes:i.filter(u=>u>a&&u<n).map(f),toolMs:Z_(e,n)}}function Z_(t,e){let n=t.map(i=>i.tool).filter(i=>i.at!==void 0).sort((i,o)=>i.at-o.at),r=0,s=-1/0;for(let i of n){let o=i.doneAt??e;o>s&&(r+=o-Math.max(i.at,s),s=o)}return r}function eR(t){let e=[],n=t.filter(o=>o.tool.isError);n.length&&e.push(`${n.length} of ${t.length} steps failed.`);let r=new Map;for(let o of n){let a=Va(o.tool,60);r.set(a,[...r.get(a)??[],o.n])}for(let[o,a]of r)a.length>1&&e.push(`${o} failed ${a.length} times (steps ${a.join(", ")}).`);let s=t.slice(-20).filter(o=>o.tool.isError).length;s>=4&&e.push(`${s} of the last 20 steps failed.`);for(let o of t)if(o.wall>=F_){let a=Bw(o.tool),l=a!==void 0&&a<o.wall/2?`: the call ran ${Se(a)}, the rest was the model before it`:"";e.push(`Step ${o.n} (${Va(o.tool,60)}) took ${Se(o.wall)}${l}.`)}let i=t.reduce((o,a)=>o+a.wall,0);return i&&e.push(`${Se(i)} in all over ${t.length} steps.`),e.join(`
2087
- `)}function Uw(t,e,n){let r=[t.brief,...t.followups].map(i=>e.get(i));if(r.some(i=>!i))return;let s={subtasks:r.flatMap(i=>i.subtasks),log:t.log,facts:t.facts,finished:n};return{key:tR(JSON.stringify(s)),payload:s,steps:t.steps.length,followups:t.followups.length}}function tR(t){let e=3735928559,n=1103547991;for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);e=Math.imul(e^s,2654435761),n=Math.imul(n^s,1597334677)}return e=Math.imul(e^e>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),(4294967296*(2097151&n)+(e>>>0)).toString(36)}function hf(t,e,n,r){let s=[],i=0;[t.brief,...t.followups].forEach((o,a)=>{let l=e.get(o);a>0&&s.push({kind:"group",request:l?.request??"",idx:a});for(let c of l?.subtasks??[]){i++;let f=t.brief+`
2088
- `+c,d=n?.rows.find(p=>p.id===i);d?.status==="done"&&!r.has(f)&&r.set(f,d),d=r.get(f)??d;let u=d?.steps??[];s.push({kind:"row",num:i,title:c,status:d?.status??"",did:d?.did??"",note:d?.note??"",steps:u,cite:d?.evidence?.length?d.evidence:u,ms:0,spans:[]})}});for(let o of n?.offBrief??[])s.push({kind:"row",title:o.what,status:"off",did:"",note:o.note,steps:o.steps,cite:o.steps,ms:0,spans:[]});return nR(s,t),s}function nR(t,e){let n=t.filter(o=>o.kind==="row"),r=e.steps.map(o=>n.find(a=>z_(o.n,a.steps))),s=r.find(Boolean);if(!s)return;let i=s;for(let o=0;o<r.length;o++)r[o]=i=r[o]??i;e.steps.forEach((o,a)=>{let l=r[a];l.ms+=o.wall;for(let c of o.parts){let f=l.spans.at(-1);f&&Math.abs(f.to-c.from)<1e3?f.to=Math.max(f.to,c.to):l.spans.push({...c})}})}function qw(t,e,n,r){let s=t.tests,i=e&&e.followups===t.followups.length,o=t.followups.length?n.get(t.followups.at(-1))?.request:void 0;return[["Now",i?e.data.now:o?`Working on the latest follow-up: ${o}`:r?"\u2026":""],["Tests",s?`${s.state}${s.line?`, ${s.line}`:""}${s.ms!==void 0?`, took ${Se(s.ms)}`:""} (step ${s.n})`:"",s?`tests-${s.state}`:void 0],["Time",t.span&&t.steps.length?`${Se(t.toolMs)} in tools, ${Se(Math.max(0,t.span-t.toolMs))} in the model${t.idle?`, ${Se(t.idle)} stopped`:""}`:""],["Needs a decision",i?e.data.decision:"","warn"]].filter(([,l])=>l)}function Jw(t,e){let n=new Map,r=o=>{let a=o.trim().replace(/^["']|["']$/g,"").replace(/\\/g,"/").replace(/^\/([a-zA-Z])\//,"$1:/"),l=ny(a,e).replace(/^\.\//,"");return!l||/^([a-zA-Z]:)?\//.test(l)?void 0:l},s=(o,a={})=>{let l=r(o);if(!l)return;let c=n.get(l)??{path:l};c.deleted=a.deleted,a.from&&(c.from=a.from),n.set(l,c)},i=(o,a)=>{let l=r(o),c=l?n.get(l):void 0;l&&n.delete(l),s(a,{from:c?.from??l})};for(let{tool:o}of t.steps){if(o.isError)continue;let a=o.input??{},l=!1;for(let[d,u]of Object.entries(a)){if(d==="command"||d==="cmd"||typeof u!="string"||!/^(---|\+\+\+) /m.test(u))continue;let p;for(let m of u.split(`
2089
- `)){let h=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(m);if(h?.[1]==="---"){p=h[2];continue}if(h?.[1]==="+++"){l=!0,h[2]==="/dev/null"?p&&p!=="/dev/null"&&s(p,{deleted:!0}):s(h[2]);continue}let g=/^\*\*\* Move to: (.+?)\s*$/.exec(m);g&&p&&i(p,g[1])}}let c=ge(a.file_path)??ge(a.filePath)??ge(a.path);!l&&c&&rR.some(d=>d in a)&&s(c);let f=pf(o);if(f)for(let d of sR(f))d.to?i(d.from,d.to):s(d.from,{deleted:!0})}return[...n.values()]}function sR(t){let e=[];for(let n of t.split(/&&|\|\||[;|\n]/)){let r=n.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[],s=r.indexOf("git"),i=r[s+1];if(s<0||i!=="rm"&&i!=="mv"||r.includes("--cached"))continue;let o=r.slice(s+2).filter(l=>!l.startsWith("-")).map(l=>l.replace(/^["']|["']$/g,""));if(i==="rm"){for(let l of o)e.push({from:l});continue}let a=o.pop();if(a)for(let l of o)e.push({from:l,to:o.length>1?`${a.replace(/\/+$/,"")}/${Ou(l)}`:a})}return e}function Ww(t){let{d:e}=t,n=t.working?`running, step ${e.steps.length}${oR(e,t.now)}`:`finished after ${e.steps.length} steps`,r=[`Sub-agent "${t.name}": ${n}, ${Se(e.span)} active${e.lastAt?`, as of ${Y_(e.lastAt)}`:""}.`];r.push("",`Request: ${e.brief?t.plans.get(e.brief)?.request??"(not summarized yet)":V_}`);for(let s of t.lines){if(s.kind==="group"){r.push("",`Follow-up: ${s.request||"(not summarized yet)"}`);continue}let i=s.ms?` (${Se(s.ms)})`:"";r.push(`- ${s.title}: ${H_(s.status||"pending")}.${s.did?` ${s.did}`:""}${i}`),s.note&&r.push(` Note: ${s.note}`)}t.edited.length&&r.push("","Edited:",...t.edited.map(iR)),t.facts.length&&r.push("");for(let[s,i]of t.facts)r.push(`${s}: ${i}`);return r.join(`
2090
- `)}function oR(t,e){let n=[...t.steps].reverse().find(r=>r.tool.result===void 0&&r.tool.at);return n?`, waiting ${Se(e-n.tool.at)} on ${Va(n.tool,60)}`:t.lastAt?`, last activity ${Se(e-t.lastAt)} ago`:""}function Kw(t){let e=t??{},n=r=>Array.isArray(r)?r.filter(Array.isArray).map(s=>[Number(s[0]),s[1]===void 0?void 0:Number(s[1])]).filter(s=>s[0]>0):[];return{now:String(e.now??""),decision:String(e.decision??""),rows:(Array.isArray(e.rows)?e.rows:[]).map(r=>({id:Number(r.id),status:String(r.status??""),did:String(r.did??""),note:String(r.note??""),steps:n(r.steps),evidence:n(r.evidence)})),offBrief:(Array.isArray(e.offBrief)?e.offBrief:[]).map(r=>({what:String(r.what??""),note:String(r.note??""),steps:n(r.steps)}))}}function Hw(t){let e=t;return{request:String(e?.request??""),subtasks:Array.isArray(e?.subtasks)?e.subtasks.map(n=>String(n).replace(/[.\s]+$/,"")):[]}}var j_,F_,U_,Dw,q_,Or,ni,J_,W_,K_,Va,pf,Bw,H_,z_,Y_,V_,rR,iR,zw=S(()=>{"use strict";Po();j_=30,F_=3*6e4,U_=6e4,Dw=new Set(["Read","Grep","Glob"]),q_=/\b(vitest|jest|pytest|mocha|playwright test|go test|cargo test|dotnet test|(?:npm|pnpm|yarn|bun)(?: run)? test)\b/,Or=(t,e)=>(t=bs(t).replace(/\s+/g," ").trim(),t.length>e?t.slice(0,e)+"\u2026":t),ni=(t,e)=>t.length<=e?t:t.slice(0,e/2)+`
2081
+ `+t.slice(-lf*2/3)});import{readFileSync as D_,statSync as B_}from"fs";function Ha(t,e,n,r){let s=t.apply(e,r),i=Date.parse(t.timestampOf(e)??""),o=s.events.map(a=>{let l=n==="child"&&a.type==="user"?{...a,authored:!0}:a;return!isNaN(i)&&(l.type==="user"||l.type==="assistant"||l.type==="tool_result")&&(l.at=i),l});return{...s,events:o}}function za(t){let e=new Map,n=t.linker();return{entries:e,add(r,s){let i;for(let o of r){if(!o.trim())continue;let a=t.parseEntry(o);if(!a)continue;n.link(a);let l=t.idOf(a);l&&(e.set(l,a),!t.isSidechain(a,s)&&t.isLeafType(a)&&(i=l))}return i}}}function Bw(t,e,n){let r=t.forRead(),s;try{s=D_(e,"utf8")}catch{return[]}let{entries:i,add:o}=za(r),a=o(s.split(`
2082
+ `),n),l=[],c=new Set;for(let u=a;u&&!c.has(u);){let p=i.get(u);if(!p)break;c.add(u),l.push(p),u=r.parentOf(p)}let f=[],d=Date.now();for(let u of l.reverse())if(!r.isSidechain(u,n))try{f.push(...Ha(r,u,n,d).events)}catch{}return f}function Ya(t,e,n,r){let s=t.sessionAlive(e,n);if(s!==void 0)return s;if(!r)return!1;try{return Date.now()-B_(r).mtimeMs<1e4}catch{return!1}}function ei(t,e){return t.stopped?"stopped":t.running&&e?"running":"done"}var df=S(()=>{"use strict"});function j_(t,...e){return t.slice().sort((n,r)=>{for(let{key:s,desc:i}of e){let o=s(n),a=s(r);if(o!==a)return o==null?i?-1:1:a==null||o<a?i?1:-1:i?-1:1}return 0})}var ti,ff=S(()=>{"use strict";ti=(t,e)=>j_(t,{key:e,desc:!0})});function X_(t,e){let n=t.digest??"",r=ty.exec(n)?.[0]??"",s=Pr(n.slice(0,n.length-r.length),e)+r,i=r&&pf(t)?Pr(K_(t.result??""),e):"";return i?`${s}, last: ${i}`:s}function Uw(t){let e=[];for(let n of t)if(n.type==="cleared")e.length=0;else if(n.type==="user"){let r=e.at(-1);r?.role==="user"&&!n.agent&&!r.agent?r.text+=`
2083
+
2084
+ `+n.text:e.push({role:"user",text:n.text,tools:[],agent:n.agent,at:n.at})}else if(n.type==="assistant")e.push({role:"assistant",text:n.text,tools:n.tools.map(r=>({...r,isError:!1,at:n.at})),at:n.at});else if(n.type==="tool_result"){let r=e.flatMap(s=>s.tools).find(s=>s.id===n.id);r&&(r.result=n.content,r.isError=n.isError,r.digest=n.digest,r.doneAt=n.at)}return e}function qw(t){let e="",n=[],r=[],s=[],i=[],o=0;for(let d of t)if(o=Math.max(o,d.at??0,...d.tools.map(u=>u.doneAt??u.at??0)),d.role!=="fork"){if(d.role==="user"){if(d.agent){i.push({after:r.length,line:"REPORT FROM ITS OWN SUB-AGENT: "+ni(d.text,1500)});continue}if(!e){e=d.text;continue}n.push(d.text),i.push({after:r.length,line:`FOLLOW-UP FROM PARENT: ${ni(d.text,1500)}`});continue}d.text&&i.push({after:r.length,line:"AGENT SAYS: "+ni(d.text,1500)});for(let u of d.tools){r.push({n:r.length+1,tool:u,wall:0,parts:[]});let p=u.input?.message;typeof p=="string"&&p.length>200&&i.push({after:r.length,line:`AGENT SENDS (${Cu(u.name)}): ${ni(p,8e3)}`})}}let a=Z_(t,r,o),l=i.at(-1);if(l&&/^AGENT SAYS/.test(l.line)){let d=[...t].reverse().find(u=>u.role==="assistant"&&u.text);d&&(l.line="AGENT SAYS: "+ni(d.text,8e3))}let c=new Map;for(let d of i)c.set(d.after,[...c.get(d.after)??[],d.line]);s.push(...c.get(0)??[]);let f=r.length-F_;for(let d=0;d<r.length;){let u=r[d];if(u.n<=f&&jw.has(u.tool.name)&&!u.tool.isError){let g=d;for(;g<r.length&&r[g].n<=f&&jw.has(r[g].tool.name)&&!r[g].tool.isError&&(g===d||!c.has(r[g-1].n));)g++;if(g-d>=3){let x=[...new Set(r.slice(d,g).map(O=>Ou(Pu(O.tool.input))))];s.push(`[${u.n}-${r[g-1].n}] explored ${g-d} files/searches: ${Pr(x.join(", "),160)}`),s.push(...c.get(r[g-1].n)??[]),d=g;continue}}let p=u.n>f,m=u.tool,h=m.result===void 0?"(running)":m.isError?"ERROR: "+Pr(W_(m.result),160):X_(m,p?120:60)||"ok";s.push(`[${u.n}] ${Va(m,p?160:80)} \u2192 ${h}`),s.push(...c.get(u.n)??[]),d++}return{brief:e,followups:n,steps:r,log:s.join(`
2085
+ `),facts:tR(r),...a,tests:Q_(r),lastAt:o}}function Q_(t){for(let e=t.length-1;e>=0;e--){let n=t[e].tool,r=pf(n);if(!r||!J_.test(r)||n.result===void 0)continue;let s=(ws(n.result).split(`
2086
+ `).filter(o=>/\b\d+\s+(passed|failed)\b/i.test(o)).at(-1)??"").trim().replace(/^tests?:?\s+/i,""),i=n.isError||/\b[1-9]\d*\s+failed\b/i.test(s)?"red":/\bpassed\b/i.test(s)?"green":"unknown";return{n:t[e].n,state:i,line:Pr(s,90),ms:Fw(n)}}}function Z_(t,e,n){let r=t.flatMap(u=>u.tools),s=[],i=[],o;for(let u of t)if(u.role!=="fork"){if(u.role==="user"){o===void 0&&!u.agent?o=u.at:u.at&&i.push(u.at);continue}u.at&&s.push(u.at);for(let p of u.tools)p.at&&s.push(p.at),p.doneAt&&s.push(p.doneAt)}let a=o??e[0]?.tool.at??n,l=[];for(let u of i){let p=-1/0;for(let h of s)h<=u&&h>p&&(p=h);let m=r.some(h=>h.at!==void 0&&h.at<u&&(h.doneAt??1/0)>u);p>-1/0&&!m&&u-p>=q_&&l.push([p,u])}let c=u=>l.reduce((p,[m,h])=>p+Math.max(0,Math.min(u,h)-m),0),f=u=>Math.max(0,u-a-c(u)),d=[];e.forEach((u,p)=>{let m=e[p-1]?.tool,h=p===0?a:m?.doneAt??m?.at??a;d.push(Math.min(n,Math.max(d[p-1]??a,h)))}),e.forEach((u,p)=>{let m=d[p],h=d[p+1]??n,g=m,x=!0;for(let[O,C]of l){if(C<=m||O>=h)continue;let E=x&&p>0?e[p-1]:u;O>g&&E.parts.push({from:f(g),to:f(O)}),g=Math.max(g,C),x=!1}h>g&&u.parts.push({from:f(g),to:f(h)})});for(let u of e)u.wall=u.parts.reduce((p,m)=>p+m.to-m.from,0);return{span:f(n),idle:c(n),wakes:i.filter(u=>u>a&&u<n).map(f),toolMs:eR(e,n)}}function eR(t,e){let n=t.map(i=>i.tool).filter(i=>i.at!==void 0).sort((i,o)=>i.at-o.at),r=0,s=-1/0;for(let i of n){let o=i.doneAt??e;o>s&&(r+=o-Math.max(i.at,s),s=o)}return r}function tR(t){let e=[],n=t.filter(o=>o.tool.isError);n.length&&e.push(`${n.length} of ${t.length} steps failed.`);let r=new Map;for(let o of n){let a=Va(o.tool,60);r.set(a,[...r.get(a)??[],o.n])}for(let[o,a]of r)a.length>1&&e.push(`${o} failed ${a.length} times (steps ${a.join(", ")}).`);let s=t.slice(-20).filter(o=>o.tool.isError).length;s>=4&&e.push(`${s} of the last 20 steps failed.`);for(let o of t)if(o.wall>=U_){let a=Fw(o.tool),l=a!==void 0&&a<o.wall/2?`: the call ran ${Se(a)}, the rest was the model before it`:"";e.push(`Step ${o.n} (${Va(o.tool,60)}) took ${Se(o.wall)}${l}.`)}let i=t.reduce((o,a)=>o+a.wall,0);return i&&e.push(`${Se(i)} in all over ${t.length} steps.`),e.join(`
2087
+ `)}function Jw(t,e,n){let r=[t.brief,...t.followups].map(i=>e.get(i));if(r.some(i=>!i))return;let s={subtasks:r.flatMap(i=>i.subtasks),log:t.log,facts:t.facts,finished:n};return{key:nR(JSON.stringify(s)),payload:s,steps:t.steps.length,followups:t.followups.length}}function nR(t){let e=3735928559,n=1103547991;for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);e=Math.imul(e^s,2654435761),n=Math.imul(n^s,1597334677)}return e=Math.imul(e^e>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),(4294967296*(2097151&n)+(e>>>0)).toString(36)}function hf(t,e,n,r){let s=[],i=0;[t.brief,...t.followups].forEach((o,a)=>{let l=e.get(o);a>0&&s.push({kind:"group",request:l?.request??"",idx:a});for(let c of l?.subtasks??[]){i++;let f=t.brief+`
2088
+ `+c,d=n?.rows.find(p=>p.id===i);d?.status==="done"&&!r.has(f)&&r.set(f,d),d=r.get(f)??d;let u=d?.steps??[];s.push({kind:"row",num:i,title:c,status:d?.status??"",did:d?.did??"",note:d?.note??"",steps:u,cite:d?.evidence?.length?d.evidence:u,ms:0,spans:[]})}});for(let o of n?.offBrief??[])s.push({kind:"row",title:o.what,status:"off",did:"",note:o.note,steps:o.steps,cite:o.steps,ms:0,spans:[]});return rR(s,t),s}function rR(t,e){let n=t.filter(o=>o.kind==="row"),r=e.steps.map(o=>n.find(a=>Y_(o.n,a.steps))),s=r.find(Boolean);if(!s)return;let i=s;for(let o=0;o<r.length;o++)r[o]=i=r[o]??i;e.steps.forEach((o,a)=>{let l=r[a];l.ms+=o.wall;for(let c of o.parts){let f=l.spans.at(-1);f&&Math.abs(f.to-c.from)<1e3?f.to=Math.max(f.to,c.to):l.spans.push({...c})}})}function Ww(t,e,n,r){let s=t.tests,i=e&&e.followups===t.followups.length,o=t.followups.length?n.get(t.followups.at(-1))?.request:void 0;return[["Now",i?e.data.now:o?`Working on the latest follow-up: ${o}`:r?"\u2026":""],["Tests",s?`${s.state}${s.line?`, ${s.line}`:""}${s.ms!==void 0?`, took ${Se(s.ms)}`:""} (step ${s.n})`:"",s?`tests-${s.state}`:void 0],["Time",t.span&&t.steps.length?`${Se(t.toolMs)} in tools, ${Se(Math.max(0,t.span-t.toolMs))} in the model${t.idle?`, ${Se(t.idle)} stopped`:""}`:""],["Needs a decision",i?e.data.decision:"","warn"]].filter(([,l])=>l)}function Kw(t,e){let n=new Map,r=o=>{let a=o.trim().replace(/^["']|["']$/g,"").replace(/\\/g,"/").replace(/^\/([a-zA-Z])\//,"$1:/"),l=ny(a,e).replace(/^\.\//,"");return!l||/^([a-zA-Z]:)?\//.test(l)?void 0:l},s=(o,a={})=>{let l=r(o);if(!l)return;let c=n.get(l)??{path:l};c.deleted=a.deleted,a.from&&(c.from=a.from),n.set(l,c)},i=(o,a)=>{let l=r(o),c=l?n.get(l):void 0;l&&n.delete(l),s(a,{from:c?.from??l})};for(let{tool:o}of t.steps){if(o.isError)continue;let a=o.input??{},l=!1;for(let[d,u]of Object.entries(a)){if(d==="command"||d==="cmd"||typeof u!="string"||!/^(---|\+\+\+) /m.test(u))continue;let p;for(let m of u.split(`
2089
+ `)){let h=/^(---|\+\+\+) (?:[ab]\/)?(.+?)\s*$/.exec(m);if(h?.[1]==="---"){p=h[2];continue}if(h?.[1]==="+++"){l=!0,h[2]==="/dev/null"?p&&p!=="/dev/null"&&s(p,{deleted:!0}):s(h[2]);continue}let g=/^\*\*\* Move to: (.+?)\s*$/.exec(m);g&&p&&i(p,g[1])}}let c=ge(a.file_path)??ge(a.filePath)??ge(a.path);!l&&c&&sR.some(d=>d in a)&&s(c);let f=pf(o);if(f)for(let d of iR(f))d.to?i(d.from,d.to):s(d.from,{deleted:!0})}return[...n.values()]}function iR(t){let e=[];for(let n of t.split(/&&|\|\||[;|\n]/)){let r=n.trim().match(/"[^"]*"|'[^']*'|\S+/g)??[],s=r.indexOf("git"),i=r[s+1];if(s<0||i!=="rm"&&i!=="mv"||r.includes("--cached"))continue;let o=r.slice(s+2).filter(l=>!l.startsWith("-")).map(l=>l.replace(/^["']|["']$/g,""));if(i==="rm"){for(let l of o)e.push({from:l});continue}let a=o.pop();if(a)for(let l of o)e.push({from:l,to:o.length>1?`${a.replace(/\/+$/,"")}/${Ou(l)}`:a})}return e}function Hw(t){let{d:e}=t,n=t.working?`running, step ${e.steps.length}${aR(e,t.now)}`:`finished after ${e.steps.length} steps`,r=[`Sub-agent "${t.name}": ${n}, ${Se(e.span)} active${e.lastAt?`, as of ${V_(e.lastAt)}`:""}.`];r.push("",`Request: ${e.brief?t.plans.get(e.brief)?.request??"(not summarized yet)":G_}`);for(let s of t.lines){if(s.kind==="group"){r.push("",`Follow-up: ${s.request||"(not summarized yet)"}`);continue}let i=s.ms?` (${Se(s.ms)})`:"";r.push(`- ${s.title}: ${z_(s.status||"pending")}.${s.did?` ${s.did}`:""}${i}`),s.note&&r.push(` Note: ${s.note}`)}t.edited.length&&r.push("","Edited:",...t.edited.map(oR)),t.facts.length&&r.push("");for(let[s,i]of t.facts)r.push(`${s}: ${i}`);return r.join(`
2090
+ `)}function aR(t,e){let n=[...t.steps].reverse().find(r=>r.tool.result===void 0&&r.tool.at);return n?`, waiting ${Se(e-n.tool.at)} on ${Va(n.tool,60)}`:t.lastAt?`, last activity ${Se(e-t.lastAt)} ago`:""}function zw(t){let e=t??{},n=r=>Array.isArray(r)?r.filter(Array.isArray).map(s=>[Number(s[0]),s[1]===void 0?void 0:Number(s[1])]).filter(s=>s[0]>0):[];return{now:String(e.now??""),decision:String(e.decision??""),rows:(Array.isArray(e.rows)?e.rows:[]).map(r=>({id:Number(r.id),status:String(r.status??""),did:String(r.did??""),note:String(r.note??""),steps:n(r.steps),evidence:n(r.evidence)})),offBrief:(Array.isArray(e.offBrief)?e.offBrief:[]).map(r=>({what:String(r.what??""),note:String(r.note??""),steps:n(r.steps)}))}}function Yw(t){let e=t;return{request:String(e?.request??""),subtasks:Array.isArray(e?.subtasks)?e.subtasks.map(n=>String(n).replace(/[.\s]+$/,"")):[]}}var F_,U_,q_,jw,J_,Pr,ni,W_,K_,H_,Va,pf,Fw,z_,Y_,V_,G_,sR,oR,Vw=S(()=>{"use strict";Po();F_=30,U_=3*6e4,q_=6e4,jw=new Set(["Read","Grep","Glob"]),J_=/\b(vitest|jest|pytest|mocha|playwright test|go test|cargo test|dotnet test|(?:npm|pnpm|yarn|bun)(?: run)? test)\b/,Pr=(t,e)=>(t=ws(t).replace(/\s+/g," ").trim(),t.length>e?t.slice(0,e)+"\u2026":t),ni=(t,e)=>t.length<=e?t:t.slice(0,e/2)+`
2091
2091
  [\u2026]
2092
- `+t.slice(-e/2),J_=t=>t.split(`
2093
- `).find(e=>e.trim())??"",W_=t=>t.split(`
2094
- `).reverse().find(e=>e.trim())??"",K_=t=>t.replace(/^(\s*(cd\s+\S+|export\s+PATH=\S+)\s*(;|&&)\s*)+/,""),Va=(t,e)=>`${Cu(t.name)}: ${Or(K_(Pu(t.input)),e)}`,pf=t=>ge(t.input?.command)??ge(t.input?.cmd),Bw=t=>t.at!==void 0&&t.doneAt!==void 0?t.doneAt-t.at:void 0,H_=t=>t==="off"?"off brief":t.replace("_"," "),z_=(t,e)=>e.some(([n,r])=>t>=n&&t<=(r??n)),Y_=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),V_="No readable brief on record, so no subtasks to judge.";rR=["content","diff","new_string","new_source","edits"];iR=t=>t.deleted?`${t.path} (deleted)`:t.from?`${t.path} (moved from ${t.from})`:t.path});import{readFileSync as aR,writeFileSync as lR,mkdirSync as cR}from"fs";import{join as Yw}from"path";import{createHash as uR}from"crypto";function Vw(t,e){if(!t.listChildren)return[];let n=t.callerSessionId?.(e),r=ti(t.listSessionFiles(e),i=>i.mtime).sort((i,o)=>+(o.sessionId===n)-+(i.sessionId===n)),s=[];for(let i of r){let o=t.listChildren(e,i.sessionId);if(!o.length)continue;let a=Ya(t,i.sessionId,e,i.file);s.push({sessionId:i.sessionId,children:o.map(l=>({...l,state:ei(l,a)}))})}return s}function Gw(t,e){let n=e.trim().toLowerCase();for(let r of t){let s=r.children.filter(o=>o.id.toLowerCase()===n);if(s.length)return s;let i=r.children.filter(o=>o.id.toLowerCase().startsWith(n)||Cn(o).toLowerCase().includes(n));if(i.length)return i}return[]}async function mf(t,e){let n=Fw(jw(Mw(t,e.file,"child"))),r=Yw(ze(),"cache","child-status",`${dR(e.file)}.json`),s={plans:{},frozen:{}};try{s={...s,...JSON.parse(aR(r,"utf8"))}}catch{}let i=new Map(Object.entries(s.plans)),o=new Map(Object.entries(s.frozen)),a,l=!1,c=m=>{a??=m.error,l||=!!m.setup},f=[n.brief,...n.followups].filter(m=>m&&!i.has(m));for(let[m,h]of await Promise.all(f.map(async g=>[g,await Zs("plan",g)])))h.ok?i.set(m,Hw(h.data)):c(h);let d=s.status,u=n.brief?Uw(n,i,e.state!=="running"):void 0,p=!!u&&d?.key!==u.key;if(u&&p){let m=await Zs("status",u.payload);m.ok?d={key:u.key,data:Kw(m.data),steps:u.steps,followups:u.followups,at:Date.now()}:c(m)}hf(n,i,d?.data,o);try{cR(Yw(r,".."),{recursive:!0}),lR(r,JSON.stringify({plans:Object.fromEntries(i),frozen:Object.fromEntries(o),status:d}))}catch{}return{d:n,plans:i,frozen:o,judged:d,error:a,setup:l,cached:!f.length&&!p}}async function Xw(t,e,n){let{d:r,plans:s,frozen:i,judged:o,error:a}=await mf(t,n);return{text:Ww({d:r,lines:hf(r,s,o?.data,i),facts:qw(r,o,s,!1),edited:Jw(r,e),plans:s,name:Cn(n),working:n.state==="running",now:Date.now()}),error:a}}var dR,gf=S(()=>{"use strict";Tn();uf();df();Qs();ff();zw();dR=t=>uR("sha1").update(t).digest("hex")});import{existsSync as Qw,openSync as fR,readSync as pR,closeSync as hR,statSync as ri,readdirSync as Zw,watchFile as mR,unwatchFile as ev,mkdirSync as gR,writeFileSync as yR,readFileSync as yf,unlinkSync as bR,rmSync as wR}from"fs";import{stat as vR}from"fs/promises";import{dirname as SR,join as _n,resolve as tv}from"path";function AR(t){if(!Number.isInteger(t))return!0;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Pr(t){let e={cwd:V,sessionId:"",sessionStartMs:Date.now(),buffer:[],partial:"",offset:0,latest:{in:0,out:0,cached:0,cacheCreate:0},latestModel:null,everAttached:!1,index:za(t),thread:"main"},n;function r(y,v){let w={offset:v,text:""},T;try{T=ri(y).size}catch{return w}if(T<=v)return w;let $;try{$=fR(y,"r")}catch{return w}try{let j=T-v,D=Buffer.alloc(j),H=0;for(;H<j;){let X=pR($,D,H,j-H,v+H);if(!X)break;H+=X}return{offset:v+H,text:D.subarray(0,H).toString("utf8")}}finally{hR($)}}let s=new Set,i,o=0;function a(){if(e.file){for(let y of s)if(y.file===e.file)return y;return}return i}function l(y){let v={d:t.createDriver(e.cwd,y),file:y,id:`new:${++o}`,startedAt:Date.now()};return s.add(v),e.file||(i=v),v}function c(){let y=[...s].filter(w=>w.file);if(!y.length)return[];let v=new Map(t.listSessionFiles(e.cwd).map(w=>[w.file,w.sessionId]));return y.map(w=>{let T=v.get(w.file);return{rec:w,sessionId:T??w.id,pending:T===void 0}})}let f=()=>c().filter(y=>y.pending&&y.rec.prompt!==void 0);async function d(y){s.delete(y),i===y&&(i=void 0);try{await y.d.dispose()}catch(v){console.error("[composer] dispose:",Y(v))}}function u(){let y=a(),v=new Set(f().map(w=>w.rec));for(let w of[...s])w!==y&&(v.has(w)||w.d.streaming||w.d.queue||w.d.error||d(w))}function p(){for(let y of s)y.d.sessionFile&&y.file!==y.d.sessionFile&&(y.file=y.d.sessionFile);if(i&&!e.file&&i.file){let y=t.listSessionFiles(e.cwd).find(v=>v.file===i.file);y&&Q(y)}i&&!e.file&&i.prompt!==void 0&&e.sessionId!==i.id&&(U(void 0,i.id),e.everAttached=!0)}let m=y=>_n(y,xR),h=(y,v)=>_n(m(y),`${v}.lock`);function g(y,v){try{let w=h(y,v);if(Date.now()-ri(w).mtimeMs>=nv)return!1;try{let T=parseInt(yf(w,"utf8").trim(),10);if(T===process.pid||!AR(T))return!1}catch{}return!0}catch{return!1}}function E(y,v){if(v)try{gR(m(y),{recursive:!0}),yR(h(y,v),String(process.pid))}catch(w){console.error("[lock] claim failed:",Y(w))}}function O(y){try{wR(_n(y,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function C(y){let v=m(y);if(!Qw(v))return;let w;try{w=Zw(v)}catch{return}let T=Date.now();for(let $ of w){if(!$.endsWith(".lock"))continue;let j=_n(v,$);try{let D=ri(j);T-D.mtimeMs>ER&&bR(j)}catch{}}}function x(y){try{return ri(y),!1}catch(v){return v.code==="ENOENT"}}function R(){let y=e;if(y.file&&!x(y.file)){E(y.cwd,y.sessionId);return}let v=I(y);v&&Q(v)}function I(y){if(!y.everAttached)return L(y.cwd)??A(y.cwd,()=>!0)}function L(y){let v=m(y);if(!Qw(v))return;let w;try{w=Zw(v)}catch{return}let T;for(let j of w)if(j.endsWith(".lock"))try{let D=ri(_n(v,j));if(Date.now()-D.mtimeMs>=nv||parseInt(yf(_n(v,j),"utf8").trim(),10)!==process.pid)continue;(!T||D.mtimeMs>T.mtime)&&(T={sessionId:j.slice(0,-5),mtime:D.mtimeMs})}catch{}if(!T)return;let $=t.listSessionFiles(y).find(j=>j.sessionId===T.sessionId);if(!(!$||x($.file)))return $}function A(y,v){return t.listSessionFiles(y).sort((w,T)=>T.mtime-w.mtime).find(w=>!g(y,w.sessionId)&&v(w))}function U(y,v){let w=e;if(w.file)try{ev(w.file)}catch{}w.file=y,w.sessionId=v,w.partial="",w.offset=0,w.latest={in:0,out:0,cached:0,cacheCreate:0},w.latestModel=null,w.index=za(t),w.chainLastId=void 0,w.buffer.push({type:"cleared"}),w.buffer.push({type:"session",sessionId:v})}function Q(y){let v=e;i=void 0,wi(),n=y.file,U(y.file,y.sessionId),v.everAttached=!0,E(v.cwd,y.sessionId),G(y.file)}function G(y){if(me(),!!y){try{ev(y)}catch{}mR(y,{interval:200},()=>me())}}function F(){wi(),n=void 0,U(void 0,"")}function me(){let y=e;if(!y.file)return;let v=r(y.file,y.offset);if(!v.text)return;y.offset=v.offset,y.partial+=v.text;let w=y.partial.lastIndexOf(`
2092
+ `+t.slice(-e/2),W_=t=>t.split(`
2093
+ `).find(e=>e.trim())??"",K_=t=>t.split(`
2094
+ `).reverse().find(e=>e.trim())??"",H_=t=>t.replace(/^(\s*(cd\s+\S+|export\s+PATH=\S+)\s*(;|&&)\s*)+/,""),Va=(t,e)=>`${Cu(t.name)}: ${Pr(H_(Pu(t.input)),e)}`,pf=t=>ge(t.input?.command)??ge(t.input?.cmd),Fw=t=>t.at!==void 0&&t.doneAt!==void 0?t.doneAt-t.at:void 0,z_=t=>t==="off"?"off brief":t.replace("_"," "),Y_=(t,e)=>e.some(([n,r])=>t>=n&&t<=(r??n)),V_=t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),G_="No readable brief on record, so no subtasks to judge.";sR=["content","diff","new_string","new_source","edits"];oR=t=>t.deleted?`${t.path} (deleted)`:t.from?`${t.path} (moved from ${t.from})`:t.path});import{readFileSync as lR,writeFileSync as cR,mkdirSync as uR}from"fs";import{join as Gw}from"path";import{createHash as dR}from"crypto";function Xw(t,e){if(!t.listChildren)return[];let n=t.callerSessionId?.(e),r=ti(t.listSessionFiles(e),i=>i.mtime).sort((i,o)=>+(o.sessionId===n)-+(i.sessionId===n)),s=[];for(let i of r){let o=t.listChildren(e,i.sessionId);if(!o.length)continue;let a=Ya(t,i.sessionId,e,i.file);s.push({sessionId:i.sessionId,children:o.map(l=>({...l,state:ei(l,a)}))})}return s}function Qw(t,e){let n=e.trim().toLowerCase();for(let r of t){let s=r.children.filter(o=>o.id.toLowerCase()===n);if(s.length)return s;let i=r.children.filter(o=>o.id.toLowerCase().startsWith(n)||Cn(o).toLowerCase().includes(n));if(i.length)return i}return[]}async function mf(t,e){let n=qw(Uw(Bw(t,e.file,"child"))),r=Gw(ze(),"cache","child-status",`${fR(e.file)}.json`),s={plans:{},frozen:{}};try{s={...s,...JSON.parse(lR(r,"utf8"))}}catch{}let i=new Map(Object.entries(s.plans)),o=new Map(Object.entries(s.frozen)),a,l=!1,c=m=>{a??=m.error,l||=!!m.setup},f=[n.brief,...n.followups].filter(m=>m&&!i.has(m));for(let[m,h]of await Promise.all(f.map(async g=>[g,await Zs("plan",g)])))h.ok?i.set(m,Yw(h.data)):c(h);let d=s.status,u=n.brief?Jw(n,i,e.state!=="running"):void 0,p=!!u&&d?.key!==u.key;if(u&&p){let m=await Zs("status",u.payload);m.ok?d={key:u.key,data:zw(m.data),steps:u.steps,followups:u.followups,at:Date.now()}:c(m)}hf(n,i,d?.data,o);try{uR(Gw(r,".."),{recursive:!0}),cR(r,JSON.stringify({plans:Object.fromEntries(i),frozen:Object.fromEntries(o),status:d}))}catch{}return{d:n,plans:i,frozen:o,judged:d,error:a,setup:l,cached:!f.length&&!p}}async function Zw(t,e,n){let{d:r,plans:s,frozen:i,judged:o,error:a}=await mf(t,n);return{text:Hw({d:r,lines:hf(r,s,o?.data,i),facts:Ww(r,o,s,!1),edited:Kw(r,e),plans:s,name:Cn(n),working:n.state==="running",now:Date.now()}),error:a}}var fR,gf=S(()=>{"use strict";Tn();uf();df();Qs();ff();Vw();fR=t=>dR("sha1").update(t).digest("hex")});import{existsSync as ev,openSync as pR,readSync as hR,closeSync as mR,statSync as ri,readdirSync as tv,watchFile as gR,unwatchFile as nv,mkdirSync as yR,writeFileSync as bR,readFileSync as yf,unlinkSync as wR,rmSync as vR}from"fs";import{stat as SR}from"fs/promises";import{dirname as kR,join as _n,resolve as rv}from"path";function TR(t){if(!Number.isInteger(t))return!0;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function Cr(t){let e={cwd:V,sessionId:"",sessionStartMs:Date.now(),buffer:[],partial:"",offset:0,latest:{in:0,out:0,cached:0,cacheCreate:0},latestModel:null,everAttached:!1,index:za(t),thread:"main"},n;function r(y,v){let w={offset:v,text:""},T;try{T=ri(y).size}catch{return w}if(T<=v)return w;let $;try{$=pR(y,"r")}catch{return w}try{let j=T-v,D=Buffer.alloc(j),H=0;for(;H<j;){let G=hR($,D,H,j-H,v+H);if(!G)break;H+=G}return{offset:v+H,text:D.subarray(0,H).toString("utf8")}}finally{mR($)}}let s=new Set,i,o=0;function a(){if(e.file){for(let y of s)if(y.file===e.file)return y;return}return i}function l(y){let v={d:t.createDriver(e.cwd,y),file:y,id:`new:${++o}`,startedAt:Date.now()};return s.add(v),e.file||(i=v),v}function c(){let y=[...s].filter(w=>w.file);if(!y.length)return[];let v=new Map(t.listSessionFiles(e.cwd).map(w=>[w.file,w.sessionId]));return y.map(w=>{let T=v.get(w.file);return{rec:w,sessionId:T??w.id,pending:T===void 0}})}let f=()=>c().filter(y=>y.pending&&y.rec.prompt!==void 0);async function d(y){s.delete(y),i===y&&(i=void 0);try{await y.d.dispose()}catch(v){console.error("[composer] dispose:",Y(v))}}function u(){let y=a(),v=new Set(f().map(w=>w.rec));for(let w of[...s])w!==y&&(v.has(w)||w.d.streaming||w.d.queue||w.d.error||d(w))}function p(){for(let y of s)y.d.sessionFile&&y.file!==y.d.sessionFile&&(y.file=y.d.sessionFile);if(i&&!e.file&&i.file){let y=t.listSessionFiles(e.cwd).find(v=>v.file===i.file);y&&Z(y)}i&&!e.file&&i.prompt!==void 0&&e.sessionId!==i.id&&(F(void 0,i.id),e.everAttached=!0)}let m=y=>_n(y,ER),h=(y,v)=>_n(m(y),`${v}.lock`);function g(y,v){try{let w=h(y,v);if(Date.now()-ri(w).mtimeMs>=sv)return!1;try{let T=parseInt(yf(w,"utf8").trim(),10);if(T===process.pid||!TR(T))return!1}catch{}return!0}catch{return!1}}function x(y,v){if(v)try{yR(m(y),{recursive:!0}),bR(h(y,v),String(process.pid))}catch(w){console.error("[lock] claim failed:",Y(w))}}function O(y){try{vR(_n(y,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function C(y){let v=m(y);if(!ev(v))return;let w;try{w=tv(v)}catch{return}let T=Date.now();for(let $ of w){if(!$.endsWith(".lock"))continue;let j=_n(v,$);try{let D=ri(j);T-D.mtimeMs>AR&&wR(j)}catch{}}}function E(y){try{return ri(y),!1}catch(v){return v.code==="ENOENT"}}function R(){let y=e;if(y.file&&!E(y.file)){x(y.cwd,y.sessionId);return}let v=I(y);v&&Z(v)}function I(y){if(!y.everAttached)return L(y.cwd)??A(y.cwd,()=>!0)}function L(y){let v=m(y);if(!ev(v))return;let w;try{w=tv(v)}catch{return}let T;for(let j of w)if(j.endsWith(".lock"))try{let D=ri(_n(v,j));if(Date.now()-D.mtimeMs>=sv||parseInt(yf(_n(v,j),"utf8").trim(),10)!==process.pid)continue;(!T||D.mtimeMs>T.mtime)&&(T={sessionId:j.slice(0,-5),mtime:D.mtimeMs})}catch{}if(!T)return;let $=t.listSessionFiles(y).find(j=>j.sessionId===T.sessionId);if(!(!$||E($.file)))return $}function A(y,v){return t.listSessionFiles(y).sort((w,T)=>T.mtime-w.mtime).find(w=>!g(y,w.sessionId)&&v(w))}function F(y,v){let w=e;if(w.file)try{nv(w.file)}catch{}w.file=y,w.sessionId=v,w.partial="",w.offset=0,w.latest={in:0,out:0,cached:0,cacheCreate:0},w.latestModel=null,w.index=za(t),w.chainLastId=void 0,w.buffer.push({type:"cleared"}),w.buffer.push({type:"session",sessionId:v})}function Z(y){let v=e;i=void 0,wi(),n=y.file,F(y.file,y.sessionId),v.everAttached=!0,x(v.cwd,y.sessionId),te(y.file)}function te(y){if(ne(),!!y){try{nv(y)}catch{}gR(y,{interval:200},()=>ne())}}function U(){wi(),n=void 0,F(void 0,"")}function ne(){let y=e;if(!y.file)return;let v=r(y.file,y.offset);if(!v.text)return;y.offset=v.offset,y.partial+=v.text;let w=y.partial.lastIndexOf(`
2095
2095
  `);if(w<0)return;let T=y.index.add(y.partial.slice(0,w).split(`
2096
- `),y.thread);if(y.partial=y.partial.slice(w+1),!T)return;let $=[],{entries:j}=y.index,D=j.get(T),H=!1;for(;D;){if($.push(D),t.idOf(D)===y.chainLastId){H=!0;break}let X=t.parentOf(D);D=X?j.get(X):void 0}if(H)for(let X=$.length-2;X>=0;X--)ue($[X]);else{y.chainLastId!==void 0&&(y.buffer.push({type:"cleared"}),y.buffer.push({type:"session",sessionId:y.sessionId}),y.latest={in:0,out:0,cached:0,cacheCreate:0});let X=new Set($.map(ae=>t.idOf(ae))),ut=pe(j);for(let ae=$.length-1;ae>=0;ae--)ue($[ae]),Ie(t.idOf($[ae]),ut,X)}y.chainLastId=T}function pe(y){let v=new Map;for(let w of y.values()){let T=t.parentOf(w);if(!T)continue;let $=v.get(T);$?$.push(w):v.set(T,[w])}return v}function Ie(y,v,w){if(!y)return;let T=v.get(y);if(!T)return;let $=T.filter(X=>!t.isSidechain(X,e.thread));if($.length<2)return;let j=$.filter(X=>!w.has(t.idOf(X)));if(!j.length)return;let D=[],H=0;for(let X of j){let ut=ct(X,v);D.push(...ut.events),H+=ut.count}H>0&&e.buffer.push({type:"fork",atId:y,count:H,events:D})}function ct(y,v){let w=[],T=[y];for(;T.length;){let D=T.pop();if(t.isSidechain(D,e.thread))continue;w.push(D);let H=v.get(t.idOf(D)??"");if(H)for(let X of H)T.push(X)}w.sort((D,H)=>(Date.parse(t.timestampOf(D)??"")||0)-(Date.parse(t.timestampOf(H)??"")||0));let $=[];for(let D of w)t.isRecoveryNoise(D)||$.push(...Ha(t,D,e.thread,e.sessionStartMs).events);return{count:$.reduce((D,H)=>D+(H.type==="user"||H.type==="assistant"?1:0),0),events:$}}function ue(y){if(!t.isSidechain(y,e.thread))try{let{events:v,usage:w,model:T,cost:$}=Ha(t,y,e.thread,e.sessionStartMs);for(let j of v)e.buffer.push(j);v.some(j=>j.type==="assistant")&&a()?.d.clearCompletedDraft(),v.some(j=>j.type==="user")&&a()?.d.clearEcho(),T&&(e.latestModel=T),w&&(e.latest=w),(w||$)&&e.buffer.push({type:"usage",...e.latest,cost:$})}catch(v){console.error("[mirror] skipped malformed entry:",Y(v))}}async function Ae(){return{cwd:e.cwd,pid:process.pid,composer:!!t.createDriver,children:!!t.listChildren,childStatus:!!t.listChildren&&t.childBriefs,elsewhere:await Tt()}}async function Tt(){if(t.listSessionFiles(e.cwd).length)return;let y=await Pn();if(!y)return;let v=tv(y).toLowerCase();for(let w=tv(e.cwd);w.toLowerCase()!==v;){let T=SR(w);if(T===w)return;w=T;let $=t.listSessionFiles(w).length;if($)return{dir:w,count:$}}}Tt().then(y=>{y&&console.log(`No sessions for ${e.cwd} \u2014 ${y.count} exist for ${y.dir}. Launched from a subfolder? Relaunch from the project root.`)}).catch(()=>{});let b=new Ua;async function k(y,v){e.thread!=="child"&&b.accept(y,v)&&console.log(v)}function P(){return Ya(t,e.sessionId,e.cwd,e.file)}function N(){return t.chainWorking([...e.index.entries.values()])&&P()}function M(){!t.createDriver||a()||e.latestModel||N()||l(e.file)}async function W(y){let v=e;R(),p(),M(),u();let w=a();for(let D of s)D!==w&&D.d.dialog;let T=c().filter(D=>D.rec.d.streaming).map(D=>D.sessionId),$=N(),j=t.createDriver?{streaming:!!w?.d.streaming,foreign:!w&&$,draft:w?.d.draft??null,echo:w?.d.echo??null,status:w?.d.status??null,dialog:w?.d.dialog??null,queue:w?.d.queue??null,stats:w?.d.stats??null,model:w?.d.model??null,error:w?.d.error}:void 0;return{events:v.buffer.slice(y),cursor:v.buffer.length,working:!!w?.d.streaming||$,latestModel:v.latestModel,child:v.child?.id??null,composer:j,busy:T}}async function q(){R(),p();let y=a();if(y?.d.error&&!y.d.streaming&&(await d(y),y=void 0),!y){if(N())return{ok:!1,error:"the agent is mid-turn in a terminal \u2014 watch only"};y=l(e.file)}let v=y;return{ok:!0,d:v.d,markSent:w=>{v.prompt===void 0&&(v.prompt=w)}}}async function qe(y,v){if(!t.createDriver)return{ok:!1,error:"not supported"};let w=String(y??"").trim();if(!w)return{ok:!1,error:"empty message"};let T=await q();if(!T.ok)return T;let $=await T.d.send(w,v);return $.ok&&T.markSent(w),$}async function z(y,v){let w=a();return w?w.d.respondUi(String(y??""),v??{}):{ok:!1,error:"no dialog pending"}}async function oe(y,v){if(!t.createDriver)return{ok:!1,error:"not supported"};if(!y||typeof y.type!="string")return{ok:!1,error:"bad command"};if(v?.spawn){let T=await q();return T.ok?T.d.rpc(y):T}let w=a();return!w||w.d.error?{ok:!1,error:"not running"}:w.d.rpc(y)}async function Te(){let y=a();if(y)try{await y.d.stop()}catch(v){console.error("[composer] stop:",Y(v))}return{ok:!0}}async function Lr(){return t.createDriver?(p(),!e.file&&i&&i.prompt===void 0&&!i.d.streaming&&!i.d.error?{ok:!0}:(i?.d.error&&await d(i),i=void 0,F(),l(void 0),u(),{ok:!0})):{ok:!1,error:"not supported"}}async function tn(){if(!t.createDriver)return[];let y=await et(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),v=y!==null?y.split(`
2097
- `).filter(Boolean):await t.walkFiles?.(e.cwd)??[];return(await Promise.all(v.map(async T=>{try{return{f:T,m:(await vR(_n(e.cwd,T))).mtimeMs}}catch{return{f:T,m:0}}}))).sort((T,$)=>$.m-T.m).map(T=>T.f)}function Ot(){for(let y of[...s])d(y)}async function Al(y){return t.createDriver?Pw(e.cwd,y):{ok:!1,error:"not supported"}}async function Tl(y){return Cw(e.cwd,String(y??""))}async function rk(y,v){return Lw(String(y??""),String(v??""))}async function sk(y,v){return Zs(y==="status"?"status":"plan",v)}async function ik(y){let v=t.listChildren?.(e.cwd,e.sessionId).find(T=>T.id===y);if(!v)return{ok:!1,error:"child not found"};let w=await mf(t,{...v,state:ei(v,P())});return{ok:!0,plans:Object.fromEntries(w.plans),frozen:Object.fromEntries(w.frozen),judged:w.judged,error:w.error,setup:w.setup,cached:w.cached}}async function ok(){let y=t.sessionsWorking?.(e.cwd),v=t.listSessionFiles(e.cwd).map(({sessionId:T,file:$,mtime:j})=>({sessionId:T,mtime:j,preview:t.readPreview($),working:y?.has(T)})),w=f().map(T=>({sessionId:T.sessionId,mtime:T.rec.startedAt,preview:T.rec.prompt??"",pending:!0}));return ti([...v,...w],T=>T.mtime)}let dp=new Map;function fp(y,v){let w=dp.get(y);if(w&&w.mtime===v)return w.turns;let T=[],$="";try{$=yf(y,"utf8")}catch{return[]}for(let j of $.split(`
2098
- `)){if(!j.trim())continue;let D=t.parseEntry(j);if(!D)continue;let H=t.searchText(D);H&&T.push({text:H,lower:H.toLowerCase()})}return dp.set(y,{mtime:v,turns:T}),T}async function ak(y){let v=y.toLowerCase(),w=[],T=0,$=t.sessionsWorking?.(e.cwd);for(let{sessionId:j,file:D,mtime:H}of t.listSessionFiles(e.cwd).sort((X,ut)=>ut.mtime-X.mtime)){let X=Gs(fp(D,H),v),ut=(t.listChildren?.(e.cwd,j)??[]).map(ae=>({c:ae,hit:Gs(fp(ae.file,ae.mtime),v)})).filter(ae=>ae.hit.hitCount);if(!(!X.hitCount&&!ut.length)){for(let{c:ae,hit:fk}of ti(ut,pk=>pk.c.mtime))w.push({sessionId:j,mtime:ae.mtime,preview:Cn(ae),...fk,child:{id:ae.id,kind:ae.kind,depth:ae.depth}});if(w.push({sessionId:j,mtime:H,preview:t.readPreview(D),working:$?.has(j),...X}),++T>=TR)break}}return w}async function lk(y){let v=e,w=t.listSessionFiles(v.cwd).find(T=>T.sessionId===y);if(!w){let T=f().find($=>$.sessionId===y)?.rec;return T?((i!==T||v.sessionId!==T.id)&&(i=T,wi(),n=void 0,U(void 0,T.id),v.everAttached=!0,u()),{ok:!0}):{ok:!1,error:"session not found"}}return w.file===v.file?{ok:!0}:(Q(w),p(),u(),{ok:!0})}async function ck(){if(!t.listChildren||!e.sessionId)return[];let y=P();return t.listChildren(e.cwd,e.sessionId).map(v=>({...v,state:ei(v,y)}))}async function uk(y){let v=e;if(!t.listChildren)return{ok:!1,error:"this harness has no child transcripts"};let w=t.listChildren(v.cwd,v.sessionId).find(T=>T.id===y);return w?(v.thread="child",v.child=w,U(w.file,v.sessionId),G(w.file),{ok:!0}):{ok:!1,error:"child not found"}}async function dk(){let y=n;return!wi()||!y?{ok:!0}:(U(y,e.sessionId),G(y),{ok:!0})}function wi(){let y=e;return y.thread==="main"?!1:(y.thread="main",y.child=void 0,!0)}return O(e.cwd),C(e.cwd),R(),{info:Ae,poll:W,logInlineStatus:k,listSessions:ok,searchSessions:ak,attach:lk,listChildren:ck,openChild:uk,closeChild:dk,composerSend:qe,composerStop:Te,composerNew:Lr,composerFiles:tn,composerUiRespond:z,composerRpc:oe,composerPaste:Al,composerPasteRead:Tl,summarizeTurn:rk,childStatus:sk,judgeChildStatus:ik,shutdownComposer:Ot}}var kR,xR,nv,ER,TR,Ga=S(()=>{"use strict";Vt();xw();Vs();sf();_w();uf();df();gf();ff();Qs();kR=".typebulb",xR=`${kR}/locks`,nv=5e3,ER=6e4;TR=50});import{existsSync as Sf,mkdirSync as OR,readFileSync as rv,writeFileSync as PR}from"fs";import{join as Rn,isAbsolute as CR}from"path";async function xf(t,e){let n=CR(t)?t:Rn(V,t);return Sf(n)?(id(n,e),{ok:!0}):{ok:!1,error:"file not found"}}async function Ef(t){let e=V,n=sd(t),r=Rn(e,"typebulbs");OR(r,{recursive:!0});let s=ed(n),i=`${s}.bulb.md`;for(let c=2;Sf(Rn(r,i))&&rv(Rn(r,i),"utf8")!==n;c++)i=`${s}-${c}.bulb.md`;let o=Rn(r,i);Sf(o)||PR(o,n);let a=Rn("typebulbs",i),l=await Ts(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:l.pid,url:l.url}}async function Af(){return Z(V)}async function Tf(t){let e=(await Z()).find(n=>n.pid===t);return e?{ok:!0,outcome:await Ft(e)}:(await tr(t),{ok:!0})}async function Of(){let t=await dn(V);return ea(V).filter(e=>!e.serverOnly).map(e=>({...e,trusted:yn(e.path),lastRunAt:t(e.path)}))}async function Pf(t){let e=t.toLowerCase(),n=[];for(let r of ea(V).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=rv(r.path,"utf8")}catch{continue}let i=[];for(let l of s.split(`
2099
- `)){let c=l.replace(/\s+/g," ").trim();c&&i.push({text:c,lower:c.toLowerCase()})}let{hitCount:o,snippet:a}=Gs(i,e);o&&n.push({path:r.path,hitCount:o,snippet:a})}return n}async function Cf(t,e){let n=V;e!=null&&ar(t,e);let r=await Ts(t,{cwd:n,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function _f(t){return{cap:await nd(t)}}async function Rf(t,e){return ar(t,e),{ok:!0}}async function If(t,e){return Ve(t,e)}async function Nf(){return si&&Date.now()-si.fetchedAt<=RR?si.samples:(bf??=IR().finally(()=>{bf=null}),bf)}async function IR(){try{let t=await fetch(`${_R}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(iv)});if(!t.ok)throw new Error(`HTTP ${t.status}`);let e=await t.json(),n=i=>i.order??Number.MAX_SAFE_INTEGER,r=i=>Date.parse(i.createdAt??"")||0,s=e.filter(i=>i.slug!=="welcome").sort((i,o)=>n(i)-n(o)||r(o)-r(i)).map(i=>({slug:i.slug,name:i.name,description:Ll(i.config)}));return si={samples:s,fetchedAt:Date.now()},s}catch{return si?.samples??[]}}async function $f(t){return kf.test(t)?av(sv,"samples",t,!0):{ok:!1,error:"bad slug"}}async function Mf(){let t=Lf();if(!t)return{bulbs:[]};let e=`${Xa()}
2100
- ${t}`;return Gt?.key===e&&Date.now()-Gt.fetchedAt<=NR?{user:Gt.user,bulbs:Gt.bulbs}:(wf??=$R(e,t).finally(()=>{wf=null}),wf)}async function vf(t,e,n){let r=await fetch(`${t}${e}`,{headers:n,signal:AbortSignal.timeout(iv)});if(!r.ok)throw new Error(`HTTP ${r.status}`);if(!r.headers.get("content-type")?.includes("json"))throw new Error("not json");return r.json()}async function $R(t,e){let n={Authorization:`Bearer ${e}`};try{let r=Xa(),s;try{s=await vf(r,"/api/me",n)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await vf(r,"/api/me",n)}let o=(await vf(r,"/api/scripts/list",n)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:Ll(a.config)}));return Gt={key:t,user:s.slug,bulbs:o,fetchedAt:Date.now()},{user:s.slug,bulbs:o}}catch{return Gt?.key===t?{user:Gt.user,bulbs:Gt.bulbs}:{bulbs:[]}}}async function Df(t,e,n=!1){return!kf.test(e)||!kf.test(t)?{ok:!1,error:"bad slug"}:av(Xa(),t,e,n)}async function av(t,e,n,r){let s=Ia(e,n);try{let i=await La({origin:t,userSlug:e,slug:n,dest:Rn(V,s)},{force:r,token:Lf(),timeoutMs:ov});return i.kind==="conflict"?{ok:!1,conflict:!0,error:"local file differs from the site copy"}:i.kind==="asset-conflict"?{ok:!1,conflict:!0,error:`local assets differ from the site copies (${i.paths.join(", ")})`}:i.kind==="http-error"?{ok:!1,error:`HTTP ${i.status}`}:i.kind==="not-markdown"?{ok:!1,error:`not a bulb (${i.contentType??"no content-type"})`}:{ok:!0,file:s,upToDate:i.kind==="up-to-date"}}catch(i){return{ok:!1,error:i?.message??String(i)}}}async function Bf(t,e=!1){let n=Lf();if(!n)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=$a(t,V,Xa()),s=await Da(r,{token:n,force:e,timeoutMs:ov});return s.kind==="conflict"?{ok:!1,conflict:!0,error:s.message}:s.kind==="asset-error"?{ok:!1,error:`assets sync failed: ${s.message}`}:s.kind==="http-error"?{ok:!1,error:`HTTP ${s.status}: ${s.message}`}:{ok:!0,created:s.created,serverStripped:s.serverStripped}}catch(r){return{ok:!1,error:r?.message??String(r)}}}var _R,sv,RR,iv,ov,si,bf,kf,NR,Gt,wf,Xa,Lf,Qa=S(()=>{"use strict";Tn();Vt();sf();ee();_R="https://api.typebulb.com",sv="https://typebulb.com",RR=3600*1e3,iv=5e3,ov=15e3,si=null,bf=null;kf=/^[a-z0-9][a-z0-9-]*$/,NR=300*1e3,Gt=null,wf=null,Xa=()=>da("TYPEBULB_ORIGIN",V)||sv,Lf=()=>da("TYPEBULB_TOKEN",V)});import{readFileSync as Uf,writeFileSync as cv,mkdirSync as LR,appendFileSync as uv,rmSync as lv}from"fs";import{join as tl,dirname as MR}from"path";import{createServer as DR}from"http";function Xt(t){try{return JSON.parse(Uf(t,"utf8"))}catch{return null}}function el(t,e){LR(MR(t),{recursive:!0}),cv(t,JSON.stringify(e,null,2)+`
2101
- `)}function fv(t,e,n){let r=tl(t,".gitignore"),s="";try{s=Uf(r,"utf8")}catch{}let i=new Set(s.split(/\r?\n/).map(l=>l.trim())),o=e.filter(l=>!i.has(l));if(!o.length)return;let a=s&&!s.endsWith(`
2096
+ `),y.thread);if(y.partial=y.partial.slice(w+1),!T)return;let $=[],{entries:j}=y.index,D=j.get(T),H=!1;for(;D;){if($.push(D),t.idOf(D)===y.chainLastId){H=!0;break}let G=t.parentOf(D);D=G?j.get(G):void 0}if(H)for(let G=$.length-2;G>=0;G--)de($[G]);else{y.chainLastId!==void 0&&(y.buffer.push({type:"cleared"}),y.buffer.push({type:"session",sessionId:y.sessionId}),y.latest={in:0,out:0,cached:0,cacheCreate:0});let G=new Set($.map(le=>t.idOf(le))),ut=he(j);for(let le=$.length-1;le>=0;le--)de($[le]),Ie(t.idOf($[le]),ut,G)}y.chainLastId=T}function he(y){let v=new Map;for(let w of y.values()){let T=t.parentOf(w);if(!T)continue;let $=v.get(T);$?$.push(w):v.set(T,[w])}return v}function Ie(y,v,w){if(!y)return;let T=v.get(y);if(!T)return;let $=T.filter(G=>!t.isSidechain(G,e.thread));if($.length<2)return;let j=$.filter(G=>!w.has(t.idOf(G)));if(!j.length)return;let D=[],H=0;for(let G of j){let ut=ct(G,v);D.push(...ut.events),H+=ut.count}H>0&&e.buffer.push({type:"fork",atId:y,count:H,events:D})}function ct(y,v){let w=[],T=[y];for(;T.length;){let D=T.pop();if(t.isSidechain(D,e.thread))continue;w.push(D);let H=v.get(t.idOf(D)??"");if(H)for(let G of H)T.push(G)}w.sort((D,H)=>(Date.parse(t.timestampOf(D)??"")||0)-(Date.parse(t.timestampOf(H)??"")||0));let $=[];for(let D of w)t.isRecoveryNoise(D)||$.push(...Ha(t,D,e.thread,e.sessionStartMs).events);return{count:$.reduce((D,H)=>D+(H.type==="user"||H.type==="assistant"?1:0),0),events:$}}function de(y){if(!t.isSidechain(y,e.thread))try{let{events:v,usage:w,model:T,cost:$}=Ha(t,y,e.thread,e.sessionStartMs);for(let j of v)e.buffer.push(j);v.some(j=>j.type==="assistant")&&a()?.d.clearCompletedDraft(),v.some(j=>j.type==="user")&&a()?.d.clearEcho(),T&&(e.latestModel=T),w&&(e.latest=w),(w||$)&&e.buffer.push({type:"usage",...e.latest,cost:$})}catch(v){console.error("[mirror] skipped malformed entry:",Y(v))}}async function Ae(){return{cwd:e.cwd,pid:process.pid,composer:!!t.createDriver,children:!!t.listChildren,childStatus:!!t.listChildren&&t.childBriefs,elsewhere:await Tt()}}async function Tt(){if(t.listSessionFiles(e.cwd).length)return;let y=await Pn();if(!y)return;let v=rv(y).toLowerCase();for(let w=rv(e.cwd);w.toLowerCase()!==v;){let T=kR(w);if(T===w)return;w=T;let $=t.listSessionFiles(w).length;if($)return{dir:w,count:$}}}Tt().then(y=>{y&&console.log(`No sessions for ${e.cwd} \u2014 ${y.count} exist for ${y.dir}. Launched from a subfolder? Relaunch from the project root.`)}).catch(()=>{});let b=new Ua;async function k(y,v){e.thread!=="child"&&b.accept(y,v)&&console.log(v)}function P(){return Ya(t,e.sessionId,e.cwd,e.file)}function N(){return t.chainWorking([...e.index.entries.values()])&&P()}function M(){!t.createDriver||a()||e.latestModel||N()||l(e.file)}async function W(y){let v=e;R(),p(),M(),u();let w=a();for(let D of s)D!==w&&D.d.dialog;let T=c().filter(D=>D.rec.d.streaming).map(D=>D.sessionId),$=N(),j=t.createDriver?{streaming:!!w?.d.streaming,foreign:!w&&$,draft:w?.d.draft??null,echo:w?.d.echo??null,status:w?.d.status??null,dialog:w?.d.dialog??null,queue:w?.d.queue??null,stats:w?.d.stats??null,model:w?.d.model??null,error:w?.d.error}:void 0;return{events:v.buffer.slice(y),cursor:v.buffer.length,working:!!w?.d.streaming||$,latestModel:v.latestModel,child:v.child?.id??null,composer:j,busy:T}}async function q(){R(),p();let y=a();if(y?.d.error&&!y.d.streaming&&(await d(y),y=void 0),!y){if(N())return{ok:!1,error:"the agent is mid-turn in a terminal \u2014 watch only"};y=l(e.file)}let v=y;return{ok:!0,d:v.d,markSent:w=>{v.prompt===void 0&&(v.prompt=w)}}}async function qe(y,v){if(!t.createDriver)return{ok:!1,error:"not supported"};let w=String(y??"").trim();if(!w)return{ok:!1,error:"empty message"};let T=await q();if(!T.ok)return T;let $=await T.d.send(w,v);return $.ok&&T.markSent(w),$}async function z(y,v){let w=a();return w?w.d.respondUi(String(y??""),v??{}):{ok:!1,error:"no dialog pending"}}async function ae(y,v){if(!t.createDriver)return{ok:!1,error:"not supported"};if(!y||typeof y.type!="string")return{ok:!1,error:"bad command"};if(v?.spawn){let T=await q();return T.ok?T.d.rpc(y):T}let w=a();return!w||w.d.error?{ok:!1,error:"not running"}:w.d.rpc(y)}async function Te(){let y=a();if(y)try{await y.d.stop()}catch(v){console.error("[composer] stop:",Y(v))}return{ok:!0}}async function Mr(){return t.createDriver?(p(),!e.file&&i&&i.prompt===void 0&&!i.d.streaming&&!i.d.error?{ok:!0}:(i?.d.error&&await d(i),i=void 0,U(),l(void 0),u(),{ok:!0})):{ok:!1,error:"not supported"}}async function tn(){if(!t.createDriver)return[];let y=await et(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),v=y!==null?y.split(`
2097
+ `).filter(Boolean):await t.walkFiles?.(e.cwd)??[];return(await Promise.all(v.map(async T=>{try{return{f:T,m:(await SR(_n(e.cwd,T))).mtimeMs}}catch{return{f:T,m:0}}}))).sort((T,$)=>$.m-T.m).map(T=>T.f)}function Ot(){for(let y of[...s])d(y)}async function Al(y){return t.createDriver?_w(e.cwd,y):{ok:!1,error:"not supported"}}async function Tl(y){return Rw(e.cwd,String(y??""))}async function ik(y,v){return Dw(String(y??""),String(v??""))}async function ok(y,v){return Zs(y==="status"?"status":"plan",v)}async function ak(y){let v=t.listChildren?.(e.cwd,e.sessionId).find(T=>T.id===y);if(!v)return{ok:!1,error:"child not found"};let w=await mf(t,{...v,state:ei(v,P())});return{ok:!0,plans:Object.fromEntries(w.plans),frozen:Object.fromEntries(w.frozen),judged:w.judged,error:w.error,setup:w.setup,cached:w.cached}}async function lk(){let y=t.sessionsWorking?.(e.cwd),v=t.listSessionFiles(e.cwd).map(({sessionId:T,file:$,mtime:j})=>({sessionId:T,mtime:j,preview:t.readPreview($),working:y?.has(T)})),w=f().map(T=>({sessionId:T.sessionId,mtime:T.rec.startedAt,preview:T.rec.prompt??"",pending:!0}));return ti([...v,...w],T=>T.mtime)}let dp=new Map;function fp(y,v){let w=dp.get(y);if(w&&w.mtime===v)return w.turns;let T=[],$="";try{$=yf(y,"utf8")}catch{return[]}for(let j of $.split(`
2098
+ `)){if(!j.trim())continue;let D=t.parseEntry(j);if(!D)continue;let H=t.searchText(D);H&&T.push({text:H,lower:H.toLowerCase()})}return dp.set(y,{mtime:v,turns:T}),T}async function ck(y){let v=y.toLowerCase(),w=[],T=0,$=t.sessionsWorking?.(e.cwd);for(let{sessionId:j,file:D,mtime:H}of t.listSessionFiles(e.cwd).sort((G,ut)=>ut.mtime-G.mtime)){let G=Gs(fp(D,H),v),ut=(t.listChildren?.(e.cwd,j)??[]).map(le=>({c:le,hit:Gs(fp(le.file,le.mtime),v)})).filter(le=>le.hit.hitCount);if(!(!G.hitCount&&!ut.length)){for(let{c:le,hit:hk}of ti(ut,mk=>mk.c.mtime))w.push({sessionId:j,mtime:le.mtime,preview:Cn(le),...hk,child:{id:le.id,kind:le.kind,depth:le.depth}});if(w.push({sessionId:j,mtime:H,preview:t.readPreview(D),working:$?.has(j),...G}),++T>=OR)break}}return w}async function uk(y){let v=e,w=t.listSessionFiles(v.cwd).find(T=>T.sessionId===y);if(!w){let T=f().find($=>$.sessionId===y)?.rec;return T?((i!==T||v.sessionId!==T.id)&&(i=T,wi(),n=void 0,F(void 0,T.id),v.everAttached=!0,u()),{ok:!0}):{ok:!1,error:"session not found"}}return w.file===v.file?{ok:!0}:(Z(w),p(),u(),{ok:!0})}async function dk(){if(!t.listChildren||!e.sessionId)return[];let y=P();return t.listChildren(e.cwd,e.sessionId).map(v=>({...v,state:ei(v,y)}))}async function fk(y){let v=e;if(!t.listChildren)return{ok:!1,error:"this harness has no child transcripts"};let w=t.listChildren(v.cwd,v.sessionId).find(T=>T.id===y);return w?(v.thread="child",v.child=w,F(w.file,v.sessionId),te(w.file),{ok:!0}):{ok:!1,error:"child not found"}}async function pk(){let y=n;return!wi()||!y?{ok:!0}:(F(y,e.sessionId),te(y),{ok:!0})}function wi(){let y=e;return y.thread==="main"?!1:(y.thread="main",y.child=void 0,!0)}return O(e.cwd),C(e.cwd),R(),{info:Ae,poll:W,logInlineStatus:k,listSessions:lk,searchSessions:ck,attach:uk,listChildren:dk,openChild:fk,closeChild:pk,composerSend:qe,composerStop:Te,composerNew:Mr,composerFiles:tn,composerUiRespond:z,composerRpc:ae,composerPaste:Al,composerPasteRead:Tl,summarizeTurn:ik,childStatus:ok,judgeChildStatus:ak,shutdownComposer:Ot}}var xR,ER,sv,AR,OR,Ga=S(()=>{"use strict";Vt();Aw();Vs();sf();Iw();uf();df();gf();ff();Qs();xR=".typebulb",ER=`${xR}/locks`,sv=5e3,AR=6e4;OR=50});import{existsSync as Sf,mkdirSync as PR,readFileSync as iv,writeFileSync as CR}from"fs";import{join as Rn,isAbsolute as _R}from"path";async function xf(t,e){let n=_R(t)?t:Rn(V,t);return Sf(n)?(id(n,e),{ok:!0}):{ok:!1,error:"file not found"}}async function Ef(t){let e=V,n=sd(t),r=Rn(e,"typebulbs");PR(r,{recursive:!0});let s=ed(n),i=`${s}.bulb.md`;for(let c=2;Sf(Rn(r,i))&&iv(Rn(r,i),"utf8")!==n;c++)i=`${s}-${c}.bulb.md`;let o=Rn(r,i);Sf(o)||CR(o,n);let a=Rn("typebulbs",i),l=await Ts(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:l.pid,url:l.url}}async function Af(){return X(V)}async function Tf(t){let e=(await X()).find(n=>n.pid===t);return e?{ok:!0,outcome:await Ft(e)}:(await nr(t),{ok:!0})}async function Of(){let t=await dn(V);return ea(V).filter(e=>!e.serverOnly).map(e=>({...e,trusted:yn(e.path),lastRunAt:t(e.path)}))}async function Pf(t){let e=t.toLowerCase(),n=[];for(let r of ea(V).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=iv(r.path,"utf8")}catch{continue}let i=[];for(let l of s.split(`
2099
+ `)){let c=l.replace(/\s+/g," ").trim();c&&i.push({text:c,lower:c.toLowerCase()})}let{hitCount:o,snippet:a}=Gs(i,e);o&&n.push({path:r.path,hitCount:o,snippet:a})}return n}async function Cf(t,e){let n=V;e!=null&&lr(t,e);let r=await Ts(t,{cwd:n,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function _f(t){return{cap:await nd(t)}}async function Rf(t,e){return lr(t,e),{ok:!0}}async function If(t,e){return Ve(t,e)}async function Nf(){return si&&Date.now()-si.fetchedAt<=IR?si.samples:(bf??=NR().finally(()=>{bf=null}),bf)}async function NR(){try{let t=await fetch(`${RR}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(av)});if(!t.ok)throw new Error(`HTTP ${t.status}`);let e=await t.json(),n=i=>i.order??Number.MAX_SAFE_INTEGER,r=i=>Date.parse(i.createdAt??"")||0,s=e.filter(i=>i.slug!=="welcome").sort((i,o)=>n(i)-n(o)||r(o)-r(i)).map(i=>({slug:i.slug,name:i.name,description:Ll(i.config)}));return si={samples:s,fetchedAt:Date.now()},s}catch{return si?.samples??[]}}async function $f(t){return kf.test(t)?cv(ov,"samples",t,!0):{ok:!1,error:"bad slug"}}async function Mf(){let t=Lf();if(!t)return{bulbs:[]};let e=`${Xa()}
2100
+ ${t}`;return Gt?.key===e&&Date.now()-Gt.fetchedAt<=$R?{user:Gt.user,bulbs:Gt.bulbs}:(wf??=LR(e,t).finally(()=>{wf=null}),wf)}async function vf(t,e,n){let r=await fetch(`${t}${e}`,{headers:n,signal:AbortSignal.timeout(av)});if(!r.ok)throw new Error(`HTTP ${r.status}`);if(!r.headers.get("content-type")?.includes("json"))throw new Error("not json");return r.json()}async function LR(t,e){let n={Authorization:`Bearer ${e}`};try{let r=Xa(),s;try{s=await vf(r,"/api/me",n)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await vf(r,"/api/me",n)}let o=(await vf(r,"/api/scripts/list",n)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:Ll(a.config)}));return Gt={key:t,user:s.slug,bulbs:o,fetchedAt:Date.now()},{user:s.slug,bulbs:o}}catch{return Gt?.key===t?{user:Gt.user,bulbs:Gt.bulbs}:{bulbs:[]}}}async function Df(t,e,n=!1){return!kf.test(e)||!kf.test(t)?{ok:!1,error:"bad slug"}:cv(Xa(),t,e,n)}async function cv(t,e,n,r){let s=Ia(e,n);try{let i=await La({origin:t,userSlug:e,slug:n,dest:Rn(V,s)},{force:r,token:Lf(),timeoutMs:lv});return i.kind==="conflict"?{ok:!1,conflict:!0,error:"local file differs from the site copy"}:i.kind==="asset-conflict"?{ok:!1,conflict:!0,error:`local assets differ from the site copies (${i.paths.join(", ")})`}:i.kind==="http-error"?{ok:!1,error:`HTTP ${i.status}`}:i.kind==="not-markdown"?{ok:!1,error:`not a bulb (${i.contentType??"no content-type"})`}:{ok:!0,file:s,upToDate:i.kind==="up-to-date"}}catch(i){return{ok:!1,error:i?.message??String(i)}}}async function Bf(t,e=!1){let n=Lf();if(!n)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=$a(t,V,Xa()),s=await Da(r,{token:n,force:e,timeoutMs:lv});return s.kind==="conflict"?{ok:!1,conflict:!0,error:s.message}:s.kind==="asset-error"?{ok:!1,error:`assets sync failed: ${s.message}`}:s.kind==="http-error"?{ok:!1,error:`HTTP ${s.status}: ${s.message}`}:{ok:!0,created:s.created,serverStripped:s.serverStripped}}catch(r){return{ok:!1,error:r?.message??String(r)}}}var RR,ov,IR,av,lv,si,bf,kf,$R,Gt,wf,Xa,Lf,Qa=S(()=>{"use strict";Tn();Vt();sf();Q();RR="https://api.typebulb.com",ov="https://typebulb.com",IR=3600*1e3,av=5e3,lv=15e3,si=null,bf=null;kf=/^[a-z0-9][a-z0-9-]*$/,$R=300*1e3,Gt=null,wf=null,Xa=()=>da("TYPEBULB_ORIGIN",V)||ov,Lf=()=>da("TYPEBULB_TOKEN",V)});import{readFileSync as Uf,writeFileSync as dv,mkdirSync as MR,appendFileSync as fv,rmSync as uv}from"fs";import{join as tl,dirname as DR}from"path";import{createServer as BR}from"http";function Xt(t){try{return JSON.parse(Uf(t,"utf8"))}catch{return null}}function el(t,e){MR(DR(t),{recursive:!0}),dv(t,JSON.stringify(e,null,2)+`
2101
+ `)}function hv(t,e,n){let r=tl(t,".gitignore"),s="";try{s=Uf(r,"utf8")}catch{}let i=new Set(s.split(/\r?\n/).map(l=>l.trim())),o=e.filter(l=>!i.has(l));if(!o.length)return;let a=s&&!s.endsWith(`
2102
2102
  `)?`
2103
- `:"";try{uv(r,a+n+`
2103
+ `:"";try{fv(r,a+n+`
2104
2104
  `+o.join(`
2105
2105
  `)+`
2106
- `)}catch(l){console.error("[switcher] .gitignore update failed",Y(l))}}function qR(t){let e=i=>{let o=i.exec(t);return o?Number(o[1]):0},n=e(/"cache_read_input_tokens":\s*(\d+)/),r=e(/"cache_creation_input_tokens":\s*(\d+)/),s=e(/"input_tokens":\s*(\d+)/);n>0||r>0?ai="live":s>UR&&(ai="uncached")}function hv(t,e){let n={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":t.headers["anthropic-version"]||"2023-06-01",...fd},r=t.headers["anthropic-beta"];return typeof r=="string"&&(n["anthropic-beta"]=r),n}function JR(t){if(Array.isArray(t?.messages))for(let e of t.messages){if(!Array.isArray(e?.content))continue;let n=e.content.filter(r=>r?.type!=="thinking"&&r?.type!=="redacted_thinking");n.length&&n.length!==e.content.length&&(e.content=n)}}function mv(t){let e;try{e=JSON.parse(t)}catch{return t}oi=typeof e?.model=="string"?e.model:null,lt&&(e.model=lt),Nn&&(e.provider=pv(Nn));let n=/haiku/i.test(oi||"");return li!=null&&!n&&(e.reasoning={effort:jf[li]}),delete e.thinking,e.output_config&&delete e.output_config.effort,JR(e),JSON.stringify(e)}function WR(){let t="",e=0,n=new Map,r=new Set(["thinking","redacted_thinking"]),s=i=>{let o=/^data: (.*)$/m.exec(i);if(!o)return i;let a;try{a=JSON.parse(o[1])}catch{return i}switch(a.type){case"message_start":return n.clear(),e=0,i;case"content_block_start":{if(r.has(a.content_block?.type))return n.set(a.index,null),null;let l=e++;return n.set(a.index,l),a.index=l,`event: ${a.type}
2106
+ `)}catch(l){console.error("[switcher] .gitignore update failed",Y(l))}}function JR(t){let e=i=>{let o=i.exec(t);return o?Number(o[1]):0},n=e(/"cache_read_input_tokens":\s*(\d+)/),r=e(/"cache_creation_input_tokens":\s*(\d+)/),s=e(/"input_tokens":\s*(\d+)/);n>0||r>0?ai="live":s>qR&&(ai="uncached")}function gv(t,e){let n={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":t.headers["anthropic-version"]||"2023-06-01",...fd},r=t.headers["anthropic-beta"];return typeof r=="string"&&(n["anthropic-beta"]=r),n}function WR(t){if(Array.isArray(t?.messages))for(let e of t.messages){if(!Array.isArray(e?.content))continue;let n=e.content.filter(r=>r?.type!=="thinking"&&r?.type!=="redacted_thinking");n.length&&n.length!==e.content.length&&(e.content=n)}}function yv(t){let e;try{e=JSON.parse(t)}catch{return t}oi=typeof e?.model=="string"?e.model:null,lt&&(e.model=lt),Nn&&(e.provider=mv(Nn));let n=/haiku/i.test(oi||"");return li!=null&&!n&&(e.reasoning={effort:jf[li]}),delete e.thinking,e.output_config&&delete e.output_config.effort,WR(e),JSON.stringify(e)}function KR(){let t="",e=0,n=new Map,r=new Set(["thinking","redacted_thinking"]),s=i=>{let o=/^data: (.*)$/m.exec(i);if(!o)return i;let a;try{a=JSON.parse(o[1])}catch{return i}switch(a.type){case"message_start":return n.clear(),e=0,i;case"content_block_start":{if(r.has(a.content_block?.type))return n.set(a.index,null),null;let l=e++;return n.set(a.index,l),a.index=l,`event: ${a.type}
2107
2107
  data: ${JSON.stringify(a)}
2108
2108
 
2109
2109
  `}case"content_block_delta":case"content_block_stop":{let l=n.get(a.index);return l==null?null:(a.index=l,`event: ${a.type}
@@ -2111,11 +2111,11 @@ data: ${JSON.stringify(a)}
2111
2111
 
2112
2112
  `)}default:return i}};return i=>{t+=i;let o="",a;for(;(a=t.indexOf(`
2113
2113
 
2114
- `))!==-1;){let l=t.slice(0,a);if(t=t.slice(a+2),!l.trim())continue;let c=s(l);c!==null&&(o+=c)}return o}}function KR(t){return new Promise(e=>{let n=[];t.on("data",r=>n.push(r)),t.on("end",()=>e(Buffer.concat(n).toString("utf8"))),t.on("error",()=>e(Buffer.concat(n).toString("utf8")))})}function ii(t,e,n,r){t.writableEnded||(t.writeHead(e,{"content-type":"application/json"}),t.end(JSON.stringify({type:"error",error:{type:n,message:r}})))}async function HR(t,e,n){if(!lt){ii(e,400,"invalid_request_error",FR);return}let r=process.env.OPENROUTER_API_KEY;if(!r){ii(e,401,"authentication_error","OPENROUTER_API_KEY not set in the typebulb proxy");return}let s=new AbortController;e.on("close",()=>{e.writableEnded||s.abort()});let i;try{i=await fetch(qf,{method:"POST",headers:hv(t,r),body:mv(n),signal:s.signal})}catch(d){ii(e,502,"api_error",`proxy upstream failed: ${Y(d)}`);return}let o=i.headers.get("content-type")||"application/json";if(e.writeHead(i.status,{"content-type":o}),!i.body){e.end();return}let a=o.includes("event-stream"),l=i.body.getReader(),c=new TextDecoder,f=a?WR():null;try{for(;;){let{done:d,value:u}=await l.read();if(d)break;if(u)if(f){let p=c.decode(u,{stream:!0});qR(p);let m=f(p);m&&e.write(m)}else e.write(Buffer.from(u))}}catch{}finally{e.writableEnded||e.end()}}async function zR(t,e,n){let r=process.env.OPENROUTER_API_KEY,s=()=>{e.writeHead(200,{"content-type":"application/json"}),e.end(JSON.stringify({input_tokens:Math.max(1,Math.ceil(n.length/4))}))};if(!lt||!r)return s();try{let i=await fetch(`${qf}/count_tokens`,{method:"POST",headers:hv(t,r),body:mv(n)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function YR(t,e){let n=t.url||"/";if(t.method==="HEAD"){e.writeHead(200),e.end();return}if(t.method!=="POST"){ii(e,404,"not_found_error",n);return}KR(t).then(r=>{if(n.includes("count_tokens"))return zR(t,e,r);if(n.includes("/v1/messages"))return HR(t,e,r);ii(e,404,"not_found_error",n)})}function VR(){return Cr&&In?Promise.resolve(In):new Promise((t,e)=>{let n=DR(YR);n.on("error",e),n.listen(0,"127.0.0.1",()=>{Cr=n,In=n.address().port,console.log(`[switcher] wire proxy listening on ${Za(In)}`),t(In)})})}function GR(){try{Cr?.close()}catch{}Cr=null,In=null}function XR(t,e){let n=nl(t),r=Xt(n),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===Za(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=rl(t);if(!Xt(i)){let a={};for(let l of dv)a[l]=l in s.env?s.env[l]:null;el(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=Za(e),s.env.ANTHROPIC_AUTH_TOKEN=jR,el(n,s),fv(t,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function QR(t,e,n){let r=rl(t),s=Xt(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:n},el(r,s)}function gv(t){let e=nl(t),n=rl(t),r=Xt(n),s=Xt(e);if(s?.env){let i=r?.snapshot||{};for(let o of dv){let a=i[o];a==null?delete s.env[o]:s.env[o]=a}if(Object.keys(s.env).length===0&&delete s.env,r?.fileExisted===!1&&Object.keys(s).length===0)try{lv(e,{force:!0})}catch{}else el(e,s)}try{lv(n,{force:!0})}catch{}}async function ZR(){let t=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await mt()).filter(r=>r.provider==="openrouter"&&!Jf(r.name)).map(r=>({id:r.name,label:r.friendlyName||r.name}))}catch(r){console.error("[switcher] model list failed",Y(r))}let n=e.length?void 0:cd()??void 0;return{hasKey:t,models:e,error:n}}async function eI(){if(Cr&&lt)return{active:!0,managed:!0,model:lt,port:In,provider:Nn,routedModel:oi,caching:ai,reasoning:li,externalBaseUrl:null};let t=Xt(nl(V))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:li,externalBaseUrl:t.ANTHROPIC_BASE_URL||null}}async function yv(t,e){let n=await VR();return lt=t,Nn=e,XR(V,n),n}async function tI({model:t}){if(!process.env.OPENROUTER_API_KEY)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!t)return{ok:!1,error:"no model given"};if(Jf(t))return{ok:!1,error:"Refusing to route an Anthropic model through OpenRouter \u2014 that bills full API rate with no caching. Use it on your Anthropic subscription instead."};try{await yv(t,Wf[t]??null),oi=null,ai="unknown",QR(V,t,Nn)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${Y(e)}`}}return{ok:!0}}async function nI({level:t}){return t!=null&&(!Number.isInteger(t)||t<0||t>=jf.length)?{ok:!1,error:`reasoning level must be 0\u2013${jf.length-1} or null`}:(li=t,{ok:!0,level:t})}async function rI(){return gv(V),lt=null,Nn=null,oi=null,ai="unknown",{ok:!0}}async function sI({key:t}){let e=(t||"").trim();if(!e)return{ok:!1,error:"empty key"};let n=V,r=tl(n,".env"),s="";try{s=Uf(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))cv(r,s.replace(/^\s*OPENROUTER_API_KEY\s*=.*$/m,`OPENROUTER_API_KEY=${e}`));else{let i=s&&!s.endsWith(`
2114
+ `))!==-1;){let l=t.slice(0,a);if(t=t.slice(a+2),!l.trim())continue;let c=s(l);c!==null&&(o+=c)}return o}}function HR(t){return new Promise(e=>{let n=[];t.on("data",r=>n.push(r)),t.on("end",()=>e(Buffer.concat(n).toString("utf8"))),t.on("error",()=>e(Buffer.concat(n).toString("utf8")))})}function ii(t,e,n,r){t.writableEnded||(t.writeHead(e,{"content-type":"application/json"}),t.end(JSON.stringify({type:"error",error:{type:n,message:r}})))}async function zR(t,e,n){if(!lt){ii(e,400,"invalid_request_error",UR);return}let r=process.env.OPENROUTER_API_KEY;if(!r){ii(e,401,"authentication_error","OPENROUTER_API_KEY not set in the typebulb proxy");return}let s=new AbortController;e.on("close",()=>{e.writableEnded||s.abort()});let i;try{i=await fetch(qf,{method:"POST",headers:gv(t,r),body:yv(n),signal:s.signal})}catch(d){ii(e,502,"api_error",`proxy upstream failed: ${Y(d)}`);return}let o=i.headers.get("content-type")||"application/json";if(e.writeHead(i.status,{"content-type":o}),!i.body){e.end();return}let a=o.includes("event-stream"),l=i.body.getReader(),c=new TextDecoder,f=a?KR():null;try{for(;;){let{done:d,value:u}=await l.read();if(d)break;if(u)if(f){let p=c.decode(u,{stream:!0});JR(p);let m=f(p);m&&e.write(m)}else e.write(Buffer.from(u))}}catch{}finally{e.writableEnded||e.end()}}async function YR(t,e,n){let r=process.env.OPENROUTER_API_KEY,s=()=>{e.writeHead(200,{"content-type":"application/json"}),e.end(JSON.stringify({input_tokens:Math.max(1,Math.ceil(n.length/4))}))};if(!lt||!r)return s();try{let i=await fetch(`${qf}/count_tokens`,{method:"POST",headers:gv(t,r),body:yv(n)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function VR(t,e){let n=t.url||"/";if(t.method==="HEAD"){e.writeHead(200),e.end();return}if(t.method!=="POST"){ii(e,404,"not_found_error",n);return}HR(t).then(r=>{if(n.includes("count_tokens"))return YR(t,e,r);if(n.includes("/v1/messages"))return zR(t,e,r);ii(e,404,"not_found_error",n)})}function GR(){return _r&&In?Promise.resolve(In):new Promise((t,e)=>{let n=BR(VR);n.on("error",e),n.listen(0,"127.0.0.1",()=>{_r=n,In=n.address().port,console.log(`[switcher] wire proxy listening on ${Za(In)}`),t(In)})})}function XR(){try{_r?.close()}catch{}_r=null,In=null}function QR(t,e){let n=nl(t),r=Xt(n),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===Za(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=rl(t);if(!Xt(i)){let a={};for(let l of pv)a[l]=l in s.env?s.env[l]:null;el(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=Za(e),s.env.ANTHROPIC_AUTH_TOKEN=FR,el(n,s),hv(t,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function ZR(t,e,n){let r=rl(t),s=Xt(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:n},el(r,s)}function bv(t){let e=nl(t),n=rl(t),r=Xt(n),s=Xt(e);if(s?.env){let i=r?.snapshot||{};for(let o of pv){let a=i[o];a==null?delete s.env[o]:s.env[o]=a}if(Object.keys(s.env).length===0&&delete s.env,r?.fileExisted===!1&&Object.keys(s).length===0)try{uv(e,{force:!0})}catch{}else el(e,s)}try{uv(n,{force:!0})}catch{}}async function eI(){let t=!!process.env.OPENROUTER_API_KEY,e=[];try{e=(await mt()).filter(r=>r.provider==="openrouter"&&!Jf(r.name)).map(r=>({id:r.name,label:r.friendlyName||r.name}))}catch(r){console.error("[switcher] model list failed",Y(r))}let n=e.length?void 0:cd()??void 0;return{hasKey:t,models:e,error:n}}async function tI(){if(_r&&lt)return{active:!0,managed:!0,model:lt,port:In,provider:Nn,routedModel:oi,caching:ai,reasoning:li,externalBaseUrl:null};let t=Xt(nl(V))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:li,externalBaseUrl:t.ANTHROPIC_BASE_URL||null}}async function wv(t,e){let n=await GR();return lt=t,Nn=e,QR(V,n),n}async function nI({model:t}){if(!process.env.OPENROUTER_API_KEY)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!t)return{ok:!1,error:"no model given"};if(Jf(t))return{ok:!1,error:"Refusing to route an Anthropic model through OpenRouter \u2014 that bills full API rate with no caching. Use it on your Anthropic subscription instead."};try{await wv(t,Wf[t]??null),oi=null,ai="unknown",ZR(V,t,Nn)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${Y(e)}`}}return{ok:!0}}async function rI({level:t}){return t!=null&&(!Number.isInteger(t)||t<0||t>=jf.length)?{ok:!1,error:`reasoning level must be 0\u2013${jf.length-1} or null`}:(li=t,{ok:!0,level:t})}async function sI(){return bv(V),lt=null,Nn=null,oi=null,ai="unknown",{ok:!0}}async function iI({key:t}){let e=(t||"").trim();if(!e)return{ok:!1,error:"empty key"};let n=V,r=tl(n,".env"),s="";try{s=Uf(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))dv(r,s.replace(/^\s*OPENROUTER_API_KEY\s*=.*$/m,`OPENROUTER_API_KEY=${e}`));else{let i=s&&!s.endsWith(`
2115
2115
  `)?`
2116
- `:"";uv(r,i+`OPENROUTER_API_KEY=${e}
2117
- `)}}catch(i){return{ok:!1,error:Y(i)}}return process.env.OPENROUTER_API_KEY=e,fv(n,[".env"],"# secrets"),{ok:!0}}function iI(){if(!(!Cr&&!lt)){try{gv(V)}catch{}GR()}}function oI(t,e){return bv.test(e)?"blocked by your OpenRouter data policy":t===401||t===403||/unauthor|invalid api key|no auth|forbidden/i.test(e)?"auth rejected \u2014 check your OpenRouter key":t===404||/not a valid model|no such model|unknown model|model not found/i.test(e)?"model not found on this route":t===429||/rate limit/i.test(e)?"rate limited":t===402||/insufficient|credit|quota|balance/i.test(e)?"out of credits / quota":e.slice(0,160)}function aI(t){if(bv.test(t))return"This model's only provider(s) require prompt logging/training, which your OpenRouter account disallows by default. Allow it (or that provider) at openrouter.ai/settings/privacy, then probe again."}function lI(t,e,n){if(!t)return{works:null,read:0,note:n?`couldn't re-test on ${n} \u2014 caching unconfirmed`:"caching unconfirmed"};let r=Ff(e?.cache_read_input_tokens)||Ff(e?.prompt_tokens_details?.cached_tokens),s=e?.cache_read_input_tokens!==void 0||e?.cache_creation_input_tokens!==void 0||e?.prompt_tokens_details!==void 0;return r>0?{works:!0,read:r,note:`${r} tokens read from cache on the 2nd call`}:s?{works:!1,read:r,note:"no cache reads after a warm call \u2014 every turn re-bills the full context"}:{works:null,read:r,note:"route doesn't report cache usage \u2014 caching almost certainly not honored"}}async function cI({model:t}){let e=process.env.OPENROUTER_API_KEY;if(!e)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!t)return{ok:!1,error:"no model given"};if(Jf(t))return{ok:!1,error:"Anthropic model \u2014 not offered or probed via OpenRouter"};let n=Date.now(),r=Array(350).fill("Caching probe filler sentence; its only purpose is to exceed the prompt-cache minimum token threshold.").join(" "),s={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":"2023-06-01"},i={model:t,max_tokens:64,system:[{type:"text",text:r,cache_control:{type:"ephemeral"}}],messages:[{role:"user",content:"Reply with exactly: ok"}]},o=async a=>{let l=new AbortController,c=setTimeout(()=>l.abort(),2e4);try{let f=JSON.stringify(a?{...i,provider:pv(a)}:i),d=await fetch(qf,{method:"POST",signal:l.signal,headers:s,body:f}),u=await d.json().catch(()=>({}));return{r:d,j:u}}finally{clearTimeout(c)}};try{let{r:a,j:l}=await o();if(!a.ok){let E=l?.error?.message||l?.message||JSON.stringify(l).slice(0,300);return{ok:!0,callable:!1,status:a.status,ms:Date.now()-n,error:oI(a.status,E),restriction:aI(E)}}let c=typeof l?.provider=="string"?l.provider:void 0,f=l?.content?.find?.(E=>E.type==="text")?.text??l?.content?.[0]?.text??"ok",d=Ff(l?.usage?.cache_creation_input_tokens),{r:u,j:p}=await o(c),{works:m,read:h,note:g}=lI(u.ok,p?.usage,c);return m===!0&&c&&(Wf[t]=c,lt===t&&(Nn=c)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-n,provider:c,sample:String(f).trim().slice(0,60),cache:{works:m,created:d,read:h,note:g}}}catch(a){let l=Y(a);return{ok:!0,callable:!1,ms:Date.now()-n,error:/abort/i.test(l)?"timed out (20s)":l}}}var BR,qf,jR,FR,dv,UR,jf,nl,rl,Za,Jf,Cr,In,lt,Nn,oi,ai,li,Wf,Ff,pv,bv,wv=S(()=>{"use strict";Tn();Vt();Ut();BR="https://openrouter.ai/api",qf=`${BR}/v1/messages`,jR="typebulb-proxy-managed",FR="The typebulb model override was reverted to Anthropic, but this Claude Code session still points at the now-idle proxy. Reload the window (VS Code/Cursor: \u201CDeveloper: Reload Window\u201D) or relaunch `claude` in a terminal to return to your Anthropic subscription.",dv=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],UR=5e3,jf=["low","medium","high"],nl=t=>tl(t,".claude","settings.local.json"),rl=t=>tl(t,".claude",".cc-switcher.json"),Za=t=>`http://127.0.0.1:${t}`;Jf=t=>/^anthropic\//i.test(t)||/claude/i.test(t),Cr=null,In=null,lt=null,Nn=null,oi=null,ai="unknown",li=1,Wf={},Ff=t=>typeof t=="number"?t:0,pv=t=>({order:[t],allow_fallbacks:!1});bv=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=Xt(rl(V)),n=e?.active?.model;if(!n)return;let s=(Xt(nl(V))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await yv(n,e.active.provider??Wf[n]??null);console.log(`[switcher] re-adopted override after restart: ${n} via ${Za(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",Y(e))}})()});var Sv={};Si(Sv,{agentMessage:()=>Mo,attach:()=>gI,blockToMarkdown:()=>Lo,breakout:()=>Ef,capText:()=>Oe,childStatus:()=>kI,cleanUserText:()=>jt,clearSwitchModel:()=>rI,closeChild:()=>wI,composerPasteRead:()=>vI,displayName:()=>uI,downloadSample:()=>$f,firstLineDigest:()=>$e,git:()=>et,gitChangedFiles:()=>nf,gitDiff:()=>rf,info:()=>dI,isHiddenTurn:()=>Ss,judgeChildStatus:()=>xI,launchBulb:()=>Cf,listBreakouts:()=>Af,listBulbFiles:()=>Of,listChildren:()=>yI,listMyBulbs:()=>Mf,listSamples:()=>Nf,listSessions:()=>hI,listSwitchModels:()=>ZR,logInlineStatus:()=>pI,openChild:()=>bI,openFile:()=>xf,poll:()=>fI,predictTrustOf:()=>_f,probeModel:()=>cI,pullRemoteBulb:()=>Df,pushLocalBulb:()=>Bf,readBulbLog:()=>If,repoRoot:()=>Pn,saveOpenRouterKey:()=>sI,searchBulbs:()=>Pf,searchSessions:()=>mI,setBulbTrust:()=>Rf,setReasoning:()=>nI,setSwitchModel:()=>tI,shutdownSwitcher:()=>iI,stopBreakout:()=>Tf,summarizeTurn:()=>SI,switchState:()=>eI,toolResultDigest:()=>$u});var vv,uI,dI,fI,pI,hI,mI,gI,yI,bI,wI,vI,SI,kI,xI,kv=S(()=>{"use strict";Ga();Do();Qa();Vs();wv();Do();ws();vv=new Gn,uI=vv.displayName,{info:dI,poll:fI,logInlineStatus:pI,listSessions:hI,searchSessions:mI,attach:gI,listChildren:yI,openChild:bI,closeChild:wI,composerPasteRead:vI,summarizeTurn:SI,childStatus:kI,judgeChildStatus:xI}=Pr(vv)});var Ev={};Si(Ev,{attach:()=>_I,breakout:()=>Ef,childStatus:()=>MI,closeChild:()=>NI,composerPasteRead:()=>$I,displayName:()=>EI,downloadSample:()=>$f,git:()=>et,gitChangedFiles:()=>nf,gitDiff:()=>rf,info:()=>AI,judgeChildStatus:()=>DI,launchBulb:()=>Cf,listBreakouts:()=>Af,listBulbFiles:()=>Of,listChildren:()=>RI,listMyBulbs:()=>Mf,listSamples:()=>Nf,listSessions:()=>PI,logInlineStatus:()=>OI,openChild:()=>II,openFile:()=>xf,poll:()=>TI,predictTrustOf:()=>_f,pullRemoteBulb:()=>Df,pushLocalBulb:()=>Bf,readBulbLog:()=>If,repoRoot:()=>Pn,searchBulbs:()=>Pf,searchSessions:()=>CI,setBulbTrust:()=>Rf,stopBreakout:()=>Tf,summarizeTurn:()=>LI});var xv,EI,AI,TI,OI,PI,CI,_I,RI,II,NI,$I,LI,MI,DI,Av=S(()=>{"use strict";Ga();Bu();Qa();Vs();xv=new Qn,EI=xv.displayName,{info:AI,poll:TI,logInlineStatus:OI,listSessions:PI,searchSessions:CI,attach:_I,listChildren:RI,openChild:II,closeChild:NI,composerPasteRead:$I,summarizeTurn:LI,childStatus:MI,judgeChildStatus:DI}=Pr(xv)});import{readFileSync as BI,writeFileSync as jI,mkdirSync as FI}from"fs";import{homedir as UI}from"os";import*as sl from"path";async function Pv(){try{let t=await fetch(new URL("/api/tags",Ov()).toString(),{signal:AbortSignal.timeout(qI)});return t.ok?((await t.json()).models??[]).map(n=>n.name).filter(n=>!!n):[]}catch{return[]}}function Cv(t){let e;try{e=BI(t,"utf-8")}catch{return{json:void 0,unreadable:!1}}try{let n=JSON.parse(e);if(n&&typeof n=="object"&&!Array.isArray(n)){let r=n;return{json:r,unreadable:"providers"in r&&!Kf(r)}}}catch{}return{json:void 0,unreadable:!0}}function Kf(t){let e=t?.providers;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function JI(t){let e=Kf(t);if(!e||!("ollama"in e))return null;let n=e.ollama?.models;return Array.isArray(n)?n.map(r=>r?.id).filter(r=>typeof r=="string"):[]}async function _v(){let{json:t,unreadable:e}=Cv(Tv());return e?{installed:[],configured:null}:{installed:await Pv(),configured:JI(t)}}async function Rv(){let t=await Pv();return t.length?WI(Tv(),t,Ov()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function WI(t,e,n){let{json:r,unreadable:s}=Cv(t);if(s)return{ok:!1,error:`could not parse ${t} \u2014 edit the ollama provider there yourself`};let i={...r??{},providers:{...Kf(r)??{},ollama:{baseUrl:`${n}/v1`,api:"openai-completions",apiKey:"ollama",models:e.map(o=>({id:o}))}}};try{FI(sl.dirname(t),{recursive:!0}),jI(t,JSON.stringify(i,null,2)+`
2118
- `)}catch(o){return{ok:!1,error:`could not write ${t}: ${Y(o)}`}}return{ok:!0,count:e.length}}var qI,Tv,Ov,Iv=S(()=>{"use strict";Vt();Tn();qI=1500,Tv=()=>sl.join(UI(),".pi","agent","models.json"),Ov=()=>cr(process.env.OLLAMA_HOST??"http://localhost:11434")});var $v={};Si($v,{attach:()=>XI,breakout:()=>Ef,closeChild:()=>eN,composerFiles:()=>sN,composerNew:()=>rN,composerPaste:()=>aN,composerPasteRead:()=>lN,composerRpc:()=>oN,composerSend:()=>tN,composerStop:()=>nN,composerUiRespond:()=>iN,displayName:()=>KI,downloadSample:()=>$f,git:()=>et,gitChangedFiles:()=>nf,gitDiff:()=>rf,info:()=>HI,launchBulb:()=>Cf,listBreakouts:()=>Af,listBulbFiles:()=>Of,listChildren:()=>QI,listMyBulbs:()=>Mf,listSamples:()=>Nf,listSessions:()=>VI,logInlineStatus:()=>YI,ollamaOffer:()=>_v,ollamaSync:()=>Rv,openChild:()=>ZI,openFile:()=>xf,poll:()=>zI,predictTrustOf:()=>_f,pullRemoteBulb:()=>Df,pushLocalBulb:()=>Bf,readBulbLog:()=>If,repoRoot:()=>Pn,searchBulbs:()=>Pf,searchSessions:()=>GI,setBulbTrust:()=>Rf,shutdownComposer:()=>uN,stopBreakout:()=>Tf,summarizeTurn:()=>cN});var Nv,KI,HI,zI,YI,VI,GI,XI,QI,ZI,eN,tN,nN,rN,sN,iN,oN,aN,lN,cN,uN,Lv=S(()=>{"use strict";Ga();ef();Qa();Vs();Iv();Nv=new Tr,KI=Nv.displayName,{info:HI,poll:zI,logInlineStatus:YI,listSessions:VI,searchSessions:GI,attach:XI,listChildren:QI,openChild:ZI,closeChild:eN,composerSend:tN,composerStop:nN,composerNew:rN,composerFiles:sN,composerUiRespond:iN,composerRpc:oN,composerPaste:aN,composerPasteRead:lN,summarizeTurn:cN,shutdownComposer:uN}=Pr(Nv)});import*as nk from"fs/promises";import*as At from"path";ki();ee();function Tu(t){if(!Je.includes(t))throw new Error(`Unknown block kind '${t}' (one of: ${Je.join(", ")})`);return t}function Zg(t){let e=[];for(let n of t){let r=n.indexOf("=");if(r<=0||r===n.length-1)throw new Error(`Expected <kind>=<source>, got '${n}' (e.g. data=results.json, or data=- for stdin)`);let s=Tu(n.slice(0,r));if(e.some(i=>i.kind===s))throw new Error(`Duplicate block kind '${s}' \u2014 each block can be written once per invocation`);e.push({kind:s,source:n.slice(r+1)})}if(e.filter(n=>n.source==="-").length>1)throw new Error("Only one <kind>=- can read stdin");return e}Do();Bu();ef();var il={claude:{adapter:()=>new Gn,server:()=>Promise.resolve().then(()=>(kv(),Sv))},codex:{adapter:()=>new Qn,server:()=>Promise.resolve().then(()=>(Av(),Ev))},pi:{adapter:()=>new Tr,server:()=>Promise.resolve().then(()=>(Lv(),$v))}};function Mv(t){return t in il}function _r(){return Object.keys(il)}function ol(){return Object.fromEntries(Object.entries(il).map(([t,e])=>[t,e.adapter]))}function Dv(t){return il[t].server()}var ci=ol();function Bv(){for(let t of Object.values(ci))try{t().ensureHarnessSupport()}catch{}}function kt(){for(let t of Object.keys(ci))try{if(ci[t]().detectsSelf())return t}catch{}}function jv(t){let e=_r(),n=new Map(e.filter(i=>ci[i]).map(i=>[i,ci[i]()]));for(let[i,o]of n)if(o.detectsSelf())return{name:i};let r=[...n].filter(([,i])=>i.detectsInstalled()).map(([i])=>i);if(r.length===0)return{name:e[0]};if(r.length===1)return{name:r[0]};let s=i=>n.get(i).listSessionFiles(t).length>0;return{ambiguous:[...r].sort((i,o)=>Number(s(o))-Number(s(i)))}}var zf=5e3;function Hf(t){try{return t()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function Fv(t){let n={subcommand:"run",file:"",watch:!0,open:process.env.TERM_PROGRAM==="vscode"||kt()!==void 0?"link":"window",server:!1,trust:!1,noTrust:!1,force:!1,follow:!1,clear:!1,help:!1,version:!1,callArgs:[],hasArgsFlag:!1},r=["call","check","predict","logs","wait","stop","trust","untrust","models","slug","send","pull","push","get","put","status"],s=t[0];if(s==="agent"||s?.startsWith("agent:")){n.subcommand="agent";let o=s.indexOf(":");if(o!==-1){let a=s.slice(o+1);a&&(n.agentTarget=a)}t=t.slice(1)}else s&&r.includes(s)&&(n.subcommand=s,t=t.slice(1));let i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="--help"||a==="-h")n.help=!0;else if(a==="--version"||a==="-V")n.version=!0;else if(a==="--no-watch")n.watch=!1;else if(a==="--open")n.open="window";else if(a==="--no-open")n.open="none";else if(a==="--server")n.server=!0;else if(a==="--trust")n.trust=!0;else if(a==="--no-trust")n.noTrust=!0;else if(a==="--force")n.force=!0;else if(a==="--mode"){let l=t[++o];(!l||l.startsWith("-"))&&(console.error("Missing value for --mode (e.g. --mode staging)"),process.exit(1)),n.mode=l}else if(a==="--follow"||a==="-f")n.follow=!0;else if(a==="--clear")n.clear=!0;else if(a==="--run"){let l=t[++o];if(l==="latest")n.run="latest";else{let c=parseInt(l,10);(isNaN(c)||c<1)&&(console.error(`Invalid --run value: ${l} (a run number, or 'latest')`),process.exit(1)),n.run=c}}else if(a==="--bulbs")n.stopScope="bulbs";else if(a==="--agent")n.stopScope="agent";else if(a==="--global")n.stopScope="global";else if(a==="--match"){let l=t[++o];l===void 0&&(console.error("Missing value for --match (a literal substring new log lines must contain)"),process.exit(1)),n.match=l}else if(a==="--timeout"){let l=parseInt(t[++o],10);(isNaN(l)||l<=0)&&(console.error(`Invalid --timeout value: ${t[o]} (seconds)`),process.exit(1)),n.timeoutSec=l}else if(a==="--wait"||a.startsWith("--wait="))if(a.startsWith("--wait=")){let l=parseInt(a.slice(7),10);(isNaN(l)||l<=0)&&(console.error(`Invalid --wait value: ${a.slice(7)} (milliseconds)`),process.exit(1)),n.sendWaitMs=l}else n.sendWaitMs=zf;else if(a==="--lines"||a==="-n"){let l=parseInt(t[++o],10);(isNaN(l)||l<0)&&(console.error(`Invalid --lines value: ${t[o]}`),process.exit(1)),n.lines=l}else if(a==="--port"||a==="-p"){let l=t[++o],c=parseInt(l,10);isNaN(c)&&(console.error(`Invalid port: ${l}`),process.exit(1)),n.port=c}else if(a==="--replace"||a.startsWith("--replace=")){let l=a.startsWith("--replace=")?a.slice(10):t[++o]??"",c=Hf(()=>bp(l));n.local&&(console.error(`--replace can only be used once (got '${n.local.name}' and '${c.name}')`),process.exit(1)),n.local=c}else if(a==="--args"||a.startsWith("--args=")){n.hasArgsFlag=!0;let l=a.startsWith("--args=")?a.slice(7):t[++o];l===void 0&&(console.error("Missing value for --args (a JSON array, or - to read it from stdin)"),process.exit(1)),n.argsJson=l}else if(!a.startsWith("-")||a==="-"&&n.subcommand==="send")["call","send","get","put","slug","status"].includes(n.subcommand)?i.push(a):n.file=a;else{let l=n.subcommand==="call"?" (for a negative or dash-leading argument, use --args '<json-array>')":"";console.error(`Unknown option: ${a}${l}`),process.exit(1)}}return n.subcommand==="call"&&(i.length<2&&(console.error("Usage: typebulb call <file> <fn> [arg\u2026]"),process.exit(1)),n.file=i[0],n.fn=i[1],n.callArgs=i.slice(2)),n.subcommand==="send"&&(i.length<1&&(console.error("Usage: typebulb send <file> [message]"),process.exit(1)),n.file=i[0],n.sendMessage=i[1]),n.subcommand==="slug"&&(i.length||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1)),n.slugName=i.join(" ")),n.subcommand==="status"&&i.length&&(n.statusQuery=i.join(" ")),n.subcommand==="get"&&(i.length!==2&&(console.error("Usage: typebulb get <file> <kind>"),process.exit(1)),n.file=i[0],n.blockKind=Hf(()=>Tu(i[1]))),n.subcommand==="put"&&(i.length<2&&(console.error("Usage: typebulb put <file> <kind>=<source> [<kind>=<source> \u2026]"),process.exit(1)),n.file=i[0],n.blockPairs=Hf(()=>Zg(i.slice(1)))),n}function Uv(){console.log(`
2116
+ `:"";fv(r,i+`OPENROUTER_API_KEY=${e}
2117
+ `)}}catch(i){return{ok:!1,error:Y(i)}}return process.env.OPENROUTER_API_KEY=e,hv(n,[".env"],"# secrets"),{ok:!0}}function oI(){if(!(!_r&&!lt)){try{bv(V)}catch{}XR()}}function aI(t,e){return vv.test(e)?"blocked by your OpenRouter data policy":t===401||t===403||/unauthor|invalid api key|no auth|forbidden/i.test(e)?"auth rejected \u2014 check your OpenRouter key":t===404||/not a valid model|no such model|unknown model|model not found/i.test(e)?"model not found on this route":t===429||/rate limit/i.test(e)?"rate limited":t===402||/insufficient|credit|quota|balance/i.test(e)?"out of credits / quota":e.slice(0,160)}function lI(t){if(vv.test(t))return"This model's only provider(s) require prompt logging/training, which your OpenRouter account disallows by default. Allow it (or that provider) at openrouter.ai/settings/privacy, then probe again."}function cI(t,e,n){if(!t)return{works:null,read:0,note:n?`couldn't re-test on ${n} \u2014 caching unconfirmed`:"caching unconfirmed"};let r=Ff(e?.cache_read_input_tokens)||Ff(e?.prompt_tokens_details?.cached_tokens),s=e?.cache_read_input_tokens!==void 0||e?.cache_creation_input_tokens!==void 0||e?.prompt_tokens_details!==void 0;return r>0?{works:!0,read:r,note:`${r} tokens read from cache on the 2nd call`}:s?{works:!1,read:r,note:"no cache reads after a warm call \u2014 every turn re-bills the full context"}:{works:null,read:r,note:"route doesn't report cache usage \u2014 caching almost certainly not honored"}}async function uI({model:t}){let e=process.env.OPENROUTER_API_KEY;if(!e)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!t)return{ok:!1,error:"no model given"};if(Jf(t))return{ok:!1,error:"Anthropic model \u2014 not offered or probed via OpenRouter"};let n=Date.now(),r=Array(350).fill("Caching probe filler sentence; its only purpose is to exceed the prompt-cache minimum token threshold.").join(" "),s={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":"2023-06-01"},i={model:t,max_tokens:64,system:[{type:"text",text:r,cache_control:{type:"ephemeral"}}],messages:[{role:"user",content:"Reply with exactly: ok"}]},o=async a=>{let l=new AbortController,c=setTimeout(()=>l.abort(),2e4);try{let f=JSON.stringify(a?{...i,provider:mv(a)}:i),d=await fetch(qf,{method:"POST",signal:l.signal,headers:s,body:f}),u=await d.json().catch(()=>({}));return{r:d,j:u}}finally{clearTimeout(c)}};try{let{r:a,j:l}=await o();if(!a.ok){let x=l?.error?.message||l?.message||JSON.stringify(l).slice(0,300);return{ok:!0,callable:!1,status:a.status,ms:Date.now()-n,error:aI(a.status,x),restriction:lI(x)}}let c=typeof l?.provider=="string"?l.provider:void 0,f=l?.content?.find?.(x=>x.type==="text")?.text??l?.content?.[0]?.text??"ok",d=Ff(l?.usage?.cache_creation_input_tokens),{r:u,j:p}=await o(c),{works:m,read:h,note:g}=cI(u.ok,p?.usage,c);return m===!0&&c&&(Wf[t]=c,lt===t&&(Nn=c)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-n,provider:c,sample:String(f).trim().slice(0,60),cache:{works:m,created:d,read:h,note:g}}}catch(a){let l=Y(a);return{ok:!0,callable:!1,ms:Date.now()-n,error:/abort/i.test(l)?"timed out (20s)":l}}}var jR,qf,FR,UR,pv,qR,jf,nl,rl,Za,Jf,_r,In,lt,Nn,oi,ai,li,Wf,Ff,mv,vv,Sv=S(()=>{"use strict";Tn();Vt();Ut();jR="https://openrouter.ai/api",qf=`${jR}/v1/messages`,FR="typebulb-proxy-managed",UR="The typebulb model override was reverted to Anthropic, but this Claude Code session still points at the now-idle proxy. Reload the window (VS Code/Cursor: \u201CDeveloper: Reload Window\u201D) or relaunch `claude` in a terminal to return to your Anthropic subscription.",pv=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],qR=5e3,jf=["low","medium","high"],nl=t=>tl(t,".claude","settings.local.json"),rl=t=>tl(t,".claude",".cc-switcher.json"),Za=t=>`http://127.0.0.1:${t}`;Jf=t=>/^anthropic\//i.test(t)||/claude/i.test(t),_r=null,In=null,lt=null,Nn=null,oi=null,ai="unknown",li=1,Wf={},Ff=t=>typeof t=="number"?t:0,mv=t=>({order:[t],allow_fallbacks:!1});vv=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=Xt(rl(V)),n=e?.active?.model;if(!n)return;let s=(Xt(nl(V))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await wv(n,e.active.provider??Wf[n]??null);console.log(`[switcher] re-adopted override after restart: ${n} via ${Za(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",Y(e))}})()});var xv={};Si(xv,{agentMessage:()=>Mo,attach:()=>yI,blockToMarkdown:()=>Lo,breakout:()=>Ef,capText:()=>Oe,childStatus:()=>xI,cleanUserText:()=>jt,clearSwitchModel:()=>sI,closeChild:()=>vI,composerPasteRead:()=>SI,displayName:()=>dI,downloadSample:()=>$f,firstLineDigest:()=>$e,git:()=>et,gitChangedFiles:()=>nf,gitDiff:()=>rf,info:()=>fI,isHiddenTurn:()=>Ss,judgeChildStatus:()=>EI,launchBulb:()=>Cf,listBreakouts:()=>Af,listBulbFiles:()=>Of,listChildren:()=>bI,listMyBulbs:()=>Mf,listSamples:()=>Nf,listSessions:()=>mI,listSwitchModels:()=>eI,logInlineStatus:()=>hI,openChild:()=>wI,openFile:()=>xf,poll:()=>pI,predictTrustOf:()=>_f,probeModel:()=>uI,pullRemoteBulb:()=>Df,pushLocalBulb:()=>Bf,readBulbLog:()=>If,repoRoot:()=>Pn,saveOpenRouterKey:()=>iI,searchBulbs:()=>Pf,searchSessions:()=>gI,setBulbTrust:()=>Rf,setReasoning:()=>rI,setSwitchModel:()=>nI,shutdownSwitcher:()=>oI,stopBreakout:()=>Tf,summarizeTurn:()=>kI,switchState:()=>tI,toolResultDigest:()=>$u});var kv,dI,fI,pI,hI,mI,gI,yI,bI,wI,vI,SI,kI,xI,EI,Ev=S(()=>{"use strict";Ga();Do();Qa();Vs();Sv();Do();vs();kv=new Xn,dI=kv.displayName,{info:fI,poll:pI,logInlineStatus:hI,listSessions:mI,searchSessions:gI,attach:yI,listChildren:bI,openChild:wI,closeChild:vI,composerPasteRead:SI,summarizeTurn:kI,childStatus:xI,judgeChildStatus:EI}=Cr(kv)});var Tv={};Si(Tv,{attach:()=>RI,breakout:()=>Ef,childStatus:()=>DI,closeChild:()=>$I,composerPasteRead:()=>LI,displayName:()=>AI,downloadSample:()=>$f,git:()=>et,gitChangedFiles:()=>nf,gitDiff:()=>rf,info:()=>TI,judgeChildStatus:()=>BI,launchBulb:()=>Cf,listBreakouts:()=>Af,listBulbFiles:()=>Of,listChildren:()=>II,listMyBulbs:()=>Mf,listSamples:()=>Nf,listSessions:()=>CI,logInlineStatus:()=>PI,openChild:()=>NI,openFile:()=>xf,poll:()=>OI,predictTrustOf:()=>_f,pullRemoteBulb:()=>Df,pushLocalBulb:()=>Bf,readBulbLog:()=>If,repoRoot:()=>Pn,searchBulbs:()=>Pf,searchSessions:()=>_I,setBulbTrust:()=>Rf,stopBreakout:()=>Tf,summarizeTurn:()=>MI});var Av,AI,TI,OI,PI,CI,_I,RI,II,NI,$I,LI,MI,DI,BI,Ov=S(()=>{"use strict";Ga();Bu();Qa();Vs();Av=new Zn,AI=Av.displayName,{info:TI,poll:OI,logInlineStatus:PI,listSessions:CI,searchSessions:_I,attach:RI,listChildren:II,openChild:NI,closeChild:$I,composerPasteRead:LI,summarizeTurn:MI,childStatus:DI,judgeChildStatus:BI}=Cr(Av)});import{readFileSync as jI,writeFileSync as FI,mkdirSync as UI}from"fs";import{homedir as qI}from"os";import*as sl from"path";async function _v(){try{let t=await fetch(new URL("/api/tags",Cv()).toString(),{signal:AbortSignal.timeout(JI)});return t.ok?((await t.json()).models??[]).map(n=>n.name).filter(n=>!!n):[]}catch{return[]}}function Rv(t){let e;try{e=jI(t,"utf-8")}catch{return{json:void 0,unreadable:!1}}try{let n=JSON.parse(e);if(n&&typeof n=="object"&&!Array.isArray(n)){let r=n;return{json:r,unreadable:"providers"in r&&!Kf(r)}}}catch{}return{json:void 0,unreadable:!0}}function Kf(t){let e=t?.providers;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function WI(t){let e=Kf(t);if(!e||!("ollama"in e))return null;let n=e.ollama?.models;return Array.isArray(n)?n.map(r=>r?.id).filter(r=>typeof r=="string"):[]}async function Iv(){let{json:t,unreadable:e}=Rv(Pv());return e?{installed:[],configured:null}:{installed:await _v(),configured:WI(t)}}async function Nv(){let t=await _v();return t.length?KI(Pv(),t,Cv()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function KI(t,e,n){let{json:r,unreadable:s}=Rv(t);if(s)return{ok:!1,error:`could not parse ${t} \u2014 edit the ollama provider there yourself`};let i={...r??{},providers:{...Kf(r)??{},ollama:{baseUrl:`${n}/v1`,api:"openai-completions",apiKey:"ollama",models:e.map(o=>({id:o}))}}};try{UI(sl.dirname(t),{recursive:!0}),FI(t,JSON.stringify(i,null,2)+`
2118
+ `)}catch(o){return{ok:!1,error:`could not write ${t}: ${Y(o)}`}}return{ok:!0,count:e.length}}var JI,Pv,Cv,$v=S(()=>{"use strict";Vt();Tn();JI=1500,Pv=()=>sl.join(qI(),".pi","agent","models.json"),Cv=()=>ur(process.env.OLLAMA_HOST??"http://localhost:11434")});var Mv={};Si(Mv,{attach:()=>QI,breakout:()=>Ef,closeChild:()=>tN,composerFiles:()=>iN,composerNew:()=>sN,composerPaste:()=>lN,composerPasteRead:()=>cN,composerRpc:()=>aN,composerSend:()=>nN,composerStop:()=>rN,composerUiRespond:()=>oN,displayName:()=>HI,downloadSample:()=>$f,git:()=>et,gitChangedFiles:()=>nf,gitDiff:()=>rf,info:()=>zI,launchBulb:()=>Cf,listBreakouts:()=>Af,listBulbFiles:()=>Of,listChildren:()=>ZI,listMyBulbs:()=>Mf,listSamples:()=>Nf,listSessions:()=>GI,logInlineStatus:()=>VI,ollamaOffer:()=>Iv,ollamaSync:()=>Nv,openChild:()=>eN,openFile:()=>xf,poll:()=>YI,predictTrustOf:()=>_f,pullRemoteBulb:()=>Df,pushLocalBulb:()=>Bf,readBulbLog:()=>If,repoRoot:()=>Pn,searchBulbs:()=>Pf,searchSessions:()=>XI,setBulbTrust:()=>Rf,shutdownComposer:()=>dN,stopBreakout:()=>Tf,summarizeTurn:()=>uN});var Lv,HI,zI,YI,VI,GI,XI,QI,ZI,eN,tN,nN,rN,sN,iN,oN,aN,lN,cN,uN,dN,Dv=S(()=>{"use strict";Ga();ef();Qa();Vs();$v();Lv=new Or,HI=Lv.displayName,{info:zI,poll:YI,logInlineStatus:VI,listSessions:GI,searchSessions:XI,attach:QI,listChildren:ZI,openChild:eN,closeChild:tN,composerSend:nN,composerStop:rN,composerNew:sN,composerFiles:iN,composerUiRespond:oN,composerRpc:aN,composerPaste:lN,composerPasteRead:cN,summarizeTurn:uN,shutdownComposer:dN}=Cr(Lv)});import*as sk from"fs/promises";import*as At from"path";ki();Q();function Tu(t){if(!Je.includes(t))throw new Error(`Unknown block kind '${t}' (one of: ${Je.join(", ")})`);return t}function Zg(t){let e=[];for(let n of t){let r=n.indexOf("=");if(r<=0||r===n.length-1)throw new Error(`Expected <kind>=<source>, got '${n}' (e.g. data=results.json, or data=- for stdin)`);let s=Tu(n.slice(0,r));if(e.some(i=>i.kind===s))throw new Error(`Duplicate block kind '${s}' \u2014 each block can be written once per invocation`);e.push({kind:s,source:n.slice(r+1)})}if(e.filter(n=>n.source==="-").length>1)throw new Error("Only one <kind>=- can read stdin");return e}Do();Bu();ef();var il={claude:{adapter:()=>new Xn,server:()=>Promise.resolve().then(()=>(Ev(),xv))},codex:{adapter:()=>new Zn,server:()=>Promise.resolve().then(()=>(Ov(),Tv))},pi:{adapter:()=>new Or,server:()=>Promise.resolve().then(()=>(Dv(),Mv))}};function Bv(t){return t in il}function Rr(){return Object.keys(il)}function ol(){return Object.fromEntries(Object.entries(il).map(([t,e])=>[t,e.adapter]))}function jv(t){return il[t].server()}var ci=ol();function Fv(){for(let t of Object.values(ci))try{t().ensureHarnessSupport()}catch{}}function kt(){for(let t of Object.keys(ci))try{if(ci[t]().detectsSelf())return t}catch{}}function Uv(t){let e=Rr(),n=new Map(e.filter(i=>ci[i]).map(i=>[i,ci[i]()]));for(let[i,o]of n)if(o.detectsSelf())return{name:i};let r=[...n].filter(([,i])=>i.detectsInstalled()).map(([i])=>i);if(r.length===0)return{name:e[0]};if(r.length===1)return{name:r[0]};let s=i=>n.get(i).listSessionFiles(t).length>0;return{ambiguous:[...r].sort((i,o)=>Number(s(o))-Number(s(i)))}}var zf=5e3;function Hf(t){try{return t()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function qv(t){let n={subcommand:"run",file:"",watch:!0,open:process.env.TERM_PROGRAM==="vscode"||kt()!==void 0?"link":"window",server:!1,trust:!1,noTrust:!1,force:!1,follow:!1,clear:!1,help:!1,version:!1,callArgs:[],hasArgsFlag:!1},r=["call","check","predict","logs","wait","stop","trust","untrust","models","slug","send","pull","push","get","put","status"],s=t[0];if(s==="agent"||s?.startsWith("agent:")){n.subcommand="agent";let o=s.indexOf(":");if(o!==-1){let a=s.slice(o+1);a&&(n.agentTarget=a)}t=t.slice(1)}else s&&r.includes(s)&&(n.subcommand=s,t=t.slice(1));let i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="--help"||a==="-h")n.help=!0;else if(a==="--version"||a==="-V")n.version=!0;else if(a==="--no-watch")n.watch=!1;else if(a==="--open")n.open="window";else if(a==="--no-open")n.open="none";else if(a==="--server")n.server=!0;else if(a==="--trust")n.trust=!0;else if(a==="--no-trust")n.noTrust=!0;else if(a==="--force")n.force=!0;else if(a==="--mode"){let l=t[++o];(!l||l.startsWith("-"))&&(console.error("Missing value for --mode (e.g. --mode staging)"),process.exit(1)),n.mode=l}else if(a==="--follow"||a==="-f")n.follow=!0;else if(a==="--clear")n.clear=!0;else if(a==="--run"){let l=t[++o];if(l==="latest")n.run="latest";else{let c=parseInt(l,10);(isNaN(c)||c<1)&&(console.error(`Invalid --run value: ${l} (a run number, or 'latest')`),process.exit(1)),n.run=c}}else if(a==="--bulbs")n.stopScope="bulbs";else if(a==="--agent")n.stopScope="agent";else if(a==="--global")n.stopScope="global";else if(a==="--match"){let l=t[++o];l===void 0&&(console.error("Missing value for --match (a literal substring new log lines must contain)"),process.exit(1)),n.match=l}else if(a==="--timeout"){let l=parseInt(t[++o],10);(isNaN(l)||l<=0)&&(console.error(`Invalid --timeout value: ${t[o]} (seconds)`),process.exit(1)),n.timeoutSec=l}else if(a==="--wait"||a.startsWith("--wait="))if(a.startsWith("--wait=")){let l=parseInt(a.slice(7),10);(isNaN(l)||l<=0)&&(console.error(`Invalid --wait value: ${a.slice(7)} (milliseconds)`),process.exit(1)),n.sendWaitMs=l}else n.sendWaitMs=zf;else if(a==="--lines"||a==="-n"){let l=parseInt(t[++o],10);(isNaN(l)||l<0)&&(console.error(`Invalid --lines value: ${t[o]}`),process.exit(1)),n.lines=l}else if(a==="--port"||a==="-p"){let l=t[++o],c=parseInt(l,10);isNaN(c)&&(console.error(`Invalid port: ${l}`),process.exit(1)),n.port=c}else if(a==="--replace"||a.startsWith("--replace=")){let l=a.startsWith("--replace=")?a.slice(10):t[++o]??"",c=Hf(()=>bp(l));n.local&&(console.error(`--replace can only be used once (got '${n.local.name}' and '${c.name}')`),process.exit(1)),n.local=c}else if(a==="--args"||a.startsWith("--args=")){n.hasArgsFlag=!0;let l=a.startsWith("--args=")?a.slice(7):t[++o];l===void 0&&(console.error("Missing value for --args (a JSON array, or - to read it from stdin)"),process.exit(1)),n.argsJson=l}else if(!a.startsWith("-")||a==="-"&&n.subcommand==="send")["call","send","get","put","slug","status"].includes(n.subcommand)?i.push(a):n.file=a;else{let l=n.subcommand==="call"?" (for a negative or dash-leading argument, use --args '<json-array>')":"";console.error(`Unknown option: ${a}${l}`),process.exit(1)}}return n.subcommand==="call"&&(i.length<2&&(console.error("Usage: typebulb call <file> <fn> [arg\u2026]"),process.exit(1)),n.file=i[0],n.fn=i[1],n.callArgs=i.slice(2)),n.subcommand==="send"&&(i.length<1&&(console.error("Usage: typebulb send <file> [message]"),process.exit(1)),n.file=i[0],n.sendMessage=i[1]),n.subcommand==="slug"&&(i.length||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1)),n.slugName=i.join(" ")),n.subcommand==="status"&&i.length&&(n.statusQuery=i.join(" ")),n.subcommand==="get"&&(i.length!==2&&(console.error("Usage: typebulb get <file> <kind>"),process.exit(1)),n.file=i[0],n.blockKind=Hf(()=>Tu(i[1]))),n.subcommand==="put"&&(i.length<2&&(console.error("Usage: typebulb put <file> <kind>=<source> [<kind>=<source> \u2026]"),process.exit(1)),n.file=i[0],n.blockPairs=Hf(()=>Zg(i.slice(1)))),n}function Jv(){console.log(`
2119
2119
  typebulb - Local bulb runner for Typebulb
2120
2120
 
2121
2121
  Usage:
@@ -2293,7 +2293,7 @@ Examples:
2293
2293
  typebulb my-editor.bulb.md
2294
2294
  typebulb --no-watch my-editor.bulb.md
2295
2295
  typebulb .
2296
- `)}St();Os();ki();_s();St();import*as Ue from"path";import{spawn as BN,execSync as jN}from"child_process";import{createRequire as FN}from"module";import{existsSync as UN}from"fs";import*as be from"fs/promises";import*as he from"path";var Yf=[{name:"es5"},{name:"es2015.core"},{name:"es2015.collection"},{name:"es2015.promise"},{name:"es2015.iterable"},{name:"es2015.symbol"},{name:"es2015.symbol.wellknown"},{name:"es2015.generator"},{name:"es2015.proxy"},{name:"es2015.reflect"},{name:"es2016.array.include"},{name:"es2016.intl"},{name:"es2017.object"},{name:"es2017.string"},{name:"es2017.sharedmemory"},{name:"es2017.typedarrays"},{name:"es2017.date"},{name:"es2017.intl"},{name:"es2018.asynciterable"},{name:"es2018.asyncgenerator"},{name:"es2018.promise"},{name:"es2018.regexp"},{name:"es2018.intl"},{name:"es2019.array"},{name:"es2019.object"},{name:"es2019.string"},{name:"es2019.symbol"},{name:"es2019.intl"},{name:"es2020.bigint"},{name:"es2020.promise"},{name:"es2020.string"},{name:"es2020.sharedmemory"},{name:"es2020.date"},{name:"es2020.number"},{name:"es2020.symbol.wellknown"},{name:"es2020.intl"},{name:"es2021.promise"},{name:"es2021.string"},{name:"es2021.weakref"},{name:"es2021.intl"},{name:"es2022.array"},{name:"es2022.object"},{name:"es2022.error"},{name:"es2022.string"},{name:"es2022.regexp"},{name:"es2022.intl"},{name:"es2023.array"},{name:"es2023.collection"},{name:"es2023.intl",since:"5.5"},{name:"es2024.arraybuffer",since:"5.5"},{name:"es2024.collection",since:"5.5"},{name:"es2024.object",since:"5.5"},{name:"es2024.promise",since:"5.5"},{name:"es2024.regexp",since:"5.5"},{name:"es2024.sharedmemory",since:"5.5"},{name:"es2024.string",since:"5.5"},{name:"esnext.array",since:"5.5"},{name:"esnext.collection"},{name:"esnext.decorators"},{name:"esnext.disposable"},{name:"esnext.error",since:"5.5"},{name:"esnext.float16",since:"5.5"},{name:"esnext.iterator",since:"5.5"},{name:"esnext.object"},{name:"esnext.promise"},{name:"esnext.sharedmemory",since:"5.5"},{name:"esnext.intl"}],Vf=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];function Gf(t,e){if(!e)return t.filter(s=>!s.since);let n={"5.0":0,"5.5":1},r=n[e];return t.filter(s=>!s.since||n[s.since]<=r)}ee();var dN=`
2296
+ `)}St();Os();ki();_s();St();import*as Ue from"path";import{spawn as jN,execSync as FN}from"child_process";import{createRequire as UN}from"module";import{existsSync as qN}from"fs";import*as be from"fs/promises";import*as me from"path";var Yf=[{name:"es5"},{name:"es2015.core"},{name:"es2015.collection"},{name:"es2015.promise"},{name:"es2015.iterable"},{name:"es2015.symbol"},{name:"es2015.symbol.wellknown"},{name:"es2015.generator"},{name:"es2015.proxy"},{name:"es2015.reflect"},{name:"es2016.array.include"},{name:"es2016.intl"},{name:"es2017.object"},{name:"es2017.string"},{name:"es2017.sharedmemory"},{name:"es2017.typedarrays"},{name:"es2017.date"},{name:"es2017.intl"},{name:"es2018.asynciterable"},{name:"es2018.asyncgenerator"},{name:"es2018.promise"},{name:"es2018.regexp"},{name:"es2018.intl"},{name:"es2019.array"},{name:"es2019.object"},{name:"es2019.string"},{name:"es2019.symbol"},{name:"es2019.intl"},{name:"es2020.bigint"},{name:"es2020.promise"},{name:"es2020.string"},{name:"es2020.sharedmemory"},{name:"es2020.date"},{name:"es2020.number"},{name:"es2020.symbol.wellknown"},{name:"es2020.intl"},{name:"es2021.promise"},{name:"es2021.string"},{name:"es2021.weakref"},{name:"es2021.intl"},{name:"es2022.array"},{name:"es2022.object"},{name:"es2022.error"},{name:"es2022.string"},{name:"es2022.regexp"},{name:"es2022.intl"},{name:"es2023.array"},{name:"es2023.collection"},{name:"es2023.intl",since:"5.5"},{name:"es2024.arraybuffer",since:"5.5"},{name:"es2024.collection",since:"5.5"},{name:"es2024.object",since:"5.5"},{name:"es2024.promise",since:"5.5"},{name:"es2024.regexp",since:"5.5"},{name:"es2024.sharedmemory",since:"5.5"},{name:"es2024.string",since:"5.5"},{name:"esnext.array",since:"5.5"},{name:"esnext.collection"},{name:"esnext.decorators"},{name:"esnext.disposable"},{name:"esnext.error",since:"5.5"},{name:"esnext.float16",since:"5.5"},{name:"esnext.iterator",since:"5.5"},{name:"esnext.object"},{name:"esnext.promise"},{name:"esnext.sharedmemory",since:"5.5"},{name:"esnext.intl"}],Vf=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];function Gf(t,e){if(!e)return t.filter(s=>!s.since);let n={"5.0":0,"5.5":1},r=n[e];return t.filter(s=>!s.since||n[s.since]<=r)}Q();var fN=`
2297
2297
  /**
2298
2298
  * Get raw data chunk from the Data tab.
2299
2299
  * @param index - Chunk index (0-based). Separate chunks with 2 blank lines.
@@ -2304,7 +2304,7 @@ Examples:
2304
2304
  * @param index - Chunk index (0-based)
2305
2305
  * @throws If chunk is not valid JSON/JSON-ish
2306
2306
  */
2307
- json<T = unknown>(index: number): T;`,fN=`
2307
+ json<T = unknown>(index: number): T;`,pN=`
2308
2308
  /**
2309
2309
  * Get the insight data produced by the inference layer.
2310
2310
  *
@@ -2313,7 +2313,7 @@ Examples:
2313
2313
  *
2314
2314
  * @returns The parsed insight JSON, or undefined if no insight is available
2315
2315
  */
2316
- insight<T = unknown>(): T | undefined;`,pN=`
2316
+ insight<T = unknown>(): T | undefined;`,hN=`
2317
2317
  /**
2318
2318
  * Replace the data this run is working on.
2319
2319
  *
@@ -2336,7 +2336,7 @@ Examples:
2336
2336
  *
2337
2337
  * @param value - Any JSON-serializable value
2338
2338
  */
2339
- setInsight(value: unknown): Promise<void>;`,qv=`options: {
2339
+ setInsight(value: unknown): Promise<void>;`,Wv=`options: {
2340
2340
  messages: Array<{ role: "user" | "assistant"; content: string }>;
2341
2341
  system?: string;
2342
2342
  /** Reasoning effort: 0=minimal, 1=low, 2=med, 3=high, 4=xhigh. Mapped to each provider's native mechanism (OpenAI/OpenRouter reasoning effort, Gemini thinking level, Anthropic adaptive thinking). 0 reaches the vendor's explicit off switch, and floors to a little thinking only on always-thinking models. 4 reaches the rung above high where the vendor has one (OpenAI/OpenRouter xhigh, Anthropic max) and clamps to high where it doesn't (Gemini) \u2014 never an error. Pin 1 (low) for most work; pick 0 deliberately, when you want the raw model or latency is the constraint. Omitting is NOT off \u2014 it buys the model's own default (medium on GPT-5.6), which reasons and bills invisibly. Ignored on the courtesy model, which runs at the level Typebulb sets. */
@@ -2347,7 +2347,7 @@ Examples:
2347
2347
  webSearch?: boolean;
2348
2348
  /** Abort the request. On abort the promise rejects / the stream ends. */
2349
2349
  signal?: AbortSignal;
2350
- }`,Jv=`
2350
+ }`,Kv=`
2351
2351
  /** Provider-reported token counts for one call \u2014 real usage from the API, never an estimate.
2352
2352
  * \`output\` is total billed output (reasoning included); \`reasoning\` is the itemized subset where
2353
2353
  * the provider splits it (OpenAI, Gemini, OpenRouter \u2014 Anthropic doesn't); \`cacheRead\` is the
@@ -2359,10 +2359,10 @@ type AiChunk =
2359
2359
  | { kind: "text"; text: string }
2360
2360
  | { kind: "reasoning"; text: string }
2361
2361
  | { kind: "usage"; usage: AiUsage };
2362
- `,Wv=`
2362
+ `,Hv=`
2363
2363
  /** What backs \`tb.ai\`: the user's own keys, the quota-limited courtesy model, or nothing. */
2364
2364
  type AiAccess = "own" | "courtesy" | "none";
2365
- `,Kv=`
2365
+ `,zv=`
2366
2366
  /**
2367
2367
  * General-purpose AI call. \`tb.ai(opts)\` resolves with the full text; \`tb.ai.stream(opts)\`
2368
2368
  * returns an async iterable of {@link AiChunk} deltas you consume with \`for await\`.
@@ -2372,7 +2372,7 @@ type AiAccess = "own" | "courtesy" | "none";
2372
2372
  * @throws On rate limit, network error, or provider error
2373
2373
  */
2374
2374
  ai: {
2375
- (${qv}): Promise<{ text: string; usage?: AiUsage }>;
2375
+ (${Wv}): Promise<{ text: string; usage?: AiUsage }>;
2376
2376
  /**
2377
2377
  * Streaming counterpart of \`tb.ai()\`. Yields \`{ kind: "text" | "reasoning", text }\` deltas
2378
2378
  * as they arrive, then one final \`{ kind: "usage", usage }\` chunk with the call's token
@@ -2389,8 +2389,8 @@ type AiAccess = "own" | "courtesy" | "none";
2389
2389
  * if (c.kind === "text") answer += c.text;
2390
2390
  * }
2391
2391
  */
2392
- stream(${qv}): AsyncIterable<AiChunk>;
2393
- };`,Hv=`
2392
+ stream(${Wv}): AsyncIterable<AiChunk>;
2393
+ };`,Yv=`
2394
2394
  /**
2395
2395
  * Returns AI models available to the current user.
2396
2396
  * Models are filtered by the user's configured API keys.
@@ -2420,7 +2420,7 @@ type AiAccess = "own" | "courtesy" | "none";
2420
2420
  * \`tb.mode\` or the length of \`tb.models()\` \u2014 which hosts offer a courtesy
2421
2421
  * model is the host's business and changes without your bulb changing.
2422
2422
  */
2423
- aiAccess(): Promise<AiAccess>;`,hN="\n /**\n * The bulb's theme override (`<html data-theme>`).\n *\n * - Get: the current override \u2014 `'dark'` | `'light'`, or `undefined` when\n * following the OS preference.\n * - Set `'dark'`/`'light'` to force and persist it (per-bulb); set\n * `undefined` to clear the override and follow the OS again.\n *\n * Drives `<html data-theme>`, so render off `html[data-theme=\"\u2026\"]` selectors\n * (or observe the attribute) rather than reading `tb.theme`.\n */\n theme: 'light' | 'dark' | undefined;",zv=`
2423
+ aiAccess(): Promise<AiAccess>;`,mN="\n /**\n * The bulb's theme override (`<html data-theme>`).\n *\n * - Get: the current override \u2014 `'dark'` | `'light'`, or `undefined` when\n * following the OS preference.\n * - Set `'dark'`/`'light'` to force and persist it (per-bulb); set\n * `undefined` to clear the override and follow the OS again.\n *\n * Drives `<html data-theme>`, so render off `html[data-theme=\"\u2026\"]` selectors\n * (or observe the attribute) rather than reading `tb.theme`.\n */\n theme: 'light' | 'dark' | undefined;",Vv=`
2424
2424
  /**
2425
2425
  * The mode this bulb is running in.
2426
2426
  *
@@ -2430,7 +2430,7 @@ type AiAccess = "own" | "courtesy" | "none";
2430
2430
  * - \`'inline'\` \u2014 Running inline in an agent's transcript, rendered by the mirror
2431
2431
  * (sandboxed, client-only: AI, filesystem, and server RPC are unavailable)
2432
2432
  */
2433
- mode: ${Hg};`,Yv=`
2433
+ mode: ${Hg};`,Gv=`
2434
2434
  /**
2435
2435
  * Local filesystem access (CLI only).
2436
2436
  *
@@ -2451,7 +2451,7 @@ type AiAccess = "own" | "courtesy" | "none";
2451
2451
  list(path?: string): Promise<Array<{ name: string; dir: boolean; mtime: number }>>;
2452
2452
  /** Remove a file, or a folder and everything in it. Throws if the path does not exist; the bulb's folder itself cannot be removed. */
2453
2453
  remove(path: string): Promise<boolean>;
2454
- };`,Vv=`
2454
+ };`,Xv=`
2455
2455
  /**
2456
2456
  * The bulb's folder \u2014 absolute path to \`<bulb-dir>/<filename-stem>/\`
2457
2457
  *
@@ -2459,7 +2459,7 @@ type AiAccess = "own" | "courtesy" | "none";
2459
2459
  * \`tb.fs\` already resolves relative paths against it, so bulb code writing
2460
2460
  * its own files never needs it. CLI only \u2014 throws in ide/published/inline mode.
2461
2461
  */
2462
- readonly dir: string;`,mN=`
2462
+ readonly dir: string;`,gN=`
2463
2463
  /**
2464
2464
  * Async value inspector for tensor-like objects.
2465
2465
  *
@@ -2512,48 +2512,48 @@ type AiAccess = "own" | "courtesy" | "none";
2512
2512
  *
2513
2513
  * @returns The full canonical URL
2514
2514
  */
2515
- url(): Promise<string>;`,gN="\n /**\n * Subscribe to a value pushed from the terminal via `typebulb send <file> [message]`.\n *\n * The dual of `tb.log` (data out): a value sent *in* from the CLI, no `--trust` required.\n * Use it to start expensive work on demand instead of on load \u2014 e.g. `tb.onMessage(() => start())`\n * \u2014 so hot reloads don't re-trigger it while you edit, and an agent kicks off one run when ready.\n *\n * The message is the JSON-parsed value of what `send` was given (or the raw string if it isn't\n * JSON; `undefined` for a bare `typebulb send <file>`). A non-`undefined` return value (awaited)\n * becomes the reply `send --wait` prints on stdout \u2014 JSON-serializable, at most one handler\n * replying \u2014 the structured read-back for self-tests. Returns an unsubscribe function. Inert in\n * an inline bulb (no sender) \u2014 the handler is registered but never fires.\n *\n * @param handler - Called with each pushed message; may return a JSON-serializable reply.\n * @returns An unsubscribe function.\n */\n onMessage(handler: (message: any) => unknown): () => void;",yN="\n /**\n * Print to the CLI's stdout \u2014 the bulb's log channel, read back with `typebulb logs <file>`.\n *\n * Ungated: needs no `server.ts` block and no `--trust`, so a Restricted client-only bulb can\n * instrument itself. Args cross to the CLI as JSON; where no CLI serves the page (web, inline,\n * or a transport failure) it falls back to the browser console. Works in `server.ts` too (same\n * as `console.log` there).\n */\n log(...args: any[]): void;",bN="\n /**\n * Server-side function proxy.\n *\n * In the CLI, calls exported functions from the `**server.ts**` section.\n *\n * A normal export is awaited for its result (`await tb.server.fn()`). An `async function*`\n * export streams: `for await (const chunk of tb.server.gen())`. The call object supports both;\n * break the `for await` to cancel and tear down the server generator.\n */\n server: Record<string, (...args: any[]) => Promise<any> & AsyncIterable<any>>;",Xf=`${Jv}${Wv}
2515
+ url(): Promise<string>;`,yN="\n /**\n * Subscribe to a value pushed from the terminal via `typebulb send <file> [message]`.\n *\n * The dual of `tb.log` (data out): a value sent *in* from the CLI, no `--trust` required.\n * Use it to start expensive work on demand instead of on load \u2014 e.g. `tb.onMessage(() => start())`\n * \u2014 so hot reloads don't re-trigger it while you edit, and an agent kicks off one run when ready.\n *\n * The message is the JSON-parsed value of what `send` was given (or the raw string if it isn't\n * JSON; `undefined` for a bare `typebulb send <file>`). A non-`undefined` return value (awaited)\n * becomes the reply `send --wait` prints on stdout \u2014 JSON-serializable, at most one handler\n * replying \u2014 the structured read-back for self-tests. Returns an unsubscribe function. Inert in\n * an inline bulb (no sender) \u2014 the handler is registered but never fires.\n *\n * @param handler - Called with each pushed message; may return a JSON-serializable reply.\n * @returns An unsubscribe function.\n */\n onMessage(handler: (message: any) => unknown): () => void;",bN="\n /**\n * Print to the CLI's stdout \u2014 the bulb's log channel, read back with `typebulb logs <file>`.\n *\n * Ungated: needs no `server.ts` block and no `--trust`, so a Restricted client-only bulb can\n * instrument itself. Args cross to the CLI as JSON; where no CLI serves the page (web, inline,\n * or a transport failure) it falls back to the browser console. Works in `server.ts` too (same\n * as `console.log` there).\n */\n log(...args: any[]): void;",wN="\n /**\n * Server-side function proxy.\n *\n * In the CLI, calls exported functions from the `**server.ts**` section.\n *\n * A normal export is awaited for its result (`await tb.server.fn()`). An `async function*`\n * export streams: `for await (const chunk of tb.server.gen())`. The call object supports both;\n * break the `for await` to cancel and tear down the server generator.\n */\n server: Record<string, (...args: any[]) => Promise<any> & AsyncIterable<any>>;",Xf=`${Kv}${Hv}
2516
2516
  /**
2517
2517
  * Typebulb utilities namespace.
2518
2518
  * Type \`tb.\` to discover available helpers.
2519
2519
  */
2520
- declare const tb: {${dN}${mN}${fN}${pN}${yN}${bN}${gN}${Kv}${Yv}${Vv}${Hv}${hN}${zv}
2520
+ declare const tb: {${fN}${gN}${pN}${hN}${bN}${wN}${yN}${zv}${Gv}${Xv}${Yv}${mN}${Vv}
2521
2521
  };
2522
- `,wN=`
2522
+ `,vN=`
2523
2523
  /**
2524
2524
  * Print to the CLI's stdout \u2014 the same channel as \`console.log\` here (the server's console IS
2525
2525
  * the bulb's log). One log verb across blocks: page-side \`tb.log\` reaches this same stdout.
2526
2526
  */
2527
- log(...args: any[]): void;`,Qf=`${Jv}${Wv}
2527
+ log(...args: any[]): void;`,Qf=`${Kv}${Hv}
2528
2528
  /**
2529
2529
  * Typebulb utilities namespace (server-side).
2530
2530
  * Type \`tb.\` to discover available helpers.
2531
2531
  */
2532
- declare const tb: {${wN}${Kv}${Yv}${Vv}${Hv}${zv}
2532
+ declare const tb: {${vN}${zv}${Gv}${Xv}${Yv}${Vv}
2533
2533
  };
2534
- `;yt();import xN from"p-limit";yt();import{resolve as Xv}from"resolve.exports";var xt={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},ui=["index.d.ts","index.d.mts"],Zf=/\.d\.(ts|mts|cts)$/i;function al(t){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(t)||/[?&]dts(?:[&#]|$)/i.test(t)}function Gv(t){return[`${t}.d.ts`,`${t}.d.mts`]}function Qt(t){if(!t||t==="./"||t==="/")return[...ui];let e=t.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),n=Gv(e),r=e.endsWith("/")?e:`${e}/`;return n.push(...Gv(`${r}index`)),n}async function Rr(t,{retries:e=2,timeoutMs:n=15e3,init:r}={}){for(let s=0;s<=e;s++){let i=new AbortController,o=setTimeout(()=>i.abort(),n);try{let a=await fetch(t,{...r,signal:i.signal});if(vN(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function vN(t){return t===408||t===429||t>=500&&t<600}var ll=class{constructor(e,n){this.fetchDts=e,this.cdnClient=n}async tryUrls(e){for(let n of e){let r=await this.fetchDts(n);if(r&&(this.looksLikeDts(r.dts)||al(r.url)))return r}}looksLikeDts(e){return/^\s*export\s*\{\s*\}\s*;?\s*$/m.test(e)?!0:/declare\s+(module|namespace|class|interface|function|const|var|let)/.test(e)||/interface\s+\w+/.test(e)||/type\s+\w+\s*=/.test(e)}async loadPackageAtVersionedRoot(e,n){let r=this.cdnClient.packageJson(new B({name:e,version:n})),s=await Rr(r);if(!s?.ok)return;let i;try{i=await s.json()}catch{return}if(i)return{pkg:i,baseDir:this.cdnClient.baseDir(new B({name:e,version:n??i.version})),version:n}}extractPathFromResult(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.find(n=>typeof n=="string")}async tryUntilSuccess(e,n){for(let r of e){let s=await n(r);if(s)return s}}async resolveFromSelected(e,n,r){if(e.kind==="types"){let o=kn(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([...ui],n);if(!Zf.test(o)){let a=await this.tryUntilSuccess(Qt(o),n);if(a)return a}return n(o)}let s=Qt(e.path),i=r?.subpath?[...s,...ui]:[...ui,...s];return this.tryUntilSuccess(i,n)}toResolutionResult(e){return{kind:Zf.test(e)?"types":"probe",path:e}}resolveExportsPath(e,n){let r=n||".",s=e;try{let i=this.extractPathFromResult(Xv(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(Xv(s,r,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let n=B.parse(e),{pkg:r,baseDir:s}=await this.loadPackageAtVersionedRoot(n.name,n.version)||{};if(!r||!s)return;let i={name:n.name,version:n.version},o=new B(i).format(),a=new B({...i,subpath:n.subpath}).format(),l=d=>this.fetchCandidateFrom(s,n.name,d);if(n.subpath){let d=Cd(n.subpath),u=this.resolveExportsPath(r,d);if(u){let m=await this.resolveFromSelected(this.toResolutionResult(u),l,{subpath:!0});if(m)return{...m,resolvedPkg:a}}let p=await this.tryUntilSuccess(Qt(d),l);if(p)return{...p,resolvedPkg:a}}let c=r.types??r.typings;if(c){let d=await this.resolveFromSelected({kind:"types",path:c},l);if(d)return{...d,resolvedPkg:o}}let f=this.resolveExportsPath(r,".");if(f){let d=await this.resolveFromSelected(this.toResolutionResult(f),l);if(d)return{...d,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,n,r){let s=kn(r),i=new URL(s,e).toString(),o=await this.tryUrls([i]);return o?{dts:o.dts,url:o.url,resolvedPkg:n}:void 0}};yt();import{gunzipSync as SN}from"fflate";var cl=class{async fetchAndExtract(e,n){let r=this.getTarballUrl(e,n),s=await Rr(r,{timeoutMs:3e4});if(!s?.ok)return new Map;let i=new Uint8Array(await s.arrayBuffer());return this.extractDtsFiles(i)}getTarballUrl(e,n){return`https://registry.npmjs.org/${e.replace("/","%2F")}/-/${e.split("/").pop()}-${n}.tgz`}normalizeTarPath(e){let n=e.replace(/^package\//,""),r=n.indexOf("/");return r>0?n.substring(r+1):n}extractDtsFiles(e){let n=new Map;try{let r=SN(e),s=new TextDecoder("utf-8"),i=0;for(;i<r.length-512;){let o=r.slice(i,i+512);if(o[0]===0)break;let a=o.slice(0,100),l=a.indexOf(0),c=s.decode(a.slice(0,l>0?l:100)).trim(),f=o.slice(124,136),d=s.decode(f).trim().replace(/\0/g,""),u=parseInt(d,8)||0,p=String.fromCharCode(o[156]);if(i+=512,(p==="0"||p==="\0")&&(c.endsWith(".d.ts")||c.endsWith(".d.mts"))){let m=r.slice(i,i+u);n.set(this.normalizeTarPath(c),s.decode(m))}i+=Math.ceil(u/512)*512}}catch{}return n}};var ul=class{constructor(e,n,r=new cl){this.cdnClient=e,this.cache=n,this.tarballFetcher=r}typesNameCandidates(e){let n=e.startsWith("@")?e.slice(1).replace("/","__"):e;return n.includes(".")?[n,n.split(".").join("-"),n.split(".").join("")]:[n]}selectTypesVersion(e,n,r){try{if(r){let i=xn.majorOf(r),o=e.filter(a=>xn.majorOf(a)===i);if(o.length)return o.sort((a,l)=>xn.cmp(l,a))[0]}let s=n?.latest;return s&&e.includes(s)?s:e[0]}catch{return e[0]}}subpathCandidates(e){let n=e.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),r=Qt(e);return n!==e&&r.push(`${e}.d.ts`,`${e}/index.d.ts`),r}async fetchFromVersionedRoot(e,n){let r=new B(e),s=r.version;if(!s)return;let i;try{i=await this.tarballFetcher.fetchAndExtract(r.name,s)}catch{return}if(!i||i.size===0)return;for(let[a,l]of i.entries()){let c=this.cdnClient.file(e,a);try{await this.cache.setCachedFile(c,l)}catch{}}let o=n.subpath?this.subpathCandidates(n.subpath):["index.d.ts"];for(let a of o){let l=i.get(a);if(l)return{dts:l,url:this.cdnClient.file(e,a),resolvedPkg:n.subpath?new B(n).format():n.name}}}async resolve(e){let n=B.parse(e);if(n.name)for(let r of this.typesNameCandidates(n.name)){let s=`@types/${r}`,i;try{i=await this.cdnClient.fetchVersionsIndex(s)}catch{continue}if(!i?.versions?.length)continue;let o=this.selectTypesVersion(i.versions,i.distTags,n.version),a=await this.fetchFromVersionedRoot(`${s}@${o}`,n);if(a)return a}}};var dl=class{collectRelativeTypeRefs(e){return this.collectRefs(e).filter(n=>n.startsWith("./")||n.startsWith("../"))}collectBareModuleRefs(e){return this.collectRefs(e).filter(n=>this.isBare(n))}collectRefs(e){let n=e.split(`
2534
+ `;yt();import EN from"p-limit";yt();import{resolve as Zv}from"resolve.exports";var xt={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},ui=["index.d.ts","index.d.mts"],Zf=/\.d\.(ts|mts|cts)$/i;function al(t){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(t)||/[?&]dts(?:[&#]|$)/i.test(t)}function Qv(t){return[`${t}.d.ts`,`${t}.d.mts`]}function Qt(t){if(!t||t==="./"||t==="/")return[...ui];let e=t.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),n=Qv(e),r=e.endsWith("/")?e:`${e}/`;return n.push(...Qv(`${r}index`)),n}async function Ir(t,{retries:e=2,timeoutMs:n=15e3,init:r}={}){for(let s=0;s<=e;s++){let i=new AbortController,o=setTimeout(()=>i.abort(),n);try{let a=await fetch(t,{...r,signal:i.signal});if(SN(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function SN(t){return t===408||t===429||t>=500&&t<600}var ll=class{constructor(e,n){this.fetchDts=e,this.cdnClient=n}async tryUrls(e){for(let n of e){let r=await this.fetchDts(n);if(r&&(this.looksLikeDts(r.dts)||al(r.url)))return r}}looksLikeDts(e){return/^\s*export\s*\{\s*\}\s*;?\s*$/m.test(e)?!0:/declare\s+(module|namespace|class|interface|function|const|var|let)/.test(e)||/interface\s+\w+/.test(e)||/type\s+\w+\s*=/.test(e)}async loadPackageAtVersionedRoot(e,n){let r=this.cdnClient.packageJson(new B({name:e,version:n})),s=await Ir(r);if(!s?.ok)return;let i;try{i=await s.json()}catch{return}if(i)return{pkg:i,baseDir:this.cdnClient.baseDir(new B({name:e,version:n??i.version})),version:n}}extractPathFromResult(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.find(n=>typeof n=="string")}async tryUntilSuccess(e,n){for(let r of e){let s=await n(r);if(s)return s}}async resolveFromSelected(e,n,r){if(e.kind==="types"){let o=kn(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([...ui],n);if(!Zf.test(o)){let a=await this.tryUntilSuccess(Qt(o),n);if(a)return a}return n(o)}let s=Qt(e.path),i=r?.subpath?[...s,...ui]:[...ui,...s];return this.tryUntilSuccess(i,n)}toResolutionResult(e){return{kind:Zf.test(e)?"types":"probe",path:e}}resolveExportsPath(e,n){let r=n||".",s=e;try{let i=this.extractPathFromResult(Zv(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(Zv(s,r,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let n=B.parse(e),{pkg:r,baseDir:s}=await this.loadPackageAtVersionedRoot(n.name,n.version)||{};if(!r||!s)return;let i={name:n.name,version:n.version},o=new B(i).format(),a=new B({...i,subpath:n.subpath}).format(),l=d=>this.fetchCandidateFrom(s,n.name,d);if(n.subpath){let d=Cd(n.subpath),u=this.resolveExportsPath(r,d);if(u){let m=await this.resolveFromSelected(this.toResolutionResult(u),l,{subpath:!0});if(m)return{...m,resolvedPkg:a}}let p=await this.tryUntilSuccess(Qt(d),l);if(p)return{...p,resolvedPkg:a}}let c=r.types??r.typings;if(c){let d=await this.resolveFromSelected({kind:"types",path:c},l);if(d)return{...d,resolvedPkg:o}}let f=this.resolveExportsPath(r,".");if(f){let d=await this.resolveFromSelected(this.toResolutionResult(f),l);if(d)return{...d,resolvedPkg:o}}return}catch{return}}async fetchCandidateFrom(e,n,r){let s=kn(r),i=new URL(s,e).toString(),o=await this.tryUrls([i]);return o?{dts:o.dts,url:o.url,resolvedPkg:n}:void 0}};yt();import{gunzipSync as kN}from"fflate";var cl=class{async fetchAndExtract(e,n){let r=this.getTarballUrl(e,n),s=await Ir(r,{timeoutMs:3e4});if(!s?.ok)return new Map;let i=new Uint8Array(await s.arrayBuffer());return this.extractDtsFiles(i)}getTarballUrl(e,n){return`https://registry.npmjs.org/${e.replace("/","%2F")}/-/${e.split("/").pop()}-${n}.tgz`}normalizeTarPath(e){let n=e.replace(/^package\//,""),r=n.indexOf("/");return r>0?n.substring(r+1):n}extractDtsFiles(e){let n=new Map;try{let r=kN(e),s=new TextDecoder("utf-8"),i=0;for(;i<r.length-512;){let o=r.slice(i,i+512);if(o[0]===0)break;let a=o.slice(0,100),l=a.indexOf(0),c=s.decode(a.slice(0,l>0?l:100)).trim(),f=o.slice(124,136),d=s.decode(f).trim().replace(/\0/g,""),u=parseInt(d,8)||0,p=String.fromCharCode(o[156]);if(i+=512,(p==="0"||p==="\0")&&(c.endsWith(".d.ts")||c.endsWith(".d.mts"))){let m=r.slice(i,i+u);n.set(this.normalizeTarPath(c),s.decode(m))}i+=Math.ceil(u/512)*512}}catch{}return n}};var ul=class{constructor(e,n,r=new cl){this.cdnClient=e,this.cache=n,this.tarballFetcher=r}typesNameCandidates(e){let n=e.startsWith("@")?e.slice(1).replace("/","__"):e;return n.includes(".")?[n,n.split(".").join("-"),n.split(".").join("")]:[n]}selectTypesVersion(e,n,r){try{if(r){let i=xn.majorOf(r),o=e.filter(a=>xn.majorOf(a)===i);if(o.length)return o.sort((a,l)=>xn.cmp(l,a))[0]}let s=n?.latest;return s&&e.includes(s)?s:e[0]}catch{return e[0]}}subpathCandidates(e){let n=e.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),r=Qt(e);return n!==e&&r.push(`${e}.d.ts`,`${e}/index.d.ts`),r}async fetchFromVersionedRoot(e,n){let r=new B(e),s=r.version;if(!s)return;let i;try{i=await this.tarballFetcher.fetchAndExtract(r.name,s)}catch{return}if(!i||i.size===0)return;for(let[a,l]of i.entries()){let c=this.cdnClient.file(e,a);try{await this.cache.setCachedFile(c,l)}catch{}}let o=n.subpath?this.subpathCandidates(n.subpath):["index.d.ts"];for(let a of o){let l=i.get(a);if(l)return{dts:l,url:this.cdnClient.file(e,a),resolvedPkg:n.subpath?new B(n).format():n.name}}}async resolve(e){let n=B.parse(e);if(n.name)for(let r of this.typesNameCandidates(n.name)){let s=`@types/${r}`,i;try{i=await this.cdnClient.fetchVersionsIndex(s)}catch{continue}if(!i?.versions?.length)continue;let o=this.selectTypesVersion(i.versions,i.distTags,n.version),a=await this.fetchFromVersionedRoot(`${s}@${o}`,n);if(a)return a}}};var dl=class{collectRelativeTypeRefs(e){return this.collectRefs(e).filter(n=>n.startsWith("./")||n.startsWith("../"))}collectBareModuleRefs(e){return this.collectRefs(e).filter(n=>this.isBare(n))}collectRefs(e){let n=e.split(`
2535
2535
  `).filter(s=>{let i=s.trimStart();return!(i.startsWith("*")||i.startsWith("//")||i.startsWith("/*"))}).join(`
2536
- `),r=new Set;for(let s of n.matchAll(/(import|export)\s+[^'"\n]*from\s*['"]([^'"\n]+)['"]/g))r.add(s[2]);for(let s of n.matchAll(/export\s*\*\s*from\s*['"]([^'"\n]+)['"]/g))r.add(s[1]);return Array.from(r)}isBare(e){return!(e.startsWith("./")||e.startsWith("../")||e.startsWith("file:")||e.startsWith("http://")||e.startsWith("https://"))}};yt();var Qv="file:///node_modules",fl=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${Qv}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,n){let r=kn(n);return`${Qv}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as kN}from"lru-cache";function Zv(t){let e=new kN({ttl:xt.negativeTtlMs,max:500}),n=new Map;return async function(s){try{if(await t.isNegative(s)||e.has(s))return;let i=await t.getCachedFile(s);if(i)return{dts:i,url:s};let o=n.get(s);if(o)return o;let a=(async()=>{let l=await Rr(s,{init:{cache:"no-store"}});if(!l?.ok){l?.status===404&&(e.set(s,!0),await t.recordNegative(s));return}let c=await l.text(),f=l.url||s;return await t.clearNegative(s),await t.setCachedFile(f,c),{dts:c,url:f}})();return n.set(s,a),await a.finally(()=>n.delete(s))}catch{return}}}var di=class{constructor(e){this.inFlight=new Map,this.scanner=new dl,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=Zv(e.cache),this.typescriptProvider=new ll(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new ul(e.cdnClient,e.cache),this.virtualFs=new fl}withInFlight(e,n){let r=this.inFlight.get(e);if(r)return r;let s=n().finally(()=>this.inFlight.delete(e));return this.inFlight.set(e,s),s}invalidate(){this.virtualFs.bumpEpoch(),this.inFlight.clear()}pushFileIfNew(e,n,r){e.some(s=>s.path===n)||e.push({path:n,content:r})}createStubDef(e){let n=this.virtualFs.pathForMain(e);return{pkg:e,mainPath:n,files:[{path:n,content:"export const _shim: any; export default _shim;"}],shims:[{module:e,path:n}]}}async fetchViaProviders(e){for(let n of[this.typescriptProvider,this.definitelyTypedProvider])try{let r=await n.resolve(e);if(r?.dts)return r}catch{}}async fetchRootDts(e,n){let{effectivePackage:r,root:s,pinned:i}=await this.versionResolver.effectivePackage(e,n),o=await this.cache.getCachedDts(r);if(o?.content){let l=o.url??this.cdnClient.file(i?`${s}@${i}`:s,"index.d.ts");return{dts:o.content,url:l,resolvedPkg:r}}let a;try{a=await this.fetchViaProviders(r)}catch{return}if(!(!a?.dts||!a.url)&&new B(r).subpath===new B(a.resolvedPkg||r).subpath){try{await this.cache.setCachedDts(r,a.dts,a.url)}catch{}return a}}extractPackageRootUrl(e){let n=e.pathname.match(/^(.+@[^/]+\/)/);return n?new URL(n[1],e.origin):new URL("./",e)}toVirtualPath(e,n,r){let s=n.pathname.startsWith(e.pathname)?n.pathname.slice(e.pathname.length):`__deps__/${encodeURIComponent(n.toString()).replace(/%/g,"_")}.d.ts`;return this.virtualFs.pathFor(r,s)}computeEntryPath(e,n){if(!e)return{mainPath:this.virtualFs.pathForMain(n),packageRootUrl:void 0};let r=new URL(e),s=this.extractPackageRootUrl(r);return{mainPath:this.toVirtualPath(s,r,n),packageRootUrl:s}}async expandRelativeRefs(e,n,r,s,i=new Set,o){if(!i.has(n)&&(i.add(n),!(i.size>xt.maxRelativeTypeRefs)))try{let a=new URL(n),l=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let c=this.scanner.collectRelativeTypeRefs(e).slice(0,xt.maxRelativeTypeRefs);for(let f of c)await this.tryRelativeRef(f,l,o,r,s,i)}catch{}}async tryRelativeRef(e,n,r,s,i,o){try{let a=new URL(e,n),l=a.pathname+a.search,c=al(l)?[l]:Qt(l);for(let f of c){let u=new URL(f,a).toString();if(o.has(u))return;let p=await this.fetchDts(u);if(p?.dts){let m=this.toVirtualPath(r,new URL(p.url),s);this.pushFileIfNew(i,m,p.dts),await this.expandRelativeRefs(p.dts,p.url,s,i,o,r);return}}}catch{}}isDifferentPackage(e,n){return e===n?!1:new B(e).name!==new B(n).name}ambientlyDeclares(e,n){if(/^(?:import|export)\b/m.test(e))return!1;for(let r of e.matchAll(/declare\s+module\s+['"]([^'"]+)['"]/g)){let s=r[1];if(s===n||s.endsWith("/*")&&n.startsWith(s.slice(0,-1)))return!0}return!1}markFileAmbient(e,n){let r=e.find(s=>s.path===n);r&&(r.ambient=!0)}async prefetchBareDeps(e,n,r,s,i){try{let o=this.scanner.collectBareModuleRefs(e).slice(0,xt.maxBareDeps).filter(c=>this.isDifferentPackage(c,n));if(!o.length)return;let a=new Set([n]),l=xN(xt.prefetchConcurrency);await Promise.all(o.map(c=>l(()=>this.prefetchBareDepsRecursive(c,r,s,xt.maxBareDepth,a,i).catch(()=>{}))))}catch{}}async prefetchBareDepsRecursive(e,n,r,s,i,o){if(s<=0||i.has(e))return;i.add(e);let a=await this.fetchRootDts(e,o);if(!a?.dts)return;let l=a.resolvedPkg||e,c=this.virtualFs.pathForMain(l);this.pushFileIfNew(n,c,a.dts),this.ambientlyDeclares(a.dts,e)?this.markFileAmbient(n,c):r.push({module:e,path:c}),a.url&&await this.expandRelativeRefs(a.dts,a.url,l,n);let f=this.scanner.collectBareModuleRefs(a.dts).slice(0,xt.maxBareDeps).filter(d=>!i.has(d));for(let d of f)await this.prefetchBareDepsRecursive(d,n,r,s-1,i,o)}async resolve(e,n,r){let s=await this.packageService.extractImports(e),i=r?[...s,...r]:s;return(await Promise.all(i.map(a=>this.resolveOne(a,n)))).filter(a=>!!a)}async resolveOne(e,n){let{effectivePackage:r}=await this.versionResolver.effectivePackage(e,n);return this.withInFlight(r,async()=>{let s=new B(e),i=await this.fetchRootDts(e,n)??(s.subpath?await this.fetchRootDts(s.name,n):void 0);return i?this.buildDefFromContent(e,i,i.resolvedPkg||e,n):this.createStubDef(e)})}async buildDefFromContent(e,n,r,s){let{dts:i,url:o,resolvedPkg:a}=n,l=new B(a||r),c=l.version?`${l.name}@${l.version}`:l.name,{mainPath:f,packageRootUrl:d}=this.computeEntryPath(o,c),u=[{path:f,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,c,u,void 0,d);let m=u.map(O=>O.content).join(`
2537
- `);await this.prefetchBareDeps(m,c,u,p,s);let h=l.format(),g=e===h?[e]:[e,h],E=g.some(O=>this.ambientlyDeclares(i,O));return E?this.markFileAmbient(u,f):p.push(...g.map(O=>({module:O,path:f}))),{pkg:e,mainPath:f,files:u,shims:p,ambient:E}}};jd();yt();br();Ws();Dd();yr();import*as Ir from"path";var EN=Ir.join(ya,"pkg"),AN=Ir.join(ya,"files"),TN=Ir.join(ya,"negative.json"),hl=class{pkgMem=new Map;fileMem=new Map;negativeCache=new En(new wr(TN));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await te();let n=await bt(eS(e));return this.pkgMem.set(e,n),n}async setCachedDts(e,n,r){let s={content:n,url:r};this.pkgMem.set(e,s),await pl(async()=>{await te(),await De(eS(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await te();let n=await ga(tS(e));return this.fileMem.set(e,n),n}async setCachedFile(e,n){this.fileMem.set(e,n),await pl(async()=>{await te(),await De(tS(e),n)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await pl(async()=>{await te(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return pl(()=>this.negativeCache.clearNegative(e))}};async function pl(t){try{await t()}catch{}}function eS(t){return Ir.join(EN,Xe(t)+".json")}function tS(t){return Ir.join(AN,Xe(t)+".txt")}br();var ep;function ON(){return ep||(ep=new di({cache:new hl,cdnClient:Jb,packageService:Sa,versionResolver:qb})),ep}var nS="file:///node_modules/";async function rS(t){let e=ba(t.emitKey,"typecheck");await te(),await be.rm(e,{recursive:!0,force:!0}),await be.mkdir(e,{recursive:!0});let n=RN(t.jsxImportSource,t.dependencies),r=await ON().resolve(t.code,t.dependencies,n),s=t.local?.name,i=s?r.filter(f=>f.pkg!==s):r,o=new Set;for(let f of i)for(let d of f.files){let u=ml(d.path);if(!u||o.has(u))continue;o.add(u);let p=he.join(e,"node_modules",u);await be.mkdir(he.dirname(p),{recursive:!0}),await be.writeFile(p,d.content,"utf8")}let a={};for(let f of i)for(let d of f.shims){let u=ml(d.path);u&&(a[d.module]=[`./node_modules/${u}`])}for(let f of i){if(f.ambient)continue;let d=ml(f.mainPath);d&&(a[f.pkg]=[`./node_modules/${d}`])}let l=new Set;for(let f of i)for(let d of f.files){if(!d.ambient)continue;let u=ml(d.path);u&&l.add(`node_modules/${u}`)}if(t.local){delete a[t.local.name];let f=await IN(t.local,e);f?a[t.local.name]=[`./node_modules/${t.local.name}/${f}`]:console.warn(` local: '${t.local.name}' ships no type defs; check cannot type against it.`)}let c=PN(t.jsxImportSource,a,[...l]);return await be.writeFile(he.join(e,"tsconfig.json"),JSON.stringify(c,null,2)+`
2538
- `,"utf8"),await be.writeFile(he.join(e,"code.tsx"),t.code,"utf8"),await be.writeFile(he.join(e,"tb.d.ts"),Xf,"utf8"),{dir:e}}var tp={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function PN(t,e,n=[]){return{compilerOptions:{...tp,lib:CN([...Yf,...Vf]),jsx:"react-jsx",jsxImportSource:t??"react",paths:e},include:["code.tsx","tb.d.ts",...n]}}function CN(t){return Gf(t).map(e=>_N(e.name))}function _N(t){return t.split(".").map(e=>/^es\d+$/i.test(e)?e.toUpperCase():e==="dom"?"DOM":e==="esnext"?"ESNext":e.charAt(0).toUpperCase()+e.slice(1)).join(".")}function RN(t,e){let n=t??("react"in e?"react":void 0);return n?[`${n}/jsx-runtime`,`${n}/jsx-dev-runtime`]:[]}function ml(t){if(!t.startsWith(nS))return;let e=t.slice(nS.length),n=e.indexOf("/");if(!(n<0))return e.slice(n+1)}async function IN(t,e){if(!t.typesAbs)return;let n=he.dirname(t.typesAbs),r=he.join(e,"node_modules",t.name);for(let s of await NN(n)){let i=he.join(r,he.relative(n,s));await be.mkdir(he.dirname(i),{recursive:!0}),await be.copyFile(s,i)}return he.basename(t.typesAbs)}async function NN(t){let e=[];async function n(r){let s=await be.readdir(r,{withFileTypes:!0});for(let i of s){let o=he.join(r,i.name);i.isDirectory()?await n(o):/\.d\.ts(\.map)?$/.test(i.name)&&e.push(o)}}return await n(t),e}import*as Fe from"fs/promises";import*as Et from"path";import{existsSync as $N}from"fs";br();Ud();var LN="^22";async function sS(t){let e=ba(t.emitKey,"typecheck-server");await te(),await Fe.rm(e,{recursive:!0,force:!0}),await Fe.mkdir(e,{recursive:!0});let n=Et.join(t.bulbDir,".typebulb"),r=Pa(t.server).filter(o=>o!==t.local?.name);await Oa([`@types/node@${LN}`,...r],n,t.dependencies,{ignoreScripts:!0});let s=Et.join(n,"node_modules"),i=Et.join(e,"node_modules");return await DN(s,i),await Fe.writeFile(Et.join(e,"server.ts"),t.server,"utf8"),await Fe.writeFile(Et.join(e,"tb.d.ts"),Qf,"utf8"),await Fe.writeFile(Et.join(e,"tsconfig.json"),JSON.stringify(MN(t.local),null,2)+`
2539
- `,"utf8"),{dir:e}}function MN(t){let e={...tp,lib:["ES2023"],types:["node"]};if(t?.typesAbs){let n=i=>i.replace(/\\/g,"/"),r=n(Et.dirname(t.typesAbs)),s=n(t.typesAbs).replace(/\.d\.ts$/,"");e.paths={[t.name]:[s],[`${t.name}/*`]:[`${r}/*`]}}return{compilerOptions:e,include:["server.ts","tb.d.ts"]}}async function DN(t,e){if(!$N(t)){await Fe.mkdir(e,{recursive:!0});return}await Fe.rm(e,{recursive:!0,force:!0});let n=process.platform==="win32"?"junction":"dir";await Fe.symlink(t,e,n)}na();ee();async function oS(t,e){let{bulb:n,config:r,warnings:s,starts:i}=await Ze(t),o=Ue.basename(t),a=h=>i.get(h)??1;!n.code&&!n.server&&(console.error("Bulb has neither **code.tsx** nor **server.ts**; nothing to check."),process.exit(1));let l=!1,c=!1;for(let h of s)console.log(`structure ${h}`);s.length&&(l=!0);let f=xr(Ue.resolve(t)),d=f?Yn(n.name):"";f&&d&&d!==f.slug&&(console.log(`naming filename '${f.slug}.bulb.md' doesn't match the title '${n.name}' \u2014 its slug derives to '${d}'. Rename the file to '${d}.bulb.md', or change name: to suit the filename.`),c=!0),n.code&&(l=iS(Ps(n.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||l),n.server&&(l=iS(Ps(n.server,{target:"server",lineOffset:a("server.ts")}),"server")||l);let u=KN([process.cwd(),Ue.dirname(t)]);if(!u){let h=Ue.relative(process.cwd(),t)||t;console.error("check: TypeScript not found \u2014 install it once, then re-run:"),console.error(" npm i -g typescript"),console.error(` typebulb check ${h}`),process.exit(2)}let p=[];if(n.code){let{dir:h}=await rS({code:n.code,dependencies:r.dependencies??{},jsxImportSource:r.ts?.jsxImportSource,emitKey:t,local:e});p.push({role:"client",dir:h})}if(n.server){let{dir:h}=await sS({server:n.server,bulbDir:Ue.dirname(t),emitKey:t,local:e?{name:e.name,typesAbs:e.typesAbs}:void 0,dependencies:r.dependencies});p.push({role:"server",dir:h})}for(let{role:h,dir:g}of p){let{stdout:E,exitCode:O}=await JN(u,g);for(let C of E.split(/\r?\n/))C.trim()&&console.log(`${h} ${qN(C,o,a)}`);O!==0&&(l=!0)}l&&process.exit(1);let m=[n.code&&"code.tsx",n.server&&"server.ts"].filter(Boolean).join(", ");console.error(c?`\u2713 type-checks (${m}) \u2014 see the naming warning above`:`\u2713 no issues (${m})`)}function iS(t,e){for(let n of t)for(let r of n.message.split(`
2540
- `))console.log(`${e} ${r}`);return t.length>0}function qN(t,e,n){return t.replace(/\b(code\.tsx|server\.ts)\((\d+),(\d+)\)/g,(r,s,i,o)=>`${e}(${Number(i)+n(s)-1},${o})`)}function JN(t,e){return new Promise(n=>{let r=BN(process.execPath,[t,"--noEmit"],{cwd:e}),s="";r.stdout?.on("data",i=>{s+=i.toString()}),r.stderr?.on("data",i=>{s+=i.toString()}),r.on("close",i=>n({stdout:s,exitCode:i??1}))})}var WN=FN(import.meta.url);function KN(t){let e=r=>{try{let s=WN.resolve("typescript/package.json",{paths:r}),i=Ue.join(Ue.dirname(s),"lib","tsc.js");return UN(i)?i:void 0}catch{return}},n=e(t);if(n)return n;try{let r=jN("npm root -g",{encoding:"utf8"}).trim();return e([r])}catch{return}}St();ta();_s();async function aS(t,e){let{bulb:n}=await Ze(t),r=or(n);if(yn(t)){console.log("remembered-trusted \u2014 runs with filesystem / AI / server.ts automatically (`typebulb untrust` to revoke)."),r&&console.log(` (it uses ${r})`);return}r?(console.log(`This bulb appears to use ${r}; it runs Restricted unless you grant trust:`),console.log(` ${e}`)):console.log("No privileged capability detected \u2014 runs Restricted by default. (A clean scan is a hint, not a guarantee.)")}_s();import*as fi from"path";async function lS(t,e){if(!t){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=ld();if(!r.length){console.log("No bulbs are remembered as trusted.");return}console.log("Trusted bulbs (run with fs/AI/server.ts without --trust):");for(let s of r)console.log(` ${s}`);return}let n=fi.resolve(t);n.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));try{ar(n,e)}catch(r){console.error(r.message),process.exit(1)}console.log(e?`Trusted ${fi.basename(n)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${fi.basename(n)} \u2014 runs Restricted.`),console.log(` ${n}`)}Le();import*as dS from"readline";Td();function np(t){let e=n=>r=>t?`\x1B[${n}m${r}\x1B[0m`:r;return{lit:e("38;5;70"),litLink:e("4;38;5;70"),brand:e("38;5;135")}}var HN=5e3,gl=()=>Math.round(performance.now()),cS=t=>t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`;async function fS(t){let e=jv(process.cwd()),n=gl();if("ambiguous"in e){let r=await zN(t,e.ambiguous);return r?uS(t,r,{boot:n,from:gl()}):YN(t,e.ambiguous)}return uS(t,e.name,{boot:n,from:gl()})}async function uS(t,e,n){let r,s;try{r=await Zu(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=gl()-n.from,{lit:o,litLink:a,brand:l}=np(process.stdout.isTTY===!0),c=[" Read the authoring skill before writing a bulb:",` \u2022 ${o($s())}`],f=r?[` Agent mirror (${e}) is live\u{1F4A1}`,` ${o("\u25CF")} ${a(r.url)}`," Inline bulbs render live here."," Agents:",` Reusable app/tool \u2192 write a ${o(".bulb.md")}`," Show something inline \u2192 emit an inline bulb"," emit it with no .bulb.md draft first",...e==="codex"?[" verify it this turn \u2014 foreground-wait, bounded:",` \u2022 ${o('typebulb wait agent --match "[inline <name>" --timeout 120')}`," raise the shell tool's timeout_ms to 130000"," (its 10s default kills even a clean ok)"]:[e==="pi"?" arm a wait for its render verdict \u2014 run it plainly:":" background a wait for its render verdict:",` \u2022 ${o('typebulb wait agent --match "[inline <name>"')}`],...c," End this reply with the mirror link above"," \u2022 easy to miss the link mid-message"]:[` The mirror did not start (${s})`,` \u25CF Start it manually: ${o(`npx typebulb agent:${e}`)}`," Agents:",...c],d=n.boot+i>HN?[` slow launch: boot ${cS(n.boot)} \xB7 mirror ${cS(i)}`]:[],u=[` ${l(`typebulb v${t}`)}`,...d,...f,""];process.stdout.write(u.join(`
2536
+ `),r=new Set;for(let s of n.matchAll(/(import|export)\s+[^'"\n]*from\s*['"]([^'"\n]+)['"]/g))r.add(s[2]);for(let s of n.matchAll(/export\s*\*\s*from\s*['"]([^'"\n]+)['"]/g))r.add(s[1]);return Array.from(r)}isBare(e){return!(e.startsWith("./")||e.startsWith("../")||e.startsWith("file:")||e.startsWith("http://")||e.startsWith("https://"))}};yt();var eS="file:///node_modules",fl=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${eS}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,n){let r=kn(n);return`${eS}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as xN}from"lru-cache";function tS(t){let e=new xN({ttl:xt.negativeTtlMs,max:500}),n=new Map;return async function(s){try{if(await t.isNegative(s)||e.has(s))return;let i=await t.getCachedFile(s);if(i)return{dts:i,url:s};let o=n.get(s);if(o)return o;let a=(async()=>{let l=await Ir(s,{init:{cache:"no-store"}});if(!l?.ok){l?.status===404&&(e.set(s,!0),await t.recordNegative(s));return}let c=await l.text(),f=l.url||s;return await t.clearNegative(s),await t.setCachedFile(f,c),{dts:c,url:f}})();return n.set(s,a),await a.finally(()=>n.delete(s))}catch{return}}}var di=class{constructor(e){this.inFlight=new Map,this.scanner=new dl,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=tS(e.cache),this.typescriptProvider=new ll(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new ul(e.cdnClient,e.cache),this.virtualFs=new fl}withInFlight(e,n){let r=this.inFlight.get(e);if(r)return r;let s=n().finally(()=>this.inFlight.delete(e));return this.inFlight.set(e,s),s}invalidate(){this.virtualFs.bumpEpoch(),this.inFlight.clear()}pushFileIfNew(e,n,r){e.some(s=>s.path===n)||e.push({path:n,content:r})}createStubDef(e){let n=this.virtualFs.pathForMain(e);return{pkg:e,mainPath:n,files:[{path:n,content:"export const _shim: any; export default _shim;"}],shims:[{module:e,path:n}]}}async fetchViaProviders(e){for(let n of[this.typescriptProvider,this.definitelyTypedProvider])try{let r=await n.resolve(e);if(r?.dts)return r}catch{}}async fetchRootDts(e,n){let{effectivePackage:r,root:s,pinned:i}=await this.versionResolver.effectivePackage(e,n),o=await this.cache.getCachedDts(r);if(o?.content){let l=o.url??this.cdnClient.file(i?`${s}@${i}`:s,"index.d.ts");return{dts:o.content,url:l,resolvedPkg:r}}let a;try{a=await this.fetchViaProviders(r)}catch{return}if(!(!a?.dts||!a.url)&&new B(r).subpath===new B(a.resolvedPkg||r).subpath){try{await this.cache.setCachedDts(r,a.dts,a.url)}catch{}return a}}extractPackageRootUrl(e){let n=e.pathname.match(/^(.+@[^/]+\/)/);return n?new URL(n[1],e.origin):new URL("./",e)}toVirtualPath(e,n,r){let s=n.pathname.startsWith(e.pathname)?n.pathname.slice(e.pathname.length):`__deps__/${encodeURIComponent(n.toString()).replace(/%/g,"_")}.d.ts`;return this.virtualFs.pathFor(r,s)}computeEntryPath(e,n){if(!e)return{mainPath:this.virtualFs.pathForMain(n),packageRootUrl:void 0};let r=new URL(e),s=this.extractPackageRootUrl(r);return{mainPath:this.toVirtualPath(s,r,n),packageRootUrl:s}}async expandRelativeRefs(e,n,r,s,i=new Set,o){if(!i.has(n)&&(i.add(n),!(i.size>xt.maxRelativeTypeRefs)))try{let a=new URL(n),l=new URL("./",a);o??(o=this.extractPackageRootUrl(a));let c=this.scanner.collectRelativeTypeRefs(e).slice(0,xt.maxRelativeTypeRefs);for(let f of c)await this.tryRelativeRef(f,l,o,r,s,i)}catch{}}async tryRelativeRef(e,n,r,s,i,o){try{let a=new URL(e,n),l=a.pathname+a.search,c=al(l)?[l]:Qt(l);for(let f of c){let u=new URL(f,a).toString();if(o.has(u))return;let p=await this.fetchDts(u);if(p?.dts){let m=this.toVirtualPath(r,new URL(p.url),s);this.pushFileIfNew(i,m,p.dts),await this.expandRelativeRefs(p.dts,p.url,s,i,o,r);return}}}catch{}}isDifferentPackage(e,n){return e===n?!1:new B(e).name!==new B(n).name}ambientlyDeclares(e,n){if(/^(?:import|export)\b/m.test(e))return!1;for(let r of e.matchAll(/declare\s+module\s+['"]([^'"]+)['"]/g)){let s=r[1];if(s===n||s.endsWith("/*")&&n.startsWith(s.slice(0,-1)))return!0}return!1}markFileAmbient(e,n){let r=e.find(s=>s.path===n);r&&(r.ambient=!0)}async prefetchBareDeps(e,n,r,s,i){try{let o=this.scanner.collectBareModuleRefs(e).slice(0,xt.maxBareDeps).filter(c=>this.isDifferentPackage(c,n));if(!o.length)return;let a=new Set([n]),l=EN(xt.prefetchConcurrency);await Promise.all(o.map(c=>l(()=>this.prefetchBareDepsRecursive(c,r,s,xt.maxBareDepth,a,i).catch(()=>{}))))}catch{}}async prefetchBareDepsRecursive(e,n,r,s,i,o){if(s<=0||i.has(e))return;i.add(e);let a=await this.fetchRootDts(e,o);if(!a?.dts)return;let l=a.resolvedPkg||e,c=this.virtualFs.pathForMain(l);this.pushFileIfNew(n,c,a.dts),this.ambientlyDeclares(a.dts,e)?this.markFileAmbient(n,c):r.push({module:e,path:c}),a.url&&await this.expandRelativeRefs(a.dts,a.url,l,n);let f=this.scanner.collectBareModuleRefs(a.dts).slice(0,xt.maxBareDeps).filter(d=>!i.has(d));for(let d of f)await this.prefetchBareDepsRecursive(d,n,r,s-1,i,o)}async resolve(e,n,r){let s=await this.packageService.extractImports(e),i=r?[...s,...r]:s;return(await Promise.all(i.map(a=>this.resolveOne(a,n)))).filter(a=>!!a)}async resolveOne(e,n){let{effectivePackage:r}=await this.versionResolver.effectivePackage(e,n);return this.withInFlight(r,async()=>{let s=new B(e),i=await this.fetchRootDts(e,n)??(s.subpath?await this.fetchRootDts(s.name,n):void 0);return i?this.buildDefFromContent(e,i,i.resolvedPkg||e,n):this.createStubDef(e)})}async buildDefFromContent(e,n,r,s){let{dts:i,url:o,resolvedPkg:a}=n,l=new B(a||r),c=l.version?`${l.name}@${l.version}`:l.name,{mainPath:f,packageRootUrl:d}=this.computeEntryPath(o,c),u=[{path:f,content:i}],p=[];o&&await this.expandRelativeRefs(i,o,c,u,void 0,d);let m=u.map(O=>O.content).join(`
2537
+ `);await this.prefetchBareDeps(m,c,u,p,s);let h=l.format(),g=e===h?[e]:[e,h],x=g.some(O=>this.ambientlyDeclares(i,O));return x?this.markFileAmbient(u,f):p.push(...g.map(O=>({module:O,path:f}))),{pkg:e,mainPath:f,files:u,shims:p,ambient:x}}};jd();yt();wr();Ws();Dd();br();import*as Nr from"path";var AN=Nr.join(ya,"pkg"),TN=Nr.join(ya,"files"),ON=Nr.join(ya,"negative.json"),hl=class{pkgMem=new Map;fileMem=new Map;negativeCache=new En(new vr(ON));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await ee();let n=await bt(nS(e));return this.pkgMem.set(e,n),n}async setCachedDts(e,n,r){let s={content:n,url:r};this.pkgMem.set(e,s),await pl(async()=>{await ee(),await De(nS(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await ee();let n=await ga(rS(e));return this.fileMem.set(e,n),n}async setCachedFile(e,n){this.fileMem.set(e,n),await pl(async()=>{await ee(),await De(rS(e),n)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await pl(async()=>{await ee(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return pl(()=>this.negativeCache.clearNegative(e))}};async function pl(t){try{await t()}catch{}}function nS(t){return Nr.join(AN,Xe(t)+".json")}function rS(t){return Nr.join(TN,Xe(t)+".txt")}wr();var ep;function PN(){return ep||(ep=new di({cache:new hl,cdnClient:Kb,packageService:Sa,versionResolver:Wb})),ep}var sS="file:///node_modules/";async function iS(t){let e=ba(t.emitKey,"typecheck");await ee(),await be.rm(e,{recursive:!0,force:!0}),await be.mkdir(e,{recursive:!0});let n=IN(t.jsxImportSource,t.dependencies),r=await PN().resolve(t.code,t.dependencies,n),s=t.local?.name,i=s?r.filter(f=>f.pkg!==s):r,o=new Set;for(let f of i)for(let d of f.files){let u=ml(d.path);if(!u||o.has(u))continue;o.add(u);let p=me.join(e,"node_modules",u);await be.mkdir(me.dirname(p),{recursive:!0}),await be.writeFile(p,d.content,"utf8")}let a={};for(let f of i)for(let d of f.shims){let u=ml(d.path);u&&(a[d.module]=[`./node_modules/${u}`])}for(let f of i){if(f.ambient)continue;let d=ml(f.mainPath);d&&(a[f.pkg]=[`./node_modules/${d}`])}let l=new Set;for(let f of i)for(let d of f.files){if(!d.ambient)continue;let u=ml(d.path);u&&l.add(`node_modules/${u}`)}if(t.local){delete a[t.local.name];let f=await NN(t.local,e);f?a[t.local.name]=[`./node_modules/${t.local.name}/${f}`]:console.warn(` local: '${t.local.name}' ships no type defs; check cannot type against it.`)}let c=CN(t.jsxImportSource,a,[...l]);return await be.writeFile(me.join(e,"tsconfig.json"),JSON.stringify(c,null,2)+`
2538
+ `,"utf8"),await be.writeFile(me.join(e,"code.tsx"),t.code,"utf8"),await be.writeFile(me.join(e,"tb.d.ts"),Xf,"utf8"),{dir:e}}var tp={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function CN(t,e,n=[]){return{compilerOptions:{...tp,lib:_N([...Yf,...Vf]),jsx:"react-jsx",jsxImportSource:t??"react",paths:e},include:["code.tsx","tb.d.ts",...n]}}function _N(t){return Gf(t).map(e=>RN(e.name))}function RN(t){return t.split(".").map(e=>/^es\d+$/i.test(e)?e.toUpperCase():e==="dom"?"DOM":e==="esnext"?"ESNext":e.charAt(0).toUpperCase()+e.slice(1)).join(".")}function IN(t,e){let n=t??("react"in e?"react":void 0);return n?[`${n}/jsx-runtime`,`${n}/jsx-dev-runtime`]:[]}function ml(t){if(!t.startsWith(sS))return;let e=t.slice(sS.length),n=e.indexOf("/");if(!(n<0))return e.slice(n+1)}async function NN(t,e){if(!t.typesAbs)return;let n=me.dirname(t.typesAbs),r=me.join(e,"node_modules",t.name);for(let s of await $N(n)){let i=me.join(r,me.relative(n,s));await be.mkdir(me.dirname(i),{recursive:!0}),await be.copyFile(s,i)}return me.basename(t.typesAbs)}async function $N(t){let e=[];async function n(r){let s=await be.readdir(r,{withFileTypes:!0});for(let i of s){let o=me.join(r,i.name);i.isDirectory()?await n(o):/\.d\.ts(\.map)?$/.test(i.name)&&e.push(o)}}return await n(t),e}import*as Fe from"fs/promises";import*as Et from"path";import{existsSync as LN}from"fs";wr();Ud();var MN="^22";async function oS(t){let e=ba(t.emitKey,"typecheck-server");await ee(),await Fe.rm(e,{recursive:!0,force:!0}),await Fe.mkdir(e,{recursive:!0});let n=Et.join(t.bulbDir,".typebulb"),r=Pa(t.server).filter(o=>o!==t.local?.name);await Oa([`@types/node@${MN}`,...r],n,t.dependencies,{ignoreScripts:!0});let s=Et.join(n,"node_modules"),i=Et.join(e,"node_modules");return await BN(s,i),await Fe.writeFile(Et.join(e,"server.ts"),t.server,"utf8"),await Fe.writeFile(Et.join(e,"tb.d.ts"),Qf,"utf8"),await Fe.writeFile(Et.join(e,"tsconfig.json"),JSON.stringify(DN(t.local),null,2)+`
2539
+ `,"utf8"),{dir:e}}function DN(t){let e={...tp,lib:["ES2023"],types:["node"]};if(t?.typesAbs){let n=i=>i.replace(/\\/g,"/"),r=n(Et.dirname(t.typesAbs)),s=n(t.typesAbs).replace(/\.d\.ts$/,"");e.paths={[t.name]:[s],[`${t.name}/*`]:[`${r}/*`]}}return{compilerOptions:e,include:["server.ts","tb.d.ts"]}}async function BN(t,e){if(!LN(t)){await Fe.mkdir(e,{recursive:!0});return}await Fe.rm(e,{recursive:!0,force:!0});let n=process.platform==="win32"?"junction":"dir";await Fe.symlink(t,e,n)}na();Q();async function lS(t,e){let{bulb:n,config:r,warnings:s,starts:i}=await Ze(t),o=Ue.basename(t),a=h=>i.get(h)??1;!n.code&&!n.server&&(console.error("Bulb has neither **code.tsx** nor **server.ts**; nothing to check."),process.exit(1));let l=!1,c=!1;for(let h of s)console.log(`structure ${h}`);s.length&&(l=!0);let f=Er(Ue.resolve(t)),d=f?Yn(n.name):"";f&&d&&d!==f.slug&&(console.log(`naming filename '${f.slug}.bulb.md' doesn't match the title '${n.name}' \u2014 its slug derives to '${d}'. Rename the file to '${d}.bulb.md', or change name: to suit the filename.`),c=!0),n.code&&(l=aS(Ps(n.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||l),n.server&&(l=aS(Ps(n.server,{target:"server",lineOffset:a("server.ts")}),"server")||l);let u=HN([process.cwd(),Ue.dirname(t)]);if(!u){let h=Ue.relative(process.cwd(),t)||t;console.error("check: TypeScript not found \u2014 install it once, then re-run:"),console.error(" npm i -g typescript"),console.error(` typebulb check ${h}`),process.exit(2)}let p=[];if(n.code){let{dir:h}=await iS({code:n.code,dependencies:r.dependencies??{},jsxImportSource:r.ts?.jsxImportSource,emitKey:t,local:e});p.push({role:"client",dir:h})}if(n.server){let{dir:h}=await oS({server:n.server,bulbDir:Ue.dirname(t),emitKey:t,local:e?{name:e.name,typesAbs:e.typesAbs}:void 0,dependencies:r.dependencies});p.push({role:"server",dir:h})}for(let{role:h,dir:g}of p){let{stdout:x,exitCode:O}=await WN(u,g);for(let C of x.split(/\r?\n/))C.trim()&&console.log(`${h} ${JN(C,o,a)}`);O!==0&&(l=!0)}l&&process.exit(1);let m=[n.code&&"code.tsx",n.server&&"server.ts"].filter(Boolean).join(", ");console.error(c?`\u2713 type-checks (${m}) \u2014 see the naming warning above`:`\u2713 no issues (${m})`)}function aS(t,e){for(let n of t)for(let r of n.message.split(`
2540
+ `))console.log(`${e} ${r}`);return t.length>0}function JN(t,e,n){return t.replace(/\b(code\.tsx|server\.ts)\((\d+),(\d+)\)/g,(r,s,i,o)=>`${e}(${Number(i)+n(s)-1},${o})`)}function WN(t,e){return new Promise(n=>{let r=jN(process.execPath,[t,"--noEmit"],{cwd:e}),s="";r.stdout?.on("data",i=>{s+=i.toString()}),r.stderr?.on("data",i=>{s+=i.toString()}),r.on("close",i=>n({stdout:s,exitCode:i??1}))})}var KN=UN(import.meta.url);function HN(t){let e=r=>{try{let s=KN.resolve("typescript/package.json",{paths:r}),i=Ue.join(Ue.dirname(s),"lib","tsc.js");return qN(i)?i:void 0}catch{return}},n=e(t);if(n)return n;try{let r=FN("npm root -g",{encoding:"utf8"}).trim();return e([r])}catch{return}}St();ta();_s();async function cS(t,e){let{bulb:n}=await Ze(t),r=ar(n);if(yn(t)){console.log("remembered-trusted \u2014 runs with filesystem / AI / server.ts automatically (`typebulb untrust` to revoke)."),r&&console.log(` (it uses ${r})`);return}r?(console.log(`This bulb appears to use ${r}; it runs Restricted unless you grant trust:`),console.log(` ${e}`)):console.log("No privileged capability detected \u2014 runs Restricted by default. (A clean scan is a hint, not a guarantee.)")}_s();import*as fi from"path";async function uS(t,e){if(!t){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=ld();if(!r.length){console.log("No bulbs are remembered as trusted.");return}console.log("Trusted bulbs (run with fs/AI/server.ts without --trust):");for(let s of r)console.log(` ${s}`);return}let n=fi.resolve(t);n.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));try{lr(n,e)}catch(r){console.error(r.message),process.exit(1)}console.log(e?`Trusted ${fi.basename(n)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${fi.basename(n)} \u2014 runs Restricted.`),console.log(` ${n}`)}Le();import*as pS from"readline";Td();function np(t){let e=n=>r=>t?`\x1B[${n}m${r}\x1B[0m`:r;return{lit:e("38;5;70"),litLink:e("4;38;5;70"),brand:e("38;5;135")}}var zN=5e3,gl=()=>Math.round(performance.now()),dS=t=>t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`;async function hS(t){let e=Uv(process.cwd()),n=gl();if("ambiguous"in e){let r=await YN(t,e.ambiguous);return r?fS(t,r,{boot:n,from:gl()}):VN(t,e.ambiguous)}return fS(t,e.name,{boot:n,from:gl()})}async function fS(t,e,n){let r,s;try{r=await Zu(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=gl()-n.from,{lit:o,litLink:a,brand:l}=np(process.stdout.isTTY===!0),c=[" Read the authoring skill before writing a bulb:",` \u2022 ${o($s())}`],f=r?[` Agent mirror (${e}) is live\u{1F4A1}`,` ${o("\u25CF")} ${a(r.url)}`," Inline bulbs render live here."," Agents:",` Reusable app/tool \u2192 write a ${o(".bulb.md")}`," Show something inline \u2192 emit an inline bulb"," emit it with no .bulb.md draft first",...e==="codex"?[" verify it this turn \u2014 foreground-wait, bounded:",` \u2022 ${o('typebulb wait agent --match "[inline <name>" --timeout 120')}`," raise the shell tool's timeout_ms to 130000"," (its 10s default kills even a clean ok)"]:[e==="pi"?" arm a wait for its render verdict \u2014 run it plainly:":" background a wait for its render verdict:",` \u2022 ${o('typebulb wait agent --match "[inline <name>"')}`],...c," End this reply with the mirror link above"," \u2022 easy to miss the link mid-message"]:[` The mirror did not start (${s})`,` \u25CF Start it manually: ${o(`npx typebulb agent:${e}`)}`," Agents:",...c],d=n.boot+i>zN?[` slow launch: boot ${dS(n.boot)} \xB7 mirror ${dS(i)}`]:[],u=[` ${l(`typebulb v${t}`)}`,...d,...f,""];process.stdout.write(u.join(`
2541
2541
  `)+`
2542
- `)}async function zN(t,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:n,brand:r}=np(!0),s=[` ${r(`typebulb v${t}`)}`," More than one agent harness is available here.",...e.map((o,a)=>` ${n(String(a+1))}) ${o}`),""];process.stdout.write(s.join(`
2542
+ `)}async function YN(t,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:n,brand:r}=np(!0),s=[` ${r(`typebulb v${t}`)}`," More than one agent harness is available here.",...e.map((o,a)=>` ${n(String(a+1))}) ${o}`),""];process.stdout.write(s.join(`
2543
2543
  `)+`
2544
- `);let i=dS.createInterface({input:process.stdin,output:process.stdout});try{let o=(await new Promise(l=>i.question(" Open which? [1]: ",l))).trim();if(o==="")return e[0];let a=Number(o);return Number.isInteger(a)&&a>=1&&a<=e.length?e[a-1]:e.find(l=>l===o.toLowerCase())}finally{i.close()}}function YN(t,e){let{lit:n,brand:r}=np(process.stdout.isTTY===!0),s=[` ${r(`typebulb v${t}`)}`," More than one agent harness is available here."," Open the mirror for the one you want:",...e.map(i=>` \u2022 ${n(`npx typebulb agent:${i}`)}`),""];process.stdout.write(s.join(`
2544
+ `);let i=pS.createInterface({input:process.stdin,output:process.stdout});try{let o=(await new Promise(l=>i.question(" Open which? [1]: ",l))).trim();if(o==="")return e[0];let a=Number(o);return Number.isInteger(a)&&a>=1&&a<=e.length?e[a-1]:e.find(l=>l===o.toLowerCase())}finally{i.close()}}function VN(t,e){let{lit:n,brand:r}=np(process.stdout.isTTY===!0),s=[` ${r(`typebulb v${t}`)}`," More than one agent harness is available here."," Open the mirror for the one you want:",...e.map(i=>` \u2022 ${n(`npx typebulb agent:${i}`)}`),""];process.stdout.write(s.join(`
2545
2545
  `)+`
2546
- `)}ot();bn();async function pS(t){xe(t);let e=await mt();if(e.length>0){console.log(lb(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!ud()){console.log("No AI provider keys found in this directory's .env, and no local Ollama server detected."),console.log("Set one of these to use a cloud model with tb.ai:");for(let[n,r]of Object.entries(lr))console.log(` ${r.padEnd(20)} (${n})`);console.log("\u2026or start Ollama (http://localhost:11434, or set OLLAMA_HOST) for local models. Then re-run `typebulb models`.");return}console.log("Couldn't fetch the model catalog (offline?). tb.ai still works with any valid provider/model id for your keys.")}ee();function hS(t){t?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=Yn(t);e||(console.error(`'${t}' has no slug \u2014 a bulb name needs at least one letter or digit.`),process.exit(1)),console.log(e)}Ye();import*as yS from"path";import{valid as gS,lt as GN}from"semver";Le();var tt={connected:"[page] connected",disconnected:"[page] disconnected",closed:t=>`[page] closed: ${t}`},rp=3e3,mS=1e4,VN=2500,yl=class{attached=new Set;leaving=new Set;arrivalWaiters=new Set;goneWaiters=new Set;arrivalSubs=[];settledEmpty;dropAt=0;get count(){return this.attached.size}get lastDropAt(){return this.dropAt}[Symbol.iterator](){return this.attached[Symbol.iterator]()}add(e,n){this.attached.add(e);for(let s of[...this.arrivalWaiters])s(!0);let r={page:e,firstAttach:n,count:this.attached.size};for(let s of this.arrivalSubs)s(r)}closing(e){this.attached.delete(e)&&this.leaving.add(e)}dropped(e){if(this.leaving.delete(e)){this.drainIfGone();return}if(!this.attached.delete(e))return;let n=this.dropAt=Date.now();setTimeout(()=>{this.attached.size===0&&this.dropAt===n&&this.settledEmpty?.()},rp).unref()}async closeAll(e){let n=[...this.attached];if(!n.length)return{told:0,gone:0};await Promise.all(n.map(s=>s.close(e).catch(()=>{}))),await this.whenGone(n,VN);let r=n.filter(s=>!this.leaving.has(s)).length;for(let s of n)this.leaving.delete(s);return{told:n.length,gone:r}}whenArrives(e){return this.attached.size>0?Promise.resolve(!0):e>0?new Promise(n=>{let r=i=>{clearTimeout(s),this.arrivalWaiters.delete(r),n(i)},s=setTimeout(()=>r(!1),e);s.unref(),this.arrivalWaiters.add(r)}):Promise.resolve(!1)}onArrival(e){this.arrivalSubs.push(e)}onSettledEmpty(e){this.settledEmpty=e}whenGone(e,n){return e.some(r=>this.leaving.has(r))?new Promise(r=>{let s=()=>{e.some(o=>this.leaving.has(o))||(clearTimeout(i),this.goneWaiters.delete(s),r())},i=setTimeout(()=>{this.goneWaiters.delete(s),r()},n);i.unref(),this.goneWaiters.add(s)}):Promise.resolve()}drainIfGone(){for(let e of[...this.goneWaiters])e()}};zo();function XN(t,e,n,r){if(/^\d+$/.test(e))return t.find(i=>i.pid===parseInt(e,10));let s=e==="agent"?t.filter(ye):t.filter(i=>i.agent===e);if(s.length){if(!n)return s[0];let i=s.filter(o=>rr(o,n));return r&&i.find(o=>o.agent===r)||i[0]}return t.find(i=>re(i.file)===re(e))}var Nr=t=>t.agent??yS.basename(t.file);function bS(t){return t===Me?!1:t&&gS(t)&&gS(Me)?GN(t,Me):!0}function QN(t){return t===Me?"":t?bS(t)?` STALE runtime v${t} (this CLI is v${Me} \u2014 relaunch to update)`:` runtime v${t} (newer than this CLI's v${Me})`:" STALE runtime (predates the version stamp \u2014 relaunch to update)"}function ZN(t,e){return e===void 0?" pages ?":e>0?` ${e} page${e===1?"":"s"}`:ye(t)?" NO PAGE (no tab open on it)":" NO PAGE (nothing of it is running)"}function wS(t,e,n){t.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${n?ZN(r,n[s]):""}${QN(r.version)} ${r.file}`))}async function sp(t,e){if(!t.length){console.log("No running bulb servers.");return}let n=await Promise.all(t.map(Qu));console.log("Running bulb servers:"),wS(t,r=>console.log(r),n),console.log(`
2547
- `+e)}function ip(t,e,n,r,s){let i=XN(t,e,r,s);if(i)return i;console.error(`No running server for '${e}'.`),t.length?(console.error(`Running servers (try \`typebulb ${n} <file|pid>\`):`),wS(t,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function vS(t,e){if(!t){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await sp(await Z(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let n=ip(await Z(),t,"logs",process.cwd(),kt());if(e.clear){Ku(n.pid),console.log(`Cleared log for ${Nr(n)} (pid ${n.pid}).`);return}let r=Ve(n.pid),s=r.text;if(e.run!==void 0?(s=zu(s,e.run),s||console.error(e.run==="latest"?"No output in the latest run yet (the server has logged nothing since its last reload).":`No output for run ${e.run} (it hasn't started, or was trimmed from the log).`)):!s&&!e.follow&&console.error("Log is empty \u2014 this server has logged nothing yet."),e.lines&&e.lines>0){let i=s.split(`
2546
+ `)}ot();bn();async function mS(t){xe(t);let e=await mt();if(e.length>0){console.log(ub(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!ud()){console.log("No AI provider keys found in this directory's .env, and no local Ollama server detected."),console.log("Set one of these to use a cloud model with tb.ai:");for(let[n,r]of Object.entries(cr))console.log(` ${r.padEnd(20)} (${n})`);console.log("\u2026or start Ollama (http://localhost:11434, or set OLLAMA_HOST) for local models. Then re-run `typebulb models`.");return}console.log("Couldn't fetch the model catalog (offline?). tb.ai still works with any valid provider/model id for your keys.")}Q();function gS(t){t?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=Yn(t);e||(console.error(`'${t}' has no slug \u2014 a bulb name needs at least one letter or digit.`),process.exit(1)),console.log(e)}Ye();import*as wS from"path";import{valid as bS,lt as XN}from"semver";Le();var tt={connected:"[page] connected",disconnected:"[page] disconnected",closed:t=>`[page] closed: ${t}`},rp=3e3,yS=1e4,GN=2500,yl=class{attached=new Set;leaving=new Set;arrivalWaiters=new Set;goneWaiters=new Set;arrivalSubs=[];settledEmpty;dropAt=0;get count(){return this.attached.size}get lastDropAt(){return this.dropAt}[Symbol.iterator](){return this.attached[Symbol.iterator]()}add(e,n){this.attached.add(e);for(let s of[...this.arrivalWaiters])s(!0);let r={page:e,firstAttach:n,count:this.attached.size};for(let s of this.arrivalSubs)s(r)}closing(e){this.attached.delete(e)&&this.leaving.add(e)}dropped(e){if(this.leaving.delete(e)){this.drainIfGone();return}if(!this.attached.delete(e))return;let n=this.dropAt=Date.now();setTimeout(()=>{this.attached.size===0&&this.dropAt===n&&this.settledEmpty?.()},rp).unref()}async closeAll(e){let n=[...this.attached];if(!n.length)return{told:0,gone:0};await Promise.all(n.map(s=>s.close(e).catch(()=>{}))),await this.whenGone(n,GN);let r=n.filter(s=>!this.leaving.has(s)).length;for(let s of n)this.leaving.delete(s);return{told:n.length,gone:r}}whenArrives(e){return this.attached.size>0?Promise.resolve(!0):e>0?new Promise(n=>{let r=i=>{clearTimeout(s),this.arrivalWaiters.delete(r),n(i)},s=setTimeout(()=>r(!1),e);s.unref(),this.arrivalWaiters.add(r)}):Promise.resolve(!1)}onArrival(e){this.arrivalSubs.push(e)}onSettledEmpty(e){this.settledEmpty=e}whenGone(e,n){return e.some(r=>this.leaving.has(r))?new Promise(r=>{let s=()=>{e.some(o=>this.leaving.has(o))||(clearTimeout(i),this.goneWaiters.delete(s),r())},i=setTimeout(()=>{this.goneWaiters.delete(s),r()},n);i.unref(),this.goneWaiters.add(s)}):Promise.resolve()}drainIfGone(){for(let e of[...this.goneWaiters])e()}};zo();function QN(t,e,n,r){if(/^\d+$/.test(e))return t.find(i=>i.pid===parseInt(e,10));let s=e==="agent"?t.filter(ye):t.filter(i=>i.agent===e);if(s.length){if(!n)return s[0];let i=s.filter(o=>sr(o,n));return r&&i.find(o=>o.agent===r)||i[0]}return t.find(i=>se(i.file)===se(e))}var $r=t=>t.agent??wS.basename(t.file);function vS(t){return t===Me?!1:t&&bS(t)&&bS(Me)?XN(t,Me):!0}function ZN(t){return t===Me?"":t?vS(t)?` STALE runtime v${t} (this CLI is v${Me} \u2014 relaunch to update)`:` runtime v${t} (newer than this CLI's v${Me})`:" STALE runtime (predates the version stamp \u2014 relaunch to update)"}function e1(t,e){return e===void 0?" pages ?":e>0?` ${e} page${e===1?"":"s"}`:ye(t)?" NO PAGE (no tab open on it)":" NO PAGE (nothing of it is running)"}function SS(t,e,n){t.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${n?e1(r,n[s]):""}${ZN(r.version)} ${r.file}`))}async function sp(t,e){if(!t.length){console.log("No running bulb servers.");return}let n=await Promise.all(t.map(Qu));console.log("Running bulb servers:"),SS(t,r=>console.log(r),n),console.log(`
2547
+ `+e)}function ip(t,e,n,r,s){let i=QN(t,e,r,s);if(i)return i;console.error(`No running server for '${e}'.`),t.length?(console.error(`Running servers (try \`typebulb ${n} <file|pid>\`):`),SS(t,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function kS(t,e){if(!t){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await sp(await X(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let n=ip(await X(),t,"logs",process.cwd(),kt());if(e.clear){Ku(n.pid),console.log(`Cleared log for ${$r(n)} (pid ${n.pid}).`);return}let r=Ve(n.pid),s=r.text;if(e.run!==void 0?(s=zu(s,e.run),s||console.error(e.run==="latest"?"No output in the latest run yet (the server has logged nothing since its last reload).":`No output for run ${e.run} (it hasn't started, or was trimmed from the log).`)):!s&&!e.follow&&console.error("Log is empty \u2014 this server has logged nothing yet."),e.lines&&e.lines>0){let i=s.split(`
2548
2548
  `);i.length&&i[i.length-1]===""&&i.pop(),s=i.slice(-e.lines).join(`
2549
2549
  `)}if(process.stdout.write(s),s&&!s.endsWith(`
2550
2550
  `)&&process.stdout.write(`
2551
- `),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let l=Ve(n.pid,i);i=l.offset,l.text&&process.stdout.write(l.text)},500),a=()=>{clearInterval(o),process.exit(0)};process.on("SIGINT",a),process.on("SIGTERM",a),await new Promise(()=>{})}}var e1=t=>new Promise(e=>setTimeout(e,t));async function SS(t,e){if(!t){sp(await Z(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let n=ip(await Z(),t,"wait",process.cwd(),kt()),r=process.env.TYPEBULB_WAIT_SHIM==="1",s=process.env.TYPEBULB_WAIT_FOLLOW==="1",i=r||s,o=e.timeoutSec??1800,a=e.match??"",l=Ve(n.pid).offset,c=s?void 0:Vo(n.pid,a)??(a?Vo(n.pid):void 0),f=s?l:c!==void 0&&c<=l?c:a?0:l,d=Date.now()+o*1e3,u=ye(n)?1e4:1e3,p=2e3,m=!ye(n)&&!s,h,g="",E=0;for(;;){let O=f>=l,C=Ve(n.pid,f);if(f=C.offset,C.text){g+=C.text;let x=g.split(`
2552
- `);g=x.pop()??"";let R=!1;for(let I of x)I.trim()&&(m&&O&&I.startsWith(tt.disconnected)&&(R=!0),!(e.match&&!I.includes(e.match))&&(console.log(I),!s&&(h??=Date.now()+u,ye(n)&&(I.includes("] compile error")||I.includes("] runtime error"))&&(h=Math.min(h,Date.now()+p)))));if(R&&!h){console.error(`the last page of ${Nr(n)} closed while waiting \u2014 a bulb runs in its page, so nothing can log ${e.match?`'${e.match}'`:"anything"} now`),E=3;break}}if(h&&Date.now()>=h)break;if(!i&&!h&&Date.now()>=d){console.error(`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${Nr(n)} within ${o}s`),E=2;break}if(!er(n.pid)){h||(console.error(`server ${Nr(n)} (pid ${n.pid}) exited while waiting`),process.exit(3));break}await e1(400)}s||Es(n.pid,f,a),process.exit(E)}function kS(t,e){if(e==="killed")return` \u2014 forced (${bS(t.version)?`its runtime ${t.version?`v${t.version} `:""}predates the stop route`:"it did not answer"}); a page it opened may still be open`;let n=[];return e.closed&&n.push(`closed ${e.closed} page${e.closed===1?"":"s"}`),e.stuck&&n.push(`${e.stuck} did not close`),n.length?` \u2014 ${n.join(", ")}`:""}async function xS(t){if(!t){await sp(await Z(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=ip(await Z(),t,"stop",process.cwd(),kt()),n=await Ft(e);console.log(`Stopped ${Nr(e)} (pid ${e.pid}, ${e.url}).${kS(e,n)}`)}async function ES(t){let e=process.cwd(),n=t==="agent"?kt():void 0,r=t==="global"?await Z():t==="bulbs"?await Z(e):(await Z()).filter(o=>rr(o,e)&&(!n||o.agent===n)),s=t==="global"?"server":t==="agent"?"mirror":"bulb";if(!r.length){console.log(t==="global"?"No running bulb servers.":`No running ${s}s for this project.`);return}let i=await Promise.all(r.map(o=>Ft(o)));console.log(`Stopped ${r.length} ${s}${r.length===1?"":"s"}:`),r.forEach((o,a)=>console.log(` ${o.url} pid ${o.pid} ${Nr(o)}${kS(o,i[a])}`))}Le();Ye();fn();import*as bl from"path";import*as AS from"http";import{mkdir as t1,writeFile as n1}from"fs/promises";async function $r(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function pi(t){return(t.charCodeAt(0)===65279?t.slice(1):t).replace(/\r\n/g,`
2553
- `).trimEnd()}function r1(t,e){return new Promise((n,r)=>{let s=new URL(t),i=AS.request({hostname:s.hostname,port:s.port,path:s.pathname+s.search,method:"POST",headers:{"Content-Type":"text/plain","Content-Length":Buffer.byteLength(e)}},o=>{let a="";o.setEncoding("utf8"),o.on("data",l=>{a+=l}),o.on("end",()=>n({status:o.statusCode??0,text:a}))});i.setTimeout(0),i.on("error",r),i.end(e)})}var s1=t=>{let e=Math.round((Date.now()-t)/6e4);return e<1?"moments ago":e<60?`${e}m ago`:`${Math.round(e/60)}h ago`};async function TS(t,e,n=0){e==="-"&&(e=pi(await $r()));let r=e!==void 0&&e.startsWith("tb:");r&&n<=0&&(n=zf);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=bl.resolve(t),o=hn(await Z(),i)[0];if(!o){let m=(await dn(process.cwd()))(i);console.error(m?`No running server for '${t}' \u2014 it last ran ${s1(m)}. Relaunching reuses the same URL (a stale tab is one reload from live): npx typebulb ${t}`:`No running server for '${t}'. Start it first: npx typebulb ${t}`),process.exit(1)}let a=async m=>{let h=[m>0?`reply=${m}`:"",s?"solo=1":"","open=1"].filter(Boolean).join("&"),g=await r1(`${o.url}/__send${h?`?${h}`:""}`,e??"");(g.status<200||g.status>=300)&&(console.error(`send failed: HTTP ${g.status} from ${o.url}/__send`),process.exit(1));try{return JSON.parse(g.text)}catch{return{}}},l={},c=Date.now();try{l=await a(n)}catch(m){console.error(`send failed: ${m instanceof Error?m.message:String(m)}`),process.exit(1)}let f=l.clients??0,d=`${f} page${f===1?"":"s"}`;if(l.refused&&(console.error(`Actuation needs exactly one connected page; ${d} are open on ${o.url} \u2014 the reset is \`typebulb stop ${t}\` then relaunch.`),process.exit(1)),f===0){let m=l.droppedMsAgo,h=l.opening==="none"?" and no agent mirror page is open to open one through":"",g=l.opening==="unreached"?` \u2014 the page was opened ${l.via?`in VS Code via ${l.via}`:"in your browser"} and never attached; is the browser it opened in still there?`:m!==void 0?` \u2014 a page disconnected ${Math.round(m/1e3)}s ago and hasn't reconnected${h}; reload it, or open ${o.url}`:` \u2014 no page has ever connected${h}; share ${o.url} and arm: typebulb wait ${t} --match "${tt.connected}"`;console.error(`No page connected after ${((Date.now()-c)/1e3).toFixed(1)}s, so nothing was delivered${g}`),process.exit(1)}l.opening==="editor"?console.error(`Opened in VS Code via ${l.via}.`):l.opening==="external"&&console.error("Opened in your browser, where the agent mirror is."),console.error(`Sent to ${d}.`);let u=l.results??[],p=l.errors??[];for(let m of p)console.error(`handler error: ${m}`);if(p.length&&process.exit(1),u.length>1&&(console.error(`${u.length} replies from ${d} \u2014 one reply owns stdout: at most one tb.onMessage handler, in one page, may return a value.`),process.exit(1)),u.length===1){if(e!==void 0&&/^tb:png( |$)/.test(e)){let h={};try{h=JSON.parse(u[0])}catch{}typeof h.png!="string"&&(console.error("tb:png replied with an unexpected shape \u2014 an older runtime? (`typebulb logs` lists server versions)"),process.exit(1));let g=Ty(i);await t1(bl.dirname(g),{recursive:!0}),await n1(g,Buffer.from(h.png,"base64"));let E=[h.via?`inside "${h.via}"`:"",h.backdrop?`backdrop ${h.backdrop}`:""].filter(Boolean);console.error(`canvas ${h.width}\xD7${h.height} \u2192 PNG${E.length?` (${E.join("; ")})`:""}`),console.log(g);return}let m;try{m=JSON.parse(u[0])}catch{m=void 0}console.log(typeof m=="string"?m:u[0])}else l.timedOut&&(r&&(console.error(`No reply to '${e}' within ${n/1e3}s \u2014 reload the page and retry.`),process.exit(1)),console.error(`(no reply within ${n/1e3}s \u2014 slow work needs a larger --wait=ms; a reply that NEVER comes is a done-promise that missed an exit, or a blocked main thread: tb:snapshot runs no page code, so its silence too means blocked)`))}Ma();Gd();ee();import*as OS from"fs/promises";async function PS(t,e){let n=await OS.readFile(t,"utf-8"),r=Mn(n),s=le[e].path,i=r.files.get(s);i||(console.error(i===void 0?`No **${s}** block in ${t}`:`The **${s}** block in ${t} is empty`),process.exit(2)),process.stdout.write(i.endsWith(`
2551
+ `),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let l=Ve(n.pid,i);i=l.offset,l.text&&process.stdout.write(l.text)},500),a=()=>{clearInterval(o),process.exit(0)};process.on("SIGINT",a),process.on("SIGTERM",a),await new Promise(()=>{})}}var t1=t=>new Promise(e=>setTimeout(e,t));async function xS(t,e){if(!t){sp(await X(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let n=ip(await X(),t,"wait",process.cwd(),kt()),r=process.env.TYPEBULB_WAIT_SHIM==="1",s=process.env.TYPEBULB_WAIT_FOLLOW==="1",i=r||s,o=e.timeoutSec??1800,a=e.match??"",l=Ve(n.pid).offset,c=s?void 0:Vo(n.pid,a)??(a?Vo(n.pid):void 0),f=s?l:c!==void 0&&c<=l?c:a?0:l,d=Date.now()+o*1e3,u=ye(n)?1e4:1e3,p=2e3,m=!ye(n)&&!s,h,g="",x=0;for(;;){let O=f>=l,C=Ve(n.pid,f);if(f=C.offset,C.text){g+=C.text;let E=g.split(`
2552
+ `);g=E.pop()??"";let R=!1;for(let I of E)I.trim()&&(m&&O&&I.startsWith(tt.disconnected)&&(R=!0),!(e.match&&!I.includes(e.match))&&(console.log(I),!s&&(h??=Date.now()+u,ye(n)&&(I.includes("] compile error")||I.includes("] runtime error"))&&(h=Math.min(h,Date.now()+p)))));if(R&&!h){console.error(`the last page of ${$r(n)} closed while waiting \u2014 a bulb runs in its page, so nothing can log ${e.match?`'${e.match}'`:"anything"} now`),x=3;break}}if(h&&Date.now()>=h)break;if(!i&&!h&&Date.now()>=d){console.error(`timeout: no ${e.match?`line matching '${e.match}'`:"new output"} from ${$r(n)} within ${o}s`),x=2;break}if(!tr(n.pid)){h||(console.error(`server ${$r(n)} (pid ${n.pid}) exited while waiting`),process.exit(3));break}await t1(400)}s||Es(n.pid,f,a),process.exit(x)}function ES(t,e){if(e==="killed")return` \u2014 forced (${vS(t.version)?`its runtime ${t.version?`v${t.version} `:""}predates the stop route`:"it did not answer"}); a page it opened may still be open`;let n=[];return e.closed&&n.push(`closed ${e.closed} page${e.closed===1?"":"s"}`),e.stuck&&n.push(`${e.stuck} did not close`),n.length?` \u2014 ${n.join(", ")}`:""}async function AS(t){if(!t){await sp(await X(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=ip(await X(),t,"stop",process.cwd(),kt()),n=await Ft(e);console.log(`Stopped ${$r(e)} (pid ${e.pid}, ${e.url}).${ES(e,n)}`)}async function TS(t){let e=process.cwd(),n=t==="agent"?kt():void 0,r=t==="global"?await X():t==="bulbs"?await X(e):(await X()).filter(o=>sr(o,e)&&(!n||o.agent===n)),s=t==="global"?"server":t==="agent"?"mirror":"bulb";if(!r.length){console.log(t==="global"?"No running bulb servers.":`No running ${s}s for this project.`);return}let i=await Promise.all(r.map(o=>Ft(o)));console.log(`Stopped ${r.length} ${s}${r.length===1?"":"s"}:`),r.forEach((o,a)=>console.log(` ${o.url} pid ${o.pid} ${$r(o)}${ES(o,i[a])}`))}Le();Ye();fn();import*as bl from"path";import*as OS from"http";import{mkdir as n1,writeFile as r1}from"fs/promises";async function Lr(){let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf-8")}function pi(t){return(t.charCodeAt(0)===65279?t.slice(1):t).replace(/\r\n/g,`
2553
+ `).trimEnd()}function s1(t,e){return new Promise((n,r)=>{let s=new URL(t),i=OS.request({hostname:s.hostname,port:s.port,path:s.pathname+s.search,method:"POST",headers:{"Content-Type":"text/plain","Content-Length":Buffer.byteLength(e)}},o=>{let a="";o.setEncoding("utf8"),o.on("data",l=>{a+=l}),o.on("end",()=>n({status:o.statusCode??0,text:a}))});i.setTimeout(0),i.on("error",r),i.end(e)})}var i1=t=>{let e=Math.round((Date.now()-t)/6e4);return e<1?"moments ago":e<60?`${e}m ago`:`${Math.round(e/60)}h ago`};async function PS(t,e,n=0){e==="-"&&(e=pi(await Lr()));let r=e!==void 0&&e.startsWith("tb:");r&&n<=0&&(n=zf);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=bl.resolve(t),o=hn(await X(),i)[0];if(!o){let m=(await dn(process.cwd()))(i);console.error(m?`No running server for '${t}' \u2014 it last ran ${i1(m)}. Relaunching reuses the same URL (a stale tab is one reload from live): npx typebulb ${t}`:`No running server for '${t}'. Start it first: npx typebulb ${t}`),process.exit(1)}let a=async m=>{let h=[m>0?`reply=${m}`:"",s?"solo=1":"","open=1"].filter(Boolean).join("&"),g=await s1(`${o.url}/__send${h?`?${h}`:""}`,e??"");(g.status<200||g.status>=300)&&(console.error(`send failed: HTTP ${g.status} from ${o.url}/__send`),process.exit(1));try{return JSON.parse(g.text)}catch{return{}}},l={},c=Date.now();try{l=await a(n)}catch(m){console.error(`send failed: ${m instanceof Error?m.message:String(m)}`),process.exit(1)}let f=l.clients??0,d=`${f} page${f===1?"":"s"}`;if(l.refused&&(console.error(`Actuation needs exactly one connected page; ${d} are open on ${o.url} \u2014 the reset is \`typebulb stop ${t}\` then relaunch.`),process.exit(1)),f===0){let m=l.droppedMsAgo,h=l.opening==="none"?" and no agent mirror page is open to open one through":"",g=l.opening==="unreached"?` \u2014 the page was opened ${l.via?`in VS Code via ${l.via}`:"in your browser"} and never attached; is the browser it opened in still there?`:m!==void 0?` \u2014 a page disconnected ${Math.round(m/1e3)}s ago and hasn't reconnected${h}; reload it, or open ${o.url}`:` \u2014 no page has ever connected${h}; share ${o.url} and arm: typebulb wait ${t} --match "${tt.connected}"`;console.error(`No page connected after ${((Date.now()-c)/1e3).toFixed(1)}s, so nothing was delivered${g}`),process.exit(1)}l.opening==="editor"?console.error(`Opened in VS Code via ${l.via}.`):l.opening==="external"&&console.error("Opened in your browser, where the agent mirror is."),console.error(`Sent to ${d}.`);let u=l.results??[],p=l.errors??[];for(let m of p)console.error(`handler error: ${m}`);if(p.length&&process.exit(1),u.length>1&&(console.error(`${u.length} replies from ${d} \u2014 one reply owns stdout: at most one tb.onMessage handler, in one page, may return a value.`),process.exit(1)),u.length===1){if(e!==void 0&&/^tb:png( |$)/.test(e)){let h={};try{h=JSON.parse(u[0])}catch{}typeof h.png!="string"&&(console.error("tb:png replied with an unexpected shape \u2014 an older runtime? (`typebulb logs` lists server versions)"),process.exit(1));let g=Py(i);await n1(bl.dirname(g),{recursive:!0}),await r1(g,Buffer.from(h.png,"base64"));let x=[h.via?`inside "${h.via}"`:"",h.backdrop?`backdrop ${h.backdrop}`:""].filter(Boolean);console.error(`canvas ${h.width}\xD7${h.height} \u2192 PNG${x.length?` (${x.join("; ")})`:""}`),console.log(g);return}let m;try{m=JSON.parse(u[0])}catch{m=void 0}console.log(typeof m=="string"?m:u[0])}else l.timedOut&&(r&&(console.error(`No reply to '${e}' within ${n/1e3}s \u2014 reload the page and retry.`),process.exit(1)),console.error(`(no reply within ${n/1e3}s \u2014 slow work needs a larger --wait=ms; a reply that NEVER comes is a done-promise that missed an exit, or a blocked main thread: tb:snapshot runs no page code, so its silence too means blocked)`))}Ma();Gd();Q();import*as CS from"fs/promises";async function _S(t,e){let n=await CS.readFile(t,"utf-8"),r=Mn(n),s=ce[e].path,i=r.files.get(s);i||(console.error(i===void 0?`No **${s}** block in ${t}`:`The **${s}** block in ${t} is empty`),process.exit(2)),process.stdout.write(i.endsWith(`
2554
2554
  `)?i:i+`
2555
- `)}ee();import*as hi from"fs/promises";async function RS(t,e){let n=await hi.readFile(t,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await $r():await hi.readFile(o,"utf-8")}catch(l){_S(`Cannot read ${i}'s source: ${l instanceof Error?l.message:String(l)}`)}r.push({kind:i,content:pi(a),label:o==="-"?"stdin":o})}let s;try{s=i1(n,r)}catch(i){_S(`${t}: ${i instanceof Error?i.message:String(i)}`)}for(let i of s.upToDate)console.log(`${le[i].path}: already up to date`);if(s.written.length){await hi.writeFile(t,s.text);for(let i of s.written)console.log(i.action==="removed"?`${le[i.kind].path}: removed (${i.label} is empty)`:`${le[i.kind].path}: ${i.action} from ${i.label} (${i.chars.toLocaleString()} chars)`)}}function i1(t,e){let n=Mn(t),r=t,s=[],i=[];for(let{kind:o,content:a,label:l}of e){let c=le[o].path,f=n.files.get(c);if(!a){if(f===void 0){i.push(o);continue}r=CS(Ip(r,o),r,c),s.push({kind:o,action:"removed",chars:0,label:l});continue}if(f!==void 0&&pi(f)===a){i.push(o);continue}r=CS(Mr(r,o,a),r,c),s.push({kind:o,action:f===void 0?"created":"replaced",chars:a.length,label:l})}return{text:r,written:s,upToDate:i}}function CS(t,e,n){if(t===e)throw new Error(`the **${n}** block's fence is unterminated; refusing to rewrite inside it`);return t}function _S(t){console.error(t),process.exit(1)}ot();gf();Qs();Po();async function IS(t,e){xe(e);let n=process.cwd(),r=ol(),s=kt(),i=(s?[s]:Object.keys(r)).map(a=>r[a]()).filter(a=>a.listChildren&&a.childBriefs);if(!i.length){console.error(`Sub-agent status isn't supported for ${s} sessions.`),process.exitCode=1;return}let o=i.map(a=>({adapter:a,sessions:Vw(a,n)})).filter(a=>a.sessions.length);if(!o.length){console.log("No sub-agents in this project's sessions.");return}if(!t){let{sessions:a}=o[0];o1(a[0]);return}for(let{adapter:a,sessions:l}of o){let c=Gw(l,t);if(!c.length)continue;if(c.length>1){console.error(`Several agents match "${t}"; name one by its id:`);for(let u of c)console.error(` ${NS(u)}`);process.exitCode=1;return}let{text:f,error:d}=await Xw(a,n,c[0]);console.log(f),d&&console.error(`
2556
- (partly unjudged: ${d})`);return}console.error(`No agent matches "${t}". Run \`typebulb status\` to list them.`),process.exitCode=1}function o1(t){let e=[...t.children].sort((n,r)=>n.mtime-r.mtime);console.log(`Sub-agents of session ${t.sessionId}:`);for(let n of e)console.log(` ${" ".repeat(Math.max(0,n.depth-1))}${NS(n)}`);console.log("\nRun `typebulb status <id>` for one agent's report.")}var NS=t=>{let e=t.started?Se((t.state==="running"?Date.now():t.mtime)-t.started):"",n=t.failing&&t.state!=="stopped"?"failing":t.state;return`${t.id} ${n.padEnd(7)} ${e.padStart(6)} ${Cn(t)}`};ot();St();ee();ta();import*as en from"fs/promises";import*as $n from"path";import{EventEmitter as P1}from"events";Ut();ee();import{Hono as f1}from"hono";import{serve as p1}from"@hono/node-server";import{streamSSE as h1}from"hono/streaming";import*as lp from"fs/promises";import m1 from"open";br();Ws();yr();import*as op from"fs/promises";import*as mi from"path";var wl=class{async get(e){let n=Xe(e),r=mi.join(Js,n+".bin"),s=mi.join(Js,n+".json");try{let[i,o]=await Promise.all([op.readFile(r),op.readFile(s,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,n){await te();let r=Xe(e),s=mi.join(Js,r+".bin"),i=mi.join(Js,r+".json"),o={url:e,contentType:n.contentType,cacheControl:n.cacheControl};await Promise.all([De(s,n.body),De(i,JSON.stringify(o))])}};var $S=`
2555
+ `)}Q();import*as hi from"fs/promises";async function NS(t,e){let n=await hi.readFile(t,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await Lr():await hi.readFile(o,"utf-8")}catch(l){IS(`Cannot read ${i}'s source: ${l instanceof Error?l.message:String(l)}`)}r.push({kind:i,content:pi(a),label:o==="-"?"stdin":o})}let s;try{s=o1(n,r)}catch(i){IS(`${t}: ${i instanceof Error?i.message:String(i)}`)}for(let i of s.upToDate)console.log(`${ce[i].path}: already up to date`);if(s.written.length){await hi.writeFile(t,s.text);for(let i of s.written)console.log(i.action==="removed"?`${ce[i.kind].path}: removed (${i.label} is empty)`:`${ce[i.kind].path}: ${i.action} from ${i.label} (${i.chars.toLocaleString()} chars)`)}}function o1(t,e){let n=Mn(t),r=t,s=[],i=[];for(let{kind:o,content:a,label:l}of e){let c=ce[o].path,f=n.files.get(c);if(!a){if(f===void 0){i.push(o);continue}r=RS(Ip(r,o),r,c),s.push({kind:o,action:"removed",chars:0,label:l});continue}if(f!==void 0&&pi(f)===a){i.push(o);continue}r=RS(Dr(r,o,a),r,c),s.push({kind:o,action:f===void 0?"created":"replaced",chars:a.length,label:l})}return{text:r,written:s,upToDate:i}}function RS(t,e,n){if(t===e)throw new Error(`the **${n}** block's fence is unterminated; refusing to rewrite inside it`);return t}function IS(t){console.error(t),process.exit(1)}ot();gf();Qs();Po();async function $S(t,e){xe(e);let n=process.cwd(),r=ol(),s=kt(),i=(s?[s]:Object.keys(r)).map(a=>r[a]()).filter(a=>a.listChildren&&a.childBriefs);if(!i.length){console.error(`Sub-agent status isn't supported for ${s} sessions.`),process.exitCode=1;return}let o=i.map(a=>({adapter:a,sessions:Xw(a,n)})).filter(a=>a.sessions.length);if(!o.length){console.log("No sub-agents in this project's sessions.");return}if(!t){let{sessions:a}=o[0];a1(a[0]);return}for(let{adapter:a,sessions:l}of o){let c=Qw(l,t);if(!c.length)continue;if(c.length>1){console.error(`Several agents match "${t}"; name one by its id:`);for(let u of c)console.error(` ${LS(u)}`);process.exitCode=1;return}let{text:f,error:d}=await Zw(a,n,c[0]);console.log(f),d&&console.error(`
2556
+ (partly unjudged: ${d})`);return}console.error(`No agent matches "${t}". Run \`typebulb status\` to list them.`),process.exitCode=1}function a1(t){let e=[...t.children].sort((n,r)=>n.mtime-r.mtime);console.log(`Sub-agents of session ${t.sessionId}:`);for(let n of e)console.log(` ${" ".repeat(Math.max(0,n.depth-1))}${LS(n)}`);console.log("\nRun `typebulb status <id>` for one agent's report.")}var LS=t=>{let e=t.started?Se((t.state==="running"?Date.now():t.mtime)-t.started):"",n=t.failing&&t.state!=="stopped"?"failing":t.state;return`${t.id} ${n.padEnd(7)} ${e.padStart(6)} ${Cn(t)}`};ot();St();Q();ta();import*as en from"fs/promises";import*as $n from"path";import{EventEmitter as C1}from"events";Ut();Q();import{Hono as p1}from"hono";import{serve as h1}from"@hono/node-server";import{streamSSE as m1}from"hono/streaming";import*as lp from"fs/promises";import g1 from"open";wr();Ws();br();import*as op from"fs/promises";import*as mi from"path";var wl=class{async get(e){let n=Xe(e),r=mi.join(Js,n+".bin"),s=mi.join(Js,n+".json");try{let[i,o]=await Promise.all([op.readFile(r),op.readFile(s,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,n){await ee();let r=Xe(e),s=mi.join(Js,r+".bin"),i=mi.join(Js,r+".json"),o={url:e,contentType:n.contentType,cacheControl:n.cacheControl};await Promise.all([De(s,n.body),De(i,JSON.stringify(o))])}};var MS=`
2557
2557
  const CSS = '\\n' +
2558
2558
  /* The agent mirror's token set, verbatim (agents/core/client/styles.css) \u2014 one system across CLI
2559
2559
  chrome: app chrome sits on --panel, content wells paint --veil, grays ride one neutral tint.
@@ -2936,22 +2936,22 @@ export function runInference(ctx) {
2936
2936
  showConfirm();
2937
2937
  document.body.appendChild(host);
2938
2938
  }
2939
- `;vr();Le();bn();fa();Ut();import{stream as a1}from"hono/streaming";var l1="X-TB-Stream";function gi(t){return t instanceof Ce?{message:t.message,code:t.code,retryable:t.retryable}:{message:t instanceof Error?t.message:"Unknown error",code:"unknown",retryable:!1}}function vl(t,e){return t.header("Content-Type","application/x-ndjson; charset=utf-8"),t.header("Cache-Control","no-cache"),t.header(l1,"1"),a1(t,async n=>{let r=e[Symbol.asyncIterator]();n.onAbort(()=>{r.return?.()});try{for(;;){let{done:s,value:i}=await r.next();if(s)break;await n.writeln(JSON.stringify({type:"chunk",value:i}))}}catch(s){await n.writeln(JSON.stringify({type:"error",error:gi(s)}))}finally{try{await r.return?.()}catch{}}})}var Sl={log:(...t)=>console.log(...t)};function kl(t,e){let n=t?.[e]??(Object.hasOwn(Sl,e)?Sl[e]:void 0);return typeof n=="function"?n:void 0}function xl(t){return t.constructor?.name==="AsyncGeneratorFunction"}qd();var c1=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,u1=/[?&]target=/,d1=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function LS(t,e=""){return c1.test(t)?!0:d1.test(t)&&u1.test(e)}var g1="127.0.0.1",y1=new Set(["localhost","127.0.0.1","::1"]),FS=(t,e)=>!!t&&typeof t=="object"&&e in t,MS=t=>{let e={};return Array.isArray(t.data)&&(e.data=t.data),FS(t,"insight")&&(e.insight=t.insight),e},DS=8*1024*1024,b1=0;function w1(t){if(t)try{return new URL(t.includes("://")?t:`http://${t}`).hostname}catch{return}}function US(t){let e=w1(t);return!!e&&y1.has(e)}function v1(t){try{let e=new URL(t);return(e.protocol==="http:"||e.protocol==="https:")&&US(e.host)}catch{return!1}}function S1(t){return!!t&&/\bCode\/\d/.test(t)&&/\bElectron\//.test(t)}function k1(t,e){if(!e)return!1;try{return new URL(t).host===e}catch{return!1}}function yi(t){return t instanceof Error?t.message:"Unknown error"}var BS=t=>t.how==="editor"||t.how==="unreached"?t.via:void 0,x1=2e3;async function qS(t){let{getHtml:e,basePath:n,fsBase:r,port:s,reloadEmitter:i,sendChannel:o,getServerExports:a,getBulbBlocks:l,saveInferenceResult:c,localOverride:f,trusted:d=!1,trustHint:u,staticAssets:p,bulbAssets:m,sourceFile:h,bulbKey:g,onStop:E}=t,O=`${process.pid}-${++b1}-${Date.now()}`,C=r??n,x=new f1;x.use("*",async(b,k)=>{if(!US(b.req.header("host")))return b.text("Forbidden: untrusted Host",403);await k()}),x.use("*",async(b,k)=>{await k(),b.res.headers.set("Cross-Origin-Opener-Policy","same-origin"),b.res.headers.set("Cross-Origin-Embedder-Policy","credentialless")});let R=[["/__fs/*","the filesystem"],["/__api/*","server-side code (server.ts)"],["/__ai","AI (your API keys)"],["/__infer","AI (your API keys)"],["/__infer-save","the filesystem"]],I=async(b,k)=>{if(!d){let P=new URL(b.req.url).pathname,N=R.find(([W])=>W.endsWith("/*")?P.startsWith(W.slice(0,-2)):P===W)?.[1]??"server-side code (server.ts)";Vu(process.pid,N);let M=u?`
2940
- ${u}`:"";return b.text(`Forbidden: this capability requires --trust.${M}`,403)}await k()},L=async(b,k)=>{let P=b.req.header("sec-fetch-site");if(P){if(P!=="same-origin")return b.text(`Forbidden: ${P} request`,403)}else{let N=b.req.header("origin");if(N&&!k1(N,b.req.header("host")))return b.text("Forbidden: cross-origin request",403)}await k()};for(let[b]of R)x.use(b,I),x.use(b,L);x.use("/__log",L),x.post("/__log",async b=>{try{let{args:k}=await b.req.json();console.log(...k||[])}catch{}return b.json({ok:!0})});let A=new yl,U=new Set,Q=new Set,G=Date.now();A.onArrival(({page:b,firstAttach:k,count:P})=>{o&&P===1&&console.log(tt.connected),k&&P>1&&b.close("yielded").catch(()=>{})}),o&&A.onSettledEmpty(()=>console.log(tt.disconnected));let F,me=0,pe=async b=>{let k=Math.max(b.fresh?0:G,A.lastDropAt);if(await A.whenArrives(rp-(Date.now()-k)))return{how:"attached"};if(Date.now()-me<x1)return{how:"none"};let P=`http://localhost:${s}#tb-relay`,N=await Xu(P,n),M;return N?.where==="editor"?M={how:"editor",via:N.via}:(b.external==="force"||b.external==="follow"&&N?.where==="external")&&(await m1(P),M={how:"external"}),M?await A.whenArrives(mS)?M:{how:"unreached",via:BS(M)}:(me=Date.now(),{how:"none"})},Ie=b=>A.count>0?Promise.resolve({how:"attached"}):F??=pe(b).finally(()=>{F=void 0});if(o){let b=0,k=new Map;x.use("/__send",L),x.post("/__send",async P=>{let N="";try{N=await P.req.text()}catch{}let M=Number(P.req.query("reply"))||0,W=A.count===0&&P.req.query("open")!==void 0?await Ie({external:"follow",fresh:!1}):void 0,q=A.count,qe=q===0&&A.lastDropAt?Date.now()-A.lastDropAt:void 0,z={clients:q,droppedMsAgo:qe,...W?{opening:W.how,via:BS(W)}:{}};if(P.req.query("solo")!==void 0&&q!==1)return P.json({...z,refused:q>1});if(q===0)return P.json(z);let oe=tn=>{for(let Ot of A)Ot.send(tn).catch(()=>{})};if(M<=0)return oe({payload:N}),P.json(z);let Te=++b,Lr=await new Promise(tn=>{let Ot={expected:q,received:0,results:[],errors:[],finish:Tl=>{clearTimeout(Al),k.delete(Te),tn({results:Ot.results,errors:Ot.errors,timedOut:Tl})}},Al=setTimeout(()=>Ot.finish(!0),M);k.set(Te,Ot),oe({id:Te,payload:N})});return P.json({...z,...Lr})}),x.use("/__send-reply",L),x.post("/__send-reply",async P=>{try{let{id:N,results:M,errors:W}=await P.req.json(),q=k.get(N);q&&(q.results.push(...M??[]),q.errors.push(...W??[]),++q.received>=q.expected&&q.finish(!1))}catch{}return P.json({ok:!0})})}x.get("/",b=>b.html(e())),x.post("/__fs/read",async b=>{try{let{path:k}=await b.req.json(),P=await Ks(k,C);return new Response(new Uint8Array(P),{headers:{"Content-Type":"application/octet-stream"}})}catch(k){let P=yi(k);return b.json({error:P},400)}}),x.post("/__fs/write",async b=>{try{let k=b.req.query("path");return k?(await Ca(k,new Uint8Array(await b.req.arrayBuffer()),C),b.json({success:!0})):b.json({error:"Missing path"},400)}catch(k){let P=yi(k);return b.json({error:P},400)}}),x.post("/__fs/list",async b=>{try{let{path:k}=await b.req.json();return b.json(await _a(k??".",C))}catch(k){return b.json({error:yi(k)},400)}}),x.post("/__fs/remove",async b=>{try{let{path:k}=await b.req.json();return await Ra(k,C),b.json({success:!0})}catch(k){return b.json({error:yi(k)},400)}}),x.post("/__api/:name",async b=>{try{let k=b.req.param("name"),P=kl(a?.(),k);if(!P)return b.json({error:`API function '${k}' not found`},404);let{args:N}=await b.req.json();if(xl(P))return vl(b,P(...N||[]));let M=await P(...N||[]);return b.json({result:M})}catch(k){let P=yi(k);return b.json({error:P},500)}}),x.post("/__ai",async b=>{try{let{messages:k,system:P,effort:N,provider:M,model:W,webSearch:q,stream:qe}=await b.req.json();if(!k||!Array.isArray(k)||k.length===0)return b.json({message:"messages array is required",code:"unknown",retryable:!1},400);let z=gt(M,W);if(typeof z=="string")return b.json({message:z,code:"unknown",retryable:!1},400);let oe=await Jt(z,{messages:k,system:P,effort:N,webSearch:q,signal:b.req.raw.signal});if(!oe.ok){let tn=await fr(oe,z.protocol);return b.json(tn,oe.status)}if(qe)return vl(b,Sn(oe,z.protocol));let{text:Te,usage:Lr}=await pr(oe,z.protocol);return Te||console.warn("[tb.ai] Empty response from provider"),b.json({text:Te,usage:Lr})}catch(k){return b.json(gi(k),500)}}),x.post("/__infer",async b=>{try{let{data:k}=await b.req.json().catch(()=>({})),P=l?.();if(!P?.infer.trim())return b.json({message:"This bulb has no infer.md block.",code:"unknown",retryable:!1},400);let N=gt();if(typeof N=="string")return b.json({message:N,code:"unknown",retryable:!1},400);let M=Array.isArray(k)?k.map(String):[],W=kd(P,M),q=await Jt(N,{messages:[{role:"user",content:W}],signal:b.req.raw.signal});if(!q.ok){let z=await fr(q,N.protocol);return b.json(z,q.status)}let qe=(async function*(){let z="";for await(let Te of Sn(q,N.protocol))Te.kind!=="text"||!Te.text||(z+=Te.text,yield{kind:"delta",text:Te.text});let oe=xd(z);if(oe.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
2941
- `+z.slice(-4e3)),new Ce("LLM output is not valid JSON","parse_error",!0);oe.fixesApplied.length&&console.warn("[tb.infer] sanitized output, fixes applied:",oe.fixesApplied.join(", ")),yield{kind:"complete",insight:oe.parsed,data:M,fixesApplied:oe.fixesApplied}})();return vl(b,qe)}catch(k){return b.json(gi(k),500)}}),x.post("/__infer-save",async b=>{try{if(!c)return b.json({message:"Save is not available for this server.",code:"unknown",retryable:!1},400);let k=MS(await b.req.json().catch(()=>({})));return Object.keys(k).length?(await c(k.data,FS(k,"insight")?JSON.stringify(k.insight,null,2):void 0),b.json({ok:!0})):b.json({message:"Nothing to save \u2014 this page holds no runtime state.",code:"unknown",retryable:!1},400)}catch(k){return b.json(gi(k),500)}}),x.get("/__infer-info",b=>{let k=l?.(),P=Dr(k?.config??"").inference,N=Ao(k?.data??""),M=!!k?.infer.trim(),W=gt();return typeof W=="string"?b.json({error:W,inference:P,data:N,hasInfer:M}):b.json({provider:W.protocol,model:W.model,inference:P,data:N,hasInfer:M})}),x.use("/__tb-decode",L),x.post("/__tb-decode",async b=>{let{hash:k}=await b.req.json().catch(()=>({})),P=typeof k=="string"?Ad(k):void 0;return b.json(P??{error:"invalid fragment"})}),x.use("/__tb-encode",L),x.post("/__tb-encode",async b=>{let k=Number(b.req.header("content-length"));if(Number.isFinite(k)&&k>DS)return b.json({hash:""});let P=await b.req.text().catch(()=>"");if(P.length>DS)return b.json({hash:""});let N;try{N=JSON.parse(P)}catch{return b.json({hash:""})}return b.json({hash:Ed(MS(N))})}),x.get("/__infer-ui.js",b=>b.body($S,200,{"Content-Type":"text/javascript; charset=utf-8"})),x.get("/__models",async b=>{try{let k=await mt();return b.json(k)}catch{return b.json([],200)}}),x.get("/__ai-access",async b=>{try{return b.json(await sa())}catch{return b.json("none",200)}}),h&&x.get("/__source/*",async b=>{let k=await lp.readFile(h,"utf-8").catch(()=>{});return k===void 0?b.text("Not Found",404):new Response(k,{headers:{"Content-Type":"text/plain; charset=utf-8"}})});let ct=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],ue=new wl;x.get("/proxy/*",async b=>{let k=new URL(b.req.url),N=(k.pathname+k.search).slice(7),M=N.lastIndexOf("https://");return M===-1?b.text("Invalid proxy URL",400):Ae(b,N.slice(M))}),f&&jS(x,`/local/${f.name}/`,f.serveDir),p&&jS(x,p.mount,p.dir),m&&x.get("/assets/*",async b=>{let{pathname:k}=new URL(b.req.url),P=k.slice(8),N;try{N=decodeURIComponent(P)}catch{return b.text("Not Found",404)}let M=Mp(N);if(M)return b.text(`${M} is not an asset type: a bulb's code and markup live in the bulb; assets are media and data`,403);try{let q=await JS(N,m.dir,{"Cache-Control":"no-cache"});if(q)return q}catch{return b.text("Not Found",404)}let W=m.remoteBase;return W?b.redirect(W+P,302):b.text("Not Found",404)});async function Ae(b,k){let P;try{P=new URL(k)}catch{return b.text("Invalid URL",400)}if(P.protocol!=="https:")return b.text("HTTPS only",400);if(!ct.includes(P.hostname))return b.text("Host not allowed",403);let N=await ue.get(k);if(N)return new Response(N.body,{status:200,headers:ap(N.contentType,N.cacheControl)});try{let M=await fetch(k,{headers:{Accept:b.req.header("Accept")||"*/*"},redirect:"follow"});if(!M.ok)return b.text(`Upstream ${M.status}`,M.status);let W=M.headers.get("Content-Type")||void 0,q=M.headers.get("Cache-Control")||void 0;if(M.body){let[qe,z]=M.body.tee();return(async()=>{try{let oe=await new Response(z).arrayBuffer();await ue.set(k,{body:Buffer.from(oe),contentType:W,cacheControl:q})}catch{}})(),new Response(qe,{status:M.status,headers:ap(W,q)})}return new Response(null,{status:M.status,headers:ap(W,q)})}catch(M){return b.text(`Proxy fetch failed: ${M instanceof Error?M.message:M}`,502)}}(i||o)&&(x.get("/__reload",b=>h1(b,async k=>{let P=b.req.query("bulb")||void 0;if(g&&P&&P!==g){U.has(P)||(U.add(P),console.log(tt.closed("foreign"))),await k.writeSSE({event:"close",data:"foreign"});return}let N=()=>{k.writeSSE({event:"reload",data:""})};i?.on("reload",N);let M=()=>i?.removeListener("reload",N),W=b.req.query("relay")||void 0,q={inEditor:S1(b.req.header("user-agent")),doc:W,open:z=>k.writeSSE({event:"open-url",data:z}),send:z=>k.writeSSE({event:"message",data:JSON.stringify(z)}),close:z=>(M(),A.closing(q),console.log(tt.closed(z)),k.writeSSE({event:"close",data:z}))},qe=!!W&&!Q.has(W);for(W&&Q.add(W),A.add(q,qe),k.onAbort(()=>{M(),A.dropped(q)}),await k.writeSSE({event:"hello",data:O,retry:Fd});!k.aborted;)await k.sleep(3e4)})),x.use("/__open",L),x.post("/__open",async b=>{let k="";try{k=String((await b.req.json()).url??"")}catch{}if(!v1(k))return b.json({error:"a local http URL is required"},400);let P=[...A].find(N=>N.inEditor);return await P?.open(k),b.json({opened:!!P,pages:A.count})})),x.use("/__stop",L),x.post("/__stop",async b=>{if(b.req.header("sec-fetch-site")||b.req.header("origin"))return b.text("Forbidden: browser request",403);let k="close";try{let N=await b.req.json();(N?.pages==="keep"||N?.pages==="close")&&(k=N.pages)}catch{}let P=k==="close"?await A.closeAll("stopped"):{told:0,gone:0};return E&&setTimeout(()=>{E({pages:k})},50),b.json({closed:P.gone,stuck:P.told-P.gone,exiting:!!E})}),x.get("/__pages",b=>b.json({pages:A.count})),x.notFound(async b=>{if(b.req.method!=="GET")return b.text("Not Found",404);let k=new URL(b.req.url);return LS(k.pathname,k.search)?Ae(b,"https://esm.sh"+k.pathname+k.search):b.text("Not Found",404)});let Tt=p1({fetch:x.fetch,port:s,hostname:g1});return Tt.listening||await new Promise((b,k)=>{let P=N=>k(N);Tt.once("error",P),Tt.once("listening",()=>{Tt.removeListener("error",P),b()})}),{port:s,close:()=>Tt.close(),requestPage:Ie,closePages:b=>A.closeAll(b),pageCount:()=>A.count}}function ap(t,e){let n=new Headers;return t&&n.set("Content-Type",t),e&&n.set("Cache-Control",e),n.set("Access-Control-Allow-Origin","*"),n.set("Cross-Origin-Resource-Policy","cross-origin"),n}function jS(t,e,n){t.get(`${e}*`,async r=>{let{pathname:s}=new URL(r.req.url);if(!s.startsWith(e))return r.text("Not Found",404);try{return await JS(decodeURIComponent(s.slice(e.length)),n)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function JS(t,e,n={}){let r=Sr(t,e),s=await lp.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":Lp(r),...n}})}Le();fn();async function El(t){let{port:e,portNote:n,makeServerOptions:r,makeEntry:s,displayName:i,waitTarget:o,stopLog:a}=t,l=`http://localhost:${e}`,c=s(e,l),f=[],d,u=!1,p=async h=>{if(!u){u=!0,console.log(`
2942
- Shutting down...`),(h?.pages??(ye(c)?"keep":"close"))==="close"&&await d?.closePages("stopped"),d?.close();for(let g of f)try{await g()}catch{}a(),await pn(process.pid),process.exit(0)}},m=await qS({...r(e),onStop:p}).catch(async h=>{if(h?.code!=="EADDRINUSE")throw h;return Fu(e)});return d=m,await Yu(c),console.log(`
2943
- ${i}`),console.log(` ${l}`),n&&console.log(` ${n}`),process.on("SIGINT",()=>{p()}),process.on("SIGTERM",()=>{p()}),{port:e,url:l,pageCount:()=>m.pageCount(),async handOver({mode:h,fresh:g,replacedLive:E}){if(h==="none")return;let O={fresh:g,external:E?"never":h==="window"?"force":"follow"},C=await m.requestPage(O);C.how==="attached"?console.log(` Reusing the open browser tab.
2939
+ `;Sr();Le();bn();fa();Ut();import{stream as l1}from"hono/streaming";var c1="X-TB-Stream";function gi(t){return t instanceof Ce?{message:t.message,code:t.code,retryable:t.retryable}:{message:t instanceof Error?t.message:"Unknown error",code:"unknown",retryable:!1}}function vl(t,e){return t.header("Content-Type","application/x-ndjson; charset=utf-8"),t.header("Cache-Control","no-cache"),t.header(c1,"1"),l1(t,async n=>{let r=e[Symbol.asyncIterator]();n.onAbort(()=>{r.return?.()});try{for(;;){let{done:s,value:i}=await r.next();if(s)break;await n.writeln(JSON.stringify({type:"chunk",value:i}))}}catch(s){await n.writeln(JSON.stringify({type:"error",error:gi(s)}))}finally{try{await r.return?.()}catch{}}})}var Sl={log:(...t)=>console.log(...t)};function kl(t,e){let n=t?.[e]??(Object.hasOwn(Sl,e)?Sl[e]:void 0);return typeof n=="function"?n:void 0}function xl(t){return t.constructor?.name==="AsyncGeneratorFunction"}qd();var u1=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,d1=/[?&]target=/,f1=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function DS(t,e=""){return u1.test(t)?!0:f1.test(t)&&d1.test(e)}var y1="127.0.0.1",b1=new Set(["localhost","127.0.0.1","::1"]),qS=(t,e)=>!!t&&typeof t=="object"&&e in t,BS=t=>{let e={};return Array.isArray(t.data)&&(e.data=t.data),qS(t,"insight")&&(e.insight=t.insight),e},jS=8*1024*1024,w1=0;function v1(t){if(t)try{return new URL(t.includes("://")?t:`http://${t}`).hostname}catch{return}}function JS(t){let e=v1(t);return!!e&&b1.has(e)}function S1(t){try{let e=new URL(t);return(e.protocol==="http:"||e.protocol==="https:")&&JS(e.host)}catch{return!1}}function k1(t){return!!t&&/\bCode\/\d/.test(t)&&/\bElectron\//.test(t)}function x1(t,e){if(!e)return!1;try{return new URL(t).host===e}catch{return!1}}function yi(t){return t instanceof Error?t.message:"Unknown error"}var FS=t=>t.how==="editor"||t.how==="unreached"?t.via:void 0,E1=2e3;async function WS(t){let{getHtml:e,basePath:n,fsBase:r,port:s,reloadEmitter:i,sendChannel:o,getServerExports:a,getBulbBlocks:l,saveInferenceResult:c,localOverride:f,trusted:d=!1,trustHint:u,staticAssets:p,bulbAssets:m,sourceFile:h,bulbKey:g,onStop:x}=t,O=`${process.pid}-${++w1}-${Date.now()}`,C=r??n,E=new p1;E.use("*",async(b,k)=>{if(!JS(b.req.header("host")))return b.text("Forbidden: untrusted Host",403);await k()}),E.use("*",async(b,k)=>{await k(),b.res.headers.set("Cross-Origin-Opener-Policy","same-origin"),b.res.headers.set("Cross-Origin-Embedder-Policy","credentialless")});let R=[["/__fs/*","the filesystem"],["/__api/*","server-side code (server.ts)"],["/__ai","AI (your API keys)"],["/__infer","AI (your API keys)"],["/__infer-save","the filesystem"]],I=async(b,k)=>{if(!d){let P=new URL(b.req.url).pathname,N=R.find(([W])=>W.endsWith("/*")?P.startsWith(W.slice(0,-2)):P===W)?.[1]??"server-side code (server.ts)";Vu(process.pid,N);let M=u?`
2940
+ ${u}`:"";return b.text(`Forbidden: this capability requires --trust.${M}`,403)}await k()},L=async(b,k)=>{let P=b.req.header("sec-fetch-site");if(P){if(P!=="same-origin")return b.text(`Forbidden: ${P} request`,403)}else{let N=b.req.header("origin");if(N&&!x1(N,b.req.header("host")))return b.text("Forbidden: cross-origin request",403)}await k()};for(let[b]of R)E.use(b,I),E.use(b,L);E.use("/__log",L),E.post("/__log",async b=>{try{let{args:k}=await b.req.json();console.log(...k||[])}catch{}return b.json({ok:!0})});let A=new yl,F=new Set,Z=new Set,te=Date.now();A.onArrival(({page:b,firstAttach:k,count:P})=>{o&&P===1&&console.log(tt.connected),k&&P>1&&b.close("yielded").catch(()=>{})}),o&&A.onSettledEmpty(()=>console.log(tt.disconnected));let U,ne=0,he=async b=>{let k=Math.max(b.fresh?0:te,A.lastDropAt);if(await A.whenArrives(rp-(Date.now()-k)))return{how:"attached"};if(Date.now()-ne<E1)return{how:"none"};let P=`http://localhost:${s}#tb-relay`,N=await Xu(P,n),M;return N?.where==="editor"?M={how:"editor",via:N.via}:(b.external==="force"||b.external==="follow"&&N?.where==="external")&&(await g1(P),M={how:"external"}),M?await A.whenArrives(yS)?M:{how:"unreached",via:FS(M)}:(ne=Date.now(),{how:"none"})},Ie=b=>A.count>0?Promise.resolve({how:"attached"}):U??=he(b).finally(()=>{U=void 0});if(o){let b=0,k=new Map;E.use("/__send",L),E.post("/__send",async P=>{let N="";try{N=await P.req.text()}catch{}let M=Number(P.req.query("reply"))||0,W=A.count===0&&P.req.query("open")!==void 0?await Ie({external:"follow",fresh:!1}):void 0,q=A.count,qe=q===0&&A.lastDropAt?Date.now()-A.lastDropAt:void 0,z={clients:q,droppedMsAgo:qe,...W?{opening:W.how,via:FS(W)}:{}};if(P.req.query("solo")!==void 0&&q!==1)return P.json({...z,refused:q>1});if(q===0)return P.json(z);let ae=tn=>{for(let Ot of A)Ot.send(tn).catch(()=>{})};if(M<=0)return ae({payload:N}),P.json(z);let Te=++b,Mr=await new Promise(tn=>{let Ot={expected:q,received:0,results:[],errors:[],finish:Tl=>{clearTimeout(Al),k.delete(Te),tn({results:Ot.results,errors:Ot.errors,timedOut:Tl})}},Al=setTimeout(()=>Ot.finish(!0),M);k.set(Te,Ot),ae({id:Te,payload:N})});return P.json({...z,...Mr})}),E.use("/__send-reply",L),E.post("/__send-reply",async P=>{try{let{id:N,results:M,errors:W}=await P.req.json(),q=k.get(N);q&&(q.results.push(...M??[]),q.errors.push(...W??[]),++q.received>=q.expected&&q.finish(!1))}catch{}return P.json({ok:!0})})}E.get("/",b=>b.html(e())),E.post("/__fs/read",async b=>{try{let{path:k}=await b.req.json(),P=await Ks(k,C);return new Response(new Uint8Array(P),{headers:{"Content-Type":"application/octet-stream"}})}catch(k){let P=yi(k);return b.json({error:P},400)}}),E.post("/__fs/write",async b=>{try{let k=b.req.query("path");return k?(await Ca(k,new Uint8Array(await b.req.arrayBuffer()),C),b.json({success:!0})):b.json({error:"Missing path"},400)}catch(k){let P=yi(k);return b.json({error:P},400)}}),E.post("/__fs/list",async b=>{try{let{path:k}=await b.req.json();return b.json(await _a(k??".",C))}catch(k){return b.json({error:yi(k)},400)}}),E.post("/__fs/remove",async b=>{try{let{path:k}=await b.req.json();return await Ra(k,C),b.json({success:!0})}catch(k){return b.json({error:yi(k)},400)}}),E.post("/__api/:name",async b=>{try{let k=b.req.param("name"),P=kl(a?.(),k);if(!P)return b.json({error:`API function '${k}' not found`},404);let{args:N}=await b.req.json();if(xl(P))return vl(b,P(...N||[]));let M=await P(...N||[]);return b.json({result:M})}catch(k){let P=yi(k);return b.json({error:P},500)}}),E.post("/__ai",async b=>{try{let{messages:k,system:P,effort:N,provider:M,model:W,webSearch:q,stream:qe}=await b.req.json();if(!k||!Array.isArray(k)||k.length===0)return b.json({message:"messages array is required",code:"unknown",retryable:!1},400);let z=gt(M,W);if(typeof z=="string")return b.json({message:z,code:"unknown",retryable:!1},400);let ae=await Jt(z,{messages:k,system:P,effort:N,webSearch:q,signal:b.req.raw.signal});if(!ae.ok){let tn=await pr(ae,z.protocol);return b.json(tn,ae.status)}if(qe)return vl(b,Sn(ae,z.protocol));let{text:Te,usage:Mr}=await hr(ae,z.protocol);return Te||console.warn("[tb.ai] Empty response from provider"),b.json({text:Te,usage:Mr})}catch(k){return b.json(gi(k),500)}}),E.post("/__infer",async b=>{try{let{data:k}=await b.req.json().catch(()=>({})),P=l?.();if(!P?.infer.trim())return b.json({message:"This bulb has no infer.md block.",code:"unknown",retryable:!1},400);let N=gt();if(typeof N=="string")return b.json({message:N,code:"unknown",retryable:!1},400);let M=Array.isArray(k)?k.map(String):[],W=kd(P,M),q=await Jt(N,{messages:[{role:"user",content:W}],signal:b.req.raw.signal});if(!q.ok){let z=await pr(q,N.protocol);return b.json(z,q.status)}let qe=(async function*(){let z="";for await(let Te of Sn(q,N.protocol))Te.kind!=="text"||!Te.text||(z+=Te.text,yield{kind:"delta",text:Te.text});let ae=xd(z);if(ae.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
2941
+ `+z.slice(-4e3)),new Ce("LLM output is not valid JSON","parse_error",!0);ae.fixesApplied.length&&console.warn("[tb.infer] sanitized output, fixes applied:",ae.fixesApplied.join(", ")),yield{kind:"complete",insight:ae.parsed,data:M,fixesApplied:ae.fixesApplied}})();return vl(b,qe)}catch(k){return b.json(gi(k),500)}}),E.post("/__infer-save",async b=>{try{if(!c)return b.json({message:"Save is not available for this server.",code:"unknown",retryable:!1},400);let k=BS(await b.req.json().catch(()=>({})));return Object.keys(k).length?(await c(k.data,qS(k,"insight")?JSON.stringify(k.insight,null,2):void 0),b.json({ok:!0})):b.json({message:"Nothing to save \u2014 this page holds no runtime state.",code:"unknown",retryable:!1},400)}catch(k){return b.json(gi(k),500)}}),E.get("/__infer-info",b=>{let k=l?.(),P=Br(k?.config??"").inference,N=Ao(k?.data??""),M=!!k?.infer.trim(),W=gt();return typeof W=="string"?b.json({error:W,inference:P,data:N,hasInfer:M}):b.json({provider:W.protocol,model:W.model,inference:P,data:N,hasInfer:M})}),E.use("/__tb-decode",L),E.post("/__tb-decode",async b=>{let{hash:k}=await b.req.json().catch(()=>({})),P=typeof k=="string"?Ad(k):void 0;return b.json(P??{error:"invalid fragment"})}),E.use("/__tb-encode",L),E.post("/__tb-encode",async b=>{let k=Number(b.req.header("content-length"));if(Number.isFinite(k)&&k>jS)return b.json({hash:""});let P=await b.req.text().catch(()=>"");if(P.length>jS)return b.json({hash:""});let N;try{N=JSON.parse(P)}catch{return b.json({hash:""})}return b.json({hash:Ed(BS(N))})}),E.get("/__infer-ui.js",b=>b.body(MS,200,{"Content-Type":"text/javascript; charset=utf-8"})),E.get("/__models",async b=>{try{let k=await mt();return b.json(k)}catch{return b.json([],200)}}),E.get("/__ai-access",async b=>{try{return b.json(await sa())}catch{return b.json("none",200)}}),h&&E.get("/__source/*",async b=>{let k=await lp.readFile(h,"utf-8").catch(()=>{});return k===void 0?b.text("Not Found",404):new Response(k,{headers:{"Content-Type":"text/plain; charset=utf-8"}})});let ct=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],de=new wl;E.get("/proxy/*",async b=>{let k=new URL(b.req.url),N=(k.pathname+k.search).slice(7),M=N.lastIndexOf("https://");return M===-1?b.text("Invalid proxy URL",400):Ae(b,N.slice(M))}),f&&US(E,`/local/${f.name}/`,f.serveDir),p&&US(E,p.mount,p.dir),m&&E.get("/assets/*",async b=>{let{pathname:k}=new URL(b.req.url),P=k.slice(8),N;try{N=decodeURIComponent(P)}catch{return b.text("Not Found",404)}let M=Mp(N);if(M)return b.text(`${M} is not an asset type: a bulb's code and markup live in the bulb; assets are media and data`,403);try{let q=await KS(N,m.dir,{"Cache-Control":"no-cache"});if(q)return q}catch{return b.text("Not Found",404)}let W=m.remoteBase;return W?b.redirect(W+P,302):b.text("Not Found",404)});async function Ae(b,k){let P;try{P=new URL(k)}catch{return b.text("Invalid URL",400)}if(P.protocol!=="https:")return b.text("HTTPS only",400);if(!ct.includes(P.hostname))return b.text("Host not allowed",403);let N=await de.get(k);if(N)return new Response(N.body,{status:200,headers:ap(N.contentType,N.cacheControl)});try{let M=await fetch(k,{headers:{Accept:b.req.header("Accept")||"*/*"},redirect:"follow"});if(!M.ok)return b.text(`Upstream ${M.status}`,M.status);let W=M.headers.get("Content-Type")||void 0,q=M.headers.get("Cache-Control")||void 0;if(M.body){let[qe,z]=M.body.tee();return(async()=>{try{let ae=await new Response(z).arrayBuffer();await de.set(k,{body:Buffer.from(ae),contentType:W,cacheControl:q})}catch{}})(),new Response(qe,{status:M.status,headers:ap(W,q)})}return new Response(null,{status:M.status,headers:ap(W,q)})}catch(M){return b.text(`Proxy fetch failed: ${M instanceof Error?M.message:M}`,502)}}(i||o)&&(E.get("/__reload",b=>m1(b,async k=>{let P=b.req.query("bulb")||void 0;if(g&&P&&P!==g){F.has(P)||(F.add(P),console.log(tt.closed("foreign"))),await k.writeSSE({event:"close",data:"foreign"});return}let N=()=>{k.writeSSE({event:"reload",data:""})};i?.on("reload",N);let M=()=>i?.removeListener("reload",N),W=b.req.query("relay")||void 0,q={inEditor:k1(b.req.header("user-agent")),doc:W,open:z=>k.writeSSE({event:"open-url",data:z}),send:z=>k.writeSSE({event:"message",data:JSON.stringify(z)}),close:z=>(M(),A.closing(q),console.log(tt.closed(z)),k.writeSSE({event:"close",data:z}))},qe=!!W&&!Z.has(W);for(W&&Z.add(W),A.add(q,qe),k.onAbort(()=>{M(),A.dropped(q)}),await k.writeSSE({event:"hello",data:O,retry:Fd});!k.aborted;)await k.sleep(3e4)})),E.use("/__open",L),E.post("/__open",async b=>{let k="";try{k=String((await b.req.json()).url??"")}catch{}if(!S1(k))return b.json({error:"a local http URL is required"},400);let P=[...A].find(N=>N.inEditor);return await P?.open(k),b.json({opened:!!P,pages:A.count})})),E.use("/__stop",L),E.post("/__stop",async b=>{if(b.req.header("sec-fetch-site")||b.req.header("origin"))return b.text("Forbidden: browser request",403);let k="close";try{let N=await b.req.json();(N?.pages==="keep"||N?.pages==="close")&&(k=N.pages)}catch{}let P=k==="close"?await A.closeAll("stopped"):{told:0,gone:0};return x&&setTimeout(()=>{x({pages:k})},50),b.json({closed:P.gone,stuck:P.told-P.gone,exiting:!!x})}),E.get("/__pages",b=>b.json({pages:A.count})),E.notFound(async b=>{if(b.req.method!=="GET")return b.text("Not Found",404);let k=new URL(b.req.url);return DS(k.pathname,k.search)?Ae(b,"https://esm.sh"+k.pathname+k.search):b.text("Not Found",404)});let Tt=h1({fetch:E.fetch,port:s,hostname:y1});return Tt.listening||await new Promise((b,k)=>{let P=N=>k(N);Tt.once("error",P),Tt.once("listening",()=>{Tt.removeListener("error",P),b()})}),{port:s,close:()=>Tt.close(),requestPage:Ie,closePages:b=>A.closeAll(b),pageCount:()=>A.count}}function ap(t,e){let n=new Headers;return t&&n.set("Content-Type",t),e&&n.set("Cache-Control",e),n.set("Access-Control-Allow-Origin","*"),n.set("Cross-Origin-Resource-Policy","cross-origin"),n}function US(t,e,n){t.get(`${e}*`,async r=>{let{pathname:s}=new URL(r.req.url);if(!s.startsWith(e))return r.text("Not Found",404);try{return await KS(decodeURIComponent(s.slice(e.length)),n)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function KS(t,e,n={}){let r=kr(t,e),s=await lp.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":Lp(r),...n}})}Le();fn();async function El(t){let{port:e,portNote:n,makeServerOptions:r,makeEntry:s,displayName:i,waitTarget:o,stopLog:a}=t,l=`http://localhost:${e}`,c=s(e,l),f=[],d,u=!1,p=async h=>{if(!u){u=!0,console.log(`
2942
+ Shutting down...`),(h?.pages??(ye(c)?"keep":"close"))==="close"&&await d?.closePages("stopped"),d?.close();for(let g of f)try{await g()}catch{}a(),await pn(process.pid),process.exit(0)}},m=await WS({...r(e),onStop:p}).catch(async h=>{if(h?.code!=="EADDRINUSE")throw h;return Fu(e)});return d=m,await Yu(c),console.log(`
2943
+ ${i}`),console.log(` ${l}`),n&&console.log(` ${n}`),process.on("SIGINT",()=>{p()}),process.on("SIGTERM",()=>{p()}),{port:e,url:l,pageCount:()=>m.pageCount(),async handOver({mode:h,fresh:g,replacedLive:x}){if(h==="none")return;let O={fresh:g,external:x?"never":h==="window"?"force":"follow"},C=await m.requestPage(O);C.how==="attached"?console.log(` Reusing the open browser tab.
2944
2944
  `):C.how==="editor"?console.log(` Opened in VS Code via ${C.via}.
2945
2945
  `):C.how==="external"?console.log(` Opened in your browser.
2946
2946
  `):console.log(` ${C.how==="unreached"?`Opened ${C.via?`in VS Code via ${C.via}`:"in your browser"}, but no page attached \u2014 is the browser it opened in still there?`:ye(c)?"No page opened \u2014 nothing is reading this mirror until someone opens it.":"No page opened \u2014 no agent mirror page to open one through, and a bulb runs in its page."}
2947
2947
  Share ${l}, and wake on the arrival:
2948
2948
  typebulb wait ${o} --match "${tt.connected}"
2949
- `)},onCleanup(h){f.push(h)}}}fn();import E1 from"chokidar";import WS from"node:fs";import A1 from"node:path";var T1={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function Zt(t){let{target:e,onChange:n,events:r="change",debounceMs:s=150}=t,i,o=E1.watch(e,T1);o.on("error",l=>console.warn(`watch: ${l instanceof Error?l.message:l} \u2014 continuing`));let a=()=>{i&&clearTimeout(i),i=setTimeout(n,s)};return r==="all"?o.on("all",a):o.on("change",a),()=>{i&&clearTimeout(i),o.close()}}var O1=t=>process.platform==="win32"||process.platform==="darwin"?t.toLowerCase()==="assets":t==="assets";function KS(t,e,n=150){let r,s=()=>{r&&clearTimeout(r),r=setTimeout(e,n)};try{let i=WS.watch(t,{recursive:!0},(o,a)=>{a&&O1(a.split(/[\\/]/)[0])&&s()});return i.on("error",o=>console.warn(`watch: ${o instanceof Error?o.message:o} \u2014 continuing`)),()=>{r&&clearTimeout(r),i.close()}}catch{let i=A1.join(t,"assets");return WS.existsSync(i)?Zt({target:i,onChange:e,events:"all",debounceMs:n}):()=>{}}}Le();Ye();vr();async function HS(t,e,n,r){e.port!==void 0&&(console.error("--port isn't supported when running a bulb: a bulb keeps its assigned project port across runs, and moving it strands the open tab."),console.error("It applies to `typebulb agent`. Run the bulb with no --port; `typebulb logs` prints the URL it kept."),process.exit(1));let s=process.cwd(),i=As(process.pid),o=e.watch?new P1:void 0,a=xe(e.mode),l=(await dn(process.cwd()))(t),c=await Zn({kind:"bulb",file:t},process.cwd()),f=await Xo(t,c);f.length&&console.log(`Replacing the running server for this bulb (pid ${f.map(pe=>pe.pid).join(", ")})`);let d=f.length>0||Date.now()-l<Kb,{port:u,note:p}=await Ho({target:{kind:"bulb",file:t},cwd:process.cwd()});c!==void 0&&u!==c&&d&&(console.error(`
2950
- Port ${c} is this bulb's, and a page of it may be waiting there, but something else took it.`),console.error("Free that port and relaunch; starting elsewhere would leave that page running with no way to reach it."),process.exit(1));let m=0,h=()=>console.log(Hu(++m));h(),console.log(`Loading ${$n.basename(t)}...`);let{html:g,bulb:E,serverExports:O}=await Wd(t,e.watch,e.trust,r);qt(a,t,E.server);let C=An(t),x=xr($n.resolve(t)),R=e.trust?void 0:or(E),{port:I,onCleanup:L,handOver:A,pageCount:U}=await El({port:u,portNote:p,displayName:E.name,stopLog:i,makeServerOptions:pe=>({getHtml:()=>g,basePath:s,fsBase:kr(t),port:pe,reloadEmitter:o,sendChannel:!0,getServerExports:()=>O,getBulbBlocks:()=>({infer:E.infer,insight:E.insight,code:E.code,config:E.config,data:E.data}),saveInferenceResult:async(Ie,ct)=>{let ue=await en.readFile(t,"utf-8");Ie!==void 0&&(ue=Mr(ue,"data",Ie.join(Lg))),ct!==void 0&&(ue=Mr(ue,"insight",ct)),await en.writeFile(t,ue)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dir:C,remoteBase:x&&Ti(x.userSlug,x.slug)},sourceFile:t,bulbKey:xs(t),trusted:e.trust,trustHint:n}),makeEntry:(pe,Ie)=>({pid:process.pid,port:pe,url:Ie,file:t,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,mode:e.mode,predicted:R}),waitTarget:$n.relative(process.cwd(),t)||$n.basename(t)});e.trust?console.log(" trust: granted (filesystem, AI, server.ts enabled)"):console.log(R?` trust: restricted \u2014 this bulb appears to use ${R}; re-run with --trust to enable it:
2949
+ `)},onCleanup(h){f.push(h)}}}fn();import A1 from"chokidar";import HS from"node:fs";import T1 from"node:path";var O1={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function Zt(t){let{target:e,onChange:n,events:r="change",debounceMs:s=150}=t,i,o=A1.watch(e,O1);o.on("error",l=>console.warn(`watch: ${l instanceof Error?l.message:l} \u2014 continuing`));let a=()=>{i&&clearTimeout(i),i=setTimeout(n,s)};return r==="all"?o.on("all",a):o.on("change",a),()=>{i&&clearTimeout(i),o.close()}}var P1=t=>process.platform==="win32"||process.platform==="darwin"?t.toLowerCase()==="assets":t==="assets";function zS(t,e,n=150){let r,s=()=>{r&&clearTimeout(r),r=setTimeout(e,n)};try{let i=HS.watch(t,{recursive:!0},(o,a)=>{a&&P1(a.split(/[\\/]/)[0])&&s()});return i.on("error",o=>console.warn(`watch: ${o instanceof Error?o.message:o} \u2014 continuing`)),()=>{r&&clearTimeout(r),i.close()}}catch{let i=T1.join(t,"assets");return HS.existsSync(i)?Zt({target:i,onChange:e,events:"all",debounceMs:n}):()=>{}}}Le();Ye();Sr();async function YS(t,e,n,r){e.port!==void 0&&(console.error("--port isn't supported when running a bulb: a bulb keeps its assigned project port across runs, and moving it strands the open tab."),console.error("It applies to `typebulb agent`. Run the bulb with no --port; `typebulb logs` prints the URL it kept."),process.exit(1));let s=process.cwd(),i=As(process.pid),o=e.watch?new C1:void 0,a=xe(e.mode),l=(await dn(process.cwd()))(t),c=await er({kind:"bulb",file:t},process.cwd()),f=await Xo(t,c);f.length&&console.log(`Replacing the running server for this bulb (pid ${f.map(he=>he.pid).join(", ")})`);let d=f.length>0||Date.now()-l<zb,{port:u,note:p}=await Ho({target:{kind:"bulb",file:t},cwd:process.cwd()});c!==void 0&&u!==c&&d&&(console.error(`
2950
+ Port ${c} is this bulb's, and a page of it may be waiting there, but something else took it.`),console.error("Free that port and relaunch; starting elsewhere would leave that page running with no way to reach it."),process.exit(1));let m=0,h=()=>console.log(Hu(++m));h(),console.log(`Loading ${$n.basename(t)}...`);let{html:g,bulb:x,serverExports:O}=await Wd(t,e.watch,e.trust,r);qt(a,t,x.server);let C=An(t),E=Er($n.resolve(t)),R=e.trust?void 0:ar(x),{port:I,onCleanup:L,handOver:A,pageCount:F}=await El({port:u,portNote:p,displayName:x.name,stopLog:i,makeServerOptions:he=>({getHtml:()=>g,basePath:s,fsBase:xr(t),port:he,reloadEmitter:o,sendChannel:!0,getServerExports:()=>O,getBulbBlocks:()=>({infer:x.infer,insight:x.insight,code:x.code,config:x.config,data:x.data}),saveInferenceResult:async(Ie,ct)=>{let de=await en.readFile(t,"utf-8");Ie!==void 0&&(de=Dr(de,"data",Ie.join(Lg))),ct!==void 0&&(de=Dr(de,"insight",ct)),await en.writeFile(t,de)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dir:C,remoteBase:E&&Ti(E.userSlug,E.slug)},sourceFile:t,bulbKey:xs(t),trusted:e.trust,trustHint:n}),makeEntry:(he,Ie)=>({pid:process.pid,port:he,url:Ie,file:t,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,mode:e.mode,predicted:R}),waitTarget:$n.relative(process.cwd(),t)||$n.basename(t)});e.trust?console.log(" trust: granted (filesystem, AI, server.ts enabled)"):console.log(R?` trust: restricted \u2014 this bulb appears to use ${R}; re-run with --trust to enable it:
2951
2951
  ${n}
2952
2952
  `:` trust: restricted \u2014 re-run with --trust to enable filesystem / AI / server.ts
2953
2953
  `),e.watch&&console.log(` Watching for changes...
2954
- `);let Q,G,F=()=>{U()===0&&console.log(" No page attached \u2014 nothing reloaded; this change is not live."),o?.emit("reload")},me=pe=>{console.log(pe),h(),F()};if(e.watch&&o){let pe=0,Ie=Promise.resolve();if(Q=Zt({target:t,onChange:()=>{let ue=++pe;Ie=Ie.then(async()=>{if(ue===pe)try{console.log("Recompiling...");let Ae=await Wd(t,!0,e.trust,r);g=Ae.html,O=Ae.serverExports,E=Ae.bulb,Ae.buildError||h(),F()}catch(Ae){console.error("Recompile failed:",Ae)}})}}),r){let{name:ue,serveDir:Ae}=r;G=Zt({target:Ae,events:"all",onChange:()=>me(`Local package '${ue}' changed.`)})}let ct=kr(t);await en.stat(ct).then(ue=>ue.isDirectory()).catch(()=>!1)&&L(KS(ct,()=>me("Assets changed.")))}Q&&L(Q),G&&L(G),L(()=>en.rm(Jd(t),{force:!0})),await A({mode:e.open,fresh:!d,replacedLive:f.some(pe=>pe.port===I)})}ot();import{readFileSync as up,copyFileSync as _1,existsSync as R1}from"fs";import*as fe from"path";import{fileURLToPath as I1}from"url";import{EventEmitter as N1}from"events";import $1 from"open";fn();Le();vr();var cp=t=>`/agents/${t}/client.js`,C1=`
2954
+ `);let Z,te,U=()=>{F()===0&&console.log(" No page attached \u2014 nothing reloaded; this change is not live."),o?.emit("reload")},ne=he=>{console.log(he),h(),U()};if(e.watch&&o){let he=0,Ie=Promise.resolve();if(Z=Zt({target:t,onChange:()=>{let de=++he;Ie=Ie.then(async()=>{if(de===he)try{console.log("Recompiling...");let Ae=await Wd(t,!0,e.trust,r);g=Ae.html,O=Ae.serverExports,x=Ae.bulb,Ae.buildError||h(),U()}catch(Ae){console.error("Recompile failed:",Ae)}})}}),r){let{name:de,serveDir:Ae}=r;te=Zt({target:Ae,events:"all",onChange:()=>ne(`Local package '${de}' changed.`)})}let ct=xr(t);await en.stat(ct).then(de=>de.isDirectory()).catch(()=>!1)&&L(zS(ct,()=>ne("Assets changed.")))}Z&&L(Z),te&&L(te),L(()=>en.rm(Jd(t),{force:!0})),await A({mode:e.open,fresh:!d,replacedLive:f.some(he=>he.port===I)})}ot();import{readFileSync as up,copyFileSync as R1,existsSync as I1}from"fs";import*as pe from"path";import{fileURLToPath as N1}from"url";import{EventEmitter as $1}from"events";import L1 from"open";fn();Le();Sr();var cp=t=>`/agents/${t}/client.js`,_1=`
2955
2955
  (() => {
2956
2956
  const api = async (name, ...args) => {
2957
2957
  const resp = await fetch('/__api/' + name, {
@@ -2983,7 +2983,7 @@ Port ${c} is this bulb's, and a page of it may be waiting there, but something e
2983
2983
  ${Ea()}
2984
2984
  }
2985
2985
  })();
2986
- `;function zS(t){let{name:e,agent:n,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=t,l=cp(n);return`<!DOCTYPE html>
2986
+ `;function VS(t){let{name:e,agent:n,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=t,l=cp(n);return`<!DOCTYPE html>
2987
2987
  <html>
2988
2988
  <head>
2989
2989
  <meta charset="utf-8">
@@ -2991,7 +2991,7 @@ ${Ea()}
2991
2991
  <title>${ka(e)} - typebulb</title>
2992
2992
  ${xa(e,a)}
2993
2993
  <style>
2994
- ${ys}
2994
+ ${bs}
2995
2995
  </style>
2996
2996
  <style>
2997
2997
  ${r}
@@ -3006,18 +3006,18 @@ ${i}
3006
3006
  ${o?"<script>window.__TYPEBULB_WATCH__ = true;</script>":""}
3007
3007
 
3008
3008
  <script>
3009
- ${C1}
3009
+ ${_1}
3010
3010
  </script>
3011
3011
 
3012
3012
  <script type="module" src="${l}"></script>
3013
3013
  </body>
3014
- </html>`}async function YS(t){let e=process.cwd(),n=t.agentTarget;Mv(n)||(console.error(`Unknown agent '${n}'. Known: ${_r().join(", ")}.`),process.exit(1));let r=await Go(e,n);if(r){console.log(`Mirror '${n}' is already running for this project:
3015
- ${r.url}`),t.open==="window"&&await $1(r.url);return}let s=As(process.pid),i=t.watch?new N1:void 0,o=xe(t.mode),a=await Dv(n),l=a.displayName||`${n} mirror`;qt(o,fe.join(e,"mirror"));let c=fe.dirname(I1(import.meta.url)),f=fe.join(c,"agents",n),d=fe.join(c,"..","cli","agents"),u=fe.join(f,"styles.css"),p=fe.join(f,"katex.min.css"),m=fe.join(f,"index.html"),h=()=>zS({name:l,agent:n,styles:up(u,"utf8"),katex:up(p,"utf8"),mountHtml:up(m,"utf8"),watch:t.watch}),{port:g,note:E}=await Ho({explicit:t.port,target:{kind:"mirror",agent:n},cwd:e}),{port:O,url:C,onCleanup:x,handOver:R,pageCount:I}=await El({port:g,portNote:E,displayName:l,stopLog:s,waitTarget:"agent",makeServerOptions:G=>({getHtml:h,basePath:e,port:G,reloadEmitter:i,getServerExports:()=>a,trusted:!0,staticAssets:{mount:`${fe.posix.dirname(cp(n))}/`,dir:f}}),makeEntry:(G,F)=>({pid:process.pid,port:G,url:F,file:`agent:${n}`,cwd:e,startedAt:Date.now(),trust:!0,agent:n})});t.watch&&console.log(` Watching for changes...
3016
- `);let L=fe.join(d,n,"client"),A=fe.join(d,"core","client");async function U(){await(await import("esbuild")).build({entryPoints:[fe.join(L,"index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:fe.join(f,"client.js")});for(let F of["styles.css","index.html","typebulb.png","typebulb-inv.png"])_1(fe.join(A,F),fe.join(f,F))}let Q;if(t.watch&&i){let G=R1(L),F=!1;Q=Zt({target:G?d:f,events:"all",onChange:async()=>{if(!F){F=!0;try{G&&await U(),console.log(I()?`Mirror rebuilt. Reloading.
3014
+ </html>`}async function GS(t){let e=process.cwd(),n=t.agentTarget;Bv(n)||(console.error(`Unknown agent '${n}'. Known: ${Rr().join(", ")}.`),process.exit(1));let r=await Go(e,n);if(r){console.log(`Mirror '${n}' is already running for this project:
3015
+ ${r.url}`),t.open==="window"&&await L1(r.url);return}let s=As(process.pid),i=t.watch?new $1:void 0,o=xe(t.mode),a=await jv(n),l=a.displayName||`${n} mirror`;qt(o,pe.join(e,"mirror"));let c=pe.dirname(N1(import.meta.url)),f=pe.join(c,"agents",n),d=pe.join(c,"..","cli","agents"),u=pe.join(f,"styles.css"),p=pe.join(f,"katex.min.css"),m=pe.join(f,"index.html"),h=()=>VS({name:l,agent:n,styles:up(u,"utf8"),katex:up(p,"utf8"),mountHtml:up(m,"utf8"),watch:t.watch}),{port:g,note:x}=await Ho({explicit:t.port,target:{kind:"mirror",agent:n},cwd:e}),{port:O,url:C,onCleanup:E,handOver:R,pageCount:I}=await El({port:g,portNote:x,displayName:l,stopLog:s,waitTarget:"agent",makeServerOptions:U=>({getHtml:h,basePath:e,port:U,reloadEmitter:i,getServerExports:()=>a,trusted:!0,staticAssets:{mount:`${pe.posix.dirname(cp(n))}/`,dir:f}}),makeEntry:(U,ne)=>({pid:process.pid,port:U,url:ne,file:`agent:${n}`,cwd:e,startedAt:Date.now(),trust:!0,agent:n})}),L=pe.join(d,n,"client"),A=pe.join(d,"core","client"),F=I1(L);t.watch&&F&&console.log(` Watching for changes...
3016
+ `);async function Z(){await(await import("esbuild")).build({entryPoints:[pe.join(L,"index.ts")],bundle:!0,platform:"browser",format:"esm",outfile:pe.join(f,"client.js")});for(let ne of["styles.css","index.html","typebulb.png","typebulb-inv.png"])R1(pe.join(A,ne),pe.join(f,ne))}let te;if(t.watch&&F&&i){let U=!1;te=Zt({target:d,events:"all",onChange:async()=>{if(!U){U=!0;try{await Z(),console.log(I()?`Mirror rebuilt. Reloading.
3017
3017
  `:`Mirror rebuilt. No tab open on it \u2014 nobody is reading this.
3018
- `),i.emit("reload")}catch(me){console.error("Mirror rebuild failed:",me instanceof Error?me.message:me)}finally{F=!1}}}})}await R({mode:t.open,fresh:!1,replacedLive:!1}),x(()=>a.shutdownSwitcher?.()),x(()=>a.shutdownComposer?.()),Q&&x(Q)}ot();St();import*as VS from"path";async function GS(t,e,n,r){let s=xe(n),i=!1,o=async()=>{let{bulb:a,config:l}=await Ze(t);i||(qt(s,t,a.server),i=!0),await Hs(a.server,t,r,l.dependencies)};if(console.log(`Running ${VS.basename(t)}...`),await o(),e){console.log(`Watching for changes...
3019
- `);let a=0,l=Promise.resolve();Zt({target:t,onChange:()=>{let c=++a;l=l.then(async()=>{if(c===a)try{console.log("Re-running..."),await o()}catch(f){console.error("Error:",f)}})}})}}ot();St();import{Console as L1}from"node:console";Le();async function ZS(t,e,n,r){F1();try{let u=hn(await Z(),t)[0];u&&(Es(u.pid,Ve(u.pid).offset),console.error(`note: 'call' boots a fresh server.ts instance; the running server (${u.url}) is not contacted \u2014 state shared with it must live on disk.`))}catch{}let s=xe(n),{bulb:i,config:o}=await Ze(t);i.server||bi("This bulb has no **server.ts** block; nothing to call."),qt(s,t,i.server);let a;try{a=await Hs(i.server,t,r,o.dependencies)}catch(u){bi(u instanceof Error?u.message:String(u))}let l=kl(a,e.fn);if(!l){let u=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(Sl)];bi(`Function '${e.fn}' not found. Available: ${u.length?u.join(", "):"(none)"}.`)}let c=await M1(e);if(xl(l)){try{for await(let u of l(...c))await QS(JSON.stringify(u,ek)+`
3020
- `)}catch(u){bi(u instanceof Error?u.stack??u.message:String(u))}return XS(0)}let f;try{f=await l(...c)}catch(u){bi(u instanceof Error?u.stack??u.message:String(u))}let d=j1(f);d!==void 0&&await QS(d+`
3021
- `),XS(0)}function XS(t){process.exitCode=t,setTimeout(()=>process.exit(t),2e3).unref?.()}async function M1(t){if(t.hasArgsFlag){let e=t.argsJson??"";return e==="-"&&(e=await $r()),B1(e)}return D1(t.positional)}function D1(t){return t.map(e=>{try{return JSON.parse(e)}catch{return e}})}function B1(t){let e;try{e=JSON.parse(t)}catch(n){throw new Error(`--args must be a JSON array: ${n instanceof Error?n.message:String(n)}`)}if(!Array.isArray(e))throw new Error(`--args must be a JSON array, got ${e===null?"null":typeof e}`);return e}function j1(t){if(t!==void 0)return JSON.stringify(t,ek,2)}function ek(t,e){return typeof e=="bigint"?e.toString():e}function bi(t){process.stderr.write(t+`
3022
- `),process.exit(1)}function F1(){let t=new L1(process.stderr,process.stderr);console.log=t.log.bind(t),console.info=t.info.bind(t),console.debug=t.debug.bind(t),console.dir=t.dir.bind(t)}function QS(t){return new Promise((e,n)=>{process.stdout.write(t,r=>r?n(r):e())})}zo();for(let t of[process.stdout,process.stderr])t.on("error",e=>{if(e?.code!=="EPIPE")throw e});function tk(t,e){t||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
3023
- ${e}`),process.exit(1))}async function U1(){let t=Fv(process.argv.slice(2));if(t.version&&(console.log(`typebulb ${Me}`),process.exit(0)),t.help&&(Uv(),process.exit(0)),Bv(),t.subcommand==="logs"){await vS(t.file||void 0,{follow:t.follow,clear:t.clear,run:t.run,lines:t.lines});return}if(t.subcommand==="wait"){await SS(t.file||void 0,{match:t.match,timeoutSec:t.timeoutSec});return}if(t.subcommand==="stop"){t.stopScope?await ES(t.stopScope):await xS(t.file||void 0);return}if(t.subcommand==="send"){await TS(t.file,t.sendMessage,t.sendWaitMs??0);return}if(t.subcommand==="models"){await pS(t.mode);return}if(t.subcommand==="slug"){hS(t.slugName);return}if(t.subcommand==="status"){await IS(t.statusQuery,t.mode);return}if(t.subcommand==="pull"){await nw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="push"){await sw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="agent"){await(t.agentTarget?YS(t):fS(Me));return}if(t.subcommand==="trust"||t.subcommand==="untrust"){await lS(t.file||void 0,t.subcommand==="trust");return}let e;if(!t.file||t.file==="."){let l=await ew(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=At.resolve(t.file);if(await nk.access(e).then(()=>!0,()=>!1)||(_r().includes(t.file)&&(console.error(`To open the ${t.file} agent mirror, run: npx typebulb agent:${t.file}`),process.exit(1)),console.error(`File not found: ${e}`+(At.isAbsolute(t.file)?"":` (resolved from cwd ${process.cwd()})`)),process.exit(1)),e.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1)),t.subcommand==="get"){await PS(e,t.blockKind);return}if(t.subcommand==="put"){await RS(e,t.blockPairs);return}let r=t.file&&t.file!=="."?t.file:At.relative(process.cwd(),e)||At.basename(e),s=`npx typebulb --trust ${r.includes(" ")?`"${r}"`:r}`;if(t.subcommand==="predict"){await aS(e,s);return}let i=!t.noTrust&&yn(e);i&&!t.trust&&console.error("trust: granted from memory (run `typebulb untrust` to revoke)"),t.trust=t.noTrust?!1:t.trust||i;let o;try{o=await Ze(e)}catch{}let a;if(t.local){o&&!(t.local.name in(o.config.dependencies??{}))&&(console.error(`--replace: '${t.local.name}' is not a dependency in this bulb's config.json; nothing to replace.`),process.exit(1)),o&&t.subcommand!=="call"&&(!o.bulb.code||t.server)&&console.warn("warning: --replace has no effect in server mode (the override is client-only).");try{a=await wp(t.local)}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.error(`replace: ${a.name} \u2192 ${At.relative(process.cwd(),a.dir)||"."}`)}if(t.subcommand==="check"){await oS(e,a);return}if(t.subcommand==="call"){tk(t.trust,s),await ZS(e,{fn:t.fn,positional:t.callArgs,argsJson:t.argsJson,hasArgsFlag:t.hasArgsFlag},t.mode,a);return}if(o&&o.bulb.server&&(Qo(o.bulb)||t.server)){tk(t.trust,s),await GS(e,t.watch,t.mode,a);return}await HS(e,t,s,a)}U1().catch(t=>{console.error("Error:",t.message),process.exit(1)});
3018
+ `),i.emit("reload")}catch(ne){console.error("Mirror rebuild failed:",ne instanceof Error?ne.message:ne)}finally{U=!1}}}})}await R({mode:t.open,fresh:!1,replacedLive:!1}),E(()=>a.shutdownSwitcher?.()),E(()=>a.shutdownComposer?.()),te&&E(te)}ot();St();import*as XS from"path";async function QS(t,e,n,r){let s=xe(n),i=!1,o=async()=>{let{bulb:a,config:l}=await Ze(t);i||(qt(s,t,a.server),i=!0),await Hs(a.server,t,r,l.dependencies)};if(console.log(`Running ${XS.basename(t)}...`),await o(),e){console.log(`Watching for changes...
3019
+ `);let a=0,l=Promise.resolve();Zt({target:t,onChange:()=>{let c=++a;l=l.then(async()=>{if(c===a)try{console.log("Re-running..."),await o()}catch(f){console.error("Error:",f)}})}})}}ot();St();import{Console as M1}from"node:console";Le();async function tk(t,e,n,r){U1();try{let u=hn(await X(),t)[0];u&&(Es(u.pid,Ve(u.pid).offset),console.error(`note: 'call' boots a fresh server.ts instance; the running server (${u.url}) is not contacted \u2014 state shared with it must live on disk.`))}catch{}let s=xe(n),{bulb:i,config:o}=await Ze(t);i.server||bi("This bulb has no **server.ts** block; nothing to call."),qt(s,t,i.server);let a;try{a=await Hs(i.server,t,r,o.dependencies)}catch(u){bi(u instanceof Error?u.message:String(u))}let l=kl(a,e.fn);if(!l){let u=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(Sl)];bi(`Function '${e.fn}' not found. Available: ${u.length?u.join(", "):"(none)"}.`)}let c=await D1(e);if(xl(l)){try{for await(let u of l(...c))await ek(JSON.stringify(u,nk)+`
3020
+ `)}catch(u){bi(u instanceof Error?u.stack??u.message:String(u))}return ZS(0)}let f;try{f=await l(...c)}catch(u){bi(u instanceof Error?u.stack??u.message:String(u))}let d=F1(f);d!==void 0&&await ek(d+`
3021
+ `),ZS(0)}function ZS(t){process.exitCode=t,setTimeout(()=>process.exit(t),2e3).unref?.()}async function D1(t){if(t.hasArgsFlag){let e=t.argsJson??"";return e==="-"&&(e=await Lr()),j1(e)}return B1(t.positional)}function B1(t){return t.map(e=>{try{return JSON.parse(e)}catch{return e}})}function j1(t){let e;try{e=JSON.parse(t)}catch(n){throw new Error(`--args must be a JSON array: ${n instanceof Error?n.message:String(n)}`)}if(!Array.isArray(e))throw new Error(`--args must be a JSON array, got ${e===null?"null":typeof e}`);return e}function F1(t){if(t!==void 0)return JSON.stringify(t,nk,2)}function nk(t,e){return typeof e=="bigint"?e.toString():e}function bi(t){process.stderr.write(t+`
3022
+ `),process.exit(1)}function U1(){let t=new M1(process.stderr,process.stderr);console.log=t.log.bind(t),console.info=t.info.bind(t),console.debug=t.debug.bind(t),console.dir=t.dir.bind(t)}function ek(t){return new Promise((e,n)=>{process.stdout.write(t,r=>r?n(r):e())})}zo();for(let t of[process.stdout,process.stderr])t.on("error",e=>{if(e?.code!=="EPIPE")throw e});function rk(t,e){t||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
3023
+ ${e}`),process.exit(1))}async function q1(){let t=qv(process.argv.slice(2));if(t.version&&(console.log(`typebulb ${Me}`),process.exit(0)),t.help&&(Jv(),process.exit(0)),Fv(),t.subcommand==="logs"){await kS(t.file||void 0,{follow:t.follow,clear:t.clear,run:t.run,lines:t.lines});return}if(t.subcommand==="wait"){await xS(t.file||void 0,{match:t.match,timeoutSec:t.timeoutSec});return}if(t.subcommand==="stop"){t.stopScope?await TS(t.stopScope):await AS(t.file||void 0);return}if(t.subcommand==="send"){await PS(t.file,t.sendMessage,t.sendWaitMs??0);return}if(t.subcommand==="models"){await mS(t.mode);return}if(t.subcommand==="slug"){gS(t.slugName);return}if(t.subcommand==="status"){await $S(t.statusQuery,t.mode);return}if(t.subcommand==="pull"){await sw(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="push"){await ow(t.file||void 0,{force:t.force,mode:t.mode});return}if(t.subcommand==="agent"){await(t.agentTarget?GS(t):hS(Me));return}if(t.subcommand==="trust"||t.subcommand==="untrust"){await uS(t.file||void 0,t.subcommand==="trust");return}let e;if(!t.file||t.file==="."){let l=await nw(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=At.resolve(t.file);if(await sk.access(e).then(()=>!0,()=>!1)||(Rr().includes(t.file)&&(console.error(`To open the ${t.file} agent mirror, run: npx typebulb agent:${t.file}`),process.exit(1)),console.error(`File not found: ${e}`+(At.isAbsolute(t.file)?"":` (resolved from cwd ${process.cwd()})`)),process.exit(1)),e.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1)),t.subcommand==="get"){await _S(e,t.blockKind);return}if(t.subcommand==="put"){await NS(e,t.blockPairs);return}let r=t.file&&t.file!=="."?t.file:At.relative(process.cwd(),e)||At.basename(e),s=`npx typebulb --trust ${r.includes(" ")?`"${r}"`:r}`;if(t.subcommand==="predict"){await cS(e,s);return}let i=!t.noTrust&&yn(e);i&&!t.trust&&console.error("trust: granted from memory (run `typebulb untrust` to revoke)"),t.trust=t.noTrust?!1:t.trust||i;let o;try{o=await Ze(e)}catch{}let a;if(t.local){o&&!(t.local.name in(o.config.dependencies??{}))&&(console.error(`--replace: '${t.local.name}' is not a dependency in this bulb's config.json; nothing to replace.`),process.exit(1)),o&&t.subcommand!=="call"&&(!o.bulb.code||t.server)&&console.warn("warning: --replace has no effect in server mode (the override is client-only).");try{a=await wp(t.local)}catch(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.error(`replace: ${a.name} \u2192 ${At.relative(process.cwd(),a.dir)||"."}`)}if(t.subcommand==="check"){await lS(e,a);return}if(t.subcommand==="call"){rk(t.trust,s),await tk(e,{fn:t.fn,positional:t.callArgs,argsJson:t.argsJson,hasArgsFlag:t.hasArgsFlag},t.mode,a);return}if(o&&o.bulb.server&&(Qo(o.bulb)||t.server)){rk(t.trust,s),await QS(e,t.watch,t.mode,a);return}await YS(e,t,s,a)}q1().catch(t=>{console.error("Error:",t.message),process.exit(1)});