typebulb 0.61.8 → 0.61.10

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,176 +1,176 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
3
- var ok=Object.create;var xl=Object.defineProperty;var ak=Object.getOwnPropertyDescriptor;var lk=Object.getOwnPropertyNames;var ck=Object.getPrototypeOf,uk=Object.prototype.hasOwnProperty;var bi=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var k=(n,e)=>()=>(n&&(e=n(n=0)),e);var _=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),wi=(n,e)=>{for(var t in e)xl(n,t,{get:e[t],enumerable:!0})},dk=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of lk(e))!uk.call(n,s)&&s!==t&&xl(n,s,{get:()=>e[s],enumerable:!(r=ak(e,s))||r.enumerable});return n};var fk=(n,e,t)=>(t=n!=null?ok(ck(n)):{},dk(e||!n||!n.__esModule?xl(t,"default",{value:n,enumerable:!0}):t,n));import*as up from"fs/promises";import{existsSync as Ln,readFileSync as pk}from"fs";import*as se from"path";import{pathToFileURL as hk}from"url";import{resolve as Al}from"resolve.exports";import{init as dp,parse as fp}from"es-module-lexer";function pp(n,e){let t=se.join(n,"package.json");try{return JSON.parse(pk(t,"utf8"))}catch{throw new Error(`--replace package '${e}' has no readable package.json at ${t}`)}}function hp(n){let e=n.indexOf("=");if(e===-1)throw new Error(`--replace must be <name>=<path> (got '${n}')`);let t=n.slice(0,e).trim(),r=n.slice(e+1).trim();if(!t)throw new Error(`--replace missing package name (got '${n}')`);if(!r)throw new Error(`--replace missing path for '${t}'`);if(t.startsWith("@"))throw new Error(`--replace does not support scoped names yet; '${t}' is scoped`);return{name:t,dir:se.resolve(r)}}async function mp(n){let{name:e,dir:t}=n;if(!Ln(t))throw new Error(`--replace path for '${e}' does not exist: ${t}`);let r=pp(t,e),s=mk(r,e),i=se.resolve(t,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=gk(r,t);return await yk(e,i,o),{name:e,dir:t,entryAbs:i,serveDir:o,entryUrl:a,typesAbs:l}}function mk(n,e){if(n.exports!==void 0){let r;try{r=Al(n,".",{browser:!0,conditions:El})}catch(i){throw new Error(`--replace package '${e}' "exports" does not resolve a browser entry (conditions: ${El.join(", ")}): ${i instanceof Error?i.message:i}`)}let s=Tl(r);if(!s)throw new Error(`--replace package '${e}' "exports" did not resolve "." to a single file (conditions: ${El.join(", ")}); too complex to override.`);return s}let t=n.module??n.main;if(!t)throw new Error(`--replace package '${e}' has no "exports", "module", or "main" entry to resolve.`);return t}function gk(n,e){if(n.exports!==void 0)try{let r=Al(n,".",{conditions:["types"]}),s=Tl(r);if(s){let i=se.resolve(e,s);if(Ln(i))return i}}catch{}let t=n.types??n.typings;if(t){let r=se.resolve(e,t);if(Ln(r))return r}}function Tl(n){if(typeof n=="string")return n;if(Array.isArray(n))return n.find(e=>typeof e=="string")}async function yk(n,e,t){await dp;let r=se.normalize(t),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 up.readFile(o,"utf8")}catch{continue}let l,c;try{[l,,,c]=fp(a,o)}catch{continue}if(o===e&&!c)throw new Error(`override package '${n}' 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=bk(o,d,r);u&&!s.has(u)&&i.push(u);continue}throw new Error(`override package must ship self-contained (bundle its dependencies); ${n} externalizes '${d}'`)}}}}function bk(n,e,t){let r=e.replace(/[?#].*$/,""),s=se.resolve(se.dirname(n),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(t)&&Ln(o))return o}function wk(n,e,t){let r=pp(n,e),s;if(r.exports!==void 0)try{s=Tl(Al(r,t,{conditions:cp}))}catch(o){throw new Error(`--replace package '${e}' "exports" does not resolve a node entry for '${t}' (conditions: ${cp.join(", ")}): ${o instanceof Error?o.message:o}`)}else t==="."&&(s=r.main??r.module);if(!s)throw new Error(`--replace package '${e}' has no node export for '${t}'.`);let i=se.resolve(n,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 hk(i).href}async function gp(n,e){await dp;let t;try{[t]=fp(n)}catch{return n}let r="",s=0;for(let i of t){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=wk(e.dir,e.name,a);r+=n.slice(s,i.s)+l,s=i.e}return r+n.slice(s)}var El,cp,vi=k(()=>{"use strict";El=["browser","import","default"],cp=["node","import","default"]});function yp(n){return Je.find(e=>le[e].path===n)}function wp(n){return!!n?.startsWith("typebulb")}var le,Je,bp,Si=k(()=>{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"];bp="typebulb/v1"});function Ol(n){return/[:\n"']/.test(n)||n.startsWith(" ")||n.endsWith(" ")?`"${n.replace(/"/g,'\\"')}"`:n}function Pl(n){return n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1).replace(/\\"/g,'"'):n.startsWith("'")&&n.endsWith("'")?n.slice(1,-1):n}var ki=k(()=>{});function Mn(n){let e=Sp(n);if("reason"in e)throw new Error(`Invalid .bulb.md file format: ${e.reason}`);return e.bulb}function We(n){let e=Sp(n);return"bulb"in e?e.bulb:void 0}function Sp(n){try{let e=n.split(`
4
- `),t=0;if(e[t]?.trim()!=="---")return{reason:Sk(n,e)};t++;let r=[];for(;t<e.length&&e[t]?.trim()!=="---";)r.push(e[t]),t++;if(e[t]?.trim()!=="---")return{reason:"the frontmatter opened on line 1 but never closed (no second '---')"};t++;let s=Ek(r);if(!wp(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=t;for(;t<e.length;){let d=e[t]?.trim()?.match(vp);if(d){let u=d[1].trim();for(t++;t<e.length&&e[t]?.trim()==="";)t++;let p=e[t]?.match(xi);if(!p){l.push(`**${u}** has no code fence \u2014 block skipped`);continue}let m=p[1];t++;let h=t+1,y=[],v=Cl(m);for(;t<e.length&&!e[t]?.match(v);)y.push(e[t]),t++;let O=t<e.length;t++,l.push(...kk(u,y,O)),o.set(u,y.join(`
5
- `)),a.set(u,h),c=t}else t++}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 Sk(n,e){let t=Ak(n)[0];if(t&&t.start>0)return`expected '---' on line 1; the frontmatter starts on line ${t.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 kk(n,e,t){let r=[];for(let s=0;s<e.length;s++){let i=e[s]?.trim().match(vp);i&&vk.has(i[1].trim())&&xk(e,s)&&r.push(i[1].trim())}return r.length?r.map(s=>`**${n}** block has an unterminated code fence \u2014 it swallowed the **${s}** block.`):t?[]:[`**${n}** block has an unterminated code fence (it runs to the end of the file).`]}function xk(n,e){let t=e+1;for(;t<n.length&&n[t]?.trim()==="";)t++;return!!n[t]?.match(xi)}function Ek(n){let e={};for(let t of n){let r=t.indexOf(":");if(r===-1)continue;let s=t.slice(0,r).trim(),i=t.slice(r+1).trim();switch(s){case"format":e.format=i;break;case"name":e.name=Pl(i);break}}return e}function kp(n){return We(n)?.warnings??[]}function Ak(n){let e=n.split(`
6
- `),t=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s=We(e.slice(r).join(`
7
- `));if(s&&s.files.size>0){let i=r+s.bodyEndLine;t.push({start:r,end:i,source:e.slice(r,i).join(`
8
- `)}),r=i}else r++}return t}function xp(n){let e=Object.fromEntries(Je.map(t=>[t,n.files.get(le[t].path)||""]));return{name:n.frontmatter.name,...e}}var vp,xi,vk,Cl,_l=k(()=>{Si();ki();vp=/^\*\*(.+)\*\*$/,xi=/^(`{3,})(\w*)\s*$/,vk=new Set(Je.map(n=>le[n].path)),Cl=n=>new RegExp(`^${n}\\s*$`)});function Ep(n){let e=n.match(/^`{3,}/gm),t=e?Math.max(...e.map(r=>r.length)):0;return"`".repeat(Math.max(3,t+1))}function Ap(n,e){let{path:t}=le[n],r=t.split(".").pop(),s=Ep(e);return`**${t}**
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(`
6
+ `),n=[],r=0;for(;r<e.length;){if(e[r]?.trim()!=="---"){r++;continue}let s=We(e.slice(r).join(`
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}**
9
9
 
10
10
  ${s}${r}
11
11
  ${e}
12
- ${s}`}function Tp(n){let e=Je.filter(t=>n[t]).map(t=>Ap(t,n[t]));return["---",`format: ${bp}`,`name: ${Ol(n.name)}`,"---","",...e].join(`
13
- `)}function Op(n,e){for(let t=0;t<n.length;t++){if(n[t]?.trim()!==`**${e}**`)continue;let r=t+1;for(;r<n.length&&n[r]?.trim()==="";)r++;let s=n[r]?.match(xi);if(!s)continue;let i=Cl(s[1]),o=r+1;for(;o<n.length&&!n[o]?.match(i);)o++;return o>=n.length?"unterminated":{header:t,open:r,close:o,fence:s[1],lang:s[2]}}}function Lr(n,e,t){let r=n.split(`
14
- `),s=Op(r,le[e].path);if(s==="unterminated")return n;if(!s)return`${n.replace(/\s*$/,"")}
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*$/,"")}
15
15
 
16
- ${Ap(e,t)}
17
- `;let i=Ep(t),o=i.length>s.fence.length?i:s.fence;return[...r.slice(0,s.open),o+s.lang,...t.split(`
16
+ ${Cp(e,n)}
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
- `)}function Pp(n,e){let t=n.split(`
20
- `),r=Op(t,le[e].path);if(!r||r==="unterminated")return n;let s=r.close+1;for(;s<t.length&&t[s]?.trim()==="";)s++;return[...t.slice(0,r.header),...t.slice(s)].join(`
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(`
21
21
  `).replace(/\s*$/,"")+`
22
- `}var Cp=k(()=>{Si();_l();ki()});function Mr(n){if(!n.trim())return{};try{return JSON.parse(n)}catch{return{}}}function Rp(n){switch(_p(n)){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 Ip(n){let e=_p(n);return e!==void 0&&Ok.has(e)?e:void 0}function Ck(n){return n.replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"")}function Rl(n){let e=Mr(n??"").description?.trim();if(!e)return Pk;let t=Ck(e);return(t.length>200?t.slice(0,197)+"...":t).replace(/\n/g," ")}var Tk,Ei,_p,Ok,Pk,Np=k(()=>{Tk="https://assets.typebulb.com",Ei=(n,e)=>`${Tk}/u/${encodeURIComponent(n)}/${encodeURIComponent(e)}/`,_p=n=>/\.[^./\\]+$/.exec(n)?.[0]?.toLowerCase();Ok=new Set([".html",".htm",".xhtml",".js",".mjs",".cjs",".ts",".tsx",".css"]);Pk="A Typebulb bulb."});var $p=k(()=>{});function Il(n,e,t){let s=new RegExp(e).exec(n.slice(t));return s?t+s.index:-1}var Lp=k(()=>{});function Dr(n,e,t){let s=new RegExp(e).exec(n.slice(t));return s?t+s.index+s[0].length-1:-1}var Mp=k(()=>{});function Ai(n,e){let t=new RegExp(e,"g"),r=n.match(t);return r?r.length:0}var Dp=k(()=>{});function Br(n,e,t){let r=t&&t.debug||!1,s=!(t&&typeof t.nested===!1),i=t&&t.startIndex||0;r&&console.log("[xml-utils] starting findTagByName with",e," and ",t);let o=Il(n,`<${e}[
23
- >/]`,i);if(r&&console.log("[xml-utils] start:",o),o===-1)return;let a=n.slice(o+e.length),l=Dr(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=Dr(a,"[ /]"+e+">",p))!==-1;){let y=a.substring(p,l+1);if(m+=Ai(y,"<"+e+`[
24
- >]`),h+=Ai(y,"</"+e+">"),h>=m)break;p=l}}else l=Dr(a,"[ /]"+e+">",0);let f=o+e.length+l+1;if(r&&console.log("[xml-utils] end:",f),f===-1)return;let d=n.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 Nl=k(()=>{Lp();Mp();Dp()});var $l=k(()=>{Nl()});var Ll=k(()=>{$l()});var Bp=k(()=>{Ll()});var jp=k(()=>{});var Fp=k(()=>{$p();Nl();$l();Bp();Ll();jp()});var W=_(de=>{"use strict";var Ml=Symbol.for("yaml.alias"),Up=Symbol.for("yaml.document"),Ti=Symbol.for("yaml.map"),qp=Symbol.for("yaml.pair"),Dl=Symbol.for("yaml.scalar"),Oi=Symbol.for("yaml.seq"),dt=Symbol.for("yaml.node.type"),Ik=n=>!!n&&typeof n=="object"&&n[dt]===Ml,Nk=n=>!!n&&typeof n=="object"&&n[dt]===Up,$k=n=>!!n&&typeof n=="object"&&n[dt]===Ti,Lk=n=>!!n&&typeof n=="object"&&n[dt]===qp,Jp=n=>!!n&&typeof n=="object"&&n[dt]===Dl,Mk=n=>!!n&&typeof n=="object"&&n[dt]===Oi;function Wp(n){if(n&&typeof n=="object")switch(n[dt]){case Ti:case Oi:return!0}return!1}function Dk(n){if(n&&typeof n=="object")switch(n[dt]){case Ml:case Ti:case Dl:case Oi:return!0}return!1}var Bk=n=>(Jp(n)||Wp(n))&&!!n.anchor;de.ALIAS=Ml;de.DOC=Up;de.MAP=Ti;de.NODE_TYPE=dt;de.PAIR=qp;de.SCALAR=Dl;de.SEQ=Oi;de.hasAnchor=Bk;de.isAlias=Ik;de.isCollection=Wp;de.isDocument=Nk;de.isMap=$k;de.isNode=Dk;de.isPair=Lk;de.isScalar=Jp;de.isSeq=Mk});var jr=_(Bl=>{"use strict";var ie=W(),we=Symbol("break visit"),Kp=Symbol("skip children"),nt=Symbol("remove node");function Pi(n,e){let t=Hp(e);ie.isDocument(n)?Dn(null,n.contents,t,Object.freeze([n]))===nt&&(n.contents=null):Dn(null,n,t,Object.freeze([]))}Pi.BREAK=we;Pi.SKIP=Kp;Pi.REMOVE=nt;function Dn(n,e,t,r){let s=zp(n,e,t,r);if(ie.isNode(s)||ie.isPair(s))return Yp(n,r,s),Dn(n,s,t,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],t,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,t,r);if(i===we)return we;i===nt&&(e.key=null);let o=Dn("value",e.value,t,r);if(o===we)return we;o===nt&&(e.value=null)}}return s}async function Ci(n,e){let t=Hp(e);ie.isDocument(n)?await Bn(null,n.contents,t,Object.freeze([n]))===nt&&(n.contents=null):await Bn(null,n,t,Object.freeze([]))}Ci.BREAK=we;Ci.SKIP=Kp;Ci.REMOVE=nt;async function Bn(n,e,t,r){let s=await zp(n,e,t,r);if(ie.isNode(s)||ie.isPair(s))return Yp(n,r,s),Bn(n,s,t,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],t,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,t,r);if(i===we)return we;i===nt&&(e.key=null);let o=await Bn("value",e.value,t,r);if(o===we)return we;o===nt&&(e.value=null)}}return s}function Hp(n){return typeof n=="object"&&(n.Collection||n.Node||n.Value)?Object.assign({Alias:n.Node,Map:n.Node,Scalar:n.Node,Seq:n.Node},n.Value&&{Map:n.Value,Scalar:n.Value,Seq:n.Value},n.Collection&&{Map:n.Collection,Seq:n.Collection},n):n}function zp(n,e,t,r){if(typeof t=="function")return t(n,e,r);if(ie.isMap(e))return t.Map?.(n,e,r);if(ie.isSeq(e))return t.Seq?.(n,e,r);if(ie.isPair(e))return t.Pair?.(n,e,r);if(ie.isScalar(e))return t.Scalar?.(n,e,r);if(ie.isAlias(e))return t.Alias?.(n,e,r)}function Yp(n,e,t){let r=e[e.length-1];if(ie.isCollection(r))r.items[n]=t;else if(ie.isPair(r))n==="key"?r.key=t:r.value=t;else if(ie.isDocument(r))r.contents=t;else{let s=ie.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}Bl.visit=Pi;Bl.visitAsync=Ci});var jl=_(Gp=>{"use strict";var Vp=W(),jk=jr(),Fk={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Uk=n=>n.replace(/[!,[\]{}]/g,e=>Fk[e]),Fr=class n{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},n.defaultYaml,e),this.tags=Object.assign({},n.defaultTags,t)}clone(){let e=new n(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new n(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:n.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},n.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:n.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},n.defaultTags),this.atNextDocument=!1);let r=e.trim().split(/[ \t]+/),s=r.shift();switch(s){case"%TAG":{if(r.length!==2&&(t(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 t(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 t(6,`Unsupported YAML version ${i}`,o),!1}}default:return t(0,`Unknown directive ${s}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}let[,r,s]=e.match(/^(.*!)([^!]*)$/s);s||t(`The ${e} tag has no suffix`);let i=this.tags[r];if(i)try{return i+decodeURIComponent(s)}catch(o){return t(String(o)),null}return r==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,r]of Object.entries(this.tags))if(e.startsWith(r))return t+Uk(e.substring(r.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),s;if(e&&r.length>0&&Vp.isNode(e.contents)){let i={};jk.visit(e.contents,(o,a)=>{Vp.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)))&&t.push(`%TAG ${i} ${o}`);return t.join(`
25
- `)}};Fr.defaultYaml={explicit:!1,version:"1.2"};Fr.defaultTags={"!!":"tag:yaml.org,2002:"};Gp.Directives=Fr});var _i=_(Ur=>{"use strict";var Xp=W(),qk=jr();function Jk(n){if(/[\x00-\x19\s,[\]{}]/.test(n)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(n)}`;throw new Error(t)}return!0}function Qp(n){let e=new Set;return qk.visit(n,{Value(t,r){r.anchor&&e.add(r.anchor)}}),e}function Zp(n,e){for(let t=1;;++t){let r=`${n}${t}`;if(!e.has(r))return r}}function Wk(n,e){let t=[],r=new Map,s=null;return{onAnchor:i=>{t.push(i),s??(s=Qp(n));let o=Zp(e,s);return s.add(o),o},setAnchors:()=>{for(let i of t){let o=r.get(i);if(typeof o=="object"&&o.anchor&&(Xp.isScalar(o.node)||Xp.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}}Ur.anchorIsValid=Jk;Ur.anchorNames=Qp;Ur.createNodeAnchors=Wk;Ur.findNewAnchor=Zp});var Fl=_(eh=>{"use strict";function qr(n,e,t,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=qr(n,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=qr(n,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=qr(n,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=qr(n,r,s,i);o===void 0?delete r[s]:o!==i&&(r[s]=o)}return n.call(e,t,r)}eh.applyReviver=qr});var Pt=_(nh=>{"use strict";var Kk=W();function th(n,e,t){if(Array.isArray(n))return n.map((r,s)=>th(r,String(s),t));if(n&&typeof n.toJSON=="function"){if(!t||!Kk.hasAnchor(n))return n.toJSON(e,t);let r={aliasCount:0,count:1,res:void 0};t.anchors.set(n,r),t.onCreate=i=>{r.res=i,delete t.onCreate};let s=n.toJSON(e,t);return t.onCreate&&t.onCreate(s),s}return typeof n=="bigint"&&!t?.keep?Number(n):n}nh.toJS=th});var Ri=_(sh=>{"use strict";var Hk=Fl(),rh=W(),zk=Pt(),Ul=class{constructor(e){Object.defineProperty(this,rh.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:t,maxAliasCount:r,onAnchor:s,reviver:i}={}){if(!rh.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=zk.toJS(this,"",o);if(typeof s=="function")for(let{count:l,res:c}of o.anchors.values())s(c,l);return typeof i=="function"?Hk.applyReviver(i,{"":a},"",a):a}};sh.NodeBase=Ul});var Jr=_(ih=>{"use strict";var Yk=_i(),Vk=jr(),jn=W(),Gk=Ri(),Xk=Pt(),ql=class extends Gk.NodeBase{constructor(e){super(jn.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){let r;t?.aliasResolveCache?r=t.aliasResolveCache:(r=[],Vk.visit(e,{Node:(i,o)=>{(jn.isAlias(o)||jn.hasAnchor(o))&&r.push(o)}}),t&&(t.aliasResolveCache=r));let s;for(let i of r){if(i===this)break;i.anchor===this.source&&(s=i)}return s}toJSON(e,t){if(!t)return{source:this.source};let{anchors:r,doc:s,maxAliasCount:i}=t,o=this.resolve(s,t);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||(Xk.toJS(o,null,t),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=Ii(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,t,r){let s=`*${this.source}`;if(e){if(Yk.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 Ii(n,e,t){if(jn.isAlias(e)){let r=e.resolve(n),s=t&&r&&t.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=Ii(n,s,t);i>r&&(r=i)}return r}else if(jn.isPair(e)){let r=Ii(n,e.key,t),s=Ii(n,e.value,t);return Math.max(r,s)}return 1}ih.Alias=ql});var ne=_(Jl=>{"use strict";var Qk=W(),Zk=Ri(),ex=Pt(),tx=n=>!n||typeof n!="function"&&typeof n!="object",Ct=class extends Zk.NodeBase{constructor(e){super(Qk.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:ex.toJS(this.value,e,t)}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";Jl.Scalar=Ct;Jl.isScalarValue=tx});var Wr=_(ah=>{"use strict";var nx=Jr(),nn=W(),oh=ne(),rx="tag:yaml.org,2002:";function sx(n,e,t){if(e){let r=t.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 t.find(r=>r.identify?.(n)&&!r.format)}function ix(n,e,t){if(nn.isDocument(n)&&(n=n.contents),nn.isNode(n))return n;if(nn.isPair(n)){let d=t.schema[nn.MAP].createNode?.(t.schema,null,t);return d.items.push(n),d}(n instanceof String||n instanceof Number||n instanceof Boolean||typeof BigInt<"u"&&n instanceof BigInt)&&(n=n.valueOf());let{aliasDuplicateObjects:r,onAnchor:s,onTagObj:i,schema:o,sourceObjects:a}=t,l;if(r&&n&&typeof n=="object"){if(l=a.get(n),l)return l.anchor??(l.anchor=s(n)),new nx.Alias(l.anchor);l={anchor:null,node:null},a.set(n,l)}e?.startsWith("!!")&&(e=rx+e.slice(2));let c=sx(n,e,o.tags);if(!c){if(n&&typeof n.toJSON=="function"&&(n=n.toJSON()),!n||typeof n!="object"){let d=new oh.Scalar(n);return l&&(l.node=d),d}c=n instanceof Map?o[nn.MAP]:Symbol.iterator in Object(n)?o[nn.SEQ]:o[nn.MAP]}i&&(i(c),delete t.onTagObj);let f=c?.createNode?c.createNode(t.schema,n,t):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(t.schema,n,t):new oh.Scalar(n);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}ah.createNode=ix});var $i=_(Ni=>{"use strict";var ox=Wr(),rt=W(),ax=Ri();function Wl(n,e,t){let r=t;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 ox.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:n,sourceObjects:new Map})}var lh=n=>n==null||typeof n=="object"&&!!n[Symbol.iterator]().next().done,Kl=class extends ax.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(r=>rt.isNode(r)||rt.isPair(r)?r.clone(e):r),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(lh(e))this.add(t);else{let[r,...s]=e,i=this.get(r,!0);if(rt.isCollection(i))i.addIn(s,t);else if(i===void 0&&this.schema)this.set(r,Wl(this.schema,s,t));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let s=this.get(t,!0);if(rt.isCollection(s))return s.deleteIn(r);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...s]=e,i=this.get(r,!0);return s.length===0?!t&&rt.isScalar(i)?i.value:i:rt.isCollection(i)?i.getIn(s,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!rt.isPair(t))return!1;let r=t.value;return r==null||e&&rt.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let s=this.get(t,!0);return rt.isCollection(s)?s.hasIn(r):!1}setIn(e,t){let[r,...s]=e;if(s.length===0)this.set(r,t);else{let i=this.get(r,!0);if(rt.isCollection(i))i.setIn(s,t);else if(i===void 0&&this.schema)this.set(r,Wl(this.schema,s,t));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${s}`)}}};Ni.Collection=Kl;Ni.collectionFromPath=Wl;Ni.isEmptyPath=lh});var Kr=_(Li=>{"use strict";var lx=n=>n.replace(/^(?!$)(?: $)?/gm,"#");function Hl(n,e){return/^\n+$/.test(n)?n.substring(1):e?n.replace(/^(?! *$)/gm,e):n}var cx=(n,e,t)=>n.endsWith(`
26
- `)?Hl(t,e):t.includes(`
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(`
26
+ `)?Gl(n,e):n.includes(`
27
27
  `)?`
28
- `+Hl(t,e):(n.endsWith(" ")?"":" ")+t;Li.indentComment=Hl;Li.lineComment=cx;Li.stringifyComment=lx});var uh=_(Hr=>{"use strict";var ux="flow",zl="block",Mi="quoted";function dx(n,e,t="flow",{indentAtStart:r,lineWidth:s=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!s||s<0)return n;s<i&&(i=0);let l=Math.max(1+i,1+s-e.length);if(n.length<=l)return n;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,y=-1,v=-1;t===zl&&(h=ch(n,h,e.length),h!==-1&&(d=h+l));for(let P;P=n[h+=1];){if(t===Mi&&P==="\\"){switch(y=h,n[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}v=h}if(P===`
29
- `)t===zl&&(h=ch(n,h,e.length)),d=h+e.length+l,u=void 0;else{if(P===" "&&p&&p!==" "&&p!==`
30
- `&&p!==" "){let E=n[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(t===Mi){for(;p===" "||p===" ";)p=P,P=n[h+=1],m=!0;let E=h>v+1?h-2:y-1;if(f[E])return n;c.push(E),f[E]=!0,d=E+l,u=void 0}else m=!0}p=P}if(m&&a&&a(),c.length===0)return n;o&&o();let O=n.slice(0,c[0]);for(let P=0;P<c.length;++P){let E=c[P],R=c[P+1]||n.length;E===0?O=`
32
- ${e}${n.slice(0,R)}`:(t===Mi&&f[E]&&(O+=`${n[E]}\\`),O+=`
33
- ${e}${n.slice(E+1,R)}`)}return O}function ch(n,e,t){let r=e,s=e+1,i=n[s];for(;i===" "||i===" ";)if(e<s+t)i=n[++e];else{do i=n[++e];while(i&&i!==`
34
- `);r=e,s=e+1,i=n[s]}return r}Hr.FOLD_BLOCK=zl;Hr.FOLD_FLOW=ux;Hr.FOLD_QUOTED=Mi;Hr.foldFlowLines=dx});var Yr=_(dh=>{"use strict";var Ke=ne(),_t=uh(),Bi=(n,e)=>({indentAtStart:e?n.indent.length:n.indentAtStart,lineWidth:n.options.lineWidth,minContentWidth:n.options.minContentWidth}),ji=n=>/^(%|---|\.\.\.)/m.test(n);function fx(n,e,t){if(!e||e<0)return!1;let r=e-t,s=n.length;if(s<=r)return!1;for(let i=0,o=0;i<s;++i)if(n[i]===`
35
- `){if(i-o>r)return!0;if(o=i+1,s-o<=r)return!1}return!0}function zr(n,e){let t=JSON.stringify(n);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:r}=e,s=e.options.doubleQuotedMinMultiLineLength,i=e.indent||(ji(n)?" ":""),o="",a=0;for(let l=0,c=t[l];c;c=t[++l])if(c===" "&&t[l+1]==="\\"&&t[l+2]==="n"&&(o+=t.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(t[l+1]){case"u":{o+=t.slice(a,l);let f=t.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+=t.substr(l,6)}l+=5,a=l+1}break;case"n":if(r||t[l+2]==='"'||t.length<s)l+=1;else{for(o+=t.slice(a,l)+`
36
-
37
- `;t[l+2]==="\\"&&t[l+3]==="n"&&t[l+4]!=='"';)o+=`
38
- `,l+=2;o+=i,t[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+t.slice(a):t,r?o:_t.foldFlowLines(o,i,_t.FOLD_QUOTED,Bi(e,!1))}function Yl(n,e){if(e.options.singleQuote===!1||e.implicitKey&&n.includes(`
39
- `)||/[ \t]\n|\n[ \t]/.test(n))return zr(n,e);let t=e.indent||(ji(n)?" ":""),r="'"+n.replace(/'/g,"''").replace(/\n+/g,`$&
40
- ${t}`)+"'";return e.implicitKey?r:_t.foldFlowLines(r,t,_t.FOLD_FLOW,Bi(e,!1))}function Fn(n,e){let{singleQuote:t}=e.options,r;if(t===!1)r=zr;else{let s=n.includes('"'),i=n.includes("'");s&&!i?r=Yl:i&&!s?r=zr:r=t?Yl:zr}return r(n,e)}var Vl;try{Vl=new RegExp(`(^|(?<!
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===`
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)+`
36
+
37
+ `;n[l+2]==="\\"&&n[l+3]==="n"&&n[l+4]!=='"';)o+=`
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(`(^|(?<!
41
41
  ))
42
42
  +(?!
43
- |$)`,"g")}catch{Vl=/\n+(?!\n|$)/g}function Di({comment:n,type:e,value:t},r,s,i){let{blockQuote:o,commentString:a,lineWidth:l}=r.options;if(!o||/\n[\t ]+$/.test(t))return Fn(t,r);let c=r.indent||(r.forceBlockIndent||ji(t)?" ":""),f=o==="literal"?!0:o==="folded"||e===Ke.Scalar.BLOCK_FOLDED?!1:e===Ke.Scalar.BLOCK_LITERAL?!0:!fx(t,l,c.length);if(!t)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:!vx(n,l,c.length);if(!n)return f?`|
44
44
  `:`>
45
- `;let d,u;for(u=t.length;u>0;--u){let R=t[u-1];if(R!==`
46
- `&&R!==" "&&R!==" ")break}let p=t.substring(u),m=p.indexOf(`
47
- `);m===-1?d="-":t===p||m!==p.length-1?(d="+",i&&i()):d="",p&&(t=t.slice(0,-p.length),p[p.length-1]===`
48
- `&&(p=p.slice(0,-1)),p=p.replace(Vl,`$&${c}`));let h=!1,y,v=-1;for(y=0;y<t.length;++y){let R=t[y];if(R===" ")h=!0;else if(R===`
49
- `)v=y;else break}let O=t.substring(0,v<y?v+1:y);O&&(t=t.substring(O.length),O=O.replace(/\n+/g,`$&${c}`));let E=(h?c?"2":"1":"")+d;if(n&&(E+=" "+a(n.replace(/ ?[\r\n]+/g," ")),s&&s()),!f){let R=t.replace(/\n+/g,`
50
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),I=!1,L=Bi(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 t=t.replace(/\n+/g,`$&${c}`),`|${E}
52
- ${c}${O}${t}${p}`}function px(n,e,t,r){let{type:s,value:i}=n,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=e;if(a&&i.includes(`
45
+ `;let d,u;for(u=n.length;u>0;--u){let R=n[u-1];if(R!==`
46
+ `&&R!==" "&&R!==" ")break}let p=n.substring(u),m=p.indexOf(`
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(`
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
- `)?Fn(i,e):Di(n,e,t,r);if(!a&&!f&&s!==Ke.Scalar.PLAIN&&i.includes(`
55
- `))return Di(n,e,t,r);if(ji(i)){if(l==="")return e.forceBlockIndent=!0,Di(n,e,t,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,Bi(e,!1))}function hx(n,e,t,r){let{implicitKey:s,inFlow:i}=e,o=typeof n.value=="string"?n:Object.assign({},n,{value:String(n.value)}),{type:a}=n;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):Di(o,e,t,r);case Ke.Scalar.QUOTE_DOUBLE:return zr(o.value,e);case Ke.Scalar.QUOTE_SINGLE:return Yl(o.value,e);case Ke.Scalar.PLAIN:return px(o,e,t,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}dh.stringifyString=hx});var Vr=_(Gl=>{"use strict";var mx=_i(),Rt=W(),gx=Kr(),yx=Yr();function bx(n,e){let t=Object.assign({blockQuote:!0,commentString:gx.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},n.schema.toStringOptions,e),r;switch(t.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:n,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:r,options:t}}function wx(n,e){if(e.tag){let s=n.filter(i=>i.tag===e.tag);if(s.length>0)return s.find(i=>i.format===e.format)??s[0]}let t,r;if(Rt.isScalar(e)){r=e.value;let s=n.filter(i=>i.identify?.(r));if(s.length>1){let i=s.filter(o=>o.test);i.length>0&&(s=i)}t=s.find(i=>i.format===e.format)??s.find(i=>!i.format)}else r=e,t=n.find(s=>s.nodeClass&&r instanceof s.nodeClass);if(!t){let s=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${s} value`)}return t}function vx(n,e,{anchors:t,doc:r}){if(!r.directives)return"";let s=[],i=(Rt.isScalar(n)||Rt.isCollection(n))&&n.anchor;i&&mx.anchorIsValid(i)&&(t.add(i),s.push(`&${i}`));let o=n.tag??(e.default?null:e.tag);return o&&s.push(r.directives.tagString(o)),s.join(" ")}function Sx(n,e,t,r){if(Rt.isPair(n))return n.toString(e,t,r);if(Rt.isAlias(n)){if(e.doc.directives)return n.toString(e);if(e.resolvedAliases?.has(n))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(n):e.resolvedAliases=new Set([n]),n=n.resolve(e.doc)}let s,i=Rt.isNode(n)?n:e.doc.createNode(n,{onTagObj:l=>s=l});s??(s=wx(e.doc.schema.tags,i));let o=vx(i,s,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof s.stringify=="function"?s.stringify(i,e,t,r):Rt.isScalar(i)?yx.stringifyString(i,e,t,r):i.toString(e,t,r);return o?Rt.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
57
- ${e.indent}${a}`:a}Gl.createStringifyContext=bx;Gl.stringify=Sx});var mh=_(hh=>{"use strict";var ft=W(),fh=ne(),ph=Vr(),Gr=Kr();function kx({key:n,value:e},t,r,s){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:d}}=t,u=ft.isNode(n)&&n.comment||null;if(d){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(ft.isCollection(n)||!ft.isNode(n)&&typeof n=="object"){let L="With simple keys, collection cannot be used as a key value";throw new Error(L)}}let p=!d&&(!n||u&&e==null&&!t.inFlow||ft.isCollection(n)||(ft.isScalar(n)?n.type===fh.Scalar.BLOCK_FOLDED||n.type===fh.Scalar.BLOCK_LITERAL:typeof n=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!p&&(d||!i),indent:a+l});let m=!1,h=!1,y=ph.stringify(n,t,()=>m=!0,()=>h=!0);if(!p&&!t.inFlow&&y.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(t.inFlow){if(i||e==null)return m&&r&&r(),y===""?"?":p?`? ${y}`:y}else if(i&&!d||e==null&&p)return y=`? ${y}`,u&&!m?y+=Gr.lineComment(y,t.indent,c(u)):h&&s&&s(),y;m&&(u=null),p?(u&&(y+=Gr.lineComment(y,t.indent,c(u))),y=`? ${y}
58
- ${a}:`):(y=`${y}:`,u&&(y+=Gr.lineComment(y,t.indent,c(u))));let v,O,P;ft.isNode(e)?(v=!!e.spaceBefore,O=e.commentBefore,P=e.comment):(v=!1,O=null,P=null,e&&typeof e=="object"&&(e=o.createNode(e))),t.implicitKey=!1,!p&&!u&&ft.isScalar(e)&&(t.indentAtStart=y.length+1),h=!1,!f&&l.length>=2&&!t.inFlow&&!p&&ft.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let E=!1,R=ph.stringify(e,t,()=>E=!0,()=>h=!0),I=" ";if(u||v||O){if(I=v?`
54
+ `)?Fn(i,e):ji(t,e,n,r);if(!a&&!f&&s!==Ke.Scalar.PLAIN&&i.includes(`
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?`
59
59
  `:"",O){let L=c(O);I+=`
60
- ${Gr.indentComment(L,t.indent)}`}R===""&&!t.inFlow?I===`
61
- `&&P&&(I=`
60
+ ${Xr.indentComment(L,n.indent)}`}R===""&&!n.inFlow?I===`
61
+ `&&C&&(I=`
62
62
 
63
63
  `):I+=`
64
- ${t.indent}`}else if(!p&&ft.isCollection(e)){let L=R[0],A=R.indexOf(`
65
- `),q=A!==-1,X=t.inFlow??e.flow??e.items.length===0;if(q||!X){let G=!1;if(q&&(L==="&"||L==="!")){let U=R.indexOf(" ");L==="&"&&U!==-1&&U<A&&R[U+1]==="!"&&(U=R.indexOf(" ",U+1)),(U===-1||A<U)&&(G=!0)}G||(I=`
66
- ${t.indent}`)}}else(R===""||R[0]===`
67
- `)&&(I="");return y+=I+R,t.inFlow?E&&r&&r():P&&!E?y+=Gr.lineComment(y,t.indent,c(P)):h&&s&&s(),y}hh.stringifyPair=kx});var Ql=_(Xl=>{"use strict";var gh=bi("process");function xx(n,...e){n==="debug"&&console.log(...e)}function Ex(n,e){(n==="debug"||n==="warn")&&(typeof gh.emitWarning=="function"?gh.emitWarning(e):console.warn(e))}Xl.debug=xx;Xl.warn=Ex});var Ji=_(qi=>{"use strict";var Xr=W(),yh=ne(),Fi="<<",Ui={identify:n=>n===Fi||typeof n=="symbol"&&n.description===Fi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new yh.Scalar(Symbol(Fi)),{addToJSMap:bh}),stringify:()=>Fi},Ax=(n,e)=>(Ui.identify(e)||Xr.isScalar(e)&&(!e.type||e.type===yh.Scalar.PLAIN)&&Ui.identify(e.value))&&n?.doc.schema.tags.some(t=>t.tag===Ui.tag&&t.default);function bh(n,e,t){if(t=n&&Xr.isAlias(t)?t.resolve(n.doc):t,Xr.isSeq(t))for(let r of t.items)Zl(n,e,r);else if(Array.isArray(t))for(let r of t)Zl(n,e,r);else Zl(n,e,t)}function Zl(n,e,t){let r=n&&Xr.isAlias(t)?t.resolve(n.doc):t;if(!Xr.isMap(r))throw new Error("Merge sources must be maps or map aliases");let s=r.toJSON(null,n,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}qi.addMergeToJSMap=bh;qi.isMergeKey=Ax;qi.merge=Ui});var tc=_(Sh=>{"use strict";var Tx=Ql(),wh=Ji(),Ox=Vr(),vh=W(),ec=Pt();function Px(n,e,{key:t,value:r}){if(vh.isNode(t)&&t.addToJSMap)t.addToJSMap(n,e,r);else if(wh.isMergeKey(n,t))wh.addMergeToJSMap(n,e,r);else{let s=ec.toJS(t,"",n);if(e instanceof Map)e.set(s,ec.toJS(r,s,n));else if(e instanceof Set)e.add(s);else{let i=Cx(t,s,n),o=ec.toJS(r,i,n);i in e?Object.defineProperty(e,i,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[i]=o}}return e}function Cx(n,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(vh.isNode(n)&&t?.doc){let r=Ox.createStringifyContext(t.doc,{});r.anchors=new Set;for(let i of t.anchors.keys())r.anchors.add(i.anchor);r.inFlow=!0,r.inStringifyKey=!0;let s=n.toString(r);if(!t.mapKeyWarned){let i=JSON.stringify(s);i.length>40&&(i=i.substring(0,36)+'..."'),Tx.warn(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return s}return JSON.stringify(e)}Sh.addPairToJSMap=Px});var It=_(nc=>{"use strict";var kh=Wr(),_x=mh(),Rx=tc(),Wi=W();function Ix(n,e,t){let r=kh.createNode(n,void 0,t),s=kh.createNode(e,void 0,t);return new Ki(r,s)}var Ki=class n{constructor(e,t=null){Object.defineProperty(this,Wi.NODE_TYPE,{value:Wi.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:r}=this;return Wi.isNode(t)&&(t=t.clone(e)),Wi.isNode(r)&&(r=r.clone(e)),new n(t,r)}toJSON(e,t){let r=t?.mapAsMap?new Map:{};return Rx.addPairToJSMap(t,r,this)}toString(e,t,r){return e?.doc?_x.stringifyPair(this,e,t,r):JSON.stringify(this)}};nc.Pair=Ki;nc.createPair=Ix});var rc=_(Eh=>{"use strict";var rn=W(),xh=Vr(),Hi=Kr();function Nx(n,e,t){return(e.inFlow??n.flow?Lx:$x)(n,e,t)}function $x({comment:n,items:e},t,{blockItemPrefix:r,flowChars:s,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=t,f=Object.assign({},t,{indent:i,type:null}),d=!1,u=[];for(let m=0;m<e.length;++m){let h=e[m],y=null;if(rn.isNode(h))!d&&h.spaceBefore&&u.push(""),zi(t,u,h.commentBefore,d),h.comment&&(y=h.comment);else if(rn.isPair(h)){let O=rn.isNode(h.key)?h.key:null;O&&(!d&&O.spaceBefore&&u.push(""),zi(t,u,O.commentBefore,d))}d=!1;let v=xh.stringify(h,f,()=>y=null,()=>d=!0);y&&(v+=Hi.lineComment(v,i,c(y))),d&&y&&(d=!1),u.push(r+v)}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?`
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=`
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?`
68
68
  ${l}${h}`:`
69
- `}}return n?(p+=`
70
- `+Hi.indentComment(c(n),l),a&&a()):d&&o&&o(),p}function Lx({items:n},e,{flowChars:t,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<n.length;++m){let h=n[m],y=null;if(rn.isNode(h))h.spaceBefore&&d.push(""),zi(e,d,h.commentBefore,!1),h.comment&&(y=h.comment);else if(rn.isPair(h)){let O=rn.isNode(h.key)?h.key:null;O&&(O.spaceBefore&&d.push(""),zi(e,d,O.commentBefore,!1),O.comment&&(c=!0));let P=rn.isNode(h.value)?h.value:null;P?(P.comment&&(y=P.comment),P.commentBefore&&(c=!0)):h.value==null&&O?.comment&&(y=O.comment)}y&&(c=!0);let v=xh.stringify(h,l,()=>y=null);m<n.length-1&&(v+=","),y&&(v+=Hi.lineComment(v,r,a(y))),!c&&(d.length>f||v.includes(`
71
- `))&&(c=!0),d.push(v),f=d.length}let{start:u,end:p}=t;if(d.length===0)return u+p;if(!c){let m=d.reduce((h,y)=>h+y.length+2,2);c=e.options.lineWidth>0&&m>e.options.lineWidth}if(c){let m=u;for(let h of d)m+=h?`
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?`
72
72
  ${i}${s}${h}`:`
73
73
  `;return`${m}
74
- ${s}${p}`}else return`${u}${o}${d.join(" ")}${o}${p}`}function zi({indent:n,options:{commentString:e}},t,r,s){if(r&&s&&(r=r.replace(/^\n+/,"")),r){let i=Hi.indentComment(e(r),n);t.push(i.trimStart())}}Eh.stringifyCollection=Nx});var $t=_(ic=>{"use strict";var Mx=rc(),Dx=tc(),Bx=$i(),Nt=W(),Yi=It(),jx=ne();function Qr(n,e){let t=Nt.isScalar(e)?e.value:e;for(let r of n)if(Nt.isPair(r)&&(r.key===e||r.key===t||Nt.isScalar(r.key)&&r.key.value===t))return r}var sc=class extends Bx.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Nt.MAP,e),this.items=[]}static from(e,t,r){let{keepUndefined:s,replacer:i}=r,o=new this(e),a=(l,c)=>{if(typeof i=="function")c=i.call(t,l,c);else if(Array.isArray(i)&&!i.includes(l))return;(c!==void 0||s)&&o.items.push(Yi.createPair(l,c,r))};if(t instanceof Map)for(let[l,c]of t)a(l,c);else if(t&&typeof t=="object")for(let l of Object.keys(t))a(l,t[l]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,t){let r;Nt.isPair(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new Yi.Pair(e,e?.value):r=new Yi.Pair(e.key,e.value);let s=Qr(this.items,r.key),i=this.schema?.sortMapEntries;if(s){if(!t)throw new Error(`Key ${r.key} already set`);Nt.isScalar(s.value)&&jx.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 t=Qr(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let s=Qr(this.items,e)?.value;return(!t&&Nt.isScalar(s)?s.value:s)??void 0}has(e){return!!Qr(this.items,e)}set(e,t){this.add(new Yi.Pair(e,t),!0)}toJSON(e,t,r){let s=r?new r:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(s);for(let i of this.items)Dx.addPairToJSMap(t,s,i);return s}toString(e,t,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})),Mx.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:t})}};ic.YAMLMap=sc;ic.findPair=Qr});var Un=_(Th=>{"use strict";var Fx=W(),Ah=$t(),Ux={collection:"map",default:!0,nodeClass:Ah.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(n,e){return Fx.isMap(n)||e("Expected a mapping for this tag"),n},createNode:(n,e,t)=>Ah.YAMLMap.from(n,e,t)};Th.map=Ux});var Lt=_(Oh=>{"use strict";var qx=Wr(),Jx=rc(),Wx=$i(),Gi=W(),Kx=ne(),Hx=Pt(),oc=class extends Wx.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Gi.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Vi(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let r=Vi(e);if(typeof r!="number")return;let s=this.items[r];return!t&&Gi.isScalar(s)?s.value:s}has(e){let t=Vi(e);return typeof t=="number"&&t<this.items.length}set(e,t){let r=Vi(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let s=this.items[r];Gi.isScalar(s)&&Kx.isScalarValue(t)?s.value=t:this.items[r]=t}toJSON(e,t){let r=[];t?.onCreate&&t.onCreate(r);let s=0;for(let i of this.items)r.push(Hx.toJS(i,String(s++),t));return r}toString(e,t,r){return e?Jx.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,t,r){let{replacer:s}=r,i=new this(e);if(t&&Symbol.iterator in Object(t)){let o=0;for(let a of t){if(typeof s=="function"){let l=t instanceof Set?a:String(o++);a=s.call(t,l,a)}i.items.push(qx.createNode(a,void 0,r))}}return i}};function Vi(n){let e=Gi.isScalar(n)?n.value:n;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}Oh.YAMLSeq=oc});var qn=_(Ch=>{"use strict";var zx=W(),Ph=Lt(),Yx={collection:"seq",default:!0,nodeClass:Ph.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(n,e){return zx.isSeq(n)||e("Expected a sequence for this tag"),n},createNode:(n,e,t)=>Ph.YAMLSeq.from(n,e,t)};Ch.seq=Yx});var Zr=_(_h=>{"use strict";var Vx=Yr(),Gx={identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify(n,e,t,r){return e=Object.assign({actualString:!0},e),Vx.stringifyString(n,e,t,r)}};_h.string=Gx});var Xi=_(Nh=>{"use strict";var Rh=ne(),Ih={identify:n=>n==null,createNode:()=>new Rh.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Rh.Scalar(null),stringify:({source:n},e)=>typeof n=="string"&&Ih.test.test(n)?n:e.options.nullStr};Nh.nullTag=Ih});var ac=_(Lh=>{"use strict";var Xx=ne(),$h={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new Xx.Scalar(n[0]==="t"||n[0]==="T"),stringify({source:n,value:e},t){if(n&&$h.test.test(n)){let r=n[0]==="t"||n[0]==="T";if(e===r)return n}return e?t.options.trueStr:t.options.falseStr}};Lh.boolTag=$h});var Jn=_(Mh=>{"use strict";function Qx({format:n,minFractionDigits:e,tag:t,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(!n&&e&&(!t||t==="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}Mh.stringifyNumber=Qx});var cc=_(Qi=>{"use strict";var Zx=ne(),lc=Jn(),e0={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:lc.stringifyNumber},t0={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n),stringify(n){let e=Number(n.value);return isFinite(e)?e.toExponential():lc.stringifyNumber(n)}},n0={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(n){let e=new Zx.Scalar(parseFloat(n)),t=n.indexOf(".");return t!==-1&&n[n.length-1]==="0"&&(e.minFractionDigits=n.length-t-1),e},stringify:lc.stringifyNumber};Qi.float=n0;Qi.floatExp=t0;Qi.floatNaN=e0});var dc=_(eo=>{"use strict";var Dh=Jn(),Zi=n=>typeof n=="bigint"||Number.isInteger(n),uc=(n,e,t,{intAsBigInt:r})=>r?BigInt(n):parseInt(n.substring(e),t);function Bh(n,e,t){let{value:r}=n;return Zi(r)&&r>=0?t+r.toString(e):Dh.stringifyNumber(n)}var r0={identify:n=>Zi(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(n,e,t)=>uc(n,2,8,t),stringify:n=>Bh(n,8,"0o")},s0={identify:Zi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(n,e,t)=>uc(n,0,10,t),stringify:Dh.stringifyNumber},i0={identify:n=>Zi(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(n,e,t)=>uc(n,2,16,t),stringify:n=>Bh(n,16,"0x")};eo.int=s0;eo.intHex=i0;eo.intOct=r0});var Fh=_(jh=>{"use strict";var o0=Un(),a0=Xi(),l0=qn(),c0=Zr(),u0=ac(),fc=cc(),pc=dc(),d0=[o0.map,l0.seq,c0.string,a0.nullTag,u0.boolTag,pc.intOct,pc.int,pc.intHex,fc.floatNaN,fc.floatExp,fc.float];jh.schema=d0});var Jh=_(qh=>{"use strict";var f0=ne(),p0=Un(),h0=qn();function Uh(n){return typeof n=="bigint"||Number.isInteger(n)}var to=({value:n})=>JSON.stringify(n),m0=[{identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify:to},{identify:n=>n==null,createNode:()=>new f0.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:to},{identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:n=>n==="true",stringify:to},{identify:Uh,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(n,e,{intAsBigInt:t})=>t?BigInt(n):parseInt(n,10),stringify:({value:n})=>Uh(n)?n.toString():JSON.stringify(n)},{identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:n=>parseFloat(n),stringify:to}],g0={default:!0,tag:"",test:/^/,resolve(n,e){return e(`Unresolved plain scalar ${JSON.stringify(n)}`),n}},y0=[p0.map,h0.seq].concat(m0,g0);qh.schema=y0});var mc=_(Wh=>{"use strict";var es=bi("buffer"),hc=ne(),b0=Yr(),w0={identify:n=>n instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(n,e){if(typeof es.Buffer=="function")return es.Buffer.from(n,"base64");if(typeof atob=="function"){let t=atob(n.replace(/[\n\r]/g,"")),r=new Uint8Array(t.length);for(let s=0;s<t.length;++s)r[s]=t.charCodeAt(s);return r}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),n},stringify({comment:n,type:e,value:t},r,s,i){if(!t)return"";let o=t,a;if(typeof es.Buffer=="function")a=o instanceof es.Buffer?o.toString("base64"):es.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=hc.Scalar.BLOCK_LITERAL),e!==hc.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===hc.Scalar.BLOCK_LITERAL?`
75
- `:" ")}return b0.stringifyString({comment:n,type:e,value:a},r,s,i)}};Wh.binary=w0});var so=_(ro=>{"use strict";var no=W(),gc=It(),v0=ne(),S0=Lt();function Kh(n,e){if(no.isSeq(n))for(let t=0;t<n.items.length;++t){let r=n.items[t];if(!no.isPair(r)){if(no.isMap(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let s=r.items[0]||new gc.Pair(new v0.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=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}
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}n.items[t]=no.isPair(r)?r:new gc.Pair(r)}}else e("Expected a sequence for this tag");return n}function Hh(n,e,t){let{replacer:r}=t,s=new S0.YAMLSeq(n);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(gc.createPair(a,l,t))}return s}var k0={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Kh,createNode:Hh};ro.createPairs=Hh;ro.pairs=k0;ro.resolvePairs=Kh});var wc=_(bc=>{"use strict";var zh=W(),yc=Pt(),ts=$t(),x0=Lt(),Yh=so(),sn=class n extends x0.YAMLSeq{constructor(){super(),this.add=ts.YAMLMap.prototype.add.bind(this),this.delete=ts.YAMLMap.prototype.delete.bind(this),this.get=ts.YAMLMap.prototype.get.bind(this),this.has=ts.YAMLMap.prototype.has.bind(this),this.set=ts.YAMLMap.prototype.set.bind(this),this.tag=n.tag}toJSON(e,t){if(!t)return super.toJSON(e);let r=new Map;t?.onCreate&&t.onCreate(r);for(let s of this.items){let i,o;if(zh.isPair(s)?(i=yc.toJS(s.key,"",t),o=yc.toJS(s.value,i,t)):i=yc.toJS(s,"",t),r.has(i))throw new Error("Ordered maps must not include duplicate keys");r.set(i,o)}return r}static from(e,t,r){let s=Yh.createPairs(e,t,r),i=new this;return i.items=s.items,i}};sn.tag="tag:yaml.org,2002:omap";var E0={collection:"seq",identify:n=>n instanceof Map,nodeClass:sn,default:!1,tag:"tag:yaml.org,2002:omap",resolve(n,e){let t=Yh.resolvePairs(n,e),r=[];for(let{key:s}of t.items)zh.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,t)},createNode:(n,e,t)=>sn.from(n,e,t)};bc.YAMLOMap=sn;bc.omap=E0});var Zh=_(vc=>{"use strict";var Vh=ne();function Gh({value:n,source:e},t){return e&&(n?Xh:Qh).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}var Xh={identify:n=>n===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Vh.Scalar(!0),stringify:Gh},Qh={identify:n=>n===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Vh.Scalar(!1),stringify:Gh};vc.falseTag=Qh;vc.trueTag=Xh});var em=_(io=>{"use strict";var A0=ne(),Sc=Jn(),T0={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Sc.stringifyNumber},O0={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n.replace(/_/g,"")),stringify(n){let e=Number(n.value);return isFinite(e)?e.toExponential():Sc.stringifyNumber(n)}},P0={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(n){let e=new A0.Scalar(parseFloat(n.replace(/_/g,""))),t=n.indexOf(".");if(t!==-1){let r=n.substring(t+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:Sc.stringifyNumber};io.float=P0;io.floatExp=O0;io.floatNaN=T0});var nm=_(rs=>{"use strict";var tm=Jn(),ns=n=>typeof n=="bigint"||Number.isInteger(n);function oo(n,e,t,{intAsBigInt:r}){let s=n[0];if((s==="-"||s==="+")&&(e+=1),n=n.substring(e).replace(/_/g,""),r){switch(t){case 2:n=`0b${n}`;break;case 8:n=`0o${n}`;break;case 16:n=`0x${n}`;break}let o=BigInt(n);return s==="-"?BigInt(-1)*o:o}let i=parseInt(n,t);return s==="-"?-1*i:i}function kc(n,e,t){let{value:r}=n;if(ns(r)){let s=r.toString(e);return r<0?"-"+t+s.substr(1):t+s}return tm.stringifyNumber(n)}var C0={identify:ns,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>oo(n,2,2,t),stringify:n=>kc(n,2,"0b")},_0={identify:ns,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>oo(n,1,8,t),stringify:n=>kc(n,8,"0")},R0={identify:ns,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>oo(n,0,10,t),stringify:tm.stringifyNumber},I0={identify:ns,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>oo(n,2,16,t),stringify:n=>kc(n,16,"0x")};rs.int=R0;rs.intBin=C0;rs.intHex=I0;rs.intOct=_0});var Ec=_(xc=>{"use strict";var co=W(),ao=It(),lo=$t(),on=class n extends lo.YAMLMap{constructor(e){super(e),this.tag=n.tag}add(e){let t;co.isPair(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new ao.Pair(e.key,null):t=new ao.Pair(e,null),lo.findPair(this.items,t.key)||this.items.push(t)}get(e,t){let r=lo.findPair(this.items,e);return!t&&co.isPair(r)?co.isScalar(r.key)?r.key.value:r.key:r}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let r=lo.findPair(this.items,e);r&&!t?this.items.splice(this.items.indexOf(r),1):!r&&t&&this.items.push(new ao.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,r);throw new Error("Set items must all have null values")}static from(e,t,r){let{replacer:s}=r,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t)typeof s=="function"&&(o=s.call(t,o,o)),i.items.push(ao.createPair(o,null,r));return i}};on.tag="tag:yaml.org,2002:set";var N0={collection:"map",identify:n=>n instanceof Set,nodeClass:on,default:!1,tag:"tag:yaml.org,2002:set",createNode:(n,e,t)=>on.from(n,e,t),resolve(n,e){if(co.isMap(n)){if(n.hasAllNullValues(!0))return Object.assign(new on,n);e("Set items must all have null values")}else e("Expected a mapping for this tag");return n}};xc.YAMLSet=on;xc.set=N0});var Tc=_(uo=>{"use strict";var $0=Jn();function Ac(n,e){let t=n[0],r=t==="-"||t==="+"?n.substring(1):n,s=o=>e?BigInt(o):Number(o),i=r.replace(/_/g,"").split(":").reduce((o,a)=>o*s(60)+s(a),s(0));return t==="-"?s(-1)*i:i}function rm(n){let{value:e}=n,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return $0.stringifyNumber(n);let r="";e<0&&(r="-",e*=t(-1));let s=t(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 L0={identify:n=>typeof n=="bigint"||Number.isInteger(n),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(n,e,{intAsBigInt:t})=>Ac(n,t),stringify:rm},M0={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:n=>Ac(n,!1),stringify:rm},sm={identify:n=>n 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(n){let e=n.match(sm.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,t,r,s,i,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(t,r-1,s,i||0,o||0,a||0,l),f=e[8];if(f&&f!=="Z"){let d=Ac(f,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:n})=>n?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};uo.floatTime=M0;uo.intTime=L0;uo.timestamp=sm});var am=_(om=>{"use strict";var D0=Un(),B0=Xi(),j0=qn(),F0=Zr(),U0=mc(),im=Zh(),Oc=em(),fo=nm(),q0=Ji(),J0=wc(),W0=so(),K0=Ec(),Pc=Tc(),H0=[D0.map,j0.seq,F0.string,B0.nullTag,im.trueTag,im.falseTag,fo.intBin,fo.intOct,fo.int,fo.intHex,Oc.floatNaN,Oc.floatExp,Oc.float,U0.binary,q0.merge,J0.omap,W0.pairs,K0.set,Pc.intTime,Pc.floatTime,Pc.timestamp];om.schema=H0});var ym=_(Rc=>{"use strict";var dm=Un(),z0=Xi(),fm=qn(),Y0=Zr(),V0=ac(),Cc=cc(),_c=dc(),G0=Fh(),X0=Jh(),pm=mc(),ss=Ji(),hm=wc(),mm=so(),lm=am(),gm=Ec(),po=Tc(),cm=new Map([["core",G0.schema],["failsafe",[dm.map,fm.seq,Y0.string]],["json",X0.schema],["yaml11",lm.schema],["yaml-1.1",lm.schema]]),um={binary:pm.binary,bool:V0.boolTag,float:Cc.float,floatExp:Cc.floatExp,floatNaN:Cc.floatNaN,floatTime:po.floatTime,int:_c.int,intHex:_c.intHex,intOct:_c.intOct,intTime:po.intTime,map:dm.map,merge:ss.merge,null:z0.nullTag,omap:hm.omap,pairs:mm.pairs,seq:fm.seq,set:gm.set,timestamp:po.timestamp},Q0={"tag:yaml.org,2002:binary":pm.binary,"tag:yaml.org,2002:merge":ss.merge,"tag:yaml.org,2002:omap":hm.omap,"tag:yaml.org,2002:pairs":mm.pairs,"tag:yaml.org,2002:set":gm.set,"tag:yaml.org,2002:timestamp":po.timestamp};function Z0(n,e,t){let r=cm.get(e);if(r&&!n)return t&&!r.includes(ss.merge)?r.concat(ss.merge):r.slice();let s=r;if(!s)if(Array.isArray(n))s=[];else{let i=Array.from(cm.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(n))for(let i of n)s=s.concat(i);else typeof n=="function"&&(s=n(s.slice()));return t&&(s=s.concat(ss.merge)),s.reduce((i,o)=>{let a=typeof o=="string"?um[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(um).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},[])}Rc.coreKnownTags=Q0;Rc.getTags=Z0});var $c=_(bm=>{"use strict";var Ic=W(),eE=Un(),tE=qn(),nE=Zr(),ho=ym(),rE=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0,Nc=class n{constructor({compat:e,customTags:t,merge:r,resolveKnownTags:s,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?ho.getTags(e,"compat"):e?ho.getTags(null,e):null,this.name=typeof i=="string"&&i||"core",this.knownTags=s?ho.coreKnownTags:{},this.tags=ho.getTags(t,this.name,r),this.toStringOptions=a??null,Object.defineProperty(this,Ic.MAP,{value:eE.map}),Object.defineProperty(this,Ic.SCALAR,{value:nE.string}),Object.defineProperty(this,Ic.SEQ,{value:tE.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?rE:null}clone(){let e=Object.create(n.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};bm.Schema=Nc});var vm=_(wm=>{"use strict";var sE=W(),Lc=Vr(),is=Kr();function iE(n,e){let t=[],r=e.directives===!0;if(e.directives!==!1&&n.directives){let l=n.directives.toString(n);l?(t.push(l),r=!0):n.directives.docStart&&(r=!0)}r&&t.push("---");let s=Lc.createStringifyContext(n,e),{commentString:i}=s.options;if(n.commentBefore){t.length!==1&&t.unshift("");let l=i(n.commentBefore);t.unshift(is.indentComment(l,""))}let o=!1,a=null;if(n.contents){if(sE.isNode(n.contents)){if(n.contents.spaceBefore&&r&&t.push(""),n.contents.commentBefore){let f=i(n.contents.commentBefore);t.push(is.indentComment(f,""))}s.forceBlockIndent=!!n.comment,a=n.contents.comment}let l=a?void 0:()=>o=!0,c=Lc.stringify(n.contents,s,()=>a=null,l);a&&(c+=is.lineComment(c,"",i(a))),(c[0]==="|"||c[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${c}`:t.push(c)}else t.push(Lc.stringify(n.contents,s));if(n.directives?.docEnd)if(n.comment){let l=i(n.comment);l.includes(`
78
- `)?(t.push("..."),t.push(is.indentComment(l,""))):t.push(`... ${l}`)}else t.push("...");else{let l=n.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&t[t.length-1]!==""&&t.push(""),t.push(is.indentComment(i(l),"")))}return t.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 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(`
79
79
  `)+`
80
- `}wm.stringifyDocument=iE});var os=_(Sm=>{"use strict";var oE=Jr(),Wn=$i(),Ie=W(),aE=It(),lE=Pt(),cE=$c(),uE=vm(),Mc=_i(),dE=Fl(),fE=Wr(),Dc=jl(),Bc=class n{constructor(e,t,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Ie.NODE_TYPE,{value:Ie.DOC});let s=null;typeof t=="function"||Array.isArray(t)?s=t:r===void 0&&t&&(r=t,t=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 Dc.Directives({version:o}),this.setSchema(o,r),this.contents=e===void 0?null:this.createNode(e,s,r)}clone(){let e=Object.create(n.prototype,{[Ie.NODE_TYPE]:{value:Ie.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=Ie.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,t){Kn(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let r=Mc.anchorNames(this);e.anchor=!t||r.has(t)?Mc.findNewAnchor(t||"a",r):t}return new oE.Alias(e.anchor)}createNode(e,t,r){let s;if(typeof t=="function")e=t.call({"":e},"",e),s=t;else if(Array.isArray(t)){let y=O=>typeof O=="number"||O instanceof String||O instanceof Number,v=t.filter(y).map(String);v.length>0&&(t=t.concat(v)),s=t}else r===void 0&&t&&(r=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:f}=r??{},{onAnchor:d,setAnchors:u,sourceObjects:p}=Mc.createNodeAnchors(this,o||"a"),m={aliasDuplicateObjects:i??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:s,schema:this.schema,sourceObjects:p},h=fE.createNode(e,f,m);return a&&Ie.isCollection(h)&&(h.flow=!0),u(),h}createPair(e,t,r={}){let s=this.createNode(e,null,r),i=this.createNode(t,null,r);return new aE.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,t){return Ie.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Wn.isEmptyPath(e)?!t&&Ie.isScalar(this.contents)?this.contents.value:this.contents:Ie.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Ie.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Wn.isEmptyPath(e)?this.contents!==void 0:Ie.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Wn.collectionFromPath(this.schema,[e],t):Kn(this.contents)&&this.contents.set(e,t)}setIn(e,t){Wn.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=Wn.collectionFromPath(this.schema,Array.from(e),t):Kn(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Dc.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 Dc.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(t.schema instanceof Object)this.schema=t.schema;else if(r)this.schema=new cE.Schema(Object.assign(r,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,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=lE.toJS(this.contents,t??"",a);if(typeof i=="function")for(let{count:c,res:f}of a.anchors.values())i(f,c);return typeof o=="function"?dE.applyReviver(o,{"":l},"",l):l}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}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 t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return uE.stringifyDocument(this,e)}};function Kn(n){if(Ie.isCollection(n))return!0;throw new Error("Expected a YAML collection as document contents")}Sm.Document=Bc});var cs=_(ls=>{"use strict";var as=class extends Error{constructor(e,t,r,s){super(),this.name=e,this.code=r,this.message=s,this.pos=t}},jc=class extends as{constructor(e,t,r){super("YAMLParseError",e,t,r)}},Fc=class extends as{constructor(e,t,r){super("YAMLWarning",e,t,r)}},pE=(n,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(a=>e.linePos(a));let{line:r,col:s}=t.linePos[0];t.message+=` at line ${r}, column ${s}`;let i=s-1,o=n.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=n.substring(e.lineStarts[r-2],e.lineStarts[r-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
81
- `),o=a+o}if(/[^ ]/.test(o)){let a=1,l=t.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);t.message+=`:
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
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
- `}};ls.YAMLError=as;ls.YAMLParseError=jc;ls.YAMLWarning=Fc;ls.prettifyError=pE});var us=_(km=>{"use strict";function hE(n,{flow:e,indicator:t,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,y=null,v=null,O=null,P=null,E=null,R=null;for(let A of n)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&&(t!=="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 q=A.source.substring(1)||" ";d?d+=u+q:d=q,u="",c=!1;break}case"newline":c?d?d+=A.source:(!E||t!=="seq-item-ind")&&(l=!0):u+=A.source,c=!0,p=!0,(y||v)&&(O=A),f=!0;break;case"anchor":y&&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),y=A,R??(R=A.offset),c=!1,f=!1,m=!0;break;case"tag":{v&&i(A,"MULTIPLE_TAGS","A node can have at most one tag"),v=A,R??(R=A.offset),c=!1,f=!1,m=!0;break}case t:(y||v)&&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=t==="seq-item-ind"||t==="explicit-key-ind",f=!1;break;case"comma":if(e){P&&i(A,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),P=A,c=!1,f=!1;break}default:i(A,"UNEXPECTED_TOKEN",`Unexpected ${A.type} token`),c=!1,f=!1}let I=n[n.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:P,found:E,spaceBefore:l,comment:d,hasNewline:p,anchor:y,tag:v,newlineAfterProp:O,end:L,start:R??L}}km.resolveProps=hE});var mo=_(xm=>{"use strict";function Uc(n){if(!n)return null;switch(n.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(n.source.includes(`
86
- `))return!0;if(n.end){for(let e of n.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of n.items){for(let t of e.start)if(t.type==="newline")return!0;if(e.sep){for(let t of e.sep)if(t.type==="newline")return!0}if(Uc(e.key)||Uc(e.value))return!0}return!1;default:return!0}}xm.containsNewline=Uc});var qc=_(Em=>{"use strict";var mE=mo();function gE(n,e,t){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===n&&(r.source==="]"||r.source==="}")&&mE.containsNewline(e)&&t(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Em.flowIndentCheck=gE});var Jc=_(Tm=>{"use strict";var Am=W();function yE(n,e,t){let{uniqueKeys:r}=n.options;if(r===!1)return!1;let s=typeof r=="function"?r:(i,o)=>i===o||Am.isScalar(i)&&Am.isScalar(o)&&i.value===o.value;return e.some(i=>s(i.key,t))}Tm.mapIncludes=yE});var Im=_(Rm=>{"use strict";var Om=It(),bE=$t(),Pm=us(),wE=mo(),Cm=qc(),vE=Jc(),_m="All mapping items must start at the same column";function SE({composeNode:n,composeEmptyNode:e},t,r,s,i){let o=i?.nodeClass??bE.YAMLMap,a=new o(t.schema);t.atRoot&&(t.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=Pm.resolveProps(d,{indicator:"explicit-key-ind",next:u??p?.[0],offset:l,onError:s,parentIndent:r.indent,startOnNewline:!0}),y=!h.found;if(y){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||wE.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);t.atKey=!0;let v=h.end,O=u?n(t,u,h,s):e(t,v,d,null,h,s);t.schema.compat&&Cm.flowIndentCheck(r.indent,u,s),t.atKey=!1,vE.mapIncludes(t,a.items,O)&&s(v,"DUPLICATE_KEY","Map keys must be unique");let P=Pm.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=P.end,P.found){y&&(m?.type==="block-map"&&!P.hasNewline&&s(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&h.start<P.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?n(t,m,P,s):e(t,l,p,null,P,s);t.schema.compat&&Cm.flowIndentCheck(r.indent,m,s),l=E.range[2];let R=new Om.Pair(O,E);t.options.keepSourceTokens&&(R.srcToken=f),a.items.push(R)}else{y&&s(O.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),P.comment&&(O.comment?O.comment+=`
88
- `+P.comment:O.comment=P.comment);let E=new Om.Pair(O);t.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}Rm.resolveBlockMap=SE});var $m=_(Nm=>{"use strict";var kE=Lt(),xE=us(),EE=qc();function AE({composeNode:n,composeEmptyNode:e},t,r,s,i){let o=i?.nodeClass??kE.YAMLSeq,a=new o(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let l=r.offset,c=null;for(let{start:f,value:d}of r.items){let u=xE.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?n(t,d,u,s):e(t,u.end,f,null,u,s);t.schema.compat&&EE.flowIndentCheck(r.indent,d,s),l=p.range[2],a.items.push(p)}return a.range=[r.offset,l,c??l],a}Nm.resolveBlockSeq=AE});var Hn=_(Lm=>{"use strict";function TE(n,e,t,r){let s="";if(n){let i=!1,o="";for(let a of n){let{source:l,type:c}=a;switch(c){case"space":i=!0;break;case"comment":{t&&!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}}Lm.resolveEnd=TE});var jm=_(Bm=>{"use strict";var OE=W(),PE=It(),Mm=$t(),CE=Lt(),_E=Hn(),Dm=us(),RE=mo(),IE=Jc(),Wc="Block collections are not allowed within flow collections",Kc=n=>n&&(n.type==="block-map"||n.type==="block-seq");function NE({composeNode:n,composeEmptyNode:e},t,r,s,i){let o=r.start.source==="{",a=o?"flow map":"flow sequence",l=i?.nodeClass??(o?Mm.YAMLMap:CE.YAMLSeq),c=new l(t.schema);c.flow=!0;let f=t.atRoot;f&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let d=r.offset+r.start.source.length;for(let y=0;y<r.items.length;++y){let v=r.items[y],{start:O,key:P,sep:E,value:R}=v,I=Dm.resolveProps(O,{flow:a,indicator:"explicit-key-ind",next:P??E?.[0],offset:d,onError:s,parentIndent:r.indent,startOnNewline:!1});if(!I.found){if(!I.anchor&&!I.tag&&!E&&!R){y===0&&I.comma?s(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):y<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&&t.options.strict&&RE.containsNewline(P)&&s(P,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===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];OE.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?n(t,R,I,s):e(t,I.end,E,null,I,s);c.items.push(L),d=L.range[2],Kc(R)&&s(L.range,"BLOCK_IN_FLOW",Wc)}else{t.atKey=!0;let L=I.end,A=P?n(t,P,I,s):e(t,L,O,null,I,s);Kc(P)&&s(A.range,"BLOCK_IN_FLOW",Wc),t.atKey=!1;let q=Dm.resolveProps(E??[],{flow:a,indicator:"map-value-ind",next:R,offset:A.range[2],onError:s,parentIndent:r.indent,startOnNewline:!1});if(q.found){if(!o&&!I.found&&t.options.strict){if(E)for(let U of E){if(U===q.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<q.found.offset-1024&&s(q.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(q.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let X=R?n(t,R,q,s):q.found?e(t,q.end,E,null,q,s):null;X?Kc(R)&&s(X.range,"BLOCK_IN_FLOW",Wc):q.comment&&(A.comment?A.comment+=`
91
- `+q.comment:A.comment=q.comment);let G=new PE.Pair(A,X);if(t.options.keepSourceTokens&&(G.srcToken=v),o){let U=c;IE.mapIncludes(t,U.items,A)&&s(L,"DUPLICATE_KEY","Map keys must be unique"),U.items.push(G)}else{let U=new Mm.YAMLMap(t.schema);U.flow=!0,U.items.push(G);let ge=(X??A).range;U.range=[A.range[0],ge[1],ge[2]],c.items.push(U)}d=X?X.range[2]:q.end}}let u=o?"}":"]",[p,...m]=r.end,h=d;if(p?.source===u)h=p.offset+p.source.length;else{let y=a[0].toUpperCase()+a.substring(1),v=f?`${y} must end with a ${u}`:`${y} in block collection must be sufficiently indented and end with a ${u}`;s(d,f?"MISSING_CHAR":"BAD_INDENT",v),p&&p.source.length!==1&&m.unshift(p)}if(m.length>0){let y=_E.resolveEnd(m,h,t.options.strict,s);y.comment&&(c.comment?c.comment+=`
92
- `+y.comment:c.comment=y.comment),c.range=[r.offset,h,y.offset]}else c.range=[r.offset,h,h];return c}Bm.resolveFlowCollection=NE});var Um=_(Fm=>{"use strict";var $E=W(),LE=ne(),ME=$t(),DE=Lt(),BE=Im(),jE=$m(),FE=jm();function Hc(n,e,t,r,s,i){let o=t.type==="block-map"?BE.resolveBlockMap(n,e,t,r,i):t.type==="block-seq"?jE.resolveBlockSeq(n,e,t,r,i):FE.resolveFlowCollection(n,e,t,r,i),a=o.constructor;return s==="!"||s===a.tagName?(o.tag=a.tagName,o):(s&&(o.tag=s),o)}function UE(n,e,t,r,s){let i=r.tag,o=i?e.directives.tagName(i.source,u=>s(i,"TAG_RESOLVE_FAILED",u)):null;if(t.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=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===ME.YAMLMap.tagName&&a==="map"||o===DE.YAMLSeq.tagName&&a==="seq")return Hc(n,e,t,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),Hc(n,e,t,s,o)}let c=Hc(n,e,t,s,o,l),f=l.resolve?.(c,u=>s(i,"TAG_RESOLVE_FAILED",u),e.options)??c,d=$E.isNode(f)?f:new LE.Scalar(f);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}Fm.composeCollection=UE});var Yc=_(qm=>{"use strict";var zc=ne();function qE(n,e,t){let r=e.offset,s=JE(e,n.options.strict,t);if(!s)return{value:"",type:null,comment:"",range:[r,r,r]};let i=s.mode===">"?zc.Scalar.BLOCK_FOLDED:zc.Scalar.BLOCK_LITERAL,o=e.source?WE(e.source):[],a=o.length;for(let h=o.length-1;h>=0;--h){let y=o[h][1];if(y===""||y==="\r")a=h;else break}if(a===0){let h=s.chomp==="+"&&o.length>0?`
93
- `.repeat(Math.max(1,o.length-1)):"",y=r+s.length;return e.source&&(y+=e.source.length),{value:h,type:i,comment:s.comment,range:[r,y,y]}}let l=e.indent+s.indent,c=e.offset+s.length,f=0;for(let h=0;h<a;++h){let[y,v]=o[h];if(v===""||v==="\r")s.indent===0&&y.length>l&&(l=y.length);else{y.length<l&&t(c+y.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),s.indent===0&&(l=y.length),f=h,l===0&&!n.atRoot&&t(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=y.length+v.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[y,v]=o[h];c+=y.length+v.length+1;let O=v[v.length-1]==="\r";if(O&&(v=v.slice(0,-1)),v&&y.length<l){let E=`Block scalar lines must not be less indented than their ${s.indent?"explicit indentation indicator":"first line"}`;t(c-v.length-(O?2:1),"BAD_INDENT",E),y=""}i===zc.Scalar.BLOCK_LITERAL?(d+=u+y.slice(l)+v,u=`
95
- `):y.length>l||v[0]===" "?(u===" "?u=`
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=`
96
96
  `:!p&&u===`
97
97
  `&&(u=`
98
98
 
99
- `),d+=u+y.slice(l)+v,u=`
100
- `,p=!0):v===""?u===`
99
+ `),d+=u+g.slice(l)+E,u=`
100
+ `,p=!0):E===""?u===`
101
101
  `?d+=`
102
102
  `:u=`
103
- `:(d+=u+v,u=" ",p=!1)}switch(s.chomp){case"-":break;case"+":for(let h=a;h<o.length;++h)d+=`
103
+ `:(d+=u+E,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 JE({offset:n,props:e},t,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=n+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":t&&!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 WE(n){let e=n.split(/\n( *)/),t=e[0],r=t.match(/^( *)/),i=[r?.[1]?[r[1],t.slice(r[1].length)]:["",t]];for(let o=1;o<e.length;o+=2)i.push([e[o],e[o+1]]);return i}qm.resolveBlockScalar=qE});var Gc=_(Wm=>{"use strict";var Vc=ne(),KE=Hn();function HE(n,e,t){let{offset:r,type:s,source:i,end:o}=n,a,l,c=(u,p,m)=>t(r+u,p,m);switch(s){case"scalar":a=Vc.Scalar.PLAIN,l=zE(i,c);break;case"single-quoted-scalar":a=Vc.Scalar.QUOTE_SINGLE,l=YE(i,c);break;case"double-quoted-scalar":a=Vc.Scalar.QUOTE_DOUBLE,l=VE(i,c);break;default:return t(n,"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=KE.resolveEnd(o,f,e,t);return{value:l,type:a,comment:d.comment,range:[r,f,d.offset]}}function zE(n,e){let t="";switch(n[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${n[0]}`;break}case"@":case"`":{t=`reserved character ${n[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),Jm(n)}function YE(n,e){return(n[n.length-1]!=="'"||n.length===1)&&e(n.length,"MISSING_CHAR","Missing closing 'quote"),Jm(n.slice(1,-1)).replace(/''/g,"'")}function Jm(n){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
108
- `,"sy"),t=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
109
- `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,t=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=e.exec(n);if(!r)return n;let s=r[1],i=" ",o=e.lastIndex;for(t.lastIndex=o;r=t.exec(n);)r[1]===""?i===`
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?
108
+ `,"sy"),n=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
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=t.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,r=a.exec(n),s+i+(r?.[1]??"")}function VE(n,e){let t="";for(let r=1;r<n.length-1;++r){let s=n[r];if(!(s==="\r"&&n[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 rA(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}=GE(n,r);t+=i,r=o}else if(s==="\\"){let i=n[++r],o=XE[i];if(o)t+=o;else if(i===`
114
- `)for(i=n[r+1];i===" "||i===" ";)i=n[++r+1];else if(i==="\r"&&n[r+1]===`
115
- `)for(i=n[++r+1];i===" "||i===" ";)i=n[++r+1];else if(i==="x"||i==="u"||i==="U"){let a={x:2,u:4,U:8}[i];t+=QE(n,r+1,a,e),r+=a}else{let a=n.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),t+=a}}else if(s===" "||s===" "){let i=r,o=n[r+1];for(;o===" "||o===" ";)o=n[++r+1];o!==`
116
- `&&!(o==="\r"&&n[r+2]===`
117
- `)&&(t+=r>i?n.slice(i,r+1):s)}else t+=s}return(n[n.length-1]!=='"'||n.length===1)&&e(n.length,"MISSING_CHAR",'Missing closing "quote'),t}function GE(n,e){let t="",r=n[e+1];for(;(r===" "||r===" "||r===`
118
- `||r==="\r")&&!(r==="\r"&&n[e+2]!==`
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===`
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!==`
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===`
118
+ `||r==="\r")&&!(r==="\r"&&t[e+2]!==`
119
119
  `);)r===`
120
- `&&(t+=`
121
- `),e+=1,r=n[e+1];return t||(t=" "),{fold:t,offset:e}}var XE={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 QE(n,e,t,r){let s=n.substr(e,t),o=s.length===t&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;if(isNaN(o)){let a=n.substr(e-2,t+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}Wm.resolveFlowScalar=HE});var zm=_(Hm=>{"use strict";var an=W(),Km=ne(),ZE=Yc(),eA=Gc();function tA(n,e,t,r){let{value:s,type:i,comment:o,range:a}=e.type==="block-scalar"?ZE.resolveBlockScalar(n,e,r):eA.resolveFlowScalar(e,n.options.strict,r),l=t?n.directives.tagName(t.source,d=>r(t,"TAG_RESOLVE_FAILED",d)):null,c;n.options.stringKeys&&n.atKey?c=n.schema[an.SCALAR]:l?c=nA(n.schema,s,l,t,r):e.type==="scalar"?c=rA(n,s,e,r):c=n.schema[an.SCALAR];let f;try{let d=c.resolve(s,u=>r(t??e,"TAG_RESOLVE_FAILED",u),n.options);f=an.isScalar(d)?d:new Km.Scalar(d)}catch(d){let u=d instanceof Error?d.message:String(d);r(t??e,"TAG_RESOLVE_FAILED",u),f=new Km.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 nA(n,e,t,r,s){if(t==="!")return n[an.SCALAR];let i=[];for(let a of n.tags)if(!a.collection&&a.tag===t)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=n.knownTags[t];return o&&!o.collection?(n.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(s(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),n[an.SCALAR])}function rA({atKey:n,directives:e,schema:t},r,s,i){let o=t.tags.find(a=>(a.default===!0||n&&a.default==="key")&&a.test?.test(r))||t[an.SCALAR];if(t.compat){let a=t.compat.find(l=>l.default&&l.test?.test(r))??t[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}Hm.composeScalar=tA});var Vm=_(Ym=>{"use strict";function sA(n,e,t){if(e){t??(t=e.length);for(let r=t-1;r>=0;--r){let s=e[r];switch(s.type){case"space":case"comment":case"newline":n-=s.source.length;continue}for(s=e[++r];s?.type==="space";)n+=s.source.length,s=e[++r];break}}return n}Ym.emptyScalarPosition=sA});var Qm=_(Qc=>{"use strict";var iA=Jr(),oA=W(),aA=Um(),Gm=zm(),lA=Hn(),cA=Vm(),uA={composeNode:Xm,composeEmptyNode:Xc};function Xm(n,e,t,r){let s=n.atKey,{spaceBefore:i,comment:o,anchor:a,tag:l}=t,c,f=!0;switch(e.type){case"alias":c=dA(n,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=Gm.composeScalar(n,e,l,r),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=aA.composeCollection(uA,n,e,t,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=Xc(n,e.offset,void 0,null,t,r),f=!1}}return a&&c.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),s&&n.options.stringKeys&&(!oA.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),n.options.keepSourceTokens&&f&&(c.srcToken=e),c}function Xc(n,e,t,r,{spaceBefore:s,comment:i,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:cA.emptyScalarPosition(e,t,r),indent:-1,source:""},d=Gm.composeScalar(n,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 dA({options:n},{offset:e,source:t,end:r},s){let i=new iA.Alias(t.substring(1));i.source===""&&s(e,"BAD_ALIAS","Alias cannot be an empty string"),i.source.endsWith(":")&&s(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+t.length,a=lA.resolveEnd(r,o,n.strict,s);return i.range=[e,o,a.offset],a.comment&&(i.comment=a.comment),i}Qc.composeEmptyNode=Xc;Qc.composeNode=Xm});var tg=_(eg=>{"use strict";var fA=os(),Zm=Qm(),pA=Hn(),hA=us();function mA(n,e,{offset:t,start:r,value:s,end:i},o){let a=Object.assign({_directives:e},n),l=new fA.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=hA.resolveProps(r,{indicator:"doc-start",next:s??i?.[0],offset:t,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?Zm.composeNode(c,s,f,o):Zm.composeEmptyNode(c,f.end,r,null,f,o);let d=l.contents.range[2],u=pA.resolveEnd(i,d,!1,o);return u.comment&&(l.comment=u.comment),l.range=[t,d,u.offset],l}eg.composeDoc=mA});var eu=_(sg=>{"use strict";var gA=bi("process"),yA=jl(),bA=os(),ds=cs(),ng=W(),wA=tg(),vA=Hn();function fs(n){if(typeof n=="number")return[n,n+1];if(Array.isArray(n))return n.length===2?n:[n[0],n[1]];let{offset:e,source:t}=n;return[e,e+(typeof t=="string"?t.length:1)]}function rg(n){let e="",t=!1,r=!1;for(let s=0;s<n.length;++s){let i=n[s];switch(i[0]){case"#":e+=(e===""?"":r?`
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?`
123
123
 
124
124
  `:`
125
- `)+(i.substring(1)||" "),t=!0,r=!1;break;case"%":n[s+1]?.[0]!=="#"&&(s+=1),t=!1;break;default:t||(r=!0),t=!1}}return{comment:e,afterEmptyLine:r}}var Zc=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,r,s,i)=>{let o=fs(t);i?this.warnings.push(new ds.YAMLWarning(o,r,s)):this.errors.push(new ds.YAMLParseError(o,r,s))},this.directives=new yA.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:r,afterEmptyLine:s}=rg(this.prelude);if(r){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}
126
- ${r}`:r;else if(s||e.directives.docStart||!i)e.commentBefore=r;else if(ng.isCollection(i)&&!i.flow&&i.items.length>0){let o=i.items[0];ng.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${r}
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}
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}}t?(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:rg(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,r=-1){for(let s of e)yield*this.next(s);yield*this.end(t,r)}*next(e){switch(gA.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(t,r,s)=>{let i=fs(e);i[0]+=t,this.onError(i,"BAD_DIRECTIVE",r,s)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=wA.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new ds.YAMLParseError(fs(e),"UNEXPECTED_TOKEN",t);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 ds.YAMLParseError(fs(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let t=vA.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let r=this.doc.comment;this.doc.comment=r?`${r}
129
- ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new ds.YAMLParseError(fs(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-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 bA.Document(void 0,r);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),s.range=[0,t,t],this.decorate(s,!1),yield s}}};sg.Composer=Zc});var ag=_(go=>{"use strict";var SA=Yc(),kA=Gc(),xA=cs(),ig=Yr();function EA(n,e=!0,t){if(n){let r=(s,i,o)=>{let a=typeof s=="number"?s:Array.isArray(s)?s[0]:s.offset;if(t)t(a,i,o);else throw new xA.YAMLParseError([a,a+1],i,o)};switch(n.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return kA.resolveFlowScalar(n,e,r);case"block-scalar":return SA.resolveBlockScalar({options:{strict:e}},n,r)}}return null}function AA(n,e){let{implicitKey:t=!1,indent:r,inFlow:s=!1,offset:i=-1,type:o="PLAIN"}=e,a=ig.stringifyString({type:o,value:n},{implicitKey:t,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(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:`
130
130
  `}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
131
131
  `),f=a.substring(0,c),d=a.substring(c+1)+`
132
- `,u=[{type:"block-scalar-header",offset:i,indent:r,source:f}];return og(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 TA(n,e,t={}){let{afterKey:r=!1,implicitKey:s=!1,inFlow:i=!1,type:o}=t,a="indent"in n?n.indent:null;if(r&&typeof a=="number"&&(a+=2),!o)switch(n.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=n.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=ig.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">":OA(n,l);break;case'"':tu(n,l,"double-quoted-scalar");break;case"'":tu(n,l,"single-quoted-scalar");break;default:tu(n,l,"scalar")}}function OA(n,e){let t=e.indexOf(`
134
- `),r=e.substring(0,t),s=e.substring(t+1)+`
135
- `;if(n.type==="block-scalar"){let i=n.props[0];if(i.type!=="block-scalar-header")throw new Error("Invalid block scalar header");i.source=r,n.source=s}else{let{offset:i}=n,o="indent"in n?n.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:r}];og(a,"end"in n?n.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
136
- `});for(let l of Object.keys(n))l!=="type"&&l!=="offset"&&delete n[l];Object.assign(n,{type:"block-scalar",indent:o,props:a,source:s})}}function og(n,e){if(e)for(let t of e)switch(t.type){case"space":case"comment":n.push(t);break;case"newline":return n.push(t),!0}return!1}function tu(n,e,t){switch(n.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":n.type=t,n.source=e;break;case"block-scalar":{let r=n.props.slice(1),s=e.length;n.props[0].type==="block-scalar-header"&&(s-=n.props[0].source.length);for(let i of r)i.offset+=s;delete n.props,Object.assign(n,{type:t,source:e,end:r});break}case"block-map":case"block-seq":{let s={type:"newline",offset:n.offset+e.length,indent:n.indent,source:`
137
- `};delete n.items,Object.assign(n,{type:t,source:e,end:[s]});break}default:{let r="indent"in n?n.indent:-1,s="end"in n&&Array.isArray(n.end)?n.end.filter(i=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(n))i!=="type"&&i!=="offset"&&delete n[i];Object.assign(n,{type:t,indent:r,source:e,end:s})}}}go.createScalarToken=AA;go.resolveAsScalar=EA;go.setScalarValue=TA});var cg=_(lg=>{"use strict";var PA=n=>"type"in n?bo(n):yo(n);function bo(n){switch(n.type){case"block-scalar":{let e="";for(let t of n.props)e+=bo(t);return e+n.source}case"block-map":case"block-seq":{let e="";for(let t of n.items)e+=yo(t);return e}case"flow-collection":{let e=n.start.source;for(let t of n.items)e+=yo(t);for(let t of n.end)e+=t.source;return e}case"document":{let e=yo(n);if(n.end)for(let t of n.end)e+=t.source;return e}default:{let e=n.source;if("end"in n&&n.end)for(let t of n.end)e+=t.source;return e}}}function yo({start:n,key:e,sep:t,value:r}){let s="";for(let i of n)s+=i.source;if(e&&(s+=bo(e)),t)for(let i of t)s+=i.source;return r&&(s+=bo(r)),s}lg.stringify=PA});var pg=_(fg=>{"use strict";var nu=Symbol("break visit"),CA=Symbol("skip children"),ug=Symbol("remove item");function ln(n,e){"type"in n&&n.type==="document"&&(n={start:n.start,value:n.value}),dg(Object.freeze([]),n,e)}ln.BREAK=nu;ln.SKIP=CA;ln.REMOVE=ug;ln.itemAtPath=(n,e)=>{let t=n;for(let[r,s]of e){let i=t?.[r];if(i&&"items"in i)t=i.items[s];else return}return t};ln.parentCollection=(n,e)=>{let t=ln.itemAtPath(n,e.slice(0,-1)),r=e[e.length-1][0],s=t?.[r];if(s&&"items"in s)return s;throw new Error("Parent collection not found")};function dg(n,e,t){let r=t(e,n);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=dg(Object.freeze(n.concat([[s,o]])),i.items[o],t);if(typeof a=="number")o=a-1;else{if(a===nu)return nu;a===ug&&(i.items.splice(o,1),o-=1)}}typeof r=="function"&&s==="key"&&(r=r(e,n))}}return typeof r=="function"?r(e,n):r}fg.visit=ln});var wo=_(ve=>{"use strict";var ru=ag(),_A=cg(),RA=pg(),su="\uFEFF",iu="",ou="",au="",IA=n=>!!n&&"items"in n,NA=n=>!!n&&(n.type==="scalar"||n.type==="single-quoted-scalar"||n.type==="double-quoted-scalar"||n.type==="block-scalar");function $A(n){switch(n){case su:return"<BOM>";case iu:return"<DOC>";case ou:return"<FLOW_END>";case au:return"<SCALAR>";default:return JSON.stringify(n)}}function LA(n){switch(n){case su:return"byte-order-mark";case iu:return"doc-mode";case ou:return"flow-error-end";case au:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
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(`
134
+ `),r=e.substring(0,n),s=e.substring(n+1)+`
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
+ `});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`
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(n[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=ru.createScalarToken;ve.resolveAsScalar=ru.resolveAsScalar;ve.setScalarValue=ru.setScalarValue;ve.stringify=_A.stringify;ve.visit=RA.visit;ve.BOM=su;ve.DOCUMENT=iu;ve.FLOW_END=ou;ve.SCALAR=au;ve.isCollection=IA;ve.isScalar=NA;ve.prettyToken=$A;ve.tokenType=LA});var uu=_(mg=>{"use strict";var ps=wo();function He(n){switch(n){case void 0:case" ":case`
140
- `:case"\r":case" ":return!0;default:return!1}}var hg=new Set("0123456789ABCDEFabcdef"),MA=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),vo=new Set(",[]{}"),DA=new Set(` ,[]{}
141
- \r `),lu=n=>!n||DA.has(n),cu=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,t=!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=!t;let r=this.next??"stream";for(;r&&(t||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===`
142
- `?!0:t==="\r"?this.buffer[e+1]===`
143
- `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let r=0;for(;t===" ";)t=this.buffer[++r+e];if(t==="\r"){let s=this.buffer[r+e+1];if(s===`
144
- `||!s&&!this.atEnd)return e+r+1}return t===`
145
- `||r>=this.indentNext||!t&&!this.atEnd?e+r:-1}if(t==="-"||t==="."){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]===ps.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,r=e.indexOf("#");for(;r!==-1;){let i=e[r-1];if(i===" "||i===" "){t=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let i=e[t-1];if(i===" "||i===" ")t-=1;else break}let s=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-s),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield ps.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 t=this.peek(3);if((t==="---"||t==="...")&&He(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"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,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&He(t)){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 t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);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(lu),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,r=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=r=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>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 ps.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(lu),"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),t=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;t!==-1&&this.buffer[t+1]==="'";)t=this.buffer.indexOf("'",t+2);else for(;t!==-1;){let i=0;for(;this.buffer[t-1-i]==="\\";)i+=1;if(i%2===0)break;t=this.buffer.indexOf('"',t+1)}let r=this.buffer.substring(0,t),s=r.indexOf(`
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===`
142
+ `?!0:n==="\r"?this.buffer[e+1]===`
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
+ `||!s&&!this.atEnd)return e+r+1}return n===`
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(`
147
147
  `,this.pos);if(s!==-1){for(;s!==-1;){let i=this.continueScalar(s+1);if(i===-1)break;s=r.indexOf(`
148
- `,i)}s!==-1&&(t=s-(r[s-1]==="\r"?2:1))}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil(t=>He(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,r;e:for(let i=this.pos;r=this.buffer[i];++i)switch(r){case" ":t+=1;break;case`
149
- `:e=i,t=0;break;case"\r":{let o=this.buffer[i+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
150
- `)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=t: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(`
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
+ `: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
+ `)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+t>a)e=i;else break}while(!0);return yield ps.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=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&&vo.has(i))break;t=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 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===`
154
154
  `?(r+=1,s=`
155
- `,i=this.buffer[r+1]):t=r),i==="#"||e&&vo.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&&vo.has(s))break;t=r}return!s&&!this.atEnd?this.setNext("plain-scalar"):(yield ps.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(t&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(lu))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,t=this.charAt(1);if(He(t)||e&&vo.has(t))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,t=this.buffer[e];for(;!He(t)&&t!==">";)t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(MA.has(t))t=this.buffer[++e];else if(t==="%"&&hg.has(this.buffer[e+1])&&hg.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
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===`
157
157
  `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
158
- `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,r;do r=this.buffer[++t];while(r===" "||e&&r===" ");let s=t-this.pos;return s>0&&(yield this.buffer.substr(this.pos,s),this.pos=t),s}*pushUntil(e){let t=this.pos,r=this.buffer[t];for(;!e(r);)r=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};mg.Lexer=cu});var fu=_(gg=>{"use strict";var du=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,r=this.lineStarts.length;for(;t<r;){let i=t+r>>1;this.lineStarts[i]<e?t=i+1:r=i}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let s=this.lineStarts[t-1];return{line:t,col:e-s+1}}}};gg.LineCounter=du});var hu=_(Sg=>{"use strict";var BA=bi("process"),yg=wo(),jA=uu();function Mt(n,e){for(let t=0;t<n.length;++t)if(n[t].type===e)return!0;return!1}function bg(n){for(let e=0;e<n.length;++e)switch(n[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function vg(n){switch(n?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function So(n){switch(n.type){case"document":return n.start;case"block-map":{let e=n.items[n.items.length-1];return e.sep??e.start}case"block-seq":return n.items[n.items.length-1].start;default:return[]}}function zn(n){if(n.length===0)return[];let e=n.length;e:for(;--e>=0;)switch(n[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;n[++e]?.type==="space";);return n.splice(e,n.length)}function wg(n){if(n.start.type==="flow-seq-start")for(let e of n.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,vg(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 pu=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 jA.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,t))yield*this.next(r);t||(yield*this.end())}*next(e){if(this.source=e,BA.env.LOG_TOKENS&&console.log("|",yg.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=yg.tokenType(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){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 t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let r=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in r?r.indent:0:t.type==="flow-collection"&&r.type==="document"&&(t.indent=0),t.type==="flow-collection"&&wg(t),r.type){case"document":r.value=t;break;case"block-scalar":r.props.push(t);break;case"block-map":{let s=r.items[r.items.length-1];if(s.value){r.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(s.sep)s.value=t;else{Object.assign(s,{key:t,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:t}):s.value=t;break}case"flow-collection":{let s=r.items[r.items.length-1];!s||s.value?r.items.push({start:[],key:t,sep:[]}):s.sep?s.value=t:Object.assign(s,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let s=t.items[t.items.length-1];s&&!s.sep&&!s.value&&s.start.length>0&&bg(s.start)===-1&&(t.indent===0||s.start.every(i=>i.type!=="comment"||i.indent<t.indent))&&(r.type==="document"?r.end=s.start:r.items.push({start:s.start}),t.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":{bg(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 t=this.startBlockValue(e);t?this.stack.push(t):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 t=So(this.peek(2)),r=zn(t),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 t=this.source.indexOf(`
159
- `)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
160
- `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let r="end"in t.value?t.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 t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,t.start),s.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,s=r&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",i=[];if(s&&t.sep&&!t.value){let o=[];for(let a=0;a<t.sep.length;++a){let l=t.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=t.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":s||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):s||t.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(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Mt(t.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(vg(t.key)&&!Mt(t.sep,"newline")){let o=zn(t.start),a=t.key,l=t.sep;l.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:l}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else if(Mt(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=zn(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||s?e.items.push({start:i,key:null,sep:[this.sourceToken]}):Mt(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{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||t.value?(e.items.push({start:i,key:o,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(o):(Object.assign(t,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!t.explicitKey&&t.sep&&!Mt(t.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 t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let r="end"in t.value?t.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 t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let s=e.items[e.items.length-2]?.value?.end;if(Array.isArray(s)){Array.prototype.push.apply(s,t.start),s.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||Mt(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.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 t=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":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let s=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:s,sep:[]}):t.sep?this.stack.push(s):Object.assign(t,{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=So(r),i=zn(s);wg(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 t=this.source.indexOf(`
161
- `)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
162
- `,t)+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 t=So(e),r=zn(t);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 t=So(e),r=zn(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!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())}}};Sg.Parser=pu});var Tg=_(ms=>{"use strict";var kg=eu(),FA=os(),hs=cs(),UA=Ql(),qA=W(),JA=fu(),xg=hu();function Eg(n){let e=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||e&&new JA.LineCounter||null,prettyErrors:e}}function WA(n,e={}){let{lineCounter:t,prettyErrors:r}=Eg(e),s=new xg.Parser(t?.addNewLine),i=new kg.Composer(e),o=Array.from(i.compose(s.parse(n)));if(r&&t)for(let a of o)a.errors.forEach(hs.prettifyError(n,t)),a.warnings.forEach(hs.prettifyError(n,t));return o.length>0?o:Object.assign([],{empty:!0},i.streamInfo())}function Ag(n,e={}){let{lineCounter:t,prettyErrors:r}=Eg(e),s=new xg.Parser(t?.addNewLine),i=new kg.Composer(e),o=null;for(let a of i.compose(s.parse(n),!0,n.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new hs.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&t&&(o.errors.forEach(hs.prettifyError(n,t)),o.warnings.forEach(hs.prettifyError(n,t))),o}function KA(n,e,t){let r;typeof e=="function"?r=e:t===void 0&&e&&typeof e=="object"&&(t=e);let s=Ag(n,t);if(!s)return null;if(s.warnings.forEach(i=>UA.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},t))}function HA(n,e,t){let r=null;if(typeof e=="function"||Array.isArray(e)?r=e:t===void 0&&e&&(t=e),typeof t=="string"&&(t=t.length),typeof t=="number"){let s=Math.round(t);t=s<1?void 0:s>8?{indent:8}:{indent:s}}if(n===void 0){let{keepUndefined:s}=t??e??{};if(!s)return}return qA.isDocument(n)&&!r?n.toString(t):new FA.Document(n,r,t).toString(t)}ms.parse=KA;ms.parseAllDocuments=WA;ms.parseDocument=Ag;ms.stringify=HA});var Pg=_(H=>{"use strict";var zA=eu(),YA=os(),VA=$c(),mu=cs(),GA=Jr(),Dt=W(),XA=It(),QA=ne(),ZA=$t(),eT=Lt(),tT=wo(),nT=uu(),rT=fu(),sT=hu(),ko=Tg(),Og=jr();H.Composer=zA.Composer;H.Document=YA.Document;H.Schema=VA.Schema;H.YAMLError=mu.YAMLError;H.YAMLParseError=mu.YAMLParseError;H.YAMLWarning=mu.YAMLWarning;H.Alias=GA.Alias;H.isAlias=Dt.isAlias;H.isCollection=Dt.isCollection;H.isDocument=Dt.isDocument;H.isMap=Dt.isMap;H.isNode=Dt.isNode;H.isPair=Dt.isPair;H.isScalar=Dt.isScalar;H.isSeq=Dt.isSeq;H.Pair=XA.Pair;H.Scalar=QA.Scalar;H.YAMLMap=ZA.YAMLMap;H.YAMLSeq=eT.YAMLSeq;H.CST=tT;H.Lexer=nT.Lexer;H.LineCounter=rT.LineCounter;H.Parser=sT.Parser;H.parse=ko.parse;H.parseAllDocuments=ko.parseAllDocuments;H.parseDocument=ko.parseDocument;H.stringify=ko.stringify;H.visit=Og.visit;H.visitAsync=Og.visitAsync});function oT(n){try{return JSON.parse(n.trim()),!0}catch{return!1}}function aT(n){let e=n.trim();if(!e.startsWith("<"))return!1;let t=e.match(iT);return t?Br(e,t[1])!==null:!1}function lT(n){let e=n.trim();if(!e.match(/^(---|#|\w+:|-)/)||"[{<".includes(e[0]))return!1;try{let t=Cg.parse(e);return t!==null&&typeof t=="object"}catch{return!1}}function _g(n){return oT(n)||aT(n)||lT(n)}var Cg,iT,gu=k(()=>{Fp();Cg=fk(Pg(),1),iT=/<([a-zA-Z_][\w.-]*)/});function cT(n){if(!n?.trim())return[];let e=n.replace(/\r\n/g,`
163
- `),t=e.trim();if(_g(t))return[{text:t,startLine:1,endLine:e.split(`
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(`
159
+ `)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
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
+ `)+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,`
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 xo(n){return cT(n).map(e=>e.text)}var Rg,Ig=k(()=>{gu();Rg=`
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=`
167
167
 
168
168
 
169
- `});function Eo(n){if(typeof n!="string")throw new TypeError("Expected a string");return n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var Ng=k(()=>{});var uT,dT,yu,$g=k(()=>{uT=[["\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","-"]],dT=new Map(uT),yu=dT});var Lg,Ao,bu,Mg=k(()=>{Lg=[["\xE6","ae"],["\xC6","Ae"],["\xF8","oe"],["\xD8","Oe"],["\xE5","aa"],["\xC5","Aa"]],Ao={sv:[["\xE4","a"],["\xC4","A"],["\xF6","o"],["\xD6","O"],["\xE5","a"],["\xC5","A"]],da:Lg,nb:Lg,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 n of Object.keys(Ao))Ao[n]=new Map(Ao[n]);bu=Ao});function wu(n,e){if(typeof n!="string")throw new TypeError(`Expected a string, got \`${typeof n}\``);e={customReplacements:[],...e};let t=pT(e.locale),r=yu,s=e.customReplacements.length>0||e.customReplacements.size>0;if(t||s){if(r=new Map(yu),t)for(let[i,o]of t)r.set(i,o);for(let[i,o]of e.customReplacements)r.set(i,o)}return n=n.normalize(),n=fT(n,r),n=n.normalize("NFD").replaceAll(/\p{Diacritic}/gu,"").normalize(),n=n.replaceAll(/\p{Dash_Punctuation}/gu,"-"),n}var fT,pT,Dg=k(()=>{$g();Mg();fT=(n,e)=>{for(let[t,r]of e)n=n.replaceAll(t,r);return n},pT=n=>{if(!n)return;let e=n.toLowerCase().replace(/^no(-|$)/,"nb$1");return bu[e]||bu[e.split("-")[0]]||void 0}});var hT,Bg,jg=k(()=>{hT=[["&"," and "],["\u{1F984}"," unicorn "],["\u2665"," love "]],Bg=hT});function vu(n,e){if(typeof n!="string")throw new TypeError(`Expected a string, got \`${typeof n}\``);e={separator:"-",lowercase:!0,decamelize:!0,customReplacements:[],preserveLeadingUnderscore:!1,preserveTrailingDash:!1,preserveCharacters:[],transliterate:!0,...e};let t=e.preserveLeadingUnderscore&&n.startsWith("_"),r=e.preserveTrailingDash&&n.endsWith("-");if(e.transliterate){let i=new Map([...Bg,...e.customReplacements]);n=wu(n,{customReplacements:i,locale:e.locale})}else if(e.customReplacements.length>0)for(let[i,o]of e.customReplacements)n=n.replaceAll(i,o);e.decamelize&&(n=mT(n));let s=yT(e);return e.lowercase&&(n=e.locale?n.toLocaleLowerCase(e.locale):n.toLowerCase()),n=n.replaceAll(/([a-zA-Z\d]+)['\u2019]([ts])(\s|$)/g,"$1$2$3"),n=n.replace(s,e.separator),n=n.replaceAll("\\",""),e.separator&&(n=gT(n,e.separator)),t&&(n=`_${n}`),r&&(n=`${n}-`),n}var mT,gT,yT,Fg=k(()=>{Ng();Dg();jg();mT=n=>n.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"),gT=(n,e)=>{let t=Eo(e);return n.replaceAll(new RegExp(`(?:${t}){2,}`,"g"),e).replaceAll(new RegExp(`^(?:${t})|(?:${t})$`,"g"),"")},yT=n=>{let e=String.raw`a-z\d`;if(e+=n.lowercase?"":"A-Z",n.transliterate===!1&&(e+=String.raw`\p{L}\p{N}`),n.preserveCharacters.length>0)for(let r of n.preserveCharacters){if(r===n.separator)throw new Error(`The separator character \`${n.separator}\` cannot be included in preserved characters: ${n.preserveCharacters}`);e+=Eo(r)}let t=n.transliterate?"g":"gu";return new RegExp(`[^${e}]+`,t)}});function Yn(n){return vu(n)}var Ug=k(()=>{Fg()});var Vn,qg,Jg=k(()=>{Vn={local:"local",ide:"ide",published:"published",inline:"inline"},qg=Object.values(Vn).map(n=>`'${n}'`).join(" | ")});var gs,Su,Wg=k(()=>{gs=` *, *::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 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; }
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; }
173
- html[data-theme="light"] { color-scheme: light; }`,Su=" html, body { height: 100%; }"});var Kg,Hg=k(()=>{Kg=`(function () {
173
+ html[data-theme="light"] { color-scheme: light; }`,Au=" html, body { height: 100%; }"});var Vg,Gg=S(()=>{Vg=`(function () {
174
174
  var W = window, D = document;
175
175
  var TAIL_MS = 1500, TOL = 2, THROTTLE_MS = 200;
176
176
  var SCROLL_KEYS = { ' ': 1, ArrowUp: 1, ArrowDown: 1, PageUp: 1, PageDown: 1, Home: 1, End: 1 };
@@ -238,7 +238,7 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
238
238
  top: function () { disarm(); write(0); report(0); },
239
239
  flush: flush
240
240
  };
241
- })();`});var zg,Yg=k(()=>{zg=`(function () {
241
+ })();`});var Xg,Qg=S(()=>{Xg=`(function () {
242
242
  var W = window;
243
243
  var rtData, rtInsight, rtHasInsight = false;
244
244
  var applyData, applyInsight, send;
@@ -292,39 +292,40 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
292
292
  return publish();
293
293
  }
294
294
  };
295
- })();`});var ee=k(()=>{Si();_l();Cp();Np();gu();Ig();Ug();Jg();Wg();Hg();Yg();ki()});function Te(n){return n.length>5e4?n.slice(0,5e4)+`
296
- \u2026[${n.length-5e4} more characters truncated]`:n}function Ne(n){let e=n.replace(bT,"").split(`
297
- `).map(i=>i.trim()).filter(Boolean),t=e[0];if(!t)return"";let r=t.length>300?t.slice(0,300).trimEnd()+"\u2026":t,s=e.length-1;return s>0?`${r} (+${s} line${s===1?"":"s"})`:r}var Se,bT,To,ys=k(()=>{"use strict";Se=(n,e,t=e+"s")=>`${n} ${n===1?e:t}`;bT=/\u001b\[[0-9;]*m/g;To=(n,e)=>`![pasted image](data:${e||"image/png"};base64,${n})`});import{closeSync as Gg,existsSync as wT,fstatSync as vT,openSync as Xg,readdirSync as ST,readSync as Qg,statSync as kT}from"fs";import{join as xT}from"path";function xu(n,e){let t;try{t=Xg(n,"r")}catch{return}try{let r=Buffer.alloc(e),s=Qg(t,r,0,e,0);return{text:r.subarray(0,s).toString("utf8"),bytes:s}}finally{Gg(t)}}function Oo(n,e){let t;try{t=Xg(n,"r")}catch{return}try{let r=vT(t).size,s=Math.min(e,r),i=Buffer.alloc(s),o=Qg(t,i,0,s,r-s);return{text:i.subarray(0,o).toString("utf8"),partial:r>s}}finally{Gg(t)}}function Po(n){if(!wT(n))return[];let e;try{e=ST(n)}catch{return[]}let t=[];for(let r of e){if(!r.endsWith(".jsonl"))continue;let s=xT(n,r);try{let i=kT(s);i.isFile()&&t.push({sessionId:r.slice(0,-6),file:s,mtime:i.mtimeMs})}catch{}}return t}var Co=k(()=>{"use strict"});var Bt,_o=k(()=>{"use strict";Bt=class{ensureHarnessSupport(){}childBriefs=!0;forRead(){return this}}});import{openSync as ET,readSync as AT,closeSync as TT,statSync as ny,readdirSync as ry,readFileSync as sy,existsSync as OT}from"fs";import{join as cn}from"path";import{homedir as PT}from"os";function CT(n){return n.replace(/[^a-zA-Z0-9]/g,"-")}function RT(n,e,t){let r=cn(Eu(n,e),t,_T),s;try{s=ry(r)}catch{return[]}let i=zT(n,t),o=[];for(let a of s){if(!a.endsWith(".jsonl"))continue;let l=cn(r,a),c;try{c=ny(l)}catch{continue}let f=a.slice(0,-6),d={};try{d=JSON.parse(sy(cn(r,`${f}.meta.json`),"utf8"))}catch{}let u=$T(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,running:!!u.running&&(i===void 0||c.mtimeMs>=i),label:d.description??"",kind:d.agentType===IT?void 0:d.agentType,model:d.model,spawnId:d.toolUseId,parentId:d.parentAgentId,depth:d.spawnDepth??1,stopped:!!d.stoppedByUser})}return o}function $T(n,e,t){let r=Zg.get(n);if(r&&r.size===e&&r.mtime===t)return{tokens:r.tokens,running:r.running};let s={};for(let i of NT){let o=Oo(n,i);if(!o)break;let a=o.text.split(`
298
- `);o.partial&&a.shift();let l=[];for(let f of a)if(f.trim())try{l.push(JSON.parse(f))}catch{}if(!l.length&&o.partial)continue;let c;for(let f=l.length-1;f>=0&&!c;f--)l[f]?.type==="assistant"&&(c=l[f].message?.usage);s={tokens:c&&(c.input_tokens??0)+(c.output_tokens??0)+(c.cache_read_input_tokens??0)+(c.cache_creation_input_tokens??0),running:iy(l)};break}return Zg.set(n,{size:e,mtime:t,...s}),s}function iy(n){let e;for(let i of n)(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(l=>l&&l.type==="text").map(l=>l.text??"").join(""):"";if(!(Array.isArray(i)&&i.some(l=>l&&l.type==="tool_result"))&&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 n){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 Io(n){let e=n?.type==="image"?n.source:void 0;return e?.type==="base64"&&e.data?To(e.data,e.media_type):""}function Au(n){return typeof n=="string"?Te(n):Array.isArray(n)?n.map(e=>{if(typeof e=="string")return Te(e);let t=e;return typeof t?.text=="string"?Te(t.text):t?.content!=null?Au(t.content):Io(t)}).join(`
299
- `):n==null?"":Te(JSON.stringify(n))}function LT(n){let e=n.trim();return!!e&&oy.some(t=>t.test(e))}function MT(n){let e=n.trim();return e?oy.some(t=>{let r=t.exec(e);return!!r&&r.index===0}):!0}function BT(n){return n.replace(DT,"")}function jT(n){let e=/^<command-name>([\s\S]*?)<\/command-name>/.exec(n)?.[1]?.trim();if(!e)return;let t=/<command-args>([\s\S]*?)<\/command-args>/.exec(n)?.[1]?.trim();return t?`${e} ${t}`:e}function jt(n){let e=BT(n).trim();return e?jT(e)??(LT(e)?"":e):""}function No(n){let e=FT.exec(n.trim());if(e)return{from:e[1],body:qT(e[2].replace(UT,""))}}function qT(n){let e=n.split(`
300
- `).filter(r=>r.trim()).map(r=>r.length-r.trimStart().length),t=e.length?Math.min(...e):0;return t?n.split(`
301
- `).map(r=>r.slice(t)).join(`
302
- `):n}function Ro(n){let e=No(n);return e?{type:"user",text:e.body,agent:{from:e.from}}:{type:"user",text:n}}function JT(n){let e=n.message?.content;return typeof e=="string"&&!!No(e)}function WT(n){let e=n.message?.content;return typeof e=="string"&&e.startsWith(ey)?e.slice(ey.length).trim():void 0}function Tu(n){return n?.type==="text"&&typeof n.text=="string"?jt(n.text):""}function Ou(n,e){if(typeof n=="string")return Ne(n);if(!n||typeof n!="object")return Ne(e);let t=n;if(t.type==="text"&&typeof t.file?.numLines=="number")return Se(t.file.numLines,"line");if(t.type==="image"){let r=ty(t.file?.originalSize);return r?`image (${r})`:"image"}if(t.type==="pdf"){let r=ty(t.file?.originalSize);return r?`PDF (${r})`:"PDF"}if(t.type==="parts"&&typeof t.file?.count=="number")return Se(t.file.count,"page");if(t.type==="file_unchanged")return"unchanged since last read";if(t.type==="create"&&typeof t.content=="string")return`created, ${Se(t.content.split(`
303
- `).length,"line")}`;if(t.mode==="content")return Se(t.numLines??0,"line");if(t.mode==="count")return`${Se(t.numMatches??0,"match","matches")} (${Se(t.numFiles??0,"file")})`;if(t.mode==="files_with_matches")return Se(t.numFiles??0,"file");if(Array.isArray(t.structuredPatch)){let r=0,s=0;for(let i of t.structuredPatch)for(let o of i?.lines??[])typeof o=="string"&&(o.startsWith("+")?r++:o.startsWith("-")&&s++);return`+${r} \u2212${s}`}return typeof t.stdout=="string"||typeof t.stderr=="string"?t.backgroundTaskId?"running in background":t.interrupted?"interrupted":Ne(t.stdout||t.stderr||"")||"no output":typeof t.code=="number"&&typeof t.codeText=="string"?`${t.code} ${t.codeText}`:typeof t.searchCount=="number"?Se(t.searchCount,"search","searches"):Array.isArray(t.matches)&&typeof t.total_deferred_tools=="number"?Se(t.matches.length,"tool"):Array.isArray(t.newTodos)?Se(t.newTodos.length,"todo"):typeof t.numFiles=="number"?Se(t.numFiles,"file"):Ne(e)}function bs(n){return!!n.isMeta}function KT(n){let e;try{e=ET(n,"r")}catch{return""}try{let r=65536;try{r=ny(n).size}catch{}let s=(c,f)=>{if(f<=0)return"";let d=Buffer.alloc(f),u=AT(e,d,0,f,c);return d.subarray(0,u).toString("utf8")},i=(c,f,d)=>{let u="";for(let p of c.split(`
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(`
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(`
301
+ `).filter(r=>r.trim()).map(r=>r.length-r.trimStart().length),n=e.length?Math.min(...e):0;return n?t.split(`
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(`
304
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(`
305
- `)){if(!c.trim())continue;let f;try{f=JSON.parse(c)}catch{continue}if(!f||bs(f)||f.type!=="user")continue;let d=f.message?.content,u="";typeof d=="string"?u=jt(d):Array.isArray(d)&&(u=d.map(Tu).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{TT(e)}}function Pu(n){let e=cn(n,"sessions"),t;try{t=ry(e)}catch{return[]}let r=[];for(let s of t)if(s.endsWith(".json"))try{let i=JSON.parse(sy(cn(e,s),"utf8"));if(!i?.sessionId)continue;process.kill(i.pid,0),r.push(i)}catch{}return r}function HT(n,e){return Pu(n).some(t=>t.sessionId===e)}function zT(n,e){let t=Pu(n).filter(r=>r.sessionId===e).map(r=>r.startedAt);return t.length&&t.every(r=>typeof r=="number")?Math.min(...t):void 0}function YT(n){return new Set(Pu(n).filter(e=>e.status==="busy").map(e=>e.sessionId))}var Eu,_T,IT,NT,Zg,oy,DT,FT,UT,ey,ty,Gn,$o=k(()=>{"use strict";ys();Co();_o();Eu=(n,e)=>cn(n,"projects",CT(e)),_T="subagents";IT="general-purpose",NT=[256*1024,4*1024*1024,64*1024*1024],Zg=new Map;oy=[/\[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];DT=/<ide_[a-z_]+>[\s\S]*?<\/ide_[a-z_]+>/gi;FT=/^(?:[^\n<][^\n]*\n)?<agent-message from="([^"]+)">\n([\s\S]*?)(?:\n?<\/agent-message>[\s\S]*)?$/,UT=/^\[[^\]\n]+\][\s\S]*?The report follows:\n/;ey=`The coordinator sent a message while you were working:
306
- `;ty=n=>typeof n!="number"?"":n<1024?`${n}B`:n<1048576?`${Math.round(n/1024)}KB`:`${(n/1048576).toFixed(1)}MB`;Gn=class extends Bt{constructor(t=cn(PT(),".claude")){super();this.root=t}displayName="Claude Mirror";detectsSelf(){return process.env.CLAUDECODE==="1"}detectsInstalled(){return OT(this.root)}sessionsDir(t){return Eu(this.root,t)}listSessionFiles(t){return Po(Eu(this.root,t))}listChildren(t,r){return RT(this.root,t,r)}callerSessionId(){return process.env.CLAUDE_CODE_SESSION_ID||void 0}parseEntry(t){try{return JSON.parse(t)}catch{return null}}idOf(t){return t.uuid}parentOf(t){return t.parentUuid}timestampOf(t){return t.timestamp}isSidechain(t,r){return!!t.isSidechain!=(r==="child")}isLeafType(t){return t.type==="user"||t.type==="assistant"}isRecoveryNoise(t){return!!t.isApiErrorMessage}apply(t,r){let s=WT(t);if(s)return{events:[Ro(s)]};if(bs(t)&&!JT(t))return{events:[]};let i=[];if(t.type==="user"){let o=t.message?.content;if(typeof o=="string"){let a=jt(o);a&&i.push(Ro(a))}else if(Array.isArray(o))for(let a of o)if(a?.type==="tool_result"){let l=Au(a.content);i.push({type:"tool_result",id:a.tool_use_id??"",content:l,isError:!!a.is_error,digest:Ou(t.toolUseResult,l)})}else{let l=Tu(a)||Io(a);l&&i.push(Ro(l))}return{events:i}}if(t.type==="attachment"&&t.attachment?.type==="queued_command"){let o=jt(Au(t.attachment.prompt));return o&&i.push(Ro(o)),{events:i}}if(t.type==="assistant"){let o=t.message?.content,a=Array.isArray(o)?o:[],l=a.filter(p=>p.type==="text").map(p=>p.text??"").filter(p=>!MT(p)).join(""),c=a.filter(p=>p.type==="thinking").map(p=>p.thinking??"").join(`
307
- `),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(t.timestamp??""),m=!isNaN(p)&&p>=r;i.push({type:"assistant",text:l,thinking:c,tools:f,live:m})}let d=t.message?.usage??t.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:t.message?.model}}return{events:i}}chainWorking(t){return iy(t)}sessionAlive(t){return HT(this.root,t)}sessionsWorking(t){return YT(this.root)}readPreview(t){return KT(t)}searchText(t){if(!t||bs(t)||t.type!=="user"&&t.type!=="assistant")return"";let r=t.message?.content,s="";if(typeof r=="string")s=jt(r);else if(Array.isArray(r)){let i=r;s=t.type==="user"?i.map(Tu).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 Lo,readdirSync as VT,existsSync as GT}from"fs";import{basename as ay,join as Cu,resolve as XT}from"path";import{homedir as ly}from"os";function ZT(n){let e=n.trimStart();return QT.some(t=>e.startsWith(t))}function Xn(n,e){return Array.isArray(n)?n.map(t=>typeof t?.text=="string"?e&&ZT(t.text)?"":Te(t.text):t?.type==="input_image"&&typeof t.image_url=="string"&&t.image_url.startsWith("data:")?`![image](${t.image_url})`:"").filter(Boolean).join(`
308
- `):""}function eO(n){return typeof n=="string"?Te(n):Xn(n,!1)}function tO(n,e){let t=e??"",r=pO(t);if(!r.length)return{name:n,input:{script:t}};let s=r.map(i=>_u(i.fn)&&ws(i.arg)?cO(String(i.arg.cmd??i.arg.command??"")):void 0);if(s.every(i=>i!==void 0))return{name:"read",input:cy(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}=uy(o);return{name:i,input:new Set(a).size===1?{path:a[0],patch:l}:{patch:l},pending:{kind:"patch",digest:sO(l)}}}return ws(o)?_u(i)?{name:n,input:rO(o)}:{name:i,input:o}:typeof o=="string"?{name:i,input:{arg:o}}:{name:n,input:{script:t}}}return{name:n,input:cy(r.map(({fn:i,arg:o})=>i==="apply_patch"&&typeof o=="string"?["patch",uy(o).diff]:_u(i)&&ws(o)?["command",o.cmd??o.command]:[i,o]))}}function rO(n){let e=Object.fromEntries(Object.entries(n).filter(([r])=>r!=="cmd"&&r!=="command"&&!nO.has(r))),t=n.command??n.cmd;return t===void 0?e:{command:t,...e}}function cy(n){let e={};for(let[t,r]of n){let s=t;for(let i=2;s in e;i++)s=`${t} (${i})`;e[s]=r}return e}function sO(n){let e=0,t=0;for(let r of n.split(`
309
- `))r.startsWith("+")&&!r.startsWith("+++")?e++:r.startsWith("-")&&!r.startsWith("---")&&t++;return`+${e} \u2212${t}`}function cO(n){let e=dO(n),t=e.map(uO);return e.length&&t.every(r=>r!==void 0)?t:void 0}function uO(n){let[e,...t]=n.split("|");if(!t.every(i=>lO.test(i.trim())))return;let r=fO(e);if(!iO.test(r[0]??""))return;let s=[];for(let i=1;i<r.length;i++){let o=r[i];if(oO.test(o)){i+1<r.length&&s.push(r[++i]);continue}if(aO.test(o)){i++;continue}o.startsWith("-")||/^\d+(,\d+)?p?$/.test(o)||s.push(o)}return s.length===1?s[0]:void 0}function dO(n){let e=[],t=0;for(let r=0;r<n.length;r++){let s=n[r];if(s==='"'||s==="'"){let o=n.indexOf(s,r+1);if(o<0)break;r=o;continue}let i=n.slice(r,r+2);(s===";"||s===`
310
- `||i==="&&"||i==="||")&&(e.push(n.slice(t,r)),(i==="&&"||i==="||")&&r++,t=r+1)}return e.push(n.slice(t)),e.map(r=>r.trim()).filter(Boolean)}function fO(n){return(n.match(/'[^']*'|"[^"]*"|\S+/g)??[]).map(e=>/^(['"])(.*)\1$/.exec(e)?.[2]??e)}function pO(n){let e=[],t=/tools\.([A-Za-z_$][\w$]*)\s*\(/g;for(let r=t.exec(n);r;r=t.exec(n)){let s=r.index+r[0].length-1,i=hy(n,s);if(i<0)break;e.push({fn:r[1],arg:py(n.slice(s+1,i).trim(),n)}),t.lastIndex=i+1}return e}function py(n,e){let t=n[0];if(t==='"'||t==="'"||t==="`")return Do(n,0)===n.length-1?my(n.slice(1,-1)):n;if(t==="{"){for(let r of[n,mO(n)])try{let s=JSON.parse(r);if(ws(s))return s}catch{}return n}if(/^[A-Za-z_$][\w$]*$/.test(n)){let r=new RegExp(`\\b(?:const|let|var)\\s+${n.replace(/\$/g,"\\$")}\\s*=\\s*`).exec(e);if(r){let s=r.index+r[0].length,i=e[s],o=i==='"'||i==="'"||i==="`"?Do(e,s):i==="{"?hy(e,s):-1;if(o>s)return py(e.slice(s,o+1),"")}}return n}function hy(n,e){let t=0;for(let r=e;r<n.length;r++){let s=n[r];if(s==='"'||s==="'"||s==="`"){if(r=Do(n,r),r<0)return-1}else if(s==="("||s==="["||s==="{")t++;else if((s===")"||s==="]"||s==="}")&&--t===0)return r}return-1}function Do(n,e){let t=n[e];for(let r=e+1;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]===t)return r;return-1}function my(n){return n.replace(/\\(?:u\{([0-9a-fA-F]+)\}|u([0-9a-fA-F]{4})|x([0-9a-fA-F]{2})|([\s\S]))/g,(e,t,r,s,i)=>t||r||s?String.fromCodePoint(parseInt(t||r||s,16)):hO[i]??i)}function mO(n){let e=/[A-Za-z_$][\w$]*(?=\s*:)/y,t=/,(?=\s*[}\]])/y,r="",s="";for(let i=0;i<n.length;i++){let o=n[i];if(o==='"'||o==="'"||o==="`"){let l=Do(n,i);if(l<0)return n;r+=JSON.stringify(my(n.slice(i+1,l))),i=l,s=o;continue}e.lastIndex=i;let a=s==="{"||s===","?e.exec(n):null;if(a){r+=`"${a[0]}"`,i+=a[0].length-1,s='"';continue}t.lastIndex=i,!t.test(n)&&(r+=o,/\s/.test(o)||(s=o))}return r}function uy(n){let e=[],t=[],r=!1;for(let s of n.split(/\r?\n/)){let i=/^\*\*\* (Update|Add|Delete) File: (.+)$/.exec(s);if(i){let o=i[2].trim();e.push(o),t.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:")){t.push(s);continue}r&&!s.startsWith("@@")&&t.push("@@"),r=!1,t.push(s)}}return r&&t.push("@@"),{files:e,diff:t.join(`
311
- `)}}function gO(n,e){let t=/^Script (completed|failed|running with cell ID (\d+))\nWall time [^\n]*\nOutput:\n([\s\S]*)$/.exec(n);if(!t)return{content:n,isError:!1,digest:Ne(n)};let r=t[3].replace(/^\n+/,"").replace(/^Script error:\n/,""),s=t[1]==="failed",i=yO(r);return i&&(r=i.output,i.exit_code&&(s=!0)),t[2]?{content:r,isError:s,digest:`running (cell ${t[2]})`}:e?.kind==="read"&&!s?{content:r,isError:s,digest:Se(bO(r),"line")}:e?.kind==="patch"&&!s?{content:e.digest,isError:s,digest:e.digest}:{content:r,isError:s,digest:Ne(r)}}function yO(n){if(n.startsWith("{"))try{let e=JSON.parse(n);if(ws(e)&&typeof e.output=="string")return{output:e.output,exit_code:typeof e.exit_code=="number"?e.exit_code:void 0}}catch{}}function wO(n){if(typeof n=="string"&&n)try{let e=JSON.parse(n);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}return{arguments:n??""}}function SO(n){let e,t;for(let r of vO){let s=Oo(n,r);if(s===void 0)return{};let i=s.text.split(`
312
- `);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(t===void 0&&l.type==="event_msg"&&l.payload?.type==="token_count"&&l.payload.info?.last_token_usage){let c=gy(l.payload.info.last_token_usage);t=c.in+c.out+c.cached+c.cacheCreate}if(o!==void 0&&e!==void 0&&t!==void 0)break}if(o!==void 0)return{ms:o,running:e??!0,tokens:t};if(!s.partial)break}return{running:e??!0,tokens:t}}function gy(n){return{in:Math.max(0,(n.input_tokens??0)-(n.cached_input_tokens??0)),out:n.output_tokens??0,cached:n.cached_input_tokens??0,cacheCreate:n.cache_write_input_tokens??0}}function fy(n){let t=xu(n,65536);if(t===void 0)return;let r=t.text.indexOf(`
313
- `);if(r<0)return t.bytes>=65536?{cwd:"",subagent:!1}:void 0;try{let s=JSON.parse(t.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:kO(i,o),model:xO(t.text,r)}}catch{return{cwd:"",subagent:!1}}}function kO(n,e){let t=e?.thread_spawn;if(!t)return;let r=t.parent_thread_id??n.parent_thread_id;if(!(!n.id||!r))return{id:n.id,parent:r,path:t.agent_path??"",role:t.agent_role??void 0,depth:t.depth??1}}function xO(n,e){for(let t of n.slice(e+1).split(`
314
- `))if(t.trim())try{let r=JSON.parse(t);if(r.type==="turn_context"&&typeof r.payload?.model=="string")return r.payload.model}catch{}}var QT,ws,_u,nO,iO,oO,aO,lO,hO,bO,Mo,dy,Qn,vO,Ru=k(()=>{"use strict";ys();_o();Co();QT=["<permissions instructions>","<apps_instructions>","<plugins_instructions>","<skills_instructions>","<recommended_plugins>","<environment_context>","<node_repl_review_evidence>","# AGENTS.md instructions for "];ws=n=>!!n&&typeof n=="object"&&!Array.isArray(n),_u=n=>n==="shell_command"||n==="exec_command",nO=new Set(["max_output_tokens","yield_time_ms","timeout_ms"]);iO=/^(Get-Content|gc|cat|type|nl|bat|sed|head|tail)$/i,oO=/^-(Path|LiteralPath)$/i,aO=/^-(Encoding|TotalCount|Head|Tail|ReadCount|Delimiter)$/i,lO=/^(sed -n|head|tail|Select-Object|select)(\s|$)/i;hO={n:`
315
- `,t:" ",r:"\r",b:"\b",f:"\f",v:"\v",0:"\0"};bO=n=>n?n.replace(/\r?\n$/,"").split(`
316
- `).length:0;Mo=n=>{let e=XT(n);return process.platform==="win32"?e.toLowerCase():e},dy=12e4,Qn=class n extends Bt{constructor(t=Cu(ly(),".codex","sessions")){super();this.root=t}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 n(this.root)}callerSessionId(t){let r=process.env.CODEX_THREAD_ID;return r?this.listSessionFiles(t).find(s=>s.sessionId.endsWith(r))?.sessionId:void 0}detectsInstalled(){return GT(Cu(ly(),".codex"))}sessionsDir(t){return this.root}listSessionFiles(t){let r=Mo(t),s=[];for(let i of this.#u()){let o=0,a=0;try{let f=Lo(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=fy(i),l===void 0)continue;this.#s.set(i,l)}if(l.subagent||Mo(l.cwd)!==r)continue;let c=ay(i,".jsonl");this.#o.set(c,i),s.push({sessionId:c,file:i,mtime:this.#e(i,o,a)})}return s}listChildren(t,r){let s=Mo(t),i=new Map,o,a;for(let f of this.#u()){let d=0,u=0,p;try{let v=Lo(f);if(!v.isFile())continue;d=v.size,u=v.mtimeMs,p=v.birthtimeMs||void 0}catch{continue}let m=this.#s.get(f);if(m===void 0){if(m=fy(f),m===void 0)continue;this.#s.set(f,m)}if(ay(f,".jsonl")===r&&(o=m.id,a=m.model),!m.spawn||Mo(m.cwd)!==s)continue;let{running:h,tokens:y}=this.#r(f,d,u);i.set(m.spawn.id,{file:f,mtime:this.#e(f,d,u),started:p,running:h,tokens:y,spawn:m.spawn,model:m.model})}if(!o)return[];let l=(f,d=new Set)=>{if(f.parent===o)return!0;if(d.has(f.id))return!1;d.add(f.id);let u=i.get(f.parent);return u?l(u.spawn,d):!1},c=[];for(let{file:f,mtime:d,started:u,running:p,tokens:m,spawn:h,model:y}of i.values())l(h)&&c.push({id:h.id,file:f,mtime:d,started:u,tokens:m,label:h.path.split("/").filter(Boolean).pop()??h.path,kind:h.role||void 0,model:y&&y!==a?y:void 0,parentId:i.has(h.parent)?h.parent:void 0,depth:h.depth,stopped:!1,running:p});return c}sessionsWorking(t){let r=new Set,s=Date.now();for(let{sessionId:i,file:o,mtime:a}of this.listSessionFiles(t)){if(s-a>=dy)continue;let l;try{let c=Lo(o);l=this.#r(o,c.size,c.mtimeMs)}catch{continue}l.running&&r.add(i)}return r}#e(t,r,s){return Math.max(s,this.#r(t,r,s).ms??0)}#r(t,r,s){let i=this.#d.get(t);if(i&&i.size===r&&i.mtime===s)return i;let o={size:r,mtime:s,...SO(t)};return this.#d.set(t,o),o}#u(){let t=[],r=s=>{try{return VT(s).map(i=>Cu(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")&&t.push(a);return t}parseEntry(t){let r;try{r=JSON.parse(t)}catch{return null}return!r||typeof r.type!="string"?null:r}idOf(t){return t.ord===void 0&&(this.#a(t),t.ord=String(this.#t++),t.parent=this.#l,this.#l=t.ord),t.ord}#a(t){let r=t.payload;if(t.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);t.inherited=this.#n}parentOf(t){return t.parent}timestampOf(t){return t.timestamp}isSidechain(t,r){return r==="child"&&!!t.inherited}isLeafType(t){return!0}isRecoveryNoise(t){return!1}apply(t,r){let s=[],i=t.payload;if(!i)return{events:s};let o=()=>{let a=Date.parse(t.timestamp??"");return!isNaN(a)&&a>=r};if(t.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"?tO(i.name??"",i.input):{name:i.name??"",input:wO(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,...gO(eO(i.output),l)}),{events:s}}return{events:s}}if(t.type==="event_msg"){if(i.type==="token_count"){let a=i.info?.last_token_usage;return a?{events:s,usage:gy(a)}:{events:s}}return{events:s}}return t.type==="turn_context"?{events:s,model:i.model}:{events:s}}chainWorking(t){let r=!1;for(let s of t){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(t){let r=this.#o.get(t);if(!r)return;let s;try{let i=Lo(r);s=this.#e(r,i.size,i.mtimeMs)}catch{return}return Date.now()-s<dy}readPreview(t){for(let r of(xu(t,256*1024)?.text??"").split(`
317
- `))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(t){if(t?.type!=="response_item"||t.payload?.type!=="message")return"";let r=t.payload.role;return r!=="user"&&r!=="assistant"?"":Xn(t.payload.content,r==="user").replace(/\s+/g," ").trim()}},vO=[64*1024,1024*1024]});import{realpathSync as EO}from"fs";import{createHash as AO}from"crypto";import{join as Bo,resolve as TO}from"path";import{homedir as OO}from"os";function ze(){let n=process.env.TYPEBULB_SERVERS_DIR;return n?Bo(n,".."):Bo(OO(),".typebulb")}function pt(){yy||(yy=!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||Bo(ze(),"servers")}function by(n){let e=re(n),t=e.slice(e.lastIndexOf("/")+1).replace(/\.bulb\.md$/,"");return Bo(ze(),"canvas",`${t}-${vs(n)}.png`)}function vs(n){return AO("sha1").update(re(n)).digest("hex").slice(0,8)}function re(n){let e=TO(n),t=e;try{t=EO.native(e)}catch{}return(process.platform==="win32"?t.toLowerCase():t).replace(/\\/g,"/")}function wy(n,e){let t=re(n),r=re(e);return t.startsWith(r.endsWith("/")?r:r+"/")?!t.includes("/node_modules/"):!1}var yy,Ye=k(()=>{"use strict";yy=!1});import*as ky from"net";import{mkdir as PO,readFile as CO,writeFile as xy}from"fs/promises";import{existsSync as _O}from"fs";import{join as Ey}from"path";function Oy(){return Ey(ze(),"blocks")}function Iu(n){return Ey(Oy(),`${n}.json`)}function Fo(n){return new Promise(e=>{let t=ky.createServer();t.once("error",()=>e(!1)),t.listen(n,"127.0.0.1",()=>t.close(()=>e(!0)))})}async function $O(n){for(let e=n;e<65535;e++)if(await Fo(e))return e;throw new Error(`No free port found above ${n}`)}async function Nu(n){let{listBulbServers:e}=await Promise.resolve().then(()=>($e(),Py)),t=(await e()).find(s=>s.port===n),r=t?` (pid ${t.pid}, ${t.agent?`agent:${t.agent}`:t.file})`:"";console.error(`port ${n} in use${r}`),process.exit(1)}async function Uo(n){try{let e=JSON.parse(await CO(Iu(n),"utf8"));return e&&typeof e.cwd=="string"?{cwd:e.cwd,slots:e.slots??{},mirrors:e.mirrors??{}}:void 0}catch{return}}async function qo(n,e){try{return await xy(Iu(n),JSON.stringify(e,null,2)),!0}catch{return pt(),!1}}async function LO(n){let e=re(n);try{await PO(Oy(),{recursive:!0})}catch{return}let t=[];for(let o=0;o<Ty;o++)t.push(Ay+o*un);let r=await Promise.all(t.map(async o=>({base:o,block:await Uo(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 xy(Iu(o),JSON.stringify(s,null,2),{flag:"wx"}),o}catch(l){if((await Uo(o))?.cwd===e)return o;l.code!=="EEXIST"&&pt();continue}if(!_O(a.cwd))return await qo(o,s)?o:void 0}let i=r.filter(o=>!!o.block).sort((o,a)=>vy(o.block)-vy(a.block))[0];if(i)return await qo(i.base,s)?i.base:void 0}function vy(n){return Object.values(n.slots).reduce((e,t)=>Math.max(e,t.usedAt??0),0)}async function MO(n,e){let t=await Uo(n)??{cwd:"",slots:{},mirrors:{}};if(e.kind==="mirror"){let i=t.mirrors[e.agent];if(i!==void 0)return i;let o=Sy(t),a=o.has(0)?IO:0;for(;a>jo&&o.has(a);)a--;return t.mirrors[e.agent]=a,await qo(n,t),a}let r=re(e.file),s=t.slots[r]?.offset;if(s===void 0){let i=Sy(t);for(s=jo;s<un&&i.has(s);)s++;if(s>=un){let o=Object.entries(t.slots).sort((a,l)=>(a[1].usedAt??0)-(l[1].usedAt??0))[0];s=o?o[1].offset:jo,o&&delete t.slots[o[0]]}}return t.slots[r]={offset:s,usedAt:Date.now()},await qo(n,t),s}function Sy(n){return new Set([...Object.values(n.mirrors),...Object.values(n.slots).map(e=>e.offset)])}async function Zn(n,e){let t=await LO(e);return t===void 0?void 0:t+await MO(t,n)}async function dn(n){let e=re(n);for(let t=0;t<Ty;t++){let r=await Uo(Ay+t*un);if(r?.cwd===e)return s=>r.slots[re(s)]?.usedAt??0}return()=>0}async function Jo(n){if(n.explicit!==void 0)return await Fo(n.explicit)||await Nu(n.explicit),n.target.kind==="bulb"&&await Zn(n.target,n.cwd),{port:n.explicit};let e=await Zn(n.target,n.cwd);if(e!==void 0){let r=e-e%un,s=Date.now()+NO;do{if(await Fo(e))return{port:e};await new Promise(i=>setTimeout(i,150))}while(Date.now()<s);for(let i=jo;i<un;i++){let o=r+i;if(o!==e&&await Fo(o))return{port:o,note:`(slot ${e} was busy)`}}}return{port:await $O(RO),note:e===void 0?"(no port block available)":"(this project's block was full)"}}var Ay,un,Ty,RO,jo,IO,NO,fn=k(()=>{"use strict";Ye();Ay=20100,un=100,Ty=19,RO=23e3,jo=1,IO=un-1,NO=3e3});var Le,Wo=k(()=>{"use strict";Le="0.61.8"});var Py={};wi(Py,{agentViewerCommand:()=>By,bulbServerCommand:()=>Dy,clearServerLog:()=>Bu,findProjectViewer:()=>zo,isAlive:()=>er,isMirror:()=>ye,isProjectBulb:()=>Ju,isProjectMirror:()=>rr,launchAgentViewer:()=>Hu,launchBulbServer:()=>xs,listBulbServers:()=>Z,probePageCount:()=>Ku,readServerLog:()=>Ve,readWaitCursor:()=>Ho,recordDenial:()=>qu,registerServer:()=>Uu,relayOpen:()=>Wu,runMarker:()=>ju,serverLogPath:()=>nr,serversForBulb:()=>hn,sliceRunLog:()=>Fu,startServerLog:()=>ks,stopBulbServer:()=>tr,stopServer:()=>Ft,stopServersForBulb:()=>Yo,typebulbBinPath:()=>sr,unregisterServer:()=>pn,writeWaitCursor:()=>Ss});import{spawn as Cy}from"child_process";import{readdir as DO,readFile as Iy,writeFile as Ny,unlink as $u,mkdir as BO}from"fs/promises";import{mkdirSync as $y,writeFileSync as Ko,appendFileSync as jO,readFileSync as Lu}from"fs";import*as Oe from"path";import{fileURLToPath as FO}from"url";function Mu(n){return Oe.join(ht(),`${n}.json`)}function nr(n){return Oe.join(ht(),`${n}.log`)}function Du(n){return Oe.join(ht(),`${n}.wait.json`)}function Ly(n){try{let e=JSON.parse(Lu(Du(n),"utf8"));return e.cursors&&typeof e.cursors=="object"?e.cursors:{}}catch{return{}}}function Ho(n,e=""){let t=Ly(n)[e];return typeof t=="number"&&Number.isFinite(t)&&t>=0?t:void 0}function Ss(n,e,t=""){try{$y(ht(),{recursive:!0});let r=Ly(n);r[t]=e,Ko(Du(n),JSON.stringify({cursors:r}))}catch{}}function ks(n){let e=nr(n);try{$y(ht(),{recursive:!0}),Ko(e,"")}catch{return()=>{}}let t=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(jO(e,l),s+=l.length,s>2*_y){let c=Lu(e),f=c.subarray(Math.max(0,c.length-_y));Ko(e,f),s=f.length}}catch{i=!0}};return process.stdout.write=((a,...l)=>(o(a),t(a,...l))),process.stderr.write=((a,...l)=>(o(a),r(a,...l))),()=>{process.stdout.write=t,process.stderr.write=r}}function Bu(n){try{Ko(nr(n),"")}catch{}}function Ve(n,e=0){try{let t=Lu(nr(n)),r=e>=0&&e<=t.length?e:0;return{text:t.subarray(r).toString("utf8"),offset:t.length}}catch{return{text:"",offset:0}}}function ju(n){return`\u2500\u2500 run ${n} \u2500\u2500 ${new Date().toTimeString().slice(0,8)}`}function qO(n){let e=UO.exec(n);return e?Number(e[1]):void 0}function Fu(n,e){let t=n.split(`
318
- `),r=[];if(t.forEach((o,a)=>{let l=qO(o);l!==void 0&&r.push({id:l,idx:a})}),!r.length)return e==="latest"?n:"";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 t.slice(s.idx,i?i.idx:t.length).join(`
319
- `)}function er(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}async function Uu(n){try{await BO(ht(),{recursive:!0}),await Ny(Mu(n.pid),JSON.stringify({version:Le,...n}))}catch{pt()}}async function qu(n,e){let t=Mu(n);try{let r=JSON.parse(await Iy(t,"utf8"));if(r.denied===e)return;r.denied=e,await Ny(t,JSON.stringify(r))}catch{}}async function pn(n){await $u(Mu(n)).catch(()=>{}),await $u(nr(n)).catch(()=>{}),await $u(Du(n)).catch(()=>{})}function ye(n){return n.agent!=null}function rr(n,e){return ye(n)&&n.cwd!=null&&re(n.cwd)===re(e)}function Ju(n,e){return!ye(n)&&wy(n.file,e)}async function Z(n){let e;try{e=await DO(ht())}catch{return[]}let t=[];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 Iy(Oe.join(ht(),s),"utf8"))}catch{await pn(i);return}o&&typeof o.pid=="number"&&er(o.pid)?t.push(o):await pn(i)})),(n?t.filter(s=>Ju(s,n)):t).sort((s,i)=>s.startedAt-i.startedAt)}async function zo(n,e){return(await Z()).find(t=>rr(t,n)&&(e?t.agent===e:!0))}async function Wu(n,e){let t=new URL(n).port,r=(await Z()).filter(a=>String(a.port)!==t),s=r.filter(a=>rr(a,e)),i=r.filter(a=>Ju(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:n}),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":`${Oe.basename(a.file)}'s page`};ye(a)&&(o+=f??0)}catch{}return o>0?{where:"external"}:void 0}async function tr(n){try{process.kill(n,"SIGTERM")}catch{}await pn(n)}async function Ku(n){try{let e=await fetch(`${n.url}/__pages`,{signal:AbortSignal.timeout(JO)});if(!e.ok)return;let{pages:t}=await e.json();return typeof t=="number"?t:void 0}catch{return}}async function Ft(n,e=ye(n)?"keep":"close"){try{let t=await fetch(`${n.url}/__stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pages:e}),signal:AbortSignal.timeout(Ry)});if(!t.ok)throw new Error(`/__stop ${t.status}`);let{closed:r=0,stuck:s=0}=await t.json(),i=Date.now()+Ry;for(;er(n.pid)&&Date.now()<i;)await My(100);return er(n.pid)?(await tr(n.pid),"killed"):(await pn(n.pid),{closed:r,stuck:s})}catch{return await tr(n.pid),"killed"}}function hn(n,e){let t=re(e);return n.filter(r=>!ye(r)&&r.pid!==process.pid&&re(r.file)===t)}async function Yo(n,e){let t=hn(await Z(),n);for(let r of t)await Ft(r,e!==void 0&&r.port===e?"keep":"close");return t}function WO(n,e,t){(process.platform==="win32"?Cy("cmd",["/c","start","","/b",n,...e],{cwd:t,stdio:"ignore",windowsHide:!0}):Cy(n,e,{cwd:t,detached:!0,stdio:"ignore"})).unref()}function sr(){return Oe.join(Oe.dirname(FO(import.meta.url)),"index.js")}function Dy(n,e={}){return{command:process.execPath,args:[sr(),...e.trust?["--trust"]:[],...e.mode?["--mode",e.mode]:[],n,...e.open===!1?["--no-open"]:[]]}}function By(n){return{command:process.execPath,args:[sr(),`agent:${n}`,"--no-open"]}}async function jy(n,e,t,r){let s=await n();if(s)return s;WO(e.command,e.args,t);let i=Date.now()+2e4;for(;Date.now()<i;){await My(150);let o=await n();if(o)return o}throw new Error(`Launched ${r} but it did not register within 20s.`)}async function xs(n,e={}){let t=e.cwd??process.cwd(),r=Oe.resolve(t,n),s=await Zn({kind:"bulb",file:r},t),[i]=await Yo(r,s),o={...e,mode:e.mode??i?.mode};return jy(async()=>hn(await Z(),r)[0],Dy(n,o),t,Oe.basename(n))}async function Hu(n,e=process.cwd()){return jy(()=>zo(e,n),By(n),e,`the ${n} mirror`)}var _y,UO,Ry,JO,My,$e=k(()=>{"use strict";Ye();fn();Wo();_y=1e6;UO=/^── run (\d+) ── /;Ry=6e3,JO=500;My=n=>new Promise(e=>setTimeout(e,n))});function ir(n){return{...xp(n),server:n.files.get("server.ts")??""}}function Vo(n){return!!n.server&&!n.code}var Es=k(()=>{"use strict";ee();ee()});function Go(n){let e=/^---[^\n]*\n([\s\S]*?)\n---/.exec(n),t=e?/^\s*name:\s*(.+?)\s*$/m.exec(e[1]):null;return t?t[1].replace(/^["']|["']$/g,""):void 0}function zu(n){return Yn(Go(n)??"bulb")||"bulb"}var Yu=k(()=>{"use strict";ee()});import{readdirSync as KO,readFileSync as HO,statSync as zO}from"fs";import{join as Fy,basename as YO}from"path";function qy(n,e,t){if(e>8)return t;let r;try{r=KO(n,{withFileTypes:!0})}catch{return t}for(let s of r)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;qy(Fy(n,s.name),e+1,t)}else s.isFile()&&s.name.endsWith(".bulb.md")&&t.push(Fy(n,s.name));return t}function VO(n,e){let t,r=!1;try{let s=HO(n,"utf8");t=Go(s.slice(0,1024));let i=We(s);r=!!i&&Vo(ir(i))}catch{}return{mtime:e,name:t??YO(n).replace(/\.bulb\.md$/,""),serverOnly:r}}function Xo(n){let e=new Map,t=qy(n,0,[]).map(r=>{let s=0;try{s=zO(r).mtimeMs}catch{}let i=s?Uy.get(r):void 0,o=i?.mtime===s?i:VO(r,s);return s&&e.set(r,o),{path:r,...o}});return Uy=e,t}var Uy,Jy=k(()=>{"use strict";ee();Es();Yu();Uy=new Map});function or(n){if(n.server.trim())return"server-side code (server.ts)";let e=n.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")||n.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 Qo=k(()=>{"use strict"});import{readFile as GO}from"fs/promises";async function Vu(n){try{let e=We(await GO(n,"utf-8"));return e?or(ir(e)):void 0}catch{return}}var Wy=k(()=>{"use strict";Es();Qo()});function Gu(n){let e=n.split(""),t=(i,o)=>{for(let a=i;a<o&&a<e.length;a++)e[a]!==`
320
- `&&(e[a]=" ")},r=0,s="";for(;r<n.length;){let i=n[r],o=n[r+1];if(i==="/"&&o==="/"){let a=r;for(;a<n.length&&n[a]!==`
321
- `;)a++;t(r,a),r=a}else if(i==="/"&&o==="*"){let a=r+2;for(;a<n.length&&!(n[a]==="*"&&n[a+1]==="/");)a++;t(r,Math.min(a+2,n.length)),r=a+2}else if(i==="/"&&XO.has(s)){let a=r+1,l=!1;for(;a<n.length&&n[a]!==`
322
- `;){let c=n[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<n.length&&n[a]!==i&&n[a]!==`
323
- `;)n[a]==="\\"&&a++,a++;r=a+1,s=i}else if(i==="`"){let a=Ky(n,r);t(r,a),r=a,s="`"}else/\s/.test(i)||(s=i),r++}return e.join("")}function Ky(n,e){let t=e+1,r=0;for(;t<n.length;){let s=n[t];if(s==="\\"){t+=2;continue}if(s==="`"){if(r===0)return t+1;t=Ky(n,t);continue}if(s==="$"&&n[t+1]==="{"){r++,t+=2;continue}if(s==="}"&&r>0){r--,t++;continue}t++}return n.length}var XO,Hy=k(()=>{XO=new Set(["","(",",","=",":","[","!","&","|","?",";","{"])});function eP(n){if(/^[./]/.test(n)||/^[a-z][a-z0-9+.-]*:/i.test(n))return;let e=n.split("/");return n.startsWith("@")?e.slice(0,2).join("/"):e[0]}function zy(n){let e=[];for(let s of ZO)for(let i of n.matchAll(s)){let o=eP(i[1]);o&&e.push({root:o,index:i.index??0})}e.sort((s,i)=>s.index-i.index);let t=new Set,r=[];for(let{root:s,index:i}of e)t.has(s)||(t.add(s),r.push({root:s,lineIndex:n.slice(0,i).split(`
324
- `).length-1}));return r}function Yy(n){return zy(Gu(n)).map(e=>e.root)}function As(n,e){if(!n)return[];let{target:t,dependencies:r}=e,s=(e.lineOffset??1)-1,i=[],o=n.split(`
325
- `),a=Gu(n).split(`
326
- `);for(let l=0;l<o.length;l++){let c=a[l],f=l+1+s;for(let d of QO)d.targets.includes(t)&&d.pattern.test(c)&&i.push({type:d.type,severity:"error",message:rP(d.type,f),lineNumber:f,lineContent:o[l]})}return t==="client"&&r&&i.push(...tP(a,o,r,s)),i}function tP(n,e,t,r){let s=new Set(Object.keys(t));return zy(n.join(`
327
- `)).filter(({root:i})=>!s.has(i)).map(({root:i,lineIndex:o})=>{let a=o+1+r;return{type:"UNDECLARED_IMPORT",severity:"error",message:nP(i,a),lineNumber:a,lineContent:e[o]}})}function nP(n,e){return`Import "${n}" is not declared in config.json dependencies! Found on line ${e}.
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]!==`
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]!==`
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(`
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}.
328
329
 
329
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.
330
331
 
@@ -333,12 +334,12 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
333
334
  {
334
335
  "description": "\u2026",
335
336
  "dependencies": {
336
- "${n}": "*"
337
+ "${t}": "*"
337
338
  }
338
339
  }
339
340
  \`\`\`
340
341
 
341
- **Fix:** Add a **config.json** block (or extend the existing one) with a "dependencies" entry for "${n}" \u2014 and for every other bare import in code.tsx. Pin a real version where you can (e.g. "react": "^19.2.7").`}function rP(n,e){return n==="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 dP(t,e){return t==="URL_IMPORT"?`Direct URL imports are not supported! Found on line ${e}.
342
343
 
343
344
  **CRITICAL**: Import packages by name only. Do NOT use CDN URLs:
344
345
 
@@ -355,7 +356,7 @@ import _ from "https://cdn.skypack.dev/lodash"
355
356
  import x from "https://unpkg.com/some-package"
356
357
  \`\`\`
357
358
 
358
- **Fix:** Use the package name only. Package resolution is handled automatically.`:n==="VERSION_SPECIFIER_IMPORT"?`Version specifiers in imports are not supported! Found on line ${e}.
359
+ **Fix:** Use the package name only. Package resolution is handled automatically.`:t==="VERSION_SPECIFIER_IMPORT"?`Version specifiers in imports are not supported! Found on line ${e}.
359
360
 
360
361
  **CRITICAL**: Import packages by name only. Do NOT include version numbers:
361
362
 
@@ -373,7 +374,7 @@ import _ from "lodash@^4.17.0"
373
374
  import { x } from "@scope/package@1.0.0"
374
375
  \`\`\`
375
376
 
376
- **Fix:** Remove the version specifier (everything from @ onwards). Versions are managed separately.`:n==="JS_EXTENSION_IMPORT"?`Deep import paths must NOT include \`.js\` extension! Found on line ${e}.
377
+ **Fix:** Remove the version specifier (everything from @ onwards). Versions are managed separately.`:t==="JS_EXTENSION_IMPORT"?`Deep import paths must NOT include \`.js\` extension! Found on line ${e}.
377
378
 
378
379
  **CRITICAL**: Remove the \`.js\` extension from deep import paths (paths with \`/\`):
379
380
 
@@ -389,7 +390,7 @@ import { OrbitControls } from "three/examples/jsm/controls/OrbitControls.js"
389
390
 
390
391
  **Note:** Package names that literally end with ".js" (like \`decimal.js\`) are fine - this rule only applies to file paths within packages.
391
392
 
392
- **Fix:** Remove \`.js\` from the end of the import path.`:n==="DYNAMIC_IMPORT"?`Dynamic imports are not supported! You used \`import('...')\` on line ${e}.
393
+ **Fix:** Remove \`.js\` from the end of the import path.`:t==="DYNAMIC_IMPORT"?`Dynamic imports are not supported! You used \`import('...')\` on line ${e}.
393
394
 
394
395
  **CRITICAL**: All imports MUST be at the TOP of the file using standard ES6 import syntax:
395
396
 
@@ -411,8 +412,8 @@ import('react-dom/client').then(({ createRoot }) => {
411
412
  })
412
413
  \`\`\`
413
414
 
414
- **Fix:** Move ALL import statements to the top of the file using standard \`import\` syntax.`:n==="REDUNDANT_TB_DECLARATION"?`Redundant \`declare const tb\` found on line ${e}.
415
- The \`tb\` global is already provided by the environment. Remove this declaration.`:n==="CONST_ENUM"?`\`const enum\` is not supported! Found on line ${e}.
415
+ **Fix:** Move ALL import statements to the top of the file using standard \`import\` syntax.`:t==="REDUNDANT_TB_DECLARATION"?`Redundant \`declare const tb\` found on line ${e}.
416
+ The \`tb\` global is already provided by the environment. Remove this declaration.`:t==="CONST_ENUM"?`\`const enum\` is not supported! Found on line ${e}.
416
417
 
417
418
  **Fix:** Use a regular \`enum\` or an object with \`as const\`:
418
419
 
@@ -424,7 +425,7 @@ enum Direction { Up, Down, Left, Right }
424
425
  const Direction = { Up: 0, Down: 1, Left: 2, Right: 3 } as const
425
426
  \`\`\`
426
427
 
427
- \`const enum\` requires the full TypeScript compiler to inline values at compile time. Regular \`enum\` and object literals work identically at runtime.`:n==="NAMESPACE_DECLARATION"?`TypeScript \`namespace\` is not supported! Found on line ${e}.
428
+ \`const enum\` requires the full TypeScript compiler to inline values at compile time. Regular \`enum\` and object literals work identically at runtime.`:t==="NAMESPACE_DECLARATION"?`TypeScript \`namespace\` is not supported! Found on line ${e}.
428
429
 
429
430
  **Fix:** Use ES modules instead:
430
431
 
@@ -434,23 +435,23 @@ const Direction = { Up: 0, Down: 1, Left: 2, Right: 3 } as const
434
435
  export function foo() {}
435
436
  \`\`\`
436
437
 
437
- Namespaces are a legacy TypeScript pattern. Use standard ES module imports/exports instead.`:n==="COMMONJS_EXPORT_EQUALS"?`\`export =\` syntax is not supported! Found on line ${e}.
438
+ Namespaces are a legacy TypeScript pattern. Use standard ES module imports/exports instead.`:t==="COMMONJS_EXPORT_EQUALS"?`\`export =\` syntax is not supported! Found on line ${e}.
438
439
 
439
440
  **Fix:** Use ES module \`export default\` instead:
440
441
 
441
442
  \`\`\`typescript
442
443
  // Instead of: export = myValue
443
444
  export default myValue
444
- \`\`\``:n==="COMMONJS_IMPORT_EQUALS"?`\`import x =\` syntax is not supported! Found on line ${e}.
445
+ \`\`\``:t==="COMMONJS_IMPORT_EQUALS"?`\`import x =\` syntax is not supported! Found on line ${e}.
445
446
 
446
447
  **Fix:** Use ES module \`import\` instead:
447
448
 
448
449
  \`\`\`typescript
449
450
  // Instead of: import x = require('module')
450
451
  import x from 'module'
451
- \`\`\``:n==="MODULE_DECLARATION"?`TypeScript \`module\` declarations are not supported! Found on line ${e}.
452
+ \`\`\``:t==="MODULE_DECLARATION"?`TypeScript \`module\` declarations are not supported! Found on line ${e}.
452
453
 
453
- **Fix:** Use ES modules instead. The \`module Foo {}\` syntax is a legacy TypeScript pattern \u2014 use standard imports/exports.`:n==="CSS_FILE_IMPORT"?`Importing CSS files is not supported! Found on line ${e}.
454
+ **Fix:** Use ES modules instead. The \`module Foo {}\` syntax is a legacy TypeScript pattern \u2014 use standard imports/exports.`:t==="CSS_FILE_IMPORT"?`Importing CSS files is not supported! Found on line ${e}.
454
455
 
455
456
  **CRITICAL**: CSS imports don't work here. The styles.css block is already applied to the page automatically.
456
457
 
@@ -462,7 +463,7 @@ import "./styles.css"
462
463
  import styles from "./styles.css"
463
464
  \`\`\`
464
465
 
465
- **Fix:** Delete the CSS import line entirely. Write styles in the styles.css block \u2014 they are loaded automatically.`:n==="NAVIGATION"?`Navigation is forbidden in this sandboxed environment! Found on line ${e}.
466
+ **Fix:** Delete the CSS import line entirely. Write styles in the styles.css block \u2014 they are loaded automatically.`:t==="NAVIGATION"?`Navigation is forbidden in this sandboxed environment! Found on line ${e}.
466
467
 
467
468
  **CRITICAL**: \`window.location\` changes, \`window.open()\`, and page reloads will break the app.
468
469
 
@@ -492,46 +493,46 @@ import { something } from 'module-name'
492
493
  const something = require('module-name') // NOT SUPPORTED!
493
494
  \`\`\`
494
495
 
495
- **Fix:** Replace all \`require()\` calls with ES6 \`import\` statements at the top of the file.`}var mn,gn,QO,ZO,Zo=k(()=>{Hy();mn=["client"],gn=["client","server"],QO=[{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}],ZO=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});function Xu(n){let e=We(n);if(!e)return n;let t=e.files.get("code.tsx");if(!t)return n;let r=Yy(t);if(!r.length)return n;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 n;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=yp(c);d&&(l[d]=f)}return l.config=JSON.stringify(i,null,2),Tp(l)}var Vy=k(()=>{"use strict";ee();Zo()});import{spawn as Gy}from"child_process";import{basename as sP}from"path";function iP(){return process.env.TYPEBULB_EDITOR||"code"}function aP(n,e,t){return t==null?[e]:oP.test(sP(n))?["-g",`${e}:${t}`]:[`+${t}`,e]}function lP(n,e){let t=iP();return{command:t,args:aP(t,n,e)}}function Qu(n,e){let{command:t,args:r}=lP(n,e),s=process.platform==="win32"?Gy("cmd.exe",["/d","/s","/c",t,...r],{detached:!0,stdio:"ignore",windowsHide:!0}):Gy(t,r,{detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}var oP,Xy=k(()=>{"use strict";oP=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i});import{readFileSync as cP,writeFileSync as uP,mkdirSync as dP,statSync as fP}from"fs";import{join as pP}from"path";function Zu(){return pP(ze(),"trust.json")}function ed(){try{let n=Zu(),e=fP(n).mtimeMs;if(Ts?.mtime!==e){let t=JSON.parse(cP(n,"utf8"));Ts={mtime:e,set:new Set(Array.isArray(t)?t:[])}}return Ts.set}catch{return Ts=void 0,new Set}}function hP(n){try{dP(ze(),{recursive:!0}),uP(Zu(),JSON.stringify([...n])),Ts=void 0}catch(e){throw new Error(`can't write ${Zu()} \u2014 trust not remembered (unwritable home; sandboxed shell?): ${e.message}`)}}function yn(n){return ed().has(re(n))}function ar(n,e){let t=new Set(ed()),r=re(n);(e?t.has(r):!t.has(r))||(e?t.add(r):t.delete(r),hP(t))}function td(){return[...ed()]}var Ts,Os=k(()=>{"use strict";Ye()});function cr(n){return(n.includes("://")?n:`http://${n}`).replace(/\/+$/,"")}function nd(){return Cs}async function mt(){let[n,e]=await Promise.all([Zy(),SP()]);return vP([...kP(e),...n],process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL)}function vP(n,e,t){return!e||!t?n:n.map(r=>r.provider===e&&r.name===t?{...r,default:!0}:r)}async function Qy(){let n;try{n=await fetch(mP,{signal:AbortSignal.timeout(yP)})}catch(e){Cs=`catalog fetch failed: ${e?.message??e}`;return}if(!n.ok){Cs=`catalog fetch failed: HTTP ${n.status}`;return}try{return await n.json()}catch(e){Cs=`catalog returned an unreadable body: ${e?.message??e}`;return}}async function SP(){if(Ps&&Date.now()-Ps.fetchedAt<=gP)return Ps.models;let n=await Qy()??await Qy();return n?(Ps={models:n,fetchedAt:Date.now()},Cs=void 0,n):Ps?.models??[]}async function Zy(){if(ea&&Date.now()-ea.fetchedAt<=bP)return ea.models;let n=cr(process.env.OLLAMA_HOST??"http://localhost:11434"),e=[];try{let t=await fetch(new URL("/api/tags",n).toString(),{signal:AbortSignal.timeout(wP)});t.ok&&(e=((await t.json()).models??[]).map(s=>s.name).filter(s=>!!s).map(s=>({provider:"ollama",name:s,friendlyName:s,providerName:"Ollama"})))}catch{}return ea={models:e,fetchedAt:Date.now()},e}function kP(n){let e=new Set(Object.entries(lr).filter(([,t])=>!!process.env[t]).map(([t])=>t));return n.filter(t=>e.has(t.provider))}function rd(){return Object.values(lr).some(n=>!!process.env[n])}async function ta(){return rd()||process.env.TB_AI_BASE_URL||(await Zy()).length>0?"own":"none"}function eb(n,e,t){let r=Math.max(...n.map(o=>o.name.length)),s=Math.max(...n.map(o=>o.friendlyName.length)),i=["Models available to tb.ai (filtered by your .env keys):",""];for(let o of n)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&&t&&i.push(`Default (from .env): ${e} / ${t}`),i.join(`
496
- `)}var lr,mP,gP,yP,bP,wP,Ps,ea,Cs,bn=k(()=>{"use strict";lr={anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GOOGLE_API_KEY",openrouter:"OPENROUTER_API_KEY"};mP="https://api.typebulb.com/api/models",gP=1440*60*1e3,yP=5e3,bP=60*1e3,wP=1500});var tb,nb,st,wn=k(()=>{tb=n=>n!=null&&n>=0&&n<=4?n:void 0,nb=(n,e)=>{let t={...n};for(let r of["input","output","reasoning","cacheRead"])e[r]!==void 0&&(t[r]=e[r]);return t},st=n=>n===void 0||n.input===void 0&&n.output===void 0?void 0:{input:n.input??0,output:n.output??0,reasoning:n.reasoning,cacheRead:n.cacheRead}});var Pe,Ge,ur=k(()=>{Pe=class extends Error{constructor(e,t="unknown",r=!1){super(e),this.code=t,this.retryable=r}},Ge=class{getPath(e,t){return this.path}parseError(e,t){return this.parseJsonError(e,t)}parseStreamChunk(e){return this.checkAndThrowError(e),this.parseProviderStreamChunk(e)}extractSystemMessages(e,t=`
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=`
497
498
 
498
- `){let r=e.filter(s=>s.role==="system").map(s=>s.content);return{system:r.length?r.join(t):void 0,conversationMessages:e.filter(s=>s.role!=="system")}}parseJsonError(e,t){if(!e)return{message:`HTTP ${t}`};try{let r=JSON.parse(e);return r.error&&typeof r.error=="object"?{message:r.error.message||`HTTP ${t}`,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 t=e;if(t.type==="error"&&"message"in t){let r=t.code||"unknown";throw new Pe(t.message,r,!!t.retryable)}if(t.error){let r=t.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 Pe(this.extractErrorMessage(t.error),i?"rate_limit":a?"context_exceeded":"unknown",i||o)}}extractErrorMessage(e){if(typeof e=="string")try{let t=JSON.parse(e);return t.error?.message||t.message||e}catch{return e}return typeof e=="object"&&e!==null?e.message||JSON.stringify(e):`${this.providerName} returned an error`}}});var na,sd=k(()=>{wn();ur();na=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,t,r,s){let i=this.convertMessagesToInput(e),o={model:t,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 t=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
- `)),!t&&s.type==="message"&&s.content&&(t=s.content.filter(i=>i.type==="output_text").map(i=>i.text).join(""));return{text:t,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 Pe(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 t=this.mapUsage(e.response?.usage);return t?{usage:t}: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(t=>t.role==="system"?`System: ${t.content}`:t.role==="user"?`User: ${t.content}`:t.role==="assistant"?`Assistant: ${t.content}`:t.content).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();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(`
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(`
500
501
 
501
- `)}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,ra=k(()=>{wn();ur();dr=class extends Ge{parseNonStreamingResponse(e){if(!this.hasChoices(e))return{text:""};let t=e,r=t.choices[0],s=r?.message,i=s?.content??r?.text??"",o=s?.reasoning??s?.reasoning_content??t.reasoning;return{text:i,reasoning:o,usage:this.mapUsage(t.usage)}}parseProviderStreamChunk(e){if(!this.hasChoices(e))return;let t=e,r=this.mapUsage(t.usage),s=t.choices[0]?.delta||t.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 id,sa,od=k(()=>{ra();id={"HTTP-Referer":"https://typebulb.com","X-OpenRouter-Title":"Typebulb"},sa=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",...id}}buildPayload(e,t,r,s){let i={model:t,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 ia,ad=k(()=>{wn();ur();ia=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,t,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e),a={model:t,max_tokens:Math.min(this.getMaxTokens(t),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(t))if(l===0)this.alwaysThinks(t)||(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 t=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 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
503
 
503
- `);return{text:t,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 t=this.mapUsage(e.message?.usage);return t?{usage:t}:void 0}case"message_delta":{let t=this.mapUsage(e.usage);return t?{usage:t}:void 0}default:return}}mapUsage(e){if(typeof e!="object"||e===null)return;let t=e,r=c=>typeof c=="number"?c:void 0,s=r(t.input_tokens),i=r(t.cache_read_input_tokens),o=r(t.cache_creation_input_tokens),a=r(t.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 t=Math.max(0,e.length-2);return e.map((r,s)=>s>=t?{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 t=e.match(/^claude-[a-z]+-(\d+)(?:-(\d+))?/i);if(!t)return!1;let r=+t[1],s=t[2]?+t[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 oa,ld=k(()=>{wn();ur();oa=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,t){return`/v1beta/models/${e}:${t?"streamGenerateContent":"generateContent"}${t?"?alt=sse":""}`}buildHeaders(e){return{"Content-Type":"application/json","x-goog-api-key":e}}buildPayload(e,t,r,s){let{system:i,conversationMessages:o}=this.extractSystemMessages(e,`
504
- `),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(t),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,t){if(!e)return{message:`HTTP ${t}`};try{let r=JSON.parse(e),s=Array.isArray(r)?r[0]?.error:r?.error;return s&&typeof s=="object"?{message:(s.message||`HTTP ${t}`).split(`
505
- `)[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 t=this.extractParts(e).text||"",r=e.candidates?.[0]?.finishReason,s="complete";return r==="MAX_TOKENS"?s="interrupted":(r==="SAFETY"||r==="RECITATION")&&(s="failed"),{text:t,status:s,usage:this.mapUsage(e.usageMetadata)}}parseProviderStreamChunk(e){if(this.checkGeminiError(e),!this.isGeminiResponse(e))return;let t=this.extractParts(e),r=this.mapUsage(e.usageMetadata);return r&&(t.usage=r),t.text||t.reasoning||t.usage?t:void 0}mapUsage(e){if(!e)return;let t=e.candidatesTokenCount!==void 0||e.thoughtsTokenCount!==void 0;return st({input:e.promptTokenCount,output:t?(e.candidatesTokenCount??0)+(e.thoughtsTokenCount??0):void 0,reasoning:e.thoughtsTokenCount,cacheRead:e.cachedContentTokenCount})}geminiVersion(e){let t=e.match(/^gemini-(\d+(?:\.\d+)?)/);return t?Number(t[1]):void 0}thinkingLevelFor(e,t){let r=["minimal","low","medium","high","high"][t];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 t=e.candidates?.[0]?.content?.parts;if(!t)return{};let r="",s="";for(let i of t)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 t=e.promptFeedback.blockReason;throw new Pe(`Prompt blocked: ${t}`)}}}});var aa,cd=k(()=>{ra();aa=class extends dr{constructor(){super(...arguments),this.providerName="Ollama",this.defaultBaseUrl="http://localhost:11434",this.path="/chat/completions"}buildHeaders(e){let t={"Content-Type":"application/json",Accept:"application/json"};return e&&(t.Authorization=`Bearer ${e}`),t}buildPayload(e,t,r,s){return s?{model:t,messages:e,stream:s,stream_options:{include_usage:!0}}:{model:t,messages:e,stream:s}}}});function vn(n){let e=xP.get(n);if(!e)throw new Error(`Unsupported protocol: ${n}`);return e}function EP(n,e){return n.replace(/\/+$/,"")+(e.startsWith("/")?e:`/${e}`)}async function ud(n,e){let t=vn(n.protocol),r=t.getPath(n.model,e.stream),s=EP(n.baseUrl,r),i=t.buildHeaders(n.apiKey),o=t.buildPayload(e.messages,n.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 AP(n){return/prompt is too long|context[_ ](length|window)|maximum context|token count exceeds|too many tokens/i.test(n)}async function fr(n,e){let t=vn(e),r=await n.text().catch(()=>""),{message:s}=t.parseError(r,n.status),i=n.status,o="unknown";return i===429?o="rate_limit":(i===413||AP(s))&&(o="context_exceeded"),{code:o,message:s,retryable:i===429||i>=500}}var rb,xP,dd=k(()=>{sd();od();ad();ld();cd();rb=new aa,xP=new Map([["openai",new na],["openrouter",new sa],["anthropic",new ia],["gemini",new oa],["ollama",rb],["openai-compat",rb]])});function sb(n){let e=n.indexOf(`\r
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,`
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
507
  \r
507
- `),t=n.indexOf(`
508
+ `),n=t.indexOf(`
508
509
 
509
- `);return e!==-1&&(t===-1||e<t)?{pos:e,len:4}:t!==-1?{pos:t,len:2}:{pos:-1,len:0}}function fd(n){let t=n.split(/\r?\n/).filter(s=>s.startsWith("data:"));if(!t.length)return;let r=t.map(s=>s.replace(/^data:\s?/,"")).join(`
510
- `).trim();if(r){if(r==="[DONE]")return"done";try{return JSON.parse(r)}catch{return}}}async function*ib(n,e,t){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([n.read(),o]):await n.read();if(a){if(s.trim()){let d=fd(s);d!==void 0&&d!=="done"&&(yield d)}return}t?.(),s+=r.decode(l,{stream:!0});let{pos:c,len:f}=sb(s);for(;c!==-1;){let d=s.slice(0,c);s=s.slice(c+f);let u=fd(d);if(u==="done")return;u!==void 0&&(yield u),{pos:c,len:f}=sb(s)}}}finally{i&&e?.removeEventListener("abort",i);try{await n.cancel()}catch{}}}async function pd(n,e){return(await pr(n,e)).text}async function pr(n,e){if(!n.body)throw new Error("Response body is missing");let t="",r;for await(let s of Sn(n,e))s.kind==="text"?t+=s.text:s.kind==="usage"&&(r=s.usage);return{text:t,usage:r}}async function*Sn(n,e){let t=e??(n.headers.get("X-Provider-Protocol")||"openai"),r=vn(t);if(!n.body)return;let s=n.body.getReader(),i;for await(let a of ib(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=nb(i,l.usage))}let o=st(i);o&&(yield{kind:"usage",usage:o})}var ob=k(()=>{wn();dd()});import{strToU8 as TP,strFromU8 as OP,deflateSync as PP,inflateSync as CP}from"fflate";function md(n,e){let t=[];if(t.push(`You are a data processor. Follow the instructions to analyze the provided data. Output valid JSON that the code can consume.
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
512
 
512
513
  ---
513
514
  Instructions:
514
- ${n.infer||"Process the data and return a JSON object."}`),n.insight&&t.push(`---
515
+ ${t.infer||"Process the data and return a JSON object."}`),t.insight&&n.push(`---
515
516
  Example output:
516
- ${n.insight}`),n.code&&t.push(`---
517
+ ${t.insight}`),t.code&&n.push(`---
517
518
  Code that will consume your output:
518
- ${n.code}`),e.length>0){let r=e.length===1?e[0]:e.map((s,i)=>`[Chunk ${i+1}]
519
+ ${t.code}`),e.length>0){let r=e.length===1?e[0]:e.map((s,i)=>`[Chunk ${i+1}]
519
520
  ${s}`).join(`
520
521
 
521
- `);t.push(`---
522
+ `);n.push(`---
522
523
  Data to process:
523
524
  <data>
524
525
  ${r}
525
- </data>`)}return t.push(`
526
- 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.`),t.join(`
526
+ </data>`)}return n.push(`
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(`
527
528
 
528
- `)}function _s(n){try{return JSON.parse(n)}catch{return}}function ab(n,e){let t="",r=0,s=!1,i=!1;for(let o=0;o<n.length;o++){let a=n[o];if(i){i=!1;continue}if(a==="\\"){i=!0;continue}a==='"'&&(s?(t+=n.slice(r,o+1),r=o+1):(t+=e(n.slice(r,o))+'"',r=o+1),s=!s)}return t+=s?n.slice(r):e(n.slice(r)),t}function RP(n){let e=ab(n,t=>t.replace(/,(\s*[}\]])/g,"$1"));return e!==n?e:void 0}function IP(n){let e=ab(n,t=>t.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!==n?e:void 0}function NP(n,e){let t=0,r=!1,s=!1;for(let i=e;i<n.length;i++){let o=n[i];if(s){s=!1;continue}if(o==="\\"){s=!0;continue}if(o==='"'){r=!r;continue}if(!r){if(o==="{"||o==="[")t++;else if((o==="}"||o==="]")&&(t--,t===0))return i}}return-1}function $P(n){let e,t=0;for(;t<n.length;){let r=n[t];if(r==="{"||r==="["){let s=NP(n,t);if(s!==-1){let i=n.slice(t,s+1),o=_s(i);o!==void 0&&(e={parsed:o,json:i}),t=s+1;continue}}t++}return e}function gd(n){let e=[],t=n.trim();t.startsWith("```")&&(t=t.replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```\s*$/,""),e.push("markdown fences"));let r=_s(t);if(r!==void 0)return{parsed:r,json:t,fixesApplied:e};let s=t.match(/```(?:json)?\s*\n([\s\S]*?)\n?```\s*$/);if(s&&(t=s[1].trim(),e.push("preamble before fenced JSON"),r=_s(t),r!==void 0))return{parsed:r,json:t,fixesApplied:e};if(!t.startsWith("{")&&!t.startsWith("[")){let o=t.indexOf("{"),a=t.indexOf("["),l=o>=0&&a>=0?Math.min(o,a):o>=0?o:a;if(l>0&&(t=t.slice(l),e.push("preamble text"),r=_s(t),r!==void 0))return{parsed:r,json:t,fixesApplied:e}}for(let[o,a]of _P){let l=a(t);if(l!==void 0){let c=_s(l);if(c!==void 0)return{parsed:c,json:l,fixesApplied:[...e,o]}}}let i=$P(n);return i!==void 0?{...i,fixesApplied:[...e,"extracted last JSON value"]}:{parsed:void 0,json:t,fixesApplied:e}}function yd(n){try{let e={};if(n.insight!==void 0&&(e.i=n.insight),n.data!==void 0&&(e.d=n.data),e.i===void 0&&e.d===void 0)return"";let t=JSON.stringify(e),r=PP(TP(t),{level:9}),s=MP(r),i=`${lb}:${s}`;return i.length>LP?"":"#"+hd+i}catch{return""}}function bd(n){try{let e=n.startsWith("#")?n.slice(1):n;if(!e.startsWith(hd))return;let t=e.slice(hd.length),r=t.indexOf(":");if(r===-1||t.slice(0,r)!==lb)return;let s=DP(t.slice(r+1)),i=JSON.parse(OP(CP(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 MP(n){let e="";for(let t=0;t<n.length;t+=32768)e+=String.fromCharCode(...n.subarray(t,t+32768));return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function DP(n){let e=n.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4;)e+="=";let t=atob(e),r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}var _P,hd,lb,LP,cb=k(()=>{_P=[["orphan quote",n=>{let e=n.replace(/^[ \t]*"[ \t]*\r?\n/gm,"");return e!==n?e:void 0}],["trailing }",n=>n.endsWith("}}")?n.slice(0,-1):void 0],["trailing ]",n=>n.endsWith("]]")?n.slice(0,-1):void 0],["trailing },",n=>n.endsWith("},")?n.slice(0,-1):void 0],["trailing ],",n=>n.endsWith("],")?n.slice(0,-1):void 0],["trailing commas",RP],["arithmetic constants",IP]];hd="tb=",lb="1",LP=6e4});var Ut=k(()=>{wn();ur();dd();ob();cb();ra();ad();ld();sd();od();cd()});import{readFileSync as ub,existsSync as BP}from"fs";import*as it from"path";function db(n){return[...n?[`.env.${n}.local`,`.env.${n}`]:[],".env.local",".env"]}function ke(n,e=process.cwd()){let t={},r=[];for(let s of db(n)){let i;try{i=ub(it.resolve(e,s),"utf-8")}catch{continue}r.push(s);for(let[o,a]of fb(i))process.env[o]===void 0&&(process.env[o]=a,t[o]=s)}return{mode:n,sources:t,loaded:r}}function*fb(n){for(let e of n.split(`
529
- `)){let t=e.trim();if(!t||t.startsWith("#"))continue;let r=t.indexOf("=");if(r===-1)continue;let s=t.slice(0,r).trim(),i=t.slice(r+1).trim();(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),yield[s,i]}}function la(n,e=process.cwd()){for(let t of db()){let r;try{r=ub(it.resolve(e,t),"utf-8")}catch{continue}for(let[s,i]of fb(r))if(s===n)return i}return process.env[n]}function jP(n){let e=new Set,t=/process\.env\.([A-Za-z_$][\w$]*)|process\.env\[\s*['"]([^'"]+)['"]\s*\]/g;for(let r;r=t.exec(n);)e.add(r[1]??r[2]);return[...e]}function pb(){return`.env loads from ${process.cwd()} (the directory you ran from, not the bulb's)`}function qt(n,e,t){let{sources:r,mode:s,loaded:i}=n,o=process.cwd(),a=it.dirname(e),l=`(mode: ${s??"none"})`,c=t?jP(t):[],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"])BP(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=k(()=>{"use strict"});function gt(n,e){let t=n??process.env.TB_AI_PROVIDER,r=e??process.env.TB_AI_MODEL;if(!t)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(t)}catch{return`Unknown provider '${t}'.`}if(t==="ollama")return{apiKey:"",baseUrl:`${cr(process.env.OLLAMA_HOST??s.defaultBaseUrl)}/v1`,protocol:t,model:r,isFreeModel:!1};if(t==="openai-compat"){let a=process.env.TB_AI_BASE_URL;return a?{apiKey:process.env.TB_AI_API_KEY??"",baseUrl:a,protocol:t,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[t];if(!i)return`Unknown provider '${t}'.`;let o=process.env[i];return o?{apiKey:o,baseUrl:s.defaultBaseUrl,protocol:t,model:r,isFreeModel:!1}:`No API key for '${t}'. Set ${i} \u2014 ${pb()}.`}function Jt(n,e){let t=[...e.system?[{role:"system",content:e.system}]:[],...e.messages.map(r=>({role:r.role,content:r.content}))];return ud(n,{messages:t,stream:!0,effort:tb(e.effort),webSearch:e.webSearch,signal:e.signal})}var ca=k(()=>{"use strict";Ut();Ut();ot();bn()});import{readFileSync as PB,existsSync as FP}from"fs";import*as hr from"path";import{fileURLToPath as UP}from"url";function qP(){let n=hr.dirname(UP(import.meta.url));for(;!FP(hr.join(n,"package.json"));){let e=hr.dirname(n);if(e===n)break;n=e}return n}function Rs(){return hr.join(qP(),"SKILL.md")}var wd=k(()=>{"use strict"});import{transform as JP}from"sucrase";function vd(n,e={}){let t=e.serverOnly?["typescript"]:["typescript","jsx"];try{let{code:r}=JP(n,{transforms:t,jsxRuntime:"automatic",jsxImportSource:e.jsxImportSource||"react",production:!0});return{code:r}}catch(r){return{code:"",error:String(r)}}}var hb=k(()=>{});function WP(n){return n.map(e=>`${e.type} (line ${e.lineNumber}): ${e.message.split(`
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(`
530
531
  `)[0]}`).join(`
531
- `)}function mb(n,e){let t=As(n,{target:"client",dependencies:e}).filter(r=>r.type==="UNDECLARED_IMPORT");if(t.length)throw new Error(`Lint failed:
532
- ${WP(t)}`)}var gb=k(()=>{"use strict";Zo()});var Wt,Is,Sd,Ns=k(()=>{Wt="https://esm.sh",Is="https://cdn.jsdelivr.net/npm/",Sd="https://data.jsdelivr.com/v1/package/npm/"});function yb(n){let e=(n||"").replace(/^\/+/,"").replace(/\/+$/,"");return e?e.split("/"):[]}var B,mr,bb,$s=k(()=>{Ns();B=class n{constructor(e,t,r){let s=typeof e=="string"?n.parse(e):e;this.name=s.name,this.version=mr(t??s.version),this.subpath=mr(r??s.subpath)}static parse(e){let t=yb(e||"");if(!t.length)return new n({name:""});if(t[0].startsWith("@")){let s=t[0],[i,o]=bb(t[1]??""),a=mr(t.slice(2).join("/"));return new n({name:`${s}/${i}`,version:o,subpath:a})}else{let[s,i]=bb(t[0]),o=mr(t.slice(1).join("/"));return new n({name:s,version:i,subpath:o})}}static fromUrl(e){try{let t=new URL(e),r=new URL(Wt).host,s=new URL(Is).host;if(t.host===r){let i=yb(t.pathname.replace(/^\/v\d+\//,"/"));if(!i.length)return;let o=i[0].startsWith("@")?`${i[0]}/${i[1]??""}`:i[0];return n.parse(o)}if(t.host===s){let i=t.pathname.split("/npm/")[1];if(!i)return;let o=i.split("/")[0]||"";return n.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 n.parse(e).name}withVersion(e){return new n({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=n=>n&&n.length?n:void 0,bb=n=>{let e=n.indexOf("@");return e<0?[n,void 0]:[n.slice(0,e),mr(n.slice(e+1))]}});async function xe(n){try{return await n()}catch{return}}var ua=k(()=>{});function kn(n){let e=n||"";return e.startsWith("./")?e.slice(2):e.replace(/^\/+/,"")}function kd(n){return n.startsWith("./")?n:`./${n}`}var Ls,xd=k(()=>{$s();ua();Ns();Ls=class{constructor(e,t){this.cache=e,this.http=t,this.pinMs=1e4,this.versionsIndexMs=1440*60*1e3,this.metaTtlMs=10080*60*1e3,this.pinCache=new Map}baseDir(e){let t=typeof e=="string"?new B(e):e;return`${Is}${t.name}${t.version?`@${t.version}`:""}/`}file(e,t){return new URL(kn(t),this.baseDir(e)).toString()}packageJson(e){return this.file(e,"package.json")}buildEsmUrl(e,t={}){let{target:r="es2022",bundle:s=!1,external:i}=t,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 t=Date.now(),r=this.pinCache.get(e);if(r&&t-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:t}),s}async tryResolveFromUrls(e){for(let t of e){let r=await xe(()=>this.http.head(t)),s=this.parseVersionFromUrl(r?.url||t);if(s)return s}}async fetchVersionsIndex(e){if(await this.cache.isNegative(e))return;let t=await this.cache.getIndex(e);if(t&&Date.now()-t.updatedAt<this.versionsIndexMs)return{versions:t.versions,distTags:t.distTags};let r=await xe(()=>this.http.getJson(`${Sd}${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 t=B.fromUrl(e)?.version;return t&&/\d+\.\d+\.\d+/.test(t)?t:void 0}async fetchPackageMeta(e,t){let r=await this.cache.getMeta(e,t);if(r&&Date.now()-r.updatedAt<this.metaTtlMs){let{dependencies:f,peerDependencies:d,peerDependenciesMeta:u}=r;return{name:e,version:t,dependencies:f,peerDependencies:d,peerDependenciesMeta:u}}let s=this.packageJson(new B(`${e}@${t}`)),i=await xe(()=>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,t,a,l,c),{name:e,version:t,dependencies:a,peerDependencies:l,peerDependenciesMeta:c}}}});var wb,Ms,Ed,KP,Ds,da=k(()=>{wb=n=>n.startsWith("@types/"),Ms=n=>Object.keys(n?.peerDependencies||{}).filter(e=>!wb(e)),Ed=n=>Object.keys(n?.dependencies||{}).filter(e=>!wb(e)),KP=n=>Ms(n).filter(e=>!n?.peerDependenciesMeta?.[e]?.optional),Ds=class{constructor(e){this.cdn=e}async resolve(e,t){let r=await this.fetchMeta(e),{allRoots:s,autoAddedPeers:i}=await this.expandWithPeers(r,t),o=this.computeFlags(s);return{allRoots:s,flags:o,autoAddedPeers:i}}async fetchMeta(e){return Promise.all(e.map(async({name:t,version:r})=>({name:t,version:r,meta:await this.cdn.fetchPackageMeta(t,r)})))}async expandWithPeers(e,t){let r=new Map(e.map(i=>[i.name,i])),s=[];for(let i of e)for(let o of KP(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 t(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 t=new Set(e.flatMap(i=>Ms(i.meta))),r=new Map;for(let i of e)for(let o of Ed(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:t.has(i.name),hasPeers:Ms(i.meta).length>0,isSharedDep:s.has(i.name)}]))}}});var Bs,Ad=k(()=>{$s();ua();Bs=class{constructor(e,t,r){this.cache=e,this.cdn=t,this.semver=r}async learnExactVersion(e){let t=await xe(()=>this.cdn.fetchVersionsIndex(e));if(t?.versions?.length){let r=this.semver.selectBestVersion(t.versions,{distTags:t.distTags});if(r)return r}return this.cdn.resolveExactVersion(e)}async resolveExactForRoot(e,t){if(!t)return this.learnExactVersion(e);let r=a=>!this.semver.isRange(t)||this.semver.satisfies(t,a),s=await this.cache.getPinnedExact(e,t);if(s){if(this.semver.isExactVersion(s)&&r(s))return s;console.debug("[typebulb] cached version for",e,"is not exact or not in",t,"(",s,"); re-resolving from registry")}let i=async a=>{if(a&&this.semver.isExactVersion(a)&&r(a))return await this.cache.setPinnedExact(e,t,a),a},o=await xe(()=>this.cdn.fetchVersionsIndex(e));if(o?.versions?.length){let a=this.semver.selectBestVersion(o.versions,{range:t,distTags:o.distTags});if(a){let l=await i(a);if(l)return l}else{console.debug("[typebulb] refreshing version cache for",e,"(",t,"not in cached set \u2014 likely a new release)"),await this.cache.invalidateVersionsCache(e);let l=await xe(()=>this.cdn.fetchVersionsIndex(e));if(l?.versions?.length){let c=await i(this.semver.selectBestVersion(l.versions,{range:t,distTags:l.distTags}));if(c)return c}}}return i(await this.cdn.resolveExactVersion(`${e}@${t}`))}async effectivePackage(e,t){let r=new B(e),s=r.root(),i=t[s],o=i?await xe(()=>this.resolveExactForRoot(s,i)):void 0;return{effectivePackage:o?r.withVersion(o).format():e,root:s,range:i,pinned:o}}}});import{init as HP,parse as zP}from"es-module-lexer";var gr,Td=k(()=>{$s();Ns();da();gr=class n{constructor(e,t,r){this.version=e,this.cdn=t,this.peer=r}extractImportsSync(e){let t=new Set;for(let r of n.importPatterns){r.lastIndex=0;for(let s of e.matchAll(r))B.isBare(s[1])&&t.add(s[1])}return Array.from(t)}async extractImports(e){let t=new Set,r=s=>{B.isBare(s)&&t.add(s)};try{await HP;let[s]=zP(e);s.forEach(i=>r(e.slice(i.s,i.e).trim()))}catch{return this.extractImportsSync(e)}return Array.from(t)}async buildImportMap(e,t,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,t)}))),{allRoots:a,flags:l,autoAddedPeers:c}=await this.peer.resolve(o,d=>this.resolveVersion(d,t)),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,t){let r=t[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,t,r){let s=new Map(t.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:y,hasPeers:v,isSharedDep:O}=r.get(m),P=a.has(m),E=p!==m,I=!(y||O)&&(P||!v),L=this.singletonDepsOf(h,o),A=E&&f.has(m);A&&d.add(m);let q=A?[...L,m]:L.length?L:void 0;l.push([p,this.cdn.buildEsmUrl(i(p),{bundle:I,external:q})]),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,t){return[...new Set([...Ms(e.meta),...Ed(e.meta)])].filter(r=>t.has(r))}};gr.importPatterns=[/\bimport\s+(?:[^'";]*?from\s*)?['"]([^'"]+)['"]/g,/\bexport\s+[^'";]*?from\s*['"]([^'"]+)['"]/g]});import{gt as vb,satisfies as YP,maxSatisfying as Sb,major as VP,valid as GP,validRange as XP}from"semver";var fa,xn,Od=k(()=>{fa=class{cmp(e,t){return e===t?0:vb(e,t)?1:vb(t,e)?-1:0}satisfies(e,t){return!e||!e.trim()?!0:!!YP(t,e,{includePrerelease:!0})}selectBestVersion(e,t){if(!e?.length)return;let r=t?.range?.trim()||"*",s=t?.preferStable??!0,i=t?.distTags?.latest;if(i&&e.includes(i)&&this.satisfies(r,i))return i;if(s){let a=Sb(e,r,{includePrerelease:!1});if(a)return a}return Sb(e,r,{includePrerelease:!0})??void 0}majorOf(e){return VP(e)}isExactVersion(e){return GP(e)!==null}isRange(e){return XP(e)!==null}},xn=new fa});function QP(n){return Math.min(9e5*Math.pow(2,Math.max(0,n-1)),864e5)}var En,kb=k(()=>{ua();En=class{constructor(e){this.store=e}async isNegative(e){let t=await xe(()=>this.store.get(e));return!!t&&t.until>Date.now()}async recordNegative(e){let r=((await xe(()=>this.store.get(e)))?.attempts||0)+1;await xe(()=>this.store.set(e,{until:Date.now()+QP(r),attempts:r}))}async clearNegative(e){await xe(()=>this.store.delete(e))}}});function xb(n,e){let t=new Ls(n,e),r=new Ds(t),s=new Bs(n,t,xn);return{packageService:new gr(s,t,r),versionResolver:s,cdnClient:t,peerResolver:r}}var yt=k(()=>{xd();da();Ad();Td();Od();$s();Od();Ns();xd();da();Ad();Td();kb()});import*as Pd from"fs/promises";import*as Eb from"crypto";function Xe(n){return Eb.createHash("sha1").update(n).digest("hex")}async function bt(n){try{return JSON.parse(await Pd.readFile(n,"utf8"))}catch{return}}async function pa(n){try{return await Pd.readFile(n,"utf8")}catch{return}}var yr=k(()=>{"use strict"});import*as Ht from"fs/promises";import*as wt from"path";import*as Tb from"os";function te(){return Cd||(Cd=eC().catch(()=>pt())),Cd}function ma(n,e){return wt.join(ZP,Xe(n),e)}async function eC(){await Ht.mkdir(Kt,{recursive:!0});let n=wt.join(Kt,"version.json");if((await bt(n))?.version===Ab)return;let t=await Ht.readdir(Kt).catch(()=>[]);await Promise.all(t.map(r=>Ht.rm(wt.join(Kt,r),{recursive:!0,force:!0}))),await Ht.writeFile(n,JSON.stringify({version:Ab})+`
533
- `,"utf8")}var Ab,Kt,js,Fs,ha,ZP,Cd,br=k(()=>{"use strict";yr();Ye();Ab=1,Kt=wt.join(Tb.homedir(),".typebulb","cache"),js=wt.join(Kt,"packages"),Fs=wt.join(Kt,"proxy"),ha=wt.join(Kt,"dts"),ZP=wt.join(Kt,"emit")});import*as zt from"fs/promises";import*as Ob from"path";async function Me(n,e){let t=`${n}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;try{await zt.mkdir(Ob.dirname(n),{recursive:!0}),await zt.writeFile(t,e,"utf8")}catch{pt();return}await zt.rename(t,n).catch(async()=>{await zt.rm(t,{force:!0}).catch(()=>{})})}var Us=k(()=>{"use strict";Ye()});var wr,_d=k(()=>{"use strict";Us();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,t){let r=await this.load();r.set(e,t),await this.persist(r)}async delete(e){let t=await this.load();t.delete(e)&&await this.persist(t)}async persist(e){await Me(this.filePath,JSON.stringify(Object.fromEntries(e)))}}});import*as _b from"fs/promises";import*as Qe from"path";function Cb(n,e){return Qe.join(tC,ga(n),encodeURIComponent(e)+".json")}function ga(n){return n.replace(/\//g,"__")}var Rd,Pb,tC,nC,ya,Rb=k(()=>{"use strict";yt();br();Us();_d();yr();Rd=Qe.join(js,"indexes"),Pb=Qe.join(js,"pinned"),tC=Qe.join(js,"meta"),nC=Qe.join(js,"negative.json"),ya=class{pinnedMem=new Map;indexMem=new Map;metaMem=new Map;negativeCache=new En(new wr(nC));async getPinnedExact(e,t){let r=`${e}@${t}`;if(this.pinnedMem.has(r))return this.pinnedMem.get(r);await te();let s=await pa(Qe.join(Pb,Xe(r)+".txt"));return this.pinnedMem.set(r,s),s}async setPinnedExact(e,t,r){let s=`${e}@${t}`;this.pinnedMem.set(s,r),await te(),await Me(Qe.join(Pb,Xe(s)+".txt"),r)}async getIndex(e){if(this.indexMem.has(e))return this.indexMem.get(e);await te();let t=await bt(Qe.join(Rd,ga(e)+".json"));return this.indexMem.set(e,t),t}async setIndex(e,t,r){let s={versions:t,distTags:r,updatedAt:Date.now()};this.indexMem.set(e,s),await te(),await Me(Qe.join(Rd,ga(e)+".json"),JSON.stringify(s))}async invalidateVersionsCache(e){this.indexMem.delete(e),await _b.rm(Qe.join(Rd,ga(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,t){let r=`${e}@${t}`;if(this.metaMem.has(r))return this.metaMem.get(r);await te();let s=await bt(Cb(e,t));return this.metaMem.set(r,s),s}async setMeta(e,t,r,s,i){let o={dependencies:r,peerDependencies:s,peerDependenciesMeta:i,updatedAt:Date.now()};this.metaMem.set(`${e}@${t}`,o),await te(),await Me(Cb(e,t),JSON.stringify(o))}}});var Ib,Nb=k(()=>{"use strict";Ib={async getJson(n){try{let e=await fetch(n,{redirect:"follow"});return e.ok?await e.json():void 0}catch{return}},async head(n){try{let e=await fetch(n,{method:"HEAD",redirect:"follow"});return{ok:e.ok,url:e.url}}catch{return}}}});var rC,ba,$b,Lb,Lj,Id=k(()=>{"use strict";yt();Rb();Nb();rC=new ya,{packageService:ba,versionResolver:$b,cdnClient:Lb,peerResolver:Lj}=xb(rC,Ib)});function wa(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Mb(){return` <script>
534
- ${Kg}
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>
535
+ ${Vg}
535
536
  (function () {
536
537
  try {
537
538
  var key = function () { return 'tb-scroll:' + location.pathname + location.search; };
@@ -544,10 +545,10 @@ ${Kg}
544
545
  });
545
546
  } catch (e) {}
546
547
  })();
547
- </script>`}function va(n,e){return` <script>
548
+ </script>`}function xa(t,e){return` <script>
548
549
  (function() {
549
550
  try {
550
- var KEY = ${vt(JSON.stringify("tb-theme:"+n))};
551
+ var KEY = ${vt(JSON.stringify("tb-theme:"+t))};
551
552
  var doc = document.documentElement;
552
553
  var mq = window.matchMedia('(prefers-color-scheme: dark)');
553
554
  var os = function() { return mq.matches ? 'dark' : 'light'; };
@@ -589,7 +590,7 @@ ${Kg}
589
590
  });
590
591
  } catch (e) {}
591
592
  })();
592
- </script>`}var vt,Db,Nd,sC,iC,Sa,vr=k(()=>{"use strict";ee();ee();vt=n=>n.replace(/<\/script/gi,"<\\/script");Db=30*6e4,Nd=1e3,sC=6e4,iC=3e4,Sa=(n="'/__reload'")=>`
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
594
  let es = null;
594
595
  let bootId = null;
595
596
  let firstErrorAt = 0;
@@ -599,14 +600,14 @@ ${Kg}
599
600
  // one instance, and the page outlives many.
600
601
  const tbOn = (event, fn) => { tbListeners.push([event, fn]); if (es) es.addEventListener(event, fn); };
601
602
  const tbConnect = () => {
602
- es = new EventSource(${n});
603
+ es = new EventSource(${t});
603
604
  for (const pair of tbListeners) es.addEventListener(pair[0], pair[1]);
604
605
  es.onerror = () => {
605
606
  if (!firstErrorAt) firstErrorAt = Date.now();
606
607
  // Inside the replace window, EventSource's own retry is faster than anything we'd schedule.
607
- if (Date.now() - firstErrorAt <= ${sC}) return;
608
+ if (Date.now() - firstErrorAt <= ${fC}) return;
608
609
  es.close();
609
- backoff = Math.min(${iC}, backoff ? backoff * 2 : ${Nd} * 2);
610
+ backoff = Math.min(${pC}, backoff ? backoff * 2 : ${Fd} * 2);
610
611
  setTimeout(tbConnect, backoff);
611
612
  };
612
613
  };
@@ -622,7 +623,7 @@ ${Kg}
622
623
  // A relay open (TB-VSCode-Browser.md): the CLI asks a page of ours inside VS Code to open a URL,
623
624
  // since its integrated browser honors a gesture-less window.open and keeps the new tab in-editor.
624
625
  tbOn('open-url', (e) => { window.open(e.data, '_blank', 'noopener'); });
625
- tbConnect();`});var Bb,jb=k(()=>{"use strict";vr();ee();Bb=`
626
+ tbConnect();`});var Hb,zb=S(()=>{"use strict";vr();ee();Hb=`
626
627
  (() => {
627
628
  // Inline (bulb-in-a-bulb): runs inside a sandboxed iframe with no parent
628
629
  // bridge, so privileged tb.* (AI, fs, server RPC) can't reach a host and would
@@ -1495,7 +1496,7 @@ ${Kg}
1495
1496
  if (relayed) history.replaceState(null, '', location.pathname + location.search);
1496
1497
  const tbStreamUrl = '/__reload?bulb=' + encodeURIComponent(window.__TB_BULB__ || '')
1497
1498
  + (relayed ? '&relay=' + Math.random().toString(36).slice(2) : '');
1498
- ${Sa("tbStreamUrl")}
1499
+ ${Ea("tbStreamUrl")}
1499
1500
  // Told to go, the page goes: it closes the tab, and where the browser refuses a script the close
1500
1501
  // (a tab that wasn't script-opened and has history) it replaces itself with a note naming the
1501
1502
  // reason. The note is a blob document, never a served route \u2014 a note that needs the server
@@ -1582,20 +1583,20 @@ ${Sa("tbStreamUrl")}
1582
1583
  });
1583
1584
  }
1584
1585
  })();
1585
- `});function Fb(n){let{name:e,code:t,css:r,html:s,data:i,insight:o,importMap:a,theme:l,inline:c,dir:f,source:d,bulbKey:u,compileError:p}=n,m=s.trim()||'<div id="app"></div>',h=c?"":`
1586
- `+Su,y={imports:uC(a.imports)};return`<!DOCTYPE html>
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>
1587
1588
  <html>
1588
1589
  <head>
1589
1590
  <meta charset="utf-8">
1590
1591
  <meta name="viewport" content="width=device-width, initial-scale=1">
1591
- <title>${wa(e)} - typebulb</title>
1592
- ${va(e,l)}
1593
- ${c?"":Mb()}
1592
+ <title>${ka(e)} - typebulb</title>
1593
+ ${xa(e,l)}
1594
+ ${c?"":Wb()}
1594
1595
  <script type="importmap">
1595
- ${JSON.stringify(y,null,2)}
1596
+ ${JSON.stringify(g,null,2)}
1596
1597
  </script>
1597
1598
  <style>
1598
- ${gs}${h}
1599
+ ${ys}${h}
1599
1600
  </style>
1600
1601
  <style>
1601
1602
  ${r}
@@ -1611,20 +1612,20 @@ ${u?`<script>window.__TB_BULB__ = ${vt(JSON.stringify(u))};</script>`:""}
1611
1612
  ${p?`<script>window.__TB_COMPILE_ERROR__ = ${vt(JSON.stringify(p))};</script>`:""}
1612
1613
 
1613
1614
  <script>
1614
- ${zg}
1615
- ${Bb}
1615
+ ${Xg}
1616
+ ${Hb}
1616
1617
  </script>
1617
1618
 
1618
- ${cC}
1619
+ ${yC}
1619
1620
 
1620
- ${aC(t,d)}
1621
+ ${mC(n,d)}
1621
1622
  </body>
1622
- </html>`}function aC(n,e){let t=["",...oC],r=e?Array(Math.max(0,e.codeLine-t.length-1)).fill(""):[],s=[...t,...r,vt(n)].join(`
1623
- `);return`<script type="module">${s}${lC(e,s)}
1624
- </script>`}function lC(n,e){if(!n)return"";let t=e.split(`
1625
- `).length,r={version:3,file:n.file,sources:[`/__source/${n.file}`],names:[],mappings:["AAAA",...Array(Math.max(0,t-1)).fill("AACA")].join(";")};return`
1626
- //# sourceURL=${n.file.replace(/\s/g,"%20")}
1627
- //# sourceMappingURL=data:application/json;charset=utf-8,${encodeURIComponent(JSON.stringify(r))}`}function uC(n){let e={};for(let[t,r]of Object.entries(n))e[t]=r.startsWith("https://")?"/proxy/"+r:r;return e}var oC,cC,Ub=k(()=>{"use strict";ee();jb();vr();oC=["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) */"];cC=`<script>
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(`
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
+ //# 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
1629
  (function () {
1629
1630
  var framed = window.parent !== window;
1630
1631
  var post = function (m) { try { parent.postMessage(m, '*'); } catch (e) {} }; /* framed only */
@@ -1723,20 +1724,20 @@ ${aC(t,d)}
1723
1724
  }
1724
1725
  });
1725
1726
  })();
1726
- </script>`});import*as xa from"fs/promises";import*as ka from"path";import{existsSync as qb,readFileSync as dC}from"fs";import{execFile as fC}from"child_process";import{promisify as pC}from"util";import{builtinModules as hC}from"node:module";import{satisfies as mC}from"semver";async function Ea(n,e,t,r){let i=n.map(c=>wC(c,t)).filter(c=>!vC(c,e));if(i.length===0)return;let o=i.filter(c=>!bC.test(c));if(o.length)throw new Error(`Refusing to install npm spec(s) with unsupported characters: ${o.join(", ")}
1727
- Use a plain name with an exact / caret / tilde range (e.g. three@^0.160.0).`);await xa.mkdir(e,{recursive:!0});let a=ka.join(e,"package.json");qb(a)||await xa.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 gC("npm",["install",...l,...i],{cwd:e,shell:!0})}function wC(n,e){if(!e||B.parse(n).version)return n;let t=e[n];return t?`${n}@${t}`:n}function vC(n,e){let{name:t,version:r}=B.parse(n),s=ka.join(e,"node_modules",t);if(!qb(s))return!1;if(!r)return!0;try{let i=JSON.parse(dC(ka.join(s,"package.json"),"utf-8")).version;return mC(i,r)}catch{return!1}}function Aa(n){let e=new Set,t=/\bimport\s+(?:[\s\S]*?\s+from\s+)?['"]([^./][^'"]*)['"]/g,r;for(;r=t.exec(n);){let s=r[1];if(s.includes(":"))continue;let i=B.rootOf(s);yC.has(i)||e.add(i)}return[...e]}var gC,yC,bC,$d=k(()=>{"use strict";yt();gC=pC(fC),yC=new Set(hC),bC=/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+(@[a-zA-Z0-9.^~*x-]+)?$/i});import*as De from"fs/promises";import*as Ce from"path";function Sr(n,e){let t=Ce.resolve(e,n),r=Ce.normalize(e),s=Ce.normalize(t);if(s!==r&&!s.startsWith(r+Ce.sep))throw new Error("Path traversal detected - access denied");return t}async function qs(n,e){return De.readFile(Sr(n,e))}async function Ta(n,e,t){let r=Sr(n,t);await De.mkdir(Ce.dirname(r),{recursive:!0}),await De.writeFile(r,typeof e=="string"?e:Buffer.from(e))}async function Oa(n,e){let t=Sr(n,e),r=await De.readdir(t,{withFileTypes:!0});return Promise.all(r.map(async s=>{let i=await De.stat(Ce.join(t,s.name)).then(o=>o.mtimeMs).catch(()=>0);return{name:s.name,dir:s.isDirectory(),mtime:i}}))}async function Pa(n,e){let t=Sr(n,e);if(Ce.normalize(t)===Ce.normalize(e))throw new Error("Cannot remove the bulb's folder itself: remove its contents instead");await De.rm(t,{recursive:!0})}var Ld=k(()=>{"use strict"});async function Jb(n){let e=gt(n.provider,n.model);if(typeof e=="string")throw new Error(e);let t=await Jt(e,n);if(!t.ok){let r=await fr(t,e.protocol);throw new Error(r.message)}return{response:t,protocol:e.protocol}}async function SC(n){let{response:e,protocol:t}=await Jb(n);return pr(e,t)}async function*kC(n){let{response:e,protocol:t}=await Jb(n);yield*Sn(e,t)}function Wb(n){let e=Object.assign(SC,{stream:kC}),t={read:async r=>{let s=await qs(r,n);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 qs(r,n)),write:async(r,s)=>(await Ta(r,s,n),!0),list:async(r=".")=>Oa(r,n),remove:async r=>(await Pa(r,n),!0)};globalThis.tb=Object.freeze({log:(...r)=>{console.log(...r)},ai:e,fs:t,dir:n,models:()=>mt(),aiAccess:ta,mode:Vn.local})}var Kb=k(()=>{"use strict";Ut();ee();ca();bn();Ld()});import*as Yt from"fs/promises";import*as ce from"path";import{pathToFileURL as xC}from"url";async function Hb(n){let t=(await Yt.readdir(n)).find(r=>r.endsWith(".bulb.md"));return t?ce.join(n,t):void 0}function kr(n){let e=ce.resolve(n);return ce.join(ce.dirname(e),ce.basename(e).replace(/\.bulb\.md$/,""))}function xr(n){let[e,t,r,s]=n.split(ce.sep).slice(-4);if(!(e!=="typebulbs"||t!=="u"||!r||!s?.endsWith(".bulb.md")))return{userSlug:r,slug:s.slice(0,-8)}}async function Ze(n){let e=await Yt.readFile(n,"utf-8"),t=Mn(e),r=ir(t);return{bulb:r,config:Mr(r.config),warnings:kp(e),starts:t.starts}}function Md(n){let e=ce.basename(n).replace(/\.bulb\.md$/i,"");return ce.join(ce.dirname(n),".typebulb",`${e}.server.mjs`)}async function Js(n,e,t,r){let s=vd(n,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;t&&(i=await gp(i,t));let o=ce.join(ce.dirname(e),".typebulb");await Yt.mkdir(o,{recursive:!0});let a=Aa(i);a.length>0&&await Ea(a,o,r);let l=Md(e);return await Yt.writeFile(l,i,"utf-8"),Wb(kr(e)),await import(`${xC(l).href}?t=${Date.now()}`)}async function Dd(n,e,t,r){let{bulb:s,config:i,starts:o}=await Ze(n),a=xo(s.data),l,c=m=>{l??=m instanceof Error?m.message:String(m)};try{mb(s.code,i.dependencies??{})}catch(m){c(m)}let f=vd(s.code,{jsxImportSource:i.ts?.jsxImportSource});f.error&&c(f.error);let d={imports:{}};if(!l)try{({importMap:d}=await ba.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=Fb({name:s.name,code:l?"":f.code,css:s.css,html:s.html,data:a,insight:s.insight,importMap:d,dir:kr(n),watch:e,source:{file:ce.basename(n),codeLine:o.get("code.tsx")??1},bulbKey:vs(n),compileError:l}),p;return s.server&&t&&(p=await Js(s.server,n,r,i.dependencies)),{html:u,bulb:s,serverExports:p,buildError:l}}var An,St=k(()=>{"use strict";Es();hb();gb();Id();Ub();$d();vi();Ye();Kb();An=n=>ce.join(kr(n),"assets")});import*as _e from"fs/promises";import*as Be from"path";import{createHash as EC}from"crypto";async function jd(n,e,t){let r=[...n],s=async()=>{for(let i=r.shift();i!==void 0;i=r.shift())await t(i)};await Promise.all(Array.from({length:Math.min(e,n.length)},s))}function Er(n){try{return JSON.parse(n).error||n}catch{return n}}async function Ud(n,e){try{let t=await fetch(Ws(n),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});return t.ok?t.headers.get("content-type")?.includes("json")?{entries:await t.json()}:{error:"manifest response is not JSON \u2014 wrong origin?"}:{error:`manifest request failed (${t.status}): ${Er(await t.text())}`}}catch(t){return{error:t instanceof Error?t.message:String(t)}}}function qd(n,e){ke(e);let t=process.env.TYPEBULB_ORIGIN||AC;try{return Ra(n,process.cwd(),t)}catch(r){console.error(r instanceof Error?r.message:String(r)),process.exit(1)}}function Ra(n,e,t){if(/^https?:\/\//i.test(n)){let i=new URL(n),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: ${n}
1728
- Expected <origin>/u/<user>/<slug>`);let l=a[1],c=a[2].replace(/(\.bulb)?\.md$/,"");return{origin:i.origin,userSlug:l,slug:c,dest:Be.join(e,Ca(l,c))}}let r=Be.resolve(e,n),s=xr(r);if(!s)throw new Error(`Not a conventional bulb path: ${n}
1729
- 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:t,...s,dest:r}}async function TC(n,e){let t=await Ud(n,e);if("error"in t||!t.entries.length)return{kind:"none"};let r=t.entries,s=An(n.dest),i=[],o=[],a=0;for(let l of r){let c=await _e.readFile(Be.join(s,...l.path.split("/"))).catch(()=>{});c===void 0?i.push(l.path):Fd(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 OC(n,e,t){let r=An(n.dest),s=[],i=0;return await jd(e.toGet,4,async o=>{try{let a=await fetch(`${Ws(n)}/${_a(o)}`,{headers:t.token?{Authorization:`Bearer ${t.token}`}:{},signal:AbortSignal.timeout(t.timeoutMs??3e4)});if(!a.ok){s.push(`${o}: HTTP ${a.status}`);return}let l=Be.join(r,...o.split("/"));await _e.mkdir(Be.dirname(l),{recursive:!0}),await _e.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 Ia(n,e={}){let t=await fetch(Bd(n),{headers:e.token?{Authorization:`Bearer ${e.token}`}:{},signal:e.timeoutMs?AbortSignal.timeout(e.timeoutMs):void 0});if(!t.ok)return{kind:"http-error",status:t.status};let r=t.headers.get("content-type");if(!r?.includes("text/markdown"))return{kind:"not-markdown",contentType:r??void 0};let s=await t.text(),i;try{i=await _e.readFile(n.dest,"utf-8")}catch{}let o=i!==void 0&&PC(i,s);if(i!==void 0&&!o&&!e.force){let{mtime:c}=await _e.stat(n.dest);return{kind:"conflict",dest:n.dest,localMtime:c,remoteLastModified:t.headers.get("last-modified")??void 0}}let a=await TC(n,e);if(a.kind==="conflict")return{kind:"asset-conflict",dest:n.dest,paths:a.paths};if(!o){await _e.mkdir(Be.dirname(n.dest),{recursive:!0}),await _e.writeFile(n.dest,s);let c=new Date(t.headers.get("last-modified")??"");isNaN(c.getTime())||await _e.utimes(n.dest,new Date,c)}let l=a.kind==="plan"?await OC(n,a,e):void 0;return o?{kind:"up-to-date",dest:n.dest,assets:l}:{kind:"written",dest:n.dest,created:i===void 0,assets:l}}function PC(n,e){let t=i=>i.replace(/\r\n/g,`
1730
- `),r=We(t(n)),s=We(t(e));return!r||!s?t(n)===t(e):r.frontmatter.name===s.frontmatter.name&&Je.every(i=>(r.files.get(le[i].path)||"")===(s.files.get(le[i].path)||""))}async function Yb(n,e){n||(console.error("Usage: typebulb pull <bulb url | typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1));let t=qd(n,e.mode),r=`${t.origin}/u/${t.userSlug}/${t.slug}`,s;try{s=await Ia(t,{force:e.force,token:process.env.TYPEBULB_TOKEN})}catch(o){console.error(`Could not reach ${t.origin}: ${o instanceof Error?o.message:String(o)}`),process.exitCode=1;return}let i=Be.relative(process.cwd(),t.dest)||t.dest;switch(s.kind){case"written":console.log(`pulled ${r} \u2192 ${i}${s.created?"":" (overwritten)"}`),zb(s.assets);return;case"up-to-date":console.log(`up to date: ${i}`),zb(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 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}
1731
1732
  local file modified ${s.localMtime.toISOString()}
1732
1733
  remote last saved ${s.remoteLastModified??"unknown"}
1733
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:
1734
1735
  `+s.paths.map(o=>` assets/${o}`).join(`
1735
1736
  `)+`
1736
- 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: ${t.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 ${t.origin} a typebulb host?`),process.exitCode=1}}function zb(n){if(!(!n||!n.downloaded&&!n.errors.length)){console.log(`assets: ${n.downloaded} downloaded${n.unchanged?`, ${n.unchanged} unchanged`:""}`);for(let e of n.errors)console.error(` asset failed \u2014 ${e} (a re-pull retries just the missing ones)`);n.errors.length&&(process.exitCode=1)}}var AC,Ca,Bd,_a,Ws,Fd,Na=k(()=>{"use strict";ot();ee();St();AC="https://typebulb.com",Ca=(n,e)=>Be.join("typebulbs","u",n,`${e}.bulb.md`),Bd=n=>`${n.origin}/u/${encodeURIComponent(n.userSlug)}/${encodeURIComponent(n.slug)}.md`,_a=n=>n.split("/").map(encodeURIComponent).join("/"),Ws=n=>`${n.origin}/u/${encodeURIComponent(n.userSlug)}/${encodeURIComponent(n.slug)}/assets`;Fd=n=>EC("md5").update(n).digest("hex")});import*as at from"fs/promises";import*as Ks from"path";async function Vb(n,e=""){let t=await at.readdir(n,{withFileTypes:!0}).catch(()=>[]),r=[];for(let s of t)s.isDirectory()?r.push(...await Vb(Ks.join(n,s.name),`${e}${s.name}/`)):s.isFile()&&r.push(e+s.name);return r}async function CC(n,e){let t=e.timeoutMs??3e4,r=Ws(n),s={Authorization:`Bearer ${e.token}`},i=An(n.dest);if(!await at.stat(i).then(m=>m.isDirectory()).catch(()=>!1))return{kind:"skipped"};let o=await Vb(i),a=await Ud(n,{token:e.token,timeoutMs:t});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 jd(o,4,async m=>{let h=await at.readFile(Ks.join(i,...m.split("/")));if(c.get(m)===Fd(h)){p++;return}let y=await fetch(`${r}/${_a(m)}`,{method:"PUT",body:new Uint8Array(h),headers:s,signal:AbortSignal.timeout(t)});if(!y.ok)throw new Error(`upload of '${m}' refused (${y.status}): ${Er(await y.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:Ei(n.userSlug,n.slug)}}async function _C(n,e,t){let r=t.timeoutMs??3e4,s=Ws(n),i=[];for(let o of e)try{let a=await fetch(`${s}/${_a(o)}`,{method:"DELETE",headers:{Authorization:`Bearer ${t.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 $a(n,e){let t=await at.readFile(n.dest,"utf-8"),{mtime:r}=await at.stat(n.dest),s=await CC(n,{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(Bd(n),{method:"PUT",body:t,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(n.dest,new Date,new Date(c.updatedAt)),i&&s.kind==="synced"&&s.toDelete.length){let f=await _C(n,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 Gb(n,e){n||(console.error("Usage: typebulb push <typebulbs/u/<user>/<slug>.bulb.md>"),process.exit(1)),/^https?:\/\//i.test(n)&&(console.error("push takes a local .bulb.md file, not a URL (the path is its remote identity)"),process.exit(1));let t=qd(n,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=`${t.origin}/u/${t.userSlug}/${t.slug}`,i=Ks.relative(process.cwd(),t.dest)||t.dest,o;try{o=await $a(t,{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 ${t.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 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
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}
1738
1739
  pull to see the remote: typebulb pull ${i}
1739
- 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: ${t.origin} responded ${o.status}${o.message?` \u2014 ${o.message}`:""}`),process.exitCode=1}}var Jd=k(()=>{"use strict";ee();Na();St()});var Tn=k(()=>{"use strict";$e();Jy();fn();Wy();Yu();Vy();Xy();Os();bn();bn();ca();wd();$e();Na();Jd();ot();Ye()});import{existsSync as RC,mkdirSync as IC,readFileSync as NC,rmSync as $C,writeFileSync as LC}from"fs";import{homedir as MC}from"os";import*as Ar from"path";function FC(){return jC.replace('"__TB_SKILL_PATH__"',JSON.stringify(Rs())).replace('"__TB_BIN_PATH__"',JSON.stringify(sr()))}function Xb(){try{if(!RC(Wd()))return}catch{return}try{let n=DC(),e=FC(),t;try{t=NC(n,"utf8")}catch{}t!==e&&(IC(Ar.dirname(n),{recursive:!0}),LC(n,e))}catch{}for(let n of BC())try{$C(n,{force:!0})}catch{}}var Wd,DC,BC,jC,Qb=k(()=>{"use strict";Tn();Wd=()=>Ar.join(MC(),".pi","agent"),DC=()=>Ar.join(Wd(),"extensions","typebulb.ts"),BC=()=>["typebulb-wait.ts","matchu-patchu.ts"].map(n=>Ar.join(Wd(),"extensions",n)),jC=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";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
1741
  import { spawn } from "node:child_process";
1741
1742
  import { existsSync } from "node:fs";
1742
1743
 
@@ -2004,23 +2005,23 @@ export default function (pi) {
2004
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) {}
2005
2006
  } catch (e) { logErr("load", e && e.message); }
2006
2007
  }
2007
- `});function Y(n){return n?.message??String(n)}var V,Vt=k(()=>{"use strict";V=process.cwd()});import{spawn as Zb}from"child_process";import{StringDecoder as UC}from"string_decoder";function zC(n,e){let t=new UC("utf8"),r="";n.on("data",s=>{r+=typeof s=="string"?s:t.write(s);let i;for(;(i=r.indexOf(`
2008
- `))>=0;){let o=r.slice(0,i);r=r.slice(i+1),o.endsWith("\r")&&(o=o.slice(0,-1)),o&&e(o)}})}var qC,ew,tw,Kd,nw,JC,WC,KC,rw,HC,La,Ma,sw,iw=k(()=>{"use strict";Vt();qC=3e4,ew=18e4,tw="starting pi\u2026",Kd=5e3,nw=2e3,JC=2e3,WC=12e4,KC=8e3,rw=15e3,HC=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"]),La=new Set;process.on("exit",()=>{for(let n of La)try{n.kill()}catch{}});Ma=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,t,r=(s,i)=>Zb(s,{cwd:i,shell:!0,stdio:["pipe","pipe","pipe"],env:{...process.env,TYPEBULB_MIRROR:"1"}})){if(this.#x=new Promise(o=>{this.#S=o}),t?.includes('"')){this.#g="session path contains a quote \u2014 cannot drive it",this.#S();return}let s=t?`pi --mode rpc --session "${t}"`:"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=t,this.#i=!0,this.#h=Date.now()+ew,this.#e={text:tw,kind:"info"},La.add(i),i.stdout&&zC(i.stdout,o=>this.#I(o)),i.stderr&&i.stderr.on("data",o=>{this.#v=(this.#v+o.toString()).slice(-JC)}),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"),La.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===tw&&(this.#e=null),this.#r&&(this.#r.until=Date.now()+rw),!this.#l&&Date.now()<this.#n&&(this.#n=Date.now()+Kd),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 t=this.#a[0];if(e<t.until)return t.req;this.#a.shift(),t.ownTimeout||this.#E({type:"extension_ui_response",id:t.req.id,cancelled:!0})}return null}notice(e,t){this.#y(e,t)}respondUi(e,t){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 t.cancelled?i.cancelled=!0:s.req.method==="confirm"?i.confirmed=!!t.confirmed:i.value=t.value??"",this.#E(i),{ok:!0}}async rpc(e){if(!HC.has(e.type))return{ok:!1,error:`command not allowed: ${e.type}`};try{let t=await this.#p(e);if(t.success&&e.type==="set_model"){let r=t.data?.id;typeof r=="string"&&r&&(this.#w=r)}if(t.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:{...t.data??{},sessionFile:this.#m}}}return t.success?{ok:!0,data:t.data}:{ok:!1,error:t.error??`pi rejected ${e.type}`}}catch(t){return{ok:!1,error:Y(t)}}}async send(e,t){let r=this.streaming,s=e.trimStart().startsWith("/"),i=r?s?{type:"prompt",message:e,streamingBehavior:t?.followUp?"followUp":"steer"}:{type:t?.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+Kd),{ok:!0};let a;try{a=await this.#p(i)}catch(l){return{ok:!1,error:Y(l)}}return a.success&&o(Date.now()+Kd),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"})+`
2009
- `)}catch{}await Promise.race([this.#x,sw(nw)])}try{e.stdin?.end()}catch{}if(await Promise.race([this.#x,sw(nw)]),e.exitCode===null&&!e.killed)if(process.platform==="win32"&&e.pid)try{Zb("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"})}catch{}else try{e.kill("SIGKILL")}catch{}La.delete(e),this.#a=[],this.#C("pi was shut down")}}#E(e){try{this.#t?.stdin?.write(JSON.stringify(e)+`
2010
- `)}catch{}}#O(){let e=this.#o[this.#o.length-1];this.#d={text:this.#o.filter(t=>t?.kind==="text").map(t=>t.text).join(""),thinking:this.#o.filter(t=>t?.kind==="thinking").map(t=>t.text).join(`
2011
- `),tool:e?.kind==="tool"?e.name:void 0}}#A(e){let t=Array.isArray(e?.content)?e.content:[];this.#o=t.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,t){let r=e.length>200?e.slice(0,200)+"\u2026":e;r&&(this.#r={text:r,kind:t,until:Date.now()+(t==="info"?KC:rw)})}#T(){this.#p({type:"get_session_stats"}).then(e=>{if(!e.success||!e.data)return;let t=e.data;this.#k={cost:typeof t.cost=="number"?t.cost:0,contextTokens:typeof t.contextUsage?.tokens=="number"?t.contextUsage.tokens:null,contextPercent:typeof t.contextUsage?.percent=="number"?t.contextUsage.percent:null}}).catch(()=>{})}#p(e){let t=this.#t;if(!t?.stdin?.writable)return Promise.reject(new Error(this.#g??"pi is not running"));let r=this.#i?ew:qC,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{t.stdin.write(JSON.stringify({id:s,...e})+`
2012
- `)}catch(l){clearTimeout(a),this.#f.delete(s),o(new Error(Y(l)))}})}#I(e){let t;try{t=JSON.parse(e)}catch{return}switch(t.type){case"response":{let r=t,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=t.message;if(r?.role!=="assistant")return;this.#s=!0,this.#A(r);return}case"message_update":{if(!this.#s)return;if(t.message){this.#A(t.message);return}let r=t.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;t.message&&this.#A(t.message),this.#s=!1;return;case"auto_retry_start":this.#e={text:`retrying after a transient error (attempt ${Number(t.attempt)||1}/${Number(t.maxAttempts)||"?"})\u2026`,kind:"warning"};return;case"auto_retry_end":this.#e=null,t.success===!1&&this.#y(`retries exhausted: ${String(t.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=t.result;typeof t.errorMessage=="string"&&t.errorMessage?this.#y(`compaction failed: ${t.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(t.steering)?t.steering.map(String):[],s=Array.isArray(t.followUp)?t.followUp.map(String):[];this.#b=r.length||s.length?{steering:r,followUp:s}:null;return}case"extension_ui_request":{let r=String(t.method??"");if(r==="select"||r==="confirm"||r==="input"||r==="editor"){let s=typeof t.timeout=="number"&&t.timeout>0?t.timeout:void 0;this.#a.push({req:{id:String(t.id??""),method:r,title:typeof t.title=="string"?t.title:void 0,message:typeof t.message=="string"?t.message:void 0,options:Array.isArray(t.options)?t.options.map(String):void 0,placeholder:typeof t.placeholder=="string"?t.placeholder:void 0,prefill:typeof t.prefill=="string"?t.prefill:void 0},until:Date.now()+(s??WC),ownTimeout:s!==void 0})}else if(r==="notify"){let s=t.notifyType==="warning"?"warning":t.notifyType==="error"?"error":"info";this.#y(String(t.message??""),s),console.log(`[composer] pi extension: ${String(t.message??"")}`)}else if(r==="setStatus"){let s=String(t.statusKey??"");typeof t.statusText=="string"&&t.statusText?this.#u.set(s,t.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[,t]of this.#f)clearTimeout(t.timer),t.resolve({type:"response",success:!1,error:e});this.#f.clear()}},sw=n=>new Promise(e=>{setTimeout(e,n).unref?.()})});import{existsSync as ow,readFileSync as YC,realpathSync as VC}from"fs";import{join as On,dirname as uw,resolve as GC}from"path";import{homedir as aw}from"os";function QC(n,e){let t=On(n,".pi");if(XC.some(s=>ow(On(t,s))))return!0;let r=On(e,".agents","skills");for(let s=n;;){let i=On(s,".agents","skills");if(i!==r&&ow(i))return!0;let o=uw(s);if(o===s)return!1;s=o}}function ZC(n,e){for(let t=e;;){if(n[t]===!0||n[t]===!1)return!0;let r=uw(t);if(r===t)return!1;t=r}}function dw(n,e){try{let t=e?.agentDir??On(aw(),".pi","agent"),r=lw(e?.home??process.env.HOME??aw()),s=lw(GC(n));if(!QC(s,r))return null;let i=cw(On(t,"settings.json")).defaultProjectTrust;return i==="always"||i==="never"||ZC(cw(On(t,"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 XC,lw,cw,fw=k(()=>{"use strict";XC=["settings.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],lw=n=>{try{return VC(n)}catch{return n}},cw=n=>{try{return JSON.parse(YC(n,"utf8"))}catch{return{}}}});import{statSync as e_,openSync as t_,readSync as n_,closeSync as r_,existsSync as hw}from"fs";import{join as Da}from"path";import{homedir as Hd}from"os";import{execFile as s_}from"child_process";async function o_(n){let e=Da(Hd(),".pi","agent","bin",process.platform==="win32"?"fd.exe":"fd");for(let t of["fd","fdfind",...hw(e)?[e]:[]]){let r=await new Promise(s=>{s_(t,["--base-directory",n,"--type","f","--follow","--hidden","--exclude",".git"],{maxBuffer:67108864},(i,o)=>s(i?null:o))});if(r!==null)return r.split(`
2013
- `).filter(Boolean).map(s=>s.replace(/\\/g,"/"))}return null}function a_(n){return`--${n.replace(/^[/\\]/,"").replace(/[/\\:]/g,"-")}--`}function pw(n){return n.type==="message"?l_(n.message?.role):n.type==="custom_message"?n.display!==!1:!1}var i_,l_,Tr,zd=k(()=>{"use strict";ys();Co();_o();Qb();iw();fw();i_=Da(Hd(),".pi","agent","sessions");l_=n=>n==="user"||n==="assistant"||n==="toolResult"||n==="bashExecution";Tr=class extends Bt{displayName="Pi Mirror";detectsSelf(){return process.env.PI_CODING_AGENT==="true"}detectsInstalled(){return hw(Da(Hd(),".pi","agent"))}ensureHarnessSupport(){Xb()}createDriver(e,t){let r=new Ma(e,t),s=dw(e);return s&&r.notice(s,"warning"),r}walkFiles(e){return o_(e)}sessionsDir(e){return Da(i_,a_(e))}listSessionFiles(e){return Po(this.sessionsDir(e))}parseEntry(e){let t;try{t=JSON.parse(e)}catch{return null}return!t||t.type==="session"||!t.id?null:t}idOf(e){return e.id}parentOf(e){return e.parentId??void 0}timestampOf(e){return e.timestamp}isSidechain(e){return!1}isLeafType(e){return pw(e)}isRecoveryNoise(e){return!1}apply(e,t){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:Ne(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(`
2014
- `),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>=t;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 t;for(let a of e)pw(a)&&(t=a);if(!t||t.type==="custom_message")return!1;let r=t.message.role;if(r==="user"||r==="toolResult"||r==="bashExecution")return!0;if(r!=="assistant")return!1;let i=(Array.isArray(t.message.content)?t.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 t;try{t=t_(e,"r")}catch{return""}try{let s=65536;try{s=e_(e).size}catch{}let i=(d,u)=>{let p=Buffer.alloc(u),m=n_(t,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(`
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)+`
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(`
2015
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(`
2016
- `))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{r_(t)}}searchText(e){if(e?.type!=="message")return"";let t=e.message?.role;if(t!=="user"&&t!=="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"?Te(e):Array.isArray(e)?e.map(t=>typeof t?.text=="string"?Te(t.text):t?.type==="image"&&t.data?To(t.data,t.mimeType):"").filter(Boolean).join(`
2017
- `):""}}});var Ba,mw=k(()=>{"use strict";Ba=class{#t=new Map;accept(e,t){return this.#t.get(e)===t?!1:(this.#t.set(e,t),!0)}}});import{execFile as c_}from"child_process";import{promisify as u_}from"util";import{readFile as d_}from"fs/promises";import{resolve as gw,sep as f_}from"path";async function et(n,e){let{stdout:t}=await p_("git",n,{cwd:e,maxBuffer:67108864});return t}async function Pn(){if(ja)return ja;try{ja=(await et(["rev-parse","--show-toplevel"],V)).trim()}catch{}return ja}function h_(n,e){let t=e===" "?n:e;return t==="?"?"U":t}async function Vd(){let n=await Pn();if(!n)return{repo:!1,root:"",files:[]};try{let e=await et(["status","--porcelain","-z"],n),t=[],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++,t.push({path:i.slice(3),status:h_(i[0],i[1])}))}try{let s=await et(["diff","--numstat","-z","HEAD"],n),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 t){let l=i.get(a.path);l&&(l.binary?a.binary=!0:(a.add=l.add,a.del=l.del))}}catch{}return t.sort((s,i)=>s.path.localeCompare(i.path)),{repo:!0,root:n,files:t}}catch(e){return{repo:!1,root:"",files:[],error:Y(e)}}}async function Gd(n){let e=await Pn();if(!e)return{ok:!1,error:"not a git repository"};try{if((await et(["status","--porcelain","-z","--",n],e)).startsWith("??")){let s=gw(e,n);if(!s.startsWith(gw(e)+f_))return{ok:!1,error:"outside repository"};let i=await d_(s);return i.includes(0)?Yd("Binary file (not shown)",!1):Yd(i.toString("utf8"),!0)}let r;try{r=await et(["diff","--no-color","--unified=999999","HEAD","--",n],e)}catch{r=await et(["diff","--no-color","--unified=999999","--",n],e)}return Yd(r,!1)}catch(t){return{ok:!1,error:Y(t)}}}var p_,yw,ja,Yd,Hs=k(()=>{"use strict";Vt();p_=u_(c_),yw=2e6;Yd=(n,e)=>({ok:!0,text:n.slice(0,yw),untracked:e,truncated:n.length>yw})});function zs(n,e){let t=0,r="";for(let s of n){let i=s.lower.indexOf(e);if(!(i<0)&&(t++,!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:t,snippet:r}}var Xd=k(()=>{"use strict"});function bw(){return m_.map(([n,e])=>gt(n,e)).filter(n=>typeof n!="string")}function Qd(){return bw().length>0}async function Ys(n,e,t=0){let r=AbortSignal.timeout(e);for(let s of bw()){try{let i=await Jt(s,{messages:[{role:"user",content:n}],effort:t,webSearch:!1,signal:r});if(i.ok){let o=(await pd(i,s.protocol)).trim();if(o)return o}}catch{}if(r.aborted)return}}var m_,Zd=k(()=>{"use strict";Ut();Tn();m_=[["openrouter","openai/gpt-6-luna"],["openai","gpt-6-luna"]]});var Fa,Ua,Cn,Vs=k(()=>{"use strict";Fa=".typebulb/paste",Ua={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",bmp:"image/bmp"},Cn=n=>n.label||n.kind||"agent"});import{existsSync as g_,mkdirSync as y_,writeFileSync as b_,readFileSync as w_}from"fs";import{join as qa}from"path";function ww(){let n=new Date,e=t=>String(t).padStart(2,"0");return`${n.getFullYear()}${e(n.getMonth()+1)}${e(n.getDate())}-${e(n.getHours())}${e(n.getMinutes())}${e(n.getSeconds())}`}function k_(n){return n.trim().toLowerCase().replace(/\.[a-z0-9]{1,4}$/,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function x_(n){let e=await Ys(`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{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:
2018
2019
 
2019
- ${n.slice(0,S_)}`,v_);return e&&k_(e)||void 0}async function vw(n,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 t=qa(n,Fa);try{y_(t,{recursive:!0})}catch(a){return{ok:!1,error:Y(a)}}let r,s,i;if(e.kind==="image"){if(r=`img-${ww()}`,s=Object.keys(Ua).find(a=>Ua[a]===e.mime)??"png",i=Buffer.from(e.data,"base64"),!i.length)return{ok:!1,error:"empty image data"}}else r=await x_(e.data)??`paste-${ww()}`,s="md",i=e.data;let o=`${r}.${s}`;for(let a=2;g_(qa(t,o));a++)o=`${r}-${a}.${s}`;try{b_(qa(t,o),i)}catch(a){return{ok:!1,error:Y(a)}}return{ok:!0,path:`${Fa}/${o}`}}function Sw(n,e){if(!/^[\w-]+(\.[\w-]+)*$/.test(e))return{ok:!1,error:"bad name"};let t=e.slice(e.lastIndexOf(".")+1).toLowerCase(),r=Ua[t];if(!r)return{ok:!1,error:"not an image"};try{return{ok:!0,mime:r,base64:w_(qa(n,Fa,e)).toString("base64")}}catch{return{ok:!1,error:"not found"}}}var v_,S_,kw=k(()=>{"use strict";Zd();Vt();Vs();v_=4e3,S_=4e3});async function Ow(n,e=""){let t=n.trim();if(!t)return{ok:!1,error:"nothing to summarize"};if(!Qd())return Aw;let r=e.trim()?xw+`CONTEXT \u2014 the user message this reply answers. It is context only: never summarize it, and never report it as the reply's content.
2020
- `+E_(e.trim())+`
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())+`
2021
2022
 
2022
2023
  REPLY TO SUMMARIZE:
2023
- `+t.slice(0,tf):xw+t.slice(0,tf),s=await Ys(r,Ew,1);return s?{ok:!0,text:s}:Tw}async function Gs(n,e){if(!Qd())return Aw;let t;if(n==="plan"){let s=String(e??"").trim();if(!s)return{ok:!1,error:"nothing to summarize"};t=A_+s.slice(0,tf)}else{let s=e;if(!Array.isArray(s?.subtasks)||typeof s.log!="string")return{ok:!1,error:"nothing to summarize"};t=T_({...s,log:O_(s.log)})}let r=await Ys(t,Ew*2,1);if(!r)return Tw;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 Ew,tf,xw,E_,Aw,Tw,A_,T_,ef,O_,nf=k(()=>{"use strict";Zd();Ew=2e4,tf=24e3,xw=`Summarize this assistant reply for someone who wants its substance without the prose.
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
2025
 
2025
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.
2026
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.
@@ -2035,23 +2036,23 @@ Reply with the summary alone.
2035
2036
 
2036
2037
  ---
2037
2038
 
2038
- `,E_=(n,e=4e3)=>{if(n.length<=e)return n;let t=Math.floor(e/2)-20;return n.slice(0,t)+`
2039
+ `,I_=(t,e=4e3)=>{if(t.length<=e)return t;let n=Math.floor(e/2)-20;return t.slice(0,n)+`
2039
2040
 
2040
2041
  [snipped for brevity]
2041
2042
 
2042
- `+n.slice(n.length-t)},Aw={ok:!1,error:"Summary needs OPENROUTER_API_KEY or OPENAI_API_KEY in this project\u2019s .env.",setup:!0},Tw={ok:!1,error:"the model call failed or timed out"};A_=`A coordinator sent this message to a sub-agent. Return JSON only:
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
2044
  {"request": "one or two plain sentences: what it asks for and what must be delivered", "subtasks": ["..."]}
2044
2045
 
2045
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": [].
2046
2047
 
2047
2048
  MESSAGE:
2048
- `,T_=n=>`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
+ `,$_=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
2050
 
2050
2051
  SUBTASKS:
2051
- ${n.subtasks.map((e,t)=>`${t+1}. ${e}`).join(`
2052
+ ${t.subtasks.map((e,n)=>`${n+1}. ${e}`).join(`
2052
2053
  `)}
2053
2054
 
2054
- The agent has ${n.finished?"FINISHED":"NOT finished; the log ends where it is now"}.
2055
+ The agent has ${t.finished?"FINISHED":"NOT finished; the log ends where it is now"}.
2055
2056
 
2056
2057
  Return JSON only:
2057
2058
  {"now": "...", "decision": "...",
@@ -2064,6 +2065,7 @@ Rules:
2064
2065
  - One row per subtask, same ids. "steps" lists EVERY bracketed step range that worked on it: reading, attempts, failures and fixes, not only the result. Together the rows and offBrief should cover the whole log; ranges never overlap.
2065
2066
  - "evidence" lists the few steps that show where it stands: the result for done, the latest work for in_progress.
2066
2067
  - "done" only when the log shows the result. If the only evidence is the agent's own report, write "reported" in "did".
2068
+ - A step's result is one line of its output, and its last line where the log gives one; "(+N lines)" is how much more there was. Never read a count or a total off a line that does not state it.
2067
2069
  - "did" says what was achieved so far: outcome and state, not tool mechanics. For a done row, one short clause. For an in_progress row, what has been found or confirmed so far, never only what was examined ("Confirmed the per-stroke check drops stretches 3 and 6-10", not "Investigated the dropped stretches"); when nothing is established yet, the hypothesis being tested. A file name only when it is the deliverable. A not_started row has "did": "".
2068
2070
  - Make the work the subject of every sentence ("Counted 14 references", "The build passes"); never refer to the agent itself, as "the agent", "it", or otherwise.
2069
2071
  - Unfinished is not off track: a subtask not started yet is normal while earlier ones run.
@@ -2071,47 +2073,49 @@ Rules:
2071
2073
  - "offBrief": work the brief did not ask for, done by the sub-agent itself. Something it only saw is not its work: a file changed by someone else, shown in a status or a diff. Empty array if none.
2072
2074
 
2073
2075
  FACTS (counted from the log):
2074
- ${n.facts||"none"}
2076
+ ${t.facts||"none"}
2075
2077
 
2076
2078
  LOG (steps numbered in brackets):
2077
- ${n.log}`,ef=2e5,O_=n=>n.length<=ef?n:n.slice(0,ef/3)+`
2079
+ ${t.log}`,lf=2e5,L_=t=>t.length<=lf?t:t.slice(0,lf/3)+`
2078
2080
  [\u2026 earlier steps omitted \u2026]
2079
- `+n.slice(-ef*2/3)});import{readFileSync as P_,statSync as C_}from"fs";function Ja(n,e,t,r){let s=n.apply(e,r),i=Date.parse(n.timestampOf(e)??""),o=s.events.map(a=>{let l=t==="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 Pw(n,e,t){let r=n.forRead(),s;try{s=P_(e,"utf8")}catch{return[]}let i=new Map,o;for(let d of s.split(`
2080
- `)){if(!d.trim())continue;let u=r.parseEntry(d),p=u&&r.idOf(u);!u||!p||(i.set(p,u),!r.isSidechain(u,t)&&r.isLeafType(u)&&(o=p))}let a=[],l=new Set;for(let d=o;d&&!l.has(d);){let u=i.get(d);if(!u)break;l.add(d),a.push(u),d=r.parentOf(u)}let c=[],f=Date.now();for(let d of a.reverse())if(!r.isSidechain(d,t))try{c.push(...Ja(r,d,t,f).events)}catch{}return c}function Wa(n,e,t,r){let s=n.sessionAlive(e,t);if(s!==void 0)return s;if(!r)return!1;try{return Date.now()-C_(r).mtimeMs<1e4}catch{return!1}}function Xs(n,e){return n.stopped?"stopped":n.running&&e?"running":"done"}var rf=k(()=>{"use strict"});function __(n,...e){return n.slice().sort((t,r)=>{for(let{key:s,desc:i}of e){let o=s(t),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 Qs,sf=k(()=>{"use strict";Qs=(n,e)=>__(n,{key:e,desc:!0})});function lt(n){let e=Math.max(0,Math.round(n/1e3));if(e<60)return`${e}s`;let t=Math.floor(e/60);return t<60?`${t}m`:`${Math.floor(t/60)}h ${t%60}m`}function Cw(n,e){if(!e)return n;let t=n.replace(/\\/g,"/"),r=e.replace(/\\/g,"/").replace(/\/+$/,"");return t.toLowerCase().startsWith(r.toLowerCase()+"/")?t.slice(r.length+1):n}function of(n){return n.replace(/[/\\]+$/,"").split(/[/\\]/).pop()??""}function af(n){return!n||typeof n!="object"?"":fe(n.command)??fe(n.file_path)??fe(n.filePath)??fe(n.path)??fe(n.pattern)??fe(n.query)??fe(n.url)??fe(n.skill)??fe(n.description)??""}function lf(n){let e=/^mcp__(.+?)__(.+)$/.exec(n);return e?`${e[1][0].toUpperCase()}${e[1].slice(1)} [${e[2]}]`:n}var fe,cf=k(()=>{"use strict";fe=n=>typeof n=="string"?n:void 0});function Rw(n){let e=[];for(let t of n)if(t.type==="cleared")e.length=0;else if(t.type==="user"){let r=e.at(-1);r?.role==="user"&&!t.agent&&!r.agent?r.text+=`
2081
-
2082
- `+t.text:e.push({role:"user",text:t.text,tools:[],agent:t.agent,at:t.at})}else if(t.type==="assistant")e.push({role:"assistant",text:t.text,tools:t.tools.map(r=>({...r,isError:!1,at:t.at})),at:t.at});else if(t.type==="tool_result"){let r=e.flatMap(s=>s.tools).find(s=>s.id===t.id);r&&(r.result=t.content,r.isError=t.isError,r.digest=t.digest,r.doneAt=t.at)}return e}function Iw(n){let e="",t=[],r=[],s=[],i=[],o=0;for(let u of n)if(o=Math.max(o,u.at??0,...u.tools.map(p=>p.doneAt??p.at??0)),u.role!=="fork"){if(u.role==="user"){if(u.agent){i.push({after:r.length,line:"REPORT FROM ITS OWN SUB-AGENT: "+Zs(u.text,1500)});continue}if(!e){e=u.text;continue}t.push(u.text),i.push({after:r.length,line:`FOLLOW-UP FROM PARENT: ${Zs(u.text,1500)}`});continue}u.text&&i.push({after:r.length,line:"AGENT SAYS: "+Zs(u.text,1500)});for(let p of u.tools){r.push({n:r.length+1,tool:p,wall:0,parts:[]});let m=p.input?.message;typeof m=="string"&&m.length>200&&i.push({after:r.length,line:`AGENT SENDS (${lf(p.name)}): ${Zs(m,8e3)}`})}}let l=q_(n,r,o),c=i.at(-1);if(c&&/^AGENT SAYS/.test(c.line)){let u=[...n].reverse().find(p=>p.role==="assistant"&&p.text);u&&(c.line="AGENT SAYS: "+Zs(u.text,8e3))}let f=new Map;for(let u of i)f.set(u.after,[...f.get(u.after)??[],u.line]);s.push(...f.get(0)??[]);let d=r.length-R_;for(let u=0;u<r.length;){let p=r[u];if(p.n<=d&&_w.has(p.tool.name)&&!p.tool.isError){let v=u;for(;v<r.length&&r[v].n<=d&&_w.has(r[v].tool.name)&&!r[v].tool.isError&&(v===u||!f.has(r[v-1].n));)v++;if(v-u>=3){let O=[...new Set(r.slice(u,v).map(P=>of(af(P.tool.input))))];s.push(`[${p.n}-${r[v-1].n}] explored ${v-u} files/searches: ${ei(O.join(", "),160)}`),s.push(...f.get(r[v-1].n)??[]),u=v;continue}}let m=p.n>d,h=p.tool,y=h.result===void 0?"(running)":h.isError?"ERROR: "+ei(L_(h.result),160):ei(h.digest??"",m?120:60)||"ok";s.push(`[${p.n}] ${Ka(h,m?160:80)} \u2192 ${y}`),s.push(...f.get(p.n)??[]),u++}return{brief:e,followups:t,steps:r,log:s.join(`
2083
- `),facts:J_(r),span:l.span,idle:l.idle,wakes:l.wakes,tests:U_(r),lastAt:o}}function U_(n){for(let e=n.length-1;e>=0;e--){let t=n[e].tool,r=fe(t.input?.command)??fe(t.input?.cmd);if(!r||!$_.test(r)||t.result===void 0)continue;let s=(t.result.replace(/\x1b\[[0-9;]*m/g,"").split(`
2084
- `).filter(a=>/\b\d+\s+(passed|failed)\b/i.test(a)).at(-1)??"").trim().replace(/^tests?:?\s+/i,""),i=t.isError||/\b[1-9]\d*\s+failed\b/i.test(s)?"red":/\bpassed\b/i.test(s)?"green":"unknown",o=t.at!==void 0&&t.doneAt!==void 0?t.doneAt-t.at:void 0;return{n:n[e].n,state:i,line:ei(s,90),ms:o}}}function q_(n,e,t){let r=n.flatMap(u=>u.tools),s=[],i=[],o;for(let u of n)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??t,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>=N_&&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(t,Math.max(d[p-1]??a,h)))}),e.forEach((u,p)=>{let m=d[p],h=d[p+1]??t,y=m,v=!0;for(let[O,P]of l){if(P<=m||O>=h)continue;let E=v&&p>0?e[p-1]:u;O>y&&E.parts.push({from:f(y),to:f(O)}),y=Math.max(y,P),v=!1}h>y&&u.parts.push({from:f(y),to:f(h)})});for(let u of e)u.wall=u.parts.reduce((p,m)=>p+m.to-m.from,0);return{span:f(t),idle:c(t),wakes:i.filter(u=>u>a&&u<t).map(f)}}function J_(n){let e=[],t=n.filter(o=>o.tool.isError);t.length&&e.push(`${t.length} of ${n.length} steps failed.`);let r=new Map;for(let o of t){let a=Ka(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=n.slice(-20).filter(o=>o.tool.isError).length;s>=4&&e.push(`${s} of the last 20 steps failed.`);for(let o of n)o.wall>=I_&&e.push(`Step ${o.n} (${Ka(o.tool,60)}) took ${lt(o.wall)}.`);let i=n.reduce((o,a)=>o+a.wall,0);return i&&e.push(`${lt(i)} in all over ${n.length} steps.`),e.join(`
2085
- `)}function Nw(n,e,t){let r=[n.brief,...n.followups].map(i=>e.get(i));if(r.some(i=>!i))return;let s={subtasks:r.flatMap(i=>i.subtasks),log:n.log,facts:n.facts,finished:t};return{key:W_(JSON.stringify(s)),payload:s,steps:n.steps.length,followups:n.followups.length}}function W_(n){let e=3735928559,t=1103547991;for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);e=Math.imul(e^s,2654435761),t=Math.imul(t^s,1597334677)}return e=Math.imul(e^e>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),t=Math.imul(t^t>>>16,2246822507)^Math.imul(e^e>>>13,3266489909),(4294967296*(2097151&t)+(e>>>0)).toString(36)}function uf(n,e,t,r){let s=[],i=0;[n.brief,...n.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=n.brief+`
2086
- `+c,d=t?.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 t?.offBrief??[])s.push({kind:"row",title:o.what,status:"off",did:"",note:o.note,steps:o.steps,cite:o.steps,ms:0,spans:[]});return K_(s,n),s}function K_(n,e){let t=n.filter(o=>o.kind==="row"),r=e.steps.map(o=>t.find(a=>B_(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 $w(n,e,t,r){let s=n.tests,i=e&&e.followups===n.followups.length,o=n.followups.length?t.get(n.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 ${lt(s.ms)}`:""} (step ${s.n})`:"",s?`tests-${s.state}`:void 0],["Needs a decision",i?e.data.decision:"","warn"]].filter(([,l])=>l)}function Lw(n,e){let t=new Map,r=o=>{let a=o.trim().replace(/^["']|["']$/g,"").replace(/\\/g,"/").replace(/^\/([a-zA-Z])\//,"$1:/"),l=Cw(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=t.get(l)??{path:l};c.deleted=a.deleted,a.from&&(c.from=a.from),t.set(l,c)},i=(o,a)=>{let l=r(o),c=l?t.get(l):void 0;l&&t.delete(l),s(a,{from:c?.from??l})};for(let{tool:o}of n.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(`
2087
- `)){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 y=/^\*\*\* Move to: (.+?)\s*$/.exec(m);y&&p&&i(p,y[1])}}let c=fe(a.file_path)??fe(a.filePath)??fe(a.path);!l&&c&&H_.some(d=>d in a)&&s(c);let f=fe(a.command)??fe(a.cmd);if(f)for(let d of z_(f))d.to?i(d.from,d.to):s(d.from,{deleted:!0})}return[...t.values()]}function z_(n){let e=[];for(let t of n.split(/&&|\|\||[;|\n]/)){let r=t.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(/\/+$/,"")}/${of(l)}`:a})}return e}function Mw(n){let{d:e}=n,t=n.working?`running, step ${e.steps.length}${V_(e,n.now)}`:`finished after ${e.steps.length} steps`,r=[`Sub-agent "${n.name}": ${t}, ${lt(e.span)} active${e.lastAt?`, as of ${j_(e.lastAt)}`:""}.`];r.push("",`Request: ${e.brief?n.plans.get(e.brief)?.request??"(not summarized yet)":F_}`);for(let s of n.lines){if(s.kind==="group"){r.push("",`Follow-up: ${s.request||"(not summarized yet)"}`);continue}let i=s.ms?` (${lt(s.ms)})`:"";r.push(`- ${s.title}: ${D_(s.status||"pending")}.${s.did?` ${s.did}`:""}${i}`),s.note&&r.push(` Note: ${s.note}`)}n.edited.length&&r.push("","Edited:",...n.edited.map(Y_)),n.facts.length&&r.push("");for(let[s,i]of n.facts)r.push(`${s}: ${i}`);return r.join(`
2088
- `)}function V_(n,e){let t=[...n.steps].reverse().find(r=>r.tool.result===void 0&&r.tool.at);return t?`, waiting ${lt(e-t.tool.at)} on ${Ka(t.tool,60)}`:n.lastAt?`, last activity ${lt(e-n.lastAt)} ago`:""}function Dw(n){let e=n??{},t=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:t(r.steps),evidence:t(r.evidence)})),offBrief:(Array.isArray(e.offBrief)?e.offBrief:[]).map(r=>({what:String(r.what??""),note:String(r.note??""),steps:t(r.steps)}))}}function Bw(n){let e=n;return{request:String(e?.request??""),subtasks:Array.isArray(e?.subtasks)?e.subtasks.map(t=>String(t).replace(/[.\s]+$/,"")):[]}}var R_,I_,N_,_w,$_,ei,Zs,L_,M_,Ka,D_,B_,j_,F_,H_,Y_,jw=k(()=>{"use strict";cf();R_=30,I_=3*6e4,N_=6e4,_w=new Set(["Read","Grep","Glob"]),$_=/\b(vitest|jest|pytest|mocha|playwright test|go test|cargo test|dotnet test|(?:npm|pnpm|yarn|bun)(?: run)? test)\b/,ei=(n,e)=>(n=n.replace(/\s+/g," ").trim(),n.length>e?n.slice(0,e)+"\u2026":n),Zs=(n,e)=>n.length<=e?n:n.slice(0,e/2)+`
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)+`
2089
2091
  [\u2026]
2090
- `+n.slice(-e/2),L_=n=>n.split(`
2091
- `).find(e=>e.trim())??"",M_=n=>n.replace(/^(\s*(cd\s+\S+|export\s+PATH=\S+)\s*(;|&&)\s*)+/,""),Ka=(n,e)=>`${lf(n.name)}: ${ei(M_(af(n.input)),e)}`,D_=n=>n==="off"?"off brief":n.replace("_"," "),B_=(n,e)=>e.some(([t,r])=>n>=t&&n<=(r??t)),j_=n=>new Date(n).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),F_="No readable brief on record, so no subtasks to judge.";H_=["content","diff","new_string","new_source","edits"];Y_=n=>n.deleted?`${n.path} (deleted)`:n.from?`${n.path} (moved from ${n.from})`:n.path});import{readFileSync as G_,writeFileSync as X_,mkdirSync as Q_}from"fs";import{join as Fw}from"path";import{createHash as Z_}from"crypto";function Uw(n,e){if(!n.listChildren)return[];let t=n.callerSessionId?.(e),r=Qs(n.listSessionFiles(e),i=>i.mtime).sort((i,o)=>+(o.sessionId===t)-+(i.sessionId===t)),s=[];for(let i of r){let o=n.listChildren(e,i.sessionId);if(!o.length)continue;let a=Wa(n,i.sessionId,e,i.file);s.push({sessionId:i.sessionId,children:o.map(l=>({...l,state:Xs(l,a)}))})}return s}function qw(n,e){let t=e.trim().toLowerCase();for(let r of n){let s=r.children.filter(o=>o.id.toLowerCase()===t);if(s.length)return s;let i=r.children.filter(o=>o.id.toLowerCase().startsWith(t)||Cn(o).toLowerCase().includes(t));if(i.length)return i}return[]}async function df(n,e){let t=Iw(Rw(Pw(n,e.file,"child"))),r=Fw(ze(),"cache","child-status",`${eR(e.file)}.json`),s={plans:{},frozen:{}};try{s={...s,...JSON.parse(G_(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=[t.brief,...t.followups].filter(m=>m&&!i.has(m));for(let[m,h]of await Promise.all(f.map(async y=>[y,await Gs("plan",y)])))h.ok?i.set(m,Bw(h.data)):c(h);let d=s.status,u=t.brief?Nw(t,i,e.state!=="running"):void 0,p=!!u&&d?.key!==u.key;if(u&&p){let m=await Gs("status",u.payload);m.ok?d={key:u.key,data:Dw(m.data),steps:u.steps,followups:u.followups,at:Date.now()}:c(m)}uf(t,i,d?.data,o);try{Q_(Fw(r,".."),{recursive:!0}),X_(r,JSON.stringify({plans:Object.fromEntries(i),frozen:Object.fromEntries(o),status:d}))}catch{}return{d:t,plans:i,frozen:o,judged:d,error:a,setup:l,cached:!f.length&&!p}}async function Jw(n,e,t){let{d:r,plans:s,frozen:i,judged:o,error:a}=await df(n,t);return{text:Mw({d:r,lines:uf(r,s,o?.data,i),facts:$w(r,o,s,!1),edited:Lw(r,e),plans:s,name:Cn(t),working:t.state==="running",now:Date.now()}),error:a}}var eR,ff=k(()=>{"use strict";Tn();nf();rf();Vs();sf();jw();eR=n=>Z_("sha1").update(n).digest("hex")});import{existsSync as Ww,openSync as tR,readSync as nR,closeSync as rR,statSync as ti,readdirSync as Kw,watchFile as sR,unwatchFile as Hw,mkdirSync as iR,writeFileSync as oR,readFileSync as pf,unlinkSync as aR,rmSync as lR}from"fs";import{stat as cR}from"fs/promises";import{dirname as uR,join as _n,resolve as zw}from"path";function hR(n){if(!Number.isInteger(n))return!0;try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}function Or(n){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,entries:new Map,thread:"main"},t;function r(g,S){let w={offset:S,text:""},T;try{T=ti(g).size}catch{return w}if(T<=S)return w;let $;try{$=tR(g,"r")}catch{return w}try{let D=T-S,j=Buffer.alloc(D),F=0;for(;F<D;){let Q=nR($,j,F,D-F,S+F);if(!Q)break;F+=Q}return{offset:S+F,text:j.subarray(0,F).toString("utf8")}}finally{rR($)}}let s=new Set,i,o=0;function a(){if(e.file){for(let g of s)if(g.file===e.file)return g;return}return i}function l(g){let S={d:n.createDriver(e.cwd,g),file:g,id:`new:${++o}`,startedAt:Date.now()};return s.add(S),e.file||(i=S),S}function c(){let g=[...s].filter(w=>w.file);if(!g.length)return[];let S=new Map(n.listSessionFiles(e.cwd).map(w=>[w.file,w.sessionId]));return g.map(w=>{let T=S.get(w.file);return{rec:w,sessionId:T??w.id,pending:T===void 0}})}let f=()=>c().filter(g=>g.pending&&g.rec.prompt!==void 0);async function d(g){s.delete(g),i===g&&(i=void 0);try{await g.d.dispose()}catch(S){console.error("[composer] dispose:",Y(S))}}function u(){let g=a(),S=new Set(f().map(w=>w.rec));for(let w of[...s])w!==g&&(S.has(w)||w.d.streaming||w.d.queue||w.d.error||d(w))}function p(){for(let g of s)g.d.sessionFile&&g.file!==g.d.sessionFile&&(g.file=g.d.sessionFile);if(i&&!e.file&&i.file){let g=n.listSessionFiles(e.cwd).find(S=>S.file===i.file);g&&X(g)}i&&!e.file&&i.prompt!==void 0&&e.sessionId!==i.id&&(q(void 0,i.id),e.everAttached=!0)}let m=g=>_n(g,fR),h=(g,S)=>_n(m(g),`${S}.lock`);function y(g,S){try{let w=h(g,S);if(Date.now()-ti(w).mtimeMs>=Yw)return!1;try{let T=parseInt(pf(w,"utf8").trim(),10);if(T===process.pid||!hR(T))return!1}catch{}return!0}catch{return!1}}function v(g,S){if(S)try{iR(m(g),{recursive:!0}),oR(h(g,S),String(process.pid))}catch(w){console.error("[lock] claim failed:",Y(w))}}function O(g){try{lR(_n(g,".claude-bulb"),{recursive:!0,force:!0})}catch{}}function P(g){let S=m(g);if(!Ww(S))return;let w;try{w=Kw(S)}catch{return}let T=Date.now();for(let $ of w){if(!$.endsWith(".lock"))continue;let D=_n(S,$);try{let j=ti(D);T-j.mtimeMs>pR&&aR(D)}catch{}}}function E(g){try{return ti(g),!1}catch(S){return S.code==="ENOENT"}}function R(){let g=e;if(g.file&&!E(g.file)){v(g.cwd,g.sessionId);return}let S=I(g);S&&X(S)}function I(g){if(!g.everAttached)return L(g.cwd)??A(g.cwd,()=>!0)}function L(g){let S=m(g);if(!Ww(S))return;let w;try{w=Kw(S)}catch{return}let T;for(let D of w)if(D.endsWith(".lock"))try{let j=ti(_n(S,D));if(Date.now()-j.mtimeMs>=Yw||parseInt(pf(_n(S,D),"utf8").trim(),10)!==process.pid)continue;(!T||j.mtimeMs>T.mtime)&&(T={sessionId:D.slice(0,-5),mtime:j.mtimeMs})}catch{}if(!T)return;let $=n.listSessionFiles(g).find(D=>D.sessionId===T.sessionId);if(!(!$||E($.file)))return $}function A(g,S){return n.listSessionFiles(g).sort((w,T)=>T.mtime-w.mtime).find(w=>!y(g,w.sessionId)&&S(w))}function q(g,S){let w=e;if(w.file)try{Hw(w.file)}catch{}w.file=g,w.sessionId=S,w.partial="",w.offset=0,w.latest={in:0,out:0,cached:0,cacheCreate:0},w.latestModel=null,w.entries=new Map,w.chainLastId=void 0,w.buffer.push({type:"cleared"}),w.buffer.push({type:"session",sessionId:S})}function X(g){let S=e;i=void 0,yi(),t=g.file,q(g.file,g.sessionId),S.everAttached=!0,v(S.cwd,g.sessionId),G(g.file)}function G(g){if(ge(),!!g){try{Hw(g)}catch{}sR(g,{interval:200},()=>ge())}}function U(){yi(),t=void 0,q(void 0,"")}function ge(){let g=e;if(!g.file)return;let S=r(g.file,g.offset);if(!S.text)return;g.offset=S.offset,g.partial+=S.text;let w,T;for(;(T=g.partial.indexOf(`
2092
- `))>=0;){let F=g.partial.slice(0,T);if(g.partial=g.partial.slice(T+1),!F.trim())continue;let Q=n.parseEntry(F);if(!Q)continue;let ae=n.idOf(Q);ae&&(g.entries.set(ae,Q),!n.isSidechain(Q,g.thread)&&n.isLeafType(Q)&&(w=ae))}if(!w)return;let $=[],D=g.entries.get(w),j=!1;for(;D;){if($.push(D),n.idOf(D)===g.chainLastId){j=!0;break}let F=n.parentOf(D);D=F?g.entries.get(F):void 0}if(j)for(let F=$.length-2;F>=0;F--)ue($[F]);else{g.chainLastId!==void 0&&(g.buffer.push({type:"cleared"}),g.buffer.push({type:"session",sessionId:g.sessionId}),g.latest={in:0,out:0,cached:0,cacheCreate:0});let F=new Set($.map(ae=>n.idOf(ae))),Q=he(g.entries);for(let ae=$.length-1;ae>=0;ae--)ue($[ae]),Re(n.idOf($[ae]),Q,F)}g.chainLastId=w}function he(g){let S=new Map;for(let w of g.values()){let T=n.parentOf(w);if(!T)continue;let $=S.get(T);$?$.push(w):S.set(T,[w])}return S}function Re(g,S,w){if(!g)return;let T=S.get(g);if(!T)return;let $=T.filter(Q=>!n.isSidechain(Q,e.thread));if($.length<2)return;let D=$.filter(Q=>!w.has(n.idOf(Q)));if(!D.length)return;let j=[],F=0;for(let Q of D){let ae=ut(Q,S);j.push(...ae.events),F+=ae.count}F>0&&e.buffer.push({type:"fork",atId:g,count:F,events:j})}function ut(g,S){let w=[],T=[g];for(;T.length;){let j=T.pop();if(n.isSidechain(j,e.thread))continue;w.push(j);let F=S.get(n.idOf(j)??"");if(F)for(let Q of F)T.push(Q)}w.sort((j,F)=>(Date.parse(n.timestampOf(j)??"")||0)-(Date.parse(n.timestampOf(F)??"")||0));let $=[];for(let j of w)n.isRecoveryNoise(j)||$.push(...Ja(n,j,e.thread,e.sessionStartMs).events);return{count:$.reduce((j,F)=>j+(F.type==="user"||F.type==="assistant"?1:0),0),events:$}}function ue(g){if(!n.isSidechain(g,e.thread))try{let{events:S,usage:w,model:T,cost:$}=Ja(n,g,e.thread,e.sessionStartMs);for(let D of S)e.buffer.push(D);S.some(D=>D.type==="assistant")&&a()?.d.clearCompletedDraft(),S.some(D=>D.type==="user")&&a()?.d.clearEcho(),T&&(e.latestModel=T),w&&(e.latest=w),(w||$)&&e.buffer.push({type:"usage",...e.latest,cost:$})}catch(S){console.error("[mirror] skipped malformed entry:",Y(S))}}async function Ee(){return{cwd:e.cwd,pid:process.pid,composer:!!n.createDriver,children:!!n.listChildren,childStatus:!!n.listChildren&&n.childBriefs,elsewhere:await Tt()}}async function Tt(){if(n.listSessionFiles(e.cwd).length)return;let g=await Pn();if(!g)return;let S=zw(g).toLowerCase();for(let w=zw(e.cwd);w.toLowerCase()!==S;){let T=uR(w);if(T===w)return;w=T;let $=n.listSessionFiles(w).length;if($)return{dir:w,count:$}}}Tt().then(g=>{g&&console.log(`No sessions for ${e.cwd} \u2014 ${g.count} exist for ${g.dir}. Launched from a subfolder? Relaunch from the project root.`)}).catch(()=>{});let b=new Ba;async function x(g,S){e.thread!=="child"&&b.accept(g,S)&&console.log(S)}function C(){return Wa(n,e.sessionId,e.cwd,e.file)}function N(){return n.chainWorking([...e.entries.values()])&&C()}function M(){!n.createDriver||a()||e.latestModel||N()||l(e.file)}async function K(g){let S=e;R(),p(),M(),u();let w=a();for(let j of s)j!==w&&j.d.dialog;let T=c().filter(j=>j.rec.d.streaming).map(j=>j.sessionId),$=N(),D=n.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:S.buffer.slice(g),cursor:S.buffer.length,working:!!w?.d.streaming||$,latestModel:S.latestModel,child:S.child?.id??null,composer:D,busy:T}}async function J(){R(),p();let g=a();if(g?.d.error&&!g.d.streaming&&(await d(g),g=void 0),!g){if(N())return{ok:!1,error:"the agent is mid-turn in a terminal \u2014 watch only"};g=l(e.file)}let S=g;return{ok:!0,d:S.d,markSent:w=>{S.prompt===void 0&&(S.prompt=w)}}}async function Ue(g,S){if(!n.createDriver)return{ok:!1,error:"not supported"};let w=String(g??"").trim();if(!w)return{ok:!1,error:"empty message"};let T=await J();if(!T.ok)return T;let $=await T.d.send(w,S);return $.ok&&T.markSent(w),$}async function z(g,S){let w=a();return w?w.d.respondUi(String(g??""),S??{}):{ok:!1,error:"no dialog pending"}}async function oe(g,S){if(!n.createDriver)return{ok:!1,error:"not supported"};if(!g||typeof g.type!="string")return{ok:!1,error:"bad command"};if(S?.spawn){let T=await J();return T.ok?T.d.rpc(g):T}let w=a();return!w||w.d.error?{ok:!1,error:"not running"}:w.d.rpc(g)}async function Ae(){let g=a();if(g)try{await g.d.stop()}catch(S){console.error("[composer] stop:",Y(S))}return{ok:!0}}async function $r(){return n.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(!n.createDriver)return[];let g=await et(["ls-files","--cached","--others","--exclude-standard"],e.cwd).catch(()=>null),S=g!==null?g.split(`
2093
- `).filter(Boolean):await n.walkFiles?.(e.cwd)??[];return(await Promise.all(S.map(async T=>{try{return{f:T,m:(await cR(_n(e.cwd,T))).mtimeMs}}catch{return{f:T,m:0}}}))).sort((T,$)=>$.m-T.m).map(T=>T.f)}function Ot(){for(let g of[...s])d(g)}async function Sl(g){return n.createDriver?vw(e.cwd,g):{ok:!1,error:"not supported"}}async function kl(g){return Sw(e.cwd,String(g??""))}async function VS(g,S){return Ow(String(g??""),String(S??""))}async function GS(g,S){return Gs(g==="status"?"status":"plan",S)}async function XS(g){let S=n.listChildren?.(e.cwd,e.sessionId).find(T=>T.id===g);if(!S)return{ok:!1,error:"child not found"};let w=await df(n,{...S,state:Xs(S,C())});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 QS(){let g=n.sessionsWorking?.(e.cwd),S=n.listSessionFiles(e.cwd).map(({sessionId:T,file:$,mtime:D})=>({sessionId:T,mtime:D,preview:n.readPreview($),working:g?.has(T)})),w=f().map(T=>({sessionId:T.sessionId,mtime:T.rec.startedAt,preview:T.rec.prompt??"",pending:!0}));return Qs([...S,...w],T=>T.mtime)}let ap=new Map;function lp(g,S){let w=ap.get(g);if(w&&w.mtime===S)return w.turns;let T=[],$="";try{$=pf(g,"utf8")}catch{return[]}for(let D of $.split(`
2094
- `)){if(!D.trim())continue;let j=n.parseEntry(D);if(!j)continue;let F=n.searchText(j);F&&T.push({text:F,lower:F.toLowerCase()})}return ap.set(g,{mtime:S,turns:T}),T}async function ZS(g){let S=g.toLowerCase(),w=[],T=0,$=n.sessionsWorking?.(e.cwd);for(let{sessionId:D,file:j,mtime:F}of n.listSessionFiles(e.cwd).sort((Q,ae)=>ae.mtime-Q.mtime)){let Q=zs(lp(j,F),S),ae=(n.listChildren?.(e.cwd,D)??[]).map(qe=>({c:qe,hit:zs(lp(qe.file,qe.mtime),S)})).filter(qe=>qe.hit.hitCount);if(!(!Q.hitCount&&!ae.length)){for(let{c:qe,hit:sk}of Qs(ae,ik=>ik.c.mtime))w.push({sessionId:D,mtime:qe.mtime,preview:Cn(qe),...sk,child:{id:qe.id,kind:qe.kind,depth:qe.depth}});if(w.push({sessionId:D,mtime:F,preview:n.readPreview(j),working:$?.has(D),...Q}),++T>=mR)break}}return w}async function ek(g){let S=e,w=n.listSessionFiles(S.cwd).find(T=>T.sessionId===g);if(!w){let T=f().find($=>$.sessionId===g)?.rec;return T?((i!==T||S.sessionId!==T.id)&&(i=T,yi(),t=void 0,q(void 0,T.id),S.everAttached=!0,u()),{ok:!0}):{ok:!1,error:"session not found"}}return w.file===S.file?{ok:!0}:(X(w),p(),u(),{ok:!0})}async function tk(){if(!n.listChildren||!e.sessionId)return[];let g=C();return n.listChildren(e.cwd,e.sessionId).map(S=>({...S,state:Xs(S,g)}))}async function nk(g){let S=e;if(!n.listChildren)return{ok:!1,error:"this harness has no child transcripts"};let w=n.listChildren(S.cwd,S.sessionId).find(T=>T.id===g);return w?(S.thread="child",S.child=w,q(w.file,S.sessionId),G(w.file),{ok:!0}):{ok:!1,error:"child not found"}}async function rk(){let g=t;return!yi()||!g?{ok:!0}:(q(g,e.sessionId),G(g),{ok:!0})}function yi(){let g=e;return g.thread==="main"?!1:(g.thread="main",g.child=void 0,!0)}return O(e.cwd),P(e.cwd),R(),{info:Ee,poll:K,logInlineStatus:x,listSessions:QS,searchSessions:ZS,attach:ek,listChildren:tk,openChild:nk,closeChild:rk,composerSend:Ue,composerStop:Ae,composerNew:$r,composerFiles:tn,composerUiRespond:z,composerRpc:oe,composerPaste:Sl,composerPasteRead:kl,summarizeTurn:VS,childStatus:GS,judgeChildStatus:XS,shutdownComposer:Ot}}var dR,fR,Yw,pR,mR,Ha=k(()=>{"use strict";Vt();mw();Hs();Xd();kw();nf();rf();ff();sf();Vs();dR=".typebulb",fR=`${dR}/locks`,Yw=5e3,pR=6e4;mR=50});import{existsSync as yf,mkdirSync as gR,readFileSync as Vw,writeFileSync as yR}from"fs";import{join as Rn,isAbsolute as bR}from"path";async function wf(n,e){let t=bR(n)?n:Rn(V,n);return yf(t)?(Qu(t,e),{ok:!0}):{ok:!1,error:"file not found"}}async function vf(n){let e=V,t=Xu(n),r=Rn(e,"typebulbs");gR(r,{recursive:!0});let s=zu(t),i=`${s}.bulb.md`;for(let c=2;yf(Rn(r,i))&&Vw(Rn(r,i),"utf8")!==t;c++)i=`${s}-${c}.bulb.md`;let o=Rn(r,i);yf(o)||yR(o,t);let a=Rn("typebulbs",i),l=await xs(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:l.pid,url:l.url}}async function Sf(){return Z(V)}async function kf(n){let e=(await Z()).find(t=>t.pid===n);return e?{ok:!0,outcome:await Ft(e)}:(await tr(n),{ok:!0})}async function xf(){let n=await dn(V);return Xo(V).filter(e=>!e.serverOnly).map(e=>({...e,trusted:yn(e.path),lastRunAt:n(e.path)}))}async function Ef(n){let e=n.toLowerCase(),t=[];for(let r of Xo(V).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=Vw(r.path,"utf8")}catch{continue}let i=[];for(let l of s.split(`
2095
- `)){let c=l.replace(/\s+/g," ").trim();c&&i.push({text:c,lower:c.toLowerCase()})}let{hitCount:o,snippet:a}=zs(i,e);o&&t.push({path:r.path,hitCount:o,snippet:a})}return t}async function Af(n,e){let t=V;e!=null&&ar(n,e);let r=await xs(n,{cwd:t,open:!1,trust:e});return{ok:!0,file:r.file,pid:r.pid,url:r.url,trust:!!r.trust}}async function Tf(n){return{cap:await Vu(n)}}async function Of(n,e){return ar(n,e),{ok:!0}}async function Pf(n,e){return Ve(n,e)}async function Cf(){return ni&&Date.now()-ni.fetchedAt<=vR?ni.samples:(hf??=SR().finally(()=>{hf=null}),hf)}async function SR(){try{let n=await fetch(`${wR}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(Xw)});if(!n.ok)throw new Error(`HTTP ${n.status}`);let e=await n.json(),t=i=>i.order??Number.MAX_SAFE_INTEGER,r=i=>Date.parse(i.createdAt??"")||0,s=e.filter(i=>i.slug!=="welcome").sort((i,o)=>t(i)-t(o)||r(o)-r(i)).map(i=>({slug:i.slug,name:i.name,description:Rl(i.config)}));return ni={samples:s,fetchedAt:Date.now()},s}catch{return ni?.samples??[]}}async function _f(n){return bf.test(n)?Zw(Gw,"samples",n,!0):{ok:!1,error:"bad slug"}}async function If(){let n=Rf();if(!n)return{bulbs:[]};let e=`${za()}
2096
- ${n}`;return Gt?.key===e&&Date.now()-Gt.fetchedAt<=kR?{user:Gt.user,bulbs:Gt.bulbs}:(mf??=xR(e,n).finally(()=>{mf=null}),mf)}async function gf(n,e,t){let r=await fetch(`${n}${e}`,{headers:t,signal:AbortSignal.timeout(Xw)});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 xR(n,e){let t={Authorization:`Bearer ${e}`};try{let r=za(),s;try{s=await gf(r,"/api/me",t)}catch{let a=new URL(r);r=`${a.protocol}//api.${a.host}`,s=await gf(r,"/api/me",t)}let o=(await gf(r,"/api/scripts/list",t)).filter(a=>a.userSlug===s.slug&&!a.isTemplate).map(a=>({slug:a.slug,name:a.name,description:Rl(a.config)}));return Gt={key:n,user:s.slug,bulbs:o,fetchedAt:Date.now()},{user:s.slug,bulbs:o}}catch{return Gt?.key===n?{user:Gt.user,bulbs:Gt.bulbs}:{bulbs:[]}}}async function Nf(n,e,t=!1){return!bf.test(e)||!bf.test(n)?{ok:!1,error:"bad slug"}:Zw(za(),n,e,t)}async function Zw(n,e,t,r){let s=Ca(e,t);try{let i=await Ia({origin:n,userSlug:e,slug:t,dest:Rn(V,s)},{force:r,token:Rf(),timeoutMs:Qw});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 $f(n,e=!1){let t=Rf();if(!t)return{ok:!1,error:"no TYPEBULB_TOKEN in .env"};try{let r=Ra(n,V,za()),s=await $a(r,{token:t,force:e,timeoutMs:Qw});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 wR,Gw,vR,Xw,Qw,ni,hf,bf,kR,Gt,mf,za,Rf,Ya=k(()=>{"use strict";Tn();Vt();Xd();ee();wR="https://api.typebulb.com",Gw="https://typebulb.com",vR=3600*1e3,Xw=5e3,Qw=15e3,ni=null,hf=null;bf=/^[a-z0-9][a-z0-9-]*$/,kR=300*1e3,Gt=null,mf=null,za=()=>la("TYPEBULB_ORIGIN",V)||Gw,Rf=()=>la("TYPEBULB_TOKEN",V)});import{readFileSync as Df,writeFileSync as tv,mkdirSync as ER,appendFileSync as nv,rmSync as ev}from"fs";import{join as Xa,dirname as AR}from"path";import{createServer as TR}from"http";function Xt(n){try{return JSON.parse(Df(n,"utf8"))}catch{return null}}function Ga(n,e){ER(AR(n),{recursive:!0}),tv(n,JSON.stringify(e,null,2)+`
2097
- `)}function sv(n,e,t){let r=Xa(n,".gitignore"),s="";try{s=Df(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(`
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(`
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(`
2098
2102
  `)?`
2099
- `:"";try{nv(r,a+t+`
2103
+ `:"";try{uv(r,a+n+`
2100
2104
  `+o.join(`
2101
2105
  `)+`
2102
- `)}catch(l){console.error("[switcher] .gitignore update failed",Y(l))}}function RR(n){let e=i=>{let o=i.exec(n);return o?Number(o[1]):0},t=e(/"cache_read_input_tokens":\s*(\d+)/),r=e(/"cache_creation_input_tokens":\s*(\d+)/),s=e(/"input_tokens":\s*(\d+)/);t>0||r>0?ii="live":s>_R&&(ii="uncached")}function ov(n,e){let t={"content-type":"application/json",authorization:`Bearer ${e}`,"anthropic-version":n.headers["anthropic-version"]||"2023-06-01",...id},r=n.headers["anthropic-beta"];return typeof r=="string"&&(t["anthropic-beta"]=r),t}function IR(n){if(Array.isArray(n?.messages))for(let e of n.messages){if(!Array.isArray(e?.content))continue;let t=e.content.filter(r=>r?.type!=="thinking"&&r?.type!=="redacted_thinking");t.length&&t.length!==e.content.length&&(e.content=t)}}function av(n){let e;try{e=JSON.parse(n)}catch{return n}si=typeof e?.model=="string"?e.model:null,ct&&(e.model=ct),Nn&&(e.provider=iv(Nn));let t=/haiku/i.test(si||"");return oi!=null&&!t&&(e.reasoning={effort:Lf[oi]}),delete e.thinking,e.output_config&&delete e.output_config.effort,IR(e),JSON.stringify(e)}function NR(){let n="",e=0,t=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 t.clear(),e=0,i;case"content_block_start":{if(r.has(a.content_block?.type))return t.set(a.index,null),null;let l=e++;return t.set(a.index,l),a.index=l,`event: ${a.type}
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}
2103
2107
  data: ${JSON.stringify(a)}
2104
2108
 
2105
- `}case"content_block_delta":case"content_block_stop":{let l=t.get(a.index);return l==null?null:(a.index=l,`event: ${a.type}
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}
2106
2110
  data: ${JSON.stringify(a)}
2107
2111
 
2108
- `)}default:return i}};return i=>{n+=i;let o="",a;for(;(a=n.indexOf(`
2112
+ `)}default:return i}};return i=>{t+=i;let o="",a;for(;(a=t.indexOf(`
2109
2113
 
2110
- `))!==-1;){let l=n.slice(0,a);if(n=n.slice(a+2),!l.trim())continue;let c=s(l);c!==null&&(o+=c)}return o}}function $R(n){return new Promise(e=>{let t=[];n.on("data",r=>t.push(r)),n.on("end",()=>e(Buffer.concat(t).toString("utf8"))),n.on("error",()=>e(Buffer.concat(t).toString("utf8")))})}function ri(n,e,t,r){n.writableEnded||(n.writeHead(e,{"content-type":"application/json"}),n.end(JSON.stringify({type:"error",error:{type:t,message:r}})))}async function LR(n,e,t){if(!ct){ri(e,400,"invalid_request_error",CR);return}let r=process.env.OPENROUTER_API_KEY;if(!r){ri(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(Bf,{method:"POST",headers:ov(n,r),body:av(t),signal:s.signal})}catch(d){ri(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?NR():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});RR(p);let m=f(p);m&&e.write(m)}else e.write(Buffer.from(u))}}catch{}finally{e.writableEnded||e.end()}}async function MR(n,e,t){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(t.length/4))}))};if(!ct||!r)return s();try{let i=await fetch(`${Bf}/count_tokens`,{method:"POST",headers:ov(n,r),body:av(t)});if(!i.ok)return s();let o=await i.text();e.writeHead(200,{"content-type":"application/json"}),e.end(o)}catch{s()}}function DR(n,e){let t=n.url||"/";if(n.method==="HEAD"){e.writeHead(200),e.end();return}if(n.method!=="POST"){ri(e,404,"not_found_error",t);return}$R(n).then(r=>{if(t.includes("count_tokens"))return MR(n,e,r);if(t.includes("/v1/messages"))return LR(n,e,r);ri(e,404,"not_found_error",t)})}function BR(){return Pr&&In?Promise.resolve(In):new Promise((n,e)=>{let t=TR(DR);t.on("error",e),t.listen(0,"127.0.0.1",()=>{Pr=t,In=t.address().port,console.log(`[switcher] wire proxy listening on ${Va(In)}`),n(In)})})}function jR(){try{Pr?.close()}catch{}Pr=null,In=null}function FR(n,e){let t=Qa(n),r=Xt(t),s=r||{};if((!s.env||typeof s.env!="object")&&(s.env={}),s.env.ANTHROPIC_BASE_URL===Va(e)&&s.env.ANTHROPIC_AUTH_TOKEN)return;let i=Za(n);if(!Xt(i)){let a={};for(let l of rv)a[l]=l in s.env?s.env[l]:null;Ga(i,{managedBy:"agent-switcher",fileExisted:r!==null,snapshot:a,active:null})}s.env.ANTHROPIC_BASE_URL=Va(e),s.env.ANTHROPIC_AUTH_TOKEN=PR,Ga(t,s),sv(n,[".claude/settings.local.json",".claude/.cc-switcher.json"],"# agent switcher (local Claude Code model override)")}function UR(n,e,t){let r=Za(n),s=Xt(r)||{managedBy:"agent-switcher",fileExisted:!1,snapshot:{}};s.active={model:e,provider:t},Ga(r,s)}function lv(n){let e=Qa(n),t=Za(n),r=Xt(t),s=Xt(e);if(s?.env){let i=r?.snapshot||{};for(let o of rv){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{ev(e,{force:!0})}catch{}else Ga(e,s)}try{ev(t,{force:!0})}catch{}}async function qR(){let n=!!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 t=e.length?void 0:nd()??void 0;return{hasKey:n,models:e,error:t}}async function JR(){if(Pr&&ct)return{active:!0,managed:!0,model:ct,port:In,provider:Nn,routedModel:si,caching:ii,reasoning:oi,externalBaseUrl:null};let n=Xt(Qa(V))?.env||{};return{active:!1,managed:!1,model:null,port:null,provider:null,routedModel:null,caching:"unknown",reasoning:oi,externalBaseUrl:n.ANTHROPIC_BASE_URL||null}}async function cv(n,e){let t=await BR();return ct=n,Nn=e,FR(V,t),t}async function WR({model:n}){if(!process.env.OPENROUTER_API_KEY)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!n)return{ok:!1,error:"no model given"};if(jf(n))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 cv(n,Ff[n]??null),si=null,ii="unknown",UR(V,n,Nn)}catch(e){return{ok:!1,error:`failed to start the wire proxy: ${Y(e)}`}}return{ok:!0}}async function KR({level:n}){return n!=null&&(!Number.isInteger(n)||n<0||n>=Lf.length)?{ok:!1,error:`reasoning level must be 0\u2013${Lf.length-1} or null`}:(oi=n,{ok:!0,level:n})}async function HR(){return lv(V),ct=null,Nn=null,si=null,ii="unknown",{ok:!0}}async function zR({key:n}){let e=(n||"").trim();if(!e)return{ok:!1,error:"empty key"};let t=V,r=Xa(t,".env"),s="";try{s=Df(r,"utf8")}catch{}try{if(/^\s*OPENROUTER_API_KEY\s*=/m.test(s))tv(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 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(`
2111
2115
  `)?`
2112
- `:"";nv(r,i+`OPENROUTER_API_KEY=${e}
2113
- `)}}catch(i){return{ok:!1,error:Y(i)}}return process.env.OPENROUTER_API_KEY=e,sv(t,[".env"],"# secrets"),{ok:!0}}function YR(){if(!(!Pr&&!ct)){try{lv(V)}catch{}jR()}}function VR(n,e){return uv.test(e)?"blocked by your OpenRouter data policy":n===401||n===403||/unauthor|invalid api key|no auth|forbidden/i.test(e)?"auth rejected \u2014 check your OpenRouter key":n===404||/not a valid model|no such model|unknown model|model not found/i.test(e)?"model not found on this route":n===429||/rate limit/i.test(e)?"rate limited":n===402||/insufficient|credit|quota|balance/i.test(e)?"out of credits / quota":e.slice(0,160)}function GR(n){if(uv.test(n))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 XR(n,e,t){if(!n)return{works:null,read:0,note:t?`couldn't re-test on ${t} \u2014 caching unconfirmed`:"caching unconfirmed"};let r=Mf(e?.cache_read_input_tokens)||Mf(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 QR({model:n}){let e=process.env.OPENROUTER_API_KEY;if(!e)return{ok:!1,error:"OPENROUTER_API_KEY not set \u2014 add a key first"};if(!n)return{ok:!1,error:"no model given"};if(jf(n))return{ok:!1,error:"Anthropic model \u2014 not offered or probed via OpenRouter"};let t=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:n,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:iv(a)}:i),d=await fetch(Bf,{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 v=l?.error?.message||l?.message||JSON.stringify(l).slice(0,300);return{ok:!0,callable:!1,status:a.status,ms:Date.now()-t,error:VR(a.status,v),restriction:GR(v)}}let c=typeof l?.provider=="string"?l.provider:void 0,f=l?.content?.find?.(v=>v.type==="text")?.text??l?.content?.[0]?.text??"ok",d=Mf(l?.usage?.cache_creation_input_tokens),{r:u,j:p}=await o(c),{works:m,read:h,note:y}=XR(u.ok,p?.usage,c);return m===!0&&c&&(Ff[n]=c,ct===n&&(Nn=c)),{ok:!0,callable:!0,status:a.status,ms:Date.now()-t,provider:c,sample:String(f).trim().slice(0,60),cache:{works:m,created:d,read:h,note:y}}}catch(a){let l=Y(a);return{ok:!0,callable:!1,ms:Date.now()-t,error:/abort/i.test(l)?"timed out (20s)":l}}}var OR,Bf,PR,CR,rv,_R,Lf,Qa,Za,Va,jf,Pr,In,ct,Nn,si,ii,oi,Ff,Mf,iv,uv,dv=k(()=>{"use strict";Tn();Vt();Ut();OR="https://openrouter.ai/api",Bf=`${OR}/v1/messages`,PR="typebulb-proxy-managed",CR="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.",rv=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],_R=5e3,Lf=["low","medium","high"],Qa=n=>Xa(n,".claude","settings.local.json"),Za=n=>Xa(n,".claude",".cc-switcher.json"),Va=n=>`http://127.0.0.1:${n}`;jf=n=>/^anthropic\//i.test(n)||/claude/i.test(n),Pr=null,In=null,ct=null,Nn=null,si=null,ii="unknown",oi=1,Ff={},Mf=n=>typeof n=="number"?n:0,iv=n=>({order:[n],allow_fallbacks:!1});uv=/data policy|no endpoints|no allowed providers|privacy|requires.*(training|logging|data)/i;(async function(){try{let e=Xt(Za(V)),t=e?.active?.model;if(!t)return;let s=(Xt(Qa(V))?.env||{}).ANTHROPIC_BASE_URL||"";if(!/127\.0\.0\.1|localhost/.test(s))return;let i=await cv(t,e.active.provider??Ff[t]??null);console.log(`[switcher] re-adopted override after restart: ${t} via ${Va(i)}`)}catch(e){console.error("[switcher] boot reconcile failed",Y(e))}})()});var pv={};wi(pv,{agentMessage:()=>No,attach:()=>iI,blockToMarkdown:()=>Io,breakout:()=>vf,capText:()=>Te,childStatus:()=>dI,cleanUserText:()=>jt,clearSwitchModel:()=>HR,closeChild:()=>lI,composerPasteRead:()=>cI,displayName:()=>ZR,downloadSample:()=>_f,firstLineDigest:()=>Ne,git:()=>et,gitChangedFiles:()=>Vd,gitDiff:()=>Gd,info:()=>eI,isHiddenTurn:()=>bs,judgeChildStatus:()=>fI,launchBulb:()=>Af,listBreakouts:()=>Sf,listBulbFiles:()=>xf,listChildren:()=>oI,listMyBulbs:()=>If,listSamples:()=>Cf,listSessions:()=>rI,listSwitchModels:()=>qR,logInlineStatus:()=>nI,openChild:()=>aI,openFile:()=>wf,poll:()=>tI,predictTrustOf:()=>Tf,probeModel:()=>QR,pullRemoteBulb:()=>Nf,pushLocalBulb:()=>$f,readBulbLog:()=>Pf,repoRoot:()=>Pn,saveOpenRouterKey:()=>zR,searchBulbs:()=>Ef,searchSessions:()=>sI,setBulbTrust:()=>Of,setReasoning:()=>KR,setSwitchModel:()=>WR,shutdownSwitcher:()=>YR,stopBreakout:()=>kf,summarizeTurn:()=>uI,switchState:()=>JR,toolResultDigest:()=>Ou});var fv,ZR,eI,tI,nI,rI,sI,iI,oI,aI,lI,cI,uI,dI,fI,hv=k(()=>{"use strict";Ha();$o();Ya();Hs();dv();$o();ys();fv=new Gn,ZR=fv.displayName,{info:eI,poll:tI,logInlineStatus:nI,listSessions:rI,searchSessions:sI,attach:iI,listChildren:oI,openChild:aI,closeChild:lI,composerPasteRead:cI,summarizeTurn:uI,childStatus:dI,judgeChildStatus:fI}=Or(fv)});var gv={};wi(gv,{attach:()=>wI,breakout:()=>vf,childStatus:()=>AI,closeChild:()=>kI,composerPasteRead:()=>xI,displayName:()=>pI,downloadSample:()=>_f,git:()=>et,gitChangedFiles:()=>Vd,gitDiff:()=>Gd,info:()=>hI,judgeChildStatus:()=>TI,launchBulb:()=>Af,listBreakouts:()=>Sf,listBulbFiles:()=>xf,listChildren:()=>vI,listMyBulbs:()=>If,listSamples:()=>Cf,listSessions:()=>yI,logInlineStatus:()=>gI,openChild:()=>SI,openFile:()=>wf,poll:()=>mI,predictTrustOf:()=>Tf,pullRemoteBulb:()=>Nf,pushLocalBulb:()=>$f,readBulbLog:()=>Pf,repoRoot:()=>Pn,searchBulbs:()=>Ef,searchSessions:()=>bI,setBulbTrust:()=>Of,stopBreakout:()=>kf,summarizeTurn:()=>EI});var mv,pI,hI,mI,gI,yI,bI,wI,vI,SI,kI,xI,EI,AI,TI,yv=k(()=>{"use strict";Ha();Ru();Ya();Hs();mv=new Qn,pI=mv.displayName,{info:hI,poll:mI,logInlineStatus:gI,listSessions:yI,searchSessions:bI,attach:wI,listChildren:vI,openChild:SI,closeChild:kI,composerPasteRead:xI,summarizeTurn:EI,childStatus:AI,judgeChildStatus:TI}=Or(mv)});import{readFileSync as OI,writeFileSync as PI,mkdirSync as CI}from"fs";import{homedir as _I}from"os";import*as el from"path";async function vv(){try{let n=await fetch(new URL("/api/tags",wv()).toString(),{signal:AbortSignal.timeout(RI)});return n.ok?((await n.json()).models??[]).map(t=>t.name).filter(t=>!!t):[]}catch{return[]}}function Sv(n){let e;try{e=OI(n,"utf-8")}catch{return{json:void 0,unreadable:!1}}try{let t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t)){let r=t;return{json:r,unreadable:"providers"in r&&!Uf(r)}}}catch{}return{json:void 0,unreadable:!0}}function Uf(n){let e=n?.providers;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function II(n){let e=Uf(n);if(!e||!("ollama"in e))return null;let t=e.ollama?.models;return Array.isArray(t)?t.map(r=>r?.id).filter(r=>typeof r=="string"):[]}async function kv(){let{json:n,unreadable:e}=Sv(bv());return e?{installed:[],configured:null}:{installed:await vv(),configured:II(n)}}async function xv(){let n=await vv();return n.length?NI(bv(),n,wv()):{ok:!1,error:"Ollama is not running (or has no models installed)"}}function NI(n,e,t){let{json:r,unreadable:s}=Sv(n);if(s)return{ok:!1,error:`could not parse ${n} \u2014 edit the ollama provider there yourself`};let i={...r??{},providers:{...Uf(r)??{},ollama:{baseUrl:`${t}/v1`,api:"openai-completions",apiKey:"ollama",models:e.map(o=>({id:o}))}}};try{CI(el.dirname(n),{recursive:!0}),PI(n,JSON.stringify(i,null,2)+`
2114
- `)}catch(o){return{ok:!1,error:`could not write ${n}: ${Y(o)}`}}return{ok:!0,count:e.length}}var RI,bv,wv,Ev=k(()=>{"use strict";Vt();Tn();RI=1500,bv=()=>el.join(_I(),".pi","agent","models.json"),wv=()=>cr(process.env.OLLAMA_HOST??"http://localhost:11434")});var Tv={};wi(Tv,{attach:()=>FI,breakout:()=>vf,closeChild:()=>JI,composerFiles:()=>zI,composerNew:()=>HI,composerPaste:()=>GI,composerPasteRead:()=>XI,composerRpc:()=>VI,composerSend:()=>WI,composerStop:()=>KI,composerUiRespond:()=>YI,displayName:()=>$I,downloadSample:()=>_f,git:()=>et,gitChangedFiles:()=>Vd,gitDiff:()=>Gd,info:()=>LI,launchBulb:()=>Af,listBreakouts:()=>Sf,listBulbFiles:()=>xf,listChildren:()=>UI,listMyBulbs:()=>If,listSamples:()=>Cf,listSessions:()=>BI,logInlineStatus:()=>DI,ollamaOffer:()=>kv,ollamaSync:()=>xv,openChild:()=>qI,openFile:()=>wf,poll:()=>MI,predictTrustOf:()=>Tf,pullRemoteBulb:()=>Nf,pushLocalBulb:()=>$f,readBulbLog:()=>Pf,repoRoot:()=>Pn,searchBulbs:()=>Ef,searchSessions:()=>jI,setBulbTrust:()=>Of,shutdownComposer:()=>ZI,stopBreakout:()=>kf,summarizeTurn:()=>QI});var Av,$I,LI,MI,DI,BI,jI,FI,UI,qI,JI,WI,KI,HI,zI,YI,VI,GI,XI,QI,ZI,Ov=k(()=>{"use strict";Ha();zd();Ya();Hs();Ev();Av=new Tr,$I=Av.displayName,{info:LI,poll:MI,logInlineStatus:DI,listSessions:BI,searchSessions:jI,attach:FI,listChildren:UI,openChild:qI,closeChild:JI,composerSend:WI,composerStop:KI,composerNew:HI,composerFiles:zI,composerUiRespond:YI,composerRpc:VI,composerPaste:GI,composerPasteRead:XI,summarizeTurn:QI,shutdownComposer:ZI}=Or(Av)});import*as YS from"fs/promises";import*as At from"path";vi();ee();function ku(n){if(!Je.includes(n))throw new Error(`Unknown block kind '${n}' (one of: ${Je.join(", ")})`);return n}function Vg(n){let e=[];for(let t of n){let r=t.indexOf("=");if(r<=0||r===t.length-1)throw new Error(`Expected <kind>=<source>, got '${t}' (e.g. data=results.json, or data=- for stdin)`);let s=ku(t.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:t.slice(r+1)})}if(e.filter(t=>t.source==="-").length>1)throw new Error("Only one <kind>=- can read stdin");return e}$o();Ru();zd();var tl={claude:{adapter:()=>new Gn,server:()=>Promise.resolve().then(()=>(hv(),pv))},codex:{adapter:()=>new Qn,server:()=>Promise.resolve().then(()=>(yv(),gv))},pi:{adapter:()=>new Tr,server:()=>Promise.resolve().then(()=>(Ov(),Tv))}};function Pv(n){return n in tl}function Cr(){return Object.keys(tl)}function nl(){return Object.fromEntries(Object.entries(tl).map(([n,e])=>[n,e.adapter]))}function Cv(n){return tl[n].server()}var ai=nl();function _v(){for(let n of Object.values(ai))try{n().ensureHarnessSupport()}catch{}}function kt(){for(let n of Object.keys(ai))try{if(ai[n]().detectsSelf())return n}catch{}}function Rv(n){let e=Cr(),t=new Map(e.filter(i=>ai[i]).map(i=>[i,ai[i]()]));for(let[i,o]of t)if(o.detectsSelf())return{name:i};let r=[...t].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=>t.get(i).listSessionFiles(n).length>0;return{ambiguous:[...r].sort((i,o)=>Number(s(o))-Number(s(i)))}}var Jf=5e3;function qf(n){try{return n()}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(1)}}function Iv(n){let t={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=n[0];if(s==="agent"||s?.startsWith("agent:")){t.subcommand="agent";let o=s.indexOf(":");if(o!==-1){let a=s.slice(o+1);a&&(t.agentTarget=a)}n=n.slice(1)}else s&&r.includes(s)&&(t.subcommand=s,n=n.slice(1));let i=[];for(let o=0;o<n.length;o++){let a=n[o];if(a==="--help"||a==="-h")t.help=!0;else if(a==="--version"||a==="-V")t.version=!0;else if(a==="--no-watch")t.watch=!1;else if(a==="--open")t.open="window";else if(a==="--no-open")t.open="none";else if(a==="--server")t.server=!0;else if(a==="--trust")t.trust=!0;else if(a==="--no-trust")t.noTrust=!0;else if(a==="--force")t.force=!0;else if(a==="--mode"){let l=n[++o];(!l||l.startsWith("-"))&&(console.error("Missing value for --mode (e.g. --mode staging)"),process.exit(1)),t.mode=l}else if(a==="--follow"||a==="-f")t.follow=!0;else if(a==="--clear")t.clear=!0;else if(a==="--run"){let l=n[++o];if(l==="latest")t.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)),t.run=c}}else if(a==="--bulbs")t.stopScope="bulbs";else if(a==="--agent")t.stopScope="agent";else if(a==="--global")t.stopScope="global";else if(a==="--match"){let l=n[++o];l===void 0&&(console.error("Missing value for --match (a literal substring new log lines must contain)"),process.exit(1)),t.match=l}else if(a==="--timeout"){let l=parseInt(n[++o],10);(isNaN(l)||l<=0)&&(console.error(`Invalid --timeout value: ${n[o]} (seconds)`),process.exit(1)),t.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)),t.sendWaitMs=l}else t.sendWaitMs=Jf;else if(a==="--lines"||a==="-n"){let l=parseInt(n[++o],10);(isNaN(l)||l<0)&&(console.error(`Invalid --lines value: ${n[o]}`),process.exit(1)),t.lines=l}else if(a==="--port"||a==="-p"){let l=n[++o],c=parseInt(l,10);isNaN(c)&&(console.error(`Invalid port: ${l}`),process.exit(1)),t.port=c}else if(a==="--replace"||a.startsWith("--replace=")){let l=a.startsWith("--replace=")?a.slice(10):n[++o]??"",c=qf(()=>hp(l));t.local&&(console.error(`--replace can only be used once (got '${t.local.name}' and '${c.name}')`),process.exit(1)),t.local=c}else if(a==="--args"||a.startsWith("--args=")){t.hasArgsFlag=!0;let l=a.startsWith("--args=")?a.slice(7):n[++o];l===void 0&&(console.error("Missing value for --args (a JSON array, or - to read it from stdin)"),process.exit(1)),t.argsJson=l}else if(!a.startsWith("-")||a==="-"&&t.subcommand==="send")["call","send","get","put","slug","status"].includes(t.subcommand)?i.push(a):t.file=a;else{let l=t.subcommand==="call"?" (for a negative or dash-leading argument, use --args '<json-array>')":"";console.error(`Unknown option: ${a}${l}`),process.exit(1)}}return t.subcommand==="call"&&(i.length<2&&(console.error("Usage: typebulb call <file> <fn> [arg\u2026]"),process.exit(1)),t.file=i[0],t.fn=i[1],t.callArgs=i.slice(2)),t.subcommand==="send"&&(i.length<1&&(console.error("Usage: typebulb send <file> [message]"),process.exit(1)),t.file=i[0],t.sendMessage=i[1]),t.subcommand==="slug"&&(i.length||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1)),t.slugName=i.join(" ")),t.subcommand==="status"&&i.length&&(t.statusQuery=i.join(" ")),t.subcommand==="get"&&(i.length!==2&&(console.error("Usage: typebulb get <file> <kind>"),process.exit(1)),t.file=i[0],t.blockKind=qf(()=>ku(i[1]))),t.subcommand==="put"&&(i.length<2&&(console.error("Usage: typebulb put <file> <kind>=<source> [<kind>=<source> \u2026]"),process.exit(1)),t.file=i[0],t.blockPairs=qf(()=>Vg(i.slice(1)))),t}function Nv(){console.log(`
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(`
2115
2119
  typebulb - Local bulb runner for Typebulb
2116
2120
 
2117
2121
  Usage:
@@ -2289,7 +2293,7 @@ Examples:
2289
2293
  typebulb my-editor.bulb.md
2290
2294
  typebulb --no-watch my-editor.bulb.md
2291
2295
  typebulb .
2292
- `)}St();Es();vi();Os();St();import*as Fe from"path";import{spawn as ON,execSync as PN}from"child_process";import{createRequire as CN}from"module";import{existsSync as _N}from"fs";import*as be from"fs/promises";import*as me from"path";var Wf=[{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"}],Kf=[{name:"dom"},{name:"dom.iterable"},{name:"dom.asynciterable"}];function Hf(n,e){if(!e)return n.filter(s=>!s.since);let t={"5.0":0,"5.5":1},r=t[e];return n.filter(s=>!s.since||t[s.since]<=r)}ee();var eN=`
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=`
2293
2297
  /**
2294
2298
  * Get raw data chunk from the Data tab.
2295
2299
  * @param index - Chunk index (0-based). Separate chunks with 2 blank lines.
@@ -2300,7 +2304,7 @@ Examples:
2300
2304
  * @param index - Chunk index (0-based)
2301
2305
  * @throws If chunk is not valid JSON/JSON-ish
2302
2306
  */
2303
- json<T = unknown>(index: number): T;`,tN=`
2307
+ json<T = unknown>(index: number): T;`,fN=`
2304
2308
  /**
2305
2309
  * Get the insight data produced by the inference layer.
2306
2310
  *
@@ -2309,7 +2313,7 @@ Examples:
2309
2313
  *
2310
2314
  * @returns The parsed insight JSON, or undefined if no insight is available
2311
2315
  */
2312
- insight<T = unknown>(): T | undefined;`,nN=`
2316
+ insight<T = unknown>(): T | undefined;`,pN=`
2313
2317
  /**
2314
2318
  * Replace the data this run is working on.
2315
2319
  *
@@ -2332,7 +2336,7 @@ Examples:
2332
2336
  *
2333
2337
  * @param value - Any JSON-serializable value
2334
2338
  */
2335
- setInsight(value: unknown): Promise<void>;`,$v=`options: {
2339
+ setInsight(value: unknown): Promise<void>;`,qv=`options: {
2336
2340
  messages: Array<{ role: "user" | "assistant"; content: string }>;
2337
2341
  system?: string;
2338
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. */
@@ -2343,7 +2347,7 @@ Examples:
2343
2347
  webSearch?: boolean;
2344
2348
  /** Abort the request. On abort the promise rejects / the stream ends. */
2345
2349
  signal?: AbortSignal;
2346
- }`,Lv=`
2350
+ }`,Jv=`
2347
2351
  /** Provider-reported token counts for one call \u2014 real usage from the API, never an estimate.
2348
2352
  * \`output\` is total billed output (reasoning included); \`reasoning\` is the itemized subset where
2349
2353
  * the provider splits it (OpenAI, Gemini, OpenRouter \u2014 Anthropic doesn't); \`cacheRead\` is the
@@ -2355,10 +2359,10 @@ type AiChunk =
2355
2359
  | { kind: "text"; text: string }
2356
2360
  | { kind: "reasoning"; text: string }
2357
2361
  | { kind: "usage"; usage: AiUsage };
2358
- `,Mv=`
2362
+ `,Wv=`
2359
2363
  /** What backs \`tb.ai\`: the user's own keys, the quota-limited courtesy model, or nothing. */
2360
2364
  type AiAccess = "own" | "courtesy" | "none";
2361
- `,Dv=`
2365
+ `,Kv=`
2362
2366
  /**
2363
2367
  * General-purpose AI call. \`tb.ai(opts)\` resolves with the full text; \`tb.ai.stream(opts)\`
2364
2368
  * returns an async iterable of {@link AiChunk} deltas you consume with \`for await\`.
@@ -2368,7 +2372,7 @@ type AiAccess = "own" | "courtesy" | "none";
2368
2372
  * @throws On rate limit, network error, or provider error
2369
2373
  */
2370
2374
  ai: {
2371
- (${$v}): Promise<{ text: string; usage?: AiUsage }>;
2375
+ (${qv}): Promise<{ text: string; usage?: AiUsage }>;
2372
2376
  /**
2373
2377
  * Streaming counterpart of \`tb.ai()\`. Yields \`{ kind: "text" | "reasoning", text }\` deltas
2374
2378
  * as they arrive, then one final \`{ kind: "usage", usage }\` chunk with the call's token
@@ -2385,8 +2389,8 @@ type AiAccess = "own" | "courtesy" | "none";
2385
2389
  * if (c.kind === "text") answer += c.text;
2386
2390
  * }
2387
2391
  */
2388
- stream(${$v}): AsyncIterable<AiChunk>;
2389
- };`,Bv=`
2392
+ stream(${qv}): AsyncIterable<AiChunk>;
2393
+ };`,Hv=`
2390
2394
  /**
2391
2395
  * Returns AI models available to the current user.
2392
2396
  * Models are filtered by the user's configured API keys.
@@ -2416,7 +2420,7 @@ type AiAccess = "own" | "courtesy" | "none";
2416
2420
  * \`tb.mode\` or the length of \`tb.models()\` \u2014 which hosts offer a courtesy
2417
2421
  * model is the host's business and changes without your bulb changing.
2418
2422
  */
2419
- aiAccess(): Promise<AiAccess>;`,rN="\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;",jv=`
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=`
2420
2424
  /**
2421
2425
  * The mode this bulb is running in.
2422
2426
  *
@@ -2426,7 +2430,7 @@ type AiAccess = "own" | "courtesy" | "none";
2426
2430
  * - \`'inline'\` \u2014 Running inline in an agent's transcript, rendered by the mirror
2427
2431
  * (sandboxed, client-only: AI, filesystem, and server RPC are unavailable)
2428
2432
  */
2429
- mode: ${qg};`,Fv=`
2433
+ mode: ${Hg};`,Yv=`
2430
2434
  /**
2431
2435
  * Local filesystem access (CLI only).
2432
2436
  *
@@ -2447,7 +2451,7 @@ type AiAccess = "own" | "courtesy" | "none";
2447
2451
  list(path?: string): Promise<Array<{ name: string; dir: boolean; mtime: number }>>;
2448
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. */
2449
2453
  remove(path: string): Promise<boolean>;
2450
- };`,Uv=`
2454
+ };`,Vv=`
2451
2455
  /**
2452
2456
  * The bulb's folder \u2014 absolute path to \`<bulb-dir>/<filename-stem>/\`
2453
2457
  *
@@ -2455,7 +2459,7 @@ type AiAccess = "own" | "courtesy" | "none";
2455
2459
  * \`tb.fs\` already resolves relative paths against it, so bulb code writing
2456
2460
  * its own files never needs it. CLI only \u2014 throws in ide/published/inline mode.
2457
2461
  */
2458
- readonly dir: string;`,sN=`
2462
+ readonly dir: string;`,mN=`
2459
2463
  /**
2460
2464
  * Async value inspector for tensor-like objects.
2461
2465
  *
@@ -2508,48 +2512,48 @@ type AiAccess = "own" | "courtesy" | "none";
2508
2512
  *
2509
2513
  * @returns The full canonical URL
2510
2514
  */
2511
- url(): Promise<string>;`,iN="\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;",oN="\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;",aN="\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>>;",zf=`${Lv}${Mv}
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}
2512
2516
  /**
2513
2517
  * Typebulb utilities namespace.
2514
2518
  * Type \`tb.\` to discover available helpers.
2515
2519
  */
2516
- declare const tb: {${eN}${sN}${tN}${nN}${oN}${aN}${iN}${Dv}${Fv}${Uv}${Bv}${rN}${jv}
2520
+ declare const tb: {${dN}${mN}${fN}${pN}${yN}${bN}${gN}${Kv}${Yv}${Vv}${Hv}${hN}${zv}
2517
2521
  };
2518
- `,lN=`
2522
+ `,wN=`
2519
2523
  /**
2520
2524
  * Print to the CLI's stdout \u2014 the same channel as \`console.log\` here (the server's console IS
2521
2525
  * the bulb's log). One log verb across blocks: page-side \`tb.log\` reaches this same stdout.
2522
2526
  */
2523
- log(...args: any[]): void;`,Yf=`${Lv}${Mv}
2527
+ log(...args: any[]): void;`,Qf=`${Jv}${Wv}
2524
2528
  /**
2525
2529
  * Typebulb utilities namespace (server-side).
2526
2530
  * Type \`tb.\` to discover available helpers.
2527
2531
  */
2528
- declare const tb: {${lN}${Dv}${Fv}${Uv}${Bv}${jv}
2532
+ declare const tb: {${wN}${Kv}${Yv}${Vv}${Hv}${zv}
2529
2533
  };
2530
- `;yt();import fN from"p-limit";yt();import{resolve as Jv}from"resolve.exports";var xt={maxRelativeTypeRefs:500,maxBareDeps:8,maxBareDepth:3,prefetchConcurrency:4,negativeTtlMs:1e4},li=["index.d.ts","index.d.mts"],Vf=/\.d\.(ts|mts|cts)$/i;function rl(n){return/\.d\.(ts|mts|cts)(?:[?#].*)?$/i.test(n)||/[?&]dts(?:[&#]|$)/i.test(n)}function qv(n){return[`${n}.d.ts`,`${n}.d.mts`]}function Qt(n){if(!n||n==="./"||n==="/")return[...li];let e=n.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),t=qv(e),r=e.endsWith("/")?e:`${e}/`;return t.push(...qv(`${r}index`)),t}async function _r(n,{retries:e=2,timeoutMs:t=15e3,init:r}={}){for(let s=0;s<=e;s++){let i=new AbortController,o=setTimeout(()=>i.abort(),t);try{let a=await fetch(n,{...r,signal:i.signal});if(cN(a.status)&&s<e)continue;return a}catch{if(s<e)continue;return}finally{clearTimeout(o)}}}function cN(n){return n===408||n===429||n>=500&&n<600}var sl=class{constructor(e,t){this.fetchDts=e,this.cdnClient=t}async tryUrls(e){for(let t of e){let r=await this.fetchDts(t);if(r&&(this.looksLikeDts(r.dts)||rl(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,t){let r=this.cdnClient.packageJson(new B({name:e,version:t})),s=await _r(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:t??i.version})),version:t}}extractPathFromResult(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.find(t=>typeof t=="string")}async tryUntilSuccess(e,t){for(let r of e){let s=await t(r);if(s)return s}}async resolveFromSelected(e,t,r){if(e.kind==="types"){let o=kn(e.path);if(!o||o==="/"||o===".")return this.tryUntilSuccess([...li],t);if(!Vf.test(o)){let a=await this.tryUntilSuccess(Qt(o),t);if(a)return a}return t(o)}let s=Qt(e.path),i=r?.subpath?[...s,...li]:[...li,...s];return this.tryUntilSuccess(i,t)}toResolutionResult(e){return{kind:Vf.test(e)?"types":"probe",path:e}}resolveExportsPath(e,t){let r=t||".",s=e;try{let i=this.extractPathFromResult(Jv(s,r,{conditions:["types"]}));if(i)return i}catch{}try{return this.extractPathFromResult(Jv(s,r,{browser:!0,conditions:["import","default","module","browser","node"]}))}catch{return}}async resolve(e){try{let t=B.parse(e),{pkg:r,baseDir:s}=await this.loadPackageAtVersionedRoot(t.name,t.version)||{};if(!r||!s)return;let i={name:t.name,version:t.version},o=new B(i).format(),a=new B({...i,subpath:t.subpath}).format(),l=d=>this.fetchCandidateFrom(s,t.name,d);if(t.subpath){let d=kd(t.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,t,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:t}:void 0}};yt();import{gunzipSync as uN}from"fflate";var il=class{async fetchAndExtract(e,t){let r=this.getTarballUrl(e,t),s=await _r(r,{timeoutMs:3e4});if(!s?.ok)return new Map;let i=new Uint8Array(await s.arrayBuffer());return this.extractDtsFiles(i)}getTarballUrl(e,t){return`https://registry.npmjs.org/${e.replace("/","%2F")}/-/${e.split("/").pop()}-${t}.tgz`}normalizeTarPath(e){let t=e.replace(/^package\//,""),r=t.indexOf("/");return r>0?t.substring(r+1):t}extractDtsFiles(e){let t=new Map;try{let r=uN(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);t.set(this.normalizeTarPath(c),s.decode(m))}i+=Math.ceil(u/512)*512}}catch{}return t}};var ol=class{constructor(e,t,r=new il){this.cdnClient=e,this.cache=t,this.tarballFetcher=r}typesNameCandidates(e){let t=e.startsWith("@")?e.slice(1).replace("/","__"):e;return t.includes(".")?[t,t.split(".").join("-"),t.split(".").join("")]:[t]}selectTypesVersion(e,t,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=t?.latest;return s&&e.includes(s)?s:e[0]}catch{return e[0]}}subpathCandidates(e){let t=e.replace(/\.(mjs|cjs|js|mts|cts|ts)$/i,""),r=Qt(e);return t!==e&&r.push(`${e}.d.ts`,`${e}/index.d.ts`),r}async fetchFromVersionedRoot(e,t){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=t.subpath?this.subpathCandidates(t.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:t.subpath?new B(t).format():t.name}}}async resolve(e){let t=B.parse(e);if(t.name)for(let r of this.typesNameCandidates(t.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,t.version),a=await this.fetchFromVersionedRoot(`${s}@${o}`,t);if(a)return a}}};var al=class{collectRelativeTypeRefs(e){return this.collectRefs(e).filter(t=>t.startsWith("./")||t.startsWith("../"))}collectBareModuleRefs(e){return this.collectRefs(e).filter(t=>this.isBare(t))}collectRefs(e){let t=e.split(`
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(`
2531
2535
  `).filter(s=>{let i=s.trimStart();return!(i.startsWith("*")||i.startsWith("//")||i.startsWith("/*"))}).join(`
2532
- `),r=new Set;for(let s of t.matchAll(/(import|export)\s+[^'"\n]*from\s*['"]([^'"\n]+)['"]/g))r.add(s[2]);for(let s of t.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 Wv="file:///node_modules",ll=class{constructor(){this.epoch=0}bumpEpoch(){this.epoch+=1}epochDir(){return`__tsepoch_${this.epoch}`}pathForMain(e){return`${Wv}/${this.epochDir()}/${e}/index.d.ts`}pathFor(e,t){let r=kn(t);return`${Wv}/${this.epochDir()}/${e}/${r}`}};import{LRUCache as dN}from"lru-cache";function Kv(n){let e=new dN({ttl:xt.negativeTtlMs,max:500}),t=new Map;return async function(s){try{if(await n.isNegative(s)||e.has(s))return;let i=await n.getCachedFile(s);if(i)return{dts:i,url:s};let o=t.get(s);if(o)return o;let a=(async()=>{let l=await _r(s,{init:{cache:"no-store"}});if(!l?.ok){l?.status===404&&(e.set(s,!0),await n.recordNegative(s));return}let c=await l.text(),f=l.url||s;return await n.clearNegative(s),await n.setCachedFile(f,c),{dts:c,url:f}})();return t.set(s,a),await a.finally(()=>t.delete(s))}catch{return}}}var ci=class{constructor(e){this.inFlight=new Map,this.scanner=new al,this.cache=e.cache,this.cdnClient=e.cdnClient,this.versionResolver=e.versionResolver,this.packageService=e.packageService,this.fetchDts=Kv(e.cache),this.typescriptProvider=new sl(this.fetchDts,e.cdnClient),this.definitelyTypedProvider=new ol(e.cdnClient,e.cache),this.virtualFs=new ll}withInFlight(e,t){let r=this.inFlight.get(e);if(r)return r;let s=t().finally(()=>this.inFlight.delete(e));return this.inFlight.set(e,s),s}invalidate(){this.virtualFs.bumpEpoch(),this.inFlight.clear()}pushFileIfNew(e,t,r){e.some(s=>s.path===t)||e.push({path:t,content:r})}createStubDef(e){let t=this.virtualFs.pathForMain(e);return{pkg:e,mainPath:t,files:[{path:t,content:"export const _shim: any; export default _shim;"}],shims:[{module:e,path:t}]}}async fetchViaProviders(e){for(let t of[this.typescriptProvider,this.definitelyTypedProvider])try{let r=await t.resolve(e);if(r?.dts)return r}catch{}}async fetchRootDts(e,t){let{effectivePackage:r,root:s,pinned:i}=await this.versionResolver.effectivePackage(e,t),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 t=e.pathname.match(/^(.+@[^/]+\/)/);return t?new URL(t[1],e.origin):new URL("./",e)}toVirtualPath(e,t,r){let s=t.pathname.startsWith(e.pathname)?t.pathname.slice(e.pathname.length):`__deps__/${encodeURIComponent(t.toString()).replace(/%/g,"_")}.d.ts`;return this.virtualFs.pathFor(r,s)}computeEntryPath(e,t){if(!e)return{mainPath:this.virtualFs.pathForMain(t),packageRootUrl:void 0};let r=new URL(e),s=this.extractPackageRootUrl(r);return{mainPath:this.toVirtualPath(s,r,t),packageRootUrl:s}}async expandRelativeRefs(e,t,r,s,i=new Set,o){if(!i.has(t)&&(i.add(t),!(i.size>xt.maxRelativeTypeRefs)))try{let a=new URL(t),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,t,r,s,i,o){try{let a=new URL(e,t),l=a.pathname+a.search,c=rl(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,t){return e===t?!1:new B(e).name!==new B(t).name}ambientlyDeclares(e,t){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===t||s.endsWith("/*")&&t.startsWith(s.slice(0,-1)))return!0}return!1}markFileAmbient(e,t){let r=e.find(s=>s.path===t);r&&(r.ambient=!0)}async prefetchBareDeps(e,t,r,s,i){try{let o=this.scanner.collectBareModuleRefs(e).slice(0,xt.maxBareDeps).filter(c=>this.isDifferentPackage(c,t));if(!o.length)return;let a=new Set([t]),l=fN(xt.prefetchConcurrency);await Promise.all(o.map(c=>l(()=>this.prefetchBareDepsRecursive(c,r,s,xt.maxBareDepth,a,i).catch(()=>{}))))}catch{}}async prefetchBareDepsRecursive(e,t,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(t,c,a.dts),this.ambientlyDeclares(a.dts,e)?this.markFileAmbient(t,c):r.push({module:e,path:c}),a.url&&await this.expandRelativeRefs(a.dts,a.url,l,t);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,t,r,s-1,i,o)}async resolve(e,t,r){let s=await this.packageService.extractImports(e),i=r?[...s,...r]:s;return(await Promise.all(i.map(a=>this.resolveOne(a,t)))).filter(a=>!!a)}async resolveOne(e,t){let{effectivePackage:r}=await this.versionResolver.effectivePackage(e,t);return this.withInFlight(r,async()=>{let s=new B(e),i=await this.fetchRootDts(e,t)??(s.subpath?await this.fetchRootDts(s.name,t):void 0);return i?this.buildDefFromContent(e,i,i.resolvedPkg||e,t):this.createStubDef(e)})}async buildDefFromContent(e,t,r,s){let{dts:i,url:o,resolvedPkg:a}=t,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(`
2533
- `);await this.prefetchBareDeps(m,c,u,p,s);let h=l.format(),y=e===h?[e]:[e,h],v=y.some(O=>this.ambientlyDeclares(i,O));return v?this.markFileAmbient(u,f):p.push(...y.map(O=>({module:O,path:f}))),{pkg:e,mainPath:f,files:u,shims:p,ambient:v}}};Id();yt();br();Us();_d();yr();import*as Rr from"path";var pN=Rr.join(ha,"pkg"),hN=Rr.join(ha,"files"),mN=Rr.join(ha,"negative.json"),ul=class{pkgMem=new Map;fileMem=new Map;negativeCache=new En(new wr(mN));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await te();let t=await bt(Hv(e));return this.pkgMem.set(e,t),t}async setCachedDts(e,t,r){let s={content:t,url:r};this.pkgMem.set(e,s),await cl(async()=>{await te(),await Me(Hv(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await te();let t=await pa(zv(e));return this.fileMem.set(e,t),t}async setCachedFile(e,t){this.fileMem.set(e,t),await cl(async()=>{await te(),await Me(zv(e),t)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await cl(async()=>{await te(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return cl(()=>this.negativeCache.clearNegative(e))}};async function cl(n){try{await n()}catch{}}function Hv(n){return Rr.join(pN,Xe(n)+".json")}function zv(n){return Rr.join(hN,Xe(n)+".txt")}br();var Gf;function gN(){return Gf||(Gf=new ci({cache:new ul,cdnClient:Lb,packageService:ba,versionResolver:$b})),Gf}var Yv="file:///node_modules/";async function Vv(n){let e=ma(n.emitKey,"typecheck");await te(),await be.rm(e,{recursive:!0,force:!0}),await be.mkdir(e,{recursive:!0});let t=vN(n.jsxImportSource,n.dependencies),r=await gN().resolve(n.code,n.dependencies,t),s=n.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=dl(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=dl(d.path);u&&(a[d.module]=[`./node_modules/${u}`])}for(let f of i){if(f.ambient)continue;let d=dl(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=dl(d.path);u&&l.add(`node_modules/${u}`)}if(n.local){delete a[n.local.name];let f=await SN(n.local,e);f?a[n.local.name]=[`./node_modules/${n.local.name}/${f}`]:console.warn(` local: '${n.local.name}' ships no type defs; check cannot type against it.`)}let c=yN(n.jsxImportSource,a,[...l]);return await be.writeFile(me.join(e,"tsconfig.json"),JSON.stringify(c,null,2)+`
2534
- `,"utf8"),await be.writeFile(me.join(e,"code.tsx"),n.code,"utf8"),await be.writeFile(me.join(e,"tb.d.ts"),zf,"utf8"),{dir:e}}var Xf={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function yN(n,e,t=[]){return{compilerOptions:{...Xf,lib:bN([...Wf,...Kf]),jsx:"react-jsx",jsxImportSource:n??"react",paths:e},include:["code.tsx","tb.d.ts",...t]}}function bN(n){return Hf(n).map(e=>wN(e.name))}function wN(n){return n.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 vN(n,e){let t=n??("react"in e?"react":void 0);return t?[`${t}/jsx-runtime`,`${t}/jsx-dev-runtime`]:[]}function dl(n){if(!n.startsWith(Yv))return;let e=n.slice(Yv.length),t=e.indexOf("/");if(!(t<0))return e.slice(t+1)}async function SN(n,e){if(!n.typesAbs)return;let t=me.dirname(n.typesAbs),r=me.join(e,"node_modules",n.name);for(let s of await kN(t)){let i=me.join(r,me.relative(t,s));await be.mkdir(me.dirname(i),{recursive:!0}),await be.copyFile(s,i)}return me.basename(n.typesAbs)}async function kN(n){let e=[];async function t(r){let s=await be.readdir(r,{withFileTypes:!0});for(let i of s){let o=me.join(r,i.name);i.isDirectory()?await t(o):/\.d\.ts(\.map)?$/.test(i.name)&&e.push(o)}}return await t(n),e}import*as je from"fs/promises";import*as Et from"path";import{existsSync as xN}from"fs";br();$d();var EN="^22";async function Gv(n){let e=ma(n.emitKey,"typecheck-server");await te(),await je.rm(e,{recursive:!0,force:!0}),await je.mkdir(e,{recursive:!0});let t=Et.join(n.bulbDir,".typebulb"),r=Aa(n.server).filter(o=>o!==n.local?.name);await Ea([`@types/node@${EN}`,...r],t,n.dependencies,{ignoreScripts:!0});let s=Et.join(t,"node_modules"),i=Et.join(e,"node_modules");return await TN(s,i),await je.writeFile(Et.join(e,"server.ts"),n.server,"utf8"),await je.writeFile(Et.join(e,"tb.d.ts"),Yf,"utf8"),await je.writeFile(Et.join(e,"tsconfig.json"),JSON.stringify(AN(n.local),null,2)+`
2535
- `,"utf8"),{dir:e}}function AN(n){let e={...Xf,lib:["ES2023"],types:["node"]};if(n?.typesAbs){let t=i=>i.replace(/\\/g,"/"),r=t(Et.dirname(n.typesAbs)),s=t(n.typesAbs).replace(/\.d\.ts$/,"");e.paths={[n.name]:[s],[`${n.name}/*`]:[`${r}/*`]}}return{compilerOptions:e,include:["server.ts","tb.d.ts"]}}async function TN(n,e){if(!xN(n)){await je.mkdir(e,{recursive:!0});return}await je.rm(e,{recursive:!0,force:!0});let t=process.platform==="win32"?"junction":"dir";await je.symlink(n,e,t)}Zo();ee();async function Qv(n,e){let{bulb:t,config:r,warnings:s,starts:i}=await Ze(n),o=Fe.basename(n),a=h=>i.get(h)??1;!t.code&&!t.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(Fe.resolve(n)),d=f?Yn(t.name):"";f&&d&&d!==f.slug&&(console.log(`naming filename '${f.slug}.bulb.md' doesn't match the title '${t.name}' \u2014 its slug derives to '${d}'. Rename the file to '${d}.bulb.md', or change name: to suit the filename.`),c=!0),t.code&&(l=Xv(As(t.code,{target:"client",dependencies:r.dependencies??{},lineOffset:a("code.tsx")}),"client")||l),t.server&&(l=Xv(As(t.server,{target:"server",lineOffset:a("server.ts")}),"server")||l);let u=$N([process.cwd(),Fe.dirname(n)]);if(!u){let h=Fe.relative(process.cwd(),n)||n;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(t.code){let{dir:h}=await Vv({code:t.code,dependencies:r.dependencies??{},jsxImportSource:r.ts?.jsxImportSource,emitKey:n,local:e});p.push({role:"client",dir:h})}if(t.server){let{dir:h}=await Gv({server:t.server,bulbDir:Fe.dirname(n),emitKey:n,local:e?{name:e.name,typesAbs:e.typesAbs}:void 0,dependencies:r.dependencies});p.push({role:"server",dir:h})}for(let{role:h,dir:y}of p){let{stdout:v,exitCode:O}=await IN(u,y);for(let P of v.split(/\r?\n/))P.trim()&&console.log(`${h} ${RN(P,o,a)}`);O!==0&&(l=!0)}l&&process.exit(1);let m=[t.code&&"code.tsx",t.server&&"server.ts"].filter(Boolean).join(", ");console.error(c?`\u2713 type-checks (${m}) \u2014 see the naming warning above`:`\u2713 no issues (${m})`)}function Xv(n,e){for(let t of n)for(let r of t.message.split(`
2536
- `))console.log(`${e} ${r}`);return n.length>0}function RN(n,e,t){return n.replace(/\b(code\.tsx|server\.ts)\((\d+),(\d+)\)/g,(r,s,i,o)=>`${e}(${Number(i)+t(s)-1},${o})`)}function IN(n,e){return new Promise(t=>{let r=ON(process.execPath,[n,"--noEmit"],{cwd:e}),s="";r.stdout?.on("data",i=>{s+=i.toString()}),r.stderr?.on("data",i=>{s+=i.toString()}),r.on("close",i=>t({stdout:s,exitCode:i??1}))})}var NN=CN(import.meta.url);function $N(n){let e=r=>{try{let s=NN.resolve("typescript/package.json",{paths:r}),i=Fe.join(Fe.dirname(s),"lib","tsc.js");return _N(i)?i:void 0}catch{return}},t=e(n);if(t)return t;try{let r=PN("npm root -g",{encoding:"utf8"}).trim();return e([r])}catch{return}}St();Qo();Os();async function Zv(n,e){let{bulb:t}=await Ze(n),r=or(t);if(yn(n)){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.)")}Os();import*as ui from"path";async function eS(n,e){if(!n){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let r=td();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 t=ui.resolve(n);t.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));try{ar(t,e)}catch(r){console.error(r.message),process.exit(1)}console.log(e?`Trusted ${ui.basename(t)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${ui.basename(t)} \u2014 runs Restricted.`),console.log(` ${t}`)}$e();import*as rS from"readline";wd();function Qf(n){let e=t=>r=>n?`\x1B[${t}m${r}\x1B[0m`:r;return{lit:e("38;5;70"),litLink:e("4;38;5;70"),brand:e("38;5;135")}}var LN=5e3,fl=()=>Math.round(performance.now()),tS=n=>n>=1e3?`${(n/1e3).toFixed(1)}s`:`${n}ms`;async function sS(n){let e=Rv(process.cwd()),t=fl();if("ambiguous"in e){let r=await MN(n,e.ambiguous);return r?nS(n,r,{boot:t,from:fl()}):DN(n,e.ambiguous)}return nS(n,e.name,{boot:t,from:fl()})}async function nS(n,e,t){let r,s;try{r=await Hu(e)}catch(p){s=p instanceof Error?p.message:String(p)}let i=fl()-t.from,{lit:o,litLink:a,brand:l}=Qf(process.stdout.isTTY===!0),c=[" Read the authoring skill before writing a bulb:",` \u2022 ${o(Rs())}`],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=t.boot+i>LN?[` slow launch: boot ${tS(t.boot)} \xB7 mirror ${tS(i)}`]:[],u=[` ${l(`typebulb v${n}`)}`,...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 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(`
2537
2541
  `)+`
2538
- `)}async function MN(n,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:t,brand:r}=Qf(!0),s=[` ${r(`typebulb v${n}`)}`," More than one agent harness is available here.",...e.map((o,a)=>` ${t(String(a+1))}) ${o}`),""];process.stdout.write(s.join(`
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(`
2539
2543
  `)+`
2540
- `);let i=rS.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 DN(n,e){let{lit:t,brand:r}=Qf(process.stdout.isTTY===!0),s=[` ${r(`typebulb v${n}`)}`," More than one agent harness is available here."," Open the mirror for the one you want:",...e.map(i=>` \u2022 ${t(`npx typebulb agent:${i}`)}`),""];process.stdout.write(s.join(`
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(`
2541
2545
  `)+`
2542
- `)}ot();bn();async function iS(n){ke(n);let e=await mt();if(e.length>0){console.log(eb(e,process.env.TB_AI_PROVIDER,process.env.TB_AI_MODEL));return}if(!rd()){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[t,r]of Object.entries(lr))console.log(` ${r.padEnd(20)} (${t})`);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 oS(n){n?.trim()||(console.error("Usage: typebulb slug <bulb name>"),process.exit(1));let e=Yn(n);e||(console.error(`'${n}' has no slug \u2014 a bulb name needs at least one letter or digit.`),process.exit(1)),console.log(e)}Ye();import*as cS from"path";import{valid as lS,lt as jN}from"semver";$e();var tt={connected:"[page] connected",disconnected:"[page] disconnected",closed:n=>`[page] closed: ${n}`},Zf=3e3,aS=1e4,BN=2500,pl=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,t){this.attached.add(e);for(let s of[...this.arrivalWaiters])s(!0);let r={page:e,firstAttach:t,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 t=this.dropAt=Date.now();setTimeout(()=>{this.attached.size===0&&this.dropAt===t&&this.settledEmpty?.()},Zf).unref()}async closeAll(e){let t=[...this.attached];if(!t.length)return{told:0,gone:0};await Promise.all(t.map(s=>s.close(e).catch(()=>{}))),await this.whenGone(t,BN);let r=t.filter(s=>!this.leaving.has(s)).length;for(let s of t)this.leaving.delete(s);return{told:t.length,gone:r}}whenArrives(e){return this.attached.size>0?Promise.resolve(!0):e>0?new Promise(t=>{let r=i=>{clearTimeout(s),this.arrivalWaiters.delete(r),t(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,t){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()},t);i.unref(),this.goneWaiters.add(s)}):Promise.resolve()}drainIfGone(){for(let e of[...this.goneWaiters])e()}};Wo();function FN(n,e,t,r){if(/^\d+$/.test(e))return n.find(i=>i.pid===parseInt(e,10));let s=e==="agent"?n.filter(ye):n.filter(i=>i.agent===e);if(s.length){if(!t)return s[0];let i=s.filter(o=>rr(o,t));return r&&i.find(o=>o.agent===r)||i[0]}return n.find(i=>re(i.file)===re(e))}var Ir=n=>n.agent??cS.basename(n.file);function uS(n){return n===Le?!1:n&&lS(n)&&lS(Le)?jN(n,Le):!0}function UN(n){return n===Le?"":n?uS(n)?` STALE runtime v${n} (this CLI is v${Le} \u2014 relaunch to update)`:` runtime v${n} (newer than this CLI's v${Le})`:" STALE runtime (predates the version stamp \u2014 relaunch to update)"}function qN(n,e){return e===void 0?" pages ?":e>0?` ${e} page${e===1?"":"s"}`:ye(n)?" NO PAGE (no tab open on it)":" NO PAGE (nothing of it is running)"}function dS(n,e,t){n.forEach((r,s)=>e(` ${r.url} pid ${r.pid} ${r.trust?"trusted":"restricted"}${t?qN(r,t[s]):""}${UN(r.version)} ${r.file}`))}async function ep(n,e){if(!n.length){console.log("No running bulb servers.");return}let t=await Promise.all(n.map(Ku));console.log("Running bulb servers:"),dS(n,r=>console.log(r),t),console.log(`
2543
- `+e)}function tp(n,e,t,r,s){let i=FN(n,e,r,s);if(i)return i;console.error(`No running server for '${e}'.`),n.length?(console.error(`Running servers (try \`typebulb ${t} <file|pid>\`):`),dS(n,o=>console.error(o))):console.error("No bulb servers are running."),process.exit(1)}async function fS(n,e){if(!n){e.clear&&(console.error("Specify which server to clear: typebulb logs --clear <file|pid>"),process.exit(1)),await ep(await Z(process.cwd()),"Run `typebulb logs <file|pid>` to print one server's console.");return}let t=tp(await Z(),n,"logs",process.cwd(),kt());if(e.clear){Bu(t.pid),console.log(`Cleared log for ${Ir(t)} (pid ${t.pid}).`);return}let r=Ve(t.pid),s=r.text;if(e.run!==void 0?(s=Fu(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 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(`
2544
2548
  `);i.length&&i[i.length-1]===""&&i.pop(),s=i.slice(-e.lines).join(`
2545
2549
  `)}if(process.stdout.write(s),s&&!s.endsWith(`
2546
2550
  `)&&process.stdout.write(`
2547
- `),e.follow&&e.run===void 0){let i=r.offset,o=setInterval(()=>{let l=Ve(t.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 JN=n=>new Promise(e=>setTimeout(e,n));async function pS(n,e){if(!n){ep(await Z(process.cwd()),"Run `typebulb wait <file|pid>` to block until one logs a new line.");return}let t=tp(await Z(),n,"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(t.pid).offset,c=s?void 0:Ho(t.pid,a)??(a?Ho(t.pid):void 0),f=s?l:c!==void 0&&c<=l?c:a?0:l,d=Date.now()+o*1e3,u=ye(t)?1e4:1e3,p=2e3,m=!ye(t)&&!s,h,y="",v=0;for(;;){let O=f>=l,P=Ve(t.pid,f);if(f=P.offset,P.text){y+=P.text;let E=y.split(`
2548
- `);y=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(t)&&(I.includes("] compile error")||I.includes("] runtime error"))&&(h=Math.min(h,Date.now()+p)))));if(R&&!h){console.error(`the last page of ${Ir(t)} closed while waiting \u2014 a bulb runs in its page, so nothing can log ${e.match?`'${e.match}'`:"anything"} now`),v=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 ${Ir(t)} within ${o}s`),v=2;break}if(!er(t.pid)){h||(console.error(`server ${Ir(t)} (pid ${t.pid}) exited while waiting`),process.exit(3));break}await JN(400)}s||Ss(t.pid,f,a),process.exit(v)}function hS(n,e){if(e==="killed")return` \u2014 forced (${uS(n.version)?`its runtime ${n.version?`v${n.version} `:""}predates the stop route`:"it did not answer"}); a page it opened may still be open`;let t=[];return e.closed&&t.push(`closed ${e.closed} page${e.closed===1?"":"s"}`),e.stuck&&t.push(`${e.stuck} did not close`),t.length?` \u2014 ${t.join(", ")}`:""}async function mS(n){if(!n){await ep(await Z(process.cwd()),"Run `typebulb stop <file|pid>` to stop one.");return}let e=tp(await Z(),n,"stop",process.cwd(),kt()),t=await Ft(e);console.log(`Stopped ${Ir(e)} (pid ${e.pid}, ${e.url}).${hS(e,t)}`)}async function gS(n){let e=process.cwd(),t=n==="agent"?kt():void 0,r=n==="global"?await Z():n==="bulbs"?await Z(e):(await Z()).filter(o=>rr(o,e)&&(!t||o.agent===t)),s=n==="global"?"server":n==="agent"?"mirror":"bulb";if(!r.length){console.log(n==="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} ${Ir(o)}${hS(o,i[a])}`))}$e();Ye();fn();import*as hl from"path";import*as yS from"http";import{mkdir as WN,writeFile as KN}from"fs/promises";async function Nr(){let n=[];for await(let e of process.stdin)n.push(e);return Buffer.concat(n).toString("utf-8")}function di(n){return(n.charCodeAt(0)===65279?n.slice(1):n).replace(/\r\n/g,`
2549
- `).trimEnd()}function HN(n,e){return new Promise((t,r)=>{let s=new URL(n),i=yS.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",()=>t({status:o.statusCode??0,text:a}))});i.setTimeout(0),i.on("error",r),i.end(e)})}var zN=n=>{let e=Math.round((Date.now()-n)/6e4);return e<1?"moments ago":e<60?`${e}m ago`:`${Math.round(e/60)}h ago`};async function bS(n,e,t=0){e==="-"&&(e=di(await Nr()));let r=e!==void 0&&e.startsWith("tb:");r&&t<=0&&(t=Jf);let s=e!==void 0&&/^tb:(click|set)( |$)/.test(e),i=hl.resolve(n),o=hn(await Z(),i)[0];if(!o){let m=(await dn(process.cwd()))(i);console.error(m?`No running server for '${n}' \u2014 it last ran ${zN(m)}. Relaunching reuses the same URL (a stale tab is one reload from live): npx typebulb ${n}`:`No running server for '${n}'. Start it first: npx typebulb ${n}`),process.exit(1)}let a=async m=>{let h=[m>0?`reply=${m}`:"",s?"solo=1":"","open=1"].filter(Boolean).join("&"),y=await HN(`${o.url}/__send${h?`?${h}`:""}`,e??"");(y.status<200||y.status>=300)&&(console.error(`send failed: HTTP ${y.status} from ${o.url}/__send`),process.exit(1));try{return JSON.parse(y.text)}catch{return{}}},l={},c=Date.now();try{l=await a(t)}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 ${n}\` 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":"",y=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 ${n} --match "${tt.connected}"`;console.error(`No page connected after ${((Date.now()-c)/1e3).toFixed(1)}s, so nothing was delivered${y}`),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 y=by(i);await WN(hl.dirname(y),{recursive:!0}),await KN(y,Buffer.from(h.png,"base64"));let v=[h.via?`inside "${h.via}"`:"",h.backdrop?`backdrop ${h.backdrop}`:""].filter(Boolean);console.error(`canvas ${h.width}\xD7${h.height} \u2192 PNG${v.length?` (${v.join("; ")})`:""}`),console.log(y);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 ${t/1e3}s \u2014 reload the page and retry.`),process.exit(1)),console.error(`(no reply within ${t/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)`))}Na();Jd();ee();import*as wS from"fs/promises";async function vS(n,e){let t=await wS.readFile(n,"utf-8"),r=Mn(t),s=le[e].path,i=r.files.get(s);i||(console.error(i===void 0?`No **${s}** block in ${n}`:`The **${s}** block in ${n} 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 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(`
2550
2554
  `)?i:i+`
2551
- `)}ee();import*as fi from"fs/promises";async function xS(n,e){let t=await fi.readFile(n,"utf-8"),r=[];for(let{kind:i,source:o}of e){let a;try{a=o==="-"?await Nr():await fi.readFile(o,"utf-8")}catch(l){kS(`Cannot read ${i}'s source: ${l instanceof Error?l.message:String(l)}`)}r.push({kind:i,content:di(a),label:o==="-"?"stdin":o})}let s;try{s=YN(t,r)}catch(i){kS(`${n}: ${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 fi.writeFile(n,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 YN(n,e){let t=Mn(n),r=n,s=[],i=[];for(let{kind:o,content:a,label:l}of e){let c=le[o].path,f=t.files.get(c);if(!a){if(f===void 0){i.push(o);continue}r=SS(Pp(r,o),r,c),s.push({kind:o,action:"removed",chars:0,label:l});continue}if(f!==void 0&&di(f)===a){i.push(o);continue}r=SS(Lr(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 SS(n,e,t){if(n===e)throw new Error(`the **${t}** block's fence is unterminated; refusing to rewrite inside it`);return n}function kS(n){console.error(n),process.exit(1)}ot();ff();Vs();cf();async function ES(n,e){ke(e);let t=process.cwd(),r=nl(),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:Uw(a,t)})).filter(a=>a.sessions.length);if(!o.length){console.log("No sub-agents in this project's sessions.");return}if(!n){let{sessions:a}=o[0];VN(a[0]);return}for(let{adapter:a,sessions:l}of o){let c=qw(l,n);if(!c.length)continue;if(c.length>1){console.error(`Several agents match "${n}"; name one by its id:`);for(let u of c)console.error(` ${AS(u)}`);process.exitCode=1;return}let{text:f,error:d}=await Jw(a,t,c[0]);console.log(f),d&&console.error(`
2552
- (partly unjudged: ${d})`);return}console.error(`No agent matches "${n}". Run \`typebulb status\` to list them.`),process.exitCode=1}function VN(n){let e=[...n.children].sort((t,r)=>t.mtime-r.mtime);console.log(`Sub-agents of session ${n.sessionId}:`);for(let t of e)console.log(` ${" ".repeat(Math.max(0,t.depth-1))}${AS(t)}`);console.log("\nRun `typebulb status <id>` for one agent's report.")}var AS=n=>{let e=n.started?lt((n.state==="running"?Date.now():n.mtime)-n.started):"";return`${n.id} ${n.state.padEnd(7)} ${e.padStart(6)} ${Cn(n)}`};ot();St();ee();Qo();import*as en from"fs/promises";import*as $n from"path";import{EventEmitter as y1}from"events";Ut();ee();import{Hono as t1}from"hono";import{serve as n1}from"@hono/node-server";import{streamSSE as r1}from"hono/streaming";import*as sp from"fs/promises";import s1 from"open";br();Us();yr();import*as np from"fs/promises";import*as pi from"path";var ml=class{async get(e){let t=Xe(e),r=pi.join(Fs,t+".bin"),s=pi.join(Fs,t+".json");try{let[i,o]=await Promise.all([np.readFile(r),np.readFile(s,"utf8")]),a=JSON.parse(o);return{body:i,contentType:a.contentType,cacheControl:a.cacheControl}}catch{return}}async set(e,t){await te();let r=Xe(e),s=pi.join(Fs,r+".bin"),i=pi.join(Fs,r+".json"),o={url:e,contentType:t.contentType,cacheControl:t.cacheControl};await Promise.all([Me(s,t.body),Me(i,JSON.stringify(o))])}};var TS=`
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=`
2553
2557
  const CSS = '\\n' +
2554
2558
  /* The agent mirror's token set, verbatim (agents/core/client/styles.css) \u2014 one system across CLI
2555
2559
  chrome: app chrome sits on --panel, content wells paint --veil, grays ride one neutral tint.
@@ -2932,22 +2936,22 @@ export function runInference(ctx) {
2932
2936
  showConfirm();
2933
2937
  document.body.appendChild(host);
2934
2938
  }
2935
- `;vr();$e();bn();ca();Ut();import{stream as GN}from"hono/streaming";var XN="X-TB-Stream";function hi(n){return n instanceof Pe?{message:n.message,code:n.code,retryable:n.retryable}:{message:n instanceof Error?n.message:"Unknown error",code:"unknown",retryable:!1}}function gl(n,e){return n.header("Content-Type","application/x-ndjson; charset=utf-8"),n.header("Cache-Control","no-cache"),n.header(XN,"1"),GN(n,async t=>{let r=e[Symbol.asyncIterator]();t.onAbort(()=>{r.return?.()});try{for(;;){let{done:s,value:i}=await r.next();if(s)break;await t.writeln(JSON.stringify({type:"chunk",value:i}))}}catch(s){await t.writeln(JSON.stringify({type:"error",error:hi(s)}))}finally{try{await r.return?.()}catch{}}})}var yl={log:(...n)=>console.log(...n)};function bl(n,e){let t=n?.[e]??(Object.hasOwn(yl,e)?yl[e]:void 0);return typeof t=="function"?t:void 0}function wl(n){return n.constructor?.name==="AsyncGeneratorFunction"}Ld();var QN=/^\/(v\d+\/|stable\/|node\/|gh\/|@[^/]+\/[^@/]+@|[^@/]+@)/,ZN=/[?&]target=/,e1=/^\/(?:@[^/]+\/)?[^/@]+\/[^/]+/;function OS(n,e=""){return QN.test(n)?!0:e1.test(n)&&ZN.test(e)}var i1="127.0.0.1",o1=new Set(["localhost","127.0.0.1","::1"]),IS=(n,e)=>!!n&&typeof n=="object"&&e in n,PS=n=>{let e={};return Array.isArray(n.data)&&(e.data=n.data),IS(n,"insight")&&(e.insight=n.insight),e},CS=8*1024*1024,a1=0;function l1(n){if(n)try{return new URL(n.includes("://")?n:`http://${n}`).hostname}catch{return}}function NS(n){let e=l1(n);return!!e&&o1.has(e)}function c1(n){try{let e=new URL(n);return(e.protocol==="http:"||e.protocol==="https:")&&NS(e.host)}catch{return!1}}function u1(n){return!!n&&/\bCode\/\d/.test(n)&&/\bElectron\//.test(n)}function d1(n,e){if(!e)return!1;try{return new URL(n).host===e}catch{return!1}}function mi(n){return n instanceof Error?n.message:"Unknown error"}var _S=n=>n.how==="editor"||n.how==="unreached"?n.via:void 0,f1=2e3;async function $S(n){let{getHtml:e,basePath:t,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:y,onStop:v}=n,O=`${process.pid}-${++a1}-${Date.now()}`,P=r??t,E=new t1;E.use("*",async(b,x)=>{if(!NS(b.req.header("host")))return b.text("Forbidden: untrusted Host",403);await x()}),E.use("*",async(b,x)=>{await x(),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,x)=>{if(!d){let C=new URL(b.req.url).pathname,N=R.find(([K])=>K.endsWith("/*")?C.startsWith(K.slice(0,-2)):C===K)?.[1]??"server-side code (server.ts)";qu(process.pid,N);let M=u?`
2936
- ${u}`:"";return b.text(`Forbidden: this capability requires --trust.${M}`,403)}await x()},L=async(b,x)=>{let C=b.req.header("sec-fetch-site");if(C){if(C!=="same-origin")return b.text(`Forbidden: ${C} request`,403)}else{let N=b.req.header("origin");if(N&&!d1(N,b.req.header("host")))return b.text("Forbidden: cross-origin request",403)}await x()};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:x}=await b.req.json();console.log(...x||[])}catch{}return b.json({ok:!0})});let A=new pl,q=new Set,X=new Set,G=Date.now();A.onArrival(({page:b,firstAttach:x,count:C})=>{o&&C===1&&console.log(tt.connected),x&&C>1&&b.close("yielded").catch(()=>{})}),o&&A.onSettledEmpty(()=>console.log(tt.disconnected));let U,ge=0,he=async b=>{let x=Math.max(b.fresh?0:G,A.lastDropAt);if(await A.whenArrives(Zf-(Date.now()-x)))return{how:"attached"};if(Date.now()-ge<f1)return{how:"none"};let C=`http://localhost:${s}#tb-relay`,N=await Wu(C,t),M;return N?.where==="editor"?M={how:"editor",via:N.via}:(b.external==="force"||b.external==="follow"&&N?.where==="external")&&(await s1(C),M={how:"external"}),M?await A.whenArrives(aS)?M:{how:"unreached",via:_S(M)}:(ge=Date.now(),{how:"none"})},Re=b=>A.count>0?Promise.resolve({how:"attached"}):U??=he(b).finally(()=>{U=void 0});if(o){let b=0,x=new Map;E.use("/__send",L),E.post("/__send",async C=>{let N="";try{N=await C.req.text()}catch{}let M=Number(C.req.query("reply"))||0,K=A.count===0&&C.req.query("open")!==void 0?await Re({external:"follow",fresh:!1}):void 0,J=A.count,Ue=J===0&&A.lastDropAt?Date.now()-A.lastDropAt:void 0,z={clients:J,droppedMsAgo:Ue,...K?{opening:K.how,via:_S(K)}:{}};if(C.req.query("solo")!==void 0&&J!==1)return C.json({...z,refused:J>1});if(J===0)return C.json(z);let oe=tn=>{for(let Ot of A)Ot.send(tn).catch(()=>{})};if(M<=0)return oe({payload:N}),C.json(z);let Ae=++b,$r=await new Promise(tn=>{let Ot={expected:J,received:0,results:[],errors:[],finish:kl=>{clearTimeout(Sl),x.delete(Ae),tn({results:Ot.results,errors:Ot.errors,timedOut:kl})}},Sl=setTimeout(()=>Ot.finish(!0),M);x.set(Ae,Ot),oe({id:Ae,payload:N})});return C.json({...z,...$r})}),E.use("/__send-reply",L),E.post("/__send-reply",async C=>{try{let{id:N,results:M,errors:K}=await C.req.json(),J=x.get(N);J&&(J.results.push(...M??[]),J.errors.push(...K??[]),++J.received>=J.expected&&J.finish(!1))}catch{}return C.json({ok:!0})})}E.get("/",b=>b.html(e())),E.post("/__fs/read",async b=>{try{let{path:x}=await b.req.json(),C=await qs(x,P);return new Response(new Uint8Array(C),{headers:{"Content-Type":"application/octet-stream"}})}catch(x){let C=mi(x);return b.json({error:C},400)}}),E.post("/__fs/write",async b=>{try{let x=b.req.query("path");return x?(await Ta(x,new Uint8Array(await b.req.arrayBuffer()),P),b.json({success:!0})):b.json({error:"Missing path"},400)}catch(x){let C=mi(x);return b.json({error:C},400)}}),E.post("/__fs/list",async b=>{try{let{path:x}=await b.req.json();return b.json(await Oa(x??".",P))}catch(x){return b.json({error:mi(x)},400)}}),E.post("/__fs/remove",async b=>{try{let{path:x}=await b.req.json();return await Pa(x,P),b.json({success:!0})}catch(x){return b.json({error:mi(x)},400)}}),E.post("/__api/:name",async b=>{try{let x=b.req.param("name"),C=bl(a?.(),x);if(!C)return b.json({error:`API function '${x}' not found`},404);let{args:N}=await b.req.json();if(wl(C))return gl(b,C(...N||[]));let M=await C(...N||[]);return b.json({result:M})}catch(x){let C=mi(x);return b.json({error:C},500)}}),E.post("/__ai",async b=>{try{let{messages:x,system:C,effort:N,provider:M,model:K,webSearch:J,stream:Ue}=await b.req.json();if(!x||!Array.isArray(x)||x.length===0)return b.json({message:"messages array is required",code:"unknown",retryable:!1},400);let z=gt(M,K);if(typeof z=="string")return b.json({message:z,code:"unknown",retryable:!1},400);let oe=await Jt(z,{messages:x,system:C,effort:N,webSearch:J,signal:b.req.raw.signal});if(!oe.ok){let tn=await fr(oe,z.protocol);return b.json(tn,oe.status)}if(Ue)return gl(b,Sn(oe,z.protocol));let{text:Ae,usage:$r}=await pr(oe,z.protocol);return Ae||console.warn("[tb.ai] Empty response from provider"),b.json({text:Ae,usage:$r})}catch(x){return b.json(hi(x),500)}}),E.post("/__infer",async b=>{try{let{data:x}=await b.req.json().catch(()=>({})),C=l?.();if(!C?.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(x)?x.map(String):[],K=md(C,M),J=await Jt(N,{messages:[{role:"user",content:K}],signal:b.req.raw.signal});if(!J.ok){let z=await fr(J,N.protocol);return b.json(z,J.status)}let Ue=(async function*(){let z="";for await(let Ae of Sn(J,N.protocol))Ae.kind!=="text"||!Ae.text||(z+=Ae.text,yield{kind:"delta",text:Ae.text});let oe=gd(z);if(oe.parsed===void 0)throw console.warn(`[tb.infer] output not valid JSON after sanitize; raw output (last 4000 chars):
2937
- `+z.slice(-4e3)),new Pe("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 gl(b,Ue)}catch(x){return b.json(hi(x),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 x=PS(await b.req.json().catch(()=>({})));return Object.keys(x).length?(await c(x.data,IS(x,"insight")?JSON.stringify(x.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(x){return b.json(hi(x),500)}}),E.get("/__infer-info",b=>{let x=l?.(),C=Mr(x?.config??"").inference,N=xo(x?.data??""),M=!!x?.infer.trim(),K=gt();return typeof K=="string"?b.json({error:K,inference:C,data:N,hasInfer:M}):b.json({provider:K.protocol,model:K.model,inference:C,data:N,hasInfer:M})}),E.use("/__tb-decode",L),E.post("/__tb-decode",async b=>{let{hash:x}=await b.req.json().catch(()=>({})),C=typeof x=="string"?bd(x):void 0;return b.json(C??{error:"invalid fragment"})}),E.use("/__tb-encode",L),E.post("/__tb-encode",async b=>{let x=Number(b.req.header("content-length"));if(Number.isFinite(x)&&x>CS)return b.json({hash:""});let C=await b.req.text().catch(()=>"");if(C.length>CS)return b.json({hash:""});let N;try{N=JSON.parse(C)}catch{return b.json({hash:""})}return b.json({hash:yd(PS(N))})}),E.get("/__infer-ui.js",b=>b.body(TS,200,{"Content-Type":"text/javascript; charset=utf-8"})),E.get("/__models",async b=>{try{let x=await mt();return b.json(x)}catch{return b.json([],200)}}),E.get("/__ai-access",async b=>{try{return b.json(await ta())}catch{return b.json("none",200)}}),h&&E.get("/__source/*",async b=>{let x=await sp.readFile(h,"utf-8").catch(()=>{});return x===void 0?b.text("Not Found",404):new Response(x,{headers:{"Content-Type":"text/plain; charset=utf-8"}})});let ut=["esm.sh","unpkg.com","cdn.jsdelivr.net","cdnjs.cloudflare.com"],ue=new ml;E.get("/proxy/*",async b=>{let x=new URL(b.req.url),N=(x.pathname+x.search).slice(7),M=N.lastIndexOf("https://");return M===-1?b.text("Invalid proxy URL",400):Ee(b,N.slice(M))}),f&&RS(E,`/local/${f.name}/`,f.serveDir),p&&RS(E,p.mount,p.dir),m&&E.get("/assets/*",async b=>{let{pathname:x}=new URL(b.req.url),C=x.slice(8),N;try{N=decodeURIComponent(C)}catch{return b.text("Not Found",404)}let M=Ip(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 J=await LS(N,m.dir,{"Cache-Control":"no-cache"});if(J)return J}catch{return b.text("Not Found",404)}let K=m.remoteBase;return K?b.redirect(K+C,302):b.text("Not Found",404)});async function Ee(b,x){let C;try{C=new URL(x)}catch{return b.text("Invalid URL",400)}if(C.protocol!=="https:")return b.text("HTTPS only",400);if(!ut.includes(C.hostname))return b.text("Host not allowed",403);let N=await ue.get(x);if(N)return new Response(N.body,{status:200,headers:rp(N.contentType,N.cacheControl)});try{let M=await fetch(x,{headers:{Accept:b.req.header("Accept")||"*/*"},redirect:"follow"});if(!M.ok)return b.text(`Upstream ${M.status}`,M.status);let K=M.headers.get("Content-Type")||void 0,J=M.headers.get("Cache-Control")||void 0;if(M.body){let[Ue,z]=M.body.tee();return(async()=>{try{let oe=await new Response(z).arrayBuffer();await ue.set(x,{body:Buffer.from(oe),contentType:K,cacheControl:J})}catch{}})(),new Response(Ue,{status:M.status,headers:rp(K,J)})}return new Response(null,{status:M.status,headers:rp(K,J)})}catch(M){return b.text(`Proxy fetch failed: ${M instanceof Error?M.message:M}`,502)}}(i||o)&&(E.get("/__reload",b=>r1(b,async x=>{let C=b.req.query("bulb")||void 0;if(y&&C&&C!==y){q.has(C)||(q.add(C),console.log(tt.closed("foreign"))),await x.writeSSE({event:"close",data:"foreign"});return}let N=()=>{x.writeSSE({event:"reload",data:""})};i?.on("reload",N);let M=()=>i?.removeListener("reload",N),K=b.req.query("relay")||void 0,J={inEditor:u1(b.req.header("user-agent")),doc:K,open:z=>x.writeSSE({event:"open-url",data:z}),send:z=>x.writeSSE({event:"message",data:JSON.stringify(z)}),close:z=>(M(),A.closing(J),console.log(tt.closed(z)),x.writeSSE({event:"close",data:z}))},Ue=!!K&&!X.has(K);for(K&&X.add(K),A.add(J,Ue),x.onAbort(()=>{M(),A.dropped(J)}),await x.writeSSE({event:"hello",data:O,retry:Nd});!x.aborted;)await x.sleep(3e4)})),E.use("/__open",L),E.post("/__open",async b=>{let x="";try{x=String((await b.req.json()).url??"")}catch{}if(!c1(x))return b.json({error:"a local http URL is required"},400);let C=[...A].find(N=>N.inEditor);return await C?.open(x),b.json({opened:!!C,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 x="close";try{let N=await b.req.json();(N?.pages==="keep"||N?.pages==="close")&&(x=N.pages)}catch{}let C=x==="close"?await A.closeAll("stopped"):{told:0,gone:0};return v&&setTimeout(()=>{v({pages:x})},50),b.json({closed:C.gone,stuck:C.told-C.gone,exiting:!!v})}),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 x=new URL(b.req.url);return OS(x.pathname,x.search)?Ee(b,"https://esm.sh"+x.pathname+x.search):b.text("Not Found",404)});let Tt=n1({fetch:E.fetch,port:s,hostname:i1});return Tt.listening||await new Promise((b,x)=>{let C=N=>x(N);Tt.once("error",C),Tt.once("listening",()=>{Tt.removeListener("error",C),b()})}),{port:s,close:()=>Tt.close(),requestPage:Re,closePages:b=>A.closeAll(b),pageCount:()=>A.count}}function rp(n,e){let t=new Headers;return n&&t.set("Content-Type",n),e&&t.set("Cache-Control",e),t.set("Access-Control-Allow-Origin","*"),t.set("Cross-Origin-Resource-Policy","cross-origin"),t}function RS(n,e,t){n.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 LS(decodeURIComponent(s.slice(e.length)),t)??r.text("Not Found",404)}catch{return r.text("Not Found",404)}})}async function LS(n,e,t={}){let r=Sr(n,e),s=await sp.readFile(r).catch(()=>{});if(s)return new Response(s,{headers:{"Content-Type":Rp(r),...t}})}$e();fn();async function vl(n){let{port:e,portNote:t,makeServerOptions:r,makeEntry:s,displayName:i,waitTarget:o,stopLog:a}=n,l=`http://localhost:${e}`,c=s(e,l),f=[],d,u=!1,p=async h=>{if(!u){u=!0,console.log(`
2938
- Shutting down...`),(h?.pages??(ye(c)?"keep":"close"))==="close"&&await d?.closePages("stopped"),d?.close();for(let y of f)try{await y()}catch{}a(),await pn(process.pid),process.exit(0)}},m=await $S({...r(e),onStop:p}).catch(async h=>{if(h?.code!=="EADDRINUSE")throw h;return Nu(e)});return d=m,await Uu(c),console.log(`
2939
- ${i}`),console.log(` ${l}`),t&&console.log(` ${t}`),process.on("SIGINT",()=>{p()}),process.on("SIGTERM",()=>{p()}),{port:e,url:l,pageCount:()=>m.pageCount(),async handOver({mode:h,fresh:y,replacedLive:v}){if(h==="none")return;let O={fresh:y,external:v?"never":h==="window"?"force":"follow"},P=await m.requestPage(O);P.how==="attached"?console.log(` Reusing the open browser tab.
2940
- `):P.how==="editor"?console.log(` Opened in VS Code via ${P.via}.
2941
- `):P.how==="external"?console.log(` Opened in your browser.
2942
- `):console.log(` ${P.how==="unreached"?`Opened ${P.via?`in VS Code via ${P.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."}
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.
2944
+ `):C.how==="editor"?console.log(` Opened in VS Code via ${C.via}.
2945
+ `):C.how==="external"?console.log(` Opened in your browser.
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."}
2943
2947
  Share ${l}, and wake on the arrival:
2944
2948
  typebulb wait ${o} --match "${tt.connected}"
2945
- `)},onCleanup(h){f.push(h)}}}fn();import p1 from"chokidar";import MS from"node:fs";import h1 from"node:path";var m1={persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:50}};function Zt(n){let{target:e,onChange:t,events:r="change",debounceMs:s=150}=n,i,o=p1.watch(e,m1);o.on("error",l=>console.warn(`watch: ${l instanceof Error?l.message:l} \u2014 continuing`));let a=()=>{i&&clearTimeout(i),i=setTimeout(t,s)};return r==="all"?o.on("all",a):o.on("change",a),()=>{i&&clearTimeout(i),o.close()}}var g1=n=>process.platform==="win32"||process.platform==="darwin"?n.toLowerCase()==="assets":n==="assets";function DS(n,e,t=150){let r,s=()=>{r&&clearTimeout(r),r=setTimeout(e,t)};try{let i=MS.watch(n,{recursive:!0},(o,a)=>{a&&g1(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=h1.join(n,"assets");return MS.existsSync(i)?Zt({target:i,onChange:e,events:"all",debounceMs:t}):()=>{}}}$e();Ye();vr();async function BS(n,e,t,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=ks(process.pid),o=e.watch?new y1:void 0,a=ke(e.mode),l=(await dn(process.cwd()))(n),c=await Zn({kind:"bulb",file:n},process.cwd()),f=await Yo(n,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<Db,{port:u,note:p}=await Jo({target:{kind:"bulb",file:n},cwd:process.cwd()});c!==void 0&&u!==c&&d&&(console.error(`
2946
- 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(ju(++m));h(),console.log(`Loading ${$n.basename(n)}...`);let{html:y,bulb:v,serverExports:O}=await Dd(n,e.watch,e.trust,r);qt(a,n,v.server);let P=An(n),E=xr($n.resolve(n)),R=e.trust?void 0:or(v),{port:I,onCleanup:L,handOver:A,pageCount:q}=await vl({port:u,portNote:p,displayName:v.name,stopLog:i,makeServerOptions:he=>({getHtml:()=>y,basePath:s,fsBase:kr(n),port:he,reloadEmitter:o,sendChannel:!0,getServerExports:()=>O,getBulbBlocks:()=>({infer:v.infer,insight:v.insight,code:v.code,config:v.config,data:v.data}),saveInferenceResult:async(Re,ut)=>{let ue=await en.readFile(n,"utf-8");Re!==void 0&&(ue=Lr(ue,"data",Re.join(Rg))),ut!==void 0&&(ue=Lr(ue,"insight",ut)),await en.writeFile(n,ue)},localOverride:r?{name:r.name,serveDir:r.serveDir}:void 0,bulbAssets:{dir:P,remoteBase:E&&Ei(E.userSlug,E.slug)},sourceFile:n,bulbKey:vs(n),trusted:e.trust,trustHint:t}),makeEntry:(he,Re)=>({pid:process.pid,port:he,url:Re,file:n,cwd:process.cwd(),startedAt:Date.now(),trust:e.trust,mode:e.mode,predicted:R}),waitTarget:$n.relative(process.cwd(),n)||$n.basename(n)});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:
2947
- ${t}
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:
2951
+ ${n}
2948
2952
  `:` trust: restricted \u2014 re-run with --trust to enable filesystem / AI / server.ts
2949
2953
  `),e.watch&&console.log(` Watching for changes...
2950
- `);let X,G,U=()=>{q()===0&&console.log(" No page attached \u2014 nothing reloaded; this change is not live."),o?.emit("reload")},ge=he=>{console.log(he),h(),U()};if(e.watch&&o){let he=0,Re=Promise.resolve();if(X=Zt({target:n,onChange:()=>{let ue=++he;Re=Re.then(async()=>{if(ue===he)try{console.log("Recompiling...");let Ee=await Dd(n,!0,e.trust,r);y=Ee.html,O=Ee.serverExports,v=Ee.bulb,Ee.buildError||h(),U()}catch(Ee){console.error("Recompile failed:",Ee)}})}}),r){let{name:ue,serveDir:Ee}=r;G=Zt({target:Ee,events:"all",onChange:()=>ge(`Local package '${ue}' changed.`)})}let ut=kr(n);await en.stat(ut).then(ue=>ue.isDirectory()).catch(()=>!1)&&L(DS(ut,()=>ge("Assets changed.")))}X&&L(X),G&&L(G),L(()=>en.rm(Md(n),{force:!0})),await A({mode:e.open,fresh:!d,replacedLive:f.some(he=>he.port===I)})}ot();import{readFileSync as op,copyFileSync as w1,existsSync as v1}from"fs";import*as pe from"path";import{fileURLToPath as S1}from"url";import{EventEmitter as k1}from"events";import x1 from"open";fn();$e();vr();var ip=n=>`/agents/${n}/client.js`,b1=`
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=`
2951
2955
  (() => {
2952
2956
  const api = async (name, ...args) => {
2953
2957
  const resp = await fetch('/__api/' + name, {
@@ -2976,18 +2980,18 @@ Port ${c} is this bulb's, and a page of it may be waiting there, but something e
2976
2980
  })
2977
2981
  });
2978
2982
  if (window.__TYPEBULB_WATCH__) {
2979
- ${Sa()}
2983
+ ${Ea()}
2980
2984
  }
2981
2985
  })();
2982
- `;function jS(n){let{name:e,agent:t,styles:r,katex:s,mountHtml:i,watch:o,theme:a}=n,l=ip(t);return`<!DOCTYPE html>
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>
2983
2987
  <html>
2984
2988
  <head>
2985
2989
  <meta charset="utf-8">
2986
2990
  <meta name="viewport" content="width=device-width, initial-scale=1">
2987
- <title>${wa(e)} - typebulb</title>
2988
- ${va(e,a)}
2991
+ <title>${ka(e)} - typebulb</title>
2992
+ ${xa(e,a)}
2989
2993
  <style>
2990
- ${gs}
2994
+ ${ys}
2991
2995
  </style>
2992
2996
  <style>
2993
2997
  ${r}
@@ -3002,18 +3006,18 @@ ${i}
3002
3006
  ${o?"<script>window.__TYPEBULB_WATCH__ = true;</script>":""}
3003
3007
 
3004
3008
  <script>
3005
- ${b1}
3009
+ ${C1}
3006
3010
  </script>
3007
3011
 
3008
3012
  <script type="module" src="${l}"></script>
3009
3013
  </body>
3010
- </html>`}async function FS(n){let e=process.cwd(),t=n.agentTarget;Pv(t)||(console.error(`Unknown agent '${t}'. Known: ${Cr().join(", ")}.`),process.exit(1));let r=await zo(e,t);if(r){console.log(`Mirror '${t}' is already running for this project:
3011
- ${r.url}`),n.open==="window"&&await x1(r.url);return}let s=ks(process.pid),i=n.watch?new k1:void 0,o=ke(n.mode),a=await Cv(t),l=a.displayName||`${t} mirror`;qt(o,pe.join(e,"mirror"));let c=pe.dirname(S1(import.meta.url)),f=pe.join(c,"agents",t),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=()=>jS({name:l,agent:t,styles:op(u,"utf8"),katex:op(p,"utf8"),mountHtml:op(m,"utf8"),watch:n.watch}),{port:y,note:v}=await Jo({explicit:n.port,target:{kind:"mirror",agent:t},cwd:e}),{port:O,url:P,onCleanup:E,handOver:R,pageCount:I}=await vl({port:y,portNote:v,displayName:l,stopLog:s,waitTarget:"agent",makeServerOptions:G=>({getHtml:h,basePath:e,port:G,reloadEmitter:i,getServerExports:()=>a,trusted:!0,staticAssets:{mount:`${pe.posix.dirname(ip(t))}/`,dir:f}}),makeEntry:(G,U)=>({pid:process.pid,port:G,url:U,file:`agent:${t}`,cwd:e,startedAt:Date.now(),trust:!0,agent:t})});n.watch&&console.log(` Watching for changes...
3012
- `);let L=pe.join(d,t,"client"),A=pe.join(d,"core","client");async function q(){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 U of["styles.css","index.html","typebulb.png","typebulb-inv.png"])w1(pe.join(A,U),pe.join(f,U))}let X;if(n.watch&&i){let G=v1(L),U=!1;X=Zt({target:G?d:f,events:"all",onChange:async()=>{if(!U){U=!0;try{G&&await q(),console.log(I()?`Mirror rebuilt. Reloading.
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.
3013
3017
  `:`Mirror rebuilt. No tab open on it \u2014 nobody is reading this.
3014
- `),i.emit("reload")}catch(ge){console.error("Mirror rebuild failed:",ge instanceof Error?ge.message:ge)}finally{U=!1}}}})}await R({mode:n.open,fresh:!1,replacedLive:!1}),E(()=>a.shutdownSwitcher?.()),E(()=>a.shutdownComposer?.()),X&&E(X)}ot();St();import*as US from"path";async function qS(n,e,t,r){let s=ke(t),i=!1,o=async()=>{let{bulb:a,config:l}=await Ze(n);i||(qt(s,n,a.server),i=!0),await Js(a.server,n,r,l.dependencies)};if(console.log(`Running ${US.basename(n)}...`),await o(),e){console.log(`Watching for changes...
3015
- `);let a=0,l=Promise.resolve();Zt({target:n,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 E1}from"node:console";$e();async function KS(n,e,t,r){C1();try{let u=hn(await Z(),n)[0];u&&(Ss(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=ke(t),{bulb:i,config:o}=await Ze(n);i.server||gi("This bulb has no **server.ts** block; nothing to call."),qt(s,n,i.server);let a;try{a=await Js(i.server,n,r,o.dependencies)}catch(u){gi(u instanceof Error?u.message:String(u))}let l=bl(a,e.fn);if(!l){let u=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(yl)];gi(`Function '${e.fn}' not found. Available: ${u.length?u.join(", "):"(none)"}.`)}let c=await A1(e);if(wl(l)){try{for await(let u of l(...c))await WS(JSON.stringify(u,HS)+`
3016
- `)}catch(u){gi(u instanceof Error?u.stack??u.message:String(u))}return JS(0)}let f;try{f=await l(...c)}catch(u){gi(u instanceof Error?u.stack??u.message:String(u))}let d=P1(f);d!==void 0&&await WS(d+`
3017
- `),JS(0)}function JS(n){process.exitCode=n,setTimeout(()=>process.exit(n),2e3).unref?.()}async function A1(n){if(n.hasArgsFlag){let e=n.argsJson??"";return e==="-"&&(e=await Nr()),O1(e)}return T1(n.positional)}function T1(n){return n.map(e=>{try{return JSON.parse(e)}catch{return e}})}function O1(n){let e;try{e=JSON.parse(n)}catch(t){throw new Error(`--args must be a JSON array: ${t instanceof Error?t.message:String(t)}`)}if(!Array.isArray(e))throw new Error(`--args must be a JSON array, got ${e===null?"null":typeof e}`);return e}function P1(n){if(n!==void 0)return JSON.stringify(n,HS,2)}function HS(n,e){return typeof e=="bigint"?e.toString():e}function gi(n){process.stderr.write(n+`
3018
- `),process.exit(1)}function C1(){let n=new E1(process.stderr,process.stderr);console.log=n.log.bind(n),console.info=n.info.bind(n),console.debug=n.debug.bind(n),console.dir=n.dir.bind(n)}function WS(n){return new Promise((e,t)=>{process.stdout.write(n,r=>r?t(r):e())})}Wo();for(let n of[process.stdout,process.stderr])n.on("error",e=>{if(e?.code!=="EPIPE")throw e});function zS(n,e){n||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
3019
- ${e}`),process.exit(1))}async function _1(){let n=Iv(process.argv.slice(2));if(n.version&&(console.log(`typebulb ${Le}`),process.exit(0)),n.help&&(Nv(),process.exit(0)),_v(),n.subcommand==="logs"){await fS(n.file||void 0,{follow:n.follow,clear:n.clear,run:n.run,lines:n.lines});return}if(n.subcommand==="wait"){await pS(n.file||void 0,{match:n.match,timeoutSec:n.timeoutSec});return}if(n.subcommand==="stop"){n.stopScope?await gS(n.stopScope):await mS(n.file||void 0);return}if(n.subcommand==="send"){await bS(n.file,n.sendMessage,n.sendWaitMs??0);return}if(n.subcommand==="models"){await iS(n.mode);return}if(n.subcommand==="slug"){oS(n.slugName);return}if(n.subcommand==="status"){await ES(n.statusQuery,n.mode);return}if(n.subcommand==="pull"){await Yb(n.file||void 0,{force:n.force,mode:n.mode});return}if(n.subcommand==="push"){await Gb(n.file||void 0,{force:n.force,mode:n.mode});return}if(n.subcommand==="agent"){await(n.agentTarget?FS(n):sS(Le));return}if(n.subcommand==="trust"||n.subcommand==="untrust"){await eS(n.file||void 0,n.subcommand==="trust");return}let e;if(!n.file||n.file==="."){let l=await Hb(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=At.resolve(n.file);if(await YS.access(e).then(()=>!0,()=>!1)||(Cr().includes(n.file)&&(console.error(`To open the ${n.file} agent mirror, run: npx typebulb agent:${n.file}`),process.exit(1)),console.error(`File not found: ${e}`+(At.isAbsolute(n.file)?"":` (resolved from cwd ${process.cwd()})`)),process.exit(1)),e.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1)),n.subcommand==="get"){await vS(e,n.blockKind);return}if(n.subcommand==="put"){await xS(e,n.blockPairs);return}let r=n.file&&n.file!=="."?n.file:At.relative(process.cwd(),e)||At.basename(e),s=`npx typebulb --trust ${r.includes(" ")?`"${r}"`:r}`;if(n.subcommand==="predict"){await Zv(e,s);return}let i=!n.noTrust&&yn(e);i&&!n.trust&&console.error("trust: granted from memory (run `typebulb untrust` to revoke)"),n.trust=n.noTrust?!1:n.trust||i;let o;try{o=await Ze(e)}catch{}let a;if(n.local){o&&!(n.local.name in(o.config.dependencies??{}))&&(console.error(`--replace: '${n.local.name}' is not a dependency in this bulb's config.json; nothing to replace.`),process.exit(1)),o&&n.subcommand!=="call"&&(!o.bulb.code||n.server)&&console.warn("warning: --replace has no effect in server mode (the override is client-only).");try{a=await mp(n.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(n.subcommand==="check"){await Qv(e,a);return}if(n.subcommand==="call"){zS(n.trust,s),await KS(e,{fn:n.fn,positional:n.callArgs,argsJson:n.argsJson,hasArgsFlag:n.hasArgsFlag},n.mode,a);return}if(o&&o.bulb.server&&(Vo(o.bulb)||n.server)){zS(n.trust,s),await qS(e,n.watch,n.mode,a);return}await BS(e,n,s,a)}_1().catch(n=>{console.error("Error:",n.message),process.exit(1)});
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)});